@prodara/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/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @prodara/cli
2
+
3
+ A thin global CLI wrapper that resolves and delegates to the project-local `@prodara/compiler`.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @prodara/cli
9
+ ```
10
+
11
+ ## How It Works
12
+
13
+ 1. Walks up from the current directory to find `node_modules/@prodara/compiler`
14
+ 2. Checks version compatibility (major versions must match)
15
+ 3. Delegates all commands to the local compiler's CLI binary via `execFileSync`
16
+
17
+ This ensures you always run the compiler version pinned in your project's `package.json`.
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ # In a project with @prodara/compiler installed locally
23
+ prodara build
24
+ prodara validate
25
+ prodara graph
26
+ prodara plan
27
+ prodara test
28
+ prodara doctor
29
+ ```
30
+
31
+ If no local compiler is found, the CLI prints installation instructions.
32
+
33
+ ## License
34
+
35
+ MIT
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ // ---------------------------------------------------------------------------
3
+ // @prodara/cli — Entry Point (thin wrapper)
4
+ // ---------------------------------------------------------------------------
5
+ // This is the global `prodara` command. Its job:
6
+ // 1. Resolve the project-local @prodara/compiler installation
7
+ // 2. Delegate to the local CLI binary
8
+ // 3. If no local install exists, provide a helpful error
9
+ //
10
+ // This mirrors the Angular CLI delegation pattern — the global wrapper
11
+ // finds and exec's the local compiler so users always run the version
12
+ // pinned in their project's package.json.
13
+ import { execFileSync } from 'node:child_process';
14
+ import { readFileSync, existsSync } from 'node:fs';
15
+ import { resolve, dirname } from 'node:path';
16
+ import { fileURLToPath } from 'node:url';
17
+ import { resolveLocal, checkVersionCompatibility } from './resolve.js';
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = dirname(__filename);
20
+ function getWrapperVersion() {
21
+ const pkgPath = resolve(__dirname, '..', 'package.json');
22
+ if (existsSync(pkgPath)) {
23
+ try {
24
+ const raw = readFileSync(pkgPath, 'utf-8');
25
+ const pkg = JSON.parse(raw);
26
+ return typeof pkg.version === 'string' ? pkg.version : '0.0.0';
27
+ }
28
+ catch {
29
+ return '0.0.0';
30
+ }
31
+ }
32
+ return '0.0.0';
33
+ }
34
+ function main() {
35
+ const cwd = process.cwd();
36
+ const local = resolveLocal(cwd);
37
+ const wrapperVersion = getWrapperVersion();
38
+ if (!local) {
39
+ process.stderr.write('Error: Could not find a local installation of @prodara/compiler.\n' +
40
+ '\n' +
41
+ 'To set up a Prodara project:\n' +
42
+ ' npm install --save-dev @prodara/compiler\n' +
43
+ ' npx prodara init\n' +
44
+ '\n' +
45
+ `@prodara/cli v${wrapperVersion}\n`);
46
+ process.exitCode = 1;
47
+ return;
48
+ }
49
+ // Check version compatibility
50
+ const compat = checkVersionCompatibility(wrapperVersion, local.version);
51
+ if (!compat.compatible) {
52
+ process.stderr.write(`Warning: ${compat.message}\n\n`);
53
+ // Still attempt delegation — only hard-fail on truly broken resolution
54
+ }
55
+ // Check that the local CLI entry exists (package may not be built)
56
+ if (!existsSync(local.cliEntry)) {
57
+ process.stderr.write(`Error: Found @prodara/compiler v${local.version} at ${local.packageDir}\n` +
58
+ 'but the CLI binary is not built.\n' +
59
+ '\n' +
60
+ 'Try: cd <project-root> && npm run build --workspace=packages/compiler\n' +
61
+ 'Or: npx prodara <command> (uses the local bin directly)\n');
62
+ process.exitCode = 1;
63
+ return;
64
+ }
65
+ // Delegate to the local compiler CLI
66
+ const args = process.argv.slice(2);
67
+ try {
68
+ execFileSync(process.execPath, [local.cliEntry, ...args], {
69
+ cwd,
70
+ stdio: 'inherit',
71
+ env: process.env,
72
+ });
73
+ }
74
+ catch (err) {
75
+ // execFileSync throws if exit code is non-zero; propagate it
76
+ if (err && typeof err === 'object' && 'status' in err) {
77
+ process.exitCode = err.status;
78
+ }
79
+ else {
80
+ process.exitCode = 1;
81
+ }
82
+ }
83
+ }
84
+ main();
85
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,8EAA8E;AAC9E,4CAA4C;AAC5C,8EAA8E;AAC9E,iDAAiD;AACjD,gEAAgE;AAChE,wCAAwC;AACxC,2DAA2D;AAC3D,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,0CAA0C;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,SAAS,iBAAiB;IACxB,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACzD,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAyB,CAAC;YACpD,OAAO,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,CAA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AAK,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,CAAC;QACH,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,EAAE;YACxD,GAAG;YACH,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,6DAA6D;QAC7D,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,QAAQ,IAAI,GAAG,EAAE,CAAC;YACtD,OAAO,CAAC,QAAQ,GAAI,GAA0B,CAAC,MAAM,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { resolveLocal, parseSemver, checkVersionCompatibility } from './resolve.js';
2
+ export type { LocalResolution } from './resolve.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACpF,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @prodara/cli — Public API
3
+ // ---------------------------------------------------------------------------
4
+ export { resolveLocal, parseSemver, checkVersionCompatibility } from './resolve.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,4BAA4B;AAC5B,8EAA8E;AAC9E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,27 @@
1
+ /** Result of resolving a local @prodara/compiler installation. */
2
+ export interface LocalResolution {
3
+ /** Absolute path to the local @prodara/compiler package directory */
4
+ readonly packageDir: string;
5
+ /** Version string from the local package.json */
6
+ readonly version: string;
7
+ /** Absolute path to the local CLI entry point (dist/cli/main.js) */
8
+ readonly cliEntry: string;
9
+ }
10
+ /**
11
+ * Walk up from `startDir` looking for node_modules/@prodara/compiler.
12
+ * Returns null if no local installation is found.
13
+ */
14
+ export declare function resolveLocal(startDir: string): LocalResolution | null;
15
+ /**
16
+ * Parse a semver version string into major.minor.patch.
17
+ * Returns [0,0,0] if parsing fails.
18
+ */
19
+ export declare function parseSemver(version: string): [number, number, number];
20
+ /**
21
+ * Check whether two versions are compatible (same major, local >= wrapper).
22
+ */
23
+ export declare function checkVersionCompatibility(wrapperVersion: string, localVersion: string): {
24
+ compatible: boolean;
25
+ message: string;
26
+ };
27
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAUA,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAkCrE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAIrE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,GACnB;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAe1C"}
@@ -0,0 +1,69 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @prodara/cli — Local Resolution
3
+ // ---------------------------------------------------------------------------
4
+ // Resolves the project-local @prodara/compiler installation.
5
+ // Walks up from cwd looking for node_modules/@prodara/compiler.
6
+ // Returns the resolved path or null if not found.
7
+ import { existsSync, readFileSync } from 'node:fs';
8
+ import { join, dirname } from 'node:path';
9
+ /**
10
+ * Walk up from `startDir` looking for node_modules/@prodara/compiler.
11
+ * Returns null if no local installation is found.
12
+ */
13
+ export function resolveLocal(startDir) {
14
+ let current = startDir;
15
+ for (;;) {
16
+ const candidate = join(current, 'node_modules', '@prodara', 'compiler');
17
+ const pkgPath = join(candidate, 'package.json');
18
+ if (existsSync(pkgPath)) {
19
+ try {
20
+ const raw = readFileSync(pkgPath, 'utf-8');
21
+ const pkg = JSON.parse(raw);
22
+ const version = typeof pkg.version === 'string' ? pkg.version : '0.0.0';
23
+ // The CLI entry is either the bin field or the conventional path
24
+ const cliEntry = join(candidate, 'dist', 'cli', 'main.js');
25
+ if (existsSync(cliEntry)) {
26
+ return { packageDir: candidate, version, cliEntry };
27
+ }
28
+ // Package found but not built — this is a valid resolution but with a
29
+ // missing binary. We still return it so the caller can give a helpful message.
30
+ return { packageDir: candidate, version, cliEntry };
31
+ }
32
+ catch {
33
+ // Corrupted package.json — skip this candidate
34
+ }
35
+ }
36
+ const parent = dirname(current);
37
+ if (parent === current)
38
+ break; // reached filesystem root
39
+ current = parent;
40
+ }
41
+ return null;
42
+ }
43
+ /**
44
+ * Parse a semver version string into major.minor.patch.
45
+ * Returns [0,0,0] if parsing fails.
46
+ */
47
+ export function parseSemver(version) {
48
+ const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version);
49
+ if (!match)
50
+ return [0, 0, 0];
51
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
52
+ }
53
+ /**
54
+ * Check whether two versions are compatible (same major, local >= wrapper).
55
+ */
56
+ export function checkVersionCompatibility(wrapperVersion, localVersion) {
57
+ const [wMajor] = parseSemver(wrapperVersion);
58
+ const [lMajor] = parseSemver(localVersion);
59
+ if (wMajor !== lMajor) {
60
+ return {
61
+ compatible: false,
62
+ message: `Version mismatch: @prodara/cli v${wrapperVersion} (major ${wMajor}) ` +
63
+ `is incompatible with local @prodara/compiler v${localVersion} (major ${lMajor}).\n` +
64
+ `Update one of them so the major versions match.`,
65
+ };
66
+ }
67
+ return { compatible: true, message: '' };
68
+ }
69
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,kCAAkC;AAClC,8EAA8E;AAC9E,6DAA6D;AAC7D,gEAAgE;AAChE,kDAAkD;AAElD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAY1C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,IAAI,OAAO,GAAG,QAAQ,CAAC;IAEvB,SAAS,CAAC;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QACxE,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAEhD,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAuD,CAAC;gBAClF,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,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AAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,OAAO,EACL,mCAAmC,cAAc,WAAW,MAAM,IAAI;gBACtE,iDAAiD,YAAY,WAAW,MAAM,MAAM;gBACpF,iDAAiD;SACpD,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC3C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@prodara/cli",
3
+ "version": "0.1.0",
4
+ "description": "Prodara CLI — thin wrapper that delegates to the project-local @prodara/compiler",
5
+ "author": "Prodara Contributors",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/prodara-ai/prodara.git",
9
+ "directory": "packages/cli"
10
+ },
11
+ "homepage": "https://github.com/prodara-ai/prodara/tree/main/packages/cli#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/prodara-ai/prodara/issues"
14
+ },
15
+ "type": "module",
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "bin": {
19
+ "prodara": "dist/bin.js"
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "build": "tsc -p tsconfig.build.json",
26
+ "typecheck": "tsc --noEmit",
27
+ "clean": "rm -rf dist",
28
+ "prepublishOnly": "npm run clean && npm run build"
29
+ },
30
+ "keywords": [
31
+ "prodara",
32
+ "cli",
33
+ "compiler"
34
+ ],
35
+ "license": "MIT",
36
+ "engines": {
37
+ "node": ">=20.0.0"
38
+ },
39
+ "dependencies": {
40
+ "@prodara/compiler": "^0.1.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^20.14.0",
44
+ "typescript": "^5.5.0"
45
+ }
46
+ }