ng-alain 14.3.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/application/files/root/.stylelintrc +2 -1
  2. package/application/files/src/assets/color.less +6 -1
  3. package/application/files/src/assets/style.compact.css +1 -1
  4. package/application/files/src/assets/style.dark.css +1 -1
  5. package/application/index.js +8 -7
  6. package/application/index.js.map +1 -1
  7. package/application/index.ts +8 -7
  8. package/migration.json +4 -14
  9. package/ng-add/index.js +2 -2
  10. package/ng-add/index.ts +2 -2
  11. package/ng-update/data/attribute-selectors.js +1 -1
  12. package/ng-update/data/attribute-selectors.ts +1 -1
  13. package/ng-update/data/class-names.js +1 -1
  14. package/ng-update/data/class-names.ts +1 -1
  15. package/ng-update/data/constructor-checks.js +1 -1
  16. package/ng-update/data/constructor-checks.ts +1 -1
  17. package/ng-update/data/css-selectors.js +1 -1
  18. package/ng-update/data/css-selectors.ts +1 -1
  19. package/ng-update/data/element-selectors.js +1 -1
  20. package/ng-update/data/element-selectors.ts +1 -1
  21. package/ng-update/data/input-names.js +1 -1
  22. package/ng-update/data/input-names.ts +1 -1
  23. package/ng-update/data/method-call-checks.js +1 -1
  24. package/ng-update/data/method-call-checks.ts +1 -1
  25. package/ng-update/data/output-names.js +1 -1
  26. package/ng-update/data/output-names.ts +1 -1
  27. package/ng-update/data/property-names.js +1 -1
  28. package/ng-update/data/property-names.ts +1 -1
  29. package/ng-update/index.js +6 -19
  30. package/ng-update/index.js.map +1 -1
  31. package/ng-update/index.ts +4 -17
  32. package/ng-update/upgrade-rules/v15/index.js +44 -0
  33. package/ng-update/upgrade-rules/v15/index.js.map +1 -0
  34. package/ng-update/upgrade-rules/v15/index.spec.ts +20 -0
  35. package/ng-update/upgrade-rules/v15/index.ts +38 -0
  36. package/package.json +4 -2
  37. package/plugin/plugin.icon.js +1 -0
  38. package/plugin/plugin.icon.js.map +1 -1
  39. package/plugin/plugin.icon.ts +4 -1
  40. package/tpl/schema.json +1 -1
  41. package/utils/less.js +19 -0
  42. package/utils/less.js.map +1 -0
  43. package/utils/less.ts +15 -0
  44. package/utils/lib-versions.js +2 -2
  45. package/utils/lib-versions.ts +2 -2
  46. package/utils/versions.js +15 -15
  47. package/utils/versions.ts +15 -15
  48. package/application/files/src/test.ts +0 -24
  49. package/ng-update/test-cases/v12/deprecated-src.spec.ts +0 -29
  50. package/ng-update/upgrade-rules/checks/_src-to-nz-image-rule.js +0 -25
  51. package/ng-update/upgrade-rules/checks/_src-to-nz-image-rule.js.map +0 -1
  52. package/ng-update/upgrade-rules/checks/_src-to-nz-image-rule.ts +0 -26
  53. package/ng-update/upgrade-rules/v12/index.js +0 -164
  54. package/ng-update/upgrade-rules/v12/index.js.map +0 -1
  55. package/ng-update/upgrade-rules/v12/index.spec.ts +0 -335
  56. package/ng-update/upgrade-rules/v12/index.ts +0 -187
  57. package/ng-update/upgrade-rules/v12/schema.js +0 -3
  58. package/ng-update/upgrade-rules/v12/schema.js.map +0 -1
  59. package/ng-update/upgrade-rules/v12/schema.json +0 -13
  60. package/ng-update/upgrade-rules/v12/schema.ts +0 -4
  61. package/ng-update/upgrade-rules/v13/index.js +0 -100
  62. package/ng-update/upgrade-rules/v13/index.js.map +0 -1
  63. package/ng-update/upgrade-rules/v13/index.spec.ts +0 -39
  64. package/ng-update/upgrade-rules/v13/index.ts +0 -110
  65. package/ng-update/upgrade-rules/v14/index.js +0 -80
  66. package/ng-update/upgrade-rules/v14/index.js.map +0 -1
  67. package/ng-update/upgrade-rules/v14/index.spec.ts +0 -305
  68. package/ng-update/upgrade-rules/v14/index.ts +0 -91
