Skip to content

Commit

Permalink
fix: improve vitest matcher sources resolver (#1514)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard authored Jul 19, 2024
1 parent eb93002 commit 0cd1b95
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
run: npm install -g wasm-pack

- name: Build Wasm packages
run: npm run build:wasm
run: npm run build:sdk-wasm

- name: Install dependencies
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion components/clarinet-sdk-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "clarinet-sdk-wasm"
# version.workspace = true
version = "2.8.0-beta1"
version = "2.8.0-beta6"
edition = "2021"
license = "GPL-3.0"
repository = "https://github.com/hirosystems/clarinet"
Expand Down
4 changes: 2 additions & 2 deletions components/clarinet-sdk-wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ In the root directory of Clarinet, run the following command to build the packag
Under the hood, it will run `wasm-pack build` twice, once for each target.

```sh
npm run build:wasm
npm run build:sdk-wasm
```

Alternatively, it's also possible to build the packages separately. It should only be done for development purpose.
Expand All @@ -39,7 +39,7 @@ The following script will build for both target, it will also rename the package
browser build.

```sh
npm run build:wasm
npm run build:sdk-wasm
```

Once built, the packages can be released by running the following command. Note that by default we
Expand Down
2 changes: 1 addition & 1 deletion components/clarinet-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ wasm-pack (install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer)).

```sh
# build the wasm package
npm run build:wasm
npm run build:sdk-wasm
# install dependencies and build the node package
npm install
# make sure the installation works
Expand Down
4 changes: 2 additions & 2 deletions components/clarinet-sdk/browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hirosystems/clarinet-sdk-browser",
"version": "2.8.0-beta1",
"version": "2.8.0-beta6",
"description": "A SDK to interact with Clarity Smart Contracts in the browser",
"homepage": "https://www.hiro.so/clarinet",
"repository": {
Expand Down Expand Up @@ -28,7 +28,7 @@
"license": "GPL-3.0",
"readme": "./README.md",
"dependencies": {
"@hirosystems/clarinet-sdk-wasm-browser": "^2.8.0-beta1",
"@hirosystems/clarinet-sdk-wasm-browser": "^2.8.0-beta6",
"@stacks/transactions": "^6.13.0"
}
}
4 changes: 2 additions & 2 deletions components/clarinet-sdk/node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hirosystems/clarinet-sdk",
"version": "2.8.0-beta1",
"version": "2.8.0-beta6",
"description": "A SDK to interact with Clarity Smart Contracts in node.js",
"homepage": "https://www.hiro.so/clarinet",
"repository": {
Expand Down Expand Up @@ -61,7 +61,7 @@
"license": "GPL-3.0",
"readme": "./README.md",
"dependencies": {
"@hirosystems/clarinet-sdk-wasm": "^2.8.0-beta1",
"@hirosystems/clarinet-sdk-wasm": "^2.8.0-beta6",
"@stacks/transactions": "^6.13.0",
"kolorist": "^1.8.0",
"prompts": "^2.4.2",
Expand Down
14 changes: 12 additions & 2 deletions components/clarinet-sdk/node/src/vitest/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import path from "node:path";
import url from "node:url";

import yargs from "yargs";
import { hideBin } from "yargs/helpers";

Expand Down Expand Up @@ -39,5 +42,12 @@ export function getClarinetVitestsArgv() {
}).argv;
}

export const vitestHelpersPath = "node_modules/@hirosystems/clarinet-sdk/vitest-helpers/src/";
export const vitestSetupFilePath = `${vitestHelpersPath}vitest.setup.ts`;
// ensure vitest helpers can be imported even in workspace setup
// import.meta.resolve return an url like "file:///absolute/path/to/clarinet-sdk/dist/esm/index.js"
const sdkURL = import.meta.resolve("@hirosystems/clarinet-sdk");
const sdkPath = url.fileURLToPath(sdkURL);
const sdkDir = path.dirname(sdkPath);

// sdkDir is in /dist/esm/node/src, hence the ../../../../
export const vitestHelpersPath = path.join(sdkDir, "../../../../vitest-helpers/src/");
export const vitestSetupFilePath = path.join(vitestHelpersPath, "vitest.setup.ts");
3 changes: 2 additions & 1 deletion components/clarinet-sdk/node/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"module": "commonjs",
"outDir": "dist/cjs",
"target": "ESNext"
}
},
"exclude": ["./src/vitest"]
}
83 changes: 42 additions & 41 deletions package-lock.json

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

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"components/clarinet-sdk/browser"
],
"scripts": {
"build:wasm": "node components/clarinet-sdk-wasm/build.mjs",
"build:sdk-wasm": "node components/clarinet-sdk-wasm/build.mjs",
"build:sdk": "npm run -w components/clarinet-sdk/node -w components/clarinet-sdk/browser build",
"test": "npm test --workspaces --if-present",
"publish:sdk-wasm": "npm publish -w components/clarinet-sdk-wasm/pkg-node -w components/clarinet-sdk-wasm/pkg-browser --tag beta",
"publish:sdk": "npm publish -w components/clarinet-sdk/node -w components/clarinet-sdk/browser --tag beta"
Expand All @@ -22,8 +23,8 @@
"@types/node": "^20.4.5",
"@types/prompts": "^2.4.5",
"@types/yargs": "^17.0.24",
"prettier": "^3.0.3",
"rimraf": "^5.0.1",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"ts-loader": "^9.4.4",
"typescript": "^5.1.6"
}
Expand Down

0 comments on commit 0cd1b95

Please sign in to comment.