@arkstack/console-slim 0.4.3 → 0.5.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/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # @arkstack/console-slim
2
2
 
3
- Shared Arkstack console (slim) runtime package containing console app, kernel bootstrap, and framework stubs.
3
+ Slim console module for Arkstack, providing the command-line runtime and console integration layer.
@@ -1,7 +1,6 @@
1
1
  import path, { isAbsolute, join } from "node:path";
2
2
  import { CliApp } from "resora";
3
3
  import { existsSync } from "node:fs";
4
-
5
4
  //#region dist/config.js
6
5
  const defaultConfig = (app) => {
7
6
  return {
@@ -17,7 +16,6 @@ const defaultConfig = (app) => {
17
16
  }
18
17
  };
19
18
  };
20
-
21
19
  //#endregion
22
20
  //#region dist/app.js
23
21
  const resolveStubsDir = (config, options, core) => {
@@ -88,7 +86,7 @@ var ArkstackConsoleApp = class extends CliApp {
88
86
  };
89
87
  };
90
88
  };
91
-
92
89
  //#endregion
93
90
  export { resolveStubsDir as n, ArkstackConsoleApp as t };
94
- //# sourceMappingURL=app-DtecNuLP.js.map
91
+
92
+ //# sourceMappingURL=app-CCSjImjr.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-DtecNuLP.js","names":[],"sources":["../src/config.ts","../src/app.ts"],"sourcesContent":["import { Core } from './types'\n\nexport const defaultConfig = (app: Core) => {\n const driver = app.getDriver().name ?? 'h3'\n\n return {\n resourcesDir: 'src/app/http/resources',\n localStubsDir: `node_modules/@arkstack/driver-${driver}/stubs`,\n stubs: {\n resource: 'resource.stub',\n collection: 'resource.collection.stub',\n controller: 'controller.stub',\n api: 'controller.api.stub',\n model: 'controller.model.stub',\n apiResource: 'controller.api.resource.stub',\n }\n }\n}","// oxlint-disable typescript/no-explicit-any\nimport path, { isAbsolute, join } from 'node:path'\n\nimport { CliApp } from 'resora'\nimport { defaultConfig } from './config'\nimport { existsSync } from 'node:fs'\n\ninterface Core {\n [k: string]: any\n getDriver: () => {\n [k: string]: any\n name: string\n }\n}\n\nexport interface ConsoleAppOptions {\n stubsDir?: string;\n}\n\nexport const resolveStubsDir = (\n config: { localStubsDir?: string } | undefined,\n options?: ConsoleAppOptions,\n core?: Core\n\n) => {\n const configuredDir = config?.localStubsDir\n\n if (configuredDir) {\n return isAbsolute(configuredDir)\n ? configuredDir\n : join(process.cwd(), configuredDir)\n }\n\n if (!options?.stubsDir) {\n const driver = core?.getDriver().name ?? 'h3'\n let stubsDir = path.resolve(process.cwd(), `node_modules/@arkstack/driver-${driver}/stubs`)\n if (!existsSync(stubsDir)) {\n stubsDir = path.resolve(process.cwd(), 'stubs')\n }\n\n return stubsDir\n }\n\n return options?.stubsDir\n}\n\nexport class ArkstackConsoleApp<TCore extends Core> extends CliApp {\n core: TCore\n private readonly options: ConsoleAppOptions\n\n constructor(\n core: TCore,\n options: ConsoleAppOptions,\n ) {\n super()\n this.core = core\n this.options = options\n this.mergeConfig()\n }\n\n makeController = (name: string, opts: any) => {\n this.mergeConfig()\n const normalized = (name.endsWith('Controller') ? name.replace(/controller/i, '') : name)\n\n let controllerName = normalized.endsWith('Controller') ? normalized : `${normalized}Controller`\n const controllersDir = path.resolve(process.cwd(), 'src', 'app/http/controllers')\n const fileName = `${controllerName}.${opts?.ext ?? 'ts'}`\n const outputPath = join(controllersDir, fileName)\n const stubsDir = resolveStubsDir(this.config as any, this.options, this.core)\n if (!stubsDir) {\n console.error('Error: stubsDir is not configured. Set stubsDir in resora.config.js.')\n process.exit(1)\n }\n\n const stubPath = join(\n stubsDir,\n opts.model\n ? (this.config.stubs as any).model\n : opts.api\n ? (this.config.stubs as any).api\n : (this.config.stubs as any).controller,\n )\n\n if (!existsSync(stubPath)) {\n console.error(`Error: Stub file ${stubPath} not found.`)\n process.exit(1)\n }\n\n controllerName = controllerName.split('/').pop() as string\n\n this.generateFile(\n stubPath,\n outputPath,\n {\n // If class name contains / or ., take only the last part for the class name\n ControllerName: controllerName,\n Model: opts.model?.pascalCase(),\n ModelName: opts.model?.camelCase(),\n Name: controllerName.replace(/controller/i, ''),\n },\n opts,\n )\n\n return outputPath\n }\n\n /**\n * Normalize a file path by removing the current working directory from it. \n * \n * @param p \n * @returns \n */\n normalizePath = (p: string) => {\n return p.replace(process.cwd(), '')\n }\n\n /**\n * Recursively merge defaultConfig with config from resora.config.js, giving \n * precedence to resora.\n */\n mergeConfig = () => {\n this.config = {\n ...defaultConfig(this.core),\n ...this.config,\n stubs: {\n ...defaultConfig(this.core).stubs,\n ...this.config?.stubs,\n },\n }\n }\n}\n"],"mappings":";;;;;AAEA,MAAa,iBAAiB,QAAc;AAGxC,QAAO;EACH,cAAc;EACd,eAAe,iCAJJ,IAAI,WAAW,CAAC,QAAQ,KAIoB;EACvD,OAAO;GACH,UAAU;GACV,YAAY;GACZ,YAAY;GACZ,KAAK;GACL,OAAO;GACP,aAAa;GAChB;EACJ;;;;;ACGL,MAAa,mBACT,QACA,SACA,SAEC;CACD,MAAM,gBAAgB,QAAQ;AAE9B,KAAI,cACA,QAAO,WAAW,cAAc,GAC1B,gBACA,KAAK,QAAQ,KAAK,EAAE,cAAc;AAG5C,KAAI,CAAC,SAAS,UAAU;EACpB,MAAM,SAAS,MAAM,WAAW,CAAC,QAAQ;EACzC,IAAI,WAAW,KAAK,QAAQ,QAAQ,KAAK,EAAE,iCAAiC,OAAO,QAAQ;AAC3F,MAAI,CAAC,WAAW,SAAS,CACrB,YAAW,KAAK,QAAQ,QAAQ,KAAK,EAAE,QAAQ;AAGnD,SAAO;;AAGX,QAAO,SAAS;;AAGpB,IAAa,qBAAb,cAA4D,OAAO;CAC/D;CACA,AAAiB;CAEjB,YACI,MACA,SACF;AACE,SAAO;AACP,OAAK,OAAO;AACZ,OAAK,UAAU;AACf,OAAK,aAAa;;CAGtB,kBAAkB,MAAc,SAAc;AAC1C,OAAK,aAAa;EAClB,MAAM,aAAc,KAAK,SAAS,aAAa,GAAG,KAAK,QAAQ,eAAe,GAAG,GAAG;EAEpF,IAAI,iBAAiB,WAAW,SAAS,aAAa,GAAG,aAAa,GAAG,WAAW;EAGpF,MAAM,aAAa,KAFI,KAAK,QAAQ,QAAQ,KAAK,EAAE,OAAO,uBAAuB,EAChE,GAAG,eAAe,GAAG,MAAM,OAAO,OACF;EACjD,MAAM,WAAW,gBAAgB,KAAK,QAAe,KAAK,SAAS,KAAK,KAAK;AAC7E,MAAI,CAAC,UAAU;AACX,WAAQ,MAAM,uEAAuE;AACrF,WAAQ,KAAK,EAAE;;EAGnB,MAAM,WAAW,KACb,UACA,KAAK,QACE,KAAK,OAAO,MAAc,QAC3B,KAAK,MACA,KAAK,OAAO,MAAc,MAC1B,KAAK,OAAO,MAAc,WACxC;AAED,MAAI,CAAC,WAAW,SAAS,EAAE;AACvB,WAAQ,MAAM,oBAAoB,SAAS,aAAa;AACxD,WAAQ,KAAK,EAAE;;AAGnB,mBAAiB,eAAe,MAAM,IAAI,CAAC,KAAK;AAEhD,OAAK,aACD,UACA,YACA;GAEI,gBAAgB;GAChB,OAAO,KAAK,OAAO,YAAY;GAC/B,WAAW,KAAK,OAAO,WAAW;GAClC,MAAM,eAAe,QAAQ,eAAe,GAAG;GAClD,EACD,KACH;AAED,SAAO;;;;;;;;CASX,iBAAiB,MAAc;AAC3B,SAAO,EAAE,QAAQ,QAAQ,KAAK,EAAE,GAAG;;;;;;CAOvC,oBAAoB;AAChB,OAAK,SAAS;GACV,GAAG,cAAc,KAAK,KAAK;GAC3B,GAAG,KAAK;GACR,OAAO;IACH,GAAG,cAAc,KAAK,KAAK,CAAC;IAC5B,GAAG,KAAK,QAAQ;IACnB;GACJ"}
1
+ {"version":3,"file":"app-CCSjImjr.js","names":[],"sources":["../src/config.ts","../src/app.ts"],"sourcesContent":["import { Core } from './types'\n\nexport const defaultConfig = (app: Core) => {\n const driver = app.getDriver().name ?? 'h3'\n\n return {\n resourcesDir: 'src/app/http/resources',\n localStubsDir: `node_modules/@arkstack/driver-${driver}/stubs`,\n stubs: {\n resource: 'resource.stub',\n collection: 'resource.collection.stub',\n controller: 'controller.stub',\n api: 'controller.api.stub',\n model: 'controller.model.stub',\n apiResource: 'controller.api.resource.stub',\n }\n }\n}","// oxlint-disable typescript/no-explicit-any\nimport path, { isAbsolute, join } from 'node:path'\n\nimport { CliApp } from 'resora'\nimport { defaultConfig } from './config'\nimport { existsSync } from 'node:fs'\n\ninterface Core {\n [k: string]: any\n getDriver: () => {\n [k: string]: any\n name: string\n }\n}\n\nexport interface ConsoleAppOptions {\n stubsDir?: string;\n}\n\nexport const resolveStubsDir = (\n config: { localStubsDir?: string } | undefined,\n options?: ConsoleAppOptions,\n core?: Core\n\n) => {\n const configuredDir = config?.localStubsDir\n\n if (configuredDir) {\n return isAbsolute(configuredDir)\n ? configuredDir\n : join(process.cwd(), configuredDir)\n }\n\n if (!options?.stubsDir) {\n const driver = core?.getDriver().name ?? 'h3'\n let stubsDir = path.resolve(process.cwd(), `node_modules/@arkstack/driver-${driver}/stubs`)\n if (!existsSync(stubsDir)) {\n stubsDir = path.resolve(process.cwd(), 'stubs')\n }\n\n return stubsDir\n }\n\n return options?.stubsDir\n}\n\nexport class ArkstackConsoleApp<TCore extends Core> extends CliApp {\n core: TCore\n private readonly options: ConsoleAppOptions\n\n constructor(\n core: TCore,\n options: ConsoleAppOptions,\n ) {\n super()\n this.core = core\n this.options = options\n this.mergeConfig()\n }\n\n makeController = (name: string, opts: any) => {\n this.mergeConfig()\n const normalized = (name.endsWith('Controller') ? name.replace(/controller/i, '') : name)\n\n let controllerName = normalized.endsWith('Controller') ? normalized : `${normalized}Controller`\n const controllersDir = path.resolve(process.cwd(), 'src', 'app/http/controllers')\n const fileName = `${controllerName}.${opts?.ext ?? 'ts'}`\n const outputPath = join(controllersDir, fileName)\n const stubsDir = resolveStubsDir(this.config as any, this.options, this.core)\n if (!stubsDir) {\n console.error('Error: stubsDir is not configured. Set stubsDir in resora.config.js.')\n process.exit(1)\n }\n\n const stubPath = join(\n stubsDir,\n opts.model\n ? (this.config.stubs as any).model\n : opts.api\n ? (this.config.stubs as any).api\n : (this.config.stubs as any).controller,\n )\n\n if (!existsSync(stubPath)) {\n console.error(`Error: Stub file ${stubPath} not found.`)\n process.exit(1)\n }\n\n controllerName = controllerName.split('/').pop() as string\n\n this.generateFile(\n stubPath,\n outputPath,\n {\n // If class name contains / or ., take only the last part for the class name\n ControllerName: controllerName,\n Model: opts.model?.pascalCase(),\n ModelName: opts.model?.camelCase(),\n Name: controllerName.replace(/controller/i, ''),\n },\n opts,\n )\n\n return outputPath\n }\n\n /**\n * Normalize a file path by removing the current working directory from it. \n * \n * @param p \n * @returns \n */\n normalizePath = (p: string) => {\n return p.replace(process.cwd(), '')\n }\n\n /**\n * Recursively merge defaultConfig with config from resora.config.js, giving \n * precedence to resora.\n */\n mergeConfig = () => {\n this.config = {\n ...defaultConfig(this.core),\n ...this.config,\n stubs: {\n ...defaultConfig(this.core).stubs,\n ...this.config?.stubs,\n },\n }\n }\n}\n"],"mappings":";;;;AAEA,MAAa,iBAAiB,QAAc;CAGxC,OAAO;EACH,cAAc;EACd,eAAe,iCAJJ,IAAI,WAAW,CAAC,QAAQ,KAIoB;EACvD,OAAO;GACH,UAAU;GACV,YAAY;GACZ,YAAY;GACZ,KAAK;GACL,OAAO;GACP,aAAa;GAChB;EACJ;;;;ACGL,MAAa,mBACT,QACA,SACA,SAEC;CACD,MAAM,gBAAgB,QAAQ;CAE9B,IAAI,eACA,OAAO,WAAW,cAAc,GAC1B,gBACA,KAAK,QAAQ,KAAK,EAAE,cAAc;CAG5C,IAAI,CAAC,SAAS,UAAU;EACpB,MAAM,SAAS,MAAM,WAAW,CAAC,QAAQ;EACzC,IAAI,WAAW,KAAK,QAAQ,QAAQ,KAAK,EAAE,iCAAiC,OAAO,QAAQ;EAC3F,IAAI,CAAC,WAAW,SAAS,EACrB,WAAW,KAAK,QAAQ,QAAQ,KAAK,EAAE,QAAQ;EAGnD,OAAO;;CAGX,OAAO,SAAS;;AAGpB,IAAa,qBAAb,cAA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"}
package/dist/app.js CHANGED
@@ -1,3 +1,2 @@
1
- import { n as resolveStubsDir, t as ArkstackConsoleApp } from "./app-DtecNuLP.js";
2
-
3
- export { ArkstackConsoleApp, resolveStubsDir };
1
+ import { n as resolveStubsDir, t as ArkstackConsoleApp } from "./app-CCSjImjr.js";
2
+ export { ArkstackConsoleApp, resolveStubsDir };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as ArkstackConsoleApp } from "./app-DtecNuLP.js";
2
+ import { t as ArkstackConsoleApp } from "./app-CCSjImjr.js";
3
3
  import { config, env, importFile, loadPrototypes, outputDir } from "@arkstack/common";
