@ui5/webcomponents-tools 0.0.0-35e2c9666 → 0.0.0-38861c872
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 +715 -0
- package/README.md +6 -6
- package/assets-meta.js +16 -7
- package/bin/dev.js +1 -5
- package/components-package/eslint.js +36 -0
- package/components-package/nps.js +105 -69
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -26
- package/components-package/vite.config.js +13 -0
- package/components-package/wdio.js +405 -369
- package/components-package/wdio.sync.js +10 -2
- package/icons-collection/nps.js +13 -14
- package/lib/cem/custom-elements-manifest.config.mjs +463 -0
- package/lib/cem/event.mjs +114 -0
- package/lib/cem/schema-internal.json +1354 -0
- package/lib/cem/schema.json +1098 -0
- package/lib/cem/types-internal.d.ts +1032 -0
- package/lib/cem/types.d.ts +871 -0
- package/lib/cem/utils.mjs +355 -0
- package/lib/cem/validate.js +63 -0
- package/lib/copy-and-watch/index.js +24 -1
- package/lib/copy-list/index.js +17 -17
- package/lib/create-icons/index.js +124 -72
- package/lib/create-illustrations/index.js +128 -113
- package/lib/create-new-component/index.js +71 -104
- package/lib/create-new-component/jsFileContentTemplate.js +73 -0
- package/lib/create-new-component/tsFileContentTemplate.js +71 -0
- package/lib/css-processors/css-processor-components.mjs +77 -0
- package/lib/css-processors/css-processor-themes.mjs +79 -0
- package/lib/css-processors/scope-variables.mjs +46 -0
- package/lib/css-processors/shared.mjs +76 -0
- package/lib/dev-server/custom-hot-update-plugin.js +39 -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 +17 -10
- package/lib/generate-custom-elements-manifest/index.js +327 -0
- package/lib/generate-js-imports/illustrations.js +86 -0
- package/lib/generate-json-imports/i18n.js +43 -31
- package/lib/generate-json-imports/themes.js +36 -24
- package/lib/hbs2lit/src/compiler.js +24 -4
- package/lib/hbs2lit/src/includesReplacer.js +5 -5
- package/lib/hbs2lit/src/litVisitor2.js +85 -22
- package/lib/hbs2lit/src/svgProcessor.js +12 -5
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +32 -4
- package/lib/hbs2ui5/index.js +56 -23
- package/lib/i18n/defaults.js +65 -57
- package/lib/i18n/toJSON.js +12 -11
- package/lib/jsdoc/configTypescript.json +29 -0
- package/lib/jsdoc/plugin.js +32 -0
- package/lib/jsdoc/preprocess.js +146 -0
- package/lib/jsdoc/template/publish.js +9 -1
- package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
- package/lib/replace-global-core/index.js +13 -8
- package/lib/scoping/get-all-tags.js +2 -9
- package/lib/scoping/scope-test-pages.js +2 -1
- package/lib/test-runner/test-runner.js +71 -0
- package/package.json +28 -29
- package/components-package/rollup-plugins/empty-module.js +0 -15
- package/components-package/rollup.js +0 -239
- package/lib/documentation/index.js +0 -165
- 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 -42
- package/lib/documentation/templates/api-slots-section.js +0 -28
- package/lib/documentation/templates/template.js +0 -39
- package/lib/hash/config.js +0 -10
- package/lib/hash/generate.js +0 -19
- package/lib/hash/upToDate.js +0 -31
- package/lib/polyfill-placeholder/index.js +0 -5
- package/lib/postcss-css-to-esm/index.js +0 -45
- package/lib/postcss-css-to-json/index.js +0 -36
- package/lib/postcss-new-files/index.js +0 -36
- package/lib/postcss-p/postcss-p.mjs +0 -11
- package/lib/serve/index.js +0 -46
- package/lib/serve/serve.json +0 -3
- package/package-lock.json +0 -48
@@ -1,72 +1,124 @@
|
|
1
|
-
const fs = require("fs");
|
2
|
-
const path = require("path");
|
3
|
-
|
4
|
-
|
5
|
-
const
|
6
|
-
const
|
7
|
-
const
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
const
|
13
|
-
|
14
|
-
const
|
15
|
-
const
|
16
|
-
const
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
const
|
29
|
-
const
|
30
|
-
const
|
31
|
-
const
|
32
|
-
const
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
export
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
const collectionTemplate = (name) => `import {
|
42
|
-
import
|
43
|
-
import
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
const
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
createIcons(
|
1
|
+
const fs = require("fs").promises;
|
2
|
+
const path = require("path");
|
3
|
+
|
4
|
+
const collectionName = process.argv[2] || "SAP-icons-v4";
|
5
|
+
const collectionVersion = process.argv[3];
|
6
|
+
const srcFile = collectionVersion ? path.normalize(`src/${collectionVersion}/${collectionName}.json`) : path.normalize(`src/${collectionName}.json`);
|
7
|
+
const destDir = collectionVersion ? path.normalize(`dist/${collectionVersion}/`) : path.normalize("dist/");
|
8
|
+
|
9
|
+
const iconTemplate = (name, pathData, ltr, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
10
|
+
|
11
|
+
const name = "${name}";
|
12
|
+
const pathData = "${pathData}";
|
13
|
+
const ltr = ${ltr};
|
14
|
+
const accData = null;
|
15
|
+
const collection = "${collection}";
|
16
|
+
const packageName = "${packageName}";
|
17
|
+
|
18
|
+
registerIcon(name, { pathData, ltr, collection, packageName });
|
19
|
+
|
20
|
+
export default "${collection}/${name}";
|
21
|
+
export { pathData, ltr, accData };`;
|
22
|
+
|
23
|
+
|
24
|
+
const iconAccTemplate = (name, pathData, ltr, accData, collection, packageName) => `import { registerIcon } from "@ui5/webcomponents-base/dist/asset-registries/Icons.js";
|
25
|
+
import { ${accData.key} } from "../generated/i18n/i18n-defaults.js";
|
26
|
+
|
27
|
+
const name = "${name}";
|
28
|
+
const pathData = "${pathData}";
|
29
|
+
const ltr = ${ltr};
|
30
|
+
const accData = ${accData.key};
|
31
|
+
const collection = "${collection}";
|
32
|
+
const packageName = "${packageName}";
|
33
|
+
|
34
|
+
registerIcon(name, { pathData, ltr, accData, collection, packageName });
|
35
|
+
|
36
|
+
export default "${collection}/${name}";
|
37
|
+
export { pathData, ltr, accData };`;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
const collectionTemplate = (name, versions, fullName) => `import { isLegacyThemeFamily } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
42
|
+
import { pathData as pathData${versions[0]}, ltr, accData } from "./${versions[0]}/${name}.js";
|
43
|
+
import { pathData as pathData${versions[1]} } from "./${versions[1]}/${name}.js";
|
44
|
+
|
45
|
+
const pathData = isLegacyThemeFamily() ? pathData${versions[0]} : pathData${versions[1]};
|
46
|
+
|
47
|
+
export default "${fullName}";
|
48
|
+
export { pathData, ltr, accData };`;
|
49
|
+
|
50
|
+
|
51
|
+
const typeDefinitionTemplate = (name, accData, collection) => `declare const pathData: string;
|
52
|
+
declare const ltr: boolean;
|
53
|
+
declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
|
54
|
+
declare const _default: "${collection}/${name}";
|
55
|
+
|
56
|
+
export default _default;
|
57
|
+
export { pathData, ltr, accData };`
|
58
|
+
|
59
|
+
const collectionTypeDefinitionTemplate = (name, accData) => `declare const pathData: string;
|
60
|
+
declare const ltr: boolean;
|
61
|
+
declare const accData: ${accData ? '{ key: string; defaultText: string; }' : null}
|
62
|
+
declare const _default: "${name}";
|
63
|
+
|
64
|
+
export default _default;
|
65
|
+
export { pathData, ltr, accData };`
|
66
|
+
|
67
|
+
|
68
|
+
const svgTemplate = (pathData) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
69
|
+
<path d="${pathData}"/>
|
70
|
+
</svg>`;
|
71
|
+
|
72
|
+
const createIcons = async (file) => {
|
73
|
+
await fs.mkdir(destDir, { recursive: true });
|
74
|
+
|
75
|
+
const json = JSON.parse(await fs.readFile(file));
|
76
|
+
|
77
|
+
const promises = [];
|
78
|
+
for (let name in json.data) {
|
79
|
+
const iconData = json.data[name];
|
80
|
+
const pathData = iconData.path;
|
81
|
+
const ltr = !!iconData.ltr;
|
82
|
+
const acc = iconData.acc;
|
83
|
+
const packageName = json.packageName;
|
84
|
+
const collection = json.collection;
|
85
|
+
|
86
|
+
const content = acc ? iconAccTemplate(name, pathData, ltr, acc, collection, packageName) : iconTemplate(name, pathData, ltr, collection, packageName);
|
87
|
+
|
88
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.js`), content));
|
89
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.svg`), svgTemplate(pathData)));
|
90
|
+
promises.push(fs.writeFile(path.join(destDir, `${name}.d.ts`), typeDefinitionTemplate(name, acc, collection)));
|
91
|
+
|
92
|
+
// For versioned icons collections, the script creates top level (unversioned) module that internally imports the versioned ones.
|
93
|
+
// For example, the top level "@ui5/ui5-webcomponents-icons/dist/accept.js" imports:
|
94
|
+
// - "@ui5/ui5-webcomponents-icons/dist/v5/accept.js"
|
95
|
+
// - "@ui5/ui5-webcomponents-icons/dist/v4/accept.js"
|
96
|
+
|
97
|
+
if (json.version) {
|
98
|
+
// The exported value from the top level (unversioned) icon module depends on whether the collection is the default,
|
99
|
+
// to add or not the collection name to the exported value:
|
100
|
+
// For the default collection (SAPIcons) we export just the icon name - "export default { 'accept' }"
|
101
|
+
// For non-default collections (SAPTNTIcons and SAPBSIcons) we export the full name - "export default { 'tnt/actor' }"
|
102
|
+
const effectiveName = isDefaultCollection(collection) ? name : getUnversionedFullIconName(name, collection);
|
103
|
+
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.js`), collectionTemplate(name, json.versions, effectiveName)));
|
104
|
+
promises.push(fs.writeFile(path.join(path.normalize("dist/"), `${name}.d.ts`), collectionTypeDefinitionTemplate(effectiveName, acc)));
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
return Promise.all(promises);
|
109
|
+
};
|
110
|
+
|
111
|
+
const isDefaultCollection = collectionName => collectionName === "SAP-icons-v4" || collectionName === "SAP-icons-v5";
|
112
|
+
const getUnversionedFullIconName = (name, collection) => `${getUnversionedCollectionName(collection)}/${name}`;
|
113
|
+
const getUnversionedCollectionName = collectionName => CollectionVersionedToUnversionedMap[collectionName] || collectionName;
|
114
|
+
|
115
|
+
const CollectionVersionedToUnversionedMap = {
|
116
|
+
"tnt-v2": "tnt",
|
117
|
+
"tnt-v3": "tnt",
|
118
|
+
"business-suite-v1": "business-suite",
|
119
|
+
"business-suite-v2": "business-suite",
|
120
|
+
};
|
121
|
+
|
122
|
+
createIcons(srcFile).then(() => {
|
123
|
+
console.log("Icons created.");
|
124
|
+
});
|
@@ -1,150 +1,165 @@
|
|
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
|
if (process.argv.length < 7) {
|
6
|
-
|
5
|
+
throw new Error("Not enough arguments");
|
7
6
|
}
|
8
7
|
|
9
|
-
const
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
8
|
+
const generate = async () => {
|
9
|
+
|
10
|
+
const ORIGINAL_TEXTS = {
|
11
|
+
UnableToLoad: "UnableToLoad",
|
12
|
+
UnableToUpload: "UnableToUpload",
|
13
|
+
NoActivities: "NoActivities",
|
14
|
+
BeforeSearch: "BeforeSearch",
|
15
|
+
NoSearchResults: "NoSearchResults",
|
16
|
+
NoEntries: "NoEntries",
|
17
|
+
NoData: "NoData",
|
18
|
+
NoNotifications: "NoNotifications",
|
19
|
+
BalloonSky: "BalloonSky",
|
20
|
+
SuccessScreen: "SuccessScreen",
|
21
|
+
NoMail: "NoMail",
|
22
|
+
NoSavedItems: "NoSavedItems",
|
23
|
+
NoTasks: "NoTasks"
|
24
|
+
};
|
25
|
+
|
26
|
+
const FALLBACK_TEXTS = {
|
27
|
+
ReloadScreen: ORIGINAL_TEXTS.UnableToLoad,
|
28
|
+
Connection: ORIGINAL_TEXTS.UnableToLoad,
|
29
|
+
ErrorScreen: ORIGINAL_TEXTS.UnableToUpload,
|
30
|
+
EmptyCalendar: ORIGINAL_TEXTS.NoActivities,
|
31
|
+
SearchEarth: ORIGINAL_TEXTS.BeforeSearch,
|
32
|
+
SearchFolder: ORIGINAL_TEXTS.NoSearchResults,
|
33
|
+
EmptyList: ORIGINAL_TEXTS.NoEntries,
|
34
|
+
Tent: ORIGINAL_TEXTS.NoData,
|
35
|
+
SleepingBell: ORIGINAL_TEXTS.NoNotifications,
|
36
|
+
SimpleBalloon: ORIGINAL_TEXTS.BalloonSky,
|
37
|
+
SimpleBell: ORIGINAL_TEXTS.NoNotifications,
|
38
|
+
SimpleCalendar: ORIGINAL_TEXTS.NoActivities,
|
39
|
+
SimpleCheckMark: ORIGINAL_TEXTS.SuccessScreen,
|
40
|
+
SimpleConnection: ORIGINAL_TEXTS.UnableToLoad,
|
41
|
+
SimpleEmptyDoc: ORIGINAL_TEXTS.NoData,
|
42
|
+
SimpleEmptyList: ORIGINAL_TEXTS.NoEntries,
|
43
|
+
SimpleError: ORIGINAL_TEXTS.UnableToUpload,
|
44
|
+
SimpleMagnifier: ORIGINAL_TEXTS.BeforeSearch,
|
45
|
+
SimpleMail: ORIGINAL_TEXTS.NoMail,
|
46
|
+
SimpleNoSavedItems: ORIGINAL_TEXTS.NoSavedItems,
|
47
|
+
SimpleNotFoundMagnifier: ORIGINAL_TEXTS.NoSearchResults,
|
48
|
+
SimpleReload: ORIGINAL_TEXTS.UnableToLoad,
|
49
|
+
SimpleTask: ORIGINAL_TEXTS.NoTasks,
|
50
|
+
SuccessBalloon: ORIGINAL_TEXTS.BalloonSky,
|
51
|
+
SuccessCheckMark: ORIGINAL_TEXTS.SuccessScreen,
|
52
|
+
SuccessHighFive: ORIGINAL_TEXTS.BalloonSky
|
53
|
+
};
|
54
|
+
|
55
|
+
const srcPath = process.argv[2];
|
56
|
+
const defaultText = process.argv[3] === "true";
|
57
|
+
const illustrationsPrefix = process.argv[4];
|
58
|
+
const illustrationSet = process.argv[5];
|
59
|
+
const destPath = process.argv[6];
|
60
|
+
const collection = process.argv[7];
|
61
|
+
const fileNamePattern = new RegExp(`${illustrationsPrefix}-.+-(.+).svg`);
|
62
|
+
// collect each illustration name because each one should have Sample.js file
|
63
|
+
const fileNames = new Set();
|
64
|
+
|
65
|
+
try {
|
66
|
+
await fs.access(srcPath);
|
67
|
+
} catch (error) {
|
68
|
+
console.log(`The path ${srcPath} does not exist.`);
|
69
|
+
return Promise.resolve(null);
|
70
|
+
}
|
53
71
|
|
54
|
-
|
55
|
-
|
56
|
-
const
|
57
|
-
|
58
|
-
|
59
|
-
const
|
60
|
-
|
61
|
-
const
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
const
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
if (FALLBACK_TEXTS[illustrationNameForTranslation]) {
|
76
|
-
illustrationNameForTranslation = FALLBACK_TEXTS[illustrationNameForTranslation];
|
77
|
-
} else if (illustrationName.indexOf("_v") !== -1) {
|
78
|
-
illustrationNameForTranslation = illustrationNameForTranslation.substr(0, illustrationNameForTranslation.indexOf('_v'));
|
72
|
+
console.log(`Generating illustrations from ${srcPath} to ${destPath}`)
|
73
|
+
|
74
|
+
const svgImportTemplate = svgContent => {
|
75
|
+
return `export default \`${svgContent}\`;`
|
76
|
+
};
|
77
|
+
const svgToJs = async fileName => {
|
78
|
+
const svg = await fs.readFile(path.join(srcPath, fileName), { encoding: "utf-8" });
|
79
|
+
const fileContent = svgImportTemplate(svg);
|
80
|
+
fileName = fileName.replace(/\.svg$/, ".js");
|
81
|
+
|
82
|
+
return fs.writeFile(path.join(destPath, fileName), fileContent);
|
83
|
+
};
|
84
|
+
const illustrationImportTemplate = illustrationName => {
|
85
|
+
let illustrationNameForTranslation = illustrationName;
|
86
|
+
|
87
|
+
if (defaultText) {
|
88
|
+
if (FALLBACK_TEXTS[illustrationNameForTranslation]) {
|
89
|
+
illustrationNameForTranslation = FALLBACK_TEXTS[illustrationNameForTranslation];
|
90
|
+
} else if (illustrationName.indexOf("_v") !== -1) {
|
91
|
+
illustrationNameForTranslation = illustrationNameForTranslation.substr(0, illustrationNameForTranslation.indexOf('_v'));
|
92
|
+
}
|
79
93
|
}
|
80
|
-
}
|
81
94
|
|
82
|
-
|
83
|
-
|
84
|
-
|
95
|
+
const illustrationNameUpperCase = illustrationNameForTranslation.toUpperCase();
|
96
|
+
|
97
|
+
return `import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
|
85
98
|
import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
|
86
99
|
import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
|
87
|
-
import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js"
|
88
|
-
import {
|
100
|
+
import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";${
|
101
|
+
defaultText ? `import {
|
89
102
|
IM_TITLE_${illustrationNameUpperCase},
|
90
103
|
IM_SUBTITLE_${illustrationNameUpperCase},
|
91
|
-
} from "../generated/i18n/i18n-defaults.js"
|
104
|
+
} from "../generated/i18n/i18n-defaults.js";` : ``}
|
92
105
|
|
93
106
|
const name = "${illustrationName}";
|
94
107
|
const set = "${illustrationSet}";
|
108
|
+
const collection = "${collection}";${defaultText ? `
|
95
109
|
const title = IM_TITLE_${illustrationNameUpperCase};
|
96
|
-
const subtitle = IM_SUBTITLE_${illustrationNameUpperCase}
|
110
|
+
const subtitle = IM_SUBTITLE_${illustrationNameUpperCase};` : ``}
|
97
111
|
|
98
112
|
registerIllustration(name, {
|
99
113
|
dialogSvg,
|
100
114
|
sceneSvg,
|
101
|
-
spotSvg
|
115
|
+
spotSvg,${defaultText ? `
|
102
116
|
title,
|
103
|
-
subtitle
|
117
|
+
subtitle,` : ``}
|
104
118
|
set,
|
119
|
+
collection,
|
105
120
|
});
|
106
121
|
|
122
|
+
export default "${illustrationSet === "fiori" ? "" : `${illustrationSet}/`}${illustrationName}";
|
107
123
|
export {
|
108
124
|
dialogSvg,
|
109
125
|
sceneSvg,
|
110
126
|
spotSvg,
|
111
|
-
};`
|
112
|
-
|
113
|
-
import dialogSvg from "./${illustrationsPrefix}-Dialog-${illustrationName}.js";
|
114
|
-
import sceneSvg from "./${illustrationsPrefix}-Scene-${illustrationName}.js";
|
115
|
-
import spotSvg from "./${illustrationsPrefix}-Spot-${illustrationName}.js";
|
127
|
+
};`
|
128
|
+
};
|
116
129
|
|
117
|
-
const
|
118
|
-
const
|
130
|
+
const illustrationTypeDefinition = illustrationName => {
|
131
|
+
return `declare const dialogSvg: string;
|
132
|
+
declare const sceneSvg: string;
|
133
|
+
declare const spotSvg: string;
|
134
|
+
declare const _default: "${illustrationSet === "fiori" ? "" : `${illustrationSet}/`}${illustrationName}";
|
119
135
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
spotSvg,
|
124
|
-
set,
|
125
|
-
});
|
136
|
+
export default _default;
|
137
|
+
export { dialogSvg, sceneSvg, spotSvg };`
|
138
|
+
};
|
126
139
|
|
127
|
-
|
128
|
-
dialogSvg,
|
129
|
-
sceneSvg,
|
130
|
-
spotSvg,
|
131
|
-
};`
|
132
|
-
};
|
140
|
+
await fs.mkdir(destPath, { recursive: true });
|
133
141
|
|
134
|
-
|
142
|
+
const illustrationFileNames = await fs.readdir(path.normalize(srcPath));
|
135
143
|
|
136
|
-
|
144
|
+
// convert SVG to JS imports
|
145
|
+
const promises = [];
|
146
|
+
illustrationFileNames.forEach(illustration => {
|
147
|
+
if (fileNamePattern.test(illustration)) {
|
148
|
+
let [fileName, illustrationName] = illustration.match(fileNamePattern);
|
137
149
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
150
|
+
promises.push(svgToJs(fileName));
|
151
|
+
fileNames.add(illustrationName);
|
152
|
+
}
|
153
|
+
});
|
142
154
|
|
143
|
-
|
144
|
-
|
155
|
+
for (let illustrationName of fileNames) {
|
156
|
+
promises.push(fs.writeFile(path.join(destPath, `${illustrationName}.js`), illustrationImportTemplate(illustrationName)));
|
157
|
+
promises.push(fs.writeFile(path.join(destPath, `${illustrationName}.d.ts`), illustrationTypeDefinition(illustrationName)));
|
145
158
|
}
|
146
|
-
});
|
147
159
|
|
148
|
-
|
149
|
-
|
150
|
-
|
160
|
+
return Promise.all(promises);
|
161
|
+
};
|
162
|
+
|
163
|
+
generate().then(() => {
|
164
|
+
console.log("Illustrations generated.");
|
165
|
+
});
|