@iconify/tools 2.1.0 → 2.1.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.
- package/lib/colors/attribs.d.ts +4 -4
- package/lib/colors/detect.cjs +68 -0
- package/lib/colors/detect.d.ts +15 -0
- package/lib/colors/detect.mjs +64 -0
- package/lib/colors/parse.cjs +31 -7
- package/lib/colors/parse.d.ts +5 -5
- package/lib/colors/parse.mjs +31 -7
- package/lib/colors/validate.cjs +9 -3
- package/lib/colors/validate.d.ts +1 -1
- package/lib/colors/validate.mjs +9 -3
- package/lib/css/parser/error.cjs +1 -1
- package/lib/css/parser/error.mjs +1 -1
- package/lib/css/parser/strings.cjs +10 -2
- package/lib/css/parser/strings.mjs +10 -2
- package/lib/css/parser/tokens.cjs +133 -109
- package/lib/css/parser/tokens.mjs +133 -109
- package/lib/css/parser/types.d.ts +4 -4
- package/lib/download/api/cache.cjs +28 -21
- package/lib/download/api/cache.mjs +28 -21
- package/lib/download/git/branch.cjs +1 -1
- package/lib/download/git/branch.mjs +1 -1
- package/lib/download/git/hash.cjs +1 -1
- package/lib/download/git/hash.mjs +1 -1
- package/lib/download/git/index.cjs +7 -4
- package/lib/download/git/index.mjs +7 -4
- package/lib/download/git/reset.cjs +1 -2
- package/lib/download/git/reset.mjs +1 -2
- package/lib/download/github/index.cjs +10 -7
- package/lib/download/github/index.mjs +10 -7
- package/lib/download/gitlab/hash.cjs +3 -1
- package/lib/download/gitlab/hash.mjs +3 -1
- package/lib/download/gitlab/index.cjs +9 -6
- package/lib/download/gitlab/index.mjs +9 -6
- package/lib/download/index.cjs +4 -3
- package/lib/download/index.d.ts +4 -4
- package/lib/download/index.mjs +4 -3
- package/lib/download/npm/index.cjs +12 -8
- package/lib/download/npm/index.mjs +12 -8
- package/lib/download/npm/version.cjs +4 -2
- package/lib/download/npm/version.mjs +4 -2
- package/lib/download/types/modified.d.ts +1 -1
- package/lib/download/types/sources.d.ts +1 -1
- package/lib/export/directory.d.ts +1 -1
- package/lib/export/helpers/types-version.cjs +3 -1
- package/lib/export/helpers/types-version.mjs +3 -1
- package/lib/export/icon-package.d.ts +1 -1
- package/lib/export/json-package.cjs +13 -3
- package/lib/export/json-package.d.ts +1 -1
- package/lib/export/json-package.mjs +13 -3
- package/lib/icon-set/index.cjs +20 -8
- package/lib/icon-set/index.d.ts +1 -1
- package/lib/icon-set/index.mjs +20 -8
- package/lib/icon-set/match.d.ts +1 -1
- package/lib/icon-set/merge.d.ts +1 -1
- package/lib/icon-set/modified.d.ts +1 -1
- package/lib/icon-set/props.d.ts +1 -1
- package/lib/icon-set/tags.cjs +97 -0
- package/lib/icon-set/tags.d.ts +22 -0
- package/lib/icon-set/tags.mjs +91 -0
- package/lib/icon-set/types.d.ts +8 -8
- package/lib/import/directory.cjs +4 -1
- package/lib/import/directory.d.ts +3 -3
- package/lib/import/directory.mjs +4 -1
- package/lib/import/figma/index.cjs +5 -2
- package/lib/import/figma/index.d.ts +1 -1
- package/lib/import/figma/index.mjs +5 -2
- package/lib/import/figma/nodes.cjs +6 -2
- package/lib/import/figma/nodes.d.ts +2 -2
- package/lib/import/figma/nodes.mjs +6 -2
- package/lib/import/figma/query.cjs +29 -15
- package/lib/import/figma/query.d.ts +1 -1
- package/lib/import/figma/query.mjs +29 -15
- package/lib/import/figma/types/api.d.ts +1 -1
- package/lib/import/figma/types/nodes.d.ts +6 -6
- package/lib/import/figma/types/options.d.ts +2 -2
- package/lib/import/figma/types/result.d.ts +1 -1
- package/lib/index.cjs +6 -3
- package/lib/index.d.ts +3 -1
- package/lib/index.mjs +4 -3
- package/lib/misc/cheerio.d.ts +2 -2
- package/lib/misc/compare-dirs.cjs +3 -1
- package/lib/misc/compare-dirs.mjs +3 -1
- package/lib/misc/exec.cjs +7 -8
- package/lib/misc/exec.mjs +7 -8
- package/lib/misc/keyword.cjs +4 -1
- package/lib/misc/keyword.mjs +4 -1
- package/lib/misc/scan.cjs +3 -1
- package/lib/misc/scan.d.ts +5 -5
- package/lib/misc/scan.mjs +3 -1
- package/lib/optimise/flags.cjs +9 -3
- package/lib/optimise/flags.d.ts +1 -1
- package/lib/optimise/flags.mjs +9 -3
- package/lib/optimise/global-style.cjs +10 -3
- package/lib/optimise/global-style.d.ts +1 -1
- package/lib/optimise/global-style.mjs +10 -3
- package/lib/optimise/scale.d.ts +1 -1
- package/lib/optimise/svgo.d.ts +2 -2
- package/lib/svg/analyse/types.d.ts +1 -1
- package/lib/svg/analyse.cjs +20 -6
- package/lib/svg/analyse.d.ts +1 -1
- package/lib/svg/analyse.mjs +20 -6
- package/lib/svg/cleanup/attribs.d.ts +1 -1
- package/lib/svg/cleanup/bad-tags.cjs +7 -2
- package/lib/svg/cleanup/bad-tags.d.ts +1 -1
- package/lib/svg/cleanup/bad-tags.mjs +7 -2
- package/lib/svg/cleanup/inline-style.cjs +12 -4
- package/lib/svg/cleanup/inline-style.d.ts +1 -1
- package/lib/svg/cleanup/inline-style.mjs +12 -4
- package/lib/svg/cleanup/root-style.d.ts +1 -1
- package/lib/svg/cleanup/root-svg.d.ts +1 -1
- package/lib/svg/cleanup/svgo-style.d.ts +1 -1
- package/lib/svg/cleanup.d.ts +1 -1
- package/lib/svg/data/attributes.cjs +0 -1
- package/lib/svg/data/attributes.mjs +0 -1
- package/lib/svg/index.cjs +12 -3
- package/lib/svg/index.d.ts +2 -2
- package/lib/svg/index.mjs +12 -3
- package/lib/svg/parse-style.cjs +13 -8
- package/lib/svg/parse-style.d.ts +4 -4
- package/lib/svg/parse-style.mjs +13 -8
- package/lib/svg/parse.d.ts +2 -2
- package/package.json +209 -100
- package/lib/types-6360d61e.d.ts +0 -261
|
@@ -14,15 +14,16 @@ function apiCacheKey(query) {
|
|
|
14
14
|
}
|
|
15
15
|
async function storeAPICache(options, key, data) {
|
|
16
16
|
const expires = Date.now() + options.ttl * 1e3;
|
|
17
|
-
const filename = options.dir + "/" + key + "." + expires + ".json";
|
|
17
|
+
const filename = options.dir + "/" + key + "." + expires.toString() + ".json";
|
|
18
18
|
if (!storedFiles[options.dir]) {
|
|
19
19
|
await getStoredFiles(options.dir);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
const content = {
|
|
22
22
|
version: cacheVersion,
|
|
23
23
|
expires,
|
|
24
24
|
data
|
|
25
|
-
}
|
|
25
|
+
};
|
|
26
|
+
await promises.writeFile(filename, JSON.stringify(content, null, 4), "utf8");
|
|
26
27
|
storedFiles[options.dir][key] = {
|
|
27
28
|
filename,
|
|
28
29
|
expires
|
|
@@ -38,7 +39,9 @@ async function getAPICache(dir, key) {
|
|
|
38
39
|
}
|
|
39
40
|
const time = Date.now();
|
|
40
41
|
try {
|
|
41
|
-
const content = JSON.parse(
|
|
42
|
+
const content = JSON.parse(
|
|
43
|
+
await promises.readFile(item.filename, "utf8")
|
|
44
|
+
);
|
|
42
45
|
return content.version === cacheVersion && content.expires > time ? content.data : null;
|
|
43
46
|
} catch (err) {
|
|
44
47
|
return null;
|
|
@@ -57,23 +60,27 @@ async function getStoredFiles(dir, clear = false) {
|
|
|
57
60
|
});
|
|
58
61
|
} catch (err) {
|
|
59
62
|
}
|
|
60
|
-
await scanDirectory(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
await scanDirectory(
|
|
64
|
+
dir,
|
|
65
|
+
async (ext, file, subdir, path) => {
|
|
66
|
+
if (ext !== ".json") {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const filename = path + subdir + file + ext;
|
|
70
|
+
const parts = file.split(".");
|
|
71
|
+
const expires = parseInt(parts.pop());
|
|
72
|
+
if (clear || expires < time || parts.length !== 1) {
|
|
73
|
+
await promises.unlink(filename);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const cacheKey = parts[0];
|
|
77
|
+
storage[cacheKey] = {
|
|
78
|
+
filename,
|
|
79
|
+
expires
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
false
|
|
83
|
+
);
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
export { apiCacheKey, clearAPICache, getAPICache, storeAPICache };
|
|
@@ -9,7 +9,6 @@ const download_git_hash = require('./hash.cjs');
|
|
|
9
9
|
const download_git_reset = require('./reset.cjs');
|
|
10
10
|
require('fs');
|
|
11
11
|
require('pathe');
|
|
12
|
-
require('path');
|
|
13
12
|
require('child_process');
|
|
14
13
|
require('cheerio');
|
|
15
14
|
require('@iconify/utils');
|
|
@@ -24,6 +23,7 @@ require('@iconify/utils/lib/icon-set/minify');
|
|
|
24
23
|
require('@iconify/utils/lib/icon-set/convert-info');
|
|
25
24
|
require('../../icon-set/props.cjs');
|
|
26
25
|
require('@iconify/utils/lib/misc/objects');
|
|
26
|
+
require('@iconify/utils/lib/colors');
|
|
27
27
|
require('node-fetch');
|
|
28
28
|
require('crypto');
|
|
29
29
|
require('../api/download.cjs');
|
|
@@ -31,14 +31,15 @@ require('util');
|
|
|
31
31
|
require('stream');
|
|
32
32
|
require('extract-zip');
|
|
33
33
|
require('tar');
|
|
34
|
-
require('@iconify/utils/lib/colors');
|
|
35
34
|
|
|
36
35
|
async function downloadGitRepo(options) {
|
|
37
36
|
const { remote, branch } = options;
|
|
38
37
|
const hasHashInTarget = options.target.indexOf("{hash}") !== -1;
|
|
39
38
|
const ifModifiedSince = options.ifModifiedSince;
|
|
40
39
|
if (ifModifiedSince || hasHashInTarget) {
|
|
41
|
-
const result = await misc_exec.execAsync(
|
|
40
|
+
const result = await misc_exec.execAsync(
|
|
41
|
+
`git ls-remote ${remote} --branch ${branch}`
|
|
42
|
+
);
|
|
42
43
|
const parts = result.stdout.split(/\s/);
|
|
43
44
|
const latestHash = parts.shift();
|
|
44
45
|
if (hasHashInTarget) {
|
|
@@ -63,7 +64,9 @@ async function downloadGitRepo(options) {
|
|
|
63
64
|
if (options.log) {
|
|
64
65
|
console.log(`Cloning ${remote}#${branch} to ${target}`);
|
|
65
66
|
}
|
|
66
|
-
await misc_exec.execAsync(
|
|
67
|
+
await misc_exec.execAsync(
|
|
68
|
+
`git clone --branch ${branch} --no-tags --depth 1 ${remote} "${target}"`
|
|
69
|
+
);
|
|
67
70
|
const hash = await download_git_hash.getGitRepoHash(options);
|
|
68
71
|
await download_git_branch.getGitRepoBranch(options, branch);
|
|
69
72
|
return {
|
|
@@ -5,7 +5,6 @@ import { getGitRepoHash } from './hash.mjs';
|
|
|
5
5
|
import { resetGitRepoContents } from './reset.mjs';
|
|
6
6
|
import 'fs';
|
|
7
7
|
import 'pathe';
|
|
8
|
-
import 'path';
|
|
9
8
|
import 'child_process';
|
|
10
9
|
import 'cheerio';
|
|
11
10
|
import '@iconify/utils';
|
|
@@ -20,6 +19,7 @@ import '@iconify/utils/lib/icon-set/minify';
|
|
|
20
19
|
import '@iconify/utils/lib/icon-set/convert-info';
|
|
21
20
|
import '../../icon-set/props.mjs';
|
|
22
21
|
import '@iconify/utils/lib/misc/objects';
|
|
22
|
+
import '@iconify/utils/lib/colors';
|
|
23
23
|
import 'node-fetch';
|
|
24
24
|
import 'crypto';
|
|
25
25
|
import '../api/download.mjs';
|
|
@@ -27,14 +27,15 @@ import 'util';
|
|
|
27
27
|
import 'stream';
|
|
28
28
|
import 'extract-zip';
|
|
29
29
|
import 'tar';
|
|
30
|
-
import '@iconify/utils/lib/colors';
|
|
31
30
|
|
|
32
31
|
async function downloadGitRepo(options) {
|
|
33
32
|
const { remote, branch } = options;
|
|
34
33
|
const hasHashInTarget = options.target.indexOf("{hash}") !== -1;
|
|
35
34
|
const ifModifiedSince = options.ifModifiedSince;
|
|
36
35
|
if (ifModifiedSince || hasHashInTarget) {
|
|
37
|
-
const result = await execAsync(
|
|
36
|
+
const result = await execAsync(
|
|
37
|
+
`git ls-remote ${remote} --branch ${branch}`
|
|
38
|
+
);
|
|
38
39
|
const parts = result.stdout.split(/\s/);
|
|
39
40
|
const latestHash = parts.shift();
|
|
40
41
|
if (hasHashInTarget) {
|
|
@@ -59,7 +60,9 @@ async function downloadGitRepo(options) {
|
|
|
59
60
|
if (options.log) {
|
|
60
61
|
console.log(`Cloning ${remote}#${branch} to ${target}`);
|
|
61
62
|
}
|
|
62
|
-
await execAsync(
|
|
63
|
+
await execAsync(
|
|
64
|
+
`git clone --branch ${branch} --no-tags --depth 1 ${remote} "${target}"`
|
|
65
|
+
);
|
|
63
66
|
const hash = await getGitRepoHash(options);
|
|
64
67
|
await getGitRepoBranch(options, branch);
|
|
65
68
|
return {
|
|
@@ -13,6 +13,7 @@ require('@iconify/utils/lib/svg/build');
|
|
|
13
13
|
require('@iconify/utils/lib/icon-set/minify');
|
|
14
14
|
require('@iconify/utils/lib/icon-set/convert-info');
|
|
15
15
|
require('../../icon-set/props.cjs');
|
|
16
|
+
require('@iconify/utils/lib/colors');
|
|
16
17
|
require('node-fetch');
|
|
17
18
|
require('fs');
|
|
18
19
|
require('crypto');
|
|
@@ -21,10 +22,8 @@ const misc_exec = require('../../misc/exec.cjs');
|
|
|
21
22
|
require('../api/download.cjs');
|
|
22
23
|
require('extract-zip');
|
|
23
24
|
require('tar');
|
|
24
|
-
require('@iconify/utils/lib/colors');
|
|
25
25
|
require('../../svg/parse.cjs');
|
|
26
26
|
require('@iconify/utils/lib/misc/objects');
|
|
27
|
-
require('path');
|
|
28
27
|
require('child_process');
|
|
29
28
|
require('util');
|
|
30
29
|
require('stream');
|
|
@@ -9,6 +9,7 @@ import '@iconify/utils/lib/svg/build';
|
|
|
9
9
|
import '@iconify/utils/lib/icon-set/minify';
|
|
10
10
|
import '@iconify/utils/lib/icon-set/convert-info';
|
|
11
11
|
import '../../icon-set/props.mjs';
|
|
12
|
+
import '@iconify/utils/lib/colors';
|
|
12
13
|
import 'node-fetch';
|
|
13
14
|
import 'fs';
|
|
14
15
|
import 'crypto';
|
|
@@ -17,10 +18,8 @@ import { execAsync } from '../../misc/exec.mjs';
|
|
|
17
18
|
import '../api/download.mjs';
|
|
18
19
|
import 'extract-zip';
|
|
19
20
|
import 'tar';
|
|
20
|
-
import '@iconify/utils/lib/colors';
|
|
21
21
|
import '../../svg/parse.mjs';
|
|
22
22
|
import '@iconify/utils/lib/misc/objects';
|
|
23
|
-
import 'path';
|
|
24
23
|
import 'child_process';
|
|
25
24
|
import 'util';
|
|
26
25
|
import 'stream';
|
|
@@ -53,13 +53,16 @@ async function downloadGitHubRepo(options) {
|
|
|
53
53
|
}
|
|
54
54
|
if (!exists) {
|
|
55
55
|
const uri = `https://api.github.com/repos/${options.user}/${options.repo}/zipball/${hash}`;
|
|
56
|
-
await download_api_download.downloadFile(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
await download_api_download.downloadFile(
|
|
57
|
+
{
|
|
58
|
+
uri,
|
|
59
|
+
headers: {
|
|
60
|
+
Accept: "application/vnd.github.v3+json",
|
|
61
|
+
Authorization: "token " + options.token
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
archiveTarget
|
|
65
|
+
);
|
|
63
66
|
}
|
|
64
67
|
const files = await fs.promises.readdir(rootDir);
|
|
65
68
|
const hashSearch = "-" + hash;
|
|
@@ -49,13 +49,16 @@ async function downloadGitHubRepo(options) {
|
|
|
49
49
|
}
|
|
50
50
|
if (!exists) {
|
|
51
51
|
const uri = `https://api.github.com/repos/${options.user}/${options.repo}/zipball/${hash}`;
|
|
52
|
-
await downloadFile(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
await downloadFile(
|
|
53
|
+
{
|
|
54
|
+
uri,
|
|
55
|
+
headers: {
|
|
56
|
+
Accept: "application/vnd.github.v3+json",
|
|
57
|
+
Authorization: "token " + options.token
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
archiveTarget
|
|
61
|
+
);
|
|
59
62
|
}
|
|
60
63
|
const files = await promises.readdir(rootDir);
|
|
61
64
|
const hashSearch = "-" + hash;
|
|
@@ -22,7 +22,9 @@ async function getGitLabRepoHash(options) {
|
|
|
22
22
|
throw new Error(`Error downloading data from GitLab API: ${data}`);
|
|
23
23
|
}
|
|
24
24
|
const content = JSON.parse(data);
|
|
25
|
-
const item = (content instanceof Array ? content : [content]).find(
|
|
25
|
+
const item = (content instanceof Array ? content : [content]).find(
|
|
26
|
+
(item2) => item2.name === options.branch && typeof item2.commit.id === "string"
|
|
27
|
+
);
|
|
26
28
|
if (!item) {
|
|
27
29
|
throw new Error("Error parsing GitLab API response");
|
|
28
30
|
}
|
|
@@ -18,7 +18,9 @@ async function getGitLabRepoHash(options) {
|
|
|
18
18
|
throw new Error(`Error downloading data from GitLab API: ${data}`);
|
|
19
19
|
}
|
|
20
20
|
const content = JSON.parse(data);
|
|
21
|
-
const item = (content instanceof Array ? content : [content]).find(
|
|
21
|
+
const item = (content instanceof Array ? content : [content]).find(
|
|
22
|
+
(item2) => item2.name === options.branch && typeof item2.commit.id === "string"
|
|
23
|
+
);
|
|
22
24
|
if (!item) {
|
|
23
25
|
throw new Error("Error parsing GitLab API response");
|
|
24
26
|
}
|
|
@@ -54,12 +54,15 @@ async function downloadGitLabRepo(options) {
|
|
|
54
54
|
}
|
|
55
55
|
if (!exists) {
|
|
56
56
|
const uri = `${options.uri || download_gitlab_types.defaultGitLabBaseURI}/${options.project}/repository/archive.zip?sha=${hash}`;
|
|
57
|
-
await download_api_download.downloadFile(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
await download_api_download.downloadFile(
|
|
58
|
+
{
|
|
59
|
+
uri,
|
|
60
|
+
headers: {
|
|
61
|
+
Authorization: "token " + options.token
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
archiveTarget
|
|
65
|
+
);
|
|
63
66
|
}
|
|
64
67
|
const files = await fs.promises.readdir(rootDir);
|
|
65
68
|
const hashSearch = "-" + hash;
|
|
@@ -50,12 +50,15 @@ async function downloadGitLabRepo(options) {
|
|
|
50
50
|
}
|
|
51
51
|
if (!exists) {
|
|
52
52
|
const uri = `${options.uri || defaultGitLabBaseURI}/${options.project}/repository/archive.zip?sha=${hash}`;
|
|
53
|
-
await downloadFile(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
await downloadFile(
|
|
54
|
+
{
|
|
55
|
+
uri,
|
|
56
|
+
headers: {
|
|
57
|
+
Authorization: "token " + options.token
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
archiveTarget
|
|
61
|
+
);
|
|
59
62
|
}
|
|
60
63
|
const files = await promises.readdir(rootDir);
|
|
61
64
|
const hashSearch = "-" + hash;
|
package/lib/download/index.cjs
CHANGED
|
@@ -21,7 +21,6 @@ require('stream');
|
|
|
21
21
|
require('./helpers/unzip.cjs');
|
|
22
22
|
require('extract-zip');
|
|
23
23
|
require('../misc/exec.cjs');
|
|
24
|
-
require('path');
|
|
25
24
|
require('child_process');
|
|
26
25
|
require('./git/branch.cjs');
|
|
27
26
|
require('./git/hash.cjs');
|
|
@@ -39,8 +38,8 @@ require('@iconify/utils/lib/icon-set/minify');
|
|
|
39
38
|
require('@iconify/utils/lib/icon-set/convert-info');
|
|
40
39
|
require('../icon-set/props.cjs');
|
|
41
40
|
require('@iconify/utils/lib/misc/objects');
|
|
42
|
-
require('tar');
|
|
43
41
|
require('@iconify/utils/lib/colors');
|
|
42
|
+
require('tar');
|
|
44
43
|
require('./helpers/untar.cjs');
|
|
45
44
|
require('./npm/version.cjs');
|
|
46
45
|
require('./gitlab/hash.cjs');
|
|
@@ -57,7 +56,9 @@ function downloadPackage(options) {
|
|
|
57
56
|
case "npm":
|
|
58
57
|
return download_npm_index.downloadNPMPackage(options);
|
|
59
58
|
default:
|
|
60
|
-
throw new Error(
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Invalid download type: ${options.downloadType}`
|
|
61
|
+
);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
package/lib/download/index.d.ts
CHANGED
|
@@ -30,16 +30,16 @@ interface DownloadNPMPackage {
|
|
|
30
30
|
/**
|
|
31
31
|
* Combinations based on type
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
type DownloadParamsMixin<T extends DownloadSourceType> = T extends 'git' ? DownloadGitRepo : T extends 'github' ? DownloadGitHubRepo : T extends 'gitlab' ? DownloadGitLabRepo : T extends 'npm' ? DownloadNPMPackage : never;
|
|
34
34
|
/**
|
|
35
35
|
* Combinations
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
type DownloadParams = DownloadGitRepo | DownloadGitHubRepo | DownloadGitLabRepo | DownloadNPMPackage;
|
|
38
38
|
/**
|
|
39
39
|
* Pick options or result from combinations
|
|
40
40
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
type DownloadOptions<T extends DownloadSourceType> = DownloadParamsMixin<T>['options'];
|
|
42
|
+
type DownloadResult<T extends DownloadSourceType> = Promise<DocumentNotModified | DownloadParamsMixin<T>['result']>;
|
|
43
43
|
declare function downloadPackage<T extends 'git'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
44
44
|
declare function downloadPackage<T extends 'github'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
45
45
|
declare function downloadPackage<T extends 'gitlab'>(options: DownloadOptions<T>): DownloadResult<T>;
|
package/lib/download/index.mjs
CHANGED
|
@@ -17,7 +17,6 @@ import 'stream';
|
|
|
17
17
|
import './helpers/unzip.mjs';
|
|
18
18
|
import 'extract-zip';
|
|
19
19
|
import '../misc/exec.mjs';
|
|
20
|
-
import 'path';
|
|
21
20
|
import 'child_process';
|
|
22
21
|
import './git/branch.mjs';
|
|
23
22
|
import './git/hash.mjs';
|
|
@@ -35,8 +34,8 @@ import '@iconify/utils/lib/icon-set/minify';
|
|
|
35
34
|
import '@iconify/utils/lib/icon-set/convert-info';
|
|
36
35
|
import '../icon-set/props.mjs';
|
|
37
36
|
import '@iconify/utils/lib/misc/objects';
|
|
38
|
-
import 'tar';
|
|
39
37
|
import '@iconify/utils/lib/colors';
|
|
38
|
+
import 'tar';
|
|
40
39
|
import './helpers/untar.mjs';
|
|
41
40
|
import './npm/version.mjs';
|
|
42
41
|
import './gitlab/hash.mjs';
|
|
@@ -53,7 +52,9 @@ function downloadPackage(options) {
|
|
|
53
52
|
case "npm":
|
|
54
53
|
return downloadNPMPackage(options);
|
|
55
54
|
default:
|
|
56
|
-
throw new Error(
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Invalid download type: ${options.downloadType}`
|
|
57
|
+
);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -13,7 +13,6 @@ require('util');
|
|
|
13
13
|
require('stream');
|
|
14
14
|
require('tar');
|
|
15
15
|
require('../../misc/exec.cjs');
|
|
16
|
-
require('path');
|
|
17
16
|
require('child_process');
|
|
18
17
|
|
|
19
18
|
async function downloadNPMPackage(options) {
|
|
@@ -43,7 +42,9 @@ async function downloadNPMPackage(options) {
|
|
|
43
42
|
}
|
|
44
43
|
const archiveURL = versionInfo.file;
|
|
45
44
|
if (!archiveURL) {
|
|
46
|
-
throw new Error(
|
|
45
|
+
throw new Error(
|
|
46
|
+
`NPM registry did not provide link to package archive.`
|
|
47
|
+
);
|
|
47
48
|
}
|
|
48
49
|
const archiveTarget = rootDir + "/" + version + ".tgz";
|
|
49
50
|
await export_helpers_prepare.prepareDirectoryForExport(options);
|
|
@@ -57,12 +58,15 @@ async function downloadNPMPackage(options) {
|
|
|
57
58
|
if (options.log) {
|
|
58
59
|
console.log(`Downloading ${archiveURL}`);
|
|
59
60
|
}
|
|
60
|
-
await download_api_download.downloadFile(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
await download_api_download.downloadFile(
|
|
62
|
+
{
|
|
63
|
+
uri: archiveURL,
|
|
64
|
+
headers: {
|
|
65
|
+
Accept: "application/tar+gzip"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
archiveTarget
|
|
69
|
+
);
|
|
66
70
|
}
|
|
67
71
|
await export_helpers_prepare.prepareDirectoryForExport({
|
|
68
72
|
target: contentsDir,
|
|
@@ -9,7 +9,6 @@ import 'util';
|
|
|
9
9
|
import 'stream';
|
|
10
10
|
import 'tar';
|
|
11
11
|
import '../../misc/exec.mjs';
|
|
12
|
-
import 'path';
|
|
13
12
|
import 'child_process';
|
|
14
13
|
|
|
15
14
|
async function downloadNPMPackage(options) {
|
|
@@ -39,7 +38,9 @@ async function downloadNPMPackage(options) {
|
|
|
39
38
|
}
|
|
40
39
|
const archiveURL = versionInfo.file;
|
|
41
40
|
if (!archiveURL) {
|
|
42
|
-
throw new Error(
|
|
41
|
+
throw new Error(
|
|
42
|
+
`NPM registry did not provide link to package archive.`
|
|
43
|
+
);
|
|
43
44
|
}
|
|
44
45
|
const archiveTarget = rootDir + "/" + version + ".tgz";
|
|
45
46
|
await prepareDirectoryForExport(options);
|
|
@@ -53,12 +54,15 @@ async function downloadNPMPackage(options) {
|
|
|
53
54
|
if (options.log) {
|
|
54
55
|
console.log(`Downloading ${archiveURL}`);
|
|
55
56
|
}
|
|
56
|
-
await downloadFile(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
await downloadFile(
|
|
58
|
+
{
|
|
59
|
+
uri: archiveURL,
|
|
60
|
+
headers: {
|
|
61
|
+
Accept: "application/tar+gzip"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
archiveTarget
|
|
65
|
+
);
|
|
62
66
|
}
|
|
63
67
|
await prepareDirectoryForExport({
|
|
64
68
|
target: contentsDir,
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const misc_exec = require('../../misc/exec.cjs');
|
|
7
|
-
require('
|
|
7
|
+
require('pathe');
|
|
8
8
|
require('child_process');
|
|
9
9
|
|
|
10
10
|
async function getNPMVersion(options) {
|
|
@@ -17,7 +17,9 @@ async function getNPMVersion(options) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
async function getPackageVersion(target) {
|
|
20
|
-
return JSON.parse(
|
|
20
|
+
return JSON.parse(
|
|
21
|
+
await fs.promises.readFile(target + "/package.json", "utf8")
|
|
22
|
+
).version;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
exports.getNPMVersion = getNPMVersion;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
2
|
import { execAsync } from '../../misc/exec.mjs';
|
|
3
|
-
import '
|
|
3
|
+
import 'pathe';
|
|
4
4
|
import 'child_process';
|
|
5
5
|
|
|
6
6
|
async function getNPMVersion(options) {
|
|
@@ -13,7 +13,9 @@ async function getNPMVersion(options) {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
async function getPackageVersion(target) {
|
|
16
|
-
return JSON.parse(
|
|
16
|
+
return JSON.parse(
|
|
17
|
+
await promises.readFile(target + "/package.json", "utf8")
|
|
18
|
+
).version;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export { getNPMVersion, getPackageVersion };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IconSet } from '../icon-set/index.js';
|
|
2
2
|
import { ExportTargetOptions } from './helpers/prepare.js';
|
|
3
|
-
import '
|
|
3
|
+
import '@iconify/types';
|
|
4
4
|
import '@iconify/utils/lib/customisations/defaults';
|
|
5
5
|
import '../icon-set/types.js';
|
|
6
6
|
import '../svg/index.js';
|
|
@@ -6,7 +6,9 @@ require('local-pkg');
|
|
|
6
6
|
require('fs');
|
|
7
7
|
|
|
8
8
|
async function getTypesVersion() {
|
|
9
|
-
throw new Error(
|
|
9
|
+
throw new Error(
|
|
10
|
+
`getTypesVersion() is deprecated, use wildcard to make packages work with all versions`
|
|
11
|
+
);
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
exports.getTypesVersion = getTypesVersion;
|
|
@@ -2,7 +2,9 @@ import 'local-pkg';
|
|
|
2
2
|
import 'fs';
|
|
3
3
|
|
|
4
4
|
async function getTypesVersion() {
|
|
5
|
-
throw new Error(
|
|
5
|
+
throw new Error(
|
|
6
|
+
`getTypesVersion() is deprecated, use wildcard to make packages work with all versions`
|
|
7
|
+
);
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
export { getTypesVersion };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IconSet } from '../icon-set/index.js';
|
|
2
2
|
import { ExportTargetOptions } from './helpers/prepare.js';
|
|
3
3
|
import { ExportOptionsWithCustomFiles } from './helpers/custom-files.js';
|
|
4
|
-
import '
|
|
4
|
+
import '@iconify/types';
|
|
5
5
|
import '@iconify/utils/lib/customisations/defaults';
|
|
6
6
|
import '../icon-set/types.js';
|
|
7
7
|
import '../svg/index.js';
|