Skip to content

Commit

Permalink
Adding in version and deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauan committed Sep 25, 2024
1 parent de1027e commit 113a8e7
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 26 deletions.
9 changes: 9 additions & 0 deletions PUBLISH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Publish instructions

Replace `$VERSION` with the desired new version (e.g. `0.7.0`):

```bash
npm login
yarn change-version $VERSION
yarn deploy
```
10 changes: 0 additions & 10 deletions create-leo-app/PUBLISH.md

This file was deleted.

3 changes: 1 addition & 2 deletions create-leo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild",
"typecheck": "tsc --noEmit",
"prepublishOnly": "yarn build"
"typecheck": "tsc --noEmit"
},
"engines": {
"node": "^14.18.0 || >=16.0.0"
Expand Down
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"name": "sdk-root",
"private": true,
"version": "0.0.0",
Expand All @@ -15,18 +15,27 @@
"scripts": {
"build:wasm": "cd wasm && yarn build",
"build:sdk": "cd sdk && yarn build",
"build:all": "yarn build:wasm && yarn build:sdk",
"build:create-leo-app": "cd create-leo-app && yarn build",
"build:all": "yarn build:wasm && yarn build:sdk && yarn build:create-leo-app",

"start:website": "cd website && yarn dev",

"test:wasm": "cd wasm && yarn test",
"test:sdk": "cd sdk && yarn test",
"test": "yarn test:wasm && yarn test:sdk",

"change-version": "node scripts/change-version.js",

"deploy:wasm": "cd wasm && npm publish --access=public",
"deploy:sdk": "cd sdk && npm publish --access=public",
"deploy:create-leo-app": "cd create-leo-app && npm publish --access=public",
"deploy": "yarn build:all && yarn deploy:wasm && yarn deploy:sdk && yarn deploy:create-leo-app",

"lint": "prettier . --check",
"pretty": "prettier . --write"
},
"devDependencies": {
"glob": "^11.0.0",
"prettier": "3.0.3",
"wasm-pack": "^0.12.1"
}
Expand Down
55 changes: 55 additions & 0 deletions scripts/change-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { readFile, writeFile } from "node:fs/promises";
import { glob } from "glob";


// Updates the version in the `package.json` file
async function updateVersion(path, newVersion) {
const json = await readFile(path, { encoding: "utf8" });

const replaced = json.replace(/"version": *"[^"]+"/, `"version": "${newVersion}"`);

await writeFile(path, replaced);
}


// Updates the `package.json` file so it uses the correct
// version of `@provablehq/wasm` and `@provablehq/sdk`
async function updateDependency(path, newVersion) {
const json = await readFile(path, { encoding: "utf8" });

const replaced = json
.replace(/"@provablehq\/sdk": *"[^"]+"/g, `"@provablehq/sdk": "^${newVersion}"`)
.replace(/"@provablehq\/wasm": *"[^"]+"/g, `"@provablehq/wasm": "^${newVersion}"`)
.replace(/"create-leo-app": *"[^"]+"/g, `"create-leo-app": "^${newVersion}"`);

await writeFile(path, replaced);
}


// Updates the version of the published `package.json` files
async function updateVersions(newVersion) {
await Promise.all([
"create-leo-app/package.json",
"sdk/package.json",
"wasm/package.json",
].map(async (file) => {
await updateVersion(file, newVersion);
}));
}


// Updates all of the `package.json` files so they use the correct
// version of `@provablehq/wasm` and `@provablehq/sdk`
async function updateDependencies(newVersion) {
const files = await glob("**/package.json", { ignore: "**/node_modules/**" });

await Promise.all(files.map(async (file) => {
await updateDependency(file, newVersion);
}));
}


const newVersion = process.argv[2];

await updateVersions(newVersion);
await updateDependencies(newVersion);
1 change: 0 additions & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
],
"scripts": {
"build": "rimraf dist && rollup -c rollup.config.js",
"prepublish": "yarn build",
"test": "rimraf tmp && rollup -c rollup.test.js && mocha tmp/**/*.test.js --parallel --timeout 60000"
},
"repository": {
Expand Down
10 changes: 0 additions & 10 deletions wasm/PUBLISH.md

This file was deleted.

1 change: 0 additions & 1 deletion wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"homepage": "https://github.com/ProvableHQ/sdk#readme",
"scripts": {
"build": "rimraf dist && node build.js",
"prepublish": "yarn build",
"test": "node test.js"
},
"devDependencies": {
Expand Down
39 changes: 39 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5334,6 +5334,18 @@ glob@^10.2.2, glob@^10.3.7, glob@^10.4.5:
package-json-from-dist "^1.0.0"
path-scurry "^1.11.1"

glob@^11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/glob/-/glob-11.0.0.tgz#6031df0d7b65eaa1ccb9b29b5ced16cea658e77e"
integrity sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==
dependencies:
foreground-child "^3.1.0"
jackspeak "^4.0.1"
minimatch "^10.0.0"
minipass "^7.1.2"
package-json-from-dist "^1.0.0"
path-scurry "^2.0.0"

glob@^7.0.3, glob@^7.1.3, glob@^7.1.4:
version "7.2.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
Expand Down Expand Up @@ -6027,6 +6039,13 @@ jackspeak@^3.1.2:
optionalDependencies:
"@pkgjs/parseargs" "^0.11.0"

jackspeak@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-4.0.2.tgz#11f9468a3730c6ff6f56823a820d7e3be9bef015"
integrity sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==
dependencies:
"@isaacs/cliui" "^8.0.2"

jest-worker@^27.4.5:
version "27.5.1"
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0"
Expand Down Expand Up @@ -6357,6 +6376,11 @@ lru-cache@^10.2.0:
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==

lru-cache@^11.0.0:
version "11.0.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-11.0.1.tgz#3a732fbfedb82c5ba7bca6564ad3f42afcb6e147"
integrity sha512-CgeuL5uom6j/ZVrg7G/+1IXqRY8JXX4Hghfy5YE0EhoYQWvndP1kufu58cmZLNIDKnRhZrXfdS9urVWx98AipQ==

lru-cache@^4.1.5:
version "4.1.5"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
Expand Down Expand Up @@ -6531,6 +6555,13 @@ minimalistic-assert@^1.0.0:
resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"
integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==

minimatch@^10.0.0:
version "10.0.1"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-10.0.1.tgz#ce0521856b453c86e25f2c4c0d03e6ff7ddc440b"
integrity sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==
dependencies:
brace-expansion "^2.0.1"

minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
Expand Down Expand Up @@ -7008,6 +7039,14 @@ path-scurry@^1.11.1:
lru-cache "^10.2.0"
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"

path-scurry@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-2.0.0.tgz#9f052289f23ad8bf9397a2a0425e7b8615c58580"
integrity sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==
dependencies:
lru-cache "^11.0.0"
minipass "^7.1.2"

[email protected]:
version "0.1.10"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.10.tgz#67e9108c5c0551b9e5326064387de4763c4d5f8b"
Expand Down

0 comments on commit 113a8e7

Please sign in to comment.