@ui5/webcomponents-tools 0.0.0-6cb3eb0db → 0.0.0-6ebf1b8af

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 (107) hide show
  1. package/CHANGELOG.md +859 -0
  2. package/README.md +6 -6
  3. package/assets-meta.js +17 -3
  4. package/bin/dev.js +1 -5
  5. package/components-package/eslint.js +36 -0
  6. package/components-package/nps.js +105 -71
  7. package/components-package/postcss.components.js +1 -21
  8. package/components-package/postcss.themes.js +1 -23
  9. package/components-package/vite.config.js +13 -0
  10. package/components-package/wdio.js +405 -353
  11. package/components-package/wdio.sync.js +26 -2
  12. package/icons-collection/nps.js +51 -18
  13. package/lib/amd-to-es6/index.js +104 -0
  14. package/lib/cem/custom-elements-manifest.config.mjs +479 -0
  15. package/lib/cem/event.mjs +131 -0
  16. package/lib/cem/schema-internal.json +1357 -0
  17. package/lib/cem/schema.json +1098 -0
  18. package/lib/cem/types-internal.d.ts +796 -0
  19. package/lib/cem/types.d.ts +736 -0
  20. package/lib/cem/utils.mjs +379 -0
  21. package/lib/cem/validate.js +70 -0
  22. package/lib/copy-and-watch/index.js +24 -1
  23. package/lib/copy-list/index.js +17 -17
  24. package/lib/create-icons/index.js +124 -58
  25. package/lib/create-illustrations/index.js +133 -63
  26. package/lib/create-new-component/index.js +71 -104
  27. package/lib/create-new-component/jsFileContentTemplate.js +73 -0
  28. package/lib/create-new-component/tsFileContentTemplate.js +71 -0
  29. package/lib/css-processors/css-processor-components.mjs +77 -0
  30. package/lib/css-processors/css-processor-themes.mjs +79 -0
  31. package/lib/css-processors/scope-variables.mjs +49 -0
  32. package/lib/css-processors/shared.mjs +76 -0
  33. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  34. package/lib/dev-server/dev-server.js +66 -0
  35. package/lib/dev-server/virtual-index-html-plugin.js +52 -0
  36. package/lib/generate-custom-elements-manifest/index.js +271 -0
  37. package/lib/generate-js-imports/illustrations.js +86 -0
  38. package/lib/generate-json-imports/i18n.js +43 -31
  39. package/lib/generate-json-imports/themes.js +36 -24
  40. package/lib/hbs2lit/src/compiler.js +24 -4
  41. package/lib/hbs2lit/src/includesReplacer.js +5 -5
  42. package/lib/hbs2lit/src/litVisitor2.js +95 -24
  43. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  44. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +32 -4
  45. package/lib/hbs2ui5/index.js +56 -23
  46. package/lib/i18n/defaults.js +65 -57
  47. package/lib/i18n/toJSON.js +12 -11
  48. package/lib/jsdoc/configTypescript.json +29 -0
  49. package/lib/jsdoc/plugin.js +41 -0
  50. package/lib/jsdoc/preprocess.js +146 -0
  51. package/lib/jsdoc/template/publish.js +21 -2
  52. package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
  53. package/lib/scoping/get-all-tags.js +2 -9
  54. package/lib/scoping/missing-dependencies.js +65 -0
  55. package/lib/scoping/report-tags-usage.js +28 -0
  56. package/lib/scoping/scope-test-pages.js +2 -1
  57. package/lib/test-runner/test-runner.js +71 -0
  58. package/package.json +34 -35
  59. package/bin/init-ui5-package.js +0 -3
  60. package/components-package/rollup.js +0 -216
  61. package/lib/documentation/index.js +0 -165
  62. package/lib/documentation/templates/api-component-since.js +0 -3
  63. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  64. package/lib/documentation/templates/api-events-section.js +0 -35
  65. package/lib/documentation/templates/api-methods-section.js +0 -26
  66. package/lib/documentation/templates/api-properties-section.js +0 -40
  67. package/lib/documentation/templates/api-slots-section.js +0 -28
  68. package/lib/documentation/templates/template.js +0 -38
  69. package/lib/esm-abs-to-rel/index.js +0 -54
  70. package/lib/hash/config.js +0 -10
  71. package/lib/hash/generate.js +0 -19
  72. package/lib/hash/upToDate.js +0 -31
  73. package/lib/init-package/index.js +0 -134
  74. package/lib/init-package/resources/.eslintignore +0 -3
  75. package/lib/init-package/resources/bundle.js +0 -31
  76. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  77. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  78. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  79. package/lib/init-package/resources/config/rollup.config.js +0 -1
  80. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  81. package/lib/init-package/resources/package-scripts.js +0 -11
  82. package/lib/init-package/resources/src/Assets.js +0 -5
  83. package/lib/init-package/resources/src/MyFirstComponent.hbs +0 -1
  84. package/lib/init-package/resources/src/MyFirstComponent.js +0 -56
  85. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  86. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  87. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  88. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  89. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  90. package/lib/init-package/resources/src/themes/MyFirstComponent.css +0 -11
  91. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  92. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  93. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  94. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  95. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  96. package/lib/init-package/resources/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  97. package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  98. package/lib/init-package/resources/test/pages/index.html +0 -54
  99. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
  100. package/lib/polyfill-placeholder/index.js +0 -5
  101. package/lib/postcss-css-to-esm/index.js +0 -45
  102. package/lib/postcss-css-to-json/index.js +0 -31
  103. package/lib/postcss-new-files/index.js +0 -36
  104. package/lib/replace-global-core/index.js +0 -20
  105. package/lib/serve/index.js +0 -46
  106. package/lib/serve/serve.json +0 -3
  107. package/package-lock.json +0 -48
