@positronic/cli 0.0.2 → 0.0.3
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/src/cli.js +16 -1
- package/dist/types/cli.d.ts.map +1 -1
- package/package.json +7 -4
- package/src/cli.ts +17 -1
package/dist/src/cli.js
CHANGED
|
@@ -133,16 +133,31 @@ import { BrainCommand } from './commands/brain.js';
|
|
|
133
133
|
import { ResourcesCommand } from './commands/resources.js';
|
|
134
134
|
import { ScheduleCommand } from './commands/schedule.js';
|
|
135
135
|
import { SecretCommand } from './commands/secret.js';
|
|
136
|
+
import { readFileSync } from 'fs';
|
|
137
|
+
import { fileURLToPath } from 'url';
|
|
138
|
+
import { dirname, join } from 'path';
|
|
136
139
|
export function buildCli(options) {
|
|
137
140
|
var _options_argv = options.argv, argv = _options_argv === void 0 ? hideBin(process.argv) : _options_argv, server = options.server, _options_exitProcess = options.exitProcess, exitProcess = _options_exitProcess === void 0 ? false : _options_exitProcess, render = options.render;
|
|
138
141
|
var isLocalDevMode = server !== undefined;
|
|
142
|
+
// Get version from package.json
|
|
143
|
+
var version = 'TEST'; // Default version for test environment where package.json path differs
|
|
144
|
+
try {
|
|
145
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
146
|
+
var __dirname = dirname(__filename);
|
|
147
|
+
var packageJsonPath = join(__dirname, '..', '..', 'package.json');
|
|
148
|
+
var packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
149
|
+
version = packageJson.version;
|
|
150
|
+
} catch (error) {
|
|
151
|
+
// In test environment, the relative path to package.json is different
|
|
152
|
+
// so we use 'TEST' as the version to avoid breaking tests
|
|
153
|
+
}
|
|
139
154
|
// Instantiate command classes, passing the determined mode and path
|
|
140
155
|
var projectCommand = new ProjectCommand();
|
|
141
156
|
var brainCommand = new BrainCommand();
|
|
142
157
|
var scheduleCommand = new ScheduleCommand();
|
|
143
158
|
var secretCommand = new SecretCommand(server);
|
|
144
159
|
// Main CLI definition
|
|
145
|
-
var cli = yargs(argv).scriptName('positronic').usage('Usage: $0 <command> [options]').version().alias('v', 'version').help('h').alias('h', 'help').wrap(null).strictCommands().exitProcess(exitProcess);
|
|
160
|
+
var cli = yargs(argv).scriptName('positronic').usage('Usage: $0 <command> [options]').version(version).alias('v', 'version').help('h').alias('h', 'help').wrap(null).strictCommands().exitProcess(exitProcess);
|
|
146
161
|
// --- Project Management Commands (Global Mode Only) ---
|
|
147
162
|
cli = cli.command('project', 'Manage your Positronic projects\n', function(yargsProject) {
|
|
148
163
|
if (!isLocalDevMode) {
|
package/dist/types/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAK5D,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,KAAK,GAAG,CAAC;CAC9C;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,UAAU,4BAg9B3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@positronic/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
4
7
|
"description": "A CLI for AI Brains",
|
|
5
8
|
"type": "module",
|
|
6
9
|
"license": "MIT",
|
|
@@ -16,9 +19,9 @@
|
|
|
16
19
|
"clean": "rm -rf tsconfig.tsbuildinfo dist node_modules"
|
|
17
20
|
},
|
|
18
21
|
"dependencies": {
|
|
19
|
-
"@positronic/core": "^0.0.
|
|
20
|
-
"@positronic/spec": "^0.0.
|
|
21
|
-
"@positronic/template-new-project": "^0.0.
|
|
22
|
+
"@positronic/core": "^0.0.3",
|
|
23
|
+
"@positronic/spec": "^0.0.3",
|
|
24
|
+
"@positronic/template-new-project": "^0.0.3",
|
|
22
25
|
"caz": "^2.0.0",
|
|
23
26
|
"chokidar": "^3.6.0",
|
|
24
27
|
"eventsource": "^3.0.6",
|
package/src/cli.ts
CHANGED
|
@@ -7,6 +7,9 @@ import { ResourcesCommand } from './commands/resources.js';
|
|
|
7
7
|
import { ScheduleCommand } from './commands/schedule.js';
|
|
8
8
|
import { SecretCommand } from './commands/secret.js';
|
|
9
9
|
import type { PositronicDevServer } from '@positronic/spec';
|
|
10
|
+
import { readFileSync } from 'fs';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
import { dirname, join } from 'path';
|
|
10
13
|
|
|
11
14
|
export interface CliOptions {
|
|
12
15
|
argv?: string[];
|
|
@@ -25,6 +28,19 @@ export function buildCli(options: CliOptions) {
|
|
|
25
28
|
|
|
26
29
|
const isLocalDevMode = server !== undefined;
|
|
27
30
|
|
|
31
|
+
// Get version from package.json
|
|
32
|
+
let version = 'TEST'; // Default version for test environment where package.json path differs
|
|
33
|
+
try {
|
|
34
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
35
|
+
const __dirname = dirname(__filename);
|
|
36
|
+
const packageJsonPath = join(__dirname, '..', '..', 'package.json');
|
|
37
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
38
|
+
version = packageJson.version;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
// In test environment, the relative path to package.json is different
|
|
41
|
+
// so we use 'TEST' as the version to avoid breaking tests
|
|
42
|
+
}
|
|
43
|
+
|
|
28
44
|
// Instantiate command classes, passing the determined mode and path
|
|
29
45
|
const projectCommand = new ProjectCommand();
|
|
30
46
|
const brainCommand = new BrainCommand();
|
|
@@ -35,7 +51,7 @@ export function buildCli(options: CliOptions) {
|
|
|
35
51
|
let cli = yargs(argv)
|
|
36
52
|
.scriptName('positronic')
|
|
37
53
|
.usage('Usage: $0 <command> [options]')
|
|
38
|
-
.version()
|
|
54
|
+
.version(version)
|
|
39
55
|
.alias('v', 'version')
|
|
40
56
|
.help('h')
|
|
41
57
|
.alias('h', 'help')
|