feat(chore): updated version up to angular 13 and nx 13

This commit is contained in:
SvetlanaMuravlova
2022-04-20 10:10:45 +03:00
parent 19ec08cc02
commit f8025b896c
20 changed files with 7755 additions and 15148 deletions

View File

@@ -8,12 +8,7 @@
], ],
"overrides": [ "overrides": [
{ {
"files": [ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"*.ts",
"*.tsx",
"*.js",
"*.jsx"
],
"rules": { "rules": {
"@nrwl/nx/enforce-module-boundaries": [ "@nrwl/nx/enforce-module-boundaries": [
"error", "error",
@@ -21,39 +16,25 @@
"enforceBuildableLibDependency": true, "enforceBuildableLibDependency": true,
"allow": [], "allow": [],
"depConstraints": [ "depConstraints": [
{ { "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] }
"sourceTag": "*",
"onlyDependOnLibsWithTags": [
"*"
]
}
] ]
} }
] ]
} }
}, },
{ {
"files": [ "files": ["*.ts", "*.tsx"],
"*.ts", "extends": ["plugin:@nrwl/nx/typescript"],
"*.tsx"
],
"extends": [
"plugin:@nrwl/nx/typescript"
],
"parserOptions": { "project": "./tsconfig.*?.json" }, "parserOptions": { "project": "./tsconfig.*?.json" },
"rules": { "rules": {
"semi": "off", "semi": "off",
"@typescript-eslint/semi": ["error"] "@typescript-eslint/semi": ["error"],
"@typescript-eslint/ban-ts-comment": "off"
} }
}, },
{ {
"files": [ "files": ["*.js", "*.jsx"],
"*.js", "extends": ["plugin:@nrwl/nx/javascript"],
"*.jsx"
],
"extends": [
"plugin:@nrwl/nx/javascript"
],
"rules": {} "rules": {}
} }
] ]

View File

@@ -51,6 +51,7 @@ jobs:
dist dist
key: dist-${{ github.run_id }} key: dist-${{ github.run_id }}
- run: npx ng build --prod - run: npx ng build --prod
npx nx run ng2-file-upload:build:production
# update release notes in github # update release notes in github
update_release_draft: update_release_draft:

View File

@@ -60,6 +60,7 @@ jobs:
path: ${{ env.CACHE_DIST_PATH }} path: ${{ env.CACHE_DIST_PATH }}
key: dist-${{ github.run_id }} key: dist-${{ github.run_id }}
- run: npx ng build --prod - run: npx ng build --prod
npx nx run ng2-file-upload:build:production
# run unit tests # run unit tests
unit_tests_with_coverage: unit_tests_with_coverage:

1
.gitignore vendored
View File

@@ -12,6 +12,7 @@
.settings/ .settings/
# misc # misc
/.angular/cache
/.sass-cache /.sass-cache
/connect.lock /connect.lock
/coverage /coverage

View File

@@ -2,7 +2,6 @@
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1, "version": 1,
"newProjectRoot": "projects", "newProjectRoot": "projects",
"defaultProject": "ng2-file-upload-demo",
"projects": { "projects": {
"ng2-file-upload": { "ng2-file-upload": {
"root": "libs/ng2-file-upload", "root": "libs/ng2-file-upload",
@@ -30,7 +29,10 @@
"lintFilePatterns": [ "lintFilePatterns": [
"libs/ng2-file-upload/**/*.ts" "libs/ng2-file-upload/**/*.ts"
] ]
} },
"outputs": [
"{options.outputFile}"
]
}, },
"test": { "test": {
"builder": "@nrwl/jest:jest", "builder": "@nrwl/jest:jest",
@@ -44,8 +46,7 @@
}, },
"version": { "version": {
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"outputs": [ "outputs": [],
],
"options": { "options": {
"commands": [ "commands": [
"ts-node ./scripts/set-version.ts", "ts-node ./scripts/set-version.ts",
@@ -59,7 +60,10 @@
"production": {} "production": {}
} }
} }
} },
"tags": [
"lib"
]
}, },
"ng2-file-upload-demo": { "ng2-file-upload-demo": {
"root": "apps/demo", "root": "apps/demo",
@@ -90,7 +94,6 @@
"optimization": true, "optimization": true,
"outputHashing": "all", "outputHashing": "all",
"sourceMap": false, "sourceMap": false,
"extractCss": true,
"namedChunks": false, "namedChunks": false,
"aot": true, "aot": true,
"extractLicenses": true, "extractLicenses": true,
@@ -122,18 +125,16 @@
"lintFilePatterns": [ "lintFilePatterns": [
"apps/demo/**/*.ts" "apps/demo/**/*.ts"
] ]
} },
"outputs": [
"{options.outputFile}"
]
} }
} },
} "tags": [],
}, "implicitDependencies": [
"schematics": { "ng2-file-upload"
"@schematics/angular:component": { ]
"prefix": "",
"styleext": "css"
},
"@schematics/angular:directive": {
"prefix": ""
} }
} }
} }

