turborepoã¨changesetã使ã£ã¦ãmonorepoã®ã©ã¤ãã©ãªéçºã«ãããæ§æãæ¤è¨ãã
æ¦è¦
monorepoãªã©ã¤ãã©ãªãnpmã«å ¬éããããã®æ§æã調æ»ãæ¤è¨ããã
æ¤è¨¼ãªãã¸ããª
以ä¸ã«ãã®è¨äºã§æ¤è¨¼ãããªãã¸ããªã示ãã
åä½ç°å¢
macOS Ventura ãã¼ã¸ã§ã³13.6.6 Node 21.4.0
åæã¨ãªãæ§æ
turborepo
turboã使ã£ã¦monorepoãæ§æãã
changeset
turborepoã«ããã¨ã@changesets/cli - npmãæ¨å¥¨ãã¦ããã
verdaccio
localã§åä½ããnpm registryã å®é¨ã§publishãã¾ããã®ã§å ¬å¼ã®registryã¯æµç³ã«ä½¿ãã«ããã
Verdaccioã®æ§ç¯
docker imageã使ãã®ããæ軽ãããªã®ã§ãåå¾ãã¦ç«ã¡ä¸ããã
以ä¸ã®ç¹ã«æ³¨æã * portã®æå®å¿ããã¨éããªã * volumeã®æå®ããªãã¨åèµ·åã§ãã¼ã¿ãæ¶ãã
$ docker pull verdaccio/verdaccio:nightly-master $ docker run -it -p4873:4873 --rm verdaccio/verdaccio:nightly-master (node:8) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created) info -=- local storage path /verdaccio/storage/data/.verdaccio-db.json info -=- no private database found, recreating new one on /verdaccio/storage/data/.verdaccio-db.json info --- using htpasswd file: /verdaccio/storage/htpasswd info --- http address http://0.0.0.0:4873/ info --- version: 7.0.0-next-7.13 info --- server started
æå®ããportããã©ã¦ã¶ã§éãã
open http://0.0.0.0:4873/
ã²ã¨ã¾ãåæç»é¢ã表示ãããã
æ¤è¨¼ç¨ã®ãªãã¸ããªãä½æ
ãã¡ãã«ä½æãã¾ãããä½æã®æå³ã¨ãã¦ã¯ - nodejs ã§åä½ããpackageãã¤ã¡ã¼ã¸ - turborepoã§æ§æ - è¤æ°ã®packageãæ§æ
changesetã®å°å ¥
packageã«ã¤ã³ã¹ãã¼ã«
$ npm -w packages/core i -D @changesets/cli $ npm -w packages/express i -D @changesets/cli
coreã¨expressã®package.jsonã«changeset
ã¹ã¯ãªããã追å
diff --git a/packages/core/package.json b/packages/core/package.json index f8facde..c7876fd 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -7,12 +7,14 @@ "scripts": { "build": "tsup src/*", "lint:eslint": "eslint --max-warnings 0 --ext .ts,.tsx .", - "lint:prettier": "prettier './src/**/*.{ts,tsx,js,json,css}' --check" + "lint:prettier": "prettier './src/**/*.{ts,tsx,js,json,css}' --check", + "changeset": "changeset" diff --git a/packages/express/package.json b/packages/express/package.json index f8facde..c7876fd 100644 --- a/packages/express/package.json +++ b/packages/express/package.json @@ -7,12 +7,14 @@ "scripts": { "build": "tsup src/*", "lint:eslint": "eslint --max-warnings 0 --ext .ts,.tsx .", - "lint:prettier": "prettier './src/**/*.{ts,tsx,js,json,css}' --check" + "lint:prettier": "prettier './src/**/*.{ts,tsx,js,json,css}' --check", + "changeset": "changeset"
changesetã®åæå
$ npm -w packages/core run changeset init $ npm -w packages/express run changeset init
publishã®accessãpublicã«å¤æ´
diff --git a/packages/core/.changeset/config.json b/packages/core/.changeset/config.json index 91b6a95..fce1c26 100644 --- a/packages/core/.changeset/config.json +++ b/packages/core/.changeset/config.json @@ -4,7 +4,7 @@ "commit": false, "fixed": [], "linked": [], - "access": "restricted", + "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", "ignore": [] diff --git a/packages/core/package.json b/packages/core/package.json index 5f59f4d..1987880 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -14,5 +14,8 @@ "@changesets/cli": "^2.27.1", "@example-monorepo/dev-config": "*", "tsup": "^8.0.2" + }, + "publishConfig": { + "access": "public" } } diff --git a/packages/express/.changeset/config.json b/packages/express/.changeset/config.json index 91b6a95..fce1c26 100644 --- a/packages/express/.changeset/config.json +++ b/packages/express/.changeset/config.json @@ -4,7 +4,7 @@ "commit": false, "fixed": [], "linked": [], - "access": "restricted", + "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", "ignore": [] diff --git a/packages/express/package.json b/packages/express/package.json index c7876fd..586fd64 100644 --- a/packages/express/package.json +++ b/packages/express/package.json @@ -19,5 +19,8 @@ "@types/express": "^4.17.21", "express": "^4.19.2", "tsup": "^8.0.2" + }, + "publishConfig": { + "access": "public" } }
changesetã®è¨å®ãè¡ã
$ npm -w packages/core run changeset [branch:main](untracked)[~/project/example-monorepo] > @example-monorepo/core@0.0.0 changeset > changeset ð¦ Which packages would you like to include? · @example-monorepo/core, @example-monorepo/express ð¦ Which packages should have a major bump? · No items were selected ð¦ Which packages should have a minor bump? · No items were selected ð¦ The following packages will be patch bumped: ð¦ @example-monorepo/core@0.0.0 ð¦ @example-monorepo/express@0.0.0 ð¦ Please enter a summary for this change (this will be in the changelogs). ð¦ (submit empty line to open external editor) ð¦ Summary · the first update ð¦ ð¦ === Summary of changesets === ð¦ patch: @example-monorepo/core, @example-monorepo/express ð¦ ð¦ Note: All dependents of these packages that will be incompatible with ð¦ the new version will be patch bumped when this changeset is applied. ð¦ ð¦ Is this your desired changeset? (Y/n) · true ð¦ Changeset added! - you can now commit it ð¦ ð¦ If you want to modify or expand on the changeset summary, you can find it here
bump up
version, publishã¸ã®ã¨ã¤ãªã¢ã¹ãä½æããã
diff --git a/package.json b/package.json index 106fd31..3f6c163 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "build": "turbo run build", "lint:eslint": "turbo run lint:eslint", "lint:prettier": "turbo run lint:prettier", + "version": "turbo run version", + "publish": "turbo run publish", "format": "prettier --write \"**/*.{ts,tsx,md}\"" }, "devDependencies": { diff --git a/packages/core/package.json b/packages/core/package.json index 1987880..74c6f4a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -8,7 +8,9 @@ "build": "tsup src/*", "lint:eslint": "eslint --max-warnings 0 --ext .ts,.tsx .", "lint:prettier": "prettier './src/**/*.{ts,tsx,js,json,css}' --check", - "changeset": "changeset" + "changeset": "changeset", + "version": "changeset version", + "publish": "changeset publish" }, "devDependencies": { "@changesets/cli": "^2.27.1", diff --git a/packages/express/package.json b/packages/express/package.json index 586fd64..531b6b9 100644 --- a/packages/express/package.json +++ b/packages/express/package.json @@ -8,7 +8,9 @@ "build": "tsup src/*", "lint:eslint": "eslint --max-warnings 0 --ext .ts,.tsx .", "lint:prettier": "prettier './src/**/*.{ts,tsx,js,json,css}' --check", - "changeset": "changeset" + "changeset": "changeset", + "version": "changeset version", + "publish": "changeset publish" }, "dependencies": { "@example-monorepo/core": "*" diff --git a/turbo.json b/turbo.json index 8402ed6..c3df47b 100644 --- a/turbo.json +++ b/turbo.json @@ -18,6 +18,15 @@ "dev": { "cache": false, "persistent": true + }, + "version": { + "cache": false, + "persistent": true + }, + "publish": { + "cache": false, + "persistent": true } + } }
versionãä¸ãã
$ npm run version
commit 62802584c2bbc5be7fec65d73d33d2efc12b01c3 Author: mizuki_r <[email protected]> Date: Mon Apr 29 15:40:07 2024 +0900 bump 0.0.1 diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md new file mode 100644 index 0000000..726ce34 --- /dev/null +++ b/packages/core/CHANGELOG.md @@ -0,0 +1,7 @@ +# @example-monorepo/core + +## 0.0.1 + +### Patch Changes + +- the first update diff --git a/packages/core/package.json b/packages/core/package.json index 74c6f4a..8b1b54c 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@example-monorepo/core", - "version": "0.0.0", + "version": "0.0.1", "private": true, "main": "build/index.js", "types": "src/index.ts", diff --git a/packages/express/CHANGELOG.md b/packages/express/CHANGELOG.md new file mode 100644 index 0000000..07d956c --- /dev/null +++ b/packages/express/CHANGELOG.md @@ -0,0 +1,9 @@ +# @example-monorepo/express + +## 0.0.1 + +### Patch Changes + +- the first update +- Updated dependencies + - @example-monorepo/[email protected] diff --git a/packages/express/package.json b/packages/express/package.json index 531b6b9..1d38dc0 100644 --- a/packages/express/package.json +++ b/packages/express/package.json @@ -1,6 +1,6 @@ { "name": "@example-monorepo/express", - "version": "0.0.0", + "version": "0.0.1", "private": true, "main": "build/index.js", "types": "src/index.ts",
verdaccioã¨ã®æ¥ç¶
verdaccioã®URLãnpmrcã«ç»é²
diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..30fb789 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=http://0.0.0.0:4873
adduserãã¦verdaccioã«ã¦ã¼ã¶ãç»é²
$ npm adduser npm notice Log in on http://0.0.0.0:4873/ Username: mizuki_r Email: (this IS public) [email protected] Logged in on http://0.0.0.0:4873/.
ãããpublishãã¨ããã£ãã®ã«....
$ npm run publish > example-monorepo@0.0.0 publish > turbo run publish ⢠Packages in scope: @example-monorepo/core, @example-monorepo/dev-config, @example-monorepo/express ⢠Running publish in 3 packages ⢠Remote caching disabled @example-monorepo/core:publish: cache bypass, force executing 6d170e85bb8ec0a1 @example-monorepo/express:publish: cache bypass, force executing 97213dc3ac891ae0 @example-monorepo/express:publish: @example-monorepo/express:publish: > @example-monorepo/express@0.0.1 publish @example-monorepo/express:publish: > changeset publish @example-monorepo/express:publish: @example-monorepo/core:publish: @example-monorepo/core:publish: > @example-monorepo/core@0.0.1 publish @example-monorepo/core:publish: > changeset publish @example-monorepo/core:publish: @example-monorepo/express:publish: ð¦ warn No unpublished projects to publish @example-monorepo/core:publish: ð¦ warn No unpublished projects to publish Tasks: 2 successful, 2 total Cached: 0 cached, 2 total Time: 701ms
packageãprivate: trueã ã£ãããã§ãã
diff --git a/packages/core/package.json b/packages/core/package.json index 8b1b54c..cc96e00 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@example-monorepo/core", "version": "0.0.1", - "private": true, + "private": false, "main": "build/index.js", "types": "src/index.ts", "scripts": { diff --git a/packages/express/package.json b/packages/express/package.json index 1d38dc0..df29381 100644 --- a/packages/express/package.json +++ b/packages/express/package.json @@ -1,7 +1,7 @@ { "name": "@example-monorepo/express", "version": "0.0.1", - "private": true, + "private": false, "main": "build/index.js", "types": "src/index.ts", "scripts": {
ä»åº¦ããpublish
$ npm run publish > example-monorepo@0.0.0 publish > turbo run publish ⢠Packages in scope: @example-monorepo/core, @example-monorepo/dev-config, @example-monorepo/express ⢠Running publish in 3 packages ⢠Remote caching disabled @example-monorepo/express:publish: cache bypass, force executing 95f6040856482a97 @example-monorepo/core:publish: cache bypass, force executing 304ea4a437f8c0b8 @example-monorepo/express:publish: @example-monorepo/express:publish: > @example-monorepo/express@0.0.1 publish @example-monorepo/express:publish: > changeset publish @example-monorepo/express:publish: @example-monorepo/core:publish: @example-monorepo/core:publish: > @example-monorepo/core@0.0.1 publish @example-monorepo/core:publish: > changeset publish @example-monorepo/core:publish: @example-monorepo/express:publish: ð¦ info npm info @example-monorepo/core @example-monorepo/core:publish: ð¦ info npm info @example-monorepo/core @example-monorepo/core:publish: ð¦ info npm info @example-monorepo/express @example-monorepo/express:publish: ð¦ info npm info @example-monorepo/express @example-monorepo/core:publish: ð¦ warn Received 404 for npm info "@example-monorepo/core" @example-monorepo/express:publish: ð¦ warn Received 404 for npm info "@example-monorepo/express" @example-monorepo/express:publish: ð¦ warn Received 404 for npm info "@example-monorepo/core" @example-monorepo/express:publish: ð¦ info @example-monorepo/core is being published because our local version (0.0.1) has not been published on npm @example-monorepo/express:publish: ð¦ info @example-monorepo/express is being published because our local version (0.0.1) has not been published on npm @example-monorepo/express:publish: ð¦ info Publishing "@example-monorepo/core" at "0.0.1" @example-monorepo/express:publish: ð¦ info Publishing "@example-monorepo/express" at "0.0.1" @example-monorepo/core:publish: ð¦ warn Received 404 for npm info "@example-monorepo/express" @example-monorepo/core:publish: ð¦ info @example-monorepo/core is being published because our local version (0.0.1) has not been published on npm @example-monorepo/core:publish: ð¦ info @example-monorepo/express is being published because our local version (0.0.1) has not been published on npm @example-monorepo/core:publish: ð¦ info Publishing "@example-monorepo/core" at "0.0.1" @example-monorepo/core:publish: ð¦ info Publishing "@example-monorepo/express" at "0.0.1" @example-monorepo/core:publish: ð¦ error an error occurred while publishing @example-monorepo/express: E409 409 Conflict - PUT http://0.0.0.0:4873/@example-monorepo%2fcore - this package is already present @example-monorepo/express:publish: ð¦ error an error occurred while publishing @example-monorepo/express: E409 409 Conflict - PUT http://0.0.0.0:4873/@example-monorepo%2fexpress - this package is already present @example-monorepo/core:publish: ð¦ error npm notice Publishing to http://0.0.0.0:4873 with tag latest and public access @example-monorepo/core:publish: ð¦ error npm ERR! code E409 @example-monorepo/core:publish: ð¦ error npm ERR! 409 Conflict - PUT http://0.0.0.0:4873/@example-monorepo%2fcore - this package is already present @example-monorepo/core:publish: ð¦ error @example-monorepo/core:publish: ð¦ error @example-monorepo/express:publish: ð¦ error npm notice Publishing to http://0.0.0.0:4873 with tag latest and public access @example-monorepo/express:publish: ð¦ error npm ERR! code E409 @example-monorepo/express:publish: ð¦ error npm ERR! 409 Conflict - PUT http://0.0.0.0:4873/@example-monorepo%2fexpress - this package is already present @example-monorepo/express:publish: ð¦ error @example-monorepo/express:publish: ð¦ error @example-monorepo/express:publish: ð¦ success packages published successfully: @example-monorepo/core:publish: ð¦ success packages published successfully: @example-monorepo/express:publish: ð¦ @example-monorepo/core@0.0.1 @example-monorepo/express:publish: ð¦ Creating git tag... @example-monorepo/core:publish: ð¦ @example-monorepo/core@0.0.1 @example-monorepo/core:publish: ð¦ Creating git tag... @example-monorepo/express:publish: ð¦ New tag: @example-monorepo/core@0.0.1 @example-monorepo/core:publish: ð¦ New tag: @example-monorepo/core@0.0.1 @example-monorepo/core:publish: ð¦ error packages failed to publish: @example-monorepo/core:publish: ð¦ @example-monorepo/express@0.0.1 @example-monorepo/express:publish: ð¦ error packages failed to publish: @example-monorepo/express:publish: ð¦ @example-monorepo/express@0.0.1
ãã¼ãåå¥ã«publishããã¨ã ããªã®ãã ä¸å¿publishã§ãã¦ãããã©ãå¤årootã«å ¥ããã°åãã£ã½ã
rootã«changesetãè¨å®ãã
$ npm install -D @changesets/cli $ npm run changeset init $ npm run changeset $ npm run changeset version $ npm run changeset publish > [email protected] publish > changeset publish ð¦ info npm info @example-monorepo/core ð¦ info npm info @example-monorepo/express ð¦ info @example-monorepo/core is being published because our local version (0.0.2) has not been published on npm ð¦ info @example-monorepo/express is being published because our local version (0.0.2) has not been published on npm ð¦ info Publishing "@example-monorepo/core" at "0.0.2" ð¦ info Publishing "@example-monorepo/express" at "0.0.2" ð¦ success packages published successfully: ð¦ @example-monorepo/[email protected] ð¦ @example-monorepo/[email protected] ð¦ Creating git tags... ð¦ New tag: @example-monorepo/[email protected] ð¦ New tag: @example-monorepo/[email protected]
ã¾ã¨ã
- turborepo x changesetsã§è¯ããã
- changesetsã¯rootã«ç½®ã
- å¿ è¦ãªããã±ã¼ã¸ãé¸æå¼ã§publishã§ãã
- å¤æ´ãstackãã¦ã¾ã¨ãã¦bumpã§ãã
- publishãä¸æ¬ã§ãã£ã¦ããã
- ããã±ã¼ã¸ä½æå®é¨ã«verdaccioã¯ä¾¿å©