Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: yarn 4 #261

Merged
merged 3 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
541 changes: 0 additions & 541 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

550 changes: 0 additions & 550 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

This file was deleted.

28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

807 changes: 0 additions & 807 deletions .yarn/releases/yarn-3.3.0.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.1.cjs

Large diffs are not rendered by default.

16 changes: 5 additions & 11 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules

npmPublishAccess: public

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"

yarnPath: .yarn/releases/yarn-3.3.0.cjs
yarnPath: .yarn/releases/yarn-4.0.1.cjs
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
"packages/*"
],
"scripts": {
"build": "yarn workspaces foreach --topological --verbose run build",
"build:watch": "yarn workspaces foreach --parallel --interlaced run build:watch",
"build:clean": "yarn workspaces foreach --topological --verbose run build:clean",
"build": "yarn workspaces foreach --worktree --topological --verbose run build",
"build:watch": "yarn workspaces foreach --worktree --parallel --interlaced run build:watch",
"build:clean": "yarn workspaces foreach --worktree --topological --verbose run build:clean",
"doctoc": "doctoc README.md",
"format": "prettier --write --ignore-unknown .",
"format:check": "prettier --check --ignore-unknown .",
"postinstall": "husky install",
"release": "semantic-release",
"start": "node packages/cli/moker.js",
"test": "yarn workspaces foreach --topological --verbose run test",
"test": "yarn workspaces foreach --worktree --topological --verbose run test",
"todos": "leasot --exit-nicely --reporter markdown --ignore \"**/node_modules\" \"**/*.ts\" > TODO.md",
"typescript": "yarn build:clean && tsc --build --force",
"typescript:watch": "tsc --build --watch"
Expand All @@ -41,7 +41,7 @@
"semantic-release-yarn": "2.0.1",
"typescript": "5.2.2"
},
"packageManager": "yarn@3.3.0",
"packageManager": "yarn@4.0.1",
"moker": {
"scoped": true,
"plugins": [
Expand Down
27 changes: 26 additions & 1 deletion packages/core/src/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ export async function addYarnPlugin({
directory: string;
name: string;
}) {
await runYarnCmd(["plugin", "import", name], { directory });
const currentPlugins = await getYarnPlugins({ directory });

if (!currentPlugins.includes(name)) {
await runYarnCmd(["plugin", "import", name], { directory });
}
}

export async function removeYarnPlugin({
Expand All @@ -89,6 +93,27 @@ export async function removeYarnPlugin({
await runYarnCmd(["plugin", "remove", name], { directory });
}

export async function getYarnPlugins({ directory }: { directory: string }) {
const { stdout } = await runYarnCmd(
["plugin", "plugin", "runtime", "--json"],
{ directory },
);

return stdout.split("\n").reduce((acc, line) => {
try {
const { name } = JSON.parse(line);

if (name !== "@@core") {
return [...acc, name.replace("@yarnpkg/plugin-", "")];
}
} catch {
// ignore
}

return acc;
}, [] as string[]);
}

export async function installDependency({
directory,
identifier,
Expand Down
3 changes: 2 additions & 1 deletion packages/plugins/src/esbuild/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ async function load({ directory }: PluginArgs) {
directory: monorepoDirectory,
data: {
scripts: {
build: "yarn workspaces foreach --topological --verbose run build",
build:
"yarn workspaces foreach --worktree --topological --verbose run build",
},
},
});
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/src/jest/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ async function install({ directory }: PluginArgs) {
directory: monorepoDirectory,
data: {
scripts: {
test: "yarn workspaces foreach --topological --verbose run test",
test: "yarn workspaces foreach --worktree --topological --verbose run test",
"test:watch":
"yarn workspaces foreach --parallel --interlaced run test:watch",
"yarn workspaces foreach --worktree --parallel --interlaced run test:watch",
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function install({ directory }: PluginArgs) {
directory: monorepoDirectory,
data: {
scripts: {
test: "yarn workspaces foreach --topological --verbose run test",
test: "yarn workspaces foreach --worktree --topological --verbose run test",
},
},
});
Expand Down
7 changes: 4 additions & 3 deletions packages/plugins/src/typescript/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ async function install({ directory }: PluginArgs) {
directory: monorepoDirectory,
data: {
scripts: {
build: "yarn workspaces foreach --topological --verbose run build",
build:
"yarn workspaces foreach --worktree --topological --verbose run build",
"build:watch":
"yarn workspaces foreach --parallel --interlaced run build:watch",
"yarn workspaces foreach --worktree --parallel --interlaced run build:watch",
"build:clean":
"yarn workspaces foreach --topological --verbose run build:clean",
"yarn workspaces foreach --worktree --topological --verbose run build:clean",
typescript: "yarn build:clean && tsc --build --force",
"typescript:watch": "tsc --build --watch",
},
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/xv/xv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function install({ directory }: PluginArgs) {
directory: monorepoDirectory,
data: {
scripts: {
test: "yarn workspaces foreach --topological --verbose run test",
test: "yarn workspaces foreach --worktree --topological --verbose run test",
},
},
});
Expand Down
Loading