@ui5/webcomponents-tools 0.0.0-fb61e9889 → 0.0.0-fc993d8cd

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +357 -0
  2. package/README.md +5 -6
  3. package/assets-meta.js +6 -1
  4. package/bin/dev.js +1 -5
  5. package/components-package/eslint.js +34 -0
  6. package/components-package/nps.js +86 -57
  7. package/components-package/postcss.components.js +13 -13
  8. package/components-package/postcss.themes.js +19 -16
  9. package/components-package/vite.config.js +13 -0
  10. package/components-package/wdio.js +393 -353
  11. package/components-package/wdio.sync.js +17 -1
  12. package/icons-collection/nps.js +46 -15
  13. package/lib/copy-and-watch/index.js +24 -1
  14. package/lib/copy-list/index.js +17 -17
  15. package/lib/create-icons/index.js +124 -58
  16. package/lib/create-illustrations/index.js +107 -41
  17. package/lib/create-new-component/index.js +105 -108
  18. package/lib/create-new-component/jsFileContentTemplate.js +77 -0
  19. package/lib/create-new-component/tsFileContentTemplate.js +84 -0
  20. package/lib/dev-server/dev-server.js +66 -0
  21. package/lib/dev-server/virtual-index-html-plugin.js +52 -0
  22. package/lib/esm-abs-to-rel/index.js +13 -9
  23. package/lib/generate-custom-elements-manifest/index.js +327 -0
  24. package/lib/generate-js-imports/illustrations.js +72 -0
  25. package/lib/generate-json-imports/i18n.js +38 -31
  26. package/lib/generate-json-imports/themes.js +31 -24
  27. package/lib/hbs2lit/src/compiler.js +20 -3
  28. package/lib/hbs2lit/src/includesReplacer.js +5 -5
  29. package/lib/hbs2lit/src/litVisitor2.js +56 -10
  30. package/lib/hbs2ui5/index.js +37 -21
  31. package/lib/i18n/defaults.js +65 -57
  32. package/lib/i18n/toJSON.js +12 -11
  33. package/lib/jsdoc/configTypescript.json +29 -0
  34. package/lib/jsdoc/plugin.js +41 -0
  35. package/lib/jsdoc/preprocess.js +146 -0
  36. package/lib/jsdoc/template/publish.js +21 -2
  37. package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
  38. package/lib/postcss-css-to-esm/index.js +53 -8
  39. package/lib/postcss-css-to-json/index.js +18 -2
  40. package/lib/postcss-p/postcss-p.mjs +14 -0
  41. package/lib/replace-global-core/index.js +13 -8
  42. package/lib/scoping/get-all-tags.js +1 -8
  43. package/lib/scoping/missing-dependencies.js +65 -0
  44. package/lib/scoping/report-tags-usage.js +28 -0
  45. package/lib/scoping/scope-test-pages.js +1 -1
  46. package/lib/test-runner/test-runner.js +71 -0
  47. package/package.json +28 -28
  48. package/components-package/rollup-plugins/empty-module.js +0 -15
  49. package/components-package/rollup.js +0 -237
  50. package/lib/documentation/index.js +0 -165
  51. package/lib/documentation/templates/api-component-since.js +0 -3
  52. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  53. package/lib/documentation/templates/api-events-section.js +0 -35
  54. package/lib/documentation/templates/api-methods-section.js +0 -26
  55. package/lib/documentation/templates/api-properties-section.js +0 -40
  56. package/lib/documentation/templates/api-slots-section.js +0 -28
  57. package/lib/documentation/templates/template.js +0 -38
  58. package/lib/hash/config.js +0 -10
  59. package/lib/hash/generate.js +0 -19
  60. package/lib/hash/upToDate.js +0 -31
  61. package/lib/polyfill-placeholder/index.js +0 -5
  62. package/lib/serve/index.js +0 -46
  63. package/lib/serve/serve.json +0 -3
  64. package/package-lock.json +0 -48
@@ -1,40 +1,76 @@
1
1
  const path = require("path");
2
2
  const fs = require("fs");
3
-
3
+ const resolve = require("resolve");
4
4
  const LIB = path.join(__dirname, `../lib/`);
5
- const polyfillDir = path.dirname(require.resolve("@webcomponents/webcomponentsjs"));
6
- const polyfillPath = path.join(polyfillDir, "{*.js,*.map,*.md,bundles/**/*.*}");
7
- const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
5
+ const preprocessJSDocScript = resolve.sync("@ui5/webcomponents-tools/lib/jsdoc/preprocess.js");
8
6
 
