@positronic/cli 0.0.8 → 0.0.9
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
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
1
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
10
|
try {
|
|
3
11
|
var info = gen[key](arg);
|
|
@@ -34,6 +42,23 @@ function _instanceof(left, right) {
|
|
|
34
42
|
return left instanceof right;
|
|
35
43
|
}
|
|
36
44
|
}
|
|
45
|
+
function _iterable_to_array(iter) {
|
|
46
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
47
|
+
}
|
|
48
|
+
function _non_iterable_rest() {
|
|
49
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50
|
+
}
|
|
51
|
+
function _to_array(arr) {
|
|
52
|
+
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
|
|
53
|
+
}
|
|
54
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
55
|
+
if (!o) return;
|
|
56
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
57
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
58
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
59
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
60
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
61
|
+
}
|
|
37
62
|
function _ts_generator(thisArg, body) {
|
|
38
63
|
var f, y, t, _ = {
|
|
39
64
|
label: 0,
|
|
@@ -127,6 +152,7 @@ function _ts_generator(thisArg, body) {
|
|
|
127
152
|
}
|
|
128
153
|
import yargs from 'yargs';
|
|
129
154
|
import { hideBin } from 'yargs/helpers';
|
|
155
|
+
import React from 'react';
|
|
130
156
|
import { ProjectCommand } from './commands/project.js';
|
|
131
157
|
import { ServerCommand } from './commands/server.js';
|
|
132
158
|
import { BrainCommand } from './commands/brain.js';
|
|
@@ -136,6 +162,37 @@ import { SecretCommand } from './commands/secret.js';
|
|
|
136
162
|
import { readFileSync } from 'fs';
|
|
137
163
|
import { fileURLToPath } from 'url';
|
|
138
164
|
import { dirname, join } from 'path';
|
|
165
|
+
// Helper function to parse key=value options
|
|
166
|
+
function parseKeyValueOptions(opts) {
|
|
167
|
+
if (!opts || opts.length === 0) return undefined;
|
|
168
|
+
var parsed = {};
|
|
169
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
170
|
+
try {
|
|
171
|
+
for(var _iterator = opts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
172
|
+
var opt = _step.value;
|
|
173
|
+
var _opt_split = _to_array(opt.split('=')), key = _opt_split[0], valueParts = _opt_split.slice(1);
|
|
174
|
+
var value = valueParts.join('=');
|
|
175
|
+
if (!key || !value) {
|
|
176
|
+
throw new Error('Invalid option format: "'.concat(opt, '". Options must be in key=value format.'));
|
|
177
|
+
}
|
|
178
|
+
parsed[key] = value;
|
|
179
|
+
}
|
|
180
|
+
} catch (err) {
|
|
181
|
+
_didIteratorError = true;
|
|
182
|
+
_iteratorError = err;
|
|
183
|
+
} finally{
|
|
184
|
+
try {
|
|
185
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
186
|
+
_iterator.return();
|
|
187
|
+
}
|
|
188
|
+
} finally{
|
|
189
|
+
if (_didIteratorError) {
|
|
190
|
+
throw _iteratorError;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return parsed;
|
|
195
|
+
}
|
|
139
196
|
export function buildCli(options) {
|
|
140
197
|
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;
|
|
141
198
|
var isLocalDevMode = server !== undefined;
|
|
@@ -360,7 +417,13 @@ export function buildCli(options) {
|
|
|
360
417
|
type: 'boolean',
|
|
361
418
|
alias: 'w',
|
|
362
419
|
default: false
|
|
363
|
-
}).
|
|
420
|
+
}).option('options', {
|
|
421
|
+
describe: 'Options to pass to the brain (key=value format)',
|
|
422
|
+
type: 'array',
|
|
423
|
+
alias: 'o',
|
|
424
|
+
string: true,
|
|
425
|
+
coerce: parseKeyValueOptions
|
|
426
|
+
}).example('$0 run my-brain', 'Run a brain by name').example('$0 run my-brain --watch', 'Run a brain and watch its execution').example('$0 run my-brain -o channel=#general -o debug=true', 'Run a brain with options');
|
|
364
427
|
}, function(argv) {
|
|
365
428
|
return _async_to_generator(function() {
|
|
366
429
|
var element;
|
|
@@ -475,7 +538,13 @@ export function buildCli(options) {
|
|
|
475
538
|
type: 'boolean',
|
|
476
539
|
alias: 'w',
|
|
477
540
|
default: false
|
|
478
|
-
}).
|
|
541
|
+
}).option('options', {
|
|
542
|
+
describe: 'Options to pass to the brain (key=value format)',
|
|
543
|
+
type: 'array',
|
|
544
|
+
alias: 'o',
|
|
545
|
+
string: true,
|
|
546
|
+
coerce: parseKeyValueOptions
|
|
547
|
+
}).example('$0 brain run my-brain', 'Run a brain by name').example('$0 brain run my-brain --watch', 'Run a brain and watch its execution').example('$0 brain run my-brain -o channel=#general -o debug=true', 'Run a brain with options');
|
|
479
548
|
}, function(argv) {
|
|
480
549
|
return _async_to_generator(function() {
|
|
481
550
|
var element;
|
|
@@ -193,11 +193,11 @@ export var BrainCommand = /*#__PURE__*/ function() {
|
|
|
193
193
|
key: "run",
|
|
194
194
|
value: function run(_0) {
|
|
195
195
|
return _async_to_generator(function(param) {
|
|
196
|
-
var brainName, watch, apiPath, response, result, errorText, error;
|
|
196
|
+
var brainName, watch, options, apiPath, response, result, errorText, error;
|
|
197
197
|
return _ts_generator(this, function(_state) {
|
|
198
198
|
switch(_state.label){
|
|
199
199
|
case 0:
|
|
200
|
-
brainName = param.name, watch = param.watch;
|
|
200
|
+
brainName = param.name, watch = param.watch, options = param.options;
|
|
201
201
|
apiPath = '/brains/runs';
|
|
202
202
|
_state.label = 1;
|
|
203
203
|
case 1:
|
|
@@ -215,7 +215,8 @@ export var BrainCommand = /*#__PURE__*/ function() {
|
|
|
215
215
|
'Content-Type': 'application/json'
|
|
216
216
|
},
|
|
217
217
|
body: JSON.stringify({
|
|
218
|
-
brainName: brainName
|
|
218
|
+
brainName: brainName,
|
|
219
|
+
options: options
|
|
219
220
|
})
|
|
220
221
|
})
|
|
221
222
|
];
|
package/dist/types/cli.d.ts
CHANGED
package/dist/types/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,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;AAoBD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,UAAU,4BAs+B3C"}
|
|
@@ -18,6 +18,7 @@ interface BrainRerunArgs {
|
|
|
18
18
|
interface BrainRunArgs {
|
|
19
19
|
name: string;
|
|
20
20
|
watch?: boolean;
|
|
21
|
+
options?: Record<string, string>;
|
|
21
22
|
}
|
|
22
23
|
interface BrainWatchArgs {
|
|
23
24
|
runId?: string;
|
|
@@ -28,7 +29,7 @@ export declare class BrainCommand {
|
|
|
28
29
|
history({ name: brainName, limit, }: ArgumentsCamelCase<BrainHistoryArgs>): React.ReactElement;
|
|
29
30
|
show({ name: brainName, }: ArgumentsCamelCase<BrainShowArgs>): React.ReactElement;
|
|
30
31
|
rerun({ name: brainName, runId, startsAt, stopsAfter, }: ArgumentsCamelCase<BrainRerunArgs>): React.ReactElement;
|
|
31
|
-
run({ name: brainName, watch }: ArgumentsCamelCase<BrainRunArgs>): Promise<React.ReactElement>;
|
|
32
|
+
run({ name: brainName, watch, options }: ArgumentsCamelCase<BrainRunArgs>): Promise<React.ReactElement>;
|
|
32
33
|
watch({ runId, name: brainName, }: ArgumentsCamelCase<BrainWatchArgs>): Promise<React.ReactElement>;
|
|
33
34
|
}
|
|
34
35
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../../src/commands/brain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,UAAU,aAAa;CAAG;AAC1B,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AACD,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AACD,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,Q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