@arkstack/console-slim 0.12.35 → 0.12.37

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.
@@ -1,7 +1,7 @@
1
+ import { existsSync } from "node:fs";
1
2
  import path, { isAbsolute, join } from "node:path";
2
3
  import { Arkstack } from "@arkstack/contract";
3
4
  import { CliApp } from "resora";
4
- import { existsSync } from "node:fs";
5
5
 
6
6
  //#region dist/config.js
7
7
  const defaultConfig = (app) => {
package/dist/app.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as resolveStubsDir, t as ArkstackConsoleApp } from "./app-Co9YdqkD.js";
1
+ import { n as resolveStubsDir, t as ArkstackConsoleApp } from "./app-6GsnmZ2-.js";
2
2
 
3
3
  export { ArkstackConsoleApp, resolveStubsDir };
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { t as ArkstackConsoleApp } from "./app-Co9YdqkD.js";
3
- import { config, env, importFile, loadPrototypes, outputDir } from "@arkstack/common";
2
+ import { t as ArkstackConsoleApp } from "./app-6GsnmZ2-.js";
3
+ import { config, discoverCommands, env, importFile, loadPrototypes, outputDir, rebuildOutput } from "@arkstack/common";
4
+ import { existsSync, realpathSync } from "node:fs";
4
5
  import { fileURLToPath, pathToFileURL } from "node:url";
5
6
  import path, { join } from "node:path";
6
7
  import { Arkstack } from "@arkstack/contract";
7
8
  import { MakeResource } from "resora";
8
- import { realpathSync } from "node:fs";
9
9
  import { Command, Kernel } from "@h3ravel/musket";
10
10
  import { spawn } from "node:child_process";
11
11
  import { resolve } from "path";
@@ -196,14 +196,37 @@ var logo_default = String.raw`
196
196
 
197
197
  //#endregion
198
198
  //#region dist/index.js
199
- /**
200
- * Loads the core application instance by importing the bootstrap file.
199
+ /**
200
+ * A missing-module error from importing a stale/incomplete build artifact.
201
201
  *
202
+ * @param error
202
203
  * @returns
203
204
  */
205
+ const isMissingModuleError = (error) => {
206
+ const code = error?.code;
207
+ return code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND";
208
+ };
209
+ /**
210
+ * Loads the core application instance by importing the built bootstrap file.
211
+ *
212
+ * The kernel boots this for every command — including `build` — before the build
213
+ * can run, so a stale or incomplete build artifact (source changed since the last
214
+ * build: a module moved, renamed, or added) would otherwise wedge startup with
215
+ * `Cannot find module '<outDir>/...'`. When that happens and source is present,
216
+ * regenerate the output once and retry.
217
+ *
218
+ * @returns
219
+ */
204
220
  const loadCoreApp = async () => {
205
221
  const dist = path.relative(Arkstack.rootDir(), outputDir());
206
- return (await importFile(join(Arkstack.rootDir(), `${dist}/core/bootstrap.js`))).app;
222
+ const bootstrapPath = join(Arkstack.rootDir(), `${dist}/core/bootstrap.js`);
223
+ try {
224
+ return (await importFile(bootstrapPath)).app;
225
+ } catch (error) {
226
+ if (!isMissingModuleError(error) || !existsSync(join(Arkstack.rootDir(), "src"))) throw error;
227
+ await rebuildOutput();
228
+ return (await importFile(bootstrapPath)).app;
229
+ }
207
230
  };
208
231
  /**
209
232
  * Runs the console kernel, initializing the application and registering commands.
@@ -213,12 +236,12 @@ const loadCoreApp = async () => {
213
236
  const runConsoleKernel = async (options = {}) => {
214
237
  loadPrototypes();
215
238
  const app = await loadCoreApp();
216
- const dist = path.relative(Arkstack.rootDir(), outputDir());
217
239
  const stubsDir = process.env.ARKSTACK_STUBS_DIR;
218
240
  globalThis.app = () => app;
219
241
  globalThis.env = env;
220
242
  globalThis.config = config;
221
243
  globalThis.arkctx = { runtime: "CLI" };
244
+ const userCommands = await discoverCommands();
222
245
  await Kernel.init(await new ArkstackConsoleApp(app, { stubsDir }).loadConfig(), {
223
246
  logo: options.logo ?? logo_default,
224
247
  name: "Cmd",
@@ -229,16 +252,10 @@ const runConsoleKernel = async (options = {}) => {
229
252
  MakeFullResource,
230
253
  DevCommand,
231
254
  BuildCommand,
232
- MakeCommand
233
- ],
234
- discoveryPaths: [
235
- join(Arkstack.rootDir(), "src", "app", "console", "commands/*.js"),
236
- join(Arkstack.rootDir(), "src", "app/console/commands/*.js"),
237
- join(Arkstack.rootDir(), "src", "app/console/commands/*.mjs"),
238
- join(Arkstack.rootDir(), dist, "app/console/commands/*.js"),
239
- join(Arkstack.rootDir(), dist, "app/console/commands/*.mjs"),
240
- join(Arkstack.rootDir(), "node_modules", "@arkstack/*", "dist", "commands", "*.js")
255
+ MakeCommand,
256
+ ...userCommands
241
257
  ],
258
+ discoveryPaths: [join(Arkstack.rootDir(), "node_modules", "@arkstack/*", "dist", "commands", "*.js")],
242
259
  exceptionHandler(exception) {
243
260
  throw exception;
244
261
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/console-slim",
3
- "version": "0.12.35",
3
+ "version": "0.12.37",
4
4
  "type": "module",
5
5
  "description": "Slim console module for Arkstack, providing the command-line runtime and console integration layer.",
6
6
  "homepage": "https://arkstack.toneflix.net",
@@ -48,8 +48,8 @@
48
48
  "@h3ravel/musket": "^2.0.0",
49
49
  "chalk": "^5.6.2",
50
50
  "resora": "^1.3.25",
51
- "@arkstack/contract": "^0.12.35",
52
- "@arkstack/common": "^0.12.35"
51
+ "@arkstack/common": "^0.12.37",
52
+ "@arkstack/contract": "^0.12.37"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsdown",