@iconify/tools 2.0.6 → 2.0.7

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.
@@ -0,0 +1,5 @@
1
+ import type { ExportTargetOptions } from '../../export/helpers/prepare';
2
+ /**
3
+ * Get current branch from cloned git repo
4
+ */
5
+ export declare function getGitRepoBranch(options: ExportTargetOptions, checkout?: string): Promise<string>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGitRepoBranch = void 0;
4
+ const exec_1 = require("../../misc/exec");
5
+ /**
6
+ * Get current branch from cloned git repo
7
+ */
8
+ async function getGitRepoBranch(options, checkout) {
9
+ const result = await (0, exec_1.execAsync)('git branch --show-current', {
10
+ cwd: options.target,
11
+ });
12
+ const branch = result.stdout.trim();
13
+ if (typeof checkout === 'string' && branch !== checkout) {
14
+ // Checkout correct branch
15
+ await (0, exec_1.execAsync)(`git checkout ${checkout}`, {
16
+ cwd: options.target,
17
+ });
18
+ return await getGitRepoBranch(options);
19
+ }
20
+ return branch;
21
+ }
22
+ exports.getGitRepoBranch = getGitRepoBranch;
@@ -0,0 +1,18 @@
1
+ // src/download/git/branch.ts
2
+ import { execAsync } from "../../misc/exec.mjs";
3
+ async function getGitRepoBranch(options, checkout) {
4
+ const result = await execAsync("git branch --show-current", {
5
+ cwd: options.target
6
+ });
7
+ const branch = result.stdout.trim();
8
+ if (typeof checkout === "string" && branch !== checkout) {
9
+ await execAsync(`git checkout ${checkout}`, {
10
+ cwd: options.target
11
+ });
12
+ return await getGitRepoBranch(options);
13
+ }
14
+ return branch;
15
+ }
16
+ export {
17
+ getGitRepoBranch
18
+ };
@@ -1,7 +1,8 @@
1
1
  import { ExportTargetOptions } from '../../export/helpers/prepare';
2
2
  import type { DocumentNotModified } from '../types/modified';
3
+ import type { DownloadSourceMixin } from '../types/sources';
3
4
  interface IfModifiedSinceOption {
4
- ifModifiedSince: string | true;
5
+ ifModifiedSince: string | true | DownloadGitRepoResult;
5
6
  }
6
7
  /**
7
8
  * Options for downloadGitRepo()
@@ -14,8 +15,8 @@ export interface DownloadGitRepoOptions extends ExportTargetOptions, Partial<IfM
14
15
  /**
15
16
  * Result
16
17
  */