4
4
  import { fileURLToPath, pathToFileURL } from "node:url";
5
5
  import path, { join } from "node:path";
@@ -10,7 +10,6 @@ import { spawn } from "node:child_process";
10
10
  import { resolve } from "path";
11
11
  import { writeFile } from "fs/promises";
12
12
  import chalk from "chalk";
13
-
14
13
  //#region dist/commands/BuildCommand.js
15
14
  var BuildCommand = class extends Command {
16
15
  signature = "build";
@@ -35,7 +34,6 @@ var BuildCommand = class extends Command {
35
34
  });
36
35
  }
37
36
  };
38
-
39
37
  //#endregion
40
38
  //#region dist/commands/DevCommand.js
41
39
  var DevCommand = class extends Command {
@@ -65,7 +63,6 @@ var DevCommand = class extends Command {
65
63
  });
66
64
  }
67
65
  };
68
-
69
66
  //#endregion
70
67
  //#region dist/commands/MakeCommand.js
71
68
  var MakeCommand = class extends Command {
@@ -101,7 +98,6 @@ var MakeCommand = class extends Command {
101
98
  ].join("\n");
102
99
  }
103
100
  };
104
-
105
101
  //#endregion
106
102
  //#region dist/commands/MakeController.js
107
103
  var MakeController = class extends Command {
@@ -119,7 +115,6 @@ var MakeController = class extends Command {
119
115
  this.success(`Controller: ${this.app.normalizePath(name)} created successfully!`);
120
116
  }
121
117
  };
