@anvil-works/anvil-cli 0.8.0 → 0.9.0-canary.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/cli.js CHANGED
@@ -6698,189 +6698,6 @@ var __webpack_modules__ = {
6698
6698
  stderr: getSupportLevel(process.stderr)
6699
6699
  };
6700
6700
  },
6701
- "./src/CLILogger.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
6702
- "use strict";
6703
- __webpack_require__.d(__webpack_exports__, {
6704
- B: ()=>CLILogger
6705
- });
6706
- var chalk__rspack_import_0 = __webpack_require__("chalk");
6707
- var chalk__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(chalk__rspack_import_0);
6708
- var _config__rspack_import_1 = __webpack_require__("./src/config.ts");
6709
- var _globalConfig__rspack_import_3 = __webpack_require__("./src/globalConfig.ts");
6710
- var _logger__rspack_import_2 = __webpack_require__("./src/logger.ts");
6711
- const timestamp = ()=>new Date().toISOString();
6712
- function writeJson(entry) {
6713
- console.log(JSON.stringify(entry));
6714
- }
6715
- class CLILogger {
6716
- paused = false;
6717
- spinners = new Map();
6718
- activeProgressKeys = new Set();
6719
- sessionVerbose;
6720
- constructor(options = {}){
6721
- this.sessionVerbose = options.verbose ?? false;
6722
- }
6723
- get jsonMode() {
6724
- return (0, _globalConfig__rspack_import_3.JP)().jsonMode;
6725
- }
6726
- isVerbose() {
6727
- return this.sessionVerbose || (0, _config__rspack_import_1.zj)("verbose");
6728
- }
6729
- logJson(level, message) {
6730
- if (this.paused) return;
6731
- writeJson({
6732
- type: "log",
6733
- level,
6734
- message,
6735
- timestamp: timestamp()
6736
- });
6737
- }
6738
- log(...args) {
6739
- if (this.paused) return;
6740
- const activeSpinners = [];
6741
- for (const [key, spinner] of this.spinners)if (spinner.isSpinning) {
6742
- spinner.stop();
6743
- activeSpinners.push([
6744
- key,
6745
- spinner
6746
- ]);
6747
- }
6748
- console.log(...args);
6749
- for (const [key, spinner] of activeSpinners)spinner.start();
6750
- }
6751
- debug(...args) {
6752
- if ((0, _config__rspack_import_1.n)()) if (this.jsonMode) this.logJson("debug", args.map(String).join(" "));
6753
- else this.log(chalk__rspack_import_0_default().gray("[DEV]"), ...args);
6754
- }
6755
- verbose(...args) {
6756
- if (this.isVerbose()) if (this.jsonMode) this.logJson("verbose", args.map(String).join(" "));
6757
- else this.log(chalk__rspack_import_0_default().gray(`[${(0, _logger__rspack_import_2.vk)()}]`), ...args);
6758
- }
6759
- info(...args) {
6760
- if (this.jsonMode) this.logJson("info", args.map(String).join(" "));
6761
- else this.log(...args);
6762
- }
6763
- warn(...args) {
6764
- if (this.jsonMode) this.logJson("warn", args.map(String).join(" "));
6765
- else this.log(chalk__rspack_import_0_default().yellow("⚠"), ...args);
6766
- }
6767
- error(...args) {
6768
- if (this.jsonMode) this.logJson("error", args.map(String).join(" "));
6769
- else this.log(chalk__rspack_import_0_default().red("✖"), ...args);
6770
- }
6771
- success(message) {
6772
- if (this.jsonMode) this.logJson("info", message);
6773
- else this.log(chalk__rspack_import_0_default().green("✔"), message);
6774
- }
6775
- progress(key, message) {
6776
- if (this.paused) return;
6777
- if (this.jsonMode) writeJson({
6778
- type: "progress",
6779
- key,
6780
- status: "start",
6781
- message,
6782
- timestamp: timestamp()
6783
- });
6784
- else if (this.isVerbose()) {
6785
- this.log(chalk__rspack_import_0_default().blue("→"), chalk__rspack_import_0_default().blue(message));
6786
- this.activeProgressKeys.add(key);
6787
- } else {
6788
- const existing = this.spinners.get(key);
6789
- if (existing) {
6790
- existing.text = chalk__rspack_import_0_default().blue(message);
6791
- existing.start();
6792
- } else {
6793
- const { default: ora } = __webpack_require__("ora");
6794
- this.spinners.set(key, ora(chalk__rspack_import_0_default().blue(message)).start());
6795
- }
6796
- }
6797
- }
6798
- progressUpdate(key, message) {
6799
- if (this.paused) return;
6800
- if (this.jsonMode) writeJson({
6801
- type: "progress",
6802
- key,
6803
- status: "update",
6804
- message,
6805
- timestamp: timestamp()
6806
- });
6807
- else if (this.isVerbose()) this.log(chalk__rspack_import_0_default().blue("→"), chalk__rspack_import_0_default().blue(message));
6808
- else {
6809
- const spinner = this.spinners.get(key);
6810
- if (spinner) spinner.text = chalk__rspack_import_0_default().blue(message);
6811
- }
6812
- }
6813
- progressEnd(key, message) {
6814
- if (this.paused) return;
6815
- if (this.jsonMode) writeJson({
6816
- type: "progress",
6817
- key,
6818
- status: "end",
6819
- message: message || "",
6820
- timestamp: timestamp()
6821
- });
6822
- else if (this.isVerbose()) {
6823
- if (message && this.activeProgressKeys.has(key)) this.log(chalk__rspack_import_0_default().green("✔"), message);
6824
- this.activeProgressKeys.delete(key);
6825
- } else {
6826
- const spinner = this.spinners.get(key);
6827
- if (spinner) {
6828
- if (message) spinner.succeed(message);
6829
- else spinner.stop();
6830
- this.spinners.delete(key);
6831
- }
6832
- }
6833
- }
6834
- pause() {
6835
- this.paused = true;
6836
- for (const [key, spinner] of this.spinners){
6837
- spinner.stop();
6838
- this.spinners.delete(key);
6839
- }
6840
- this.activeProgressKeys.clear();
6841
- }
6842
- resume() {
6843
- this.paused = false;
6844
- }
6845
- setVerbose(value) {
6846
- this.sessionVerbose = value;
6847
- }
6848
- async prompt(questions, options) {
6849
- (0, _globalConfig__rspack_import_3.lo)(options?.action ?? "Prompt", options?.nonInteractiveHint);
6850
- this.pause();
6851
- try {
6852
- const { default: inquirer } = await import("inquirer");
6853
- return await inquirer.prompt(questions);
6854
- } finally{
6855
- this.resume();
6856
- }
6857
- }
6858
- async confirm(message, defaultValue = true, options) {
6859
- const answer = await this.prompt([
6860
- {
6861
- type: "confirm",
6862
- name: "value",
6863
- message,
6864
- default: defaultValue
6865
- }
6866
- ], options);
6867
- return answer.value;
6868
- }
6869
- async select(message, choices, defaultValue, options) {
6870
- const answer = await this.prompt([
6871
- {
6872
- type: "list",
6873
- name: "value",
6874
- message,
6875
- choices,
6876
- default: defaultValue,
6877
- loop: false
6878
- }
6879
- ], options);
6880
- return answer.value;
6881
- }
6882
- }
6883
- },
6884
6701
  "./src/Emitter.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
6885
6702
  "use strict";
