devextreme-schematics 1.11.1 → 1.12.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/README.md +27 -0
- package/package.json +7 -4
- package/src/add-app-template/index_spec.js +24 -1
- package/src/add-app-template/index_spec.js.map +1 -1
- package/src/add-app-template/schema.json +1 -1
- package/src/add-layout/files/src/app/shared/services/theme.service.ts +4 -5
- package/src/add-layout/index_spec.js +24 -1
- package/src/add-layout/index_spec.js.map +1 -1
- package/src/add-sample-views/index_spec.js +24 -1
- package/src/add-sample-views/index_spec.js.map +1 -1
- package/src/add-view/index_spec.js +24 -1
- package/src/add-view/index_spec.js.map +1 -1
- package/src/collection.json +5 -0
- package/src/install/index.js +9 -0
- package/src/install/index.js.map +1 -1
- package/src/install/index.ts +10 -0
- package/src/install/index_spec.js +24 -1
- package/src/install/index_spec.js.map +1 -1
- package/src/install/schema.json +1 -1
- package/src/migrate-config-components/README.md +87 -0
- package/src/migrate-config-components/index.d.ts +7 -0
- package/src/migrate-config-components/index.js +80 -0
- package/src/migrate-config-components/index.js.map +1 -0
- package/src/migrate-config-components/index.ts +80 -0
- package/src/migrate-config-components/mappings/deprecated-config-map.json +1088 -0
- package/src/migrate-config-components/schema.json +28 -0
- package/src/migrate-config-components/template-migrator.d.ts +22 -0
- package/src/migrate-config-components/template-migrator.js +317 -0
- package/src/migrate-config-components/template-migrator.js.map +1 -0
- package/src/migrate-config-components/template-migrator.ts +333 -0
- package/src/utility/latest-versions.d.ts +1 -0
- package/src/utility/latest-versions.js +4 -3
- package/src/utility/latest-versions.js.map +1 -1
- package/src/utility/latest-versions.ts +4 -3
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.migrateConfigComponents = void 0;
|
|
16
|
+
const template_migrator_1 = require("./template-migrator");
|
|
17
|
+
const deprecated_config_map_json_1 = __importDefault(require("./mappings/deprecated-config-map.json"));
|
|
18
|
+
function migrateConfigComponents(options = {}) {
|
|
19
|
+
// Accept --include as array or comma-separated string
|
|
20
|
+
let include = ['**/*.html'];
|
|
21
|
+
const rawInclude = options.include;
|
|
22
|
+
if (Array.isArray(rawInclude) && rawInclude.length) {
|
|
23
|
+
include = rawInclude;
|
|
24
|
+
}
|
|
25
|
+
else if (typeof rawInclude === 'string' && rawInclude) {
|
|
26
|
+
let str = rawInclude.trim();
|
|
27
|
+
if (str.startsWith('[') && str.endsWith(']')) {
|
|
28
|
+
str = str.slice(1, -1);
|
|
29
|
+
}
|
|
30
|
+
include = str.split(',').map((s) => s.trim()).filter((s) => !!s);
|
|
31
|
+
}
|
|
32
|
+
// Coerce string 'true'/'false' to boolean for dry option
|
|
33
|
+
let dryFlag = false;
|
|
34
|
+
if (typeof options.dry === 'string') {
|
|
35
|
+
dryFlag = options.dry === 'true';
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
dryFlag = !!options.dry;
|
|
39
|
+
}
|
|
40
|
+
// Accept --script-include as array or comma-separated string
|
|
41
|
+
let scriptGlobs = ['**/*.ts', '**/*.js'];
|
|
42
|
+
const rawScriptInclude = options.scriptInclude;
|
|
43
|
+
if (Array.isArray(rawScriptInclude) && rawScriptInclude.length) {
|
|
44
|
+
scriptGlobs = rawScriptInclude;
|
|
45
|
+
}
|
|
46
|
+
else if (typeof rawScriptInclude === 'string' && rawScriptInclude) {
|
|
47
|
+
let str = rawScriptInclude.trim();
|
|
48
|
+
if (str.startsWith('[') && str.endsWith(']')) {
|
|
49
|
+
str = str.slice(1, -1);
|
|
50
|
+
}
|
|
51
|
+
scriptGlobs = str.split(',').map((s) => s.trim()).filter((s) => !!s);
|
|
52
|
+
}
|
|
53
|
+
return (tree, ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
ctx.logger.info(`[config-migrator] Starting…`);
|
|
55
|
+
const hostMap = deprecated_config_map_json_1.default;
|
|
56
|
+
const processedMapping = Object.entries(hostMap).map(([hostComponentName, map]) => {
|
|
57
|
+
var _a;
|
|
58
|
+
const hostSelector = (_a = map._hostSelector) !== null && _a !== void 0 ? _a : componentToSelectorGuess(hostComponentName);
|
|
59
|
+
const configMap = Object.fromEntries(Object.entries(map).filter(([k]) => k !== '_hostSelector'));
|
|
60
|
+
return { hostSelector, configMap };
|
|
61
|
+
});
|
|
62
|
+
// External HTML templates
|
|
63
|
+
yield (0, template_migrator_1.applyHostAwareTemplateMigrations)(tree, {
|
|
64
|
+
includeGlobs: include,
|
|
65
|
+
rules: processedMapping
|
|
66
|
+
}, { dryRun: dryFlag, logger: ctx.logger });
|
|
67
|
+
// Inline templates inside component decorators (ts/js)
|
|
68
|
+
yield (0, template_migrator_1.applyInlineComponentTemplateMigrations)(tree, {
|
|
69
|
+
includeGlobs: [], rules: processedMapping
|
|
70
|
+
}, { dryRun: dryFlag, logger: ctx.logger }, scriptGlobs);
|
|
71
|
+
ctx.logger.info(`[config-migrator] Done.`);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
exports.migrateConfigComponents = migrateConfigComponents;
|
|
75
|
+
// Fallback if _hostSelector is missing: "DxFooBarComponent" -> "dx-foo-bar"
|
|
76
|
+
function componentToSelectorGuess(componentName) {
|
|
77
|
+
const core = componentName.replace(/Component$/, '').replace(/^Dx/, 'dx-');
|
|
78
|
+
return core.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,2DAA+G;AAC/G,uGAA4D;AAQ5D,SAAgB,uBAAuB,CAAC,UAAmB,EAAE;IAC3D,sDAAsD;IACtD,IAAI,OAAO,GAAa,CAAC,WAAW,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IACnC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE;QAClD,OAAO,GAAG,UAAU,CAAC;KACtB;SAAM,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,EAAE;QACvD,IAAI,GAAG,GAAI,UAAqB,CAAC,IAAI,EAAE,CAAC;QACxC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC5C,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SACxB;QACD,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAClF;IAED,yDAAyD;IACzD,IAAI,OAAO,GAAY,KAAK,CAAC;IAC7B,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,EAAE;QACnC,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,CAAC,iBAAiB,CAAC,CAAC;YACtF,MAAM,SAAS,GAA2B,MAAM,CAAC,WAAW,CAC1D,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,eAAe,CAAC,CAC3D,CAAC;YACF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;QACrC,CAAC,CAAe,CAAC;QAEjB,0BAA0B;QAC1B,MAAM,IAAA,oDAAgC,EAAC,IAAI,EAAE;YAC3C,YAAY,EAAE,OAAO;YACrB,KAAK,EAAE,gBAAgB;SACxB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QAE5C,uDAAuD;QACvD,MAAM,IAAA,0DAAsC,EAAC,IAAI,EAAE;YACjD,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,gBAAgB;SAC1C,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC,CAAC;QAEzD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC,CAAA,CAAC;AACJ,CAAC;AA9DD,0DA8DC;AAED,4EAA4E;AAC5E,SAAS,wBAAwB,CAAC,aAAqB;IACrD,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC3E,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Rule, Tree, SchematicContext } from '@angular-devkit/schematics';
|
|
2
|
+
import type { HostRule } from './template-migrator';
|
|
3
|
+
import { applyHostAwareTemplateMigrations, applyInlineComponentTemplateMigrations } from './template-migrator';
|
|
4
|
+
import mapping from './mappings/deprecated-config-map.json';
|
|
5
|
+
|
|
6
|
+
export interface Options {
|
|
7
|
+
include?: string[];
|
|
8
|
+
dry?: boolean;
|
|
9
|
+
scriptInclude?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function migrateConfigComponents(options: Options = {}): Rule {
|
|
13
|
+
// Accept --include as array or comma-separated string
|
|
14
|
+
let include: string[] = ['**/*.html'];
|
|
15
|
+
const rawInclude = options.include;
|
|
16
|
+
if (Array.isArray(rawInclude) && rawInclude.length) {
|
|
17
|
+
include = rawInclude;
|
|
18
|
+
} else if (typeof rawInclude === 'string' && rawInclude) {
|
|
19
|
+
let str = (rawInclude as string).trim();
|
|
20
|
+
if (str.startsWith('[') && str.endsWith(']')) {
|
|
21
|
+
str = str.slice(1, -1);
|
|
22
|
+
}
|
|
23
|
+
include = str.split(',').map((s: string) => s.trim()).filter((s: string) => !!s);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Coerce string 'true'/'false' to boolean for dry option
|
|
27
|
+
let dryFlag: boolean = false;
|
|
28
|
+
if (typeof options.dry === 'string') {
|
|
29
|
+
dryFlag = options.dry === 'true';
|
|
30
|
+
} else {
|
|
31
|
+
dryFlag = !!options.dry;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Accept --script-include as array or comma-separated string
|
|
35
|
+
let scriptGlobs: string[] = ['**/*.ts', '**/*.js'];
|
|
36
|
+
const rawScriptInclude = options.scriptInclude;
|
|
37
|
+
if (Array.isArray(rawScriptInclude) && rawScriptInclude.length) {
|
|
38
|
+
scriptGlobs = rawScriptInclude;
|
|
39
|
+
} else if (typeof rawScriptInclude === 'string' && rawScriptInclude) {
|
|
40
|
+
let str = (rawScriptInclude as string).trim();
|
|
41
|
+
if (str.startsWith('[') && str.endsWith(']')) {
|
|
42
|
+
str = str.slice(1, -1);
|
|
43
|
+
}
|
|
44
|
+
scriptGlobs = str.split(',').map((s: string) => s.trim()).filter((s: string) => !!s);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return async (tree: Tree, ctx: SchematicContext): Promise<void> => {
|
|
48
|
+
ctx.logger.info(`[config-migrator] Starting…`);
|
|
49
|
+
|
|
50
|
+
type HostMap = Record<string, { _hostSelector?: string } & Record<string, string>>;
|
|
51
|
+
const hostMap = mapping as unknown as HostMap;
|
|
52
|
+
|
|
53
|
+
const processedMapping = Object.entries(hostMap).map(([hostComponentName, map]) => {
|
|
54
|
+
const hostSelector = map._hostSelector ?? componentToSelectorGuess(hostComponentName);
|
|
55
|
+
const configMap: Record<string, string> = Object.fromEntries(
|
|
56
|
+
Object.entries(map).filter(([k]) => k !== '_hostSelector')
|
|
57
|
+
);
|
|
58
|
+
return { hostSelector, configMap };
|
|
59
|
+
}) as HostRule[];
|
|
60
|
+
|
|
61
|
+
// External HTML templates
|
|
62
|
+
await applyHostAwareTemplateMigrations(tree, {
|
|
63
|
+
includeGlobs: include,
|
|
64
|
+
rules: processedMapping
|
|
65
|
+
}, { dryRun: dryFlag, logger: ctx.logger });
|
|
66
|
+
|
|
67
|
+
// Inline templates inside component decorators (ts/js)
|
|
68
|
+
await applyInlineComponentTemplateMigrations(tree, {
|
|
69
|
+
includeGlobs: [], rules: processedMapping
|
|
70
|
+
}, { dryRun: dryFlag, logger: ctx.logger }, scriptGlobs);
|
|
71
|
+
|
|
72
|
+
ctx.logger.info(`[config-migrator] Done.`);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Fallback if _hostSelector is missing: "DxFooBarComponent" -> "dx-foo-bar"
|
|
77
|
+
function componentToSelectorGuess(componentName: string): string {
|
|
78
|
+
const core = componentName.replace(/Component$/, '').replace(/^Dx/, 'dx-');
|
|
79
|
+
return core.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
80
|
+
}
|