devextreme-schematics 1.11.2 → 1.12.1
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 +34 -6
- package/package.json +6 -3
- 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/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_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 +74 -0
- package/src/migrate-config-components/index.d.ts +7 -0
- package/src/migrate-config-components/index.js +71 -0
- package/src/migrate-config-components/index.js.map +1 -0
- package/src/migrate-config-components/index.ts +77 -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 +301 -0
- package/src/migrate-config-components/template-migrator.js.map +1 -0
- package/src/migrate-config-components/template-migrator.ts +320 -0
- package/src/utility/latest-versions.js +2 -2
- package/src/utility/latest-versions.ts +2 -2
- package/src/utility/typescript-resolver.d.ts +12 -0
- package/src/utility/typescript-resolver.js +153 -0
- package/src/utility/typescript-resolver.js.map +1 -0
- package/src/utility/typescript-resolver.ts +144 -0
|
@@ -0,0 +1,77 @@
|
|
|
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 | string[];
|
|
8
|
+
dry?: boolean | string;
|
|
9
|
+
scriptInclude?: string | string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function migrateConfigComponents(options: Options = {}): Rule {
|
|
13
|
+
const include = normalizeGlobOption(options.include, ['**/*.html']);
|
|
14
|
+
const dryFlag = normalizeBoolean(options.dry);
|
|
15
|
+
const scriptGlobs = normalizeGlobOption(options.scriptInclude, ['**/*.ts', '**/*.js']);
|
|
16
|
+
|
|
17
|
+
return async (tree: Tree, ctx: SchematicContext): Promise<void> => {
|
|
18
|
+
ctx.logger.info(`[config-migrator] Starting…`);
|
|
19
|
+
|
|
20
|
+
type HostMap = Record<string, { _hostSelector?: string } & Record<string, string>>;
|
|
21
|
+
const hostMap = mapping as unknown as HostMap;
|
|
22
|
+
|
|
23
|
+
const processedMapping = Object.entries(hostMap).map(([hostComponentName, map]) => {
|
|
24
|
+
const hostSelector = map._hostSelector ?? componentToSelectorGuess(hostComponentName);
|
|
25
|
+
const configMap: Record<string, string> = Object.fromEntries(
|
|
26
|
+
Object.entries(map).filter(([k]) => k !== '_hostSelector')
|
|
27
|
+
);
|
|
28
|
+
return { hostSelector, configMap };
|
|
29
|
+
}) as HostRule[];
|
|
30
|
+
|
|
31
|
+
// External HTML templates
|
|
32
|
+
await applyHostAwareTemplateMigrations(tree, {
|
|
33
|
+
includeGlobs: include,
|
|
34
|
+
rules: processedMapping
|
|
35
|
+
}, { dryRun: dryFlag, logger: ctx.logger });
|
|
36
|
+
|
|
37
|
+
// Inline templates inside component decorators (ts/js)
|
|
38
|
+
await applyInlineComponentTemplateMigrations(tree, {
|
|
39
|
+
includeGlobs: [], rules: processedMapping
|
|
40
|
+
}, { dryRun: dryFlag, logger: ctx.logger }, scriptGlobs);
|
|
41
|
+
|
|
42
|
+
ctx.logger.info(`[config-migrator] Done.`);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Fallback if _hostSelector is missing: "DxFooBarComponent" -> "dx-foo-bar"
|
|
47
|
+
function componentToSelectorGuess(componentName: string): string {
|
|
48
|
+
const core = componentName.replace(/Component$/, '').replace(/^Dx/, 'dx-');
|
|
49
|
+
return core.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function normalizeGlobOption(
|
|
53
|
+
value: Options['include'] | Options['scriptInclude'],
|
|
54
|
+
fallback: string[]
|
|
55
|
+
): string[] {
|
|
56
|
+
if (Array.isArray(value)) {
|
|
57
|
+
return value.filter(Boolean);
|
|
58
|
+
}
|
|
59
|
+
if (typeof value === 'string' && value.trim()) {
|
|
60
|
+
const trimmed = value.trim();
|
|
61
|
+
const inner = trimmed.startsWith('[') && trimmed.endsWith(']')
|
|
62
|
+
? trimmed.slice(1, -1)
|
|
63
|
+
: trimmed;
|
|
64
|
+
return inner
|
|
65
|
+
.split(',')
|
|
66
|
+
.map(segment => segment.trim())
|
|
67
|
+
.filter(Boolean);
|
|
68
|
+
}
|
|
69
|
+
return fallback.slice();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function normalizeBoolean(value: Options['dry']): boolean {
|
|
73
|
+
if (typeof value === 'string') {
|
|
74
|
+
return value.toLowerCase() === 'true';
|
|
75
|
+
}
|
|
76
|
+
return !!value;
|
|
77
|
+
}
|