@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.
Files changed (309) hide show
  1. package/lib/colors/attribs.cjs +30 -0
  2. package/lib/colors/attribs.d.ts +13 -10
  3. package/lib/colors/attribs.mjs +7 -13
  4. package/lib/colors/parse.cjs +269 -0
  5. package/lib/colors/parse.d.ts +15 -11
  6. package/lib/colors/parse.mjs +27 -31
  7. package/lib/colors/validate.cjs +52 -0
  8. package/lib/colors/validate.d.ts +11 -4
  9. package/lib/colors/validate.mjs +19 -6
  10. package/lib/css/parse.cjs +26 -0
  11. package/lib/css/parse.d.ts +3 -1
  12. package/lib/css/parse.mjs +8 -6
  13. package/lib/css/parser/error.cjs +25 -0
  14. package/lib/css/parser/error.d.ts +4 -2
  15. package/lib/css/parser/error.mjs +2 -4
  16. package/lib/css/parser/export.cjs +48 -0
  17. package/lib/css/parser/export.d.ts +5 -2
  18. package/lib/css/parser/export.mjs +4 -6
  19. package/lib/css/parser/strings.cjs +77 -0
  20. package/lib/css/parser/strings.d.ts +6 -3
  21. package/lib/css/parser/strings.mjs +4 -6
  22. package/lib/css/parser/text.cjs +135 -0
  23. package/lib/css/parser/text.d.ts +8 -5
  24. package/lib/css/parser/text.mjs +3 -8
  25. package/lib/css/parser/tokens.cjs +184 -0
  26. package/lib/css/parser/tokens.d.ts +6 -3
  27. package/lib/css/parser/tokens.mjs +7 -13
  28. package/lib/css/parser/tree.cjs +42 -0
  29. package/lib/css/parser/tree.d.ts +5 -2
  30. package/lib/css/parser/tree.mjs +2 -4
  31. package/lib/css/parser/types.cjs +2 -0
  32. package/lib/css/parser/types.d.ts +13 -11
  33. package/lib/css/parser/types.mjs +1 -0
  34. package/lib/download/api/cache.cjs +86 -0
  35. package/lib/download/api/cache.d.ts +8 -5
  36. package/lib/download/api/cache.mjs +14 -19
  37. package/lib/download/api/download.cjs +28 -0
  38. package/lib/download/api/download.d.ts +5 -2
  39. package/lib/download/api/download.mjs +8 -9
  40. package/lib/download/api/index.cjs +51 -0
  41. package/lib/download/api/index.d.ts +5 -2
  42. package/lib/download/api/index.mjs +8 -6
  43. package/lib/download/api/types.cjs +2 -0
  44. package/lib/download/api/types.d.ts +4 -2
  45. package/lib/download/api/types.mjs +1 -0
  46. package/lib/download/git/branch.cjs +22 -0
  47. package/lib/download/git/branch.d.ts +5 -2
  48. package/lib/download/git/branch.mjs +5 -5
  49. package/lib/download/git/hash.cjs +15 -0
  50. package/lib/download/git/hash.d.ts +5 -2
  51. package/lib/download/git/hash.mjs +5 -5
  52. package/lib/download/git/index.cjs +76 -0
  53. package/lib/download/git/index.d.ts +10 -8
  54. package/lib/download/git/index.mjs +41 -26
  55. package/lib/download/git/reset.cjs +41 -0
  56. package/lib/download/git/reset.d.ts +3 -1
  57. package/lib/download/git/reset.mjs +29 -5
  58. package/lib/download/github/hash.cjs +32 -0
  59. package/lib/download/github/hash.d.ts +5 -2
  60. package/lib/download/github/hash.mjs +10 -7
  61. package/lib/download/github/index.cjs +98 -0
  62. package/lib/download/github/index.d.ts +11 -9
  63. package/lib/download/github/index.mjs +23 -17
  64. package/lib/download/github/types.cjs +2 -0
  65. package/lib/download/github/types.d.ts +3 -1
  66. package/lib/download/github/types.mjs +1 -0
  67. package/lib/download/gitlab/hash.cjs +32 -0
  68. package/lib/download/gitlab/hash.d.ts +5 -2
  69. package/lib/download/gitlab/hash.mjs +10 -6
  70. package/lib/download/gitlab/index.cjs +98 -0
  71. package/lib/download/gitlab/index.d.ts +11 -9
  72. package/lib/download/gitlab/index.mjs +24 -18
  73. package/lib/download/gitlab/types.cjs +7 -0
  74. package/lib/download/gitlab/types.d.ts +4 -2
  75. package/lib/download/gitlab/types.mjs +3 -5
  76. package/lib/download/helpers/untar.cjs +14 -0
  77. package/lib/download/helpers/untar.d.ts +3 -1
  78. package/lib/download/helpers/untar.mjs +4 -5
  79. package/lib/download/helpers/unzip.cjs +19 -0
  80. package/lib/download/helpers/unzip.d.ts +3 -1
  81. package/lib/download/helpers/unzip.mjs +6 -7
  82. package/lib/download/index.cjs +64 -0
  83. package/lib/download/index.d.ts +18 -13
  84. package/lib/download/index.mjs +46 -19
  85. package/lib/download/npm/index.cjs +82 -0
  86. package/lib/download/npm/index.d.ts +10 -8
  87. package/lib/download/npm/index.mjs +16 -13
  88. package/lib/download/npm/types.cjs +2 -0
  89. package/lib/download/npm/types.d.ts +3 -1
  90. package/lib/download/npm/types.mjs +1 -0
  91. package/lib/download/npm/version.cjs +23 -0
  92. package/lib/download/npm/version.d.ts +7 -4
  93. package/lib/download/npm/version.mjs +8 -10
  94. package/lib/download/types/modified.cjs +2 -0
  95. package/lib/download/types/modified.d.ts +3 -1
  96. package/lib/download/types/modified.mjs +1 -0
  97. package/lib/download/types/sources.cjs +2 -0
  98. package/lib/download/types/sources.d.ts +4 -2
  99. package/lib/download/types/sources.mjs +1 -0
  100. package/lib/export/directory.cjs +45 -0
  101. package/lib/export/directory.d.ts +11 -4
  102. package/lib/export/directory.mjs +8 -8
  103. package/lib/export/helpers/custom-files.cjs +28 -0
  104. package/lib/export/helpers/custom-files.d.ts +4 -2
  105. package/lib/export/helpers/custom-files.mjs +8 -9
  106. package/lib/export/helpers/prepare.cjs +36 -0
  107. package/lib/export/helpers/prepare.d.ts +5 -3
  108. package/lib/export/helpers/prepare.mjs +7 -9
  109. package/lib/export/helpers/types-version.cjs +22 -0
  110. package/lib/export/helpers/types-version.d.ts +3 -1
  111. package/lib/export/helpers/types-version.mjs +15 -37
  112. package/lib/export/icon-package.cjs +59 -0
  113. package/lib/export/icon-package.d.ts +12 -5
  114. package/lib/export/icon-package.mjs +15 -16
  115. package/lib/export/json-package.cjs +133 -0
  116. package/lib/export/json-package.d.ts +12 -5
  117. package/lib/export/json-package.mjs +20 -21
  118. package/lib/icon-set/index.cjs +589 -0
  119. package/lib/icon-set/index.d.ts +9 -6
  120. package/lib/icon-set/index.mjs +40 -53
  121. package/lib/icon-set/match.cjs +58 -0
  122. package/lib/icon-set/match.d.ts +10 -3
  123. package/lib/icon-set/match.mjs +5 -6
  124. package/lib/icon-set/merge.cjs +83 -0
  125. package/lib/icon-set/merge.d.ts +9 -2
  126. package/lib/icon-set/merge.mjs +15 -10
  127. package/lib/icon-set/props.cjs +28 -0
  128. package/lib/icon-set/props.d.ts +8 -4
  129. package/lib/icon-set/props.mjs +7 -10
  130. package/lib/icon-set/types.cjs +2 -0
  131. package/lib/icon-set/types.d.ts +19 -17
  132. package/lib/icon-set/types.mjs +1 -0
  133. package/lib/import/directory.cjs +76 -0
  134. package/lib/import/directory.d.ts +11 -5
  135. package/lib/import/directory.mjs +36 -11
  136. package/lib/import/figma/index.cjs +105 -0
  137. package/lib/import/figma/index.d.ts +15 -5
  138. package/lib/import/figma/index.mjs +40 -13
  139. package/lib/import/figma/nodes.cjs +86 -0
  140. package/lib/import/figma/nodes.d.ts +13 -4
  141. package/lib/import/figma/nodes.mjs +3 -11
  142. package/lib/import/figma/query.cjs +218 -0
  143. package/lib/import/figma/query.d.ts +18 -9
  144. package/lib/import/figma/query.mjs +9 -12
  145. package/lib/import/figma/types/api.cjs +2 -0
  146. package/lib/import/figma/types/api.d.ts +8 -7
  147. package/lib/import/figma/types/api.mjs +1 -0
  148. package/lib/import/figma/types/nodes.cjs +2 -0
  149. package/lib/import/figma/types/nodes.d.ts +16 -9
  150. package/lib/import/figma/types/nodes.mjs +1 -0
  151. package/lib/import/figma/types/options.cjs +2 -0
  152. package/lib/import/figma/types/options.d.ts +17 -10
  153. package/lib/import/figma/types/options.mjs +1 -0
  154. package/lib/import/figma/types/result.cjs +2 -0
  155. package/lib/import/figma/types/result.d.ts +12 -5
  156. package/lib/import/figma/types/result.mjs +1 -0
  157. package/lib/index.cjs +137 -0
  158. package/lib/index.d.ts +65 -44
  159. package/lib/index.mjs +83 -94
  160. package/lib/misc/bump-version.cjs +17 -0
  161. package/lib/misc/bump-version.d.ts +3 -1
  162. package/lib/misc/bump-version.mjs +2 -4
  163. package/lib/misc/compare-dirs.cjs +75 -0
  164. package/lib/misc/compare-dirs.d.ts +4 -2
  165. package/lib/misc/compare-dirs.mjs +12 -12
  166. package/lib/misc/exec.cjs +25 -0
  167. package/lib/misc/exec.d.ts +6 -4
  168. package/lib/misc/exec.mjs +4 -5
  169. package/lib/misc/keyword.cjs +19 -0
  170. package/lib/misc/keyword.d.ts +3 -1
  171. package/lib/misc/keyword.mjs +2 -4
  172. package/lib/misc/scan.cjs +51 -0
  173. package/lib/misc/scan.d.ts +7 -6
  174. package/lib/misc/scan.mjs +6 -7
  175. package/lib/misc/write-json.cjs +11 -0
  176. package/lib/misc/write-json.d.ts +3 -1
  177. package/lib/misc/write-json.mjs +5 -6
  178. package/lib/optimise/flags.cjs +252 -0
  179. package/lib/optimise/flags.d.ts +7 -2
  180. package/lib/optimise/flags.mjs +18 -19
  181. package/lib/optimise/global-style.cjs +154 -0
  182. package/lib/optimise/global-style.d.ts +7 -2
  183. package/lib/optimise/global-style.mjs +18 -15
  184. package/lib/optimise/scale.cjs +26 -0
  185. package/lib/optimise/scale.d.ts +7 -2
  186. package/lib/optimise/scale.mjs +5 -5
  187. package/lib/optimise/svgo.cjs +83 -0
  188. package/lib/optimise/svgo.d.ts +10 -6
  189. package/lib/optimise/svgo.mjs +6 -9
  190. package/lib/svg/analyse/error.cjs +18 -0
  191. package/lib/svg/analyse/error.d.ts +5 -2
  192. package/lib/svg/analyse/error.mjs +2 -4
  193. package/lib/svg/analyse/types.cjs +2 -0
  194. package/lib/svg/analyse/types.d.ts +11 -11
  195. package/lib/svg/analyse/types.mjs +1 -0
  196. package/lib/svg/analyse.cjs +291 -0
  197. package/lib/svg/analyse.d.ts +8 -3
  198. package/lib/svg/analyse.mjs +15 -30
  199. package/lib/svg/cleanup/attribs.cjs +41 -0
  200. package/lib/svg/cleanup/attribs.d.ts +7 -2
  201. package/lib/svg/cleanup/attribs.mjs +6 -12
  202. package/lib/svg/cleanup/bad-tags.cjs +51 -0
  203. package/lib/svg/cleanup/bad-tags.d.ts +7 -2
  204. package/lib/svg/cleanup/bad-tags.mjs +10 -25
  205. package/lib/svg/cleanup/inline-style.cjs +64 -0
  206. package/lib/svg/cleanup/inline-style.d.ts +7 -2
  207. package/lib/svg/cleanup/inline-style.mjs +14 -19
  208. package/lib/svg/cleanup/root-svg.cjs +81 -0
  209. package/lib/svg/cleanup/root-svg.d.ts +7 -2
  210. package/lib/svg/cleanup/root-svg.mjs +7 -18
  211. package/lib/svg/cleanup/svgo-style.cjs +38 -0
  212. package/lib/svg/cleanup/svgo-style.d.ts +7 -2
  213. package/lib/svg/cleanup/svgo-style.mjs +16 -11
  214. package/lib/svg/cleanup.cjs +32 -0
  215. package/lib/svg/cleanup.d.ts +7 -2
  216. package/lib/svg/cleanup.mjs +21 -9
  217. package/lib/svg/data/attributes.cjs +355 -0
  218. package/lib/svg/data/attributes.d.ts +27 -25
  219. package/lib/svg/data/attributes.mjs +90 -115
  220. package/lib/svg/data/tags.cjs +137 -0
  221. package/lib/svg/data/tags.d.ts +25 -23
  222. package/lib/svg/data/tags.mjs +25 -49
  223. package/lib/svg/index.cjs +130 -0
  224. package/lib/svg/index.d.ts +16 -5
  225. package/lib/svg/index.mjs +48 -14
  226. package/lib/svg/parse-style.cjs +134 -0
  227. package/lib/svg/parse-style.d.ts +12 -8
  228. package/lib/svg/parse-style.mjs +11 -9
  229. package/lib/svg/parse.cjs +42 -0
  230. package/lib/svg/parse.d.ts +11 -7
  231. package/lib/svg/parse.mjs +2 -4
  232. package/package.json +99 -94
  233. package/lib/colors/attribs.js +0 -26
  234. package/lib/colors/parse.js +0 -341
  235. package/lib/colors/validate.js +0 -48
  236. package/lib/css/parse.js +0 -23
  237. package/lib/css/parser/error.js +0 -27
  238. package/lib/css/parser/export.js +0 -69
  239. package/lib/css/parser/strings.js +0 -93
  240. package/lib/css/parser/text.js +0 -171
  241. package/lib/css/parser/tokens.js +0 -200
  242. package/lib/css/parser/tree.js +0 -44
  243. package/lib/css/parser/types.js +0 -2
  244. package/lib/download/api/cache.js +0 -108
  245. package/lib/download/api/download.js +0 -27
  246. package/lib/download/api/index.js +0 -52
  247. package/lib/download/api/types.js +0 -2
  248. package/lib/download/git/branch.js +0 -22
  249. package/lib/download/git/hash.js +0 -14
  250. package/lib/download/git/index.js +0 -75
  251. package/lib/download/git/reset.js +0 -16
  252. package/lib/download/github/hash.js +0 -28
  253. package/lib/download/github/index.js +0 -116
  254. package/lib/download/github/types.js +0 -2
  255. package/lib/download/gitlab/hash.js +0 -27
  256. package/lib/download/gitlab/index.js +0 -115
  257. package/lib/download/gitlab/types.js +0 -7
  258. package/lib/download/helpers/untar.js +0 -14
  259. package/lib/download/helpers/unzip.js +0 -18
  260. package/lib/download/index.js +0 -27
  261. package/lib/download/npm/index.js +0 -91
  262. package/lib/download/npm/types.js +0 -2
  263. package/lib/download/npm/version.js +0 -27
  264. package/lib/download/types/modified.js +0 -2
  265. package/lib/download/types/sources.js +0 -2
  266. package/lib/export/directory.js +0 -52
  267. package/lib/export/helpers/custom-files.js +0 -32
  268. package/lib/export/helpers/prepare.js +0 -49
  269. package/lib/export/helpers/types-version.js +0 -12
  270. package/lib/export/icon-package.js +0 -77
  271. package/lib/export/json-package.js +0 -156
  272. package/lib/icon-set/index.js +0 -749
  273. package/lib/icon-set/match.js +0 -66
  274. package/lib/icon-set/merge.js +0 -90
  275. package/lib/icon-set/props.js +0 -34
  276. package/lib/icon-set/types.js +0 -2
  277. package/lib/import/directory.js +0 -59
  278. package/lib/import/figma/index.js +0 -90
  279. package/lib/import/figma/nodes.js +0 -106
  280. package/lib/import/figma/query.js +0 -244
  281. package/lib/import/figma/types/api.js +0 -12
  282. package/lib/import/figma/types/nodes.js +0 -2
  283. package/lib/import/figma/types/options.js +0 -2
  284. package/lib/import/figma/types/result.js +0 -2
  285. package/lib/index.js +0 -103
  286. package/lib/misc/bump-version.js +0 -19
  287. package/lib/misc/compare-dirs.js +0 -84
  288. package/lib/misc/exec.js +0 -26
  289. package/lib/misc/keyword.js +0 -31
  290. package/lib/misc/scan.js +0 -55
  291. package/lib/misc/write-json.js +0 -11
  292. package/lib/optimise/flags.js +0 -312
  293. package/lib/optimise/global-style.js +0 -185
  294. package/lib/optimise/scale.js +0 -42
  295. package/lib/optimise/svgo.js +0 -99
  296. package/lib/svg/analyse/error.js +0 -22
  297. package/lib/svg/analyse/types.js +0 -2
  298. package/lib/svg/analyse.js +0 -352
  299. package/lib/svg/cleanup/attribs.js +0 -51
  300. package/lib/svg/cleanup/bad-tags.js +0 -65
  301. package/lib/svg/cleanup/inline-style.js +0 -77
  302. package/lib/svg/cleanup/root-svg.js +0 -107
  303. package/lib/svg/cleanup/svgo-style.js +0 -35
  304. package/lib/svg/cleanup.js +0 -24
  305. package/lib/svg/data/attributes.js +0 -403
  306. package/lib/svg/data/tags.js +0 -188
  307. package/lib/svg/index.js +0 -134
  308. package/lib/svg/parse-style.js +0 -151
  309. package/lib/svg/parse.js +0 -49
@@ -1,6 +1,11 @@
1
- // src/download/gitlab/hash.ts
2
- import { sendAPIQuery } from "../api/index.mjs";
3
- import { defaultGitLabBaseURI } from "./types.mjs";
1
+ import { sendAPIQuery } from '../api/index.mjs';
2
+ import { defaultGitLabBaseURI } from './types.mjs';
3
+ import 'node-fetch';
4
+ import '../api/cache.mjs';
5
+ import 'fs';
6
+ import 'crypto';
7
+ import '../../misc/scan.mjs';
8
+
4
9
  async function getGitLabRepoHash(options) {
5
10
  const uri = `${options.uri || defaultGitLabBaseURI}/${options.project}/repository/branches/${options.branch}/`;
6
11
  const data = await sendAPIQuery({
@@ -19,6 +24,5 @@ async function getGitLabRepoHash(options) {
19
24
  }
20
25
  return item.commit.id;
21
26
  }
22
- export {
23
- getGitLabRepoHash
24
- };
27
+
28
+ export { getGitLabRepoHash };
@@ -0,0 +1,98 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const fs = require('fs');
6
+ const export_helpers_prepare = require('../../export/helpers/prepare.cjs');
7
+ const download_gitlab_hash = require('./hash.cjs');
8
+ const download_gitlab_types = require('./types.cjs');
9
+ const download_api_download = require('../api/download.cjs');
10
+ const download_helpers_unzip = require('../helpers/unzip.cjs');
11
+ require('pathe');
12
+ require('../api/index.cjs');
13
+ require('node-fetch');
14
+ require('../api/cache.cjs');
15
+ require('crypto');
16
+ require('../../misc/scan.cjs');
17
+ require('util');
18
+ require('stream');
19
+ require('extract-zip');
20
+
21
+ async function findMatchingDirs(rootDir, hash) {
22
+ const matches = [];
23
+ const files = await fs.promises.readdir(rootDir);
24
+ for (let i = 0; i < files.length; i++) {
25
+ const file = files[i];
26
+ const lastChunk = file.split("-").pop();
27
+ if (lastChunk.length < 4 || lastChunk !== hash.slice(0, lastChunk.length)) {
28
+ continue;
29
+ }
30
+ const stat = await fs.promises.stat(rootDir + "/" + file);
31
+ if (stat.isDirectory()) {
32
+ matches.push(file);
33
+ }
34
+ }
35
+ return matches;
36
+ }
37
+ async function downloadGitLabRepo(options) {
38
+ const hash = await download_gitlab_hash.getGitLabRepoHash(options);
39
+ const ifModifiedSince = options.ifModifiedSince;
40
+ if (ifModifiedSince) {
41
+ const expectedHash = typeof ifModifiedSince === "string" ? ifModifiedSince : ifModifiedSince.downloadType === "gitlab" ? ifModifiedSince.hash : null;
42
+ if (hash === expectedHash) {
43
+ return "not_modified";
44
+ }
45
+ }
46
+ options.target = options.target.replace("{hash}", hash);
47
+ const rootDir = options.target = await export_helpers_prepare.prepareDirectoryForExport(options);
48
+ const archiveTarget = rootDir + "/" + hash + ".zip";
49
+ let exists = false;
50
+ try {
51
+ const stat = await fs.promises.stat(archiveTarget);
52
+ exists = stat.isFile();
53
+ } catch (err) {
54
+ }
55
+ if (!exists) {
56
+ const uri = `${options.uri || download_gitlab_types.defaultGitLabBaseURI}/${options.project}/repository/archive.zip?sha=${hash}`;
57
+ await download_api_download.downloadFile({
58
+ uri,
59
+ headers: {
60
+ Authorization: "token " + options.token
61
+ }
62
+ }, archiveTarget);
63
+ }
64
+ const files = await fs.promises.readdir(rootDir);
65
+ const hashSearch = "-" + hash;
66
+ for (let i = 0; i < files.length; i++) {
67
+ const file = files[i];
68
+ if (file === hash + ".zip") {
69
+ continue;
70
+ }
71
+ const filename = rootDir + "/" + files[i];
72
+ const stat = await fs.promises.lstat(filename);
73
+ const isDir = stat.isDirectory();
74
+ if (stat.isSymbolicLink() || isDir && filename.slice(0 - hashSearch.length) === hashSearch || isDir && options.cleanupOldDirectories !== false || !isDir && options.cleanupOldFiles) {
75
+ try {
76
+ await fs.promises.rm(filename, {
77
+ force: true,
78
+ recursive: true
79
+ });
80
+ } catch (err) {
81
+ }
82
+ }
83
+ }
84
+ await download_helpers_unzip.unzip(archiveTarget, rootDir);
85
+ const matchingDirs = await findMatchingDirs(rootDir, hash);
86
+ if (matchingDirs.length !== 1) {
87
+ throw new Error(`Error unpacking ${hash}.zip`);
88
+ }
89
+ const contentsDir = rootDir + "/" + matchingDirs[0];
90
+ return {
91
+ downloadType: "gitlab",
92
+ rootDir,
93
+ contentsDir,
94
+ hash
95
+ };
96
+ }
97
+
98
+ exports.downloadGitLabRepo = downloadGitLabRepo;
@@ -1,14 +1,15 @@
1
- import { ExportTargetOptions } from '../../export/helpers/prepare';
2
- import type { DocumentNotModified } from '../types/modified';
3
- import { GitLabAPIOptions } from './types';
4
- import type { DownloadSourceMixin } from '../types/sources';
1
+ import { ExportTargetOptions } from '../../export/helpers/prepare.js';
2
+ import { DocumentNotModified } from '../types/modified.js';
3
+ import { GitLabAPIOptions } from './types.js';
4
+ import { DownloadSourceMixin } from '../types/sources.js';
5
+
5
6
  interface IfModifiedSinceOption {
6
7
  ifModifiedSince: string | DownloadGitLabRepoResult;
7
8
  }
8
9
  /**
9
10
  * Options for downloadGitLabRepo()
10
11
  */
11
- export interface DownloadGitLabRepoOptions extends ExportTargetOptions, GitLabAPIOptions, Partial<IfModifiedSinceOption> {
12
+ interface DownloadGitLabRepoOptions extends ExportTargetOptions, GitLabAPIOptions, Partial<IfModifiedSinceOption> {
12
13
  cleanupOldFiles?: boolean;
13
14
  cleanupOldDirectories?: boolean;
14
15
  log?: boolean;
@@ -16,7 +17,7 @@ export interface DownloadGitLabRepoOptions extends ExportTargetOptions, GitLabAP
16
17
  /**
17
18
  * Result
18
19
  */
19
- export interface DownloadGitLabRepoResult extends DownloadSourceMixin<'gitlab'> {
20
+ interface DownloadGitLabRepoResult extends DownloadSourceMixin<'gitlab'> {
20
21
  rootDir: string;
21
22
  contentsDir: string;
22
23
  hash: string;
@@ -24,6 +25,7 @@ export interface DownloadGitLabRepoResult extends DownloadSourceMixin<'gitlab'>
24
25
  /**
25
26
  * Download GitLab repo using API
26
27
  */
27
- export declare function downloadGitLabRepo<T extends IfModifiedSinceOption & DownloadGitLabRepoOptions>(options: T): Promise<DownloadGitLabRepoResult | DocumentNotModified>;
28
- export declare function downloadGitLabRepo(options: DownloadGitLabRepoOptions): Promise<DownloadGitLabRepoResult>;
29
- export {};
28
+ declare function downloadGitLabRepo<T extends IfModifiedSinceOption & DownloadGitLabRepoOptions>(options: T): Promise<DownloadGitLabRepoResult | DocumentNotModified>;
29
+ declare function downloadGitLabRepo(options: DownloadGitLabRepoOptions): Promise<DownloadGitLabRepoResult>;
30
+
31
+ export { DownloadGitLabRepoOptions, DownloadGitLabRepoResult, downloadGitLabRepo };
@@ -1,22 +1,29 @@
1
- // 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";
1
+ import { promises } from 'fs';
2
+ import { prepareDirectoryForExport } from '../../export/helpers/prepare.mjs';
3
+ import { getGitLabRepoHash } from './hash.mjs';
4
+ import { defaultGitLabBaseURI } from './types.mjs';
5
+ import { downloadFile } from '../api/download.mjs';
6
+ import { unzip } from '../helpers/unzip.mjs';
7
+ import 'pathe';
8
+ import '../api/index.mjs';
9
+ import 'node-fetch';
10
+ import '../api/cache.mjs';
11
+ import 'crypto';
12
+ import '../../misc/scan.mjs';
13
+ import 'util';
14
+ import 'stream';
15
+ import 'extract-zip';
16
+
10
17
  async function findMatchingDirs(rootDir, hash) {
11
18
  const matches = [];
12
- const files = await fs.readdir(rootDir);
19
+ const files = await promises.readdir(rootDir);
13
20
  for (let i = 0; i < files.length; i++) {
14
21
  const file = files[i];
15
22
  const lastChunk = file.split("-").pop();
16
23
  if (lastChunk.length < 4 || lastChunk !== hash.slice(0, lastChunk.length)) {
17
24
  continue;
18
25
  }
19
- const stat = await fs.stat(rootDir + "/" + file);
26
+ const stat = await promises.stat(rootDir + "/" + file);
20
27
  if (stat.isDirectory()) {
21
28
  matches.push(file);
22
29
  }
@@ -37,7 +44,7 @@ async function downloadGitLabRepo(options) {
37
44
  const archiveTarget = rootDir + "/" + hash + ".zip";
38
45
  let exists = false;
39
46
  try {
40
- const stat = await fs.stat(archiveTarget);
47
+ const stat = await promises.stat(archiveTarget);
41
48
  exists = stat.isFile();
42
49
  } catch (err) {
43
50
  }
@@ -50,7 +57,7 @@ async function downloadGitLabRepo(options) {
50
57
  }
51
58
  }, archiveTarget);
52
59
  }
53
- const files = await fs.readdir(rootDir);
60
+ const files = await promises.readdir(rootDir);
54
61
  const hashSearch = "-" + hash;
55
62
  for (let i = 0; i < files.length; i++) {
56
63
  const file = files[i];
@@ -58,11 +65,11 @@ async function downloadGitLabRepo(options) {
58
65
  continue;
59
66
  }
60
67
  const filename = rootDir + "/" + files[i];
61
- const stat = await fs.lstat(filename);
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 fs.rm(filename, {
72
+ await promises.rm(filename, {
66
73
  force: true,
67
74
  recursive: true
68
75
  });
@@ -83,6 +90,5 @@ async function downloadGitLabRepo(options) {
83
90
  hash
84
91
  };
85
92
  }
86
- export {
87
- downloadGitLabRepo
88
- };
93
+
94
+ export { downloadGitLabRepo };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const defaultGitLabBaseURI = "https://gitlab.com/api/v4/projects";
6
+
7
+ exports.defaultGitLabBaseURI = defaultGitLabBaseURI;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * API options
3
3
  */
4
- export interface GitLabAPIOptions {
4
+ interface GitLabAPIOptions {
5
5
  uri?: string;
6
6
  token: string;
7
7
  project: string;
@@ -10,4 +10,6 @@ export interface GitLabAPIOptions {
10
10
  /**
11
11
  * Default base URI for GitLab API
12
12
  */
13
- export declare const defaultGitLabBaseURI = "https://gitlab.com/api/v4/projects";
13
+ declare const defaultGitLabBaseURI = "https://gitlab.com/api/v4/projects";
14
+
15
+ export { GitLabAPIOptions, defaultGitLabBaseURI };
@@ -1,5 +1,3 @@
1
- // src/download/gitlab/types.ts
2
- var defaultGitLabBaseURI = "https://gitlab.com/api/v4/projects";
3
- export {
4
- defaultGitLabBaseURI
5
- };
1
+ const defaultGitLabBaseURI = "https://gitlab.com/api/v4/projects";
2
+
3
+ export { defaultGitLabBaseURI };
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const tar = require('tar');
6
+
7
+ async function untar(file, path) {
8
+ await tar.x({
9
+ file,
10
+ C: path
11
+ });
12
+ }
13
+
14
+ exports.untar = untar;
@@ -1,4 +1,6 @@
1
1
  /**
2
2
  * Unpack .tgz archive
3
3
  */
4
- export declare function untar(file: string, path: string): Promise<void>;
4
+ declare function untar(file: string, path: string): Promise<void>;
5
+
6
+ export { untar };
@@ -1,11 +1,10 @@
1
- // src/download/helpers/untar.ts
2
- import { x } from "tar";
1
+ import { x } from 'tar';
2
+
3
3
  async function untar(file, path) {
4
4
  await x({
5
5
  file,
6
6
  C: path
7
7
  });
8
8
  }
9
- export {
10
- untar
11
- };
9
+
10
+ export { untar };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const extract = require('extract-zip');
6
+ const fs = require('fs');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
9
+
10
+ const extract__default = /*#__PURE__*/_interopDefaultLegacy(extract);
11
+
12
+ async function unzip(source, path) {
13
+ const dir = await fs.promises.realpath(path);
14
+ await extract__default(source, {
15
+ dir
16
+ });
17
+ }
18
+
19
+ exports.unzip = unzip;
@@ -1,4 +1,6 @@
1
1
  /**
2
2
  * Unzip archive
3
3
  */
4
- export declare function unzip(source: string, path: string): Promise<void>;
4
+ declare function unzip(source: string, path: string): Promise<void>;
5
+
6
+ export { unzip };
@@ -1,12 +1,11 @@
1
- // src/download/helpers/unzip.ts
2
- import extract from "extract-zip";
3
- import { promises as fs } from "fs";
1
+ import extract from 'extract-zip';
2
+ import { promises } from 'fs';
3
+
4
4
  async function unzip(source, path) {
5
- const dir = await fs.realpath(path);
5
+ const dir = await promises.realpath(path);
6
6
  await extract(source, {
7
7
  dir
8
8
  });
9
9
  }
10
- export {
11
- unzip
12
- };
10
+
11
+ export { unzip };
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const download_github_index = require('./github/index.cjs');
6
+ const download_git_index = require('./git/index.cjs');
7
+ const download_npm_index = require('./npm/index.cjs');
8
+ const download_gitlab_index = require('./gitlab/index.cjs');
9
+ require('fs');
10
+ require('../export/helpers/prepare.cjs');
11
+ require('pathe');
12
+ require('./github/hash.cjs');
13
+ require('./api/index.cjs');
14
+ require('node-fetch');
15
+ require('./api/cache.cjs');
16
+ require('crypto');
17
+ require('../misc/scan.cjs');
18
+ require('./api/download.cjs');
19
+ require('util');
20
+ require('stream');
21
+ require('./helpers/unzip.cjs');
22
+ require('extract-zip');
23
+ require('../misc/exec.cjs');
24
+ require('child_process');
25
+ require('./git/branch.cjs');
26
+ require('./git/hash.cjs');
27
+ require('./git/reset.cjs');
28
+ require('cheerio');
29
+ require('@iconify/utils');
30
+ require('@iconify/utils/lib/icon');
31
+ require('../svg/data/attributes.cjs');
32
+ require('../svg/data/tags.cjs');
33
+ require('../svg/cleanup/bad-tags.cjs');
34
+ require('../svg/parse.cjs');
35
+ require('svgo');
36
+ require('@iconify/utils/lib/svg/build');
37
+ require('@iconify/utils/lib/customisations');
38
+ require('@iconify/utils/lib/icon-set/minify');
39
+ require('@iconify/utils/lib/icon-set/convert-info');
40
+ require('../icon-set/props.cjs');
41
+ require('tar');
42
+ require('@iconify/utils/lib/colors');
43
+ require('local-pkg');
44
+ require('./helpers/untar.cjs');
45
+ require('./npm/version.cjs');
46
+ require('./gitlab/hash.cjs');
47
+ require('./gitlab/types.cjs');
48
+
49
+ function downloadPackage(options) {
50
+ switch (options.downloadType) {
51
+ case "git":
52
+ return download_git_index.downloadGitRepo(options);
53
+ case "github":
54
+ return download_github_index.downloadGitHubRepo(options);
55
+ case "gitlab":
56
+ return download_gitlab_index.downloadGitLabRepo(options);
57
+ case "npm":
58
+ return download_npm_index.downloadNPMPackage(options);
59
+ default:
60
+ throw new Error(`Invalid download type: ${options.downloadType}`);
61
+ }
62
+ }
63
+
64
+ exports.downloadPackage = downloadPackage;
@@ -1,9 +1,13 @@
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
- import { DownloadGitLabRepoOptions, DownloadGitLabRepoResult } from './gitlab';
1
+ import { DownloadGitHubRepoOptions, DownloadGitHubRepoResult } from './github/index.js';
2
+ import { DownloadGitRepoOptions, DownloadGitRepoResult } from './git/index.js';
3
+ import { DownloadNPMPackageOptions, DownloadNPMPackageResult } from './npm/index.js';
4
+ import { DocumentNotModified } from './types/modified.js';
5
+ import { DownloadSourceType, DownloadSourceMixin } from './types/sources.js';
6
+ import { DownloadGitLabRepoOptions, DownloadGitLabRepoResult } from './gitlab/index.js';
7
+ import '../export/helpers/prepare.js';
8
+ import './github/types.js';
9
+ import './gitlab/types.js';
10
+
7
11
  /**
8
12
  * Options and result combinations
9
13
  */
@@ -26,18 +30,19 @@ interface DownloadNPMPackage {
26
30
  /**
27
31
  * Combinations based on type
28
32
  */
29
- export declare type DownloadParamsMixin<T extends DownloadSourceType> = T extends 'git' ? DownloadGitRepo : T extends 'github' ? DownloadGitHubRepo : T extends 'gitlab' ? DownloadGitLabRepo : T extends 'npm' ? DownloadNPMPackage : never;
33
+ declare type DownloadParamsMixin<T extends DownloadSourceType> = T extends 'git' ? DownloadGitRepo : T extends 'github' ? DownloadGitHubRepo : T extends 'gitlab' ? DownloadGitLabRepo : T extends 'npm' ? DownloadNPMPackage : never;
30
34
  /**
31
35
  * Combinations
32
36
  */
33
- export declare type DownloadParams = DownloadGitRepo | DownloadGitHubRepo | DownloadGitLabRepo | DownloadNPMPackage;
37
+ declare type DownloadParams = DownloadGitRepo | DownloadGitHubRepo | DownloadGitLabRepo | DownloadNPMPackage;
34
38
  /**
35
39
  * Pick options or result from combinations
36
40
  */
37
41
  declare type DownloadOptions<T extends DownloadSourceType> = DownloadParamsMixin<T>['options'];
38
42
  declare type DownloadResult<T extends DownloadSourceType> = Promise<DocumentNotModified | DownloadParamsMixin<T>['result']>;
39
- 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>;
43
- export {};
43
+ declare function downloadPackage<T extends 'git'>(options: DownloadOptions<T>): DownloadResult<T>;
44
+ declare function downloadPackage<T extends 'github'>(options: DownloadOptions<T>): DownloadResult<T>;
45
+ declare function downloadPackage<T extends 'gitlab'>(options: DownloadOptions<T>): DownloadResult<T>;
46
+ declare function downloadPackage<T extends 'npm'>(options: DownloadOptions<T>): DownloadResult<T>;
47
+
48
+ export { DownloadParams, DownloadParamsMixin, downloadPackage };
@@ -1,18 +1,47 @@
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
- import {
12
- downloadGitLabRepo
13
- } from "./gitlab/index.mjs";
14
- function assertNever(v) {
15
- }
1
+ import { downloadGitHubRepo } from './github/index.mjs';
2
+ import { downloadGitRepo } from './git/index.mjs';
3
+ import { downloadNPMPackage } from './npm/index.mjs';
4
+ import { downloadGitLabRepo } from './gitlab/index.mjs';
5
+ import 'fs';
6
+ import '../export/helpers/prepare.mjs';
7
+ import 'pathe';
8
+ import './github/hash.mjs';
9
+ import './api/index.mjs';
10
+ import 'node-fetch';
11
+ import './api/cache.mjs';
12
+ import 'crypto';
13
+ import '../misc/scan.mjs';
14
+ import './api/download.mjs';
15
+ import 'util';
16
+ import 'stream';
17
+ import './helpers/unzip.mjs';
18
+ import 'extract-zip';
19
+ import '../misc/exec.mjs';
20
+ import 'child_process';
21
+ import './git/branch.mjs';
22
+ import './git/hash.mjs';
23
+ import './git/reset.mjs';
24
+ import 'cheerio';
25
+ import '@iconify/utils';
26
+ import '@iconify/utils/lib/icon';
27
+ import '../svg/data/attributes.mjs';
28
+ import '../svg/data/tags.mjs';
29
+ import '../svg/cleanup/bad-tags.mjs';
30
+ import '../svg/parse.mjs';
31
+ import 'svgo';
32
+ import '@iconify/utils/lib/svg/build';
33
+ import '@iconify/utils/lib/customisations';
34
+ import '@iconify/utils/lib/icon-set/minify';
35
+ import '@iconify/utils/lib/icon-set/convert-info';
36
+ import '../icon-set/props.mjs';
37
+ import 'tar';
38
+ import '@iconify/utils/lib/colors';
39
+ import 'local-pkg';
40
+ import './helpers/untar.mjs';
41
+ import './npm/version.mjs';
42
+ import './gitlab/hash.mjs';
43
+ import './gitlab/types.mjs';
44
+
16
45
  function downloadPackage(options) {
17
46
  switch (options.downloadType) {
18
47
  case "git":
@@ -24,10 +53,8 @@ function downloadPackage(options) {
24
53
  case "npm":
25
54
  return downloadNPMPackage(options);
26
55
  default:
27
- assertNever(options);
28
56
  throw new Error(`Invalid download type: ${options.downloadType}`);
29
57
  }
30
58
  }
31
- export {
32
- downloadPackage
33
- };
59
+
60
+ export { downloadPackage };
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const fs = require('fs');
6
+ const export_helpers_prepare = require('../../export/helpers/prepare.cjs');
7
+ const download_api_download = require('../api/download.cjs');
8
+ const download_helpers_untar = require('../helpers/untar.cjs');
9
+ const download_npm_version = require('./version.cjs');
10
+ require('pathe');
11
+ require('node-fetch');
12
+ require('util');
13
+ require('stream');
14
+ require('tar');
15
+ require('../../misc/exec.cjs');
16
+ require('child_process');
17
+
18
+ async function downloadNPMPackage(options) {
19
+ const rootDir = options.target = export_helpers_prepare.normalizeDir(options.target);
20
+ const contentsDir = rootDir + "/package";
21
+ const versionInfo = await download_npm_version.getNPMVersion(options);
22
+ const version = versionInfo.version;
23
+ const ifModifiedSince = options.ifModifiedSince;
24
+ if (ifModifiedSince) {
25
+ try {
26
+ let expectedVersion;
27
+ if (typeof ifModifiedSince === "object") {
28
+ if (ifModifiedSince.downloadType === "npm" && ifModifiedSince.rootDir === rootDir && ifModifiedSince.contentsDir === contentsDir) {
29
+ expectedVersion = ifModifiedSince.version;
30
+ } else {
31
+ expectedVersion = null;
32
+ }
33
+ } else {
34
+ expectedVersion = ifModifiedSince === true ? await download_npm_version.getPackageVersion(contentsDir) : ifModifiedSince;
35
+ }
36
+ if (version === expectedVersion) {
37
+ return "not_modified";
38
+ }
39
+ } catch (err) {
40
+ options.cleanup = true;
41
+ }
42
+ }
43
+ const archiveURL = versionInfo.file;
44
+ if (!archiveURL) {
45
+ throw new Error(`NPM registry did not provide link to package archive.`);
46
+ }
47
+ const archiveTarget = rootDir + "/" + version + ".tgz";
48
+ await export_helpers_prepare.prepareDirectoryForExport(options);
49
+ let archiveExists = false;
50
+ try {
51
+ const stat = await fs.promises.stat(archiveTarget);
52
+ archiveExists = stat.isFile();
53
+ } catch (err) {
54
+ }
55
+ if (!archiveExists) {
56
+ if (options.log) {
57
+ console.log(`Downloading ${archiveURL}`);
58
+ }
59
+ await download_api_download.downloadFile({
60
+ uri: archiveURL,
61
+ headers: {
62
+ Accept: "application/tar+gzip"
63
+ }
64
+ }, archiveTarget);
65
+ }
66
+ await export_helpers_prepare.prepareDirectoryForExport({
67
+ target: contentsDir,
68
+ cleanup: true
69
+ });
70
+ if (options.log) {
71
+ console.log(`Unpacking ${archiveTarget}`);
72
+ }
73
+ await download_helpers_untar.untar(archiveTarget, rootDir);
74
+ return {
75
+ downloadType: "npm",
76
+ rootDir,
77
+ contentsDir,
78
+ version
79
+ };
80
+ }
81
+
82
+ exports.downloadNPMPackage = downloadNPMPackage;