Skip to content

Commit 96ef029

Browse files
authored
chore: Script to Update package.json files. (#5355)
1 parent 78eadb4 commit 96ef029

File tree

26 files changed

+89
-28
lines changed

26 files changed

+89
-28
lines changed

packages/Samples/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@
1212
"license": "MIT",
1313
"devDependencies": {
1414
"@cspell/cspell-tools": "workspace:*"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
19+
"directory": "packages/Samples"
1520
}
1621
}

packages/cspell-bundled-dicts/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
},
3131
"repository": {
3232
"type": "git",
33-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
33+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
34+
"directory": "packages/cspell-bundled-dicts"
3435
},
3536
"keywords": [
3637
"spell",

packages/cspell-code-snippets/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
},
1616
"repository": {
1717
"type": "git",
18-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
18+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
19+
"directory": "packages/cspell-code-snippets"
1920
},
2021
"keywords": [
2122
"cspell"

packages/cspell-config-lib/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
},
3838
"repository": {
3939
"type": "git",
40-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
40+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
41+
"directory": "packages/cspell-config-lib"
4142
},
4243
"bugs": {
4344
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-config"

packages/cspell-dictionary/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
},
3232
"repository": {
3333
"type": "git",
34-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
34+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
35+
"directory": "packages/cspell-dictionary"
3536
},
3637
"keywords": [
3738
"cspell"

packages/cspell-eslint-plugin/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
},
6464
"repository": {
6565
"type": "git",
66-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
66+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
67+
"directory": "packages/cspell-eslint-plugin"
6768
},
6869
"bugs": {
6970
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-gitignore"

packages/cspell-gitignore/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
},
4444
"repository": {
4545
"type": "git",
46-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
46+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
47+
"directory": "packages/cspell-gitignore"
4748
},
4849
"bugs": {
4950
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-gitignore"

packages/cspell-glob/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
},
4141
"repository": {
4242
"type": "git",
43-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
43+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
44+
"directory": "packages/cspell-glob"
4445
},
4546
"bugs": {
4647
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-glob"

packages/cspell-grammar/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
},
7272
"repository": {
7373
"type": "git",
74-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
74+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
75+
"directory": "packages/cspell-grammar"
7576
},
7677
"bugs": {
7778
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-grammar"

packages/cspell-io/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
},
3333
"repository": {
3434
"type": "git",
35-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
35+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
36+
"directory": "packages/cspell-io"
3637
},
3738
"keywords": [
3839
"cspell"

packages/cspell-json-reporter/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
},
3232
"repository": {
3333
"type": "git",
34-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
34+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
35+
"directory": "packages/cspell-json-reporter"
3536
},
3637
"scripts": {
3738
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",

packages/cspell-lib/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
},
3939
"repository": {
4040
"type": "git",
41-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
41+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
42+
"directory": "packages/cspell-lib"
4243
},
4344
"keywords": [
4445
"spell",

packages/cspell-pipe/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@
105105
},
106106
"repository": {
107107
"type": "git",
108-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
108+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
109+
"directory": "packages/cspell-pipe"
109110
},
110111
"bugs": {
111112
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-pipe"

packages/cspell-resolver/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
},
4141
"repository": {
4242
"type": "git",
43-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
43+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
44+
"directory": "packages/cspell-resolver"
4445
},
4546
"bugs": {
4647
"url": "https://github.com/streetsidesoftware/cspell/issues"

packages/cspell-service-bus/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
},
4444
"repository": {
4545
"type": "git",
46-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
46+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
47+
"directory": "packages/cspell-service-bus"
4748
},
4849
"bugs": {
4950
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-service-bus"

packages/cspell-strong-weak-map/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
},
4747
"repository": {
4848
"type": "git",
49-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
49+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
50+
"directory": "packages/cspell-strong-weak-map"
5051
},
5152
"bugs": {
5253
"url": "https://github.com/streetsidesoftware/cspell"

packages/cspell-tools/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
},
2525
"repository": {
2626
"type": "git",
27-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
27+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
28+
"directory": "packages/cspell-tools"
2829
},
2930
"keywords": [
3031
"cSpell",

packages/cspell-trie-lib/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
},
3535
"repository": {
3636
"type": "git",
37-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
37+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
38+
"directory": "packages/cspell-trie-lib"
3839
},
3940
"keywords": [
4041
"trie",

packages/cspell-trie/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
},
2828
"repository": {
2929
"type": "git",
30-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
30+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
31+
"directory": "packages/cspell-trie"
3132
},
3233
"keywords": [
3334
"trie",

packages/cspell-types/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
},
6363
"repository": {
6464
"type": "git",
65-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
65+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
66+
"directory": "packages/cspell-types"
6667
},
6768
"files": [
6869
"dist",

packages/cspell/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
},
6262
"repository": {
6363
"type": "git",
64-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
64+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
65+
"directory": "packages/cspell"
6566
},
6667
"keywords": [
6768
"spell",

packages/dynamic-import/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
},
4949
"repository": {
5050
"type": "git",
51-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
51+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
52+
"directory": "packages/dynamic-import"
5253
},
5354
"bugs": {
5455
"url": "https://github.com/streetsidesoftware/cspell/labels/cspell-pipe"

packages/hunspell-reader/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
},
3232
"repository": {
3333
"type": "git",
34-
"url": "git+https://github.com/streetsidesoftware/cspell.git"
34+
"url": "git+https://github.com/streetsidesoftware/cspell.git",
35+
"directory": "packages/hunspell-reader"
3536
},
3637
"keywords": [
3738
"Hunspell"

pnpm-lock.yaml

+3-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"description": "Tools and Scripts",
66
"bin": {
77
"update-release-please": "./update-release-please.mjs",
8-
"build-cspell-schema": "./build-cspell-schema.mjs"
8+
"build-cspell-schema": "./build-cspell-schema.mjs",
9+
"update-package-json": "./update-package-json.mjs"
910
},
1011
"scripts": {
1112
"#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",
@@ -21,6 +22,7 @@
2122
"esbuild": "^0.20.1"
2223
},
2324
"dependencies": {
25+
"globby": "^14.0.1",
2426
"safe-stable-stringify": "^2.4.3",
2527
"ts-json-schema-generator": "^1.5.0"
2628
}

scripts/update-package-json.mjs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env node
2+
3+
import fs from 'node:fs/promises';
4+
import { globby } from 'globby';
5+
6+
const rootUrl = new URL('../', import.meta.url);
7+
8+
async function updatePackageJson(pkgFile) {
9+
const directory = pkgFile.split(/[/\\]/g).slice(-3, -1).join('/');
10+
console.log(directory);
11+
12+
const pkg = JSON.parse(await fs.readFile(pkgFile, 'utf-8'));
13+
14+
const repository = {
15+
type: 'git',
16+
url: 'git+https://github.com/streetsidesoftware/cspell.git',
17+
directory,
18+
};
19+
20+
pkg.repository = repository;
21+
22+
await fs.writeFile(pkgFile, JSON.stringify(pkg, null, 2) + '\n');
23+
}
24+
25+
async function run() {
26+
console.log('Updating package.json files...\n');
27+
28+
const files = await globby('packages/*/package.json', { cwd: rootUrl, absolute: true });
29+
30+
await Promise.all(files.map(updatePackageJson));
31+
console.log('\nDone.');
32+
}
33+
34+
run();

0 commit comments

Comments
 (0)