@iconify/tools 2.0.0-dev.3 → 2.0.2

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.
Files changed (107) hide show
  1. package/README.md +90 -0
  2. package/lib/colors/parse.d.ts +1 -1
  3. package/lib/colors/parse.js +3 -1
  4. package/lib/colors/parse.mjs +2 -1
  5. package/lib/colors/validate.d.ts +11 -0
  6. package/lib/colors/validate.js +45 -0
  7. package/lib/colors/validate.mjs +33 -0
  8. package/lib/css/parser/text.js +3 -6
  9. package/lib/css/parser/text.mjs +3 -3
  10. package/lib/{api → download/api}/cache.d.ts +0 -0
  11. package/lib/{api → download/api}/cache.js +1 -1
  12. package/lib/{api → download/api}/cache.mjs +2 -2
  13. package/lib/download/api/download.d.ts +5 -0
  14. package/lib/download/api/download.js +27 -0
  15. package/lib/download/api/download.mjs +21 -0
  16. package/lib/{api → download/api}/index.d.ts +0 -0
  17. package/lib/{api → download/api}/index.js +2 -2
  18. package/lib/{api → download/api}/index.mjs +3 -3
  19. package/lib/{api → download/api}/types.d.ts +0 -0
  20. package/lib/{api → download/api}/types.js +0 -0
  21. package/lib/{api → download/api}/types.mjs +0 -0
  22. package/lib/download/git/hash.d.ts +5 -0
  23. package/lib/download/git/hash.js +14 -0
  24. package/lib/download/git/hash.mjs +11 -0
  25. package/lib/download/git/index.d.ts +26 -0
  26. package/lib/download/git/index.js +52 -0
  27. package/lib/download/git/index.mjs +44 -0
  28. package/lib/download/github/hash.d.ts +5 -0
  29. package/lib/download/github/hash.js +28 -0
  30. package/lib/download/github/hash.mjs +25 -0
  31. package/lib/download/github/index.d.ts +28 -0
  32. package/lib/download/github/index.js +105 -0
  33. package/lib/download/github/index.mjs +83 -0
  34. package/lib/download/github/types.d.ts +9 -0
  35. package/lib/download/github/types.js +2 -0
  36. package/lib/download/github/types.mjs +0 -0
  37. package/lib/download/helpers/untar.d.ts +4 -0
  38. package/lib/download/helpers/untar.js +14 -0
  39. package/lib/download/helpers/untar.mjs +11 -0
  40. package/lib/download/helpers/unzip.d.ts +4 -0
  41. package/lib/download/helpers/unzip.js +18 -0
  42. package/lib/download/helpers/unzip.mjs +12 -0
  43. package/lib/download/npm/index.d.ts +27 -0
  44. package/lib/download/npm/index.js +73 -0
  45. package/lib/download/npm/index.mjs +63 -0
  46. package/lib/download/npm/types.d.ts +7 -0
  47. package/lib/download/npm/types.js +2 -0
  48. package/lib/download/npm/types.mjs +0 -0
  49. package/lib/download/npm/version.d.ts +13 -0
  50. package/lib/download/npm/version.js +27 -0
  51. package/lib/download/npm/version.mjs +20 -0
  52. package/lib/download/types/modified.d.ts +4 -0
  53. package/lib/download/types/modified.js +2 -0
  54. package/lib/download/types/modified.mjs +0 -0
  55. package/lib/export/directory.d.ts +2 -2
  56. package/lib/export/directory.js +2 -2
  57. package/lib/export/directory.mjs +2 -2
  58. package/lib/export/helpers/custom-files.d.ts +10 -0
  59. package/lib/export/helpers/custom-files.js +32 -0
  60. package/lib/export/helpers/custom-files.mjs +25 -0
  61. package/lib/export/{prepare.d.ts → helpers/prepare.d.ts} +4 -0
  62. package/lib/export/{prepare.js → helpers/prepare.js} +14 -5
  63. package/lib/export/{prepare.mjs → helpers/prepare.mjs} +9 -4
  64. package/lib/export/helpers/types-version.d.ts +4 -0
  65. package/lib/export/helpers/types-version.js +12 -0
  66. package/lib/export/helpers/types-version.mjs +40 -0
  67. package/lib/export/icon-package.d.ts +17 -0
  68. package/lib/export/icon-package.js +77 -0
  69. package/lib/export/icon-package.mjs +56 -0
  70. package/lib/export/json-package.d.ts +15 -0
  71. package/lib/export/json-package.js +151 -0
  72. package/lib/export/json-package.mjs +127 -0
  73. package/lib/icon-set/index.js +1 -2
  74. package/lib/icon-set/index.mjs +1 -1
  75. package/lib/import/figma/index.d.ts +5 -3
  76. package/lib/import/figma/index.js +0 -3
  77. package/lib/import/figma/query.d.ts +6 -4
  78. package/lib/import/figma/query.js +2 -5
  79. package/lib/import/figma/query.mjs +6 -2
  80. package/lib/import/figma/types/options.d.ts +4 -2
  81. package/lib/import/figma/types/result.d.ts +0 -4
  82. package/lib/index.d.ts +37 -0
  83. package/lib/index.js +89 -0
  84. package/lib/index.mjs +80 -0
  85. package/lib/misc/bump-version.d.ts +4 -0
  86. package/lib/misc/bump-version.js +19 -0
  87. package/lib/misc/bump-version.mjs +15 -0
  88. package/lib/misc/compare-dirs.d.ts +9 -0
  89. package/lib/misc/compare-dirs.js +84 -0
  90. package/lib/misc/compare-dirs.mjs +71 -0
  91. package/lib/misc/exec.d.ts +10 -0
  92. package/lib/misc/exec.js +26 -0
  93. package/lib/misc/exec.mjs +22 -0
  94. package/lib/misc/keyword.js +1 -1
  95. package/lib/misc/keyword.mjs +1 -1
  96. package/lib/misc/scan.d.ts +1 -1
  97. package/lib/misc/scan.js +14 -8
  98. package/lib/misc/scan.mjs +11 -6
  99. package/lib/misc/write-json.d.ts +4 -0
  100. package/lib/misc/write-json.js +11 -0
  101. package/lib/misc/write-json.mjs +8 -0
  102. package/lib/optimise/svgo.js +3 -1
  103. package/lib/optimise/svgo.mjs +2 -1
  104. package/lib/svg/index.d.ts +3 -0
  105. package/lib/svg/index.js +3 -0
  106. package/license.txt +21 -0
  107. package/package.json +138 -27
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.downloadGitHubRepo = void 0;
4
+ const fs_1 = require("fs");
5
+ const prepare_1 = require("../../export/helpers/prepare");
6
+ const hash_1 = require("./hash");
7
+ const download_1 = require("../api/download");
8
+ const unzip_1 = require("../helpers/unzip");
9
+ /**
10
+ * Find matching directories
11
+ */
12
+ async function findMatchingDirs(rootDir, hash) {
13
+ const matches = [];
14
+ const files = await fs_1.promises.readdir(rootDir);
15
+ for (let i = 0; i < files.length; i++) {
16
+ const file = files[i];
17
+ const lastChunk = file.split('-').pop();
18
+ if (lastChunk.length < 4 ||
19
+ lastChunk !== hash.slice(0, lastChunk.length)) {
20
+ continue;
21
+ }
22
+ const stat = await fs_1.promises.lstat(rootDir + '/' + file);
23
+ if (stat.isDirectory()) {
24
+ matches.push(file);
25
+ }
26
+ }
27
+ return matches;
28
+ }
29
+ async function downloadGitHubRepo(options) {
30
+ // Check for last commit
31
+ const hash = await (0, hash_1.getGitHubRepoHash)(options);
32
+ if (options.ifModifiedSince && hash === options.ifModifiedSince) {
33
+ return 'not_modified';
34
+ }
35
+ // Replace hash in target
36
+ options.target = options.target.replace('{hash}', hash);
37
+ // Prepare target directory
38
+ const rootDir = (options.target = await (0, prepare_1.prepareDirectoryForExport)(options));
39
+ // Archive name
40
+ const archiveTarget = rootDir + '/' + hash + '.zip';
41
+ // Check if archive exists
42
+ let exists = false;
43
+ try {
44
+ const stat = await fs_1.promises.lstat(archiveTarget);
45
+ exists = stat.isFile();
46
+ }
47
+ catch (err) {
48
+ //
49
+ }
50
+ // Download file
51
+ if (!exists) {
52
+ const uri = `https://api.github.com/repos/${options.user}/${options.repo}/zipball/${hash}`;
53
+ // const uri = `https://codeload.github.com/${options.user}/${options.repo}/zip/${hash}`;
54
+ await (0, download_1.downloadFile)({
55
+ uri,
56
+ headers: {
57
+ Accept: 'application/vnd.github.v3+json',
58
+ Authorization: 'token ' + options.token,
59
+ },
60
+ }, archiveTarget);
61
+ }
62
+ // Clean up old directories
63
+ const files = await fs_1.promises.readdir(rootDir);
64
+ const hashSearch = '-' + hash;
65
+ for (let i = 0; i < files.length; i++) {
66
+ const file = files[i];
67
+ if (file === hash + '.zip') {
68
+ continue;
69
+ }
70
+ const filename = rootDir + '/' + files[i];
71
+ const stat = await fs_1.promises.lstat(filename);
72
+ const isDir = stat.isDirectory();
73
+ if (
74
+ // Remove if directory matches hash to avoid errors extracting zip
75
+ (isDir && filename.slice(0 - hashSearch.length) === hashSearch) ||
76
+ // Remove if directory and cleanupOldDirectories is not disabled
77
+ (isDir && options.cleanupOldDirectories !== false) ||
78
+ // Remove if file and cleanupOldFiles is enabled
79
+ (!isDir && options.cleanupOldFiles)) {
80
+ try {
81
+ await fs_1.promises.rm(filename, {
82
+ force: true,
83
+ recursive: true,
84
+ });
85
+ }
86
+ catch (err) {
87
+ //
88
+ }
89
+ }
90
+ }
91
+ // Unpack it
92
+ await (0, unzip_1.unzip)(archiveTarget, rootDir);
93
+ // Get actual dir
94
+ const matchingDirs = await findMatchingDirs(rootDir, hash);
95
+ if (matchingDirs.length !== 1) {
96
+ throw new Error(`Error unpacking ${hash}.zip`);
97
+ }
98
+ const actualDir = rootDir + '/' + matchingDirs[0];
99
+ return {
100
+ rootDir,
101
+ actualDir,
102
+ hash,
103
+ };
104
+ }
105
+ exports.downloadGitHubRepo = downloadGitHubRepo;
@@ -0,0 +1,83 @@
1
+ // src/download/github/index.ts
2
+ import { promises as fs } from "fs";
3
+ import {
4
+ prepareDirectoryForExport
5
+ } from "../../export/helpers/prepare.mjs";
6
+ import { getGitHubRepoHash } from "./hash.mjs";
7
+ import { downloadFile } from "../api/download.mjs";
8
+ import { unzip } from "../helpers/unzip.mjs";
9
+ async function findMatchingDirs(rootDir, hash) {
10
+ const matches = [];
11
+ const files = await fs.readdir(rootDir);
12
+ for (let i = 0; i < files.length; i++) {
13
+ const file = files[i];
14
+ const lastChunk = file.split("-").pop();
15
+ if (lastChunk.length < 4 || lastChunk !== hash.slice(0, lastChunk.length)) {
16
+ continue;
17
+ }
18
+ const stat = await fs.lstat(rootDir + "/" + file);
19
+ if (stat.isDirectory()) {
20
+ matches.push(file);
21
+ }
22
+ }
23
+ return matches;
24
+ }
25
+ async function downloadGitHubRepo(options) {
26
+ const hash = await getGitHubRepoHash(options);
27
+ if (options.ifModifiedSince && hash === options.ifModifiedSince) {
28
+ return "not_modified";
29
+ }
30
+ options.target = options.target.replace("{hash}", hash);
31
+ const rootDir = options.target = await prepareDirectoryForExport(options);
32
+ const archiveTarget = rootDir + "/" + hash + ".zip";
33
+ let exists = false;
34
+ try {
35
+ const stat = await fs.lstat(archiveTarget);
36
+ exists = stat.isFile();
37
+ } catch (err) {
38
+ }
39
+ if (!exists) {
40
+ const uri = `https://api.github.com/repos/${options.user}/${options.repo}/zipball/${hash}`;
41
+ await downloadFile({
42
+ uri,
43
+ headers: {
44
+ Accept: "application/vnd.github.v3+json",
45
+ Authorization: "token " + options.token
46
+ }
47
+ }, archiveTarget);
48
+ }
49
+ const files = await fs.readdir(rootDir);
50
+ const hashSearch = "-" + hash;
51
+ for (let i = 0; i < files.length; i++) {
52
+ const file = files[i];
53
+ if (file === hash + ".zip") {
54
+ continue;
55
+ }
56
+ const filename = rootDir + "/" + files[i];
57
+ const stat = await fs.lstat(filename);
58
+ const isDir = stat.isDirectory();
59
+ if (isDir && filename.slice(0 - hashSearch.length) === hashSearch || isDir && options.cleanupOldDirectories !== false || !isDir && options.cleanupOldFiles) {
60
+ try {
61
+ await fs.rm(filename, {
62
+ force: true,
63
+ recursive: true
64
+ });
65
+ } catch (err) {
66
+ }
67
+ }
68
+ }
69
+ await unzip(archiveTarget, rootDir);
70
+ const matchingDirs = await findMatchingDirs(rootDir, hash);
71
+ if (matchingDirs.length !== 1) {
72
+ throw new Error(`Error unpacking ${hash}.zip`);
73
+ }
74
+ const actualDir = rootDir + "/" + matchingDirs[0];
75
+ return {
76
+ rootDir,
77
+ actualDir,
78
+ hash
79
+ };
80
+ }
81
+ export {
82
+ downloadGitHubRepo
83
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * API options
3
+ */
4
+ export interface GitHubAPIOptions {
5
+ token: string;
6
+ user: string;
7
+ repo: string;
8
+ branch: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Unpack .tgz archive
3
+ */
4
+ export declare function untar(file: string, path: string): Promise<void>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.untar = void 0;
4
+ const tar_1 = require("tar");
5
+ /**
6
+ * Unpack .tgz archive
7
+ */
8
+ async function untar(file, path) {
9
+ await (0, tar_1.x)({
10
+ file,
11
+ C: path,
12
+ });
13
+ }
14
+ exports.untar = untar;
@@ -0,0 +1,11 @@
1
+ // src/download/helpers/untar.ts
2
+ import { x } from "tar";
3
+ async function untar(file, path) {
4
+ await x({
5
+ file,
6
+ C: path
7
+ });
8
+ }
9
+ export {
10
+ untar
11
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Unzip archive
3
+ */
4
+ export declare function unzip(source: string, path: string): Promise<void>;
@@ -0,0 +1,18 @@
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.unzip = void 0;
7
+ const extract_zip_1 = __importDefault(require("extract-zip"));
8
+ const fs_1 = require("fs");
9
+ /**
10
+ * Unzip archive
11
+ */
12
+ async function unzip(source, path) {
13
+ const dir = await fs_1.promises.realpath(path);
14
+ await (0, extract_zip_1.default)(source, {
15
+ dir,
16
+ });
17
+ }
18
+ exports.unzip = unzip;
@@ -0,0 +1,12 @@
1
+ // src/download/helpers/unzip.ts
2
+ import extract from "extract-zip";
3
+ import { promises as fs } from "fs";
4
+ async function unzip(source, path) {
5
+ const dir = await fs.realpath(path);
6
+ await extract(source, {
7
+ dir
8
+ });
9
+ }
10
+ export {
11
+ unzip
12
+ };
@@ -0,0 +1,27 @@
1
+ import { ExportTargetOptions } from '../../export/helpers/prepare';
2
+ import type { DocumentNotModified } from '../types/modified';
3
+ interface IfModifiedSinceOption {
4
+ ifModifiedSince: string | true;
5
+ }
6
+ /**
7
+ * Options for downloadNPMPackage()
8
+ */
9
+ export interface DownloadNPMPackageOptions extends ExportTargetOptions, Partial<IfModifiedSinceOption> {
10
+ package: string;
11
+ tag?: string;
12
+ log?: boolean;
13
+ }
14
+ /**
15
+ * Result
16
+ */
17
+ export interface DownloadNPMPackageResult {
18
+ rootDir: string;
19
+ actualDir: string;
20
+ version: string;
21
+ }
22
+ /**
23
+ * Download NPM package
24
+ */
25
+ export declare function downloadNPMPackage<T extends IfModifiedSinceOption & DownloadNPMPackageOptions>(options: T): Promise<DownloadNPMPackageResult | DocumentNotModified>;
26
+ export declare function downloadNPMPackage(options: DownloadNPMPackageOptions): Promise<DownloadNPMPackageResult>;
27
+ export {};
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.downloadNPMPackage = void 0;
4
+ const fs_1 = require("fs");
5
+ const prepare_1 = require("../../export/helpers/prepare");
6
+ const download_1 = require("../api/download");
7
+ const untar_1 = require("../helpers/untar");
8
+ const version_1 = require("./version");
9
+ async function downloadNPMPackage(options) {
10
+ const rootDir = (options.target = (0, prepare_1.normalizeDir)(options.target));
11
+ const actualDir = rootDir + '/package';
12
+ // Get latest location
13
+ const versionInfo = await (0, version_1.getNPMVersion)(options);
14
+ const version = versionInfo.version;
15
+ // Check downloaded copy
16
+ if (options.ifModifiedSince) {
17
+ try {
18
+ const expectedVersion = options.ifModifiedSince === true
19
+ ? await (0, version_1.getPackageVersion)(actualDir)
20
+ : options.ifModifiedSince;
21
+ if (version === expectedVersion) {
22
+ return 'not_modified';
23
+ }
24
+ }
25
+ catch (err) {
26
+ //
27
+ }
28
+ }
29
+ const archiveURL = versionInfo.file;
30
+ if (!archiveURL) {
31
+ throw new Error(`NPM registry did not provide link to package archive.`);
32
+ }
33
+ const archiveTarget = rootDir + '/' + version + '.tgz';
34
+ // Prepare target directory
35
+ await (0, prepare_1.prepareDirectoryForExport)(options);
36
+ // Check if archive exists
37
+ let archiveExists = false;
38
+ try {
39
+ const stat = await fs_1.promises.lstat(archiveTarget);
40
+ archiveExists = stat.isFile();
41
+ }
42
+ catch (err) {
43
+ //
44
+ }
45
+ // Download file
46
+ if (!archiveExists) {
47
+ if (options.log) {
48
+ console.log(`Downloading ${archiveURL}`);
49
+ }
50
+ await (0, download_1.downloadFile)({
51
+ uri: archiveURL,
52
+ headers: {
53
+ Accept: 'application/tar+gzip',
54
+ },
55
+ }, archiveTarget);
56
+ }
57
+ // Remove old unpacked file
58
+ await (0, prepare_1.prepareDirectoryForExport)({
59
+ target: actualDir,
60
+ cleanup: true,
61
+ });
62
+ // Unpack file
63
+ if (options.log) {
64
+ console.log(`Unpacking ${archiveTarget}`);
65
+ }
66
+ await (0, untar_1.untar)(archiveTarget, rootDir);
67
+ return {
68
+ rootDir,
69
+ actualDir,
70
+ version,
71
+ };
72
+ }
73
+ exports.downloadNPMPackage = downloadNPMPackage;
@@ -0,0 +1,63 @@
1
+ // src/download/npm/index.ts
2
+ import { promises as fs } from "fs";
3
+ import {
4
+ normalizeDir,
5
+ prepareDirectoryForExport
6
+ } from "../../export/helpers/prepare.mjs";
7
+ import { downloadFile } from "../api/download.mjs";
8
+ import { untar } from "../helpers/untar.mjs";
9
+ import { getNPMVersion, getPackageVersion } from "./version.mjs";
10
+ async function downloadNPMPackage(options) {
11
+ const rootDir = options.target = normalizeDir(options.target);
12
+ const actualDir = rootDir + "/package";
13
+ const versionInfo = await getNPMVersion(options);
14
+ const version = versionInfo.version;
15
+ if (options.ifModifiedSince) {
16
+ try {
17
+ const expectedVersion = options.ifModifiedSince === true ? await getPackageVersion(actualDir) : options.ifModifiedSince;
18
+ if (version === expectedVersion) {
19
+ return "not_modified";
20
+ }
21
+ } catch (err) {
22
+ }
23
+ }
24
+ const archiveURL = versionInfo.file;
25
+ if (!archiveURL) {
26
+ throw new Error(`NPM registry did not provide link to package archive.`);
27
+ }
28
+ const archiveTarget = rootDir + "/" + version + ".tgz";
29
+ await prepareDirectoryForExport(options);
30
+ let archiveExists = false;
31
+ try {
32
+ const stat = await fs.lstat(archiveTarget);
33
+ archiveExists = stat.isFile();
34
+ } catch (err) {
35
+ }
36
+ if (!archiveExists) {
37
+ if (options.log) {
38
+ console.log(`Downloading ${archiveURL}`);
39
+ }
40
+ await downloadFile({
41
+ uri: archiveURL,
42
+ headers: {
43
+ Accept: "application/tar+gzip"
44
+ }
45
+ }, archiveTarget);
46
+ }
47
+ await prepareDirectoryForExport({
48
+ target: actualDir,
49
+ cleanup: true
50
+ });
51
+ if (options.log) {
52
+ console.log(`Unpacking ${archiveTarget}`);
53
+ }
54
+ await untar(archiveTarget, rootDir);
55
+ return {
56
+ rootDir,
57
+ actualDir,
58
+ version
59
+ };
60
+ }
61
+ export {
62
+ downloadNPMPackage
63
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Package options
3
+ */
4
+ export interface NPMPackageOptions {
5
+ package: string;
6
+ tag?: string;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -0,0 +1,13 @@
1
+ import type { NPMPackageOptions } from './types';
2
+ export interface GetNPMVersionResult {
3
+ version: string;
4
+ file?: string;
5
+ }
6
+ /**
7
+ * Get version of package from NPM registry
8
+ */
9
+ export declare function getNPMVersion(options: NPMPackageOptions): Promise<GetNPMVersionResult>;
10
+ /**
11
+ * Get version of package from filename
12
+ */
13
+ export declare function getPackageVersion(target: string): Promise<string>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPackageVersion = exports.getNPMVersion = void 0;
4
+ const fs_1 = require("fs");
5
+ const exec_1 = require("../../misc/exec");
6
+ /**
7
+ * Get version of package from NPM registry
8
+ */
9
+ async function getNPMVersion(options) {
10
+ var _a;
11
+ const tag = options.tag || 'latest';
12
+ const result = await (0, exec_1.execAsync)(`npm view ${options.package}@${tag} --json`);
13
+ const data = JSON.parse(result.stdout);
14
+ return {
15
+ version: data.version,
16
+ file: (_a = data.dist) === null || _a === void 0 ? void 0 : _a.tarball,
17
+ };
18
+ }
19
+ exports.getNPMVersion = getNPMVersion;
20
+ /**
21
+ * Get version of package from filename
22
+ */
23
+ async function getPackageVersion(target) {
24
+ return JSON.parse(await fs_1.promises.readFile(target + '/package.json', 'utf8'))
25
+ .version;
26
+ }
27
+ exports.getPackageVersion = getPackageVersion;
@@ -0,0 +1,20 @@
1
+ // src/download/npm/version.ts
2
+ import { promises as fs } from "fs";
3
+ import { execAsync } from "../../misc/exec.mjs";
4
+ async function getNPMVersion(options) {
5
+ var _a;
6
+ const tag = options.tag || "latest";
7
+ const result = await execAsync(`npm view ${options.package}@${tag} --json`);
8
+ const data = JSON.parse(result.stdout);
9
+ return {
10
+ version: data.version,
11
+ file: (_a = data.dist) == null ? void 0 : _a.tarball
12
+ };
13
+ }
14
+ async function getPackageVersion(target) {
15
+ return JSON.parse(await fs.readFile(target + "/package.json", "utf8")).version;
16
+ }
17
+ export {
18
+ getNPMVersion,
19
+ getPackageVersion
20
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Document wasn't modified
3
+ */
4
+ export declare type DocumentNotModified = 'not_modified';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -1,5 +1,5 @@
1
1
  import type { IconSet } from '../icon-set';
2
- import type { ExportTargetOptions } from './prepare';
2
+ import type { ExportTargetOptions } from './helpers/prepare';
3
3
  /**
4
4
  * Options
5
5
  */
@@ -14,4 +14,4 @@ export interface ExportToDirectoryOptions extends ExportTargetOptions {
14
14
  *
15
15
  * Returns list of stored files
16
16
  */
17
- export declare function exportToDirectory(iconSet: IconSet, options: ExportToDirectoryOptions): Promise<Set<string>>;
17
+ export declare function exportToDirectory(iconSet: IconSet, options: ExportToDirectoryOptions): Promise<string[]>;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.exportToDirectory = void 0;
4
4
  const fs_1 = require("fs");
5
- const prepare_1 = require("./prepare");
5
+ const prepare_1 = require("./helpers/prepare");
6
6
  /**
7
7
  * Export icon set to directory
8
8
  *
@@ -47,6 +47,6 @@ async function exportToDirectory(iconSet, options) {
47
47
  }
48
48
  await store(name, `${dir}/${name}.svg`);
49
49
  });
50
- return storedFiles;
50
+ return Array.from(storedFiles);
51
51
  }
52
52
  exports.exportToDirectory = exportToDirectory;
@@ -1,6 +1,6 @@
1
1
  // src/export/directory.ts
2
2
  import { promises as fs } from "fs";
3
- import { prepareDirectoryForExport } from "./prepare.mjs";
3
+ import { prepareDirectoryForExport } from "./helpers/prepare.mjs";
4
4
  async function exportToDirectory(iconSet, options) {
5
5
  const dir = await prepareDirectoryForExport(options);
6
6
  const storedFiles = new Set();
@@ -34,7 +34,7 @@ async function exportToDirectory(iconSet, options) {
34
34
  }
35
35
  await store(name, `${dir}/${name}.svg`);
36
36
  });
37
- return storedFiles;
37
+ return Array.from(storedFiles);
38
38
  }
39
39
  export {
40
40
  exportToDirectory
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Options
3
+ */
4
+ export interface ExportOptionsWithCustomFiles {
5
+ customFiles?: Record<string, string | Record<string, unknown> | null>;
6
+ }
7
+ /**
8
+ * Write custom files
9
+ */
10
+ export declare function exportCustomFiles(dir: string, options: ExportOptionsWithCustomFiles, result?: Set<string>): Promise<void>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exportCustomFiles = void 0;
4
+ const fs_1 = require("fs");
5
+ const write_json_1 = require("../../misc/write-json");
6
+ /**
7
+ * Write custom files
8
+ */
9
+ async function exportCustomFiles(dir, options, result) {
10
+ const customFiles = options.customFiles || {};
11
+ for (const filename in customFiles) {
12
+ const content = customFiles[filename];
13
+ if (content === null) {
14
+ // Delete file, if exists
15
+ try {
16
+ await fs_1.promises.unlink(dir + '/' + filename);
17
+ }
18
+ catch (err) {
19
+ //
20
+ }
21
+ continue;
22
+ }
23
+ if (typeof content === 'string') {
24
+ await fs_1.promises.writeFile(dir + '/' + filename, content, 'utf8');
25
+ }
26
+ else if (typeof content === 'object') {
27
+ await (0, write_json_1.writeJSONFile)(dir + '/' + filename, content);
28
+ }
29
+ result === null || result === void 0 ? void 0 : result.add(filename);
30
+ }
31
+ }
32
+ exports.exportCustomFiles = exportCustomFiles;
@@ -0,0 +1,25 @@
1
+ // src/export/helpers/custom-files.ts
2
+ import { promises as fs } from "fs";
3
+ import { writeJSONFile } from "../../misc/write-json.mjs";
4
+ async function exportCustomFiles(dir, options, result) {
5
+ const customFiles = options.customFiles || {};
6
+ for (const filename in customFiles) {
7
+ const content = customFiles[filename];
8
+ if (content === null) {
9
+ try {
10
+ await fs.unlink(dir + "/" + filename);
11
+ } catch (err) {
12
+ }
13
+ continue;
14
+ }
15
+ if (typeof content === "string") {
16
+ await fs.writeFile(dir + "/" + filename, content, "utf8");
17
+ } else if (typeof content === "object") {
18
+ await writeJSONFile(dir + "/" + filename, content);
19
+ }
20
+ result == null ? void 0 : result.add(filename);
21
+ }
22
+ }
23
+ export {
24
+ exportCustomFiles
25
+ };
@@ -5,6 +5,10 @@ export interface ExportTargetOptions {
5
5
  target: string;
6
6
  cleanup?: boolean;
7
7
  }
8
+ /**
9
+ * Normalize directory
10
+ */
11
+ export declare function normalizeDir(dir: string): string;
8
12
  /**
9
13
  * Prepare directory for export
10
14
  *