@ui5/webcomponents-tools 0.0.0-dff5837d7 → 0.0.0-e03cd01f3
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 +2415 -0
- package/LICENSE.txt +201 -0
- package/README.md +7 -10
- package/assets-meta.js +23 -5
- package/bin/dev.js +8 -6
- package/bin/ui5nps.js +274 -0
- package/components-package/eslint.js +66 -2
- package/components-package/nps.js +147 -49
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -23
- package/components-package/vite.config.js +9 -0
- package/components-package/wdio.js +118 -41
- package/icons-collection/nps.js +64 -12
- package/lib/amd-to-es6/index.js +107 -0
- package/lib/amd-to-es6/no-remaining-require.js +33 -0
- package/lib/cem/cem.js +12 -0
- package/lib/cem/custom-elements-manifest.config.mjs +550 -0
- package/lib/cem/event.mjs +168 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
- package/lib/cem/schema-internal.json +1422 -0
- package/lib/cem/schema.json +1098 -0
- package/lib/cem/types-internal.d.ts +808 -0
- package/lib/cem/types.d.ts +736 -0
- package/lib/cem/utils.mjs +423 -0
- package/lib/cem/validate.js +76 -0
- package/lib/chokidar/chokidar.js +28 -0
- package/lib/copy-and-watch/index.js +128 -95
- package/lib/copy-list/index.js +34 -0
- package/lib/create-icons/index.js +131 -54
- package/lib/create-illustrations/index.js +204 -0
- package/lib/create-new-component/Component.js +74 -0
- package/lib/create-new-component/ComponentTemplate.js +12 -0
- package/lib/create-new-component/index.js +66 -93
- package/lib/css-processors/css-processor-components.mjs +92 -0
- package/lib/css-processors/css-processor-themes.mjs +102 -0
- package/lib/css-processors/scope-variables.mjs +49 -0
- package/lib/css-processors/shared.mjs +46 -0
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/dev-server/dev-server.mjs +78 -0
- package/lib/dev-server/virtual-index-html-plugin.js +56 -0
- package/lib/eslint/eslint.js +44 -0
- package/lib/generate-js-imports/illustrations.js +85 -0
- package/lib/generate-json-imports/i18n.js +73 -38
- package/lib/generate-json-imports/themes.js +58 -20
- package/lib/hbs2lit/src/compiler.js +24 -4
- package/lib/hbs2lit/src/includesReplacer.js +5 -5
- package/lib/hbs2lit/src/litVisitor2.js +125 -26
- package/lib/hbs2lit/src/svgProcessor.js +12 -5
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +40 -7
- package/lib/hbs2ui5/index.js +68 -19
- package/lib/i18n/defaults.js +74 -60
- package/lib/i18n/toJSON.js +46 -19
- package/lib/icons-hash/icons-hash.mjs +149 -0
- package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
- package/lib/remove-dev-mode/remove-dev-mode.mjs +51 -0
- package/lib/rimraf/rimraf.js +31 -0
- package/lib/scoping/get-all-tags.js +44 -0
- package/lib/scoping/lint-src.js +32 -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 +41 -0
- package/lib/test-runner/test-runner.js +79 -0
- package/lib/vite-bundler/vite-bundler.mjs +35 -0
- package/package.json +62 -58
- package/tsconfig.json +18 -0
- package/bin/init-ui5-package.js +0 -3
- package/components-package/rollup.js +0 -134
- package/components-package/serve.json +0 -3
- package/lib/documentation/index.js +0 -143
- package/lib/documentation/templates/api-component-since.js +0 -3
- package/lib/documentation/templates/api-css-variables-section.js +0 -24
- package/lib/documentation/templates/api-events-section.js +0 -35
- package/lib/documentation/templates/api-methods-section.js +0 -26
- package/lib/documentation/templates/api-properties-section.js +0 -40
- package/lib/documentation/templates/api-slots-section.js +0 -28
- package/lib/documentation/templates/template.js +0 -38
- 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
- package/lib/jsdoc/config.json +0 -29
- package/lib/jsdoc/plugin.js +0 -2407
- package/lib/jsdoc/template/publish.js +0 -4092
- package/lib/postcss-css-to-esm/index.js +0 -42
- package/lib/postcss-css-to-json/index.js +0 -27
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
let documentationErrors = new Map();
|
|
5
|
+
|
|
6
|
+
const packageRegex = /^((@([a-z0-9._-]+)\/)?([a-z0-9._-]+))/;
|
|
7
|
+
|
|
8
|
+
const getDeprecatedStatus = (jsdocComment) => {
|
|
9
|
+
const deprecatedTag = findTag(jsdocComment, "deprecated");
|
|
10
|
+
return deprecatedTag?.name
|
|
11
|
+
? deprecatedTag.description
|
|
12
|
+
? `${deprecatedTag.name} ${deprecatedTag.description}`
|
|
13
|
+
: deprecatedTag.name
|
|
14
|
+
: deprecatedTag
|
|
15
|
+
? true
|
|
16
|
+
: undefined;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getExperimentalStatus = (jsdocComment) => {
|
|
20
|
+
const experimentalTag = findTag(jsdocComment, "experimental");
|
|
21
|
+
return experimentalTag?.name
|
|
22
|
+
? experimentalTag.description
|
|
23
|
+
? `${experimentalTag.name} ${experimentalTag.description}`
|
|
24
|
+
: experimentalTag.name
|
|
25
|
+
: experimentalTag
|
|
26
|
+
? true
|
|
27
|
+
: undefined;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const toKebabCase = str => {
|
|
31
|
+
return str.replaceAll(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase())
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const normalizeDescription = (description) => {
|
|
35
|
+
return typeof description === 'string' ? description.replaceAll(/^-\s+|^(\n)+|(\n)+$/g, "") : description;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const getTypeRefs = (ts, node, member) => {
|
|
39
|
+
const extractTypeRefs = (type) => {
|
|
40
|
+
if (type?.kind === ts.SyntaxKind.TypeReference) {
|
|
41
|
+
return type.typeArguments?.length
|
|
42
|
+
? type.typeArguments.map((typeRef) => typeRef.typeName?.text)
|
|
43
|
+
: [type.typeName?.text];
|
|
44
|
+
} else if (type?.kind === ts.SyntaxKind.ArrayType) {
|
|
45
|
+
return [type.elementType?.typeName?.text];
|
|
46
|
+
} else if (type?.kind === ts.SyntaxKind.UnionType) {
|
|
47
|
+
return type.types
|
|
48
|
+
.map((type) => extractTypeRefs(type))
|
|
49
|
+
.flat(1);
|
|
50
|
+
} else if (type?.kind === ts.SyntaxKind.TemplateLiteralType) {
|
|
51
|
+
if (member?.type) {
|
|
52
|
+
member.type.text = member.type.text.replaceAll?.(/`|\${|}/g, "");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return type.templateSpans?.length
|
|
56
|
+
? type.templateSpans.map((typeRef) => typeRef.type?.typeName?.text)
|
|
57
|
+
: [type.typeName?.text];
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
let typeRefs = extractTypeRefs(node.type) || node?.typeArguments?.map(n => extractTypeRefs(n)).flat(2);
|
|
62
|
+
|
|
63
|
+
if (typeRefs) {
|
|
64
|
+
typeRefs = typeRefs.filter((e) => !!e);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return typeRefs?.length ? typeRefs : undefined;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const getSinceStatus = (jsdocComment) => {
|
|
71
|
+
const sinceTag = findTag(jsdocComment, "since");
|
|
72
|
+
return sinceTag
|
|
73
|
+
? sinceTag.description
|
|
74
|
+
? `${sinceTag.name} ${sinceTag.description}`
|
|
75
|
+
: sinceTag.name
|
|
76
|
+
: undefined;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const getPrivacyStatus = (jsdocComment) => {
|
|
80
|
+
const privacyTag = findTag(jsdocComment, ["public", "private", "protected"]);
|
|
81
|
+
return privacyTag?.tag || "private";
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const findPackageName = (ts, sourceFile, typeName) => {
|
|
85
|
+
const localStatements = [
|
|
86
|
+
ts.SyntaxKind.EnumDeclaration,
|
|
87
|
+
ts.SyntaxKind.InterfaceDeclaration,
|
|
88
|
+
ts.SyntaxKind.ClassDeclaration,
|
|
89
|
+
ts.SyntaxKind.TypeAliasDeclaration,
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
const isLocalDeclared = sourceFile.statements.some(
|
|
93
|
+
(statement) =>
|
|
94
|
+
localStatements.includes(statement.kind) && statement?.name?.text === typeName
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
if (isLocalDeclared) {
|
|
98
|
+
return packageJSON?.name;
|
|
99
|
+
} else {
|
|
100
|
+
const importStatements = sourceFile.statements?.filter(
|
|
101
|
+
(statement) => statement.kind === ts.SyntaxKind.ImportDeclaration
|
|
102
|
+
);
|
|
103
|
+
const currentModuleSpecifier = importStatements.find((statement) => {
|
|
104
|
+
if (statement.importClause?.name?.text === typeName) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return statement.importClause?.namedBindings?.elements?.some(
|
|
109
|
+
(element) => element.name?.text === typeName
|
|
110
|
+
);
|
|
111
|
+
})?.moduleSpecifier;
|
|
112
|
+
|
|
113
|
+
if (currentModuleSpecifier?.text?.startsWith(".")) {
|
|
114
|
+
return packageJSON?.name;
|
|
115
|
+
} else {
|
|
116
|
+
// my-package/test
|
|
117
|
+
// my-package
|
|
118
|
+
// @scope/my-package
|
|
119
|
+
// my.package
|
|
120
|
+
// _mypackage
|
|
121
|
+
// mypackage-
|
|
122
|
+
// scope/my-package/test
|
|
123
|
+
// @scope/my-package/test
|
|
124
|
+
const match = currentModuleSpecifier?.text.match(packageRegex);
|
|
125
|
+
let packageName;
|
|
126
|
+
|
|
127
|
+
if (match) {
|
|
128
|
+
packageName = match[1];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return packageName || undefined;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const findImportPath = (ts, sourceFile, typeName, modulePath) => {
|
|
137
|
+
const localStatements = [
|
|
138
|
+
ts.SyntaxKind.EnumDeclaration,
|
|
139
|
+
ts.SyntaxKind.InterfaceDeclaration,
|
|
140
|
+
ts.SyntaxKind.ClassDeclaration,
|
|
141
|
+
ts.SyntaxKind.TypeAliasDeclaration,
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
const isLocalDeclared = sourceFile.statements.some(
|
|
145
|
+
(statement) =>
|
|
146
|
+
localStatements.includes(statement.kind) && statement?.name?.text === typeName
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
if (isLocalDeclared) {
|
|
150
|
+
return (
|
|
151
|
+
modulePath?.replace("src", "dist")?.replace(".ts", ".js") || undefined
|
|
152
|
+
);
|
|
153
|
+
} else {
|
|
154
|
+
const importStatements = sourceFile.statements?.filter(
|
|
155
|
+
(statement) => statement.kind === ts.SyntaxKind.ImportDeclaration
|
|
156
|
+
);
|
|
157
|
+
const currentModuleSpecifier = importStatements.find((statement) => {
|
|
158
|
+
if (statement.importClause?.name?.text === typeName) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return statement.importClause?.namedBindings?.elements?.some(
|
|
163
|
+
(element) => element.name?.text === typeName
|
|
164
|
+
);
|
|
165
|
+
})?.moduleSpecifier;
|
|
166
|
+
|
|
167
|
+
if (currentModuleSpecifier?.text?.startsWith(".")) {
|
|
168
|
+
return (
|
|
169
|
+
path.join(path.dirname(modulePath), currentModuleSpecifier.text)
|
|
170
|
+
?.replace("src", "dist")?.replace(".ts", ".js") || undefined
|
|
171
|
+
);
|
|
172
|
+
} else {
|
|
173
|
+
let packageName = currentModuleSpecifier?.text?.replace(packageRegex, "") || undefined;
|
|
174
|
+
|
|
175
|
+
if (packageName?.startsWith("/")) {
|
|
176
|
+
packageName = packageName.replace("/", "");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return packageName;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
const isClass = text => {
|
|
186
|
+
return text.includes("@abstract") || text.includes("@class") || text.includes("@constructor");
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const normalizeTagType = (type) => {
|
|
190
|
+
return type?.trim();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const packageJSON = JSON.parse(fs.readFileSync("./package.json"));
|
|
194
|
+
|
|
195
|
+
const getReference = (ts, type, classNode, modulePath) => {
|
|
196
|
+
let sourceFile = classNode.parent;
|
|
197
|
+
|
|
198
|
+
while (sourceFile && sourceFile.kind !== ts.SyntaxKind.SourceFile) {
|
|
199
|
+
sourceFile = sourceFile.parent;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const typeName =
|
|
203
|
+
typeof type === "string"
|
|
204
|
+
? normalizeTagType(type)
|
|
205
|
+
: type.class?.expression?.text ||
|
|
206
|
+
type.typeExpression?.type?.getText() ||
|
|
207
|
+
type.typeExpression?.type?.elementType?.typeName?.text;
|
|
208
|
+
const packageName = findPackageName(ts, sourceFile, typeName);
|
|
209
|
+
const importPath = findImportPath(
|
|
210
|
+
ts,
|
|
211
|
+
sourceFile,
|
|
212
|
+
typeName,
|
|
213
|
+
modulePath
|
|
214
|
+
)?.replace(`${packageName}/`, "");
|
|
215
|
+
|
|
216
|
+
return packageName && {
|
|
217
|
+
name: typeName,
|
|
218
|
+
package: packageName,
|
|
219
|
+
module: importPath,
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const getType = (type) => {
|
|
224
|
+
const typeName = typeof type === "string" ? normalizeTagType(type) : type?.type;
|
|
225
|
+
|
|
226
|
+
const multiple =
|
|
227
|
+
typeName?.endsWith("[]") || typeName?.startsWith("Array<");
|
|
228
|
+
const name = multiple
|
|
229
|
+
? typeName?.replace("[]", "")?.replace("Array<", "")?.replace(">", "")
|
|
230
|
+
: typeName;
|
|
231
|
+
|
|
232
|
+
return typeName ? { typeName: multiple ? `Array<${name}>` : typeName, name, multiple } : undefined;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const commonTags = ["public", "protected", "private", "since", "deprecated"];
|
|
236
|
+
|
|
237
|
+
const allowedTags = {
|
|
238
|
+
field: [...commonTags, "formEvents", "formProperty", "default"],
|
|
239
|
+
slot: [...commonTags, "default"],
|
|
240
|
+
event: [...commonTags, "param", "native", "allowPreventDefault"],
|
|
241
|
+
eventParam: [...commonTags],
|
|
242
|
+
method: [...commonTags, "param", "returns", "override"],
|
|
243
|
+
class: [...commonTags, "constructor", "class", "abstract", "experimental", "implements", "extends", "slot", "csspart"],
|
|
244
|
+
enum: [...commonTags, "experimental",],
|
|
245
|
+
enumMember: [...commonTags, "experimental",],
|
|
246
|
+
interface: [...commonTags, "experimental",],
|
|
247
|
+
};
|
|
248
|
+
allowedTags.getter = [...allowedTags.field, "override"]
|
|
249
|
+
|
|
250
|
+
const tagMatchCallback = (tag, tagName) => {
|
|
251
|
+
const currentTagName = tag.tag;
|
|
252
|
+
|
|
253
|
+
return typeof tagName === "string"
|
|
254
|
+
? currentTagName === tagName
|
|
255
|
+
: tagName.includes(currentTagName);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const findDecorator = (node, decoratorName) => {
|
|
259
|
+
return (node?.modifiers || node?.decorators)?.find(
|
|
260
|
+
(decorator) =>
|
|
261
|
+
decorator?.expression?.expression?.text === decoratorName
|
|
262
|
+
);
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const findAllDecorators = (node, decoratorName) => {
|
|
266
|
+
if (typeof decoratorName === "string") {
|
|
267
|
+
return (node?.modifiers || node?.decorators)?.filter(decorator => decorator?.expression?.expression?.text === decoratorName) || [];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (Array.isArray(decoratorName)) {
|
|
271
|
+
return (node?.modifiers || node?.decorators)?.filter(decorator => {
|
|
272
|
+
if (decorator?.expression?.expression?.text) {
|
|
273
|
+
return decoratorName.includes(decorator.expression.expression.text);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
) || [];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return [];
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const hasTag = (jsDoc, tagName) => {
|
|
285
|
+
if (!jsDoc) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return jsDoc?.tags?.some((tag) => tagMatchCallback(tag, tagName));
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const findTag = (jsDoc, tagName) => {
|
|
293
|
+
if (!jsDoc) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return jsDoc?.tags?.find((tag) => tagMatchCallback(tag, tagName));
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const findAllTags = (jsDoc, tagName) => {
|
|
301
|
+
if (!jsDoc) {
|
|
302
|
+
return [];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const foundTags = jsDoc?.tags?.filter((tag) => tagMatchCallback(tag, tagName));
|
|
306
|
+
|
|
307
|
+
return foundTags || [];
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const validateJSDocTag = (tag) => {
|
|
311
|
+
const booleanTags = ["private", "protected", "public", "abstract", "native", "allowPreventDefault", "formProperty", "constructor", "override"];
|
|
312
|
+
let tagName = tag.tag;
|
|
313
|
+
|
|
314
|
+
if (booleanTags.includes(tag.tag)) {
|
|
315
|
+
tagName = "boolean";
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
switch (tagName) {
|
|
319
|
+
case "boolean":
|
|
320
|
+
return !tag.name && !tag.type && !tag.description;
|
|
321
|
+
case "deprecated":
|
|
322
|
+
return !tag.type;
|
|
323
|
+
case "experimental":
|
|
324
|
+
return !tag.type;
|
|
325
|
+
case "extends":
|
|
326
|
+
return !tag.type && tag.name && !tag.description;
|
|
327
|
+
case "implements":
|
|
328
|
+
return tag.type && !tag.name && !tag.description;
|
|
329
|
+
case "slot":
|
|
330
|
+
return tag.type && tag.name && tag.description;
|
|
331
|
+
case "csspart":
|
|
332
|
+
return !tag.type && tag.name && tag.description;
|
|
333
|
+
case "since":
|
|
334
|
+
return !tag.type && tag.name;
|
|
335
|
+
case "returns":
|
|
336
|
+
return !tag.type && tag.name;
|
|
337
|
+
case "default":
|
|
338
|
+
return !tag.type && !tag.description;
|
|
339
|
+
case "class":
|
|
340
|
+
return !tag.type;
|
|
341
|
+
case "param":
|
|
342
|
+
return !tag.type && tag.name;
|
|
343
|
+
case "eventparam":
|
|
344
|
+
return tag.type && tag.name;
|
|
345
|
+
case "formEvents":
|
|
346
|
+
return !tag.type && tag.name;
|
|
347
|
+
default:
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const validateJSDocComment = (fieldType, jsdocComment, node, moduleDoc) => {
|
|
353
|
+
return !!jsdocComment?.tags?.every((tag) => {
|
|
354
|
+
let isValid = false
|
|
355
|
+
|
|
356
|
+
if (fieldType === "event" && tag?.tag === "param") {
|
|
357
|
+
isValid = allowedTags[fieldType]?.includes(tag.tag) && validateJSDocTag({ ...tag, tag: "eventparam" });
|
|
358
|
+
} else {
|
|
359
|
+
isValid = allowedTags[fieldType]?.includes(tag.tag) && validateJSDocTag(tag);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (!isValid) {
|
|
363
|
+
logDocumentationError(moduleDoc.path, `Incorrect use of @${tag.tag}. Ensure it is part of ${fieldType} JSDoc tags.`)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return !!isValid;
|
|
367
|
+
});
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
const logDocumentationError = (modulePath, message) => {
|
|
371
|
+
let moduleErrors = documentationErrors.get(modulePath);
|
|
372
|
+
|
|
373
|
+
if (!moduleErrors) {
|
|
374
|
+
documentationErrors.set(modulePath, []);
|
|
375
|
+
moduleErrors = documentationErrors.get(modulePath);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
moduleErrors.push(message);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const displayDocumentationErrors = () => {
|
|
382
|
+
let errorsCount = 0;
|
|
383
|
+
[...documentationErrors.keys()].forEach(modulePath => {
|
|
384
|
+
const moduleErrors = documentationErrors.get(modulePath);
|
|
385
|
+
|
|
386
|
+
console.log(`=== ERROR: ${moduleErrors.length > 1 ? `${moduleErrors.length} problems` : "Problem"} found in file: ${modulePath}:`)
|
|
387
|
+
moduleErrors.forEach(moduleError => {
|
|
388
|
+
errorsCount++;
|
|
389
|
+
console.log(`\t- ${moduleError}`)
|
|
390
|
+
})
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
if (errorsCount) {
|
|
394
|
+
throw new Error(`Found ${errorsCount} errors in the description of the public API.`);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const formatArrays = (typeText) => {
|
|
399
|
+
return typeText?.replaceAll(/(\S+)\[\]/g, "Array<$1>")
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export {
|
|
403
|
+
getPrivacyStatus,
|
|
404
|
+
getSinceStatus,
|
|
405
|
+
getDeprecatedStatus,
|
|
406
|
+
getExperimentalStatus,
|
|
407
|
+
getType,
|
|
408
|
+
getReference,
|
|
409
|
+
validateJSDocComment,
|
|
410
|
+
findDecorator,
|
|
411
|
+
findAllDecorators,
|
|
412
|
+
hasTag,
|
|
413
|
+
findTag,
|
|
414
|
+
findAllTags,
|
|
415
|
+
getTypeRefs,
|
|
416
|
+
normalizeDescription,
|
|
417
|
+
formatArrays,
|
|
418
|
+
isClass,
|
|
419
|
+
normalizeTagType,
|
|
420
|
+
displayDocumentationErrors,
|
|
421
|
+
logDocumentationError,
|
|
422
|
+
toKebabCase
|
|
423
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const Ajv = require('ajv');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
// Load your JSON schema
|
|
5
|
+
const extenalSchema = require('./schema.json');
|
|
6
|
+
const internalSchema = require('./schema-internal.json');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const validateFn = async () => {
|
|
10
|
+
// Load your JSON data from the input file
|
|
11
|
+
const inputFilePath = path.join(process.cwd(), "dist/custom-elements.json"); // Update with your file path
|
|
12
|
+
const customManifest = fs.readFileSync(inputFilePath, 'utf8');
|
|
13
|
+
const inputDataInternal = JSON.parse(customManifest);
|
|
14
|
+
const devMode = process.env.UI5_CEM_MODE === "dev";
|
|
15
|
+
|
|
16
|
+
inputDataInternal.modules.forEach(moduleDoc => {
|
|
17
|
+
moduleDoc.exports = moduleDoc.exports.
|
|
18
|
+
filter(e => moduleDoc.declarations.find(d => d.name === e.declaration.name && ["class", "function", "variable", "enum"].includes(d.kind)) || e.name === "default");
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const clearProps = (data) => {
|
|
22
|
+
if (Array.isArray(data)) {
|
|
23
|
+
for (let i = 0; i < data.length; i++) {
|
|
24
|
+
if (typeof data[i] === "object") {
|
|
25
|
+
if (["enum", "interface"].includes(data[i].kind)) {
|
|
26
|
+
data.splice(i, 1);
|
|
27
|
+
i--;
|
|
28
|
+
} else {
|
|
29
|
+
clearProps(data[i]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
} else if (typeof data === "object") {
|
|
34
|
+
Object.keys(data).forEach(prop => {
|
|
35
|
+
if (prop.startsWith("_ui5")) {
|
|
36
|
+
delete data[prop];
|
|
37
|
+
} else if (typeof data[prop] === "object") {
|
|
38
|
+
clearProps(data[prop]);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const ajv = new Ajv({ allowUnionTypes: true, allError: true })
|
|
47
|
+
let validate = ajv.compile(internalSchema)
|
|
48
|
+
|
|
49
|
+
// Validate the JSON data against the schema
|
|
50
|
+
if (devMode) {
|
|
51
|
+
if (validate(inputDataInternal)) {
|
|
52
|
+
console.log('Internal custom element manifest is validated successfully');
|
|
53
|
+
} else {
|
|
54
|
+
console.log(validate.errors)
|
|
55
|
+
throw new Error(`Validation of internal custom elements manifest failed: ${validate.errors}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const inputDataExternal = clearProps(JSON.parse(JSON.stringify(inputDataInternal)));
|
|
60
|
+
validate = ajv.compile(extenalSchema)
|
|
61
|
+
|
|
62
|
+
// Validate the JSON data against the schema
|
|
63
|
+
if (validate(inputDataExternal)) {
|
|
64
|
+
console.log('Custom element manifest is validated successfully');
|
|
65
|
+
fs.writeFileSync(inputFilePath, JSON.stringify(inputDataExternal, null, 2), 'utf8');
|
|
66
|
+
fs.writeFileSync(inputFilePath.replace("custom-elements", "custom-elements-internal"), JSON.stringify(inputDataInternal, null, 2), 'utf8');
|
|
67
|
+
} else if (devMode) {
|
|
68
|
+
throw new Error(`Validation of public custom elements manifest failed: ${validate.errors}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (require.main === module) {
|
|
73
|
+
validateFn()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
exports._ui5mainFn = validateFn;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const chokidar = require('chokidar');
|
|
2
|
+
const { exec } = require("child_process");
|
|
3
|
+
|
|
4
|
+
const main = async (argv) => {
|
|
5
|
+
if (argv.length < 4) {
|
|
6
|
+
console.error("Please provide a file pattern to watch and a command to execute on changes.");
|
|
7
|
+
console.error("<file-pattern> <command>");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const filePattern = argv[2];
|
|
12
|
+
const command = argv.slice(3).join(' ');
|
|
13
|
+
|
|
14
|
+
const watcher = new chokidar.FSWatcher();
|
|
15
|
+
|
|
16
|
+
watcher.add(filePattern);
|
|
17
|
+
watcher.unwatch("src/generated");
|
|
18
|
+
|
|
19
|
+
watcher.on('change', async () => {
|
|
20
|
+
exec(command);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
if (require.main === module) {
|
|
25
|
+
main(process.argv)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports._ui5mainFn = main;
|