@bonnard/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/bon.mjs +41 -0
- package/package.json +28 -0
package/dist/bin/bon.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import pc from "picocolors";
|
|
6
|
+
|
|
7
|
+
//#region src/commands/init.ts
|
|
8
|
+
const BON_YAML_TEMPLATE = (projectName) => `project:
|
|
9
|
+
name: ${projectName}
|
|
10
|
+
`;
|
|
11
|
+
const GITIGNORE_TEMPLATE = `.bon/
|
|
12
|
+
`;
|
|
13
|
+
async function initCommand() {
|
|
14
|
+
const cwd = process.cwd();
|
|
15
|
+
const projectName = path.basename(cwd);
|
|
16
|
+
if (fs.existsSync(path.join(cwd, "bon.yaml"))) {
|
|
17
|
+
console.log(pc.red("A bon.yaml already exists in this directory."));
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
fs.mkdirSync(path.join(cwd, "models"), { recursive: true });
|
|
21
|
+
fs.mkdirSync(path.join(cwd, "views"), { recursive: true });
|
|
22
|
+
fs.mkdirSync(path.join(cwd, ".bon"), { recursive: true });
|
|
23
|
+
fs.writeFileSync(path.join(cwd, "bon.yaml"), BON_YAML_TEMPLATE(projectName));
|
|
24
|
+
fs.writeFileSync(path.join(cwd, ".gitignore"), GITIGNORE_TEMPLATE);
|
|
25
|
+
console.log(pc.green(`Initialised Bonnard project "${projectName}"`));
|
|
26
|
+
console.log();
|
|
27
|
+
console.log(` ${pc.dim("bon.yaml")} project config`);
|
|
28
|
+
console.log(` ${pc.dim("models/")} model definitions`);
|
|
29
|
+
console.log(` ${pc.dim("views/")} view definitions`);
|
|
30
|
+
console.log(` ${pc.dim(".bon/")} local state (gitignored)`);
|
|
31
|
+
console.log(` ${pc.dim(".gitignore")} git ignore rules`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/bin/bon.ts
|
|
36
|
+
program.name("bon").description("Bonnard semantic layer CLI").version("0.1.0");
|
|
37
|
+
program.command("init").description("Create a new Bonnard project in the current directory").action(initCommand);
|
|
38
|
+
program.parse();
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { };
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bonnard/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"bon": "./dist/bin/bon.mjs"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsdown src/bin/bon.ts --format esm --out-dir dist/bin",
|
|
13
|
+
"dev": "tsdown src/bin/bon.ts --format esm --out-dir dist/bin --watch",
|
|
14
|
+
"test": "vitest run"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@bonnard/core": "workspace:*",
|
|
18
|
+
"commander": "^12.0.0",
|
|
19
|
+
"picocolors": "^1.0.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"tsdown": "^0.20.1",
|
|
23
|
+
"vitest": "^2.0.0"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20.0.0"
|
|
27
|
+
}
|
|
28
|
+
}
|