@ui5/webcomponents-tools 2.15.0-rc.2 → 2.15.0
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 +16 -0
- package/bin/ui5nps.js +41 -8
- package/components-package/nps.js +50 -33
- package/icons-collection/nps.js +17 -13
- package/lib/amd-to-es6/index.js +15 -10
- package/lib/cem/cem.js +12 -0
- package/lib/cem/validate.js +56 -47
- package/lib/copy-and-watch/index.js +105 -97
- package/lib/copy-list/index.js +16 -10
- package/lib/create-icons/index.js +19 -15
- package/lib/create-illustrations/index.js +28 -24
- package/lib/css-processors/css-processor-components.mjs +71 -61
- package/lib/css-processors/css-processor-themes.mjs +76 -66
- package/lib/generate-js-imports/illustrations.js +17 -14
- package/lib/generate-json-imports/i18n.js +13 -9
- package/lib/generate-json-imports/themes.js +15 -10
- package/lib/i18n/defaults.js +12 -7
- package/lib/i18n/toJSON.js +14 -10
- package/lib/remove-dev-mode/remove-dev-mode.mjs +34 -24
- package/lib/rimraf/rimraf.js +31 -0
- package/package.json +4 -5
|
@@ -30,116 +30,124 @@ const globParent = require('glob-parent');
|
|
|
30
30
|
|
|
31
31
|
/* CODE */
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const copyAndWatchFn = async (argv) => {
|
|
34
|
+
const args = argv.slice(2);
|
|
35
|
+
const options = {};
|
|
36
|
+
|
|
37
|
+
['watch', 'clean', 'skip-initial-copy', 'safe', 'silent'].forEach(key => {
|
|
38
|
+
const index = args.indexOf(`--${key}`);
|
|
39
|
+
if (index >= 0) {
|
|
40
|
+
options[key] = true;
|
|
41
|
+
args.splice(index, 1);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (args.length < 2) {
|
|
46
|
+
console.error('Not enough arguments: copy-and-watch [options] <sources> <target>');
|
|
47
|
+
process.exit(1);
|
|
41
48
|
}
|
|
42
|
-
});
|
|
43
49
|
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
50
|
+
if (options['skip-initial-copy'] && !options['watch']) {
|
|
51
|
+
console.error('--skip-initial-copy argument is meant to be used with --watch, otherwise no files will be copied');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
55
|
+
const target = args.pop();
|
|
56
|
+
const sources = args;
|
|
57
|
+
const parents = [...new Set(sources.map(globParent))];
|
|
53
58
|
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
'use strict';
|
|
67
|
-
|
|
68
|
-
const dirs = [];
|
|
69
|
-
let dir = path.dirname(to);
|
|
70
|
-
|
|
71
|
-
while (dir !== path.dirname(dir)) {
|
|
72
|
-
dirs.unshift(dir);
|
|
73
|
-
dir = path.dirname(dir);
|
|
74
|
-
}
|
|
59
|
+
const findTarget = from => {
|
|
60
|
+
const parent = parents
|
|
61
|
+
.filter(p => from.indexOf(p) >= 0)
|
|
62
|
+
.sort()
|
|
63
|
+
.reverse()[0];
|
|
64
|
+
return path.join(target, path.relative(parent, from));
|
|
65
|
+
};
|
|
66
|
+
const createDirIfNotExist = to => {
|
|
67
|
+
'use strict';
|
|
68
|
+
|
|
69
|
+
const dirs = [];
|
|
70
|
+
let dir = path.dirname(to);
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
while (dir !== path.dirname(dir)) {
|
|
73
|
+
dirs.unshift(dir);
|
|
74
|
+
dir = path.dirname(dir);
|
|
79
75
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
createDirIfNotExist(to);
|
|
85
|
-
const stats = fs.statSync(from);
|
|
86
|
-
if (stats.isDirectory()) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
fs.writeFileSync(to, fs.readFileSync(from));
|
|
90
|
-
options.silent || console.log('[COPY]'.yellow, from, 'to'.yellow, to);
|
|
91
|
-
};
|
|
92
|
-
const remove = from => {
|
|
93
|
-
const to = findTarget(from);
|
|
94
|
-
fs.unlinkSync(to);
|
|
95
|
-
options.silent || console.log('[DELETE]'.yellow, to);
|
|
96
|
-
};
|
|
97
|
-
const rimraf = dir => {
|
|
98
|
-
if (fs.existsSync(dir)) {
|
|
99
|
-
fs.readdirSync(dir).forEach(entry => {
|
|
100
|
-
const entryPath = path.join(dir, entry);
|
|
101
|
-
if (fs.lstatSync(entryPath).isDirectory()) {
|
|
102
|
-
rimraf(entryPath);
|
|
103
|
-
} else {
|
|
104
|
-
fs.unlinkSync(entryPath);
|
|
76
|
+
|
|
77
|
+
dirs.forEach(dir => {
|
|
78
|
+
if (!fs.existsSync(dir)) {
|
|
79
|
+
fs.mkdirSync(dir);
|
|
105
80
|
}
|
|
106
81
|
});
|
|
107
|
-
|
|
82
|
+
};
|
|
83
|
+
const copy = from => {
|
|
84
|
+
const to = findTarget(from);
|
|
85
|
+
createDirIfNotExist(to);
|
|
86
|
+
const stats = fs.statSync(from);
|
|
87
|
+
if (stats.isDirectory()) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
fs.writeFileSync(to, fs.readFileSync(from));
|
|
91
|
+
options.silent || console.log('[COPY]', from, 'to', to);
|
|
92
|
+
};
|
|
93
|
+
const remove = from => {
|
|
94
|
+
const to = findTarget(from);
|
|
95
|
+
fs.unlinkSync(to);
|
|
96
|
+
options.silent || console.log('[DELETE]', to);
|
|
97
|
+
};
|
|
98
|
+
const rimraf = dir => {
|
|
99
|
+
if (fs.existsSync(dir)) {
|
|
100
|
+
fs.readdirSync(dir).forEach(entry => {
|
|
101
|
+
const entryPath = path.join(dir, entry);
|
|
102
|
+
if (fs.lstatSync(entryPath).isDirectory()) {
|
|
103
|
+
rimraf(entryPath);
|
|
104
|
+
} else {
|
|
105
|
+
fs.unlinkSync(entryPath);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
fs.rmdirSync(dir);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// clean
|
|
113
|
+
if (options.clean) {
|
|
114
|
+
rimraf(target);
|
|
108
115
|
}
|
|
109
|
-
};
|
|
110
116
|
|
|
111
|
-
//
|
|
112
|
-
if (options
|
|
113
|
-
|
|
114
|
-
}
|
|
117
|
+
// initial copy
|
|
118
|
+
if (!options['skip-initial-copy']) {
|
|
119
|
+
sources.forEach(s => glob.sync(s).forEach(copy));
|
|
120
|
+
}
|
|
115
121
|
|
|
116
|
-
//
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
// watch
|
|
123
|
+
if (options.watch) {
|
|
124
|
+
const chokidarOptions = {
|
|
125
|
+
ignoreInitial: true
|
|
126
|
+
};
|
|
120
127
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
if (options.safe) {
|
|
129
|
+
chokidarOptions.awaitWriteFinish = {
|
|
130
|
+
stabilityThreshold: 500,
|
|
131
|
+
pollInterval: 100
|
|
132
|
+
};
|
|
133
|
+
}
|
|
126
134
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
135
|
+
chokidar
|
|
136
|
+
.watch(sources, chokidarOptions)
|
|
137
|
+
.on('ready', () => sources.forEach(s => {
|
|
138
|
+
options.silent || console.log('[WATCH]', s);
|
|
139
|
+
}))
|
|
140
|
+
.on('add', copy)
|
|
141
|
+
.on('addDir', copy)
|
|
142
|
+
.on('change', copy)
|
|
143
|
+
.on('unlink', remove)
|
|
144
|
+
.on('unlinkDir', remove)
|
|
145
|
+
.on('error', e => console.log('[ERROR]', e));
|
|
132
146
|
}
|
|
147
|
+
}
|
|
133
148
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.on('ready', () => sources.forEach(s => {
|
|
137
|
-
options.silent || console.log('[WATCH]'.yellow, s);
|
|
138
|
-
}))
|
|
139
|
-
.on('add', copy)
|
|
140
|
-
.on('addDir', copy)
|
|
141
|
-
.on('change', copy)
|
|
142
|
-
.on('unlink', remove)
|
|
143
|
-
.on('unlinkDir', remove)
|
|
144
|
-
.on('error', e => console.log('[ERROR]'.red, e));
|
|
149
|
+
if (require.main === module) {
|
|
150
|
+
copyAndWatchFn(process.argv)
|
|
145
151
|
}
|
|
152
|
+
|
|
153
|
+
exports._ui5mainFn = copyAndWatchFn;
|
package/lib/copy-list/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const fs = require("fs").promises;
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const generate = async () => {
|
|
4
|
+
const generate = async (argv) => {
|
|
5
|
+
const fileList = argv[2];
|
|
6
|
+
const dest = argv[3];
|
|
7
|
+
const src = "@openui5/sap.ui.core/src/";
|
|
9
8
|
const filesToCopy = (await fs.readFile(fileList)).toString();
|
|
10
9
|
// console.log(filesToCopy);
|
|
11
10
|
|
|
@@ -14,15 +13,22 @@ const generate = async () => {
|
|
|
14
13
|
|
|
15
14
|
const trimFile = file => file.trim();
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
const srcPath = require.resolve(path.join(src, moduleName), {paths: [process.cwd()]});
|
|
16
|
+
const promises = filesToCopy.split("\n").map(trimFile).filter(shouldCopy).map(async moduleName => {
|
|
17
|
+
const srcPath = require.resolve(path.join(src, moduleName), { paths: [process.cwd()] });
|
|
19
18
|
const destPath = path.join(dest, moduleName);
|
|
20
19
|
|
|
21
20
|
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
22
21
|
return fs.copyFile(srcPath, destPath);
|
|
23
22
|
});
|
|
23
|
+
|
|
24
|
+
return Promise.all(promises).then(() => {
|
|
25
|
+
console.log("Files copied.");
|
|
26
|
+
});
|
|
24
27
|
};
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
|
|
30
|
+
if (require.main === module) {
|
|
31
|
+
generate(process.argv)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports._ui5mainFn = generate;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
const fs = require("fs").promises;
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
-
const collectionName = process.argv[2] || "SAP-icons-v4";
|
|
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
4
|
const iconTemplate = (name, pathData, ltr, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
|
10
5
|
|
|
11
6
|
const name = "${name}";
|
|
@@ -71,10 +66,14 @@ const svgTemplate = (pathData) => `<svg xmlns="http://www.w3.org/2000/svg" viewB
|
|
|
71
66
|
<path d="${pathData}"/>
|
|
72
67
|
</svg>`;
|
|
73
68
|
|
|
74
|
-
const createIcons = async (
|
|
69
|
+
const createIcons = async (argv) => {
|
|
70
|
+
const collectionName = argv[2] || "SAP-icons-v4";
|
|
71
|
+
const collectionVersion = argv[3];
|
|
72
|
+
const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
|
|
73
|
+
const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
|
|
75
74
|
await fs.mkdir(destDir, { recursive: true });
|
|
76
75
|
|
|
77
|
-
const json = JSON.parse(await fs.readFile(
|
|
76
|
+
const json = JSON.parse(await fs.readFile(srcFile));
|
|
78
77
|
|
|
79
78
|
const promises = [];
|
|
80
79
|
for (let name in json.data) {
|
|
@@ -82,8 +81,8 @@ const createIcons = async (file) => {
|
|
|
82
81
|
const pathData = iconData.path;
|
|
83
82
|
const ltr = !!iconData.ltr;
|
|
84
83
|
const acc = iconData.acc;
|
|
85
|
-
const packageName =
|
|
86
|
-
const collection =
|
|
84
|
+
const packageName = json.packageName;
|
|
85
|
+
const collection = json.collection;
|
|
87
86
|
const versioned = json.version;
|
|
88
87
|
|
|
89
88
|
const content = acc ? iconAccTemplate(name, pathData, ltr, acc, collection, packageName, versioned) : iconTemplate(name, pathData, ltr, collection, packageName);
|
|
@@ -104,14 +103,17 @@ const createIcons = async (file) => {
|
|
|
104
103
|
// For non-default collections (SAPTNTIcons and SAPBSIcons) we export the full name - "export default { 'tnt/actor' }"
|
|
105
104
|
const effectiveName = isDefaultCollection(collection) ? name : getUnversionedFullIconName(name, collection);
|
|
106
105
|
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name, json.versions, effectiveName)));
|
|
107
|
-
|
|
106
|
+
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.d.ts`), collectionTypeDefinitionTemplate(effectiveName, acc)));
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
return Promise.all(promises)
|
|
110
|
+
return Promise.all(promises)
|
|
111
|
+
.then(() => {
|
|
112
|
+
console.log("Icons created.");
|
|
113
|
+
});
|
|
112
114
|
};
|
|
113
115
|
|
|
114
|
-
const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4"
|
|
116
|
+
const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4" || collectionName === "SAP-icons-v5";
|
|
115
117
|
const getUnversionedFullIconName = (name, collection) => `${getUnversionedCollectionName(collection)}/${name}`;
|
|
116
118
|
const getUnversionedCollectionName = collectionName => CollectionVersionedToUnversionedMap[collectionName] || collectionName;
|
|
117
119
|
|
|
@@ -122,6 +124,8 @@ const CollectionVersionedToUnversionedMap = {
|
|
|
122
124
|
"business-suite-v2": "business-suite",
|
|
123
125
|
};
|
|
124
126
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
127
|
+
if (require.main === module) {
|
|
128
|
+
createIcons(process.argv)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
exports._ui5mainFn = createIcons;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const fs = require("fs").promises;
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const generate = async () => {
|
|
4
|
+
const generate = async (argv) => {
|
|
5
|
+
if (argv.length < 7) {
|
|
6
|
+
throw new Error("Not enough arguments");
|
|
7
|
+
}
|
|
9
8
|
|
|
10
9
|
const ORIGINAL_TEXTS = {
|
|
11
10
|
UnableToLoad: "UnableToLoad",
|
|
@@ -70,12 +69,12 @@ const generate = async () => {
|
|
|
70
69
|
SuccessHighFive: ORIGINAL_TEXTS.BalloonSky
|
|
71
70
|
};
|
|
72
71
|
|
|
73
|
-
const srcPath =
|
|
74
|
-
const defaultText =
|
|
75
|
-
const illustrationsPrefix =
|
|
76
|
-
const illustrationSet =
|
|
77
|
-
const destPath =
|
|
78
|
-
const collection =
|
|
72
|
+
const srcPath = argv[2];
|
|
73
|
+
const defaultText = argv[3] === "true";
|
|
74
|
+
const illustrationsPrefix = argv[4];
|
|
75
|
+
const illustrationSet = argv[5];
|
|
76
|
+
const destPath = argv[6];
|
|
77
|
+
const collection = argv[7];
|
|
79
78
|
const fileNamePattern = new RegExp(`${illustrationsPrefix}-.+-(.+).svg`);
|
|
80
79
|
// collect each illustration name because each one should have Sample.js file
|
|
81
80
|
const fileNames = new Set();
|
|
@@ -126,8 +125,7 @@ const generate = async () => {
|
|
|
126
125
|
import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
|
|
127
126
|
import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
|
|
128
127
|
import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
|
|
129
|
-
import dotSvg from "./${illustrationsPrefix}-${hasDot}-${illustrationName}.js";${
|
|
130
|
-
defaultText ? `import {
|
|
128
|
+
import dotSvg from "./${illustrationsPrefix}-${hasDot}-${illustrationName}.js";${defaultText ? `import {
|
|
131
129
|
IM_TITLE_${illustrationNameUpperCase},
|
|
132
130
|
IM_SUBTITLE_${illustrationNameUpperCase},
|
|
133
131
|
} from "../generated/i18n/i18n-defaults.js";` : ``}
|
|
@@ -184,17 +182,23 @@ export { dialogSvg, sceneSvg, spotSvg, dotSvg };`
|
|
|
184
182
|
}
|
|
185
183
|
});
|
|
186
184
|
|
|
187
|
-
return Promise.all(promises)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
185
|
+
return Promise.all(promises)
|
|
186
|
+
.then(() => {
|
|
187
|
+
const nestedPromises = [];
|
|
188
|
+
for (let illustrationName of fileNames) {
|
|
189
|
+
nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.js`), illustrationImportTemplate(illustrationName)));
|
|
190
|
+
nestedPromises.push(fs.writeFile(path.join(destPath, `${illustrationName}.d.ts`), illustrationTypeDefinition(illustrationName)));
|
|
191
|
+
}
|
|
193
192
|
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
return Promise.all(nestedPromises);
|
|
194
|
+
})
|
|
195
|
+
.then(() => {
|
|
196
|
+
console.log("Illustrations generated.");
|
|
197
|
+
});
|
|
196
198
|
};
|
|
197
199
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
200
|
+
if (require.main === module) {
|
|
201
|
+
generate(process.argv)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
exports._ui5mainFn = generate;
|
|
@@ -7,72 +7,82 @@ import chokidar from "chokidar";
|
|
|
7
7
|
import scopeVariables from "./scope-variables.mjs";
|
|
8
8
|
import { writeFileIfChanged, getFileContent } from "./shared.mjs";
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const generate = async (argv) => {
|
|
11
|
+
const tsMode = process.env.UI5_TS === "true";
|
|
12
|
+
const extension = tsMode ? ".css.ts" : ".css.js";
|
|
12
13
|
|
|
13
|
-
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
|
14
|
-
const inputFilesGlob = "src/themes/*.css";
|
|
15
|
-
const restArgs =
|
|
14
|
+
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
|
15
|
+
const inputFilesGlob = "src/themes/*.css";
|
|
16
|
+
const restArgs = argv.slice(2);
|
|
16
17
|
|
|
17
|
-
let customPlugin = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
let customPlugin = {
|
|
19
|
+
name: 'ui5-tools',
|
|
20
|
+
setup(build) {
|
|
21
|
+
build.initialOptions.write = false;
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
build.onEnd(result => {
|
|
24
|
+
result.outputFiles.forEach(async f => {
|
|
25
|
+
// scoping
|
|
26
|
+
let newText = scopeVariables(f.text, packageJSON);
|
|
27
|
+
newText = newText.replaceAll(/\\/g, "\\\\"); // Escape backslashes as they might appear in css rules
|
|
28
|
+
await mkdir(path.dirname(f.path), { recursive: true });
|
|
29
|
+
writeFile(f.path, newText);
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
31
|
+
// JS/TS
|
|
32
|
+
const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
|
|
33
|
+
const jsContent = getFileContent(packageJSON.name, "\`" + newText + "\`", true);
|
|
34
|
+
writeFileIfChanged(jsPath, jsContent);
|
|
35
|
+
});
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
}
|
|
38
39
|
|
|
39
|
-
const getConfig = async () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
40
|
+
const getConfig = async () => {
|
|
41
|
+
const config = {
|
|
42
|
+
entryPoints: await globby(inputFilesGlob),
|
|
43
|
+
bundle: true,
|
|
44
|
+
minify: true,
|
|
45
|
+
outdir: 'dist/css',
|
|
46
|
+
outbase: 'src',
|
|
47
|
+
plugins: [
|
|
48
|
+
customPlugin,
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
return config;
|
|
52
|
+
}
|
|
52
53
|
|
|
53
|
-
if (restArgs.includes("-w")) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
if (restArgs.includes("-w")) {
|
|
55
|
+
let ready;
|
|
56
|
+
let config = await getConfig();
|
|
57
|
+
let ctx = await esbuild.context(config);
|
|
58
|
+
await ctx.watch()
|
|
59
|
+
console.log('watching...')
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} else {
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
// when new component css files are added, they do not trigger a build as no one directly imports them
|
|
62
|
+
// restart the watch mode with the new entry points if a css file is added.
|
|
63
|
+
const watcher = chokidar.watch(inputFilesGlob);
|
|
64
|
+
watcher.on("ready", () => {
|
|
65
|
+
ready = true; // Initial scan is over -> waiting for new files
|
|
66
|
+
});
|
|
67
|
+
watcher.on("add", async path => {
|
|
68
|
+
if (ready) {
|
|
69
|
+
// new file
|
|
70
|
+
ctx.dispose();
|
|
71
|
+
config = await getConfig();
|
|
72
|
+
ctx = await esbuild.context(config);
|
|
73
|
+
ctx.watch();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
const config = await getConfig();
|
|
78
|
+
const result = await esbuild.build(config);
|
|
79
|
+
}
|
|
78
80
|
}
|
|
81
|
+
|
|
82
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
83
|
+
generate(process.argv)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default {
|
|
87
|
+
_ui5mainFn: generate
|
|
88
|
+
}
|