@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/command.loader.js +40 -20
- package/dist/command.loader.js.map +1 -1
- package/dist/nf.js +41 -21
- package/package.json +1 -1
package/dist/command.loader.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bgRgb, bold, green, red, yellow } from "ansis";
|
|
1
|
+
import { bgRgb, bold, cyan, green, red, yellow } from "ansis";
|
|
2
2
|
import { get } from "node-emoji";
|
|
3
3
|
import ora from "ora";
|
|
4
4
|
import { watch } from "chokidar";
|
|
@@ -12,7 +12,7 @@ import { Expose, Type, plainToInstance } from "class-transformer";
|
|
|
12
12
|
import { IsBoolean, IsEnum, IsNotEmpty, IsObject, IsOptional, IsPort, IsString, Matches, ValidateNested, validate } from "class-validator";
|
|
13
13
|
import { existsSync, readFileSync } from "node:fs";
|
|
14
14
|
import open from "open";
|
|
15
|
-
import { read,
|
|
15
|
+
import { read, readUserConfig, write, writeUserConfig } from "rc9";
|
|
16
16
|
import dotenv from "dotenv";
|
|
17
17
|
//#region src/lib/ui/emojis.ts
|
|
18
18
|
const Emojis = {
|
|
@@ -128,41 +128,43 @@ const getSpinner = (message) => ora({ text: message });
|
|
|
128
128
|
//#endregion
|
|
129
129
|
//#region src/lib/utils/errors.ts
|
|
130
130
|
var CLIError = class extends Error {
|
|
131
|
-
|
|
131
|
+
suggestion;
|
|
132
|
+
constructor(message, suggestion) {
|
|
132
133
|
super(message);
|
|
133
134
|
this.name = this.constructor.name;
|
|
135
|
+
this.suggestion = suggestion;
|
|
134
136
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
135
137
|
}
|
|
136
138
|
};
|
|
137
139
|
var ConfigNotFoundError = class extends CLIError {
|
|
138
140
|
constructor(configPath) {
|
|
139
|
-
super(`Configuration file not found at path: ${configPath}
|
|
141
|
+
super(`Configuration file not found at path: ${configPath}.`, "Please run 'nf new' or provide a valid --config path.");
|
|
140
142
|
}
|
|
141
143
|
};
|
|
142
144
|
var InvalidCommandArgumentError = class extends CLIError {
|
|
143
145
|
constructor(argName, expected) {
|
|
144
|
-
super(`Invalid argument '${argName}'. Expected: ${expected}
|
|
146
|
+
super(`Invalid argument '${argName}'. Expected: ${expected}.`, "Verify the command syntax using the --help flag.");
|
|
145
147
|
}
|
|
146
148
|
};
|
|
147
149
|
var RegistryAuthenticationError = class extends CLIError {
|
|
148
150
|
constructor() {
|
|
149
|
-
super("You must be logged in to perform this action. Run 'nf login'.");
|
|
151
|
+
super("You must be logged in to perform this action.", "Run 'nf login' to authenticate.");
|
|
150
152
|
}
|
|
151
153
|
};
|
|
152
154
|
var ManifestError = class extends CLIError {
|
|
153
155
|
constructor(detail) {
|
|
154
|
-
super(`Manifest Error: ${detail}
|
|
156
|
+
super(`Manifest Error: ${detail}`, "Check your nanoforge.manifest.json file for syntax or formatting errors.");
|
|
155
157
|
}
|
|
156
158
|
};
|
|
157
159
|
var FileSystemError = class extends CLIError {
|
|
158
160
|
constructor(action, targetPath) {
|
|
159
|
-
super(`File System Error [${action}]: ${targetPath}
|
|
161
|
+
super(`File System Error [${action}]: ${targetPath}`, "Verify your file permissions and ensure the path exists.");
|
|
160
162
|
}
|
|
161
163
|
};
|
|
162
164
|
var ApiRequestError = class extends CLIError {
|
|
163
165
|
constructor(status, cause) {
|
|
164
166
|
const causeStr = cause && typeof cause === "object" ? JSON.stringify(cause, null, 2) : cause;
|
|
165
|
-
super(`API Request failed (Status ${status})${causeStr ? `\nDetails: ${causeStr}` : ""}
|
|
167
|
+
super(`API Request failed (Status ${status})${causeStr ? `\nDetails: ${causeStr}` : ""}`, "Check your network connection, API key, or the registry status.");
|
|
166
168
|
}
|
|
167
169
|
};
|
|
168
170
|
const getErrorString = (error) => {
|
|
@@ -179,6 +181,7 @@ const handleActionError = (context, error) => {
|
|
|
179
181
|
console.error(red(context));
|
|
180
182
|
if (error instanceof CLIError) {
|
|
181
183
|
console.error(error.message);
|
|
184
|
+
if (error.suggestion) console.info(cyan(`\nš” Suggestion: ${error.suggestion}`));
|
|
182
185
|
process.exit(1);
|
|
183
186
|
}
|
|
184
187
|
const msg = getErrorMessage(error);
|
|
@@ -1364,20 +1367,34 @@ var DevAction = class extends AbstractAction {
|
|
|
1364
1367
|
async handle(_args, options) {
|
|
1365
1368
|
const directory = getDirectoryInput(options);
|
|
1366
1369
|
const generate = getDevGenerateInput(options);
|
|
1367
|
-
const
|
|
1370
|
+
const editor = getEditorInput(options);
|
|
1371
|
+
const tasks = this.buildTaskList(directory, generate, editor);
|
|
1368
1372
|
await Promise.all(tasks);
|
|
1369
1373
|
return { keepAlive: true };
|
|
1370
1374
|
}
|
|
1371
|
-
buildTaskList(directory, generate) {
|
|
1375
|
+
buildTaskList(directory, generate, editor) {
|
|
1372
1376
|
const tasks = [];
|
|
1373
|
-
|
|
1374
|
-
tasks.push(this.runSubCommand("
|
|
1377
|
+
const extraFlags = editor ? ["--editor"] : [];
|
|
1378
|
+
if (generate) tasks.push(this.runSubCommand("generate", directory, {
|
|
1379
|
+
silent: true,
|
|
1380
|
+
extraFlags
|
|
1381
|
+
}));
|
|
1382
|
+
tasks.push(this.runSubCommand("build", directory, {
|
|
1383
|
+
silent: true,
|
|
1384
|
+
extraFlags
|
|
1385
|
+
}));
|
|
1375
1386
|
tasks.push(this.runSubCommand("start", directory, { silent: false }));
|
|
1376
1387
|
return tasks;
|
|
1377
1388
|
}
|
|
1378
1389
|
async runSubCommand(command, directory, options) {
|
|
1379
1390
|
await runSafe(async () => {
|
|
1380
|
-
|
|
1391
|
+
const packageManager = await PackageManagerFactory.find(directory);
|
|
1392
|
+
const args = [
|
|
1393
|
+
command,
|
|
1394
|
+
"--watch",
|
|
1395
|
+
...options.extraFlags ?? []
|
|
1396
|
+
];
|
|
1397
|
+
await packageManager.runDev(directory, "nf", {}, args, options.silent);
|
|
1381
1398
|
});
|
|
1382
1399
|
}
|
|
1383
1400
|
};
|
|
@@ -1462,9 +1479,11 @@ const GLOBAL_CONFIG_DEFAULTS = {};
|
|
|
1462
1479
|
//#region src/lib/global-config/global-config-handler.ts
|
|
1463
1480
|
var GlobalConfigHandler = class {
|
|
1464
1481
|
static read(dir) {
|
|
1465
|
-
const
|
|
1466
|
-
if (
|
|
1467
|
-
|
|
1482
|
+
const dirConfig = this._readConfig(read, false, dir);
|
|
1483
|
+
if (dirConfig) return dirConfig;
|
|
1484
|
+
const cwdConfig = this._readConfig(read, false, process.cwd());
|
|
1485
|
+
if (cwdConfig) return cwdConfig;
|
|
1486
|
+
return this._readConfig(readUserConfig, true);
|
|
1468
1487
|
}
|
|
1469
1488
|
static write(config, local = false, dir) {
|
|
1470
1489
|
const options = {
|
|
@@ -1472,7 +1491,7 @@ var GlobalConfigHandler = class {
|
|
|
1472
1491
|
dir
|
|
1473
1492
|
};
|
|
1474
1493
|
if (local) write(config, options);
|
|
1475
|
-
else
|
|
1494
|
+
else writeUserConfig(config, options);
|
|
1476
1495
|
}
|
|
1477
1496
|
static _readConfig(func, force, dir) {
|
|
1478
1497
|
const res = func({
|
|
@@ -2212,11 +2231,12 @@ var CreateCommand = class extends AbstractCommand {
|
|
|
2212
2231
|
//#region src/command/commands/dev.command.ts
|
|
2213
2232
|
var DevCommand = class extends AbstractCommand {
|
|
2214
2233
|
load(program) {
|
|
2215
|
-
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) => {
|
|
2234
|
+
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) => {
|
|
2216
2235
|
const options = AbstractCommand.mapToInput({
|
|
2217
2236
|
directory: rawOptions.directory,
|
|
2218
2237
|
config: rawOptions.config,
|
|
2219
|
-
generate: rawOptions.generate
|
|
2238
|
+
generate: rawOptions.generate,
|
|
2239
|
+
editor: rawOptions.editor
|
|
2220
2240
|
});
|
|
2221
2241
|
await this.action.run(/* @__PURE__ */ new Map(), options);
|
|
2222
2242
|
});
|