Skip to content

Commit 60b4533

Browse files
authored
chore: introduce zx, corepack and setup script (#2754)
* chore: introduce corepack and setup script * update docs * Update lock * Delete catch * Add readme * Improve readme * Improve readme * Improve readme
1 parent f54621d commit 60b4533

File tree

14 files changed

+179
-1
lines changed

14 files changed

+179
-1
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ nvm alias default 16
7575
nvm use 16
7676
```
7777

78+
#### Running setup script
79+
80+
Make sure you are under the workspace root
81+
82+
```bash
83+
node ./scripts/meta/setup.mjs
84+
```
85+
7886
#### Install Dependencies
7987

8088
Install Node.js dependencies via [pnpm](https://pnpm.io/).

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"bump": "changeset version",
3030
"changeset": "changeset",
3131
"prepare": "is-ci || husky install",
32+
"pnpm:devPreinstall": "is-ci || node ./scripts/meta/doctor.mjs",
3233
"test:example": "pnpm --filter \"example-*\" build",
3334
"test:unit": "pnpm --filter \"@rspack/*\" test",
3435
"test:e2e": "pnpm --filter \"@rspack-e2e/*\" test"

scripts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

scripts/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Scripts here are related to development workflow of Rspack.
2+
3+
## Usages
4+
5+
```bash
6+
node ./scripts/xxxx.js
7+
```
8+
9+
- Some scripts require executing under the folder of workspace root. Don't worries, they would validate the environment while executing.
10+
11+
## Guidance
12+
13+
### Writting scripts with zx
14+
15+
[zx](https://github.com/google/zx) is a wonderful tool for writting scripts using JavaScript.
16+
17+
There are many [ways](https://github.com/google/zx#documentation) to use zx. The way we recommended is import globals explicitly.
18+
19+
```js
20+
import "zx/globals";
21+
```
22+
23+
This allow us to execute every script(some of them might not use zx) in this folder by using the same way: `node ./scripts/xxxx.js`

scripts/build-npm.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
const path = require("path");
23
const fs = require("fs");
34
const assert = require("assert");

scripts/check_changeset.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
const { spawnSync } = require("child_process");
23
const path = require("path");
34
const util = require("util");

scripts/check_rust_dependency.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
const path = require("path");
23
const fs = require("fs");
34
const child_process = require("child_process");

scripts/cmd.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
const cp = require("child_process");
23
const log = require("./log");
34
const { Command } = require("commander");

scripts/log.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
const PREFIX = "[x] ";
23

34
const COLOR = {

scripts/meta/doctor.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Yeah. Doctor here.");

0 commit comments

Comments
 (0)