@@ -0,0 +1,379 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ let documentationErrors = new Map();
5
+
6
+ const getDeprecatedStatus = (jsdocComment) => {
7
+ const deprecatedTag = findTag(jsdocComment, "deprecated");
8
+ return deprecatedTag?.name
9
+ ? deprecatedTag.description
10
+ ? `${deprecatedTag.name} ${deprecatedTag.description}`
11
+ : deprecatedTag.name
12
+ : deprecatedTag
13
+ ? true
14
+ : undefined;
15
+ };
16
+
17
+ const normalizeDescription = (description) => {
18
+ return typeof description === 'string' ? description.replaceAll(/^-\s+|^(\n)+|(\n)+$/g, ""): description;
19
+ }
20
+
21
+ const getTypeRefs = (ts, node, member) => {
22
+ const extractTypeRefs = (type) => {
23
+ if (type?.kind === ts.SyntaxKind.TypeReference) {
24
+ return type.typeArguments?.length
25
+ ? type.typeArguments.map((typeRef) => typeRef.typeName?.text)
26
+ : [type.typeName?.text];
27
+ } else if (type?.kind === ts.SyntaxKind.ArrayType) {
28
+ return [type.elementType?.typeName?.text];
29
+ } else if (type?.kind === ts.SyntaxKind.UnionType) {
30
+ return type.types
31
+ .map((type) => extractTypeRefs(type))
32
+ .flat(1);
33
+ } else if (type?.kind === ts.SyntaxKind.TemplateLiteralType) {
34
+ if (member?.type) {
35
+ member.type.text = member.type.text.replaceAll?.(/`|\${|}/g, "");
36
+ }
37
+
38
+ return type.templateSpans?.length
39
+ ? type.templateSpans.map((typeRef) => typeRef.type?.typeName?.text)
40
+ : [type.typeName?.text];
41
+ }
42
+ };
43
+
44
+ let typeRefs = extractTypeRefs(node.type) || node?.typeArguments?.map(n => extractTypeRefs(n)).flat(2);
45
+
46
+ if (typeRefs) {
47
+ typeRefs = typeRefs.filter((e) => !!e);
48
+ }
49
+
50
+ return typeRefs?.length ? typeRefs : undefined;
51
+ };
52
+
53
+ const getSinceStatus = (jsdocComment) => {
54
+ const sinceTag = findTag(jsdocComment, "since");
55
+ return sinceTag
56
+ ? sinceTag.description
57
+ ? `${sinceTag.name} ${sinceTag.description}`
58
+ : sinceTag.name
59
+ : undefined;
60
+ };
61
+
62
+ const getPrivacyStatus = (jsdocComment) => {
63
+ const privacyTag = findTag(jsdocComment, ["public", "private", "protected"]);
64
+ return privacyTag?.tag || "private";
65
+ };
66
+
67
+ const findPackageName = (ts, sourceFile, typeName) => {
68
+ const localStatements = [
69
+ ts.SyntaxKind.EnumDeclaration,
70
+ ts.SyntaxKind.InterfaceDeclaration,
71
+ ts.SyntaxKind.ClassDeclaration,
72
+ ts.SyntaxKind.TypeAliasDeclaration,
73
+ ];
74
+
75
+ const isLocalDeclared = sourceFile.statements.some(
76
+ (statement) =>
77
+ localStatements.includes(statement.kind) && statement?.name?.text === typeName
78
+ );
79
+
80
+ if (isLocalDeclared) {
81
+ return packageJSON?.name;
82
+ } else {
83
+ const importStatements = sourceFile.statements?.filter(
84
+ (statement) => statement.kind === ts.SyntaxKind.ImportDeclaration
85
+ );
86
+ const currentModuleSpecifier = importStatements.find((statement) => {
87
+ if (statement.importClause?.name?.text === typeName) {
88
+ return true;
89
+ }
90
+
91
+ return statement.importClause?.namedBindings?.elements?.some(
92
+ (element) => element.name?.text === typeName
93
+ );
94
+ })?.moduleSpecifier;
95
+
96
+ if (currentModuleSpecifier?.text?.startsWith(".")) {
97
+ return packageJSON?.name;
98
+ } else {
99
+ return Object.keys(packageJSON?.dependencies || {}).find(
100
+ (dependency) =>
101
+ currentModuleSpecifier?.text?.startsWith(`${dependency}/`)
102
+ );
103
+ }
104
+ }
105
+ };
106
+
107
+ const findImportPath = (ts, sourceFile, typeName, modulePath) => {
108
+ const localStatements = [
109
+ ts.SyntaxKind.EnumDeclaration,
110
+ ts.SyntaxKind.InterfaceDeclaration,
111
+ ts.SyntaxKind.ClassDeclaration,
112
+ ts.SyntaxKind.TypeAliasDeclaration,
113
+ ];
114
+
115
+ const isLocalDeclared = sourceFile.statements.some(
116
+ (statement) =>
117
+ localStatements.includes(statement.kind) && statement?.name?.text === typeName
118
+ );
119
+
120
+ if (isLocalDeclared) {
121
+ return (
122
+ modulePath?.replace("src", "dist")?.replace(".ts", ".js") || undefined
123
+ );
124
+ } else {
125
+ const importStatements = sourceFile.statements?.filter(
126
+ (statement) => statement.kind === ts.SyntaxKind.ImportDeclaration
127
+ );
128
+ const currentModuleSpecifier = importStatements.find((statement) => {
129
+ if (statement.importClause?.name?.text === typeName) {
130
+ return true;
131
+ }
132
+
133
+ return statement.importClause?.namedBindings?.elements?.some(
134
+ (element) => element.name?.text === typeName
135
+ );
136
+ })?.moduleSpecifier;
137
+
138
+ if (currentModuleSpecifier?.text?.startsWith(".")) {
139
+ return (
140
+ path.join(path.dirname(modulePath), currentModuleSpecifier.text)
141
+ ?.replace("src", "dist")?.replace(".ts", ".js") || undefined
142
+ );
143
+ } else {
144
+ const packageName = Object.keys(packageJSON?.dependencies || {}).find(
145
+ (dependency) =>
146
+ currentModuleSpecifier?.text?.startsWith(dependency)
147
+ );
148
+ return currentModuleSpecifier?.text
149
+ ?.replace(`${packageName}/`, "") || undefined;
150
+ }
151
+ }
152
+ };
153
+
154
+
155
+ const isClass = text => {
156
+ return text.includes("@abstract") || text.includes("@class") || text.includes("@constructor");
157
+ };
158
+
159
+ const normalizeTagType = (type) => {
160
+ return type?.trim();
161
+ }
162
+
163
+ const packageJSON = JSON.parse(fs.readFileSync("./package.json"));
164
+
165
+ const getReference = (ts, type, classNode, modulePath) => {
166
+ let sourceFile = classNode.parent;
167
+
168
+ while (sourceFile && sourceFile.kind !== ts.SyntaxKind.SourceFile) {
169
+ sourceFile = sourceFile.parent;
170
+ }
171
+
172
+ const typeName =
173
+ typeof type === "string"
174
+ ? normalizeTagType(type)
175
+ : type.class?.expression?.text ||
176
+ type.typeExpression?.type?.getText() ||
177
+ type.typeExpression?.type?.elementType?.typeName?.text;
178
+ const packageName = findPackageName(ts, sourceFile, typeName);
179
+ const importPath = findImportPath(
180
+ ts,
181
+ sourceFile,
182
+ typeName,
183
+ modulePath
184
+ )?.replace(`${packageName}/`, "");
185
+
186
+ return packageName && {
187
+ name: typeName,
188
+ package: packageName,
189
+ module: importPath,
190
+ };
191
+ };
192
+
193
+ const getType = (type) => {
194
+ const typeName = typeof type === "string" ? normalizeTagType(type) : type?.type;
195
+
196
+ const multiple =
197
+ typeName?.endsWith("[]") || typeName?.startsWith("Array<");
198
+ const name = multiple
199
+ ? typeName?.replace("[]", "")?.replace("Array<", "")?.replace(">", "")
200
+ : typeName;
201
+
202
+ return typeName ? { typeName: multiple ? `Array<${name}>` : typeName, name, multiple } : undefined;
203
+ };
204
+
205
+ const commonTags = ["public", "protected", "private", "since", "deprecated"];
206
+
207
+ const allowedTags = {
208
+ field: [...commonTags, "formEvents", "formProperty", "default"],
209
+ slot: [...commonTags, "default"],
210
+ event: [...commonTags, "param", "allowPreventDefault", "native"],
211
+ eventParam: [...commonTags],
212
+ method: [...commonTags, "param", "returns", "override"],
213
+ class: [...commonTags, "constructor", "class", "abstract", "implements", "extends", "slot", "csspart"],
214
+ enum: [...commonTags],
215
+ enumMember: [...commonTags],
216
+ interface: [...commonTags],
217
+ };
218
+ allowedTags.getter = [...allowedTags.field, "override"]
219
+
220
+ const tagMatchCallback = (tag, tagName) => {
221
+ const currentTagName = tag.tag;
222
+
223
+ return typeof tagName === "string"
224
+ ? currentTagName === tagName
225
+ : tagName.includes(currentTagName);
226
+ };
227
+
228
+ const findDecorator = (node, decoratorName) => {
229
+ return node?.decorators?.find(
230
+ (decorator) =>
231
+ decorator?.expression?.expression?.text === decoratorName
232
+ );
233
+ };
234
+
235
+ const findAllDecorators = (node, decoratorName) => {
236
+ return (
237
+ node?.decorators?.filter(
238
+ (decorator) =>
239
+ decorator?.expression?.expression?.text === decoratorName
240
+ ) || []
241
+ );
242
+ };
243
+
244
+ const hasTag = (jsDoc, tagName) => {
245
+ if (!jsDoc) {
246
+ return;
247
+ }
248
+
249
+ return jsDoc?.tags?.some((tag) => tagMatchCallback(tag, tagName));
250
+ };
251
+
252
+ const findTag = (jsDoc, tagName) => {
253
+ if (!jsDoc) {
254
+ return;
255
+ }
256
+
257
+ return jsDoc?.tags?.find((tag) => tagMatchCallback(tag, tagName));
258
+ };
259
+
260
+ const findAllTags = (jsDoc, tagName) => {
261
+ if (!jsDoc) {
262
+ return [];
263
+ }
264
+
265
+ const foundTags = jsDoc?.tags?.filter((tag) => tagMatchCallback(tag, tagName));
266
+
267
+ return foundTags || [];
268
+ };
269
+
270
+ const validateJSDocTag = (tag) => {
271
+ const booleanTags = ["private", "protected", "public", "abstract", "allowPreventDefault", "native", "formProperty", "constructor", "override"];
272
+ let tagName = tag.tag;
273
+
274
+ if (booleanTags.includes(tag.tag)) {
275
+ tagName = "boolean";
276
+ }
277
+
278
+ switch (tagName) {
279
+ case "boolean":
280
+ return !tag.name && !tag.type && !tag.description;
281
+ case "deprecated":
282
+ return !tag.type;
283
+ case "extends":
284
+ return !tag.type && tag.name && !tag.description;
285
+ case "implements":
286
+ return tag.type && !tag.name && !tag.description;
287
+ case "slot":
288
+ return tag.type && tag.name && tag.description;
289
+ case "csspart":
290
+ return !tag.type && tag.name && tag.description;
291
+ case "since":
292
+ return !tag.type && tag.name;
293
+ case "returns":
294
+ return !tag.type && tag.name;
295
+ case "default":
296
+ return !tag.type && !tag.description;
297
+ case "class":
298
+ return !tag.type;
299
+ case "param":
300
+ return !tag.type && tag.name;
301
+ case "eventparam":
302
+ return tag.type && tag.name;
303
+ case "formEvents":
304
+ return !tag.type && tag.name;
305
+ default:
306
+ return false;
307
+ }
308
+ };
309
+
310
+ const validateJSDocComment = (fieldType, jsdocComment, node, moduleDoc) => {
311
+ return !!jsdocComment?.tags?.every((tag) => {
312
+ let isValid = false
313
+
314
+ if (fieldType === "event" && tag?.tag === "param") {
315
+ isValid = allowedTags[fieldType]?.includes(tag.tag) && validateJSDocTag({...tag, tag: "eventparam"});
316
+ } else {
317
+ isValid = allowedTags[fieldType]?.includes(tag.tag) && validateJSDocTag(tag);
318
+ }
319
+
320
+ if (!isValid) {
321
+ logDocumentationError(moduleDoc.path, `Incorrect use of @${tag.tag}. Ensure it is part of ${fieldType} JSDoc tags.`)
322
+ }
323
+
324
+ return !!isValid;
325
+ });
326
+ };
327
+
328
+ const logDocumentationError = (modulePath, message) => {
329
+ let moduleErrors = documentationErrors.get(modulePath);
330
+
331
+ if (!moduleErrors) {
332
+ documentationErrors.set(modulePath, []);
333
+ moduleErrors = documentationErrors.get(modulePath);
334
+ }
335
+
336
+ moduleErrors.push(message);
337
+ }
338
+
339
+ const displayDocumentationErrors = () => {
340
+ let errorsCount = 0;
341
+ [...documentationErrors.keys()].forEach(modulePath => {
342
+ const moduleErrors = documentationErrors.get(modulePath);
343
+
344
+ console.log(`=== ERROR: ${moduleErrors.length > 1 ? `${moduleErrors.length} problems` : "Problem"} found in file: ${modulePath}:`)
345
+ moduleErrors.forEach(moduleError => {
346
+ errorsCount++;
347
+ console.log(`\t- ${moduleError}`)
348
+ })
349
+ })
350
+
351
+ if(errorsCount) {
352
+ throw new Error(`Found ${errorsCount} errors in the description of the public API.`);
353
+ }
354
+ }
355
+
356
+ const formatArrays = (typeText) => {
357
+ return typeText?.replaceAll(/(\S+)\[\]/g, "Array<$1>")
358
+ }
359
+
360
+ export {
361
+ getPrivacyStatus,
362
+ getSinceStatus,
363
+ getDeprecatedStatus,
364
+ getType,
365
+ getReference,
366
+ validateJSDocComment,
367
+ findDecorator,
368
+ findAllDecorators,
369
+ hasTag,
370
+ findTag,
371
+ findAllTags,
372
+ getTypeRefs,
373
+ normalizeDescription,
374
+ formatArrays,
375
+ isClass,
376
+ normalizeTagType,
377
+ displayDocumentationErrors,
378
+ logDocumentationError,
379
+ };
@@ -0,0 +1,70 @@
1
+ const fs = require('fs');
2
+ const Ajv = require('ajv');
3
+ const path = require('path');
4
+ const yargs = require('yargs/yargs')
5
+ const { hideBin } = require('yargs/helpers')
6
+ const argv = yargs(hideBin(process.argv))
7
+ .argv;
8
+
9
+ // Load your JSON schema
10
+ const extenalSchema = require('./schema.json');
11
+ const internalSchema = require('./schema-internal.json');
12
+
13
+ // Load your JSON data from the input file
14
+ const inputFilePath = path.join(process.cwd(), "dist/custom-elements.json"); // Update with your file path
15
+ const customManifest = fs.readFileSync(inputFilePath, 'utf8');
16
+ const inputDataInternal = JSON.parse(customManifest);
17
+
18
+ inputDataInternal.modules.forEach(moduleDoc => {
19
+ moduleDoc.exports = moduleDoc.exports.
20
+ filter(e => moduleDoc.declarations.find(d => d.name === e.declaration.name && ["class", "function", "variable", "enum"].includes(d.kind)) || e.name === "default");
21
+ })
22
+
23
+ const clearProps = (data) => {
24
+ if (Array.isArray(data)) {
25
+ for (let i = 0; i < data.length; i++) {
26
+ if (typeof data[i] === "object") {
27
+ if (["enum", "interface"].includes(data[i].kind)) {
28
+ data.splice(i, 1);
29
+ i--;
30
+ } else {
31
+ clearProps(data[i]);
32
+ }
33
+ }
34
+ }
35
+ } else if (typeof data === "object") {
36
+ Object.keys(data).forEach(prop => {
37
+ if (prop.startsWith("_ui5")) {
38
+ delete data[prop];
39
+ } else if (typeof data[prop] === "object") {
40
+ clearProps(data[prop]);
41
+ }
42
+ });
43
+ }
44
+
45
+ return data;
46
+ }
47
+
48
+ const ajv = new Ajv({ allowUnionTypes: true, allError: true })
49
+ let validate = ajv.compile(internalSchema)
50
+
51
+ // Validate the JSON data against the schema
52
+ if (argv.dev) {
53
+ if (validate(inputDataInternal)) {
54
+ console.log('Internal custom element manifest is validated successfully');
55
+ } else {
56
+ throw new Error(`Validation of internal custom elements manifest failed: ${validate.errors}`);
57
+ }
58
+ }
59
+
60
+ const inputDataExternal = clearProps(JSON.parse(JSON.stringify(inputDataInternal)));
61
+ validate = ajv.compile(extenalSchema)
62
+
63
+ // Validate the JSON data against the schema
64
+ if (validate(inputDataExternal)) {
65
+ console.log('Custom element manifest is validated successfully');
66
+ fs.writeFileSync(inputFilePath, JSON.stringify(inputDataExternal, null, 2), 'utf8');
67
+ fs.writeFileSync(inputFilePath.replace("custom-elements", "custom-elements-internal"), JSON.stringify(inputDataInternal, null, 2), 'utf8');
68
+ } else if (argv.dev) {
69
+ throw new Error(`Validation of public custom elements manifest failed: ${validate.errors}`);
70
+ }
@@ -1,9 +1,32 @@
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
 
@@ -1,28 +1,28 @@
1
- const fs = require("fs");
1
+ const fs = require("fs").promises;
2
2
  const path = require("path");
3
- const mkdirp = require("mkdirp");
4
3
 
5
4
  const fileList = process.argv[2];
6
5
  const dest = process.argv[3];
7
- const src = "../../node_modules/@openui5/sap.ui.core/src/";
6
+ const src = "@openui5/sap.ui.core/src/";
8
7
 
9
- const filesToCopy = fs.readFileSync(fileList).toString();
10
- // console.log(filesToCopy);
8
+ const generate = async () => {
9
+ const filesToCopy = (await fs.readFile(fileList)).toString();
10
+ // console.log(filesToCopy);
11
11
 
12
- // Support full-line comments starting with # in the used-modules.txt file
13
- const shouldCopy = file => file.length && !file.startsWith("#");
12
+ // Support full-line comments starting with # in the used-modules.txt file
13
+ const shouldCopy = file => file.length && !file.startsWith("#");
14
14
 
15
- const trimFile = file => file.trim();
15
+ const trimFile = file => file.trim();
16
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);
17
+ return filesToCopy.split("\n").map(trimFile).filter(shouldCopy).map(async moduleName => {
18
+ const srcPath = require.resolve(path.join(src, moduleName), {paths: [process.cwd()]});
19
+ const destPath = path.join(dest, moduleName);
20
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.`);
21
+ await fs.mkdir(path.dirname(destPath), { recursive: true });
22
+ return fs.copyFile(srcPath, destPath);
27
23
  });
24
+ };
25
+
26
+ generate().then(() => {
27
+ console.log("Files copied.");
28
28
  });