Skip to content

Commit

Permalink
chore(scripts): sync okam before pub bundler (#843)
Browse files Browse the repository at this point in the history
* chore: 🔧 script check okam whether synced

* refactor: 🎨 slient sync logs

* chore: 🔧 sync optinal deps in scripts
  • Loading branch information
stormslowly authored Jan 4, 2024
1 parent b1b80cf commit 0de97bf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/bundler-okam/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts
4 changes: 4 additions & 0 deletions packages/bundler-okam/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"rimraf": "5.0.1",
"webpack-5-chain": "8.0.1"
},
"scripts": {
"prepublishOnly": "esno ./scripts/ensure_synced.ts",
"sync": "esno ./scripts/ensure_synced.ts"
},
"publishConfig": {
"registry": "https://registry.antgroup-inc.cn"
},
Expand Down
31 changes: 31 additions & 0 deletions packages/bundler-okam/scripts/ensure_synced.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'zx/globals';

(async () => {
const makoVersion =
require('../package.json')['dependencies']['@okamjs/okam'];

await retry(3, () => {
return (async () => {
await $`tnpm sync @okamjs/okam`.quiet();
const info =
await $`tnpm info --json @okamjs/okam@${makoVersion}`.quiet();

const optionDeps = JSON.parse(info.stdout)['optionalDependencies'];

await Promise.all(
Object.keys(optionDeps).map((key) => {
return $`tnpm info ${key}@${optionDeps[key]}`.quiet();
}),
);
})();
});

console.error(chalk.bgGreen(chalk.white('SUCCEED')), chalk.green('synced'));
})().catch((err) => {
console.error(err);
console.error(
chalk.bgRed(chalk.white('FAILED')),
chalk.red('sync @okamjs/okam failed!'),
);
process.exit(1);
});

0 comments on commit 0de97bf

Please sign in to comment.