@vm0/cli 4.18.0 → 4.19.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.
Files changed (2) hide show
  1. package/index.js +53 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -16294,7 +16294,7 @@ async function generateEnvPlaceholders(missingVars, envFilePath) {
16294
16294
  }
16295
16295
  }
16296
16296
  var cookCommand = new Command13().name("cook").description("One-click agent preparation and execution from vm0.yaml").argument("[prompt]", "Prompt for the agent").action(async (prompt) => {
16297
- const shouldExit = await checkAndUpgrade("4.18.0", prompt);
16297
+ const shouldExit = await checkAndUpgrade("4.19.0", prompt);
16298
16298
  if (shouldExit) {
16299
16299
  process.exit(0);
16300
16300
  }
@@ -16481,6 +16481,38 @@ import { Command as Command14 } from "commander";
16481
16481
  import chalk16 from "chalk";
16482
16482
  import { readFile as readFile6 } from "fs/promises";
16483
16483
  import { existsSync as existsSync7 } from "fs";
16484
+
16485
+ // src/lib/dockerfile-validator.ts
16486
+ var ALLOWED_INSTRUCTIONS = /* @__PURE__ */ new Set(["FROM", "RUN"]);
16487
+ function validateDockerfile(content) {
16488
+ const errors = [];
16489
+ const lines = content.split("\n");
16490
+ let inContinuation = false;
16491
+ for (let i = 0; i < lines.length; i++) {
16492
+ const line = lines[i];
16493
+ const trimmed = line.trim();
16494
+ if (!inContinuation && !trimmed) continue;
16495
+ if (!inContinuation && trimmed.startsWith("#")) continue;
16496
+ if (inContinuation) {
16497
+ inContinuation = trimmed.endsWith("\\");
16498
+ continue;
16499
+ }
16500
+ const match = trimmed.match(/^([A-Za-z]+)\s/);
16501
+ if (match) {
16502
+ const instruction = match[1].toUpperCase();
16503
+ if (!ALLOWED_INSTRUCTIONS.has(instruction)) {
16504
+ errors.push(`Unsupported instruction: ${instruction} (line ${i + 1})`);
16505
+ }
16506
+ }
16507
+ inContinuation = trimmed.endsWith("\\");
16508
+ }
16509
+ return {
16510
+ valid: errors.length === 0,
16511
+ errors
16512
+ };
16513
+ }
16514
+
16515
+ // src/commands/image/build.ts
16484
16516
  var sleep2 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
16485
16517
  var buildCommand = new Command14().name("build").description("Build a custom image from a Dockerfile").requiredOption("-f, --file <path>", "Path to Dockerfile").requiredOption("-n, --name <name>", "Name for the image").option("--delete-existing", "Delete existing image before building").action(
16486
16518
  async (options) => {
@@ -16509,6 +16541,25 @@ var buildCommand = new Command14().name("build").description("Build a custom ima
16509
16541
  try {
16510
16542
  const scope = await apiClient.getScope();
16511
16543
  const dockerfile = await readFile6(file2, "utf8");
16544
+ const validation = validateDockerfile(dockerfile);
16545
+ if (!validation.valid) {
16546
+ console.error(chalk16.red("\u2717 Dockerfile validation failed\n"));
16547
+ for (const error43 of validation.errors) {
16548
+ console.error(chalk16.red(` ${error43}`));
16549
+ }
16550
+ console.error();
16551
+ console.error(
16552
+ chalk16.yellow(
16553
+ " vm0 image build only supports FROM and RUN instructions."
16554
+ )
16555
+ );
16556
+ console.error(
16557
+ chalk16.yellow(
16558
+ " The purpose is to pre-install environment dependencies."
16559
+ )
16560
+ );
16561
+ process.exit(1);
16562
+ }
16512
16563
  console.log(chalk16.blue(`Building image: ${scope.slug}/${name}`));
16513
16564
  console.log();
16514
16565
  const buildInfo = await apiClient.createImage({
@@ -17178,7 +17229,7 @@ var scopeCommand = new Command22().name("scope").description("Manage your scope
17178
17229
 
17179
17230
  // src/index.ts
17180
17231
  var program = new Command23();
17181
- program.name("vm0").description("VM0 CLI - A modern build tool").version("4.18.0");
17232
+ program.name("vm0").description("VM0 CLI - A modern build tool").version("4.19.0");
17182
17233
  program.command("info").description("Display environment information").action(async () => {
17183
17234
  console.log(chalk23.cyan("System Information:"));
17184
17235
  console.log(`Node Version: ${process.version}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/cli",
3
- "version": "4.18.0",
3
+ "version": "4.19.0",
4
4
  "description": "CLI application",
5
5
  "repository": {
6
6
  "type": "git",