Skip to content

Commit

Permalink
feat: use zx for workspace only deps installation
Browse files Browse the repository at this point in the history
  • Loading branch information
linbudu599 committed Mar 22, 2022
1 parent ec1ee02 commit b64d914
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pnpm-vscode-helper.extraWorkspaceScripts": ["develop"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"docs:build": "vitepress build docs",
"docs:dev": "vitepress dev docs",
"docs:serve": "vitepress serve docs",
"init:dep": "pnpm install cac fs-extra ora consola execa preferred-pm type-fest chalk enquirer --workspace-root --registry=https://registry.npmmirror.com",
"init:dep": "pnpx zx scripts/zx/install-workspace-root-deps-only.mjs",
"init:workspace": "pnpm init:dep && pnpm cli cache && pnpm cli init",
"postinstall": "pnpm cli cache && pnpm remind",
"remind": "ts-node -P scripts/tsconfig.script.json scripts/postinstall-reminder.ts"
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

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

19 changes: 19 additions & 0 deletions scripts/zx/install-workspace-root-deps-only.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env zx

// https://github.com/google/zx#__filename--__dirname
const content = await fs.readFile(
path.resolve(__dirname, '../../package.json'),
'utf-8'
);

const { devDependencies } = JSON.parse(content);

const composed = Object.entries(devDependencies)
.reduce((prev, curr) => {
const withVersion = curr[0] + '@' + curr[1];
prev.push(withVersion);
return prev;
}, [])
.filter((p) => !p.startsWith('@types'));

await $`pnpm install ${composed} --workspace-root --registry=https://registry.npmmirror.com`;

0 comments on commit b64d914

Please sign in to comment.