Skip to content

Commit 5adeb68

Browse files
committed
chore: Reorganize JS packages using NPM workspaces
1 parent f247ca2 commit 5adeb68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+10486
-3015
lines changed

.github/workflows/release.yml

+6-17
Original file line numberDiff line numberDiff line change
@@ -74,28 +74,17 @@ jobs:
7474
with:
7575
node-version: 20
7676

77-
- name: Deploy CLI
77+
- name: Deploy JS packages
7878
env:
7979
AWS_CODEARTIFACT_DOMAIN: ${{ secrets.AWS_CODEARTIFACT_DOMAIN }}
8080
AWS_CODEARTIFACT_OWNER: ${{ secrets.AWS_CODEARTIFACT_OWNER }}
8181
AWS_CODEARTIFACT_REGION: ${{ secrets.AWS_CODEARTIFACT_REGION }}
8282
NODE_AUTH_TOKEN: ${{ steps.repository.outputs.token }}
83-
working-directory: ./js-cli
83+
working-directory: ./js
8484
run: |
8585
npm ci
86-
npm run build
8786
npm version "${{ steps.deploy-jvm.outputs.version }}"
88-
npm publish
89-
90-
- name: Deploy DSL
91-
env:
92-
AWS_CODEARTIFACT_DOMAIN: ${{ secrets.AWS_CODEARTIFACT_DOMAIN }}
93-
AWS_CODEARTIFACT_OWNER: ${{ secrets.AWS_CODEARTIFACT_OWNER }}
94-
AWS_CODEARTIFACT_REGION: ${{ secrets.AWS_CODEARTIFACT_REGION }}
95-
NODE_AUTH_TOKEN: ${{ steps.repository.outputs.token }}
96-
working-directory: ./js-dsl
97-
run: |
98-
npm ci
99-
npm run build
100-
npm version "${{ steps.deploy-jvm.outputs.version }}"
101-
npm publish
87+
npm run build --workspaces
88+
for pkg in "cli" "jvm-types" "core" "http"; do
89+
npm publish "[email protected]/$pkg"
90+
done

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# sbt
22
.bsp/
3+
version.sbt
34

45
# yarn
56
node_modules/
67

78
# build targets
89
target/
910
/tmp/
10-
/js-cli/src/dependencies/versions.ts
11+
/js/cli/src/dependencies/versions.ts
12+
/js/jvm-types/index.js
13+
/js/jvm-types/index.d.ts
1114

1215
# IntelliJ
1316
*.iml

build-all.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ root_dir="$(dirname "$(realpath -- "$0")")"
66

77
"$root_dir/build-jvm.sh"
88

9-
"$root_dir/build-js-cli.sh"
10-
11-
"$root_dir/build-js-dsl.sh"
9+
"$root_dir/build-js.sh"
1210

1311
# Rebuild js-simulation
1412
cd "$root_dir/js-simulation"

build-js-cli.sh

-16
This file was deleted.

build-js-dsl.sh

-16
This file was deleted.

build-js.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
root_dir="$(dirname "$(realpath -- "$0")")"
6+
7+
build_pkg() {
8+
pkg=$1
9+
target_dir="$root_dir/tmp/$pkg"
10+
pkg_archive="$root_dir/js/gatling.io-$pkg-0.0.0.tgz"
11+
linked_pkgs=("${@:2}")
12+
13+
echo "Building $pkg and linking it at $target_dir"
14+
mkdir -p "$target_dir"
15+
16+
cd "$root_dir/js"
17+
npm run build "--workspace=$pkg"
18+
npm pack "--workspace=$pkg"
19+
tar xzf "$pkg_archive" -C "$target_dir"
20+
rm "$pkg_archive"
21+
22+
cd "$target_dir/package"
23+
# Multiple packages MUST be linked all at once (executing 'npm link <pkg>' again will remove previous links...)
24+
npm link "${linked_pkgs[@]}"
25+
npm install
26+
npm link
27+
}
28+
29+
rm -rf "$root_dir/tmp"
30+
build_pkg "cli"
31+
build_pkg "jvm-types"
32+
build_pkg "core" "@gatling.io/jvm-types"
33+
build_pkg "http" "@gatling.io/jvm-types" "@gatling.io/core"

install-all-with-links.sh

+6-13
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,17 @@ set -e
44

55
root_dir="$(dirname "$(realpath -- "$0")")"
66

7+
# Publish JVM adapter
78
"$root_dir/build-jvm.sh"
89

9-
# Install and link js-cli
10-
cd "$root_dir/js-cli"
10+
# Install and link js
11+
cd "$root_dir/js"
1112
npm install
12-
"$root_dir/build-js-cli.sh"
13-
cd "$root_dir/tmp/js-cli/package"
14-
npm link
15-
16-
# Install and link js-dsl
17-
cd "$root_dir/js-dsl"
18-
npm install
19-
"$root_dir/build-js-dsl.sh"
20-
cd "$root_dir/tmp/js-dsl/package"
21-
npm link
13+
"$root_dir/build-js.sh"
2214

2315
# Install js-simulation
2416
cd "$root_dir/js-simulation"
17+
# Multiple packages MUST be linked all at once (executing 'npm link <pkg>' again will remove previous links...):
18+
npm link "@gatling.io/cli" "@gatling.io/core" "@gatling.io/http"
2519
npm install
26-
npm link "@gatling/js-cli" "@gatling/js" # Multiple packages MUST be linked all at once (executing npm link again will remove previous links...)
2720
npm run build # Make sure that js-simulation build works

install-all-without-links.sh

+5-8
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ set -e
55
root_dir="$(dirname "$(realpath -- "$0")")"
66

77
# Publish JVM adapter
8+
"$root_dir/build-jvm.sh"
9+
810
cd "$root_dir/jvm"
911
sbt gatling-jvm-to-js-adapter/publishLocal
1012

11-
# Install js-cli
12-
cd "$root_dir/js-cli"
13-
npm install
14-
npm run build # Make sure that js-cli build works
15-
16-
# Install and link js-dsl
17-
cd "$root_dir/js-dsl"
13+
# Install js
14+
cd "$root_dir/js"
1815
npm install
19-
npm run build # Make sure that js-dsl build works
16+
npm run build --workspaces # Make sure that js builds works
2017

2118
# Install js-simulation
2219
cd "$root_dir/js-simulation"

js-cli/.npmrc

-2
This file was deleted.

0 commit comments

Comments
 (0)