@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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const export_helpers_prepare = require('../../export/helpers/prepare.cjs');
|
|
6
|
+
const misc_exec = require('../../misc/exec.cjs');
|
|
7
|
+
const download_git_branch = require('./branch.cjs');
|
|
8
|
+
const download_git_hash = require('./hash.cjs');
|
|
9
|
+
const download_git_reset = require('./reset.cjs');
|
|
10
|
+
require('fs');
|
|
11
|
+
require('pathe');
|
|
12
|
+
require('child_process');
|
|
13
|
+
require('cheerio');
|
|
14
|
+
require('@iconify/utils');
|
|
15
|
+
require('@iconify/utils/lib/icon');
|
|
16
|
+
require('../../svg/data/attributes.cjs');
|
|
17
|
+
require('../../svg/data/tags.cjs');
|
|
18
|
+
require('../../svg/cleanup/bad-tags.cjs');
|
|
19
|
+
require('../../svg/parse.cjs');
|
|
20
|
+
require('svgo');
|
|
21
|
+
require('@iconify/utils/lib/svg/build');
|
|
22
|
+
require('@iconify/utils/lib/customisations');
|
|
23
|
+
require('@iconify/utils/lib/icon-set/minify');
|
|
24
|
+
require('@iconify/utils/lib/icon-set/convert-info');
|
|
25
|
+
require('../../icon-set/props.cjs');
|
|
26
|
+
require('node-fetch');
|
|
27
|
+
require('crypto');
|
|
28
|
+
require('../api/download.cjs');
|
|
29
|
+
require('util');
|
|
30
|
+
require('stream');
|
|
31
|
+
require('extract-zip');
|
|
32
|
+
require('tar');
|
|
33
|
+
require('@iconify/utils/lib/colors');
|
|
34
|
+
require('local-pkg');
|
|
35
|
+
|
|
36
|
+
async function downloadGitRepo(options) {
|
|
37
|
+
const { remote, branch } = options;
|
|
38
|
+
const hasHashInTarget = options.target.indexOf("{hash}") !== -1;
|
|
39
|
+
const ifModifiedSince = options.ifModifiedSince;
|
|
40
|
+
if (ifModifiedSince || hasHashInTarget) {
|
|
41
|
+
const result = await misc_exec.execAsync(`git ls-remote ${remote} --branch ${branch}`);
|
|
42
|
+
const parts = result.stdout.split(/\s/);
|
|
43
|
+
const latestHash = parts.shift();
|
|
44
|
+
if (hasHashInTarget) {
|
|
45
|
+
options.target = options.target.replace("{hash}", latestHash);
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
await download_git_branch.getGitRepoBranch(options, branch);
|
|
49
|
+
if (ifModifiedSince) {
|
|
50
|
+
const expectedHash = ifModifiedSince === true ? await download_git_hash.getGitRepoHash(options) : typeof ifModifiedSince === "string" ? ifModifiedSince : ifModifiedSince.downloadType === "git" ? ifModifiedSince.hash : null;
|
|
51
|
+
if (latestHash === expectedHash) {
|
|
52
|
+
await download_git_reset.resetGitRepoContents(options.target);
|
|
53
|
+
return "not_modified";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const target = options.target = await export_helpers_prepare.prepareDirectoryForExport({
|
|
60
|
+
...options,
|
|
61
|
+
cleanup: true
|
|
62
|
+
});
|
|
63
|
+
if (options.log) {
|
|
64
|
+
console.log(`Cloning ${remote}#${branch} to ${target}`);
|
|
65
|
+
}
|
|
66
|
+
await misc_exec.execAsync(`git clone --branch ${branch} --no-tags --depth 1 ${remote} "${target}"`);
|
|
67
|
+
const hash = await download_git_hash.getGitRepoHash(options);
|
|
68
|
+
await download_git_branch.getGitRepoBranch(options, branch);
|
|
69
|
+
return {
|
|
70
|
+
downloadType: "git",
|
|
71
|
+
contentsDir: target,
|
|
72
|
+
hash
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
exports.downloadGitRepo = downloadGitRepo;
|
|
@@ -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 | DownloadGitRepoResult;
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Options for downloadGitRepo()
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
interface DownloadGitRepoOptions extends ExportTargetOptions, Partial<IfModifiedSinceOption> {
|
|
11
12
|
remote: string;
|
|
12
13
|
branch: string;
|
|
13
14
|
log?: boolean;
|
|
@@ -15,13 +16,14 @@ export interface DownloadGitRepoOptions extends ExportTargetOptions, Partial<IfM
|
|
|
15
16
|
/**
|
|
16
17
|
* Result
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
interface DownloadGitRepoResult extends DownloadSourceMixin<'git'> {
|
|
19
20
|
contentsDir: string;
|
|
20
21
|
hash: string;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Download Git repo
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
declare function downloadGitRepo<T extends IfModifiedSinceOption & DownloadGitRepoOptions>(options: T): Promise<DownloadGitRepoResult | DocumentNotModified>;
|
|
27
|
+
declare function downloadGitRepo(options: DownloadGitRepoOptions): Promise<DownloadGitRepoResult>;
|
|
28
|
+
|
|
29
|
+
export { DownloadGitRepoOptions, DownloadGitRepoResult, downloadGitRepo };
|
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
} from
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
1
|
+
import { prepareDirectoryForExport } from '../../export/helpers/prepare.mjs';
|
|
2
|
+
import { execAsync } from '../../misc/exec.mjs';
|
|
3
|
+
import { getGitRepoBranch } from './branch.mjs';
|
|
4
|
+
import { getGitRepoHash } from './hash.mjs';
|
|
5
|
+
import { resetGitRepoContents } from './reset.mjs';
|
|
6
|
+
import 'fs';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
import 'child_process';
|
|
9
|
+
import 'cheerio';
|
|
10
|
+
import '@iconify/utils';
|
|
11
|
+
import '@iconify/utils/lib/icon';
|
|
12
|
+
import '../../svg/data/attributes.mjs';
|
|
13
|
+
import '../../svg/data/tags.mjs';
|
|
14
|
+
import '../../svg/cleanup/bad-tags.mjs';
|
|
15
|
+
import '../../svg/parse.mjs';
|
|
16
|
+
import 'svgo';
|
|
17
|
+
import '@iconify/utils/lib/svg/build';
|
|
18
|
+
import '@iconify/utils/lib/customisations';
|
|
19
|
+
import '@iconify/utils/lib/icon-set/minify';
|
|
20
|
+
import '@iconify/utils/lib/icon-set/convert-info';
|
|
21
|
+
import '../../icon-set/props.mjs';
|
|
22
|
+
import 'node-fetch';
|
|
23
|
+
import 'crypto';
|
|
24
|
+
import '../api/download.mjs';
|
|
25
|
+
import 'util';
|
|
26
|
+
import 'stream';
|
|
27
|
+
import 'extract-zip';
|
|
28
|
+
import 'tar';
|
|
29
|
+
import '@iconify/utils/lib/colors';
|
|
30
|
+
import 'local-pkg';
|
|
31
|
+
|
|
10
32
|
async function downloadGitRepo(options) {
|
|
11
33
|
const { remote, branch } = options;
|
|
12
34
|
const hasHashInTarget = options.target.indexOf("{hash}") !== -1;
|
|
@@ -27,23 +49,17 @@ async function downloadGitRepo(options) {
|
|
|
27
49
|
return "not_modified";
|
|
28
50
|
}
|
|
29
51
|
}
|
|
30
|
-
} catch
|
|
31
|
-
options.cleanup = true;
|
|
52
|
+
} catch {
|
|
32
53
|
}
|
|
33
54
|
}
|
|
34
|
-
const target = options.target = await prepareDirectoryForExport(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
await execAsync(`git clone --branch ${branch} --no-tags --depth 1 ${remote} "${target}"`);
|
|
41
|
-
} else {
|
|
42
|
-
try {
|
|
43
|
-
await resetGitRepoContents(options.target);
|
|
44
|
-
} catch (err) {
|
|
45
|
-
}
|
|
55
|
+
const target = options.target = await prepareDirectoryForExport({
|
|
56
|
+
...options,
|
|
57
|
+
cleanup: true
|
|
58
|
+
});
|
|
59
|
+
if (options.log) {
|
|
60
|
+
console.log(`Cloning ${remote}#${branch} to ${target}`);
|
|
46
61
|
}
|
|
62
|
+
await execAsync(`git clone --branch ${branch} --no-tags --depth 1 ${remote} "${target}"`);
|
|
47
63
|
const hash = await getGitRepoHash(options);
|
|
48
64
|
await getGitRepoBranch(options, branch);
|
|
49
65
|
return {
|
|
@@ -52,6 +68,5 @@ async function downloadGitRepo(options) {
|
|
|
52
68
|
hash
|
|
53
69
|
};
|
|
54
70
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
71
|
+
|
|
72
|
+
export { downloadGitRepo };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('cheerio');
|
|
6
|
+
require('@iconify/utils');
|
|
7
|
+
require('@iconify/utils/lib/icon');
|
|
8
|
+
require('../../svg/data/attributes.cjs');
|
|
9
|
+
require('../../svg/data/tags.cjs');
|
|
10
|
+
require('../../svg/cleanup/bad-tags.cjs');
|
|
11
|
+
require('svgo');
|
|
12
|
+
require('@iconify/utils/lib/svg/build');
|
|
13
|
+
require('@iconify/utils/lib/customisations');
|
|
14
|
+
require('@iconify/utils/lib/icon-set/minify');
|
|
15
|
+
require('@iconify/utils/lib/icon-set/convert-info');
|
|
16
|
+
require('../../icon-set/props.cjs');
|
|
17
|
+
require('node-fetch');
|
|
18
|
+
require('fs');
|
|
19
|
+
require('crypto');
|
|
20
|
+
require('pathe');
|
|
21
|
+
const misc_exec = require('../../misc/exec.cjs');
|
|
22
|
+
require('../api/download.cjs');
|
|
23
|
+
require('extract-zip');
|
|
24
|
+
require('tar');
|
|
25
|
+
require('@iconify/utils/lib/colors');
|
|
26
|
+
require('local-pkg');
|
|
27
|
+
require('../../svg/parse.cjs');
|
|
28
|
+
require('child_process');
|
|
29
|
+
require('util');
|
|
30
|
+
require('stream');
|
|
31
|
+
|
|
32
|
+
async function resetGitRepoContents(target) {
|
|
33
|
+
await misc_exec.execAsync("git add -A", {
|
|
34
|
+
cwd: target
|
|
35
|
+
});
|
|
36
|
+
await misc_exec.execAsync("git reset --hard --quiet", {
|
|
37
|
+
cwd: target
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.resetGitRepoContents = resetGitRepoContents;
|
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import 'cheerio';
|
|
2
|
+
import '@iconify/utils';
|
|
3
|
+
import '@iconify/utils/lib/icon';
|
|
4
|
+
import '../../svg/data/attributes.mjs';
|
|
5
|
+
import '../../svg/data/tags.mjs';
|
|
6
|
+
import '../../svg/cleanup/bad-tags.mjs';
|
|
7
|
+
import 'svgo';
|
|
8
|
+
import '@iconify/utils/lib/svg/build';
|
|
9
|
+
import '@iconify/utils/lib/customisations';
|
|
10
|
+
import '@iconify/utils/lib/icon-set/minify';
|
|
11
|
+
import '@iconify/utils/lib/icon-set/convert-info';
|
|
12
|
+
import '../../icon-set/props.mjs';
|
|
13
|
+
import 'node-fetch';
|
|
14
|
+
import 'fs';
|
|
15
|
+
import 'crypto';
|
|
16
|
+
import 'pathe';
|
|
17
|
+
import { execAsync } from '../../misc/exec.mjs';
|
|
18
|
+
import '../api/download.mjs';
|
|
19
|
+
import 'extract-zip';
|
|
20
|
+
import 'tar';
|
|
21
|
+
import '@iconify/utils/lib/colors';
|
|
22
|
+
import 'local-pkg';
|
|
23
|
+
import '../../svg/parse.mjs';
|
|
24
|
+
import 'child_process';
|
|
25
|
+
import 'util';
|
|
26
|
+
import 'stream';
|
|
27
|
+
|
|
3
28
|
async function resetGitRepoContents(target) {
|
|
4
29
|
await execAsync("git add -A", {
|
|
5
30
|
cwd: target
|
|
@@ -8,6 +33,5 @@ async function resetGitRepoContents(target) {
|
|
|
8
33
|
cwd: target
|
|
9
34
|
});
|
|
10
35
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
36
|
+
|
|
37
|
+
export { resetGitRepoContents };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const download_api_index = require('../api/index.cjs');
|
|
6
|
+
require('node-fetch');
|
|
7
|
+
require('../api/cache.cjs');
|
|
8
|
+
require('fs');
|
|
9
|
+
require('crypto');
|
|
10
|
+
require('../../misc/scan.cjs');
|
|
11
|
+
|
|
12
|
+
async function getGitHubRepoHash(options) {
|
|
13
|
+
const uri = `https://api.github.com/repos/${options.user}/${options.repo}/branches/${options.branch}`;
|
|
14
|
+
const data = await download_api_index.sendAPIQuery({
|
|
15
|
+
uri,
|
|
16
|
+
headers: {
|
|
17
|
+
Accept: "application/vnd.github.v3+json",
|
|
18
|
+
Authorization: "token " + options.token
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
if (typeof data !== "string") {
|
|
22
|
+
throw new Error(`Error downloading data from GitHub API: ${data}`);
|
|
23
|
+
}
|
|
24
|
+
const content = JSON.parse(data);
|
|
25
|
+
const hash = content?.commit?.sha;
|
|
26
|
+
if (typeof hash !== "string") {
|
|
27
|
+
throw new Error("Error parsing GitHub API response");
|
|
28
|
+
}
|
|
29
|
+
return hash;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.getGitHubRepoHash = getGitHubRepoHash;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GitHubAPIOptions } from './types.js';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Get latest hash from GitHub using API
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
declare function getGitHubRepoHash(options: GitHubAPIOptions): Promise<string>;
|
|
7
|
+
|
|
8
|
+
export { getGitHubRepoHash };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import { sendAPIQuery } from '../api/index.mjs';
|
|
2
|
+
import 'node-fetch';
|
|
3
|
+
import '../api/cache.mjs';
|
|
4
|
+
import 'fs';
|
|
5
|
+
import 'crypto';
|
|
6
|
+
import '../../misc/scan.mjs';
|
|
7
|
+
|
|
3
8
|
async function getGitHubRepoHash(options) {
|
|
4
|
-
var _a;
|
|
5
9
|
const uri = `https://api.github.com/repos/${options.user}/${options.repo}/branches/${options.branch}`;
|
|
6
10
|
const data = await sendAPIQuery({
|
|
7
11
|
uri,
|
|
@@ -14,12 +18,11 @@ async function getGitHubRepoHash(options) {
|
|
|
14
18
|
throw new Error(`Error downloading data from GitHub API: ${data}`);
|
|
15
19
|
}
|
|
16
20
|
const content = JSON.parse(data);
|
|
17
|
-
const hash =
|
|
21
|
+
const hash = content?.commit?.sha;
|
|
18
22
|
if (typeof hash !== "string") {
|
|
19
23
|
throw new Error("Error parsing GitHub API response");
|
|
20
24
|
}
|
|
21
25
|
return hash;
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
27
|
+
|
|
28
|
+
export { getGitHubRepoHash };
|
|
@@ -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_github_hash = require('./hash.cjs');
|
|
8
|
+
const download_api_download = require('../api/download.cjs');
|
|
9
|
+
const download_helpers_unzip = require('../helpers/unzip.cjs');
|
|
10
|
+
require('pathe');
|
|
11
|
+
require('../api/index.cjs');
|
|
12
|
+
require('node-fetch');
|
|
13
|
+
require('../api/cache.cjs');
|
|
14
|
+
require('crypto');
|
|
15
|
+
require('../../misc/scan.cjs');
|
|
16
|
+
require('util');
|
|
17
|
+
require('stream');
|
|
18
|
+
require('extract-zip');
|
|
19
|
+
|
|
20
|
+
async function findMatchingDirs(rootDir, hash) {
|
|
21
|
+
const matches = [];
|
|
22
|
+
const files = await fs.promises.readdir(rootDir);
|
|
23
|
+
for (let i = 0; i < files.length; i++) {
|
|
24
|
+
const file = files[i];
|
|
25
|
+
const lastChunk = file.split("-").pop();
|
|
26
|
+
if (lastChunk.length < 4 || lastChunk !== hash.slice(0, lastChunk.length)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const stat = await fs.promises.stat(rootDir + "/" + file);
|
|
30
|
+
if (stat.isDirectory()) {
|
|
31
|
+
matches.push(file);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return matches;
|
|
35
|
+
}
|
|
36
|
+
async function downloadGitHubRepo(options) {
|
|
37
|
+
const hash = await download_github_hash.getGitHubRepoHash(options);
|
|
38
|
+
const ifModifiedSince = options.ifModifiedSince;
|
|
39
|
+
if (ifModifiedSince) {
|
|
40
|
+
const expectedHash = typeof ifModifiedSince === "string" ? ifModifiedSince : ifModifiedSince.downloadType === "github" ? ifModifiedSince.hash : null;
|
|
41
|
+
if (hash === expectedHash) {
|
|
42
|
+
return "not_modified";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
options.target = options.target.replace("{hash}", hash);
|
|
46
|
+
const rootDir = options.target = await export_helpers_prepare.prepareDirectoryForExport(options);
|
|
47
|
+
const archiveTarget = rootDir + "/" + hash + ".zip";
|
|
48
|
+
let exists = false;
|
|
49
|
+
try {
|
|
50
|
+
const stat = await fs.promises.stat(archiveTarget);
|
|
51
|
+
exists = stat.isFile();
|
|
52
|
+
} catch (err) {
|
|
53
|
+
}
|
|
54
|
+
if (!exists) {
|
|
55
|
+
const uri = `https://api.github.com/repos/${options.user}/${options.repo}/zipball/${hash}`;
|
|
56
|
+
await download_api_download.downloadFile({
|
|
57
|
+
uri,
|
|
58
|
+
headers: {
|
|
59
|
+
Accept: "application/vnd.github.v3+json",
|
|
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: "github",
|
|
92
|
+
rootDir,
|
|
93
|
+
contentsDir,
|
|
94
|
+
hash
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
exports.downloadGitHubRepo = downloadGitHubRepo;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { ExportTargetOptions } from '../../export/helpers/prepare';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { ExportTargetOptions } from '../../export/helpers/prepare.js';
|
|
2
|
+
import { DocumentNotModified } from '../types/modified.js';
|
|
3
|
+
import { GitHubAPIOptions } from './types.js';
|
|
4
|
+
import { DownloadSourceMixin } from '../types/sources.js';
|
|
5
|
+
|
|
5
6
|
interface IfModifiedSinceOption {
|
|
6
7
|
ifModifiedSince: string | DownloadGitHubRepoResult;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Options for downloadGitHubRepo()
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
interface DownloadGitHubRepoOptions extends ExportTargetOptions, GitHubAPIOptions, Partial<IfModifiedSinceOption> {
|
|
12
13
|
cleanupOldFiles?: boolean;
|
|
13
14
|
cleanupOldDirectories?: boolean;
|
|
14
15
|
log?: boolean;
|
|
@@ -16,7 +17,7 @@ export interface DownloadGitHubRepoOptions extends ExportTargetOptions, GitHubAP
|
|
|
16
17
|
/**
|
|
17
18
|
* Result
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
interface DownloadGitHubRepoResult extends DownloadSourceMixin<'github'> {
|
|
20
21
|
rootDir: string;
|
|
21
22
|
contentsDir: string;
|
|
22
23
|
hash: string;
|
|
@@ -24,6 +25,7 @@ export interface DownloadGitHubRepoResult extends DownloadSourceMixin<'github'>
|
|
|
24
25
|
/**
|
|
25
26
|
* Download GitHub repo using API
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
declare function downloadGitHubRepo<T extends IfModifiedSinceOption & DownloadGitHubRepoOptions>(options: T): Promise<DownloadGitHubRepoResult | DocumentNotModified>;
|
|
29
|
+
declare function downloadGitHubRepo(options: DownloadGitHubRepoOptions): Promise<DownloadGitHubRepoResult>;
|
|
30
|
+
|
|
31
|
+
export { DownloadGitHubRepoOptions, DownloadGitHubRepoResult, downloadGitHubRepo };
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
} from
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { prepareDirectoryForExport } from '../../export/helpers/prepare.mjs';
|
|
3
|
+
import { getGitHubRepoHash } from './hash.mjs';
|
|
4
|
+
import { downloadFile } from '../api/download.mjs';
|
|
5
|
+
import { unzip } from '../helpers/unzip.mjs';
|
|
6
|
+
import 'pathe';
|
|
7
|
+
import '../api/index.mjs';
|
|
8
|
+
import 'node-fetch';
|
|
9
|
+
import '../api/cache.mjs';
|
|
10
|
+
import 'crypto';
|
|
11
|
+
import '../../misc/scan.mjs';
|
|
12
|
+
import 'util';
|
|
13
|
+
import 'stream';
|
|
14
|
+
import 'extract-zip';
|
|
15
|
+
|
|
9
16
|
async function findMatchingDirs(rootDir, hash) {
|
|
10
17
|
const matches = [];
|
|
11
|
-
const files = await
|
|
18
|
+
const files = await promises.readdir(rootDir);
|
|
12
19
|
for (let i = 0; i < files.length; i++) {
|
|
13
20
|
const file = files[i];
|
|
14
21
|
const lastChunk = file.split("-").pop();
|
|
15
22
|
if (lastChunk.length < 4 || lastChunk !== hash.slice(0, lastChunk.length)) {
|
|
16
23
|
continue;
|
|
17
24
|
}
|
|
18
|
-
const stat = await
|
|
25
|
+
const stat = await promises.stat(rootDir + "/" + file);
|
|
19
26
|
if (stat.isDirectory()) {
|
|
20
27
|
matches.push(file);
|
|
21
28
|
}
|
|
@@ -36,7 +43,7 @@ async function downloadGitHubRepo(options) {
|
|
|
36
43
|
const archiveTarget = rootDir + "/" + hash + ".zip";
|
|
37
44
|
let exists = false;
|
|
38
45
|
try {
|
|
39
|
-
const stat = await
|
|
46
|
+
const stat = await promises.stat(archiveTarget);
|
|
40
47
|
exists = stat.isFile();
|
|
41
48
|
} catch (err) {
|
|
42
49
|
}
|
|
@@ -50,7 +57,7 @@ async function downloadGitHubRepo(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 downloadGitHubRepo(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 downloadGitHubRepo(options) {
|
|
|
83
90
|
hash
|
|
84
91
|
};
|
|
85
92
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
93
|
+
|
|
94
|
+
export { downloadGitHubRepo };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const download_api_index = require('../api/index.cjs');
|
|
6
|
+
const download_gitlab_types = require('./types.cjs');
|
|
7
|
+
require('node-fetch');
|
|
8
|
+
require('../api/cache.cjs');
|
|
9
|
+
require('fs');
|
|
10
|
+
require('crypto');
|
|
11
|
+
require('../../misc/scan.cjs');
|
|
12
|
+
|
|
13
|
+
async function getGitLabRepoHash(options) {
|
|
14
|
+
const uri = `${options.uri || download_gitlab_types.defaultGitLabBaseURI}/${options.project}/repository/branches/${options.branch}/`;
|
|
15
|
+
const data = await download_api_index.sendAPIQuery({
|
|
16
|
+
uri,
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: "token " + options.token
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
if (typeof data !== "string") {
|
|
22
|
+
throw new Error(`Error downloading data from GitLab API: ${data}`);
|
|
23
|
+
}
|
|
24
|
+
const content = JSON.parse(data);
|
|
25
|
+
const item = (content instanceof Array ? content : [content]).find((item2) => item2.name === options.branch && typeof item2.commit.id === "string");
|
|
26
|
+
if (!item) {
|
|
27
|
+
throw new Error("Error parsing GitLab API response");
|
|
28
|
+
}
|
|
29
|
+
return item.commit.id;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.getGitLabRepoHash = getGitLabRepoHash;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { GitLabAPIOptions } from './types';
|
|
1
|
+
import { GitLabAPIOptions } from './types.js';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Get latest hash from GitHub using API
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
declare function getGitLabRepoHash(options: GitLabAPIOptions): Promise<string>;
|
|
7
|
+
|
|
8
|
+
export { getGitLabRepoHash };
|