-
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.
- Loading branch information
Showing
7 changed files
with
138 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
"version": "0.11.2", | ||
"description": "The moker CLI", | ||
"repository": "https://github.com/hongaar/moker", | ||
"author": "[email protected]", | ||
"license": "MIT", | ||
"author": "[email protected]", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"types": "types/index.d.ts", | ||
|
@@ -14,11 +14,12 @@ | |
"types" | ||
], | ||
"scripts": { | ||
"start": "node moker.js", | ||
"prepublish": "yarn build && cp ../../README.md .", | ||
"clean": "rm -rf dist && rm -rf types", | ||
"build": "yarn clean && tsc", | ||
"build:watch": "tsc --watch" | ||
"build:watch": "tsc --watch", | ||
"clean": "rm -rf dist && rm -rf types", | ||
"prepublish": "yarn build && cp ../../README.md .", | ||
"start": "node moker.js", | ||
"test": "NODE_OPTIONS='--loader=ts-node/esm --no-warnings' node--test test/*.test.ts | NODE_OPTIONS='--loader=ts-node/esm --no-warnings' tap --no-coverage" | ||
}, | ||
"dependencies": { | ||
"@mokr/core": "workspace:*", | ||
|
@@ -28,11 +29,15 @@ | |
}, | ||
"devDependencies": { | ||
"@types/node": "18.14.6", | ||
"tap": "16.3.4", | ||
"test": "3.3.0", | ||
"ts-node": "10.9.1", | ||
"typescript": "4.9.5" | ||
}, | ||
"moker": { | ||
"plugins": [ | ||
"typescript" | ||
"typescript", | ||
"test" | ||
] | ||
} | ||
} |
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,80 @@ | ||
import { createDirectory, isDirectory, writePackage } from "@mokr/core"; | ||
import { setFastFail } from "@mokr/core/src/io.js"; | ||
import assert from "node:assert"; | ||
import { temporaryDirectory } from "tempy"; | ||
import test from "test"; | ||
import cli from "../src/cli.js"; | ||
|
||
/* @ts-expect-error */ | ||
const { beforeEach, before, after, it } = test; | ||
|
||
let tempDir: string; | ||
|
||
before(() => { | ||
setFastFail(true); | ||
}); | ||
|
||
after(() => { | ||
setFastFail(false); | ||
}); | ||
|
||
beforeEach(() => { | ||
tempDir = temporaryDirectory(); | ||
}); | ||
|
||
it("should only run wihtin monorepos", async () => { | ||
await assert.rejects(cli.run(`add --cwd ${tempDir} foo`), { | ||
name: "Error", | ||
message: "Execute this command from within a monorepo", | ||
}); | ||
}); | ||
|
||
it("needs a workspace configuration", async () => { | ||
await createDirectory({ directory: `${tempDir}/.git` }); | ||
await writePackage({ | ||
directory: tempDir, | ||
data: { | ||
moker: { scoped: true }, | ||
}, | ||
}); | ||
|
||
await assert.rejects(cli.run(`add --cwd ${tempDir} foo`), { | ||
name: "Error", | ||
message: "No workspace configuration found in package.json", | ||
}); | ||
}); | ||
|
||
it("should add a workspace", async () => { | ||
const tempDir = temporaryDirectory(); | ||
|
||
await createDirectory({ directory: `${tempDir}/.git` }); | ||
await writePackage({ | ||
directory: tempDir, | ||
data: { | ||
workspaces: ["packages/*"], | ||
moker: { scoped: true }, | ||
}, | ||
}); | ||
|
||
await cli.run(`add --cwd ${tempDir} foo`); | ||
}); | ||
|
||
it( | ||
"should not confuse templates and workspace names", | ||
{ only: true }, | ||
async () => { | ||
const tempDir = temporaryDirectory(); | ||
|
||
await createDirectory({ directory: `${tempDir}/.git` }); | ||
await writePackage({ | ||
directory: tempDir, | ||
data: { | ||
workspaces: ["packages/*"], | ||
moker: { scoped: true }, | ||
}, | ||
}); | ||
|
||
await cli.run(`add --cwd ${tempDir} --template bar foo`); | ||
assert(await isDirectory({ directory: `${tempDir}/packages/foo` })); | ||
} | ||
); |
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