@iconify/tools 2.0.14 → 2.0.15
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/lib/colors/attribs.cjs +30 -0
- package/lib/colors/attribs.d.ts +13 -10
- package/lib/colors/attribs.mjs +7 -13
- package/lib/colors/parse.cjs +269 -0
- package/lib/colors/parse.d.ts +15 -11
- package/lib/colors/parse.mjs +27 -31
- package/lib/colors/validate.cjs +52 -0
- package/lib/colors/validate.d.ts +11 -4
- package/lib/colors/validate.mjs +19 -6
- package/lib/css/parse.cjs +26 -0
- package/lib/css/parse.d.ts +3 -1
- package/lib/css/parse.mjs +8 -6
- package/lib/css/parser/error.cjs +25 -0
- package/lib/css/parser/error.d.ts +4 -2
- package/lib/css/parser/error.mjs +2 -4
- package/lib/css/parser/export.cjs +48 -0
- package/lib/css/parser/export.d.ts +5 -2
- package/lib/css/parser/export.mjs +4 -6
- package/lib/css/parser/strings.cjs +77 -0
- package/lib/css/parser/strings.d.ts +6 -3
- package/lib/css/parser/strings.mjs +4 -6
- package/lib/css/parser/text.cjs +135 -0
- package/lib/css/parser/text.d.ts +8 -5
- package/lib/css/parser/text.mjs +3 -8
- package/lib/css/parser/tokens.cjs +184 -0
- package/lib/css/parser/tokens.d.ts +6 -3
- package/lib/css/parser/tokens.mjs +7 -13
- package/lib/css/parser/tree.cjs +42 -0
- package/lib/css/parser/tree.d.ts +5 -2
- package/lib/css/parser/tree.mjs +2 -4
- package/lib/css/parser/types.cjs +2 -0
- package/lib/css/parser/types.d.ts +13 -11
- package/lib/css/parser/types.mjs +1 -0
- package/lib/download/api/cache.cjs +86 -0
- package/lib/download/api/cache.d.ts +8 -5
- package/lib/download/api/cache.mjs +14 -19
- package/lib/download/api/download.cjs +28 -0
- package/lib/download/api/download.d.ts +5 -2
- package/lib/download/api/download.mjs +8 -9
- package/lib/download/api/index.cjs +51 -0
- package/lib/download/api/index.d.ts +5 -2
- package/lib/download/api/index.mjs +8 -6
- package/lib/download/api/types.cjs +2 -0
- package/lib/download/api/types.d.ts +4 -2
- package/lib/download/api/types.mjs +1 -0
- package/lib/download/git/branch.cjs +22 -0
- package/lib/download/git/branch.d.ts +5 -2
- package/lib/download/git/branch.mjs +5 -5
- package/lib/download/git/hash.cjs +15 -0
- package/lib/download/git/hash.d.ts +5 -2
- package/lib/download/git/hash.mjs +5 -5
- package/lib/download/git/index.cjs +76 -0
- package/lib/download/git/index.d.ts +10 -8
- package/lib/download/git/index.mjs +41 -26
- package/lib/download/git/reset.cjs +41 -0
- package/lib/download/git/reset.d.ts +3 -1
- package/lib/download/git/reset.mjs +29 -5
- package/lib/download/github/hash.cjs +32 -0
- package/lib/download/github/hash.d.ts +5 -2
- package/lib/download/github/hash.mjs +10 -7
- package/lib/download/github/index.cjs +98 -0
- package/lib/download/github/index.d.ts +11 -9
- package/lib/download/github/index.mjs +23 -17
- package/lib/download/github/types.cjs +2 -0
- package/lib/download/github/types.d.ts +3 -1
- package/lib/download/github/types.mjs +1 -0
- package/lib/download/gitlab/hash.cjs +32 -0
- package/lib/download/gitlab/hash.d.ts +5 -2
- package/lib/download/gitlab/hash.mjs +10 -6
- package/lib/download/gitlab/index.cjs +98 -0
- package/lib/download/gitlab/index.d.ts +11 -9
- package/lib/download/gitlab/index.mjs +24 -18
- package/lib/download/gitlab/types.cjs +7 -0
- package/lib/download/gitlab/types.d.ts +4 -2
- package/lib/download/gitlab/types.mjs +3 -5
- package/lib/download/helpers/untar.cjs +14 -0
- package/lib/download/helpers/untar.d.ts +3 -1
- package/lib/download/helpers/untar.mjs +4 -5
- package/lib/download/helpers/unzip.cjs +19 -0
- package/lib/download/helpers/unzip.d.ts +3 -1
- package/lib/download/helpers/unzip.mjs +6 -7
- package/lib/download/index.cjs +64 -0
- package/lib/download/index.d.ts +18 -13
- package/lib/download/index.mjs +46 -19
- package/lib/download/npm/index.cjs +82 -0
- package/lib/download/npm/index.d.ts +10 -8
- package/lib/download/npm/index.mjs +16 -13
- package/lib/download/npm/types.cjs +2 -0
- package/lib/download/npm/types.d.ts +3 -1
- package/lib/download/npm/types.mjs +1 -0
- package/lib/download/npm/version.cjs +23 -0
- package/lib/download/npm/version.d.ts +7 -4
- package/lib/download/npm/version.mjs +8 -10
- package/lib/download/types/modified.cjs +2 -0
- package/lib/download/types/modified.d.ts +3 -1
- package/lib/download/types/modified.mjs +1 -0
- package/lib/download/types/sources.cjs +2 -0
- package/lib/download/types/sources.d.ts +4 -2
- package/lib/download/types/sources.mjs +1 -0
- package/lib/export/directory.cjs +45 -0
- package/lib/export/directory.d.ts +11 -4
- package/lib/export/directory.mjs +8 -8
- package/lib/export/helpers/custom-files.cjs +28 -0
- package/lib/export/helpers/custom-files.d.ts +4 -2
- package/lib/export/helpers/custom-files.mjs +8 -9
- package/lib/export/helpers/prepare.cjs +36 -0
- package/lib/export/helpers/prepare.d.ts +5 -3
- package/lib/export/helpers/prepare.mjs +7 -9
- package/lib/export/helpers/types-version.cjs +22 -0
- package/lib/export/helpers/types-version.d.ts +3 -1
- package/lib/export/helpers/types-version.mjs +15 -37
- package/lib/export/icon-package.cjs +59 -0
- package/lib/export/icon-package.d.ts +12 -5
- package/lib/export/icon-package.mjs +15 -16
- package/lib/export/json-package.cjs +133 -0
- package/lib/export/json-package.d.ts +12 -5
- package/lib/export/json-package.mjs +20 -21
- package/lib/icon-set/index.cjs +589 -0
- package/lib/icon-set/index.d.ts +9 -6
- package/lib/icon-set/index.mjs +40 -53
- package/lib/icon-set/match.cjs +58 -0
- package/lib/icon-set/match.d.ts +10 -3
- package/lib/icon-set/match.mjs +5 -6
- package/lib/icon-set/merge.cjs +83 -0
- package/lib/icon-set/merge.d.ts +9 -2
- package/lib/icon-set/merge.mjs +15 -10
- package/lib/icon-set/props.cjs +28 -0
- package/lib/icon-set/props.d.ts +8 -4
- package/lib/icon-set/props.mjs +7 -10
- package/lib/icon-set/types.cjs +2 -0
- package/lib/icon-set/types.d.ts +19 -17
- package/lib/icon-set/types.mjs +1 -0
- package/lib/import/directory.cjs +76 -0
- package/lib/import/directory.d.ts +11 -5
- package/lib/import/directory.mjs +36 -11
- package/lib/import/figma/index.cjs +105 -0
- package/lib/import/figma/index.d.ts +15 -5
- package/lib/import/figma/index.mjs +40 -13
- package/lib/import/figma/nodes.cjs +86 -0
- package/lib/import/figma/nodes.d.ts +13 -4
- package/lib/import/figma/nodes.mjs +3 -11
- package/lib/import/figma/query.cjs +218 -0
- package/lib/import/figma/query.d.ts +18 -9
- package/lib/import/figma/query.mjs +9 -12
- package/lib/import/figma/types/api.cjs +2 -0
- package/lib/import/figma/types/api.d.ts +8 -7
- package/lib/import/figma/types/api.mjs +1 -0
- package/lib/import/figma/types/nodes.cjs +2 -0
- package/lib/import/figma/types/nodes.d.ts +16 -9
- package/lib/import/figma/types/nodes.mjs +1 -0
- package/lib/import/figma/types/options.cjs +2 -0
- package/lib/import/figma/types/options.d.ts +17 -10
- package/lib/import/figma/types/options.mjs +1 -0
- package/lib/import/figma/types/result.cjs +2 -0
- package/lib/import/figma/types/result.d.ts +12 -5
- package/lib/import/figma/types/result.mjs +1 -0
- package/lib/index.cjs +137 -0
- package/lib/index.d.ts +65 -44
- package/lib/index.mjs +83 -94
- package/lib/misc/bump-version.cjs +17 -0
- package/lib/misc/bump-version.d.ts +3 -1
- package/lib/misc/bump-version.mjs +2 -4
- package/lib/misc/compare-dirs.cjs +75 -0
- package/lib/misc/compare-dirs.d.ts +4 -2
- package/lib/misc/compare-dirs.mjs +12 -12
- package/lib/misc/exec.cjs +25 -0
- package/lib/misc/exec.d.ts +6 -4
- package/lib/misc/exec.mjs +4 -5
- package/lib/misc/keyword.cjs +19 -0
- package/lib/misc/keyword.d.ts +3 -1
- package/lib/misc/keyword.mjs +2 -4
- package/lib/misc/scan.cjs +51 -0
- package/lib/misc/scan.d.ts +7 -6
- package/lib/misc/scan.mjs +6 -7
- package/lib/misc/write-json.cjs +11 -0
- package/lib/misc/write-json.d.ts +3 -1
- package/lib/misc/write-json.mjs +5 -6
- package/lib/optimise/flags.cjs +252 -0
- package/lib/optimise/flags.d.ts +7 -2
- package/lib/optimise/flags.mjs +18 -19
- package/lib/optimise/global-style.cjs +154 -0
- package/lib/optimise/global-style.d.ts +7 -2
- package/lib/optimise/global-style.mjs +18 -15
- package/lib/optimise/scale.cjs +26 -0
- package/lib/optimise/scale.d.ts +7 -2
- package/lib/optimise/scale.mjs +5 -5
- package/lib/optimise/svgo.cjs +83 -0
- package/lib/optimise/svgo.d.ts +10 -6
- package/lib/optimise/svgo.mjs +6 -9
- package/lib/svg/analyse/error.cjs +18 -0
- package/lib/svg/analyse/error.d.ts +5 -2
- package/lib/svg/analyse/error.mjs +2 -4
- package/lib/svg/analyse/types.cjs +2 -0
- package/lib/svg/analyse/types.d.ts +11 -11
- package/lib/svg/analyse/types.mjs +1 -0
- package/lib/svg/analyse.cjs +291 -0
- package/lib/svg/analyse.d.ts +8 -3
- package/lib/svg/analyse.mjs +15 -30
- package/lib/svg/cleanup/attribs.cjs +41 -0
- package/lib/svg/cleanup/attribs.d.ts +7 -2
- package/lib/svg/cleanup/attribs.mjs +6 -12
- package/lib/svg/cleanup/bad-tags.cjs +51 -0
- package/lib/svg/cleanup/bad-tags.d.ts +7 -2
- package/lib/svg/cleanup/bad-tags.mjs +10 -25
- package/lib/svg/cleanup/inline-style.cjs +64 -0
- package/lib/svg/cleanup/inline-style.d.ts +7 -2
- package/lib/svg/cleanup/inline-style.mjs +14 -19
- package/lib/svg/cleanup/root-svg.cjs +81 -0
- package/lib/svg/cleanup/root-svg.d.ts +7 -2
- package/lib/svg/cleanup/root-svg.mjs +7 -18
- package/lib/svg/cleanup/svgo-style.cjs +38 -0
- package/lib/svg/cleanup/svgo-style.d.ts +7 -2
- package/lib/svg/cleanup/svgo-style.mjs +16 -11
- package/lib/svg/cleanup.cjs +32 -0
- package/lib/svg/cleanup.d.ts +7 -2
- package/lib/svg/cleanup.mjs +21 -9
- package/lib/svg/data/attributes.cjs +355 -0
- package/lib/svg/data/attributes.d.ts +27 -25
- package/lib/svg/data/attributes.mjs +90 -115
- package/lib/svg/data/tags.cjs +137 -0
- package/lib/svg/data/tags.d.ts +25 -23
- package/lib/svg/data/tags.mjs +25 -49
- package/lib/svg/index.cjs +130 -0
- package/lib/svg/index.d.ts +16 -5
- package/lib/svg/index.mjs +48 -14
- package/lib/svg/parse-style.cjs +134 -0
- package/lib/svg/parse-style.d.ts +12 -8
- package/lib/svg/parse-style.mjs +11 -9
- package/lib/svg/parse.cjs +42 -0
- package/lib/svg/parse.d.ts +11 -7
- package/lib/svg/parse.mjs +2 -4
- package/package.json +99 -94
- package/lib/colors/attribs.js +0 -26
- package/lib/colors/parse.js +0 -341
- package/lib/colors/validate.js +0 -48
- package/lib/css/parse.js +0 -23
- package/lib/css/parser/error.js +0 -27
- package/lib/css/parser/export.js +0 -69
- package/lib/css/parser/strings.js +0 -93
- package/lib/css/parser/text.js +0 -171
- package/lib/css/parser/tokens.js +0 -200
- package/lib/css/parser/tree.js +0 -44
- package/lib/css/parser/types.js +0 -2
- package/lib/download/api/cache.js +0 -108
- package/lib/download/api/download.js +0 -27
- package/lib/download/api/index.js +0 -52
- package/lib/download/api/types.js +0 -2
- package/lib/download/git/branch.js +0 -22
- package/lib/download/git/hash.js +0 -14
- package/lib/download/git/index.js +0 -75
- package/lib/download/git/reset.js +0 -16
- package/lib/download/github/hash.js +0 -28
- package/lib/download/github/index.js +0 -116
- package/lib/download/github/types.js +0 -2
- package/lib/download/gitlab/hash.js +0 -27
- package/lib/download/gitlab/index.js +0 -115
- package/lib/download/gitlab/types.js +0 -7
- package/lib/download/helpers/untar.js +0 -14
- package/lib/download/helpers/unzip.js +0 -18
- package/lib/download/index.js +0 -27
- package/lib/download/npm/index.js +0 -91
- package/lib/download/npm/types.js +0 -2
- package/lib/download/npm/version.js +0 -27
- package/lib/download/types/modified.js +0 -2
- package/lib/download/types/sources.js +0 -2
- package/lib/export/directory.js +0 -52
- package/lib/export/helpers/custom-files.js +0 -32
- package/lib/export/helpers/prepare.js +0 -49
- package/lib/export/helpers/types-version.js +0 -12
- package/lib/export/icon-package.js +0 -77
- package/lib/export/json-package.js +0 -156
- package/lib/icon-set/index.js +0 -749
- package/lib/icon-set/match.js +0 -66
- package/lib/icon-set/merge.js +0 -90
- package/lib/icon-set/props.js +0 -34
- package/lib/icon-set/types.js +0 -2
- package/lib/import/directory.js +0 -59
- package/lib/import/figma/index.js +0 -90
- package/lib/import/figma/nodes.js +0 -106
- package/lib/import/figma/query.js +0 -244
- package/lib/import/figma/types/api.js +0 -12
- package/lib/import/figma/types/nodes.js +0 -2
- package/lib/import/figma/types/options.js +0 -2
- package/lib/import/figma/types/result.js +0 -2
- package/lib/index.js +0 -103
- package/lib/misc/bump-version.js +0 -19
- package/lib/misc/compare-dirs.js +0 -84
- package/lib/misc/exec.js +0 -26
- package/lib/misc/keyword.js +0 -31
- package/lib/misc/scan.js +0 -55
- package/lib/misc/write-json.js +0 -11
- package/lib/optimise/flags.js +0 -312
- package/lib/optimise/global-style.js +0 -185
- package/lib/optimise/scale.js +0 -42
- package/lib/optimise/svgo.js +0 -99
- package/lib/svg/analyse/error.js +0 -22
- package/lib/svg/analyse/types.js +0 -2
- package/lib/svg/analyse.js +0 -352
- package/lib/svg/cleanup/attribs.js +0 -51
- package/lib/svg/cleanup/bad-tags.js +0 -65
- package/lib/svg/cleanup/inline-style.js +0 -77
- package/lib/svg/cleanup/root-svg.js +0 -107
- package/lib/svg/cleanup/svgo-style.js +0 -35
- package/lib/svg/cleanup.js +0 -24
- package/lib/svg/data/attributes.js +0 -403
- package/lib/svg/data/tags.js +0 -188
- package/lib/svg/index.js +0 -134
- package/lib/svg/parse-style.js +0 -151
- package/lib/svg/parse.js +0 -49
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ExportTargetOptions } from '../../export/helpers/prepare';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { ExportTargetOptions } from '../../export/helpers/prepare.js';
|
|
2
|
+
import { DocumentNotModified } from '../types/modified.js';
|
|
3
|
+
import { DownloadSourceMixin } from '../types/sources.js';
|
|
4
|
+
|
|
4
5
|
interface IfModifiedSinceOption {
|
|
5
6
|
ifModifiedSince: string | true | DownloadNPMPackageResult;
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Options for downloadNPMPackage()
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
interface DownloadNPMPackageOptions extends ExportTargetOptions, Partial<IfModifiedSinceOption> {
|
|
11
12
|
package: string;
|
|
12
13
|
tag?: string;
|
|
13
14
|
log?: boolean;
|
|
@@ -15,7 +16,7 @@ export interface DownloadNPMPackageOptions extends ExportTargetOptions, Partial<
|
|
|
15
16
|
/**
|
|
16
17
|
* Result
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
interface DownloadNPMPackageResult extends DownloadSourceMixin<'npm'> {
|
|
19
20
|
rootDir: string;
|
|
20
21
|
contentsDir: string;
|
|
21
22
|
version: string;
|
|
@@ -23,6 +24,7 @@ export interface DownloadNPMPackageResult extends DownloadSourceMixin<'npm'> {
|
|
|
23
24
|
/**
|
|
24
25
|
* Download NPM package
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
declare function downloadNPMPackage<T extends IfModifiedSinceOption & DownloadNPMPackageOptions>(options: T): Promise<DownloadNPMPackageResult | DocumentNotModified>;
|
|
28
|
+
declare function downloadNPMPackage(options: DownloadNPMPackageOptions): Promise<DownloadNPMPackageResult>;
|
|
29
|
+
|
|
30
|
+
export { DownloadNPMPackageOptions, DownloadNPMPackageResult, downloadNPMPackage };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { normalizeDir, prepareDirectoryForExport } from '../../export/helpers/prepare.mjs';
|
|
3
|
+
import { downloadFile } from '../api/download.mjs';
|
|
4
|
+
import { untar } from '../helpers/untar.mjs';
|
|
5
|
+
import { getNPMVersion, getPackageVersion } from './version.mjs';
|
|
6
|
+
import 'pathe';
|
|
7
|
+
import 'node-fetch';
|
|
8
|
+
import 'util';
|
|
9
|
+
import 'stream';
|
|
10
|
+
import 'tar';
|
|
11
|
+
import '../../misc/exec.mjs';
|
|
12
|
+
import 'child_process';
|
|
13
|
+
|
|
10
14
|
async function downloadNPMPackage(options) {
|
|
11
15
|
const rootDir = options.target = normalizeDir(options.target);
|
|
12
16
|
const contentsDir = rootDir + "/package";
|
|
@@ -40,7 +44,7 @@ async function downloadNPMPackage(options) {
|
|
|
40
44
|
await prepareDirectoryForExport(options);
|
|
41
45
|
let archiveExists = false;
|
|
42
46
|
try {
|
|
43
|
-
const stat = await
|
|
47
|
+
const stat = await promises.stat(archiveTarget);
|
|
44
48
|
archiveExists = stat.isFile();
|
|
45
49
|
} catch (err) {
|
|
46
50
|
}
|
|
@@ -70,6 +74,5 @@ async function downloadNPMPackage(options) {
|
|
|
70
74
|
version
|
|
71
75
|
};
|
|
72
76
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
77
|
+
|
|
78
|
+
export { downloadNPMPackage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const misc_exec = require('../../misc/exec.cjs');
|
|
7
|
+
require('child_process');
|
|
8
|
+
|
|
9
|
+
async function getNPMVersion(options) {
|
|
10
|
+
const tag = options.tag || "latest";
|
|
11
|
+
const result = await misc_exec.execAsync(`npm view ${options.package}@${tag} --json`);
|
|
12
|
+
const data = JSON.parse(result.stdout);
|
|
13
|
+
return {
|
|
14
|
+
version: data.version,
|
|
15
|
+
file: data.dist?.tarball
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async function getPackageVersion(target) {
|
|
19
|
+
return JSON.parse(await fs.promises.readFile(target + "/package.json", "utf8")).version;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.getNPMVersion = getNPMVersion;
|
|
23
|
+
exports.getPackageVersion = getPackageVersion;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { NPMPackageOptions } from './types.js';
|
|
2
|
+
|
|
3
|
+
interface GetNPMVersionResult {
|
|
3
4
|
version: string;
|
|
4
5
|
file?: string;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* Get version of package from NPM registry
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
declare function getNPMVersion(options: NPMPackageOptions): Promise<GetNPMVersionResult>;
|
|
10
11
|
/**
|
|
11
12
|
* Get version of package from filename
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
declare function getPackageVersion(target: string): Promise<string>;
|
|
15
|
+
|
|
16
|
+
export { GetNPMVersionResult, getNPMVersion, getPackageVersion };
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { execAsync } from '../../misc/exec.mjs';
|
|
3
|
+
import 'child_process';
|
|
4
|
+
|
|
4
5
|
async function getNPMVersion(options) {
|
|
5
|
-
var _a;
|
|
6
6
|
const tag = options.tag || "latest";
|
|
7
7
|
const result = await execAsync(`npm view ${options.package}@${tag} --json`);
|
|
8
8
|
const data = JSON.parse(result.stdout);
|
|
9
9
|
return {
|
|
10
10
|
version: data.version,
|
|
11
|
-
file:
|
|
11
|
+
file: data.dist?.tarball
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
async function getPackageVersion(target) {
|
|
15
|
-
return JSON.parse(await
|
|
15
|
+
return JSON.parse(await promises.readFile(target + "/package.json", "utf8")).version;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
getPackageVersion
|
|
20
|
-
};
|
|
17
|
+
|
|
18
|
+
export { getNPMVersion, getPackageVersion };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Download types
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
declare type DownloadSourceType = 'git' | 'github' | 'gitlab' | 'npm';
|
|
5
5
|
/**
|
|
6
6
|
* Type in other objects
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
interface DownloadSourceMixin<T extends DownloadSourceType> {
|
|
9
9
|
downloadType: T;
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
export { DownloadSourceMixin, DownloadSourceType };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const export_helpers_prepare = require('./helpers/prepare.cjs');
|
|
7
|
+
require('pathe');
|
|
8
|
+
|
|
9
|
+
async function exportToDirectory(iconSet, options) {
|
|
10
|
+
const dir = await export_helpers_prepare.prepareDirectoryForExport(options);
|
|
11
|
+
const storedFiles = /* @__PURE__ */ new Set();
|
|
12
|
+
const customisations = options.autoHeight === false ? {
|
|
13
|
+
height: "1em"
|
|
14
|
+
} : {
|
|
15
|
+
width: "auto",
|
|
16
|
+
height: "auto"
|
|
17
|
+
};
|
|
18
|
+
const store = async (name, target) => {
|
|
19
|
+
const svg = iconSet.toString(name, customisations);
|
|
20
|
+
if (!svg) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
await fs.promises.writeFile(target, svg, "utf8");
|
|
24
|
+
storedFiles.add(target);
|
|
25
|
+
if (options.log) {
|
|
26
|
+
console.log(`Saved ${target} (${svg.length} bytes)`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
if (options.includeChars) {
|
|
30
|
+
const chars = iconSet.chars();
|
|
31
|
+
for (const char in chars) {
|
|
32
|
+
const name = chars[char];
|
|
33
|
+
await store(name, `${dir}/${char}.svg`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
await iconSet.forEach(async (name, type) => {
|
|
37
|
+
if (type === "alias" && options.includeAliases === false) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
await store(name, `${dir}/${name}.svg`);
|
|
41
|
+
});
|
|
42
|
+
return Array.from(storedFiles);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.exportToDirectory = exportToDirectory;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { IconSet } from '../icon-set/index.js';
|
|
2
|
+
import { ExportTargetOptions } from './helpers/prepare.js';
|
|
3
|
+
import '@iconify/types';
|
|
4
|
+
import '@iconify/utils/lib/customisations';
|
|
5
|
+
import '../icon-set/types.js';
|
|
6
|
+
import '../svg/index.js';
|
|
7
|
+
|
|
3
8
|
/**
|
|
4
9
|
* Options
|
|
5
10
|
*/
|
|
6
|
-
|
|
11
|
+
interface ExportToDirectoryOptions extends ExportTargetOptions {
|
|
7
12
|
autoHeight?: boolean;
|
|
8
13
|
includeAliases?: boolean;
|
|
9
14
|
includeChars?: boolean;
|
|
@@ -14,4 +19,6 @@ export interface ExportToDirectoryOptions extends ExportTargetOptions {
|
|
|
14
19
|
*
|
|
15
20
|
* Returns list of stored files
|
|
16
21
|
*/
|
|
17
|
-
|
|
22
|
+
declare function exportToDirectory(iconSet: IconSet, options: ExportToDirectoryOptions): Promise<string[]>;
|
|
23
|
+
|
|
24
|
+
export { ExportToDirectoryOptions, exportToDirectory };
|
package/lib/export/directory.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { prepareDirectoryForExport } from './helpers/prepare.mjs';
|
|
3
|
+
import 'pathe';
|
|
4
|
+
|
|
4
5
|
async function exportToDirectory(iconSet, options) {
|
|
5
6
|
const dir = await prepareDirectoryForExport(options);
|
|
6
|
-
const storedFiles = new Set();
|
|
7
|
+
const storedFiles = /* @__PURE__ */ new Set();
|
|
7
8
|
const customisations = options.autoHeight === false ? {
|
|
8
9
|
height: "1em"
|
|
9
10
|
} : {
|
|
@@ -15,7 +16,7 @@ async function exportToDirectory(iconSet, options) {
|
|
|
15
16
|
if (!svg) {
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
|
-
await
|
|
19
|
+
await promises.writeFile(target, svg, "utf8");
|
|
19
20
|
storedFiles.add(target);
|
|
20
21
|
if (options.log) {
|
|
21
22
|
console.log(`Saved ${target} (${svg.length} bytes)`);
|
|
@@ -36,6 +37,5 @@ async function exportToDirectory(iconSet, options) {
|
|
|
36
37
|
});
|
|
37
38
|
return Array.from(storedFiles);
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
40
|
+
|
|
41
|
+
export { exportToDirectory };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const misc_writeJson = require('../../misc/write-json.cjs');
|
|
7
|
+
|
|
8
|
+
async function exportCustomFiles(dir, options, result) {
|
|
9
|
+
const customFiles = options.customFiles || {};
|
|
10
|
+
for (const filename in customFiles) {
|
|
11
|
+
const content = customFiles[filename];
|
|
12
|
+
if (content === null) {
|
|
13
|
+
try {
|
|
14
|
+
await fs.promises.unlink(dir + "/" + filename);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
}
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (typeof content === "string") {
|
|
20
|
+
await fs.promises.writeFile(dir + "/" + filename, content, "utf8");
|
|
21
|
+
} else if (typeof content === "object") {
|
|
22
|
+
await misc_writeJson.writeJSONFile(dir + "/" + filename, content);
|
|
23
|
+
}
|
|
24
|
+
result?.add(filename);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.exportCustomFiles = exportCustomFiles;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Options
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
interface ExportOptionsWithCustomFiles {
|
|
5
5
|
customFiles?: Record<string, string | Record<string, unknown> | null>;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Write custom files
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
declare function exportCustomFiles(dir: string, options: ExportOptionsWithCustomFiles, result?: Set<string>): Promise<void>;
|
|
11
|
+
|
|
12
|
+
export { ExportOptionsWithCustomFiles, exportCustomFiles };
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { writeJSONFile } from '../../misc/write-json.mjs';
|
|
3
|
+
|
|
4
4
|
async function exportCustomFiles(dir, options, result) {
|
|
5
5
|
const customFiles = options.customFiles || {};
|
|
6
6
|
for (const filename in customFiles) {
|
|
7
7
|
const content = customFiles[filename];
|
|
8
8
|
if (content === null) {
|
|
9
9
|
try {
|
|
10
|
-
await
|
|
10
|
+
await promises.unlink(dir + "/" + filename);
|
|
11
11
|
} catch (err) {
|
|
12
12
|
}
|
|
13
13
|
continue;
|
|
14
14
|
}
|
|
15
15
|
if (typeof content === "string") {
|
|
16
|
-
await
|
|
16
|
+
await promises.writeFile(dir + "/" + filename, content, "utf8");
|
|
17
17
|
} else if (typeof content === "object") {
|
|
18
18
|
await writeJSONFile(dir + "/" + filename, content);
|
|
19
19
|
}
|
|
20
|
-
result
|
|
20
|
+
result?.add(filename);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
23
|
+
|
|
24
|
+
export { exportCustomFiles };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const pathe = require('pathe');
|
|
7
|
+
|
|
8
|
+
function normalizeDir(dir) {
|
|
9
|
+
dir = pathe.normalize(dir);
|
|
10
|
+
if (dir.slice(-1) === "/") {
|
|
11
|
+
dir = dir.slice(0, -1);
|
|
12
|
+
}
|
|
13
|
+
return dir;
|
|
14
|
+
}
|
|
15
|
+
async function prepareDirectoryForExport(options) {
|
|
16
|
+
const dir = normalizeDir(options.target);
|
|
17
|
+
if (options.cleanup) {
|
|
18
|
+
try {
|
|
19
|
+
await fs.promises.rm(dir, {
|
|
20
|
+
recursive: true,
|
|
21
|
+
force: true
|
|
22
|
+
});
|
|
23
|
+
} catch (err) {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
await fs.promises.mkdir(dir, {
|
|
28
|
+
recursive: true
|
|
29
|
+
});
|
|
30
|
+
} catch (err) {
|
|
31
|
+
}
|
|
32
|
+
return dir;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.normalizeDir = normalizeDir;
|
|
36
|
+
exports.prepareDirectoryForExport = prepareDirectoryForExport;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Common options for all functions that export to directory
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
interface ExportTargetOptions {
|
|
5
5
|
target: string;
|
|
6
6
|
cleanup?: boolean;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Normalize directory
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
declare function normalizeDir(dir: string): string;
|
|
12
12
|
/**
|
|
13
13
|
* Prepare directory for export
|
|
14
14
|
*
|
|
15
15
|
* Also normalizes directory and returns normalized value
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
declare function prepareDirectoryForExport(options: ExportTargetOptions): Promise<string>;
|
|
18
|
+
|
|
19
|
+
export { ExportTargetOptions, normalizeDir, prepareDirectoryForExport };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { normalize } from 'pathe';
|
|
3
|
+
|
|
4
4
|
function normalizeDir(dir) {
|
|
5
5
|
dir = normalize(dir);
|
|
6
6
|
if (dir.slice(-1) === "/") {
|
|
@@ -12,7 +12,7 @@ async function prepareDirectoryForExport(options) {
|
|
|
12
12
|
const dir = normalizeDir(options.target);
|
|
13
13
|
if (options.cleanup) {
|
|
14
14
|
try {
|
|
15
|
-
await
|
|
15
|
+
await promises.rm(dir, {
|
|
16
16
|
recursive: true,
|
|
17
17
|
force: true
|
|
18
18
|
});
|
|
@@ -20,14 +20,12 @@ async function prepareDirectoryForExport(options) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
try {
|
|
23
|
-
await
|
|
23
|
+
await promises.mkdir(dir, {
|
|
24
24
|
recursive: true
|
|
25
25
|
});
|
|
26
26
|
} catch (err) {
|
|
27
27
|
}
|
|
28
28
|
return dir;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
prepareDirectoryForExport
|
|
33
|
-
};
|
|
30
|
+
|
|
31
|
+
export { normalizeDir, prepareDirectoryForExport };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const localPkg = require('local-pkg');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
let cache;
|
|
9
|
+
async function getVersion() {
|
|
10
|
+
const packageName = "@iconify/types/package.json";
|
|
11
|
+
const filename = localPkg.resolveModule(packageName);
|
|
12
|
+
if (!filename) {
|
|
13
|
+
throw new Error(`Cannot resolve ${packageName}`);
|
|
14
|
+
}
|
|
15
|
+
const content = JSON.parse(await fs.promises.readFile(filename, "utf8"));
|
|
16
|
+
return cache = content.version;
|
|
17
|
+
}
|
|
18
|
+
async function getTypesVersion() {
|
|
19
|
+
return cache || await getVersion();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.getTypesVersion = getTypesVersion;
|
|
@@ -1,40 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
};
|
|
1
|
+
import { resolveModule } from 'local-pkg';
|
|
2
|
+
import { promises } from 'fs';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
version: "1.0.12",
|
|
12
|
-
author: "Vjacheslav Trushkin",
|
|
13
|
-
license: "(Apache-2.0 OR GPL-2.0)",
|
|
14
|
-
main: "./index.js",
|
|
15
|
-
types: "./types.ts",
|
|
16
|
-
scripts: {
|
|
17
|
-
test: "tsc --noEmit --strict --typeRoots '[]' types.ts"
|
|
18
|
-
},
|
|
19
|
-
bugs: "https://github.com/iconify/iconify/issues",
|
|
20
|
-
homepage: "https://github.com/iconify/iconify",
|
|
21
|
-
repository: {
|
|
22
|
-
type: "git",
|
|
23
|
-
url: "https://github.com/iconify/iconify.git",
|
|
24
|
-
directory: "packages/types"
|
|
25
|
-
},
|
|
26
|
-
devDependencies: {
|
|
27
|
-
typescript: "^4.4.3"
|
|
28
|
-
}
|
|
29
|
-
};
|
|
4
|
+
let cache;
|
|
5
|
+
async function getVersion() {
|
|
6
|
+
const packageName = "@iconify/types/package.json";
|
|
7
|
+
const filename = resolveModule(packageName);
|
|
8
|
+
if (!filename) {
|
|
9
|
+
throw new Error(`Cannot resolve ${packageName}`);
|
|
30
10
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return pkg.version;
|
|
11
|
+
const content = JSON.parse(await promises.readFile(filename, "utf8"));
|
|
12
|
+
return cache = content.version;
|
|
13
|
+
}
|
|
14
|
+
async function getTypesVersion() {
|
|
15
|
+
return cache || await getVersion();
|
|
37
16
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
17
|
+
|
|
18
|
+
export { getTypesVersion };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const export_helpers_prepare = require('./helpers/prepare.cjs');
|
|
7
|
+
const misc_writeJson = require('../misc/write-json.cjs');
|
|
8
|
+
const export_helpers_typesVersion = require('./helpers/types-version.cjs');
|
|
9
|
+
const export_helpers_customFiles = require('./helpers/custom-files.cjs');
|
|
10
|
+
require('pathe');
|
|
11
|
+
require('local-pkg');
|
|
12
|
+
|
|
13
|
+
const defaultTypesContent = `import type { IconifyIcon } from '@iconify/types';
|
|
14
|
+
declare const data: IconifyIcon;
|
|
15
|
+
export default data;
|
|
16
|
+
`;
|
|
17
|
+
async function exportIconPackage(iconSet, options) {
|
|
18
|
+
const files = /* @__PURE__ */ new Set();
|
|
19
|
+
const esm = options.module !== false;
|
|
20
|
+
const dir = await export_helpers_prepare.prepareDirectoryForExport(options);
|
|
21
|
+
const typesContent = options.typesContent || defaultTypesContent;
|
|
22
|
+
await iconSet.forEach(async (name2) => {
|
|
23
|
+
const data = iconSet.resolve(name2, false);
|
|
24
|
+
if (!data) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const typesFilename = name2 + ".d.ts";
|
|
28
|
+
await fs.promises.writeFile(`${dir}/${typesFilename}`, typesContent, "utf8");
|
|
29
|
+
files.add(typesFilename);
|
|
30
|
+
let content = `const data = ` + JSON.stringify(data, null, " ") + ";\n";
|
|
31
|
+
if (!esm) {
|
|
32
|
+
content += "exports.__esModule = true;\nexports.default = data;\n";
|
|
33
|
+
} else {
|
|
34
|
+
content += "export default data;\n";
|
|
35
|
+
}
|
|
36
|
+
const contentFilename = name2 + ".js";
|
|
37
|
+
await fs.promises.writeFile(`${dir}/${contentFilename}`, content, "utf8");
|
|
38
|
+
files.add(contentFilename);
|
|
39
|
+
});
|
|
40
|
+
await export_helpers_customFiles.exportCustomFiles(dir, options, files);
|
|
41
|
+
const info = iconSet.info;
|
|
42
|
+
const { name, description, version, dependencies, ...customPackageProps } = options.package || {};
|
|
43
|
+
const packageJSON = {
|
|
44
|
+
name: name || (esm ? `@iconify-icons/${iconSet.prefix}` : `@iconify/icons-${iconSet.prefix}`),
|
|
45
|
+
description: description || `Iconify icon components for ${info ? info.name : iconSet.prefix}`,
|
|
46
|
+
version,
|
|
47
|
+
type: esm ? "module" : void 0,
|
|
48
|
+
iconSetInfo: info,
|
|
49
|
+
...customPackageProps,
|
|
50
|
+
dependencies: dependencies || {
|
|
51
|
+
"@iconify/types": "^" + await export_helpers_typesVersion.getTypesVersion()
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
await misc_writeJson.writeJSONFile(dir + "/package.json", packageJSON);
|
|
55
|
+
files.add("package.json");
|
|
56
|
+
return Array.from(files);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.exportIconPackage = exportIconPackage;
|