@@ -1,39 +0,0 @@
1
- import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
2
-
3
- import { createAlainApp, migrationCollection } from '../../../utils/testing';
4
-
5
- describe('Schematic: ng-update: v13Rule', () => {
6
- let runner: SchematicTestRunner;
7
- let tree: UnitTestTree;
8
- const logs: string[] = [];
9
-
10
- beforeEach(async () => {
11
- ({ runner, tree } = await createAlainApp());
12
- });
13
-
14
- async function runMigration(): Promise<void> {
15
- logs.length = 0;
16
- runner = new SchematicTestRunner('schematics', migrationCollection);
17
- runner.logger.subscribe(e => logs.push(e.message));
18
- await runner.runSchematicAsync('migration-v13', {}, tree).toPromise();
19
- }
20
-
21
- it(`should be working`, async () => {
22
- tree.create(
23
- `1.less`,
24
- `@import '~@delon/theme/index';
25
- @import '~ng-zorro-antd/';`
26
- );
27
- await runMigration();
28
- const content = tree.readContent('angular.json');
29
- expect(content).toContain(`stylePreprocessorOptions`);
30
- expect(content).toContain(`"packageManager": "yarn"`);
31
- expect(tree.readContent('1.less')).not.toContain(`@import '~@delon`);
32
- });
33
-
34
- it(`should be tips not support ie`, async () => {
35
- tree.overwrite(`package.json`, JSON.stringify({ scripts: { 'ie:start': 'npm' } }));
36
- await runMigration();
37
- expect(logs.join('')).toContain(`TIPS: Starting from NG-ALAIN 13 will no longer support IE`);
38
- });
39
- });
@@ -1,110 +0,0 @@
1
- import { chain, Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
2
- import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
3
- import { updateWorkspace } from '@schematics/angular/utility/workspace';
4
- import * as colors from 'ansi-colors';
5
-
6
- import {
7
- addPackage,
8
- addStylePreprocessorOptionsToAllProject,
9
- logStart,
10
- readContent,
11
- readPackage,
12
- writePackage
13
- } from '../../../utils';
14
- import { UpgradeMainVersions } from '../../../utils/versions';
15
-
16
- function addStylePreprocessorOptions(): Rule {
17
- return updateWorkspace(async workspace => {
18
- addStylePreprocessorOptionsToAllProject(workspace);
19
- });
20
- }
21
-
22
- // Using ~ is deprecated and can be removed from your code
23
- function fixLessResolver(): Rule {
24
- return (tree: Tree, context: SchematicContext) => {
25
- logStart(
26
- context,
27
- `Removed deprecated ~ in less file, pls refer to https://github.com/webpack-contrib/less-loader#imports`
28
- );
29
- tree.visit(path => {
30
- if (!path.endsWith(`.less`)) return;
31
- const content = tree
32
- .read(path)
33
- .toString('utf8')
34
- .replace(/^(@import ['"]{1})~/gm, '$1');
35
-
36
- tree.overwrite(path, content);
37
- });
38
- };
39
- }
40
-
41
- function removeIE(): Rule {
42
- return (tree: Tree, context: SchematicContext) => {
43
- const pkg = readPackage(tree);
44
- if (pkg.scripts && !pkg.scripts['ie:start']) return;
45
-
46
- context.logger.warn(colors.yellow(`TIPS: Starting from NG-ALAIN 13 will no longer support IE`));
47
- };
48
- }
49
-
50
- function addYarn(context: SchematicContext): Rule {
51
- return updateWorkspace(async workspace => {
52
- const cli = workspace.extensions.cli as Record<string, unknown>;
53
- if (cli && cli.packageManager) return;
54
- if (cli == null) workspace.extensions.cli = {};
55
- workspace.extensions.cli['packageManager'] = 'yarn';
56
- logStart(context, `Configuration optimization using Yarn to install dependencies`);
57
- });
58
- }
59
-
60
- function upgradeKarmaCoverage(): Rule {
61
- return (tree: Tree, context: SchematicContext) => {
62
- const karmaConfJs = 'karma.conf.js';
63
- const pkg = readPackage(tree);
64
- if (!pkg.devDependencies || !pkg.devDependencies['karma-coverage-istanbul-reporter'] || !tree.exists(karmaConfJs))
65
- return;
66
- delete pkg.devDependencies['karma-coverage-istanbul-reporter'];
67
- writePackage(tree, pkg);
68
-
69
- // update karma.conf.js
70
- const content = readContent(tree, karmaConfJs).replace(`karma-coverage-istanbul-reporter`, 'karma-coverage');
71
- tree.overwrite(karmaConfJs, content);
72
-
73
- logStart(context, `karma-coverage instead of karma-coverage-istanbul-reporter`);
74
- };
75
- }
76
-
77
- function upgradeThirdVersion(): Rule {
78
- return (tree: Tree, context: SchematicContext) => {
79
- addPackage(tree, [`ngx-tinymce@^14.0.0`], 'dependencies');
80
- logStart(context, `Upgrade third libs ( ngx-tinymce) version number`);
81
- };
82
- }
83
-
84
- function finished(): Rule {
85
- return (_tree: Tree, context: SchematicContext) => {
86
- context.addTask(new NodePackageInstallTask());
87
-
88
- context.logger.info(
89
- colors.green(
90
- ` ✓ Congratulations, Abort more detail please refer to upgrade guide https://github.com/ng-alain/ng-alain/issues/2174`
91
- )
92
- );
93
- };
94
- }
95
-
96
- export function v13Rule(): Rule {
97
- return async (tree: Tree, context: SchematicContext) => {
98
- logStart(context, `Upgrade @delon/* version number`);
99
- UpgradeMainVersions(tree);
100
- return chain([
101
- removeIE(),
102
- addStylePreprocessorOptions(),
103
- fixLessResolver(),
104
- upgradeKarmaCoverage(),
105
- upgradeThirdVersion(),
106
- addYarn(context),
107
- finished()
108
- ]);
109
- };
110
- }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.v14Rule = void 0;
13
- const schematics_1 = require("@angular-devkit/schematics");
14
- const tasks_1 = require("@angular-devkit/schematics/tasks");
15
- const workspace_1 = require("@schematics/angular/utility/workspace");
16
- const colors = require("ansi-colors");
17
- const utils_1 = require("../../../utils");
18
- const versions_1 = require("../../../utils/versions");
19
- function fixSchematicCollections(context) {
20
- return (0, workspace_1.updateWorkspace)((workspace) => __awaiter(this, void 0, void 0, function* () {
21
- (0, utils_1.addSchematicCollections)(workspace);
22
- (0, utils_1.logStart)(context, `Add schematicCollections you can use 'ng g list' is equivalent to 'ng generate ng-alain:list'`);
23
- }));
24
- }
25
- function addEslintPluginDeprecation() {
26
- return (tree, context) => {
27
- const path = '.eslintrc.js';
28
- if (!tree.exists(path))
29
- return;
30
- let content = tree.readText(path);
31
- if (content.includes(`['@typescript-eslint', 'jsdoc', 'import']`)) {
32
- content = content.replace(`['@typescript-eslint', 'jsdoc', 'import']`, `['@typescript-eslint', 'jsdoc', 'import', 'deprecation']`);
33
- }
34
- if (content.includes(`'prefer-const': 'off',`)) {
35
- content = content.replace(`'prefer-const': 'off',`, `'prefer-const': 'off',\n'deprecation/deprecation': 'warn',`);
36
- }
37
- tree.overwrite(path, content);
38
- // add deprecation
39
- (0, utils_1.addPackage)(tree, `eslint-plugin-prettier@~4.2.1`, 'devDependencies');
40
- (0, utils_1.logStart)(context, `Add deprecation warn of eslint`);
41
- };
42
- }
43
- function fixReuseTabActiviteInHtml() {
44
- return (tree, context) => {
45
- const layoutPath = (0, utils_1.findFile)(tree, 'basic/basic.component.ts');
46
- if (!tree.exists(layoutPath))
47
- return;
48
- let layoutContent = tree.get(layoutPath).content.toString('utf8');
49
- const checkHtml = `<router-outlet (activate)="reuseTab.activate($event)"></router-outlet>`;
50
- if (!layoutContent.includes(checkHtml))
51
- return;
52
- layoutContent = layoutContent.replace(checkHtml, `<router-outlet (activate)="reuseTab.activate($event)" (attach)="reuseTab.activate($event)"></router-outlet>`);
53
- tree.overwrite(layoutPath, layoutContent);
54
- (0, utils_1.logStart)(context, `Fix can't refresh current item in resut-tab (https://github.com/ng-alain/ng-alain/issues/2302)`);
55
- };
56
- }
57
- function finished() {
58
- return (_tree, context) => {
59
- context.addTask(new tasks_1.NodePackageInstallTask());
60
- context.logger.info(colors.green(` ✓ Congratulations, Abort more detail please refer to upgrade guide https://github.com/ng-alain/ng-alain/issues/2285`));
61
- };
62
- }
63
- function v14Rule() {
64
- return (tree, context) => __awaiter(this, void 0, void 0, function* () {
65
- (0, utils_1.logStart)(context, `Upgrade @delon/* version number`);
66
- (0, versions_1.UpgradeMainVersions)(tree);
67
- return (0, schematics_1.chain)([
68
- (0, utils_1.addAllowSyntheticDefaultImports)(),
69
- // Configuring CommonJS dependencies
70
- // https://angular.io/guide/build#configuring-commonjs-dependencies
71
- (0, utils_1.addAllowedCommonJsDependencies)([]),
72
- fixSchematicCollections(context),
73
- fixReuseTabActiviteInHtml(),
74
- addEslintPluginDeprecation(),
75
- finished()
76
- ]);
77
- });
78
- }
79
- exports.v14Rule = v14Rule;
80
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../schematics/ng-update/upgrade-rules/v14/index.ts"],"names":[],"mappings":"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"}
@@ -1,305 +0,0 @@
1
- import { JsonObject } from '@angular-devkit/core';
2
- import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
3
-
4
- import { findFile } from '../../../utils/file';
5
- import { createAlainApp, migrationCollection } from '../../../utils/testing';
6
-
7
- describe('Schematic: ng-update: v14Rule', () => {
8
- let runner: SchematicTestRunner;
9
- let tree: UnitTestTree;
10
- const logs: string[] = [];
11
-
12
- beforeEach(async () => {
13
- ({ runner, tree } = await createAlainApp());
14
- });
15
-
16
- async function runMigration(): Promise<void> {
17
- logs.length = 0;
18
- runner = new SchematicTestRunner('schematics', migrationCollection);
19
- runner.logger.subscribe(e => logs.push(e.message));
20
- await runner.runSchematicAsync('migration-v14', {}, tree).toPromise();
21
- }
22
-
23
- it(`should be working`, async () => {
24
- tree.overwrite(
25
- '/angular.json',
26
- `{
27
- "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
28
- "version": 1,
29
- "newProjectRoot": "projects",
30
- "projects": {
31
- "ng-alain": {
32
- "projectType": "application",
33
- "root": "",
34
- "sourceRoot": "src",
35
- "prefix": "app",
36
- "schematics": {
37
- "@schematics/angular:component": {
38
- "style": "less"
39
- },
40
- "@schematics/angular:application": {
41
- "strict": true
42
- }
43
- },
44
- "architect": {
45
- "build": {
46
- "builder": "@angular-devkit/build-angular:browser",
47
- "options": {
48
- "outputPath": "dist",
49
- "index": "src/index.html",
50
- "main": "src/main.ts",
51
- "tsConfig": "tsconfig.app.json",
52
- "polyfills": "src/polyfills.ts",
53
- "assets": ["src/assets", "src/favicon.ico"],
54
- "styles": ["src/styles.less"],
55
- "scripts": [],
56
- "allowedCommonJsDependencies": ["@antv/g2", "ajv", "ajv-formats", "date-fns", "file-saver"],
57
- "stylePreprocessorOptions": {
58
- "includePaths": [
59
- "node_modules/"
60
- ]
61
- }
62
- },
63
- "configurations": {
64
- "production": {
65
- "fileReplacements": [
66
- {
67
- "replace": "src/environments/environment.ts",
68
- "with": "src/environments/environment.prod.ts"
69
- }
70
- ],
71
- "outputHashing": "all",
72
- "budgets": [
73
- {
74
- "type": "initial",
75
- "maximumWarning": "2mb",
76
- "maximumError": "6mb"
77
- },
78
- {
79
- "type": "anyComponentStyle",
80
- "maximumWarning": "6kb",
81
- "maximumError": "10kb"
82
- }
83
- ]
84
- },
85
- "development": {
86
- "buildOptimizer": false,
87
- "optimization": false,
88
- "vendorChunk": true,
89
- "extractLicenses": false,
90
- "sourceMap": true,
91
- "namedChunks": true
92
- }
93
- },
94
- "defaultConfiguration": "production"
95
- },
96
- "serve": {
97
- "builder": "@angular-devkit/build-angular:dev-server",
98
- "options": {
99
- "browserTarget": "ng-alain:build",
100
- "proxyConfig": "proxy.conf.js"
101
- },
102
- "configurations": {
103
- "production": {
104
- "browserTarget": "ng-alain:build:production"
105
- },
106
- "development": {
107
- "browserTarget": "ng-alain:build:development"
108
- }
109
- },
110
- "defaultConfiguration": "development"
111
- },
112
- "extract-i18n": {
113
- "builder": "@angular-devkit/build-angular:extract-i18n",
114
- "options": {
115
- "browserTarget": "ng-alain:build"
116
- }
117
- },
118
- "test": {
119
- "builder": "@angular-devkit/build-angular:karma",
120
- "options": {
121
- "main": "src/test.ts",
122
- "polyfills": "src/polyfills.ts",
123
- "karmaConfig": "karma.conf.js",
124
- "tsConfig": "tsconfig.spec.json",
125
- "scripts": [],
126
- "styles": [],
127
- "assets": ["src/assets"]
128
- }
129
- },
130
- "lint": {
131
- "builder": "@angular-eslint/builder:lint",
132
- "options": {
133
- "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
134
- }
135
- },
136
- "e2e": {
137
- "builder": "@angular-devkit/build-angular:protractor",
138
- "options": {
139
- "protractorConfig": "e2e/protractor.conf.js",
140
- "devServerTarget": "ng-alain:serve"
141
- },
142
- "configurations": {
143
- "production": {
144
- "devServerTarget": "ng-alain:serve:production"
145
- }
146
- }
147
- }
148
- }
149
- }
150
- },
151
- "defaultProject": "ng-alain",
152
- "cli": {
153
- "packageManager": "yarn"
154
- }
155
- }`
156
- );
157
- tree.create(
158
- `.eslintrc.js`,
159
- `
160
- const prettierConfig = require('./.prettierrc.js');
161
-
162
- module.exports = {
163
- root: true,
164
- parserOptions: { ecmaVersion: 2021 },
165
- overrides: [
166
- {
167
- files: ['*.ts'],
168
- parser: '@typescript-eslint/parser',
169
- parserOptions: {
170
- tsconfigRootDir: __dirname,
171
- project: ['tsconfig.json'],
172
- createDefaultProgram: true
173
- },
174
- plugins: ['@typescript-eslint', 'jsdoc', 'import'],
175
- extends: [
176
- 'plugin:@angular-eslint/recommended',
177
- 'plugin:@angular-eslint/template/process-inline-templates',
178
- 'plugin:prettier/recommended'
179
- ],
180
- rules: {
181
- 'prettier/prettier': ['error', prettierConfig],
182
- 'jsdoc/newline-after-description': 1,
183
- '@angular-eslint/component-class-suffix': [
184
- 'error',
185
- {
186
- suffixes: ['Directive', 'Component', 'Base', 'Widget']
187
- }
188
- ],
189
- '@angular-eslint/directive-class-suffix': [
190
- 'error',
191
- {
192
- suffixes: ['Directive', 'Component', 'Base', 'Widget']
193
- }
194
- ],
195
- '@angular-eslint/component-selector': [
196
- 'off',
197
- {
198
- type: ['element', 'attribute'],
199
- prefix: ['app', 'test'],
200
- style: 'kebab-case'
201
- }
202
- ],
203
- '@angular-eslint/directive-selector': [
204
- 'off',
205
- {
206
- type: 'attribute',
207
- prefix: ['app']
208
- }
209
- ],
210
- '@angular-eslint/no-attribute-decorator': 'error',
211
- '@angular-eslint/no-conflicting-lifecycle': 'off',
212
- '@angular-eslint/no-forward-ref': 'off',
213
- '@angular-eslint/no-host-metadata-property': 'off',
214
- '@angular-eslint/no-lifecycle-call': 'off',
215
- '@angular-eslint/no-pipe-impure': 'error',
216
- '@angular-eslint/prefer-output-readonly': 'error',
217
- '@angular-eslint/use-component-selector': 'off',
218
- '@angular-eslint/use-component-view-encapsulation': 'off',
219
- '@angular-eslint/no-input-rename': 'off',
220
- '@angular-eslint/no-output-native': 'off',
221
- '@typescript-eslint/array-type': [
222
- 'error',
223
- {
224
- default: 'array-simple'
225
- }
226
- ],
227
- '@typescript-eslint/ban-types': [
228
- 'off',
229
- {
230
- types: {
231
- String: {
232
- message: 'Use string instead.'
233
- },
234
- Number: {
235
- message: 'Use number instead.'
236
- },
237
- Boolean: {
238
- message: 'Use boolean instead.'
239
- },
240
- Function: {
241
- message: 'Use specific callable interface instead.'
242
- }
243
- }
244
- }
245
- ],
246
- 'import/no-duplicates': 'error',
247
- 'import/no-unused-modules': 'error',
248
- 'import/no-unassigned-import': 'error',
249
- 'import/order': [
250
- 'error',
251
- {
252
- alphabetize: { order: 'asc', caseInsensitive: false },
253
- 'newlines-between': 'always',
254
- groups: ['external', 'internal', ['parent', 'sibling', 'index']],
255
- pathGroups: [],
256
- pathGroupsExcludedImportTypes: []
257
- }
258
- ],
259
- '@typescript-eslint/no-this-alias': 'error',
260
- '@typescript-eslint/member-ordering': 'off',
261
- 'no-irregular-whitespace': 'error',
262
- 'no-multiple-empty-lines': 'error',
263
- 'no-sparse-arrays': 'error',
264
- 'prefer-object-spread': 'error',
265
- 'prefer-template': 'error',
266
- 'prefer-const': 'off',
267
- 'max-len': 'off'
268
- }
269
- },
270
- {
271
- files: ['*.html'],
272
- extends: ['plugin:@angular-eslint/template/recommended'],
273
- rules: {}
274
- },
275
- {
276
- files: ['*.html'],
277
- excludedFiles: ['*inline-template-*.component.html'],
278
- extends: ['plugin:prettier/recommended'],
279
- rules: {
280
- 'prettier/prettier': ['error', { parser: 'angular' }],
281
- '@angular-eslint/template/eqeqeq': 'off'
282
- }
283
- }
284
- ]
285
- };
286
- `
287
- );
288
- await runMigration();
289
- const content = tree.readJson('angular.json') as JsonObject;
290
- expect((content.cli as { schematicCollections: string[] }).schematicCollections).toContain(`ng-alain`);
291
- });
292
-
293
- it('#fixReuseTabActiviteInHtml', async () => {
294
- const layoutPath = findFile(tree, 'basic/basic.component.ts')!;
295
- tree.overwrite(
296
- layoutPath,
297
- `
298
- <router-outlet (activate)="reuseTab.activate($event)"></router-outlet>
299
- `
300
- );
301
- await runMigration();
302
- const content = tree.get(layoutPath)!.content.toString('utf8');
303
- expect(content).toContain(`(attach)`);
304
- });
305
- });
@@ -1,91 +0,0 @@
1
- import { chain, Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
2
- import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
3
- import { updateWorkspace } from '@schematics/angular/utility/workspace';
4
- import * as colors from 'ansi-colors';
5
-
6
- import {
7
- addAllowedCommonJsDependencies,
8
- addAllowSyntheticDefaultImports,
9
- addPackage,
10
- addSchematicCollections,
11
- findFile,
12
- logStart
13
- } from '../../../utils';
14
- import { UpgradeMainVersions } from '../../../utils/versions';
15
-
16
- function fixSchematicCollections(context: SchematicContext): Rule {
17
- return updateWorkspace(async workspace => {
18
- addSchematicCollections(workspace);
19
- logStart(context, `Add schematicCollections you can use 'ng g list' is equivalent to 'ng generate ng-alain:list'`);
20
- });
21
- }
22
-
23
- function addEslintPluginDeprecation(): Rule {
24
- return (tree: Tree, context: SchematicContext) => {
25
- const path = '.eslintrc.js';
26
- if (!tree.exists(path)) return;
27
-
28
- let content = tree.readText(path);
29
- if (content.includes(`['@typescript-eslint', 'jsdoc', 'import']`)) {
30
- content = content.replace(
31
- `['@typescript-eslint', 'jsdoc', 'import']`,
32
- `['@typescript-eslint', 'jsdoc', 'import', 'deprecation']`
33
- );
34
- }
35
- if (content.includes(`'prefer-const': 'off',`)) {
36
- content = content.replace(`'prefer-const': 'off',`, `'prefer-const': 'off',\n'deprecation/deprecation': 'warn',`);
37
- }
38
-
39
- tree.overwrite(path, content);
40
- // add deprecation
41
- addPackage(tree, `eslint-plugin-prettier@~4.2.1`, 'devDependencies');
42
- logStart(context, `Add deprecation warn of eslint`);
43
- };
44
- }
45
-
46
- function fixReuseTabActiviteInHtml(): Rule {
47
- return (tree: Tree, context: SchematicContext) => {
48
- const layoutPath = findFile(tree, 'basic/basic.component.ts');
49
- if (!tree.exists(layoutPath)) return;
50
-
51
- let layoutContent = tree.get(layoutPath)!.content.toString('utf8');
52
- const checkHtml = `<router-outlet (activate)="reuseTab.activate($event)"></router-outlet>`;
53
- if (!layoutContent.includes(checkHtml)) return;
54
-
55
- layoutContent = layoutContent.replace(
56
- checkHtml,
57
- `<router-outlet (activate)="reuseTab.activate($event)" (attach)="reuseTab.activate($event)"></router-outlet>`
58
- );
59
- tree.overwrite(layoutPath, layoutContent);
60
- logStart(context, `Fix can't refresh current item in resut-tab (https://github.com/ng-alain/ng-alain/issues/2302)`);
61
- };
62
- }
63
-
64
- function finished(): Rule {
65
- return (_tree: Tree, context: SchematicContext) => {
66
- context.addTask(new NodePackageInstallTask());
67
-
68
- context.logger.info(
69
- colors.green(
70
- ` ✓ Congratulations, Abort more detail please refer to upgrade guide https://github.com/ng-alain/ng-alain/issues/2285`
71
- )
72
- );
73
- };
74
- }
75
-
76
- export function v14Rule(): Rule {
77
- return async (tree: Tree, context: SchematicContext) => {
78
- logStart(context, `Upgrade @delon/* version number`);
79
- UpgradeMainVersions(tree);
80
- return chain([
81
- addAllowSyntheticDefaultImports(),
82
- // Configuring CommonJS dependencies
83
- // https://angular.io/guide/build#configuring-commonjs-dependencies
84
- addAllowedCommonJsDependencies([]),
85
- fixSchematicCollections(context),
86
- fixReuseTabActiviteInHtml(),
87
- addEslintPluginDeprecation(),
88
- finished()
89
- ]);
90
- };
91
- }