Skip to content

Commit

Permalink
chore: add ts release script to fix the lerna peer dependencies issue (
Browse files Browse the repository at this point in the history
  • Loading branch information
Lodin authored Feb 23, 2022
1 parent 4fb624c commit 0bf45af
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/ts/generator-typescript-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"tsgen": "bin/index.js"
},
"peerDependencies": {
"@hilla/generator-typescript-core": "^0.0.18"
"@hilla/generator-typescript-core": "^0.0.19"
},
"dependencies": {
"@hilla/generator-typescript-utils": "^0.0.19",
Expand Down
4 changes: 2 additions & 2 deletions packages/ts/generator-typescript-plugin-backbone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"access": "public"
},
"peerDependencies": {
"@hilla/generator-typescript-core": "^0.0.18",
"@hilla/generator-typescript-plugin-client": "^0.0.18"
"@hilla/generator-typescript-core": "^0.0.19",
"@hilla/generator-typescript-plugin-client": "^0.0.19"
},
"dependencies": {
"@hilla/generator-typescript-utils": "^0.0.19",
Expand Down
4 changes: 2 additions & 2 deletions packages/ts/generator-typescript-plugin-barrel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"access": "public"
},
"peerDependencies": {
"@hilla/generator-typescript-core": "^0.0.18",
"@hilla/generator-typescript-plugin-backbone": "^0.0.18"
"@hilla/generator-typescript-core": "^0.0.19",
"@hilla/generator-typescript-plugin-backbone": "^0.0.19"
},
"dependencies": {
"@hilla/generator-typescript-utils": "^0.0.19",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"access": "public"
},
"peerDependencies": {
"@hilla/generator-typescript-core": "^0.0.18"
"@hilla/generator-typescript-core": "^0.0.19"
},
"dependencies": {
"@hilla/generator-typescript-utils": "^0.0.19",
Expand Down
6 changes: 3 additions & 3 deletions packages/ts/generator-typescript-plugin-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"access": "public"
},
"peerDependencies": {
"@hilla/form": "^0.0.18",
"@hilla/generator-typescript-core": "^0.0.18",
"@hilla/generator-typescript-plugin-backbone": "^0.0.18"
"@hilla/form": "^0.0.19",
"@hilla/generator-typescript-core": "^0.0.19",
"@hilla/generator-typescript-plugin-backbone": "^0.0.19"
},
"dependencies": {
"@hilla/generator-typescript-utils": "^0.0.19",
Expand Down
2 changes: 2 additions & 0 deletions scripts/bump/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ find "$packages_dir"/*/src/index.ts -exec sed -i "s/version:.\+\$/version: \/* u

npx lerna version "$VERSION_TAG" --no-git-tag-version --no-push --yes

find "$packages_dir"/*/package.json -exec node "$bump_scripts_dir"/package-update.js -v "$VERSION_TAG" {} +

git add --all

git \
Expand Down
43 changes: 43 additions & 0 deletions scripts/bump/package-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* eslint-disable import/no-extraneous-dependencies,camelcase,no-console */
import meow from 'meow';
import { readFile, writeFile } from 'fs/promises';

const {
input: packageFileNames,
flags: { version },
} = meow({
importMeta: import.meta,
flags: {
version: {
type: 'string',
alias: 'v',
},
},
});

const errors = new Map();

await Promise.all(
packageFileNames.map(async (packageFileName) => {
try {
const packageJson = JSON.parse(await readFile(packageFileName, 'utf8'));
const { peerDependencies } = packageJson;

if (peerDependencies) {
for (const dependency of Object.keys(peerDependencies)) {
if (dependency.startsWith('@hilla')) {
peerDependencies[dependency] = `^${version}`;
}
}

await writeFile(packageFileName, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf8');
}
} catch (e) {
errors.set(packageFileName, e);
}
}),
);

for (const [file, error] of errors) {
console.error(`Error in ${file}:\n`, error);
}

0 comments on commit 0bf45af

Please sign in to comment.