@ui5/webcomponents-tools 0.0.0-9261ac932 → 0.0.0-95afb1087
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/CHANGELOG.md +737 -0
- package/LICENSE.txt +201 -0
- package/README.md +7 -7
- package/assets-meta.js +1 -5
- package/bin/dev.js +3 -2
- package/bin/ui5nps.js +265 -0
- package/components-package/eslint.js +29 -39
- package/components-package/nps.js +98 -75
- package/components-package/vite.config.js +7 -11
- package/components-package/wdio.js +9 -3
- package/icons-collection/nps.js +30 -21
- package/lib/amd-to-es6/index.js +15 -10
- package/lib/cem/cem.js +12 -0
- package/lib/cem/custom-elements-manifest.config.mjs +58 -39
- package/lib/cem/event.mjs +51 -31
- package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
- package/lib/cem/schema-internal.json +9 -0
- package/lib/cem/utils.mjs +50 -25
- package/lib/cem/validate.js +61 -55
- package/lib/chokidar/chokidar.js +29 -0
- package/lib/copy-and-watch/index.js +105 -97
- package/lib/copy-list/index.js +16 -10
- package/lib/create-icons/index.js +24 -19
- package/lib/create-illustrations/index.js +51 -28
- package/lib/create-new-component/{tsFileContentTemplate.js → Component.js} +11 -8
- package/lib/create-new-component/ComponentTemplate.js +12 -0
- package/lib/create-new-component/index.js +13 -10
- package/lib/css-processors/css-processor-components.mjs +75 -60
- package/lib/css-processors/css-processor-themes.mjs +101 -62
- package/lib/css-processors/scope-variables.mjs +17 -9
- package/lib/css-processors/shared.mjs +5 -35
- package/lib/dev-server/dev-server.mjs +24 -12
- package/lib/dev-server/virtual-index-html-plugin.js +24 -20
- package/lib/eslint/eslint.js +44 -0
- package/lib/generate-js-imports/illustrations.js +53 -54
- package/lib/generate-json-imports/i18n.js +20 -11
- package/lib/generate-json-imports/themes.js +20 -12
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +8 -3
- package/lib/i18n/defaults.js +12 -7
- package/lib/i18n/toJSON.js +15 -12
- package/lib/icons-hash/icons-hash.mjs +149 -0
- package/lib/remove-dev-mode/remove-dev-mode.mjs +38 -24
- package/lib/rimraf/rimraf.js +31 -0
- package/lib/test-runner/test-runner.js +56 -48
- package/lib/vite-bundler/vite-bundler.mjs +35 -0
- package/package.json +19 -22
- package/tsconfig.json +2 -0
- package/components-package/cypress/support/commands.js +0 -39
- package/components-package/cypress/support/component-index.html +0 -17
- package/components-package/cypress/support/component.d.ts +0 -23
- package/components-package/cypress/support/component.js +0 -34
- package/components-package/cypress.config.js +0 -19
- package/types/index.d.ts +0 -1
|
@@ -3,35 +3,52 @@ const fs = require("fs");
|
|
|
3
3
|
const LIB = path.join(__dirname, `../lib/`);
|
|
4
4
|
let websiteBaseUrl = "/";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const isPreview = !!process.env.PR_NUMBER;
|
|
7
|
+
const getPreviewBaseUrl = () => {
|
|
8
|
+
if (process.env.DEPLOYMENT_TYPE === "netlify_preview") {
|
|
9
|
+
return "/";
|
|
10
|
+
}
|
|
11
|
+
return `/webcomponents/pr-${process.env.PR_NUMBER}/`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (process.env.DEPLOY) {
|
|
15
|
+
websiteBaseUrl = "/webcomponents/";
|
|
8
16
|
} else if (process.env.DEPLOY_NIGHTLY) {
|
|
9
|
-
websiteBaseUrl = "/
|
|
17
|
+
websiteBaseUrl = "/webcomponents/nightly/";
|
|
18
|
+
} else if (isPreview) {
|
|
19
|
+
websiteBaseUrl = getPreviewBaseUrl();
|
|
10
20
|
}
|
|
11
21
|
|
|
12
22
|
const getScripts = (options) => {
|
|
13
|
-
|
|
14
23
|
// The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
|
|
15
24
|
const illustrationsData = options.illustrationsData || [];
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
const createIllustrationsJSImportsScript = {
|
|
26
|
+
default: `ui5nps-p ${illustrationsData.map(illustrations => `build.illustrations.build-${illustrations.set}-${illustrations.collection}`).join(" ")}` // concurently,
|
|
27
|
+
}
|
|
28
|
+
illustrationsData.forEach((illustration) => {
|
|
29
|
+
createIllustrationsJSImportsScript[`build-${illustration.set}-${illustration.collection}`] = `ui5nps-script "${LIB}create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath} ${illustration.collection}`
|
|
30
|
+
});
|
|
19
31
|
// The script creates the "src/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
|
|
20
|
-
|
|
32
|
+
const createIllustrationsLoadersScript = {
|
|
33
|
+
default: `ui5nps-p ${illustrationsData.map(illustrations => `build.jsImports.illustrationsLoaders.generate-${illustrations.set}-${illustrations.collection}`).join(" ")}` // concurently,
|
|
34
|
+
}
|
|
35
|
+
illustrationsData.forEach((illustrations) => {
|
|
36
|
+
createIllustrationsLoadersScript[`generate-${illustrations.set}-${illustrations.collection}`] = `ui5nps-script ${LIB}generate-js-imports/illustrations.js ${illustrations.path} ${illustrations.dynamicImports.outputFile} ${illustrations.set} ${illustrations.collection} ${illustrations.dynamicImports.location} ${illustrations.dynamicImports.filterOut.join(",")}`
|
|
37
|
+
});
|
|
38
|
+
|
|
21
39
|
|
|
22
|
-
const tsOption = !options.legacy;
|
|
40
|
+
const tsOption = !!(!options.legacy || options.jsx);
|
|
23
41
|
const tsCommandOld = tsOption ? "tsc" : "";
|
|
24
42
|
let tsWatchCommandStandalone = tsOption ? "tsc --watch" : "";
|
|
25
43
|
// this command is only used for standalone projects. monorepo projects get their watch from vite, so opt-out here
|
|
26
44
|
if (options.noWatchTS) {
|
|
27
45
|
tsWatchCommandStandalone = "";
|
|
28
46
|
}
|
|
29
|
-
const tsCrossEnv = tsOption ? "cross-env UI5_TS=true" : "";
|
|
30
47
|
|
|
31
48
|
if (tsOption) {
|
|
32
49
|
try {
|
|
33
50
|
require("typescript");
|
|
34
|
-
} catch(e) {
|
|
51
|
+
} catch (e) {
|
|
35
52
|
console.error(`TypeScript is not found. Try to install it by running \`npm install --save-dev typescript\` if you are using npm or by running \`yarn add --dev typescript\` if you are using yarn.`);
|
|
36
53
|
process.exit(e.code);
|
|
37
54
|
}
|
|
@@ -49,101 +66,107 @@ const getScripts = (options) => {
|
|
|
49
66
|
viteConfig = `-c "${require.resolve("@ui5/webcomponents-tools/components-package/vite.config.js")}"`;
|
|
50
67
|
}
|
|
51
68
|
|
|
52
|
-
let eslintConfig;
|
|
53
|
-
if (fs.existsSync(".eslintrc.js") || fs.existsSync(".eslintrc.cjs")) {
|
|
54
|
-
// preferred way of custom configuration in root project folder
|
|
55
|
-
eslintConfig = "";
|
|
56
|
-
} else {
|
|
57
|
-
// no custom configuration - use default from tools project
|
|
58
|
-
eslintConfig = `--config "${require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")}"`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
69
|
const scripts = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
__ui5envs: {
|
|
71
|
+
UI5_CEM_MODE: options.dev,
|
|
72
|
+
UI5_TS: `${tsOption}`,
|
|
73
|
+
CYPRESS_COVERAGE: !!(options.internal?.cypress_code_coverage),
|
|
74
|
+
},
|
|
75
|
+
clean: {
|
|
76
|
+
"default": "ui5nps clean.generated clean.dist scope.testPages.clean",
|
|
77
|
+
"generated": `ui5nps-script "${LIB}/rimraf/rimraf.js src/generated`,
|
|
78
|
+
"dist": `ui5nps-script "${LIB}/rimraf/rimraf.js dist`,
|
|
79
|
+
},
|
|
80
|
+
lint: `ui5nps-script "${LIB}eslint/eslint.js"`,
|
|
81
|
+
lintfix: `ui5nps-script "${LIB}eslint/eslint.js" --fix`,
|
|
65
82
|
generate: {
|
|
66
|
-
default:
|
|
67
|
-
all:
|
|
68
|
-
styleRelated: "
|
|
83
|
+
default: `ui5nps prepare.all`,
|
|
84
|
+
all: `ui5nps-p build.templates build.i18n prepare.styleRelated copyProps build.illustrations`, // concurently
|
|
85
|
+
styleRelated: "ui5nps build.styles build.jsonImports build.jsImports",
|
|
69
86
|
},
|
|
70
87
|
prepare: {
|
|
71
|
-
default:
|
|
72
|
-
all:
|
|
73
|
-
styleRelated: "
|
|
88
|
+
default: `ui5nps clean prepare.all copy copyProps prepare.typescript generateAPI`,
|
|
89
|
+
all: `ui5nps-p build.templates build.i18n prepare.styleRelated build.illustrations`, // concurently
|
|
90
|
+
styleRelated: "ui5nps build.styles build.jsonImports build.jsImports",
|
|
74
91
|
typescript: tsCommandOld,
|
|
75
92
|
},
|
|
76
93
|
build: {
|
|
77
|
-
default: "
|
|
78
|
-
templates: `
|
|
94
|
+
default: "ui5nps prepare lint build.bundle", // build.bundle2
|
|
95
|
+
templates: options.legacy ? `mkdir -p src/generated/templates && node "${LIB}hbs2ui5/index.js" -d src/ -o src/generated/templates` : "",
|
|
79
96
|
styles: {
|
|
80
|
-
default: `
|
|
81
|
-
themes: `
|
|
82
|
-
|
|
97
|
+
default: `ui5nps-p build.styles.themes build.styles.components`, // concurently
|
|
98
|
+
themes: `ui5nps-script "${LIB}css-processors/css-processor-themes.mjs"`,
|
|
99
|
+
themesWithWatch: `ui5nps-script "${LIB}css-processors/css-processor-themes.mjs" -w`,
|
|
100
|
+
components: `ui5nps-script "${LIB}css-processors/css-processor-components.mjs"`,
|
|
101
|
+
componentsWithWatch: `ui5nps-script "${LIB}css-processors/css-processor-components.mjs" -w`,
|
|
83
102
|
},
|
|
84
103
|
i18n: {
|
|
85
|
-
default: "
|
|
86
|
-
defaultsjs: `
|
|
87
|
-
json: `
|
|
104
|
+
default: "ui5nps build.i18n.defaultsjs build.i18n.json",
|
|
105
|
+
defaultsjs: `ui5nps-script "${LIB}i18n/defaults.js" src/i18n src/generated/i18n`,
|
|
106
|
+
json: `ui5nps-script "${LIB}i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
|
|
88
107
|
},
|
|
89
108
|
jsonImports: {
|
|
90
|
-
default: "
|
|
91
|
-
themes: `
|
|
92
|
-
i18n: `
|
|
109
|
+
default: "ui5nps build.jsonImports.themes build.jsonImports.i18n",
|
|
110
|
+
themes: `ui5nps-script "${LIB}generate-json-imports/themes.js" src/themes src/generated/json-imports`,
|
|
111
|
+
i18n: `ui5nps-script "${LIB}generate-json-imports/i18n.js" src/i18n src/generated/json-imports`,
|
|
93
112
|
},
|
|
94
113
|
jsImports: {
|
|
95
|
-
default: "
|
|
114
|
+
default: "ui5nps build.jsImports.illustrationsLoaders",
|
|
96
115
|
illustrationsLoaders: createIllustrationsLoadersScript,
|
|
97
116
|
},
|
|
98
|
-
bundle: `vite
|
|
117
|
+
bundle: `ui5nps-script "${LIB}vite-bundler/vite-bundler.mjs" ${viteConfig} --mode testing --base ${websiteBaseUrl}`,
|
|
99
118
|
bundle2: ``,
|
|
100
119
|
illustrations: createIllustrationsJSImportsScript,
|
|
101
120
|
},
|
|
102
|
-
copyProps: `
|
|
121
|
+
copyProps: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
|
|
122
|
+
copyPropsWithWatch: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/ --watch --safe --skip-initial-copy`,
|
|
123
|
+
copySrcWithWatch: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/**/*.{js,json}" dist/ --watch --safe --skip-initial-copy`,
|
|
103
124
|
copy: {
|
|
104
|
-
default: "
|
|
105
|
-
src: `
|
|
106
|
-
props: `
|
|
125
|
+
default: options.legacy ? "ui5nps copy.src copy.props" : "",
|
|
126
|
+
src: options.legacy ? `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/**/*.{js,json}" dist/` : "",
|
|
127
|
+
props: options.legacy ? `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/` : "",
|
|
107
128
|
},
|
|
108
129
|
watch: {
|
|
109
|
-
default:
|
|
110
|
-
devServer: '
|
|
111
|
-
src: '
|
|
130
|
+
default: `ui5nps-p watch.templates watch.typescript watch.src watch.styles watch.i18n watch.props`, // concurently
|
|
131
|
+
devServer: 'ui5nps-p watch.default watch.bundle', // concurently
|
|
132
|
+
src: options.legacy ? 'ui5nps copySrcWithWatch' : "",
|
|
112
133
|
typescript: tsWatchCommandStandalone,
|
|
113
|
-
props: '
|
|
114
|
-
bundle: `
|
|
134
|
+
props: 'ui5nps copyPropsWithWatch',
|
|
135
|
+
bundle: `ui5nps-script ${LIB}dev-server/dev-server.mjs ${viteConfig}`,
|
|
115
136
|
styles: {
|
|
116
|
-
default: '
|
|
117
|
-
themes: '
|
|
118
|
-
components: `
|
|
137
|
+
default: 'ui5nps-p watch.styles.themes watch.styles.components', // concurently
|
|
138
|
+
themes: 'ui5nps build.styles.themesWithWatch',
|
|
139
|
+
components: `ui5nps build.styles.componentsWithWatch`,
|
|
119
140
|
},
|
|
120
|
-
templates:
|
|
121
|
-
i18n:
|
|
141
|
+
templates: options.legacy ? `ui5nps-script "${LIB}chokidar/chokidar.js" "src/**/*.hbs" "ui5nps build.templates"` : "",
|
|
142
|
+
i18n: `ui5nps-script "${LIB}chokidar/chokidar.js" "src/i18n/messagebundle.properties" "ui5nps build.i18n.defaultsjs"`
|
|
122
143
|
},
|
|
123
|
-
start: "
|
|
124
|
-
test: `
|
|
125
|
-
"test-cy-ci": `
|
|
126
|
-
"test-cy-
|
|
127
|
-
"test-suite-
|
|
128
|
-
"test-suite-
|
|
129
|
-
|
|
144
|
+
start: "ui5nps prepare watch.devServer",
|
|
145
|
+
test: `ui5nps-script "${LIB}/test-runner/test-runner.js"`,
|
|
146
|
+
"test-cy-ci": `cypress run --component --browser chrome`,
|
|
147
|
+
"test-cy-ci-suite-1": `cypress run --component --browser chrome --spec "**/specs/[A-C]*.cy.{js,jsx,ts,tsx},**/specs/[^D-Z]*.cy.{js,jsx,ts,tsx}"`,
|
|
148
|
+
"test-cy-ci-suite-2": `cypress run --component --browser chrome --spec "**/specs/[D-L]*.cy.{js,jsx,ts,tsx}"`,
|
|
149
|
+
"test-cy-ci-suite-3": `cypress run --component --browser chrome --spec "**/specs/[M-S]*.cy.{js,jsx,ts,tsx}"`,
|
|
150
|
+
"test-cy-ci-suite-4": `cypress run --component --browser chrome --spec "**/specs/[T-Z]*.cy.{js,jsx,ts,tsx}"`,
|
|
151
|
+
"test-cy-open": `cypress open --component --browser chrome`,
|
|
152
|
+
startWithScope: "ui5nps scope.prepare scope.watchWithBundle",
|
|
130
153
|
scope: {
|
|
131
|
-
prepare: "
|
|
132
|
-
lint: `
|
|
154
|
+
prepare: "ui5nps scope.lint scope.testPages",
|
|
155
|
+
lint: `ui5nps-script "${LIB}scoping/lint-src.js"`,
|
|
133
156
|
testPages: {
|
|
134
|
-
default: "
|
|
135
|
-
clean: "rimraf test/pages/scoped
|
|
136
|
-
copy: `
|
|
137
|
-
replace: `
|
|
157
|
+
default: "ui5nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
|
|
158
|
+
"clean": `ui5nps-script "${LIB}/rimraf/rimraf.js test/pages/scoped`,
|
|
159
|
+
copy: `ui5nps-script "${LIB}copy-and-watch/index.js" --silent "test/pages/**/*" test/pages/scoped`,
|
|
160
|
+
replace: `ui5nps-script "${LIB}scoping/scope-test-pages.js" test/pages/scoped demo`,
|
|
138
161
|
},
|
|
139
|
-
watchWithBundle: '
|
|
140
|
-
watch: '
|
|
141
|
-
bundle: `
|
|
162
|
+
watchWithBundle: 'ui5nps-p scope.watch scope.bundle', // concurently
|
|
163
|
+
watch: 'ui5nps-p watch.templates watch.props watch.styles', // concurently
|
|
164
|
+
bundle: `ui5nps-script ${LIB}dev-server/dev-server.mjs ${viteConfig}`,
|
|
142
165
|
},
|
|
143
166
|
generateAPI: {
|
|
144
|
-
default: tsOption ? "
|
|
145
|
-
generateCEM: `cem analyze --config "${LIB}
|
|
146
|
-
validateCEM: `
|
|
167
|
+
default: tsOption ? "ui5nps generateAPI.generateCEM generateAPI.validateCEM" : "",
|
|
168
|
+
generateCEM: `ui5nps-script "${LIB}cem/cem.js" analyze --config "${LIB}cem/custom-elements-manifest.config.mjs"`,
|
|
169
|
+
validateCEM: `ui5nps-script "${LIB}cem/validate.js"`,
|
|
147
170
|
},
|
|
148
171
|
};
|
|
149
172
|
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
// vite.config.js
|
|
2
|
-
|
|
3
|
-
import virtualIndex from '../lib/dev-server/virtual-index-html-plugin.js';
|
|
2
|
+
const virtualIndex = require('../lib/dev-server/virtual-index-html-plugin.js');
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
plugins: [data],
|
|
12
|
-
}
|
|
13
|
-
})
|
|
4
|
+
module.exports = {
|
|
5
|
+
build: {
|
|
6
|
+
emptyOutDir: false,
|
|
7
|
+
},
|
|
8
|
+
plugins: [virtualIndex()],
|
|
9
|
+
};
|
|
@@ -60,7 +60,7 @@ exports.config = {
|
|
|
60
60
|
// to run chrome headless the following flags are required
|
|
61
61
|
// (see https://developers.google.com/web/updates/2017/04/headless-chrome)
|
|
62
62
|
args: [
|
|
63
|
-
'--headless
|
|
63
|
+
'--headless',
|
|
64
64
|
'--disable-search-engine-choice-screen',
|
|
65
65
|
'--start-maximized',
|
|
66
66
|
'--no-sandbox',
|
|
@@ -403,8 +403,14 @@ exports.config = {
|
|
|
403
403
|
* @param {Array.<Object>} capabilities list of capabilities details
|
|
404
404
|
* @param {<Object>} results object containing test results
|
|
405
405
|
*/
|
|
406
|
-
|
|
407
|
-
|
|
406
|
+
onComplete: function (exitCode, config, capabilities, results) {
|
|
407
|
+
// The results object looks like: { finished: 0, passed: 0, retries: 0, failed: 0 }.
|
|
408
|
+
// If all values are 0, consider that no tests were found or executed.
|
|
409
|
+
if (exitCode === 1 && Object.values(results).every(result => result === 0)) {
|
|
410
|
+
console.log("✅ No specs were found or executed – treating as success.");
|
|
411
|
+
process.exit(0);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
408
414
|
/**
|
|
409
415
|
* Gets executed when a refresh happens.
|
|
410
416
|
* @param {String} oldSessionId session ID of the old session
|
package/icons-collection/nps.js
CHANGED
|
@@ -4,35 +4,37 @@ const LIB = path.join(__dirname, `../lib/`);
|
|
|
4
4
|
|
|
5
5
|
const createIconImportsCommand = (options) => {
|
|
6
6
|
if (!options.versions) {
|
|
7
|
-
return `
|
|
7
|
+
return `ui5nps-script "${LIB}/create-icons/index.js" "${options.collectionName}"`;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const command
|
|
10
|
+
const command = { default: "ui5nps" };
|
|
11
11
|
options.versions.forEach((v) => {
|
|
12
12
|
command.default += ` build.icons.create${v}`;
|
|
13
|
-
command[`create${v}`] = `
|
|
13
|
+
command[`create${v}`] = `ui5nps-script "${LIB}/create-icons/index.js" "${options.collectionName}" "${v}"`;
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
return command;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
const hashesCheck = cmd => `(node "${LIB}/icons-hash/icons-hash.mjs" check) || (${cmd} && node "${LIB}/icons-hash/icons-hash.mjs" save)`;
|
|
20
|
+
|
|
19
21
|
const copyIconAssetsCommand = (options) => {
|
|
20
22
|
if (!options.versions) {
|
|
21
|
-
return
|
|
22
|
-
default: "
|
|
23
|
-
"json-imports": `
|
|
24
|
-
"icon-collection": `
|
|
23
|
+
return {
|
|
24
|
+
default: "ui5nps copy.json-imports copy.icon-collection",
|
|
25
|
+
"json-imports": `ui5nps-script "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
|
26
|
+
"icon-collection": `ui5nps-script "${LIB}/copy-and-watch/index.js" --silent "src/*.json" src/generated/assets/`,
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
const command
|
|
29
|
-
default: "
|
|
30
|
-
"json-imports": `
|
|
30
|
+
const command = {
|
|
31
|
+
default: "ui5nps copy.json-imports ",
|
|
32
|
+
"json-imports": `ui5nps-script "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
options.versions.forEach((v) => {
|
|
34
36
|
command.default += ` copy.icon-collection${v}`;
|
|
35
|
-
command[`icon-collection${v}`] = `
|
|
37
|
+
command[`icon-collection${v}`] = `ui5nps-script "${LIB}/copy-and-watch/index.js" --silent "src/${v}/*.json" src/generated/assets/${v}/`;
|
|
36
38
|
});
|
|
37
39
|
|
|
38
40
|
return command;
|
|
@@ -42,23 +44,30 @@ const getScripts = (options) => {
|
|
|
42
44
|
const createJSImportsCmd = createIconImportsCommand(options);
|
|
43
45
|
const copyAssetsCmd = copyIconAssetsCommand(options);
|
|
44
46
|
const tsCommand = !options.legacy ? "tsc --build" : "";
|
|
45
|
-
const
|
|
47
|
+
const tsOption = !options.legacy;
|
|
46
48
|
|
|
47
49
|
const scripts = {
|
|
48
|
-
|
|
50
|
+
__ui5envs: {
|
|
51
|
+
UI5_TS: `${tsOption}`,
|
|
52
|
+
},
|
|
53
|
+
clean: {
|
|
54
|
+
default: "ui5nps clean.generated clean.dist",
|
|
55
|
+
"generated": `ui5nps-script "${LIB}/rimraf/rimraf.js src/generated`,
|
|
56
|
+
"dist": `ui5nps-script "${LIB}/rimraf/rimraf.js dist`,
|
|
57
|
+
},
|
|
49
58
|
copy: copyAssetsCmd,
|
|
50
|
-
generate:
|
|
51
|
-
copyjson: "copy-and-watch
|
|
59
|
+
generate: hashesCheck(`ui5nps clean copy build.i18n build.icons build.jsonImports copyjson`),
|
|
60
|
+
copyjson: `ui5nps-script "${LIB}copy-and-watch/index.js" "src/generated/**/*.json" dist/generated`,
|
|
52
61
|
build: {
|
|
53
|
-
default:
|
|
62
|
+
default: hashesCheck(`ui5nps clean copy build.i18n typescript build.icons build.jsonImports`),
|
|
54
63
|
i18n: {
|
|
55
|
-
default: "
|
|
56
|
-
defaultsjs: `
|
|
57
|
-
json: `
|
|
64
|
+
default: "ui5nps build.i18n.defaultsjs build.i18n.json",
|
|
65
|
+
defaultsjs: `ui5nps-script "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
|
|
66
|
+
json: `ui5nps-script "${LIB}/i18n/toJSON.js" src/i18n src/generated/assets/i18n`,
|
|
58
67
|
},
|
|
59
68
|
jsonImports: {
|
|
60
|
-
default: "
|
|
61
|
-
i18n: `
|
|
69
|
+
default: "ui5nps build.jsonImports.i18n",
|
|
70
|
+
i18n: `ui5nps-script "${LIB}/generate-json-imports/i18n.js" src/generated/assets/i18n src/generated/json-imports`,
|
|
62
71
|
},
|
|
63
72
|
icons: createJSImportsCmd,
|
|
64
73
|
},
|
package/lib/amd-to-es6/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const fs = require("fs").promises;
|
|
2
2
|
const path = require("path");
|
|
3
|
-
const basePath = process.argv[2];
|
|
4
3
|
const babelCore = require("@babel/core");
|
|
5
4
|
const babelParser = require("@babel/parser");
|
|
6
5
|
const babelGenerator = require("@babel/generator").default;
|
|
@@ -21,7 +20,7 @@ const convertAmdToEs6 = async (code) => {
|
|
|
21
20
|
})).code;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
const convertAbsImportsToRelative = (filePath, code) => {
|
|
23
|
+
const convertAbsImportsToRelative = (filePath, code, basePath) => {
|
|
25
24
|
let changed = false;
|
|
26
25
|
// console.log("File processing started: ", srcPath);
|
|
27
26
|
|
|
@@ -69,7 +68,7 @@ const convertAbsImportsToRelative = (filePath, code) => {
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
const replaceGlobalCoreUsage = (filePath, code) => {
|
|
72
|
-
if (!filePath.includes("Configuration"))
|
|
71
|
+
if (!filePath.includes("Configuration")) {
|
|
73
72
|
const replaced = code.replace(/sap\.ui\.getCore\(\)/g, `Core`);
|
|
74
73
|
return code !== replaced ? `import Core from 'sap/ui/core/Core';${replaced}` : code;
|
|
75
74
|
}
|
|
@@ -77,7 +76,7 @@ const replaceGlobalCoreUsage = (filePath, code) => {
|
|
|
77
76
|
return code;
|
|
78
77
|
};
|
|
79
78
|
|
|
80
|
-
const transformAmdToES6Module = async (filePath) => {
|
|
79
|
+
const transformAmdToES6Module = async (filePath, basePath) => {
|
|
81
80
|
await convertSAPUIDefineToDefine(filePath);
|
|
82
81
|
|
|
83
82
|
let code = (await fs.readFile(filePath)).toString();
|
|
@@ -86,17 +85,23 @@ const transformAmdToES6Module = async (filePath) => {
|
|
|
86
85
|
|
|
87
86
|
code = replaceGlobalCoreUsage(filePath, code);
|
|
88
87
|
|
|
89
|
-
code = convertAbsImportsToRelative(filePath, code);
|
|
88
|
+
code = convertAbsImportsToRelative(filePath, code, basePath);
|
|
90
89
|
|
|
91
90
|
return fs.writeFile(filePath, code);
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
const transformAmdToES6Modules = async () => {
|
|
93
|
+
const transformAmdToES6Modules = async (argv) => {
|
|
94
|
+
const basePath = argv[2];
|
|
95
95
|
const { globby } = await import("globby");
|
|
96
96
|
const fileNames = await globby(basePath.replace(/\\/g, "/") + "**/*.js");
|
|
97
|
-
return Promise.all(fileNames.map(transformAmdToES6Module).filter(x => !!x))
|
|
97
|
+
return Promise.all(fileNames.map(fileName => transformAmdToES6Module(fileName, basePath)).filter(x => !!x))
|
|
98
|
+
.then(() => {
|
|
99
|
+
console.log("Success: all amd modules are transformed to es6!");
|
|
100
|
+
});
|
|
98
101
|
};
|
|
99
102
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
+
if (require.main === module) {
|
|
104
|
+
transformAmdToES6Modules(process.argv)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
exports._ui5mainFn = transformAmdToES6Modules;
|
package/lib/cem/cem.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const cemCLI = require("./patch/@custom-elements-manifest/analyzer/cli.js")
|
|
2
|
+
|
|
3
|
+
const main = async argv => {
|
|
4
|
+
const patchedArgv = argv.slice(2);
|
|
5
|
+
await cemCLI.cli({ argv: patchedArgv, cwd: process.cwd(), noWrite: false });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (require.main === module) {
|
|
9
|
+
main(process.argv)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports._ui5mainFn = main;
|
|
@@ -27,6 +27,17 @@ import { generateCustomData } from "cem-plugin-vs-code-custom-data-generator";
|
|
|
27
27
|
import { customElementJetBrainsPlugin } from "custom-element-jet-brains-integration";
|
|
28
28
|
|
|
29
29
|
const packageJSON = JSON.parse(fs.readFileSync("./package.json"));
|
|
30
|
+
let aliasMap = {};
|
|
31
|
+
|
|
32
|
+
const devMode = process.env.UI5_CEM_MODE === "dev";
|
|
33
|
+
try {
|
|
34
|
+
aliasMap = JSON.parse(fs.readFileSync("./.ui5-cem-aliases.json"));
|
|
35
|
+
} catch (e) {
|
|
36
|
+
if (devMode) {
|
|
37
|
+
console.warn("No .ui5-cem-aliases.json file found. Continuing without aliases.");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
30
41
|
|
|
31
42
|
const extractClassNodeJSDoc = node => {
|
|
32
43
|
const fileContent = node.getFullText();
|
|
@@ -127,7 +138,7 @@ function processClass(ts, classNode, moduleDoc) {
|
|
|
127
138
|
}
|
|
128
139
|
|
|
129
140
|
// Events
|
|
130
|
-
currClass.events = findAllDecorators(classNode, "event")
|
|
141
|
+
currClass.events = findAllDecorators(classNode, ["event", "eventStrict"])
|
|
131
142
|
?.map(event => processEvent(ts, event, classNode, moduleDoc));
|
|
132
143
|
|
|
133
144
|
const filename = classNode.getSourceFile().fileName;
|
|
@@ -451,14 +462,6 @@ export default {
|
|
|
451
462
|
}
|
|
452
463
|
},
|
|
453
464
|
moduleLinkPhase({ moduleDoc }) {
|
|
454
|
-
for (let i = 0; i < moduleDoc.declarations.length; i++) {
|
|
455
|
-
const shouldRemove = processPublicAPI(moduleDoc.declarations[i]) || ["function", "variable"].includes(moduleDoc.declarations[i].kind)
|
|
456
|
-
if (shouldRemove) {
|
|
457
|
-
moduleDoc.declarations.splice(i, 1);
|
|
458
|
-
i--;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
465
|
moduleDoc.path = moduleDoc.path?.replace(/^src/, "dist").replace(/\.ts$/, ".js");
|
|
463
466
|
|
|
464
467
|
moduleDoc.exports = moduleDoc.exports.
|
|
@@ -482,41 +485,57 @@ export default {
|
|
|
482
485
|
})
|
|
483
486
|
}
|
|
484
487
|
})
|
|
488
|
+
},
|
|
489
|
+
packageLinkPhase({ customElementsManifest }) {
|
|
490
|
+
customElementsManifest.modules.forEach(moduleDoc => {
|
|
491
|
+
for (let i = 0; i < moduleDoc.declarations.length; i++) {
|
|
492
|
+
const shouldRemove = processPublicAPI(moduleDoc.declarations[i]) || ["function", "variable"].includes(moduleDoc.declarations[i].kind)
|
|
493
|
+
if (shouldRemove) {
|
|
494
|
+
moduleDoc.declarations.splice(i, 1);
|
|
495
|
+
i--;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
485
498
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
["events", "slots", "members"].forEach(memberType => {
|
|
491
|
-
declaration[memberType]?.forEach(member => {
|
|
492
|
-
if (member.type?.references) {
|
|
493
|
-
member.type.references.forEach(registerTypeReference)
|
|
494
|
-
} else if (member._ui5type?.references) {
|
|
495
|
-
member._ui5type.references.forEach(registerTypeReference)
|
|
496
|
-
} else if (member.kind === "method") {
|
|
497
|
-
member.return?.type?.references?.forEach(registerTypeReference)
|
|
498
|
-
|
|
499
|
-
member.parameters?.forEach(parameter => {
|
|
500
|
-
parameter.type?.references?.forEach(registerTypeReference)
|
|
501
|
-
})
|
|
502
|
-
}
|
|
503
|
-
})
|
|
499
|
+
moduleDoc.declarations.forEach(declaration => {
|
|
500
|
+
if (declaration.superclass?.name && aliasMap[declaration.superclass.name]) {
|
|
501
|
+
declaration.superclass.name = aliasMap[declaration.superclass.name];
|
|
502
|
+
}
|
|
504
503
|
})
|
|
505
|
-
});
|
|
506
504
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
505
|
+
const typeReferences = new Set();
|
|
506
|
+
const registerTypeReference = reference => typeReferences.add(JSON.stringify(reference))
|
|
507
|
+
|
|
508
|
+
moduleDoc.declarations.forEach(declaration => {
|
|
509
|
+
["events", "slots", "members"].forEach(memberType => {
|
|
510
|
+
declaration[memberType]?.forEach(member => {
|
|
511
|
+
if (member.type?.references) {
|
|
512
|
+
member.type.references.forEach(registerTypeReference)
|
|
513
|
+
} else if (member._ui5type?.references) {
|
|
514
|
+
member._ui5type.references.forEach(registerTypeReference)
|
|
515
|
+
} else if (member.kind === "method") {
|
|
516
|
+
member.return?.type?.references?.forEach(registerTypeReference)
|
|
517
|
+
|
|
518
|
+
member.parameters?.forEach(parameter => {
|
|
519
|
+
parameter.type?.references?.forEach(registerTypeReference)
|
|
520
|
+
})
|
|
521
|
+
}
|
|
522
|
+
})
|
|
523
|
+
})
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
typeReferences.forEach(reference => {
|
|
527
|
+
reference = JSON.parse(reference);
|
|
528
|
+
if (reference.package === packageJSON?.name && reference.module === moduleDoc.path) {
|
|
529
|
+
const hasExport = moduleDoc.exports.some(e => e.declaration?.name === reference.name && e.declaration?.module === reference.module)
|
|
511
530
|
|
|
512
|
-
|
|
513
|
-
|
|
531
|
+
if (!hasExport) {
|
|
532
|
+
logDocumentationError(moduleDoc.path?.replace(/^dist/, "src").replace(/\.js$/, ".ts"), `Type '${reference.name}' is used to describe a public API but is not exported.`,)
|
|
533
|
+
}
|
|
514
534
|
}
|
|
515
|
-
}
|
|
516
|
-
})
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
if (context.dev) {
|
|
535
|
+
})
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
if (devMode) {
|
|
520
539
|
displayDocumentationErrors();
|
|
521
540
|
}
|
|
522
541
|
}
|