@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,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { sendAPIQuery } from '../api/index.mjs';
|
|
2
|
+
import { defaultGitLabBaseURI } from './types.mjs';
|
|
3
|
+
import 'node-fetch';
|
|
4
|
+
import '../api/cache.mjs';
|
|
5
|
+
import 'fs';
|
|
6
|
+
import 'crypto';
|
|
7
|
+
import '../../misc/scan.mjs';
|
|
8
|
+
|
|
4
9
|
async function getGitLabRepoHash(options) {
|
|
5
10
|
const uri = `${options.uri || defaultGitLabBaseURI}/${options.project}/repository/branches/${options.branch}/`;
|
|
6
11
|
const data = await sendAPIQuery({
|
|
@@ -19,6 +24,5 @@ async function getGitLabRepoHash(options) {
|
|
|
19
24
|
}
|
|
20
25
|
return item.commit.id;
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
27
|
+
|
|
28
|
+
export { getGitLabRepoHash };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const export_helpers_prepare = require('../../export/helpers/prepare.cjs');
|
|
7
|
+
const download_gitlab_hash = require('./hash.cjs');
|
|
8
|
+
const download_gitlab_types = require('./types.cjs');
|
|
9
|
+
const download_api_download = require('../api/download.cjs');
|
|
10
|
+
const download_helpers_unzip = require('../helpers/unzip.cjs');
|
|
11
|
+
require('pathe');
|
|
12
|
+
require('../api/index.cjs');
|
|
13
|
+
require('node-fetch');
|
|
14
|
+
require('../api/cache.cjs');
|
|
15
|
+
require('crypto');
|
|
16
|
+
require('../../misc/scan.cjs');
|
|
17
|
+
require('util');
|
|
18
|
+
require('stream');
|
|
19
|
+
require('extract-zip');
|
|
20
|
+
|
|
21
|
+
async function findMatchingDirs(rootDir, hash) {
|
|
22
|
+
const matches = [];
|
|
23
|
+
const files = await fs.promises.readdir(rootDir);
|
|
24
|
+
for (let i = 0; i < files.length; i++) {
|
|
25
|
+
const file = files[i];
|
|
26
|
+
const lastChunk = file.split("-").pop();
|
|
27
|
+
if (lastChunk.length < 4 || lastChunk !== hash.slice(0, lastChunk.length)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const stat = await fs.promises.stat(rootDir + "/" + file);
|
|
31
|
+
if (stat.isDirectory()) {
|
|
32
|
+
matches.push(file);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return matches;
|
|
36
|
+
}
|
|
37
|
+
async function downloadGitLabRepo(options) {
|
|
38
|
+
const hash = await download_gitlab_hash.getGitLabRepoHash(options);
|
|
39
|
+
const ifModifiedSince = options.ifModifiedSince;
|
|
40
|
+
if (ifModifiedSince) {
|
|
41
|
+
const expectedHash = typeof ifModifiedSince === "string" ? ifModifiedSince : ifModifiedSince.downloadType === "gitlab" ? ifModifiedSince.hash : null;
|
|
42
|
+
if (hash === expectedHash) {
|
|
43
|
+
return "not_modified";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
options.target = options.target.replace("{hash}", hash);
|
|
47
|
+
const rootDir = options.target = await export_helpers_prepare.prepareDirectoryForExport(options);
|
|
48
|
+
const archiveTarget = rootDir + "/" + hash + ".zip";
|
|
49
|
+
let exists = false;
|
|
50
|
+
try {
|
|
51
|
+
const stat = await fs.promises.stat(archiveTarget);
|
|
52
|
+
exists = stat.isFile();
|
|
53
|
+
} catch (err) {
|
|
54
|
+
}
|
|
55
|
+
if (!exists) {
|
|
56
|
+
const uri = `${options.uri || download_gitlab_types.defaultGitLabBaseURI}/${options.project}/repository/archive.zip?sha=${hash}`;
|
|
57
|
+
await download_api_download.downloadFile({
|
|
58
|
+
uri,
|
|
59
|
+
headers: {
|
|
60
|
+
Authorization: "token " + options.token
|
|
61
|
+
}
|
|
62
|
+
}, archiveTarget);
|
|
63
|
+
}
|
|
64
|
+
const files = await fs.promises.readdir(rootDir);
|
|
65
|
+
const hashSearch = "-" + hash;
|
|
66
|
+
for (let i = 0; i < files.length; i++) {
|
|
67
|
+
const file = files[i];
|
|
68
|
+
if (file === hash + ".zip") {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const filename = rootDir + "/" + files[i];
|
|
72
|
+
const stat = await fs.promises.lstat(filename);
|
|
73
|
+
const isDir = stat.isDirectory();
|
|
74
|
+
if (stat.isSymbolicLink() || isDir && filename.slice(0 - hashSearch.length) === hashSearch || isDir && options.cleanupOldDirectories !== false || !isDir && options.cleanupOldFiles) {
|
|
75
|
+
try {
|
|
76
|
+
await fs.promises.rm(filename, {
|
|
77
|
+
force: true,
|
|
78
|
+
recursive: true
|
|
79
|
+
});
|
|
80
|
+
} catch (err) {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
await download_helpers_unzip.unzip(archiveTarget, rootDir);
|
|
85
|
+
const matchingDirs = await findMatchingDirs(rootDir, hash);
|
|
86
|
+
if (matchingDirs.length !== 1) {
|
|
87
|
+
throw new Error(`Error unpacking ${hash}.zip`);
|
|
88
|
+
}
|
|
89
|
+
const contentsDir = rootDir + "/" + matchingDirs[0];
|
|
90
|
+
return {
|
|
91
|
+
downloadType: "gitlab",
|
|
92
|
+
rootDir,
|
|
93
|
+
contentsDir,
|
|
94
|
+
hash
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
exports.downloadGitLabRepo = downloadGitLabRepo;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { ExportTargetOptions } from '../../export/helpers/prepare';
|
|
2
|
-
import
|
|
3
|
-
import { GitLabAPIOptions } from './types';
|
|
4
|
-
import
|
|
1
|
+
import { ExportTargetOptions } from '../../export/helpers/prepare.js';
|
|
2
|
+
import { DocumentNotModified } from '../types/modified.js';
|
|
3
|
+
import { GitLabAPIOptions } from './types.js';
|
|
4
|
+
import { DownloadSourceMixin } from '../types/sources.js';
|
|
5
|
+
|
|
5
6
|
interface IfModifiedSinceOption {
|
|
6
7
|
ifModifiedSince: string | DownloadGitLabRepoResult;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Options for downloadGitLabRepo()
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
interface DownloadGitLabRepoOptions extends ExportTargetOptions, GitLabAPIOptions, Partial<IfModifiedSinceOption> {
|
|
12
13
|
cleanupOldFiles?: boolean;
|
|
13
14
|
cleanupOldDirectories?: boolean;
|
|
14
15
|
log?: boolean;
|
|
@@ -16,7 +17,7 @@ export interface DownloadGitLabRepoOptions extends ExportTargetOptions, GitLabAP
|
|
|
16
17
|
/**
|
|
17
18
|
* Result
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
interface DownloadGitLabRepoResult extends DownloadSourceMixin<'gitlab'> {
|
|
20
21
|
rootDir: string;
|
|
21
22
|
contentsDir: string;
|
|
22
23
|
hash: string;
|
|
@@ -24,6 +25,7 @@ export interface DownloadGitLabRepoResult extends DownloadSourceMixin<'gitlab'>
|
|
|
24
25
|
/**
|
|
25
26
|
* Download GitLab repo using API
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
declare function downloadGitLabRepo<T extends IfModifiedSinceOption & DownloadGitLabRepoOptions>(options: T): Promise<DownloadGitLabRepoResult | DocumentNotModified>;
|
|
29
|
+
declare function downloadGitLabRepo(options: DownloadGitLabRepoOptions): Promise<DownloadGitLabRepoResult>;
|
|
30
|
+
|
|
31
|
+
export { DownloadGitLabRepoOptions, DownloadGitLabRepoResult, downloadGitLabRepo };
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
} from
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { prepareDirectoryForExport } from '../../export/helpers/prepare.mjs';
|
|
3
|
+
import { getGitLabRepoHash } from './hash.mjs';
|
|
4
|
+
import { defaultGitLabBaseURI } from './types.mjs';
|
|
5
|
+
import { downloadFile } from '../api/download.mjs';
|
|
6
|
+
import { unzip } from '../helpers/unzip.mjs';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
import '../api/index.mjs';
|
|
9
|
+
import 'node-fetch';
|
|
10
|
+
import '../api/cache.mjs';
|
|
11
|
+
import 'crypto';
|
|
12
|
+
import '../../misc/scan.mjs';
|
|
13
|
+
import 'util';
|
|
14
|
+
import 'stream';
|
|
15
|
+
import 'extract-zip';
|
|
16
|
+
|
|
10
17
|
async function findMatchingDirs(rootDir, hash) {
|
|
11
18
|
const matches = [];
|
|
12
|
-
const files = await
|
|
19
|
+
const files = await promises.readdir(rootDir);
|
|
13
20
|
for (let i = 0; i < files.length; i++) {
|
|
14
21
|
const file = files[i];
|
|
15
22
|
const lastChunk = file.split("-").pop();
|
|
16
23
|
if (lastChunk.length < 4 || lastChunk !== hash.slice(0, lastChunk.length)) {
|
|
17
24
|
continue;
|
|
18
25
|
}
|
|
19
|
-
const stat = await
|
|
26
|
+
const stat = await promises.stat(rootDir + "/" + file);
|
|
20
27
|
if (stat.isDirectory()) {
|
|
21
28
|
matches.push(file);
|
|
22
29
|
}
|
|
@@ -37,7 +44,7 @@ async function downloadGitLabRepo(options) {
|
|
|
37
44
|
const archiveTarget = rootDir + "/" + hash + ".zip";
|
|
38
45
|
let exists = false;
|
|
39
46
|
try {
|
|
40
|
-
const stat = await
|
|
47
|
+
const stat = await promises.stat(archiveTarget);
|
|
41
48
|
exists = stat.isFile();
|
|
42
49
|
} catch (err) {
|
|
43
50
|
}
|
|
@@ -50,7 +57,7 @@ async function downloadGitLabRepo(options) {
|
|
|
50
57
|
}
|
|
51
58
|
}, archiveTarget);
|
|
52
59
|
}
|
|
53
|
-
const files = await
|
|
60
|
+
const files = await promises.readdir(rootDir);
|
|
54
61
|
const hashSearch = "-" + hash;
|
|
55
62
|
for (let i = 0; i < files.length; i++) {
|
|
56
63
|
const file = files[i];
|
|
@@ -58,11 +65,11 @@ async function downloadGitLabRepo(options) {
|
|
|
58
65
|
continue;
|
|
59
66
|
}
|
|
60
67
|
const filename = rootDir + "/" + files[i];
|
|
61
|
-
const stat = await
|
|
68
|
+
const stat = await promises.lstat(filename);
|
|
62
69
|
const isDir = stat.isDirectory();
|
|
63
70
|
if (stat.isSymbolicLink() || isDir && filename.slice(0 - hashSearch.length) === hashSearch || isDir && options.cleanupOldDirectories !== false || !isDir && options.cleanupOldFiles) {
|
|
64
71
|
try {
|
|
65
|
-
await
|
|
72
|
+
await promises.rm(filename, {
|
|
66
73
|
force: true,
|
|
67
74
|
recursive: true
|
|
68
75
|
});
|
|
@@ -83,6 +90,5 @@ async function downloadGitLabRepo(options) {
|
|
|
83
90
|
hash
|
|
84
91
|
};
|
|
85
92
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
93
|
+
|
|
94
|
+
export { downloadGitLabRepo };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* API options
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
interface GitLabAPIOptions {
|
|
5
5
|
uri?: string;
|
|
6
6
|
token: string;
|
|
7
7
|
project: string;
|
|
@@ -10,4 +10,6 @@ export interface GitLabAPIOptions {
|
|
|
10
10
|
/**
|
|
11
11
|
* Default base URI for GitLab API
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
declare const defaultGitLabBaseURI = "https://gitlab.com/api/v4/projects";
|
|
14
|
+
|
|
15
|
+
export { GitLabAPIOptions, defaultGitLabBaseURI };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const extract = require('extract-zip');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
9
|
+
|
|
10
|
+
const extract__default = /*#__PURE__*/_interopDefaultLegacy(extract);
|
|
11
|
+
|
|
12
|
+
async function unzip(source, path) {
|
|
13
|
+
const dir = await fs.promises.realpath(path);
|
|
14
|
+
await extract__default(source, {
|
|
15
|
+
dir
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.unzip = unzip;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import extract from 'extract-zip';
|
|
2
|
+
import { promises } from 'fs';
|
|
3
|
+
|
|
4
4
|
async function unzip(source, path) {
|
|
5
|
-
const dir = await
|
|
5
|
+
const dir = await promises.realpath(path);
|
|
6
6
|
await extract(source, {
|
|
7
7
|
dir
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
10
|
+
|
|
11
|
+
export { unzip };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const download_github_index = require('./github/index.cjs');
|
|
6
|
+
const download_git_index = require('./git/index.cjs');
|
|
7
|
+
const download_npm_index = require('./npm/index.cjs');
|
|
8
|
+
const download_gitlab_index = require('./gitlab/index.cjs');
|
|
9
|
+
require('fs');
|
|
10
|
+
require('../export/helpers/prepare.cjs');
|
|
11
|
+
require('pathe');
|
|
12
|
+
require('./github/hash.cjs');
|
|
13
|
+
require('./api/index.cjs');
|
|
14
|
+
require('node-fetch');
|
|
15
|
+
require('./api/cache.cjs');
|
|
16
|
+
require('crypto');
|
|
17
|
+
require('../misc/scan.cjs');
|
|
18
|
+
require('./api/download.cjs');
|
|
19
|
+
require('util');
|
|
20
|
+
require('stream');
|
|
21
|
+
require('./helpers/unzip.cjs');
|
|
22
|
+
require('extract-zip');
|
|
23
|
+
require('../misc/exec.cjs');
|
|
24
|
+
require('child_process');
|
|
25
|
+
require('./git/branch.cjs');
|
|
26
|
+
require('./git/hash.cjs');
|
|
27
|
+
require('./git/reset.cjs');
|
|
28
|
+
require('cheerio');
|
|
29
|
+
require('@iconify/utils');
|
|
30
|
+
require('@iconify/utils/lib/icon');
|
|
31
|
+
require('../svg/data/attributes.cjs');
|
|
32
|
+
require('../svg/data/tags.cjs');
|
|
33
|
+
require('../svg/cleanup/bad-tags.cjs');
|
|
34
|
+
require('../svg/parse.cjs');
|
|
35
|
+
require('svgo');
|
|
36
|
+
require('@iconify/utils/lib/svg/build');
|
|
37
|
+
require('@iconify/utils/lib/customisations');
|
|
38
|
+
require('@iconify/utils/lib/icon-set/minify');
|
|
39
|
+
require('@iconify/utils/lib/icon-set/convert-info');
|
|
40
|
+
require('../icon-set/props.cjs');
|
|
41
|
+
require('tar');
|
|
42
|
+
require('@iconify/utils/lib/colors');
|
|
43
|
+
require('local-pkg');
|
|
44
|
+
require('./helpers/untar.cjs');
|
|
45
|
+
require('./npm/version.cjs');
|
|
46
|
+
require('./gitlab/hash.cjs');
|
|
47
|
+
require('./gitlab/types.cjs');
|
|
48
|
+
|
|
49
|
+
function downloadPackage(options) {
|
|
50
|
+
switch (options.downloadType) {
|
|
51
|
+
case "git":
|
|
52
|
+
return download_git_index.downloadGitRepo(options);
|
|
53
|
+
case "github":
|
|
54
|
+
return download_github_index.downloadGitHubRepo(options);
|
|
55
|
+
case "gitlab":
|
|
56
|
+
return download_gitlab_index.downloadGitLabRepo(options);
|
|
57
|
+
case "npm":
|
|
58
|
+
return download_npm_index.downloadNPMPackage(options);
|
|
59
|
+
default:
|
|
60
|
+
throw new Error(`Invalid download type: ${options.downloadType}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports.downloadPackage = downloadPackage;
|
package/lib/download/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { DownloadGitHubRepoOptions, DownloadGitHubRepoResult } from './github';
|
|
2
|
-
import { DownloadGitRepoOptions, DownloadGitRepoResult } from './git';
|
|
3
|
-
import { DownloadNPMPackageOptions, DownloadNPMPackageResult } from './npm';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { DownloadGitLabRepoOptions, DownloadGitLabRepoResult } from './gitlab';
|
|
1
|
+
import { DownloadGitHubRepoOptions, DownloadGitHubRepoResult } from './github/index.js';
|
|
2
|
+
import { DownloadGitRepoOptions, DownloadGitRepoResult } from './git/index.js';
|
|
3
|
+
import { DownloadNPMPackageOptions, DownloadNPMPackageResult } from './npm/index.js';
|
|
4
|
+
import { DocumentNotModified } from './types/modified.js';
|
|
5
|
+
import { DownloadSourceType, DownloadSourceMixin } from './types/sources.js';
|
|
6
|
+
import { DownloadGitLabRepoOptions, DownloadGitLabRepoResult } from './gitlab/index.js';
|
|
7
|
+
import '../export/helpers/prepare.js';
|
|
8
|
+
import './github/types.js';
|
|
9
|
+
import './gitlab/types.js';
|
|
10
|
+
|
|
7
11
|
/**
|
|
8
12
|
* Options and result combinations
|
|
9
13
|
*/
|
|
@@ -26,18 +30,19 @@ interface DownloadNPMPackage {
|
|
|
26
30
|
/**
|
|
27
31
|
* Combinations based on type
|
|
28
32
|
*/
|
|
29
|
-
|
|
33
|
+
declare type DownloadParamsMixin<T extends DownloadSourceType> = T extends 'git' ? DownloadGitRepo : T extends 'github' ? DownloadGitHubRepo : T extends 'gitlab' ? DownloadGitLabRepo : T extends 'npm' ? DownloadNPMPackage : never;
|
|
30
34
|
/**
|
|
31
35
|
* Combinations
|
|
32
36
|
*/
|
|
33
|
-
|
|
37
|
+
declare type DownloadParams = DownloadGitRepo | DownloadGitHubRepo | DownloadGitLabRepo | DownloadNPMPackage;
|
|
34
38
|
/**
|
|
35
39
|
* Pick options or result from combinations
|
|
36
40
|
*/
|
|
37
41
|
declare type DownloadOptions<T extends DownloadSourceType> = DownloadParamsMixin<T>['options'];
|
|
38
42
|
declare type DownloadResult<T extends DownloadSourceType> = Promise<DocumentNotModified | DownloadParamsMixin<T>['result']>;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
declare function downloadPackage<T extends 'git'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
44
|
+
declare function downloadPackage<T extends 'github'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
45
|
+
declare function downloadPackage<T extends 'gitlab'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
46
|
+
declare function downloadPackage<T extends 'npm'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
47
|
+
|
|
48
|
+
export { DownloadParams, DownloadParamsMixin, downloadPackage };
|
package/lib/download/index.mjs
CHANGED
|
@@ -1,18 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
} from
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { downloadGitHubRepo } from './github/index.mjs';
|
|
2
|
+
import { downloadGitRepo } from './git/index.mjs';
|
|
3
|
+
import { downloadNPMPackage } from './npm/index.mjs';
|
|
4
|
+
import { downloadGitLabRepo } from './gitlab/index.mjs';
|
|
5
|
+
import 'fs';
|
|
6
|
+
import '../export/helpers/prepare.mjs';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
import './github/hash.mjs';
|
|
9
|
+
import './api/index.mjs';
|
|
10
|
+
import 'node-fetch';
|
|
11
|
+
import './api/cache.mjs';
|
|
12
|
+
import 'crypto';
|
|
13
|
+
import '../misc/scan.mjs';
|
|
14
|
+
import './api/download.mjs';
|
|
15
|
+
import 'util';
|
|
16
|
+
import 'stream';
|
|
17
|
+
import './helpers/unzip.mjs';
|
|
18
|
+
import 'extract-zip';
|
|
19
|
+
import '../misc/exec.mjs';
|
|
20
|
+
import 'child_process';
|
|
21
|
+
import './git/branch.mjs';
|
|
22
|
+
import './git/hash.mjs';
|
|
23
|
+
import './git/reset.mjs';
|
|
24
|
+
import 'cheerio';
|
|
25
|
+
import '@iconify/utils';
|
|
26
|
+
import '@iconify/utils/lib/icon';
|
|
27
|
+
import '../svg/data/attributes.mjs';
|
|
28
|
+
import '../svg/data/tags.mjs';
|
|
29
|
+
import '../svg/cleanup/bad-tags.mjs';
|
|
30
|
+
import '../svg/parse.mjs';
|
|
31
|
+
import 'svgo';
|
|
32
|
+
import '@iconify/utils/lib/svg/build';
|
|
33
|
+
import '@iconify/utils/lib/customisations';
|
|
34
|
+
import '@iconify/utils/lib/icon-set/minify';
|
|
35
|
+
import '@iconify/utils/lib/icon-set/convert-info';
|
|
36
|
+
import '../icon-set/props.mjs';
|
|
37
|
+
import 'tar';
|
|
38
|
+
import '@iconify/utils/lib/colors';
|
|
39
|
+
import 'local-pkg';
|
|
40
|
+
import './helpers/untar.mjs';
|
|
41
|
+
import './npm/version.mjs';
|
|
42
|
+
import './gitlab/hash.mjs';
|
|
43
|
+
import './gitlab/types.mjs';
|
|
44
|
+
|
|
16
45
|
function downloadPackage(options) {
|
|
17
46
|
switch (options.downloadType) {
|
|
18
47
|
case "git":
|
|
@@ -24,10 +53,8 @@ function downloadPackage(options) {
|
|
|
24
53
|
case "npm":
|
|
25
54
|
return downloadNPMPackage(options);
|
|
26
55
|
default:
|
|
27
|
-
assertNever(options);
|
|
28
56
|
throw new Error(`Invalid download type: ${options.downloadType}`);
|
|
29
57
|
}
|
|
30
58
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
59
|
+
|
|
60
|
+
export { downloadPackage };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const export_helpers_prepare = require('../../export/helpers/prepare.cjs');
|
|
7
|
+
const download_api_download = require('../api/download.cjs');
|
|
8
|
+
const download_helpers_untar = require('../helpers/untar.cjs');
|
|
9
|
+
const download_npm_version = require('./version.cjs');
|
|
10
|
+
require('pathe');
|
|
11
|
+
require('node-fetch');
|
|
12
|
+
require('util');
|
|
13
|
+
require('stream');
|
|
14
|
+
require('tar');
|
|
15
|
+
require('../../misc/exec.cjs');
|
|
16
|
+
require('child_process');
|
|
17
|
+
|
|
18
|
+
async function downloadNPMPackage(options) {
|
|
19
|
+
const rootDir = options.target = export_helpers_prepare.normalizeDir(options.target);
|
|
20
|
+
const contentsDir = rootDir + "/package";
|
|
21
|
+
const versionInfo = await download_npm_version.getNPMVersion(options);
|
|
22
|
+
const version = versionInfo.version;
|
|
23
|
+
const ifModifiedSince = options.ifModifiedSince;
|
|
24
|
+
if (ifModifiedSince) {
|
|
25
|
+
try {
|
|
26
|
+
let expectedVersion;
|
|
27
|
+
if (typeof ifModifiedSince === "object") {
|
|
28
|
+
if (ifModifiedSince.downloadType === "npm" && ifModifiedSince.rootDir === rootDir && ifModifiedSince.contentsDir === contentsDir) {
|
|
29
|
+
expectedVersion = ifModifiedSince.version;
|
|
30
|
+
} else {
|
|
31
|
+
expectedVersion = null;
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
expectedVersion = ifModifiedSince === true ? await download_npm_version.getPackageVersion(contentsDir) : ifModifiedSince;
|
|
35
|
+
}
|
|
36
|
+
if (version === expectedVersion) {
|
|
37
|
+
return "not_modified";
|
|
38
|
+
}
|
|
39
|
+
} catch (err) {
|
|
40
|
+
options.cleanup = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const archiveURL = versionInfo.file;
|
|
44
|
+
if (!archiveURL) {
|
|
45
|
+
throw new Error(`NPM registry did not provide link to package archive.`);
|
|
46
|
+
}
|
|
47
|
+
const archiveTarget = rootDir + "/" + version + ".tgz";
|
|
48
|
+
await export_helpers_prepare.prepareDirectoryForExport(options);
|
|
49
|
+
let archiveExists = false;
|
|
50
|
+
try {
|
|
51
|
+
const stat = await fs.promises.stat(archiveTarget);
|
|
52
|
+
archiveExists = stat.isFile();
|
|
53
|
+
} catch (err) {
|
|
54
|
+
}
|
|
55
|
+
if (!archiveExists) {
|
|
56
|
+
if (options.log) {
|
|
57
|
+
console.log(`Downloading ${archiveURL}`);
|
|
58
|
+
}
|
|
59
|
+
await download_api_download.downloadFile({
|
|
60
|
+
uri: archiveURL,
|
|
61
|
+
headers: {
|
|
62
|
+
Accept: "application/tar+gzip"
|
|
63
|
+
}
|
|
64
|
+
}, archiveTarget);
|
|
65
|
+
}
|
|
66
|
+
await export_helpers_prepare.prepareDirectoryForExport({
|
|
67
|
+
target: contentsDir,
|
|
68
|
+
cleanup: true
|
|
69
|
+
});
|
|
70
|
+
if (options.log) {
|
|
71
|
+
console.log(`Unpacking ${archiveTarget}`);
|
|
72
|
+
}
|
|
73
|
+
await download_helpers_untar.untar(archiveTarget, rootDir);
|
|
74
|
+
return {
|
|
75
|
+
downloadType: "npm",
|
|
76
|
+
rootDir,
|
|
77
|
+
contentsDir,
|
|
78
|
+
version
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
exports.downloadNPMPackage = downloadNPMPackage;
|