Skip to content

Commit 6faabe5

Browse files
committed
build(ui-icons): bump outdated dependencies
1 parent 21114ca commit 6faabe5

File tree

5 files changed

+56
-53
lines changed

5 files changed

+56
-53
lines changed

packages/calcite-ui-icons/bin/build.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
const fs = require("fs-extra");
1+
const { existsSync, mkdirSync } = require("fs");
22
const optimize = require("./optimize");
33
const generatePathFile = require("./path-data");
44

55
module.exports = function () {
6-
fs.ensureDirSync("js");
6+
if (!existsSync("js")) {
7+
mkdirSync("js");
8+
}
79

810
return optimize("*.svg")
911
.then(() => optimize("icons/*.svg", true))

packages/calcite-ui-icons/bin/optimize.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fs = require("fs-extra");
1+
const { readFile, writeFile } = require("fs/promises");
22
const { glob } = require("glob");
33
const SVGO = require("svgo");
44
const progress = require("cli-progress");
@@ -32,18 +32,17 @@ let options = {
3232
* @return {Promise}
3333
*/
3434
function optimizeIcons(filePaths, svgo, bar) {
35-
var num = 0;
35+
let num = 0;
3636
return Promise.all(
37-
filePaths.map((path) => {
38-
return fs
39-
.readFile(path, "utf-8")
37+
filePaths.map((path) =>
38+
readFile(path, "utf-8")
4039
.then((svg) => svgo.optimize(svg, { path }))
4140
.then((result) => {
4241
num++;
4342
bar.update(num);
44-
return fs.writeFile(path, result.data, "utf-8");
45-
});
46-
}),
43+
return writeFile(path, result.data, "utf-8");
44+
}),
45+
),
4746
);
4847
}
4948

