@iconify/tools 2.0.7 → 2.0.8
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/download/github/index.d.ts +1 -1
- package/lib/download/gitlab/hash.d.ts +5 -0
- package/lib/download/gitlab/hash.js +27 -0
- package/lib/download/gitlab/hash.mjs +24 -0
- package/lib/download/gitlab/index.d.ts +29 -0
- package/lib/download/gitlab/index.js +115 -0
- package/lib/download/gitlab/index.mjs +88 -0
- package/lib/download/gitlab/types.d.ts +13 -0
- package/lib/download/gitlab/types.js +7 -0
- package/lib/download/gitlab/types.mjs +5 -0
- package/lib/download/index.d.ts +33 -10
- package/lib/download/index.js +7 -6
- package/lib/download/index.mjs +9 -6
- package/lib/download/types/sources.d.ts +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +11 -7
- package/lib/index.mjs +4 -0
- package/package.json +17 -1
|
@@ -6,7 +6,7 @@ interface IfModifiedSinceOption {
|
|
|
6
6
|
ifModifiedSince: string | DownloadGitHubRepoResult;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Options for
|
|
9
|
+
* Options for downloadGitHubRepo()
|
|
10
10
|
*/
|
|
11
11
|
export interface DownloadGitHubRepoOptions extends ExportTargetOptions, GitHubAPIOptions, Partial<IfModifiedSinceOption> {
|
|
12
12
|
cleanupOldFiles?: boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGitLabRepoHash = void 0;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
/**
|
|
7
|
+
* Get latest hash from GitHub using API
|
|
8
|
+
*/
|
|
9
|
+
async function getGitLabRepoHash(options) {
|
|
10
|
+
const uri = `${options.uri || types_1.defaultGitLabBaseURI}/${options.project}/repository/branches/${options.branch}/`;
|
|
11
|
+
const data = await (0, api_1.sendAPIQuery)({
|
|
12
|
+
uri,
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: 'token ' + options.token,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
if (typeof data !== 'string') {
|
|
18
|
+
throw new Error(`Error downloading data from GitLab API: ${data}`);
|
|
19
|
+
}
|
|
20
|
+
const content = JSON.parse(data);
|
|
21
|
+
const item = (content instanceof Array ? content : [content]).find((item) => item.name === options.branch && typeof item.commit.id === 'string');
|
|
22
|
+
if (!item) {
|
|
23
|
+
throw new Error('Error parsing GitLab API response');
|
|
24
|
+
}
|
|
25
|
+
return item.commit.id;
|
|
26
|
+
}
|
|
27
|
+
exports.getGitLabRepoHash = getGitLabRepoHash;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/download/gitlab/hash.ts
|
|
2
|
+
import { sendAPIQuery } from "../api/index.mjs";
|
|
3
|
+
import { defaultGitLabBaseURI } from "./types.mjs";
|
|
4
|
+
async function getGitLabRepoHash(options) {
|
|
5
|
+
const uri = `${options.uri || defaultGitLabBaseURI}/${options.project}/repository/branches/${options.branch}/`;
|
|
6
|
+
const data = await sendAPIQuery({
|
|
7
|
+
uri,
|
|
8
|
+
headers: {
|
|
9
|
+
Authorization: "token " + options.token
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
if (typeof data !== "string") {
|
|
13
|
+
throw new Error(`Error downloading data from GitLab API: ${data}`);
|
|
14
|
+
}
|
|
15
|
+
const content = JSON.parse(data);
|
|
16
|
+
const item = (content instanceof Array ? content : [content]).find((item2) => item2.name === options.branch && typeof item2.commit.id === "string");
|
|
17
|
+
if (!item) {
|
|
18
|
+
throw new Error("Error parsing GitLab API response");
|
|
19
|
+
}
|
|
20
|
+
return item.commit.id;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
getGitLabRepoHash
|
|
24
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ExportTargetOptions } from '../../export/helpers/prepare';
|
|
2
|
+
import type { DocumentNotModified } from '../types/modified';
|
|
3
|
+
import { GitLabAPIOptions } from './types';
|
|
4
|
+
import type { DownloadSourceMixin } from '../types/sources';
|
|
5
|
+
interface IfModifiedSinceOption {
|
|
6
|
+
ifModifiedSince: string | DownloadGitLabRepoResult;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Options for downloadGitLabRepo()
|
|
10
|
+
*/
|
|
11
|
+
export interface DownloadGitLabRepoOptions extends ExportTargetOptions, GitLabAPIOptions, Partial<IfModifiedSinceOption> {
|
|
12
|
+
cleanupOldFiles?: boolean;
|
|
13
|
+
cleanupOldDirectories?: boolean;
|
|
14
|
+
log?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result
|
|
18
|
+
*/
|
|
19
|
+
export interface DownloadGitLabRepoResult extends DownloadSourceMixin<'gitlab'> {
|
|
20
|
+
rootDir: string;
|
|
21
|
+
contentsDir: string;
|
|
22
|
+
hash: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Download GitLab repo using API
|
|
26
|
+
*/
|
|
27
|
+
export declare function downloadGitLabRepo<T extends IfModifiedSinceOption & DownloadGitLabRepoOptions>(options: T): Promise<DownloadGitLabRepoResult | DocumentNotModified>;
|
|
28
|
+
export declare function downloadGitLabRepo(options: DownloadGitLabRepoOptions): Promise<DownloadGitLabRepoResult>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadGitLabRepo = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const prepare_1 = require("../../export/helpers/prepare");
|
|
6
|
+
const hash_1 = require("./hash");
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const download_1 = require("../api/download");
|
|
9
|
+
const unzip_1 = require("../helpers/unzip");
|
|
10
|
+
/**
|
|
11
|
+
* Find matching directories
|
|
12
|
+
*/
|
|
13
|
+
async function findMatchingDirs(rootDir, hash) {
|
|
14
|
+
const matches = [];
|
|
15
|
+
const files = await fs_1.promises.readdir(rootDir);
|
|
16
|
+
for (let i = 0; i < files.length; i++) {
|
|
17
|
+
const file = files[i];
|
|
18
|
+
const lastChunk = file.split('-').pop();
|
|
19
|
+
if (lastChunk.length < 4 ||
|
|
20
|
+
lastChunk !== hash.slice(0, lastChunk.length)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const stat = await fs_1.promises.stat(rootDir + '/' + file);
|
|
24
|
+
if (stat.isDirectory()) {
|
|
25
|
+
matches.push(file);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return matches;
|
|
29
|
+
}
|
|
30
|
+
async function downloadGitLabRepo(options) {
|
|
31
|
+
// Check for last commit
|
|
32
|
+
const hash = await (0, hash_1.getGitLabRepoHash)(options);
|
|
33
|
+
const ifModifiedSince = options.ifModifiedSince;
|
|
34
|
+
if (ifModifiedSince) {
|
|
35
|
+
const expectedHash = typeof ifModifiedSince === 'string'
|
|
36
|
+
? ifModifiedSince
|
|
37
|
+
: ifModifiedSince.downloadType === 'gitlab'
|
|
38
|
+
? ifModifiedSince.hash
|
|
39
|
+
: null;
|
|
40
|
+
if (hash === expectedHash) {
|
|
41
|
+
return 'not_modified';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Replace hash in target
|
|
45
|
+
options.target = options.target.replace('{hash}', hash);
|
|
46
|
+
// Prepare target directory
|
|
47
|
+
const rootDir = (options.target = await (0, prepare_1.prepareDirectoryForExport)(options));
|
|
48
|
+
// Archive name
|
|
49
|
+
const archiveTarget = rootDir + '/' + hash + '.zip';
|
|
50
|
+
// Check if archive exists
|
|
51
|
+
let exists = false;
|
|
52
|
+
try {
|
|
53
|
+
const stat = await fs_1.promises.stat(archiveTarget);
|
|
54
|
+
exists = stat.isFile();
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
//
|
|
58
|
+
}
|
|
59
|
+
// Download file
|
|
60
|
+
if (!exists) {
|
|
61
|
+
const uri = `${options.uri || types_1.defaultGitLabBaseURI}/${options.project}/repository/archive.zip?sha=${hash}`;
|
|
62
|
+
await (0, download_1.downloadFile)({
|
|
63
|
+
uri,
|
|
64
|
+
headers: {
|
|
65
|
+
Authorization: 'token ' + options.token,
|
|
66
|
+
},
|
|
67
|
+
}, archiveTarget);
|
|
68
|
+
}
|
|
69
|
+
// Clean up old directories
|
|
70
|
+
const files = await fs_1.promises.readdir(rootDir);
|
|
71
|
+
const hashSearch = '-' + hash;
|
|
72
|
+
for (let i = 0; i < files.length; i++) {
|
|
73
|
+
const file = files[i];
|
|
74
|
+
if (file === hash + '.zip') {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const filename = rootDir + '/' + files[i];
|
|
78
|
+
const stat = await fs_1.promises.lstat(filename);
|
|
79
|
+
const isDir = stat.isDirectory();
|
|
80
|
+
if (
|
|
81
|
+
// Remove symbolic links
|
|
82
|
+
stat.isSymbolicLink() ||
|
|
83
|
+
// Remove if directory matches hash to avoid errors extracting zip
|
|
84
|
+
(isDir && filename.slice(0 - hashSearch.length) === hashSearch) ||
|
|
85
|
+
// Remove if directory and cleanupOldDirectories is not disabled
|
|
86
|
+
(isDir && options.cleanupOldDirectories !== false) ||
|
|
87
|
+
// Remove if file and cleanupOldFiles is enabled
|
|
88
|
+
(!isDir && options.cleanupOldFiles)) {
|
|
89
|
+
try {
|
|
90
|
+
await fs_1.promises.rm(filename, {
|
|
91
|
+
force: true,
|
|
92
|
+
recursive: true,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
//
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Unpack it
|
|
101
|
+
await (0, unzip_1.unzip)(archiveTarget, rootDir);
|
|
102
|
+
// Get actual dir
|
|
103
|
+
const matchingDirs = await findMatchingDirs(rootDir, hash);
|
|
104
|
+
if (matchingDirs.length !== 1) {
|
|
105
|
+
throw new Error(`Error unpacking ${hash}.zip`);
|
|
106
|
+
}
|
|
107
|
+
const contentsDir = rootDir + '/' + matchingDirs[0];
|
|
108
|
+
return {
|
|
109
|
+
downloadType: 'gitlab',
|
|
110
|
+
rootDir,
|
|
111
|
+
contentsDir,
|
|
112
|
+
hash,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
exports.downloadGitLabRepo = downloadGitLabRepo;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/download/gitlab/index.ts
|
|
2
|
+
import { promises as fs } from "fs";
|
|
3
|
+
import {
|
|
4
|
+
prepareDirectoryForExport
|
|
5
|
+
} from "../../export/helpers/prepare.mjs";
|
|
6
|
+
import { getGitLabRepoHash } from "./hash.mjs";
|
|
7
|
+
import { defaultGitLabBaseURI } from "./types.mjs";
|
|
8
|
+
import { downloadFile } from "../api/download.mjs";
|
|
9
|
+
import { unzip } from "../helpers/unzip.mjs";
|
|
10
|
+
async function findMatchingDirs(rootDir, hash) {
|
|
11
|
+
const matches = [];
|
|
12
|
+
const files = await fs.readdir(rootDir);
|
|
13
|
+
for (let i = 0; i < files.length; i++) {
|
|
14
|
+
const file = files[i];
|
|
15
|
+
const lastChunk = file.split("-").pop();
|
|
16
|
+
if (lastChunk.length < 4 || lastChunk !== hash.slice(0, lastChunk.length)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const stat = await fs.stat(rootDir + "/" + file);
|
|
20
|
+
if (stat.isDirectory()) {
|
|
21
|
+
matches.push(file);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return matches;
|
|
25
|
+
}
|
|
26
|
+
async function downloadGitLabRepo(options) {
|
|
27
|
+
const hash = await getGitLabRepoHash(options);
|
|
28
|
+
const ifModifiedSince = options.ifModifiedSince;
|
|
29
|
+
if (ifModifiedSince) {
|
|
30
|
+
const expectedHash = typeof ifModifiedSince === "string" ? ifModifiedSince : ifModifiedSince.downloadType === "gitlab" ? ifModifiedSince.hash : null;
|
|
31
|
+
if (hash === expectedHash) {
|
|
32
|
+
return "not_modified";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
options.target = options.target.replace("{hash}", hash);
|
|
36
|
+
const rootDir = options.target = await prepareDirectoryForExport(options);
|
|
37
|
+
const archiveTarget = rootDir + "/" + hash + ".zip";
|
|
38
|
+
let exists = false;
|
|
39
|
+
try {
|
|
40
|
+
const stat = await fs.stat(archiveTarget);
|
|
41
|
+
exists = stat.isFile();
|
|
42
|
+
} catch (err) {
|
|
43
|
+
}
|
|
44
|
+
if (!exists) {
|
|
45
|
+
const uri = `${options.uri || defaultGitLabBaseURI}/${options.project}/repository/archive.zip?sha=${hash}`;
|
|
46
|
+
await downloadFile({
|
|
47
|
+
uri,
|
|
48
|
+
headers: {
|
|
49
|
+
Authorization: "token " + options.token
|
|
50
|
+
}
|
|
51
|
+
}, archiveTarget);
|
|
52
|
+
}
|
|
53
|
+
const files = await fs.readdir(rootDir);
|
|
54
|
+
const hashSearch = "-" + hash;
|
|
55
|
+
for (let i = 0; i < files.length; i++) {
|
|
56
|
+
const file = files[i];
|
|
57
|
+
if (file === hash + ".zip") {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const filename = rootDir + "/" + files[i];
|
|
61
|
+
const stat = await fs.lstat(filename);
|
|
62
|
+
const isDir = stat.isDirectory();
|
|
63
|
+
if (stat.isSymbolicLink() || isDir && filename.slice(0 - hashSearch.length) === hashSearch || isDir && options.cleanupOldDirectories !== false || !isDir && options.cleanupOldFiles) {
|
|
64
|
+
try {
|
|
65
|
+
await fs.rm(filename, {
|
|
66
|
+
force: true,
|
|
67
|
+
recursive: true
|
|
68
|
+
});
|
|
69
|
+
} catch (err) {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
await unzip(archiveTarget, rootDir);
|
|
74
|
+
const matchingDirs = await findMatchingDirs(rootDir, hash);
|
|
75
|
+
if (matchingDirs.length !== 1) {
|
|
76
|
+
throw new Error(`Error unpacking ${hash}.zip`);
|
|
77
|
+
}
|
|
78
|
+
const contentsDir = rootDir + "/" + matchingDirs[0];
|
|
79
|
+
return {
|
|
80
|
+
downloadType: "gitlab",
|
|
81
|
+
rootDir,
|
|
82
|
+
contentsDir,
|
|
83
|
+
hash
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
downloadGitLabRepo
|
|
88
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API options
|
|
3
|
+
*/
|
|
4
|
+
export interface GitLabAPIOptions {
|
|
5
|
+
uri?: string;
|
|
6
|
+
token: string;
|
|
7
|
+
project: string;
|
|
8
|
+
branch: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Default base URI for GitLab API
|
|
12
|
+
*/
|
|
13
|
+
export declare const defaultGitLabBaseURI = "https://gitlab.com/api/v4/projects";
|
package/lib/download/index.d.ts
CHANGED
|
@@ -3,18 +3,41 @@ import { DownloadGitRepoOptions, DownloadGitRepoResult } from './git';
|
|
|
3
3
|
import { DownloadNPMPackageOptions, DownloadNPMPackageResult } from './npm';
|
|
4
4
|
import type { DocumentNotModified } from './types/modified';
|
|
5
5
|
import type { DownloadSourceMixin, DownloadSourceType } from './types/sources';
|
|
6
|
+
import { DownloadGitLabRepoOptions, DownloadGitLabRepoResult } from './gitlab';
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Options and result combinations
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
interface DownloadGitRepo {
|
|
11
|
+
options: DownloadGitRepoOptions & DownloadSourceMixin<'git'>;
|
|
12
|
+
result: DownloadGitRepoResult;
|
|
13
|
+
}
|
|
14
|
+
interface DownloadGitHubRepo {
|
|
15
|
+
options: DownloadGitHubRepoOptions & DownloadSourceMixin<'github'>;
|
|
16
|
+
result: DownloadGitHubRepoResult;
|
|
17
|
+
}
|
|
18
|
+
interface DownloadGitLabRepo {
|
|
19
|
+
options: DownloadGitLabRepoOptions & DownloadSourceMixin<'gitlab'>;
|
|
20
|
+
result: DownloadGitLabRepoResult;
|
|
21
|
+
}
|
|
22
|
+
interface DownloadNPMPackage {
|
|
23
|
+
options: DownloadNPMPackageOptions & DownloadSourceMixin<'npm'>;
|
|
24
|
+
result: DownloadNPMPackageResult;
|
|
25
|
+
}
|
|
13
26
|
/**
|
|
14
|
-
*
|
|
27
|
+
* Combinations based on type
|
|
15
28
|
*/
|
|
16
|
-
export declare type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
export declare type DownloadParamsMixin<T extends DownloadSourceType> = T extends 'git' ? DownloadGitRepo : T extends 'github' ? DownloadGitHubRepo : T extends 'gitlab' ? DownloadGitLabRepo : T extends 'npm' ? DownloadNPMPackage : never;
|
|
30
|
+
/**
|
|
31
|
+
* Combinations
|
|
32
|
+
*/
|
|
33
|
+
export declare type DownloadParams = DownloadGitRepo | DownloadGitHubRepo | DownloadGitLabRepo | DownloadNPMPackage;
|
|
34
|
+
/**
|
|
35
|
+
* Pick options or result from combinations
|
|
36
|
+
*/
|
|
37
|
+
declare type DownloadOptions<T extends DownloadSourceType> = DownloadParamsMixin<T>['options'];
|
|
38
|
+
declare type DownloadResult<T extends DownloadSourceType> = Promise<DocumentNotModified | DownloadParamsMixin<T>['result']>;
|
|
39
|
+
export declare function downloadPackage<T extends 'git'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
40
|
+
export declare function downloadPackage<T extends 'github'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
41
|
+
export declare function downloadPackage<T extends 'gitlab'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
42
|
+
export declare function downloadPackage<T extends 'npm'>(options: DownloadOptions<T>): DownloadResult<T>;
|
|
20
43
|
export {};
|
package/lib/download/index.js
CHANGED
|
@@ -4,23 +4,24 @@ exports.downloadPackage = void 0;
|
|
|
4
4
|
const github_1 = require("./github");
|
|
5
5
|
const git_1 = require("./git");
|
|
6
6
|
const npm_1 = require("./npm");
|
|
7
|
+
const gitlab_1 = require("./gitlab");
|
|
7
8
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
9
|
function assertNever(v) {
|
|
9
10
|
//
|
|
10
11
|
}
|
|
11
12
|
function downloadPackage(options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
case 'git': {
|
|
13
|
+
switch (options.downloadType) {
|
|
14
|
+
case 'git':
|
|
15
15
|
return (0, git_1.downloadGitRepo)(options);
|
|
16
|
-
}
|
|
17
16
|
case 'github':
|
|
18
17
|
return (0, github_1.downloadGitHubRepo)(options);
|
|
18
|
+
case 'gitlab':
|
|
19
|
+
return (0, gitlab_1.downloadGitLabRepo)(options);
|
|
19
20
|
case 'npm':
|
|
20
21
|
return (0, npm_1.downloadNPMPackage)(options);
|
|
21
22
|
default:
|
|
22
|
-
assertNever(
|
|
23
|
-
throw new Error(`Invalid download type: ${
|
|
23
|
+
assertNever(options);
|
|
24
|
+
throw new Error(`Invalid download type: ${options.downloadType}`);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
exports.downloadPackage = downloadPackage;
|
package/lib/download/index.mjs
CHANGED
|
@@ -8,21 +8,24 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
downloadNPMPackage
|
|
10
10
|
} from "./npm/index.mjs";
|
|
11
|
+
import {
|
|
12
|
+
downloadGitLabRepo
|
|
13
|
+
} from "./gitlab/index.mjs";
|
|
11
14
|
function assertNever(v) {
|
|
12
15
|
}
|
|
13
16
|
function downloadPackage(options) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
case "git": {
|
|
17
|
+
switch (options.downloadType) {
|
|
18
|
+
case "git":
|
|
17
19
|
return downloadGitRepo(options);
|
|
18
|
-
}
|
|
19
20
|
case "github":
|
|
20
21
|
return downloadGitHubRepo(options);
|
|
22
|
+
case "gitlab":
|
|
23
|
+
return downloadGitLabRepo(options);
|
|
21
24
|
case "npm":
|
|
22
25
|
return downloadNPMPackage(options);
|
|
23
26
|
default:
|
|
24
|
-
assertNever(
|
|
25
|
-
throw new Error(`Invalid download type: ${
|
|
27
|
+
assertNever(options);
|
|
28
|
+
throw new Error(`Invalid download type: ${options.downloadType}`);
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
export {
|
package/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export { getGitRepoHash } from './download/git/hash';
|
|
|
16
16
|
export { getGitRepoBranch } from './download/git/branch';
|
|
17
17
|
export { downloadGitHubRepo } from './download/github/index';
|
|
18
18
|
export { getGitHubRepoHash } from './download/github/hash';
|
|
19
|
+
export { downloadGitLabRepo } from './download/gitlab/index';
|
|
20
|
+
export { getGitLabRepoHash } from './download/gitlab/hash';
|
|
19
21
|
export { downloadNPMPackage } from './download/npm/index';
|
|
20
22
|
export { getNPMVersion, getPackageVersion } from './download/npm/version';
|
|
21
23
|
export { downloadPackage } from './download/index';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendAPIQuery = exports.bumpVersion = exports.cleanupIconKeyword = exports.execAsync = exports.untar = exports.unzip = exports.compareDirectories = exports.scanDirectory = exports.prepareDirectoryForExport = exports.writeJSONFile = exports.exportJSONPackage = exports.exportIconPackage = exports.exportToDirectory = exports.scaleSVG = exports.deOptimisePaths = exports.runSVGO = exports.validateColors = exports.isEmptyColor = exports.parseColors = exports.downloadPackage = exports.getPackageVersion = exports.getNPMVersion = exports.downloadNPMPackage = exports.getGitHubRepoHash = exports.downloadGitHubRepo = exports.getGitRepoBranch = exports.getGitRepoHash = exports.downloadGitRepo = exports.importDirectory = exports.importFromFigma = exports.mergeIconSets = exports.blankIconSet = exports.IconSet = exports.convertStyleToAttrs = exports.cleanupSVGRoot = exports.cleanupInlineStyle = exports.checkBadTags = exports.removeBadAttributes = exports.cleanupSVG = exports.parseSVGStyle = exports.parseSVG = exports.SVG = void 0;
|
|
3
|
+
exports.sendAPIQuery = exports.bumpVersion = exports.cleanupIconKeyword = exports.execAsync = exports.untar = exports.unzip = exports.compareDirectories = exports.scanDirectory = exports.prepareDirectoryForExport = exports.writeJSONFile = exports.exportJSONPackage = exports.exportIconPackage = exports.exportToDirectory = exports.scaleSVG = exports.deOptimisePaths = exports.runSVGO = exports.validateColors = exports.isEmptyColor = exports.parseColors = exports.downloadPackage = exports.getPackageVersion = exports.getNPMVersion = exports.downloadNPMPackage = exports.getGitLabRepoHash = exports.downloadGitLabRepo = exports.getGitHubRepoHash = exports.downloadGitHubRepo = exports.getGitRepoBranch = exports.getGitRepoHash = exports.downloadGitRepo = exports.importDirectory = exports.importFromFigma = exports.mergeIconSets = exports.blankIconSet = exports.IconSet = exports.convertStyleToAttrs = exports.cleanupSVGRoot = exports.cleanupInlineStyle = exports.checkBadTags = exports.removeBadAttributes = exports.cleanupSVG = exports.parseSVGStyle = exports.parseSVG = exports.SVG = void 0;
|
|
4
4
|
// SVG class and functions
|
|
5
5
|
var index_1 = require("./svg/index");
|
|
6
6
|
Object.defineProperty(exports, "SVG", { enumerable: true, get: function () { return index_1.SVG; } });
|
|
@@ -43,13 +43,17 @@ var index_5 = require("./download/github/index");
|
|
|
43
43
|
Object.defineProperty(exports, "downloadGitHubRepo", { enumerable: true, get: function () { return index_5.downloadGitHubRepo; } });
|
|
44
44
|
var hash_2 = require("./download/github/hash");
|
|
45
45
|
Object.defineProperty(exports, "getGitHubRepoHash", { enumerable: true, get: function () { return hash_2.getGitHubRepoHash; } });
|
|
46
|
-
var index_6 = require("./download/
|
|
47
|
-
Object.defineProperty(exports, "
|
|
46
|
+
var index_6 = require("./download/gitlab/index");
|
|
47
|
+
Object.defineProperty(exports, "downloadGitLabRepo", { enumerable: true, get: function () { return index_6.downloadGitLabRepo; } });
|
|
48
|
+
var hash_3 = require("./download/gitlab/hash");
|
|
49
|
+
Object.defineProperty(exports, "getGitLabRepoHash", { enumerable: true, get: function () { return hash_3.getGitLabRepoHash; } });
|
|
50
|
+
var index_7 = require("./download/npm/index");
|
|
51
|
+
Object.defineProperty(exports, "downloadNPMPackage", { enumerable: true, get: function () { return index_7.downloadNPMPackage; } });
|
|
48
52
|
var version_1 = require("./download/npm/version");
|
|
49
53
|
Object.defineProperty(exports, "getNPMVersion", { enumerable: true, get: function () { return version_1.getNPMVersion; } });
|
|
50
54
|
Object.defineProperty(exports, "getPackageVersion", { enumerable: true, get: function () { return version_1.getPackageVersion; } });
|
|
51
|
-
var
|
|
52
|
-
Object.defineProperty(exports, "downloadPackage", { enumerable: true, get: function () { return
|
|
55
|
+
var index_8 = require("./download/index");
|
|
56
|
+
Object.defineProperty(exports, "downloadPackage", { enumerable: true, get: function () { return index_8.downloadPackage; } });
|
|
53
57
|
// Manipulation
|
|
54
58
|
var parse_2 = require("./colors/parse");
|
|
55
59
|
Object.defineProperty(exports, "parseColors", { enumerable: true, get: function () { return parse_2.parseColors; } });
|
|
@@ -89,5 +93,5 @@ var keyword_1 = require("./misc/keyword");
|
|
|
89
93
|
Object.defineProperty(exports, "cleanupIconKeyword", { enumerable: true, get: function () { return keyword_1.cleanupIconKeyword; } });
|
|
90
94
|
var bump_version_1 = require("./misc/bump-version");
|
|
91
95
|
Object.defineProperty(exports, "bumpVersion", { enumerable: true, get: function () { return bump_version_1.bumpVersion; } });
|
|
92
|
-
var
|
|
93
|
-
Object.defineProperty(exports, "sendAPIQuery", { enumerable: true, get: function () { return
|
|
96
|
+
var index_9 = require("./download/api/index");
|
|
97
|
+
Object.defineProperty(exports, "sendAPIQuery", { enumerable: true, get: function () { return index_9.sendAPIQuery; } });
|
package/lib/index.mjs
CHANGED
|
@@ -17,6 +17,8 @@ import { getGitRepoHash } from "./download/git/hash.mjs";
|
|
|
17
17
|
import { getGitRepoBranch } from "./download/git/branch.mjs";
|
|
18
18
|
import { downloadGitHubRepo } from "./download/github/index.mjs";
|
|
19
19
|
import { getGitHubRepoHash } from "./download/github/hash.mjs";
|
|
20
|
+
import { downloadGitLabRepo } from "./download/gitlab/index.mjs";
|
|
21
|
+
import { getGitLabRepoHash } from "./download/gitlab/hash.mjs";
|
|
20
22
|
import { downloadNPMPackage } from "./download/npm/index.mjs";
|
|
21
23
|
import { getNPMVersion, getPackageVersion } from "./download/npm/version.mjs";
|
|
22
24
|
import { downloadPackage } from "./download/index.mjs";
|
|
@@ -52,6 +54,7 @@ export {
|
|
|
52
54
|
convertStyleToAttrs,
|
|
53
55
|
deOptimisePaths,
|
|
54
56
|
downloadGitHubRepo,
|
|
57
|
+
downloadGitLabRepo,
|
|
55
58
|
downloadGitRepo,
|
|
56
59
|
downloadNPMPackage,
|
|
57
60
|
downloadPackage,
|
|
@@ -60,6 +63,7 @@ export {
|
|
|
60
63
|
exportJSONPackage,
|
|
61
64
|
exportToDirectory,
|
|
62
65
|
getGitHubRepoHash,
|
|
66
|
+
getGitLabRepoHash,
|
|
63
67
|
getGitRepoBranch,
|
|
64
68
|
getGitRepoHash,
|
|
65
69
|
getNPMVersion,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@iconify/tools",
|
|
3
3
|
"description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
|
|
4
4
|
"author": "Vjacheslav Trushkin",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.8",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bugs": "https://github.com/iconify/tools/issues",
|
|
8
8
|
"homepage": "https://github.com/iconify/tools",
|
|
@@ -136,6 +136,22 @@
|
|
|
136
136
|
"require": "./lib/download/github/types.js",
|
|
137
137
|
"import": "./lib/download/github/types.mjs"
|
|
138
138
|
},
|
|
139
|
+
"./lib/download/gitlab/hash": {
|
|
140
|
+
"require": "./lib/download/gitlab/hash.js",
|
|
141
|
+
"import": "./lib/download/gitlab/hash.mjs"
|
|
142
|
+
},
|
|
143
|
+
"./lib/download/gitlab": {
|
|
144
|
+
"require": "./lib/download/gitlab/index.js",
|
|
145
|
+
"import": "./lib/download/gitlab/index.mjs"
|
|
146
|
+
},
|
|
147
|
+
"./lib/download/gitlab/index": {
|
|
148
|
+
"require": "./lib/download/gitlab/index.js",
|
|
149
|
+
"import": "./lib/download/gitlab/index.mjs"
|
|
150
|
+
},
|
|
151
|
+
"./lib/download/gitlab/types": {
|
|
152
|
+
"require": "./lib/download/gitlab/types.js",
|
|
153
|
+
"import": "./lib/download/gitlab/types.mjs"
|
|
154
|
+
},
|
|
139
155
|
"./lib/download/helpers/untar": {
|
|
140
156
|
"require": "./lib/download/helpers/untar.js",
|
|
141
157
|
"import": "./lib/download/helpers/untar.mjs"
|