@telorun/cli 0.70.0 → 0.72.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/bundle/partition-layers.d.ts +11 -26
- package/dist/bundle/partition-layers.d.ts.map +1 -1
- package/dist/bundle/partition-layers.js +37 -88
- package/dist/bundle/partition-layers.js.map +1 -1
- package/dist/cli.js +11 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/cel.d.ts +18 -0
- package/dist/commands/cel.d.ts.map +1 -1
- package/dist/commands/cel.js +60 -12
- package/dist/commands/cel.js.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +43 -8
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +27 -17
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/module.d.ts.map +1 -1
- package/dist/commands/module.js +36 -31
- package/dist/commands/module.js.map +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +57 -26
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +15 -4
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +19 -10
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +35 -21
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/controller-progress.d.ts.map +1 -1
- package/dist/controller-progress.js +0 -0
- package/dist/controller-progress.js.map +1 -1
- package/dist/debug-event-subscriber.d.ts.map +1 -1
- package/dist/debug-event-subscriber.js +2 -1
- package/dist/debug-event-subscriber.js.map +1 -1
- package/dist/logger.d.ts +33 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +73 -37
- package/dist/logger.js.map +1 -1
- package/dist/output.d.ts +111 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +143 -0
- package/dist/output.js.map +1 -0
- package/package.json +6 -6
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GAEtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;6EAE6E;AAC7E,SAAS,iBAAiB,CAAC,GAAW;IACpC,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;iEAWiE;AACjE,SAAS,oBAAoB,CAC3B,KAAkB,EAClB,CAAqB,EACrB,cAAsB;IAEtB,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK;QAAE,OAAO,SA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AK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzF,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5C,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvD,CAAC,CAAC;QAEH,IAAI,OAAO;YAAE,UAAU,EAAE,CAAC;;YACrB,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AAC3D,CAAC"}
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/** Output encodings the CLI can produce. `yaml` is deliberately absent: the flag
|
|
2
|
+
* is an enum precisely so it can gain a value later without a second flag. */
|
|
3
|
+
export type OutputFormat = "text" | "json";
|
|
4
|
+
export declare const OUTPUT_FORMATS: OutputFormat[];
|
|
5
|
+
/** A colour palette bound to ONE stream.
|
|
6
|
+
*
|
|
7
|
+
* Colour is a property of the descriptor being written to, not of the process:
|
|
8
|
+
* `telo check 2>/dev/null` leaves stdout a TTY and stderr not, and a single
|
|
9
|
+
* process-wide decision is wrong for one of them either way. The CLI used to
|
|
10
|
+
* decide once from `process.stdout.isTTY` while `formatDiagnostics` wrote to
|
|
11
|
+
* stderr, so redirecting one stream and not the other produced escapes where
|
|
12
|
+
* they could not be rendered — the leak this splits apart. */
|
|
13
|
+
export interface Palette {
|
|
14
|
+
ok(text: string): string;
|
|
15
|
+
warn(text: string): string;
|
|
16
|
+
error(text: string): string;
|
|
17
|
+
dim(text: string): string;
|
|
18
|
+
}
|
|
19
|
+
/** The minimum of a writable stream this needs. Narrow on purpose: a test hands
|
|
20
|
+
* in a recording pair, so `Output` never reads process globals. */
|
|
21
|
+
export interface OutputStream {
|
|
22
|
+
isTTY?: boolean;
|
|
23
|
+
write(chunk: string): unknown;
|
|
24
|
+
}
|
|
25
|
+
export interface OutputOptions {
|
|
26
|
+
format: OutputFormat;
|
|
27
|
+
stdout?: OutputStream;
|
|
28
|
+
stderr?: OutputStream;
|
|
29
|
+
env?: NodeJS.ProcessEnv;
|
|
30
|
+
}
|
|
31
|
+
/** The single seam every CLI-owned write goes through.
|
|
32
|
+
*
|
|
33
|
+
* The stream split is the whole contract:
|
|
34
|
+
*
|
|
35
|
+
* - **stdout is the machine surface.** Under `-o json` it carries the payload
|
|
36
|
+
* and nothing else, so a consumer parses it whole.
|
|
37
|
+
* - **stderr is the human surface, in BOTH formats.** Prose keeps flowing under
|
|
38
|
+
* `-o json` — the convention npm, cargo and kubectl follow — because the
|
|
39
|
+
* alternative is silence: a command that reports a failure reason through
|
|
40
|
+
* prose would otherwise have it swallowed, leaving `{"ok":false}` with no
|
|
41
|
+
* cause. Suppressing stderr was error swallowing, which Telo forbids.
|
|
42
|
+
*
|
|
43
|
+
* `telo run` is exempt from `-o json` entirely; see `emit`. */
|
|
44
|
+
export declare class Output {
|
|
45
|
+
readonly format: OutputFormat;
|
|
46
|
+
readonly stdout: Palette;
|
|
47
|
+
readonly stderr: Palette;
|
|
48
|
+
private readonly outStream;
|
|
49
|
+
private readonly errStream;
|
|
50
|
+
constructor(options: OutputOptions);
|
|
51
|
+
get isJson(): boolean;
|
|
52
|
+
/** Human-readable line on stdout. Suppressed under `-o json`, where stdout is
|
|
53
|
+
* reserved for the payload. */
|
|
54
|
+
line(text?: string): void;
|
|
55
|
+
/** Human-readable line on stderr. Written in BOTH formats — stderr is not the
|
|
56
|
+
* machine contract, and silencing it loses the reason a command failed. */
|
|
57
|
+
errLine(text?: string): void;
|
|
58
|
+
/** Emit a command's structured RESULT ENVELOPE. A no-op in text mode.
|
|
59
|
+
*
|
|
60
|
+
* Every command that owns its stdout calls this exactly once, including when
|
|
61
|
+
* it has nothing interesting to report — a consumer cannot distinguish
|
|
62
|
+
* "nothing to say" from "this command ignores the flag", so a bare envelope
|
|
63
|
+
* is the difference between a contract and a guess.
|
|
64
|
+
*
|
|
65
|
+
* `telo run` is the ONE exemption, and it is a property of the command rather
|
|
66
|
+
* than an oversight: the kernel runs in-process and the app's own output goes
|
|
67
|
+
* to these same descriptors (`teeStdio` copies, it does not redirect), so
|
|
68
|
+
* NEITHER stream is the CLI's to claim. An envelope written after arbitrary
|
|
69
|
+
* app output is unparseable, which is the exact failure `-o json` exists to
|
|
70
|
+
* remove. The machine surface for a run already exists and is `--debug`,
|
|
71
|
+
* whose wire protocol is framed per event precisely because it shares a
|
|
72
|
+
* stream. */
|
|
73
|
+
emit(payload: unknown): void;
|
|
74
|
+
/** Write a bare DOCUMENT to stdout, in either format.
|
|
75
|
+
*
|
|
76
|
+
* For the commands whose structured form is the document itself rather than a
|
|
77
|
+
* result report — `cel`, `search`, `module versions|manifest|digest|resources|kinds`.
|
|
78
|
+
* Unconditional because their per-command `--json` flag predates `-o` and
|
|
79
|
+
* must keep working under the default `text` format. One serializer with
|
|
80
|
+
* `emit`, so the CLI has a single JSON encoding rather than three. */
|
|
81
|
+
document(payload: unknown): void;
|
|
82
|
+
/** Write verbatim content to stdout, unconditionally and with no framing.
|
|
83
|
+
*
|
|
84
|
+
* For the one case that is neither prose nor a JSON payload: `telo module
|
|
85
|
+
* manifest` printing a module's `telo.yaml` bytes, which ARE the output. It
|
|
86
|
+
* bypasses format handling because the bytes are the answer in every format
|
|
87
|
+
* — the `--json` path wraps them in a document instead and never reaches
|
|
88
|
+
* here. */
|
|
89
|
+
raw(content: string): void;
|
|
90
|
+
}
|
|
91
|
+
export declare function configureOutput(format: OutputFormat): void;
|
|
92
|
+
/** Swap the ambient instance, returning a restore function.
|
|
93
|
+
*
|
|
94
|
+
* For tests of code that reaches the seam through the accessor rather than
|
|
95
|
+
* through a parameter — they hand in an `Output` over recording streams instead
|
|
96
|
+
* of spying on `process.stderr.write`. */
|
|
97
|
+
export declare function installOutput(replacement: Output): () => void;
|
|
98
|
+
export declare function output(): Output;
|
|
99
|
+
/** yargs has already rejected anything outside `choices` by the time a handler
|
|
100
|
+
* runs, so an unrecognized value here means the enum grew and this function was
|
|
101
|
+
* not updated. Throwing is the point: silently degrading `-o yaml` to text is
|
|
102
|
+
* the worst failure a format flag can have. */
|
|
103
|
+
export declare function parseOutputFormat(value: unknown): OutputFormat;
|
|
104
|
+
/** Free-function forms of the seam, for the many call sites that only need to
|
|
105
|
+
* write a line and would otherwise each bind a local. They read the singleton
|
|
106
|
+
* per call, so they observe the configured format no matter when they run. */
|
|
107
|
+
export declare const outLine: (text?: string) => void;
|
|
108
|
+
export declare const outErrLine: (text?: string) => void;
|
|
109
|
+
export declare const outEmit: (payload: unknown) => void;
|
|
110
|
+
export declare const outDocument: (payload: unknown) => void;
|
|
111
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAEA;+EAC+E;AAC/E,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3C,eAAO,MAAM,cAAc,EAAE,YAAY,EAAqB,CAAC;AAE/D;;;;;;;+DAO+D;AAC/D,MAAM,WAAW,OAAO;IACtB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAiBD;oEACoE;AACpE,MAAM,WAAW,YAAY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;AAC/E,eAAO,MAAM,OAAO,GAAI,aAAS,KAAG,IAA0B,CAAC;AAC/D,eAAO,MAAM,UAAU,GAAI,aAAS,KAAG,IAA6B,CAAC;AACrE,eAAO,MAAM,OAAO,GAAI,SAAS,OAAO,KAAG,IAA6B,CAAC;AACzE,eAAO,MAAM,WAAW,GAAI,SAAS,OAAO,KAAG,IAAiC,CAAC"}
|
package/dist/output.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { decideColor } from "@telorun/kernel";
|
|
2
|
+
export const OUTPUT_FORMATS = ["text", "json"];
|
|
3
|
+
const PLAIN = {
|
|
4
|
+
ok: (t) => t,
|
|
5
|
+
warn: (t) => t,
|
|
6
|
+
error: (t) => t,
|
|
7
|
+
dim: (t) => t,
|
|
8
|
+
};
|
|
9
|
+
function paletteFor(isTTY, env) {
|
|
10
|
+
// Follows `kernel/specs/logging.md` §11.2 precedence, shared with the `pretty`
|
|
11
|
+
// log encoding rather than reimplemented.
|
|
12
|
+
if (!decideColor({ setting: "auto", env, isTTY }))
|
|
13
|
+
return PLAIN;
|
|
14
|
+
const wrap = (code) => (text) => `\x1b[${code}m${text}\x1b[0m`;
|
|
15
|
+
return { ok: wrap("32"), warn: wrap("33"), error: wrap("31"), dim: wrap("2") };
|
|
16
|
+
}
|
|
17
|
+
/** The single seam every CLI-owned write goes through.
|
|
18
|
+
*
|
|
19
|
+
* The stream split is the whole contract:
|
|
20
|
+
*
|
|
21
|
+
* - **stdout is the machine surface.** Under `-o json` it carries the payload
|
|
22
|
+
* and nothing else, so a consumer parses it whole.
|
|
23
|
+
* - **stderr is the human surface, in BOTH formats.** Prose keeps flowing under
|
|
24
|
+
* `-o json` — the convention npm, cargo and kubectl follow — because the
|
|
25
|
+
* alternative is silence: a command that reports a failure reason through
|
|
26
|
+
* prose would otherwise have it swallowed, leaving `{"ok":false}` with no
|
|
27
|
+
* cause. Suppressing stderr was error swallowing, which Telo forbids.
|
|
28
|
+
*
|
|
29
|
+
* `telo run` is exempt from `-o json` entirely; see `emit`. */
|
|
30
|
+
export class Output {
|
|
31
|
+
format;
|
|
32
|
+
stdout;
|
|
33
|
+
stderr;
|
|
34
|
+
outStream;
|
|
35
|
+
errStream;
|
|
36
|
+
constructor(options) {
|
|
37
|
+
const { format, stdout = process.stdout, stderr = process.stderr, env = process.env, } = options;
|
|
38
|
+
this.format = format;
|
|
39
|
+
this.outStream = stdout;
|
|
40
|
+
this.errStream = stderr;
|
|
41
|
+
// Structured output must never carry escapes: a consumer parses it, and no
|
|
42
|
+
// terminal renders it. Deciding this here rather than at each call site is
|
|
43
|
+
// what makes "JSON is always clean" true by construction. stderr keeps its
|
|
44
|
+
// colour under `-o json` because it stays the human surface.
|
|
45
|
+
this.stdout = format === "text" ? paletteFor(Boolean(stdout.isTTY), env) : PLAIN;
|
|
46
|
+
this.stderr = paletteFor(Boolean(stderr.isTTY), env);
|
|
47
|
+
}
|
|
48
|
+
get isJson() {
|
|
49
|
+
return this.format === "json";
|
|
50
|
+
}
|
|
51
|
+
/** Human-readable line on stdout. Suppressed under `-o json`, where stdout is
|
|
52
|
+
* reserved for the payload. */
|
|
53
|
+
line(text = "") {
|
|
54
|
+
if (this.format === "text")
|
|
55
|
+
this.outStream.write(`${text}\n`);
|
|
56
|
+
}
|
|
57
|
+
/** Human-readable line on stderr. Written in BOTH formats — stderr is not the
|
|
58
|
+
* machine contract, and silencing it loses the reason a command failed. */
|
|
59
|
+
errLine(text = "") {
|
|
60
|
+
this.errStream.write(`${text}\n`);
|
|
61
|
+
}
|
|
62
|
+
/** Emit a command's structured RESULT ENVELOPE. A no-op in text mode.
|
|
63
|
+
*
|
|
64
|
+
* Every command that owns its stdout calls this exactly once, including when
|
|
65
|
+
* it has nothing interesting to report — a consumer cannot distinguish
|
|
66
|
+
* "nothing to say" from "this command ignores the flag", so a bare envelope
|
|
67
|
+
* is the difference between a contract and a guess.
|
|
68
|
+
*
|
|
69
|
+
* `telo run` is the ONE exemption, and it is a property of the command rather
|
|
70
|
+
* than an oversight: the kernel runs in-process and the app's own output goes
|
|
71
|
+
* to these same descriptors (`teeStdio` copies, it does not redirect), so
|
|
72
|
+
* NEITHER stream is the CLI's to claim. An envelope written after arbitrary
|
|
73
|
+
* app output is unparseable, which is the exact failure `-o json` exists to
|
|
74
|
+
* remove. The machine surface for a run already exists and is `--debug`,
|
|
75
|
+
* whose wire protocol is framed per event precisely because it shares a
|
|
76
|
+
* stream. */
|
|
77
|
+
emit(payload) {
|
|
78
|
+
if (this.format === "json")
|
|
79
|
+
this.outStream.write(serialize(payload));
|
|
80
|
+
}
|
|
81
|
+
/** Write a bare DOCUMENT to stdout, in either format.
|
|
82
|
+
*
|
|
83
|
+
* For the commands whose structured form is the document itself rather than a
|
|
84
|
+
* result report — `cel`, `search`, `module versions|manifest|digest|resources|kinds`.
|
|
85
|
+
* Unconditional because their per-command `--json` flag predates `-o` and
|
|
86
|
+
* must keep working under the default `text` format. One serializer with
|
|
87
|
+
* `emit`, so the CLI has a single JSON encoding rather than three. */
|
|
88
|
+
document(payload) {
|
|
89
|
+
this.outStream.write(serialize(payload));
|
|
90
|
+
}
|
|
91
|
+
/** Write verbatim content to stdout, unconditionally and with no framing.
|
|
92
|
+
*
|
|
93
|
+
* For the one case that is neither prose nor a JSON payload: `telo module
|
|
94
|
+
* manifest` printing a module's `telo.yaml` bytes, which ARE the output. It
|
|
95
|
+
* bypasses format handling because the bytes are the answer in every format
|
|
96
|
+
* — the `--json` path wraps them in a document instead and never reaches
|
|
97
|
+
* here. */
|
|
98
|
+
raw(content) {
|
|
99
|
+
this.outStream.write(content);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function serialize(payload) {
|
|
103
|
+
return `${JSON.stringify(payload, null, 2)}\n`;
|
|
104
|
+
}
|
|
105
|
+
/** Configured once from argv by a yargs middleware, before any handler runs, so
|
|
106
|
+
* call sites far from the handler reach the same decision without threading it
|
|
107
|
+
* through every signature. Tests construct an `Output` directly instead. */
|
|
108
|
+
let current = new Output({ format: "text" });
|
|
109
|
+
export function configureOutput(format) {
|
|
110
|
+
current = new Output({ format });
|
|
111
|
+
}
|
|
112
|
+
/** Swap the ambient instance, returning a restore function.
|
|
113
|
+
*
|
|
114
|
+
* For tests of code that reaches the seam through the accessor rather than
|
|
115
|
+
* through a parameter — they hand in an `Output` over recording streams instead
|
|
116
|
+
* of spying on `process.stderr.write`. */
|
|
117
|
+
export function installOutput(replacement) {
|
|
118
|
+
const previous = current;
|
|
119
|
+
current = replacement;
|
|
120
|
+
return () => {
|
|
121
|
+
current = previous;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export function output() {
|
|
125
|
+
return current;
|
|
126
|
+
}
|
|
127
|
+
/** yargs has already rejected anything outside `choices` by the time a handler
|
|
128
|
+
* runs, so an unrecognized value here means the enum grew and this function was
|
|
129
|
+
* not updated. Throwing is the point: silently degrading `-o yaml` to text is
|
|
130
|
+
* the worst failure a format flag can have. */
|
|
131
|
+
export function parseOutputFormat(value) {
|
|
132
|
+
if (OUTPUT_FORMATS.includes(value))
|
|
133
|
+
return value;
|
|
134
|
+
throw new Error(`Unsupported --output format '${String(value)}'. Expected one of: ${OUTPUT_FORMATS.join(", ")}.`);
|
|
135
|
+
}
|
|
136
|
+
/** Free-function forms of the seam, for the many call sites that only need to
|
|
137
|
+
* write a line and would otherwise each bind a local. They read the singleton
|
|
138
|
+
* per call, so they observe the configured format no matter when they run. */
|
|
139
|
+
export const outLine = (text = "") => current.line(text);
|
|
140
|
+
export const outErrLine = (text = "") => current.errLine(text);
|
|
141
|
+
export const outEmit = (payload) => current.emit(payload);
|
|
142
|
+
export const outDocument = (payload) => current.document(payload);
|
|
143
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9C,MAAM,CAAC,MAAM,cA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M,WAAW,GAAG,CAAC,OAAgB,EAAQ,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.0",
|
|
4
4
|
"description": "Telo CLI - Command-line interface for the Telo runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"telo",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@telorun/analyzer": "0.
|
|
37
|
+
"@telorun/analyzer": "0.57.0",
|
|
38
38
|
"@telorun/glob": "0.2.0",
|
|
39
|
-
"@telorun/ide-support": "0.
|
|
40
|
-
"@telorun/kernel": "0.
|
|
41
|
-
"@telorun/sdk": "0.
|
|
42
|
-
"@telorun/templating": "0.
|
|
39
|
+
"@telorun/ide-support": "0.12.0",
|
|
40
|
+
"@telorun/kernel": "0.72.0",
|
|
41
|
+
"@telorun/sdk": "0.72.0",
|
|
42
|
+
"@telorun/templating": "0.13.0",
|
|
43
43
|
"dotenv": "^17.4.0",
|
|
44
44
|
"packageurl-js": "^2.0.1",
|
|
45
45
|
"semver": "^7.7.3",
|