@@ -58,10 +57,13 @@ module.exports = function (files, remove) {
5857
return Promise.resolve(true);
5958
}
6059
options.plugins[0] = { cleanupIDs: { remove } };
61-
svgo = new SVGO(options);
60+
let svgo = new SVGO(options);
6261
return glob(files).then((iconPaths) => {
6362
const format = " \x1b[32m {bar} {percentage}% | {value}/{total} \x1b[0m";
64-
const bar = new progress.SingleBar({ format }, progress.Presets.shades_classic);
63+
const bar = new progress.SingleBar(
64+
{ format },
65+
progress.Presets.shades_classic,
66+
);
6567
bar.start(iconPaths.length, 0);
6668
return optimizeIcons(iconPaths, svgo, bar).then(() => {
6769
bar.stop();

packages/calcite-ui-icons/bin/path-data.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
const camelCase = require("camelcase");
2-
const fs = require("fs-extra");
2+
const {
3+
promises: { writeFile, readFile },
4+
readFileSync,
5+
} = require("fs");
36
const { glob } = require("glob");
7+
const { parse } = require("svgson");
48
const path = require("path");
5-
const util = require("util");
6-
const svgson = util.promisify(require("svgson"));
79
const version = require("../package.json").version;
810

911
/**
@@ -30,9 +32,12 @@ function formatSVG(svg) {
3032
*/
3133
function getPaths(svg) {
3234
const bbPaths = ["M0 0h16v16H0z", "M0 0h24v24H0z", "M0 0h32v32H0z"];
33-
return svg.childs
34-
.filter((child) => child.name === "path" && bbPaths.indexOf(child.attrs.d) === -1) // filter out bounding box paths
35-
.map((child) => ({ opacity: child.attrs.opacity, d: child.attrs.d }));
35+
return svg.children
36+
.filter((child) => child.name === "path" && bbPaths.indexOf(child.attributes.d) === -1) // filter out bounding box paths
37+
.map((child) => ({
38+
opacity: child.attributes.opacity,
39+
d: child.attributes.d,
40+
}));
3641
}
3742

3843
/**
@@ -62,13 +67,9 @@ function getSize(name) {
6267
* @return {Promise} - Promise resolving to object which includes name and svgson data
6368
*/
6469
function readSVG(fileName) {
65-
return new Promise(function (resolve, reject) {
66-
fs.readFile(fileName, "utf-8").then(function (svg) {
67-
svgson(svg, {}, function (contents) {
68-
resolve({ file: fileName, contents });
69-
});
70-
});
71-
});
70+
return new Promise((resolve, reject) =>
71+
readFile(fileName, "utf-8").then((svg) => parse(svg).then((contents) => resolve({ file: fileName, contents }))),
72+
);
7273
}
7374

7475
module.exports = function generatePathFile() {
@@ -87,7 +88,7 @@ export type CalciteIconPath = string | CalciteMultiPathEntry[];
8788
.then((files) => files.map(formatSVG))
8889
.then((files) => {
8990
let icons = {};
90-
let keywords = JSON.parse(fs.readFileSync("docs/keywords.json", "utf-8"));
91+
let keywords = JSON.parse(readFileSync("docs/keywords.json", "utf-8"));
9192
files.forEach((file) => {
9293
// add to json file
9394
icons[file.variant] = icons[file.variant] || keywords[file.variant] || { alias: [], category: "", release: "" };
@@ -122,14 +123,14 @@ export type CalciteIconPath = string | CalciteMultiPathEntry[];
122123
tsContents = `export const ${camelCaseName}: CalciteMultiPathEntry[];\n`;
123124
}
124125

125-
fs.writeFile(`js/${camelCaseName}.js`, contents, "utf8");
126-
fs.writeFile(`js/${camelCaseName}.d.ts`, tsContents, "utf8");
127-
fs.writeFile(`js/${camelCaseName}.json`, JSON.stringify(paths), "utf8");
126+
writeFile(`js/${camelCaseName}.js`, contents, "utf8");
127+
writeFile(`js/${camelCaseName}.d.ts`, tsContents, "utf8");
128+
writeFile(`js/${camelCaseName}.json`, JSON.stringify(paths), "utf8");
128129
});
129130
let promises = [
130-
fs.writeFile("docs/icons.json", JSON.stringify({ version, icons }), "utf8"),
131-
fs.writeFile("index.d.ts", tsFile, "utf8"),
132-
fs.writeFile("index.js", jsFile, "utf8"),
131+
writeFile("docs/icons.json", JSON.stringify({ version, icons }), "utf8"),
132+
writeFile("index.d.ts", tsFile, "utf8"),
133+
writeFile("index.js", jsFile, "utf8"),
133134
];
134135
return Promise.all(promises);
135136
});

packages/calcite-ui-icons/lib/spriter/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
"use strict";
22

3-
const fs = require("fs");
3+
const { readdir, mkdir, writeFile, readFile } = require("fs/promises");
44
const path = require("path");
5-
const Promise = require("promise");
6-
7-
const readDir = Promise.denodeify(fs.readdir);
8-
const mkDir = Promise.denodeify(fs.mkdir);
9-
const writeFile = Promise.denodeify(fs.writeFile);
10-
const readFile = Promise.denodeify(fs.readFile);
115

126
const ICONS = path.resolve(path.dirname(process.argv[1]), "../icons");
137
const NAME = "generated";
@@ -18,7 +12,8 @@ const OUTLINE = "outline";
1812
const FILL = "fill";
1913

2014
const isDir = (file) => fs.lstatSync(`${ICONS}/${file}`).isDirectory();
21-
const readSVG = (icon) => readFile(`${ICONS}/${icon.fileName}`, { encoding: "utf-8" });
15+
const readSVG = (icon) =>
16+
readFile(`${ICONS}/${icon.fileName}`, { encoding: "utf-8" });
2217
const has = (haystack, needle) => haystack.indexOf(needle) > -1;
2318

2419
/**
@@ -97,7 +92,7 @@ const has = (haystack, needle) => haystack.indexOf(needle) > -1;
9792
* @return {ThenPromise<T>} - Promise that resolves when directory creation is ensured.
9893
*/
9994
function ensureDir(dir) {
100-
return mkDir(dir).catch((error) => {
95+
return mkdir(dir).catch((error) => {
10196
const triedToCreateExisting = error.code === "EEXIST";
10297

10398
if (!triedToCreateExisting) {
@@ -186,7 +181,7 @@ function generateExportInfo(requested) {
186181
const exportInfo = {};
187182
SIZES.forEach((size) => (exportInfo[size] = []));
188183

189-
return readDir(ICONS)
184+
return readdir(ICONS)
190185
.then((icons) => {
191186
if (includeAll) {
192187
processAll(icons);
@@ -227,8 +222,13 @@ function svgToSymbol(icon) {
227222
*/
228223
function createSpritesheet({ icons, output, size }) {
229224
return Promise.all(icons.map(svgToSymbol))
230-
.then((symbols) => `<svg xmlns="http://www.w3.org/2000/svg">${symbols.join("")}</svg>`)
231-
.then((content) => writeFile(`${output}/${`${NAME}-${size}.svg`}`, content));
225+
.then(
226+
(symbols) =>
227+
`<svg xmlns="http://www.w3.org/2000/svg">${symbols.join("")}</svg>`,
228+
)
229+
.then((content) =>
230+
writeFile(`${output}/${`${NAME}-${size}.svg`}`, content),
231+
);
232232
}
233233

234234
/**

packages/calcite-ui-icons/package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@esri/calcite-ui-icons",
3-
"version": "3.30.1-next.0",
3+
"version": "3.30.0",
44
"private": false,
55
"description": "A collection of UI SVG icons created by Esri for applications.",
66
"keywords": [
@@ -47,24 +47,22 @@
4747
"convert-all-desktop:size": "node bin/convert-mobile.js -o \"../desktop-output\" -i \"16\" -s",
4848
"convert-all-ios": "node bin/convert-mobile.js -o \"../mobile-output\" -p \"ios\" -i \"24\"",
4949
"convert-all-ios:size": "node bin/convert-mobile.js -o \"../mobile-output\" -p \"ios\" -s",
50-
"copy-assets": "cpy \"../../node_modules/calcite-web/dist/js/calcite-web.min.js\" \"../../node_modules/calcite-web/dist/css/calcite-web.min.css\" \"./docs/resources\" --flat",
50+
"copy-assets": "cpy \"./node_modules/calcite-web/dist/js/calcite-web.min.js\" \"./node_modules/calcite-web/dist/css/calcite-web.min.css\" \"./docs/resources\" --flat",
5151
"optimize": "node bin/cli.js",
5252
"spriter": "node bin/spriter.js",
5353
"start": "npm run copy-assets && node bin/server.js"
5454
},
5555
"devDependencies": {
56-
"browser-sync": "^2.24.7",
57-
"calcite-web": "github:esri/calcite-web#v1.1.0",
58-
"camelcase": "^5.3.1",
56+
"browser-sync": "3.0.2",
57+
"calcite-web": "github:esri/calcite-web#v1.2.5",
58+
"camelcase": "6.3.0",
5959
"cli-progress": "^3.12.0",
6060
"debounce": "^2.1.0",
61-
"fs-extra": "^7.0.0",
6261
"glob": "^11.0.0",
63-
"promise": "~8.0.1",
6462
"svg2img": "1.0.0-beta.2",
6563
"svgo": "^1.3.0",
66-
"svgson": "^2.1.1",
67-
"svgstore-cli": "^1.3.1",
64+
"svgson": "5.3.1",
65+
"svgstore-cli": "2.0.1",
6866
"yargs": "^17.7.2"
6967
},
7068
"volta": {

0 commit comments

Comments
 (0)