Skip to content

Commit 734b382

Browse files
committed
update sdk build scripts
1 parent 3f29d17 commit 734b382

File tree

8 files changed

+56
-31
lines changed

8 files changed

+56
-31
lines changed

.github/workflows/ci-lint-typescript.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424

2525
- name: Setup pnpm
2626
uses: pnpm/action-setup@v4
27+
with:
28+
run_install: |
29+
- recursive: true
2730
2831
- name: Install Rust stable
2932
uses: actions-rs/toolchain@v1

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
"dev:off": "node sdk/typescript/scripts/dev-mode-remove.mjs"
3434
},
3535
"devDependencies": {
36-
"npm-run-all": "^4.1.5",
3736
"@npmcli/node-gyp": "^3.0.0",
37+
"js-yaml": "^4.1.0",
3838
"node-gyp": "^9.3.1",
39+
"npm-run-all": "^4.1.5",
3940
"tslog": "3.3.3"
4041
},
4142
"packageManager": "[email protected]+sha256.b6fd0bfda555e7e584ad7e56b30c68b01d5a04f9ee93989f4b93ca8473c49c74"

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
packages:
2-
- "dist/wasm/**"
3-
- "dist/node/**"
4-
- "dist/ts/**"
5-
- "sdk/typescript/packages/mui-theme"
6-
- "sdk/typescript/packages/react-components"
7-
- "sdk/typescript/packages/validator-client"
8-
- "ts-packages/*"
9-
- "nym-wallet"
10-
- "explorer-nextjs"
11-
- "types"
12-
- "clients/validator"
2+
- dist/wasm/**
3+
- dist/node/**
4+
- dist/ts/**
5+
- sdk/typescript/packages/mui-theme
6+
- sdk/typescript/packages/react-components
7+
- sdk/typescript/packages/validator-client
8+
- ts-packages/*
9+
- nym-wallet
10+
- explorer-nextjs
11+
- types
12+
- clients/validator

sdk/typescript/scripts/build-prod-sdk.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ rm -rf dist || true
1111
##---------------------------------------------------------------------------
1212

1313
# use wasm-pack to build packages
14-
yarn build:wasm
14+
pnpm build:wasm
1515

1616
# enable dev mode and then install dev packages
17-
yarn dev:on
18-
yarn
17+
pnpm dev:on
18+
pnpm
1919

2020
# build the Typescript SDK packages
21-
yarn build:ci:sdk
21+
pnpm build:ci:sdk
2222

2323
# build documentation
24-
yarn docs:prod:build
24+
pnpm docs:prod:build
2525

2626
# turn dev mode off
27-
yarn dev:off
27+
pnpm dev:off
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
import fs from 'fs';
2+
import yaml from 'js-yaml';
23

3-
const packageJson = JSON.parse(fs.readFileSync('package.json').toString());
4+
// Load the pnpm-workspace.yaml file
5+
const pnpmWorkspaceYamlPath = 'pnpm-workspace.yaml';
6+
const pnpmWorkspaceContent = fs.readFileSync(pnpmWorkspaceYamlPath, 'utf8');
7+
const pnpmWorkspace = yaml.load(pnpmWorkspaceContent);
48

9+
// Define the workspaces to add
510
const devWorkspace = ['sdk/typescript/packages/**', 'sdk/typescript/examples/**', 'sdk/typescript/codegen/**'];
6-
if (!packageJson.workspaces.includes(devWorkspace)) {
7-
// add
8-
packageJson.workspaces.push(...devWorkspace);
911

10-
// write out modified file
11-
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
12+
// Check if the workspaces are already included, if not, add them
13+
if (!pnpmWorkspace.packages) {
14+
pnpmWorkspace.packages = [];
15+
}
16+
const missingWorkspaces = devWorkspace.filter((ws) => !pnpmWorkspace.packages.includes(ws));
17+
if (missingWorkspaces.length > 0) {
18+
pnpmWorkspace.packages.push(...missingWorkspaces);
19+
20+
// Write out the modified pnpm-workspace.yaml file
21+
const newYamlContent = yaml.dump(pnpmWorkspace);
22+
fs.writeFileSync(pnpmWorkspaceYamlPath, newYamlContent, 'utf8');
1223
}
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import fs from 'fs';
2+
import yaml from 'js-yaml';
23

3-
const packageJson = JSON.parse(fs.readFileSync('package.json').toString());
4+
// Load the pnpm-workspace.yaml file
5+
const pnpmWorkspaceYamlPath = 'pnpm-workspace.yaml';
6+
const pnpmWorkspaceContent = fs.readFileSync(pnpmWorkspaceYamlPath, 'utf8');
7+
const pnpmWorkspace = yaml.load(pnpmWorkspaceContent);
48

59
const devWorkspace = ['sdk/typescript/packages/**', 'sdk/typescript/examples/**', 'sdk/typescript/codegen/**'];
610

7-
// remove
8-
packageJson.workspaces = packageJson.workspaces.filter((w) => !devWorkspace.includes(w));
11+
// Remove specified workspaces
12+
pnpmWorkspace.packages = pnpmWorkspace.packages.filter((w) => !devWorkspace.includes(w));
913

10-
// write out modified file
11-
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
14+
// Convert the modified object back to YAML
15+
const newYamlContent = yaml.dump(pnpmWorkspace);
16+
17+
// Write out the modified pnpm-workspace.yaml file
18+
fs.writeFileSync(pnpmWorkspaceYamlPath, newYamlContent, 'utf8');

sdk/typescript/scripts/release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ set -o pipefail
88
make sdk-wasm-build
99

1010
# Build Typescript packages
11-
yarn
12-
yarn build:sdk
11+
pnpm i
12+
pnpm build:sdk
1313

1414
# Publish to NPM
1515
./sdk/typescript/scripts/publish.sh

0 commit comments

Comments
 (0)