17
- export interface DownloadGitRepoResult {
18
- target: string;
18
+ export interface DownloadGitRepoResult extends DownloadSourceMixin<'git'> {
19
+ contentsDir: string;
19
20
  hash: string;
20
21
  }
21
22
  /**
@@ -4,12 +4,14 @@ exports.downloadGitRepo = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const prepare_1 = require("../../export/helpers/prepare");
6
6
  const exec_1 = require("../../misc/exec");
7
+ const branch_1 = require("./branch");
7
8
  const hash_1 = require("./hash");
8
9
  async function downloadGitRepo(options) {
9
10
  const { remote, branch } = options;
10
11
  // Check for last commit
11
12
  const hasHashInTarget = options.target.indexOf('{hash}') !== -1;
12
- if (options.ifModifiedSince || hasHashInTarget) {
13
+ const ifModifiedSince = options.ifModifiedSince;
14
+ if (ifModifiedSince || hasHashInTarget) {
13
15
  // Get actual hash
14
16
  const result = await (0, exec_1.execAsync)(`git ls-remote ${remote} --branch ${branch}`);
15
17
  const parts = result.stdout.split(/\s/);
@@ -17,19 +19,26 @@ async function downloadGitRepo(options) {
17
19
  if (hasHashInTarget) {
18
20
  options.target = options.target.replace('{hash}', latestHash);
19
21
  }
20
- if (options.ifModifiedSince) {
21
- try {
22
+ try {
23
+ // Make sure correct branch is checked out. This will throw error if branch is not available
24
+ await (0, branch_1.getGitRepoBranch)(options, branch);
25
+ if (ifModifiedSince) {
22
26
  // Get expected hash
23
- const expectedHash = options.ifModifiedSince === true
27
+ const expectedHash = ifModifiedSince === true
24
28
  ? await (0, hash_1.getGitRepoHash)(options)
25
- : options.ifModifiedSince;
29
+ : typeof ifModifiedSince === 'string'
30
+ ? ifModifiedSince
31
+ : ifModifiedSince.downloadType === 'git'
32
+ ? ifModifiedSince.hash
33
+ : null;
26
34
  if (latestHash === expectedHash) {
27
35
  return 'not_modified';
28
36
  }
29
37
  }
30
- catch (err) {
31
- //
32
- }
38
+ }
39
+ catch (err) {
40
+ // Cleanup on error
41
+ options.cleanup = true;
33
42
  }
34
43
  }
35
44
  // Prepare target directory
@@ -42,10 +51,12 @@ async function downloadGitRepo(options) {
42
51
  }
43
52
  await (0, exec_1.execAsync)(`git clone --branch ${branch} --no-tags --depth 1 ${remote} "${target}"`);
44
53
  }
45
- // Get latest hash
54
+ // Get latest hash and make sure correct branch is available
46
55
  const hash = await (0, hash_1.getGitRepoHash)(options);
56
+ await (0, branch_1.getGitRepoBranch)(options, branch);
47
57
  return {
48
- target,
58
+ downloadType: 'git',
59
+ contentsDir: target,
49
60
  hash,
50
61
  };
51
62
  }
@@ -4,25 +4,29 @@ import {
4
4
  prepareDirectoryForExport
5
5
  } from "../../export/helpers/prepare.mjs";
6
6
  import { execAsync } from "../../misc/exec.mjs";
7
+ import { getGitRepoBranch } from "./branch.mjs";
7
8
  import { getGitRepoHash } from "./hash.mjs";
8
9
  async function downloadGitRepo(options) {
9
10
  const { remote, branch } = options;
10
11
  const hasHashInTarget = options.target.indexOf("{hash}") !== -1;
11
- if (options.ifModifiedSince || hasHashInTarget) {
12
+ const ifModifiedSince = options.ifModifiedSince;
13
+ if (ifModifiedSince || hasHashInTarget) {
12
14
  const result = await execAsync(`git ls-remote ${remote} --branch ${branch}`);
13
15
  const parts = result.stdout.split(/\s/);
14
16
  const latestHash = parts.shift();
15
17
  if (hasHashInTarget) {
16
18
  options.target = options.target.replace("{hash}", latestHash);
17
19
  }
18
- if (options.ifModifiedSince) {
19
- try {
20
- const expectedHash = options.ifModifiedSince === true ? await getGitRepoHash(options) : options.ifModifiedSince;
20
+ try {
21
+ await getGitRepoBranch(options, branch);
22
+ if (ifModifiedSince) {
23
+ const expectedHash = ifModifiedSince === true ? await getGitRepoHash(options) : typeof ifModifiedSince === "string" ? ifModifiedSince : ifModifiedSince.downloadType === "git" ? ifModifiedSince.hash : null;
21
24
  if (latestHash === expectedHash) {
22
25
  return "not_modified";
23
26
  }
24
- } catch (err) {
25
27
  }
28
+ } catch (err) {
29
+ options.cleanup = true;
26
30
  }
27
31
  }
28
32
  const target = options.target = await prepareDirectoryForExport(options);
@@ -34,8 +38,10 @@ async function downloadGitRepo(options) {
34
38
  await execAsync(`git clone --branch ${branch} --no-tags --depth 1 ${remote} "${target}"`);
35
39
  }
36
40
  const hash = await getGitRepoHash(options);
41
+ await getGitRepoBranch(options, branch);
37
42
  return {
38
- target,
43
+ downloadType: "git",
44
+ contentsDir: target,
39
45
  hash
40
46
  };
41
47
  }
@@ -1,8 +1,9 @@
1
1
  import { ExportTargetOptions } from '../../export/helpers/prepare';
2
2
  import type { DocumentNotModified } from '../types/modified';
3
3
  import type { GitHubAPIOptions } from './types';
4
+ import type { DownloadSourceMixin } from '../types/sources';
4
5
  interface IfModifiedSinceOption {
5
- ifModifiedSince: string;
6
+ ifModifiedSince: string | DownloadGitHubRepoResult;
6
7
  }
7
8
  /**
8
9
  * Options for downloadGitRepo()
@@ -15,9 +16,9 @@ export interface DownloadGitHubRepoOptions extends ExportTargetOptions, GitHubAP
15
16
  /**
16
17
  * Result
17
18
  */
18
- export interface DownloadGitHubRepoResult {
19
+ export interface DownloadGitHubRepoResult extends DownloadSourceMixin<'github'> {
19
20
  rootDir: string;
20
- actualDir: string;
21
+ contentsDir: string;
21
22
  hash: string;
22
23
  }
23
24
  /**
@@ -29,8 +29,16 @@ async function findMatchingDirs(rootDir, hash) {
29
29
  async function downloadGitHubRepo(options) {
30
30
  // Check for last commit
31
31
  const hash = await (0, hash_1.getGitHubRepoHash)(options);
32
- if (options.ifModifiedSince && hash === options.ifModifiedSince) {
33
- return 'not_modified';
32
+ const ifModifiedSince = options.ifModifiedSince;
33
+ if (ifModifiedSince) {
34
+ const expectedHash = typeof ifModifiedSince === 'string'
35
+ ? ifModifiedSince
36
+ : ifModifiedSince.downloadType === 'github'
37
+ ? ifModifiedSince.hash
38
+ : null;
39
+ if (hash === expectedHash) {
40
+ return 'not_modified';
41
+ }
34
42
  }
35
43
  // Replace hash in target
36
44
  options.target = options.target.replace('{hash}', hash);
@@ -97,10 +105,11 @@ async function downloadGitHubRepo(options) {
97
105
  if (matchingDirs.length !== 1) {
98
106
  throw new Error(`Error unpacking ${hash}.zip`);
99
107
  }
100
- const actualDir = rootDir + '/' + matchingDirs[0];
108
+ const contentsDir = rootDir + '/' + matchingDirs[0];
101
109
  return {
110
+ downloadType: 'github',
102
111
  rootDir,
103
- actualDir,
112
+ contentsDir,
104
113
  hash,
105
114
  };
106
115
  }
@@ -24,8 +24,12 @@ async function findMatchingDirs(rootDir, hash) {
24
24
  }
25
25
  async function downloadGitHubRepo(options) {
26
26
  const hash = await getGitHubRepoHash(options);
27
- if (options.ifModifiedSince && hash === options.ifModifiedSince) {
28
- return "not_modified";
27
+ const ifModifiedSince = options.ifModifiedSince;
28
+ if (ifModifiedSince) {
29
+ const expectedHash = typeof ifModifiedSince === "string" ? ifModifiedSince : ifModifiedSince.downloadType === "github" ? ifModifiedSince.hash : null;
30
+ if (hash === expectedHash) {
31
+ return "not_modified";
32
+ }
29
33
  }
30
34
  options.target = options.target.replace("{hash}", hash);
31
35
  const rootDir = options.target = await prepareDirectoryForExport(options);
@@ -71,10 +75,11 @@ async function downloadGitHubRepo(options) {
71
75
  if (matchingDirs.length !== 1) {
72
76
  throw new Error(`Error unpacking ${hash}.zip`);
73
77
  }
74
- const actualDir = rootDir + "/" + matchingDirs[0];
78
+ const contentsDir = rootDir + "/" + matchingDirs[0];
75
79
  return {
80
+ downloadType: "github",
76
81
  rootDir,
77
- actualDir,
82
+ contentsDir,
78
83
  hash
79
84
  };
80
85
  }
@@ -0,0 +1,20 @@
1
+ import { DownloadGitHubRepoOptions, DownloadGitHubRepoResult } from './github';
2
+ import { DownloadGitRepoOptions, DownloadGitRepoResult } from './git';
3
+ import { DownloadNPMPackageOptions, DownloadNPMPackageResult } from './npm';
4
+ import type { DocumentNotModified } from './types/modified';
5
+ import type { DownloadSourceMixin, DownloadSourceType } from './types/sources';
6
+ /**
7
+ * Add downloadType to options
8
+ */
9
+ declare type ExtendedDownloadGitRepoOptions = DownloadGitRepoOptions & DownloadSourceMixin<'git'>;
10
+ declare type ExtendedDownloadGitHubRepoOptions = DownloadGitHubRepoOptions & DownloadSourceMixin<'github'>;
11
+ declare type ExtendedDownloadNPMPackageOptions = DownloadNPMPackageOptions & DownloadSourceMixin<'npm'>;
12
+ export declare type DownloadOptions<T extends DownloadSourceType> = T extends 'git' ? ExtendedDownloadGitRepoOptions : T extends 'github' ? ExtendedDownloadGitHubRepoOptions : T extends 'npm' ? ExtendedDownloadNPMPackageOptions : never;
13
+ /**
14
+ * Result type from downloadType
15
+ */
16
+ export declare type DownloadResult<T extends DownloadSourceType> = T extends 'git' ? DownloadGitRepoResult : T extends 'github' ? DownloadGitHubRepoResult : T extends 'npm' ? DownloadNPMPackageResult : never;
17
+ export declare function downloadPackage<T extends 'git'>(options: DownloadOptions<T>): Promise<DocumentNotModified | DownloadResult<T>>;
18
+ export declare function downloadPackage<T extends 'github'>(options: DownloadOptions<T>): Promise<DocumentNotModified | DownloadResult<T>>;
19
+ export declare function downloadPackage<T extends 'npm'>(options: DownloadOptions<T>): Promise<DocumentNotModified | DownloadResult<T>>;
20
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.downloadPackage = void 0;
4
+ const github_1 = require("./github");
5
+ const git_1 = require("./git");
6
+ const npm_1 = require("./npm");
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
+ function assertNever(v) {
9
+ //
10
+ }
11
+ function downloadPackage(options) {
12
+ const type = options.downloadType;
13
+ switch (type) {
14
+ case 'git': {
15
+ return (0, git_1.downloadGitRepo)(options);
16
+ }
17
+ case 'github':
18
+ return (0, github_1.downloadGitHubRepo)(options);
19
+ case 'npm':
20
+ return (0, npm_1.downloadNPMPackage)(options);
21
+ default:
22
+ assertNever(type);
23
+ throw new Error(`Invalid download type: ${type}`);
24
+ }
25
+ }
26
+ exports.downloadPackage = downloadPackage;
@@ -0,0 +1,30 @@
1
+ // src/download/index.ts
2
+ import {
3
+ downloadGitHubRepo
4
+ } from "./github/index.mjs";
5
+ import {
6
+ downloadGitRepo
7
+ } from "./git/index.mjs";
8
+ import {
9
+ downloadNPMPackage
10
+ } from "./npm/index.mjs";
11
+ function assertNever(v) {
12
+ }
13
+ function downloadPackage(options) {
14
+ const type = options.downloadType;
15
+ switch (type) {
16
+ case "git": {
17
+ return downloadGitRepo(options);
18
+ }
19
+ case "github":
20
+ return downloadGitHubRepo(options);
21
+ case "npm":
22
+ return downloadNPMPackage(options);
23
+ default:
24
+ assertNever(type);
25
+ throw new Error(`Invalid download type: ${type}`);
26
+ }
27
+ }
28
+ export {
29
+ downloadPackage
30
+ };
@@ -1,7 +1,8 @@
1
1
  import { ExportTargetOptions } from '../../export/helpers/prepare';
2
2
  import type { DocumentNotModified } from '../types/modified';
3
+ import type { DownloadSourceMixin } from '../types/sources';
3
4
  interface IfModifiedSinceOption {
4
- ifModifiedSince: string | true;
5
+ ifModifiedSince: string | true | DownloadNPMPackageResult;
5
6
  }
6
7
  /**
7
8
  * Options for downloadNPMPackage()
@@ -14,9 +15,9 @@ export interface DownloadNPMPackageOptions extends ExportTargetOptions, Partial<
14
15
  /**
15
16
  * Result
16
17
  */
17
- export interface DownloadNPMPackageResult {
18
+ export interface DownloadNPMPackageResult extends DownloadSourceMixin<'npm'> {
18
19
  rootDir: string;
19
- actualDir: string;
20
+ contentsDir: string;
20
21
  version: string;
21
22
  }
22
23
  /**
@@ -8,22 +8,39 @@ const untar_1 = require("../helpers/untar");
8
8
  const version_1 = require("./version");
9
9
  async function downloadNPMPackage(options) {
10
10
  const rootDir = (options.target = (0, prepare_1.normalizeDir)(options.target));
11
- const actualDir = rootDir + '/package';
11
+ const contentsDir = rootDir + '/package';
12
12
  // Get latest location
13
13
  const versionInfo = await (0, version_1.getNPMVersion)(options);
14
14
  const version = versionInfo.version;
15
15
  // Check downloaded copy
16
- if (options.ifModifiedSince) {
16
+ const ifModifiedSince = options.ifModifiedSince;
17
+ if (ifModifiedSince) {
17
18
  try {
18
- const expectedVersion = options.ifModifiedSince === true
19
- ? await (0, version_1.getPackageVersion)(actualDir)
20
- : options.ifModifiedSince;
19
+ let expectedVersion;
20
+ if (typeof ifModifiedSince === 'object') {
21
+ // Make sure result object matches
22
+ if (ifModifiedSince.downloadType === 'npm' &&
23
+ ifModifiedSince.rootDir === rootDir &&
24
+ ifModifiedSince.contentsDir === contentsDir) {
25
+ expectedVersion = ifModifiedSince.version;
26
+ }
27
+ else {
28
+ expectedVersion = null;
29
+ }
30
+ }
31
+ else {
32
+ expectedVersion =
33
+ ifModifiedSince === true
34
+ ? await (0, version_1.getPackageVersion)(contentsDir)
35
+ : ifModifiedSince;
36
+ }
21
37
  if (version === expectedVersion) {
22
38
  return 'not_modified';
23
39
  }
24
40
  }
25
41
  catch (err) {
26
- //
42
+ // Clean up on error
43
+ options.cleanup = true;
27
44
  }
28
45
  }
29
46
  const archiveURL = versionInfo.file;
@@ -56,7 +73,7 @@ async function downloadNPMPackage(options) {
56
73
  }
57
74
  // Remove old unpacked file
58
75
  await (0, prepare_1.prepareDirectoryForExport)({
59
- target: actualDir,
76
+ target: contentsDir,
60
77
  cleanup: true,
61
78
  });
62
79
  // Unpack file
@@ -65,8 +82,9 @@ async function downloadNPMPackage(options) {
65
82
  }
66
83
  await (0, untar_1.untar)(archiveTarget, rootDir);
67
84
  return {
85
+ downloadType: 'npm',
68
86
  rootDir,
69
- actualDir,
87
+ contentsDir,
70
88
  version,
71
89
  };
72
90
  }
@@ -9,16 +9,27 @@ import { untar } from "../helpers/untar.mjs";
9
9
  import { getNPMVersion, getPackageVersion } from "./version.mjs";
10
10
  async function downloadNPMPackage(options) {
11
11
  const rootDir = options.target = normalizeDir(options.target);
12
- const actualDir = rootDir + "/package";
12
+ const contentsDir = rootDir + "/package";
13
13
  const versionInfo = await getNPMVersion(options);
14
14
  const version = versionInfo.version;
15
- if (options.ifModifiedSince) {
15
+ const ifModifiedSince = options.ifModifiedSince;
16
+ if (ifModifiedSince) {
16
17
  try {
17
- const expectedVersion = options.ifModifiedSince === true ? await getPackageVersion(actualDir) : options.ifModifiedSince;
18
+ let expectedVersion;
19
+ if (typeof ifModifiedSince === "object") {
20
+ if (ifModifiedSince.downloadType === "npm" && ifModifiedSince.rootDir === rootDir && ifModifiedSince.contentsDir === contentsDir) {
21
+ expectedVersion = ifModifiedSince.version;
22
+ } else {
23
+ expectedVersion = null;
24
+ }
25
+ } else {
26
+ expectedVersion = ifModifiedSince === true ? await getPackageVersion(contentsDir) : ifModifiedSince;
27
+ }
18
28
  if (version === expectedVersion) {
19
29
  return "not_modified";
20
30
  }
21
31
  } catch (err) {
32
+ options.cleanup = true;
22
33
  }
23
34
  }
24
35
  const archiveURL = versionInfo.file;
@@ -45,7 +56,7 @@ async function downloadNPMPackage(options) {
45
56
  }, archiveTarget);
46
57
  }
47
58
  await prepareDirectoryForExport({
48
- target: actualDir,
59
+ target: contentsDir,
49
60
  cleanup: true
50
61
  });
51
62
  if (options.log) {
@@ -53,8 +64,9 @@ async function downloadNPMPackage(options) {
53
64
  }
54
65
  await untar(archiveTarget, rootDir);
55
66
  return {
67
+ downloadType: "npm",
56
68
  rootDir,
57
- actualDir,
69
+ contentsDir,
58
70
  version
59
71
  };
60
72
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Download types
3
+ */
4
+ export declare type DownloadSourceType = 'git' | 'github' | 'npm';
5
+ /**
6
+ * Type in other objects
7
+ */
8
+ export interface DownloadSourceMixin<T extends DownloadSourceType> {
9
+ downloadType: T;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
package/lib/index.d.ts CHANGED
@@ -13,10 +13,12 @@ export { importFromFigma } from './import/figma/index';
13
13
  export { importDirectory } from './import/directory';
14
14
  export { downloadGitRepo } from './download/git/index';
15
15
  export { getGitRepoHash } from './download/git/hash';
16
+ export { getGitRepoBranch } from './download/git/branch';
16
17
  export { downloadGitHubRepo } from './download/github/index';
17
18
  export { getGitHubRepoHash } from './download/github/hash';
18
19
  export { downloadNPMPackage } from './download/npm/index';
19
20
  export { getNPMVersion, getPackageVersion } from './download/npm/version';
21
+ export { downloadPackage } from './download/index';
20
22
  export { parseColors, isEmptyColor } from './colors/parse';
21
23
  export { validateColors } from './colors/validate';
22
24
  export { runSVGO } from './optimise/svgo';
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.getPackageVersion = exports.getNPMVersion = exports.downloadNPMPackage = exports.getGitHubRepoHash = exports.downloadGitHubRepo = 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.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; } });
@@ -37,6 +37,8 @@ var index_4 = require("./download/git/index");
37
37
  Object.defineProperty(exports, "downloadGitRepo", { enumerable: true, get: function () { return index_4.downloadGitRepo; } });
38
38
  var hash_1 = require("./download/git/hash");
39
39
  Object.defineProperty(exports, "getGitRepoHash", { enumerable: true, get: function () { return hash_1.getGitRepoHash; } });
40
+ var branch_1 = require("./download/git/branch");
41
+ Object.defineProperty(exports, "getGitRepoBranch", { enumerable: true, get: function () { return branch_1.getGitRepoBranch; } });
40
42
  var index_5 = require("./download/github/index");
41
43
  Object.defineProperty(exports, "downloadGitHubRepo", { enumerable: true, get: function () { return index_5.downloadGitHubRepo; } });
42
44
  var hash_2 = require("./download/github/hash");
@@ -46,6 +48,8 @@ Object.defineProperty(exports, "downloadNPMPackage", { enumerable: true, get: fu
46
48
  var version_1 = require("./download/npm/version");
47
49
  Object.defineProperty(exports, "getNPMVersion", { enumerable: true, get: function () { return version_1.getNPMVersion; } });
48
50
  Object.defineProperty(exports, "getPackageVersion", { enumerable: true, get: function () { return version_1.getPackageVersion; } });
51
+ var index_7 = require("./download/index");
52
+ Object.defineProperty(exports, "downloadPackage", { enumerable: true, get: function () { return index_7.downloadPackage; } });
49
53
  // Manipulation
50
54
  var parse_2 = require("./colors/parse");
51
55
  Object.defineProperty(exports, "parseColors", { enumerable: true, get: function () { return parse_2.parseColors; } });
@@ -85,5 +89,5 @@ var keyword_1 = require("./misc/keyword");
85
89
  Object.defineProperty(exports, "cleanupIconKeyword", { enumerable: true, get: function () { return keyword_1.cleanupIconKeyword; } });
86
90
  var bump_version_1 = require("./misc/bump-version");
87
91
  Object.defineProperty(exports, "bumpVersion", { enumerable: true, get: function () { return bump_version_1.bumpVersion; } });
88
- var index_7 = require("./download/api/index");
89
- Object.defineProperty(exports, "sendAPIQuery", { enumerable: true, get: function () { return index_7.sendAPIQuery; } });
92
+ var index_8 = require("./download/api/index");
93
+ Object.defineProperty(exports, "sendAPIQuery", { enumerable: true, get: function () { return index_8.sendAPIQuery; } });
package/lib/index.mjs CHANGED
@@ -14,10 +14,12 @@ import { importFromFigma } from "./import/figma/index.mjs";
14
14
  import { importDirectory } from "./import/directory.mjs";
15
15
  import { downloadGitRepo } from "./download/git/index.mjs";
16
16
  import { getGitRepoHash } from "./download/git/hash.mjs";
17
+ import { getGitRepoBranch } from "./download/git/branch.mjs";
17
18
  import { downloadGitHubRepo } from "./download/github/index.mjs";
18
19
  import { getGitHubRepoHash } from "./download/github/hash.mjs";
19
20
  import { downloadNPMPackage } from "./download/npm/index.mjs";
20
21
  import { getNPMVersion, getPackageVersion } from "./download/npm/version.mjs";
22
+ import { downloadPackage } from "./download/index.mjs";
21
23
  import { parseColors, isEmptyColor } from "./colors/parse.mjs";
22
24
  import { validateColors } from "./colors/validate.mjs";
23
25
  import { runSVGO } from "./optimise/svgo.mjs";
@@ -52,11 +54,13 @@ export {
52
54
  downloadGitHubRepo,
53
55
  downloadGitRepo,
54
56
  downloadNPMPackage,
57
+ downloadPackage,
55
58
  execAsync,
56
59
  exportIconPackage,
57
60
  exportJSONPackage,
58
61
  exportToDirectory,
59
62
  getGitHubRepoHash,
63
+ getGitRepoBranch,
60
64
  getGitRepoHash,
61
65
  getNPMVersion,
62
66
  getPackageVersion,
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.6",
5
+ "version": "2.0.7",
6
6
  "license": "MIT",
7
7
  "bugs": "https://github.com/iconify/tools/issues",
8
8
  "homepage": "https://github.com/iconify/tools",
@@ -104,6 +104,10 @@
104
104
  "require": "./lib/download/api/types.js",
105
105
  "import": "./lib/download/api/types.mjs"
106
106
  },
107
+ "./lib/download/git/branch": {
108
+ "require": "./lib/download/git/branch.js",
109
+ "import": "./lib/download/git/branch.mjs"
110
+ },
107
111
  "./lib/download/git/hash": {
108
112
  "require": "./lib/download/git/hash.js",
109
113
  "import": "./lib/download/git/hash.mjs"
@@ -140,6 +144,14 @@
140
144
  "require": "./lib/download/helpers/unzip.js",
141
145
  "import": "./lib/download/helpers/unzip.mjs"
142
146
  },
147
+ "./lib/download": {
148
+ "require": "./lib/download/index.js",
149
+ "import": "./lib/download/index.mjs"
150
+ },
151
+ "./lib/download/index": {
152
+ "require": "./lib/download/index.js",
153
+ "import": "./lib/download/index.mjs"
154
+ },
143
155
  "./lib/download/npm": {
144
156
  "require": "./lib/download/npm/index.js",
145
157
  "import": "./lib/download/npm/index.mjs"
@@ -160,6 +172,10 @@
160
172
  "require": "./lib/download/types/modified.js",
161
173
  "import": "./lib/download/types/modified.mjs"
162
174
  },
175
+ "./lib/download/types/sources": {
176
+ "require": "./lib/download/types/sources.js",
177
+ "import": "./lib/download/types/sources.mjs"
178
+ },
163
179
  "./lib/export/directory": {
164
180
  "require": "./lib/export/directory.js",
165
181
  "import": "./lib/export/directory.mjs"