9
7
  const getScripts = (options) => {
10
8
 
11
- const port = options.port || 8080; // preferred port
12
- const portStep = options.portStep || 1; // step to check for available ports, if preferred port is already used
13
- let illustrations = options.illustrationsData || [];
9
+ // The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
10
+ const illustrationsData = options.illustrationsData || [];
11
+ const illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
12
+ const createIllustrationsJSImportsScript = illustrations.join(" && ");
13
+
14
+ // The script creates the "dist/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
15
+ const illustrationDestinationPaths = illustrationsData.map(illustrations => illustrations.destinationPath);
16
+ const createIllustrationsLoadersScript = options.fioriPackage ? `node ${LIB}/generate-js-imports/illustrations.js ${illustrationDestinationPaths[0]} ${illustrationDestinationPaths[1]} dist/generated/js-imports` : "";
17
+ const tsOption = options.typescript;
18
+ const tsCommand = tsOption ? "tsc" : "";
19
+ const tsWatchCommand = tsOption ? "tsc --watch" : "";
20
+ const tsCrossEnv = tsOption ? "cross-env UI5_TS=true" : "";
21
+ const copySrcGenerated = tsOption ? "" : "copy.srcGenerated";
14
22
 
15
- illustrations = illustrations.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
23
+ if (tsOption) {
24
+ try {
25
+ require("typescript");
26
+ } catch(e) {
27
+ 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.`);
28
+ process.exit(e.code);
29
+ }
30
+ }
16
31
 
17
- let illustrationsScript = illustrations.join(" && ");
32
+ let viteConfig;
33
+ if (fs.existsSync("config/vite.config.js")) {
34
+ // old project setup where config file is in separate folder
35
+ viteConfig = "-c config/vite.config.js";
36
+ } else if (fs.existsSync("vite.config.js")) {
37
+ // preferred way of custom configuration in root project folder
38
+ viteConfig = "";
39
+ } else {
40
+ // no custom configuration - use default from tools project
41
+ viteConfig = `-c "${require.resolve("@ui5/webcomponents-tools/components-package/vite.config.js")}"`;
42
+ }
43
+
44
+ let eslintConfig;
45
+ if (fs.existsSync(".eslintrc.js") || fs.existsSync(".eslintrc.cjs")) {
46
+ // preferred way of custom configuration in root project folder
47
+ eslintConfig = "";
48
+ } else {
49
+ // no custom configuration - use default from tools project
50
+ eslintConfig = `--config "${require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")}"`;
51
+ }
18
52
 
