@ui5/webcomponents-tools 0.0.0-5f8ce9393 → 0.0.0-6d98d0c29

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 (59) hide show
  1. package/CHANGELOG.md +107 -1
  2. package/assets-meta.js +147 -0
  3. package/bin/dev.js +16 -1
  4. package/components-package/nps.js +74 -33
  5. package/components-package/rollup.js +131 -49
  6. package/components-package/wdio.js +58 -47
  7. package/icons-collection/nps.js +38 -28
  8. package/lib/copy-and-watch/index.js +122 -0
  9. package/lib/copy-list/index.js +28 -0
  10. package/lib/create-icons/index.js +27 -23
  11. package/lib/create-illustrations/index.js +95 -0
  12. package/lib/create-new-component/index.js +18 -6
  13. package/lib/documentation/index.js +43 -21
  14. package/lib/esm-abs-to-rel/index.js +54 -0
  15. package/lib/generate-json-imports/i18n.js +91 -47
  16. package/lib/generate-json-imports/themes.js +61 -13
  17. package/lib/hash/config.js +10 -0
  18. package/lib/hash/generate.js +19 -0
  19. package/lib/hash/upToDate.js +31 -0
  20. package/lib/hbs2lit/index.js +2 -4
  21. package/lib/hbs2lit/src/compiler.js +8 -7
  22. package/lib/hbs2lit/src/includesReplacer.js +22 -16
  23. package/lib/hbs2lit/src/litVisitor2.js +47 -9
  24. package/lib/hbs2lit/src/svgProcessor.js +3 -3
  25. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
  26. package/lib/hbs2ui5/index.js +26 -20
  27. package/lib/i18n/defaults.js +25 -6
  28. package/lib/i18n/toJSON.js +15 -4
  29. package/lib/init-package/index.js +28 -11
  30. package/lib/init-package/resources/bundle.es5.js +1 -1
  31. package/lib/init-package/resources/bundle.esm.js +2 -5
  32. package/lib/init-package/resources/src/Assets.js +0 -1
  33. package/lib/init-package/resources/src/{Demo.hbs → MyFirstComponent.hbs} +0 -0
  34. package/lib/init-package/resources/src/{Demo.js → MyFirstComponent.js} +0 -0
  35. package/lib/init-package/resources/src/i18n/messagebundle.properties +1 -1
  36. package/lib/init-package/resources/src/themes/{Demo.css → MyFirstComponent.css} +2 -2
  37. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +1 -1
  38. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +1 -1
  39. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +3 -0
  40. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +1 -1
  41. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +1 -1
  42. package/lib/init-package/resources/src/themes/sap_fiori_3_hcb/parameters-bundle.css +3 -0
  43. package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +3 -0
  44. package/lib/init-package/resources/test/pages/index.html +9 -4
  45. package/lib/jsdoc/config.json +1 -1
  46. package/lib/jsdoc/plugin.js +24 -4
  47. package/lib/jsdoc/template/publish.js +11 -2
  48. package/lib/polyfill-placeholder/index.js +5 -0
  49. package/lib/postcss-css-to-esm/index.js +31 -19
  50. package/lib/postcss-css-to-json/index.js +22 -11
  51. package/lib/postcss-new-files/index.js +36 -0
  52. package/lib/replace-global-core/index.js +20 -0
  53. package/lib/scoping/get-all-tags.js +44 -0
  54. package/lib/scoping/lint-src.js +31 -0
  55. package/lib/scoping/scope-test-pages.js +40 -0
  56. package/lib/serve/index.js +46 -0
  57. package/{components-package → lib/serve}/serve.json +0 -0
  58. package/package-lock.json +48 -0
  59. package/package.json +53 -51
@@ -1,17 +1,24 @@
1
- const babel = require("rollup-plugin-babel");
2
1
  const process = require("process");
3
- const resolve = require("rollup-plugin-node-resolve");
4
- const url = require("rollup-plugin-url");
5
- const { terser } = require("rollup-plugin-terser");
6
- const notify = require('rollup-plugin-notify');
7
- const filesize = require('rollup-plugin-filesize');
8
- const livereload = require('rollup-plugin-livereload');
9
- const os = require("os");
10
2
  const fs = require("fs");
