Skip to content

Commit

Permalink
chore: Script to Update package.json files. (#5355)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Mar 5, 2024
1 parent 78eadb4 commit 96ef029
Show file tree
Hide file tree
Showing 26 changed files with 89 additions and 28 deletions.
5 changes: 5 additions & 0 deletions packages/Samples/package.json
Expand Up @@ -12,5 +12,10 @@
"license": "MIT",
"devDependencies": {
"@cspell/cspell-tools": "workspace:*"
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/Samples"
}
}
3 changes: 2 additions & 1 deletion packages/cspell-bundled-dicts/package.json
Expand Up @@ -30,7 +30,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-bundled-dicts"
},
"keywords": [
"spell",
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-code-snippets/package.json
Expand Up @@ -15,7 +15,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-code-snippets"
},
"keywords": [
"cspell"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-config-lib/package.json
Expand Up @@ -37,7 +37,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-config-lib"
},
"bugs": {
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-config"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-dictionary/package.json
Expand Up @@ -31,7 +31,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-dictionary"
},
"keywords": [
"cspell"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-eslint-plugin/package.json
Expand Up @@ -63,7 +63,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-eslint-plugin"
},
"bugs": {
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-gitignore"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-gitignore/package.json
Expand Up @@ -43,7 +43,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-gitignore"
},
"bugs": {
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-gitignore"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-glob/package.json
Expand Up @@ -40,7 +40,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-glob"
},
"bugs": {
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-glob"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-grammar/package.json
Expand Up @@ -71,7 +71,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-grammar"
},
"bugs": {
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-grammar"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-io/package.json
Expand Up @@ -32,7 +32,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-io"
},
"keywords": [
"cspell"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-json-reporter/package.json
Expand Up @@ -31,7 +31,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-json-reporter"
},
"scripts": {
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-lib/package.json
Expand Up @@ -38,7 +38,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-lib"
},
"keywords": [
"spell",
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-pipe/package.json
Expand Up @@ -105,7 +105,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-pipe"
},
"bugs": {
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-pipe"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-resolver/package.json
Expand Up @@ -40,7 +40,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-resolver"
},
"bugs": {
"url": "https://github.com/streetsidesoftware/cspell/issues"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-service-bus/package.json
Expand Up @@ -43,7 +43,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-service-bus"
},
"bugs": {
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-service-bus"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-strong-weak-map/package.json
Expand Up @@ -46,7 +46,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-strong-weak-map"
},
"bugs": {
"url": "https://github.com/streetsidesoftware/cspell"
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-tools/package.json
Expand Up @@ -24,7 +24,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-tools"
},
"keywords": [
"cSpell",
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-trie-lib/package.json
Expand Up @@ -34,7 +34,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-trie-lib"
},
"keywords": [
"trie",
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-trie/package.json
Expand Up @@ -27,7 +27,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-trie"
},
"keywords": [
"trie",
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-types/package.json
Expand Up @@ -62,7 +62,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell-types"
},
"files": [
"dist",
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell/package.json
Expand Up @@ -61,7 +61,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/cspell"
},
"keywords": [
"spell",
Expand Down
3 changes: 2 additions & 1 deletion packages/dynamic-import/package.json
Expand Up @@ -48,7 +48,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/dynamic-import"
},
"bugs": {
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-pipe"
Expand Down
3 changes: 2 additions & 1 deletion packages/hunspell-reader/package.json
Expand Up @@ -31,7 +31,8 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/streetsidesoftware/cspell.git"
"url": "git+https://github.com/streetsidesoftware/cspell.git",
"directory": "packages/hunspell-reader"
},
"keywords": [
"Hunspell"
Expand Down
8 changes: 3 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion scripts/package.json
Expand Up @@ -5,7 +5,8 @@
"description": "Tools and Scripts",
"bin": {
"update-release-please": "./update-release-please.mjs",
"build-cspell-schema": "./build-cspell-schema.mjs"
"build-cspell-schema": "./build-cspell-schema.mjs",
"update-package-json": "./update-package-json.mjs"
},
"scripts": {
"#build:ts-json-schema-generator": "pnpm esbuild ../../../code/clones/ts-json-schema-generator/dist/index.js --bundle --outfile=lib/ts-json-schema-generator.cjs --platform=node --external:typescript",
Expand All @@ -21,6 +22,7 @@
"esbuild": "^0.20.1"
},
"dependencies": {
"globby": "^14.0.1",
"safe-stable-stringify": "^2.4.3",
"ts-json-schema-generator": "^1.5.0"
}
Expand Down
34 changes: 34 additions & 0 deletions scripts/update-package-json.mjs
@@ -0,0 +1,34 @@
#!/usr/bin/env node

import fs from 'node:fs/promises';
import { globby } from 'globby';

const rootUrl = new URL('../', import.meta.url);

async function updatePackageJson(pkgFile) {
const directory = pkgFile.split(/[/\\]/g).slice(-3, -1).join('/');
console.log(directory);

const pkg = JSON.parse(await fs.readFile(pkgFile, 'utf-8'));

const repository = {
type: 'git',
url: 'git+https://github.com/streetsidesoftware/cspell.git',
directory,
};

pkg.repository = repository;

await fs.writeFile(pkgFile, JSON.stringify(pkg, null, 2) + '\n');
}

async function run() {
console.log('Updating package.json files...\n');

const files = await globby('packages/*/package.json', { cwd: rootUrl, absolute: true });

await Promise.all(files.map(updatePackageJson));
console.log('\nDone.');
}

run();

0 comments on commit 96ef029

Please sign in to comment.