View File

@@ -1,20 +1,28 @@
{ {
"extends": ["../../.eslintrc.json"], "extends": [
"ignorePatterns": ["!**/*"], "../../.eslintrc.json"
],
"ignorePatterns": [
"!**/*"
],
"overrides": [ "overrides": [
{ {
"files": ["*.ts"], "files": [
"*.ts"
],
"extends": [ "extends": [
"plugin:@nrwl/nx/angular", "plugin:@nrwl/nx/angular",
"plugin:@angular-eslint/template/process-inline-templates" "plugin:@angular-eslint/template/process-inline-templates"
], ],
"parserOptions": { "project": ["src/accordion/tsconfig.*?.json"] }, "rules": {}
"rules": {
}
}, },
{ {
"files": ["*.html"], "files": [
"extends": ["plugin:@nrwl/nx/angular-template"], "*.html"
],
"extends": [
"plugin:@nrwl/nx/angular-template"
],
"rules": {} "rules": {}
} }
] ]

View File

@@ -1,5 +1,5 @@
module.exports = { const { getJestProjects } = require('@nrwl/jest');
projects: [
'<rootDir>/libs/ng2-file-upload' module.exports = {"projects": getJestProjects()
]
}; };

View File

@@ -1,20 +1,28 @@
{ {
"extends": ["../../.eslintrc.json"], "extends": [
"ignorePatterns": ["!**/*"], "../../.eslintrc.json"
],
"ignorePatterns": [
"!**/*"
],
"overrides": [ "overrides": [
{ {
"files": ["*.ts"], "files": [
"*.ts"
],
"extends": [ "extends": [
"plugin:@nrwl/nx/angular", "plugin:@nrwl/nx/angular",
"plugin:@angular-eslint/template/process-inline-templates" "plugin:@angular-eslint/template/process-inline-templates"
], ],
"parserOptions": { "project": ["src/accordion/tsconfig.*?.json"] }, "rules": {}
"rules": {
}
}, },
{ {
"files": ["*.html"], "files": [
"extends": ["plugin:@nrwl/nx/angular-template"], "*.html"
],
"extends": [
"plugin:@nrwl/nx/angular-template"
],
"rules": {} "rules": {}
} }
] ]

View File

@@ -3,6 +3,8 @@ import { NgModule } from '@angular/core';
import { FileDropDirective } from './file-drop.directive'; import { FileDropDirective } from './file-drop.directive';
import { FileSelectDirective } from './file-select.directive'; import { FileSelectDirective } from './file-select.directive';
export { FileDropDirective } from './file-drop.directive';
export { FileSelectDirective } from './file-select.directive';
@NgModule({ @NgModule({
imports: [ CommonModule ], imports: [ CommonModule ],

View File

@@ -5,22 +5,16 @@ module.exports = {
globals: { globals: {
'ts-jest': { 'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json', tsconfig: '<rootDir>/tsconfig.spec.json',
astTransformers: {
before: [
'jest-preset-angular/build/InlineFilesTransformer',
'jest-preset-angular/build/StripStylesTransformer',
]
}
} }
}, },
transform: {
'^.+\\.[tj]sx?$': 'ts-jest'
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/libs/ng2-file-upload', coverageDirectory: '../../coverage/libs/ng2-file-upload',
snapshotSerializers: [ snapshotSerializers: [
'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js', 'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/AngularSnapshotSerializer.js', 'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/HTMLCommentSerializer.js', 'jest-preset-angular/build/serializers/html-comment'
] ],
transform: { '^.+.(ts|mjs|js|html)$': 'jest-preset-angular' },
transformIgnorePatterns: ['node_modules/(?!.*.mjs$)'],
moduleFileExtensions: ['mjs', 'ts', 'js', 'html']
}; };

View File

@@ -1,6 +1,6 @@
import { Component, DebugElement } from '@angular/core'; import { Component, DebugElement } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { inject, ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FileUploader } from '../../file-upload/file-uploader.class'; import { FileUploader } from '../../file-upload/file-uploader.class';
import { FileUploadModule } from '../../file-upload/file-upload.module'; import { FileUploadModule } from '../../file-upload/file-upload.module';
@@ -28,7 +28,7 @@ describe('Directive: FileDropDirective', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ FileUploadModule ], imports: [ FileUploadModule ],
declarations: [ ContainerComponent ], declarations: [ ContainerComponent, FileDropDirective ],
providers: [ ContainerComponent ] providers: [ ContainerComponent ]
}); });
}); });
@@ -72,19 +72,23 @@ describe('Directive: FileDropDirective', () => {
const filters = fileDropDirective.getFilters(); const filters = fileDropDirective.getFilters();
// TODO: Update test once implemented // TODO: Update test once implemented
expect(filters).toEqual({}); expect(filters).toBeFalsy();
}); });
it('handles drop event', () => { it('handles drop event', () => {
spyOn(fileDropDirective, 'onDrop'); //@ts-ignore
const drop = jest.spyOn(fileDropDirective, 'onDrop');
directiveElement.triggerEventHandler('drop', getFakeEventData()); directiveElement.triggerEventHandler('drop', getFakeEventData());
expect(fileDropDirective.onDrop).toHaveBeenCalled(); expect(drop).toHaveBeenCalled();
}); });
it('adds file to upload', () => { it('adds file to upload', () => {
spyOn(fileDropDirective.uploader, 'addToQueue'); let addToQueue;
if (fileDropDirective.uploader?.addToQueue) {
//@ts-ignore
addToQueue = jest.spyOn(fileDropDirective.uploader, 'addToQueue');
}
let fileOverData; let fileOverData;
fileDropDirective.fileOver.subscribe((data: any) => fileOverData = data); fileDropDirective.fileOver.subscribe((data: any) => fileOverData = data);
@@ -96,13 +100,14 @@ describe('Directive: FileDropDirective', () => {
const uploadedFiles = getFakeEventData().dataTransfer.files; const uploadedFiles = getFakeEventData().dataTransfer.files;
expect(fileDropDirective.uploader.addToQueue).toHaveBeenCalledWith(uploadedFiles, fileDropDirective.getOptions(), fileDropDirective.getFilters()); expect(addToQueue).toHaveBeenCalledWith(uploadedFiles, fileDropDirective.getOptions(), fileDropDirective.getFilters());
expect(fileOverData).toBeFalsy(); expect(fileOverData).toBeFalsy();
expect(fileDropData).toEqual(uploadedFiles); expect(fileDropData).toEqual(uploadedFiles);
}); });
it('handles dragover event', () => { it('handles dragover event', () => {
spyOn(fileDropDirective, 'onDragOver'); //@ts-ignore
jest.spyOn(fileDropDirective, 'onDragOver');
directiveElement.triggerEventHandler('dragover', getFakeEventData()); directiveElement.triggerEventHandler('dragover', getFakeEventData());
@@ -119,7 +124,8 @@ describe('Directive: FileDropDirective', () => {
}); });
it('handles dragleave event', () => { it('handles dragleave event', () => {
spyOn(fileDropDirective, 'onDragLeave'); //@ts-ignore
jest.spyOn(fileDropDirective, 'onDragLeave');
directiveElement.triggerEventHandler('dragleave', getFakeEventData()); directiveElement.triggerEventHandler('dragleave', getFakeEventData());

View File

@@ -72,7 +72,7 @@ describe('Directive: FileSelectDirective', () => {
const filters = fileSelectDirective.getFilters(); const filters = fileSelectDirective.getFilters();
// TODO: Update test once implemented // TODO: Update test once implemented
expect(filters).toEqual({}); expect(filters).toEqual('');
}); });
it('can check if element is empty', () => { it('can check if element is empty', () => {
@@ -82,18 +82,22 @@ describe('Directive: FileSelectDirective', () => {
}); });
it('can listed on change event', () => { it('can listed on change event', () => {
spyOn(fileSelectDirective, 'onChange'); //@ts-ignore
const change = jest.spyOn(fileSelectDirective, 'onChange');
directiveElement.triggerEventHandler('change', {}); directiveElement.triggerEventHandler('change', {});
expect(fileSelectDirective.onChange).toHaveBeenCalled(); expect(change).toHaveBeenCalled();
}); });
it('handles change event', () => { it('handles change event', () => {
spyOn(fileSelectDirective.uploader, 'addToQueue'); let addToQueue;
if (fileSelectDirective.uploader?.addToQueue) {
//@ts-ignore
addToQueue = jest.spyOn(fileSelectDirective.uploader, 'addToQueue');
}
fileSelectDirective.onChange(); fileSelectDirective.onChange();
expect(fileSelectDirective.uploader.addToQueue).toHaveBeenCalledWith(directiveElement.nativeElement.files, fileSelectDirective.getOptions(), fileSelectDirective.getFilters()); expect(addToQueue).toHaveBeenCalledWith(directiveElement.nativeElement.files, fileSelectDirective.getOptions(), fileSelectDirective.getFilters());
}); });
}); });

View File

@@ -1 +1 @@
import 'jest-preset-angular'; import 'jest-preset-angular/setup-jest';

View File

@@ -25,4 +25,3 @@
"fullTemplateTypeCheck": true "fullTemplateTypeCheck": true
} }
} }