3
+ const os = require("os");
4
+ const { babel } = require("@rollup/plugin-babel");
5
+ const { nodeResolve } = require("@rollup/plugin-node-resolve");
6
+ const url = require("@rollup/plugin-url");
7
+ const { terser } = require("rollup-plugin-terser");
8
+ const json = require("@rollup/plugin-json");
9
+ const colors = require("colors/safe");
10
+ const filesize = require("rollup-plugin-filesize");
11
+ const livereload = require("rollup-plugin-livereload");
11
12
 
12
- const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
13
+ const packageFile = JSON.parse(fs.readFileSync("./package.json"));
14
+ const packageName = packageFile.name;
13
15
  const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
14
16
 
17
+ const warningsToSkip = [{
18
+ warningCode: "THIS_IS_UNDEFINED",
19
+ filePath: /.+zxing.+/,
20
+ }];
21
+
15
22
  function ui5DevImportCheckerPlugin() {
16
23
  return {
17
24
  name: "ui5-dev-import-checker-plugin",
@@ -20,51 +27,109 @@ function ui5DevImportCheckerPlugin() {
20
27
  if (re.test(code)) {
21
28
  throw new Error(`illegal import in ${file}`);
22
29
  }
23
- }
30
+ },
31
+ };
32
+ }
33
+
34
+ function onwarn(warning, warn) {
35
+ // Skip warning for known false positives that will otherwise polute the log
36
+ let skip = warningsToSkip.find(warningToSkip => {
37
+ let loc, file;
38
+ return warning.code === warningToSkip.warningCode
39
+ && (loc = warning.loc)
40
+ && (file = loc.file)
41
+ && file.match(warningToSkip.filePath);
42
+ });
43
+ if (skip) {
44
+ return;
45
+ }
46
+
47
+ // warn everything else
48
+ warn( warning );
49
+ }
50
+
51
+ const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
52
+ function ui5DevReadyMessagePlugin() {
53
+ return {
54
+ name: "ui5-dev-message-ready-plugin",
55
+ writeBundle: (assets, bundle) => {
56
+ if (reportedForPackages.has(packageName)) {
57
+ return;
58
+ }
59
+ console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
60
+
61
+ if (fs.existsSync(".port")) {
62
+ const port = `${fs.readFileSync(".port")}`;
63
+ if (port) {
64
+ console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
65
+ }
66
+ }
67
+ reportedForPackages.add(packageName);
68
+ },
24
69
  };
25
70
  }
26
71
 
27
72
  const getPlugins = ({ transpile }) => {
28
73
  const plugins = [];
29
- let publicPath = DEPLOY_PUBLIC_PATH || "/resources/";
30
-
31
74
  if (!process.env.DEV) {
32
- plugins.push(filesize({
33
- render : function (options, bundle, { minSize, gzipSize, brotliSize, bundleSize }){
34
- return gzipSize;
35
- }
36
- }));
75
+ plugins.push(filesize(
76
+ {
77
+ reporter(options, bundle, {
78
+ minSize, gzipSize, brotliSize, bundleSize,
79
+ fileName,
80
+ // "showBeforeSizes: release"
81
+ lastVersion,
82
+ // "showBeforeSizes: "release" or "showBeforeSizes": "build"
83
+ bundleSizeBefore, brotliSizeBefore, minSizeBefore, gzipSizeBefore,
84
+ }) {
85
+ // If a promise is returned, it will be awaited before rendering.
86
+ return `${fileName.padEnd(35)} ${minSize} / gzipped: ${gzipSize}`;
87
+ },
88
+ },
89
+
90
+ ));
37
91
  }
38
92
 
93
+ const publicPath = DEPLOY_PUBLIC_PATH;
94
+
39
95
  plugins.push(ui5DevImportCheckerPlugin());
40
96
 
41
- plugins.push(url({
42
- limit: 0,
43
- include: [
44
- /.*assets\/.*\.json/
45
- ],
46
- emitFiles: true,
47
- fileName: "[name].[hash][extname]",
48
- publicPath,
49
- }));
97
+ if (!transpile) {
98
+ plugins.push(json({
99
+ include: [
100
+ /.*assets\/.*\.json/,
101
+ ],
102
+ namedExports: false,
103
+ }));
104
+ }
50
105
 
106
+ if (transpile) {
107
+ plugins.push(url({
108
+ limit: 0,
109
+ include: [
110
+ /.*assets\/.*\.json/,
111
+ ],
112
+ emitFiles: true,
113
+ fileName: "[name].[hash][extname]",
114
+ publicPath,
115
+ }));
116
+ }
51
117
 
52
118
  if (transpile) {
53
119
  plugins.push(babel({
54
120
  presets: ["@babel/preset-env"],
55
- exclude: "node_modules/**",
121
+ exclude: /node_modules\/(?!(lit-html|@ui5\/webcomponents))/, // exclude all node_modules/ except lit-html and all starting with @ui5/webcomponents
56
122
  sourcemap: true,
123
+ babelHelpers: "bundled",
57
124
  }));
58
125
  }
59
126
 
60
- plugins.push(resolve());
127
+ plugins.push(nodeResolve());
61
128
 
62
129
  if (!process.env.DEV) {
63
- plugins.push(terser());
64
- }
65
-
66
- if (process.env.DEV) {
67
- plugins.push(notify());
130
+ plugins.push(terser({
131
+ numWorkers: 1,
132
+ }));
68
133
  }
69
134
 
70
135
  const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
@@ -74,61 +139,78 @@ const getPlugins = ({ transpile }) => {
74
139
  "dist/resources/bundle.esm.js",
75
140
  "dist/**/*.html",
76
141
  "dist/**/*.json",
77
- ]
142
+ ],
78
143
  }));