19
53
  const scripts = {
20
- clean: "rimraf dist && rimraf .port",
21
- lint: "eslint . --config config/.eslintrc.js",
22
- lintfix: "eslint . --config config/.eslintrc.js --fix",
54
+ clean: 'rimraf jsdoc-dist && rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
55
+ lint: `eslint . ${eslintConfig}`,
56
+ lintfix: `eslint . ${eslintConfig} --fix`,
23
57
  prepare: {
24
- default: "nps clean build.templates build.styles build.i18n build.jsonImports copy build.samples build.illustrations",
25
- es5: "nps clean build.templates build.styles build.i18n build.jsonImports copy.es5 build.samples build.illustrations"
58
+ default: `${tsCrossEnv} nps clean prepare.all typescript generateAPI`,
59
+ all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.illustrations"',
60
+ styleRelated: "nps build.styles build.jsonImports build.jsImports",
26
61
  },
62
+ typescript: tsCommand,
27
63
  build: {
28
- default: "nps lint prepare.es5 build.bundle",
64
+ default: "nps prepare lint build.bundle",
29
65
  templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
30
66
  styles: {
31
- default: "nps build.styles.themes build.styles.components",
32
- themes: "postcss src/**/parameters-bundle.css --config config/postcss.themes --base src --dir dist/css/",
67
+ default: `nps build.styles.themes build.styles.components ${copySrcGenerated}`,
68
+ themes: `node "${LIB}/postcss-p/postcss-p.mjs"`,
33
69
  components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
34
70
  },
35
71
  i18n: {
36
72
  default: "nps build.i18n.defaultsjs build.i18n.json",
37
- defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
73
+ defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
38
74
  json: `node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
39
75
  },
40
76
  jsonImports: {
@@ -42,33 +78,26 @@ const getScripts = (options) => {
42
78
  themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes dist/generated/json-imports`,
43
79
  i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
44
80
  },
45
- bundle: "rollup --config config/rollup.config.js --environment ES5_BUILD",
46
- samples: {
47
- default: "nps build.samples.api build.samples.docs",
48
- api: `jsdoc -c "${LIB}/jsdoc/config.json"`,
49
- docs: `node "${LIB}/documentation/index.js" dist/api.json`,
81
+ jsImports: {
82
+ default: "mkdirp dist/generated/js-imports && nps build.jsImports.illustrationsLoaders",
83
+ illustrationsLoaders: createIllustrationsLoadersScript,
50
84
  },
51
- illustrations: illustrationsScript
85
+ bundle: `vite build ${viteConfig}`,
86
+ illustrations: createIllustrationsJSImportsScript,
52
87
  },
53
88
  copy: {
54
- default: "nps copy.src copy.props copy.test copy.webcomponents-polyfill-placeholder",
55
- es5: "nps copy.src copy.props copy.test copy.webcomponents-polyfill",
89
+ default: "nps copy.src copy.props",
56
90
  src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
91
+ srcGenerated: `node "${LIB}/copy-and-watch/index.js" --silent "src/generated/**/*.js" dist/generated/`,
57
92
  props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
58
- test: `node "${LIB}/copy-and-watch/index.js" --silent "test/**/*.*" dist/test-resources`,
59
- "webcomponents-polyfill": `node "${LIB}/copy-and-watch/index.js" --silent "${polyfillPath}" dist/webcomponentsjs/`,
60
- "webcomponents-polyfill-placeholder": `node "${LIB}/polyfill-placeholder/index.js"`
61
93
  },
62
94
  watch: {
63
- default: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle" "nps watch.styles" "nps watch.i18n"',
64
- es5: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.bundle.es5" "nps watch.styles" "nps watch.i18n"',
95
+ default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.typescript" "nps watch.styles" "nps watch.i18n" "nps watch.props"`,
96
+ devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
65
97
  src: 'nps "copy.src --watch --safe --skip-initial-copy"',
98
+ typescript: tsWatchCommand,
66
99
  props: 'nps "copy.props --watch --safe --skip-initial-copy"',
67
- test: 'nps "copy.test --watch --safe --skip-initial-copy"',
68
- bundle: {
69
- default: 'rollup --config config/rollup.config.js -w --environment DEV,DEPLOY_PUBLIC_PATH:/resources/',
70
- es5: 'rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,DEPLOY_PUBLIC_PATH:/resources/'
71
- },
100
+ bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
72
101
  styles: {
73
102
  default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
74
103
  themes: 'nps "build.styles.themes -w"',
@@ -79,35 +108,35 @@ const getScripts = (options) => {
79
108
  },
80
109
  },
81
110
  templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
82
- samples: 'chokidar "test/**/*.sample.html" -c "nps build.samples"',
111
+ api: 'chokidar "test/**/*.sample.html" -c "nps generateAPI"',
83
112
  i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
84
113
  },
85
- dev: {
86
- default: 'concurrently "nps serve" "nps watch"',
87
- es5: 'concurrently "nps serve" "nps watch.es5"'
88
- },
89
- start: "nps prepare dev",
90
- serve: `node "${LIB}/serve/index.js" --dir="dist/" --port=${port} --portStep=${portStep} --packageName="${packageName}"`,
91
- test: {
92
- // --success first - report the exit code of the test run (first command to finish), as serve is always terminated and has a non-0 exit code
93
- default: 'concurrently "nps serve" "nps test.run" --kill-others --success first',
94
- run: "cross-env WDIO_LOG_LEVEL=error wdio config/wdio.conf.js",
95
- spec: "wdio run config/wdio.conf.js",
96
- },
97
- startWithScope: "nps scope.prepare scope.dev",
114
+ start: "nps prepare watch.devServer",
115
+ test: `node "${LIB}/test-runner/test-runner.js"`,
116
+ "test-suite-1": `node "${LIB}/test-runner/test-runner.js" --suite suite1`,
117
+ "test-suite-2": `node "${LIB}/test-runner/test-runner.js" --suite suite2`,
118
+ startWithScope: "nps scope.prepare scope.watchWithBundle",
98
119
  scope: {
99
120
  prepare: "nps scope.lint prepare scope.testPages",
100
121
  lint: `node "${LIB}/scoping/lint-src.js"`,
101
122
  testPages: {
102
123
  default: "nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
103
- clean: "rimraf dist/test-resources/pages/scoped",
104
- copy: `node "${LIB}/copy-and-watch/index.js" --silent "dist/test-resources/pages/**/*" dist/test-resources/scoped`,
105
- replace: `node "${LIB}/scoping/scope-test-pages.js" dist/test-resources/scoped demo`,
124
+ clean: "rimraf test/pages/scoped",
125
+ copy: `node "${LIB}/copy-and-watch/index.js" --silent "test/pages/**/*" test/pages/scoped`,
126
+ replace: `node "${LIB}/scoping/scope-test-pages.js" test/pages/scoped demo`,
106
127
  },
107
- dev: 'concurrently "nps serve" "nps scope.watch"',
108
- watch: 'concurrently "nps watch.templates" "nps watch.samples" "nps watch.test" "nps watch.src" "nps watch.props" "nps scope.bundle" "nps watch.styles"',
109
- bundle: 'rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,SCOPE'
110
- }
128
+ watchWithBundle: 'concurrently "nps scope.watch" "nps scope.bundle" ',
129
+ watch: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.props" "nps watch.styles"',
130
+ bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
131
+ },
132
+ generateAPI: {
133
+ default: "nps generateAPI.prepare generateAPI.preprocess generateAPI.jsdoc generateAPI.cleanup generateAPI.prepareManifest",
134
+ prepare: `node "${LIB}/copy-and-watch/index.js" --silent "dist/**/*.js" jsdoc-dist/`,
135
+ prepareManifest: `node "${LIB}/generate-custom-elements-manifest/index.js" dist dist`,
136
+ preprocess: `node "${preprocessJSDocScript}" jsdoc-dist/ src`,
137
+ jsdoc: `jsdoc -c "${LIB}/jsdoc/configTypescript.json"`,
138
+ cleanup: "rimraf jsdoc-dist/"
139
+ },
111
140
  };