View File

@@ -7,7 +7,10 @@
"declarationMap": true, "declarationMap": true,
"inlineSources": true, "inlineSources": true,
"types": [], "types": [],
"lib": ["dom", "es2018"] "lib": [
"dom",
"es2018"
]
}, },
"angularCompilerOptions": { "angularCompilerOptions": {
"skipTemplateCodegen": true, "skipTemplateCodegen": true,
@@ -18,6 +21,7 @@
"**/*.ts" "**/*.ts"
], ],
"exclude": [ "exclude": [
"**/*.spec.ts" "**/*.spec.ts",
"**/*.test.ts"
] ]
} }

View File

@@ -1,10 +1,9 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{ {
"extends": "./tsconfig.lib.json", "extends": "./tsconfig.lib.json",
"compilerOptions": { "compilerOptions": {
"declarationMap": false "declarationMap": false
}, },
"angularCompilerOptions": { "angularCompilerOptions": {
"enableIvy": false "compilationMode": "partial"
} }
} }

View File

@@ -3,10 +3,17 @@
"compilerOptions": { "compilerOptions": {
"outDir": "../../dist/out-tsc", "outDir": "../../dist/out-tsc",
"module": "commonjs", "module": "commonjs",
"types": ["jest", "node"] "types": [
"jest",
"node"
]
}, },
"files": [
"testing/test-setup.ts"
],
"include": [ "include": [
"**/*.spec.ts", "**/*.spec.ts",
"**/*.test.ts",
"**/*.d.ts" "**/*.d.ts"
] ]
} }

