@ui5/webcomponents-tools 0.0.0-d0bcf47c7 → 0.0.0-d479b681b
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 +510 -1
- package/README.md +5 -6
- package/assets-meta.js +153 -0
- package/bin/dev.js +12 -1
- package/components-package/eslint.js +34 -0
- package/components-package/nps.js +112 -44
- package/components-package/postcss.components.js +13 -13
- package/components-package/postcss.themes.js +19 -16
- package/components-package/vite.config.js +13 -0
- package/components-package/wdio.js +393 -327
- package/components-package/wdio.sync.js +360 -0
- package/icons-collection/nps.js +69 -28
- package/lib/copy-and-watch/index.js +145 -0
- package/lib/copy-list/index.js +28 -0
- package/lib/create-icons/index.js +124 -0
- package/lib/create-illustrations/index.js +161 -0
- package/lib/create-new-component/index.js +128 -0
- package/lib/create-new-component/jsFileContentTemplate.js +77 -0
- package/lib/create-new-component/tsFileContentTemplate.js +84 -0
- package/lib/dev-server/dev-server.js +66 -0
- package/lib/dev-server/virtual-index-html-plugin.js +52 -0
- package/lib/esm-abs-to-rel/index.js +58 -0
- package/lib/generate-custom-elements-manifest/index.js +327 -0
- package/lib/generate-js-imports/illustrations.js +72 -0
- package/lib/generate-json-imports/i18n.js +98 -0
- package/lib/generate-json-imports/themes.js +80 -0
- package/lib/hbs2lit/index.js +3 -0
- package/lib/hbs2lit/src/compiler.js +57 -0
- package/lib/hbs2lit/src/extendedAttributeMapping.js +12 -0
- package/lib/hbs2lit/src/includesReplacer.js +31 -0
- package/lib/hbs2lit/src/litVisitor2.js +253 -0
- package/lib/hbs2lit/src/partials2.js +51 -0
- package/lib/hbs2lit/src/partialsVisitor.js +187 -0
- package/lib/hbs2lit/src/svgProcessor.js +69 -0
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +12 -0
- package/lib/hbs2ui5/index.js +102 -0
- package/lib/i18n/defaults.js +82 -0
- package/lib/i18n/toJSON.js +43 -0
- package/lib/jsdoc/config.json +29 -0
- package/lib/jsdoc/configTypescript.json +29 -0
- package/lib/jsdoc/plugin.js +2468 -0
- package/lib/jsdoc/preprocess.js +146 -0
- package/lib/jsdoc/template/publish.js +4120 -0
- package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
- package/lib/postcss-css-to-esm/index.js +90 -0
- package/lib/postcss-css-to-json/index.js +47 -0
- package/lib/postcss-new-files/index.js +36 -0
- package/lib/postcss-p/postcss-p.mjs +14 -0
- package/lib/replace-global-core/index.js +25 -0
- package/lib/scoping/get-all-tags.js +37 -0
- package/lib/scoping/lint-src.js +31 -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 +40 -0
- package/lib/test-runner/test-runner.js +71 -0
- package/package.json +55 -55
- package/bin/init-ui5-package.js +0 -3
- package/package-lock.json +0 -9994
@@ -0,0 +1,102 @@
|
|
1
|
+
const fs = require('fs').promises;
|
2
|
+
const getopts = require('getopts');
|
3
|
+
const hbs2lit = require('../hbs2lit');
|
4
|
+
const path = require('path');
|
5
|
+
const litRenderer = require('./RenderTemplates/LitRenderer');
|
6
|
+
const recursiveReadDir = require("recursive-readdir");
|
7
|
+
|
8
|
+
const args = getopts(process.argv.slice(2), {
|
9
|
+
alias: {
|
10
|
+
o: 'output',
|
11
|
+
d: 'directory',
|
12
|
+
f: 'file',
|
13
|
+
t: 'type'
|
14
|
+
},
|
15
|
+
default: {
|
16
|
+
t: 'lit-html'
|
17
|
+
}
|
18
|
+
});
|
19
|
+
|
20
|
+
const onError = (place) => {
|
21
|
+
console.log(`A problem occoured when reading ${place}. Please recheck passed parameters.`);
|
22
|
+
};
|
23
|
+
|
24
|
+
const isHandlebars = (fileName) => fileName.indexOf('.hbs') !== -1;
|
25
|
+
|
26
|
+
const processFile = async (file, outputDir) => {
|
27
|
+
const litCode = await hbs2lit(file);
|
28
|
+
const absoluteOutputDir = composeAbsoluteOutputDir(file, outputDir);
|
29
|
+
const componentNameMatcher = /(\w+)(\.hbs)/gim;
|
30
|
+
const componentName = componentNameMatcher.exec(file)[1];
|
31
|
+
|
32
|
+
return writeRenderers(absoluteOutputDir, componentName, litRenderer.generateTemplate(componentName, litCode));
|
33
|
+
};
|
34
|
+
|
35
|
+
const composeAbsoluteOutputDir = (file, outputDir) => {
|
36
|
+
// (1) Extract the dir structure from the source file path - "src/lvl1/lvl2/MyCompBadge.hbs"
|
37
|
+
// - remove the filename - "src/lvl1/lvl2"
|
38
|
+
// - remove the leading dir - "lvl1/lvl2"
|
39
|
+
const fileDir = file.split(path.sep).slice(1, -1).join(path.sep);
|
40
|
+
|
41
|
+
// (2) Compose full output dir - "dist/generated/templates/lvl1/lvl2"
|
42
|
+
return `${outputDir}${path.sep}${fileDir}`;
|
43
|
+
};
|
44
|
+
|
45
|
+
const wrapDirectory = (directory, outputDir) => {
|
46
|
+
directory = path.normalize(directory);
|
47
|
+
outputDir = path.normalize(outputDir);
|
48
|
+
|
49
|
+
return new Promise((resolve, reject) => {
|
50
|
+
recursiveReadDir(directory, (err, files) => {
|
51
|
+
|
52
|
+
if (err) {
|
53
|
+
onError('directory');
|
54
|
+
reject();
|
55
|
+
}
|
56
|
+
|
57
|
+
const promises = files.map(fileName => {
|
58
|
+
if (isHandlebars(fileName)) {
|
59
|
+
return processFile(fileName, outputDir);
|
60
|
+
}
|
61
|
+
}).filter(x => !!x);
|
62
|
+
|
63
|
+
resolve(Promise.all(promises));
|
64
|
+
});
|
65
|
+
});
|
66
|
+
};
|
67
|
+
|
68
|
+
const writeRenderers = async (outputDir, controlName, fileContent) => {
|
69
|
+
try {
|
70
|
+
|
71
|
+
await fs.mkdir(outputDir, { recursive: true });
|
72
|
+
|
73
|
+
const compiledFilePath = `${outputDir}${path.sep}${controlName}Template.lit.js`;
|
74
|
+
|
75
|
+
// strip DOS line endings because the break the source maps
|
76
|
+
let fileContentUnix = fileContent.replace(/\r\n/g, "\n");
|
77
|
+
fileContentUnix = fileContentUnix.replace(/\r/g, "\n");
|
78
|
+
|
79
|
+
// Only write to the file system actual changes - each updated file, no matter if the same or not, triggers an expensive operation for rollup
|
80
|
+
// Note: .hbs files that include a changed .hbs file will also be recompiled as their content will be updated too
|
81
|
+
|
82
|
+
let existingFileContent = "";
|
83
|
+
try {
|
84
|
+
existingFileContent = await fs.readFile(compiledFilePath);
|
85
|
+
} catch (e) {}
|
86
|
+
|
87
|
+
if (existingFileContent !== fileContentUnix) {
|
88
|
+
return fs.writeFile(compiledFilePath, fileContentUnix);
|
89
|
+
}
|
90
|
+
|
91
|
+
} catch (e) {
|
92
|
+
console.log(e);
|
93
|
+
}
|
94
|
+
};
|
95
|
+
|
96
|
+
if (!args['d'] || !args['o']) {
|
97
|
+
console.log('Please provide an input and output directory (-d and -o)');
|
98
|
+
} else {
|
99
|
+
wrapDirectory(args['d'], args['o']).then(() => {
|
100
|
+
console.log("Templates generated");
|
101
|
+
});
|
102
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
const fs = require('fs').promises;
|
2
|
+
const path = require('path');
|
3
|
+
const PropertiesReader = require('properties-reader');
|
4
|
+
const assets = require('../../assets-meta.js');
|
5
|
+
|
6
|
+
const generate = async () => {
|
7
|
+
const defaultLanguage = assets.languages.default;
|
8
|
+
|
9
|
+
const messageBundle = path.normalize(`${process.argv[2]}/messagebundle.properties`);
|
10
|
+
const messageBundleDefaultLanguage = path.normalize(`${process.argv[2]}/messagebundle_${defaultLanguage}.properties`);
|
11
|
+
const tsMode = process.env.UI5_TS === "true"; // In Typescript mode, we output .ts files and set the required types, otherwise - output pure .js files
|
12
|
+
|
13
|
+
const outputFile = path.normalize(`${process.argv[3]}/i18n-defaults.${tsMode ? "ts": "js"}`);
|
14
|
+
|
15
|
+
if (!messageBundle || !outputFile) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
|
19
|
+
const properties = PropertiesReader(messageBundle)._properties;
|
20
|
+
|
21
|
+
let defaultLanguageProperties;
|
22
|
+
try {
|
23
|
+
defaultLanguageProperties = PropertiesReader(messageBundleDefaultLanguage)._properties;
|
24
|
+
} catch (e) {
|
25
|
+
}
|
26
|
+
|
27
|
+
// Merge messagebundle.properties and messagebundle_en.properties files to generate the default texts.
|
28
|
+
// Note:
|
29
|
+
// (1) at DEV time, it's intuituve to work with the source bundle file - the messagebundle.properties,
|
30
|
+
// and see the changes there take effect.
|
31
|
+
// (2) as the messagebundle.properties file is always written in English,
|
32
|
+
// it makes sense to consider the messagebundle.properties content only when the default language is "en".
|
33
|
+
if (defaultLanguage === "en") {
|
34
|
+
defaultLanguageProperties = Object.assign({}, defaultLanguageProperties, properties);
|
35
|
+
}
|
36
|
+
|
37
|
+
/*
|
38
|
+
* Returns the single text object to enable single export.
|
39
|
+
*
|
40
|
+
* Example:
|
41
|
+
* const ARIA_LABEL_CARD_CONTENT = {
|
42
|
+
* key: "ARIA_LABEL_CARD_CONTENT",
|
43
|
+
* defaultText: "Card Content",
|
44
|
+
* };
|
45
|
+
*/
|
46
|
+
const getTextInfo = (key, value, defaultLanguageValue) => {
|
47
|
+
let effectiveValue = defaultLanguageValue || value;
|
48
|
+
effectiveValue = effectiveValue.replace(/\"/g, "\\\""); // escape double quotes in translations
|
49
|
+
|
50
|
+
if (tsMode) {
|
51
|
+
return `const ${key}: I18nText = {key: "${key}", defaultText: "${effectiveValue}"};`;
|
52
|
+
}
|
53
|
+
return `const ${key} = {key: "${key}", defaultText: "${effectiveValue}"};`;
|
54
|
+
};
|
55
|
+
|
56
|
+
/*
|
57
|
+
* Returns the complete content of i18n-defaults.js file:
|
58
|
+
* (1) the single text objects
|
59
|
+
* (2) the export statement at the end of the file
|
60
|
+
*
|
61
|
+
* Example:
|
62
|
+
* export {
|
63
|
+
* ARIA_LABEL_CARD_CONTENT,
|
64
|
+
* }
|
65
|
+
*/
|
66
|
+
const getOutputFileContent = (properties, defaultLanguageProperties) => {
|
67
|
+
const textKeys = Object.keys(properties);
|
68
|
+
const texts = textKeys.map(prop => getTextInfo(prop, properties[prop], defaultLanguageProperties && defaultLanguageProperties[prop])).join('');
|
69
|
+
|
70
|
+
// tabs are intentionally mixed to have proper identation in the produced file
|
71
|
+
return `${tsMode ? `import { I18nText } from "@ui5/webcomponents-base/dist/i18nBundle.js";` : ""}
|
72
|
+
${texts}
|
73
|
+
export {${textKeys.join()}};`;
|
74
|
+
};
|
75
|
+
|
76
|
+
await fs.mkdir(path.dirname(outputFile), { recursive: true });
|
77
|
+
await fs.writeFile(outputFile, getOutputFileContent(properties, defaultLanguageProperties));
|
78
|
+
};
|
79
|
+
|
80
|
+
generate().then(() => {
|
81
|
+
console.log("i18n default file generated.");
|
82
|
+
});
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/*
|
2
|
+
* The script converts all messebindle_*.properties files to messagebundle_*.json files.
|
3
|
+
*
|
4
|
+
* Execution (note: the paths depends on the the execution context)
|
5
|
+
* node toJSON.js ../../src/assets/i18n ../../dist/generated/assets/i18n
|
6
|
+
*
|
7
|
+
* The 1st param '../../src/assets/i18n' is the location of messagebundle_*.properties files
|
8
|
+
* The 2nd param './../dist/generated/assets/i18n' is where the JSON files would be written to.
|
9
|
+
*/
|
10
|
+
const path = require("path");
|
11
|
+
const PropertiesReader = require('properties-reader');
|
12
|
+
const fs = require('fs').promises;
|
13
|
+
const assets = require('../../assets-meta.js');
|
14
|
+
|
15
|
+
const allLanguages = assets.languages.all;
|
16
|
+
|
17
|
+
const messagesBundles = path.normalize(`${process.argv[2]}/messagebundle_*.properties`);
|
18
|
+
const messagesJSONDist = path.normalize(`${process.argv[3]}`);
|
19
|
+
|
20
|
+
const convertToJSON = async (file) => {
|
21
|
+
const properties = PropertiesReader(file)._properties;
|
22
|
+
const filename = path.basename(file, path.extname(file));
|
23
|
+
const language = filename.match(/^messagebundle_(.*?)$/)[1];
|
24
|
+
if (!allLanguages.includes(language)) {
|
25
|
+
console.log("Not supported language: ", language);
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
const outputFile = path.normalize(`${messagesJSONDist}/${filename}.json`);
|
29
|
+
|
30
|
+
return fs.writeFile(outputFile, JSON.stringify(properties));
|
31
|
+
// console.log(`[i18n]: "${filename}.json" has been generated!`);
|
32
|
+
};
|
33
|
+
|
34
|
+
const generate = async () => {
|
35
|
+
const { globby } = await import("globby");
|
36
|
+
await fs.mkdir(messagesJSONDist, { recursive: true });
|
37
|
+
const files = await globby(messagesBundles.replace(/\\/g, "/"));
|
38
|
+
return Promise.all(files.map(convertToJSON));
|
39
|
+
};
|
40
|
+
|
41
|
+
generate().then(() => {
|
42
|
+
console.log("Message bundle JSON files generated.");
|
43
|
+
});
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"source": {
|
3
|
+
"include": "src",
|
4
|
+
"excludePattern": "(/|\\\\)library-all\\.js|(/|\\\\).*-preload\\.js|^jquery-.*\\.js|^sap-.*\\.js|.+Renderer\\.lit\\.js|.*library\\.js|thirdparty"
|
5
|
+
},
|
6
|
+
"opts" : {
|
7
|
+
"recurse": true,
|
8
|
+
"template" : "template",
|
9
|
+
"destination": ""
|
10
|
+
},
|
11
|
+
"plugins": [
|
12
|
+
"./plugin.js"
|
13
|
+
],
|
14
|
+
"templates" : {
|
15
|
+
"ui5" : {
|
16
|
+
"variants": [
|
17
|
+
"apijson"
|
18
|
+
],
|
19
|
+
"version": "1.62",
|
20
|
+
"apiJsonFolder": "",
|
21
|
+
"apiJsonFile": "dist/api.json",
|
22
|
+
"includeSettingsInConstructor": false
|
23
|
+
}
|
24
|
+
},
|
25
|
+
"tags": {
|
26
|
+
"allowUnknownTags": true,
|
27
|
+
"dictionaries": ["jsdoc"]
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"source": {
|
3
|
+
"include": "jsdoc-dist",
|
4
|
+
"excludePattern": "(/|\\\\)library-all\\.js|(/|\\\\).*-preload\\.js|^jquery-.*\\.js|^sap-.*\\.js|.+Renderer\\.lit\\.js|.*library\\.js|thirdparty"
|
5
|
+
},
|
6
|
+
"opts" : {
|
7
|
+
"recurse": true,
|
8
|
+
"template" : "template",
|
9
|
+
"destination": ""
|
10
|
+
},
|
11
|
+
"plugins": [
|
12
|
+
"./plugin.js"
|
13
|
+
],
|
14
|
+
"templates" : {
|
15
|
+
"ui5" : {
|
16
|
+
"variants": [
|
17
|
+
"apijson"
|
18
|
+
],
|
19
|
+
"version": "1.62",
|
20
|
+
"apiJsonFolder": "",
|
21
|
+
"apiJsonFile": "dist/api.json",
|
22
|
+
"includeSettingsInConstructor": false
|
23
|
+
}
|
24
|
+
},
|
25
|
+
"tags": {
|
26
|
+
"allowUnknownTags": true,
|
27
|
+
"dictionaries": ["jsdoc"]
|
28
|
+
}
|
29
|
+
}
|