diff --git a/PUBLISH.md b/PUBLISH.md new file mode 100644 index 000000000..ca719a28c --- /dev/null +++ b/PUBLISH.md @@ -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 +``` diff --git a/create-leo-app/PUBLISH.md b/create-leo-app/PUBLISH.md deleted file mode 100644 index 13395a0a4..000000000 --- a/create-leo-app/PUBLISH.md +++ /dev/null @@ -1,10 +0,0 @@ -# create-leo-app - -## Publish instructions - -```bash -npm login -yarn build -npm version patch -yarn publish --access=public -``` \ No newline at end of file diff --git a/create-leo-app/package.json b/create-leo-app/package.json index 9485e2533..b655f2340 100644 --- a/create-leo-app/package.json +++ b/create-leo-app/package.json @@ -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" diff --git a/package.json b/package.json index 612fd6f76..4d144e863 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,4 @@ - { +{ "name": "sdk-root", "private": true, "version": "0.0.0", @@ -15,7 +15,8 @@ "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", @@ -23,9 +24,19 @@ "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" }, + "optionalDependencies": { + "glob": "^11.0.0" + }, "devDependencies": { "prettier": "3.0.3", "wasm-pack": "^0.12.1" diff --git a/scripts/change-version.js b/scripts/change-version.js new file mode 100644 index 000000000..c808ae1f7 --- /dev/null +++ b/scripts/change-version.js @@ -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); diff --git a/sdk/package.json b/sdk/package.json index 006297cc4..373f1d070 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -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": { diff --git a/wasm/PUBLISH.md b/wasm/PUBLISH.md deleted file mode 100644 index c585a1b5e..000000000 --- a/wasm/PUBLISH.md +++ /dev/null @@ -1,10 +0,0 @@ -# Aleo Wasm - -## Publish instructions - -```bash -npm login -npm run build -npm version patch -npm publish --access=public -``` \ No newline at end of file diff --git a/wasm/package.json b/wasm/package.json index b97c841d6..2196f7e79 100644 --- a/wasm/package.json +++ b/wasm/package.json @@ -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": { diff --git a/yarn.lock b/yarn.lock index f03ebda30..85a027c7f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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" @@ -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" @@ -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" + path-to-regexp@0.1.10: version "0.1.10" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.10.tgz#67e9108c5c0551b9e5326064387de4763c4d5f8b"