@iconify/tools 5.0.11 → 5.0.12
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/api/cache.js +2 -2
- package/lib/download/api/download.js +1 -1
- package/lib/download/git/reset.js +0 -1
- package/lib/download/github/index.js +1 -1
- package/lib/download/gitlab/index.js +7 -7
- package/lib/download/helpers/untar.js +1 -1
- package/lib/download/npm/index.d.ts +2 -3
- package/lib/download/npm/index.js +2 -2
- package/lib/download/npm/types.d.ts +1 -0
- package/lib/download/npm/version.js +11 -5
- package/lib/export/directory.js +2 -2
- package/lib/export/helpers/custom-files.js +3 -3
- package/lib/export/icon-package.js +3 -3
- package/lib/export/json-package.js +4 -4
- package/lib/import/directory.js +3 -2
- package/lib/misc/compare-dirs.js +5 -5
- package/lib/misc/exec.d.ts +1 -1
- package/lib/misc/exec.js +1 -1
- package/lib/misc/scan.d.ts +1 -1
- package/lib/misc/scan.js +1 -1
- package/lib/misc/write-json.js +2 -2
- package/package.json +9 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { scanDirectory } from "../../misc/scan.js";
|
|
2
|
-
import { promises } from "fs";
|
|
3
|
-
import { createHash } from "crypto";
|
|
2
|
+
import { promises } from "node:fs";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
4
|
|
|
5
5
|
const cacheVersion = 1;
|
|
6
6
|
const storedFiles = Object.create(null);
|
|
@@ -2,7 +2,7 @@ import { prepareDirectoryForExport } from "../../export/helpers/prepare.js";
|
|
|
2
2
|
import { getGitHubRepoHash } from "./hash.js";
|
|
3
3
|
import { downloadFile } from "../api/download.js";
|
|
4
4
|
import { unzip } from "../helpers/unzip.js";
|
|
5
|
-
import { promises } from "fs";
|
|
5
|
+
import { promises } from "node:fs";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Find matching directories
|
|
@@ -3,19 +3,19 @@ import { downloadFile } from "../api/download.js";
|
|
|
3
3
|
import { unzip } from "../helpers/unzip.js";
|
|
4
4
|
import { defaultGitLabBaseURI } from "./types.js";
|
|
5
5
|
import { getGitLabRepoHash } from "./hash.js";
|
|
6
|
-
import
|
|
6
|
+
import fs from "node:fs/promises";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Find matching directories
|
|
10
10
|
*/
|
|
11
11
|
async function findMatchingDirs(rootDir, hash) {
|
|
12
12
|
const matches = [];
|
|
13
|
-
const files = await
|
|
13
|
+
const files = await fs.readdir(rootDir);
|
|
14
14
|
for (let i = 0; i < files.length; i++) {
|
|
15
15
|
const file = files[i];
|
|
16
16
|
const lastChunk = file.split("-").pop();
|
|
17
17
|
if (lastChunk.length < 4 || lastChunk !== hash.slice(0, lastChunk.length)) continue;
|
|
18
|
-
if ((await
|
|
18
|
+
if ((await fs.stat(rootDir + "/" + file)).isDirectory()) matches.push(file);
|
|
19
19
|
}
|
|
20
20
|
return matches;
|
|
21
21
|
}
|
|
@@ -30,21 +30,21 @@ async function downloadGitLabRepo(options) {
|
|
|
30
30
|
const archiveTarget = rootDir + "/" + hash + ".zip";
|
|
31
31
|
let exists = false;
|
|
32
32
|
try {
|
|
33
|
-
exists = (await
|
|
33
|
+
exists = (await fs.stat(archiveTarget)).isFile();
|
|
34
34
|
} catch {}
|
|
35
35
|
if (!exists) await downloadFile({
|
|
36
36
|
uri: `${options.uri || defaultGitLabBaseURI}/${options.project}/repository/archive.zip?sha=${hash}`,
|
|
37
37
|
headers: { Authorization: "token " + options.token }
|
|
38
38
|
}, archiveTarget);
|
|
39
|
-
const files = await
|
|
39
|
+
const files = await fs.readdir(rootDir);
|
|
40
40
|
const hashSearch = "-" + hash;
|
|
41
41
|
for (let i = 0; i < files.length; i++) {
|
|
42
42
|
if (files[i] === hash + ".zip") continue;
|
|
43
43
|
const filename = rootDir + "/" + files[i];
|
|
44
|
-
const stat = await
|
|
44
|
+
const stat = await fs.lstat(filename);
|
|
45
45
|
const isDir = stat.isDirectory();
|
|
46
46
|
if (stat.isSymbolicLink() || isDir && filename.slice(0 - hashSearch.length) === hashSearch || isDir && options.cleanupOldDirectories !== false || !isDir && options.cleanupOldFiles) try {
|
|
47
|
-
await
|
|
47
|
+
await fs.rm(filename, {
|
|
48
48
|
force: true,
|
|
49
49
|
recursive: true
|
|
50
50
|
});
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { ExportTargetOptions } from "../../export/helpers/prepare.js";
|
|
2
2
|
import { DocumentNotModified } from "../types/modified.js";
|
|
3
3
|
import { DownloadSourceMixin } from "../types/sources.js";
|
|
4
|
+
import { NPMPackageOptions } from "./types.js";
|
|
4
5
|
interface IfModifiedSinceOption {
|
|
5
6
|
ifModifiedSince: string | true | DownloadNPMPackageResult;
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Options for downloadNPMPackage()
|
|
9
10
|
*/
|
|
10
|
-
interface DownloadNPMPackageOptions extends ExportTargetOptions, Partial<IfModifiedSinceOption> {
|
|
11
|
-
package: string;
|
|
12
|
-
tag?: string;
|
|
11
|
+
interface DownloadNPMPackageOptions extends NPMPackageOptions, ExportTargetOptions, Partial<IfModifiedSinceOption> {
|
|
13
12
|
log?: boolean;
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
@@ -2,7 +2,7 @@ import { normalizeDir, prepareDirectoryForExport } from "../../export/helpers/pr
|
|
|
2
2
|
import { downloadFile } from "../api/download.js";
|
|
3
3
|
import { untar } from "../helpers/untar.js";
|
|
4
4
|
import { getNPMVersion, getPackageVersion } from "./version.js";
|
|
5
|
-
import
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
6
|
|
|
7
7
|
async function downloadNPMPackage(options) {
|
|
8
8
|
const rootDir = options.target = normalizeDir(options.target);
|
|
@@ -25,7 +25,7 @@ async function downloadNPMPackage(options) {
|
|
|
25
25
|
await prepareDirectoryForExport(options);
|
|
26
26
|
let archiveExists = false;
|
|
27
27
|
try {
|
|
28
|
-
archiveExists = (await
|
|
28
|
+
archiveExists = (await fs.stat(archiveTarget)).isFile();
|
|
29
29
|
} catch {}
|
|
30
30
|
if (!archiveExists) {
|
|
31
31
|
if (options.log) console.log(`Downloading ${archiveURL}`);
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
+
import { getFetch } from "../api/fetch.js";
|
|
1
2
|
import { execAsync } from "../../misc/exec.js";
|
|
2
|
-
import
|
|
3
|
+
import fs from "node:fs/promises";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Get version of package from NPM registry
|
|
6
7
|
*/
|
|
7
8
|
async function getNPMVersion(options) {
|
|
8
9
|
const tag = options.tag || "latest";
|
|
9
|
-
const
|
|
10
|
-
|
|
10
|
+
const packageName = options.package;
|
|
11
|
+
let data;
|
|
12
|
+
if (options.fetch) data = await getFetch()(`https://registry.npmjs.org/${packageName}/${tag}`).then((res) => res.json());
|
|
13
|
+
else {
|
|
14
|
+
const result = await execAsync(`npm view ${packageName}@${tag} --json`, { maxBuffer: 1024 * 1024 * 8 });
|
|
15
|
+
data = JSON.parse(result.stdout);
|
|
16
|
+
}
|
|
11
17
|
return {
|
|
12
18
|
version: data.version,
|
|
13
|
-
file: data.dist?.tarball
|
|
19
|
+
file: data.dist?.tarball ?? `https://registry.npmjs.org/${packageName}/-/${packageName.split("/").pop()}-${data.version}.tgz`
|
|
14
20
|
};
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
17
23
|
* Get version of package from filename
|
|
18
24
|
*/
|
|
19
25
|
async function getPackageVersion(target) {
|
|
20
|
-
return JSON.parse(await
|
|
26
|
+
return JSON.parse(await fs.readFile(target + "/package.json", "utf8")).version;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export { getNPMVersion, getPackageVersion };
|
package/lib/export/directory.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { prepareDirectoryForExport } from "./helpers/prepare.js";
|
|
2
|
-
import
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Export icon set to directory
|
|
@@ -16,7 +16,7 @@ async function exportToDirectory(iconSet, options) {
|
|
|
16
16
|
const store = async (name, target) => {
|
|
17
17
|
const svg = iconSet.toString(name, customisations);
|
|
18
18
|
if (!svg) return;
|
|
19
|
-
await
|
|
19
|
+
await fs.writeFile(target, svg, "utf8");
|
|
20
20
|
storedFiles.add(target);
|
|
21
21
|
if (options.log) console.log(`Saved ${target} (${svg.length} bytes)`);
|
|
22
22
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { writeJSONFile } from "../../misc/write-json.js";
|
|
2
|
-
import
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Write custom files
|
|
@@ -10,11 +10,11 @@ async function exportCustomFiles(dir, options, result) {
|
|
|
10
10
|
const content = customFiles[filename];
|
|
11
11
|
if (content === null) {
|
|
12
12
|
try {
|
|
13
|
-
await
|
|
13
|
+
await fs.unlink(dir + "/" + filename);
|
|
14
14
|
} catch {}
|
|
15
15
|
continue;
|
|
16
16
|
}
|
|
17
|
-
if (typeof content === "string") await
|
|
17
|
+
if (typeof content === "string") await fs.writeFile(dir + "/" + filename, content, "utf8");
|
|
18
18
|
else if (typeof content === "object") await writeJSONFile(dir + "/" + filename, content);
|
|
19
19
|
result?.add(filename);
|
|
20
20
|
}
|
|
@@ -2,7 +2,7 @@ import { prepareDirectoryForExport } from "./helpers/prepare.js";
|
|
|
2
2
|
import { writeJSONFile } from "../misc/write-json.js";
|
|
3
3
|
import { exportCustomFiles } from "./helpers/custom-files.js";
|
|
4
4
|
import { getTypesVersion } from "./helpers/types-version.js";
|
|
5
|
-
import
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Content for .d.ts files
|
|
@@ -25,13 +25,13 @@ async function exportIconPackage(iconSet, options) {
|
|
|
25
25
|
const data = iconSet.resolve(name, false);
|
|
26
26
|
if (!data) return;
|
|
27
27
|
const typesFilename = name + ".d.ts";
|
|
28
|
-
await
|
|
28
|
+
await fs.writeFile(`${dir}/${typesFilename}`, typesContent, "utf8");
|
|
29
29
|
files.add(typesFilename);
|
|
30
30
|
let content = `const data = ` + JSON.stringify(data, null, " ") + ";\n";
|
|
31
31
|
if (!esm) content += "exports.__esModule = true;\nexports.default = data;\n";
|
|
32
32
|
else content += "export default data;\n";
|
|
33
33
|
const contentFilename = name + ".js";
|
|
34
|
-
await
|
|
34
|
+
await fs.writeFile(`${dir}/${contentFilename}`, content, "utf8");
|
|
35
35
|
files.add(contentFilename);
|
|
36
36
|
});
|
|
37
37
|
await exportCustomFiles(dir, options, files);
|
|
@@ -3,7 +3,7 @@ import { writeJSONFile } from "../misc/write-json.js";
|
|
|
3
3
|
import { exportCustomFiles } from "./helpers/custom-files.js";
|
|
4
4
|
import { getTypesVersion } from "./helpers/types-version.js";
|
|
5
5
|
import { defaultIconDimensions } from "@iconify/utils/lib/icon/defaults";
|
|
6
|
-
import
|
|
6
|
+
import fs from "node:fs/promises";
|
|
7
7
|
|
|
8
8
|
const exportTypes = {
|
|
9
9
|
icons: "IconifyJSON",
|
|
@@ -105,10 +105,10 @@ async function exportJSONPackage(iconSet, options) {
|
|
|
105
105
|
files.add(jsonFilename);
|
|
106
106
|
}
|
|
107
107
|
const cjsContent = cjsImports.concat([""], cjsExports);
|
|
108
|
-
await
|
|
108
|
+
await fs.writeFile(dir + "/index.js", cjsContent.join("\n") + "\n", "utf8");
|
|
109
109
|
files.add("index.js");
|
|
110
110
|
const mjsContent = mjsImports.concat([""], mjsConsts, [`export { ${mjsExports.join(", ")} };`]);
|
|
111
|
-
await
|
|
111
|
+
await fs.writeFile(dir + "/index.mjs", mjsContent.join("\n") + "\n", "utf8");
|
|
112
112
|
files.add("index.mjs");
|
|
113
113
|
const usedTypes = Object.values(exportTypes);
|
|
114
114
|
const typesData = [
|
|
@@ -117,7 +117,7 @@ async function exportJSONPackage(iconSet, options) {
|
|
|
117
117
|
`export { ${usedTypes.join(", ")} };`,
|
|
118
118
|
""
|
|
119
119
|
].concat(dtsContent);
|
|
120
|
-
await
|
|
120
|
+
await fs.writeFile(dir + "/index.d.ts", typesData.join("\n") + "\n", "utf8");
|
|
121
121
|
files.add("index.d.ts");
|
|
122
122
|
await exportCustomFiles(dir, options, files);
|
|
123
123
|
options.customisePackage?.(packageJSON);
|
package/lib/import/directory.js
CHANGED
|
@@ -3,7 +3,8 @@ import { cleanupSVG } from "../svg/cleanup.js";
|
|
|
3
3
|
import { blankIconSet } from "../icon-set/index.js";
|
|
4
4
|
import { scanDirectory, scanDirectorySync } from "../misc/scan.js";
|
|
5
5
|
import { cleanupIconKeyword } from "../misc/keyword.js";
|
|
6
|
-
import {
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
7
8
|
|
|
8
9
|
function importDir(iconSet, options, getKeyword, files, readFile, done) {
|
|
9
10
|
let i = 0;
|
|
@@ -63,7 +64,7 @@ function importDirectory(path, options = {}) {
|
|
|
63
64
|
else done(result);
|
|
64
65
|
} else done(params[1]);
|
|
65
66
|
}, files, (filename, done) => {
|
|
66
|
-
|
|
67
|
+
readFile(filename, "utf8").then(done).catch(reject);
|
|
67
68
|
}, fulfill);
|
|
68
69
|
} catch (err) {
|
|
69
70
|
reject(err);
|
package/lib/misc/compare-dirs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { scanDirectory } from "./scan.js";
|
|
2
2
|
import { normalizeDir } from "../export/helpers/prepare.js";
|
|
3
|
-
import {
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Extensions that are treated as text
|
|
@@ -37,13 +37,13 @@ async function compareDirectories(dir1, dir2, options) {
|
|
|
37
37
|
if (!files2.includes(file)) return false;
|
|
38
38
|
const ext = file.split(".").pop().toLowerCase();
|
|
39
39
|
if (!textExtensions.has(ext)) {
|
|
40
|
-
const content1 = await
|
|
41
|
-
const content2 = await
|
|
40
|
+
const content1 = await readFile(dir1 + "/" + file);
|
|
41
|
+
const content2 = await readFile(dir2 + "/" + file);
|
|
42
42
|
if (Buffer.compare(content1, content2) !== 0) return false;
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
|
-
let content1 = await
|
|
46
|
-
let content2 = await
|
|
45
|
+
let content1 = await readFile(dir1 + "/" + file, "utf8");
|
|
46
|
+
let content2 = await readFile(dir2 + "/" + file, "utf8");
|
|
47
47
|
if (content1 === content2) continue;
|
|
48
48
|
if (ignoreNewLine) {
|
|
49
49
|
content1 = content1.replace(/\s+\n/g, "\n").trimEnd();
|
package/lib/misc/exec.d.ts
CHANGED
package/lib/misc/exec.js
CHANGED
package/lib/misc/scan.d.ts
CHANGED
package/lib/misc/scan.js
CHANGED
package/lib/misc/write-json.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Write JSON file
|
|
5
5
|
*/
|
|
6
6
|
async function writeJSONFile(filename, data) {
|
|
7
|
-
return
|
|
7
|
+
return writeFile(filename, JSON.stringify(data, null, " ") + "\n");
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export { writeJSONFile };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
|
|
5
5
|
"author": "Vjacheslav Trushkin",
|
|
6
|
-
"version": "5.0.
|
|
6
|
+
"version": "5.0.12",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"bugs": "https://github.com/iconify/tools/issues",
|
|
9
9
|
"homepage": "https://github.com/iconify/tools",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"module": "./lib/index.js",
|
|
15
15
|
"types": "./lib/index.d.ts",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@cyberalien/svg-utils": "^1.2.
|
|
17
|
+
"@cyberalien/svg-utils": "^1.2.15",
|
|
18
18
|
"@iconify/types": "^2.0.0",
|
|
19
|
-
"@iconify/utils": "^3.1.
|
|
20
|
-
"fflate": "^0.8.
|
|
19
|
+
"@iconify/utils": "^3.1.3",
|
|
20
|
+
"fflate": "^0.8.3",
|
|
21
21
|
"modern-tar": "^0.7.6",
|
|
22
22
|
"pathe": "^2.0.3",
|
|
23
23
|
"svgo": "^4.0.1"
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
"@eslint/eslintrc": "^3.3.5",
|
|
27
27
|
"@eslint/js": "^9.39.4",
|
|
28
28
|
"@types/jest": "^30.0.0",
|
|
29
|
-
"@types/node": "^24.12.
|
|
30
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
31
|
-
"@typescript-eslint/parser": "^8.
|
|
29
|
+
"@types/node": "^24.12.4",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^8.59.4",
|
|
31
|
+
"@typescript-eslint/parser": "^8.59.4",
|
|
32
32
|
"cross-env": "^10.1.0",
|
|
33
33
|
"eslint": "^9.39.4",
|
|
34
34
|
"eslint-config-prettier": "^10.1.8",
|
|
35
35
|
"eslint-plugin-prettier": "^5.5.5",
|
|
36
36
|
"globals": "^16.5.0",
|
|
37
|
-
"prettier": "^3.8.
|
|
37
|
+
"prettier": "^3.8.3",
|
|
38
38
|
"rimraf": "^6.1.3",
|
|
39
39
|
"tsdown": "^0.20.3",
|
|
40
40
|
"typescript": "^5.9.3",
|
|
41
|
-
"vitest": "^4.1.
|
|
41
|
+
"vitest": "^4.1.6"
|
|
42
42
|
},
|
|
43
43
|
"exports": {
|
|
44
44
|
"./*": "./*",
|