@vm0/cli 4.9.0 → 4.10.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/index.js +68 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1200,10 +1200,13 @@ var EventRenderer = class {
|
|
|
1200
1200
|
* Render run failed state
|
|
1201
1201
|
* Note: This is run lifecycle status, not an event
|
|
1202
1202
|
*/
|
|
1203
|
-
static renderRunFailed(error43) {
|
|
1203
|
+
static renderRunFailed(error43, runId) {
|
|
1204
1204
|
console.log("");
|
|
1205
1205
|
console.log(chalk3.red("\u2717 Run failed"));
|
|
1206
1206
|
console.log(` Error: ${chalk3.red(error43 || "Unknown error")}`);
|
|
1207
|
+
console.log(
|
|
1208
|
+
chalk3.gray(` (use "vm0 logs ${runId} --system" to view system logs)`)
|
|
1209
|
+
);
|
|
1207
1210
|
}
|
|
1208
1211
|
static renderInit(event, prefix, suffix) {
|
|
1209
1212
|
console.log(
|
|
@@ -14596,11 +14599,14 @@ async function pollEvents(runId, options) {
|
|
|
14596
14599
|
};
|
|
14597
14600
|
} else if (runStatus === "failed") {
|
|
14598
14601
|
complete = true;
|
|
14599
|
-
EventRenderer.renderRunFailed(response.run.error);
|
|
14602
|
+
EventRenderer.renderRunFailed(response.run.error, runId);
|
|
14600
14603
|
result = { succeeded: false, runId };
|
|
14601
14604
|
} else if (runStatus === "timeout") {
|
|
14602
14605
|
complete = true;
|
|
14603
14606
|
console.error(chalk4.red("\n\u2717 Run timed out"));
|
|
14607
|
+
console.error(
|
|
14608
|
+
chalk4.gray(` (use "vm0 logs ${runId} --system" to view system logs)`)
|
|
14609
|
+
);
|
|
14604
14610
|
result = { succeeded: false, runId };
|
|
14605
14611
|
}
|
|
14606
14612
|
if (!complete) {
|
|
@@ -15720,11 +15726,12 @@ var artifactCommand = new Command10().name("artifact").description("Manage cloud
|
|
|
15720
15726
|
// src/commands/cook.ts
|
|
15721
15727
|
import { Command as Command11 } from "commander";
|
|
15722
15728
|
import chalk12 from "chalk";
|
|
15723
|
-
import { readFile as readFile5, mkdir as mkdir5 } from "fs/promises";
|
|
15724
|
-
import { existsSync as existsSync5 } from "fs";
|
|
15729
|
+
import { readFile as readFile5, mkdir as mkdir5, writeFile as writeFile5, appendFile } from "fs/promises";
|
|
15730
|
+
import { existsSync as existsSync5, readFileSync } from "fs";
|
|
15725
15731
|
import path12 from "path";
|
|
15726
15732
|
import { spawn } from "child_process";
|
|
15727
15733
|
import { parse as parseYaml3 } from "yaml";
|
|
15734
|
+
import { config as dotenvConfig2 } from "dotenv";
|
|
15728
15735
|
var CONFIG_FILE3 = "vm0.yaml";
|
|
15729
15736
|
var ARTIFACT_DIR = "artifact";
|
|
15730
15737
|
function execVm0Command(args, options = {}) {
|
|
@@ -15802,6 +15809,44 @@ function parseArtifactVersionFromCompletion(output, artifactName) {
|
|
|
15802
15809
|
function escapeRegExp(str) {
|
|
15803
15810
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15804
15811
|
}
|
|
15812
|
+
function extractRequiredVarNames(config2) {
|
|
15813
|
+
const refs = extractVariableReferences(config2);
|
|
15814
|
+
const grouped = groupVariablesBySource(refs);
|
|
15815
|
+
const varNames = grouped.vars.map((r) => r.name);
|
|
15816
|
+
const secretNames = grouped.secrets.map((r) => r.name);
|
|
15817
|
+
return [.../* @__PURE__ */ new Set([...varNames, ...secretNames])];
|
|
15818
|
+
}
|
|
15819
|
+
function checkMissingVariables(varNames, envFilePath) {
|
|
15820
|
+
let dotenvValues = {};
|
|
15821
|
+
if (existsSync5(envFilePath)) {
|
|
15822
|
+
const result = dotenvConfig2({ path: envFilePath });
|
|
15823
|
+
if (result.parsed) {
|
|
15824
|
+
dotenvValues = result.parsed;
|
|
15825
|
+
}
|
|
15826
|
+
}
|
|
15827
|
+
const missing = [];
|
|
15828
|
+
for (const name of varNames) {
|
|
15829
|
+
const inEnv = process.env[name] !== void 0;
|
|
15830
|
+
const inDotenv = dotenvValues[name] !== void 0;
|
|
15831
|
+
if (!inEnv && !inDotenv) {
|
|
15832
|
+
missing.push(name);
|
|
15833
|
+
}
|
|
15834
|
+
}
|
|
15835
|
+
return missing;
|
|
15836
|
+
}
|
|
15837
|
+
async function generateEnvPlaceholders(missingVars, envFilePath) {
|
|
15838
|
+
const placeholders = missingVars.map((name) => `${name}=`).join("\n");
|
|
15839
|
+
if (existsSync5(envFilePath)) {
|
|
15840
|
+
const existingContent = readFileSync(envFilePath, "utf8");
|
|
15841
|
+
const needsNewline = existingContent.length > 0 && !existingContent.endsWith("\n");
|
|
15842
|
+
const prefix = needsNewline ? "\n" : "";
|
|
15843
|
+
await appendFile(envFilePath, `${prefix}${placeholders}
|
|
15844
|
+
`);
|
|
15845
|
+
} else {
|
|
15846
|
+
await writeFile5(envFilePath, `${placeholders}
|
|
15847
|
+
`);
|
|
15848
|
+
}
|
|
15849
|
+
}
|
|
15805
15850
|
var cookCommand = new Command11().name("cook").description("One-click agent preparation and execution from vm0.yaml").argument("[prompt]", "Prompt for the agent").action(async (prompt) => {
|
|
15806
15851
|
const cwd = process.cwd();
|
|
15807
15852
|
console.log(chalk12.blue(`Reading config: ${CONFIG_FILE3}`));
|
|
@@ -15831,6 +15876,24 @@ var cookCommand = new Command11().name("cook").description("One-click agent prep
|
|
|
15831
15876
|
console.log(
|
|
15832
15877
|
chalk12.green(`\u2713 Config validated: 1 agent, ${volumeCount} volume(s)`)
|
|
15833
15878
|
);
|
|
15879
|
+
const requiredVarNames = extractRequiredVarNames(config2);
|
|
15880
|
+
if (requiredVarNames.length > 0) {
|
|
15881
|
+
const envFilePath = path12.join(cwd, ".env");
|
|
15882
|
+
const missingVars = checkMissingVariables(requiredVarNames, envFilePath);
|
|
15883
|
+
if (missingVars.length > 0) {
|
|
15884
|
+
await generateEnvPlaceholders(missingVars, envFilePath);
|
|
15885
|
+
console.log();
|
|
15886
|
+
console.log(
|
|
15887
|
+
chalk12.yellow(
|
|
15888
|
+
`\u26A0 Missing environment variables. Please fill in values in .env file:`
|
|
15889
|
+
)
|
|
15890
|
+
);
|
|
15891
|
+
for (const varName of missingVars) {
|
|
15892
|
+
console.log(chalk12.yellow(` ${varName}`));
|
|
15893
|
+
}
|
|
15894
|
+
process.exit(1);
|
|
15895
|
+
}
|
|
15896
|
+
}
|
|
15834
15897
|
if (config2.volumes && Object.keys(config2.volumes).length > 0) {
|
|
15835
15898
|
console.log();
|
|
15836
15899
|
console.log(chalk12.blue("Processing volumes..."));
|
|
@@ -16418,7 +16481,7 @@ function handleError(error43, runId) {
|
|
|
16418
16481
|
|
|
16419
16482
|
// src/index.ts
|
|
16420
16483
|
var program = new Command17();
|
|
16421
|
-
program.name("vm0").description("VM0 CLI - A modern build tool").version("4.
|
|
16484
|
+
program.name("vm0").description("VM0 CLI - A modern build tool").version("4.10.0");
|
|
16422
16485
|
program.command("info").description("Display environment information").action(async () => {
|
|
16423
16486
|
console.log(chalk17.cyan("System Information:"));
|
|
16424
16487
|
console.log(`Node Version: ${process.version}`);
|