@alcalzone/release-script-plugin-package
Advanced tools
Comparing version 3.7.0 to 3.7.3
@@ -38,2 +38,10 @@ "use strict"; | ||
} | ||
async function getYarnVersion(context) { | ||
const { stdout: output } = await context.sys.exec("yarn", ["--version"], { cwd: context.cwd }); | ||
const version = output.trim(); | ||
if (!semver_1.default.valid(version)) { | ||
context.cli.fatal(`Invalid yarn version "${version}"`); | ||
} | ||
return version; | ||
} | ||
class PackagePlugin { | ||
@@ -91,2 +99,3 @@ constructor() { | ||
if (await fs_extra_1.default.pathExists(yarnRcPath)) { | ||
const yarnVersion = await getYarnVersion(context); | ||
const yarnRc = await fs_extra_1.default.readFile(yarnRcPath, "utf8"); | ||
@@ -104,6 +113,11 @@ const yarnPlugins = yarnRc | ||
const requiredPlugins = { | ||
"workspace-tools": "workspace-tools", | ||
version: "version", | ||
changed: "https://github.com/Dcard/yarn-plugins/releases/latest/download/plugin-changed.js", | ||
}; | ||
if (semver_1.default.lt(yarnVersion, "4.0.0")) { | ||
// Yarn v4 includes these plugins by default | ||
Object.assign(requiredPlugins, { | ||
"workspace-tools": "workspace-tools", | ||
version: "version", | ||
}); | ||
} | ||
const missingPlugins = Object.keys(requiredPlugins).filter((plugin) => !yarnPlugins.includes(plugin)); | ||
@@ -119,2 +133,3 @@ // context.cli.log(`Installed yarn plugins: ${yarnPlugins.join(", ")}`); | ||
context.setData("monorepo", "yarn"); | ||
context.setData("yarn_version", yarnVersion); | ||
// One last check: make sure there is anything to publish | ||
@@ -216,5 +231,15 @@ // We cannot use getEffectivePublishAllFlag here without introducing a circular dependency | ||
await deleteStableVersions(); | ||
const yarnGte4 = context.hasData("yarn_version") && | ||
semver_1.default.gte(context.getData("yarn_version"), "4.0.0"); | ||
const commands = [ | ||
publishAll | ||
? ["yarn", "workspaces", "foreach", "version", newVersion, "--deferred"] | ||
? [ | ||
"yarn", | ||
"workspaces", | ||
"foreach", | ||
...(yarnGte4 ? ["--all"] : []), | ||
"version", | ||
newVersion, | ||
"--deferred", | ||
] | ||
: [ | ||
@@ -224,2 +249,3 @@ "yarn", | ||
"foreach", | ||
...(yarnGte4 ? ["--all"] : []), | ||
`--git-range=v${pack.version}`, | ||
@@ -226,0 +252,0 @@ "version", |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "3.7.0", | ||
"version": "3.7.3", | ||
"description": "Plugin for Al Calzone's release script: npm package files", | ||
@@ -9,0 +9,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29462
320