@ui5/webcomponents-tools 1.24.0 → 2.0.0-rc.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 +263 -0
- package/components-package/nps.js +4 -11
- package/components-package/wdio.js +404 -405
- package/icons-collection/nps.js +2 -2
- package/lib/create-new-component/index.js +4 -11
- package/lib/generate-json-imports/i18n.js +3 -35
- package/lib/generate-json-imports/themes.js +2 -29
- package/lib/i18n/defaults.js +1 -1
- package/package.json +2 -3
- package/components-package/wdio.sync.js +0 -368
- package/lib/create-new-component/jsFileContentTemplate.js +0 -73
- package/lib/generate-custom-elements-manifest/index.js +0 -271
- package/lib/jsdoc/config.json +0 -29
- package/lib/jsdoc/configTypescript.json +0 -29
- package/lib/jsdoc/plugin.js +0 -2468
- package/lib/jsdoc/preprocess.js +0 -146
- package/lib/jsdoc/template/publish.js +0 -4120
package/lib/jsdoc/preprocess.js
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
const process = require("process");
|
2
|
-
const path = require("path");
|
3
|
-
const fs = require("fs/promises");
|
4
|
-
|
5
|
-
const inputDir = process.argv[2];
|
6
|
-
const sourceDir = process.argv[3];
|
7
|
-
|
8
|
-
const preprocessTypes = async () => {
|
9
|
-
try {
|
10
|
-
const { globby } = await import("globby");
|
11
|
-
const fileNames = await globby(inputDir.replace(/\\/g, "/") + "**/types/*.js");
|
12
|
-
|
13
|
-
return Promise.all(fileNames.map(processTypeFile));
|
14
|
-
} catch(e) {
|
15
|
-
console.log("JSDoc types preprocess failed: ", e);
|
16
|
-
}
|
17
|
-
};
|
18
|
-
|
19
|
-
const processTypeFile = async (fileName) => {
|
20
|
-
let fileContent = `${await fs.readFile(fileName)}`;
|
21
|
-
|
22
|
-
const re = new RegExp(`(\\/\\*\\*\\s*\\n([^\\*]|(\\*(?!\\/)))*\\*\\/)\\s+[\\w\\d]+\\[\\"([\\w\\d]+)\\"\\]\\s*=\\s*\\"([\\w\\d]+)\\";`, "gm")
|
23
|
-
let matches = [...fileContent.matchAll(re)];
|
24
|
-
|
25
|
-
// Get all type values
|
26
|
-
const typeData = matches.map(match => {
|
27
|
-
return {
|
28
|
-
comment: match[1],
|
29
|
-
key: match[4],
|
30
|
-
value: match[5],
|
31
|
-
};
|
32
|
-
});
|
33
|
-
if (typeData.length === 0) {
|
34
|
-
return;
|
35
|
-
}
|
36
|
-
|
37
|
-
const typeName = path.parse(fileName).name;
|
38
|
-
|
39
|
-
matches = fileContent.match(/\/\*\*\s*\n([^\*]|(\*(?!\/)))*\*\//gm);
|
40
|
-
const comment = matches[0];
|
41
|
-
|
42
|
-
const propsCode = typeData.map(item => {
|
43
|
-
return `${item.comment}\n get ${item.key}() { return "${item.value}"; }`;
|
44
|
-
}).join("\n");
|
45
|
-
|
46
|
-
const newClassCode = `
|
47
|
-
${comment}
|
48
|
-
class ${typeName} {
|
49
|
-
${propsCode}
|
50
|
-
};
|
51
|
-
|
52
|
-
export default ${typeName};`;
|
53
|
-
|
54
|
-
fileContent = newClassCode;
|
55
|
-
|
56
|
-
return fs.writeFile(fileName, fileContent);
|
57
|
-
};
|
58
|
-
|
59
|
-
const preprocessComponents = async () => {
|
60
|
-
if (!sourceDir) {
|
61
|
-
return; // if the second param was not passed, there are no components
|
62
|
-
}
|
63
|
-
|
64
|
-
try {
|
65
|
-
const { globby } = await import("globby");
|
66
|
-
const fileNames = await globby(sourceDir.replace(/\\/g, "/") + "/*.ts");
|
67
|
-
|
68
|
-
return Promise.all(fileNames.map(processComponentFile));
|
69
|
-
} catch(e) {
|
70
|
-
console.log("JSDoc components preprocess failed: ", e);
|
71
|
-
}
|
72
|
-
};
|
73
|
-
|
74
|
-
const isClass = text => {
|
75
|
-
return text.includes("@abstract") || text.includes("@class");
|
76
|
-
};
|
77
|
-
|
78
|
-
const isAnnotationComment = (comment) => {
|
79
|
-
return comment.includes("@name");
|
80
|
-
}
|
81
|
-
|
82
|
-
const processComponentFile = async (fileName) => {
|
83
|
-
// source file (src/*.ts)
|
84
|
-
let tsFileContent = `${await fs.readFile(fileName)}`;
|
85
|
-
|
86
|
-
// Skip all non-component files
|
87
|
-
if (!isClass(tsFileContent)) {
|
88
|
-
return;
|
89
|
-
}
|
90
|
-
|
91
|
-
// Gather all JSDocs from the original .ts file
|
92
|
-
const allJSDocsRegExp = new RegExp(`\\/\\*\\*(.|\\n)+?\\s+\\*\\/`, "gm");
|
93
|
-
let allJSDocs = [...tsFileContent.matchAll(allJSDocsRegExp)];
|
94
|
-
allJSDocs = allJSDocs.map(match => match[0]); // all /** ..... */ comments
|
95
|
-
|
96
|
-
// Find where the class is defined in the original file
|
97
|
-
const tsClassDefinitionRegExp = new RegExp(`^(abstract\\s)?class [\\w\\d_]+`, "gm");
|
98
|
-
let tsClassDefinitionMatch = tsFileContent.match(tsClassDefinitionRegExp);
|
99
|
-
if (!tsClassDefinitionMatch) {
|
100
|
-
return; // no class defined in this .ts file
|
101
|
-
}
|
102
|
-
const tsClassDefinition = tsClassDefinitionMatch[0];
|
103
|
-
const tsClassDefinitionIndex = tsFileContent.indexOf(tsClassDefinition);
|
104
|
-
|
105
|
-
// Gather all JSDocs that are before the class definition (except for the @class one)
|
106
|
-
const JSDocsToAppend = [];
|
107
|
-
allJSDocs.forEach(JSDoc => {
|
108
|
-
if (!isClass(JSDoc) && (tsFileContent.indexOf(JSDoc) < tsClassDefinitionIndex || isAnnotationComment(JSDoc, tsFileContent))) {
|
109
|
-
JSDocsToAppend.push(JSDoc);
|
110
|
-
}
|
111
|
-
});
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
// destination file (jsdoc-dist/*.js)
|
116
|
-
const destFileName = fileName.replace(sourceDir, inputDir).replace(/\.ts$/, ".js");
|
117
|
-
let jsFileContent = `${await fs.readFile(destFileName)}`;
|
118
|
-
|
119
|
-
const classDefinitionRegExp = new RegExp(`(let.*? = class)|(^class.*?)`, "gm");
|
120
|
-
let classDefinitionMatch = jsFileContent.match(classDefinitionRegExp);
|
121
|
-
if (!classDefinitionMatch) {
|
122
|
-
return; // not a file, generated by typescript, nothing to do here
|
123
|
-
}
|
124
|
-
|
125
|
-
const classDefinition = classDefinitionMatch[0];
|
126
|
-
const classDefinitionIndex = jsFileContent.indexOf(classDefinition); // classDefinitionIndex is the position in the file where the class is defined
|
127
|
-
|
128
|
-
// All comments before the class definition, except for the @class comment, must be removed
|
129
|
-
allJSDocs.forEach(JSDoc => {
|
130
|
-
if (!isClass(JSDoc) && jsFileContent.indexOf(JSDoc) < classDefinitionIndex) {
|
131
|
-
jsFileContent = jsFileContent.replace(JSDoc, "");
|
132
|
-
}
|
133
|
-
});
|
134
|
-
|
135
|
-
// Put all other comments at the end of the file
|
136
|
-
jsFileContent = jsFileContent + "\n\n" + JSDocsToAppend.join("\n\n");
|
137
|
-
return fs.writeFile(destFileName, jsFileContent);
|
138
|
-
};
|
139
|
-
|
140
|
-
Promise.all([
|
141
|
-
preprocessTypes(),
|
142
|
-
preprocessComponents(),
|
143
|
-
]).then(() => {
|
144
|
-
console.log("JSDoc preprocess ready.");
|
145
|
-
});
|
146
|
-
|