Skip to content

Commit

Permalink
feat(bin+lib): add codepoints to entry list
Browse files Browse the repository at this point in the history
  • Loading branch information
rektdeckard committed Jan 9, 2024
1 parent dad3260 commit 6290ab1
Show file tree
Hide file tree
Showing 5 changed files with 1,267 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
printWidth: 80
semi: true
tabWidth: 2
trailingComma: "es5"
trailingComma: "es5"
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@phosphor-icons/core",
"version": "2.0.3",
"version": "2.0.4",
"description": "Icon catalog and assets for Phosphor",
"license": "MIT",
"repository": "https://github.com/phosphor-icons/phosphor-core.git",
Expand Down Expand Up @@ -49,7 +49,7 @@
],
"scripts": {
"fetch": "node ./scripts/fetch.js && yarn format",
"format": "prettier --write ./src/**",
"format": "prettier --write ./src/** ./scripts/**",
"build": "vite build && tsc --emitDeclarationOnly"
},
"devDependencies": {
Expand Down
15 changes: 15 additions & 0 deletions scripts/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,36 @@ async function main() {
try {
const res = await axios.get(`${ICON_API_URL}?${params}`);
if (res.data) {
res.data.icons.sort((a, b) => (a.name < b.name ? -1 : 1));

let fileString = `\
import { IconEntry, IconCategory, FigmaCategory } from "./types";
export const icons: ReadonlyArray<IconEntry> = [
`;

console.log(res.data.icons);
res.data.icons.forEach((icon) => {
if (!icon.codepoint) {
console.error(
`${chalk.inverse.red(" FAIL ")} ${icon.name} missing Codepoint`
);
throw new Error("codepoint");
}

if (!icon.category) {
console.error(
`${chalk.inverse.red(" FAIL ")} ${icon.name} missing Category`
);
throw new Error("category");
}

let figma_category = CATEGORY_MAP[icon.category];
if (!figma_category) {
console.error(
`${chalk.inverse.red(" FAIL ")} Invalid category ${icon.category}`
);
throw new Error("figma_category");
}

let categories = "[";
Expand Down Expand Up @@ -82,6 +94,7 @@ export const icons: ReadonlyArray<IconEntry> = [
: []),
...icon.tags,
])},
codepoint: ${icon.codepoint},
published_in: ${icon.published_in.toFixed(1)},
updated_in: ${icon.updated_in.toFixed(1)},
},
Expand All @@ -100,9 +113,11 @@ export const icons: ReadonlyArray<IconEntry> = [
);
} catch (e) {
console.error(`${chalk.inverse.red(" FAIL ")} Could not write file`);
process.exit(1);
}
} else {
console.error(`${chalk.inverse.red(" FAIL ")} No data`);
process.exit(1);
}
} catch (e) {
console.error(e);
Expand Down
Loading

0 comments on commit 6290ab1

Please sign in to comment.