-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
192 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {Cli} from "./Cli.js"; | ||
|
||
class NxCli extends Cli { | ||
constructor() { | ||
super("nx"); | ||
} | ||
|
||
run(cmd, ...args) { | ||
return super.run(cmd, ...args); | ||
} | ||
|
||
runMany(cmd, ...args) { | ||
return super.run("run-many", `--target=${cmd}`, "--all", ...args); | ||
} | ||
|
||
install(...args) { | ||
return super.run("install", ...args); | ||
} | ||
} | ||
|
||
export const nx = new NxCli(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {Cli} from "./Cli.js"; | ||
import {bumpPackagesVersion} from "../packages/bumpPackagesVersion.js"; | ||
|
||
class YarnBerryCli extends Cli { | ||
constructor() { | ||
super("yarn"); | ||
} | ||
|
||
newVersion(version, context) { | ||
return bumpPackagesVersion(version, context); | ||
} | ||
|
||
version(...args) { | ||
return this.sync("version", ...args); | ||
} | ||
|
||
run(...args) { | ||
return super.run(...args); | ||
} | ||
|
||
install(...args) { | ||
return super.run(args.length ? "add" : "install", ...args); | ||
} | ||
|
||
/** | ||
* Reinstall dependencies without yarn.lock mutation | ||
* @returns {Promise<unknown>} | ||
*/ | ||
restore() { | ||
return super.run("install", "--immutable"); | ||
} | ||
} | ||
|
||
export const yarnBerry = new YarnBerryCli(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/monorepo/src/utils/packages/bumpPackagesVersion.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import globby from "globby"; | ||
import fs from "fs-extra"; | ||
|
||
const PACKAGE_JSON_PROPS = ["dependencies", "devDependencies", "peerDependencies"]; | ||
|
||
/** | ||
* @param version {string} | ||
* @param context {MonoRepo} | ||
* @returns {Promise<void>} | ||
*/ | ||
export async function bumpPackagesVersion(version, context) { | ||
const {workspaces, cwd} = context; | ||
const patterns = workspaces.map((path) => `${path}/package.json`).concat("package.json"); | ||
|
||
const files = await globby(patterns, { | ||
cwd, | ||
absolute: true | ||
}); | ||
|
||
const names = new Set(); | ||
|
||
const packages = await Promise.all( | ||
files.map(async (file) => { | ||
const pkg = await fs.readJson(file); | ||
|
||
names.add(pkg.name); | ||
|
||
return {file, pkg}; | ||
}) | ||
); | ||
|
||
packages.map(({pkg, file}) => { | ||
pkg.version = version; | ||
|
||
PACKAGE_JSON_PROPS.forEach((key) => bumpDependencies(pkg, key, version, names)); | ||
|
||
return fs.writeJson(file, pkg); | ||
}); | ||
} | ||
|
||
function bumpDependencies(pkg, key, version, names) { | ||
pkg[key] = pkg[key] || {}; | ||
|
||
if (pkg[key]) { | ||
names.forEach((name) => { | ||
if (pkg[key][name] && !pkg[key][name].startsWith("workspace:")) { | ||
pkg[key][name] = version; | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters