@atls-ui-generators/icons 1.0.4 → 1.1.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 +53 -0
- package/README.md +16 -4
- package/dist/icons.generator.js +37 -0
- package/dist/icons.interfaces.js +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -18
- package/dist/replacement-utils/create-replacements/create-replacements.interfaces.d.ts +2 -0
- package/dist/replacement-utils/create-replacements/create-replacements.interfaces.js +1 -0
- package/dist/replacement-utils/create-replacements/create-replacements.util.d.ts +2 -0
- package/dist/replacement-utils/create-replacements/create-replacements.util.js +10 -0
- package/dist/replacement-utils/create-replacements/index.d.ts +1 -0
- package/dist/replacement-utils/create-replacements/index.js +1 -0
- package/dist/replacement-utils/create-replacements/tests/create-replacements.test.constants.d.ts +2 -0
- package/dist/replacement-utils/create-replacements/tests/create-replacements.test.constants.js +37 -0
- package/dist/replacement-utils/create-replacements/tests/create-replacements.test.interfaces.d.ts +6 -0
- package/dist/replacement-utils/create-replacements/tests/create-replacements.test.interfaces.js +1 -0
- package/dist/replacement-utils/get-color-replacement/get-color-replacement.interfaces.js +1 -0
- package/dist/{get-color-replacement → replacement-utils/get-color-replacement}/get-color-replacement.util.d.ts +1 -1
- package/dist/replacement-utils/get-color-replacement/get-color-replacement.util.js +3 -0
- package/dist/replacement-utils/get-color-replacement/index.d.ts +1 -0
- package/dist/replacement-utils/get-color-replacement/index.js +1 -0
- package/dist/replacement-utils/index.d.ts +2 -0
- package/dist/replacement-utils/index.js +2 -0
- package/dist/svgr-utils/compile-icons.util.d.ts +4 -0
- package/dist/{utils → svgr-utils}/compile-icons.util.js +11 -12
- package/dist/{utils → svgr-utils}/create-files.util.d.ts +1 -1
- package/dist/svgr-utils/create-files.util.js +23 -0
- package/dist/svgr-utils/index.d.ts +1 -0
- package/dist/svgr-utils/index.js +1 -0
- package/dist/svgr-utils/read-files.util.d.ts +2 -0
- package/dist/svgr-utils/read-files.util.js +7 -0
- package/dist/{utils → svgr-utils}/svgr-build.util.d.ts +1 -1
- package/dist/svgr-utils/svgr-build.util.js +18 -0
- package/package.json +39 -16
- package/dist/generator.js +0 -40
- package/dist/get-color-replacement/get-color-replacement.interfaces.js +0 -2
- package/dist/get-color-replacement/get-color-replacement.util.js +0 -7
- package/dist/get-color-replacement/index.d.ts +0 -1
- package/dist/get-color-replacement/index.js +0 -17
- package/dist/utils/compile-icons.util.d.ts +0 -4
- package/dist/utils/create-files.util.js +0 -57
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -17
- package/dist/utils/read-files.util.d.ts +0 -2
- package/dist/utils/read-files.util.js +0 -18
- package/dist/utils/svgr-build.util.js +0 -25
- /package/dist/{generator.d.ts → icons.generator.d.ts} +0 -0
- /package/dist/{get-color-replacement → replacement-utils/get-color-replacement}/get-color-replacement.interfaces.d.ts +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# [1.1.0](https://github.com/atls/hyperion/compare/@atls-ui-generators/icons@1.0.5...@atls-ui-generators/icons@1.1.0) (2025-03-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
* **generators:** icons generator ([#600](https://github.com/atls/hyperion/issues/600)) ([931f921](https://github.com/atls/hyperion/commit/931f921489d382f9a4e0a37c39d6082ed131f3f9))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [1.0.5](https://github.com/atls/hyperion/compare/@atls-ui-generators/icons@1.0.4...@atls-ui-generators/icons@1.0.5) (2025-02-19)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
* **hyperion:** lintter and tests ([#593](https://github.com/atls/hyperion/issues/593)) ([a01c488](https://github.com/atls/hyperion/commit/a01c488064d6386f754aafd2eecb28a19396635e))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## 1.0.4 (2025-01-09)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
* changed import when generating icons ([c14fd17](https://github.com/atls/hyperion/commit/c14fd172ff72e35b3a32286961762999accde772))
|
|
34
|
+
* formatter ([1c9d8d0](https://github.com/atls/hyperion/commit/1c9d8d0b86f101059f77da921ee24199764872b8))
|
|
35
|
+
* **icons-generator:** replacements condition ([dbb255d](https://github.com/atls/hyperion/commit/dbb255db964698fb41c43226bd5ddd8688e966b3))
|
|
36
|
+
* linter and typecheck ([e379724](https://github.com/atls/hyperion/commit/e379724b7dbf3c8cba2b0b94647239b0b37c5fb8))
|
|
37
|
+
* **ui:** typecheck ([1a2a36b](https://github.com/atls/hyperion/commit/1a2a36b8baeececd0b929dcdb94da3d38ae8ad1e))
|
|
38
|
+
* up version input and icons packages ([a01bfcd](https://github.com/atls/hyperion/commit/a01bfcd0002f94b210aa49b430ba567c83b9c396))
|
|
39
|
+
* versions ([ff7bdbb](https://github.com/atls/hyperion/commit/ff7bdbb281c9f6e732b06461a0c633c8cc010e46))
|
|
40
|
+
* versions ([96526ce](https://github.com/atls/hyperion/commit/96526cec1a282886dee66adcf35429abac2cb6d6))
|
|
41
|
+
* versions and error handlers for generators ([8b868f2](https://github.com/atls/hyperion/commit/8b868f2f1ec28f2f4ca71ab8c5f1e958fef0533f))
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
* add readme ([4ab2312](https://github.com/atls/hyperion/commit/4ab2312d6d395e2a8309b264c26174671f68a047))
|
|
47
|
+
* **icons-generator:** init ([77e013e](https://github.com/atls/hyperion/commit/77e013e926b05e042c905514d17d481fe5df98c6))
|
|
48
|
+
* memo for icons, glob as dependency ([70ad226](https://github.com/atls/hyperion/commit/70ad226932df31366baaad3477fa89fef99f8cc9))
|
|
49
|
+
* README.md badges. Yarn, code services and prettier plugin bump, ([e53ab99](https://github.com/atls/hyperion/commit/e53ab99652123c14ac8ae844078a5fc9c4e98be2))
|
|
50
|
+
* **ui-parts:** add create-container-styles util to theme ([#590](https://github.com/atls/hyperion/issues/590)) ([34064a3](https://github.com/atls/hyperion/commit/34064a384192b781fd6d667857f568d4f42228a4))
|
|
51
|
+
* updated @atls-ui-generators/icons ([3a4930c](https://github.com/atls/hyperion/commit/3a4930cc50a014053929b1a7053d79f708469fa6))
|
|
52
|
+
|
|
53
|
+
|
package/README.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Appearance генератор
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### Использование
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
-
|
|
5
|
+
```
|
|
6
|
+
generate-icons --help
|
|
7
|
+
|
|
8
|
+
generate-icons ./src/icons -i ./svg -r ./src/replacements.ts
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Разработка
|
|
12
|
+
|
|
13
|
+
Запуск тестов
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
yarn test unit create-replacements.test.ts
|
|
17
|
+
yarn test unit get-color-replacement.test.ts
|
|
18
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { lstatSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { program } from 'commander';
|
|
5
|
+
import { createLogger } from '@atls-ui-generators/utils';
|
|
6
|
+
import { processFile } from '@atls-ui-generators/utils';
|
|
7
|
+
import { svgrBuild } from './svgr-utils/index.js';
|
|
8
|
+
const logger = createLogger('icons-generator');
|
|
9
|
+
try {
|
|
10
|
+
program
|
|
11
|
+
.name('Icons generator')
|
|
12
|
+
.argument('path <string>', 'Path to save the icons')
|
|
13
|
+
.requiredOption('-i, --icons path <string>', 'Path to icons svg dir')
|
|
14
|
+
.option('-r, --replacements path <string>', 'Path to replacements file')
|
|
15
|
+
.parse(process.argv);
|
|
16
|
+
const path = program.args.at(0);
|
|
17
|
+
const { icons: iconsPath, replacements: replacementsPath } = program.opts();
|
|
18
|
+
assert.ok(path && typeof path === 'string', 'Path to save the icons is required');
|
|
19
|
+
assert.ok(lstatSync(path).isDirectory(), 'Path to save icons should point to a directory.');
|
|
20
|
+
assert.ok(iconsPath && typeof iconsPath === 'string', 'Icons svg path is required');
|
|
21
|
+
assert.ok(lstatSync(iconsPath).isDirectory(), 'Icons path should point to a directory');
|
|
22
|
+
let replacements = {};
|
|
23
|
+
if (replacementsPath) {
|
|
24
|
+
assert.ok(typeof replacementsPath === 'string', 'Replacements path should be string');
|
|
25
|
+
assert.ok(lstatSync(replacementsPath).isFile(), 'Replacements path should point to a file');
|
|
26
|
+
logger.info(`Extract replacements from ${replacementsPath}`);
|
|
27
|
+
const absoluteReplacementsPath = join(process.cwd(), replacementsPath);
|
|
28
|
+
const exports = processFile(absoluteReplacementsPath);
|
|
29
|
+
replacements = Object.values(exports)?.[0];
|
|
30
|
+
}
|
|
31
|
+
logger.info(`Icon generation started into ${path}`);
|
|
32
|
+
await svgrBuild(iconsPath, path, replacements);
|
|
33
|
+
logger.info(`Generated into ${path}`);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
logger.error(error);
|
|
37
|
+
}
|
package/dist/icons.interfaces.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './utils';
|
|
1
|
+
export * from './replacement-utils/index.js';
|
|
2
|
+
export * from './svgr-utils/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./get-color-replacement"), exports);
|
|
18
|
-
__exportStar(require("./utils"), exports);
|
|
1
|
+
export * from "./replacement-utils/index.js";
|
|
2
|
+
export * from "./svgr-utils/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getColorReplacement } from '../get-color-replacement/index.js';
|
|
2
|
+
export const createReplacements = (replacementIcons) => Object.entries(replacementIcons).reduce((replacement, [icon, value]) => {
|
|
3
|
+
if (Array.isArray(value)) {
|
|
4
|
+
return {
|
|
5
|
+
...replacement,
|
|
6
|
+
[icon]: value.reduce((colors, color) => ({ ...colors, ...getColorReplacement({ color }) }), {}),
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
return { ...replacement, [icon]: getColorReplacement({ color: value }) };
|
|
10
|
+
}, {});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create-replacements.util.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./create-replacements.util.js";
|
package/dist/replacement-utils/create-replacements/tests/create-replacements.test.constants.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const testCases = [
|
|
2
|
+
{
|
|
3
|
+
replacementIcons: {},
|
|
4
|
+
expectedResult: {},
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
replacementIcons: {
|
|
8
|
+
CircleIcon: '#18181B',
|
|
9
|
+
LeftIcon: '#18181B',
|
|
10
|
+
},
|
|
11
|
+
expectedResult: {
|
|
12
|
+
CircleIcon: {
|
|
13
|
+
'#18181B': '{(props.color && vars.colors[props.color]) || props.color || "#18181B"}',
|
|
14
|
+
},
|
|
15
|
+
LeftIcon: {
|
|
16
|
+
'#18181B': '{(props.color && vars.colors[props.color]) || props.color || "#18181B"}',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
replacementIcons: {
|
|
22
|
+
CircleIcon: ['#18181B', '#000000'],
|
|
23
|
+
LeftIcon: ['#18181B', '#000000', '#0000FF'],
|
|
24
|
+
},
|
|
25
|
+
expectedResult: {
|
|
26
|
+
CircleIcon: {
|
|
27
|
+
'#18181B': '{(props.color && vars.colors[props.color]) || props.color || "#18181B"}',
|
|
28
|
+
'#000000': '{(props.color && vars.colors[props.color]) || props.color || "#000000"}',
|
|
29
|
+
},
|
|
30
|
+
LeftIcon: {
|
|
31
|
+
'#18181B': '{(props.color && vars.colors[props.color]) || props.color || "#18181B"}',
|
|
32
|
+
'#000000': '{(props.color && vars.colors[props.color]) || props.color || "#000000"}',
|
|
33
|
+
'#0000FF': '{(props.color && vars.colors[props.color]) || props.color || "#0000FF"}',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
];
|
package/dist/replacement-utils/create-replacements/tests/create-replacements.test.interfaces.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { GetColorReplacement } from './get-color-replacement.interfaces';
|
|
1
|
+
import type { GetColorReplacement } from './get-color-replacement.interfaces.js';
|
|
2
2
|
export declare const getColorReplacement: GetColorReplacement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './get-color-replacement.util.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./get-color-replacement.util.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Icon } from '../icons.interfaces.js';
|
|
2
|
+
import type { Replacements } from '../icons.interfaces.js';
|
|
3
|
+
import type { Source } from '../icons.interfaces.js';
|
|
4
|
+
export declare const compileIcons: (icons: Array<Icon>, replacements: Replacements) => Promise<Array<Source>>;
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compileIcons = void 0;
|
|
4
|
-
const core_1 = require("@svgr/core");
|
|
1
|
+
import { transform } from '@svgr/core';
|
|
5
2
|
const createSvgrTemplate = (withReplacement) => ({ jsx, componentName }, { tpl }) => tpl `
|
|
6
3
|
import type { IconProps } from '../icons.interfaces.js'
|
|
7
4
|
|
|
5
|
+
import type { FC } from 'react'
|
|
6
|
+
|
|
8
7
|
import React from 'react'
|
|
9
|
-
import { memo } from 'react'
|
|
10
8
|
import { clsx } from 'clsx'
|
|
11
9
|
|
|
12
10
|
${withReplacement ? `import { vars } from '@ui/theme'` : ''}
|
|
13
11
|
|
|
14
12
|
import { iconSprinkles } from '../icon.css.js'
|
|
15
13
|
|
|
16
|
-
export const ${componentName} =
|
|
14
|
+
export const ${componentName}: FC<IconProps> = (props) => {
|
|
17
15
|
const { className, style, otherProps } = iconSprinkles(props)
|
|
18
16
|
|
|
17
|
+
const iconStyle = { ...style, ...otherProps.style }
|
|
18
|
+
|
|
19
19
|
return (
|
|
20
20
|
${jsx}
|
|
21
21
|
)
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
23
|
`;
|
|
24
|
-
const compileIcons = async (icons, replacements) => Promise.all(icons.map(async (icon) => ({
|
|
24
|
+
export const compileIcons = async (icons, replacements) => Promise.all(icons.map(async (icon) => ({
|
|
25
25
|
name: icon.fileName,
|
|
26
|
-
code: await
|
|
26
|
+
code: await transform(icon.source.replace(/mask0/g, icon.name), {
|
|
27
27
|
icon: true,
|
|
28
28
|
typescript: true,
|
|
29
29
|
template: createSvgrTemplate(Boolean(replacements[icon.name])),
|
|
30
30
|
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx', '@svgr/plugin-prettier'],
|
|
31
31
|
svgProps: {
|
|
32
|
-
className:
|
|
33
|
-
style: '{
|
|
32
|
+
className: `{clsx(className, typeof otherProps?.className === 'string' && otherProps.className)}`,
|
|
33
|
+
style: '{iconStyle}',
|
|
34
34
|
},
|
|
35
35
|
replaceAttrValues: { ...replacements[icon.name] },
|
|
36
36
|
}, { componentName: icon.name.replace('50+', 'FiftyPlus') }),
|
|
37
37
|
withReplacement: Boolean(replacements[icon.name]),
|
|
38
38
|
})));
|
|
39
|
-
exports.compileIcons = compileIcons;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Source } from '../icons.interfaces';
|
|
1
|
+
import type { Source } from '../icons.interfaces.js';
|
|
2
2
|
export declare const createFiles: (sources: Array<Source>, targetDir: string) => Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { pretty } from '@atls-ui-generators/utils';
|
|
4
|
+
const writeSourceFile = async (source, targetDir) => {
|
|
5
|
+
const filename = path.join(targetDir, `${source.name}.tsx`);
|
|
6
|
+
const data = await pretty(source.code);
|
|
7
|
+
fs.writeFileSync(filename, data);
|
|
8
|
+
};
|
|
9
|
+
const writeIndexFile = (sources, targetDir) => {
|
|
10
|
+
const filename = path.join(targetDir, 'index.ts');
|
|
11
|
+
const data = `${sources
|
|
12
|
+
.sort((sourceA, sourceB) => sourceA.name.localeCompare(sourceB.name))
|
|
13
|
+
.map((source) => `export * from './${source.name}.js'`)
|
|
14
|
+
.join('\n')}\n`;
|
|
15
|
+
fs.writeFileSync(filename, data);
|
|
16
|
+
};
|
|
17
|
+
export const createFiles = async (sources, targetDir) => {
|
|
18
|
+
if (!fs.existsSync(targetDir)) {
|
|
19
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
await Promise.all(sources.map(async (source) => writeSourceFile(source, targetDir)));
|
|
22
|
+
writeIndexFile(sources, targetDir);
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './svgr-build.util.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./svgr-build.util.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Replacements } from '../icons.interfaces';
|
|
1
|
+
import type { Replacements } from '../icons.interfaces.js';
|
|
2
2
|
export declare const svgrBuild: (iconsPath: string, targetDir: string, replacements: Replacements) => Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { glob } from 'glob';
|
|
2
|
+
import { compileIcons } from './compile-icons.util.js';
|
|
3
|
+
import { createFiles } from './create-files.util.js';
|
|
4
|
+
import { readFiles } from './read-files.util.js';
|
|
5
|
+
export const svgrBuild = async (iconsPath, targetDir, replacements) => {
|
|
6
|
+
const prettifyIconsPath = () => {
|
|
7
|
+
const parts = iconsPath.split('');
|
|
8
|
+
if (parts[parts.length - 1] === '/') {
|
|
9
|
+
parts.pop();
|
|
10
|
+
return parts.join('');
|
|
11
|
+
}
|
|
12
|
+
return iconsPath;
|
|
13
|
+
};
|
|
14
|
+
const files = await glob(`${prettifyIconsPath()}/*.svg`);
|
|
15
|
+
const icons = readFiles(files);
|
|
16
|
+
const sources = await compileIcons(icons.filter((icon) => icon.source), replacements);
|
|
17
|
+
await createFiles(sources, targetDir);
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,42 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atls-ui-generators/icons",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"bin": {
|
|
7
|
-
"generate-icons": "dist/generator.js"
|
|
8
|
+
"generate-icons": "dist/icons.generator.js"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
10
11
|
"dist"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
14
|
"build": "yarn library build",
|
|
15
|
+
"generate-icons": "tsx src/icons.generator.ts",
|
|
14
16
|
"prepack": "yarn run build",
|
|
15
17
|
"postpack": "rm -rf dist"
|
|
16
18
|
},
|
|
17
19
|
"dependencies": {
|
|
18
|
-
"@atls-ui-generators/utils": "
|
|
19
|
-
"@atls/config-prettier": "0.0.5",
|
|
20
|
-
"@atls/prettier-plugin": "0.0.7",
|
|
21
|
-
"@babel/standalone": "7.22.20",
|
|
20
|
+
"@atls-ui-generators/utils": "1.0.3",
|
|
22
21
|
"@svgr/core": "8.1.0",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"glob": "
|
|
27
|
-
"glob-promise": "5.0.0",
|
|
28
|
-
"prettier": "2.8.8"
|
|
22
|
+
"@swc-node/register": "1.9.0",
|
|
23
|
+
"@swc/core": "1.6.1",
|
|
24
|
+
"commander": "13.1.0",
|
|
25
|
+
"glob": "11.0.1"
|
|
29
26
|
},
|
|
30
27
|
"devDependencies": {
|
|
31
|
-
"@types/
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"@types/prettier": "2.7.3"
|
|
28
|
+
"@types/node": "22.13.8",
|
|
29
|
+
"tsx": "4.19.3",
|
|
30
|
+
"typescript": "5.5.4"
|
|
35
31
|
},
|
|
36
32
|
"publishConfig": {
|
|
37
33
|
"access": "public",
|
|
34
|
+
"exports": {
|
|
35
|
+
"./package.json": "./package.json",
|
|
36
|
+
".": {
|
|
37
|
+
"import": "./dist/index.js",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./replacement": {
|
|
42
|
+
"import": "./dist/replacement-utils/index.js",
|
|
43
|
+
"types": "./dist/replacement-utils/index.d.ts",
|
|
44
|
+
"default": "./dist/replacement-utils/index.js"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
38
47
|
"main": "dist/index.js",
|
|
39
48
|
"typings": "dist/index.d.ts"
|
|
40
49
|
},
|
|
50
|
+
"typecheckSkipLibCheck": true,
|
|
51
|
+
"exports": {
|
|
52
|
+
"./package.json": "./package.json",
|
|
53
|
+
".": {
|
|
54
|
+
"import": "./dist/index.js",
|
|
55
|
+
"types": "./dist/index.d.ts",
|
|
56
|
+
"default": "./dist/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./replacement": {
|
|
59
|
+
"import": "./dist/replacement-utils/index.js",
|
|
60
|
+
"types": "./dist/replacement-utils/index.d.ts",
|
|
61
|
+
"default": "./dist/replacement-utils/index.js"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
41
64
|
"typings": "dist/index.d.ts"
|
|
42
65
|
}
|
package/dist/generator.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const standalone_1 = require("@babel/standalone");
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const fs_2 = require("fs");
|
|
10
|
-
const fs_3 = require("fs");
|
|
11
|
-
const fs_4 = require("fs");
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
const assert_1 = __importDefault(require("assert"));
|
|
14
|
-
const utils_1 = require("./utils");
|
|
15
|
-
const command = new commander_1.Command()
|
|
16
|
-
.name('Icons generator')
|
|
17
|
-
.argument('path <string>', 'Path to save icons')
|
|
18
|
-
.option('-i, --icons path <string>', 'Path to icons dir')
|
|
19
|
-
.option('-r, --replacements path <string>', 'Path to replacements file')
|
|
20
|
-
.action(async (path, options) => {
|
|
21
|
-
assert_1.default.ok(options.icons, 'Icons dir path is required');
|
|
22
|
-
const iconsPath = (0, path_1.join)(process.cwd(), options.icons);
|
|
23
|
-
const genPath = (0, path_1.join)(process.cwd(), path);
|
|
24
|
-
if (!(0, fs_3.existsSync)(genPath)) {
|
|
25
|
-
(0, fs_4.mkdirSync)(genPath);
|
|
26
|
-
}
|
|
27
|
-
assert_1.default.ok((0, fs_2.lstatSync)(genPath).isDirectory(), 'Path to save icons should point to a directory.');
|
|
28
|
-
assert_1.default.ok((0, fs_2.lstatSync)(iconsPath).isDirectory(), 'Icons path should point to a directory.');
|
|
29
|
-
let replacements = {};
|
|
30
|
-
if (options.replacements) {
|
|
31
|
-
const replacementsFile = (0, fs_1.readFileSync)((0, path_1.join)(process.cwd(), options.replacements)).toString('utf-8');
|
|
32
|
-
const { code } = (0, standalone_1.transform)(replacementsFile, { presets: ['env'] });
|
|
33
|
-
if (!code)
|
|
34
|
-
throw Error('Could not read the file');
|
|
35
|
-
replacements = eval(code);
|
|
36
|
-
}
|
|
37
|
-
await (0, utils_1.svgrBuild)(iconsPath, genPath, replacements);
|
|
38
|
-
console.log(`Generated into ${genPath}`);
|
|
39
|
-
});
|
|
40
|
-
command.parse();
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getColorReplacement = void 0;
|
|
4
|
-
const getColorReplacement = (options) => ({
|
|
5
|
-
[options.color]: `{(props.color && vars.colors${(options.themePaths || []).reduce((str, prop) => `${str}.${prop}`, '')}[props.color]) || props.color || "${options.color}"}`,
|
|
6
|
-
});
|
|
7
|
-
exports.getColorReplacement = getColorReplacement;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './get-color-replacement.util';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./get-color-replacement.util"), exports);
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.createFiles = void 0;
|
|
30
|
-
const prettierPlugin = __importStar(require("@atls/prettier-plugin"));
|
|
31
|
-
const config_prettier_1 = __importDefault(require("@atls/config-prettier"));
|
|
32
|
-
const fs_extra_promise_1 = __importDefault(require("fs-extra-promise"));
|
|
33
|
-
const path_1 = __importDefault(require("path"));
|
|
34
|
-
const parser_babel_1 = __importDefault(require("prettier/parser-babel"));
|
|
35
|
-
const parser_typescript_1 = __importDefault(require("prettier/parser-typescript"));
|
|
36
|
-
const standalone_1 = __importDefault(require("prettier/standalone"));
|
|
37
|
-
const writeSourceFile = async (source, targetDir) => {
|
|
38
|
-
const filename = path_1.default.join(targetDir, `${source.name}.tsx`);
|
|
39
|
-
const config = config_prettier_1.default;
|
|
40
|
-
const data = standalone_1.default.format(source.code, {
|
|
41
|
-
...config,
|
|
42
|
-
filepath: path_1.default.join(targetDir, `${source.name}.tsx`),
|
|
43
|
-
plugins: [parser_typescript_1.default, parser_babel_1.default, prettierPlugin],
|
|
44
|
-
});
|
|
45
|
-
await fs_extra_promise_1.default.writeFileAsync(filename, data);
|
|
46
|
-
};
|
|
47
|
-
const writeIndexFile = async (sources, targetDir) => {
|
|
48
|
-
const filename = path_1.default.join(targetDir, 'index.ts');
|
|
49
|
-
const data = `${sources.map((source) => `export * from './${source.name}.js'`).join('\n')}\n`;
|
|
50
|
-
await fs_extra_promise_1.default.writeFileAsync(filename, data);
|
|
51
|
-
};
|
|
52
|
-
const createFiles = async (sources, targetDir) => {
|
|
53
|
-
await fs_extra_promise_1.default.ensureDir(targetDir);
|
|
54
|
-
await Promise.all(sources.map(async (source) => writeSourceFile(source, targetDir)));
|
|
55
|
-
await writeIndexFile(sources, targetDir);
|
|
56
|
-
};
|
|
57
|
-
exports.createFiles = createFiles;
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './svgr-build.util';
|
package/dist/utils/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./svgr-build.util"), exports);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.readFiles = void 0;
|
|
7
|
-
const camelcase_1 = __importDefault(require("camelcase"));
|
|
8
|
-
const fs_extra_promise_1 = __importDefault(require("fs-extra-promise"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const createIcon = async (iconPath) => ({
|
|
11
|
-
name: `${(0, camelcase_1.default)(path_1.default.basename(iconPath, path_1.default.extname(iconPath)), {
|
|
12
|
-
pascalCase: true,
|
|
13
|
-
}).replace('50+', 'FiftyPlus')}Icon`,
|
|
14
|
-
fileName: `${path_1.default.basename(iconPath, path_1.default.extname(iconPath)).replace('50+', 'FiftyPlus')}.icon`,
|
|
15
|
-
source: (await fs_extra_promise_1.default.readFileAsync(iconPath)).toString(),
|
|
16
|
-
});
|
|
17
|
-
const readFiles = async (files) => Promise.all(files.map(createIcon));
|
|
18
|
-
exports.readFiles = readFiles;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.svgrBuild = void 0;
|
|
7
|
-
const glob_promise_1 = __importDefault(require("glob-promise"));
|
|
8
|
-
const compile_icons_util_1 = require("./compile-icons.util");
|
|
9
|
-
const create_files_util_1 = require("./create-files.util");
|
|
10
|
-
const read_files_util_1 = require("./read-files.util");
|
|
11
|
-
const svgrBuild = async (iconsPath, targetDir, replacements) => {
|
|
12
|
-
const prettifyIconsPath = () => {
|
|
13
|
-
const parts = iconsPath.split('');
|
|
14
|
-
if (parts[parts.length - 1] === '/') {
|
|
15
|
-
parts.pop();
|
|
16
|
-
return parts.join('');
|
|
17
|
-
}
|
|
18
|
-
return iconsPath;
|
|
19
|
-
};
|
|
20
|
-
const files = await (0, glob_promise_1.default)(`${prettifyIconsPath()}/*.svg`);
|
|
21
|
-
const icons = await (0, read_files_util_1.readFiles)(files);
|
|
22
|
-
const sources = await (0, compile_icons_util_1.compileIcons)(icons.filter((icon) => icon.source), replacements);
|
|
23
|
-
await (0, create_files_util_1.createFiles)(sources, targetDir);
|
|
24
|
-
};
|
|
25
|
-
exports.svgrBuild = svgrBuild;
|
|
File without changes
|