feat(bin): update fetch script to take CLI args
This commit is contained in:
@@ -1,15 +1,33 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs/promises");
|
||||
const path = require("path");
|
||||
const axios = require("axios");
|
||||
const chalk = require("chalk");
|
||||
const { Command } = require("commander");
|
||||
const { version } = require("../package.json");
|
||||
|
||||
const ICON_API_URL = "https://api.phosphoricons.com";
|
||||
const PARAMS = new URLSearchParams([["release", "1.4"]]).toString();
|
||||
|
||||
async function main() {
|
||||
const program = new Command();
|
||||
program
|
||||
.version(version)
|
||||
.option(
|
||||
"-r --release <version>",
|
||||
"Fetch icons from Phosphor API and compile to internal data structure"
|
||||
)
|
||||
.option("-p --published", "Published status of icons")
|
||||
.option("-P, --no-published", "Published status of icons")
|
||||
.option("-q --query <text>", "Fulltext search term")
|
||||
.option("-n --name <name>", "Exact icon namee match");
|
||||
|
||||
program.parse(process.argv);
|
||||
const params = new URLSearchParams(Object.entries(program.opts())).toString();
|
||||
|
||||
try {
|
||||
const res = await axios.get(`${ICON_API_URL}?${PARAMS}`);
|
||||
const res = await axios.get(`${ICON_API_URL}?${params}`);
|
||||
if (res.data) {
|
||||
let fileString = `\
|
||||
import * as Icons from "phosphor-react";
|
||||
48
package.json
48
package.json
@@ -20,6 +20,15 @@
|
||||
],
|
||||
"repository": "github:phosphor-icons/phosphor-home",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"fetch": "node ./bin/fetch.js",
|
||||
"format": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json,vue}\""
|
||||
},
|
||||
"dependencies": {
|
||||
"file-saver": "^2.0.2",
|
||||
"framer-motion": "^3.10.0",
|
||||
@@ -36,14 +45,21 @@
|
||||
"svg2png-converter": "^1.0.0",
|
||||
"tinycolor2": "^1.4.2"
|
||||
},
|
||||
"scripts": {
|
||||
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"ingest": "node ./bin/ingest.js",
|
||||
"format": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json,vue}\""
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.3.2",
|
||||
"@testing-library/user-event": "^7.1.2",
|
||||
"@types/file-saver": "^2.0.1",
|
||||
"@types/jest": "^24.0.0",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/react": "^16.9.46",
|
||||
"@types/react-dom": "^16.9.8",
|
||||
"@types/react-virtualized": "^9.21.10",
|
||||
"@types/tinycolor2": "^1.4.2",
|
||||
"axios": "^0.24.0",
|
||||
"chalk": "^4",
|
||||
"commander": "^8.3.0",
|
||||
"typescript": "^3.9.6"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
@@ -59,21 +75,5 @@
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.3.2",
|
||||
"@testing-library/user-event": "^7.1.2",
|
||||
"@types/file-saver": "^2.0.1",
|
||||
"@types/jest": "^24.0.0",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/react": "^16.9.46",
|
||||
"@types/react-dom": "^16.9.8",
|
||||
"@types/react-list": "^0.8.5",
|
||||
"@types/react-virtualized": "^9.21.10",
|
||||
"@types/tinycolor2": "^1.4.2",
|
||||
"axios": "^0.24.0",
|
||||
"chalk": "^4",
|
||||
"typescript": "^3.9.6"
|
||||
}
|
||||
}
|
||||
|
||||
515
src/lib/icons.ts
515
src/lib/icons.ts
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user