generated from hamlim/template-monorepo
-
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.
WIP - setup tests, pull in jsonc-parser
- Loading branch information
Showing
9 changed files
with
812 additions
and
9 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import assert from "node:assert"; | ||
import { after, before, test } from "node:test"; | ||
import { parse } from "../utils/jsonc-parser.mjs"; | ||
|
||
test("parses plain old JSON fine", () => { | ||
let sample = { | ||
foo: { | ||
bar: ["baz", 1, 2, false, true, null], | ||
}, | ||
}; | ||
|
||
let result = parse(JSON.stringify(sample)); | ||
|
||
assert.deepEqual(result, sample); | ||
}); |
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,15 @@ | ||
import assert from "node:assert"; | ||
import { after, before, test } from "node:test"; | ||
import { start } from "../one-version.mjs"; | ||
|
||
test("stub", () => { | ||
assert.ok(true); | ||
test("supports help command", async () => { | ||
let logs = []; | ||
const logger = { | ||
log: (...args) => { | ||
logs.push(args.join(" ")); | ||
}, | ||
}; | ||
await start({ rootDirectory: process.cwd(), logger, args: ["help"] }); | ||
|
||
assert.match(logs[0], /one-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
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,4 +1,37 @@ | ||
export async function start({ rootDirectory, logger }) { | ||
logger.log(`Running one-version in ${rootDirectory}`); | ||
return Promise.resolve(); | ||
import { parse } from "./utils/jsonc-parser.mjs"; | ||
|
||
async function _loadConfig({ rootDirectory }) { | ||
} | ||
|
||
export async function start({ rootDirectory, logger, args, loadConfig = _loadConfig }) { | ||
let [firstArg] = args; | ||
|
||
let usageLogs = [ | ||
"", | ||
`Usage:`, | ||
` one-version check - Check the repo to ensure all dependencies are match the expected versions`, | ||
` one-version help - Display this help message!`, | ||
"", | ||
]; | ||
|
||
switch (firstArg) { | ||
case "check": { | ||
// @TODO | ||
return; | ||
} | ||
case "help": { | ||
logger.log(`one-version - a strict dependency conformance tool for (mono)repos!`); | ||
for (let log of usageLogs) { | ||
logger.log(log); | ||
} | ||
return; | ||
} | ||
default: { | ||
logger.log(`Unknown command: ${firstArg}`); | ||
for (let log of usageLogs) { | ||
logger.log(log); | ||
} | ||
return; | ||
} | ||
} | ||
} |
Oops, something went wrong.