@atls-ui-generators/icons 0.0.16 → 1.0.1
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/dist/generator.js
CHANGED
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const standalone_1 = require("@babel/standalone");
|
|
7
|
-
const assert_1 = __importDefault(require("assert"));
|
|
8
7
|
const commander_1 = require("commander");
|
|
9
8
|
const fs_1 = require("fs");
|
|
10
9
|
const fs_2 = require("fs");
|
|
11
10
|
const fs_3 = require("fs");
|
|
12
11
|
const fs_4 = require("fs");
|
|
13
12
|
const path_1 = require("path");
|
|
13
|
+
const assert_1 = __importDefault(require("assert"));
|
|
14
14
|
const svgr_1 = require("./svgr");
|
|
15
15
|
const command = new commander_1.Command()
|
|
16
16
|
.name('Icons generator')
|
|
@@ -2,6 +2,4 @@ export interface GetColorReplacementOptions {
|
|
|
2
2
|
themePaths?: Array<string>;
|
|
3
3
|
color: string;
|
|
4
4
|
}
|
|
5
|
-
export declare const getColorReplacement: (options: GetColorReplacementOptions) =>
|
|
6
|
-
[x: string]: string;
|
|
7
|
-
};
|
|
5
|
+
export declare const getColorReplacement: (options: GetColorReplacementOptions) => Record<string, string>;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getColorReplacement = void 0;
|
|
4
4
|
const getColorReplacement = (options) => ({
|
|
5
|
-
[options.color]: `{(
|
|
5
|
+
[options.color]: `{(vars.colors${(options.themePaths || []).reduce((str, prop) => `${str}.${prop}`, '')}[props.color || 0] || props.color) || "${options.color}"}`,
|
|
6
6
|
});
|
|
7
7
|
exports.getColorReplacement = getColorReplacement;
|
package/dist/svgr.js
CHANGED
|
@@ -30,34 +30,32 @@ exports.build = void 0;
|
|
|
30
30
|
const prettierPlugin = __importStar(require("@atls/prettier-plugin"));
|
|
31
31
|
const config_prettier_1 = __importDefault(require("@atls/config-prettier"));
|
|
32
32
|
const core_1 = __importDefault(require("@svgr/core"));
|
|
33
|
+
const standalone_1 = require("prettier/standalone");
|
|
33
34
|
const camelcase_1 = __importDefault(require("camelcase"));
|
|
34
35
|
const fs_extra_promise_1 = __importDefault(require("fs-extra-promise"));
|
|
35
36
|
const glob_promise_1 = __importDefault(require("glob-promise"));
|
|
36
37
|
const path_1 = __importDefault(require("path"));
|
|
37
38
|
const parser_babel_1 = __importDefault(require("prettier/parser-babel"));
|
|
38
39
|
const parser_typescript_1 = __importDefault(require("prettier/parser-typescript"));
|
|
39
|
-
const standalone_1 = require("prettier/standalone");
|
|
40
40
|
const svgrTemplate = ({ template }, opts, { componentName, jsx }) => {
|
|
41
41
|
const typeScriptTpl = template.smart({ plugins: ['typescript', 'prettier'] });
|
|
42
42
|
return typeScriptTpl.ast `
|
|
43
43
|
import React from 'react'
|
|
44
|
-
import {
|
|
45
|
-
import { IconProps } from '../icons.interfaces'
|
|
44
|
+
import { vars } from '@ui/theme'
|
|
45
|
+
import type { IconProps } from '../icons.interfaces'
|
|
46
46
|
|
|
47
|
-
export const ${componentName} = React.memo((props: IconProps) =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return ${jsx}
|
|
51
|
-
})
|
|
47
|
+
export const ${componentName} = React.memo((props: IconProps) => (
|
|
48
|
+
${jsx}
|
|
49
|
+
))
|
|
52
50
|
`;
|
|
53
51
|
};
|
|
54
|
-
const read = (files) => Promise.all(files.map(async (iconPath) => ({
|
|
52
|
+
const read = async (files) => Promise.all(files.map(async (iconPath) => ({
|
|
55
53
|
name: `${(0, camelcase_1.default)(path_1.default.basename(iconPath, path_1.default.extname(iconPath)), {
|
|
56
54
|
pascalCase: true,
|
|
57
55
|
}).replace('50+', 'FiftyPlus')}Icon`,
|
|
58
56
|
source: (await fs_extra_promise_1.default.readFileAsync(iconPath)).toString(),
|
|
59
57
|
})));
|
|
60
|
-
const compile = (icons, replacements) => Promise.all(icons.map(async (icon) => ({
|
|
58
|
+
const compile = async (icons, replacements) => Promise.all(icons.map(async (icon) => ({
|
|
61
59
|
name: icon.name,
|
|
62
60
|
code: await (0, core_1.default)(icon.source.replace(/mask0/g, icon.name), {
|
|
63
61
|
icon: true,
|
|
@@ -65,7 +63,7 @@ const compile = (icons, replacements) => Promise.all(icons.map(async (icon) => (
|
|
|
65
63
|
replaceAttrValues: replacements[icon.name] || {},
|
|
66
64
|
}, { componentName: icon.name.replace('50+', 'FiftyPlus') }),
|
|
67
65
|
})));
|
|
68
|
-
const save = async (sources, targetDir) => Promise.all(sources.map((source) => fs_extra_promise_1.default.writeFileAsync(path_1.default.join(targetDir, `${source.name}.tsx`), (0, standalone_1.format)(`/* eslint-disable */\n${source
|
|
66
|
+
const save = async (sources, targetDir) => Promise.all(sources.map((source) => fs_extra_promise_1.default.writeFileAsync(path_1.default.join(targetDir, `${source.name}.tsx`), (0, standalone_1.format)(`/* eslint-disable */\n${source?.code || ''}`, {
|
|
69
67
|
...config_prettier_1.default,
|
|
70
68
|
filepath: path_1.default.join(targetDir, `${source.name}.tsx`),
|
|
71
69
|
plugins: [parser_typescript_1.default, parser_babel_1.default, prettierPlugin],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atls-ui-generators/icons",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"postpack": "rm -rf dist"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@atls-ui-generators/utils": "0.0.
|
|
18
|
+
"@atls-ui-generators/utils": "0.0.7",
|
|
19
19
|
"@atls/config-prettier": "0.0.5",
|
|
20
20
|
"@atls/prettier-plugin": "0.0.7",
|
|
21
21
|
"@babel/standalone": "7.22.20",
|
|
@@ -28,14 +28,9 @@
|
|
|
28
28
|
"prettier": "2.8.8"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@types/babel__standalone": "7.1.6",
|
|
31
|
+
"@types/babel__standalone": "7.1.7",
|
|
33
32
|
"@types/fs-extra-promise": "1.0.12",
|
|
34
|
-
"@types/prettier": "2.7.3"
|
|
35
|
-
"styled-tools": "1.7.2"
|
|
36
|
-
},
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"glob": "8.0.3"
|
|
33
|
+
"@types/prettier": "2.7.3"
|
|
39
34
|
},
|
|
40
35
|
"publishConfig": {
|
|
41
36
|
"access": "public",
|