Skip to content

Commit

Permalink
feat: add packagejson rebuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Lotus authored and ayuhito committed Aug 2, 2020
1 parent b333ce8 commit a4e6456
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"parser:v2": "npm explore google-font-metadata -- yarn parser:v2",
"readme-update:google": "node scripts/google/google-readme-updater.js",
"util:generic-rebuild": "node scripts/generic/rebuilder.js",
"util:renamer": "node scripts/generic/renamer.js",
"util:generic-renamer": "node scripts/generic/renamer.js",
"util:package-json-rebuild": "node scripts/utils/package-json-rebuild.js",
"deploy": "lerna publish patch --no-git-tag-version --no-push --force-publish",
"deploy:ci": "lerna version patch --yes --no-push --message 'chore: release new versions' && lerna publish from-git --yes && git push --follow-tags --no-verify origin master"
},
Expand Down
33 changes: 33 additions & 0 deletions scripts/utils/package-json-rebuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const fs = require(`fs-extra`)
const jsonfile = require(`jsonfile`)

// Find names of all packages.
const getDirectories = () =>
fs
.readdirSync("./packages", { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name)

const directories = getDirectories()

directories.forEach(directory => {
const fontDir = `./packages/${directory}`
const metadata = jsonfile.readFileSync(`${fontDir}/metadata.json`)
const packageJSON = jsonfile.readFileSync(`${fontDir}/package.json`)
fs.removeSync(`${fontDir}/package.json`)
jsonfile.writeFileSync(`${fontDir}/package.json`, {
name: packageJSON.name,
version: packageJSON.version,
description: packageJSON.description,
main: "index.css",
keywords: packageJSON.keywords,
author: "Lotus <declininglotus@gmail.com>",
license: "MIT",
homepage: `https://github.com/fontsource/fontsource/tree/master/packages/${metadata.fontId}#readme`,
repository: {
type: "git",
url: "https://github.com/fontsource/fontsource.git",
directory: `packages/${metadata.fontId}`,
},
})
})

0 comments on commit a4e6456

Please sign in to comment.