@atls-ui-generators/icons 1.0.3 → 1.0.5

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 ADDED
@@ -0,0 +1,41 @@
1
+
2
+
3
+ ## [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)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+
9
+ * **hyperion:** lintter and tests ([#593](https://github.com/atls/hyperion/issues/593)) ([a01c488](https://github.com/atls/hyperion/commit/a01c488064d6386f754aafd2eecb28a19396635e))
10
+
11
+
12
+
13
+
14
+
15
+ ## 1.0.4 (2025-01-09)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+
21
+ * changed import when generating icons ([c14fd17](https://github.com/atls/hyperion/commit/c14fd172ff72e35b3a32286961762999accde772))
22
+ * formatter ([1c9d8d0](https://github.com/atls/hyperion/commit/1c9d8d0b86f101059f77da921ee24199764872b8))
23
+ * **icons-generator:** replacements condition ([dbb255d](https://github.com/atls/hyperion/commit/dbb255db964698fb41c43226bd5ddd8688e966b3))
24
+ * linter and typecheck ([e379724](https://github.com/atls/hyperion/commit/e379724b7dbf3c8cba2b0b94647239b0b37c5fb8))
25
+ * **ui:** typecheck ([1a2a36b](https://github.com/atls/hyperion/commit/1a2a36b8baeececd0b929dcdb94da3d38ae8ad1e))
26
+ * up version input and icons packages ([a01bfcd](https://github.com/atls/hyperion/commit/a01bfcd0002f94b210aa49b430ba567c83b9c396))
27
+ * versions ([ff7bdbb](https://github.com/atls/hyperion/commit/ff7bdbb281c9f6e732b06461a0c633c8cc010e46))
28
+ * versions ([96526ce](https://github.com/atls/hyperion/commit/96526cec1a282886dee66adcf35429abac2cb6d6))
29
+ * versions and error handlers for generators ([8b868f2](https://github.com/atls/hyperion/commit/8b868f2f1ec28f2f4ca71ab8c5f1e958fef0533f))
30
+
31
+ ### Features
32
+
33
+
34
+ * add readme ([4ab2312](https://github.com/atls/hyperion/commit/4ab2312d6d395e2a8309b264c26174671f68a047))
35
+ * **icons-generator:** init ([77e013e](https://github.com/atls/hyperion/commit/77e013e926b05e042c905514d17d481fe5df98c6))
36
+ * memo for icons, glob as dependency ([70ad226](https://github.com/atls/hyperion/commit/70ad226932df31366baaad3477fa89fef99f8cc9))
37
+ * README.md badges. Yarn, code services and prettier plugin bump, ([e53ab99](https://github.com/atls/hyperion/commit/e53ab99652123c14ac8ae844078a5fc9c4e98be2))
38
+ * **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))
39
+ * updated @atls-ui-generators/icons ([3a4930c](https://github.com/atls/hyperion/commit/3a4930cc50a014053929b1a7053d79f708469fa6))
40
+
41
+
package/dist/generator.js CHANGED
@@ -1,40 +1,35 @@
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()
1
+ import { transform } from '@babel/standalone';
2
+ import { Command } from 'commander';
3
+ import { readFileSync } from 'fs';
4
+ import { lstatSync } from 'fs';
5
+ import { existsSync } from 'fs';
6
+ import { mkdirSync } from 'fs';
7
+ import { join } from 'path';
8
+ import assert from 'assert';
9
+ import { svgrBuild } from './utils/index.js';
10
+ const command = new Command()
16
11
  .name('Icons generator')
17
12
  .argument('path <string>', 'Path to save icons')
18
13
  .option('-i, --icons path <string>', 'Path to icons dir')
19
14
  .option('-r, --replacements path <string>', 'Path to replacements file')
20
15
  .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);
16
+ assert.ok(options.icons, 'Icons dir path is required');
17
+ const iconsPath = join(process.cwd(), options.icons);
18
+ const genPath = join(process.cwd(), path);
19
+ if (!existsSync(genPath)) {
20
+ mkdirSync(genPath);
26
21
  }
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.');
22
+ assert.ok(lstatSync(genPath).isDirectory(), 'Path to save icons should point to a directory.');
23
+ assert.ok(lstatSync(iconsPath).isDirectory(), 'Icons path should point to a directory.');
29
24
  let replacements = {};
30
25
  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'] });
26
+ const replacementsFile = readFileSync(join(process.cwd(), options.replacements)).toString('utf-8');
27
+ const { code } = transform(replacementsFile, { presets: ['env'] });
33
28
  if (!code)
34
29
  throw Error('Could not read the file');
35
30
  replacements = eval(code);
36
31
  }
37
- await (0, utils_1.svgrBuild)(iconsPath, genPath, replacements);
32
+ await svgrBuild(iconsPath, genPath, replacements);
38
33
  console.log(`Generated into ${genPath}`);
39
34
  });
40
35
  command.parse();
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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;
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getColorReplacement = void 0;
4
- const getColorReplacement = (options) => ({
1
+ export const getColorReplacement = (options) => ({
5
2
  [options.color]: `{(props.color && vars.colors${(options.themePaths || []).reduce((str, prop) => `${str}.${prop}`, '')}[props.color]) || props.color || "${options.color}"}`,
6
3
  });
7
- exports.getColorReplacement = getColorReplacement;
@@ -1 +1 @@
1
- export * from './get-color-replacement.util';
1
+ export * from './get-color-replacement.util.js';
@@ -1,17 +1 @@
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
+ export * from "./get-color-replacement.util.js";
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './get-color-replacement';
2
- export * from './utils';
1
+ export * from './get-color-replacement/index.js';
2
+ export * from './utils/index.js';
package/dist/index.js CHANGED
@@ -1,18 +1,2 @@
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"), exports);
18
- __exportStar(require("./utils"), exports);
1
+ export * from "./get-color-replacement/index.js";
2
+ export * from "./utils/index.js";
@@ -1,4 +1,4 @@
1
- import type { Icon } from '../icons.interfaces';
2
- import type { Replacements } from '../icons.interfaces';
3
- import type { Source } from '../icons.interfaces';
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
4
  export declare const compileIcons: (icons: Array<Icon>, replacements: Replacements) => Promise<Array<Source>>;
@@ -1,28 +1,35 @@
1
- "use strict";
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
 
8
5
  import React from 'react'
9
6
  import { memo } from 'react'
7
+ import { clsx } from 'clsx'
10
8
 
11
9
  ${withReplacement ? `import { vars } from '@ui/theme'` : ''}
12
10
 
13
- export const ${componentName} = memo((props: IconProps) => (
14
- ${jsx}
15
- ))
11
+ import { iconSprinkles } from '../icon.css.js'
12
+
13
+ export const ${componentName} = memo((props: IconProps) => {
14
+ const { className, style, otherProps } = iconSprinkles(props)
15
+
16
+ return (
17
+ ${jsx}
18
+ )
19
+ })
16
20
  `;
17
- const compileIcons = async (icons, replacements) => Promise.all(icons.map(async (icon) => ({
21
+ export const compileIcons = async (icons, replacements) => Promise.all(icons.map(async (icon) => ({
18
22
  name: icon.fileName,
19
- code: await (0, core_1.transform)(icon.source.replace(/mask0/g, icon.name), {
23
+ code: await transform(icon.source.replace(/mask0/g, icon.name), {
20
24
  icon: true,
21
25
  typescript: true,
22
26
  template: createSvgrTemplate(Boolean(replacements[icon.name])),
23
27
  plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx', '@svgr/plugin-prettier'],
24
- replaceAttrValues: replacements[icon.name] || {},
28
+ svgProps: {
29
+ className: '{clsx(className, otherProps?.className)}',
30
+ style: '{Object.assign({}, style, otherProps.style)}',
31
+ },
32
+ replaceAttrValues: { ...replacements[icon.name] },
25
33
  }, { componentName: icon.name.replace('50+', 'FiftyPlus') }),
26
34
  withReplacement: Boolean(replacements[icon.name]),
27
35
  })));
28
- 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>;
@@ -1,57 +1,28 @@
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"));
1
+ import * as prettierPlugin from '@atls/prettier-plugin';
2
+ import atlsPrettierConfig from '@atls/config-prettier';
3
+ import fs from 'fs-extra-promise';
4
+ import path from 'path';
5
+ import parserBabel from 'prettier/parser-babel.js';
6
+ import parserTypescript from 'prettier/parser-typescript.js';
7
+ import prettier from 'prettier/standalone.js';
8
+ const prettierConfig = 'default' in atlsPrettierConfig ? atlsPrettierConfig.default : atlsPrettierConfig;
37
9
  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, {
10
+ const filename = path.join(targetDir, `${source.name}.tsx`);
11
+ const config = prettierConfig;
12
+ const data = prettier.format(source.code, {
41
13
  ...config,
42
- filepath: path_1.default.join(targetDir, `${source.name}.tsx`),
43
- plugins: [parser_typescript_1.default, parser_babel_1.default, prettierPlugin],
14
+ filepath: path.join(targetDir, `${source.name}.tsx`),
15
+ plugins: [parserTypescript, parserBabel, prettierPlugin],
44
16
  });
45
- await fs_extra_promise_1.default.writeFileAsync(filename, data);
17
+ await fs.writeFileAsync(filename, data);
46
18
  };
47
19
  const writeIndexFile = async (sources, targetDir) => {
48
- const filename = path_1.default.join(targetDir, 'index.ts');
20
+ const filename = path.join(targetDir, 'index.ts');
49
21
  const data = `${sources.map((source) => `export * from './${source.name}.js'`).join('\n')}\n`;
50
- await fs_extra_promise_1.default.writeFileAsync(filename, data);
22
+ await fs.writeFileAsync(filename, data);
51
23
  };
52
- const createFiles = async (sources, targetDir) => {
53
- await fs_extra_promise_1.default.ensureDir(targetDir);
24
+ export const createFiles = async (sources, targetDir) => {
25
+ await fs.ensureDir(targetDir);
54
26
  await Promise.all(sources.map(async (source) => writeSourceFile(source, targetDir)));
55
27
  await writeIndexFile(sources, targetDir);
56
28
  };
57
- exports.createFiles = createFiles;
@@ -1 +1 @@
1
- export * from './svgr-build.util';
1
+ export * from './svgr-build.util.js';
@@ -1,17 +1 @@
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
+ export * from "./svgr-build.util.js";
@@ -1,2 +1,2 @@
1
- import type { Icon } from '../icons.interfaces';
1
+ import type { Icon } from '../icons.interfaces.js';
2
2
  export declare const readFiles: (files: Array<string>) => Promise<Array<Icon>>;
@@ -1,18 +1,11 @@
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"));
1
+ import camelcase from 'camelcase';
2
+ import fs from 'fs-extra-promise';
3
+ import path from 'path';
10
4
  const createIcon = async (iconPath) => ({
11
- name: `${(0, camelcase_1.default)(path_1.default.basename(iconPath, path_1.default.extname(iconPath)), {
5
+ name: `${camelcase(path.basename(iconPath, path.extname(iconPath)), {
12
6
  pascalCase: true,
13
7
  }).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(),
8
+ fileName: `${path.basename(iconPath, path.extname(iconPath)).replace('50+', 'FiftyPlus')}.icon`,
9
+ source: (await fs.readFileAsync(iconPath)).toString(),
16
10
  });
17
- const readFiles = async (files) => Promise.all(files.map(createIcon));
18
- exports.readFiles = readFiles;
11
+ export const readFiles = async (files) => Promise.all(files.map(createIcon));
@@ -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>;
@@ -1,14 +1,8 @@
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) => {
1
+ import glob from 'glob-promise';
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) => {
12
6
  const prettifyIconsPath = () => {
13
7
  const parts = iconsPath.split('');
14
8
  if (parts[parts.length - 1] === '/') {
@@ -17,9 +11,8 @@ const svgrBuild = async (iconsPath, targetDir, replacements) => {
17
11
  }
18
12
  return iconsPath;
19
13
  };
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);
14
+ const files = await glob(`${prettifyIconsPath()}/*.svg`);
15
+ const icons = await readFiles(files);
16
+ const sources = await compileIcons(icons.filter((icon) => icon.source), replacements);
17
+ await createFiles(sources, targetDir);
24
18
  };
25
- exports.svgrBuild = svgrBuild;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@atls-ui-generators/icons",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "license": "BSD-3-Clause",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "bin": {
7
8
  "generate-icons": "dist/generator.js"
@@ -31,6 +32,7 @@
31
32
  "@types/babel__core": "7.20.5",
32
33
  "@types/babel__standalone": "7.1.7",
33
34
  "@types/fs-extra-promise": "1.0.12",
35
+ "@types/node": "20.11.5",
34
36
  "@types/prettier": "2.7.3"
35
37
  },
36
38
  "publishConfig": {
@@ -38,5 +40,6 @@
38
40
  "main": "dist/index.js",
39
41
  "typings": "dist/index.d.ts"
40
42
  },
43
+ "typecheckSkipLibCheck": true,
41
44
  "typings": "dist/index.d.ts"
42
45
  }