diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69acf6a..d04cfcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,11 +28,16 @@ jobs: cmd: install - name: run - run: | - yarn run test - cat ./coverage/lcov.info | ./node_modules/.bin/codecov - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: yarn run test + + - uses: codecov/codecov-action@v3 + name: upload + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: unittests + files: ./coverage/cobertura-coverage.xml + fail_ci_if_error: true + verbose: true lint: runs-on: ubuntu-latest @@ -60,12 +65,12 @@ jobs: - name: build run: | - node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --base-href /ngx-highlight-js/ - cp ./dist/index.html ./dist/404.html - ls ./dist + node ./node_modules/@angular/cli/bin/ng build --base-href /ngx-highlight-js/ + cp ./dist/browser/index.html ./dist/browser/404.html + ls ./dist/browser - name: deploy-to-gh-pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./dist + publish_dir: ./dist/browser diff --git a/.gitignore b/.gitignore index 7a9d8f0..1f94fbe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,18 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. -# compiled output +# Compiled output /dist /tmp /out-tsc -/publish -/yarn.lock -/.angular/cache +/bazel-out -# dependencies +# Node /node_modules +npm-debug.log +yarn-error.log # IDEs and editors -/.idea +.idea/ .project .classpath .c9/ @@ -20,23 +20,26 @@ .settings/ *.sublime-workspace -# IDE - VSCode +# Visual Studio Code .vscode/* !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json +.history/* -# misc -/.sass-cache +# Miscellaneous +/.angular/cache +.sass-cache/ /connect.lock /coverage /libpeerconnection.log -npm-debug.log -yarn-error.log testem.log /typings -# System Files +# System files .DS_Store Thumbs.db + +/publish +/yarn.lock diff --git a/.nvmrc b/.nvmrc index 6b17d22..3e558c9 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -14.16.1 +18.12.0 diff --git a/README.md b/README.md index d08405f..3d8dff0 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Angular for syntax highlighting with highlight.js [![NPM version](https://img.shields.io/npm/v/ngx-highlight-js.svg)](https://www.npmjs.com/package/ngx-highlight-js) [![Ci](https://github.com/cipchk/ngx-highlight-js/workflows/Ci/badge.svg)](https://github.com/cipchk/ngx-highlight-js/actions) +[![codecov](https://codecov.io/github/cipchk/ngx-highlight-js/graph/badge.svg?token=FI8lMVH3bN)](https://codecov.io/github/cipchk/ngx-highlight-js) ## Demo diff --git a/angular.json b/angular.json index 4d88083..abec15b 100644 --- a/angular.json +++ b/angular.json @@ -14,15 +14,15 @@ } }, "root": "", - "sourceRoot": "src", + "sourceRoot": "", "prefix": "app", "architect": { "build": { - "builder": "@angular-devkit/build-angular:browser", + "builder": "@angular-devkit/build-angular:application", "options": { "outputPath": "dist", "index": "src/index.html", - "main": "src/main.ts", + "browser": "src/main.ts", "polyfills": [ "zone.js" ], @@ -49,21 +49,12 @@ "maximumError": "4kb" } ], - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.prod.ts" - } - ], "outputHashing": "all" }, "development": { - "buildOptimizer": false, "optimization": false, - "vendorChunk": true, "extractLicenses": false, - "sourceMap": true, - "namedChunks": true + "sourceMap": true } }, "defaultConfiguration": "production" @@ -72,10 +63,10 @@ "builder": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { - "browserTarget": "ngx-highlight-js:build:production" + "buildTarget": "ngx-highlight-js:build:production" }, "development": { - "browserTarget": "ngx-highlight-js:build:development" + "buildTarget": "ngx-highlight-js:build:development" } }, "defaultConfiguration": "development" @@ -83,19 +74,17 @@ "test": { "builder": "@angular-devkit/build-angular:karma", "options": { - "main": "lib/test.ts", + "karmaConfig": "./karma.conf.js", "polyfills": [ "zone.js", "zone.js/testing" ], "tsConfig": "tsconfig.spec.json", - "karmaConfig": "karma.conf.js", "scripts": [ "src/assets/highlight.min.js" ], "include": [ - "../lib/test.ts", - "../lib/**/*.spec.ts" + "lib/**/*.spec.ts" ] } }, @@ -112,10 +101,5 @@ } } } - }, - "cli": { - "schematicCollections": [ - "@angular-eslint/schematics" - ] } } diff --git a/karma.conf.js b/karma.conf.js index 5ccad91..91ca45a 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,50 +1,51 @@ -// Karma configuration file, see link for more information -// https://karma-runner.github.io/1.0/config/configuration-file.html - -module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular-devkit/build-angular'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage'), - require('@angular-devkit/build-angular/plugins/karma') - ], - client: { - jasmine: { - // you can add configuration options for Jasmine here - // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html - // for example, you can disable the random execution with `random: false` - // or set a specific seed with `seed: 4321` - }, - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - jasmineHtmlReporter: { - suppressAll: true // removes the duplicated traces - }, - coverageReporter: { - dir: require('path').join(__dirname, './coverage'), - subdir: '.', - reporters: [ - { type: 'html' }, - { type: 'text-summary' } - ] - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false, - restartOnFileChange: true, - customLaunchers: { - ChromeHeadlessCI: { - base: 'ChromeHeadless', - flags: ['--no-sandbox'], - }, - } - }); -}; +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + jasmine: { + // you can add configuration options for Jasmine here + // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html + // for example, you can disable the random execution with `random: false` + // or set a specific seed with `seed: 4321` + }, + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + jasmineHtmlReporter: { + suppressAll: true // removes the duplicated traces + }, + coverageReporter: { + dir: require('path').join(__dirname, './coverage'), + subdir: '.', + reporters: [ + { type: 'html' }, + { type: 'text-summary' }, + { type: 'cobertura' }, + ] + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true, + customLaunchers: { + ChromeHeadlessCI: { + base: 'ChromeHeadless', + flags: ['--no-sandbox'], + }, + } + }); +}; diff --git a/lib/index.ts b/lib/index.ts index 4aaf8f9..7e1a213 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1 +1 @@ -export * from './public_api'; +export * from './public-api'; diff --git a/lib/ng-package.json b/lib/ng-package.json index 89a102f..ba22fde 100644 --- a/lib/ng-package.json +++ b/lib/ng-package.json @@ -3,7 +3,7 @@ "dest": "../publish", "deleteDestPath": true, "lib": { - "entryFile": "public_api.ts" + "entryFile": "public-api.ts" }, "allowedNonPeerDependencies": ["tslib", "angular", "highlight.js"] } diff --git a/lib/package.json b/lib/package.json index ddc290a..258d6f4 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,6 +1,6 @@ { "name": "ngx-highlight-js", - "version": "16.1.0", + "version": "17.0.0", "description": "Angular for syntax highlighting with highlight.js", "keywords": [ "highlight", @@ -21,6 +21,6 @@ }, "homepage": "https://cipchk.github.io/ngx-highlight-js/", "dependencies": { - "highlight.js": "^11.0.0" + "highlight.js": "^11.9.0" } } diff --git a/lib/public_api.ts b/lib/public-api.ts similarity index 100% rename from lib/public_api.ts rename to lib/public-api.ts diff --git a/lib/src/highlight-js.directive.ts b/lib/src/highlight-js.directive.ts index dc2165b..4cad612 100644 --- a/lib/src/highlight-js.directive.ts +++ b/lib/src/highlight-js.directive.ts @@ -103,10 +103,8 @@ export class HighlightJsDirective implements AfterViewInit, OnDestroy { ngOnDestroy(): void { this.destroy(); - this.destroyMutation(); - if (this.modelValue$) { - this.modelValue$.unsubscribe(); - } + this.observer?.disconnect(); + this.modelValue$?.unsubscribe(); } private initMutation(): void { @@ -122,8 +120,4 @@ export class HighlightJsDirective implements AfterViewInit, OnDestroy { }); }); } - - private destroyMutation(): void { - this.observer?.disconnect(); - } } diff --git a/lib/test.ts b/lib/test.ts deleted file mode 100644 index 84245b8..0000000 --- a/lib/test.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file is required by karma.conf.js and loads recursively all the .spec and framework files -import { getTestBed } from '@angular/core/testing'; -import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); diff --git a/lib/tsconfig.lib.json b/lib/tsconfig.lib.json index 26391b1..c04115c 100644 --- a/lib/tsconfig.lib.json +++ b/lib/tsconfig.lib.json @@ -4,12 +4,12 @@ "alwaysStrict": true, "inlineSources": true, "strictFunctionTypes": true, - "stripInternal": true + "stripInternal": true, + "declarationMap": false }, "files": ["./src/highlight-js.module.ts"], "include": ["**/*.ts"], "angularCompilerOptions": { - "enableIvy": true, "compilationMode": "partial" } } diff --git a/package.json b/package.json index 28d9815..6bac52e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-highlight-js", - "version": "16.1.0", + "version": "17.0.0", "description": "Angular for syntax highlighting with highlight.js", "keywords": [ "highlight", @@ -21,48 +21,46 @@ }, "homepage": "https://cipchk.github.io/ngx-highlight-js/", "scripts": { - "analyze": "ng b --stats-json --source-map", "lint": "ng lint", - "test": "ng t --no-progress --browsers=ChromeHeadlessCI --code-coverage --no-watch", + "test": "ng t --no-progress --code-coverage --no-watch --browsers=ChromeHeadless", "build": "node scripts/build.js", - "release:next": "npm run build && cd publish && npm publish --access public --tag next", - "release": "npm run build && cd publish && npm publish --access public" + "release": "npm run build && cd publish && npm publish --access public", + "release:next": "npm run build && cd publish && npm publish --access public --tag next" }, "dependencies": { - "@angular/animations": "^16.0.0", - "@angular/common": "^16.0.0", - "@angular/compiler": "^16.0.0", - "@angular/core": "^16.0.0", - "@angular/forms": "^16.0.0", - "@angular/platform-browser": "^16.0.0", - "@angular/platform-browser-dynamic": "^16.0.0", - "@angular/router": "^16.0.0", + "@angular/animations": "^17.0.0", + "@angular/common": "^17.0.0", + "@angular/compiler": "^17.0.0", + "@angular/core": "^17.0.0", + "@angular/forms": "^17.0.0", + "@angular/platform-browser": "^17.0.0", + "@angular/platform-browser-dynamic": "^17.0.0", + "@angular/router": "^17.0.0", "rxjs": "~7.8.0", "tslib": "^2.3.0", - "zone.js": "~0.13.0", + "zone.js": "~0.14.2", "highlight.js": "^11.0.0" }, "devDependencies": { - "@angular-devkit/build-angular": "^16.0.3", - "@angular/cli": "~16.0.3", - "@angular/compiler-cli": "^16.0.0", - "@types/jasmine": "~4.3.0", - "jasmine-core": "~4.6.0", + "@angular-devkit/build-angular": "^17.0.0", + "@angular/cli": "^17.0.0", + "@angular/compiler-cli": "^17.0.0", + "@types/jasmine": "~5.1.0", + "jasmine-core": "~5.1.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.2.0", "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", - "karma-jasmine-html-reporter": "~2.0.0", - "typescript": "~5.0.2", - "@angular-eslint/builder": "^16.0.3", - "@angular-eslint/eslint-plugin": "^16.0.3", - "@angular-eslint/eslint-plugin-template": "^16.0.3", - "@angular-eslint/schematics": "^16.0.3", - "@angular-eslint/template-parser": "^16.0.3", - "@typescript-eslint/eslint-plugin": "^5.59.8", - "@typescript-eslint/parser": "^5.59.8", - "codecov": "^3.8.3", - "eslint": "^8.42.0", - "ng-packagr": "^16.0.1" + "karma-jasmine-html-reporter": "~2.1.0", + "typescript": "~5.2.2", + "@angular-eslint/builder": "^17.0.0", + "@angular-eslint/eslint-plugin": "^17.0.0", + "@angular-eslint/eslint-plugin-template": "^17.0.0", + "@angular-eslint/schematics": "^17.0.0", + "@angular-eslint/template-parser": "^17.0.0", + "@typescript-eslint/eslint-plugin": "^6.10.0", + "@typescript-eslint/parser": "^6.10.0", + "eslint": "^8.53.0", + "ng-packagr": "^17.0.0" } } diff --git a/src/app/components/demo.component.html b/src/app/components/demo.component.html index 4258906..7e7d8c8 100644 --- a/src/app/components/demo.component.html +++ b/src/app/components/demo.component.html @@ -21,11 +21,11 @@
Load the highlight.js and theme css in page.
diff --git a/src/assets/forkme.png b/src/assets/forkme.png deleted file mode 100644 index 146ef8a..0000000 Binary files a/src/assets/forkme.png and /dev/null differ diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts deleted file mode 100644 index 0783a04..0000000 --- a/src/environments/environment.prod.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const environment = { - production: true -}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts deleted file mode 100644 index e6e6852..0000000 --- a/src/environments/environment.ts +++ /dev/null @@ -1,8 +0,0 @@ -// The file contents for the current environment will overwrite these during build. -// The build system defaults to the dev environment which uses `environment.ts`, but if you do -// `ng build --env=prod` then `environment.prod.ts` will be used instead. -// The list of which env maps to which file can be found in `angular-cli.json`. - -export const environment = { - production: false -}; diff --git a/src/index.html b/src/index.html index a21b0b9..ff79f5c 100644 --- a/src/index.html +++ b/src/index.html @@ -17,7 +17,11 @@ -