79
144
  }
80
145
 
146
+ if (process.env.DEV) {
147
+ plugins.push(ui5DevReadyMessagePlugin());
148
+ }
149
+
81
150
  return plugins;
82
151
  };
83
152
 
84
- const getES6Config = () => {
153
+ const getES6Config = (input = "bundle.esm.js") => {
85
154
  return [{
86
- input: "bundle.esm.js",
155
+ input,
87
156
  output: {
88
157
  dir: "dist/resources",
89
158
  format: "esm",
90
- sourcemap: true
159
+ sourcemap: true,
91
160
  },
92
- moduleContext: (id) => {
93
- if (id.includes("url-search-params-polyfill")) {
161
+ moduleContext: id => {
162
+ if (typeof id === "string" && id.includes("url-search-params-polyfill")) {
94
163
  // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
95
164
  return "window";
96
165
  }
97
166
  },
98
167
  watch: {
99
- clearScreen: false
168
+ clearScreen: false,
100
169
  },
101
- plugins: getPlugins({transpile: false}),
170
+ plugins: getPlugins({ transpile: false }),
171
+ onwarn: onwarn,
102
172
  }];
103
173
  };
104
174
 
105
- const getES5Config = () => {
106
- return [ {
107
- input: "bundle.es5.js",
175
+ const getES5Config = (input = "bundle.es5.js") => {
176
+ return [{
177
+ input,
108
178
  output: {
109
179
  dir: "dist/resources",
110
180
  format: "iife",
181
+ inlineDynamicImports: true,
111
182
  name: "sap-ui-webcomponents-bundle",
112
183
  extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
113
- sourcemap: true
184
+ sourcemap: true,
114
185
  },
115
- moduleContext: (id) => {
186
+ moduleContext: id => {
116
187
  if (id.includes("url-search-params-polyfill")) {
117
188
  // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
118
189
  return "window";
119
190
  }
120
191
  },
121
192
  watch: {
122
- clearScreen: false
193
+ clearScreen: false,
123
194
  },
124
- plugins: getPlugins({transpile: true}),
195
+ plugins: getPlugins({ transpile: true }),
196
+ onwarn: onwarn,
125
197
  }];
126
198
  };
127
199
 
128
200
  let config = getES6Config();
129
201
 
130
- if (process.env.ES5_BUILD) {
202
+ if (process.env.ES5_BUILD && fs.existsSync("bundle.es5.js")) {
131
203
  config = config.concat(getES5Config());
132
204
  }
133
205
 
206
+ if (process.env.SCOPE) {
207
+ if (fs.existsSync("bundle.scoped.esm.js")) {
208
+ config = config.concat(getES6Config("bundle.scoped.esm.js"));
209
+
210
+ if (fs.existsSync("bundle.scoped.es5.js") && process.env.ES5_BUILD) {
211
+ config = config.concat(getES5Config("bundle.scoped.es5.js"));
212
+ }
213
+ }
214
+ }
215
+
134
216
  module.exports = config;
@@ -57,7 +57,7 @@ exports.config = {
57
57
  // to run chrome headless the following flags are required
58
58
  // (see https://developers.google.com/web/updates/2017/04/headless-chrome)
59
59
  args: ['--headless', '--disable-gpu'],
60
- //args: ['--disable-gpu'],
60
+ // args: ['--disable-gpu'],
61
61
  }
62
62
  }],
63
63
  //
@@ -82,7 +82,7 @@ exports.config = {
82
82
  // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
83
83
  // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
84
84
  // gets prepended directly.
85
- baseUrl: '',
85
+ baseUrl: undefined, // This is important since WDIO 7+ does not accept an empty string for baseUrl
86
86
  path: '',
87
87
  //
88
88
  // Default timeout for all waitFor* commands.
@@ -153,43 +153,6 @@ exports.config = {
153
153
  * @param {Array.<String>} specs List of spec file paths that are to be run
154
154
  */
155
155
  before: function (capabilities, specs) {
156
- browser.addCommand("findElementDeep", function (selector) {
157
- const selectors = selector.split(">>>");
158
-
159
- for (var i = 0; i < selectors.length; i++) {
160
- if (i === 0) {
161
- curElement = browser.$(selectors[i]);
162
- continue;
163
- }
164
-
165
- // wait for the shadowDom to be filled before executing the selector
166
- browser.executeAsync(function (elem, done) {
167
- elem._waitForDomRef().then(done);
168
- }, curElement);
169
-
170
- // find the next element from the selector
171
- curElement = curElement.$(new Function (`
172
- return this.shadowRoot.querySelector("${selectors[i]}");
173
- `));
174
- }
175
-
176
- return curElement;
177
-
178
- });
179
-
180
- browser.addCommand("findElementDeep", function (selector) {
181
- const selectors = selector.split(">>>");
182
- let curElement = this;
183
-
184
- for (var i = 0; i < selectors.length; i++) {
185
- curElement = curElement.$(new Function (`
186
- return this.shadowRoot.querySelector("${selectors[i]}");
187
- `));
188
- }
189
-
190
- return curElement;
191
- }, this);
192
-
193
156
  browser.addCommand("isFocusedDeep", function () {
194
157
  return browser.execute(function (elem) {
195
158
  let activeElement = document.activeElement;
@@ -230,8 +193,9 @@ exports.config = {
230
193
  }, true);
231
194
 
232
195
  browser.addCommand("getStaticAreaItemClassName", function(selector) {
233
- return browser.execute((selector) => {
234
- return document.querySelector(selector).getStaticAreaItemDomRef().host.classList[0];
196
+ return browser.execute(async (selector) => {
197
+ const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
198
+ return staticAreaItem.host.classList[0];
235
199
  }, selector);
236
200
  }, false);
237
201
  },
@@ -240,8 +204,34 @@ exports.config = {
240
204
  * @param {String} commandName hook command name
241
205
  * @param {Array} args arguments that command would receive
242
206
  */
243
- // beforeCommand: function (commandName, args) {
244
- // },
207
+ beforeCommand: function (commandName, args) {
208
+ const waitFor = [
209
+ "$",
210
+ "$$",
211
+ "getAttribute",
212
+ "getCSSProperty",
213
+ "getHTML",
214
+ "getProperty",
215
+ "getSize",
216
+ "getStaticAreaItemClassName", // custom
217
+ "getText",
218
+ "getValue",
219
+ "hasClass", // custom
220
+ "isDisplayed",
221
+ "isDisplayedInViewport",
222
+ "isEnabled",
223
+ "isExisting",
224
+ "isFocused",
225
+ "isFocusedDeep", // custom
226
+ "shadow$",
227
+ "shadow$$",
228
+ ];
229
+ if (waitFor.includes(commandName)) {
230
+ browser.executeAsync(function (done) {
231
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
232
+ });
233
+ }
234
+ },
245
235
 
246
236
  /**
247
237
  * Hook that gets executed before the suite starts
@@ -288,12 +278,33 @@ exports.config = {
288
278
  * @param {Object} error error object if any
289
279
  */
290
280
  afterCommand: function (commandName, args, result, error) {
291
- const waitFor = ["$", "$$", "shadow$", "click", "performActions", "elementClick", "keys", "sendKeys", "findElement", "elementClear", "elementSendKeys", "setValue", "addValue", "getHTML", "getProperty", "setAttribute", "removeAttribute", "getElementProperty"];
281
+
282
+ // url -> set configuration first
283
+ if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
284
+ browser.execute(function() {
285
+ window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
286
+ });
287
+ }
288
+
289
+ const waitFor = [
290
+ "addValue",
291
+ "clearValue",
292
+ "click",
293
+ "doubleClick",
294
+ "dragAndDrop",
295
+ "keys",
296
+ "pause",
297
+ "removeAttribute", // custom
298
+ "setAttribute", // custom
299
+ "setProperty", // custom
300
+ "setValue",
301
+ "setWindowSize",
302
+ "touchAction",
303
+ "url"
304
+ ];
292
305
  if (waitFor.includes(commandName)) {
293
306
  browser.executeAsync(function (done) {
294
- // run all the tests in no conflict mode
295
- window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
296
- window.RenderScheduler.whenFinished().then(done);
307
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
297
308
  });
298
309
  }
299
310
  },
@@ -1,28 +1,38 @@
1
- const path = require("path");
2
-
3
- const LIB = path.join(__dirname, `../lib/`);
4
-
5
- const getScripts = () => {
6
-
7
- const scripts = {
8
- clean: "rimraf dist",
9
- copy: {
10
- default: "nps copy.json-imports copy.icon-collections",
11
- "json-imports": 'copy-and-watch "src/**/*.js" dist/',
12
- "icon-collections": 'copy-and-watch "src/icon-collections/**/*.json" dist/generated/assets/icon-collections/'
13
- },
14
- build: {
15
- default: "nps clean copy build.i18n build.icons",
16
- i18n: {
17
- default: "nps build.i18n.defaultsjs build.i18n.json",
18
- defaultsjs: `mkdirp dist/generated/i18n && node ${LIB}/i18n/defaults.js src/i18n dist/generated/i18n`,
19
- json: `mkdirp dist/generated/assets/i18n && node ${LIB}/i18n/toJSON.js src/i18n dist/generated/assets/i18n`,
20
- },
21
- icons: `node ${LIB}/create-icons/index.js`,
22
- }
23
- };
24
-
25
- return scripts;
26
- };
27
-
28
- module.exports = getScripts;
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
+
8
+ const LIB = path.join(__dirname, `../lib/`);
9
+
10
+ const getScripts = (options) => {
11
+
12
+ const scripts = {
13
+ clean: "rimraf dist",
14
+ copy: {
15
+ default: "nps copy.json-imports copy.icon-collection",
16
+ "json-imports": `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
17
+ "icon-collection": `node "${LIB}/copy-and-watch/index.js" --silent "src/*.json" dist/generated/assets/`
18
+ },
19
+ build: {
20
+ default: `${UP_TO_DATE} || nps clean copy build.i18n build.icons build.jsonImports hash`,
21
+ i18n: {
22
+ default: "nps build.i18n.defaultsjs build.i18n.json",
23
+ defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
24
+ json: `mkdirp dist/generated/assets/i18n && node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
25
+ },
26
+ jsonImports: {
27
+ default: "mkdirp dist/generated/json-imports && nps build.jsonImports.i18n",
28
+ i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
29
+ },
30
+ icons: `node "${LIB}/create-icons/index.js" "${options.collectionName}"`,
31
+ },
32
+ hash: `node "${generateHash}" dist/ hash.txt`,
33
+ };
34
+
35
+ return scripts;
36
+ };
37
+
38
+ module.exports = getScripts;
@@ -0,0 +1,122 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const chokidar = require('chokidar');
4
+ const glob = require('glob');
5
+ const globParent = require('glob-parent');
6
+ require('colors');
7
+
8
+ /* CODE */
9
+
10
+ const args = process.argv.slice(2);
11
+ const options = {};
12
+
13
+ ['watch', 'clean', 'skip-initial-copy', 'safe', 'silent'].forEach(key => {
14
+ const index = args.indexOf(`--${key}`);
15
+ if (index >= 0) {
16
+ options[key] = true;
17
+ args.splice(index, 1);
18
+ }
19
+ });
20
+
21
+ if (args.length < 2) {
22
+ console.error('Not enough arguments: copy-and-watch [options] <sources> <target>'.red);
23
+ process.exit(1);
24
+ }
25
+
26
+ if (options['skip-initial-copy'] && !options['watch']) {
27
+ console.error('--skip-initial-copy argument is meant to be used with --watch, otherwise no files will be copied'.red);
28
+ process.exit(1);
29
+ }
30
+
31
+ const target = args.pop();
32
+ const sources = args;
33
+ const parents = [...new Set(sources.map(globParent))];
34
+
35
+ const findTarget = from => {
36
+ const parent = parents
37
+ .filter(p => from.indexOf(p) >= 0)
38
+ .sort()
39
+ .reverse()[0];
40
+ return path.join(target, path.relative(parent, from));
41
+ };
42
+ const createDirIfNotExist = to => {
43
+ 'use strict';
44
+
45
+ const dirs = [];
46
+ let dir = path.dirname(to);
47
+
48
+ while (dir !== path.dirname(dir)) {
49
+ dirs.unshift(dir);
50
+ dir = path.dirname(dir);
51
+ }
52
+
53
+ dirs.forEach(dir => {
54
+ if (!fs.existsSync(dir)) {
55
+ fs.mkdirSync(dir);
56
+ }
57
+ });
58
+ };
59
+ const copy = from => {
60
+ const to = findTarget(from);
61
+ createDirIfNotExist(to);
62
+ const stats = fs.statSync(from);
63
+ if (stats.isDirectory()) {
64
+ return;
65
+ }
66
+ fs.writeFileSync(to, fs.readFileSync(from));
67
+ options.silent || console.log('[COPY]'.yellow, from, 'to'.yellow, to);
68
+ };
69
+ const remove = from => {
70
+ const to = findTarget(from);
71
+ fs.unlinkSync(to);
72
+ options.silent || console.log('[DELETE]'.yellow, to);
73
+ };
74
+ const rimraf = dir => {
75
+ if (fs.existsSync(dir)) {
76
+ fs.readdirSync(dir).forEach(entry => {
77
+ const entryPath = path.join(dir, entry);
78
+ if (fs.lstatSync(entryPath).isDirectory()) {
79
+ rimraf(entryPath);
80
+ } else {
81
+ fs.unlinkSync(entryPath);
82
+ }
83
+ });
84
+ fs.rmdirSync(dir);
85
+ }
86
+ };
87
+
88
+ // clean
89
+ if (options.clean) {
90
+ rimraf(target);
91
+ }
92
+
93
+ // initial copy
94
+ if (!options['skip-initial-copy']) {
95
+ sources.forEach(s => glob.sync(s).forEach(copy));
96
+ }
97
+
98
+ // watch
99
+ if (options.watch) {
100
+ const chokidarOptions = {
101
+ ignoreInitial: true
102
+ };
103
+
104
+ if (options.safe) {
105
+ chokidarOptions.awaitWriteFinish = {
106
+ stabilityThreshold: 500,
107
+ pollInterval: 100
108
+ };
109
+ }
110
+
111
+ chokidar
112
+ .watch(sources, chokidarOptions)
113
+ .on('ready', () => sources.forEach(s => {
114
+ options.silent || console.log('[WATCH]'.yellow, s);
115
+ }))
116
+ .on('add', copy)
117
+ .on('addDir', copy)
118
+ .on('change', copy)
119
+ .on('unlink', remove)
120
+ .on('unlinkDir', remove)
121
+ .on('error', e => console.log('[ERROR]'.red, e));
122
+ }
@@ -0,0 +1,28 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const mkdirp = require("mkdirp");
4
+
5
+ const fileList = process.argv[2];
6
+ const dest = process.argv[3];
7
+ const src = "../../node_modules/@openui5/sap.ui.core/src/";
8
+
9
+ const filesToCopy = fs.readFileSync(fileList).toString();
10
+ // console.log(filesToCopy);
11
+
12
+ // Support full-line comments starting with # in the used-modules.txt file
13
+ const shouldCopy = file => file.length && !file.startsWith("#");
14
+
15
+ const trimFile = file => file.trim();
16
+
17
+ filesToCopy.split("\n").map(trimFile).filter(shouldCopy).forEach(async moduleName => {
18
+ const srcPath = path.join(src, moduleName);
19
+ const destPath = path.join(dest, moduleName);
20
+
21
+ await mkdirp(path.dirname(destPath));
22
+ fs.copyFile(srcPath, destPath, (err) => {
23
+ if (err) {
24
+ throw err;
25
+ }
26
+ console.log(`${destPath} created.`);
27
+ });
28
+ });