ng-alain 17.3.1 → 18.0.0-beta.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.
- package/application/index.js +5 -5
- package/application/index.js.map +1 -1
- package/application/index.ts +6 -6
- package/collection.json +1 -1
- package/core/lang.config.js +2 -1
- package/core/lang.config.js.map +1 -1
- package/core/lang.config.ts +2 -1
- package/docs/plugin.en-US.md +15 -14
- package/docs/plugin.zh-CN.md +14 -13
- package/edit/index.js.map +1 -1
- package/edit/index.ts +1 -1
- package/empty/index.js.map +1 -1
- package/empty/index.ts +1 -1
- package/list/index.js.map +1 -1
- package/list/index.ts +1 -1
- package/migration.json +4 -4
- package/module/index.js.map +1 -1
- package/module/index.spec.ts +1 -1
- package/module/index.ts +1 -1
- package/ng-add/index.js +1 -1
- package/ng-add/index.js.map +1 -1
- package/ng-add/index.ts +2 -2
- package/ng-update/data/attribute-selectors.js +1 -1
- package/ng-update/data/attribute-selectors.ts +1 -1
- package/ng-update/data/class-names.js +1 -1
- package/ng-update/data/class-names.ts +1 -1
- package/ng-update/data/constructor-checks.js +1 -1
- package/ng-update/data/constructor-checks.ts +1 -1
- package/ng-update/data/css-selectors.js +1 -1
- package/ng-update/data/css-selectors.ts +1 -1
- package/ng-update/data/css-tokens.js +8 -0
- package/ng-update/data/css-tokens.js.map +1 -0
- package/ng-update/data/css-tokens.ts +5 -0
- package/ng-update/data/element-selectors.js +1 -1
- package/ng-update/data/element-selectors.ts +1 -1
- package/ng-update/data/index.js +1 -0
- package/ng-update/data/index.js.map +1 -1
- package/ng-update/data/index.ts +1 -0
- package/ng-update/data/input-names.js +1 -1
- package/ng-update/data/input-names.ts +1 -1
- package/ng-update/data/method-call-checks.js +1 -1
- package/ng-update/data/method-call-checks.ts +1 -1
- package/ng-update/data/output-names.js +1 -1
- package/ng-update/data/output-names.ts +1 -1
- package/ng-update/data/property-names.js +1 -1
- package/ng-update/data/property-names.ts +1 -1
- package/ng-update/index.js +5 -5
- package/ng-update/index.ts +3 -3
- package/ng-update/upgrade-data.js +2 -1
- package/ng-update/upgrade-data.js.map +1 -1
- package/ng-update/upgrade-data.ts +3 -1
- package/ng-update/upgrade-rules/{v17 → V18}/index.js +6 -22
- package/ng-update/upgrade-rules/V18/index.js.map +1 -0
- package/ng-update/upgrade-rules/V18/index.spec.ts +42 -0
- package/ng-update/upgrade-rules/V18/index.ts +25 -0
- package/ng-update/upgrade-rules/V18/remove-ng-less-javascript-enabled-patch.js +23 -0
- package/ng-update/upgrade-rules/V18/remove-ng-less-javascript-enabled-patch.js.map +1 -0
- package/ng-update/upgrade-rules/V18/remove-ng-less-javascript-enabled-patch.ts +24 -0
- package/package.json +3 -3
- package/plugin/index.js +1 -1
- package/plugin/index.js.map +1 -1
- package/plugin/index.ts +1 -1
- package/plugin/plugin.code-style.js.map +1 -1
- package/plugin/plugin.code-style.ts +1 -1
- package/plugin/plugin.default-language.js.map +1 -1
- package/plugin/plugin.default-language.ts +1 -1
- package/plugin/plugin.docker.js.map +1 -1
- package/plugin/plugin.docker.ts +1 -1
- package/plugin/plugin.icon.js.map +1 -1
- package/plugin/plugin.icon.ts +1 -1
- package/plugin/plugin.rtl.js.map +1 -1
- package/plugin/plugin.rtl.ts +1 -1
- package/plugin/plugin.sts.js.map +1 -1
- package/plugin/plugin.sts.ts +1 -1
- package/sta/index.js.map +1 -1
- package/sta/index.ts +2 -2
- package/tpl/index.js.map +1 -1
- package/tpl/index.ts +1 -1
- package/utils/alain.spec.ts +1 -1
- package/utils/lib-versions.js +2 -2
- package/utils/lib-versions.ts +2 -2
- package/utils/testing.js +1 -1
- package/utils/testing.js.map +1 -1
- package/utils/versions.js +20 -20
- package/utils/versions.ts +20 -20
- package/utils/workspace.js +1 -1
- package/utils/workspace.js.map +1 -1
- package/view/index.js.map +1 -1
- package/view/index.ts +1 -1
- package/ng-update/upgrade-rules/v17/angularJson.js +0 -36
- package/ng-update/upgrade-rules/v17/angularJson.js.map +0 -1
- package/ng-update/upgrade-rules/v17/angularJson.ts +0 -23
- package/ng-update/upgrade-rules/v17/autoRegisterFormWidgets.js +0 -46
- package/ng-update/upgrade-rules/v17/autoRegisterFormWidgets.js.map +0 -1
- package/ng-update/upgrade-rules/v17/autoRegisterFormWidgets.ts +0 -52
- package/ng-update/upgrade-rules/v17/files/jsonSchemaModule.js +0 -23
- package/ng-update/upgrade-rules/v17/files/jsonSchemaModule.js.map +0 -1
- package/ng-update/upgrade-rules/v17/files/jsonSchemaModule.ts +0 -20
- package/ng-update/upgrade-rules/v17/index.js.map +0 -1
- package/ng-update/upgrade-rules/v17/index.spec.ts +0 -145
- package/ng-update/upgrade-rules/v17/index.ts +0 -42
- package/ng-update/upgrade-rules/v17/nljep.js +0 -24
- package/ng-update/upgrade-rules/v17/nljep.js.map +0 -1
- package/ng-update/upgrade-rules/v17/nljep.ts +0 -21
- package/ng-update/upgrade-rules/v17/preloader.js +0 -67
- package/ng-update/upgrade-rules/v17/preloader.js.map +0 -1
- package/ng-update/upgrade-rules/v17/preloader.ts +0 -73
- package/ng-update/upgrade-rules/v17/removeForRoot.js +0 -47
- package/ng-update/upgrade-rules/v17/removeForRoot.js.map +0 -1
- package/ng-update/upgrade-rules/v17/removeForRoot.ts +0 -52
- package/ng-update/upgrade-rules/v17/replaceProvideConfig.js +0 -89
- package/ng-update/upgrade-rules/v17/replaceProvideConfig.js.map +0 -1
- package/ng-update/upgrade-rules/v17/replaceProvideConfig.ts +0 -113
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
|
|
2
|
-
|
|
3
|
-
import { logInfo, readPackage, writePackage } from '../../../utils';
|
|
4
|
-
|
|
5
|
-
const PACKAGE_NAME = 'ng-less-javascript-enabled-patch';
|
|
6
|
-
export function addNljep(): Rule {
|
|
7
|
-
return (tree: Tree, context: SchematicContext) => {
|
|
8
|
-
const json = readPackage(tree);
|
|
9
|
-
if (json == null) return;
|
|
10
|
-
if (json.devDependencies[PACKAGE_NAME]) return;
|
|
11
|
-
|
|
12
|
-
if (typeof json.scripts.postinstall !== 'string') json.scripts.postinstall = '';
|
|
13
|
-
if (json.scripts.postinstall.length > 0) json.scripts.postinstall += ' && ';
|
|
14
|
-
json.scripts.postinstall += PACKAGE_NAME;
|
|
15
|
-
|
|
16
|
-
json.devDependencies[PACKAGE_NAME] = '^17.0.0';
|
|
17
|
-
writePackage(tree, json);
|
|
18
|
-
|
|
19
|
-
logInfo(context, `Add [https://github.com/cipchk/${PACKAGE_NAME}] for devDependencies`);
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updatePreloader = void 0;
|
|
4
|
-
const utils_1 = require("../../../utils");
|
|
5
|
-
function updatePreloader() {
|
|
6
|
-
return (tree, context) => {
|
|
7
|
-
addESLintIgnore(tree);
|
|
8
|
-
const angularJson = (0, utils_1.readJSON)(tree, utils_1.DEFAULT_WORKSPACE_PATH);
|
|
9
|
-
const projectNames = Object.keys(angularJson.projects);
|
|
10
|
-
for (const name of projectNames) {
|
|
11
|
-
const sourceRoot = angularJson.projects[name].sourceRoot;
|
|
12
|
-
fixIndexHtml(tree, name, sourceRoot, context);
|
|
13
|
-
run(tree, name, sourceRoot, context);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
exports.updatePreloader = updatePreloader;
|
|
18
|
-
function addESLintIgnore(tree) {
|
|
19
|
-
const filePath = '/.eslintignore';
|
|
20
|
-
if (!tree.exists(filePath))
|
|
21
|
-
return;
|
|
22
|
-
const content = tree.readText(filePath);
|
|
23
|
-
if (!content.includes('**/src/index.html')) {
|
|
24
|
-
tree.overwrite(filePath, `${content}\n**/src/index.html`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function fixIndexHtml(tree, _, sourceRoot, __) {
|
|
28
|
-
const indexPath = `${sourceRoot}/index.html`;
|
|
29
|
-
if (!tree.exists(indexPath))
|
|
30
|
-
return;
|
|
31
|
-
let indexContent = tree.readText(indexPath);
|
|
32
|
-
const selfClose = '<app-root />';
|
|
33
|
-
if (!indexContent.includes(selfClose))
|
|
34
|
-
return;
|
|
35
|
-
tree.overwrite(indexPath, indexContent.replace(selfClose, '<app-root></app-root>'));
|
|
36
|
-
}
|
|
37
|
-
function run(tree, name, sourceRoot, context) {
|
|
38
|
-
// main.ts
|
|
39
|
-
const mainPath = `${sourceRoot}/main.ts`;
|
|
40
|
-
if (!tree.exists(mainPath))
|
|
41
|
-
return;
|
|
42
|
-
let mainContent = tree.readText(mainPath);
|
|
43
|
-
[`import { preloaderFinished } from '@delon/theme';`, 'preloaderFinished();'].forEach(item => {
|
|
44
|
-
if (mainContent.includes(item))
|
|
45
|
-
mainContent = mainContent.replace(item, '');
|
|
46
|
-
});
|
|
47
|
-
tree.overwrite(mainPath, mainContent);
|
|
48
|
-
// app
|
|
49
|
-
const appPath = `${sourceRoot}/app/app.component.ts`;
|
|
50
|
-
if (!tree.exists(appPath))
|
|
51
|
-
return;
|
|
52
|
-
const appContent = tree.readText(appPath);
|
|
53
|
-
if (appContent.includes(', stepPreloader'))
|
|
54
|
-
return;
|
|
55
|
-
const appContentLines = appContent.split('\n');
|
|
56
|
-
const importIndex = appContentLines.findIndex(line => line.includes(', VERSION as VERSION_ALAIN'));
|
|
57
|
-
const addIndex = appContentLines.findIndex(line => line.includes('export class AppComponent'));
|
|
58
|
-
const callDoneIndex = appContentLines.findIndex(line => line.includes('if (ev instanceof NavigationEnd) {'));
|
|
59
|
-
if (importIndex === -1 || addIndex === -1 || callDoneIndex === -1)
|
|
60
|
-
return;
|
|
61
|
-
appContentLines[importIndex] = appContentLines[importIndex].replace(', VERSION as VERSION_ALAIN', ', VERSION as VERSION_ALAIN, stepPreloader');
|
|
62
|
-
appContentLines.splice(addIndex + 1, 0, 'private donePreloader = stepPreloader();');
|
|
63
|
-
appContentLines.splice(callDoneIndex + 2, 0, 'this.donePreloader();');
|
|
64
|
-
tree.overwrite(appPath, appContentLines.join('\n'));
|
|
65
|
-
(0, utils_1.logInfo)(context, `Upgrade preloader in ${name} project`);
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=preloader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preloader.js","sourceRoot":"","sources":["../../../../../schematics/ng-update/upgrade-rules/v17/preloader.ts"],"names":[],"mappings":";;;AAEA,0CAA2E;AAE3E,SAAgB,eAAe;IAC7B,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,eAAe,CAAC,IAAI,CAAC,CAAC;QAEtB,MAAM,WAAW,GAAG,IAAA,gBAAQ,EAAC,IAAI,EAAE,8BAAsB,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACvD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;YAChC,MAAM,UAAU,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;YACzD,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAC9C,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAZD,0CAYC;AAED,SAAS,eAAe,CAAC,IAAU;IACjC,MAAM,QAAQ,GAAG,gBAAgB,CAAC;IAClC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QAAE,OAAO;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC3C,IAAI,CAAC,SAAS,CAAC,QAAQ,EAA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-
import { DEFAULT_WORKSPACE_PATH, logInfo, readJSON } from '../../../utils';
|
|
4
|
-
|
|
5
|
-
export function updatePreloader(): Rule {
|
|
6
|
-
return (tree: Tree, context: SchematicContext) => {
|
|
7
|
-
addESLintIgnore(tree);
|
|
8
|
-
|
|
9
|
-
const angularJson = readJSON(tree, DEFAULT_WORKSPACE_PATH);
|
|
10
|
-
const projectNames = Object.keys(angularJson.projects);
|
|
11
|
-
for (const name of projectNames) {
|
|
12
|
-
const sourceRoot = angularJson.projects[name].sourceRoot;
|
|
13
|
-
fixIndexHtml(tree, name, sourceRoot, context);
|
|
14
|
-
run(tree, name, sourceRoot, context);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function addESLintIgnore(tree: Tree): void {
|
|
20
|
-
const filePath = '/.eslintignore';
|
|
21
|
-
if (!tree.exists(filePath)) return;
|
|
22
|
-
const content = tree.readText(filePath);
|
|
23
|
-
if (!content.includes('**/src/index.html')) {
|
|
24
|
-
tree.overwrite(filePath, `${content}\n**/src/index.html`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function fixIndexHtml(tree: Tree, _: string, sourceRoot: string, __: SchematicContext): void {
|
|
29
|
-
const indexPath = `${sourceRoot}/index.html`;
|
|
30
|
-
if (!tree.exists(indexPath)) return;
|
|
31
|
-
|
|
32
|
-
let indexContent = tree.readText(indexPath);
|
|
33
|
-
|
|
34
|
-
const selfClose = '<app-root />';
|
|
35
|
-
if (!indexContent.includes(selfClose)) return;
|
|
36
|
-
|
|
37
|
-
tree.overwrite(indexPath, indexContent.replace(selfClose, '<app-root></app-root>'));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function run(tree: Tree, name: string, sourceRoot: string, context: SchematicContext): void {
|
|
41
|
-
// main.ts
|
|
42
|
-
const mainPath = `${sourceRoot}/main.ts`;
|
|
43
|
-
if (!tree.exists(mainPath)) return;
|
|
44
|
-
|
|
45
|
-
let mainContent = tree.readText(mainPath);
|
|
46
|
-
[`import { preloaderFinished } from '@delon/theme';`, 'preloaderFinished();'].forEach(item => {
|
|
47
|
-
if (mainContent.includes(item)) mainContent = mainContent.replace(item, '');
|
|
48
|
-
});
|
|
49
|
-
tree.overwrite(mainPath, mainContent);
|
|
50
|
-
|
|
51
|
-
// app
|
|
52
|
-
const appPath = `${sourceRoot}/app/app.component.ts`;
|
|
53
|
-
if (!tree.exists(appPath)) return;
|
|
54
|
-
const appContent = tree.readText(appPath);
|
|
55
|
-
if (appContent.includes(', stepPreloader')) return;
|
|
56
|
-
|
|
57
|
-
const appContentLines = appContent.split('\n');
|
|
58
|
-
const importIndex = appContentLines.findIndex(line => line.includes(', VERSION as VERSION_ALAIN'));
|
|
59
|
-
const addIndex = appContentLines.findIndex(line => line.includes('export class AppComponent'));
|
|
60
|
-
const callDoneIndex = appContentLines.findIndex(line => line.includes('if (ev instanceof NavigationEnd) {'));
|
|
61
|
-
if (importIndex === -1 || addIndex === -1 || callDoneIndex === -1) return;
|
|
62
|
-
|
|
63
|
-
appContentLines[importIndex] = appContentLines[importIndex].replace(
|
|
64
|
-
', VERSION as VERSION_ALAIN',
|
|
65
|
-
', VERSION as VERSION_ALAIN, stepPreloader'
|
|
66
|
-
);
|
|
67
|
-
appContentLines.splice(addIndex + 1, 0, 'private donePreloader = stepPreloader();');
|
|
68
|
-
appContentLines.splice(callDoneIndex + 2, 0, 'this.donePreloader();');
|
|
69
|
-
|
|
70
|
-
tree.overwrite(appPath, appContentLines.join('\n'));
|
|
71
|
-
|
|
72
|
-
logInfo(context, `Upgrade preloader in ${name} project`);
|
|
73
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeForRoot = void 0;
|
|
4
|
-
const utils_1 = require("../../../utils");
|
|
5
|
-
function removeForRoot() {
|
|
6
|
-
return (tree, context) => {
|
|
7
|
-
const angularJson = (0, utils_1.readJSON)(tree, utils_1.DEFAULT_WORKSPACE_PATH);
|
|
8
|
-
const projectNames = Object.keys(angularJson.projects);
|
|
9
|
-
for (const name of projectNames) {
|
|
10
|
-
const sourceRoot = angularJson.projects[name].sourceRoot;
|
|
11
|
-
removeAlainThemeForRoot(tree, name, sourceRoot, context);
|
|
12
|
-
removeAlainThemeForChild(tree, name, sourceRoot, context);
|
|
13
|
-
removeDelonACLModuleForRoot(tree, name, sourceRoot, context);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
exports.removeForRoot = removeForRoot;
|
|
18
|
-
function removeAlainThemeForRoot(tree, name, sourceRoot, context) {
|
|
19
|
-
const modulePath = `${sourceRoot}/app/global-config.module.ts`;
|
|
20
|
-
if (!tree.exists(modulePath))
|
|
21
|
-
return;
|
|
22
|
-
const content = tree.readText(modulePath).replace(/AlainThemeModule\.forRoot\(\),?/g, '');
|
|
23
|
-
tree.overwrite(modulePath, content);
|
|
24
|
-
(0, utils_1.logInfo)(context, `Remove AlainThemeModule.forRoot in ${name} project`);
|
|
25
|
-
}
|
|
26
|
-
function removeAlainThemeForChild(tree, name, sourceRoot, context) {
|
|
27
|
-
const forChild = 'AlainThemeModule.forChild()';
|
|
28
|
-
tree.visit((path, entry) => {
|
|
29
|
-
if (!entry || !path.endsWith('.ts') || !path.startsWith(sourceRoot))
|
|
30
|
-
return;
|
|
31
|
-
const content = tree.readText(path);
|
|
32
|
-
if (!content.includes(forChild))
|
|
33
|
-
return;
|
|
34
|
-
tree.overwrite(path, content.replace(forChild, 'AlainThemeModule'));
|
|
35
|
-
});
|
|
36
|
-
(0, utils_1.logInfo)(context, `Remove ${forChild} in ${name} project`);
|
|
37
|
-
}
|
|
38
|
-
function removeDelonACLModuleForRoot(tree, name, sourceRoot, context) {
|
|
39
|
-
const modulePath = `${sourceRoot}/app/global-config.module.ts`;
|
|
40
|
-
if (!tree.exists(modulePath))
|
|
41
|
-
return;
|
|
42
|
-
const forRoot = 'DelonACLModule.forRoot()';
|
|
43
|
-
const content = tree.readText(modulePath);
|
|
44
|
-
tree.overwrite(modulePath, content.replace(/DelonACLModule\.forRoot\(\),?/g, ''));
|
|
45
|
-
(0, utils_1.logInfo)(context, `Remove ${forRoot} in ${name} project`);
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=removeForRoot.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"removeForRoot.js","sourceRoot":"","sources":["../../../../../schematics/ng-update/upgrade-rules/v17/removeForRoot.ts"],"names":[],"mappings":";;;AAEA,0CAA2E;AAE3E,SAAgB,aAAa;IAC3B,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,WAAW,GAAG,IAAA,gBAAQ,EAAC,IAAI,EAAE,8BAAsB,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACvD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;YAChC,MAAM,UAAU,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;YACzD,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YACzD,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAC1D,2BAA2B,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAXD,sCAWC;AAED,SAAS,uBAAuB,CAAC,IAAU,EAAE,IAAY,EAAE,UAAkB,EAAE,OAAyB;IACtG,MAAM,UAAU,GAAG,GAAG,UAAU,8BAA8B,CAAC;IAC/D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QAAE,OAAO;IAErC,MAAM,OAAO,GAAG,IA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EAAE,OAAO,CAAC,OAAO,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAC,CAAC;IAElF,IAAA,eAAO,EAAC,OAAO,EAAE,UAAU,OAAO,OAAO,IAAI,UAAU,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
|
|
2
|
-
|
|
3
|
-
import { DEFAULT_WORKSPACE_PATH, logInfo, readJSON } from '../../../utils';
|
|
4
|
-
|
|
5
|
-
export function removeForRoot(): Rule {
|
|
6
|
-
return (tree: Tree, context: SchematicContext) => {
|
|
7
|
-
const angularJson = readJSON(tree, DEFAULT_WORKSPACE_PATH);
|
|
8
|
-
const projectNames = Object.keys(angularJson.projects);
|
|
9
|
-
for (const name of projectNames) {
|
|
10
|
-
const sourceRoot = angularJson.projects[name].sourceRoot;
|
|
11
|
-
removeAlainThemeForRoot(tree, name, sourceRoot, context);
|
|
12
|
-
removeAlainThemeForChild(tree, name, sourceRoot, context);
|
|
13
|
-
removeDelonACLModuleForRoot(tree, name, sourceRoot, context);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function removeAlainThemeForRoot(tree: Tree, name: string, sourceRoot: string, context: SchematicContext): void {
|
|
19
|
-
const modulePath = `${sourceRoot}/app/global-config.module.ts`;
|
|
20
|
-
if (!tree.exists(modulePath)) return;
|
|
21
|
-
|
|
22
|
-
const content = tree.readText(modulePath).replace(/AlainThemeModule\.forRoot\(\),?/g, '');
|
|
23
|
-
tree.overwrite(modulePath, content);
|
|
24
|
-
|
|
25
|
-
logInfo(context, `Remove AlainThemeModule.forRoot in ${name} project`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function removeAlainThemeForChild(tree: Tree, name: string, sourceRoot: string, context: SchematicContext): void {
|
|
29
|
-
const forChild = 'AlainThemeModule.forChild()';
|
|
30
|
-
|
|
31
|
-
tree.visit((path, entry) => {
|
|
32
|
-
if (!entry || !path.endsWith('.ts') || !path.startsWith(sourceRoot)) return;
|
|
33
|
-
|
|
34
|
-
const content = tree.readText(path);
|
|
35
|
-
if (!content.includes(forChild)) return;
|
|
36
|
-
|
|
37
|
-
tree.overwrite(path, content.replace(forChild, 'AlainThemeModule'));
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
logInfo(context, `Remove ${forChild} in ${name} project`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function removeDelonACLModuleForRoot(tree: Tree, name: string, sourceRoot: string, context: SchematicContext): void {
|
|
44
|
-
const modulePath = `${sourceRoot}/app/global-config.module.ts`;
|
|
45
|
-
if (!tree.exists(modulePath)) return;
|
|
46
|
-
|
|
47
|
-
const forRoot = 'DelonACLModule.forRoot()';
|
|
48
|
-
const content = tree.readText(modulePath);
|
|
49
|
-
tree.overwrite(modulePath, content.replace(/DelonACLModule\.forRoot\(\),?/g, ''));
|
|
50
|
-
|
|
51
|
-
logInfo(context, `Remove ${forRoot} in ${name} project`);
|
|
52
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replaceProvideConfig = void 0;
|
|
4
|
-
const utils_1 = require("../../../utils");
|
|
5
|
-
function replaceProvideConfig() {
|
|
6
|
-
return (tree, context) => {
|
|
7
|
-
const angularJson = (0, utils_1.readJSON)(tree, utils_1.DEFAULT_WORKSPACE_PATH);
|
|
8
|
-
const projectNames = Object.keys(angularJson.projects);
|
|
9
|
-
(0, utils_1.logInfo)(context, `Use provider style (TIPS: References need to be fixed manually)`);
|
|
10
|
-
for (const name of projectNames) {
|
|
11
|
-
runAlain(tree, name, angularJson.projects[name].sourceRoot, context);
|
|
12
|
-
runZorro(tree, name, angularJson.projects[name].sourceRoot, context);
|
|
13
|
-
delonMock(tree, name, angularJson.projects[name].sourceRoot, context);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
exports.replaceProvideConfig = replaceProvideConfig;
|
|
18
|
-
function runAlain(tree, name, sourceRoot, context) {
|
|
19
|
-
const filePath = `${sourceRoot}/app/global-config.module.ts`;
|
|
20
|
-
if (!tree.exists(filePath))
|
|
21
|
-
return;
|
|
22
|
-
const text = '{ provide: ALAIN_CONFIG, useValue: alainConfig }';
|
|
23
|
-
const content = tree
|
|
24
|
-
.readText(filePath)
|
|
25
|
-
.replace(text, 'provideAlain({ config: alainConfig })')
|
|
26
|
-
.replace('AlainThemeModule', 'provideAlain');
|
|
27
|
-
tree.overwrite(filePath, content);
|
|
28
|
-
(0, utils_1.logInfo)(context, ` Use provideAlain instead of ALAIN_CONFIG in ${name} project`);
|
|
29
|
-
}
|
|
30
|
-
function runZorro(tree, name, sourceRoot, context) {
|
|
31
|
-
const filePath = `${sourceRoot}/app/global-config.module.ts`;
|
|
32
|
-
if (!tree.exists(filePath))
|
|
33
|
-
return;
|
|
34
|
-
const text = '{ provide: provideNzConfig, useValue: ngZorroConfig }';
|
|
35
|
-
const content = tree.readText(filePath).replace(text, 'provideNzConfig(ngZorroConfig)');
|
|
36
|
-
tree.overwrite(filePath, content);
|
|
37
|
-
(0, utils_1.logInfo)(context, ` Use provideNzConfig instead of NzConfig in ${name} project`);
|
|
38
|
-
}
|
|
39
|
-
function delonMock(tree, name, sourceRoot, context) {
|
|
40
|
-
const filePath = `${sourceRoot}/environments/environment.ts`;
|
|
41
|
-
if (!tree.exists(filePath))
|
|
42
|
-
return;
|
|
43
|
-
const text = 'DelonMockModule.forRoot({ data: MOCKDATA })';
|
|
44
|
-
let content = tree.readText(filePath);
|
|
45
|
-
if (content.includes(text))
|
|
46
|
-
content = content.replace(text, '');
|
|
47
|
-
content = content
|
|
48
|
-
.replace('modules: [', 'providers: [provideMockConfig({ data: MOCKDATA })], \ninterceptorFns: [mockInterceptor],\nmodules: [')
|
|
49
|
-
.replace('DelonMockModule', 'provideMockConfig, mockInterceptor');
|
|
50
|
-
tree.overwrite(filePath, content);
|
|
51
|
-
// remove HttpClientModule
|
|
52
|
-
let useAuthType = '';
|
|
53
|
-
const appModuleFile = `${sourceRoot}/app/app.module.ts`;
|
|
54
|
-
if (tree.exists(appModuleFile)) {
|
|
55
|
-
let appModuleContent = tree.readText(appModuleFile);
|
|
56
|
-
if (appModuleContent.includes('JWTInterceptor')) {
|
|
57
|
-
useAuthType = 'jwt';
|
|
58
|
-
appModuleContent = appModuleContent
|
|
59
|
-
.replace(`{ provide: HTTP_INTERCEPTORS, useClass: JWTInterceptor, multi: true }`, `// { provide: HTTP_INTERCEPTORS, useClass: JWTInterceptor, multi: true }`)
|
|
60
|
-
.replace(`import { JWTInterceptor } from '@delon/auth';`, `// import { JWTInterceptor } from '@delon/auth';`);
|
|
61
|
-
}
|
|
62
|
-
else if (appModuleContent.includes('SimpleInterceptor')) {
|
|
63
|
-
useAuthType = 'simple';
|
|
64
|
-
appModuleContent = appModuleContent
|
|
65
|
-
.replace(`{ provide: HTTP_INTERCEPTORS, useClass: SimpleInterceptor, multi: true }`, `// { provide: HTTP_INTERCEPTORS, useClass: SimpleInterceptor, multi: true }`)
|
|
66
|
-
.replace(`import { SimpleInterceptor } from '@delon/auth';`, `// import { SimpleInterceptor } from '@delon/auth';`);
|
|
67
|
-
}
|
|
68
|
-
appModuleContent = appModuleContent
|
|
69
|
-
.replace(`import { HttpClientModule } from '@angular/common/http';`, '')
|
|
70
|
-
.replace(/HttpClientModule,?/g, '');
|
|
71
|
-
tree.overwrite(appModuleFile, appModuleContent);
|
|
72
|
-
}
|
|
73
|
-
const globalFile = `${sourceRoot}/app/global-config.module.ts`;
|
|
74
|
-
if (tree.exists(globalFile)) {
|
|
75
|
-
// SimpleInterceptor -> authSimpleInterceptor
|
|
76
|
-
// JWTInterceptor -> authJWTInterceptor
|
|
77
|
-
let globalContent = tree.readText(globalFile);
|
|
78
|
-
let authInterceptor = '';
|
|
79
|
-
if (useAuthType === 'jwt') {
|
|
80
|
-
authInterceptor = ', authJWTInterceptor';
|
|
81
|
-
}
|
|
82
|
-
else if (useAuthType === 'simple') {
|
|
83
|
-
authInterceptor = ', authSimpleInterceptor';
|
|
84
|
-
}
|
|
85
|
-
tree.overwrite(globalFile, globalContent.replace(', ...zorroProvides', `, ...zorroProvides, ...(environment.providers || []), \nprovideHttpClient(withInterceptors([...(environment.interceptorFns || [])${authInterceptor}]), withInterceptorsFromDi())`));
|
|
86
|
-
}
|
|
87
|
-
(0, utils_1.logInfo)(context, ` Use provideMockConfig instead of DelonMockModule in ${name} project`);
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=replaceProvideConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replaceProvideConfig.js","sourceRoot":"","sources":["../../../../../schematics/ng-update/upgrade-rules/v17/replaceProvideConfig.ts"],"names":[],"mappings":";;;AAEA,0CAA2E;AAE3E,SAAgB,oBAAoB;IAClC,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,WAAW,GAAG,IAAA,gBAAQ,EAAC,IAAI,EAAE,8BAAsB,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACvD,IAAA,eAAO,EAAC,OAAO,EAAE,iEAAiE,CAAC,CAAC;QACpF,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;YAChC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACrE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACrE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,OAAO,C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vE,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;QAEtC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,UAAU,GAAG,GAAG,UAAU,8BAA8B,CAAC;IAC/D,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,6CAA6C;QAC7C,uCAAuC;QACvC,IAAI,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC9C,IAAI,eAAe,GAAG,EAAE,CAAC;QACzB,IAAI,WAAW,KAAK,KAAK,EAAE,CAAC;YAC1B,eAAe,GAAG,sBAAsB,CAAC;QAC3C,CAAC;aAAM,IAAI,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpC,eAAe,GAAG,yBAAyB,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,SAAS,CACZ,UAAU,EACV,aAAa,CAAC,OAAO,CACnB,oBAAoB,EACpB,oIAAoI,eAAe,+BAA+B,CACnL,CACF,CAAC;IACJ,CAAC;IAED,IAAA,eAAO,EAAC,OAAO,EAAE,yDAAyD,IAAI,UAAU,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
|
|
2
|
-
|
|
3
|
-
import { DEFAULT_WORKSPACE_PATH, logInfo, readJSON } from '../../../utils';
|
|
4
|
-
|
|
5
|
-
export function replaceProvideConfig(): Rule {
|
|
6
|
-
return (tree: Tree, context: SchematicContext) => {
|
|
7
|
-
const angularJson = readJSON(tree, DEFAULT_WORKSPACE_PATH);
|
|
8
|
-
const projectNames = Object.keys(angularJson.projects);
|
|
9
|
-
logInfo(context, `Use provider style (TIPS: References need to be fixed manually)`);
|
|
10
|
-
for (const name of projectNames) {
|
|
11
|
-
runAlain(tree, name, angularJson.projects[name].sourceRoot, context);
|
|
12
|
-
runZorro(tree, name, angularJson.projects[name].sourceRoot, context);
|
|
13
|
-
delonMock(tree, name, angularJson.projects[name].sourceRoot, context);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function runAlain(tree: Tree, name: string, sourceRoot: string, context: SchematicContext): void {
|
|
19
|
-
const filePath = `${sourceRoot}/app/global-config.module.ts`;
|
|
20
|
-
if (!tree.exists(filePath)) return;
|
|
21
|
-
|
|
22
|
-
const text = '{ provide: ALAIN_CONFIG, useValue: alainConfig }';
|
|
23
|
-
const content = tree
|
|
24
|
-
.readText(filePath)
|
|
25
|
-
.replace(text, 'provideAlain({ config: alainConfig })')
|
|
26
|
-
.replace('AlainThemeModule', 'provideAlain');
|
|
27
|
-
tree.overwrite(filePath, content);
|
|
28
|
-
|
|
29
|
-
logInfo(context, ` Use provideAlain instead of ALAIN_CONFIG in ${name} project`);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function runZorro(tree: Tree, name: string, sourceRoot: string, context: SchematicContext): void {
|
|
33
|
-
const filePath = `${sourceRoot}/app/global-config.module.ts`;
|
|
34
|
-
if (!tree.exists(filePath)) return;
|
|
35
|
-
|
|
36
|
-
const text = '{ provide: provideNzConfig, useValue: ngZorroConfig }';
|
|
37
|
-
const content = tree.readText(filePath).replace(text, 'provideNzConfig(ngZorroConfig)');
|
|
38
|
-
tree.overwrite(filePath, content);
|
|
39
|
-
|
|
40
|
-
logInfo(context, ` Use provideNzConfig instead of NzConfig in ${name} project`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function delonMock(tree: Tree, name: string, sourceRoot: string, context: SchematicContext): void {
|
|
44
|
-
const filePath = `${sourceRoot}/environments/environment.ts`;
|
|
45
|
-
if (!tree.exists(filePath)) return;
|
|
46
|
-
|
|
47
|
-
const text = 'DelonMockModule.forRoot({ data: MOCKDATA })';
|
|
48
|
-
let content = tree.readText(filePath);
|
|
49
|
-
if (content.includes(text)) content = content.replace(text, '');
|
|
50
|
-
|
|
51
|
-
content = content
|
|
52
|
-
.replace(
|
|
53
|
-
'modules: [',
|
|
54
|
-
'providers: [provideMockConfig({ data: MOCKDATA })], \ninterceptorFns: [mockInterceptor],\nmodules: ['
|
|
55
|
-
)
|
|
56
|
-
.replace('DelonMockModule', 'provideMockConfig, mockInterceptor');
|
|
57
|
-
|
|
58
|
-
tree.overwrite(filePath, content);
|
|
59
|
-
|
|
60
|
-
// remove HttpClientModule
|
|
61
|
-
let useAuthType = '';
|
|
62
|
-
const appModuleFile = `${sourceRoot}/app/app.module.ts`;
|
|
63
|
-
if (tree.exists(appModuleFile)) {
|
|
64
|
-
let appModuleContent = tree.readText(appModuleFile);
|
|
65
|
-
if (appModuleContent.includes('JWTInterceptor')) {
|
|
66
|
-
useAuthType = 'jwt';
|
|
67
|
-
appModuleContent = appModuleContent
|
|
68
|
-
.replace(
|
|
69
|
-
`{ provide: HTTP_INTERCEPTORS, useClass: JWTInterceptor, multi: true }`,
|
|
70
|
-
`// { provide: HTTP_INTERCEPTORS, useClass: JWTInterceptor, multi: true }`
|
|
71
|
-
)
|
|
72
|
-
.replace(`import { JWTInterceptor } from '@delon/auth';`, `// import { JWTInterceptor } from '@delon/auth';`);
|
|
73
|
-
} else if (appModuleContent.includes('SimpleInterceptor')) {
|
|
74
|
-
useAuthType = 'simple';
|
|
75
|
-
appModuleContent = appModuleContent
|
|
76
|
-
.replace(
|
|
77
|
-
`{ provide: HTTP_INTERCEPTORS, useClass: SimpleInterceptor, multi: true }`,
|
|
78
|
-
`// { provide: HTTP_INTERCEPTORS, useClass: SimpleInterceptor, multi: true }`
|
|
79
|
-
)
|
|
80
|
-
.replace(
|
|
81
|
-
`import { SimpleInterceptor } from '@delon/auth';`,
|
|
82
|
-
`// import { SimpleInterceptor } from '@delon/auth';`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
appModuleContent = appModuleContent
|
|
86
|
-
.replace(`import { HttpClientModule } from '@angular/common/http';`, '')
|
|
87
|
-
.replace(/HttpClientModule,?/g, '');
|
|
88
|
-
|
|
89
|
-
tree.overwrite(appModuleFile, appModuleContent);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const globalFile = `${sourceRoot}/app/global-config.module.ts`;
|
|
93
|
-
if (tree.exists(globalFile)) {
|
|
94
|
-
// SimpleInterceptor -> authSimpleInterceptor
|
|
95
|
-
// JWTInterceptor -> authJWTInterceptor
|
|
96
|
-
let globalContent = tree.readText(globalFile);
|
|
97
|
-
let authInterceptor = '';
|
|
98
|
-
if (useAuthType === 'jwt') {
|
|
99
|
-
authInterceptor = ', authJWTInterceptor';
|
|
100
|
-
} else if (useAuthType === 'simple') {
|
|
101
|
-
authInterceptor = ', authSimpleInterceptor';
|
|
102
|
-
}
|
|
103
|
-
tree.overwrite(
|
|
104
|
-
globalFile,
|
|
105
|
-
globalContent.replace(
|
|
106
|
-
', ...zorroProvides',
|
|
107
|
-
`, ...zorroProvides, ...(environment.providers || []), \nprovideHttpClient(withInterceptors([...(environment.interceptorFns || [])${authInterceptor}]), withInterceptorsFromDi())`
|
|
108
|
-
)
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
logInfo(context, ` Use provideMockConfig instead of DelonMockModule in ${name} project`);
|
|
113
|
-
}
|