122
-
123
118
  //#endregion
124
119
  //#region dist/commands/MakeFullResource.js
125
120
  var MakeFullResource = class extends Command {
@@ -146,11 +141,9 @@ var MakeFullResource = class extends Command {
146
141
  this.success(`Created full resource set: ${this.app.normalizePath(res1.name)}, ${this.app.normalizePath(res2.name)}, ${this.app.normalizePath(name3)} successfully!`);
147
142
  }
148
143
  };
149
-
150
144
  //#endregion
151
145
  //#region dist/commands/MakeResource.js
152
146
  var MakeResource$1 = class extends MakeResource {};
153
-
154
147
  //#endregion
155
148
  //#region dist/commands/RouteList.js
156
149
  var RouteList = class extends Command {
@@ -181,7 +174,6 @@ var RouteList = class extends Command {
181
174
  ].join("\n");
182
175
  }
183
176
  };
184
-
185
177
  //#endregion
186
178
  //#region dist/logo.js
187
179
  var logo_default = String.raw`
@@ -192,7 +184,6 @@ var logo_default = String.raw`
192
184
  | | | | | | (__\__ \ || (_| | (__| <
193
185
  \_| |_/_| \___|___/\__\__,_|\___|_|\_\
194
186
  `;
195
-
196
187
  //#endregion
197
188
  //#region dist/index.js
198
189
  /**
@@ -259,7 +250,7 @@ const isEntrypointExecution = () => {
259
250
  }
260
251
  };
261
252
  if (isEntrypointExecution()) await runConsoleKernel();
262
-
263
253
  //#endregion
264
254
  export { runConsoleKernel };
255
+
265
256
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["MakeResource","MakeResourceBase","logo","MakeResource"],"sources":["../src/commands/BuildCommand.ts","../src/commands/DevCommand.ts","../src/commands/MakeCommand.ts","../src/commands/MakeController.ts","../src/commands/MakeFullResource.ts","../src/commands/MakeResource.ts","../src/commands/RouteList.ts","../src/logo.ts","../src/index.ts"],"sourcesContent":["import { Command } from '@h3ravel/musket'\nimport { spawn } from 'node:child_process'\n\nexport class BuildCommand extends Command {\n protected signature = 'build'\n\n protected description = 'Build the application for production'\n\n async handle () {\n await new Promise<void>((resolve, reject) => {\n const command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'\n const child = spawn(command, ['exec', 'tsdown'], {\n cwd: process.cwd(),\n stdio: 'inherit',\n env: Object.assign({}, process.env, {\n NODE_ENV: 'production',\n }),\n })\n\n child.on('error', (error) => {\n reject(error)\n })\n\n child.on('exit', (code) => {\n if (code === 0 || code === null) {\n resolve()\n \nreturn\n }\n\n reject(new Error(`tsdown exited with code ${code}`))\n })\n })\n }\n}\n","import { Command } from '@h3ravel/musket'\nimport { spawn } from 'node:child_process'\n\nexport class DevCommand extends Command {\n protected signature = 'dev'\n\n protected description = 'Run the development server'\n\n async handle () {\n await new Promise<void>((resolve, reject) => {\n const command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'\n const child = spawn(command, ['exec', 'tsdown', '--log-level', 'silent'], {\n cwd: process.cwd(),\n stdio: 'inherit',\n })\n\n child.on('error', (error) => {\n reject(error)\n })\n\n child.on('exit', (code) => {\n if (code === 0 || code === null) {\n resolve()\n \nreturn\n }\n\n reject(new Error(`tsdown exited with code ${code}`))\n })\n })\n }\n}\n","import { Command } from '@h3ravel/musket'\nimport { resolve } from 'path'\nimport { writeFile } from 'fs/promises'\n\nexport class MakeCommand extends Command {\n protected signature = `make:command \n {name : name of the command to create}\n `\n\n protected description = 'Creates a new console command class.'\n\n async handle () {\n const name = String(this.argument('name'))\n .replace(/\\s+/g, '')\n .replace(/\\.ts$/, '').trim()\n\n if (!name) return void this.error('Command name is required')\n\n const stubContent = this.stub(name)\n const filePath = resolve(process.cwd(), 'src', `app/console/commands/${name}.ts`)\n\n await writeFile(filePath, stubContent, { flag: 'wx' })\n this.success(`Command ${name} created successfully at ${filePath}`)\n }\n\n stub (name: string) {\n name = name.endsWith('Command') ? name : `${name}Command`\n name = name.split('/').pop()!.split('.').shift()!\n const signature = `app:${name.toLowerCase()}`\n const description = `Description for ${signature} command`\n\n const stub = [\n 'import { Command } from \\'@h3ravel/musket\\'',\n '',\n `export class ${name} extends Command {`,\n ` signature = '${signature}'`,\n '',\n ` description = '${description}'`,\n '',\n ' async handle () {',\n ' // Command logic goes here',\n ' }',\n '}',\n ]\n\n return stub.join('\\n')\n }\n}\n","import { ArkstackConsoleApp } from '../app'\nimport { Command } from '@h3ravel/musket'\n\n// oxlint-disable-next-line typescript/no-explicit-any\nexport class MakeController extends Command<ArkstackConsoleApp<any>> {\n protected signature = `make:controller\n {name : name of the controller to create}\n {--api : make an API controller}\n {--m|model? : name of model to attach to controller}\n {--force : force overwrite if controller already exists}\n `\n\n protected description = 'Create a new controller file'\n\n async handle () {\n this.app.command = this\n\n if (!this.argument('name')) return void this.error('Error: Controller name is required.')\n\n const name = this.app.makeController(this.argument('name'), this.options())\n\n this.success(`Controller: ${this.app.normalizePath(name)} created successfully!`)\n }\n}\n","import { ArkstackConsoleApp } from '../app'\nimport { Command } from '@h3ravel/musket'\n\n// oxlint-disable-next-line typescript/no-explicit-any\nexport class MakeFullResource extends Command<ArkstackConsoleApp<any>> {\n protected signature = `make:full-resource\n {prefix : prefix of the resources to create, \"Admin\" will create AdminResource, AdminCollection and AdminController}\n {--m|model? : name of model to attach to the generated controller}\n {--f|factory : Create and link a factory}\n {--s|seeder : Create a seeder file for the model (only if --model is specified)}\n {--x|migration : Create a migration file for the model (only if --model is specified)}\n {--force : force overwrite if resources already exist}\n `\n\n protected description =\n 'Create a full new set of API resources (Controller, Resource, Collection)'\n\n async handle () {\n this.app.command = this\n\n const res1 = this.app.makeResource(this.argument('prefix'), {\n force: this.option('force')\n })\n const res2 = this.app.makeResource(this.argument('prefix') + 'Collection', {\n collection: true,\n force: this.option('force'),\n })\n const name3 = this.app.makeController(\n this.argument('prefix'),\n Object.assign({}, this.options(), { api: true, force: this.option('force') }),\n )\n\n this.success(`Created full resource set: ${this.app.normalizePath(res1.name)}, ${this.app.normalizePath(res2.name)}, ${this.app.normalizePath(name3)} successfully!`)\n }\n}\n","import { MakeResource as MakeResourceBase } from 'resora'\n\nexport class MakeResource extends MakeResourceBase {\n}\n","import { ArkstackConsoleApp } from '../app'\nimport type { ArkstackRouterAwareCore } from '@arkstack/contract'\nimport { Command } from '@h3ravel/musket'\nimport type { Route } from 'clear-router'\nimport chalk from 'chalk'\n\ntype App = ArkstackConsoleApp<ArkstackRouterAwareCore<unknown, Route[]>>;\n\nexport class RouteList extends Command<App> {\n protected signature = `route:list\n {--p|path? : Path to filter routes by}\n `\n\n protected description = 'List all registered routes'\n\n async handle () {\n const routes = await this.app.core.getRouter().list(this.options(), this.app.core.getAppInstance())\n\n console.log(this.formatRoutes(routes.reverse()))\n this.newLine()\n this.info(`Total routes: ${routes.length}`)\n }\n\n private formatRoutes (routes: Route[]) {\n if (routes.length === 0) {\n return 'No routes registered.'\n }\n\n const rows = routes.map((route) => ({\n method: route.methods.join('|').toUpperCase(),\n path: route.path,\n handler: route.controllerName ? `${route.controllerName} → ${route.actionName}` : route.actionName ?? 'N/A',\n }))\n\n const methodWidth = Math.max('METHOD'.length, ...rows.map((row) => row.method.length))\n const pathWidth = Math.max('PATH'.length, ...rows.map((row) => row.path.length))\n const handlerWidth = Math.max('HANDLER'.length, ...rows.map((row) => row.handler.length))\n\n const header = `${'METHOD'.padEnd(methodWidth)} ${'PATH'.padEnd(pathWidth)} ${'HANDLER'.padEnd(handlerWidth)}`\n const divider = `${'-'.repeat(methodWidth)} ${'-'.repeat(pathWidth)} ${'-'.repeat(handlerWidth)}`\n const body = rows.map(\n (row) => `${chalk.green(row.method.padEnd(methodWidth))} ${chalk.blue(row.path.padEnd(pathWidth))} ${chalk.yellow(row.handler.padEnd(handlerWidth))}`\n )\n\n return [header, divider, ...body].join('\\n')\n }\n}\n","export default String.raw`\n ___ _ _ \n / _ \\ | | | | \n/ /_\\ \\_ __ ___ ___| |_ __ _ ___| | __\n| _ | '__/ __/ __| __/ _' |/ __| |/ /\n| | | | | | (__\\__ \\ || (_| | (__| < \n\\_| |_/_| \\___|___/\\__\\__,_|\\___|_|\\_\\ \n`","#!/usr/bin/env node\n\nimport { config, env, importFile, loadPrototypes, outputDir } from '@arkstack/common'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport path, { join } from 'node:path'\n\nimport { ArkstackConsoleApp } from './app'\nimport { BuildCommand } from './commands/BuildCommand'\nimport { DevCommand } from './commands/DevCommand'\nimport { Kernel } from '@h3ravel/musket'\nimport { MakeCommand } from './commands/MakeCommand'\nimport { MakeController } from './commands/MakeController'\nimport { MakeFullResource } from './commands/MakeFullResource'\nimport { MakeResource } from './commands/MakeResource'\nimport { RouteList } from './commands/RouteList'\nimport logo from './logo'\nimport { realpathSync } from 'node:fs'\n\nexport interface RunConsoleOptions {\n logo?: string;\n}\n\n/**\n * Loads the core application instance by importing the bootstrap file.\n * \n * @returns \n */\nconst loadCoreApp = async () => {\n const dist = path.relative(process.cwd(), outputDir())\n\n const bootstrapPath = join(process.cwd(), `${dist}/core/bootstrap.js`)\n\n\n const module = await importFile<{ app: any }>(bootstrapPath)\n\n return module.app\n}\n\n/**\n * Runs the console kernel, initializing the application and registering commands.\n * \n * @param options \n */\nexport const runConsoleKernel = async (options: RunConsoleOptions = {}) => {\n loadPrototypes()\n\n const app = await loadCoreApp()\n const dist = path.relative(process.cwd(), outputDir())\n const stubsDir = process.env.ARKSTACK_STUBS_DIR\n globalThis.app = () => app as never\n globalThis.env = env\n globalThis.config = config\n globalThis.arkctx = {\n runtime: 'CLI',\n }\n\n await Kernel.init(await new ArkstackConsoleApp(app, { stubsDir }).loadConfig(), {\n logo: options.logo ?? logo,\n name: 'Cmd',\n baseCommands: [\n RouteList,\n MakeResource,\n MakeController,\n MakeFullResource,\n DevCommand,\n BuildCommand,\n MakeCommand,\n ],\n discoveryPaths: [\n join(process.cwd(), 'src', 'app', 'console', 'commands/*.ts'),\n join(process.cwd(), 'src', 'app/console/commands/*.js'),\n join(process.cwd(), 'src', 'app/console/commands/*.mjs'),\n join(process.cwd(), dist, 'app/console/commands/*.js'),\n join(process.cwd(), dist, 'app/console/commands/*.mjs'),\n join(process.cwd(), 'node_modules', '@arkstack/*', 'dist', 'commands', '*.js'),\n ],\n exceptionHandler (exception) {\n throw exception\n },\n })\n}\n\n/**\n * Determines if the current module is being executed as the entry \n * point of the application.\n * \n * @returns \n */\nconst isEntrypointExecution = () => {\n const argvEntry = process.argv[1]\n\n if (!argvEntry) {\n return false\n }\n\n try {\n const currentModulePath = realpathSync(fileURLToPath(import.meta.url))\n const entryPath = realpathSync(argvEntry)\n\n return currentModulePath === entryPath\n } catch {\n return import.meta.url === pathToFileURL(argvEntry).href\n }\n}\n\nif (isEntrypointExecution()) {\n await runConsoleKernel()\n}\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAa,eAAb,cAAkC,QAAQ;CACtC,AAAU,YAAY;CAEtB,AAAU,cAAc;CAExB,MAAM,SAAU;AACZ,QAAM,IAAI,SAAe,SAAS,WAAW;GAEzC,MAAM,QAAQ,MADE,QAAQ,aAAa,UAAU,aAAa,QAC/B,CAAC,QAAQ,SAAS,EAAE;IAC7C,KAAK,QAAQ,KAAK;IAClB,OAAO;IACP,KAAK,OAAO,OAAO,EAAE,EAAE,QAAQ,KAAK,EAChC,UAAU,cACb,CAAC;IACL,CAAC;AAEF,SAAM,GAAG,UAAU,UAAU;AACzB,WAAO,MAAM;KACf;AAEF,SAAM,GAAG,SAAS,SAAS;AACvB,QAAI,SAAS,KAAK,SAAS,MAAM;AAC7B,cAAS;AAE7B;;AAGgB,2BAAO,IAAI,MAAM,2BAA2B,OAAO,CAAC;KACtD;IACJ;;;;;;AC7BV,IAAa,aAAb,cAAgC,QAAQ;CACpC,AAAU,YAAY;CAEtB,AAAU,cAAc;CAExB,MAAM,SAAU;AACZ,QAAM,IAAI,SAAe,SAAS,WAAW;GAEzC,MAAM,QAAQ,MADE,QAAQ,aAAa,UAAU,aAAa,QAC/B;IAAC;IAAQ;IAAU;IAAe;IAAS,EAAE;IACtE,KAAK,QAAQ,KAAK;IAClB,OAAO;IACV,CAAC;AAEF,SAAM,GAAG,UAAU,UAAU;AACzB,WAAO,MAAM;KACf;AAEF,SAAM,GAAG,SAAS,SAAS;AACvB,QAAI,SAAS,KAAK,SAAS,MAAM;AAC7B,cAAS;AAE7B;;AAGgB,2BAAO,IAAI,MAAM,2BAA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AAK,MAAM,IAAI,mBAAmB,KAAK,EAAE,UAAU,CAAC,CAAC,YAAY,EAAE;EAC5E,MAAM,QAAQ,QAAQC;EACtB,MAAM;EACN,cAAc;GACV;GACAC;GACA;GACA;GACA;GACA;GACA;GACH;EACD,gBAAgB;GACZ,KAAK,QAAQ,KAAK,EAAE,OAAO,OAAO,WAAW,gBAAgB;GAC7D,KAAK,QAAQ,KAAK,EAAE,OAAO,4BAA4B;GACvD,KAAK,QAAQ,KAAK,EAAE,OAAO,6BAA6B;GACxD,KAAK,QAAQ,KAAK,EAAE,MAAM,4BAA4B;GACtD,KAAK,QAAQ,KAAK,EAAE,MAAM,6BAA6B;GACvD,KAAK,QAAQ,KAAK,EAAE,gBAAgB,eAAe,QAAQ,YAAY,OAAO;GACjF;EACD,iBAAkB,WAAW;AACzB,SAAM;;EAEb,CAAC;;;;;;;;AASN,MAAM,8BAA8B;CAChC,MAAM,YAAY,QAAQ,KAAK;AAE/B,KAAI,CAAC,UACD,QAAO;AAGX,KAAI;AAIA,SAH0B,aAAa,cAAc,OAAO,KAAK,IAAI,CAAC,KACpD,aAAa,UAAU;SAGrC;AACJ,SAAO,OAAO,KAAK,QAAQ,cAAc,UAAU,CAAC;;;AAI5D,IAAI,uBAAuB,CACvB,OAAM,kBAAkB"}
1
+ {"version":3,"file":"index.js","names":["MakeResource","MakeResourceBase","logo","MakeResource"],"sources":["../src/commands/BuildCommand.ts","../src/commands/DevCommand.ts","../src/commands/MakeCommand.ts","../src/commands/MakeController.ts","../src/commands/MakeFullResource.ts","../src/commands/MakeResource.ts","../src/commands/RouteList.ts","../src/logo.ts","../src/index.ts"],"sourcesContent":["import { Command } from '@h3ravel/musket'\nimport { spawn } from 'node:child_process'\n\nexport class BuildCommand extends Command {\n protected signature = 'build'\n\n protected description = 'Build the application for production'\n\n async handle () {\n await new Promise<void>((resolve, reject) => {\n const command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'\n const child = spawn(command, ['exec', 'tsdown'], {\n cwd: process.cwd(),\n stdio: 'inherit',\n env: Object.assign({}, process.env, {\n NODE_ENV: 'production',\n }),\n })\n\n child.on('error', (error) => {\n reject(error)\n })\n\n child.on('exit', (code) => {\n if (code === 0 || code === null) {\n resolve()\n \nreturn\n }\n\n reject(new Error(`tsdown exited with code ${code}`))\n })\n })\n }\n}\n","import { Command } from '@h3ravel/musket'\nimport { spawn } from 'node:child_process'\n\nexport class DevCommand extends Command {\n protected signature = 'dev'\n\n protected description = 'Run the development server'\n\n async handle () {\n await new Promise<void>((resolve, reject) => {\n const command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'\n const child = spawn(command, ['exec', 'tsdown', '--log-level', 'silent'], {\n cwd: process.cwd(),\n stdio: 'inherit',\n })\n\n child.on('error', (error) => {\n reject(error)\n })\n\n child.on('exit', (code) => {\n if (code === 0 || code === null) {\n resolve()\n \nreturn\n }\n\n reject(new Error(`tsdown exited with code ${code}`))\n })\n })\n }\n}\n","import { Command } from '@h3ravel/musket'\nimport { resolve } from 'path'\nimport { writeFile } from 'fs/promises'\n\nexport class MakeCommand extends Command {\n protected signature = `make:command \n {name : name of the command to create}\n `\n\n protected description = 'Creates a new console command class.'\n\n async handle () {\n const name = String(this.argument('name'))\n .replace(/\\s+/g, '')\n .replace(/\\.ts$/, '').trim()\n\n if (!name) return void this.error('Command name is required')\n\n const stubContent = this.stub(name)\n const filePath = resolve(process.cwd(), 'src', `app/console/commands/${name}.ts`)\n\n await writeFile(filePath, stubContent, { flag: 'wx' })\n this.success(`Command ${name} created successfully at ${filePath}`)\n }\n\n stub (name: string) {\n name = name.endsWith('Command') ? name : `${name}Command`\n name = name.split('/').pop()!.split('.').shift()!\n const signature = `app:${name.toLowerCase()}`\n const description = `Description for ${signature} command`\n\n const stub = [\n 'import { Command } from \\'@h3ravel/musket\\'',\n '',\n `export class ${name} extends Command {`,\n ` signature = '${signature}'`,\n '',\n ` description = '${description}'`,\n '',\n ' async handle () {',\n ' // Command logic goes here',\n ' }',\n '}',\n ]\n\n return stub.join('\\n')\n }\n}\n","import { ArkstackConsoleApp } from '../app'\nimport { Command } from '@h3ravel/musket'\n\n// oxlint-disable-next-line typescript/no-explicit-any\nexport class MakeController extends Command<ArkstackConsoleApp<any>> {\n protected signature = `make:controller\n {name : name of the controller to create}\n {--api : make an API controller}\n {--m|model? : name of model to attach to controller}\n {--force : force overwrite if controller already exists}\n `\n\n protected description = 'Create a new controller file'\n\n async handle () {\n this.app.command = this\n\n if (!this.argument('name')) return void this.error('Error: Controller name is required.')\n\n const name = this.app.makeController(this.argument('name'), this.options())\n\n this.success(`Controller: ${this.app.normalizePath(name)} created successfully!`)\n }\n}\n","import { ArkstackConsoleApp } from '../app'\nimport { Command } from '@h3ravel/musket'\n\n// oxlint-disable-next-line typescript/no-explicit-any\nexport class MakeFullResource extends Command<ArkstackConsoleApp<any>> {\n protected signature = `make:full-resource\n {prefix : prefix of the resources to create, \"Admin\" will create AdminResource, AdminCollection and AdminController}\n {--m|model? : name of model to attach to the generated controller}\n {--f|factory : Create and link a factory}\n {--s|seeder : Create a seeder file for the model (only if --model is specified)}\n {--x|migration : Create a migration file for the model (only if --model is specified)}\n {--force : force overwrite if resources already exist}\n `\n\n protected description =\n 'Create a full new set of API resources (Controller, Resource, Collection)'\n\n async handle () {\n this.app.command = this\n\n const res1 = this.app.makeResource(this.argument('prefix'), {\n force: this.option('force')\n })\n const res2 = this.app.makeResource(this.argument('prefix') + 'Collection', {\n collection: true,\n force: this.option('force'),\n })\n const name3 = this.app.makeController(\n this.argument('prefix'),\n Object.assign({}, this.options(), { api: true, force: this.option('force') }),\n )\n\n this.success(`Created full resource set: ${this.app.normalizePath(res1.name)}, ${this.app.normalizePath(res2.name)}, ${this.app.normalizePath(name3)} successfully!`)\n }\n}\n","import { MakeResource as MakeResourceBase } from 'resora'\n\nexport class MakeResource extends MakeResourceBase {\n}\n","import { ArkstackConsoleApp } from '../app'\nimport type { ArkstackRouterAwareCore } from '@arkstack/contract'\nimport { Command } from '@h3ravel/musket'\nimport type { Route } from 'clear-router'\nimport chalk from 'chalk'\n\ntype App = ArkstackConsoleApp<ArkstackRouterAwareCore<unknown, Route[]>>;\n\nexport class RouteList extends Command<App> {\n protected signature = `route:list\n {--p|path? : Path to filter routes by}\n `\n\n protected description = 'List all registered routes'\n\n async handle () {\n const routes = await this.app.core.getRouter().list(this.options(), this.app.core.getAppInstance())\n\n console.log(this.formatRoutes(routes.reverse()))\n this.newLine()\n this.info(`Total routes: ${routes.length}`)\n }\n\n private formatRoutes (routes: Route[]) {\n if (routes.length === 0) {\n return 'No routes registered.'\n }\n\n const rows = routes.map((route) => ({\n method: route.methods.join('|').toUpperCase(),\n path: route.path,\n handler: route.controllerName ? `${route.controllerName} → ${route.actionName}` : route.actionName ?? 'N/A',\n }))\n\n const methodWidth = Math.max('METHOD'.length, ...rows.map((row) => row.method.length))\n const pathWidth = Math.max('PATH'.length, ...rows.map((row) => row.path.length))\n const handlerWidth = Math.max('HANDLER'.length, ...rows.map((row) => row.handler.length))\n\n const header = `${'METHOD'.padEnd(methodWidth)} ${'PATH'.padEnd(pathWidth)} ${'HANDLER'.padEnd(handlerWidth)}`\n const divider = `${'-'.repeat(methodWidth)} ${'-'.repeat(pathWidth)} ${'-'.repeat(handlerWidth)}`\n const body = rows.map(\n (row) => `${chalk.green(row.method.padEnd(methodWidth))} ${chalk.blue(row.path.padEnd(pathWidth))} ${chalk.yellow(row.handler.padEnd(handlerWidth))}`\n )\n\n return [header, divider, ...body].join('\\n')\n }\n}\n","export default String.raw`\n ___ _ _ \n / _ \\ | | | | \n/ /_\\ \\_ __ ___ ___| |_ __ _ ___| | __\n| _ | '__/ __/ __| __/ _' |/ __| |/ /\n| | | | | | (__\\__ \\ || (_| | (__| < \n\\_| |_/_| \\___|___/\\__\\__,_|\\___|_|\\_\\ \n`","#!/usr/bin/env node\n\nimport { config, env, importFile, loadPrototypes, outputDir } from '@arkstack/common'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport path, { join } from 'node:path'\n\nimport { ArkstackConsoleApp } from './app'\nimport { BuildCommand } from './commands/BuildCommand'\nimport { DevCommand } from './commands/DevCommand'\nimport { Kernel } from '@h3ravel/musket'\nimport { MakeCommand } from './commands/MakeCommand'\nimport { MakeController } from './commands/MakeController'\nimport { MakeFullResource } from './commands/MakeFullResource'\nimport { MakeResource } from './commands/MakeResource'\nimport { RouteList } from './commands/RouteList'\nimport logo from './logo'\nimport { realpathSync } from 'node:fs'\n\nexport interface RunConsoleOptions {\n logo?: string;\n}\n\n/**\n * Loads the core application instance by importing the bootstrap file.\n * \n * @returns \n */\nconst loadCoreApp = async () => {\n const dist = path.relative(process.cwd(), outputDir())\n\n const bootstrapPath = join(process.cwd(), `${dist}/core/bootstrap.js`)\n\n\n const module = await importFile<{ app: any }>(bootstrapPath)\n\n return module.app\n}\n\n/**\n * Runs the console kernel, initializing the application and registering commands.\n * \n * @param options \n */\nexport const runConsoleKernel = async (options: RunConsoleOptions = {}) => {\n loadPrototypes()\n\n const app = await loadCoreApp()\n const dist = path.relative(process.cwd(), outputDir())\n const stubsDir = process.env.ARKSTACK_STUBS_DIR\n globalThis.app = () => app as never\n globalThis.env = env\n globalThis.config = config\n globalThis.arkctx = {\n runtime: 'CLI',\n }\n\n await Kernel.init(await new ArkstackConsoleApp(app, { stubsDir }).loadConfig(), {\n logo: options.logo ?? logo,\n name: 'Cmd',\n baseCommands: [\n RouteList,\n MakeResource,\n MakeController,\n MakeFullResource,\n DevCommand,\n BuildCommand,\n MakeCommand,\n ],\n discoveryPaths: [\n join(process.cwd(), 'src', 'app', 'console', 'commands/*.ts'),\n join(process.cwd(), 'src', 'app/console/commands/*.js'),\n join(process.cwd(), 'src', 'app/console/commands/*.mjs'),\n join(process.cwd(), dist, 'app/console/commands/*.js'),\n join(process.cwd(), dist, 'app/console/commands/*.mjs'),\n join(process.cwd(), 'node_modules', '@arkstack/*', 'dist', 'commands', '*.js'),\n ],\n exceptionHandler (exception) {\n throw exception\n },\n })\n}\n\n/**\n * Determines if the current module is being executed as the entry \n * point of the application.\n * \n * @returns \n */\nconst isEntrypointExecution = () => {\n const argvEntry = process.argv[1]\n\n if (!argvEntry) {\n return false\n }\n\n try {\n const currentModulePath = realpathSync(fileURLToPath(import.meta.url))\n const entryPath = realpathSync(argvEntry)\n\n return currentModulePath === entryPath\n } catch {\n return import.meta.url === pathToFileURL(argvEntry).href\n }\n}\n\nif (isEntrypointExecution()) {\n await runConsoleKernel()\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAa,eAAb,cAAkC,QAAQ;CACtC,YAAsB;CAEtB,cAAwB;CAExB,MAAM,SAAU;EACZ,MAAM,IAAI,SAAe,SAAS,WAAW;GAEzC,MAAM,QAAQ,MADE,QAAQ,aAAa,UAAU,aAAa,QAC/B,CAAC,QAAQ,SAAS,EAAE;IAC7C,KAAK,QAAQ,KAAK;IAClB,OAAO;IACP,KAAK,OAAO,OAAO,EAAE,EAAE,QAAQ,KAAK,EAChC,UAAU,cACb,CAAC;IACL,CAAC;GAEF,MAAM,GAAG,UAAU,UAAU;IACzB,OAAO,MAAM;KACf;GAEF,MAAM,GAAG,SAAS,SAAS;IACvB,IAAI,SAAS,KAAK,SAAS,MAAM;KAC7B,SAAS;KAE7B;;IAGgB,uBAAO,IAAI,MAAM,2BAA2B,OAAO,CAAC;KACtD;IACJ;;;;;AC7BV,IAAa,aAAb,cAAgC,QAAQ;CACpC,YAAsB;CAEtB,cAAwB;CAExB,MAAM,SAAU;EACZ,MAAM,IAAI,SAAe,SAAS,WAAW;GAEzC,MAAM,QAAQ,MADE,QAAQ,aAAa,UAAU,aAAa,QAC/B;IAAC;IAAQ;IAAU;IAAe;IAAS,EAAE;IACtE,KAAK,QAAQ,KAAK;IAClB,OAAO;IACV,CAAC;GAEF,MAAM,GAAG,UAAU,UAAU;IACzB,OAAO,MAAM;KACf;GAEF,MAAM,GAAG,SAAS,SAAS;IACvB,IAAI,SAAS,KAAK,SAAS,MAAM;KAC7B,SAAS;KAE7B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mBAAmB,KAAK,EAAE,UAAU,CAAC,CAAC,YAAY,EAAE;EAC5E,MAAM,QAAQ,QAAQC;EACtB,MAAM;EACN,cAAc;GACV;GACAC;GACA;GACA;GACA;GACA;GACA;GACH;EACD,gBAAgB;GACZ,KAAK,QAAQ,KAAK,EAAE,OAAO,OAAO,WAAW,gBAAgB;GAC7D,KAAK,QAAQ,KAAK,EAAE,OAAO,4BAA4B;GACvD,KAAK,QAAQ,KAAK,EAAE,OAAO,6BAA6B;GACxD,KAAK,QAAQ,KAAK,EAAE,MAAM,4BAA4B;GACtD,KAAK,QAAQ,KAAK,EAAE,MAAM,6BAA6B;GACvD,KAAK,QAAQ,KAAK,EAAE,gBAAgB,eAAe,QAAQ,YAAY,OAAO;GACjF;EACD,iBAAkB,WAAW;GACzB,MAAM;;EAEb,CAAC;;;;;;;;AASN,MAAM,8BAA8B;CAChC,MAAM,YAAY,QAAQ,KAAK;CAE/B,IAAI,CAAC,WACD,OAAO;CAGX,IAAI;EAIA,OAH0B,aAAa,cAAc,OAAO,KAAK,IAAI,CAG7C,KAFN,aAAa,UAEO;SAClC;EACJ,OAAO,OAAO,KAAK,QAAQ,cAAc,UAAU,CAAC;;;AAI5D,IAAI,uBAAuB,EACvB,MAAM,kBAAkB"}
package/dist/prepare.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import chalk from "chalk";
3
-
4
3
  //#region dist/prepare.js
5
4
  const NODE_ENV = process.env.NODE_ENV || "development";
6
5
  const child = spawn(process.platform === "win32" ? "pnpm.cmd" : "pnpm", [
@@ -25,7 +24,7 @@ child.on("exit", (code) => {
25
24
  }
26
25
  throw new Error(`tsdown exited with code ${code}`);
27
26
  });
28
-
29
27
  //#endregion
30
- export { };
28
+ export {};
29
+
31
30
  //# sourceMappingURL=prepare.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepare.js","names":[],"sources":["../src/prepare.ts"],"sourcesContent":["import chalk from 'chalk'\nimport { spawn } from 'node:child_process'\n\nconst NODE_ENV = process.env.NODE_ENV || 'development'\nconst command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'\nconst child = spawn(command, ['exec', 'tsdown', '--log-level=silent'], {\n cwd: process.cwd(),\n stdio: 'inherit',\n env: Object.assign({}, process.env, {\n NODE_ENV,\n CLI_BUILD: 'true',\n }),\n})\n\nchild.on('error', (error) => {\n throw error\n})\n\nchild.on('exit', (code) => {\n if (code === 0 || code === null) {\n console.log(chalk.green(`Arkstak is ready for ${NODE_ENV === 'production' ? 'deployment' : NODE_ENV}!`))\n\n return\n }\n\n throw new Error(`tsdown exited with code ${code}`)\n\n})"],"mappings":";;;;AAGA,MAAM,WAAW,QAAQ,IAAI,YAAY;AAEzC,MAAM,QAAQ,MADE,QAAQ,aAAa,UAAU,aAAa,QAC/B;CAAC;CAAQ;CAAU;CAAqB,EAAE;CACnE,KAAK,QAAQ,KAAK;CAClB,OAAO;CACP,KAAK,OAAO,OAAO,EAAE,EAAE,QAAQ,KAAK;EAChC;EACA,WAAW;EACd,CAAC;CACL,CAAC;AAEF,MAAM,GAAG,UAAU,UAAU;AACzB,OAAM;EACR;AAEF,MAAM,GAAG,SAAS,SAAS;AACvB,KAAI,SAAS,KAAK,SAAS,MAAM;AAC7B,UAAQ,IAAI,MAAM,MAAM,wBAAwB,aAAa,eAAe,eAAe,SAAS,GAAG,CAAC;AAExG;;AAGJ,OAAM,IAAI,MAAM,2BAA2B,OAAO"}
1
+ {"version":3,"file":"prepare.js","names":[],"sources":["../src/prepare.ts"],"sourcesContent":["import chalk from 'chalk'\nimport { spawn } from 'node:child_process'\n\nconst NODE_ENV = process.env.NODE_ENV || 'development'\nconst command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'\nconst child = spawn(command, ['exec', 'tsdown', '--log-level=silent'], {\n cwd: process.cwd(),\n stdio: 'inherit',\n env: Object.assign({}, process.env, {\n NODE_ENV,\n CLI_BUILD: 'true',\n }),\n})\n\nchild.on('error', (error) => {\n throw error\n})\n\nchild.on('exit', (code) => {\n if (code === 0 || code === null) {\n console.log(chalk.green(`Arkstak is ready for ${NODE_ENV === 'production' ? 'deployment' : NODE_ENV}!`))\n\n return\n }\n\n throw new Error(`tsdown exited with code ${code}`)\n\n})"],"mappings":";;;AAGA,MAAM,WAAW,QAAQ,IAAI,YAAY;AAEzC,MAAM,QAAQ,MADE,QAAQ,aAAa,UAAU,aAAa,QAC/B;CAAC;CAAQ;CAAU;CAAqB,EAAE;CACnE,KAAK,QAAQ,KAAK;CAClB,OAAO;CACP,KAAK,OAAO,OAAO,EAAE,EAAE,QAAQ,KAAK;EAChC;EACA,WAAW;EACd,CAAC;CACL,CAAC;AAEF,MAAM,GAAG,UAAU,UAAU;CACzB,MAAM;EACR;AAEF,MAAM,GAAG,SAAS,SAAS;CACvB,IAAI,SAAS,KAAK,SAAS,MAAM;EAC7B,QAAQ,IAAI,MAAM,MAAM,wBAAwB,aAAa,eAAe,eAAe,SAAS,GAAG,CAAC;EAExG;;CAGJ,MAAM,IAAI,MAAM,2BAA2B,OAAO"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@arkstack/console-slim",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
- "description": "Slim console package for Arkstack providing lightweight console-specific implementations of core Arkstack features such as routing, middleware.",
5
+ "description": "Slim console module for Arkstack, providing the command-line runtime and console integration layer.",
6
6
  "homepage": "https://arkstack.toneflix.net",
7
7
  "repository": {
8
8
  "type": "git",
@@ -42,14 +42,14 @@
42
42
  }
43
43
  },
44
44
  "peerDependencies": {
45
- "clear-router": "^2.5.4"
45
+ "clear-router": "^2.6.4"
46
46
  },
47
47
  "dependencies": {
48
48
  "@h3ravel/musket": "^0.10.1",
49
49
  "chalk": "^5.6.2",
50
- "resora": "^1.2.0",
51
- "@arkstack/common": "^0.4.3",
52
- "@arkstack/contract": "^0.4.3"
50
+ "resora": "^1.2.3",
51
+ "@arkstack/common": "^0.5.0",
52
+ "@arkstack/contract": "^0.5.0"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsdown",
package/dist/app.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"app.d.ts","names":[],"sources":["../src/app.ts"],"mappings":";;;UAOU,IAAA;EAAA,CACL,CAAA;EACD,SAAA;IAAA,CACK,CAAA;IACD,IAAA;EAAA;AAAA;AAAA,UAIS,iBAAA;EACb,QAAA;AAAA;AAAA,cAGS,eAAA,GACT,MAAA;EAAU,aAAA;AAAA,eACV,OAAA,GAAU,iBAAA,EACV,IAAA,GAAO,IAAA;AAAA,cAwBE,kBAAA,eAAiC,IAAA,UAAc,MAAA;EACxD,IAAA,EAAM,KAAA;EAAA,iBACW,OAAA;cAGb,IAAA,EAAM,KAAA,EACN,OAAA,EAAS,iBAAA;EAQb,cAAA,GAAkB,IAAA,UAAc,IAAA;EAoDhC,aAAA,GAAiB,CAAA;EAQjB,WAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";UAkBiB,iBAAA;EACb,IAAA;AAAA;AAAA,cAwBS,gBAAA,GAA0B,OAAA,GAAS,iBAAA,KAAsB,OAAA"}