@nanoforge-dev/cli 1.5.4-beta.f618d37 → 1.6.1-alpha.upgrade-schematics.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.
@@ -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, readUser, write, writeUser } from "rc9";
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 = {
@@ -855,7 +855,7 @@ const runSafe = async (fn, fallback) => {
855
855
  }
856
856
  };
857
857
  //#endregion
858
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
858
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
859
859
  function __decorate(decorators, target, key, desc) {
860
860
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
861
861
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -964,12 +964,21 @@ __decorate([
964
964
  Type(() => DirsConfig),
965
965
  ValidateNested()
966
966
  ], ServerConfig.prototype, "dirs", void 0);
967
+ var SslConfig = class {
968
+ enable;
969
+ cert;
970
+ key;
971
+ };
972
+ __decorate([Expose(), IsBoolean()], SslConfig.prototype, "enable", void 0);
973
+ __decorate([Expose(), IsString()], SslConfig.prototype, "cert", void 0);
974
+ __decorate([Expose(), IsString()], SslConfig.prototype, "key", void 0);
967
975
  var Config = class {
968
976
  name;
969
977
  language;
970
978
  initFunctions;
971
979
  client;
972
980
  server;
981
+ ssl;
973
982
  };
974
983
  __decorate([
975
984
  Expose(),
@@ -988,6 +997,11 @@ __decorate([
988
997
  Type(() => ServerConfig),
989
998
  ValidateNested()
990
999
  ], Config.prototype, "server", void 0);
1000
+ __decorate([
1001
+ Expose(),
1002
+ Type(() => SslConfig),
1003
+ ValidateNested()
1004
+ ], Config.prototype, "ssl", void 0);
991
1005
  //#endregion
992
1006
  //#region src/lib/constants.ts
993
1007
  const CONFIG_FILE_NAME = "nanoforge.config.json";
@@ -1014,6 +1028,11 @@ const CONFIG_DEFAULTS = {
1014
1028
  name: "nanoforge-app",
1015
1029
  language: "ts",
1016
1030
  initFunctions: true,
1031
+ ssl: {
1032
+ enable: false,
1033
+ cert: "",
1034
+ key: ""
1035
+ },
1017
1036
  client: {
1018
1037
  enable: true,
1019
1038
  port: "3000",
@@ -1200,10 +1219,14 @@ var AbstractCollection = class {
1200
1219
  onFail
1201
1220
  });
1202
1221
  }
1203
- buildCommandLine(name, options, flags = []) {
1222
+ buildCommandLine(name, options, flags = [
1223
+ "--no-dry-run",
1224
+ "--allow-private",
1225
+ "--no-debug"
1226
+ ]) {
1204
1227
  return [
1205
- `${this.collection}:${name}`,
1206
1228
  ...flags,
1229
+ `'${getModulePath(this.collection + "/collection.json")}:${name}'`,
1207
1230
  ...this.serializeOptions(options)
1208
1231
  ];
1209
1232
  }
@@ -1407,9 +1430,11 @@ var EditorAction = class extends AbstractAction {
1407
1430
  async handle(args, options) {
1408
1431
  const directory = getDirectoryInput(options);
1409
1432
  const path = getPathInput(args);
1410
- const open = getEditorOpenInput(options, !!path);
1433
+ const shouldOpen = getEditorOpenInput(options, !!path);
1434
+ const url = `http://localhost:3000/load-project${path ? `?projectPath=${encodeURIComponent(path)}` : ""}`;
1435
+ console.log(`\nšŸ”— Editor running! Open it in your browser: \x1b[36m${url}\x1b[0m\n`);
1411
1436
  this.startEditor(directory);
1412
- if (open) await this.openEditor(path);
1437
+ if (shouldOpen) await this.openBrowser(url);
1413
1438
  return { keepAlive: true };
1414
1439
  }
1415
1440
  async startEditor(directory) {
@@ -1418,8 +1443,8 @@ var EditorAction = class extends AbstractAction {
1418
1443
  await PackageManagerFactory.create("local_bun").run("Editor", directory, editorPath, [], {}, [], true);
1419
1444
  });
1420
1445
  }
1421
- async openEditor(path) {
1422
- await open(`http://localhost:3000/load-project${path ? `?projectPath=${encodeURIComponent(path)}` : ""}`);
1446
+ async openBrowser(url) {
1447
+ await open(url);
1423
1448
  }
1424
1449
  };
1425
1450
  //#endregion
@@ -1479,9 +1504,11 @@ const GLOBAL_CONFIG_DEFAULTS = {};
1479
1504
  //#region src/lib/global-config/global-config-handler.ts
1480
1505
  var GlobalConfigHandler = class {
1481
1506
  static read(dir) {
1482
- const localConfig = this._readConfig(read, false, dir);
1483
- if (localConfig) return localConfig;
1484
- return this._readConfig(readUser, true);
1507
+ const dirConfig = this._readConfig(read, false, dir);
1508
+ if (dirConfig) return dirConfig;
1509
+ const cwdConfig = this._readConfig(read, false, process.cwd());
1510
+ if (cwdConfig) return cwdConfig;
1511
+ return this._readConfig(readUserConfig, true);
1485
1512
  }
1486
1513
  static write(config, local = false, dir) {
1487
1514
  const options = {
@@ -1489,7 +1516,7 @@ var GlobalConfigHandler = class {
1489
1516
  dir
1490
1517
  };
1491
1518
  if (local) write(config, options);
1492
- else writeUser(config, options);
1519
+ else writeUserConfig(config, options);
1493
1520
  }
1494
1521
  static _readConfig(func, force, dir) {
1495
1522
  const res = func({
@@ -2068,7 +2095,7 @@ var StartAction = class extends AbstractAction {
2068
2095
  const serverDir = getStringInputWithDefault(options, "serverDir", config.server.outDir);
2069
2096
  const watch = getWatchInput(options);
2070
2097
  const port = getStringInputWithDefault(options, "port", config.client.port);
2071
- const ssl = this.resolveSSL(options);
2098
+ const ssl = this.resolveSSL(options, config);
2072
2099
  const tasks = this.buildStartTasks(config, directory, {
2073
2100
  clientDir,
2074
2101
  serverDir,
@@ -2079,12 +2106,14 @@ var StartAction = class extends AbstractAction {
2079
2106
  await Promise.all(tasks);
2080
2107
  return { keepAlive: true };
2081
2108
  }
2082
- resolveSSL(options) {
2083
- const cert = getStringInput(options, "cert");
2084
- const key = getStringInput(options, "key");
2085
- if (!cert && !key) return void 0;
2086
- if (!cert) throw new CLIError("No cert entered for SSL. Please enter a cert with --cert.");
2087
- if (!key) throw new CLIError("No key entered for SSL. Please enter a key with --key.");
2109
+ resolveSSL(options, config) {
2110
+ const cliCert = getStringInput(options, "cert");
2111
+ const cliKey = getStringInput(options, "key");
2112
+ if (!Boolean(cliCert || cliKey || config.ssl?.enable)) return void 0;
2113
+ const cert = cliCert ? cliCert : config.ssl?.cert;
2114
+ const key = cliKey ? cliKey : config.ssl?.key;
2115
+ if (!cert) throw new CLIError("No certificate found for SSL.", "Please provide a certificate path with --cert or configure 'ssl.cert' in your nanoforge.config.json.");
2116
+ if (!key) throw new CLIError("No key found for SSL.", "Please provide a key path with --key or configure 'ssl.key' in your nanoforge.config.json.");
2088
2117
  return {
2089
2118
  cert,
2090
2119
  key