-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: reinstall * refactor: tasks
- Loading branch information
Showing
18 changed files
with
213 additions
and
83 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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
### TODOs | ||
|
||
| Filename | line # | TODO | | ||
| :------------------------------------------------------------------------- | :----: | :------------------------------------------------------------ | | ||
| [packages/core/src/yarnrc.ts](packages/core/src/yarnrc.ts#L23) | 23 | etc, fix later | | ||
| [packages/cli/src/commands/list.ts](packages/cli/src/commands/list.ts#L19) | 19 | list workspaces using https://yarnpkg.com/cli/workspaces/list | | ||
| [packages/plugins/src/jest/jest.ts](packages/plugins/src/jest/jest.ts#L31) | 31 | install jest without ts-jest | | ||
| Filename | line # | TODO | | ||
| :------------------------------------------------------------------------- | :----: | :--------------------------- | | ||
| [packages/core/src/yarnrc.ts](packages/core/src/yarnrc.ts#L23) | 23 | etc, fix later | | ||
| [packages/plugins/src/jest/jest.ts](packages/plugins/src/jest/jest.ts#L31) | 31 | install jest without ts-jest | |
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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export * from "./add.js"; | ||
export * from "./create.js"; | ||
export * from "./list.js"; | ||
export * from "./reinstall.js"; | ||
export * from "./reload.js"; | ||
export * from "./remove.js"; | ||
export * from "./use.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
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,70 @@ | ||
import { | ||
getPlugins, | ||
getWorkspaces, | ||
installPlugin, | ||
isMonorepo, | ||
loadAllPlugins, | ||
logWarning, | ||
task, | ||
} from "@mokr/core"; | ||
import { command } from "bandersnatch"; | ||
import { resolve } from "node:path"; | ||
import { REINSTALL_WARNING } from "../constants.js"; | ||
import { format, updateDependencies } from "../tasks.js"; | ||
|
||
export const reinstall = command("reinstall") | ||
.hidden() | ||
.description("Reinstalls all plugins in the current directory") | ||
.option("all", { | ||
type: "boolean", | ||
description: "Also reinstalls plugins of all workspaces in a monorepo", | ||
}) | ||
.option("cwd", { | ||
description: "Directory to use as the current working directory", | ||
default: process.cwd(), | ||
}) | ||
.action(async ({ all, cwd }) => { | ||
const directory = resolve(cwd); | ||
const plugins = await getPlugins({ directory }); | ||
|
||
for (const name of plugins) { | ||
await task(`Reinstall plugin ${name}`, async () => { | ||
await installPlugin({ directory, name }); | ||
}); | ||
} | ||
|
||
await task(`Load plugins`, () => loadAllPlugins({ directory })); | ||
|
||
if (all && (await isMonorepo({ directory }))) { | ||
const workspaces = await getWorkspaces({ directory }); | ||
|
||
for (const workspace of workspaces) { | ||
const workspaceDirectory = resolve(directory, workspace.location); | ||
const plugins = await getPlugins({ directory: workspaceDirectory }); | ||
|
||
// Skip root | ||
if (workspaceDirectory === directory) { | ||
continue; | ||
} | ||
|
||
for (const name of plugins) { | ||
await task( | ||
`Reinstall plugin ${name} of ${workspace.name}`, | ||
async () => { | ||
await installPlugin({ directory: workspaceDirectory, name }); | ||
} | ||
); | ||
} | ||
|
||
await task(`Load plugins of ${workspace.name}`, () => | ||
loadAllPlugins({ directory }) | ||
); | ||
} | ||
} | ||
|
||
await updateDependencies({ directory }); | ||
|
||
await format({ directory }); | ||
|
||
logWarning(REINSTALL_WARNING); | ||
}); |
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
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,2 @@ | ||
export const REINSTALL_WARNING = | ||
"Please verify the changes made by reinstalling the plugin(s) as they may have reverted changes you've made to the plugins defaults."; |
Oops, something went wrong.