@nanoforge-dev/cli 1.5.4-beta.5329236 → 1.5.4-beta.67c0eac

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/nf.js CHANGED
@@ -4,7 +4,7 @@ import "reflect-metadata";
4
4
  import { execSync, spawn } from "node:child_process";
5
5
  import fs, { existsSync } from "fs";
6
6
  import { join, posix, resolve } from "path";
7
- import { bgRgb, bold, green, red, yellow } from "ansis";
7
+ import { bgRgb, bold, cyan, green, red, yellow } from "ansis";
8
8
  import { get } from "node-emoji";
9
9
  import ora from "ora";
10
10
  import { watch } from "chokidar";
@@ -16,7 +16,7 @@ import { Expose, Type, plainToInstance } from "class-transformer";
16
16
  import { IsBoolean, IsEnum, IsNotEmpty, IsObject, IsOptional, IsPort, IsString, Matches, ValidateNested, validate } from "class-validator";
17
17
  import { existsSync as existsSync$1, readFileSync } from "node:fs";
18
18
  import open from "open";
19
- import { read, readUser, write, writeUser } from "rc9";
19
+ import { read, readUserConfig, write, writeUserConfig } from "rc9";
20
20
  import dotenv from "dotenv";
21
21
  //#region src/lib/tree-kill/tree-kill.ts