32
nx.json
View File

@@ -8,31 +8,31 @@
".eslintrc.json": "*", ".eslintrc.json": "*",
"nx.json": "*" "nx.json": "*"
}, },
"projects": {
"ng2-file-upload": {
"tags": [
"lib"
]
},
"ng2-file-upload-demo": {
"tags": [],
"implicitDependencies": [
"ng2-file-upload"
]
}
},
"tasksRunnerOptions": { "tasksRunnerOptions": {
"default": { "default": {
"runner": "@nrwl/workspace/tasks-runners/default", "runner": "nx/tasks-runners/default",
"options": { "options": {
"cacheableOperations": [ "cacheableOperations": [
"build", "build",
"lint", "lint",
"test", "test",
"e2e" "e2e"
] ],
"parallel": 1
} }
} }
},
"affected": {
"defaultBase": "master"
},
"defaultProject": "ng2-file-upload-demo",
"generators": {
"@schematics/angular:component": {
"prefix": "",
"styleext": "css"
},
"@schematics/angular:directive": {
"prefix": ""
}
} }
} }

22580
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,13 +11,13 @@
"build": "nx run ng2-file-upload:build", "build": "nx run ng2-file-upload:build",
"build-prod": "nx run ng2-file-upload:build:production", "build-prod": "nx run ng2-file-upload:build:production",
"build.watch": "nx run ng2-file-upload:build --watch", "build.watch": "nx run ng2-file-upload:build --watch",
"test": "nx run-many --all --target=test", "lint": "nx run-many --target=lint --all",
"test": "nx run-many --target=test --all",
"version": "nx run ng2-file-upload:version", "version": "nx run ng2-file-upload:version",
"lint": "nx run-many --all --target=lint",
"pretest": "run-s lint build", "pretest": "run-s lint build",
"test-coverage": "nx run-many --all --target=test --codeCoverage", "test-coverage": "nx run-many --all --target=test --codeCoverage",
"demo.gh-pages": "run-s build demo.build demo.deploy", "demo.gh-pages": "run-s build demo.build demo.deploy",
"demo.deploy": "gh-pages -d dist/apps/ng2-file-upload", "demo.deploy": "gh-pages -d dist/apps/demo",
"postinstall": "node ./decorate-angular-cli.js", "postinstall": "node ./decorate-angular-cli.js",
"flow.github-release": "conventional-github-releaser -p angular" "flow.github-release": "conventional-github-releaser -p angular"
}, },
@@ -40,32 +40,32 @@
"homepage": "https://github.com/valor-software/ng2-file-upload#readme", "homepage": "https://github.com/valor-software/ng2-file-upload#readme",
"peerDependencies": {}, "peerDependencies": {},
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "~0.1102.13", "@angular-devkit/build-angular": "13.3.3",
"@angular-devkit/build-ng-packagr": "^0.1002.0", "@angular-devkit/build-ng-packagr": "^0.1002.0",
"@angular/animations": "~11.2.14", "@angular-eslint/eslint-plugin": "13.0.1",
"@angular/cli": "~11.2.14", "@angular-eslint/eslint-plugin-template": "13.0.1",
"@angular/common": "~11.2.14", "@angular-eslint/template-parser": "13.0.1",
"@angular/compiler": "~11.2.14", "@angular/animations": "13.3.3",
"@angular/compiler-cli": "~11.2.14", "@angular/cli": "13.3.3",
"@angular/core": "~11.2.14", "@angular/common": "13.3.3",
"@angular/forms": "~11.2.14", "@angular/compiler": "13.3.3",
"@angular/platform-browser": "~11.2.14", "@angular/compiler-cli": "13.3.3",
"@angular/platform-browser-dynamic": "~11.2.14", "@angular/core": "13.3.3",
"@angular-eslint/eslint-plugin": "4.3.0", "@angular/forms": "13.3.3",
"@angular-eslint/eslint-plugin-template": "4.3.0", "@angular/platform-browser": "13.3.3",
"@angular-eslint/template-parser": "4.3.0", "@angular/platform-browser-dynamic": "13.3.3",
"@nrwl/angular": "11.2.12", "@nrwl/angular": "13.10.2",
"@nrwl/cli": "11.2.12", "@nrwl/cli": "13.10.2",
"@nrwl/node": "11.2.12", "@nrwl/eslint-plugin-nx": "13.10.2",
"@nrwl/eslint-plugin-nx": "11.2.12", "@nrwl/jest": "13.10.2",
"@nrwl/jest": "11.2.12", "@nrwl/linter": "13.10.2",
"@nrwl/linter": "11.2.12", "@nrwl/node": "13.10.2",
"@types/fs-extra": "9.0.7", "@types/fs-extra": "9.0.7",
"@types/jest": "26.0.20", "@types/jest": "27.0.2",
"@types/node": "^12.11.1", "@types/node": "^12.11.1",
"@types/webpack": "^5.0.0", "@types/webpack": "^5.0.0",
"@typescript-eslint/eslint-plugin": "~4.28.3", "@typescript-eslint/eslint-plugin": "5.18.0",
"@typescript-eslint/parser": "~4.28.3", "@typescript-eslint/parser": "5.18.0",
"bootstrap": "3.3.7", "bootstrap": "3.3.7",
"classlist-polyfill": "1.2.0", "classlist-polyfill": "1.2.0",
"codecov": "3.8.2", "codecov": "3.8.2",
@@ -73,29 +73,33 @@
"conventional-changelog-cli": "2.1.1", "conventional-changelog-cli": "2.1.1",
"conventional-github-releaser": "3.1.5", "conventional-github-releaser": "3.1.5",
"core-js": "^3.14.0", "core-js": "^3.14.0",
"eslint": "7.22.0", "eslint": "8.12.0",
"eslint-config-prettier": "7.2.0", "eslint-config-prettier": "8.1.0",
"fs-extra": "9.1.0", "fs-extra": "9.1.0",
"gh-pages": "3.2.2", "gh-pages": "3.2.2",
"google-code-prettify": "1.0.5", "google-code-prettify": "1.0.5",
"html-loader": "^1.3.2", "html-loader": "^1.3.2",
"jest": "26.6.3", "jest": "27.2.3",
"jest-createspyobj": "2.0.0", "jest-createspyobj": "2.0.0",
"jest-preset-angular": "8.3.2", "jest-preset-angular": "11.1.1",
"markdown-loader": "^6.0.0", "markdown-loader": "^6.0.0",
"ng-packagr": "^11.2.4", "ng-packagr": "13.3.1",
"ngx-bootstrap": "7.1.0", "ngx-bootstrap": "7.1.0",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"postcss": "^8.3.9",
"postcss-import": "^14.0.2",
"postcss-preset-env": "^6.7.0",
"postcss-url": "^10.1.1",
"protractor": "~7.0.0", "protractor": "~7.0.0",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",
"rxjs": "^6.6.0", "rxjs": "^6.6.0",
"ts-helpers": "^1.1.2", "ts-helpers": "^1.1.2",
"ts-jest": "26.5.1", "ts-jest": "27.0.5",
"ts-node": "8.3.0", "ts-node": "8.3.0",
"tslint": "^6.1.0", "tslint": "^6.1.0",
"tslint-config-valorsoft": "^2.2.1", "tslint-config-valorsoft": "^2.2.1",
"typescript": "4.1.5", "typescript": "4.6.3",
"zone.js": "~0.11.3" "zone.js": "0.11.5"
}, },
"contributors": [ "contributors": [
{ {
@@ -120,7 +124,8 @@
} }
], ],
"dependencies": { "dependencies": {
"@nrwl/workspace": "^12.8.0", "@nrwl/workspace": "13.10.2",
"nx": "13.10.2",
"tslib": "^2.0.0" "tslib": "^2.0.0"
} }
} }