@lark-apaas/openclaw-dev-cli 0.1.4 → 0.1.5

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/dist/index.js +40 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7288,7 +7288,7 @@ var initCommand = {
7288
7288
  const hasPackageJson = import_node_fs9.default.existsSync(import_node_path12.default.join(projectDir, "package.json"));
7289
7289
  const existingMeta = readSparkMeta(projectDir);
7290
7290
  const title = options.title ?? import_node_path12.default.basename(projectDir);
7291
- let stackVersion = existingMeta.stackVersion;
7291
+ let templateVersion = existingMeta.templateVersion;
7292
7292
  if (!hasPackageJson) {
7293
7293
  if (!options.template) {
7294
7294
  throw new Error(
@@ -7306,23 +7306,23 @@ Available: ${TEMPLATE_TYPES.join(", ")}`
7306
7306
  projectName: import_node_path12.default.basename(projectDir),
7307
7307
  localTemplate: options.localTemplate
7308
7308
  });
7309
- stackVersion = version;
7309
+ templateVersion = version;
7310
7310
  }
7311
- let stack = options.template ?? existingMeta.stack;
7312
- if (!stack) {
7311
+ let template = options.template ?? existingMeta.template;
7312
+ if (!template) {
7313
7313
  const pkgPath = import_node_path12.default.join(projectDir, "package.json");
7314
7314
  if (import_node_fs9.default.existsSync(pkgPath)) {
7315
7315
  try {
7316
7316
  const pkg = JSON.parse(import_node_fs9.default.readFileSync(pkgPath, "utf-8"));
7317
- stack = pkg.mclaw?.stack;
7318
- stackVersion = stackVersion ?? pkg.mclaw?.stackVersion;
7317
+ template = pkg.mclaw?.stack;
7318
+ templateVersion = templateVersion ?? pkg.mclaw?.stackVersion;
7319
7319
  } catch {
7320
7320
  }
7321
7321
  }
7322
7322
  }
7323
- if (!stack) {
7323
+ if (!template) {
7324
7324
  throw new Error(
7325
- "Cannot determine stack type. Please provide --template or ensure package.json has mclaw.stack field."
7325
+ "Cannot determine template type. Please provide --template or ensure package.json has mclaw.stack field."
7326
7326
  );
7327
7327
  }
7328
7328
  let appId = options.appId ?? existingMeta.appId;
@@ -7338,8 +7338,8 @@ Available: ${TEMPLATE_TYPES.join(", ")}`
7338
7338
  }
7339
7339
  writeSparkMeta(projectDir, {
7340
7340
  appId,
7341
- stack,
7342
- stackVersion: stackVersion ?? "0.1.0"
7341
+ template,
7342
+ templateVersion: templateVersion ?? "0.1.0"
7343
7343
  });
7344
7344
  if (!options.skipInstall) {
7345
7345
  console.log("\nInstalling dependencies...");
@@ -7352,7 +7352,7 @@ Available: ${TEMPLATE_TYPES.join(", ")}`
7352
7352
  \u2705 Initialized successfully!`);
7353
7353
  console.log(` Directory: ${projectDir}`);
7354
7354
  console.log(` App ID: ${appId}`);
7355
- console.log(` Stack: ${stack}`);
7355
+ console.log(` Template: ${template}`);
7356
7356
  });
7357
7357
  }
7358
7358
  };