22
22
  const treeKill = (pid, signal) => {
@@ -234,41 +234,43 @@ const getSpinner = (message) => ora({ text: message });
234
234
  //#endregion
235
235
  //#region src/lib/utils/errors.ts
236
236
  var CLIError = class extends Error {
237
- constructor(message) {
237
+ suggestion;
238
+ constructor(message, suggestion) {
238
239
  super(message);
239
240
  this.name = this.constructor.name;
241
+ this.suggestion = suggestion;
240
242
  Object.setPrototypeOf(this, new.target.prototype);
241
243
  }
242
244
  };
243
245
  var ConfigNotFoundError = class extends CLIError {
244
246
  constructor(configPath) {
245
- super(`Configuration file not found at path: ${configPath}. Please run 'nf new' or provide a valid --config path.`);
247
+ super(`Configuration file not found at path: ${configPath}.`, "Please run 'nf new' or provide a valid --config path.");
246
248
  }
247
249
  };
248
250
  var InvalidCommandArgumentError = class extends CLIError {
249
251
  constructor(argName, expected) {
250
- super(`Invalid argument '${argName}'. Expected: ${expected}.`);
252
+ super(`Invalid argument '${argName}'. Expected: ${expected}.`, "Verify the command syntax using the --help flag.");
251
253
  }
252
254
  };
253
255
  var RegistryAuthenticationError = class extends CLIError {
254
256
  constructor() {
255
- super("You must be logged in to perform this action. Run 'nf login'.");
257
+ super("You must be logged in to perform this action.", "Run 'nf login' to authenticate.");
256
258
  }
257
259
  };
258
260
  var ManifestError = class extends CLIError {
259
261
  constructor(detail) {
260
- super(`Manifest Error: ${detail}`);
262
+ super(`Manifest Error: ${detail}`, "Check your nanoforge.manifest.json file for syntax or formatting errors.");
261
263
  }
262
264
  };
263
265
  var FileSystemError = class extends CLIError {
264
266
  constructor(action, targetPath) {
265
- super(`File System Error [${action}]: ${targetPath}`);
267
+ super(`File System Error [${action}]: ${targetPath}`, "Verify your file permissions and ensure the path exists.");
266
268
  }
267
269
  };
268
270
  var ApiRequestError = class extends CLIError {
269
271
  constructor(status, cause) {
270
272
  const causeStr = cause && typeof cause === "object" ? JSON.stringify(cause, null, 2) : cause;
271
- super(`API Request failed (Status ${status})${causeStr ? `\nDetails: ${causeStr}` : ""}`);
273
+ super(`API Request failed (Status ${status})${causeStr ? `\nDetails: ${causeStr}` : ""}`, "Check your network connection, API key, or the registry status.");
272
274
  }
273
275
  };
274
276
  const getErrorString = (error) => {
@@ -285,6 +287,7 @@ const handleActionError = (context, error) => {
285
287
  console.error(red(context));
286
288
  if (error instanceof CLIError) {
287
289
  console.error(error.message);
290
+ if (error.suggestion) console.info(cyan(`\nšŸ’” Suggestion: ${error.suggestion}`));
288
291
  process.exit(1);
289
292
  }
290
293
  const msg = getErrorMessage(error);
@@ -1470,20 +1473,34 @@ var DevAction = class extends AbstractAction {
1470
1473
  async handle(_args, options) {
1471
1474
  const directory = getDirectoryInput(options);
1472
1475
  const generate = getDevGenerateInput(options);
1473
- const tasks = this.buildTaskList(directory, generate);
1476
+ const editor = getEditorInput(options);
1477
+ const tasks = this.buildTaskList(directory, generate, editor);
1474
1478
  await Promise.all(tasks);
1475
1479
  return { keepAlive: true };
1476
1480
  }
1477
- buildTaskList(directory, generate) {
1481
+ buildTaskList(directory, generate, editor) {
1478
1482
  const tasks = [];
1479
- if (generate) tasks.push(this.runSubCommand("generate", directory, { silent: true }));
1480
- tasks.push(this.runSubCommand("build", directory, { silent: true }));
1483
+ const extraFlags = editor ? ["--editor"] : [];
1484
+ if (generate) tasks.push(this.runSubCommand("generate", directory, {
1485
+ silent: true,
1486
+ extraFlags
1487
+ }));
1488
+ tasks.push(this.runSubCommand("build", directory, {
1489
+ silent: true,
1490
+ extraFlags
1491
+ }));
1481
1492
  tasks.push(this.runSubCommand("start", directory, { silent: false }));
1482
1493
  return tasks;
1483
1494
  }
1484
1495
  async runSubCommand(command, directory, options) {
1485
1496
  await runSafe(async () => {
1486
- await (await PackageManagerFactory.find(directory)).runDev(directory, "nf", {}, [command, "--watch"], options.silent);
1497
+ const packageManager = await PackageManagerFactory.find(directory);
1498
+ const args = [
1499
+ command,
1500
+ "--watch",
1501
+ ...options.extraFlags ?? []
1502
+ ];
1503
+ await packageManager.runDev(directory, "nf", {}, args, options.silent);
1487
1504
  });
1488
1505
  }
1489
1506
  };
@@ -1568,9 +1585,11 @@ const GLOBAL_CONFIG_DEFAULTS = {};
1568
1585
  //#region src/lib/global-config/global-config-handler.ts
1569
1586
  var GlobalConfigHandler = class {
1570
1587
  static read(dir) {
1571
- const localConfig = this._readConfig(read, false, dir);
1572
- if (localConfig) return localConfig;
1573
- return this._readConfig(readUser, true);
1588
+ const dirConfig = this._readConfig(read, false, dir);
1589
+ if (dirConfig) return dirConfig;
1590
+ const cwdConfig = this._readConfig(read, false, process.cwd());
1591
+ if (cwdConfig) return cwdConfig;
1592
+ return this._readConfig(readUserConfig, true);
1574
1593
  }
1575
1594
  static write(config, local = false, dir) {
1576
1595
  const options = {
@@ -1578,7 +1597,7 @@ var GlobalConfigHandler = class {
1578
1597
  dir
1579
1598
  };
1580
1599
  if (local) write(config, options);
1581
- else writeUser(config, options);
1600
+ else writeUserConfig(config, options);
1582
1601
  }
1583
1602
  static _readConfig(func, force, dir) {
1584
1603
  const res = func({
@@ -2318,11 +2337,12 @@ var CreateCommand = class extends AbstractCommand {
2318
2337
  //#region src/command/commands/dev.command.ts
2319
2338
  var DevCommand = class extends AbstractCommand {
2320
2339
  load(program) {
2321
- program.command("dev").description("run your game in dev mode").option("-d, --directory <directory>", "specify the working directory of the command").option("-c, --config <config>", "path to the config file", CONFIG_FILE_NAME).option("--generate", "generate app from config", false).action(async (rawOptions) => {
2340
+ program.command("dev").description("run your game in dev mode").option("-d, --directory <directory>", "specify the working directory of the command").option("-c, --config <config>", "path to the config file", CONFIG_FILE_NAME).option("--generate", "generate app from config", false).option("-e, --editor", "run the editor", false).action(async (rawOptions) => {
2322
2341
  const options = AbstractCommand.mapToInput({
2323
2342
  directory: rawOptions.directory,
2324
2343
  config: rawOptions.config,
2325
- generate: rawOptions.generate
2344
+ generate: rawOptions.generate,
2345
+ editor: rawOptions.editor
2326
2346
  });
2327
2347
  await this.action.run(/* @__PURE__ */ new Map(), options);
2328
2348
  });
@@ -2492,7 +2512,7 @@ var CommandLoader = class {
2492
2512
  };
2493
2513
  //#endregion
2494
2514
  //#region package.json
2495
- var version = "1.5.4-beta.5329236";
2515
+ var version = "1.5.4-beta.67c0eac";
2496
2516
  //#endregion
2497
2517
  //#region src/bin/nf.ts
2498
2518
  const bootstrap = async () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@nanoforge-dev/cli",
4
- "version": "1.5.4-beta.5329236",
4
+ "version": "1.5.4-beta.67c0eac",
5
5
  "description": "NanoForge CLI",
6
6
  "keywords": [
7
7
  "nanoforge",