6886
6703
  __webpack_require__.d(__webpack_exports__, {
@@ -8370,11 +8187,11 @@ var __webpack_modules__ = {
8370
8187
  __webpack_require__.d(__webpack_exports__, {
8371
8188
  Br: ()=>setLogger,
8372
8189
  SP: ()=>logJsonResult,
8373
- vF: ()=>logger,
8374
- vk: ()=>verboseTimestamp
8190
+ jQ: ()=>writeStdout,
8191
+ qM: ()=>BaseLogger,
8192
+ vF: ()=>logger
8375
8193
  });
8376
8194
  var chalk__rspack_import_0 = __webpack_require__("chalk");
8377
- var chalk__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(chalk__rspack_import_0);
8378
8195
  var _config__rspack_import_1 = __webpack_require__("./src/config.ts");
8379
8196
  var _globalConfig__rspack_import_2 = __webpack_require__("./src/globalConfig.ts");
8380
8197
  const timestamp = ()=>new Date().toISOString();
@@ -8395,6 +8212,9 @@ var __webpack_modules__ = {
8395
8212
  function writeJson(entry) {
8396
8213
  console.log(JSON.stringify(entry));
8397
8214
  }
8215
+ function writeStdout(...args) {
8216
+ console.log(...args);
8217
+ }
8398
8218
  function logJsonResult(success, options) {
8399
8219
  if ((0, _globalConfig__rspack_import_2.JP)().jsonMode) writeJson({
8400
8220
  type: "result",
@@ -8405,16 +8225,22 @@ var __webpack_modules__ = {
8405
8225
  timestamp: timestamp()
8406
8226
  });
8407
8227
  }
8408
- class DefaultLogger {
8228
+ class BaseLogger {
8409
8229
  paused = false;
8410
8230
  get jsonMode() {
8411
8231
  return (0, _globalConfig__rspack_import_2.JP)().jsonMode;
8412
8232
  }
8413
- log(...args) {
8233
+ isDebugEnabled() {
8234
+ return (0, _config__rspack_import_1.n)();
8235
+ }
8236
+ isVerboseEnabled() {
8237
+ return (0, _globalConfig__rspack_import_2.JP)().verbose || Boolean((0, _config__rspack_import_1.zj)("verbose"));
8238
+ }
8239
+ write(...args) {
8414
8240
  if (this.paused) return;
8415
- console.log(...args);
8241
+ console.error(...args);
8416
8242
  }
8417
- logJson(level, message) {
8243
+ writeLogJson(level, message) {
8418
8244
  if (this.paused) return;
8419
8245
  writeJson({
8420
8246
  type: "log",
@@ -8423,59 +8249,80 @@ var __webpack_modules__ = {
8423
8249
  timestamp: timestamp()
8424
8250
  });
8425
8251
  }
8252
+ writeProgressJson(key, status, message) {
8253
+ writeJson({
8254
+ type: "progress",
8255
+ key,
8256
+ status,
8257
+ message,
8258
+ timestamp: timestamp()
8259
+ });
8260
+ }
8261
+ result(text, options) {
8262
+ if (this.jsonMode) return void logJsonResult(options.success ?? true, options.json);
8263
+ const lines = "function" == typeof text ? text() : "string" == typeof text ? [
8264
+ text
8265
+ ] : text;
8266
+ for (const line of lines)writeStdout(line);
8267
+ if (options.note) this.info(options.note);
8268
+ }
8269
+ logAt(level, prefix, args) {
8270
+ if (this.jsonMode) this.writeLogJson(level, args.map(String).join(" "));
8271
+ else this.write(...prefix, ...args);
8272
+ }
8426
8273
  debug(...args) {
8427
- if ((0, _config__rspack_import_1.n)() && !(0, _config__rspack_import_1.Wj)()) if (this.jsonMode) this.logJson("debug", args.map(String).join(" "));
8428
- else this.log(chalk__rspack_import_0_default().gray("[DEV]"), ...args);
8274
+ if (this.isDebugEnabled()) this.logAt("debug", [
8275
+ chalk__rspack_import_0.chalkStderr.gray("[DEV]")
8276
+ ], args);
8429
8277
  }
8430
8278
  verbose(...args) {
8431
- if ((0, _config__rspack_import_1.zj)("verbose") && !(0, _config__rspack_import_1.Wj)()) if (this.jsonMode) this.logJson("verbose", args.map(String).join(" "));
8432
- else this.log(chalk__rspack_import_0_default().gray(`[${verboseTimestamp()}]`), ...args);
8279
+ if (this.isVerboseEnabled()) this.logAt("verbose", [
8280
+ chalk__rspack_import_0.chalkStderr.gray(`[${verboseTimestamp()}]`)
8281
+ ], args);
8433
8282
  }
8434
8283
  info(...args) {
8435
- if (this.jsonMode) this.logJson("info", args.map(String).join(" "));
8436
- else this.log(...args);
8284
+ this.logAt("info", [], args);
8437
8285
  }
8438
8286
  warn(...args) {
8439
- if (this.jsonMode) this.logJson("warn", args.map(String).join(" "));
8440
- else this.log(chalk__rspack_import_0_default().yellow("⚠"), ...args);
8287
+ this.logAt("warn", [
8288
+ chalk__rspack_import_0.chalkStderr.yellow("⚠")
8289
+ ], args);
8441
8290
  }
8442
8291
  error(...args) {
8443
- if (this.jsonMode) this.logJson("error", args.map(String).join(" "));
8444
- else this.log(chalk__rspack_import_0_default().red("✖"), ...args);
8292
+ this.logAt("error", [
8293
+ chalk__rspack_import_0.chalkStderr.red("✖")
8294
+ ], args);
8445
8295
  }
8446
8296
  success(message) {
8447
- if (this.jsonMode) this.logJson("info", message);
8448
- else this.log(chalk__rspack_import_0_default().green("✔"), message);
8297
+ this.logAt("info", [
8298
+ chalk__rspack_import_0.chalkStderr.green("✔")
8299
+ ], [
8300
+ message
8301
+ ]);
8449
8302
  }
8450
8303
  progress(key, message) {
8451
- if (this.jsonMode) writeJson({
8452
- type: "progress",
8453
- key,
8454
- status: "start",
8455
- message,
8456
- timestamp: timestamp()
8457
- });
8458
- else this.log(chalk__rspack_import_0_default().blue("→"), chalk__rspack_import_0_default().blue(message));
8304
+ if (this.paused) return;
8305
+ if (this.jsonMode) this.writeProgressJson(key, "start", message);
8306
+ else this.showProgressStart(key, message);
8459
8307
  }
8460
8308
  progressUpdate(key, message) {
8461
- if (this.jsonMode) writeJson({
8462
- type: "progress",
8463
- key,
8464
- status: "update",
8465
- message,
8466
- timestamp: timestamp()
8467
- });
8468
- else this.log(chalk__rspack_import_0_default().blue("→"), chalk__rspack_import_0_default().blue(message));
8309
+ if (this.paused) return;
8310
+ if (this.jsonMode) this.writeProgressJson(key, "update", message);
8311
+ else this.showProgressUpdate(key, message);
8469
8312
  }
8470
8313
  progressEnd(key, message) {
8471
- if (this.jsonMode) writeJson({
8472
- type: "progress",
8473
- key,
8474
- status: "end",
8475
- message: message || "",
8476
- timestamp: timestamp()
8477
- });
8478
- else if (message) this.log(chalk__rspack_import_0_default().green("✔"), message);
8314
+ if (this.paused) return;
8315
+ if (this.jsonMode) this.writeProgressJson(key, "end", message || "");
8316
+ else this.showProgressEnd(key, message);
8317
+ }
8318
+ showProgressStart(_key, message) {
8319
+ this.write(chalk__rspack_import_0.chalkStderr.blue("→"), chalk__rspack_import_0.chalkStderr.blue(message));
8320
+ }
8321
+ showProgressUpdate(_key, message) {
8322
+ this.write(chalk__rspack_import_0.chalkStderr.blue("→"), chalk__rspack_import_0.chalkStderr.blue(message));
8323
+ }
8324
+ showProgressEnd(_key, message) {
8325
+ if (message) this.write(chalk__rspack_import_0.chalkStderr.green("✔"), message);
8479
8326
  }
8480
8327
  pause() {
8481
8328
  this.paused = true;
@@ -8483,10 +8330,6 @@ var __webpack_modules__ = {
8483
8330
  resume() {
8484
8331
  this.paused = false;
8485
8332
  }
8486
- async prompt(questions, options) {
8487
- (0, _globalConfig__rspack_import_2.lo)(options?.action ?? "Prompt", options?.nonInteractiveHint);
8488
- throw new Error("Prompting not supported in DefaultLogger. Use CLILogger for interactive prompts.");
8489
- }
8490
8333
  async confirm(message, defaultValue = true, options) {
8491
8334
  const answer = await this.prompt([
8492
8335
  {
@@ -8505,12 +8348,25 @@ var __webpack_modules__ = {
8505
8348
  name: "value",
8506
8349
  message,
8507
8350
  choices,
8508
- default: defaultValue
8351
+ default: defaultValue,
8352
+ loop: false
8509
8353
  }
8510
8354
  ], options);
8511
8355
  return answer.value;
8512
8356
  }
8513
8357
  }
8358
+ class DefaultLogger extends BaseLogger {
8359
+ isDebugEnabled() {
8360
+ return super.isDebugEnabled() && !(0, _config__rspack_import_1.Wj)();
8361
+ }
8362
+ isVerboseEnabled() {
8363
+ return super.isVerboseEnabled() && !(0, _config__rspack_import_1.Wj)();
8364
+ }
8365
+ async prompt(questions, options) {
8366
+ (0, _globalConfig__rspack_import_2.lo)(options?.action ?? "Prompt", options?.nonInteractiveHint);
8367
+ throw new Error("Prompting not supported in DefaultLogger. Use CLILogger for interactive prompts.");
8368
+ }
8369
+ }
8514
8370
  let logger = new DefaultLogger();
8515
8371
  function setLogger(newLogger) {
8516
8372
  logger = newLogger;
@@ -8544,7 +8400,6 @@ var __webpack_modules__ = {
8544
8400
  var external_path_ = __webpack_require__("path");
8545
8401
  var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_);
8546
8402
  var esm = __webpack_require__("./node_modules/.pnpm/simple-git@3.30.0/node_modules/simple-git/dist/esm/index.js");
8547
- var CLILogger = __webpack_require__("./src/CLILogger.ts");
8548
8403
  var src_appRoot = __webpack_require__("./src/appRoot.ts");
8549
8404
  var external_node_util_ = __webpack_require__("node:util");
8550
8405
  var external_fs_ = __webpack_require__("fs");
@@ -11052,13 +10907,13 @@ var __webpack_modules__ = {
11052
10907
  }
11053
10908
  return renames;
11054
10909
  }
11055
- async getHeadAnvilYaml() {
10910
+ async getCommittedAnvilYaml(version) {
11056
10911
  try {
11057
- const content = await this.config.gitService.show("HEAD:anvil.yaml");
10912
+ const content = await this.config.gitService.show(`${version}:anvil.yaml`);
11058
10913
  const parsedYaml = external_js_yaml_.load(content);
11059
10914
  if (!parsedYaml || "object" != typeof parsedYaml) return null;
11060
10915
  try {
11061
- const requirements = await this.config.gitService.show("HEAD:server_code/requirements.txt");
10916
+ const requirements = await this.config.gitService.show(`${version}:server_code/requirements.txt`);
11062
10917
  parsedYaml.runtime_options = {
11063
10918
  ...parsedYaml.runtime_options ?? {},
11064
10919
  server_spec: {
@@ -11072,7 +10927,22 @@ var __webpack_modules__ = {
11072
10927
  return null;
11073
10928
  }
11074
10929
  }
10930
+ async getAnvilYamlUpdates(previousYaml) {
10931
+ const changes = await getAnvilYamlChanges(this.config.repoPath, previousYaml, {
10932
+ logger: this.logger
10933
+ });
10934
+ return changes.map(({ key, value })=>{
10935
+ this.logger.verbose(` ✓ anvil.yaml[${key}] → [["${key}"], ...]`);
10936
+ return [
10937
+ [
10938
+ key
10939
+ ],
10940
+ value
10941
+ ];
10942
+ });
10943
+ }
11075
10944
  async processBatchedChanges(changes) {
10945
+ const version = this.config.getCommitId();
11076
10946
  const saveArray = [];
11077
10947
  const originalFilePaths = [];
11078
10948
  let anvilYamlDependenciesChanged = false;
@@ -11081,10 +10951,8 @@ var __webpack_modules__ = {
11081
10951
  });
11082
10952
  for (const change of deduplicatedChanges){
11083
10953
  if ("anvil.yaml" === change.path) {
11084
- const previousAnvilYaml = await this.getHeadAnvilYaml();
11085
- const anvilChanges = await getAnvilYamlChanges(this.config.repoPath, previousAnvilYaml, {
11086
- logger: this.logger
11087
- });
10954
+ const previousAnvilYaml = await this.getCommittedAnvilYaml(version);
10955
+ const anvilChanges = await this.getAnvilYamlUpdates(previousAnvilYaml);
11088
10956
  const previousDependencies = (0, depsCache.R_)(previousAnvilYaml?.dependencies);
11089
10957
  const currentDependencies = await (0, depsCache.no)(this.config.repoPath);
11090
10958
  if (!(0, depsCache.DX)(previousDependencies, currentDependencies)) anvilYamlDependenciesChanged = true;
@@ -11092,15 +10960,7 @@ var __webpack_modules__ = {
11092
10960
  this.logger.verbose(" Ignoring anvil.yaml: No changes detected");
11093
10961
  continue;
11094
10962
  }
11095
- for (const { key, value } of anvilChanges){
11096
- saveArray.push([
11097
- [
11098
- key
11099
- ],
11100
- value
11101
- ]);
11102
- this.logger.verbose(` ✓ anvil.yaml[${key}] → [["${key}"], ...]`);
11103
- }
10963
+ saveArray.push(...anvilChanges);
11104
10964
  originalFilePaths.push(change.path);
11105
10965
  continue;
11106
10966
  }
@@ -11138,7 +10998,7 @@ var __webpack_modules__ = {
11138
10998
  reason: "No savable changes"
11139
10999
  };
11140
11000
  }
11141
- await this.sendSavesToAnvil(saveArray, originalFilePaths);
11001
+ await this.sendSavesToAnvil(saveArray, originalFilePaths, version);
11142
11002
  return {
11143
11003
  skipped: false,
11144
11004
  anvilYamlDependenciesChanged
@@ -11158,14 +11018,14 @@ var __webpack_modules__ = {
11158
11018
  const changeDesc = "rename" === change.type && change.from ? `${change.from} → ${change.path}` : change.path;
11159
11019
  this.logger.verbose(` ✓ ${changeDesc} → ${JSON.stringify(savePath)} → ${contentToLog}`);
11160
11020
  }
11161
- async sendSavesToAnvil(saveArray, originalFilePaths = [], retryCount = 0) {
11021
+ async sendSavesToAnvil(saveArray, originalFilePaths, version, retryCount = 0) {
11162
11022
  const fileCount = saveArray.length;
11163
11023
  const message = 1 === fileCount ? "Syncing to Anvil" : `Syncing ${fileCount} changes to Anvil`;
11164
11024
  this.progress.update("sync", message);
11165
11025
  const payload = {
11166
11026
  edit_session: this.config.editSession,
11167
11027
  save_sequence: this.saveSequence++,
11168
- version: this.config.getCommitId(),
11028
+ version,
11169
11029
  updates: saveArray
11170
11030
  };
11171
11031
  this.logger.debug((0, external_node_util_.format)("PAYLOAD:", JSON.stringify(this.sanitizePayload(payload), null, 2)));
@@ -11304,9 +11164,10 @@ var __webpack_modules__ = {
11304
11164
  ...conflicts
11305
11165
  ];
11306
11166
  if (0 === changesToSave.length) return;
11307
- const { newSaveArray, newFilePaths } = await this.rerouteChanges(changesToSave);
11167
+ const version = this.config.getCommitId();
11168
+ const { newSaveArray, newFilePaths } = await this.rerouteChanges(changesToSave, version);
11308
11169
  if (0 === newSaveArray.length) return;
11309
- await this.sendSavesToAnvil(newSaveArray, newFilePaths, retryCount + 1);
11170
+ await this.sendSavesToAnvil(newSaveArray, newFilePaths, version, retryCount + 1);
11310
11171
  }
11311
11172
  getConflictDiagnosticInfo(json_resp) {
11312
11173
  if (json_resp.overtaken) return {
@@ -11335,11 +11196,20 @@ var __webpack_modules__ = {
11335
11196
  }
11336
11197
  if (this.config.getCommitId() === commitIdBeforePostSaveSync) this.config.setCommitId(version);
11337
11198
  }
11338
- async rerouteChanges(changes) {
11199
+ async rerouteChanges(changes, version) {
11339
11200
  this.logger.verbose(`Re-routing ${changes.length} local change(s)...`);
11340
11201
  const newSaveArray = [];
11341
11202
  const newFilePaths = [];
11342
11203
  for (const change of changes){
11204
+ if ("anvil.yaml" === change.path) {
11205
+ if (this.config.stagedOnly) continue;
11206
+ const updates = await this.getAnvilYamlUpdates(await this.getCommittedAnvilYaml(version));
11207
+ if (updates.length > 0) {
11208
+ newSaveArray.push(...updates);
11209
+ newFilePaths.push(change.path);
11210
+ }
11211
+ continue;
11212
+ }
11343
11213
  const routeResult = await routeFileChange({
11344
11214
  relativePath: change.path,
11345
11215
  changeType: change.type,
@@ -11386,6 +11256,50 @@ var __webpack_modules__ = {
11386
11256
  }
11387
11257
  return normalized;
11388
11258
  }
11259
+ function isServiceList(value) {
11260
+ return Array.isArray(value) && value.every((service)=>"string" == typeof service?.source);
11261
+ }
11262
+ function isYamlMapping(value) {
11263
+ return null != value && Object.getPrototypeOf(value) === Object.prototype;
11264
+ }
11265
+ function mergeServiceAdditions(base, local, remote) {
11266
+ const before = base ?? [];
11267
+ const latest = remote ?? [];
11268
+ if (!isServiceList(before) || !isServiceList(local) || !isServiceList(latest)) return;
11269
+ const existingSources = new Set(before.map((service)=>service.source));
11270
+ const existing = local.filter((service)=>existingSources.has(service.source));
11271
+ if (!(0, utils.bD)(existing, before)) return;
11272
+ const remoteSources = new Set(latest.map((service)=>service.source));
11273
+ const additions = local.filter((service)=>!existingSources.has(service.source));
11274
+ const sharedSources = new Set(additions.map(({ source })=>source).filter((source)=>remoteSources.has(source)));
11275
+ const sharedAdditions = (services)=>services.filter(({ source })=>sharedSources.has(source));
11276
+ if (!(0, utils.bD)(sharedAdditions(additions), sharedAdditions(latest))) return;
11277
+ return [
11278
+ ...latest,
11279
+ ...additions.filter(({ source })=>!sharedSources.has(source))
11280
+ ];
11281
+ }
11282
+ function mergeAnvilYaml(baseContent, localContent, remoteContent) {
11283
+ if (baseContent === remoteContent) return localContent;
11284
+ const base = external_js_yaml_.load(baseContent);
11285
+ const local = external_js_yaml_.load(localContent);
11286
+ const remote = external_js_yaml_.load(remoteContent);
11287
+ if (!isYamlMapping(base) || !isYamlMapping(local) || !isYamlMapping(remote)) throw new Error("Cannot reconcile anvil.yaml: expected YAML mappings in the local and committed versions");
11288
+ const rebased = new Map(Object.entries(remote));
11289
+ for (const key of new Set([
11290
+ ...Object.keys(base),
11291
+ ...Object.keys(local)
11292
+ ]))if (!((0, utils.bD)(base[key], local[key]) || (0, utils.bD)(remote[key], local[key]))) if ((0, utils.bD)(base[key], remote[key])) if (Object.hasOwn(local, key)) rebased.set(key, local[key]);
11293
+ else rebased.delete(key);
11294
+ else {
11295
+ const services = "services" === key ? mergeServiceAdditions(base[key], local[key], remote[key]) : void 0;
11296
+ if (!services) throw new Error(`Cannot reconcile concurrent edits to anvil.yaml (${key})`);
11297
+ rebased.set(key, services);
11298
+ }
11299
+ const merged = Object.fromEntries(rebased);
11300
+ if ((0, utils.bD)(merged, local)) return localContent;
11301
+ return (0, utils.bD)(merged, remote) ? remoteContent : external_js_yaml_.dump(merged);
11302
+ }
11389
11303
  class SyncManager extends Emitter.v {
11390
11304
  logger;
11391
11305
  config;
@@ -11484,9 +11398,20 @@ var __webpack_modules__ = {
11484
11398
  }
11485
11399
  }
11486
11400
  async resetToFetchedAnvilRef(tempRef, oldCommitId, localChangesToPreserve) {
11401
+ const rebase = !this.config.stagedOnly && localChangesToPreserve.has("anvil.yaml") ? await this.prepareAnvilYamlRebase(tempRef) : void 0;
11487
11402
  await this.config.gitService.reset(tempRef, "mixed");
11403
+ if (rebase) try {
11404
+ const latestContent = await external_fs_.promises.readFile(rebase.manifestPath, "utf8");
11405
+ const merged = latestContent === rebase.localContent ? rebase.mergedContent : mergeAnvilYaml(rebase.baseContent, latestContent, rebase.remoteContent);
11406
+ if (merged !== latestContent) await external_fs_.promises.writeFile(rebase.manifestPath, merged);
11407
+ } catch (error) {
11408
+ await this.config.gitService.reset(rebase.baseCommit, "mixed");
11409
+ throw error;
11410
+ }
11488
11411
  const newCommitId = await this.config.gitService.getCommitId();
11489
- await this.config.gitService.checkout([
11412
+ await this.config.gitService.checkout(rebase ? [
11413
+ ".anvil_editor.yaml"
11414
+ ] : [
11490
11415
  ".anvil_editor.yaml",
11491
11416
  "anvil.yaml"
11492
11417
  ]);
@@ -11494,6 +11419,30 @@ var __webpack_modules__ = {
11494
11419
  await this.deleteFilesRemovedOnAnvilLocally(oldCommitId, newCommitId, localChangesToPreserve);
11495
11420
  await this.discardFormattingOnlyYamlChanges();
11496
11421
  }
11422
+ async prepareAnvilYamlRebase(remoteRef) {
11423
+ const baseCommit = await this.config.gitService.getCommitId();
11424
+ const [baseContent, remoteContent] = await Promise.all([
11425
+ this.config.gitService.show(`${baseCommit}:anvil.yaml`),
11426
+ this.config.gitService.show(`${remoteRef}:anvil.yaml`)
11427
+ ]);
11428
+ const manifestPath = external_path_default().join(this.config.repoPath, "anvil.yaml");
11429
+ let localContent;
11430
+ try {
11431
+ localContent = await external_fs_.promises.readFile(manifestPath, "utf8");
11432
+ } catch (error) {
11433
+ if ("ENOENT" === error.code) return;
11434
+ throw error;
11435
+ }
11436
+ const mergedContent = mergeAnvilYaml(baseContent, localContent, remoteContent);
11437
+ return {
11438
+ manifestPath,
11439
+ baseCommit,
11440
+ baseContent,
11441
+ remoteContent,
11442
+ localContent,
11443
+ mergedContent
11444
+ };
11445
+ }
11497
11446
  isCleanForFastForward(status) {
11498
11447
  return status.isClean && 0 === status.modified.length && 0 === status.notAdded.length && 0 === status.created.length && 0 === status.deleted.length && 0 === status.staged.length && 0 === status.renamed.length;
11499
11448
  }
@@ -11689,6 +11638,7 @@ var __webpack_modules__ = {
11689
11638
  username: this.username,
11690
11639
  gitService: this.gitService,
11691
11640
  editorYaml: this.editorYaml,
11641
+ stagedOnly: this.stagedOnly,
11692
11642
  getAuthToken: ()=>this.authToken,
11693
11643
  setAuthToken: (token)=>{
11694
11644
  this.authToken = token;
@@ -11744,6 +11694,7 @@ var __webpack_modules__ = {
11744
11694
  const status = await this.gitService.getStatus();
11745
11695
  const locallyChangedFiles = buildLocalChangesSet(status);
11746
11696
  if (!this.stagedOnly) for (const filePath of savedFilePaths)locallyChangedFiles.add(filePath);
11697
+ if (savedFilePaths.has("anvil.yaml")) locallyChangedFiles.delete("anvil.yaml");
11747
11698
  return this.syncManager.syncRemoteChanges(locallyChangedFiles);
11748
11699
  }
11749
11700
  async connectWebSocket() {
@@ -12718,11 +12669,9 @@ var __webpack_modules__ = {
12718
12669
  const browserPrompt = createBrowserLaunchPrompt(pkceFlow.authUrl.toString());
12719
12670
  let settled = false;
12720
12671
  let spinnerStarted = false;
12721
- src_logger.vF.info(external_chalk_default().dim(`Logging in to ${anvilUrl}`));
12722
- console.log();
12672
+ src_logger.vF.info(external_chalk_default().dim(`Logging in to ${anvilUrl}`) + "\n");
12723
12673
  src_logger.vF.info(external_chalk_default().dim("Visit:"), `${deviceAuth.verification_uri_complete || deviceAuth.verification_uri}`);
12724
- src_logger.vF.info(external_chalk_default().dim("Device code:"), `${deviceAuth.user_code}`);
12725
- console.log();
12674
+ src_logger.vF.info(external_chalk_default().dim("Device code:"), `${deviceAuth.user_code}\n`);
12726
12675
  src_logger.vF.info("OR Press ENTER to open a browser...");
12727
12676
  browserPrompt.waitForOpen.then((opened)=>{
12728
12677
  if (opened && !settled) {
@@ -13811,13 +13760,17 @@ var __webpack_modules__ = {
13811
13760
  src_logger.vF.warn(`App created and checked out at ${result.destinationPath}, but opening it failed: ${(0, errors.u1)(error)}`);
13812
13761
  }
13813
13762
  }
13814
- if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(true, {
13815
- data: result
13763
+ if ("destinationDisplay" in result) src_logger.vF.result(`${result.anvilUrl}/build/apps/${encodeURIComponent(result.appId)}`, {
13764
+ json: {
13765
+ data: result
13766
+ },
13767
+ note: `Created ${result.appName ?? result.appId} (${result.appId}) in ${result.destinationDisplay}`
13768
+ });
13769
+ else src_logger.vF.result(external_chalk_default().green("✔") + ` Created ${result.appName ?? result.appId} (${result.appId}) at ${result.editorUrl}`, {
13770
+ json: {
13771
+ data: result
13772
+ }
13816
13773
  });
13817
- else {
13818
- src_logger.vF.success("destinationDisplay" in result ? `Created ${result.appName ?? result.appId} (${result.appId}) in ${result.destinationDisplay}` : `Created ${result.appName ?? result.appId} (${result.appId}) at ${result.editorUrl}`);
13819
- if ("destinationDisplay" in result) src_logger.vF.info(`${result.anvilUrl}/build/apps/${encodeURIComponent(result.appId)}`);
13820
- }
13821
13774
  } catch (error) {
13822
13775
  const message = (0, errors.u1)(error);
13823
13776
  if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(false, {
@@ -14210,11 +14163,14 @@ var __webpack_modules__ = {
14210
14163
  gitAuthCommand.command("doctor").description("Diagnose why plain Git commands cannot authenticate to Anvil").option("--repo <PATH>", "Repository path to diagnose", process.cwd()).action(async (options)=>{
14211
14164
  try {
14212
14165
  const report = await buildGitAuthDoctorReport(options.repo || process.cwd());
14213
- if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)("error" !== report.status, {
14214
- data: report
14166
+ const success = "error" !== report.status;
14167
+ src_logger.vF.result(formatGitAuthDoctorReport(report), {
14168
+ success,
14169
+ json: {
14170
+ data: report
14171
+ }
14215
14172
  });
14216
- else src_logger.vF.info(formatGitAuthDoctorReport(report));
14217
- if ("error" === report.status) process.exitCode = 1;
14173
+ if (!success) process.exitCode = 1;
14218
14174
  } catch (e) {
14219
14175
  const message = redactSecrets(e.message);
14220
14176
  if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(false, {
@@ -15359,7 +15315,6 @@ var __webpack_modules__ = {
15359
15315
  function registerWatchCommand(program) {
15360
15316
  const watchCommand = addAppAccountOptions(program.command("watch [path]")).description("Watch for file changes and sync to Anvil").alias("sync").alias("w").option("-f, --first", "Auto-select first detected app ID without confirmation").option("-s, --staged-only", "Only sync staged changes (use git add to stage files)").option("--no-dependency-watch", "Do not watch and refresh .anvil/deps dependencies").option("-a, --auto", "Auto mode: restart on branch changes and sync when behind").option("-O, --open", "Open watched path in preferred editor (or default app)").action(async (path, options, command)=>{
15361
15317
  const globalOptions = command.optsWithGlobals();
15362
- if (void 0 !== globalOptions.verbose && src_logger.vF instanceof CLILogger.B) src_logger.vF.setVerbose(globalOptions.verbose);
15363
15318
  await handleWatchCommand({
15364
15319
  path,
15365
15320
  appid: options.appid,
@@ -15546,6 +15501,26 @@ var __webpack_modules__ = {
15546
15501
  values
15547
15502
  };
15548
15503
  }
15504
+ function formatConfigList(configData) {
15505
+ const separator = external_chalk_default().gray("─".repeat(50));
15506
+ const lines = [
15507
+ external_chalk_default().bold("\nConfiguration:"),
15508
+ separator
15509
+ ];
15510
+ const defaultHint = configData.anvilUrl.isDefault ? "" : external_chalk_default().gray(` (default: ${configData.anvilUrl.defaultValue})`);
15511
+ lines.push(external_chalk_default().cyan("anvilUrl") + ` = ${configData.anvilUrl.value}${defaultHint}`);
15512
+ if (configData.authTokens.totalUrls > 0) {
15513
+ lines.push(external_chalk_default().cyan("authTokens") + ` = ${external_chalk_default().gray(`${configData.authTokens.totalAccounts} logged-in account(s) across ${configData.authTokens.totalUrls} URL(s)`)}`);
15514
+ for (const account of configData.authTokens.accounts){
15515
+ const status = "config" === account.status ? external_chalk_default().green("✓ logged in (config)") : "keychain" === account.status ? external_chalk_default().green("✓ logged in (keychain)") : external_chalk_default().gray("(no tokens)");
15516
+ lines.push(external_chalk_default().gray(` ${account.url}: ${account.username} ${status}`));
15517
+ }
15518
+ } else lines.push(external_chalk_default().cyan("authTokens") + ` = ${external_chalk_default().gray("(none)")}`);
15519
+ for (const [key, value] of Object.entries(configData.values))if (null === value) lines.push(external_chalk_default().cyan(key) + ` = ${external_chalk_default().gray("null")}`);
15520
+ else lines.push(external_chalk_default().cyan(key) + ` = ${value}`);
15521
+ lines.push(separator, "");
15522
+ return lines;
15523
+ }
15549
15524
  function registerConfigCommand(program) {
15550
15525
  const configCommand = program.command("config").description("Manage configuration").alias("c");
15551
15526
  configCommand.command("get <key>").description("Get a configuration value").action(async (key)=>{
@@ -15555,7 +15530,14 @@ var __webpack_modules__ = {
15555
15530
  else {
15556
15531
  let displayValue;
15557
15532
  displayValue = "object" == typeof val && null !== val ? JSON.stringify(val, null, 2) : String(val);
15558
- src_logger.vF.info(external_chalk_default().green(`${key}: `) + external_chalk_default().bold(displayValue));
15533
+ src_logger.vF.result(external_chalk_default().green(`${key}: `) + external_chalk_default().bold(displayValue), {
15534
+ json: {
15535
+ data: {
15536
+ key,
15537
+ value: val
15538
+ }
15539
+ }
15540
+ });
15559
15541
  }
15560
15542
  } catch (e) {
15561
15543
  src_logger.vF.error("Error: " + e.message);
@@ -15585,24 +15567,11 @@ var __webpack_modules__ = {
15585
15567
  configCommand.command("list").description("List all configuration values").action(async ()=>{
15586
15568
  try {
15587
15569
  const configData = await getConfigListData();
15588
- if ((0, globalConfig.JP)().jsonMode) return void (0, src_logger.SP)(true, {
15589
- data: configData
15590
- });
15591
- console.log(external_chalk_default().bold("\nConfiguration:"));
15592
- console.log(external_chalk_default().gray("─".repeat(50)));
15593
- const defaultHint = configData.anvilUrl.isDefault ? "" : external_chalk_default().gray(` (default: ${configData.anvilUrl.defaultValue})`);
15594
- console.log(external_chalk_default().cyan("anvilUrl") + ` = ${configData.anvilUrl.value}${defaultHint}`);
15595
- if (configData.authTokens.totalUrls > 0) {
15596
- console.log(external_chalk_default().cyan("authTokens") + ` = ${external_chalk_default().gray(`${configData.authTokens.totalAccounts} logged-in account(s) across ${configData.authTokens.totalUrls} URL(s)`)}`);
15597
- for (const account of configData.authTokens.accounts){
15598
- const status = "config" === account.status ? external_chalk_default().green("✓ logged in (config)") : "keychain" === account.status ? external_chalk_default().green("✓ logged in (keychain)") : external_chalk_default().gray("(no tokens)");
15599
- console.log(external_chalk_default().gray(` ${account.url}: ${account.username} ${status}`));
15570
+ src_logger.vF.result(()=>formatConfigList(configData), {
15571
+ json: {
15572
+ data: configData
15600
15573
  }
15601
- } else console.log(external_chalk_default().cyan("authTokens") + ` = ${external_chalk_default().gray("(none)")}`);
15602
- for (const [key, value] of Object.entries(configData.values))if (null === value) console.log(external_chalk_default().cyan(key) + ` = ${external_chalk_default().gray("null")}`);
15603
- else console.log(external_chalk_default().cyan(key) + ` = ${value}`);
15604
- console.log(external_chalk_default().gray("─".repeat(50)));
15605
- console.log();
15574
+ });
15606
15575
  } catch (e) {
15607
15576
  src_logger.vF.error("Error: " + e.message);
15608
15577
  process.exit(1);
@@ -15695,13 +15664,13 @@ var __webpack_modules__ = {
15695
15664
  program.command("convert-template <file>").description("Convert an Anvil form template YAML file to HTML template format").option("-o, --output <path>", "Output HTML path").option("-f, --force", "Overwrite the output file if it already exists").option("--keep-source", "Keep the source YAML file after conversion").action(async (file, options)=>{
15696
15665
  try {
15697
15666
  const result = await convertTemplateFile(file, options);
15698
- if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(true, {
15699
- data: result
15667
+ const converted = `Converted ${result.source} to ${result.output}`;
15668
+ src_logger.vF.result(result.output, {
15669
+ json: {
15670
+ data: result
15671
+ },
15672
+ note: result.removedSource ? `${converted}\nRemoved source ${result.source}` : converted
15700
15673
  });
15701
- else {
15702
- src_logger.vF.success(`Converted ${result.source} to ${result.output}`);
15703
- if (result.removedSource) src_logger.vF.info(`Removed source ${result.source}`);
15704
- }
15705
15674
  } catch (error) {
15706
15675
  if (error instanceof ConvertTemplateValidationError) if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(false, {
15707
15676
  error: error.message,
@@ -15733,13 +15702,16 @@ var __webpack_modules__ = {
15733
15702
  function registerVersionCommand(program, version) {
15734
15703
  program.command("version").description("Show version information").action(()=>{
15735
15704
  const info = getVersionInfo(version);
15736
- if ((0, globalConfig.JP)().jsonMode) return void (0, src_logger.SP)(true, {
15737
- data: info
15705
+ src_logger.vF.result([
15706
+ external_chalk_default().cyan.bold(`\n⚙ anvil ${info.version}`),
15707
+ external_chalk_default().gray(` Node.js ${info.nodeVersion}`),
15708
+ external_chalk_default().gray(` Platform: ${info.platform} ${info.arch}`),
15709
+ ""
15710
+ ], {
15711
+ json: {
15712
+ data: info
15713
+ }
15738
15714
  });
15739
- console.log(external_chalk_default().cyan.bold(`\n⚙ anvil ${info.version}`));
15740
- console.log(external_chalk_default().gray(` Node.js ${info.nodeVersion}`));
15741
- console.log(external_chalk_default().gray(` Platform: ${info.platform} ${info.arch}`));
15742
- console.log();
15743
15715
  });
15744
15716
  }
15745
15717
  const configure_defaultDeps = {
@@ -15835,9 +15807,9 @@ var __webpack_modules__ = {
15835
15807
  }
15836
15808
  async function runConfigureFlow(version, deps = configure_defaultDeps) {
15837
15809
  (0, globalConfig.lo)("`anvil configure`", "Use `anvil config set anvilUrl <URL>`, `anvil config set preferredEditor <COMMAND>`, `anvil config set verbose <true|false>`, and `anvil login <URL>` instead.");
15838
- console.log();
15810
+ src_logger.vF.info("");
15839
15811
  src_logger.vF.info(external_chalk_default().cyan.bold("Anvil Configuration"));
15840
- console.log();
15812
+ src_logger.vF.info("");
15841
15813
  src_logger.vF.progress("configure-version", "Checking CLI version...");
15842
15814
  const versionStatus = await getConfigureVersionStatus(version, deps.getLatestVersion);
15843
15815
  src_logger.vF.progressEnd("configure-version");
@@ -15851,7 +15823,7 @@ var __webpack_modules__ = {
15851
15823
  if (!continueOnOldVersion) return void src_logger.vF.info("Configuration cancelled.");
15852
15824
  }
15853
15825
  } else src_logger.vF.warn("Could not determine latest published version.");
15854
- console.log();
15826
+ src_logger.vF.info("");
15855
15827
  const currentUrl = (0, src_config.mk)();
15856
15828
  src_logger.vF.info(external_chalk_default().gray("Leave this blank unless you're using a dedicated enterprise/on-prem Anvil installation."));
15857
15829
  const urlAnswer = await src_logger.vF.prompt([
@@ -15877,7 +15849,7 @@ var __webpack_modules__ = {
15877
15849
  const enableVerbose = await src_logger.vF.confirm("Enable verbose logging?", currentVerbose);
15878
15850
  (0, src_config.Nk)("verbose", enableVerbose);
15879
15851
  src_logger.vF.success(`Set verbose = ${enableVerbose}`);
15880
- console.log();
15852
+ src_logger.vF.info("");
15881
15853
  const existingAccounts = await deps.getAccountsForUrl(configuredAnvilUrl);
15882
15854
  if (existingAccounts.length > 0) src_logger.vF.success(`Already logged in to ${configuredAnvilUrl} as ${formatLoggedInAccounts(existingAccounts)}.`);
15883
15855
  else {
@@ -15887,7 +15859,7 @@ var __webpack_modules__ = {
15887
15859
  src_logger.vF.success("Logged in as " + external_chalk_default().bold(loginResult.email));
15888
15860
  } else src_logger.vF.warn("Skipping login.");
15889
15861
  }
15890
- console.log();
15862
+ src_logger.vF.info("");
15891
15863
  src_logger.vF.info(external_chalk_default().cyan("Next: anvil checkout"));
15892
15864
  src_logger.vF.info(external_chalk_default().gray("Run `anvil checkout` with no arguments to search and select your app."));
15893
15865
  src_logger.vF.success("Configuration complete.");
@@ -15929,9 +15901,19 @@ var __webpack_modules__ = {
15929
15901
  deps.command("status").description("Show cached dependencies").action(async ()=>{
15930
15902
  try {
15931
15903
  const cached = await getCachedPackages((0, src_appRoot.Q)());
15932
- if (!cached.length) return void src_logger.vF.info("No cached dependencies (run 'anvil deps fetch')");
15933
- src_logger.vF.info("Cached dependencies:");
15934
- for (const pkg of cached)src_logger.vF.info(` - ${pkg}`);
15904
+ const lines = cached.length ? [
15905
+ "Cached dependencies:",
15906
+ ...cached.map((pkg)=>` - ${pkg}`)
15907
+ ] : [
15908
+ "No cached dependencies (run 'anvil deps fetch')"
15909
+ ];
15910
+ src_logger.vF.result(lines, {
15911
+ json: {
15912
+ data: {
15913
+ packages: cached
15914
+ }
15915
+ }
15916
+ });
15935
15917
  } catch (e) {
15936
15918
  src_logger.vF.error(e.message);
15937
15919
  process.exit(1);
@@ -16056,13 +16038,15 @@ var __webpack_modules__ = {
16056
16038
  anvilUrl,
16057
16039
  username
16058
16040
  });
16059
- if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(true, {
16060
- data: {
16061
- url,
16062
- expires_at
16063
- }
16041
+ src_logger.vF.result(url, {
16042
+ json: {
16043
+ data: {
16044
+ url,
16045
+ expires_at
16046
+ }
16047
+ },
16048
+ note: `Expires at: ${expires_at}`
16064
16049
  });
16065
- else src_logger.vF.info(`URL: ${url}\nExpires at: ${expires_at}`);
16066
16050
  } catch (error) {
16067
16051
  const message = (0, errors.u1)(error);
16068
16052
  if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(false, {
@@ -16079,14 +16063,15 @@ var __webpack_modules__ = {
16079
16063
  anvilUrl,
16080
16064
  username
16081
16065
  });
16082
- if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(true, {
16083
- data: {
16084
- key,
16085
- url,
16086
- expires_at
16066
+ src_logger.vF.result(`Key: ${key}\nURL: ${url}\nExpires at: ${expires_at}`, {
16067
+ json: {
16068
+ data: {
16069
+ key,
16070
+ url,
16071
+ expires_at
16072
+ }
16087
16073
  }
16088
16074
  });
16089
- else src_logger.vF.info(`Key: ${key}\nURL: ${url}\nExpires at: ${expires_at}`);
16090
16075
  } catch (error) {
16091
16076
  const message = (0, errors.u1)(error);
16092
16077
  if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(false, {
@@ -17015,25 +17000,55 @@ Examples:
17015
17000
  await runTestCommand(targets, options);
17016
17001
  });
17017
17002
  }
17003
+ var external_os_ = __webpack_require__("os");
17004
+ async function getManagedNodeUpdate() {
17005
+ const anvilHome = process.env.ANVIL_HOME || (0, external_path_.join)((0, external_os_.homedir)(), ".anvil-cli");
17006
+ let executable;
17007
+ try {
17008
+ executable = (0, external_path_.relative)((0, external_fs_.realpathSync)(anvilHome), (0, external_fs_.realpathSync)(process.execPath)).split(external_path_.sep).join("/");
17009
+ } catch {
17010
+ return null;
17011
+ }
17012
+ if (!/^node-v(?:20|24)\/(?:bin\/node|node\.exe)$/i.test(executable)) return null;
17013
+ let latestVersion = null;
17014
+ try {
17015
+ const response = await fetch("https://nodejs.org/dist/latest-v24.x/SHASUMS256.txt", {
17016
+ signal: AbortSignal.timeout(5000)
17017
+ });
17018
+ if (response.ok) latestVersion = (await response.text()).match(/\bnode-(v24\.\d+\.\d+)-/)?.[1] ?? null;
17019
+ } catch {}
17020
+ const outdated = external_semver_default().major(process.version) < 24 || null !== latestVersion && external_semver_default().lt(process.version, latestVersion);
17021
+ return {
17022
+ currentVersion: process.version,
17023
+ latestVersion,
17024
+ status: outdated ? "update-available" : latestVersion ? "up-to-date" : "check-failed"
17025
+ };
17026
+ }
17018
17027
  var validate = __webpack_require__("./src/commands/validate.ts");
17019
17028
  var programBase = __webpack_require__("./src/programBase.ts");
17020
17029
  function getUpdateInstructions(platform) {
17021
- if ("win32" === platform) return [
17022
- "try { irm https://anvil.works/install-cli.ps1 | iex } catch { npm install -g @anvil-works/anvil-cli@latest }",
17023
- "curl -fsSL https://anvil.works/install-cli.cmd -o install.cmd && install.cmd && del install.cmd || npm install -g @anvil-works/anvil-cli@latest",
17030
+ return [
17031
+ ...getInstallerInstructions(platform),
17024
17032
  "npm install -g @anvil-works/anvil-cli@latest",
17025
17033
  "pnpm add -g @anvil-works/anvil-cli@latest"
17026
17034
  ];
17035
+ }
17036
+ function getInstallerInstructions(platform) {
17037
+ if ("win32" === platform) return [
17038
+ "irm https://anvil.works/install-cli.ps1 | iex",
17039
+ "curl -fsSL https://anvil.works/install-cli.cmd -o install.cmd && install.cmd && del install.cmd"
17040
+ ];
17027
17041
  return [
17028
- "curl -fsSL https://anvil.works/install-cli.sh | sh || npm install -g @anvil-works/anvil-cli@latest",
17029
- "npm install -g @anvil-works/anvil-cli@latest",
17030
- "pnpm add -g @anvil-works/anvil-cli@latest"
17042
+ "curl -fsSL https://anvil.works/install-cli.sh | sh"
17031
17043
  ];
17032
17044
  }
17033
17045
  async function handleUpdateCommand() {
17034
17046
  try {
17035
17047
  src_logger.vF.progress("update", "Checking for updates...");
17036
- const latestVersion = await (0, anvil_api.getLatestVersion)();
17048
+ const [latestVersion, nodeRuntime] = await Promise.all([
17049
+ (0, anvil_api.getLatestVersion)(),
17050
+ getManagedNodeUpdate()
17051
+ ]);
17037
17052
  src_logger.vF.progressEnd("update");
17038
17053
  if (!latestVersion) {
17039
17054
  src_logger.vF.warn("Could not check for updates. Please check your internet connection.");
@@ -17043,56 +17058,43 @@ Examples:
17043
17058
  src_logger.vF.warn("Could not compare versions. Version format may be invalid.");
17044
17059
  process.exit(1);
17045
17060
  }
17046
- if (external_semver_default().eq(programBase.xv, latestVersion)) {
17047
- if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(true, {
17048
- data: {
17049
- currentVersion: programBase.xv,
17050
- latestVersion,
17051
- status: "up-to-date"
17052
- }
17053
- });
17054
- else {
17055
- src_logger.vF.success(`You're already using the latest version: ${programBase.xv}`);
17056
- console.log();
17057
- }
17058
- return;
17059
- }
17060
- if (external_semver_default().gt(programBase.xv, latestVersion)) {
17061
- if ((0, globalConfig.JP)().jsonMode) (0, src_logger.SP)(true, {
17062
- data: {
17063
- currentVersion: programBase.xv,
17064
- latestVersion,
17065
- status: "ahead",
17066
- note: "This might be a development build."
17067
- }
17068
- });
17069
- else {
17070
- src_logger.vF.warn(`You're using version ${programBase.xv}, which is newer than the latest published version ${latestVersion}.`);
17071
- console.log(external_chalk_default().gray(" This might be a development build."));
17072
- console.log();
17073
- }
17074
- return;
17075
- }
17076
- const instructions = getUpdateInstructions(process.platform);
17061
+ const cliStatus = external_semver_default().eq(programBase.xv, latestVersion) ? "up-to-date" : external_semver_default().gt(programBase.xv, latestVersion) ? "ahead" : "update-available";
17062
+ const runtimeUpdateAvailable = nodeRuntime?.status === "update-available";
17063
+ const updateAvailable = "update-available" === cliStatus || runtimeUpdateAvailable;
17064
+ const instructions = runtimeUpdateAvailable ? getInstallerInstructions(process.platform) : getUpdateInstructions(process.platform);
17077
17065
  if ((0, globalConfig.JP)().jsonMode) return void (0, src_logger.SP)(true, {
17078
17066
  data: {
17079
17067
  currentVersion: programBase.xv,
17080
17068
  latestVersion,
17081
- status: "update-available",
17082
- instructions
17069
+ status: runtimeUpdateAvailable ? "update-available" : cliStatus,
17070
+ ..."ahead" === cliStatus ? {
17071
+ note: "This might be a development build."
17072
+ } : {},
17073
+ ...nodeRuntime ? {
17074
+ nodeRuntime
17075
+ } : {},
17076
+ ...updateAvailable ? {
17077
+ instructions
17078
+ } : {}
17083
17079
  }
17084
17080
  });
17085
- src_logger.vF.warn(`↑ Update available: ${programBase.xv} → ${latestVersion}`);
17086
- console.log();
17087
- console.log(external_chalk_default().cyan("To update, run one of the following commands:"));
17088
- console.log();
17081
+ if ("up-to-date" === cliStatus) src_logger.vF.success(`You're already using the latest CLI version: ${programBase.xv}`);
17082
+ else if ("ahead" === cliStatus) src_logger.vF.warn(`You're using version ${programBase.xv}, which is newer than the latest published version ${latestVersion}.\n` + external_chalk_default().gray(" This might be a development build."));
17083
+ else src_logger.vF.warn(`↑ Update available: ${programBase.xv} → ${latestVersion}`);
17084
+ if (runtimeUpdateAvailable) src_logger.vF.warn(`Bundled Node.js update available: ${nodeRuntime.currentVersion} → ${nodeRuntime.latestVersion ?? "Node.js 24 LTS"}`);
17085
+ else if (nodeRuntime?.status === "check-failed") src_logger.vF.warn("Could not check bundled Node.js for updates. Please check your internet connection.");
17086
+ if (!updateAvailable) return;
17087
+ (0, src_logger.jQ)(external_chalk_default().cyan(runtimeUpdateAvailable ? "To update bundled Node.js and the CLI, rerun the installer:" : "To update, run one of the following commands:"));
17088
+ (0, src_logger.jQ)();
17089
17089
  if ("win32" === process.platform) {
17090
- console.log(external_chalk_default().gray(" PowerShell: ") + external_chalk_default().white(instructions[0]));
17091
- console.log(external_chalk_default().gray(" CMD: ") + external_chalk_default().white(instructions[1]));
17092
- } else console.log(external_chalk_default().gray(" macOS/Linux: ") + external_chalk_default().white(instructions[0]));
17093
- console.log(external_chalk_default().gray(" npm: ") + external_chalk_default().white(instructions[instructions.length - 2]));
17094
- console.log(external_chalk_default().gray(" pnpm: ") + external_chalk_default().white(instructions[instructions.length - 1]));
17095
- console.log();
17090
+ (0, src_logger.jQ)(external_chalk_default().gray(" PowerShell: ") + external_chalk_default().white(instructions[0]));
17091
+ (0, src_logger.jQ)(external_chalk_default().gray(" CMD: ") + external_chalk_default().white(instructions[1]));
17092
+ } else (0, src_logger.jQ)(external_chalk_default().gray(" macOS/Linux: ") + external_chalk_default().white(instructions[0]));
17093
+ if (!runtimeUpdateAvailable) {
17094
+ (0, src_logger.jQ)(external_chalk_default().gray(" npm: ") + external_chalk_default().white(instructions[instructions.length - 2]));
17095
+ (0, src_logger.jQ)(external_chalk_default().gray(" pnpm: ") + external_chalk_default().white(instructions[instructions.length - 1]));
17096
+ }
17097
+ (0, src_logger.jQ)();
17096
17098
  } catch (e) {
17097
17099
  src_logger.vF.error("Error: " + e.message);
17098
17100
  process.exit(1);
@@ -17145,14 +17147,74 @@ Examples:
17145
17147
  const external_commander_namespaceObject = require("commander");
17146
17148
  var external_fs_ = __webpack_require__("fs");
17147
17149
  var external_path_ = __webpack_require__("path");
17148
- var CLILogger = __webpack_require__("./src/CLILogger.ts");
17149
17150
  var globalConfig = __webpack_require__("./src/globalConfig.ts");
17150
17151
  var logger = __webpack_require__("./src/logger.ts");
17152
+ class CLILogger extends logger.qM {
17153
+ spinners = new Map();
17154
+ activeProgressKeys = new Set();
17155
+ write(...args) {
17156
+ if (this.paused) return;
17157
+ const activeSpinners = [];
17158
+ for (const spinner of this.spinners.values())if (spinner.isSpinning) {
17159
+ spinner.stop();
17160
+ activeSpinners.push(spinner);
17161
+ }
17162
+ super.write(...args);
17163
+ for (const spinner of activeSpinners)spinner.start();
17164
+ }
17165
+ showProgressStart(key, message) {
17166
+ if (this.isVerboseEnabled()) {
17167
+ super.showProgressStart(key, message);
17168
+ this.activeProgressKeys.add(key);
17169
+ return;
17170
+ }
17171
+ const existing = this.spinners.get(key);
17172
+ if (existing) {
17173
+ existing.text = external_chalk_.chalkStderr.blue(message);
17174
+ existing.start();
17175
+ } else {
17176
+ const { default: ora } = __webpack_require__("ora");
17177
+ this.spinners.set(key, ora(external_chalk_.chalkStderr.blue(message)).start());
17178
+ }
17179
+ }
17180
+ showProgressUpdate(key, message) {
17181
+ if (this.isVerboseEnabled()) return void super.showProgressUpdate(key, message);
17182
+ const spinner = this.spinners.get(key);
17183
+ if (spinner) spinner.text = external_chalk_.chalkStderr.blue(message);
17184
+ }
17185
+ showProgressEnd(key, message) {
17186
+ if (this.isVerboseEnabled()) {
17187
+ if (this.activeProgressKeys.has(key)) super.showProgressEnd(key, message);
17188
+ this.activeProgressKeys.delete(key);
17189
+ return;
17190
+ }
17191
+ const spinner = this.spinners.get(key);
17192
+ if (spinner) {
17193
+ if (message) spinner.succeed(message);
17194
+ else spinner.stop();
17195
+ this.spinners.delete(key);
17196
+ }
17197
+ }
17198
+ pause() {
17199
+ super.pause();
17200
+ for (const spinner of this.spinners.values())spinner.stop();
17201
+ this.spinners.clear();
17202
+ this.activeProgressKeys.clear();
17203
+ }
17204
+ async prompt(questions, options) {
17205
+ (0, globalConfig.lo)(options?.action ?? "Prompt", options?.nonInteractiveHint);
17206
+ this.pause();
17207
+ try {
17208
+ const { default: inquirer } = await import("inquirer");
17209
+ return await inquirer.prompt(questions);
17210
+ } finally{
17211
+ this.resume();
17212
+ }
17213
+ }
17214
+ }
17151
17215
  const packageJson = JSON.parse((0, external_fs_.readFileSync)((0, external_path_.join)(__dirname, "../package.json"), "utf-8"));
17152
17216
  const VERSION = packageJson.version;
17153
- (0, logger.Br)(new CLILogger.B({
17154
- verbose: false
17155
- }));
17217
+ (0, logger.Br)(new CLILogger());
17156
17218
  process.on("unhandledRejection", (reason)=>{
17157
17219
  logger.vF.error(`Unexpected error: ${reason}`);
17158
17220
  process.exit(1);
@@ -17178,9 +17240,9 @@ Examples:
17178
17240
  program.name("anvil").description("CLI tool for developing Anvil apps locally").version(VERSION, "-v, --version", "Output the version number").option("--json", "Output in JSON format (NDJSON) for scripting/LLM consumption").option("-V, --verbose", "Show detailed output").helpOption('-h, --help', 'Display help for anvil command').hook("preAction", async (_thisCommand, actionCommand)=>{
17179
17241
  const opts = actionCommand.optsWithGlobals();
17180
17242
  (0, globalConfig.$O)({
17181
- jsonMode: !!opts.json
17243
+ jsonMode: !!opts.json,
17244
+ verbose: !!opts.verbose
17182
17245
  });
17183
- if (logger.vF instanceof CLILogger.B) logger.vF.setVerbose(!!opts.verbose);
17184
17246
  if (!opts.json) {
17185
17247
  const commandName = actionCommand?.name();
17186
17248
  if ("update" !== commandName && "git-credential" !== commandName) checkVersionAndWarn();