@ui5/webcomponents-tools 0.0.0-6cb3eb0db → 0.0.0-6daff23a5
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 +2253 -0
- package/LICENSE.txt +201 -0
- package/README.md +7 -10
- package/assets-meta.js +13 -7
- package/bin/dev.js +3 -6
- package/bin/ui5nps.js +265 -0
- package/components-package/eslint.js +66 -2
- package/components-package/nps.js +149 -82
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -23
- package/components-package/vite.config.js +9 -0
- package/components-package/wdio.js +85 -17
- package/icons-collection/nps.js +60 -18
- package/lib/amd-to-es6/index.js +107 -0
- package/lib/amd-to-es6/no-remaining-require.js +33 -0
- package/lib/cem/cem.js +12 -0
- package/lib/cem/custom-elements-manifest.config.mjs +546 -0
- package/lib/cem/event.mjs +168 -0
- 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 +1422 -0
- package/lib/cem/schema.json +1098 -0
- package/lib/cem/types-internal.d.ts +808 -0
- package/lib/cem/types.d.ts +736 -0
- package/lib/cem/utils.mjs +423 -0
- package/lib/cem/validate.js +76 -0
- package/lib/copy-and-watch/index.js +128 -97
- package/lib/copy-list/index.js +26 -20
- package/lib/create-icons/index.js +131 -58
- package/lib/create-illustrations/index.js +179 -69
- package/lib/create-new-component/Component.js +74 -0
- package/lib/create-new-component/ComponentTemplate.js +12 -0
- package/lib/create-new-component/index.js +62 -101
- package/lib/css-processors/css-processor-components.mjs +92 -0
- package/lib/css-processors/css-processor-themes.mjs +118 -0
- package/lib/css-processors/scope-variables.mjs +57 -0
- package/lib/css-processors/shared.mjs +46 -0
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/dev-server/dev-server.mjs +78 -0
- package/lib/dev-server/virtual-index-html-plugin.js +56 -0
- package/lib/generate-js-imports/illustrations.js +85 -0
- package/lib/generate-json-imports/i18n.js +70 -70
- package/lib/generate-json-imports/themes.js +47 -49
- package/lib/hbs2lit/src/compiler.js +24 -4
- package/lib/hbs2lit/src/includesReplacer.js +5 -5
- package/lib/hbs2lit/src/litVisitor2.js +95 -24
- package/lib/hbs2lit/src/svgProcessor.js +12 -5
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +39 -6
- package/lib/hbs2ui5/index.js +57 -24
- package/lib/i18n/defaults.js +74 -60
- package/lib/i18n/toJSON.js +22 -18
- package/lib/icons-hash/icons-hash.mjs +149 -0
- package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
- package/lib/remove-dev-mode/remove-dev-mode.mjs +51 -0
- package/lib/rimraf/rimraf.js +31 -0
- package/lib/scoping/get-all-tags.js +11 -11
- package/lib/scoping/lint-src.js +8 -7
- package/lib/scoping/missing-dependencies.js +65 -0
- package/lib/scoping/report-tags-usage.js +28 -0
- package/lib/scoping/scope-test-pages.js +2 -1
- package/lib/test-runner/test-runner.js +79 -0
- package/package.json +51 -46
- package/tsconfig.json +18 -0
- package/bin/init-ui5-package.js +0 -3
- package/components-package/rollup.js +0 -216
- package/components-package/wdio.sync.js +0 -344
- package/lib/documentation/index.js +0 -165
- package/lib/documentation/templates/api-component-since.js +0 -3
- package/lib/documentation/templates/api-css-variables-section.js +0 -24
- package/lib/documentation/templates/api-events-section.js +0 -35
- package/lib/documentation/templates/api-methods-section.js +0 -26
- package/lib/documentation/templates/api-properties-section.js +0 -40
- package/lib/documentation/templates/api-slots-section.js +0 -28
- package/lib/documentation/templates/template.js +0 -38
- package/lib/esm-abs-to-rel/index.js +0 -54
- package/lib/hash/config.js +0 -10
- package/lib/hash/generate.js +0 -19
- package/lib/hash/upToDate.js +0 -31
- package/lib/init-package/index.js +0 -134
- package/lib/init-package/resources/.eslintignore +0 -3
- package/lib/init-package/resources/bundle.js +0 -31
- package/lib/init-package/resources/config/.eslintrc.js +0 -1
- package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
- package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
- package/lib/init-package/resources/config/rollup.config.js +0 -1
- package/lib/init-package/resources/config/wdio.conf.js +0 -1
- package/lib/init-package/resources/package-scripts.js +0 -11
- package/lib/init-package/resources/src/Assets.js +0 -5
- package/lib/init-package/resources/src/MyFirstComponent.hbs +0 -1
- package/lib/init-package/resources/src/MyFirstComponent.js +0 -56
- package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
- package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
- package/lib/init-package/resources/src/themes/MyFirstComponent.css +0 -11
- package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
- package/lib/init-package/resources/test/pages/index.html +0 -54
- package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
- package/lib/jsdoc/config.json +0 -29
- package/lib/jsdoc/plugin.js +0 -2427
- package/lib/jsdoc/template/publish.js +0 -4101
- package/lib/polyfill-placeholder/index.js +0 -5
- package/lib/postcss-css-to-esm/index.js +0 -45
- package/lib/postcss-css-to-json/index.js +0 -31
- package/lib/postcss-new-files/index.js +0 -36
- package/lib/replace-global-core/index.js +0 -20
- package/lib/serve/index.js +0 -46
- package/lib/serve/serve.json +0 -3
- package/package-lock.json +0 -48
package/icons-collection/nps.js
CHANGED
|
@@ -1,35 +1,77 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
|
-
const resolve = require("resolve");
|
|
3
|
-
|
|
4
|
-
const generateHash = resolve.sync("@ui5/webcomponents-tools/lib/hash/generate.js");
|
|
5
|
-
const hashIsUpToDate = resolve.sync("@ui5/webcomponents-tools/lib/hash/upToDate.js");
|
|
6
|
-
const UP_TO_DATE = `node "${hashIsUpToDate}" dist/ hash.txt && echo "Up to date."`;
|
|
7
2
|
|
|
8
3
|
const LIB = path.join(__dirname, `../lib/`);
|
|
9
4
|
|
|
5
|
+
const createIconImportsCommand = (options) => {
|
|
6
|
+
if (!options.versions) {
|
|
7
|
+
return `ui5nps-script "${LIB}/create-icons/index.js" "${options.collectionName}"`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const command = { default: "ui5nps" };
|
|
11
|
+
options.versions.forEach((v) => {
|
|
12
|
+
command.default += ` build.icons.create${v}`;
|
|
13
|
+
command[`create${v}`] = `ui5nps-script "${LIB}/create-icons/index.js" "${options.collectionName}" "${v}"`;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return command;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const hashesCheck = cmd => `(node "${LIB}/icons-hash/icons-hash.mjs" check) || (${cmd} && node "${LIB}/icons-hash/icons-hash.mjs" save)`;
|
|
20
|
+
|
|
21
|
+
const copyIconAssetsCommand = (options) => {
|
|
22
|
+
if (!options.versions) {
|
|
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/`,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const command = {
|
|
31
|
+
default: "ui5nps copy.json-imports ",
|
|
32
|
+
"json-imports": `ui5nps-script "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
options.versions.forEach((v) => {
|
|
36
|
+
command.default += ` copy.icon-collection${v}`;
|
|
37
|
+
command[`icon-collection${v}`] = `ui5nps-script "${LIB}/copy-and-watch/index.js" --silent "src/${v}/*.json" src/generated/assets/${v}/`;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return command;
|
|
41
|
+
}
|
|
42
|
+
|
|
10
43
|
const getScripts = (options) => {
|
|
44
|
+
const createJSImportsCmd = createIconImportsCommand(options);
|
|
45
|
+
const copyAssetsCmd = copyIconAssetsCommand(options);
|
|
46
|
+
const tsCommand = !options.legacy ? "tsc --build" : "";
|
|
47
|
+
const tsOption = !options.legacy;
|
|
11
48
|
|
|
12
49
|
const scripts = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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`,
|
|
18
57
|
},
|
|
58
|
+
copy: copyAssetsCmd,
|
|
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`,
|
|
19
61
|
build: {
|
|
20
|
-
default:
|
|
62
|
+
default: hashesCheck(`ui5nps clean copy build.i18n typescript build.icons build.jsonImports`),
|
|
21
63
|
i18n: {
|
|
22
|
-
default: "
|
|
23
|
-
defaultsjs: `
|
|
24
|
-
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`,
|
|
25
67
|
},
|
|
26
68
|
jsonImports: {
|
|
27
|
-
default: "
|
|
28
|
-
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`,
|
|
29
71
|
},
|
|
30
|
-
icons:
|
|
72
|
+
icons: createJSImportsCmd,
|
|
31
73
|
},
|
|
32
|
-
|
|
74
|
+
typescript: tsCommand,
|
|
33
75
|
};
|
|
34
76
|
|
|
35
77
|
return scripts;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
const fs = require("fs").promises;
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const babelCore = require("@babel/core");
|
|
4
|
+
const babelParser = require("@babel/parser");
|
|
5
|
+
const babelGenerator = require("@babel/generator").default;
|
|
6
|
+
const replaceAsync = require('replace-in-file');
|
|
7
|
+
|
|
8
|
+
const convertSAPUIDefineToDefine = async (filePath) => {
|
|
9
|
+
return replaceAsync({
|
|
10
|
+
files: filePath,
|
|
11
|
+
processor: (input) => {
|
|
12
|
+
return input.replace("sap.ui.define", "define").replace(", /* bExport= */ false", "").replace(", /* bExport= */ true", "");
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const convertAmdToEs6 = async (code) => {
|
|
18
|
+
return (await babelCore.transformAsync(code, {
|
|
19
|
+
plugins: [['babel-plugin-amd-to-esm', {}]]
|
|
20
|
+
})).code;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const convertAbsImportsToRelative = (filePath, code, basePath) => {
|
|
24
|
+
let changed = false;
|
|
25
|
+
// console.log("File processing started: ", srcPath);
|
|
26
|
+
|
|
27
|
+
if (code.includes("import(")) {
|
|
28
|
+
// esprima can't parse this, but it's from the project files
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const tree = babelParser.parse(code, { sourceType: "module" });
|
|
33
|
+
const importer = filePath.replace(basePath, "");
|
|
34
|
+
const importerDir = path.dirname(importer);
|
|
35
|
+
// console.log("Importer -> ", importer);
|
|
36
|
+
|
|
37
|
+
tree?.program?.body?.forEach(node => {
|
|
38
|
+
if (node.type === "ImportDeclaration") {
|
|
39
|
+
let importee = node.source.value;
|
|
40
|
+
// console.log(importee);
|
|
41
|
+
if (importee.startsWith(".")) {
|
|
42
|
+
// add .js extension if missing
|
|
43
|
+
if (!importee.endsWith(".js")) {
|
|
44
|
+
node.source.value += ".js"
|
|
45
|
+
changed = true;
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let importeeDir = path.dirname(importee);
|
|
50
|
+
let importeeFile = path.basename(importee);
|
|
51
|
+
let relativePath = path.relative(importerDir, importeeDir);
|
|
52
|
+
if (relativePath.length === 0) {
|
|
53
|
+
relativePath = "."
|
|
54
|
+
}
|
|
55
|
+
if (!relativePath.startsWith(".")) {
|
|
56
|
+
relativePath = "./" + relativePath;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
relativePath = relativePath.replace(/\\/g, "/"); // the browser expects unix paths
|
|
60
|
+
let relativeImport = `${relativePath}/${importeeFile}.js`;
|
|
61
|
+
// console.log(importee + " --> " + relativeImport);
|
|
62
|
+
node.source.value = relativeImport;
|
|
63
|
+
changed = true;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return changed ? babelGenerator(tree).code : code;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const replaceGlobalCoreUsage = (filePath, code) => {
|
|
71
|
+
if (!filePath.includes("Configuration")) {
|
|
72
|
+
const replaced = code.replace(/sap\.ui\.getCore\(\)/g, `Core`);
|
|
73
|
+
return code !== replaced ? `import Core from 'sap/ui/core/Core';${replaced}` : code;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return code;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const transformAmdToES6Module = async (filePath, basePath) => {
|
|
80
|
+
await convertSAPUIDefineToDefine(filePath);
|
|
81
|
+
|
|
82
|
+
let code = (await fs.readFile(filePath)).toString();
|
|
83
|
+
|
|
84
|
+
code = await convertAmdToEs6(code);
|
|
85
|
+
|
|
86
|
+
code = replaceGlobalCoreUsage(filePath, code);
|
|
87
|
+
|
|
88
|
+
code = convertAbsImportsToRelative(filePath, code, basePath);
|
|
89
|
+
|
|
90
|
+
return fs.writeFile(filePath, code);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const transformAmdToES6Modules = async (argv) => {
|
|
94
|
+
const basePath = argv[2];
|
|
95
|
+
const { globby } = await import("globby");
|
|
96
|
+
const fileNames = await globby(basePath.replace(/\\/g, "/") + "**/*.js");
|
|
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
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
if (require.main === module) {
|
|
104
|
+
transformAmdToES6Modules(process.argv)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
exports._ui5mainFn = transformAmdToES6Modules;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const fs = require("fs").promises;
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const basePath = process.argv[2];
|
|
4
|
+
const babelCore = require("@babel/core");
|
|
5
|
+
const babelParser = require("@babel/parser");
|
|
6
|
+
const babelGenerator = require("@babel/generator").default;
|
|
7
|
+
const walk = require("estree-walk");
|
|
8
|
+
|
|
9
|
+
const checkHasRequire = (filePath, code) => {
|
|
10
|
+
code = code.replace(/sap\.ui\.require/g, "unhandledRequire");
|
|
11
|
+
|
|
12
|
+
const tree = babelParser.parse(code, { sourceType: "module" });
|
|
13
|
+
walk(tree, {
|
|
14
|
+
CallExpression: function (node) {
|
|
15
|
+
if (node.type === "CallExpression" && node?.callee?.name === "unhandledRequire") {
|
|
16
|
+
throw new Error(`sap.ui.require found in ${filePath}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const checkFile = async (filePath) => {
|
|
23
|
+
let code = (await fs.readFile(filePath)).toString();
|
|
24
|
+
checkHasRequire(filePath, code);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const checkAll = async () => {
|
|
28
|
+
const { globby } = await import("globby");
|
|
29
|
+
const fileNames = await globby(basePath.replace(/\\/g, "/") + "**/*.js");
|
|
30
|
+
return Promise.all(fileNames.map(checkFile).filter(x => !!x));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
checkAll();
|
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;
|