@design-factory/design-factory 20.0.2 → 21.0.0-next.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 +2 -11
- package/fesm2022/design-factory.mjs +889 -1113
- package/fesm2022/design-factory.mjs.map +1 -1
- package/package.json +22 -51
- package/schematics/migrations/18_0_0/stepper-classes-18.0.0/index.js +1 -1
- package/schematics/migrations/21_0_0/ag-grid-neutral-header/index.d.ts +6 -0
- package/schematics/migrations/21_0_0/ag-grid-neutral-header/index.js +33 -0
- package/schematics/migrations/21_0_0/deleted-sass-vars/files/removed-vars.json +53 -0
- package/schematics/migrations/21_0_0/deleted-sass-vars/files/vars-with-value.json +4274 -0
- package/schematics/migrations/21_0_0/deleted-sass-vars/index.d.ts +7 -0
- package/schematics/migrations/21_0_0/deleted-sass-vars/index.js +90 -0
- package/schematics/migrations/21_0_0/style-import-package/index.d.ts +7 -0
- package/schematics/migrations/21_0_0/style-import-package/index.js +85 -0
- package/schematics/migrations/21_0_0/toast-classes-21.0/index.d.ts +2 -0
- package/schematics/migrations/21_0_0/toast-classes-21.0/index.js +36 -0
- package/schematics/migrations/migration.json +20 -0
- package/schematics/migrations/utils/add-dependencies.d.ts +3 -0
- package/schematics/migrations/utils/add-dependencies.js +41 -0
- package/schematics/migrations/utils/component-resource-collector.d.ts +3 -1
- package/schematics/migrations/utils/component-resource-collector.js +9 -4
- package/schematics/migrations/utils/style-updater.js +2 -2
- package/schematics/migrations/utils/template-updater.js +2 -2
- package/schematics/ng-add/index.js +12 -50
- package/{index.d.ts → types/design-factory.d.ts} +48 -71
- package/assets/.gitkeep +0 -0
- package/assets/fonts/amadeus-bold/amadeus-bold.woff +0 -0
- package/assets/fonts/amadeus-bold/amadeus-bold.woff2 +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-bold.woff +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-bold.woff2 +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-bolditalic.woff +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-bolditalic.woff2 +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-italic.woff +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-italic.woff2 +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-light.woff +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-light.woff2 +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-lightitalic.woff +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-lightitalic.woff2 +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-regular.woff +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-regular.woff2 +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-thin.woff +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-thin.woff2 +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-thinitalic.woff +0 -0
- package/assets/fonts/amadeus-full/amadeus-full-thinitalic.woff2 +0 -0
- package/assets/fonts/amadeus-neue/bold/AmadeusNeueWeb-Bold.woff +0 -0
- package/assets/fonts/amadeus-neue/bold/AmadeusNeueWeb-Bold.woff2 +0 -0
- package/assets/fonts/amadeus-neue/bold/AmadeusNeueWeb-BoldItalic.woff +0 -0
- package/assets/fonts/amadeus-neue/bold/AmadeusNeueWeb-BoldItalic.woff2 +0 -0
- package/assets/fonts/amadeus-neue/light/AmadeusNeueWeb-Light.woff +0 -0
- package/assets/fonts/amadeus-neue/light/AmadeusNeueWeb-Light.woff2 +0 -0
- package/assets/fonts/amadeus-neue/light/AmadeusNeueWeb-LightItalic.woff +0 -0
- package/assets/fonts/amadeus-neue/light/AmadeusNeueWeb-LightItalic.woff2 +0 -0
- package/assets/fonts/amadeus-neue/medium/AmadeusNeueWeb-Medium.woff +0 -0
- package/assets/fonts/amadeus-neue/medium/AmadeusNeueWeb-Medium.woff2 +0 -0
- package/assets/fonts/amadeus-neue/medium/AmadeusNeueWeb-MediumItalic.woff +0 -0
- package/assets/fonts/amadeus-neue/medium/AmadeusNeueWeb-MediumItalic.woff2 +0 -0
- package/assets/fonts/amadeus-neue/regular/AmadeusNeueWeb-Regular.woff +0 -0
- package/assets/fonts/amadeus-neue/regular/AmadeusNeueWeb-Regular.woff2 +0 -0
- package/assets/fonts/amadeus-neue/regular/AmadeusNeueWeb-RegularItalic.woff +0 -0
- package/assets/fonts/amadeus-neue/regular/AmadeusNeueWeb-RegularItalic.woff2 +0 -0
- package/assets/fonts/amadeus-regular/amadeus-regular.woff +0 -0
- package/assets/fonts/amadeus-regular/amadeus-regular.woff2 +0 -0
- package/assets/fonts/amadeus-thin/amadeus-thin.woff +0 -0
- package/assets/fonts/amadeus-thin/amadeus-thin.woff2 +0 -0
- package/assets/fonts/df-icons/df-icons-light.woff2 +0 -0
- package/assets/fonts/df-icons/df-icons-solid.woff2 +0 -0
- package/assets/fonts/font-awesome/fa-brands-400.woff2 +0 -0
- package/assets/fonts/font-awesome/fa-light-300.woff2 +0 -0
- package/assets/fonts/font-awesome/fa-solid-900.woff2 +0 -0
- package/assets/fonts/noto/notosans-bold.woff +0 -0
- package/assets/fonts/noto/notosans-bold.woff2 +0 -0
- package/assets/fonts/noto/notosans-bolditalic.woff +0 -0
- package/assets/fonts/noto/notosans-bolditalic.woff2 +0 -0
- package/assets/fonts/noto/notosans-italic.woff +0 -0
- package/assets/fonts/noto/notosans-italic.woff2 +0 -0
- package/assets/fonts/noto/notosans-light.woff +0 -0
- package/assets/fonts/noto/notosans-light.woff2 +0 -0
- package/assets/fonts/noto/notosans-lightitalic.woff +0 -0
- package/assets/fonts/noto/notosans-lightitalic.woff2 +0 -0
- package/assets/fonts/noto/notosans-regular.woff +0 -0
- package/assets/fonts/noto/notosans-regular.woff2 +0 -0
- package/assets/fonts/noto/notosans-thin.woff +0 -0
- package/assets/fonts/noto/notosans-thin.woff2 +0 -0
- package/assets/fonts/noto/notosans-thinitalic.woff +0 -0
- package/assets/fonts/noto/notosans-thinitalic.woff2 +0 -0
- package/assets/fonts/noto/notosansarabic-bold.woff +0 -0
- package/assets/fonts/noto/notosansarabic-bold.woff2 +0 -0
- package/assets/fonts/noto/notosansarabic-light.woff +0 -0
- package/assets/fonts/noto/notosansarabic-light.woff2 +0 -0
- package/assets/fonts/noto/notosansarabic-regular.woff +0 -0
- package/assets/fonts/noto/notosansarabic-regular.woff2 +0 -0
- package/assets/fonts/noto/notosansarabic-thin.woff +0 -0
- package/assets/fonts/noto/notosansarabic-thin.woff2 +0 -0
- package/assets/fonts/noto/notosansgeorgian-bold.woff +0 -0
- package/assets/fonts/noto/notosansgeorgian-bold.woff2 +0 -0
- package/assets/fonts/noto/notosansgeorgian-light.woff +0 -0
- package/assets/fonts/noto/notosansgeorgian-light.woff2 +0 -0
- package/assets/fonts/noto/notosansgeorgian-regular.woff +0 -0
- package/assets/fonts/noto/notosansgeorgian-regular.woff2 +0 -0
- package/assets/fonts/noto/notosansgeorgian-thin.woff +0 -0
- package/assets/fonts/noto/notosansgeorgian-thin.woff2 +0 -0
- package/assets/fonts/noto/notosanshebrew-bold.woff +0 -0
- package/assets/fonts/noto/notosanshebrew-bold.woff2 +0 -0
- package/assets/fonts/noto/notosanshebrew-light.woff +0 -0
- package/assets/fonts/noto/notosanshebrew-light.woff2 +0 -0
- package/assets/fonts/noto/notosanshebrew-regular.woff +0 -0
- package/assets/fonts/noto/notosanshebrew-regular.woff2 +0 -0
- package/assets/fonts/noto/notosanshebrew-thin.woff +0 -0
- package/assets/fonts/noto/notosanshebrew-thin.woff2 +0 -0
- package/assets/fonts/source-sans-pro-bold/source-sans-pro-bold.woff +0 -0
- package/assets/fonts/source-sans-pro-bold/source-sans-pro-bold.woff2 +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-bold.woff +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-bold.woff2 +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-bolditalic.woff +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-bolditalic.woff2 +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-italic.woff +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-italic.woff2 +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-light.woff +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-light.woff2 +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-lightitalic.woff +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-lightitalic.woff2 +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-regular.woff +0 -0
- package/assets/fonts/source-sans-pro-full/sourcesanspro-full-regular.woff2 +0 -0
- package/assets/fonts/source-sans-pro-light/source-sans-pro-light.woff +0 -0
- package/assets/fonts/source-sans-pro-light/source-sans-pro-light.woff2 +0 -0
- package/assets/fonts/source-sans-pro-regular/source-sans-pro-regular.woff +0 -0
- package/assets/fonts/source-sans-pro-regular/source-sans-pro-regular.woff2 +0 -0
- package/assets/fonts/source-sans-pro-semibold/source-sans-pro-semibold.woff +0 -0
- package/assets/fonts/source-sans-pro-semibold/source-sans-pro-semibold.woff2 +0 -0
- package/design-factory-initial-branding.css +0 -13
- package/design-factory-initial-branding.scss +0 -1
- package/design-factory-utilities.scss +0 -5
- package/design-factory.css +0 -13
- package/design-factory.scss +0 -3
- package/fesm2022/design-factory-design-factory-tokens-style-dictionary.mjs +0 -358
- package/fesm2022/design-factory-design-factory-tokens-style-dictionary.mjs.map +0 -1
- package/styles/scss/_common.mixins.scss +0 -30
- package/styles/scss/_common.root.scss +0 -70
- package/styles/scss/_common.scss +0 -51
- package/styles/scss/_common.variables.scss +0 -79
- package/styles/scss/_variables.scss +0 -61
- package/styles/scss/agnosui/_variables.scss +0 -28
- package/styles/scss/bootstrap/_maps.scss +0 -52
- package/styles/scss/bootstrap/_mixins-override.scss +0 -69
- package/styles/scss/bootstrap/_rtl-styles-override.scss +0 -127
- package/styles/scss/bootstrap/_utilities-override.scss +0 -25
- package/styles/scss/bootstrap/_variables-dark.scss +0 -86
- package/styles/scss/bootstrap/_variables.scss +0 -2622
- package/styles/scss/components/.gitkeep +0 -0
- package/styles/scss/components/accordion/_accordion.scss +0 -241
- package/styles/scss/components/accordion/_accordion.variables.scss +0 -19
- package/styles/scss/components/alert/_alert.scss +0 -236
- package/styles/scss/components/alert/_alert.variables.scss +0 -56
- package/styles/scss/components/badge/_badge.mixins.scss +0 -23
- package/styles/scss/components/badge/_badge.scss +0 -483
- package/styles/scss/components/badge/_badge.variables.scss +0 -28
- package/styles/scss/components/brand-color/_brand-color.mixins.scss +0 -42
- package/styles/scss/components/brand-color/_brand-color.scss +0 -20
- package/styles/scss/components/brand-color/_brand-color.variables.scss +0 -152
- package/styles/scss/components/brand-color/_brand-color_container.scss +0 -23
- package/styles/scss/components/breadcrumbs/_breadcrumbs.scss +0 -127
- package/styles/scss/components/breadcrumbs/_breadcrumbs.variables.scss +0 -21
- package/styles/scss/components/button/_button.scss +0 -1090
- package/styles/scss/components/button/_button.utils.scss +0 -35
- package/styles/scss/components/button/_button.variables.scss +0 -48
- package/styles/scss/components/button/_button_container.scss +0 -47
- package/styles/scss/components/card/_card.scss +0 -208
- package/styles/scss/components/card/_card.variables.scss +0 -33
- package/styles/scss/components/carousel/_carousel.scss +0 -51
- package/styles/scss/components/carousel/_carousel.variables.scss +0 -12
- package/styles/scss/components/checkbox/_checkbox.scss +0 -68
- package/styles/scss/components/checkbox/_checkbox.variables.scss +0 -7
- package/styles/scss/components/collapse/_collapse.scss +0 -99
- package/styles/scss/components/collapse/_collapse.variables.scss +0 -7
- package/styles/scss/components/datepicker/_datepicker.scss +0 -362
- package/styles/scss/components/datepicker/_datepicker.variables.scss +0 -64
- package/styles/scss/components/dropdown/_dropdown.mixins.scss +0 -8
- package/styles/scss/components/dropdown/_dropdown.scss +0 -178
- package/styles/scss/components/dropdown/_dropdown.variables.scss +0 -24
- package/styles/scss/components/fieldset/_fieldset.scss +0 -8
- package/styles/scss/components/fieldset/_fieldset.variables.scss +0 -2
- package/styles/scss/components/fonts/_font-awesome-icons-brands.scss +0 -1585
- package/styles/scss/components/fonts/_font-awesome-icons.scss +0 -12886
- package/styles/scss/components/fonts/_font-faces.mixins.scss +0 -579
- package/styles/scss/components/fonts/_fonts-family.scss +0 -229
- package/styles/scss/components/fonts/_fonts.root.scss +0 -28
- package/styles/scss/components/fonts/_fonts.scss +0 -101
- package/styles/scss/components/fonts/_fonts.variables.scss +0 -33
- package/styles/scss/components/fonts/_icon-font.scss +0 -94
- package/styles/scss/components/fonts/_icon-font.variables.scss +0 -14
- package/styles/scss/components/fonts/_multi-lang.mixins.scss +0 -8
- package/styles/scss/components/fonts/multi-lang/_arabic.mixins.scss +0 -12
- package/styles/scss/components/fonts/multi-lang/_chinese.mixins.scss +0 -21
- package/styles/scss/components/fonts/multi-lang/_cyrillic-extended.mixins.scss +0 -11
- package/styles/scss/components/fonts/multi-lang/_cyrillic.mixins.scss +0 -10
- package/styles/scss/components/fonts/multi-lang/_georgian.mixins.scss +0 -13
- package/styles/scss/components/fonts/multi-lang/_hebrew.mixins.scss +0 -13
- package/styles/scss/components/fonts/multi-lang/_japanese.mixins.scss +0 -33
- package/styles/scss/components/fonts/multi-lang/_korean.mixins.scss +0 -18
- package/styles/scss/components/footer/_footer.mixins.scss +0 -36
- package/styles/scss/components/footer/_footer.scss +0 -86
- package/styles/scss/components/footer/_footer.variables.scss +0 -14
- package/styles/scss/components/form/_form.scss +0 -206
- package/styles/scss/components/form/_form.variables.scss +0 -34
- package/styles/scss/components/icon/_amadeus-icon.scss +0 -39
- package/styles/scss/components/icon/_amadeus-icon.variables.scss +0 -4
- package/styles/scss/components/inputs/_inputs.mixin.scss +0 -125
- package/styles/scss/components/inputs/_inputs.root.scss +0 -8
- package/styles/scss/components/inputs/_inputs.scss +0 -292
- package/styles/scss/components/inputs/_inputs.variables.scss +0 -39
- package/styles/scss/components/link/_link.mixins.scss +0 -198
- package/styles/scss/components/link/_link.scss +0 -170
- package/styles/scss/components/link/_link.variables.scss +0 -55
- package/styles/scss/components/list/_list.scss +0 -20
- package/styles/scss/components/list/_list.variables.scss +0 -4
- package/styles/scss/components/list-group/_list-group.scss +0 -101
- package/styles/scss/components/list-group/_list-group.variables.scss +0 -10
- package/styles/scss/components/media/_media.scss +0 -89
- package/styles/scss/components/media/_media.variables.scss +0 -19
- package/styles/scss/components/modal/_modal.scss +0 -247
- package/styles/scss/components/modal/_modal.variables.scss +0 -29
- package/styles/scss/components/navbar/_navbar.mixins.scss +0 -55
- package/styles/scss/components/navbar/_navbar.scss +0 -563
- package/styles/scss/components/navbar/_navbar.variables.scss +0 -102
- package/styles/scss/components/pagination/_pagination.scss +0 -251
- package/styles/scss/components/pagination/_pagination.variables.scss +0 -35
- package/styles/scss/components/pagination/_pagination_container.scss +0 -17
- package/styles/scss/components/popover/_popover.mixin.scss +0 -46
- package/styles/scss/components/popover/_popover.scss +0 -45
- package/styles/scss/components/popover/_popover.variables.scss +0 -25
- package/styles/scss/components/popover/_popover_container.scss +0 -214
- package/styles/scss/components/progressbar/_progressbar.scss +0 -93
- package/styles/scss/components/progressbar/_progressbar.variables.scss +0 -28
- package/styles/scss/components/radio/_radio.scss +0 -50
- package/styles/scss/components/radio/_radio.variables.scss +0 -4
- package/styles/scss/components/rating/_rating.scss +0 -118
- package/styles/scss/components/rating/_rating.variables.scss +0 -20
- package/styles/scss/components/scrollspy/_scrollspy.scss +0 -88
- package/styles/scss/components/scrollspy/_scrollspy.variables.scss +0 -23
- package/styles/scss/components/select/_select.mixin.scss +0 -34
- package/styles/scss/components/select/_select.scss +0 -804
- package/styles/scss/components/select/_select.variables.scss +0 -89
- package/styles/scss/components/separator/_separator.scss +0 -9
- package/styles/scss/components/separator/_separator.variables.scss +0 -1
- package/styles/scss/components/sidenav/_sidenav.scss +0 -347
- package/styles/scss/components/sidenav/_sidenav.variables.scss +0 -104
- package/styles/scss/components/skip-links/_skip-links.scss +0 -40
- package/styles/scss/components/skip-links/_skip-links.variables.scss +0 -9
- package/styles/scss/components/slider/_slider.scss +0 -422
- package/styles/scss/components/slider/_slider.variables.scss +0 -59
- package/styles/scss/components/speechbubble/_speechbubble.scss +0 -166
- package/styles/scss/components/speechbubble/_speechbubble.variables.scss +0 -27
- package/styles/scss/components/spinner/_spinner.scss +0 -126
- package/styles/scss/components/spinner/_spinner.variables.scss +0 -30
- package/styles/scss/components/spinner/_spinner_container.scss +0 -43
- package/styles/scss/components/stepper/_stepper.mixins.scss +0 -176
- package/styles/scss/components/stepper/_stepper.scss +0 -254
- package/styles/scss/components/stepper/_stepper.variables.scss +0 -88
- package/styles/scss/components/table/_advancedtables.scss +0 -306
- package/styles/scss/components/table/_table.scss +0 -19
- package/styles/scss/components/table/_table.variables.scss +0 -37
- package/styles/scss/components/tabs/_tabs.scss +0 -277
- package/styles/scss/components/tabs/_tabs.variables.scss +0 -36
- package/styles/scss/components/timepicker/_timepicker.scss +0 -5
- package/styles/scss/components/timepicker/_timepicker.variables.scss +0 -1
- package/styles/scss/components/toast/_toast.scss +0 -354
- package/styles/scss/components/toast/_toast.variables.scss +0 -18
- package/styles/scss/components/toggle/_toggle.scss +0 -145
- package/styles/scss/components/toggle/_toggle.variables.scss +0 -22
- package/styles/scss/components/tooltip/_tooltip.scss +0 -24
- package/styles/scss/components/tooltip/_tooltip.variables.scss +0 -6
- package/styles/scss/components/tooltip/_tooltip_container.scss +0 -116
- package/styles/scss/components/typeahead/_typeahead.scss +0 -59
- package/styles/scss/components/typeahead/_typeahead.variables.scss +0 -11
- package/styles/scss/df-styles-namespace.scss +0 -165
- package/styles/scss/df-styles.scss +0 -117
- package/styles/scss/themes/brand2023/_variables.scss +0 -1140
- package/styles/scss/themes/brand2023/tokens/_mapping.gen.scss +0 -868
- package/styles/scss/themes/brand2023/tokens/_root.gen.scss +0 -1709
- package/styles/scss/themes/brand2023/tokens/_sass-vars.gen.scss +0 -1468
- package/styles/scss/utilities/_common.utilities.scss +0 -205
- package/styles/scss/utilities/_form.mixins.scss +0 -26
- package/styles/scss/utilities/_rgb.scss +0 -10
- package/tokens/style-dictionary/index.d.ts +0 -60
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = deletedSassVars;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const project_tsconfig_paths_1 = require("../../utils/project_tsconfig_paths");
|
|
6
|
+
const compiler_host_1 = require("../../utils/typescript/compiler_host");
|
|
7
|
+
const style_updater_1 = require("../../utils/style-updater");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const core_1 = require("@angular-devkit/core");
|
|
11
|
+
const removedWithWarning = new Set(JSON.parse((0, fs_1.readFileSync)(__dirname + '/files/removed-vars.json', { encoding: 'utf-8' })));
|
|
12
|
+
const removedWithValue = JSON.parse((0, fs_1.readFileSync)(__dirname + '/files/vars-with-value.json', { encoding: 'utf-8' }));
|
|
13
|
+
const regexDefinition = /\s*(\$[a-z-]+)\s*:\s*([^;]+);\s*/g;
|
|
14
|
+
const regexUse = /(#\{\s*)?(\$[a-z-]+)\}?/g;
|
|
15
|
+
/**
|
|
16
|
+
* This migration
|
|
17
|
+
*
|
|
18
|
+
* @returns the Rule to migrate the classes
|
|
19
|
+
*/
|
|
20
|
+
function deletedSassVars() {
|
|
21
|
+
return async (tree, context) => {
|
|
22
|
+
const { buildPaths, testPaths } = await (0, project_tsconfig_paths_1.getProjectTsConfigPaths)(tree);
|
|
23
|
+
const basePath = process.cwd();
|
|
24
|
+
const allPaths = [...buildPaths, ...testPaths];
|
|
25
|
+
if (!allPaths.length) {
|
|
26
|
+
throw new schematics_1.SchematicsException('Could not find any tsconfig file. Cannot run the `deletedSassVars` migration.');
|
|
27
|
+
}
|
|
28
|
+
const varsMap = new Map();
|
|
29
|
+
for (const rename of removedWithValue) {
|
|
30
|
+
varsMap.set(rename.name, rename.value);
|
|
31
|
+
}
|
|
32
|
+
// first we search for re-declaration of the values... normally should be in main scss files
|
|
33
|
+
tree.visit((_, entry) => {
|
|
34
|
+
const path = entry?.path;
|
|
35
|
+
if (path && path.endsWith('.scss')) {
|
|
36
|
+
const styleText = entry.content.toString('utf-8');
|
|
37
|
+
let match;
|
|
38
|
+
while ((match = regexDefinition.exec(styleText)) !== null) {
|
|
39
|
+
const varName = match[1];
|
|
40
|
+
const varValue = match[2];
|
|
41
|
+
if (varsMap.has(varName)) {
|
|
42
|
+
// we found a re-declaration, we update the value in the map
|
|
43
|
+
varsMap.set(varName, varValue);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
regexDefinition.lastIndex = 0; // reset regex state
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const replaceStyleContent = (content, filePath) => {
|
|
50
|
+
return content
|
|
51
|
+
.replace(regexDefinition, (match, grp1) => (varsMap.has(grp1) ? '' : match))
|
|
52
|
+
.replace(regexUse, (match, _grp1, grp2) => {
|
|
53
|
+
if (varsMap.has(grp2)) {
|
|
54
|
+
return varsMap.get(grp2);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
if (removedWithWarning.has(grp2)) {
|
|
58
|
+
context.logger.warn(`Sass var ${grp2} used in ${filePath} was removed in the new version of Design Factory.`);
|
|
59
|
+
}
|
|
60
|
+
return match;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const templateUpdater = new style_updater_1.StyleUpdater(tree, replaceStyleContent);
|
|
65
|
+
for (const tsconfigPath of allPaths) {
|
|
66
|
+
const program = (0, compiler_host_1.createMigrationProgram)(tree, tsconfigPath, basePath);
|
|
67
|
+
const sourceFiles = program
|
|
68
|
+
.getSourceFiles()
|
|
69
|
+
.filter((sourceFile) => (0, compiler_host_1.canMigrateFile)(basePath, sourceFile, program));
|
|
70
|
+
for (const sourceFile of sourceFiles) {
|
|
71
|
+
templateUpdater.update(sourceFile, program.getTypeChecker());
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
tree.visit((_, entry) => {
|
|
75
|
+
const path = entry?.path;
|
|
76
|
+
if (path && path.endsWith('.scss')) {
|
|
77
|
+
const normalizedPath = (0, core_1.normalize)(path_1.posix.resolve(path.toString().substring(1)));
|
|
78
|
+
if (templateUpdater['_analyzedFiles'].has(normalizedPath)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const styleText = entry.content.toString();
|
|
82
|
+
const modifiedText = replaceStyleContent(styleText, path.toString().substring(1));
|
|
83
|
+
if (modifiedText !== styleText) {
|
|
84
|
+
tree.overwrite(path, modifiedText);
|
|
85
|
+
}
|
|
86
|
+
templateUpdater['_analyzedFiles'].add(normalizedPath);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Rule } from '@angular-devkit/schematics';
|
|
2
|
+
/**
|
|
3
|
+
* This migration updates the global styles to import the correct package of design factory styles.
|
|
4
|
+
*
|
|
5
|
+
* @returns the Rule to migrate the style import
|
|
6
|
+
*/
|
|
7
|
+
export default function styleImportPackage(): Rule;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = styleImportPackage;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
6
|
+
const add_dependencies_1 = require("../../utils/add-dependencies");
|
|
7
|
+
const importRegex = /(['"])(@design-factory\/design-factory\/[^'"]+)\1/g;
|
|
8
|
+
const cssBundleRegex = /^@design-factory\/design-factory\/design-factory\.css$/;
|
|
9
|
+
const scssBundleRegex = /^@design-factory\/design-factory\/design-factory(\.scss)?$/;
|
|
10
|
+
const scssUtilitiesRegex = /^@design-factory\/design-factory\/design-factory-utilities(\.scss)?$/;
|
|
11
|
+
const scssNamespaceRegex = /^@design-factory\/design-factory\/styles\/scss\/df-styles-namespace(\.scss)?$/;
|
|
12
|
+
const scssFolderRegex = /^@design-factory\/design-factory\/styles\/scss\/(.*)$/;
|
|
13
|
+
const assetsFolderRegex = /^@design-factory\/design-factory\/assets\/(.*)$/;
|
|
14
|
+
const scssTheme2023Regex = /@(import|use)\s+['"]@design-factory\/design-factory\/styles\/scss\/themes\/brand2023\/variables(\.scss)?['"][^\n]*\n?/;
|
|
15
|
+
/**
|
|
16
|
+
* This migration updates the global styles to import the correct package of design factory styles.
|
|
17
|
+
*
|
|
18
|
+
* @returns the Rule to migrate the style import
|
|
19
|
+
*/
|
|
20
|
+
function styleImportPackage() {
|
|
21
|
+
return (tree, _context) => {
|
|
22
|
+
const forcePackages = new Set();
|
|
23
|
+
const useScss = () => {
|
|
24
|
+
forcePackages.add('bootstrap');
|
|
25
|
+
forcePackages.add('@agnos-ui/core-bootstrap');
|
|
26
|
+
};
|
|
27
|
+
const transformImport = (importPath, forceExtension = false) => {
|
|
28
|
+
if (cssBundleRegex.test(importPath)) {
|
|
29
|
+
return `@design-factory/styles/bundle${forceExtension ? '.css' : ''}`;
|
|
30
|
+
}
|
|
31
|
+
if (scssBundleRegex.test(importPath)) {
|
|
32
|
+
useScss();
|
|
33
|
+
return `@design-factory/styles/scss/bundle${forceExtension ? '.scss' : ''}`;
|
|
34
|
+
}
|
|
35
|
+
if (scssUtilitiesRegex.test(importPath)) {
|
|
36
|
+
useScss();
|
|
37
|
+
return `@design-factory/styles/scss/utilities${forceExtension ? '.scss' : ''}`;
|
|
38
|
+
}
|
|
39
|
+
if (scssNamespaceRegex.test(importPath)) {
|
|
40
|
+
useScss();
|
|
41
|
+
return `@design-factory/styles/scss/namespace${forceExtension ? '.scss' : ''}`;
|
|
42
|
+
}
|
|
43
|
+
const scssFolderMatch = scssFolderRegex.exec(importPath);
|
|
44
|
+
if (scssFolderMatch && scssFolderMatch[1]) {
|
|
45
|
+
useScss();
|
|
46
|
+
return `@design-factory/styles/scss/${scssFolderMatch[1]}`;
|
|
47
|
+
}
|
|
48
|
+
const assetsFolderMatch = assetsFolderRegex.exec(importPath);
|
|
49
|
+
if (assetsFolderMatch && assetsFolderMatch[1]) {
|
|
50
|
+
return `@design-factory/styles/assets/${assetsFolderMatch[1]}`;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
};
|
|
54
|
+
const replaceImport = (match, quotes, importPath) => {
|
|
55
|
+
const modifiedImport = transformImport(importPath);
|
|
56
|
+
if (modifiedImport) {
|
|
57
|
+
return `${quotes}${modifiedImport}${quotes}`;
|
|
58
|
+
}
|
|
59
|
+
return match;
|
|
60
|
+
};
|
|
61
|
+
tree.visit((_, entry) => {
|
|
62
|
+
const path = entry?.path;
|
|
63
|
+
if (path && (path.endsWith('.scss') || path.endsWith('.css'))) {
|
|
64
|
+
const styleText = entry.content.toString();
|
|
65
|
+
const modifiedText = styleText.replace(scssTheme2023Regex, '').replace(importRegex, replaceImport);
|
|
66
|
+
if (modifiedText !== styleText) {
|
|
67
|
+
tree.overwrite(path, modifiedText);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return (0, schematics_1.chain)([
|
|
72
|
+
(0, workspace_1.updateWorkspace)((workspace) => {
|
|
73
|
+
for (const project of workspace.projects.values()) {
|
|
74
|
+
for (const target of project.targets.values()) {
|
|
75
|
+
if (Array.isArray(target.options?.['styles'])) {
|
|
76
|
+
target.options['styles'] = target.options['styles'].map((style) => typeof style === 'string' ? (transformImport(style, true) ?? style) : style);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
(0, add_dependencies_1.addDependencies)(forcePackages),
|
|
82
|
+
(0, add_dependencies_1.install)()
|
|
83
|
+
]);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = toastClassesUpdate;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const project_tsconfig_paths_1 = require("../../utils/project_tsconfig_paths");
|
|
6
|
+
const template_updater_1 = require("../../utils/template-updater");
|
|
7
|
+
const compiler_host_1 = require("../../utils/typescript/compiler_host");
|
|
8
|
+
const regexDismissible = /df-toast-dismissible/g;
|
|
9
|
+
const regexBtnOutline = /(<ngb-toast(?:(?!df-toast-subtle)[\s\S])*?>[\s\S]*?<button[\s\S]*?class="[^"]*\b)(btn-outline-neutral)(\b[^"]*)/g;
|
|
10
|
+
const regexBtnClose = /(<ngb-toast[\s\S]*?<button[\s\S]*?class="[^"]*\b)(btn-close)(\b[^"]*)/g;
|
|
11
|
+
function replaceHtmlContent(content) {
|
|
12
|
+
content = content.replace(regexDismissible, ''); //remove df-toast-dismissible class
|
|
13
|
+
content = content.replace(regexBtnOutline, (_, g1, _1, g3) => `${g1}df-btn-outline-neutral-mirror${g3}`); // uses appropriate class on subtale toast
|
|
14
|
+
content = content.replace(regexBtnClose, (_, g1, _1, g3) => `${g1}df-btn-icononly fal fa-xmark ms-5${g3}`); //removes btn close
|
|
15
|
+
return content;
|
|
16
|
+
}
|
|
17
|
+
function toastClassesUpdate() {
|
|
18
|
+
return async (tree) => {
|
|
19
|
+
const { buildPaths, testPaths } = await (0, project_tsconfig_paths_1.getProjectTsConfigPaths)(tree);
|
|
20
|
+
const basePath = process.cwd();
|
|
21
|
+
const allPaths = [...buildPaths, ...testPaths];
|
|
22
|
+
if (!allPaths.length) {
|
|
23
|
+
throw new schematics_1.SchematicsException('Could not find any tsconfig file. Cannot run the `ToastClassesUpdate` migration.');
|
|
24
|
+
}
|
|
25
|
+
const templateUpdater = new template_updater_1.TemplateUpdater(tree, replaceHtmlContent);
|
|
26
|
+
for (const tsconfigPath of allPaths) {
|
|
27
|
+
const program = (0, compiler_host_1.createMigrationProgram)(tree, tsconfigPath, basePath);
|
|
28
|
+
const sourceFiles = program
|
|
29
|
+
.getSourceFiles()
|
|
30
|
+
.filter((sourceFile) => (0, compiler_host_1.canMigrateFile)(basePath, sourceFile, program));
|
|
31
|
+
for (const sourceFile of sourceFiles) {
|
|
32
|
+
templateUpdater.update(sourceFile, program.getTypeChecker());
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -75,6 +75,26 @@
|
|
|
75
75
|
"description": "DfModalService has been removed and replaced with NgbModal.",
|
|
76
76
|
"version": "20.0.0",
|
|
77
77
|
"factory": "./20_0_0/modal-removal"
|
|
78
|
+
},
|
|
79
|
+
"style-import-package": {
|
|
80
|
+
"description": "The package from which Design Factory styles are imported has changed.",
|
|
81
|
+
"version": "21.0.0",
|
|
82
|
+
"factory": "./21_0_0/style-import-package"
|
|
83
|
+
},
|
|
84
|
+
"ag-grid-zebra-header-class": {
|
|
85
|
+
"description": "The class `df-table-white-header` is replaced by `df-table-neutral-alt-header`",
|
|
86
|
+
"version": "21.0.0",
|
|
87
|
+
"factory": "./21_0_0/ag-grid-neutral-header"
|
|
88
|
+
},
|
|
89
|
+
"toast-classes-21.0": {
|
|
90
|
+
"description": "As of Design Factory version 21, some css classes for the toast have been renamed.",
|
|
91
|
+
"version": "21.0.0",
|
|
92
|
+
"factory": "./21_0_0/toast-classes-21.0"
|
|
93
|
+
},
|
|
94
|
+
"deleted-sass-vars": {
|
|
95
|
+
"description": "As of Design Factory version 21, some deprecated sass variables have been removed. This migration helps you identify and fix usages of these variables in your codebase.",
|
|
96
|
+
"version": "21.0.0",
|
|
97
|
+
"factory": "./21_0_0/deleted-sass-vars"
|
|
78
98
|
}
|
|
79
99
|
}
|
|
80
100
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addDependencies = addDependencies;
|
|
4
|
+
exports.install = install;
|
|
5
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
6
|
+
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const listPeerDependencies = function* (pkgJson) {
|
|
10
|
+
for (const [name, version] of Object.entries(pkgJson.peerDependencies)) {
|
|
11
|
+
yield { name, version, required: !pkgJson['peerDependenciesMeta']?.[name]?.optional };
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
// Explicitly add the peer dependencies as main dependencies.
|
|
15
|
+
function addDependencies(forcePackages) {
|
|
16
|
+
return (tree) => {
|
|
17
|
+
const treePackageJson = JSON.parse(tree.read('package.json').toString('utf-8'));
|
|
18
|
+
const dfPackageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '..', '..', '..', 'package.json'), { encoding: 'utf-8' }));
|
|
19
|
+
const dfStylesPackageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '..', '..', '..', '..', 'styles', 'package.json'), { encoding: 'utf-8' }));
|
|
20
|
+
for (const { name, version, required } of [
|
|
21
|
+
...listPeerDependencies(dfStylesPackageJson),
|
|
22
|
+
...listPeerDependencies(dfPackageJson)
|
|
23
|
+
]) {
|
|
24
|
+
if (required || !!treePackageJson.dependencies?.[name] || forcePackages?.has(name)) {
|
|
25
|
+
(0, dependencies_1.addPackageJsonDependency)(tree, {
|
|
26
|
+
type: dependencies_1.NodeDependencyType.Default,
|
|
27
|
+
name,
|
|
28
|
+
version,
|
|
29
|
+
overwrite: !name.startsWith('@angular/')
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// Schedule a package install, also installing the dependencies set up in the above step.
|
|
36
|
+
function install() {
|
|
37
|
+
return (tree, context) => {
|
|
38
|
+
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
39
|
+
return tree;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -19,6 +19,8 @@ export interface ResolvedResource {
|
|
|
19
19
|
inline: boolean;
|
|
20
20
|
/** Path to the file that contains this resource. */
|
|
21
21
|
filePath: string;
|
|
22
|
+
/** Absolute path to the file that contains this resource. */
|
|
23
|
+
absFilePath: string;
|
|
22
24
|
/**
|
|
23
25
|
* Gets the character and line of a given position index in the resource.
|
|
24
26
|
* If the resource is declared inline within a TypeScript source file, the line and
|
|
@@ -39,6 +41,6 @@ export declare class ComponentResourceCollector {
|
|
|
39
41
|
visitNode(node: ts.Node): void;
|
|
40
42
|
private _visitClassDeclaration;
|
|
41
43
|
/** Resolves an external stylesheet by reading its content and computing line mappings. */
|
|
42
|
-
resolveExternalStylesheet(filePath: string, container: ts.ClassDeclaration | null): ResolvedResource | null;
|
|
44
|
+
resolveExternalStylesheet(filePath: string, absFilePath: string, container: ts.ClassDeclaration | null): ResolvedResource | null;
|
|
43
45
|
private _trackExternalStylesheet;
|
|
44
46
|
}
|
|
@@ -76,6 +76,7 @@ class ComponentResourceCollector {
|
|
|
76
76
|
const content = stripBom(el.getText().slice(1, -1));
|
|
77
77
|
this.resolvedStylesheets.push({
|
|
78
78
|
filePath,
|
|
79
|
+
absFilePath,
|
|
79
80
|
container: node,
|
|
80
81
|
content,
|
|
81
82
|
inline: true,
|
|
@@ -93,6 +94,7 @@ class ComponentResourceCollector {
|
|
|
93
94
|
const templateStartIdx = property.initializer.getStart() + 1;
|
|
94
95
|
this.resolvedTemplates.push({
|
|
95
96
|
filePath,
|
|
97
|
+
absFilePath,
|
|
96
98
|
container: node,
|
|
97
99
|
content: property.initializer.getText().slice(1, -1),
|
|
98
100
|
inline: true,
|
|
@@ -124,6 +126,7 @@ class ComponentResourceCollector {
|
|
|
124
126
|
const lineStartsMap = (0, line_mappings_1.computeLineStartsMap)(fileContent);
|
|
125
127
|
this.resolvedTemplates.push({
|
|
126
128
|
filePath: templatePath,
|
|
129
|
+
absFilePath: absTemplatePath,
|
|
127
130
|
container: node,
|
|
128
131
|
content: fileContent,
|
|
129
132
|
inline: false,
|
|
@@ -135,7 +138,7 @@ class ComponentResourceCollector {
|
|
|
135
138
|
});
|
|
136
139
|
}
|
|
137
140
|
/** Resolves an external stylesheet by reading its content and computing line mappings. */
|
|
138
|
-
resolveExternalStylesheet(filePath, container) {
|
|
141
|
+
resolveExternalStylesheet(filePath, absFilePath, container) {
|
|
139
142
|
// Strip the BOM to avoid issues with the Sass compiler. See:
|
|
140
143
|
// https://github.com/angular/components/issues/24227#issuecomment-1200934258
|
|
141
144
|
const fileContent = stripBom(this.tree.readText(filePath) || '');
|
|
@@ -144,7 +147,8 @@ class ComponentResourceCollector {
|
|
|
144
147
|
}
|
|
145
148
|
const lineStartsMap = (0, line_mappings_1.computeLineStartsMap)(fileContent);
|
|
146
149
|
return {
|
|
147
|
-
filePath
|
|
150
|
+
filePath,
|
|
151
|
+
absFilePath,
|
|
148
152
|
container: container,
|
|
149
153
|
content: fileContent,
|
|
150
154
|
inline: false,
|
|
@@ -153,8 +157,9 @@ class ComponentResourceCollector {
|
|
|
153
157
|
};
|
|
154
158
|
}
|
|
155
159
|
_trackExternalStylesheet(sourceFileDirPath, node, container) {
|
|
156
|
-
const
|
|
157
|
-
const
|
|
160
|
+
const absFilePath = (0, core_1.normalize)(path_1.posix.resolve('/', (0, core_1.normalize)(sourceFileDirPath), (0, core_1.normalize)(node.text)));
|
|
161
|
+
const stylesheetPath = path_1.posix.relative((0, core_1.normalize)(process.cwd()), absFilePath);
|
|
162
|
+
const stylesheet = this.resolveExternalStylesheet(stylesheetPath, absFilePath, container);
|
|
158
163
|
if (stylesheet) {
|
|
159
164
|
this.resolvedStylesheets.push(stylesheet);
|
|
160
165
|
}
|
|
@@ -25,7 +25,7 @@ class StyleUpdater {
|
|
|
25
25
|
};
|
|
26
26
|
visitNodeAndCollectResources(file);
|
|
27
27
|
for (const styleSheet of resourceCollector.resolvedStylesheets) {
|
|
28
|
-
if (styleSheet.inline || !this._analyzedFiles.has(styleSheet.
|
|
28
|
+
if (styleSheet.inline || !this._analyzedFiles.has(styleSheet.absFilePath)) {
|
|
29
29
|
const content = this.replaceContent(styleSheet.content, styleSheet.filePath);
|
|
30
30
|
if (content !== styleSheet.content) {
|
|
31
31
|
const recorder = this.tree.beginUpdate(styleSheet.filePath);
|
|
@@ -33,7 +33,7 @@ class StyleUpdater {
|
|
|
33
33
|
recorder.insertRight(styleSheet.start, content);
|
|
34
34
|
this.tree.commitUpdate(recorder);
|
|
35
35
|
}
|
|
36
|
-
this._analyzedFiles.add(styleSheet.
|
|
36
|
+
this._analyzedFiles.add(styleSheet.absFilePath);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -25,7 +25,7 @@ class TemplateUpdater {
|
|
|
25
25
|
};
|
|
26
26
|
visitNodeAndCollectResources(file);
|
|
27
27
|
for (const template of resourceCollector.resolvedTemplates) {
|
|
28
|
-
if (template.inline || !this._analyzedFiles.has(template.
|
|
28
|
+
if (template.inline || !this._analyzedFiles.has(template.absFilePath)) {
|
|
29
29
|
const content = this.replaceContent(template.content);
|
|
30
30
|
if (content !== template.content) {
|
|
31
31
|
const recorder = this.tree.beginUpdate(template.filePath);
|
|
@@ -33,7 +33,7 @@ class TemplateUpdater {
|
|
|
33
33
|
recorder.insertRight(template.start, content);
|
|
34
34
|
this.tree.commitUpdate(recorder);
|
|
35
35
|
}
|
|
36
|
-
this._analyzedFiles.add(template.
|
|
36
|
+
this._analyzedFiles.add(template.absFilePath);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -3,35 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = ngAdd;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
5
|
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
6
|
-
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
7
6
|
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
8
|
-
const
|
|
9
|
-
const fs_1 = require("fs");
|
|
10
|
-
// Explicitly add the peer dependencies as main dependencies.
|
|
11
|
-
function addDependencies() {
|
|
12
|
-
return (tree) => {
|
|
13
|
-
const dfDependencies = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '..', '..', 'package.json'), { encoding: 'utf-8' })).peerDependencies;
|
|
14
|
-
for (const dependency in dfDependencies) {
|
|
15
|
-
if (Object.prototype.hasOwnProperty.call(dfDependencies, dependency)) {
|
|
16
|
-
(0, dependencies_1.addPackageJsonDependency)(tree, {
|
|
17
|
-
type: dependencies_1.NodeDependencyType.Default,
|
|
18
|
-
name: dependency,
|
|
19
|
-
version: dfDependencies[dependency]
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
// Schedule a package install, also installing the dependencies set up in the above step.
|
|
26
|
-
function install() {
|
|
27
|
-
return (tree, context) => {
|
|
28
|
-
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
29
|
-
return tree;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
7
|
+
const add_dependencies_1 = require("../migrations/utils/add-dependencies");
|
|
32
8
|
// Add DF styles to the main styles file. If no styles.scss found, add DF styles to the workspace.
|
|
33
9
|
function addDFStyles(options) {
|
|
34
|
-
return async (tree) => {
|
|
10
|
+
return async (tree, context) => {
|
|
35
11
|
const workspace = await (0, workspace_1.getWorkspace)(tree);
|
|
36
12
|
const project = workspace.projects.get(options.project);
|
|
37
13
|
if (!project) {
|
|
@@ -40,40 +16,26 @@ function addDFStyles(options) {
|
|
|
40
16
|
if (project.extensions['projectType'] !== 'application') {
|
|
41
17
|
throw new schematics_1.SchematicsException(`Requires a project type of "application".`);
|
|
42
18
|
}
|
|
43
|
-
|
|
44
|
-
const
|
|
19
|
+
const scssStylePath = `${project.sourceRoot ?? ''}/styles.scss`;
|
|
20
|
+
const cssStylePath = `${project.sourceRoot ?? ''}/styles.css`;
|
|
21
|
+
const foundScss = tree.exists(scssStylePath);
|
|
22
|
+
const foundCss = !foundScss && tree.exists(cssStylePath);
|
|
45
23
|
// if the main `styles.scss` is found, append the df styles imports at the end
|
|
46
|
-
if (
|
|
47
|
-
const recorder = tree.beginUpdate(
|
|
48
|
-
recorder.insertRight(tree.readText(
|
|
49
|
-
|
|
50
|
-
$font-path: '@design-factory/design-factory/assets/fonts';
|
|
51
|
-
|
|
52
|
-
@import '@design-factory/design-factory/design-factory.scss';
|
|
24
|
+
if (foundScss || foundCss) {
|
|
25
|
+
const recorder = tree.beginUpdate(foundScss ? scssStylePath : cssStylePath);
|
|
26
|
+
recorder.insertRight(tree.readText(foundScss ? scssStylePath : cssStylePath).length, `
|
|
27
|
+
${foundCss ? '@import' : '@use'} '@design-factory/styles/bundle';
|
|
53
28
|
`);
|
|
54
29
|
tree.commitUpdate(recorder);
|
|
55
30
|
}
|
|
56
31
|
else {
|
|
57
|
-
|
|
32
|
+
context.logger.warn(`Could not find styles.scss or styles.css in the project source root. Please make sure to import Design Factory styles manually.`);
|
|
58
33
|
}
|
|
59
|
-
return (0, workspace_1.updateWorkspace)((workspace) => {
|
|
60
|
-
const buildTarget = workspace.projects.get(options.project).targets.get('build');
|
|
61
|
-
if (!buildTarget) {
|
|
62
|
-
throw new schematics_1.SchematicsException(`Requires a "build" target`);
|
|
63
|
-
}
|
|
64
|
-
const buildOptions = (buildTarget.options || {});
|
|
65
|
-
// if the main `styles.scss` was not found, add the DF styles to the workspace
|
|
66
|
-
if (addStyleToWorkspace) {
|
|
67
|
-
buildOptions.styles = [...(buildOptions.styles ?? []), '@design-factory/design-factory/design-factory.scss'];
|
|
68
|
-
}
|
|
69
|
-
// update the style preprocessor options
|
|
70
|
-
buildOptions.stylePreprocessorOptions = { includePaths: ['./src', 'node_modules'] };
|
|
71
|
-
});
|
|
72
34
|
};
|
|
73
35
|
}
|
|
74
36
|
function ngAdd(options) {
|
|
75
37
|
return (_tree, context) => {
|
|
76
38
|
context.addTask(new tasks_1.RunSchematicTask('@angular/localize', 'ng-add', options.project ? { project: options.project } : {}));
|
|
77
|
-
return (0, schematics_1.chain)([addDependencies(), install(), addDFStyles(options)]);
|
|
39
|
+
return (0, schematics_1.chain)([(0, add_dependencies_1.addDependencies)(), (0, add_dependencies_1.install)(), addDFStyles(options)]);
|
|
78
40
|
};
|
|
79
41
|
}
|