@ui5/webcomponents-tools 0.0.0-dff5837d7 → 0.0.0-ec448881d
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 +208 -0
- package/README.md +1 -1
- package/assets-meta.js +18 -1
- package/bin/dev.js +10 -5
- package/components-package/nps.js +53 -26
- package/components-package/postcss.themes.js +6 -3
- package/components-package/rollup-plugins/empty-module.js +15 -0
- package/components-package/rollup.js +93 -77
- package/components-package/wdio.js +54 -29
- package/components-package/wdio.sync.js +360 -0
- package/icons-collection/nps.js +47 -9
- package/lib/copy-and-watch/index.js +30 -5
- package/lib/copy-list/index.js +28 -0
- package/lib/create-icons/index.js +82 -54
- package/lib/create-illustrations/index.js +161 -0
- package/lib/create-new-component/index.js +16 -4
- package/lib/documentation/index.js +124 -99
- package/lib/documentation/templates/api-properties-section.js +3 -1
- package/lib/documentation/templates/template.js +2 -1
- package/lib/esm-abs-to-rel/index.js +58 -0
- package/lib/generate-json-imports/i18n.js +74 -32
- package/lib/generate-json-imports/themes.js +64 -17
- package/lib/hbs2lit/src/compiler.js +12 -3
- package/lib/hbs2lit/src/includesReplacer.js +5 -5
- package/lib/hbs2lit/src/litVisitor2.js +43 -7
- package/lib/hbs2lit/src/svgProcessor.js +3 -3
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
- package/lib/hbs2ui5/index.js +50 -18
- package/lib/i18n/defaults.js +49 -57
- package/lib/i18n/toJSON.js +13 -12
- package/lib/jsdoc/config.json +1 -1
- package/lib/jsdoc/plugin.js +33 -4
- package/lib/jsdoc/template/publish.js +24 -4
- package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
- package/lib/postcss-css-to-esm/index.js +19 -16
- package/lib/postcss-css-to-json/index.js +20 -11
- package/lib/postcss-new-files/index.js +36 -0
- package/lib/postcss-p/postcss-p.mjs +11 -0
- package/lib/replace-global-core/index.js +25 -0
- package/lib/scoping/get-all-tags.js +44 -0
- package/lib/scoping/lint-src.js +31 -0
- package/lib/scoping/missing-dependencies.js +65 -0
- package/lib/scoping/report-tags-usage.js +28 -0
- package/lib/scoping/scope-test-pages.js +40 -0
- package/lib/serve/index.js +46 -0
- package/{components-package → lib/serve}/serve.json +0 -0
- package/package-lock.json +48 -0
- package/package.json +47 -53
- package/bin/init-ui5-package.js +0 -3
- package/lib/init-package/index.js +0 -112
- package/lib/init-package/resources/.eslintignore +0 -3
- package/lib/init-package/resources/bundle.es5.js +0 -25
- package/lib/init-package/resources/bundle.esm.js +0 -34
- 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/Demo.hbs +0 -1
- package/lib/init-package/resources/src/Demo.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/Demo.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/test/pages/index.html +0 -51
- package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
@@ -0,0 +1,360 @@
|
|
1
|
+
exports.config = {
|
2
|
+
//
|
3
|
+
// ====================
|
4
|
+
// Runner Configuration
|
5
|
+
// ====================
|
6
|
+
//
|
7
|
+
// WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
|
8
|
+
// on a remote machine).
|
9
|
+
runner: 'local',
|
10
|
+
|
11
|
+
//
|
12
|
+
// ==================
|
13
|
+
// Specify Test Files
|
14
|
+
// ==================
|
15
|
+
// Define which test specs should run. The pattern is relative to the directory
|
16
|
+
// from which `wdio` was called. Notice that, if you are calling `wdio` from an
|
17
|
+
// NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
|
18
|
+
// directory is where your package.json resides, so `wdio` will be called from there.
|
19
|
+
//
|
20
|
+
specs: [
|
21
|
+
'./test/specs/**/*.js'
|
22
|
+
],
|
23
|
+
// Patterns to exclude.
|
24
|
+
exclude: [
|
25
|
+
// 'path/to/excluded/files'
|
26
|
+
],
|
27
|
+
//
|
28
|
+
// ============
|
29
|
+
// Capabilities
|
30
|
+
// ============
|
31
|
+
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
|
32
|
+
// time. Depending on the number of capabilities, WebdriverIO launches several test
|
33
|
+
// sessions. Within your capabilities you can overwrite the spec and exclude options in
|
34
|
+
// order to group specific specs to a specific capability.
|
35
|
+
//
|
36
|
+
// First, you can define how many instances should be started at the same time. Let's
|
37
|
+
// say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
|
38
|
+
// set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
|
39
|
+
// files and you set maxInstances to 10, all spec files will get tested at the same time
|
40
|
+
// and 30 processes will get spawned. The property handles how many capabilities
|
41
|
+
// from the same test should run tests.
|
42
|
+
//
|
43
|
+
maxInstances: 10,
|
44
|
+
//
|
45
|
+
// If you have trouble getting all important capabilities together, check out the
|
46
|
+
// Sauce Labs platform configurator - a great tool to configure your capabilities:
|
47
|
+
// https://docs.saucelabs.com/reference/platforms-configurator
|
48
|
+
//
|
49
|
+
capabilities: [{
|
50
|
+
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
|
51
|
+
// grid with only 5 firefox instances available you can make sure that not more than
|
52
|
+
// 5 instances get started at a time.
|
53
|
+
maxInstances: process.env.TRAVIS ? 1 : 5,
|
54
|
+
//
|
55
|
+
browserName: 'chrome',
|
56
|
+
'goog:chromeOptions': {
|
57
|
+
// to run chrome headless the following flags are required
|
58
|
+
// (see https://developers.google.com/web/updates/2017/04/headless-chrome)
|
59
|
+
args: ['--headless', '--disable-gpu'],
|
60
|
+
// args: ['--disable-gpu'],
|
61
|
+
}
|
62
|
+
}],
|
63
|
+
//
|
64
|
+
// port to find chromedriver
|
65
|
+
port: 9515, // default
|
66
|
+
// ===================
|
67
|
+
// Test Configurations
|
68
|
+
// ===================
|
69
|
+
// Define all options that are relevant for the WebdriverIO instance here
|
70
|
+
//
|
71
|
+
// Level of logging verbosity: trace | debug | info | warn | error
|
72
|
+
logLevel: 'error',
|
73
|
+
//
|
74
|
+
// Warns when a deprecated command is used
|
75
|
+
deprecationWarnings: true,
|
76
|
+
//
|
77
|
+
// If you only want to run your tests until a specific amount of tests have failed use
|
78
|
+
// bail (default is 0 - don't bail, run all tests).
|
79
|
+
bail: 0,
|
80
|
+
//
|
81
|
+
// Set a base URL in order to shorten url command calls. If your `url` parameter starts
|
82
|
+
// with `/`, the base url gets prepended, not including the path portion of your baseUrl.
|
83
|
+
// If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
|
84
|
+
// gets prepended directly.
|
85
|
+
baseUrl: undefined, // This is important since WDIO 7+ does not accept an empty string for baseUrl
|
86
|
+
path: '',
|
87
|
+
//
|
88
|
+
// Default timeout for all waitFor* commands.
|
89
|
+
waitforTimeout: 10000,
|
90
|
+
//
|
91
|
+
// Default timeout in milliseconds for request
|
92
|
+
// if Selenium Grid doesn't send response
|
93
|
+
connectionRetryTimeout: 90000,
|
94
|
+
//
|
95
|
+
// Default request retries count
|
96
|
+
connectionRetryCount: 3,
|
97
|
+
//
|
98
|
+
// Test runner services
|
99
|
+
// Services take over a specific job you don't want to take care of. They enhance
|
100
|
+
// your test setup with almost no effort. Unlike plugins, they don't add new
|
101
|
+
// commands. Instead, they hook themselves up into the test process.
|
102
|
+
services: ['chromedriver'],
|
103
|
+
// options
|
104
|
+
chromeDriverArgs: ['--port=9515'], // default
|
105
|
+
// Framework you want to run your specs with.
|
106
|
+
// The following are supported: Mocha, Jasmine, and Cucumber
|
107
|
+
// see also: https://webdriver.io/docs/frameworks.html
|
108
|
+
//
|
109
|
+
// Make sure you have the wdio adapter package for the specific framework installed
|
110
|
+
// before running any tests.
|
111
|
+
framework: 'mocha',
|
112
|
+
//
|
113
|
+
// Test reporter for stdout.
|
114
|
+
// The only one supported by default is 'dot'
|
115
|
+
// see also: https://webdriver.io/docs/dot-reporter.html
|
116
|
+
reporters: ['dot', 'spec'],
|
117
|
+
|
118
|
+
//
|
119
|
+
// Options to be passed to Mocha.
|
120
|
+
// See the full list at http://mochajs.org/
|
121
|
+
mochaOpts: {
|
122
|
+
ui: 'bdd',
|
123
|
+
timeout: 60000
|
124
|
+
},
|
125
|
+
//
|
126
|
+
// =====
|
127
|
+
// Hooks
|
128
|
+
// =====
|
129
|
+
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
|
130
|
+
// it and to build services around it. You can either apply a single function or an array of
|
131
|
+
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
|
132
|
+
// resolved to continue.
|
133
|
+
/**
|
134
|
+
* Gets executed once before all workers get launched.
|
135
|
+
* @param {Object} config wdio configuration object
|
136
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
137
|
+
*/
|
138
|
+
// onPrepare: function (config, capabilities) {
|
139
|
+
// },
|
140
|
+
/**
|
141
|
+
* Gets executed just before initialising the webdriver session and test framework. It allows you
|
142
|
+
* to manipulate configurations depending on the capability or spec.
|
143
|
+
* @param {Object} config wdio configuration object
|
144
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
145
|
+
* @param {Array.<String>} specs List of spec file paths that are to be run
|
146
|
+
*/
|
147
|
+
// beforeSession: function (config, capabilities, specs) {
|
148
|
+
// },
|
149
|
+
/**
|
150
|
+
* Gets executed before test execution begins. At this point you can access to all global
|
151
|
+
* variables like `browser`. It is the perfect place to define custom commands.
|
152
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
153
|
+
* @param {Array.<String>} specs List of spec file paths that are to be run
|
154
|
+
*/
|
155
|
+
before: function (capabilities, specs) {
|
156
|
+
browser.addCommand("isFocusedDeep", function () {
|
157
|
+
return browser.execute(function (elem) {
|
158
|
+
let activeElement = document.activeElement;
|
159
|
+
|
160
|
+
while (activeElement.shadowRoot) {
|
161
|
+
if (activeElement.shadowRoot.activeElement) {
|
162
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
163
|
+
} else {
|
164
|
+
break;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
return elem === activeElement;
|
168
|
+
}, this);
|
169
|
+
}, true);
|
170
|
+
|
171
|
+
browser.addCommand("isFocusedDeepElement", function (element) {
|
172
|
+
return browser.execute(function (elem, element, done) {
|
173
|
+
let activeElement = document.activeElement;
|
174
|
+
|
175
|
+
while (activeElement.shadowRoot) {
|
176
|
+
if (activeElement.shadowRoot.activeElement) {
|
177
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
178
|
+
} else {
|
179
|
+
break;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
done(element === activeElement);
|
183
|
+
}, this, element);
|
184
|
+
}, true);
|
185
|
+
|
186
|
+
browser.addCommand("setProperty", function(property, value) {
|
187
|
+
return browser.execute((elem, property, value) => {
|
188
|
+
return elem[property] = value;
|
189
|
+
}, this, property, value);
|
190
|
+
}, true);
|
191
|
+
|
192
|
+
browser.addCommand("setAttribute", function(attribute, value) {
|
193
|
+
return browser.execute((elem, attribute, value) => {
|
194
|
+
return elem.setAttribute(attribute, value);
|
195
|
+
}, this, attribute, value);
|
196
|
+
}, true);
|
197
|
+
|
198
|
+
browser.addCommand("removeAttribute", function(attribute) {
|
199
|
+
return browser.execute((elem, attribute) => {
|
200
|
+
return elem.removeAttribute(attribute);
|
201
|
+
}, this, attribute);
|
202
|
+
}, true);
|
203
|
+
|
204
|
+
browser.addCommand("hasClass", function(className) {
|
205
|
+
return browser.execute((elem, className) => {
|
206
|
+
return elem.classList.contains(className);
|
207
|
+
}, this, className);
|
208
|
+
}, true);
|
209
|
+
|
210
|
+
browser.addCommand("getStaticAreaItemClassName", function(selector) {
|
211
|
+
return browser.execute(async (selector) => {
|
212
|
+
const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
|
213
|
+
return staticAreaItem.host.classList[0];
|
214
|
+
}, selector);
|
215
|
+
}, false);
|
216
|
+
},
|
217
|
+
/**
|
218
|
+
* Runs before a WebdriverIO command gets executed.
|
219
|
+
* @param {String} commandName hook command name
|
220
|
+
* @param {Array} args arguments that command would receive
|
221
|
+
*/
|
222
|
+
beforeCommand: function (commandName, args) {
|
223
|
+
const waitFor = [
|
224
|
+
"$",
|
225
|
+
"$$",
|
226
|
+
"getAttribute",
|
227
|
+
"getCSSProperty",
|
228
|
+
"getHTML",
|
229
|
+
"getProperty",
|
230
|
+
"getSize",
|
231
|
+
"getStaticAreaItemClassName", // custom
|
232
|
+
"getText",
|
233
|
+
"getValue",
|
234
|
+
"hasClass", // custom
|
235
|
+
"isDisplayed",
|
236
|
+
"isDisplayedInViewport",
|
237
|
+
"isEnabled",
|
238
|
+
"isExisting",
|
239
|
+
"isFocused",
|
240
|
+
"isFocusedDeep", // custom
|
241
|
+
"isFocusedDeepElement", // custom
|
242
|
+
"shadow$",
|
243
|
+
"shadow$$",
|
244
|
+
];
|
245
|
+
if (waitFor.includes(commandName)) {
|
246
|
+
browser.executeAsync(function (done) {
|
247
|
+
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
248
|
+
});
|
249
|
+
}
|
250
|
+
},
|
251
|
+
|
252
|
+
/**
|
253
|
+
* Hook that gets executed before the suite starts
|
254
|
+
* @param {Object} suite suite details
|
255
|
+
*/
|
256
|
+
// beforeSuite: function (suite) {
|
257
|
+
// },
|
258
|
+
/**
|
259
|
+
* Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
260
|
+
* @param {Object} test test details
|
261
|
+
*/
|
262
|
+
// beforeTest: function (test) {
|
263
|
+
// },
|
264
|
+
/**
|
265
|
+
* Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
|
266
|
+
* beforeEach in Mocha)
|
267
|
+
*/
|
268
|
+
// beforeHook: function () {
|
269
|
+
// },
|
270
|
+
/**
|
271
|
+
* Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
|
272
|
+
* afterEach in Mocha)
|
273
|
+
*/
|
274
|
+
// afterHook: function () {
|
275
|
+
// },
|
276
|
+
/**
|
277
|
+
* Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
278
|
+
* @param {Object} test test details
|
279
|
+
*/
|
280
|
+
// afterTest: function (test) {
|
281
|
+
// },
|
282
|
+
/**
|
283
|
+
* Hook that gets executed after the suite has ended
|
284
|
+
* @param {Object} suite suite details
|
285
|
+
*/
|
286
|
+
// afterSuite: function (suite) {
|
287
|
+
// },
|
288
|
+
|
289
|
+
/**
|
290
|
+
* Runs after a WebdriverIO command gets executed
|
291
|
+
* @param {String} commandName hook command name
|
292
|
+
* @param {Array} args arguments that command would receive
|
293
|
+
* @param {Number} result 0 - command success, 1 - command error
|
294
|
+
* @param {Object} error error object if any
|
295
|
+
*/
|
296
|
+
afterCommand: function (commandName, args, result, error) {
|
297
|
+
|
298
|
+
// url -> set configuration first
|
299
|
+
if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
|
300
|
+
browser.execute(function() {
|
301
|
+
window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
|
302
|
+
});
|
303
|
+
}
|
304
|
+
|
305
|
+
const waitFor = [
|
306
|
+
"addValue",
|
307
|
+
"clearValue",
|
308
|
+
"click",
|
309
|
+
"doubleClick",
|
310
|
+
"dragAndDrop",
|
311
|
+
"keys",
|
312
|
+
"pause",
|
313
|
+
"removeAttribute", // custom
|
314
|
+
"setAttribute", // custom
|
315
|
+
"setProperty", // custom
|
316
|
+
"setValue",
|
317
|
+
"setWindowSize",
|
318
|
+
"touchAction",
|
319
|
+
"url"
|
320
|
+
];
|
321
|
+
if (waitFor.includes(commandName)) {
|
322
|
+
browser.executeAsync(function (done) {
|
323
|
+
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
324
|
+
});
|
325
|
+
}
|
326
|
+
},
|
327
|
+
/**
|
328
|
+
* Gets executed after all tests are done. You still have access to all global variables from
|
329
|
+
* the test.
|
330
|
+
* @param {Number} result 0 - test pass, 1 - test fail
|
331
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
332
|
+
* @param {Array.<String>} specs List of spec file paths that ran
|
333
|
+
*/
|
334
|
+
// after: function (result, capabilities, specs) {
|
335
|
+
// },
|
336
|
+
/**
|
337
|
+
* Gets executed right after terminating the webdriver session.
|
338
|
+
* @param {Object} config wdio configuration object
|
339
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
340
|
+
* @param {Array.<String>} specs List of spec file paths that ran
|
341
|
+
*/
|
342
|
+
// afterSession: function (config, capabilities, specs) {
|
343
|
+
// },
|
344
|
+
/**
|
345
|
+
* Gets executed after all workers got shut down and the process is about to exit.
|
346
|
+
* @param {Object} exitCode 0 - success, 1 - fail
|
347
|
+
* @param {Object} config wdio configuration object
|
348
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
349
|
+
* @param {<Object>} results object containing test results
|
350
|
+
*/
|
351
|
+
// onComplete: function(exitCode, config, capabilities, results) {
|
352
|
+
// },
|
353
|
+
/**
|
354
|
+
* Gets executed when a refresh happens.
|
355
|
+
* @param {String} oldSessionId session ID of the old session
|
356
|
+
* @param {String} newSessionId session ID of the new session
|
357
|
+
*/
|
358
|
+
//onReload: function(oldSessionId, newSessionId) {
|
359
|
+
//}
|
360
|
+
}
|
package/icons-collection/nps.js
CHANGED
@@ -2,24 +2,62 @@ const path = require("path");
|
|
2
2
|
|
3
3
|
const LIB = path.join(__dirname, `../lib/`);
|
4
4
|
|
5
|
-
const
|
5
|
+
const createIconImportsCommand = (options) => {
|
6
|
+
if (!options.versions) {
|
7
|
+
return `node "${LIB}/create-icons/index.js" "${options.collectionName}"`;
|
8
|
+
}
|
9
|
+
|
10
|
+
const command = { default: "nps" };
|
11
|
+
options.versions.forEach((v) => {
|
12
|
+
command.default += ` build.icons.create${v}`;
|
13
|
+
command[`create${v}`] = `node "${LIB}/create-icons/index.js" "${options.collectionName}" "${v}"`;
|
14
|
+
});
|
15
|
+
|
16
|
+
return command;
|
17
|
+
}
|
18
|
+
|
19
|
+
const copyIconAssetsCommand = (options) => {
|
20
|
+
if (!options.versions) {
|
21
|
+
return {
|
22
|
+
default: "nps copy.json-imports copy.icon-collection",
|
23
|
+
"json-imports": `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
24
|
+
"icon-collection": `node "${LIB}/copy-and-watch/index.js" --silent "src/*.json" dist/generated/assets/`,
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
const command = {
|
29
|
+
default: "nps copy.json-imports ",
|
30
|
+
"json-imports": `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
31
|
+
};
|
32
|
+
|
33
|
+
options.versions.forEach((v) => {
|
34
|
+
command.default += ` copy.icon-collection${v}`;
|
35
|
+
command[`icon-collection${v}`] = `node "${LIB}/copy-and-watch/index.js" --silent "src/${v}/*.json" dist/generated/assets/${v}/`;
|
36
|
+
});
|
37
|
+
|
38
|
+
return command;
|
39
|
+
}
|
40
|
+
|
41
|
+
const getScripts = (options) => {
|
42
|
+
const createJSImportsCmd = createIconImportsCommand(options);
|
43
|
+
const copyAssetsCmd = copyIconAssetsCommand(options);
|
6
44
|
|
7
45
|
const scripts = {
|
8
46
|
clean: "rimraf dist",
|
9
|
-
copy:
|
10
|
-
default: "nps copy.json-imports copy.icon-collections",
|
11
|
-
"json-imports": `node "${LIB}/copy-and-watch/index.js" "src/**/*.js" dist/`,
|
12
|
-
"icon-collections": `node "${LIB}/copy-and-watch/index.js" "src/icon-collections/**/*.json" dist/generated/assets/icon-collections/`
|
13
|
-
},
|
47
|
+
copy: copyAssetsCmd,
|
14
48
|
build: {
|
15
|
-
default:
|
49
|
+
default: `nps clean copy build.i18n build.icons build.jsonImports`,
|
16
50
|
i18n: {
|
17
51
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
18
52
|
defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n dist/generated/i18n`,
|
19
53
|
json: `mkdirp dist/generated/assets/i18n && node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
|
20
54
|
},
|
21
|
-
|
22
|
-
|
55
|
+
jsonImports: {
|
56
|
+
default: "mkdirp dist/generated/json-imports && nps build.jsonImports.i18n",
|
57
|
+
i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
|
58
|
+
},
|
59
|
+
icons: createJSImportsCmd,
|
60
|
+
},
|
23
61
|
};
|
24
62
|
|
25
63
|
return scripts;
|
@@ -1,16 +1,39 @@
|
|
1
|
+
/*
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Copyright (c) 2017
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
23
|
+
*/
|
24
|
+
|
1
25
|
const fs = require('fs');
|
2
26
|
const path = require('path');
|
3
27
|
const chokidar = require('chokidar');
|
4
28
|
const glob = require('glob');
|
5
29
|
const globParent = require('glob-parent');
|
6
|
-
require('colors');
|
7
30
|
|
8
31
|
/* CODE */
|
9
32
|
|
10
33
|
const args = process.argv.slice(2);
|
11
34
|
const options = {};
|
12
35
|
|
13
|
-
['watch', 'clean', 'skip-initial-copy', 'safe'].forEach(key => {
|
36
|
+
['watch', 'clean', 'skip-initial-copy', 'safe', 'silent'].forEach(key => {
|
14
37
|
const index = args.indexOf(`--${key}`);
|
15
38
|
if (index >= 0) {
|
16
39
|
options[key] = true;
|
@@ -64,12 +87,12 @@ const copy = from => {
|
|
64
87
|
return;
|
65
88
|
}
|
66
89
|
fs.writeFileSync(to, fs.readFileSync(from));
|
67
|
-
console.log('[COPY]'.yellow, from, 'to'.yellow, to);
|
90
|
+
options.silent || console.log('[COPY]'.yellow, from, 'to'.yellow, to);
|
68
91
|
};
|
69
92
|
const remove = from => {
|
70
93
|
const to = findTarget(from);
|
71
94
|
fs.unlinkSync(to);
|
72
|
-
console.log('[DELETE]'.yellow, to);
|
95
|
+
options.silent || console.log('[DELETE]'.yellow, to);
|
73
96
|
};
|
74
97
|
const rimraf = dir => {
|
75
98
|
if (fs.existsSync(dir)) {
|
@@ -110,7 +133,9 @@ if (options.watch) {
|
|
110
133
|
|
111
134
|
chokidar
|
112
135
|
.watch(sources, chokidarOptions)
|
113
|
-
.on('ready', () => sources.forEach(s =>
|
136
|
+
.on('ready', () => sources.forEach(s => {
|
137
|
+
options.silent || console.log('[WATCH]'.yellow, s);
|
138
|
+
}))
|
114
139
|
.on('add', copy)
|
115
140
|
.on('addDir', copy)
|
116
141
|
.on('change', copy)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
const fs = require("fs").promises;
|
2
|
+
const path = require("path");
|
3
|
+
|
4
|
+
const fileList = process.argv[2];
|
5
|
+
const dest = process.argv[3];
|
6
|
+
const src = "../../node_modules/@openui5/sap.ui.core/src/";
|
7
|
+
|
8
|
+
const generate = async () => {
|
9
|
+
const filesToCopy = (await fs.readFile(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
|
+
return filesToCopy.split("\n").map(trimFile).filter(shouldCopy).map(async moduleName => {
|
18
|
+
const srcPath = path.join(src, moduleName);
|
19
|
+
const destPath = path.join(dest, moduleName);
|
20
|
+
|
21
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
22
|
+
return fs.copyFile(srcPath, destPath);
|
23
|
+
});
|
24
|
+
};
|
25
|
+
|
26
|
+
generate().then(() => {
|
27
|
+
console.log("Files copied.");
|
28
|
+
});
|
@@ -1,54 +1,82 @@
|
|
1
|
-
const fs = require("fs");
|
2
|
-
const path = require("path");
|
3
|
-
|
4
|
-
|
5
|
-
const
|
6
|
-
const
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
const
|
13
|
-
const
|
14
|
-
const
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
};
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
1
|
+
const fs = require("fs").promises;
|
2
|
+
const path = require("path");
|
3
|
+
|
4
|
+
const collectionName = process.argv[2] || "SAP-icons";
|
5
|
+
const collectionVersion = process.argv[3];
|
6
|
+
const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
|
7
|
+
const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
|
8
|
+
|
9
|
+
const iconTemplate = (name, pathData, ltr, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
10
|
+
|
11
|
+
const name = "${name}";
|
12
|
+
const pathData = "${pathData}";
|
13
|
+
const ltr = ${ltr};
|
14
|
+
const accData = null;
|
15
|
+
const collection = "${collection}";
|
16
|
+
const packageName = "${packageName}";
|
17
|
+
|
18
|
+
registerIcon(name, { pathData, ltr, collection, packageName });
|
19
|
+
|
20
|
+
export default "${name}";
|
21
|
+
export { pathData, ltr, accData };`;
|
22
|
+
|
23
|
+
|
24
|
+
const iconAccTemplate = (name, pathData, ltr, accData, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
25
|
+
import { ${accData.key} } from "../generated/i18n/i18n-defaults.js";
|
26
|
+
|
27
|
+
const name = "${name}";
|
28
|
+
const pathData = "${pathData}";
|
29
|
+
const ltr = ${ltr};
|
30
|
+
const accData = ${accData.key};
|
31
|
+
const collection = "${collection}";
|
32
|
+
const packageName = "${packageName}";
|
33
|
+
|
34
|
+
registerIcon(name, { pathData, ltr, accData, collection, packageName });
|
35
|
+
|
36
|
+
export default "${name}";
|
37
|
+
export { pathData, ltr, accData };`;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
const collectionTemplate = (name) => `import { isThemeFamily } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
42
|
+
import {pathData as pathDataV5, ltr, accData} from "./v5/${name}.js";
|
43
|
+
import {pathData as pathDataV4} from "./v4/${name}.js";
|
44
|
+
|
45
|
+
const pathData = isThemeFamily("sap_horizon") ? pathDataV5 : pathDataV4;
|
46
|
+
|
47
|
+
export default "${name}";
|
48
|
+
export { pathData, ltr, accData };`;
|
49
|
+
|
50
|
+
|
51
|
+
const svgTemplate = (pathData) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
52
|
+
<path d="${pathData}"/>
|
53
|
+
</svg>`;
|
54
|
+
|
55
|
+
const createIcons = async (file) => {
|
56
|
+
await fs.mkdir(destDir, { recursive: true });
|
57
|
+
|
58
|
+
const json = JSON.parse(await fs.readFile(file));
|
59
|
+
|
60
|
+
const promises = [];
|
61
|
+
for (let name in json.data) {
|
62
|
+
const iconData = json.data[name];
|
63
|
+
const pathData = iconData.path;
|
64
|
+
const ltr = !!iconData.ltr;
|
65
|
+
const acc = iconData.acc;
|
66
|
+
|
67
|
+
const content = acc ? iconAccTemplate(name, pathData, ltr, acc, json.collection, json.packageName) : iconTemplate(name, pathData, ltr, json.collection, json.packageName);
|
68
|
+
|
69
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.js`), content));
|
70
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.svg`), svgTemplate(pathData)));
|
71
|
+
|
72
|
+
if (json.version) {
|
73
|
+
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name)));
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
return Promise.all(promises);
|
78
|
+
};
|
79
|
+
|
80
|
+
createIcons(srcFile).then(() => {
|
81
|
+
console.log("Icons created.");
|
82
|
+
});
|