@lucca-front/ng 21.0.3 → 21.1.0-rc.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/fesm2022/lucca-front-ng-a11y.mjs +8 -8
- package/fesm2022/lucca-front-ng-a11y.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-api.mjs +56 -88
- package/fesm2022/lucca-front-ng-api.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-app-layout.mjs +3 -3
- package/fesm2022/lucca-front-ng-box.mjs +3 -3
- package/fesm2022/lucca-front-ng-breadcrumbs.mjs +10 -10
- package/fesm2022/lucca-front-ng-breadcrumbs.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-bubble-icon.mjs +51 -0
- package/fesm2022/lucca-front-ng-bubble-icon.mjs.map +1 -0
- package/fesm2022/lucca-front-ng-bubble-illustration.mjs +135 -0
- package/fesm2022/lucca-front-ng-bubble-illustration.mjs.map +1 -0
- package/fesm2022/lucca-front-ng-button.mjs +3 -3
- package/fesm2022/lucca-front-ng-callout.mjs +28 -28
- package/fesm2022/lucca-front-ng-callout.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-chip.mjs +8 -8
- package/fesm2022/lucca-front-ng-chip.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-clear.mjs +8 -8
- package/fesm2022/lucca-front-ng-clear.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-code.mjs +3 -3
- package/fesm2022/lucca-front-ng-color.mjs +28 -0
- package/fesm2022/lucca-front-ng-color.mjs.map +1 -0
- package/fesm2022/lucca-front-ng-comment.mjs +9 -9
- package/fesm2022/lucca-front-ng-container.mjs +4 -4
- package/fesm2022/lucca-front-ng-container.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select-api.mjs +9 -9
- package/fesm2022/lucca-front-ng-core-select-department.mjs +6 -6
- package/fesm2022/lucca-front-ng-core-select-establishment.mjs +9 -9
- package/fesm2022/lucca-front-ng-core-select-job-qualification.mjs +6 -6
- package/fesm2022/lucca-front-ng-core-select-occupation-category.mjs +3 -3
- package/fesm2022/lucca-front-ng-core-select-user.mjs +28 -28
- package/fesm2022/lucca-front-ng-core-select-user.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select.mjs +117 -96
- package/fesm2022/lucca-front-ng-core-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core.mjs +28 -16
- package/fesm2022/lucca-front-ng-core.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-data-table.mjs +29 -29
- package/fesm2022/lucca-front-ng-data-table.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-date.mjs +102 -135
- package/fesm2022/lucca-front-ng-date.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-date2.mjs +78 -60
- package/fesm2022/lucca-front-ng-date2.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-department.mjs +31 -47
- package/fesm2022/lucca-front-ng-department.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-dialog.mjs +60 -37
- package/fesm2022/lucca-front-ng-dialog.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-divider.mjs +3 -3
- package/fesm2022/lucca-front-ng-dropdown.mjs +40 -40
- package/fesm2022/lucca-front-ng-empty-state.mjs +56 -14
- package/fesm2022/lucca-front-ng-empty-state.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-establishment.mjs +43 -107
- package/fesm2022/lucca-front-ng-establishment.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-fancy-box.mjs +3 -3
- package/fesm2022/lucca-front-ng-file-upload.mjs +67 -44
- package/fesm2022/lucca-front-ng-file-upload.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-filter-pills.mjs +30 -29
- package/fesm2022/lucca-front-ng-filter-pills.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-footer.mjs +3 -3
- package/fesm2022/lucca-front-ng-form-field.mjs +86 -17
- package/fesm2022/lucca-front-ng-form-field.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-form-header.mjs +3 -3
- package/fesm2022/lucca-front-ng-form.mjs +21 -7
- package/fesm2022/lucca-front-ng-form.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-formly.mjs +58 -58
- package/fesm2022/lucca-front-ng-formly.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-phone-number-input.mjs +15 -13
- package/fesm2022/lucca-front-ng-forms-phone-number-input.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs +117 -100
- package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms.mjs +194 -79
- package/fesm2022/lucca-front-ng-forms.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-gauge.mjs +3 -3
- package/fesm2022/lucca-front-ng-grid.mjs +6 -6
- package/fesm2022/lucca-front-ng-highlight-data.mjs +3 -3
- package/fesm2022/lucca-front-ng-horizontal-navigation.mjs +7 -7
- package/fesm2022/lucca-front-ng-horizontal-navigation.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-icon.mjs +3 -3
- package/fesm2022/lucca-front-ng-index-table.mjs +31 -31
- package/fesm2022/lucca-front-ng-index-table.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-inline-message.mjs +3 -3
- package/fesm2022/lucca-front-ng-input.mjs +27 -27
- package/fesm2022/lucca-front-ng-input.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-link.mjs +21 -15
- package/fesm2022/lucca-front-ng-link.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-listbox.mjs +9 -9
- package/fesm2022/lucca-front-ng-listing.mjs +6 -6
- package/fesm2022/lucca-front-ng-loading.mjs +3 -3
- package/fesm2022/lucca-front-ng-main-layout.mjs +7 -7
- package/fesm2022/lucca-front-ng-main-layout.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-mobile-push.mjs +8 -8
- package/fesm2022/lucca-front-ng-mobile-push.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-modal.mjs +22 -22
- package/fesm2022/lucca-front-ng-modal.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-multi-select.mjs +62 -62
- package/fesm2022/lucca-front-ng-multi-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-new-badge.mjs +3 -3
- package/fesm2022/lucca-front-ng-number-format.mjs +6 -6
- package/fesm2022/lucca-front-ng-number.mjs +7 -7
- package/fesm2022/lucca-front-ng-numeric-badge.mjs +3 -3
- package/fesm2022/lucca-front-ng-option.mjs +327 -437
- package/fesm2022/lucca-front-ng-option.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-page-header.mjs +3 -3
- package/fesm2022/lucca-front-ng-pagination.mjs +7 -7
- package/fesm2022/lucca-front-ng-pagination.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-plg-push.mjs +7 -7
- package/fesm2022/lucca-front-ng-plg-push.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-popover.mjs +18 -50
- package/fesm2022/lucca-front-ng-popover.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-popover2.mjs +20 -20
- package/fesm2022/lucca-front-ng-popover2.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-popup.mjs +10 -10
- package/fesm2022/lucca-front-ng-progress-bar.mjs +3 -3
- package/fesm2022/lucca-front-ng-read-more.mjs +25 -23
- package/fesm2022/lucca-front-ng-read-more.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-resource-card.mjs +13 -13
- package/fesm2022/lucca-front-ng-resource-card.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-safe-content.mjs +10 -10
- package/fesm2022/lucca-front-ng-scroll-box.mjs +5 -5
- package/fesm2022/lucca-front-ng-scroll-box.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-scroll.mjs +7 -7
- package/fesm2022/lucca-front-ng-segmented-control-tabs.mjs +6 -6
- package/fesm2022/lucca-front-ng-segmented-control.mjs +6 -6
- package/fesm2022/lucca-front-ng-select.mjs +14 -14
- package/fesm2022/lucca-front-ng-sidepanel.mjs +7 -7
- package/fesm2022/lucca-front-ng-simple-select.mjs +40 -25
- package/fesm2022/lucca-front-ng-simple-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-skeleton.mjs +22 -22
- package/fesm2022/lucca-front-ng-skeleton.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-sortable-list.mjs +6 -6
- package/fesm2022/lucca-front-ng-sortable-list.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-status-badge.mjs +3 -3
- package/fesm2022/lucca-front-ng-table-of-content.mjs +6 -6
- package/fesm2022/lucca-front-ng-tag.mjs +3 -3
- package/fesm2022/lucca-front-ng-text-flow.mjs +20 -0
- package/fesm2022/lucca-front-ng-text-flow.mjs.map +1 -0
- package/fesm2022/lucca-front-ng-time.mjs +72 -33
- package/fesm2022/lucca-front-ng-time.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-title.mjs +10 -10
- package/fesm2022/lucca-front-ng-toast.mjs +14 -14
- package/fesm2022/lucca-front-ng-toast.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-tooltip.mjs +27 -41
- package/fesm2022/lucca-front-ng-tooltip.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-tree-select.mjs +6 -6
- package/fesm2022/lucca-front-ng-tree-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-user-popover.mjs +23 -23
- package/fesm2022/lucca-front-ng-user-popover.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-user.mjs +75 -91
- package/fesm2022/lucca-front-ng-user.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-vertical-navigation.mjs +12 -12
- package/package.json +19 -3
- package/schematics/action-icon/index.js +4 -5
- package/schematics/action-icon/migration.js +3 -4
- package/schematics/action-icon/migration.spec.js +8 -8
- package/schematics/alignment-utilities/index.js +3 -4
- package/schematics/alignment-utilities/migration.spec.js +8 -8
- package/schematics/cdn-urls/index.js +3 -4
- package/schematics/cdn-urls/migration.js +7 -9
- package/schematics/cdn-urls/migration.spec.js +8 -8
- package/schematics/class-prefix/index.js +3 -4
- package/schematics/class-prefix/migration.spec.js +8 -8
- package/schematics/collection.json +10 -0
- package/schematics/color-text/index.js +3 -4
- package/schematics/color-text/migration.spec.js +8 -8
- package/schematics/component-path/index.js +3 -4
- package/schematics/component-path/migration.spec.js +8 -8
- package/schematics/empty-state-title/index.js +5 -7
- package/schematics/empty-state-title/migration.spec.js +5 -5
- package/schematics/lib/index.js +29 -0
- package/schematics/lib/local-deps/package-lock.json +2 -0
- package/schematics/lib/local-deps/package.json +1 -2
- package/schematics/lib/schematic.utils.js +5 -0
- package/schematics/lu-button/index.js +3 -4
- package/schematics/lu-button/migration.js +5 -11
- package/schematics/lu-button/migration.spec.js +5 -5
- package/schematics/lu-container/index.js +23 -0
- package/schematics/lu-container/migration.js +116 -0
- package/schematics/lu-container/migration.spec.js +23 -0
- package/schematics/lu-container/schema.json +23 -0
- package/schematics/lu-icon/index.js +3 -4
- package/schematics/lu-icon/migration.js +8 -14
- package/schematics/lu-icon/migration.spec.js +5 -5
- package/schematics/lu-loading/index.js +23 -0
- package/schematics/lu-loading/migration.js +136 -0
- package/schematics/lu-loading/migration.spec.js +23 -0
- package/schematics/lu-loading/schema.json +28 -0
- package/schematics/lu-select/index.js +3 -4
- package/schematics/lu-select/migration.js +18 -21
- package/schematics/lu-select/migration.spec.js +5 -5
- package/schematics/lu-select/util.js +17 -19
- package/schematics/lu-text-input/index.js +3 -4
- package/schematics/lu-text-input/migration.js +22 -28
- package/schematics/lu-text-input/migration.spec.js +5 -5
- package/schematics/new-icons/index.js +5 -6
- package/schematics/new-icons/migration.js +11 -16
- package/schematics/new-icons/migration.spec.js +8 -8
- package/schematics/palettes/index.js +3 -4
- package/schematics/palettes/migration.spec.js +8 -8
- package/schematics/tokens-radius/index.js +3 -4
- package/schematics/tokens-radius/migration.spec.js +8 -8
- package/schematics/tokens-spacing/index.js +3 -4
- package/schematics/tokens-spacing/migration.spec.js +8 -8
- package/schematics/tokens-typo/index.js +3 -4
- package/schematics/tokens-typo/migration.spec.js +8 -8
- package/types/lucca-front-ng-a11y.d.ts +3 -3
- package/types/lucca-front-ng-api.d.ts +1 -19
- package/types/lucca-front-ng-breadcrumbs.d.ts +9 -9
- package/types/lucca-front-ng-bubble-icon.d.ts +20 -0
- package/types/lucca-front-ng-bubble-illustration.d.ts +24 -0
- package/types/lucca-front-ng-callout.d.ts +2 -2
- package/types/lucca-front-ng-chip.d.ts +2 -2
- package/types/lucca-front-ng-clear.d.ts +2 -2
- package/types/lucca-front-ng-color.d.ts +12 -0
- package/types/lucca-front-ng-core-select.d.ts +84 -78
- package/types/lucca-front-ng-core.d.ts +23 -2
- package/types/lucca-front-ng-data-table.d.ts +2 -2
- package/types/lucca-front-ng-date.d.ts +6 -24
- package/types/lucca-front-ng-date2.d.ts +8 -6
- package/types/lucca-front-ng-department.d.ts +3 -12
- package/types/lucca-front-ng-dialog.d.ts +12 -5
- package/types/lucca-front-ng-empty-state.d.ts +6 -4
- package/types/lucca-front-ng-establishment.d.ts +3 -39
- package/types/lucca-front-ng-file-upload.d.ts +18 -8
- package/types/lucca-front-ng-filter-pills.d.ts +6 -5
- package/types/lucca-front-ng-form-field.d.ts +35 -5
- package/types/lucca-front-ng-form.d.ts +9 -5
- package/types/lucca-front-ng-forms-phone-number-input.d.ts +1 -0
- package/types/lucca-front-ng-forms-rich-text-input.d.ts +16 -16
- package/types/lucca-front-ng-forms.d.ts +51 -12
- package/types/lucca-front-ng-input.d.ts +2 -2
- package/types/lucca-front-ng-link.d.ts +4 -5
- package/types/lucca-front-ng-mobile-push.d.ts +2 -2
- package/types/lucca-front-ng-multi-select.d.ts +26 -24
- package/types/lucca-front-ng-option.d.ts +86 -149
- package/types/lucca-front-ng-pagination.d.ts +2 -2
- package/types/lucca-front-ng-plg-push.d.ts +2 -2
- package/types/lucca-front-ng-popover.d.ts +1 -20
- package/types/lucca-front-ng-popover2.d.ts +4 -4
- package/types/lucca-front-ng-read-more.d.ts +9 -9
- package/types/lucca-front-ng-simple-select.d.ts +5 -4
- package/types/lucca-front-ng-text-flow.d.ts +8 -0
- package/types/lucca-front-ng-time.d.ts +22 -16
- package/types/lucca-front-ng-toast.d.ts +2 -2
- package/types/lucca-front-ng-tooltip.d.ts +7 -14
- package/types/lucca-front-ng-user-popover.d.ts +6 -7
- package/types/lucca-front-ng-user.d.ts +6 -15
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateComponent = migrateComponent;
|
|
4
4
|
const change_1 = require("@schematics/angular/utility/change");
|
|
5
|
-
const
|
|
6
|
-
const angular_template_1 = require("../lib/angular-template");
|
|
7
|
-
const html_ast_js_1 = require("../lib/html-ast.js");
|
|
8
|
-
const lf_schematic_context_1 = require("../lib/lf-schematic-context");
|
|
5
|
+
const lib_1 = require("../lib");
|
|
9
6
|
function migrateComponent(sourceFile, path, tree) {
|
|
10
7
|
const cssButtons = findCssButtons(sourceFile, path, tree);
|
|
11
8
|
if (cssButtons.length > 0) {
|
|
@@ -66,7 +63,7 @@ function migrateComponent(sourceFile, path, tree) {
|
|
|
66
63
|
}
|
|
67
64
|
});
|
|
68
65
|
// Add import if needed
|
|
69
|
-
(0, change_1.applyToUpdateRecorder)(tsUpdate, [(0,
|
|
66
|
+
(0, change_1.applyToUpdateRecorder)(tsUpdate, [(0, lib_1.insertTSImportIfNeeded)(sourceFile, path, 'ButtonComponent', '@lucca-front/ng/button'), (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, 'ButtonComponent')]);
|
|
70
67
|
tree.commitUpdate(tsUpdate);
|
|
71
68
|
if (!isInlineTemplate) {
|
|
72
69
|
tree.commitUpdate(templateUpdate);
|
|
@@ -76,11 +73,11 @@ function migrateComponent(sourceFile, path, tree) {
|
|
|
76
73
|
}
|
|
77
74
|
function findCssButtons(sourceFile, basePath, tree) {
|
|
78
75
|
const buttons = [];
|
|
79
|
-
const ngTemplates = (0,
|
|
76
|
+
const ngTemplates = (0, lib_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
|
|
80
77
|
ngTemplates.forEach((template) => {
|
|
81
|
-
const htmlAst = new
|
|
78
|
+
const htmlAst = new lib_1.HtmlAst(template.content);
|
|
82
79
|
htmlAst.visitNodes((node) => {
|
|
83
|
-
if (isInterestingNode(node) && ["button", "a"].includes(node.name)) {
|
|
80
|
+
if ((0, lib_1.isInterestingNode)(node) && ["button", "a"].includes(node.name)) {
|
|
84
81
|
const classes = node.attributes.find(attr => attr.name === 'class')?.value || "";
|
|
85
82
|
if (classes.split(" ").includes("button")) {
|
|
86
83
|
const inputs = {
|
|
@@ -121,6 +118,3 @@ function getButtonType(classes) {
|
|
|
121
118
|
}
|
|
122
119
|
return '';
|
|
123
120
|
}
|
|
124
|
-
function isInterestingNode(node) {
|
|
125
|
-
return node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstElement;
|
|
126
|
-
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path = require("path");
|
|
4
|
-
const
|
|
4
|
+
const lib_1 = require("../lib");
|
|
5
5
|
const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
|
|
6
6
|
const testsRoot = path.join(__dirname, 'tests');
|
|
7
7
|
describe('luButton Migration', () => {
|
|
8
8
|
it('should handle basic case files', async () => {
|
|
9
9
|
// Arrange
|
|
10
|
-
const tree = (0,
|
|
11
|
-
const expectedTree = (0,
|
|
10
|
+
const tree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
|
|
11
|
+
const expectedTree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
|
|
12
12
|
// Act
|
|
13
13
|
try {
|
|
14
|
-
await (0,
|
|
14
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'lu-button', { skipInstallation: true }, tree);
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
17
|
// eslint-disable-next-line no-console
|
|
18
18
|
console.log(error);
|
|
19
19
|
}
|
|
20
20
|
// Assert
|
|
21
|
-
(0,
|
|
21
|
+
(0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
|
|
22
22
|
});
|
|
23
23
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const typescript_1 = require("typescript");
|
|
4
|
+
const lib_1 = require("../lib");
|
|
5
|
+
const migration_1 = require("./migration");
|
|
6
|
+
// Nx need to see "@angular-devkit/schematics" in order to run this migration correctly (see https://github.com/nrwl/nx/blob/d9fed4b832bf01d1b9a44ae9e486a5e5cd2d2253/packages/nx/src/command-line/migrate/migrate.ts#L1729-L1738)
|
|
7
|
+
require('@angular-devkit/schematics');
|
|
8
|
+
exports.default = (options) => {
|
|
9
|
+
return async (tree, context) => {
|
|
10
|
+
await lib_1.currentSchematicContext.init(context, options);
|
|
11
|
+
tree.visit((path, entry) => {
|
|
12
|
+
if (path.includes('node_modules') || !entry) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (path.endsWith('.ts')) {
|
|
16
|
+
(0, lib_1.migrateFile)(path, entry, tree, (content) => {
|
|
17
|
+
const sourceFile = (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.ESNext);
|
|
18
|
+
return (0, migration_1.migrateComponent)(sourceFile, path, tree);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateComponent = migrateComponent;
|
|
4
|
+
const change_1 = require("@schematics/angular/utility/change");
|
|
5
|
+
const lib_1 = require("../lib");
|
|
6
|
+
function migrateComponent(sourceFile, path, tree) {
|
|
7
|
+
const htmlContainers = findHTMLContainers(sourceFile, path, tree);
|
|
8
|
+
if (htmlContainers.length > 0) {
|
|
9
|
+
const tsUpdate = tree.beginUpdate(path);
|
|
10
|
+
const isInlineTemplate = htmlContainers[0].filePath === path;
|
|
11
|
+
const templateUpdate = isInlineTemplate ? tsUpdate : tree.beginUpdate(htmlContainers[0].filePath);
|
|
12
|
+
htmlContainers.forEach((container) => {
|
|
13
|
+
const classesNode = container.node.attributes.find(attr => attr.name === 'class');
|
|
14
|
+
const containerNodeLength = container.node.name.length;
|
|
15
|
+
const hasAriaHidden = container.node.attributes.find(attr => attr.name === 'aria-hidden');
|
|
16
|
+
const hasStyle = container.node.attributes.find(attr => attr.name === 'style');
|
|
17
|
+
// remove element name attribute
|
|
18
|
+
templateUpdate.remove(container.nodeOffset + container.node.startSourceSpan.start.offset + 1, containerNodeLength);
|
|
19
|
+
if (classesNode && classesNode.keySpan) {
|
|
20
|
+
/**
|
|
21
|
+
* Add stuff
|
|
22
|
+
*/
|
|
23
|
+
let thingsToAdd = `lu-container${hasThingsToAdd(container.inputs) || hasAriaHidden || hasStyle ? '' : ' '}`;
|
|
24
|
+
if (container.inputs.center) {
|
|
25
|
+
thingsToAdd += ` center`;
|
|
26
|
+
}
|
|
27
|
+
if (container.inputs.overflow) {
|
|
28
|
+
thingsToAdd += ` overflow`;
|
|
29
|
+
}
|
|
30
|
+
if (container.inputs.max) {
|
|
31
|
+
thingsToAdd += ` max="${container.inputs.max}"`;
|
|
32
|
+
}
|
|
33
|
+
// with content
|
|
34
|
+
if (container.node.children.length > 0 && container.node.endSourceSpan) {
|
|
35
|
+
templateUpdate.remove(container.nodeOffset + container.node.endSourceSpan.start.offset + 1, containerNodeLength + 1);
|
|
36
|
+
templateUpdate.insertRight(container.nodeOffset + container.node.startSourceSpan.start.offset + 1, thingsToAdd);
|
|
37
|
+
templateUpdate.insertLeft(container.nodeOffset + container.node.endSourceSpan.start.offset + 1, '/lu-container');
|
|
38
|
+
}
|
|
39
|
+
// self closing
|
|
40
|
+
else {
|
|
41
|
+
const endSpanOffset = container.node.endSourceSpan?.start.offset || -1;
|
|
42
|
+
templateUpdate.remove(container.nodeOffset + container.node.startSourceSpan.end.offset, endSpanOffset - container.node.startSourceSpan.end.offset);
|
|
43
|
+
if (container.node.endSourceSpan?.start?.offset) {
|
|
44
|
+
templateUpdate.remove(container.nodeOffset + container.node.endSourceSpan?.start?.offset, container.node.endSourceSpan?.toString().length);
|
|
45
|
+
}
|
|
46
|
+
templateUpdate.insertRight(container.nodeOffset + container.node.startSourceSpan.start.offset + 1, thingsToAdd);
|
|
47
|
+
templateUpdate.insertRight(container.nodeOffset + container.node.startSourceSpan.end.offset - 1, `${hasThingsToAdd(container.inputs) || hasAriaHidden || hasStyle ? ' ' : ''}/`);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Modify classes
|
|
51
|
+
*/
|
|
52
|
+
if (classesNode && classesNode.keySpan) {
|
|
53
|
+
const classes = classesNode.value;
|
|
54
|
+
const cleanedClasses = classes.split(' ').filter(c => {
|
|
55
|
+
return ![`mod-max${container.inputs.max}`, `mod-overflow`, `mod-center`, `container`].includes(c);
|
|
56
|
+
}).join(' ');
|
|
57
|
+
templateUpdate.remove(container.nodeOffset + classesNode.keySpan.start.offset - 1, classesNode.sourceSpan.toString().length + 1);
|
|
58
|
+
if (cleanedClasses) {
|
|
59
|
+
templateUpdate.insertRight(container.nodeOffset + classesNode.keySpan.start.offset, `${hasThingsToAdd(container.inputs) || hasAriaHidden || hasStyle ? ' ' : ''}class="${cleanedClasses}"`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
// Add import if needed
|
|
65
|
+
(0, change_1.applyToUpdateRecorder)(tsUpdate, [(0, lib_1.insertTSImportIfNeeded)(sourceFile, path, 'ContainerComponent', '@lucca-front/ng/container'), (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, 'ContainerComponent')]);
|
|
66
|
+
tree.commitUpdate(tsUpdate);
|
|
67
|
+
if (!isInlineTemplate) {
|
|
68
|
+
tree.commitUpdate(templateUpdate);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return tree.readText(path);
|
|
72
|
+
}
|
|
73
|
+
function findHTMLContainers(sourceFile, basePath, tree) {
|
|
74
|
+
const htmlContainer = [];
|
|
75
|
+
const ngTemplates = (0, lib_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
|
|
76
|
+
ngTemplates.forEach((template) => {
|
|
77
|
+
const htmlAst = new lib_1.HtmlAst(template.content);
|
|
78
|
+
htmlAst.visitNodes((node) => {
|
|
79
|
+
if ((0, lib_1.isInterestingNode)(node)) {
|
|
80
|
+
const classes = node.attributes.find(attr => attr.name === 'class')?.value;
|
|
81
|
+
// match check if it's only "container" not container-custom ...
|
|
82
|
+
if (classes?.includes("container") && classes?.match(/(^|\s)container(\s|$)/)) {
|
|
83
|
+
const container = classes.split(' ').find(c => c.startsWith('container'));
|
|
84
|
+
if (container) {
|
|
85
|
+
const inputs = {
|
|
86
|
+
max: classes.split(' ').find(c => /mod-max(M|L|XL|XXL|XXXL)/.test(c))?.replace('mod-max', ''),
|
|
87
|
+
center: classes.includes('mod-center') ? true : undefined,
|
|
88
|
+
overflow: classes.includes('mod-overflow') ? true : undefined,
|
|
89
|
+
};
|
|
90
|
+
const container = {
|
|
91
|
+
node: node,
|
|
92
|
+
inputs,
|
|
93
|
+
nodeOffset: template.offsetStart,
|
|
94
|
+
filePath: template.filePath,
|
|
95
|
+
componentTS: sourceFile,
|
|
96
|
+
};
|
|
97
|
+
htmlContainer.push(container);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
return htmlContainer;
|
|
104
|
+
}
|
|
105
|
+
function hasThingsToAdd(inputs) {
|
|
106
|
+
if (inputs?.max) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if (inputs?.overflow) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
if (inputs?.center) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const lib_1 = require("../lib");
|
|
5
|
+
const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
|
|
6
|
+
const testsRoot = path.join(__dirname, 'tests');
|
|
7
|
+
describe('lu-container Migration', () => {
|
|
8
|
+
it('should handle basic case files', async () => {
|
|
9
|
+
// Arrange
|
|
10
|
+
const tree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
|
|
11
|
+
const expectedTree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
|
|
12
|
+
// Act
|
|
13
|
+
try {
|
|
14
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'lu-container', { skipInstallation: true }, tree);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.log(error);
|
|
19
|
+
}
|
|
20
|
+
// Assert
|
|
21
|
+
(0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "LuccaFrontLuContainer",
|
|
4
|
+
"title": "Migrate HTML Container to the new lu-container component",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"dryRun": {
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"description": "Run through the migration without making any changes.",
|
|
10
|
+
"default": false
|
|
11
|
+
},
|
|
12
|
+
"skipInstall": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"description": "Skip installing dependencies.",
|
|
15
|
+
"default": false
|
|
16
|
+
},
|
|
17
|
+
"verbose": {
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"description": "Enable verbose logging.",
|
|
20
|
+
"default": false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const typescript_1 = require("typescript");
|
|
4
|
-
const
|
|
5
|
-
const schematics_1 = require("../lib/schematics");
|
|
4
|
+
const lib_1 = require("../lib");
|
|
6
5
|
const migration_1 = require("./migration");
|
|
7
6
|
// Nx need to see "@angular-devkit/schematics" in order to run this migration correctly (see https://github.com/nrwl/nx/blob/d9fed4b832bf01d1b9a44ae9e486a5e5cd2d2253/packages/nx/src/command-line/migrate/migrate.ts#L1729-L1738)
|
|
8
7
|
require('@angular-devkit/schematics');
|
|
9
8
|
exports.default = (options) => {
|
|
10
9
|
return async (tree, context) => {
|
|
11
|
-
await
|
|
10
|
+
await lib_1.currentSchematicContext.init(context, options);
|
|
12
11
|
tree.visit((path, entry) => {
|
|
13
12
|
if (path.includes('node_modules') || !entry) {
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
16
15
|
if (path.endsWith('.ts')) {
|
|
17
|
-
(0,
|
|
16
|
+
(0, lib_1.migrateFile)(path, entry, tree, (content) => {
|
|
18
17
|
const sourceFile = (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.ESNext);
|
|
19
18
|
return (0, migration_1.migrateComponent)(sourceFile, path, tree);
|
|
20
19
|
});
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateComponent = migrateComponent;
|
|
4
4
|
const change_1 = require("@schematics/angular/utility/change");
|
|
5
|
-
const
|
|
6
|
-
const angular_template_1 = require("../lib/angular-template");
|
|
7
|
-
const html_ast_js_1 = require("../lib/html-ast.js");
|
|
8
|
-
const lf_schematic_context_1 = require("../lib/lf-schematic-context");
|
|
5
|
+
const lib_1 = require("../lib");
|
|
9
6
|
function migrateComponent(sourceFile, path, tree) {
|
|
10
7
|
const htmlIcons = findHTMLIcons(sourceFile, path, tree);
|
|
11
8
|
if (htmlIcons.length > 0) {
|
|
@@ -69,7 +66,7 @@ function migrateComponent(sourceFile, path, tree) {
|
|
|
69
66
|
}
|
|
70
67
|
});
|
|
71
68
|
// Add import if needed
|
|
72
|
-
(0, change_1.applyToUpdateRecorder)(tsUpdate, [(0,
|
|
69
|
+
(0, change_1.applyToUpdateRecorder)(tsUpdate, [(0, lib_1.insertTSImportIfNeeded)(sourceFile, path, 'IconComponent', '@lucca-front/ng/icon'), (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, 'IconComponent')]);
|
|
73
70
|
tree.commitUpdate(tsUpdate);
|
|
74
71
|
if (!isInlineTemplate) {
|
|
75
72
|
tree.commitUpdate(templateUpdate);
|
|
@@ -79,11 +76,11 @@ function migrateComponent(sourceFile, path, tree) {
|
|
|
79
76
|
}
|
|
80
77
|
function findHTMLIcons(sourceFile, basePath, tree) {
|
|
81
78
|
const htmlIcons = [];
|
|
82
|
-
const ngTemplates = (0,
|
|
79
|
+
const ngTemplates = (0, lib_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
|
|
83
80
|
ngTemplates.forEach((template) => {
|
|
84
|
-
const htmlAst = new
|
|
81
|
+
const htmlAst = new lib_1.HtmlAst(template.content);
|
|
85
82
|
htmlAst.visitNodes((node, parent) => {
|
|
86
|
-
if (isInterestingNode(node)) {
|
|
83
|
+
if ((0, lib_1.isInterestingNode)(node)) {
|
|
87
84
|
const classes = node.attributes.find(attr => attr.name === 'class')?.value;
|
|
88
85
|
if (classes?.includes("lucca-icon")) {
|
|
89
86
|
const iconClass = classes.split(' ').find(c => c.startsWith('icon-'));
|
|
@@ -98,12 +95,12 @@ function findHTMLIcons(sourceFile, basePath, tree) {
|
|
|
98
95
|
filePath: template.filePath,
|
|
99
96
|
componentTS: sourceFile
|
|
100
97
|
};
|
|
101
|
-
const siblings = isInterestingNode(parent) ? parent?.children : htmlAst.nodes;
|
|
98
|
+
const siblings = (0, lib_1.isInterestingNode)(parent) ? parent?.children : htmlAst.nodes;
|
|
102
99
|
if (siblings.length > 0) {
|
|
103
100
|
const possibleAltSpan = siblings.find(child => {
|
|
104
|
-
return isInterestingNode(child) && child !== node;
|
|
101
|
+
return (0, lib_1.isInterestingNode)(child) && child !== node;
|
|
105
102
|
});
|
|
106
|
-
if (possibleAltSpan && isInterestingNode(possibleAltSpan)) {
|
|
103
|
+
if (possibleAltSpan && (0, lib_1.isInterestingNode)(possibleAltSpan)) {
|
|
107
104
|
const childClasses = possibleAltSpan.attributes.find(attr => attr.name === 'class')?.value;
|
|
108
105
|
// We know it's one of these types but TS doesn't find that info from the above call so here we go again
|
|
109
106
|
if (childClasses === 'pr-u-mask') {
|
|
@@ -120,6 +117,3 @@ function findHTMLIcons(sourceFile, basePath, tree) {
|
|
|
120
117
|
});
|
|
121
118
|
return htmlIcons;
|
|
122
119
|
}
|
|
123
|
-
function isInterestingNode(node) {
|
|
124
|
-
return node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstElement;
|
|
125
|
-
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path = require("path");
|
|
4
|
-
const
|
|
4
|
+
const lib_1 = require("../lib");
|
|
5
5
|
const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
|
|
6
6
|
const testsRoot = path.join(__dirname, 'tests');
|
|
7
7
|
describe('lu-icon Migration', () => {
|
|
8
8
|
it('should handle basic case files', async () => {
|
|
9
9
|
// Arrange
|
|
10
|
-
const tree = (0,
|
|
11
|
-
const expectedTree = (0,
|
|
10
|
+
const tree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
|
|
11
|
+
const expectedTree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
|
|
12
12
|
// Act
|
|
13
13
|
try {
|
|
14
|
-
await (0,
|
|
14
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'lu-icon', { skipInstallation: true }, tree);
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
17
|
// eslint-disable-next-line no-console
|
|
18
18
|
console.log(error);
|
|
19
19
|
}
|
|
20
20
|
// Assert
|
|
21
|
-
(0,
|
|
21
|
+
(0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
|
|
22
22
|
});
|
|
23
23
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const typescript_1 = require("typescript");
|
|
4
|
+
const lib_1 = require("../lib");
|
|
5
|
+
const migration_1 = require("./migration");
|
|
6
|
+
// Nx need to see "@angular-devkit/schematics" in order to run this migration correctly (see https://github.com/nrwl/nx/blob/d9fed4b832bf01d1b9a44ae9e486a5e5cd2d2253/packages/nx/src/command-line/migrate/migrate.ts#L1729-L1738)
|
|
7
|
+
require('@angular-devkit/schematics');
|
|
8
|
+
exports.default = (options) => {
|
|
9
|
+
return async (tree, context) => {
|
|
10
|
+
await lib_1.currentSchematicContext.init(context, options);
|
|
11
|
+
tree.visit((path, entry) => {
|
|
12
|
+
if (path.includes('node_modules') || !entry) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (path.endsWith('.ts')) {
|
|
16
|
+
(0, lib_1.migrateFile)(path, entry, tree, (content) => {
|
|
17
|
+
const sourceFile = (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.ESNext);
|
|
18
|
+
return (0, migration_1.migrateComponent)(sourceFile, path, tree);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateComponent = migrateComponent;
|
|
4
|
+
const change_1 = require("@schematics/angular/utility/change");
|
|
5
|
+
const lib_1 = require("../lib");
|
|
6
|
+
function migrateComponent(sourceFile, path, tree) {
|
|
7
|
+
const htmlLoadings = findHTMLLoadings(sourceFile, path, tree);
|
|
8
|
+
if (htmlLoadings.length > 0) {
|
|
9
|
+
const tsUpdate = tree.beginUpdate(path);
|
|
10
|
+
const isInlineTemplate = htmlLoadings[0].filePath === path;
|
|
11
|
+
const templateUpdate = isInlineTemplate ? tsUpdate : tree.beginUpdate(htmlLoadings[0].filePath);
|
|
12
|
+
htmlLoadings.forEach((loading) => {
|
|
13
|
+
const classesNode = loading.node.attributes.find(attr => attr.name === 'class');
|
|
14
|
+
const loadingNodeLength = loading.node.name.length;
|
|
15
|
+
const hasAriaHidden = loading.node.attributes.find(attr => attr.name === 'aria-hidden');
|
|
16
|
+
const hasStyle = loading.node.attributes.find(attr => attr.name === 'style');
|
|
17
|
+
// remove element name attribute
|
|
18
|
+
templateUpdate.remove(loading.nodeOffset + loading.node.startSourceSpan.start.offset + 1, loadingNodeLength);
|
|
19
|
+
if (classesNode && classesNode.keySpan) {
|
|
20
|
+
/**
|
|
21
|
+
* Add stuff
|
|
22
|
+
*/
|
|
23
|
+
let thingsToAdd = `lu-loading${hasThingsToAdd(loading.inputs) || hasAriaHidden || hasStyle ? '' : ' '}`;
|
|
24
|
+
if (loading.inputs.block) {
|
|
25
|
+
thingsToAdd += ` block`;
|
|
26
|
+
}
|
|
27
|
+
if (loading.inputs.invert) {
|
|
28
|
+
thingsToAdd += ` invert`;
|
|
29
|
+
}
|
|
30
|
+
if (loading.inputs.size) {
|
|
31
|
+
thingsToAdd += ` size="L"`;
|
|
32
|
+
}
|
|
33
|
+
if (loading.inputs.template) {
|
|
34
|
+
thingsToAdd += ` template="${loading.inputs.template}"`;
|
|
35
|
+
}
|
|
36
|
+
// with content
|
|
37
|
+
if (loading.node.children.length > 0 && loading.node.endSourceSpan) {
|
|
38
|
+
templateUpdate.remove(loading.nodeOffset + loading.node.endSourceSpan.start.offset + 1, loadingNodeLength + 1);
|
|
39
|
+
templateUpdate.insertRight(loading.nodeOffset + loading.node.startSourceSpan.start.offset + 1, thingsToAdd);
|
|
40
|
+
templateUpdate.insertLeft(loading.nodeOffset + loading.node.endSourceSpan.start.offset + 1, '/lu-loading');
|
|
41
|
+
}
|
|
42
|
+
// self closing
|
|
43
|
+
else {
|
|
44
|
+
const endSpanOffset = loading.node.endSourceSpan?.start.offset || -1;
|
|
45
|
+
templateUpdate.remove(loading.nodeOffset + loading.node.startSourceSpan.end.offset, endSpanOffset - loading.node.startSourceSpan.end.offset);
|
|
46
|
+
if (loading.node.endSourceSpan?.start?.offset) {
|
|
47
|
+
templateUpdate.remove(loading.nodeOffset + loading.node.endSourceSpan?.start?.offset, loading.node.endSourceSpan?.toString().length);
|
|
48
|
+
}
|
|
49
|
+
templateUpdate.insertRight(loading.nodeOffset + loading.node.startSourceSpan.start.offset + 1, thingsToAdd);
|
|
50
|
+
templateUpdate.insertRight(loading.nodeOffset + loading.node.startSourceSpan.end.offset - 1, `${hasThingsToAdd(loading.inputs) || hasAriaHidden || hasStyle ? ' ' : ''}/`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Modify classes
|
|
54
|
+
*/
|
|
55
|
+
if (classesNode && classesNode.keySpan) {
|
|
56
|
+
const classes = classesNode.value;
|
|
57
|
+
const cleanedClasses = classes.split(' ').filter(c => {
|
|
58
|
+
return ![`mod-L`, `mod-block`, `mod-invert`, `loading`, `mod-invert`, `mod-popin`, `mod-drawer`, `mod-fullPage`, `mod-fullpage`].includes(c);
|
|
59
|
+
}).join(' ');
|
|
60
|
+
templateUpdate.remove(loading.nodeOffset + classesNode.keySpan.start.offset - 1, classesNode.sourceSpan.toString().length + 1);
|
|
61
|
+
if (cleanedClasses) {
|
|
62
|
+
templateUpdate.insertRight(loading.nodeOffset + classesNode.keySpan.start.offset, `${hasThingsToAdd(loading.inputs) || hasAriaHidden || hasStyle ? ' ' : ''}class="${cleanedClasses}"`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
// Add import if needed
|
|
68
|
+
(0, change_1.applyToUpdateRecorder)(tsUpdate, [(0, lib_1.insertTSImportIfNeeded)(sourceFile, path, 'LoadingComponent', '@lucca-front/ng/loading'), (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, 'LoadingComponent')]);
|
|
69
|
+
tree.commitUpdate(tsUpdate);
|
|
70
|
+
if (!isInlineTemplate) {
|
|
71
|
+
tree.commitUpdate(templateUpdate);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return tree.readText(path);
|
|
75
|
+
}
|
|
76
|
+
function findHTMLLoadings(sourceFile, basePath, tree) {
|
|
77
|
+
const htmlLoadings = [];
|
|
78
|
+
const ngTemplates = (0, lib_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
|
|
79
|
+
ngTemplates.forEach((template) => {
|
|
80
|
+
const htmlAst = new lib_1.HtmlAst(template.content);
|
|
81
|
+
htmlAst.visitNodes((node) => {
|
|
82
|
+
if ((0, lib_1.isInterestingNode)(node)) {
|
|
83
|
+
const classes = node.attributes.find(attr => attr.name === 'class')?.value;
|
|
84
|
+
// match check if it's only "loading" not loading-custom ...
|
|
85
|
+
if (classes?.includes("loading") && classes?.match(/(^|\s)loading(\s|$)/)) {
|
|
86
|
+
const loading = classes.split(' ').find(c => c.startsWith('loading'));
|
|
87
|
+
if (loading) {
|
|
88
|
+
const inputs = {
|
|
89
|
+
size: classes.split(' ').find(c => /mod-L/.test(c)),
|
|
90
|
+
block: classes.includes('mod-block') ? true : undefined,
|
|
91
|
+
invert: classes.includes('mod-invert') ? true : undefined,
|
|
92
|
+
template: getLoadingTemplate(classes),
|
|
93
|
+
};
|
|
94
|
+
const loading = {
|
|
95
|
+
node: node,
|
|
96
|
+
inputs,
|
|
97
|
+
nodeOffset: template.offsetStart,
|
|
98
|
+
filePath: template.filePath,
|
|
99
|
+
componentTS: sourceFile,
|
|
100
|
+
};
|
|
101
|
+
htmlLoadings.push(loading);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
return htmlLoadings;
|
|
108
|
+
}
|
|
109
|
+
function hasThingsToAdd(inputs) {
|
|
110
|
+
if (inputs?.block) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (inputs?.invert) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
if (inputs?.size) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
if (inputs?.template) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
function getLoadingTemplate(classes) {
|
|
125
|
+
if (classes.includes('mod-popin')) {
|
|
126
|
+
return 'popin';
|
|
127
|
+
}
|
|
128
|
+
if (classes.includes('mod-drawer')) {
|
|
129
|
+
return 'drawer';
|
|
130
|
+
}
|
|
131
|
+
// fullpage is deprecated so we always use fullPage here
|
|
132
|
+
if (classes.includes('mod-fullPage') || classes.includes('mod-fullpage')) {
|
|
133
|
+
return 'fullPage';
|
|
134
|
+
}
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const lib_1 = require("../lib");
|
|
5
|
+
const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
|
|
6
|
+
const testsRoot = path.join(__dirname, 'tests');
|
|
7
|
+
describe('lu-loading Migration', () => {
|
|
8
|
+
it('should handle basic case files', async () => {
|
|
9
|
+
// Arrange
|
|
10
|
+
const tree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
|
|
11
|
+
const expectedTree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
|
|
12
|
+
// Act
|
|
13
|
+
try {
|
|
14
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'lu-loading', { skipInstallation: true }, tree);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.log(error);
|
|
19
|
+
}
|
|
20
|
+
// Assert
|
|
21
|
+
(0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "LuccaFrontLuLoading",
|
|
4
|
+
"title": "Lucca Front loading html migration into lu-loading angular component",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"dryRun": {
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"description": "Run through the migration without making any changes.",
|
|
10
|
+
"default": false
|
|
11
|
+
},
|
|
12
|
+
"skipInstall": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"description": "Skip installing dependencies.",
|
|
15
|
+
"default": false
|
|
16
|
+
},
|
|
17
|
+
"verbose": {
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"description": "Enable verbose logging.",
|
|
20
|
+
"default": false
|
|
21
|
+
},
|
|
22
|
+
"noComments": {
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"description": "Don't put comments about select migration rejections in result files.",
|
|
25
|
+
"default": false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const typescript_1 = require("typescript");
|
|
4
|
-
const
|
|
5
|
-
const schematics_1 = require("../lib/schematics");
|
|
4
|
+
const lib_1 = require("../lib");
|
|
6
5
|
const migration_1 = require("./migration");
|
|
7
6
|
// Nx need to see "@angular-devkit/schematics" in order to run this migration correctly (see https://github.com/nrwl/nx/blob/d9fed4b832bf01d1b9a44ae9e486a5e5cd2d2253/packages/nx/src/command-line/migrate/migrate.ts#L1729-L1738)
|
|
8
7
|
require('@angular-devkit/schematics');
|
|
9
8
|
exports.default = (options) => {
|
|
10
9
|
return async (tree, context) => {
|
|
11
|
-
await
|
|
10
|
+
await lib_1.currentSchematicContext.init(context, options);
|
|
12
11
|
tree.visit((path, entry) => {
|
|
13
12
|
if (path.includes('node_modules') || !entry) {
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
16
15
|
if (path.endsWith('.ts')) {
|
|
17
|
-
(0,
|
|
16
|
+
(0, lib_1.migrateFile)(path, entry, tree, (content) => {
|
|
18
17
|
const sourceFile = (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.ESNext);
|
|
19
18
|
return (0, migration_1.migrateComponent)(sourceFile, path, tree, options?.noComments);
|
|
20
19
|
});
|