112
141
 
113
142
  return scripts;
@@ -6,16 +6,16 @@ const fs = require("fs");
6
6
  const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
7
7
 
8
8
  module.exports = {
9
- plugins: [
10
- postcssImport(),
11
- cssnano({
12
- preset: [
13
- 'default', {
14
- mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
15
- mergeRules: false, // https://github.com/cssnano/cssnano/issues/730
16
- },
17
- ]
18
- }),
19
- postcssCSStoESM({toReplace: 'src', includeDefaultTheme: true, packageName}),
20
- ]
21
- };
9
+ plugins: [
10
+ postcssImport(),
11
+ cssnano({
12
+ preset: [
13
+ 'default', {
14
+ mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
15
+ mergeRules: false, // https://github.com/cssnano/cssnano/issues/730
16
+ },
17
+ ]
18
+ }),
19
+ postcssCSStoESM({ toReplace: 'src', includeDefaultTheme: true, packageName }),
20
+ ]
21
+ }
@@ -1,23 +1,26 @@
1
1
  const postcssImport = require('postcss-import');
2
- const combineSelectors = require('postcss-combine-duplicated-selectors');
2
+ const combineSelectors = require('../lib/postcss-combine-duplicated-selectors/index.js');
3
3
  const postcssCSStoJSON = require('../lib/postcss-css-to-json/index.js');
4
4
  const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
5
5
  const cssnano = require('cssnano');
6
+ const fs = require("fs");
7
+
8
+ const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
6
9
 
7
10
  module.exports = {
8
- plugins: [
9
- postcssImport(),
10
- combineSelectors({
11
- removeDuplicatedProperties: true
12
- }),
13
- cssnano({
14
- preset: [
15
- 'default', {
16
- mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
17
- },
18
- ]
19
- },),
20
- postcssCSStoJSON({toReplace: 'src'}),
21
- postcssCSStoESM({toReplace: 'src'}),
22
- ]
11
+ plugins: [
12
+ postcssImport(),
13
+ combineSelectors({
14
+ removeDuplicatedProperties: true
15
+ }),
16
+ cssnano({
17
+ preset: [
18
+ 'default', {
19
+ mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
20
+ },
21
+ ]
22
+ },),
23
+ postcssCSStoJSON({ toReplace: 'src', packageName }),
24
+ postcssCSStoESM({ toReplace: 'src', packageName }),
25
+ ]
23
26
  };
@@ -0,0 +1,13 @@
1
+ // vite.config.js
2
+ import { defineConfig } from 'vite';
3
+ import virtualIndex from '../lib/dev-server/virtual-index-html-plugin.js';
4
+
5
+ export default defineConfig(async () => {
6
+ const data = await virtualIndex();
7
+ return {
8
+ build: {
9
+ emptyOutDir: false,
10
+ },
11
+ plugins: [data],
12
+ }
13
+ })