Use a yarn plugin to manage releases (#12138)
This commit is contained in:
parent
91a7a64b4b
commit
02975b9ae1
@ -1,31 +0,0 @@
|
|||||||
diff --git a/npm-publish.js b/npm-publish.js
|
|
||||||
index ee6ad133e..6a31d1775 100644
|
|
||||||
--- a/npm-publish.js
|
|
||||||
+++ b/npm-publish.js
|
|
||||||
@@ -32,6 +32,15 @@ const PublishConfig = figgyPudding(
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
+function stripWorkspaceProtocolFromDeps(deps) {
|
|
||||||
+ if (!deps) return;
|
|
||||||
+ for (const [name, version] of Object.entries(deps)) {
|
|
||||||
+ if (version.startsWith("workspace:")) {
|
|
||||||
+ deps[name] = version.slice(10);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
function npmPublish(pkg, tarFilePath, _opts, otpCache) {
|
|
||||||
const { scope } = npa(pkg.name);
|
|
||||||
// pass only the package scope to libnpmpublish
|
|
||||||
@@ -67,6 +76,10 @@ function npmPublish(pkg, tarFilePath, _opts, otpCache) {
|
|
||||||
manifest.publishConfig.tag = opts.tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ stripWorkspaceProtocolFromDeps(manifest.dependencies);
|
|
||||||
+ stripWorkspaceProtocolFromDeps(manifest.peerDependencies);
|
|
||||||
+ stripWorkspaceProtocolFromDeps(manifest.devDependencies);
|
|
||||||
+
|
|
||||||
return otplease(innerOpts => publish(manifest, tarData, innerOpts), opts, otpCache).catch(err => {
|
|
||||||
opts.log.silly("", err);
|
|
||||||
opts.log.error(err.code, (err.body && err.body.error) || err.message);
|
|
||||||
@ -1,92 +0,0 @@
|
|||||||
diff --git a/lib/pack-directory.js b/lib/pack-directory.js
|
|
||||||
index d46069c78..2ba6bfea1 100644
|
|
||||||
--- a/lib/pack-directory.js
|
|
||||||
+++ b/lib/pack-directory.js
|
|
||||||
@@ -2,13 +2,13 @@
|
|
||||||
|
|
||||||
const path = require("path");
|
|
||||||
const figgyPudding = require("figgy-pudding");
|
|
||||||
-const packlist = require("npm-packlist");
|
|
||||||
const log = require("npmlog");
|
|
||||||
-const tar = require("tar");
|
|
||||||
const tempWrite = require("temp-write");
|
|
||||||
const getPacked = require("@lerna/get-packed");
|
|
||||||
const Package = require("@lerna/package");
|
|
||||||
const runLifecycle = require("@lerna/run-lifecycle");
|
|
||||||
+const util = require("util");
|
|
||||||
+const exec = util.promisify(require('child_process').exec);
|
|
||||||
|
|
||||||
module.exports = packDirectory;
|
|
||||||
|
|
||||||
@@ -40,34 +40,23 @@ function packDirectory(_pkg, dir, _opts) {
|
|
||||||
chain = chain.then(() => pkg.refresh());
|
|
||||||
}
|
|
||||||
|
|
||||||
- chain = chain.then(() => runLifecycle(pkg, "prepack", opts));
|
|
||||||
- chain = chain.then(() => pkg.refresh());
|
|
||||||
- chain = chain.then(() => packlist({ path: pkg.contents }));
|
|
||||||
- chain = chain.then(files =>
|
|
||||||
- tar.create(
|
|
||||||
- {
|
|
||||||
- cwd: pkg.contents,
|
|
||||||
- prefix: "package/",
|
|
||||||
- portable: true,
|
|
||||||
- // Provide a specific date in the 1980s for the benefit of zip,
|
|
||||||
- // which is confounded by files dated at the Unix epoch 0.
|
|
||||||
- mtime: new Date("1985-10-26T08:15:00.000Z"),
|
|
||||||
- gzip: true,
|
|
||||||
- },
|
|
||||||
- // NOTE: node-tar does some Magic Stuff depending on prefixes for files
|
|
||||||
- // specifically with @ signs, so we just neutralize that one
|
|
||||||
- // and any such future "features" by prepending `./`
|
|
||||||
- files.map(f => `./${f}`)
|
|
||||||
- )
|
|
||||||
+ // We need to call "yarn pack" to remove the "workspace:" protocol from
|
|
||||||
+ // package.json before publishing
|
|
||||||
+ chain = chain.then(() => tempWrite("", getTarballName(pkg)));
|
|
||||||
+ chain = chain.then(tarFilePath =>
|
|
||||||
+ exec("yarn pack --out " + tarFilePath, { cwd: pkg.location })
|
|
||||||
+ .then(({ stdout, stderr }) => {
|
|
||||||
+ const err = stderr.toString();
|
|
||||||
+ if (err) console.log(err);
|
|
||||||
+ })
|
|
||||||
+ .then(() => tarFilePath)
|
|
||||||
);
|
|
||||||
- chain = chain.then(stream => tempWrite(stream, getTarballName(pkg)));
|
|
||||||
chain = chain.then(tarFilePath =>
|
|
||||||
- getPacked(pkg, tarFilePath).then(packed =>
|
|
||||||
- Promise.resolve()
|
|
||||||
- .then(() => runLifecycle(pkg, "postpack", opts))
|
|
||||||
- .then(() => packed)
|
|
||||||
- )
|
|
||||||
+ Promise.resolve()
|
|
||||||
+ .then(() => pkg.refresh())
|
|
||||||
+ .then(() => tarFilePath)
|
|
||||||
);
|
|
||||||
+ chain = chain.then(tarFilePath => getPacked(pkg, tarFilePath));
|
|
||||||
|
|
||||||
return chain;
|
|
||||||
}
|
|
||||||
@@ -81,3 +70,7 @@ function getTarballName(pkg) {
|
|
||||||
|
|
||||||
return `${name}-${pkg.version}.tgz`;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+function tap(fn) {
|
|
||||||
+ return arg => Promise.resolve(fn(arg)).then(() => arg);
|
|
||||||
+}
|
|
||||||
\ No newline at end of file
|
|
||||||
diff --git a/package.json b/package.json
|
|
||||||
index e00ac73ff..953512b2c 100644
|
|
||||||
--- a/package.json
|
|
||||||
+++ b/package.json
|
|
||||||
@@ -31,9 +31,7 @@
|
|
||||||
"@lerna/package": "3.16.0",
|
|
||||||
"@lerna/run-lifecycle": "3.16.2",
|
|
||||||
"figgy-pudding": "^3.5.1",
|
|
||||||
- "npm-packlist": "^1.4.4",
|
|
||||||
"npmlog": "^4.1.2",
|
|
||||||
- "tar": "^4.4.10",
|
|
||||||
"temp-write": "^3.4.0"
|
|
||||||
},
|
|
||||||
"gitHead": "bb048cb306b5cfcb039aa98f667cf3751cf0ad20"
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
diff --git a/index.js b/index.js
|
|
||||||
index f860af4d2..27c4ce21d 100644
|
|
||||||
--- a/index.js
|
|
||||||
+++ b/index.js
|
|
||||||
@@ -57,8 +57,18 @@ class PackageGraph extends Map {
|
|
||||||
// Yarn decided to ignore https://github.com/npm/npm/pull/15900 and implemented "link:"
|
|
||||||
// As they apparently have no intention of being compatible, we have to do it for them.
|
|
||||||
// @see https://github.com/yarnpkg/yarn/issues/4212
|
|
||||||
- const spec = graphDependencies[depName].replace(/^link:/, "file:");
|
|
||||||
+ let spec = graphDependencies[depName].replace(/^link:/, "file:");
|
|
||||||
+
|
|
||||||
+ // npa doesn't support the explicit workspace: protocol, supported by
|
|
||||||
+ // pnpm and Yarn.
|
|
||||||
+ // https://github.com/lerna/lerna/pull/2450
|
|
||||||
+ const explicitWorkspace = /^workspace:/.test(spec);
|
|
||||||
+ if (explicitWorkspace) {
|
|
||||||
+ spec = spec.replace(/^workspace:/, "");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
const resolved = npa.resolve(depName, spec, currentNode.location);
|
|
||||||
+ resolved.explicitWorkspace = explicitWorkspace;
|
|
||||||
|
|
||||||
if (!depNode) {
|
|
||||||
// it's an external dependency, store the resolution and bail
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
diff --git a/index.js b/index.js
|
|
||||||
index 67b997073..6e2912e9e 100644
|
|
||||||
--- a/index.js
|
|
||||||
+++ b/index.js
|
|
||||||
@@ -209,6 +209,11 @@ class Package {
|
|
||||||
if (resolved.registry || resolved.type === "directory") {
|
|
||||||
// a version (1.2.3) OR range (^1.2.3) OR directory (file:../foo-pkg)
|
|
||||||
depCollection[depName] = `${savePrefix}${depVersion}`;
|
|
||||||
+
|
|
||||||
+ // https://github.com/lerna/lerna/pull/2450
|
|
||||||
+ if (resolved.explicitWorkspace) {
|
|
||||||
+ depCollection[depName] = `workspace:${depCollection[depName]}`;
|
|
||||||
+ }
|
|
||||||
} else if (resolved.gitCommittish) {
|
|
||||||
// a git url with matching committish (#v1.2.3 or #1.2.3)
|
|
||||||
const [tagPrefix] = /^\D*/.exec(resolved.gitCommittish);
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
diff --git a/command.js b/command.js
|
|
||||||
index 4109ff1db..86349e057 100644
|
|
||||||
--- a/command.js
|
|
||||||
+++ b/command.js
|
|
||||||
@@ -12,6 +12,12 @@ exports.describe = "Bump version of packages changed since the last release.";
|
|
||||||
|
|
||||||
exports.builder = (yargs, composed) => {
|
|
||||||
const opts = {
|
|
||||||
+ // THIS IS ONLY USED BY BABEL
|
|
||||||
+ "exclude-dependents": {
|
|
||||||
+ describe: "Exclude all transitive dependents.",
|
|
||||||
+ type: "boolean"
|
|
||||||
+ },
|
|
||||||
+
|
|
||||||
"allow-branch": {
|
|
||||||
describe: "Specify which branches to allow versioning from.",
|
|
||||||
type: "array",
|
|
||||||
31
.yarn/plugins/@yarnpkg/plugin-babel-release-tool.cjs
vendored
Normal file
31
.yarn/plugins/@yarnpkg/plugin-babel-release-tool.cjs
vendored
Normal file
File diff suppressed because one or more lines are too long
13
.yarnrc.yml
13
.yarnrc.yml
@ -4,6 +4,19 @@ enableTransparentWorkspaces: false
|
|||||||
|
|
||||||
nodeLinker: node-modules
|
nodeLinker: node-modules
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
- path: .yarn/plugins/@yarnpkg/plugin-babel-release-tool.cjs
|
||||||
|
spec: "https://raw.githubusercontent.com/nicolo-ribaudo/yarn-plugin-babel-release-tool/main/bundles/%40yarnpkg/plugin-babel-release-tool.js"
|
||||||
|
|
||||||
|
releaseTool:
|
||||||
|
ignoreChanges:
|
||||||
|
- "*.md"
|
||||||
|
- "*.txt"
|
||||||
|
- test/**
|
||||||
|
- "**/test/**"
|
||||||
|
- codemods/**
|
||||||
|
- "@(!(native-modules|built-ins|plugins|package)).json"
|
||||||
|
|
||||||
unsafeHttpWhitelist:
|
unsafeHttpWhitelist:
|
||||||
- localhost
|
- localhost
|
||||||
|
|
||||||
|
|||||||
13
Makefile
13
Makefile
@ -2,7 +2,7 @@ FLOW_COMMIT = a1f9a4c709dcebb27a5084acf47755fbae699c25
|
|||||||
TEST262_COMMIT = 058adfed86b1d4129996faaf50a85ea55379a66a
|
TEST262_COMMIT = 058adfed86b1d4129996faaf50a85ea55379a66a
|
||||||
TYPESCRIPT_COMMIT = da8633212023517630de5f3620a23736b63234b1
|
TYPESCRIPT_COMMIT = da8633212023517630de5f3620a23736b63234b1
|
||||||
|
|
||||||
FORCE_PUBLISH = "@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone"
|
FORCE_PUBLISH = -f @babel/runtime -f @babel/runtime-corejs2 -f @babel/runtime-corejs3 -f @babel/standalone
|
||||||
|
|
||||||
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
||||||
export FORCE_COLOR = true
|
export FORCE_COLOR = true
|
||||||
@ -218,7 +218,6 @@ prepublish:
|
|||||||
$(MAKE) prepublish-build
|
$(MAKE) prepublish-build
|
||||||
IS_PUBLISH=true $(MAKE) test
|
IS_PUBLISH=true $(MAKE) test
|
||||||
|
|
||||||
# --exclude-dependents support is added by .yarn-patches/@lerna/version
|
|
||||||
new-version:
|
new-version:
|
||||||
@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
@ -229,11 +228,11 @@ new-version:
|
|||||||
@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
@exit 1
|
@exit 1
|
||||||
git pull --rebase
|
git pull --rebase
|
||||||
$(YARN) lerna version --exclude-dependents --force-publish=$(FORCE_PUBLISH)
|
$(YARN) release-tool version $(FORCE_PUBLISH)
|
||||||
|
|
||||||
# NOTE: Run make new-version first
|
# NOTE: Run make new-version first
|
||||||
publish: prepublish
|
publish: prepublish
|
||||||
$(YARN) lerna publish from-git
|
$(YARN) release-tool publish
|
||||||
$(MAKE) clean
|
$(MAKE) clean
|
||||||
|
|
||||||
publish-ci: prepublish
|
publish-ci: prepublish
|
||||||
@ -243,7 +242,7 @@ else
|
|||||||
echo "Missing NPM_TOKEN env var"
|
echo "Missing NPM_TOKEN env var"
|
||||||
exit 1
|
exit 1
|
||||||
endif
|
endif
|
||||||
$(YARN) lerna publish from-git --yes
|
$(YARN) release-tool publish --yes
|
||||||
rm -f .npmrc
|
rm -f .npmrc
|
||||||
$(MAKE) clean
|
$(MAKE) clean
|
||||||
|
|
||||||
@ -252,9 +251,9 @@ ifneq ("$(I_AM_USING_VERDACCIO)", "I_AM_SURE")
|
|||||||
echo "You probably don't know what you are doing"
|
echo "You probably don't know what you are doing"
|
||||||
exit 1
|
exit 1
|
||||||
endif
|
endif
|
||||||
$(YARN) lerna version $(VERSION) --exclude-dependents --force-publish=$(FORCE_PUBLISH) --no-push --yes --tag-version-prefix="version-e2e-test-"
|
$(YARN) release-tool version $(VERSION) --all --yes --tag-version-prefix="version-e2e-test-"
|
||||||
$(MAKE) prepublish-build
|
$(MAKE) prepublish-build
|
||||||
$(YARN) lerna publish from-git --registry http://localhost:4873 --yes --tag-version-prefix="version-e2e-test-"
|
YARN_NPM_PUBLISH_REGISTRY=http://localhost:4873 $(YARN) release-tool publish --yes --tag-version-prefix="version-e2e-test-"
|
||||||
$(MAKE) clean
|
$(MAKE) clean
|
||||||
|
|
||||||
bootstrap-only: clean-all
|
bootstrap-only: clean-all
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Why is Babel a monorepo?
|
# Why is Babel a monorepo?
|
||||||
|
|
||||||
> The tool for managing the monorepo in Babel has been extracted out as [Lerna](https://github.com/lerna/lerna)
|
> Note: We don't use `lerna` to manage packages inside the monorepo, but yarn workspaces with an additional [custom plugin](https://github.com/nicolo-ribaudo/yarn-plugin-babel-release-tool).
|
||||||
|
|
||||||
Juggling a multimodule project over multiple repos is like trying to teach a newborn baby how to
|
Juggling a multimodule project over multiple repos is like trying to teach a newborn baby how to
|
||||||
ride a bike.
|
ride a bike.
|
||||||
|
|||||||
25
lerna.json
25
lerna.json
@ -14,28 +14,5 @@
|
|||||||
"PR: Performance :running_woman:": ":running_woman: Performance",
|
"PR: Performance :running_woman:": ":running_woman: Performance",
|
||||||
"PR: Revert :leftwards_arrow_with_hook:": ":leftwards_arrow_with_hook: Revert"
|
"PR: Revert :leftwards_arrow_with_hook:": ":leftwards_arrow_with_hook: Revert"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"command": {
|
|
||||||
"publish": {
|
|
||||||
"ignoreChanges": [
|
|
||||||
"*.md",
|
|
||||||
"*.txt",
|
|
||||||
"test/**",
|
|
||||||
"**/test/**",
|
|
||||||
"codemods/**",
|
|
||||||
"# We ignore every JSON file, except for native-modules, built-ins and plugins defined in babel-preset-env/data.",
|
|
||||||
"@(!(native-modules|built-ins|plugins|package)).json"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"version": {
|
|
||||||
"push": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"packages": [
|
|
||||||
"codemods/*",
|
|
||||||
"eslint/*",
|
|
||||||
"packages/*"
|
|
||||||
],
|
|
||||||
"npmClient": "yarn",
|
|
||||||
"useWorkspaces": true
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel",
|
"name": "babel",
|
||||||
|
"version": "7.11.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -53,7 +54,6 @@
|
|||||||
"gulp-plumber": "^1.2.1",
|
"gulp-plumber": "^1.2.1",
|
||||||
"husky": "^3.0.0",
|
"husky": "^3.0.0",
|
||||||
"jest": "^24.9.0",
|
"jest": "^24.9.0",
|
||||||
"lerna": "^3.19.0",
|
|
||||||
"lerna-changelog": "^0.5.0",
|
"lerna-changelog": "^0.5.0",
|
||||||
"lint-staged": "^9.2.0",
|
"lint-staged": "^9.2.0",
|
||||||
"mergeiterator": "^1.2.5",
|
"mergeiterator": "^1.2.5",
|
||||||
@ -74,11 +74,6 @@
|
|||||||
"test/esm"
|
"test/esm"
|
||||||
],
|
],
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@lerna/version": "patch:@lerna/version@npm:3.20.2#.yarn-patches/@lerna/version.patch",
|
|
||||||
"@lerna/npm-publish": "patch:@lerna/npm-publish@npm:3.18.5#.yarn-patches/@lerna/npm-publish.patch",
|
|
||||||
"@lerna/package": "patch:@lerna/package@npm:3.16.0#.yarn-patches/@lerna/package.patch",
|
|
||||||
"@lerna/package-graph": "patch:@lerna/package-graph@npm:3.18.5#.yarn-patches/@lerna/package-graph.patch",
|
|
||||||
"@lerna/pack-directory": "patch:@lerna/pack-directory@npm:3.16.4#.yarn-patches/@lerna/pack-directory.patch",
|
|
||||||
"browserslist": "npm:4.12.0",
|
"browserslist": "npm:4.12.0",
|
||||||
"caniuse-lite": "npm:1.0.30001077"
|
"caniuse-lite": "npm:1.0.30001077"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -10,7 +10,7 @@ export GIT_E2E_SETUP="true"
|
|||||||
function initializeE2Egit {
|
function initializeE2Egit {
|
||||||
git checkout -b $tmp_branch_name
|
git checkout -b $tmp_branch_name
|
||||||
|
|
||||||
# This is needed by lerna, which commits when publishing
|
# This is needed by "yarn release-tool", which commits when publishing
|
||||||
git config user.name "Babel E2E Test"
|
git config user.name "Babel E2E Test"
|
||||||
git config user.email "babel-e2e@example.com"
|
git config user.email "babel-e2e@example.com"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user