@lucca-front/ng 21.1.0-split.0 → 21.1.1-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 +2 -2
- package/fesm2022/lucca-front-ng-a11y.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-api.mjs +13 -45
- package/fesm2022/lucca-front-ng-api.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-app-layout.mjs +2 -2
- package/fesm2022/lucca-front-ng-app-layout.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-box.mjs +5 -4
- package/fesm2022/lucca-front-ng-box.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-breadcrumbs.mjs +2 -2
- package/fesm2022/lucca-front-ng-breadcrumbs.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-bubble-icon.mjs +2 -2
- package/fesm2022/lucca-front-ng-bubble-illustration.mjs +6 -1
- package/fesm2022/lucca-front-ng-bubble-illustration.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-callout.mjs +41 -15
- package/fesm2022/lucca-front-ng-callout.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-chip.mjs +35 -5
- package/fesm2022/lucca-front-ng-chip.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-clear.mjs +17 -2
- package/fesm2022/lucca-front-ng-clear.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-comment.mjs +20 -18
- package/fesm2022/lucca-front-ng-comment.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-container.mjs +5 -7
- package/fesm2022/lucca-front-ng-container.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select-job-qualification.mjs +0 -2
- package/fesm2022/lucca-front-ng-core-select-job-qualification.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select-user.mjs +2 -2
- package/fesm2022/lucca-front-ng-core-select-user.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select.mjs +12 -19
- package/fesm2022/lucca-front-ng-core-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-data-table.mjs +5 -5
- package/fesm2022/lucca-front-ng-data-table.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-date.mjs +5 -37
- package/fesm2022/lucca-front-ng-date.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-date2.mjs +70 -31
- package/fesm2022/lucca-front-ng-date2.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-department.mjs +2 -18
- package/fesm2022/lucca-front-ng-department.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-dialog.mjs +13 -4
- package/fesm2022/lucca-front-ng-dialog.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-divider.mjs +12 -3
- package/fesm2022/lucca-front-ng-divider.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-dropdown.mjs +9 -8
- package/fesm2022/lucca-front-ng-dropdown.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-empty-state.mjs +20 -4
- package/fesm2022/lucca-front-ng-empty-state.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-establishment.mjs +2 -66
- package/fesm2022/lucca-front-ng-establishment.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-fancy-box.mjs +12 -0
- package/fesm2022/lucca-front-ng-fancy-box.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-file-upload.mjs +8 -8
- package/fesm2022/lucca-front-ng-file-upload.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-filter-pills.mjs +4 -4
- package/fesm2022/lucca-front-ng-filter-pills.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-footer.mjs +3 -0
- package/fesm2022/lucca-front-ng-footer.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-form-field.mjs +81 -11
- package/fesm2022/lucca-front-ng-form-field.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-form-header.mjs +3 -0
- package/fesm2022/lucca-front-ng-form-header.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-form.mjs +19 -5
- package/fesm2022/lucca-front-ng-form.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-phone-number-input.mjs +10 -9
- package/fesm2022/lucca-front-ng-forms-phone-number-input.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-html.mjs +15 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-html.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-markdown.mjs +28 -3
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-markdown.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-plain-text.mjs +15 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-plain-text.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs +53 -36
- package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms.mjs +97 -48
- package/fesm2022/lucca-front-ng-forms.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-gauge.mjs +28 -5
- package/fesm2022/lucca-front-ng-gauge.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-grid.mjs +3 -3
- package/fesm2022/lucca-front-ng-grid.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-highlight-data.mjs +31 -26
- package/fesm2022/lucca-front-ng-highlight-data.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-horizontal-navigation.mjs +5 -2
- package/fesm2022/lucca-front-ng-horizontal-navigation.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-index-table.mjs +5 -5
- package/fesm2022/lucca-front-ng-index-table.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-inline-message.mjs +14 -2
- package/fesm2022/lucca-front-ng-inline-message.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-link.mjs +17 -2
- package/fesm2022/lucca-front-ng-link.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-listbox.mjs +17 -5
- package/fesm2022/lucca-front-ng-listbox.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-listing.mjs +36 -7
- package/fesm2022/lucca-front-ng-listing.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-loading.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-main-layout.mjs +9 -2
- package/fesm2022/lucca-front-ng-main-layout.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-mobile-push.mjs +18 -10
- package/fesm2022/lucca-front-ng-mobile-push.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-modal.mjs +29 -18
- package/fesm2022/lucca-front-ng-modal.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-multi-select.mjs +18 -14
- package/fesm2022/lucca-front-ng-multi-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-new-badge.mjs +3 -0
- package/fesm2022/lucca-front-ng-new-badge.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-numeric-badge.mjs +12 -3
- package/fesm2022/lucca-front-ng-numeric-badge.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-option.mjs +203 -315
- package/fesm2022/lucca-front-ng-option.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-page-header.mjs +11 -2
- package/fesm2022/lucca-front-ng-page-header.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-pagination.mjs +24 -0
- package/fesm2022/lucca-front-ng-pagination.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-plg-push.mjs +7 -1
- package/fesm2022/lucca-front-ng-plg-push.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-popover.mjs +1 -33
- package/fesm2022/lucca-front-ng-popover.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-popover2.mjs +23 -19
- package/fesm2022/lucca-front-ng-popover2.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-progress-bar.mjs +12 -5
- package/fesm2022/lucca-front-ng-progress-bar.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-read-more.mjs +18 -3
- package/fesm2022/lucca-front-ng-read-more.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-resource-card.mjs +8 -8
- package/fesm2022/lucca-front-ng-resource-card.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-scroll-box.mjs +7 -4
- package/fesm2022/lucca-front-ng-scroll-box.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-segmented-control-tabs.mjs +11 -5
- package/fesm2022/lucca-front-ng-segmented-control-tabs.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-segmented-control.mjs +18 -3
- package/fesm2022/lucca-front-ng-segmented-control.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-simple-select.mjs +22 -7
- package/fesm2022/lucca-front-ng-simple-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-skeleton.mjs +71 -20
- package/fesm2022/lucca-front-ng-skeleton.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-software-icon.mjs +62 -0
- package/fesm2022/lucca-front-ng-software-icon.mjs.map +1 -0
- package/fesm2022/lucca-front-ng-sortable-list.mjs +24 -0
- package/fesm2022/lucca-front-ng-sortable-list.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-status-badge.mjs +14 -2
- package/fesm2022/lucca-front-ng-status-badge.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-tag.mjs +8 -2
- package/fesm2022/lucca-front-ng-tag.mjs.map +1 -1
- 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 +60 -16
- package/fesm2022/lucca-front-ng-time.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-tooltip.mjs +23 -22
- package/fesm2022/lucca-front-ng-tooltip.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-user-popover.mjs +2 -2
- package/fesm2022/lucca-front-ng-user-popover.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-user.mjs +11 -27
- package/fesm2022/lucca-front-ng-user.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-vertical-navigation.mjs +32 -2
- package/fesm2022/lucca-front-ng-vertical-navigation.mjs.map +1 -1
- package/package.json +22 -14
- 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 +8 -10
- 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/html-ast.js +11 -3
- package/schematics/lib/index.js +29 -0
- 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/ng-add/file-content.js +6 -8
- package/schematics/ng-add/index.js +5 -5
- package/schematics/ng-add/tasks.js +22 -17
- 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/src/components/cdk/_overlay.scss +5 -0
- package/src/definitions/option/_option-item.scss +1 -0
- package/types/lucca-front-ng-a11y.d.ts +1 -1
- package/types/lucca-front-ng-api.d.ts +1 -19
- package/types/lucca-front-ng-box.d.ts +2 -1
- package/types/lucca-front-ng-breadcrumbs.d.ts +1 -1
- package/types/lucca-front-ng-bubble-illustration.d.ts +1 -1
- package/types/lucca-front-ng-callout.d.ts +32 -2
- package/types/lucca-front-ng-chip.d.ts +32 -2
- package/types/lucca-front-ng-clear.d.ts +20 -5
- package/types/lucca-front-ng-comment.d.ts +19 -11
- package/types/lucca-front-ng-container.d.ts +4 -4
- package/types/lucca-front-ng-core-select.d.ts +3 -2
- package/types/lucca-front-ng-date.d.ts +1 -19
- package/types/lucca-front-ng-date2.d.ts +21 -18
- package/types/lucca-front-ng-department.d.ts +1 -10
- package/types/lucca-front-ng-dialog.d.ts +6 -3
- package/types/lucca-front-ng-divider.d.ts +10 -0
- package/types/lucca-front-ng-empty-state.d.ts +18 -2
- package/types/lucca-front-ng-establishment.d.ts +1 -37
- package/types/lucca-front-ng-fancy-box.d.ts +12 -0
- package/types/lucca-front-ng-footer.d.ts +3 -0
- package/types/lucca-front-ng-form-field.d.ts +36 -5
- package/types/lucca-front-ng-form-header.d.ts +3 -0
- 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-formatters-html.d.ts +7 -1
- package/types/lucca-front-ng-forms-rich-text-input-formatters-markdown.d.ts +11 -1
- package/types/lucca-front-ng-forms-rich-text-input-formatters-plain-text.d.ts +7 -1
- package/types/lucca-front-ng-forms-rich-text-input.d.ts +2 -0
- package/types/lucca-front-ng-forms.d.ts +21 -9
- package/types/lucca-front-ng-gauge.d.ts +25 -0
- package/types/lucca-front-ng-grid.d.ts +1 -1
- package/types/lucca-front-ng-highlight-data.d.ts +36 -15
- package/types/lucca-front-ng-horizontal-navigation.d.ts +3 -0
- package/types/lucca-front-ng-inline-message.d.ts +12 -0
- package/types/lucca-front-ng-link.d.ts +15 -0
- package/types/lucca-front-ng-listbox.d.ts +16 -4
- package/types/lucca-front-ng-listing.d.ts +33 -2
- package/types/lucca-front-ng-main-layout.d.ts +6 -0
- package/types/lucca-front-ng-mobile-push.d.ts +7 -0
- package/types/lucca-front-ng-modal.d.ts +3 -1
- package/types/lucca-front-ng-new-badge.d.ts +3 -0
- package/types/lucca-front-ng-numeric-badge.d.ts +9 -0
- package/types/lucca-front-ng-option.d.ts +78 -141
- package/types/lucca-front-ng-page-header.d.ts +9 -0
- package/types/lucca-front-ng-pagination.d.ts +25 -1
- package/types/lucca-front-ng-plg-push.d.ts +7 -1
- package/types/lucca-front-ng-popover.d.ts +1 -20
- package/types/lucca-front-ng-popover2.d.ts +7 -4
- package/types/lucca-front-ng-progress-bar.d.ts +9 -0
- package/types/lucca-front-ng-read-more.d.ts +16 -1
- package/types/lucca-front-ng-resource-card.d.ts +6 -0
- package/types/lucca-front-ng-scroll-box.d.ts +4 -1
- package/types/lucca-front-ng-segmented-control-tabs.d.ts +7 -1
- package/types/lucca-front-ng-segmented-control.d.ts +16 -1
- package/types/lucca-front-ng-skeleton.d.ts +61 -6
- package/types/lucca-front-ng-software-icon.d.ts +19 -0
- package/types/lucca-front-ng-sortable-list.d.ts +24 -0
- package/types/lucca-front-ng-status-badge.d.ts +12 -0
- package/types/lucca-front-ng-tag.d.ts +6 -0
- package/types/lucca-front-ng-text-flow.d.ts +8 -0
- package/types/lucca-front-ng-time.d.ts +18 -12
- package/types/lucca-front-ng-tooltip.d.ts +2 -11
- package/types/lucca-front-ng-user.d.ts +2 -11
- package/types/lucca-front-ng-vertical-navigation.d.ts +30 -0
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const lf_schematic_context_1 = require("../lib/lf-schematic-context");
|
|
3
|
+
const lib_1 = require("../lib");
|
|
5
4
|
// 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)
|
|
6
5
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
7
6
|
require('@angular-devkit/schematics');
|
|
8
7
|
exports.default = (options) => {
|
|
9
8
|
return async (tree, context) => {
|
|
10
|
-
await
|
|
11
|
-
await new
|
|
9
|
+
await lib_1.currentSchematicContext.init(context, options);
|
|
10
|
+
await new lib_1.CssMapper(tree, {
|
|
12
11
|
classes: {
|
|
13
12
|
'pr-u-textProduct': 'pr-u-colorTextProduct',
|
|
14
13
|
'pr-u-textPrimary': 'pr-u-colorTextProduct',
|
|
@@ -3,25 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const glob = require("glob");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const
|
|
6
|
+
const lib_1 = require("../lib");
|
|
7
7
|
const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
|
|
8
8
|
const testsRoot = path.join(__dirname, 'tests');
|
|
9
9
|
const files = fs.readdirSync(testsRoot);
|
|
10
10
|
describe('Color Text Migration', () => {
|
|
11
11
|
it('should update files', async () => {
|
|
12
12
|
// Arrange
|
|
13
|
-
const tree = (0,
|
|
14
|
-
const expectedTree = (0,
|
|
13
|
+
const tree = (0, lib_1.createTreeFromFiles)(testsRoot, files, '.input.');
|
|
14
|
+
const expectedTree = (0, lib_1.createTreeFromFiles)(testsRoot, files, '.output.');
|
|
15
15
|
// Act
|
|
16
16
|
try {
|
|
17
|
-
await (0,
|
|
17
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'color-text', { skipInstallation: true }, tree);
|
|
18
18
|
}
|
|
19
19
|
catch (error) {
|
|
20
20
|
// eslint-disable-next-line no-console
|
|
21
21
|
console.log(error);
|
|
22
22
|
}
|
|
23
23
|
// Assert
|
|
24
|
-
(0,
|
|
24
|
+
(0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
|
|
25
25
|
});
|
|
26
26
|
// Use this to migrate @lucca-front/* packages
|
|
27
27
|
it.skip('should migrate @lucca-front/*', async () => {
|
|
@@ -33,10 +33,10 @@ describe('Color Text Migration', () => {
|
|
|
33
33
|
...glob.sync('packages/ng/**/*', { cwd: lfRoot, nodir: true, ignore: ['**/schematics/**'] }),
|
|
34
34
|
...glob.sync('stories/**', { cwd: lfRoot, nodir: true }),
|
|
35
35
|
];
|
|
36
|
-
const treeOriginalTree = (0,
|
|
37
|
-
const tree = (0,
|
|
36
|
+
const treeOriginalTree = (0, lib_1.createTreeFromFiles)(lfRoot, lfFiles, '.');
|
|
37
|
+
const tree = (0, lib_1.createTreeFromFiles)(lfRoot, lfFiles, '.');
|
|
38
38
|
// Act
|
|
39
|
-
await (0,
|
|
39
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'color-text', { skipInstallation: true }, tree);
|
|
40
40
|
// Assert
|
|
41
41
|
tree.visit((p, entry) => {
|
|
42
42
|
const original = treeOriginalTree.get(p)?.content.toString() || '';
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const lf_schematic_context_1 = require("../lib/lf-schematic-context");
|
|
3
|
+
const lib_1 = require("../lib");
|
|
5
4
|
// 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)
|
|
6
5
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
7
6
|
require('@angular-devkit/schematics');
|
|
8
7
|
exports.default = (options) => {
|
|
9
8
|
return async (tree, context) => {
|
|
10
|
-
await
|
|
11
|
-
new
|
|
9
|
+
await lib_1.currentSchematicContext.init(context, options);
|
|
10
|
+
new lib_1.ComponentMapper(tree, {
|
|
12
11
|
paths: {
|
|
13
12
|
"@lucca-front/ng/scrollBox": "@lucca-front/ng/scroll-box",
|
|
14
13
|
"@lucca-front/ng/segmentedControl": "@lucca-front/ng/segmented-control",
|
|
@@ -3,25 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const glob = require("glob");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const
|
|
6
|
+
const lib_1 = require("../lib");
|
|
7
7
|
const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
|
|
8
8
|
const testsRoot = path.join(__dirname, 'tests');
|
|
9
9
|
const files = fs.readdirSync(testsRoot);
|
|
10
10
|
describe('Component path Migration', () => {
|
|
11
11
|
it('should update files', async () => {
|
|
12
12
|
// Arrange
|
|
13
|
-
const tree = (0,
|
|
14
|
-
const expectedTree = (0,
|
|
13
|
+
const tree = (0, lib_1.createTreeFromFiles)(testsRoot, files, '.input.');
|
|
14
|
+
const expectedTree = (0, lib_1.createTreeFromFiles)(testsRoot, files, '.output.');
|
|
15
15
|
// Act
|
|
16
16
|
try {
|
|
17
|
-
await (0,
|
|
17
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'component-path', { skipInstallation: true }, tree);
|
|
18
18
|
}
|
|
19
19
|
catch (error) {
|
|
20
20
|
//eslint-disable-next-line no-console
|
|
21
21
|
console.log(error);
|
|
22
22
|
}
|
|
23
23
|
// Assert
|
|
24
|
-
(0,
|
|
24
|
+
(0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
|
|
25
25
|
});
|
|
26
26
|
// Use this to migrate @lucca-front/* packages
|
|
27
27
|
it.skip('should migrate @lucca-front/*', async () => {
|
|
@@ -33,10 +33,10 @@ describe('Component path Migration', () => {
|
|
|
33
33
|
...glob.sync('packages/ng/**/*', { cwd: lfRoot, nodir: true, ignore: ['**/schematics/**'] }),
|
|
34
34
|
...glob.sync('stories/**', { cwd: lfRoot, nodir: true }),
|
|
35
35
|
];
|
|
36
|
-
const treeOriginalTree = (0,
|
|
37
|
-
const tree = (0,
|
|
36
|
+
const treeOriginalTree = (0, lib_1.createTreeFromFiles)(lfRoot, lfFiles, '.');
|
|
37
|
+
const tree = (0, lib_1.createTreeFromFiles)(lfRoot, lfFiles, '.');
|
|
38
38
|
// Act
|
|
39
|
-
await (0,
|
|
39
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'component-path', { skipInstallation: true }, tree);
|
|
40
40
|
// Assert
|
|
41
41
|
tree.visit((p, entry) => {
|
|
42
42
|
const original = treeOriginalTree.get(p)?.content.toString() || '';
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const schematics_1 = require("../lib/schematics");
|
|
5
|
-
const lf_schematic_context_1 = require("../lib/lf-schematic-context");
|
|
3
|
+
const lib_1 = require("../lib");
|
|
6
4
|
// 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
5
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
8
6
|
require('@angular-devkit/schematics');
|
|
9
7
|
exports.default = (options) => {
|
|
10
8
|
return async (tree, context) => {
|
|
11
|
-
await
|
|
9
|
+
await lib_1.currentSchematicContext.init(context, options);
|
|
12
10
|
tree.visit((path, entry) => {
|
|
13
11
|
if (path.includes('node_modules') || !entry) {
|
|
14
12
|
return;
|
|
15
13
|
}
|
|
16
|
-
(0,
|
|
17
|
-
template = (0,
|
|
18
|
-
template = (0,
|
|
14
|
+
(0, lib_1.migrateFile)(path, entry, tree, (content) => (0, lib_1.updateAngularTemplate)(path, content, (template) => {
|
|
15
|
+
template = (0, lib_1.replaceComponentInputName)('lu-empty-state-page', 'title', 'heading', template);
|
|
16
|
+
template = (0, lib_1.replaceComponentInputName)('lu-empty-state-section', 'title', 'heading', template);
|
|
19
17
|
return template;
|
|
20
18
|
}));
|
|
21
19
|
});
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path");
|
|
5
|
-
const
|
|
5
|
+
const lib_1 = require("../lib");
|
|
6
6
|
const collectionPath = path.normalize(path.join(__dirname, '..', 'migrations.json'));
|
|
7
7
|
const testsRoot = path.join(__dirname, 'tests');
|
|
8
8
|
const files = fs.readdirSync(testsRoot);
|
|
9
9
|
describe('Empty state title migration', () => {
|
|
10
10
|
it('should update files', async () => {
|
|
11
11
|
// Arrange
|
|
12
|
-
const tree = (0,
|
|
13
|
-
const expectedTree = (0,
|
|
12
|
+
const tree = (0, lib_1.createTreeFromFiles)(testsRoot, files, '.input.');
|
|
13
|
+
const expectedTree = (0, lib_1.createTreeFromFiles)(testsRoot, files, '.output.');
|
|
14
14
|
// Act
|
|
15
15
|
try {
|
|
16
|
-
await (0,
|
|
16
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'empty-state-heading', { skipInstallation: true }, tree);
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
19
|
// eslint-disable-next-line no-console
|
|
20
20
|
console.log(error);
|
|
21
21
|
}
|
|
22
22
|
// Assert
|
|
23
|
-
(0,
|
|
23
|
+
(0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
|
|
24
24
|
});
|
|
25
25
|
});
|
|
@@ -77,9 +77,17 @@ class HtmlAstVisitor {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
else if (node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstSwitchBlock) {
|
|
80
|
-
node
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
if ('groups' in node) {
|
|
81
|
+
node.groups.forEach((groupNode) => {
|
|
82
|
+
this.visit(cb, groupNode.children, node);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// TODO Remove when Angular 21 is no longer supported
|
|
86
|
+
if ('cases' in node) {
|
|
87
|
+
node.cases.forEach((caseNode) => {
|
|
88
|
+
this.visit(cb, caseNode.children, node);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
83
91
|
}
|
|
84
92
|
else if (node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstDeferredBlock || node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstElement || node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstTemplate) {
|
|
85
93
|
// Visit @defer and classic AST elements
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./angular-component-ast"), exports);
|
|
18
|
+
__exportStar(require("./angular-template"), exports);
|
|
19
|
+
__exportStar(require("./component-mapper"), exports);
|
|
20
|
+
__exportStar(require("./css-mapper"), exports);
|
|
21
|
+
__exportStar(require("./file-update"), exports);
|
|
22
|
+
__exportStar(require("./html-ast"), exports);
|
|
23
|
+
__exportStar(require("./lf-schematic-context"), exports);
|
|
24
|
+
__exportStar(require("./migration-test"), exports);
|
|
25
|
+
__exportStar(require("./schematic.utils"), exports);
|
|
26
|
+
__exportStar(require("./schematics"), exports);
|
|
27
|
+
__exportStar(require("./scss-ast"), exports);
|
|
28
|
+
__exportStar(require("./scss-value-ast"), exports);
|
|
29
|
+
__exportStar(require("./typescript-ast"), exports);
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.camelize = camelize;
|
|
4
4
|
exports.pascalize = pascalize;
|
|
5
5
|
exports.expand = expand;
|
|
6
|
+
exports.isInterestingNode = isInterestingNode;
|
|
7
|
+
const lf_schematic_context_1 = require("./lf-schematic-context");
|
|
6
8
|
function camelize(str) {
|
|
7
9
|
return str[0].toLowerCase() + str.slice(1);
|
|
8
10
|
}
|
|
@@ -27,3 +29,6 @@ function expand(rawMapping, mappingProps) {
|
|
|
27
29
|
return values;
|
|
28
30
|
}));
|
|
29
31
|
}
|
|
32
|
+
function isInterestingNode(node) {
|
|
33
|
+
return node instanceof lf_schematic_context_1.currentSchematicContext.angularCompiler.TmplAstElement;
|
|
34
|
+
}
|
|
@@ -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 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
|
+
// without content
|
|
40
|
+
else if (!container.node.isSelfClosing) {
|
|
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
|
-
}
|