@iconify/tools 2.0.0-dev.3 → 2.0.2
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/README.md +90 -0
- package/lib/colors/parse.d.ts +1 -1
- package/lib/colors/parse.js +3 -1
- package/lib/colors/parse.mjs +2 -1
- package/lib/colors/validate.d.ts +11 -0
- package/lib/colors/validate.js +45 -0
- package/lib/colors/validate.mjs +33 -0
- package/lib/css/parser/text.js +3 -6
- package/lib/css/parser/text.mjs +3 -3
- package/lib/{api → download/api}/cache.d.ts +0 -0
- package/lib/{api → download/api}/cache.js +1 -1
- package/lib/{api → download/api}/cache.mjs +2 -2
- package/lib/download/api/download.d.ts +5 -0
- package/lib/download/api/download.js +27 -0
- package/lib/download/api/download.mjs +21 -0
- package/lib/{api → download/api}/index.d.ts +0 -0
- package/lib/{api → download/api}/index.js +2 -2
- package/lib/{api → download/api}/index.mjs +3 -3
- package/lib/{api → download/api}/types.d.ts +0 -0
- package/lib/{api → download/api}/types.js +0 -0
- package/lib/{api → download/api}/types.mjs +0 -0
- package/lib/download/git/hash.d.ts +5 -0
- package/lib/download/git/hash.js +14 -0
- package/lib/download/git/hash.mjs +11 -0
- package/lib/download/git/index.d.ts +26 -0
- package/lib/download/git/index.js +52 -0
- package/lib/download/git/index.mjs +44 -0
- package/lib/download/github/hash.d.ts +5 -0
- package/lib/download/github/hash.js +28 -0
- package/lib/download/github/hash.mjs +25 -0
- package/lib/download/github/index.d.ts +28 -0
- package/lib/download/github/index.js +105 -0
- package/lib/download/github/index.mjs +83 -0
- package/lib/download/github/types.d.ts +9 -0
- package/lib/download/github/types.js +2 -0
- package/lib/download/github/types.mjs +0 -0
- package/lib/download/helpers/untar.d.ts +4 -0
- package/lib/download/helpers/untar.js +14 -0
- package/lib/download/helpers/untar.mjs +11 -0
- package/lib/download/helpers/unzip.d.ts +4 -0
- package/lib/download/helpers/unzip.js +18 -0
- package/lib/download/helpers/unzip.mjs +12 -0
- package/lib/download/npm/index.d.ts +27 -0
- package/lib/download/npm/index.js +73 -0
- package/lib/download/npm/index.mjs +63 -0
- package/lib/download/npm/types.d.ts +7 -0
- package/lib/download/npm/types.js +2 -0
- package/lib/download/npm/types.mjs +0 -0
- package/lib/download/npm/version.d.ts +13 -0
- package/lib/download/npm/version.js +27 -0
- package/lib/download/npm/version.mjs +20 -0
- package/lib/download/types/modified.d.ts +4 -0
- package/lib/download/types/modified.js +2 -0
- package/lib/download/types/modified.mjs +0 -0
- package/lib/export/directory.d.ts +2 -2
- package/lib/export/directory.js +2 -2
- package/lib/export/directory.mjs +2 -2
- package/lib/export/helpers/custom-files.d.ts +10 -0
- package/lib/export/helpers/custom-files.js +32 -0
- package/lib/export/helpers/custom-files.mjs +25 -0
- package/lib/export/{prepare.d.ts → helpers/prepare.d.ts} +4 -0
- package/lib/export/{prepare.js → helpers/prepare.js} +14 -5
- package/lib/export/{prepare.mjs → helpers/prepare.mjs} +9 -4
- package/lib/export/helpers/types-version.d.ts +4 -0
- package/lib/export/helpers/types-version.js +12 -0
- package/lib/export/helpers/types-version.mjs +40 -0
- package/lib/export/icon-package.d.ts +17 -0
- package/lib/export/icon-package.js +77 -0
- package/lib/export/icon-package.mjs +56 -0
- package/lib/export/json-package.d.ts +15 -0
- package/lib/export/json-package.js +151 -0
- package/lib/export/json-package.mjs +127 -0
- package/lib/icon-set/index.js +1 -2
- package/lib/icon-set/index.mjs +1 -1
- package/lib/import/figma/index.d.ts +5 -3
- package/lib/import/figma/index.js +0 -3
- package/lib/import/figma/query.d.ts +6 -4
- package/lib/import/figma/query.js +2 -5
- package/lib/import/figma/query.mjs +6 -2
- package/lib/import/figma/types/options.d.ts +4 -2
- package/lib/import/figma/types/result.d.ts +0 -4
- package/lib/index.d.ts +37 -0
- package/lib/index.js +89 -0
- package/lib/index.mjs +80 -0
- package/lib/misc/bump-version.d.ts +4 -0
- package/lib/misc/bump-version.js +19 -0
- package/lib/misc/bump-version.mjs +15 -0
- package/lib/misc/compare-dirs.d.ts +9 -0
- package/lib/misc/compare-dirs.js +84 -0
- package/lib/misc/compare-dirs.mjs +71 -0
- package/lib/misc/exec.d.ts +10 -0
- package/lib/misc/exec.js +26 -0
- package/lib/misc/exec.mjs +22 -0
- package/lib/misc/keyword.js +1 -1
- package/lib/misc/keyword.mjs +1 -1
- package/lib/misc/scan.d.ts +1 -1
- package/lib/misc/scan.js +14 -8
- package/lib/misc/scan.mjs +11 -6
- package/lib/misc/write-json.d.ts +4 -0
- package/lib/misc/write-json.js +11 -0
- package/lib/misc/write-json.mjs +8 -0
- package/lib/optimise/svgo.js +3 -1
- package/lib/optimise/svgo.mjs +2 -1
- package/lib/svg/index.d.ts +3 -0
- package/lib/svg/index.js +3 -0
- package/license.txt +21 -0
- package/package.json +138 -27
|
@@ -17,8 +17,10 @@ interface FigmaImportCommonOptions {
|
|
|
17
17
|
file: string;
|
|
18
18
|
version?: string;
|
|
19
19
|
}
|
|
20
|
-
export interface
|
|
21
|
-
ifModifiedSince
|
|
20
|
+
export interface FigmaIfModifiedSinceOption {
|
|
21
|
+
ifModifiedSince: string | Date | true;
|
|
22
|
+
}
|
|
23
|
+
export interface FigmaFilesQueryOptions extends FigmaImportCommonOptions, Partial<FigmaIfModifiedSinceOption> {
|
|
22
24
|
ids?: string[];
|
|
23
25
|
depth?: number;
|
|
24
26
|
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export { SVG } from './svg/index';
|
|
2
|
+
export { parseSVG } from './svg/parse';
|
|
3
|
+
export { parseSVGStyle } from './svg/parse-style';
|
|
4
|
+
export { cleanupSVG } from './svg/cleanup';
|
|
5
|
+
export { removeBadAttributes } from './svg/cleanup/attribs';
|
|
6
|
+
export { checkBadTags } from './svg/cleanup/bad-tags';
|
|
7
|
+
export { cleanupInlineStyle } from './svg/cleanup/inline-style';
|
|
8
|
+
export { cleanupSVGRoot } from './svg/cleanup/root-svg';
|
|
9
|
+
export { convertStyleToAttrs } from './svg/cleanup/svgo-style';
|
|
10
|
+
export { IconSet, blankIconSet } from './icon-set/index';
|
|
11
|
+
export { mergeIconSets } from './icon-set/merge';
|
|
12
|
+
export { importFromFigma } from './import/figma/index';
|
|
13
|
+
export { importDirectory } from './import/directory';
|
|
14
|
+
export { downloadGitRepo } from './download/git/index';
|
|
15
|
+
export { getGitRepoHash } from './download/git/hash';
|
|
16
|
+
export { downloadGitHubRepo } from './download/github/index';
|
|
17
|
+
export { getGitHubRepoHash } from './download/github/hash';
|
|
18
|
+
export { downloadNPMPackage } from './download/npm/index';
|
|
19
|
+
export { getNPMVersion, getPackageVersion } from './download/npm/version';
|
|
20
|
+
export { parseColors, isEmptyColor } from './colors/parse';
|
|
21
|
+
export { validateColors } from './colors/validate';
|
|
22
|
+
export { runSVGO } from './optimise/svgo';
|
|
23
|
+
export { deOptimisePaths } from './optimise/flags';
|
|
24
|
+
export { scaleSVG } from './optimise/scale';
|
|
25
|
+
export { exportToDirectory } from './export/directory';
|
|
26
|
+
export { exportIconPackage } from './export/icon-package';
|
|
27
|
+
export { exportJSONPackage } from './export/json-package';
|
|
28
|
+
export { writeJSONFile } from './misc/write-json';
|
|
29
|
+
export { prepareDirectoryForExport } from './export/helpers/prepare';
|
|
30
|
+
export { scanDirectory } from './misc/scan';
|
|
31
|
+
export { compareDirectories } from './misc/compare-dirs';
|
|
32
|
+
export { unzip } from './download/helpers/unzip';
|
|
33
|
+
export { untar } from './download/helpers/untar';
|
|
34
|
+
export { execAsync } from './misc/exec';
|
|
35
|
+
export { cleanupIconKeyword } from './misc/keyword';
|
|
36
|
+
export { bumpVersion } from './misc/bump-version';
|
|
37
|
+
export { sendAPIQuery } from './download/api/index';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
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;
|
|
4
|
+
// SVG class and functions
|
|
5
|
+
var index_1 = require("./svg/index");
|
|
6
|
+
Object.defineProperty(exports, "SVG", { enumerable: true, get: function () { return index_1.SVG; } });
|
|
7
|
+
var parse_1 = require("./svg/parse");
|
|
8
|
+
Object.defineProperty(exports, "parseSVG", { enumerable: true, get: function () { return parse_1.parseSVG; } });
|
|
9
|
+
var parse_style_1 = require("./svg/parse-style");
|
|
10
|
+
Object.defineProperty(exports, "parseSVGStyle", { enumerable: true, get: function () { return parse_style_1.parseSVGStyle; } });
|
|
11
|
+
// SVG cleanup
|
|
12
|
+
var cleanup_1 = require("./svg/cleanup");
|
|
13
|
+
Object.defineProperty(exports, "cleanupSVG", { enumerable: true, get: function () { return cleanup_1.cleanupSVG; } });
|
|
14
|
+
var attribs_1 = require("./svg/cleanup/attribs");
|
|
15
|
+
Object.defineProperty(exports, "removeBadAttributes", { enumerable: true, get: function () { return attribs_1.removeBadAttributes; } });
|
|
16
|
+
var bad_tags_1 = require("./svg/cleanup/bad-tags");
|
|
17
|
+
Object.defineProperty(exports, "checkBadTags", { enumerable: true, get: function () { return bad_tags_1.checkBadTags; } });
|
|
18
|
+
var inline_style_1 = require("./svg/cleanup/inline-style");
|
|
19
|
+
Object.defineProperty(exports, "cleanupInlineStyle", { enumerable: true, get: function () { return inline_style_1.cleanupInlineStyle; } });
|
|
20
|
+
var root_svg_1 = require("./svg/cleanup/root-svg");
|
|
21
|
+
Object.defineProperty(exports, "cleanupSVGRoot", { enumerable: true, get: function () { return root_svg_1.cleanupSVGRoot; } });
|
|
22
|
+
var svgo_style_1 = require("./svg/cleanup/svgo-style");
|
|
23
|
+
Object.defineProperty(exports, "convertStyleToAttrs", { enumerable: true, get: function () { return svgo_style_1.convertStyleToAttrs; } });
|
|
24
|
+
// IconSet class
|
|
25
|
+
var index_2 = require("./icon-set/index");
|
|
26
|
+
Object.defineProperty(exports, "IconSet", { enumerable: true, get: function () { return index_2.IconSet; } });
|
|
27
|
+
Object.defineProperty(exports, "blankIconSet", { enumerable: true, get: function () { return index_2.blankIconSet; } });
|
|
28
|
+
var merge_1 = require("./icon-set/merge");
|
|
29
|
+
Object.defineProperty(exports, "mergeIconSets", { enumerable: true, get: function () { return merge_1.mergeIconSets; } });
|
|
30
|
+
// Import
|
|
31
|
+
var index_3 = require("./import/figma/index");
|
|
32
|
+
Object.defineProperty(exports, "importFromFigma", { enumerable: true, get: function () { return index_3.importFromFigma; } });
|
|
33
|
+
var directory_1 = require("./import/directory");
|
|
34
|
+
Object.defineProperty(exports, "importDirectory", { enumerable: true, get: function () { return directory_1.importDirectory; } });
|
|
35
|
+
// Download (for import)
|
|
36
|
+
var index_4 = require("./download/git/index");
|
|
37
|
+
Object.defineProperty(exports, "downloadGitRepo", { enumerable: true, get: function () { return index_4.downloadGitRepo; } });
|
|
38
|
+
var hash_1 = require("./download/git/hash");
|
|
39
|
+
Object.defineProperty(exports, "getGitRepoHash", { enumerable: true, get: function () { return hash_1.getGitRepoHash; } });
|
|
40
|
+
var index_5 = require("./download/github/index");
|
|
41
|
+
Object.defineProperty(exports, "downloadGitHubRepo", { enumerable: true, get: function () { return index_5.downloadGitHubRepo; } });
|
|
42
|
+
var hash_2 = require("./download/github/hash");
|
|
43
|
+
Object.defineProperty(exports, "getGitHubRepoHash", { enumerable: true, get: function () { return hash_2.getGitHubRepoHash; } });
|
|
44
|
+
var index_6 = require("./download/npm/index");
|
|
45
|
+
Object.defineProperty(exports, "downloadNPMPackage", { enumerable: true, get: function () { return index_6.downloadNPMPackage; } });
|
|
46
|
+
var version_1 = require("./download/npm/version");
|
|
47
|
+
Object.defineProperty(exports, "getNPMVersion", { enumerable: true, get: function () { return version_1.getNPMVersion; } });
|
|
48
|
+
Object.defineProperty(exports, "getPackageVersion", { enumerable: true, get: function () { return version_1.getPackageVersion; } });
|
|
49
|
+
// Manipulation
|
|
50
|
+
var parse_2 = require("./colors/parse");
|
|
51
|
+
Object.defineProperty(exports, "parseColors", { enumerable: true, get: function () { return parse_2.parseColors; } });
|
|
52
|
+
Object.defineProperty(exports, "isEmptyColor", { enumerable: true, get: function () { return parse_2.isEmptyColor; } });
|
|
53
|
+
var validate_1 = require("./colors/validate");
|
|
54
|
+
Object.defineProperty(exports, "validateColors", { enumerable: true, get: function () { return validate_1.validateColors; } });
|
|
55
|
+
var svgo_1 = require("./optimise/svgo");
|
|
56
|
+
Object.defineProperty(exports, "runSVGO", { enumerable: true, get: function () { return svgo_1.runSVGO; } });
|
|
57
|
+
var flags_1 = require("./optimise/flags");
|
|
58
|
+
Object.defineProperty(exports, "deOptimisePaths", { enumerable: true, get: function () { return flags_1.deOptimisePaths; } });
|
|
59
|
+
var scale_1 = require("./optimise/scale");
|
|
60
|
+
Object.defineProperty(exports, "scaleSVG", { enumerable: true, get: function () { return scale_1.scaleSVG; } });
|
|
61
|
+
// Export
|
|
62
|
+
var directory_2 = require("./export/directory");
|
|
63
|
+
Object.defineProperty(exports, "exportToDirectory", { enumerable: true, get: function () { return directory_2.exportToDirectory; } });
|
|
64
|
+
var icon_package_1 = require("./export/icon-package");
|
|
65
|
+
Object.defineProperty(exports, "exportIconPackage", { enumerable: true, get: function () { return icon_package_1.exportIconPackage; } });
|
|
66
|
+
var json_package_1 = require("./export/json-package");
|
|
67
|
+
Object.defineProperty(exports, "exportJSONPackage", { enumerable: true, get: function () { return json_package_1.exportJSONPackage; } });
|
|
68
|
+
// Misc: files, directories and archives
|
|
69
|
+
var write_json_1 = require("./misc/write-json");
|
|
70
|
+
Object.defineProperty(exports, "writeJSONFile", { enumerable: true, get: function () { return write_json_1.writeJSONFile; } });
|
|
71
|
+
var prepare_1 = require("./export/helpers/prepare");
|
|
72
|
+
Object.defineProperty(exports, "prepareDirectoryForExport", { enumerable: true, get: function () { return prepare_1.prepareDirectoryForExport; } });
|
|
73
|
+
var scan_1 = require("./misc/scan");
|
|
74
|
+
Object.defineProperty(exports, "scanDirectory", { enumerable: true, get: function () { return scan_1.scanDirectory; } });
|
|
75
|
+
var compare_dirs_1 = require("./misc/compare-dirs");
|
|
76
|
+
Object.defineProperty(exports, "compareDirectories", { enumerable: true, get: function () { return compare_dirs_1.compareDirectories; } });
|
|
77
|
+
var unzip_1 = require("./download/helpers/unzip");
|
|
78
|
+
Object.defineProperty(exports, "unzip", { enumerable: true, get: function () { return unzip_1.unzip; } });
|
|
79
|
+
var untar_1 = require("./download/helpers/untar");
|
|
80
|
+
Object.defineProperty(exports, "untar", { enumerable: true, get: function () { return untar_1.untar; } });
|
|
81
|
+
// Misc: other
|
|
82
|
+
var exec_1 = require("./misc/exec");
|
|
83
|
+
Object.defineProperty(exports, "execAsync", { enumerable: true, get: function () { return exec_1.execAsync; } });
|
|
84
|
+
var keyword_1 = require("./misc/keyword");
|
|
85
|
+
Object.defineProperty(exports, "cleanupIconKeyword", { enumerable: true, get: function () { return keyword_1.cleanupIconKeyword; } });
|
|
86
|
+
var bump_version_1 = require("./misc/bump-version");
|
|
87
|
+
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; } });
|
package/lib/index.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { SVG } from "./svg/index.mjs";
|
|
3
|
+
import { parseSVG } from "./svg/parse.mjs";
|
|
4
|
+
import { parseSVGStyle } from "./svg/parse-style.mjs";
|
|
5
|
+
import { cleanupSVG } from "./svg/cleanup.mjs";
|
|
6
|
+
import { removeBadAttributes } from "./svg/cleanup/attribs.mjs";
|
|
7
|
+
import { checkBadTags } from "./svg/cleanup/bad-tags.mjs";
|
|
8
|
+
import { cleanupInlineStyle } from "./svg/cleanup/inline-style.mjs";
|
|
9
|
+
import { cleanupSVGRoot } from "./svg/cleanup/root-svg.mjs";
|
|
10
|
+
import { convertStyleToAttrs } from "./svg/cleanup/svgo-style.mjs";
|
|
11
|
+
import { IconSet, blankIconSet } from "./icon-set/index.mjs";
|
|
12
|
+
import { mergeIconSets } from "./icon-set/merge.mjs";
|
|
13
|
+
import { importFromFigma } from "./import/figma/index.mjs";
|
|
14
|
+
import { importDirectory } from "./import/directory.mjs";
|
|
15
|
+
import { downloadGitRepo } from "./download/git/index.mjs";
|
|
16
|
+
import { getGitRepoHash } from "./download/git/hash.mjs";
|
|
17
|
+
import { downloadGitHubRepo } from "./download/github/index.mjs";
|
|
18
|
+
import { getGitHubRepoHash } from "./download/github/hash.mjs";
|
|
19
|
+
import { downloadNPMPackage } from "./download/npm/index.mjs";
|
|
20
|
+
import { getNPMVersion, getPackageVersion } from "./download/npm/version.mjs";
|
|
21
|
+
import { parseColors, isEmptyColor } from "./colors/parse.mjs";
|
|
22
|
+
import { validateColors } from "./colors/validate.mjs";
|
|
23
|
+
import { runSVGO } from "./optimise/svgo.mjs";
|
|
24
|
+
import { deOptimisePaths } from "./optimise/flags.mjs";
|
|
25
|
+
import { scaleSVG } from "./optimise/scale.mjs";
|
|
26
|
+
import { exportToDirectory } from "./export/directory.mjs";
|
|
27
|
+
import { exportIconPackage } from "./export/icon-package.mjs";
|
|
28
|
+
import { exportJSONPackage } from "./export/json-package.mjs";
|
|
29
|
+
import { writeJSONFile } from "./misc/write-json.mjs";
|
|
30
|
+
import { prepareDirectoryForExport } from "./export/helpers/prepare.mjs";
|
|
31
|
+
import { scanDirectory } from "./misc/scan.mjs";
|
|
32
|
+
import { compareDirectories } from "./misc/compare-dirs.mjs";
|
|
33
|
+
import { unzip } from "./download/helpers/unzip.mjs";
|
|
34
|
+
import { untar } from "./download/helpers/untar.mjs";
|
|
35
|
+
import { execAsync } from "./misc/exec.mjs";
|
|
36
|
+
import { cleanupIconKeyword } from "./misc/keyword.mjs";
|
|
37
|
+
import { bumpVersion } from "./misc/bump-version.mjs";
|
|
38
|
+
import { sendAPIQuery } from "./download/api/index.mjs";
|
|
39
|
+
export {
|
|
40
|
+
IconSet,
|
|
41
|
+
SVG,
|
|
42
|
+
blankIconSet,
|
|
43
|
+
bumpVersion,
|
|
44
|
+
checkBadTags,
|
|
45
|
+
cleanupIconKeyword,
|
|
46
|
+
cleanupInlineStyle,
|
|
47
|
+
cleanupSVG,
|
|
48
|
+
cleanupSVGRoot,
|
|
49
|
+
compareDirectories,
|
|
50
|
+
convertStyleToAttrs,
|
|
51
|
+
deOptimisePaths,
|
|
52
|
+
downloadGitHubRepo,
|
|
53
|
+
downloadGitRepo,
|
|
54
|
+
downloadNPMPackage,
|
|
55
|
+
execAsync,
|
|
56
|
+
exportIconPackage,
|
|
57
|
+
exportJSONPackage,
|
|
58
|
+
exportToDirectory,
|
|
59
|
+
getGitHubRepoHash,
|
|
60
|
+
getGitRepoHash,
|
|
61
|
+
getNPMVersion,
|
|
62
|
+
getPackageVersion,
|
|
63
|
+
importDirectory,
|
|
64
|
+
importFromFigma,
|
|
65
|
+
isEmptyColor,
|
|
66
|
+
mergeIconSets,
|
|
67
|
+
parseColors,
|
|
68
|
+
parseSVG,
|
|
69
|
+
parseSVGStyle,
|
|
70
|
+
prepareDirectoryForExport,
|
|
71
|
+
removeBadAttributes,
|
|
72
|
+
runSVGO,
|
|
73
|
+
scaleSVG,
|
|
74
|
+
scanDirectory,
|
|
75
|
+
sendAPIQuery,
|
|
76
|
+
untar,
|
|
77
|
+
unzip,
|
|
78
|
+
validateColors,
|
|
79
|
+
writeJSONFile
|
|
80
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bumpVersion = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Bump version number
|
|
6
|
+
*/
|
|
7
|
+
function bumpVersion(version) {
|
|
8
|
+
const versionParts = version.split('.');
|
|
9
|
+
const lastPart = versionParts.pop();
|
|
10
|
+
const num = parseInt(lastPart);
|
|
11
|
+
if (isNaN(num) || num + '' !== lastPart) {
|
|
12
|
+
versionParts.push(lastPart + '.1');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
versionParts.push(num + 1 + '');
|
|
16
|
+
}
|
|
17
|
+
return versionParts.join('.');
|
|
18
|
+
}
|
|
19
|
+
exports.bumpVersion = bumpVersion;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/misc/bump-version.ts
|
|
2
|
+
function bumpVersion(version) {
|
|
3
|
+
const versionParts = version.split(".");
|
|
4
|
+
const lastPart = versionParts.pop();
|
|
5
|
+
const num = parseInt(lastPart);
|
|
6
|
+
if (isNaN(num) || num + "" !== lastPart) {
|
|
7
|
+
versionParts.push(lastPart + ".1");
|
|
8
|
+
} else {
|
|
9
|
+
versionParts.push(num + 1 + "");
|
|
10
|
+
}
|
|
11
|
+
return versionParts.join(".");
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
bumpVersion
|
|
15
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CompareDirectoriesOptions {
|
|
2
|
+
ignoreNewLine?: boolean;
|
|
3
|
+
ignoreVersions?: boolean;
|
|
4
|
+
textExtensions?: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Compare directories. Returns true if files are identical, false if different
|
|
8
|
+
*/
|
|
9
|
+
export declare function compareDirectories(dir1: string, dir2: string, options?: CompareDirectoriesOptions): Promise<boolean>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareDirectories = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const prepare_1 = require("../export/helpers/prepare");
|
|
6
|
+
const scan_1 = require("./scan");
|
|
7
|
+
/**
|
|
8
|
+
* Extensions that are treated as text
|
|
9
|
+
*/
|
|
10
|
+
const textFileExtensions = [
|
|
11
|
+
'json',
|
|
12
|
+
'ts',
|
|
13
|
+
'js',
|
|
14
|
+
'mjs',
|
|
15
|
+
'cjs',
|
|
16
|
+
'jsx',
|
|
17
|
+
'tsx',
|
|
18
|
+
'vue',
|
|
19
|
+
'svelte',
|
|
20
|
+
'svg',
|
|
21
|
+
'txt',
|
|
22
|
+
'md',
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Compare directories. Returns true if files are identical, false if different
|
|
26
|
+
*/
|
|
27
|
+
async function compareDirectories(dir1, dir2, options) {
|
|
28
|
+
dir1 = (0, prepare_1.normalizeDir)(dir1);
|
|
29
|
+
dir2 = (0, prepare_1.normalizeDir)(dir2);
|
|
30
|
+
// Get all files
|
|
31
|
+
const files1 = await (0, scan_1.scanDirectory)(dir1);
|
|
32
|
+
const files2 = await (0, scan_1.scanDirectory)(dir2);
|
|
33
|
+
if (files1.length !== files2.length) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
// Options
|
|
37
|
+
options = options || {};
|
|
38
|
+
const ignoreNewLine = options.ignoreNewLine !== false;
|
|
39
|
+
const ignoreVersions = options.ignoreVersions !== false;
|
|
40
|
+
const textExtensions = new Set((options.textExtensions || []).concat(textFileExtensions));
|
|
41
|
+
// Check all files
|
|
42
|
+
for (let i = 0; i < files1.length; i++) {
|
|
43
|
+
const file = files1[i];
|
|
44
|
+
if (files2.indexOf(file) === -1) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const ext = file.split('.').pop().toLowerCase();
|
|
48
|
+
const isText = textExtensions.has(ext);
|
|
49
|
+
if (!isText) {
|
|
50
|
+
// Compare binary files
|
|
51
|
+
const content1 = await fs_1.promises.readFile(dir1 + '/' + file);
|
|
52
|
+
const content2 = await fs_1.promises.readFile(dir2 + '/' + file);
|
|
53
|
+
if (Buffer.compare(content1, content2) !== 0) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
// Text files
|
|
59
|
+
let content1 = await fs_1.promises.readFile(dir1 + '/' + file, 'utf8');
|
|
60
|
+
let content2 = await fs_1.promises.readFile(dir2 + '/' + file, 'utf8');
|
|
61
|
+
if (content1 === content2) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (ignoreNewLine) {
|
|
65
|
+
// Remove space before new line (\r\n -> \n), remove new line at the end
|
|
66
|
+
content1 = content1.replace(/\s+\n/g, '\n').trimRight();
|
|
67
|
+
content2 = content2.replace(/\s+\n/g, '\n').trimRight();
|
|
68
|
+
}
|
|
69
|
+
if (ignoreVersions && file.split('/').pop() === 'package.json') {
|
|
70
|
+
// Ignore versions in package.json
|
|
71
|
+
const data1 = JSON.parse(content1);
|
|
72
|
+
const data2 = JSON.parse(content2);
|
|
73
|
+
delete data1.version;
|
|
74
|
+
delete data2.version;
|
|
75
|
+
content1 = JSON.stringify(data1);
|
|
76
|
+
content2 = JSON.stringify(data2);
|
|
77
|
+
}
|
|
78
|
+
if (content1 !== content2) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
exports.compareDirectories = compareDirectories;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/misc/compare-dirs.ts
|
|
2
|
+
import { promises as fs } from "fs";
|
|
3
|
+
import { normalizeDir } from "../export/helpers/prepare.mjs";
|
|
4
|
+
import { scanDirectory } from "./scan.mjs";
|
|
5
|
+
var textFileExtensions = [
|
|
6
|
+
"json",
|
|
7
|
+
"ts",
|
|
8
|
+
"js",
|
|
9
|
+
"mjs",
|
|
10
|
+
"cjs",
|
|
11
|
+
"jsx",
|
|
12
|
+
"tsx",
|
|
13
|
+
"vue",
|
|
14
|
+
"svelte",
|
|
15
|
+
"svg",
|
|
16
|
+
"txt",
|
|
17
|
+
"md"
|
|
18
|
+
];
|
|
19
|
+
async function compareDirectories(dir1, dir2, options) {
|
|
20
|
+
dir1 = normalizeDir(dir1);
|
|
21
|
+
dir2 = normalizeDir(dir2);
|
|
22
|
+
const files1 = await scanDirectory(dir1);
|
|
23
|
+
const files2 = await scanDirectory(dir2);
|
|
24
|
+
if (files1.length !== files2.length) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
options = options || {};
|
|
28
|
+
const ignoreNewLine = options.ignoreNewLine !== false;
|
|
29
|
+
const ignoreVersions = options.ignoreVersions !== false;
|
|
30
|
+
const textExtensions = new Set((options.textExtensions || []).concat(textFileExtensions));
|
|
31
|
+
for (let i = 0; i < files1.length; i++) {
|
|
32
|
+
const file = files1[i];
|
|
33
|
+
if (files2.indexOf(file) === -1) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const ext = file.split(".").pop().toLowerCase();
|
|
37
|
+
const isText = textExtensions.has(ext);
|
|
38
|
+
if (!isText) {
|
|
39
|
+
const content12 = await fs.readFile(dir1 + "/" + file);
|
|
40
|
+
const content22 = await fs.readFile(dir2 + "/" + file);
|
|
41
|
+
if (Buffer.compare(content12, content22) !== 0) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
let content1 = await fs.readFile(dir1 + "/" + file, "utf8");
|
|
47
|
+
let content2 = await fs.readFile(dir2 + "/" + file, "utf8");
|
|
48
|
+
if (content1 === content2) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (ignoreNewLine) {
|
|
52
|
+
content1 = content1.replace(/\s+\n/g, "\n").trimRight();
|
|
53
|
+
content2 = content2.replace(/\s+\n/g, "\n").trimRight();
|
|
54
|
+
}
|
|
55
|
+
if (ignoreVersions && file.split("/").pop() === "package.json") {
|
|
56
|
+
const data1 = JSON.parse(content1);
|
|
57
|
+
const data2 = JSON.parse(content2);
|
|
58
|
+
delete data1.version;
|
|
59
|
+
delete data2.version;
|
|
60
|
+
content1 = JSON.stringify(data1);
|
|
61
|
+
content2 = JSON.stringify(data2);
|
|
62
|
+
}
|
|
63
|
+
if (content1 !== content2) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
compareDirectories
|
|
71
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ExecOptions } from 'child_process';
|
|
3
|
+
export interface ExecResult {
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Exec as Promise
|
|
9
|
+
*/
|
|
10
|
+
export declare function execAsync(cmd: string, options?: ExecOptions): Promise<ExecResult>;
|
package/lib/misc/exec.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execAsync = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
/**
|
|
6
|
+
* Exec as Promise
|
|
7
|
+
*/
|
|
8
|
+
function execAsync(cmd, options) {
|
|
9
|
+
return new Promise((fulfill, reject) => {
|
|
10
|
+
(0, child_process_1.exec)(cmd, {
|
|
11
|
+
...options,
|
|
12
|
+
encoding: 'utf8',
|
|
13
|
+
}, (error, stdout, stderr) => {
|
|
14
|
+
if (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
fulfill({
|
|
19
|
+
stdout,
|
|
20
|
+
stderr,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.execAsync = execAsync;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/misc/exec.ts
|
|
2
|
+
import { exec } from "child_process";
|
|
3
|
+
function execAsync(cmd, options) {
|
|
4
|
+
return new Promise((fulfill, reject) => {
|
|
5
|
+
exec(cmd, {
|
|
6
|
+
...options,
|
|
7
|
+
encoding: "utf8"
|
|
8
|
+
}, (error, stdout, stderr) => {
|
|
9
|
+
if (error) {
|
|
10
|
+
reject(error);
|
|
11
|
+
} else {
|
|
12
|
+
fulfill({
|
|
13
|
+
stdout,
|
|
14
|
+
stderr
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
execAsync
|
|
22
|
+
};
|
package/lib/misc/keyword.js
CHANGED
package/lib/misc/keyword.mjs
CHANGED
package/lib/misc/scan.d.ts
CHANGED
|
@@ -19,6 +19,6 @@ export declare type ScanDirectoryCallback = ScanDirectoryCallbackAsCustom<unknow
|
|
|
19
19
|
/**
|
|
20
20
|
* Find all files in directory
|
|
21
21
|
*/
|
|
22
|
-
export declare function scanDirectory(path: string, callback
|
|
22
|
+
export declare function scanDirectory(path: string, callback?: ScanDirectoryCallbackAsString, subdirs?: boolean): Promise<string[]>;
|
|
23
23
|
export declare function scanDirectory<T>(path: string, callback: ScanDirectoryCallbackAsCustom<T>, subdirs?: boolean): Promise<T[]>;
|
|
24
24
|
export {};
|
package/lib/misc/scan.js
CHANGED
|
@@ -29,15 +29,21 @@ async function scanDirectory(path, callback, subdirs = true) {
|
|
|
29
29
|
const ext = parts.length > 1 ? '.' + parts.pop() : '';
|
|
30
30
|
const file = parts.join('.');
|
|
31
31
|
// Callback
|
|
32
|
-
let callbackResult
|
|
33
|
-
if (
|
|
34
|
-
callbackResult =
|
|
32
|
+
let callbackResult;
|
|
33
|
+
if (callback) {
|
|
34
|
+
callbackResult = callback(ext, file, subdir, path);
|
|
35
|
+
if (callbackResult instanceof Promise) {
|
|
36
|
+
callbackResult = await callbackResult;
|
|
37
|
+
}
|
|
38
|
+
if (callbackResult === void 0 ||
|
|
39
|
+
callbackResult === false ||
|
|
40
|
+
callbackResult === null) {
|
|
41
|
+
// Skip file
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
35
44
|
}
|
|
36
|
-
|
|
37
|
-
callbackResult
|
|
38
|
-
callbackResult === null) {
|
|
39
|
-
// Skip file
|
|
40
|
-
continue;
|
|
45
|
+
else {
|
|
46
|
+
callbackResult = true;
|
|
41
47
|
}
|
|
42
48
|
// Add item
|
|
43
49
|
results.push(callbackResult === true ? subdir + filename : callbackResult);
|
package/lib/misc/scan.mjs
CHANGED
|
@@ -25,12 +25,17 @@ async function scanDirectory(path, callback, subdirs = true) {
|
|
|
25
25
|
const parts = filename.split(".");
|
|
26
26
|
const ext = parts.length > 1 ? "." + parts.pop() : "";
|
|
27
27
|
const file = parts.join(".");
|
|
28
|
-
let callbackResult
|
|
29
|
-
if (
|
|
30
|
-
callbackResult =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
let callbackResult;
|
|
29
|
+
if (callback) {
|
|
30
|
+
callbackResult = callback(ext, file, subdir, path);
|
|
31
|
+
if (callbackResult instanceof Promise) {
|
|
32
|
+
callbackResult = await callbackResult;
|
|
33
|
+
}
|
|
34
|
+
if (callbackResult === void 0 || callbackResult === false || callbackResult === null) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
callbackResult = true;
|
|
34
39
|
}
|
|
35
40
|
results.push(callbackResult === true ? subdir + filename : callbackResult);
|
|
36
41
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeJSONFile = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
/**
|
|
6
|
+
* Write JSON file
|
|
7
|
+
*/
|
|
8
|
+
async function writeJSONFile(filename, data) {
|
|
9
|
+
return fs_1.promises.writeFile(filename, JSON.stringify(data, null, '\t') + '\n');
|
|
10
|
+
}
|
|
11
|
+
exports.writeJSONFile = writeJSONFile;
|
package/lib/optimise/svgo.js
CHANGED
|
@@ -83,6 +83,8 @@ async function runSVGO(svg, options = {}) {
|
|
|
83
83
|
if (typeof result.error === 'string') {
|
|
84
84
|
throw new Error(result.error);
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
// Sometimes empty definitions are not removed: remove them
|
|
87
|
+
const content = result.data.replace(/<defs\/>/g, '');
|
|
88
|
+
svg.load(content);
|
|
87
89
|
}
|
|
88
90
|
exports.runSVGO = runSVGO;
|
package/lib/optimise/svgo.mjs
CHANGED
|
@@ -66,7 +66,8 @@ async function runSVGO(svg, options = {}) {
|
|
|
66
66
|
if (typeof result.error === "string") {
|
|
67
67
|
throw new Error(result.error);
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
const content = result.data.replace(/<defs\/>/g, "");
|
|
70
|
+
svg.load(content);
|
|
70
71
|
}
|
|
71
72
|
export {
|
|
72
73
|
defaultSVGOPlugins,
|