diff --git a/devEnv/deploy.mjs b/devEnv/deploy.mjs new file mode 100644 index 0000000..ea1bdb8 --- /dev/null +++ b/devEnv/deploy.mjs @@ -0,0 +1,84 @@ +import path from 'path' +import {writeFileSync} from 'fs' + +/** + * This script publishes all packages to npm. + * + * It assigns the same version number to all packages (like lerna's fixed mode). + **/ +// It's written in .mjs because I kept running into issues with zx+typescript +;(async function () { + // our packages will check for this env variable to make sure their + // prepublish script is only called from the `$ cd /path/to/monorepo; yarn run deploy` + process.env.THEATRE_IS_PUBLISHING = true + + await $`yarn run typecheck` + + syncVersionNumbers() + + return + + await Promise.all( + [ + 'theatre', + '@theatre/dataverse', + '@theatre/dataverse-react', + '@theatre/plugin-r3f', + ].map((workspace) => $`yarn workspace ${workspace} run build`), + ) + + await Promise.all( + [ + '@theatre/core', + '@theatre/studio', + '@theatre/dataverse', + '@theatre/dataverse-react', + '@theatre/plugin-r3f', + ].map( + (workspace) => $`yarn workspace ${workspace} npm publish --access public`, + ), + ) +})() + +function syncVersionNumbers() { + /** + * All these packages will have the same version from monorepo/package.json + */ + const workspaces = [ + 'theatre', + 'theatre/core', + 'theatre/studio', + 'packages/dataverse', + 'packages/dataverse-react', + 'packages/plugin-r3f', + ] + + const monorepoVersion = require('../package.json').version + + console.log( + `sync-versions: Setting versions of all packages to ${monorepoVersion}`, + ) + + for (const packagePathRelativeFromRoot of workspaces) { + const pathToPackage = path.resolve( + __dirname, + '../', + packagePathRelativeFromRoot, + './package.json', + ) + + const original = require(pathToPackage) + + if (original.version !== monorepoVersion) { + console.log(`Setting version of ${original.name} to ${monorepoVersion}`) + + const newJson = {...original} + newJson.version = monorepoVersion + writeFileSync( + path.join(pathToPackage), + JSON.stringify(newJson, undefined, 2), + ) + } + } + console.log('sync-versions: Done.') +} diff --git a/devEnv/ensurePublishing.js b/devEnv/ensurePublishing.js new file mode 100644 index 0000000..256da9f --- /dev/null +++ b/devEnv/ensurePublishing.js @@ -0,0 +1,5 @@ +if (process.env.THEATRE_IS_PUBLISHING !== 'true') { + throw Error( + `This script may run only when the "deploy" command in monorepo's root is running.`, + ) +} diff --git a/package.json b/package.json index 2f4df8f..6caa45b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "theatre-monorepo", "license": "Apache-2.0", + "version": "0.4.0-dev.4", "workspaces": [ "packages/*", "theatre" @@ -9,6 +10,7 @@ "typecheck": "tsc --build ./devEnv/typecheck-all-projects/tsconfig.all.json", "test": "jest", "postinstall": "husky install", + "deploy": "zx devEnv/deploy.mjs", "lint:all": "eslint . --ext ts,tsx --ignore-path=.gitignore --rulesdir ./devEnv/eslint/rules" }, "lint-staged": { @@ -38,7 +40,8 @@ "lerna": "^4.0.0", "lint-staged": "^11.0.0", "prettier": "^2.3.1", - "typescript": "^4.3.2" + "typescript": "^4.3.2", + "zx": "^2.0.0" }, "dependencies": { "node-gyp": "^8.1.0" diff --git a/packages/dataverse-react/package.json b/packages/dataverse-react/package.json index 8b293d1..07539b9 100644 --- a/packages/dataverse-react/package.json +++ b/packages/dataverse-react/package.json @@ -1,6 +1,6 @@ { "name": "@theatre/dataverse-react", - "version": "1.0.0-dev.2", + "version": "0.4.0-dev.4", "license": "Apache-2.0", "author": { "name": "Aria Minaei", @@ -31,7 +31,8 @@ "typecheck": "yarn run build", "build": "run-s build:ts build:js", "build:ts": "tsc --build ./tsconfig.json", - "build:js": "node -r esbuild-register ./devEnv/build.ts" + "build:js": "node -r esbuild-register ./devEnv/build.ts", + "prepublish": "node ../../devEnv/ensurePublishing.js" }, "devDependencies": { "@types/jest": "^26.0.23", diff --git a/packages/dataverse/package.json b/packages/dataverse/package.json index 21388e9..7cb4cdb 100644 --- a/packages/dataverse/package.json +++ b/packages/dataverse/package.json @@ -1,6 +1,6 @@ { "name": "@theatre/dataverse", - "version": "1.0.0-dev.2", + "version": "0.4.0-dev.4", "license": "Apache-2.0", "author": { "name": "Aria Minaei", @@ -31,7 +31,8 @@ "typecheck": "yarn run build", "build": "run-s build:ts build:js", "build:ts": "tsc --build ./tsconfig.json", - "build:js": "node -r esbuild-register ./devEnv/build.ts" + "build:js": "node -r esbuild-register ./devEnv/build.ts", + "prepublish": "node ../../devEnv/ensurePublishing.js" }, "devDependencies": { "@types/jest": "^26.0.23", diff --git a/packages/plugin-r3f/package.json b/packages/plugin-r3f/package.json index 0f62e2d..9220acf 100644 --- a/packages/plugin-r3f/package.json +++ b/packages/plugin-r3f/package.json @@ -1,6 +1,6 @@ { "name": "@theatre/plugin-r3f", - "version": "1.0.0-dev.1", + "version": "0.4.0-dev.4", "license": "Apache-2.0", "authors": [ { @@ -27,7 +27,8 @@ "scripts": { "prepack": "yarn run build", "typecheck": "yarn run build", - "build": "tsc --build ./tsconfig.json" + "build": "tsc --build ./tsconfig.json", + "prepublish": "node ../../devEnv/ensurePublishing.js" }, "devDependencies": { "@types/jest": "^26.0.23", diff --git a/theatre/core/package.json b/theatre/core/package.json index 3e8f08e..7d82565 100644 --- a/theatre/core/package.json +++ b/theatre/core/package.json @@ -1,6 +1,6 @@ { "name": "@theatre/core", - "version": "0.4.0-dev.3", + "version": "0.4.0-dev.4", "license": "Apache-2.0", "description": "Motion design editor for the web", "repository": { @@ -36,7 +36,7 @@ "dist/index.d.ts" ], "scripts": { - "prepublish": "cd .. && yarn run ensure-publishing" + "prepublish": "node ../../devEnv/ensurePublishing.js" }, "sideEffects": true, "dependencies": { diff --git a/theatre/devEnv/ensurePublishing.js b/theatre/devEnv/ensurePublishing.js deleted file mode 100644 index 55983cf..0000000 --- a/theatre/devEnv/ensurePublishing.js +++ /dev/null @@ -1,5 +0,0 @@ -if (process.env.THEATRE_IS_PUBLISHING !== 'true') { - throw Error( - `This script may run only when the "deploy" command in root/theatre is running.`, - ) -} diff --git a/theatre/package.json b/theatre/package.json index aada9e9..fdbf1d9 100644 --- a/theatre/package.json +++ b/theatre/package.json @@ -1,7 +1,7 @@ { "name": "theatre", "private": true, - "version": "0.4.0-dev.3", + "version": "0.4.0-dev.4", "workspaces": [ "./shared", "./core", @@ -13,13 +13,7 @@ "build:js:watch": "node -r esbuild-register devEnv/watch.ts", "build:dts": "run-s typecheck build:dts:bundle", "build:dts:bundle": "rollup -c devEnv/declarations-bundler/rollup.config.js", - "build": "run-p build:dts build:js", - "deploy": "cross-env-shell THEATRE_IS_PUBLISHING=true \"yarn run _deploy:steps\"", - "_deploy:steps": "run-s ensure-publishing update-versions build _deploy:core _deploy:studio", - "_deploy:core": "yarn workspace @theatre/core npm publish --access public", - "_deploy:studio": "yarn workspace @theatre/studio npm publish --access public", - "ensure-publishing": "node ./devEnv/ensurePublishing.js", - "update-versions": "node -r esbuild-register devEnv/updateVersions.ts" + "build": "run-p build:dts build:js" }, "devDependencies": { "@babel/cli": "^7.14.3", diff --git a/theatre/studio/package.json b/theatre/studio/package.json index 41b947c..4c49883 100644 --- a/theatre/studio/package.json +++ b/theatre/studio/package.json @@ -1,6 +1,6 @@ { "name": "@theatre/studio", - "version": "0.4.0-dev.3", + "version": "0.4.0-dev.4", "license": "AGPL-3.0-only", "description": "Motion design editor for the web", "repository": { @@ -36,7 +36,7 @@ "dist/index.d.ts" ], "scripts": { - "prepublish": "cd .. && yarn run ensure-publishing" + "prepublish": "node ../../devEnv/ensurePublishing.js" }, "sideEffects": true, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index b5f7a76..f35a5e5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3957,6 +3957,23 @@ __metadata: languageName: node linkType: hard +"@types/minimist@npm:^1.2.1": + version: 1.2.2 + resolution: "@types/minimist@npm:1.2.2" + checksum: 8dd59cefa7be641b961ccfe65f6ff16aaa6735412f47d5c993543d4e92590465a0d728abc0dad36e4957d105a44357379adadbca4baaa2926427d4eb66d74d0d + languageName: node + linkType: hard + +"@types/node-fetch@npm:^2.5.10": + version: 2.5.12 + resolution: "@types/node-fetch@npm:2.5.12" + dependencies: + "@types/node": "*" + form-data: ^3.0.0 + checksum: f648728116a24b9b5abc117e08788ed859283548ed65d374dba333d4604a7e8d22934cb4dbe7d64498c5c7f04885d84a2dc11c9a4115d426c242e74fb2f2a6a6 + languageName: node + linkType: hard + "@types/node@npm:*": version: 14.14.37 resolution: "@types/node@npm:14.14.37" @@ -3978,6 +3995,13 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^16.0": + version: 16.4.12 + resolution: "@types/node@npm:16.4.12" + checksum: 4bac961fa0bfe72c4303ca7574c8a824d159f0e01c19671be649d97e54f26959f7545ed9693a18a5d19839c8c3b85019e41c6614ee11a1e59d7265ffa26050fc + languageName: node + linkType: hard + "@types/normalize-package-data@npm:^2.4.0": version: 2.4.0 resolution: "@types/normalize-package-data@npm:2.4.0" @@ -16377,6 +16401,7 @@ fsevents@^1.2.7: node-gyp: ^8.1.0 prettier: ^2.3.1 typescript: ^4.3.2 + zx: ^2.0.0 languageName: unknown linkType: soft @@ -17776,3 +17801,22 @@ fsevents@^1.2.7: checksum: fdd1e6caaecbb0c3b7e869064752ace7113a16eabca56ab2f8cae6b1a0588ead08662289b7b7dde6a550d9ddf30881af370292406ca0b37d6d5d78a93e7db2b2 languageName: node linkType: hard + +"zx@npm:^2.0.0": + version: 2.0.0 + resolution: "zx@npm:2.0.0" + dependencies: + "@types/fs-extra": ^9.0.11 + "@types/minimist": ^1.2.1 + "@types/node": ^16.0 + "@types/node-fetch": ^2.5.10 + chalk: ^4.1.1 + fs-extra: ^10.0.0 + minimist: ^1.2.5 + node-fetch: ^2.6.1 + which: ^2.0.2 + bin: + zx: zx.mjs + checksum: 5859c0c4326350f52fbb750fdd35264ed4983158fa06e6628103314ec6424d8536f9ec9fbf2fda981bb7187781af7c068998e9daf7cd5fa1440a1fe56a568c1a + languageName: node + linkType: hard