@ui5/webcomponents-tools 0.0.0-f2abb18c2 → 0.0.0-f42e7c18c

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