@@ -7400,8 +7400,8 @@ Available: ${TEMPLATE_TYPES.join(", ")}`
7400
7400
  }
7401
7401
  writeSparkMeta(projectDir, {
7402
7402
  appId,
7403
- stack,
7404
- stackVersion
7403
+ template: stack,
7404
+ templateVersion: stackVersion
7405
7405
  });
7406
7406
  if (import_node_fs10.default.existsSync(pkgPath)) {
7407
7407
  const pkg = JSON.parse(import_node_fs10.default.readFileSync(pkgPath, "utf-8"));
@@ -7483,8 +7483,14 @@ function configureTosutil(tosutilPath, confPath, credential) {
7483
7483
  ], { stdio: "pipe" });
7484
7484
  }
7485
7485
  function uploadToTos(tosutilPath, confPath, sourceDir, destUrl) {
7486
- console.error(`${LOG_PREFIX} Uploading ${sourceDir} \u2192 ${destUrl}`);
7487
- (0, import_node_child_process3.execFileSync)(tosutilPath, [
7486
+ console.log(`${LOG_PREFIX} Uploading ${sourceDir} \u2192 ${destUrl}`);
7487
+ const files = import_node_fs12.default.readdirSync(sourceDir);
7488
+ if (files.length === 0) {
7489
+ console.warn(`${LOG_PREFIX} Warning: source directory is empty, skipping upload.`);
7490
+ return;
7491
+ }
7492
+ console.log(`${LOG_PREFIX} Source files: ${files.length}`);
7493
+ const output = (0, import_node_child_process3.execFileSync)(tosutilPath, [
7488
7494
  "cp",
7489
7495
  "-conf",
7490
7496
  confPath,
@@ -7499,7 +7505,19 @@ function uploadToTos(tosutilPath, confPath, sourceDir, destUrl) {
7499
7505
  "-ps",
7500
7506
  "10485760",
7501
7507
  "-f"
7502
- ], { stdio: "inherit" });
7508
+ ], { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
7509
+ console.log(output);
7510
+ const succeedMatch = output.match(/Succeed count is:\s*(\d+)/);
7511
+ const failedMatch = output.match(/Failed count is:\s*(\d+)/);
7512
+ const succeedCount = succeedMatch ? parseInt(succeedMatch[1], 10) : 0;
7513
+ const failedCount = failedMatch ? parseInt(failedMatch[1], 10) : 0;
7514
+ if (failedCount > 0) {
7515
+ throw new Error(`${LOG_PREFIX} Upload failed: ${failedCount} files failed, ${succeedCount} succeeded.`);
7516
+ }
7517
+ if (succeedCount === 0) {
7518
+ throw new Error(`${LOG_PREFIX} Upload failed: no files were uploaded. Check tosutil credentials and bucket permissions.`);
7519
+ }
7520
+ console.log(`${LOG_PREFIX} Uploaded ${succeedCount} files successfully.`);
7503
7521
  }
7504
7522
  function uploadWithCredential(tosutilPath, sourceDir, destUrl, credential, label) {
7505
7523
  const confPath = import_node_path15.default.join(import_node_os2.default.tmpdir(), `.tosutilconfig-mclaw-${label}-${process.pid}`);
@@ -7532,7 +7550,8 @@ function uploadOutput(options) {
7532
7550
  }
7533
7551
  if (validated.hasOutputStatic) {
7534
7552
  const localPath = import_node_path15.default.join(distDir, OUTPUT_STATIC_DIR);
7535
- const destUrl = `${preUploadResult.uploadPrefix}${OUTPUT_STATIC_DIR}/`;
7553
+ const prefix = preUploadResult.uploadPrefix.endsWith("/") ? preUploadResult.uploadPrefix : `${preUploadResult.uploadPrefix}/`;
7554
+ const destUrl = `${prefix}${OUTPUT_STATIC_DIR}/`;
7536
7555
  console.error(`${LOG_PREFIX} Uploading output_static (static credential)...`);
7537
7556
  uploadWithCredential(tosutilPath, localPath, destUrl, {
7538
7557
  accessKeyID: preUploadResult.uploadCredential.AccessKeyID,
@@ -7555,7 +7574,7 @@ var deployCommand = {
7555
7574
  throw new Error('.spark/meta.json not found. Run "mclaw-dev init" first.');
7556
7575
  }
7557
7576
  const meta = JSON.parse(import_node_fs13.default.readFileSync(metaPath, "utf-8"));
7558
- if (!meta.appId || !meta.stack) {
7577
+ if (!meta.appId || !meta.template) {
7559
7578
  throw new Error('.spark/meta.json is incomplete. Run "mclaw-dev init" to fix.');
7560
7579
  }
7561
7580
  const publishResult = await createPublish(meta.appId);
@@ -7571,14 +7590,14 @@ var deployCommand = {
7571
7590
  ...process.env,
7572
7591
  MCLAW_APP_ID: meta.appId,
7573
7592
  MCLAW_VERSION: String(publishResult.version),
7574
- MCLAW_STACK: meta.stack,
7593
+ MCLAW_STACK: meta.template,
7575
7594
  MCLAW_CDN_DOMAIN: cdnDomain,
7576
7595
  MCLAW_STATIC_PREFIX: preUploadResult.downloadURLPrefix
7577
7596
  };
7578
7597
  console.log("\nBuilding...");
7579
7598
  console.log(` MCLAW_APP_ID=${meta.appId}`);
7580
7599
  console.log(` MCLAW_VERSION=${publishResult.version}`);
7581
- console.log(` MCLAW_STACK=${meta.stack}`);
7600
+ console.log(` MCLAW_STACK=${meta.template}`);
7582
7601
  console.log(` MCLAW_CDN_DOMAIN=${cdnDomain}`);
7583
7602
  console.log(` MCLAW_STATIC_PREFIX=${preUploadResult.downloadURLPrefix}`);
7584
7603
  (0, import_node_child_process4.execSync)("npm run build", {
@@ -7653,7 +7672,7 @@ function loadEnvFile(filePath) {
7653
7672
  }
7654
7673
  }
7655
7674
  loadEnvFile(import_node_path17.default.join(process.cwd(), ".env"));
7656
- var VERSION = "0.1.4";
7675
+ var VERSION = "0.1.5";
7657
7676
  var cli = new OpenClawCLI(VERSION);
7658
7677
  cli.useAll(commands);
7659
7678
  cli.run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/openclaw-dev-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "CLI tool for OpenClaw development",
5
5
  "main": "dist/index.js",
6
6
  "bin": {