Skip to content

Commit

Permalink
0.4.2 (#2)
Browse files Browse the repository at this point in the history
Co-authored-by: Arun George <[email protected]>
  • Loading branch information
aruniverse and aruniverse authored Mar 17, 2022
1 parent e29a1d9 commit ff34381
Show file tree
Hide file tree
Showing 16 changed files with 483 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cospace
working-directory: ./cli
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand Down
File renamed without changes.
File renamed without changes.
47 changes: 29 additions & 18 deletions cospace/index.js → cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ import fs from "fs-extra";
import meow from "meow";
import { execSync } from "child_process";

const Commands = {
INIT: "init",
OVERRIDE: "override",
PURGE: "purge",
}

const help = `
Usage:
$ npx cospace <command> [<args>]
Commands:
init <dir> Initialize a new CoSpace
${Commands.INIT} <dir> Initialize a new CoSpace
If <dir> is not provided, will default to current dir
override Override the CoSpace's pnpm config
purge Purge all node_modules from the CoSpace
${Commands.OVERRIDE} Override the CoSpace's pnpm config
${Commands.PURGE} Purge all node_modules from the CoSpace
Flags:
--help, -h Show this help message
Expand Down Expand Up @@ -74,9 +80,7 @@ const overridePnpm = async () => {
})
)
.map((pkg) => {
if (!pkg.private) {
return pkg.name;
}
if (!pkg.private) return pkg.name;
})
.filter((name) => name)
.sort()
Expand All @@ -92,7 +96,7 @@ const overridePnpm = async () => {
await fs.writeJSON(pkgJsonPath, pkgJsonData, { spaces: 2 });

console.log(
"Your CoSpace's workspace links have been overriden. Run install, build and you're good to go!"
"Your CoSpace's workspace links have been overriden. Run `pnpm install`, `pnpm build` and you're good to go!"
);
};

Expand All @@ -103,7 +107,13 @@ const purge = async () => {
})
).map((pkg) => pkg.path);

await Promise.all(paths.map((path) => fs.remove(`${path}/node_modules`)));
await Promise.all(
paths.map((p) => {
const nodeModulesPath = path.join(p, "node_modules");
console.log(`Purging ${nodeModulesPath}`);
return fs.remove(nodeModulesPath);
})
);

console.log("All node_modules have been purged from the CoSpace.");
};
Expand All @@ -122,16 +132,17 @@ const run = async () => {

checkPnpmInstalled();

if (input[0] === "init") {
await init(input[1]);
} else if (input[0] === "override") {
await overridePnpm();
} else if (input[0] === "purge") {
await purge();
} else {
console.log(
`Unrecognized command, ${input[0]}, please try again with --help for more info.`
);
switch (input[0]) {
case Commands.INIT:
return await init(input[1]);
case Commands.OVERRIDE:
return await overridePnpm();
case Commands.PURGE:
return await purge();
default:
console.error(
`Unrecognized command, ${input[0]}, please try again with --help for more info.`
);
}
};

Expand Down
4 changes: 2 additions & 2 deletions cospace/package.json → cli/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "cospace",
"version": "0.4.1",
"version": "0.4.2",
"description": "Setup a `CoSpace` to link multiple (mono)repos together!",
"author": "https://github.com/aruniverse",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/aruniverse/cospace/tree/master/cospace"
"url": "https://github.com/aruniverse/cospace/tree/master/cospace/cli"
},
"type": "module",
"bin": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"preinstall": "npx only-allow pnpm",
"build": "lage build",
"build:clean": "lage build --no-cache",
"clean": "lage clean --no-cache && cospace purge",
"clean": "lage clean --no-cache && cospace purge && pnpm i -w cospace",
"setOverrides": "cospace override"
},
"devDependencies": {
Expand Down
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "cospace-monorepo",
"version": "0.1.0",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"init:test": "cospace init test",
"purge": "cospace purge",
"setOverrides": "cospace override",
"list-pkgs": "pnpm ls -r --depth -1"
},
"packageManager": "[email protected]",
"devDependencies": {
"cospace": "workspace:*"
},
"pnpm": {
"overrides": {
"cospace": "workspace:*"
},
"prefer-workspace-packages": true,
"link-workspace-packages": "deep"
}
}
Loading

0 comments on commit ff34381

Please sign in to comment.