@comity-dev/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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Filippo Bovo and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * comity — Comity unified developer CLI.
4
+ *
5
+ * Usage:
6
+ * comity <command> [options]
7
+ *
8
+ * Commands:
9
+ * validate Run architecture validation
10
+ * normalize Normalize package metadata (exports, package.json)
11
+ * build Build a package (internal use)
12
+ *
13
+ * Options:
14
+ * --help, -h Show help
15
+ * --version, -v Show version
16
+ */
17
+ export {};
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * comity — Comity unified developer CLI.
4
+ *
5
+ * Usage:
6
+ * comity <command> [options]
7
+ *
8
+ * Commands:
9
+ * validate Run architecture validation
10
+ * normalize Normalize package metadata (exports, package.json)
11
+ * build Build a package (internal use)
12
+ *
13
+ * Options:
14
+ * --help, -h Show help
15
+ * --version, -v Show version
16
+ */
17
+ import { spawn } from "node:child_process";
18
+ import { readFileSync } from "node:fs";
19
+ import { dirname, resolve } from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+ const __dirname = dirname(fileURLToPath(import.meta.url));
22
+ const COMMANDS = {
23
+ validate: {
24
+ name: "validate",
25
+ description: "Run architecture validation",
26
+ bin: "comity-validate",
27
+ args: [],
28
+ },
29
+ "normalize:package-json": {
30
+ name: "normalize package-json",
31
+ description: "Normalize package.json key order",
32
+ bin: "comity-normalize-package-json",
33
+ args: [],
34
+ },
35
+ "normalize:exports": {
36
+ name: "normalize exports",
37
+ description: "Normalize TypeScript export declarations",
38
+ bin: "comity-normalize-exports",
39
+ args: [],
40
+ },
41
+ build: {
42
+ name: "build",
43
+ description: "Build a package (internal use)",
44
+ bin: "comity-build",
45
+ args: [],
46
+ },
47
+ };
48
+ function printHelp() {
49
+ console.log(`comity — Comity unified developer CLI
50
+
51
+ Usage:
52
+ comity <command> [options]
53
+
54
+ Commands:
55
+ validate Run architecture validation
56
+ normalize package-json Normalize package.json key order
57
+ normalize exports Normalize TypeScript export declarations
58
+ build Build a package (internal use)
59
+
60
+ Options:
61
+ --help, -h Show this help
62
+ --version, -v Show version
63
+
64
+ Examples:
65
+ comity validate --repo .
66
+ comity normalize package-json --check
67
+ comity normalize exports --check
68
+ comity build --watch
69
+ `);
70
+ }
71
+ function findRepoRoot(startDir) {
72
+ let dir = startDir;
73
+ while (dir !== resolve(dir, "..")) {
74
+ try {
75
+ const pkgPath = resolve(dir, "package.json");
76
+ const content = readFileSync(pkgPath, "utf8");
77
+ const pkg = JSON.parse(content);
78
+ if (pkg.workspaces) {
79
+ return dir;
80
+ }
81
+ }
82
+ catch {
83
+ // ignore
84
+ }
85
+ dir = resolve(dir, "..");
86
+ }
87
+ return startDir;
88
+ }
89
+ function findBinary(name) {
90
+ // Find the binary in node_modules/.bin at the repo root
91
+ const repoRoot = findRepoRoot(process.cwd());
92
+ return resolve(repoRoot, "node_modules", ".bin", name);
93
+ }
94
+ function execBinary(binaryName, args) {
95
+ const binaryPath = findBinary(binaryName);
96
+ return new Promise((resolvePromise, reject) => {
97
+ const child = spawn(binaryPath, args, {
98
+ stdio: "inherit",
99
+ cwd: process.cwd(),
100
+ });
101
+ child.on("close", (code) => {
102
+ resolvePromise(code ?? 1);
103
+ });
104
+ child.on("error", (err) => {
105
+ console.error(`Failed to execute ${binaryName}:`, err.message);
106
+ reject(err);
107
+ });
108
+ });
109
+ }
110
+ async function main() {
111
+ const args = process.argv.slice(2);
112
+ if (args.includes("--help") || args.includes("-h")) {
113
+ printHelp();
114
+ process.exit(0);
115
+ }
116
+ if (args.includes("--version") || args.includes("-v")) {
117
+ console.log("0.1.0");
118
+ process.exit(0);
119
+ }
120
+ if (args.length === 0) {
121
+ console.error("Error: No command specified");
122
+ printHelp();
123
+ process.exit(1);
124
+ }
125
+ const commandName = args[0];
126
+ const commandArgs = args.slice(1);
127
+ // Handle subcommands
128
+ let fullCommandName = commandName;
129
+ if (commandName === "normalize" && commandArgs.length > 0) {
130
+ fullCommandName = `normalize:${commandArgs[0]}`;
131
+ commandArgs.shift();
132
+ }
133
+ const command = COMMANDS[fullCommandName];
134
+ if (!command) {
135
+ console.error(`Error: Unknown command "${commandName}"`);
136
+ printHelp();
137
+ process.exit(1);
138
+ }
139
+ // Pass through remaining args
140
+ const allArgs = [...command.args, ...commandArgs];
141
+ try {
142
+ const exitCode = await execBinary(command.bin, allArgs);
143
+ process.exit(exitCode);
144
+ }
145
+ catch (error) {
146
+ console.error(error);
147
+ process.exit(1);
148
+ }
149
+ }
150
+ main();
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @comity-dev/cli — Comity unified developer CLI.
3
+ *
4
+ * This package provides the `comity` binary which orchestrates
5
+ * development tooling commands.
6
+ */
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * @comity-dev/cli — Comity unified developer CLI.
4
+ *
5
+ * This package provides the `comity` binary which orchestrates
6
+ * development tooling commands.
7
+ */
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@comity-dev/cli",
3
+ "version": "0.1.0",
4
+ "description": "Comity unified developer CLI. Development tooling.",
5
+ "type": "module",
6
+ "private": false,
7
+ "license": "MIT",
8
+ "comity": {
9
+ "layer": "dev-tooling"
10
+ },
11
+ "engines": {
12
+ "node": ">=24.0.0"
13
+ },
14
+ "bin": {
15
+ "comity": "./dist/bin/comity.js"
16
+ },
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "./dist"
27
+ ],
28
+ "dependencies": {
29
+ "@comity-dev/validate": "0.1.0",
30
+ "@comity-dev/build": "0.1.0",
31
+ "@comity-dev/package-tools": "0.1.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^24.13.3",
35
+ "typescript": "^5.9.3"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc -p tsconfig.json",
39
+ "test": "vitest run"
40
+ }
41
+ }