@akanjs/cli 0.0.123 → 0.0.124

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/cjs/index.js CHANGED
@@ -2122,7 +2122,9 @@ var AiSession = class _AiSession {
2122
2122
  }
2123
2123
  } = {}) {
2124
2124
  if (!_AiSession.#chat)
2125
- throw new Error("Please initialize the AI session first");
2125
+ await _AiSession.init();
2126
+ if (!_AiSession.#chat)
2127
+ throw new Error("Failed to initialize the AI session");
2126
2128
  try {
2127
2129
  const humanMessage = new import_messages.HumanMessage(question);
2128
2130
  this.messageHistory.push(humanMessage);
@@ -2251,15 +2253,10 @@ var Builder = class {
2251
2253
  var import_compare_versions = require("compare-versions");
2252
2254
  var import_dotenv2 = __toESM(require("dotenv"));
2253
2255
  var LibraryRunner = class {
2254
- async scanSync(lib) {
2255
- const akanConfig = await lib.getConfig();
2256
- const scanResult = await lib.scan({ akanConfig });
2257
- return scanResult;
2258
- }
2259
2256
  async createLibrary(libName, workspace) {
2260
2257
  await workspace.exec(`mkdir -p libs/${libName}`);
2261
2258
  const lib = LibExecutor.from(workspace, libName);
2262
- await lib.applyTemplate({ basePath: ".", template: "libRoot", dict: { libName, Libname: capitalize(libName) } });
2259
+ await lib.applyTemplate({ basePath: ".", template: "libRoot", dict: { libName, LibName: capitalize(libName) } });
2263
2260
  const rootTsConfig = workspace.readJson("tsconfig.json");
2264
2261
  rootTsConfig.compilerOptions.paths[`@${libName}`] = [`libs/${libName}/index.ts`];
2265
2262
  rootTsConfig.compilerOptions.paths[`@${libName}/*`] = [`libs/${libName}/*`];
@@ -2351,17 +2348,18 @@ var LibraryRunner = class {
2351
2348
  var LibraryScript = class {
2352
2349
  #runner = new LibraryRunner();
2353
2350
  async scanLibrary(lib, verbose = false) {
2354
- const scanResult = await this.#runner.scanSync(lib);
2351
+ const akanConfig = await lib.getConfig();
2352
+ const scanResult = await lib.scan({ akanConfig });
2355
2353
  if (verbose)
2356
2354
  lib.logger.rawLog(JSON.stringify(scanResult, null, 2));
2357
2355
  return scanResult;
2358
2356
  }
2359
2357
  async syncLibrary(lib, { recursive = true } = {}) {
2360
- const scanResult = await this.scanLibrary(lib);
2361
- if (!recursive)
2362
- return;
2363
- for (const libName of scanResult.akanConfig.libs)
2364
- await this.syncLibrary(LibExecutor.from(lib.workspace, libName), { recursive: false });
2358
+ const akanConfig = await lib.getConfig();
2359
+ if (recursive)
2360
+ for (const libName of akanConfig.libs)
2361
+ await this.syncLibrary(LibExecutor.from(lib.workspace, libName), { recursive: false });
2362
+ return await lib.scan({ akanConfig });
2365
2363
  }
2366
2364
  async createLibrary(libName, workspace) {
2367
2365
  const lib = await this.#runner.createLibrary(libName, workspace);
@@ -4568,13 +4566,15 @@ var ApplicationRunner = class {
4568
4566
  await app.workspace.exec(`rm -rf apps/${app.name}`);
4569
4567
  app.log(`Application ${app.name} removed`);
4570
4568
  }
4571
- async scanSync(app) {
4572
- const akanConfig = await getAppConfig(app.cwdPath, {
4569
+ async getConfig(app) {
4570
+ return await getAppConfig(app.cwdPath, {
4573
4571
  ...app.workspace.getBaseDevEnv(),
4574
4572
  type: "app",
4575
4573
  name: app.name,
4576
4574
  command: "start"
4577
4575
  });
4576
+ }
4577
+ async scanSync(app, akanConfig) {
4578
4578
  const scanResult = await app.scan({ akanConfig });
4579
4579
  await app.syncAssets(scanResult.akanConfig.libs);
4580
4580
  return scanResult;
@@ -5077,17 +5077,18 @@ var ApplicationScript = class {
5077
5077
  await this.#runner.removeApplication(app);
5078
5078
  }
5079
5079
  async scanApplication(app, verbose = false) {
5080
- const scanResult = await this.#runner.scanSync(app);
5080
+ const akanConfig = await this.#runner.getConfig(app);
5081
+ const scanResult = await this.#runner.scanSync(app, akanConfig);
5081
5082
  if (verbose)
5082
5083
  app.logger.rawLog(JSON.stringify(scanResult, null, 2));
5083
5084
  return scanResult;
5084
5085
  }
5085
5086
  async syncApplication(app, { recursive = true } = {}) {
5086
- const scanResult = await this.#runner.scanSync(app);
5087
- if (!recursive)
5088
- return;
5089
- for (const libName of scanResult.akanConfig.libs)
5090
- await this.libraryScript.syncLibrary(LibExecutor.from(app, libName), { recursive: false });
5087
+ const akanConfig = await this.#runner.getConfig(app);
5088
+ if (recursive)
5089
+ for (const libName of akanConfig.libs)
5090
+ await this.libraryScript.syncLibrary(LibExecutor.from(app, libName), { recursive: false });
5091
+ return await this.#runner.scanSync(app, akanConfig);
5091
5092
  }
5092
5093
  async build(app) {
5093
5094
  await this.syncApplication(app);
@@ -5778,7 +5779,7 @@ var ModuleRunner = class {
5778
5779
  basePath: "./lib/__scalar",
5779
5780
  template: "__scalar",
5780
5781
  scanResult,
5781
- dict: { model: name, Model: capitalize(name) }
5782
+ dict: { model: name, Model: capitalize(name), sysName: sys2.name, SysName: capitalize(sys2.name) }
5782
5783
  });
5783
5784
  await sys2.scan({ akanConfig });
5784
5785
  return {
@@ -24,19 +24,11 @@ __export(libName_service_exports, {
24
24
  module.exports = __toCommonJS(libName_service_exports);
25
25
  function getContent(scanResult, dict) {
26
26
  return `
27
- import { Cron } from "@akanjs/nest";
28
- import { LogService, Service, Srv } from "@akanjs/service";
27
+ import { LogService, Service } from "@akanjs/service";
29
28
 
30
- import type * as srv from "../srv";
29
+ // import type * as srv from "../srv";
31
30
 
32
31
  @Service("${dict.libName}Service", { serverMode: "batch" })
33
- export class ${dict.LibName}Service extends LogService("${dict.libName}Service") {
34
- @Srv() protected readonly summaryService: srv.SummaryService;
35
-
36
- @Cron("0 * * * *")
37
- async takePeriodicSnapshot() {
38
- await this.summaryService.makeSummary();
39
- }
40
- }
32
+ export class ${dict.LibName}Service extends LogService("${dict.libName}Service") {}
41
33
  `;
42
34
  }
@@ -30,7 +30,7 @@ import { ModelProps } from "@akanjs/client";
30
30
  import { cnst, ${dict.Model} } from "@${dict.sysName}/client";
31
31
  import { Link } from "@util/ui";
32
32
 
33
- export const Card = ({ ${dict.model}, href }: ModelProps<"${dict.model}", cnst.Light${dict.Model}>>) => {
33
+ export const Card = ({ ${dict.model}, href }: ModelProps<"${dict.model}", cnst.Light${dict.Model}>) => {
34
34
  return (
35
35
  <Link href={href} className="animate-fadeIn w-full h-36 flex rounded-lg shadow-sm hover:shadow-lg duration-300">
36
36
  <div>{${dict.model}.id}</div>
@@ -32,7 +32,7 @@ import { ModelsProps } from "@akanjs/client";
32
32
  import { cnst, ${dict.Model} } from "@${dict.sysName}/client";
33
33
  import { ClientInit, ClientView, DefaultOf } from "@akanjs/signal";
34
34
 
35
- export const Admin = ({ sliceName = "${dict.model}", init, query }: ModelsProps<cnst.${dict.Model}>>) => {
35
+ export const Admin = ({ sliceName = "${dict.model}", init, query }: ModelsProps<cnst.${dict.Model}>) => {
36
36
  return (
37
37
  <Data.ListContainer
38
38
  init={init}
@@ -42,8 +42,8 @@ export const Admin = ({ sliceName = "${dict.model}", init, query }: ModelsProps<
42
42
  renderDashboard={${dict.Model}.Util.Stat}
43
43
  renderInsight={${dict.Model}.Util.Insight}
44
44
  renderTemplate={${dict.Model}.Template.General}
45
- renderTitle={(${dict.model}: DefaultOf<cnst.${dict.Model}>>) => \`${dict.Model} - \${${dict.model}.id ? ${dict.model}.id : "New"}\`}
46
- renderView={(${dict.model}: cnst.${dict.Model}>) => <${dict.Model}.View.General ${dict.model}={${dict.model}} />}
45
+ renderTitle={(${dict.model}: DefaultOf<cnst.${dict.Model}>) => \`${dict.Model} - \${${dict.model}.id ? ${dict.model}.id : "New"}\`}
46
+ renderView={(${dict.model}: cnst.${dict.Model}) => <${dict.Model}.View.General ${dict.model}={${dict.model}} />}
47
47
  columns={[
48
48
  "id",
49
49
  "status",
package/esm/index.js CHANGED
@@ -2109,7 +2109,9 @@ var AiSession = class _AiSession {
2109
2109
  }
2110
2110
  } = {}) {
2111
2111
  if (!_AiSession.#chat)
2112
- throw new Error("Please initialize the AI session first");
2112
+ await _AiSession.init();
2113
+ if (!_AiSession.#chat)
2114
+ throw new Error("Failed to initialize the AI session");
2113
2115
  try {
2114
2116
  const humanMessage = new HumanMessage(question);
2115
2117
  this.messageHistory.push(humanMessage);
@@ -2238,15 +2240,10 @@ var Builder = class {
2238
2240
  import { compareVersions } from "compare-versions";
2239
2241
  import dotenv2 from "dotenv";
2240
2242
  var LibraryRunner = class {
2241
- async scanSync(lib) {
2242
- const akanConfig = await lib.getConfig();
2243
- const scanResult = await lib.scan({ akanConfig });
2244
- return scanResult;
2245
- }
2246
2243
  async createLibrary(libName, workspace) {
2247
2244
  await workspace.exec(`mkdir -p libs/${libName}`);
2248
2245
  const lib = LibExecutor.from(workspace, libName);
2249
- await lib.applyTemplate({ basePath: ".", template: "libRoot", dict: { libName, Libname: capitalize(libName) } });
2246
+ await lib.applyTemplate({ basePath: ".", template: "libRoot", dict: { libName, LibName: capitalize(libName) } });
2250
2247
  const rootTsConfig = workspace.readJson("tsconfig.json");
2251
2248
  rootTsConfig.compilerOptions.paths[`@${libName}`] = [`libs/${libName}/index.ts`];
2252
2249
  rootTsConfig.compilerOptions.paths[`@${libName}/*`] = [`libs/${libName}/*`];
@@ -2338,17 +2335,18 @@ var LibraryRunner = class {
2338
2335
  var LibraryScript = class {
2339
2336
  #runner = new LibraryRunner();
2340
2337
  async scanLibrary(lib, verbose = false) {
2341
- const scanResult = await this.#runner.scanSync(lib);
2338
+ const akanConfig = await lib.getConfig();
2339
+ const scanResult = await lib.scan({ akanConfig });
2342
2340
  if (verbose)
2343
2341
  lib.logger.rawLog(JSON.stringify(scanResult, null, 2));
2344
2342
  return scanResult;
2345
2343
  }
2346
2344
  async syncLibrary(lib, { recursive = true } = {}) {
2347
- const scanResult = await this.scanLibrary(lib);
2348
- if (!recursive)
2349
- return;
2350
- for (const libName of scanResult.akanConfig.libs)
2351
- await this.syncLibrary(LibExecutor.from(lib.workspace, libName), { recursive: false });
2345
+ const akanConfig = await lib.getConfig();
2346
+ if (recursive)
2347
+ for (const libName of akanConfig.libs)
2348
+ await this.syncLibrary(LibExecutor.from(lib.workspace, libName), { recursive: false });
2349
+ return await lib.scan({ akanConfig });
2352
2350
  }
2353
2351
  async createLibrary(libName, workspace) {
2354
2352
  const lib = await this.#runner.createLibrary(libName, workspace);
@@ -4555,13 +4553,15 @@ var ApplicationRunner = class {
4555
4553
  await app.workspace.exec(`rm -rf apps/${app.name}`);
4556
4554
  app.log(`Application ${app.name} removed`);
4557
4555
  }
4558
- async scanSync(app) {
4559
- const akanConfig = await getAppConfig(app.cwdPath, {
4556
+ async getConfig(app) {
4557
+ return await getAppConfig(app.cwdPath, {
4560
4558
  ...app.workspace.getBaseDevEnv(),
4561
4559
  type: "app",
4562
4560
  name: app.name,
4563
4561
  command: "start"
4564
4562
  });
4563
+ }
4564
+ async scanSync(app, akanConfig) {
4565
4565
  const scanResult = await app.scan({ akanConfig });
4566
4566
  await app.syncAssets(scanResult.akanConfig.libs);
4567
4567
  return scanResult;
@@ -5064,17 +5064,18 @@ var ApplicationScript = class {
5064
5064
  await this.#runner.removeApplication(app);
5065
5065
  }
5066
5066
  async scanApplication(app, verbose = false) {
5067
- const scanResult = await this.#runner.scanSync(app);
5067
+ const akanConfig = await this.#runner.getConfig(app);
5068
+ const scanResult = await this.#runner.scanSync(app, akanConfig);
5068
5069
  if (verbose)
5069
5070
  app.logger.rawLog(JSON.stringify(scanResult, null, 2));
5070
5071
  return scanResult;
5071
5072
  }
5072
5073
  async syncApplication(app, { recursive = true } = {}) {
5073
- const scanResult = await this.#runner.scanSync(app);
5074
- if (!recursive)
5075
- return;
5076
- for (const libName of scanResult.akanConfig.libs)
5077
- await this.libraryScript.syncLibrary(LibExecutor.from(app, libName), { recursive: false });
5074
+ const akanConfig = await this.#runner.getConfig(app);
5075
+ if (recursive)
5076
+ for (const libName of akanConfig.libs)
5077
+ await this.libraryScript.syncLibrary(LibExecutor.from(app, libName), { recursive: false });
5078
+ return await this.#runner.scanSync(app, akanConfig);
5078
5079
  }
5079
5080
  async build(app) {
5080
5081
  await this.syncApplication(app);
@@ -5765,7 +5766,7 @@ var ModuleRunner = class {
5765
5766
  basePath: "./lib/__scalar",
5766
5767
  template: "__scalar",
5767
5768
  scanResult,
5768
- dict: { model: name, Model: capitalize(name) }
5769
+ dict: { model: name, Model: capitalize(name), sysName: sys2.name, SysName: capitalize(sys2.name) }
5769
5770
  });
5770
5771
  await sys2.scan({ akanConfig });
5771
5772
  return {
@@ -1,20 +1,12 @@
1
1
  // pkgs/@akanjs/cli/src/templates/libRoot/lib/___libName__/__libName__.service.ts
2
2
  function getContent(scanResult, dict) {
3
3
  return `
4
- import { Cron } from "@akanjs/nest";
5
- import { LogService, Service, Srv } from "@akanjs/service";
4
+ import { LogService, Service } from "@akanjs/service";
6
5
 
7
- import type * as srv from "../srv";
6
+ // import type * as srv from "../srv";
8
7
 
9
8
  @Service("${dict.libName}Service", { serverMode: "batch" })
10
- export class ${dict.LibName}Service extends LogService("${dict.libName}Service") {
11
- @Srv() protected readonly summaryService: srv.SummaryService;
12
-
13
- @Cron("0 * * * *")
14
- async takePeriodicSnapshot() {
15
- await this.summaryService.makeSummary();
16
- }
17
- }
9
+ export class ${dict.LibName}Service extends LogService("${dict.libName}Service") {}
18
10
  `;
19
11
  }
20
12
  export {
@@ -7,7 +7,7 @@ import { ModelProps } from "@akanjs/client";
7
7
  import { cnst, ${dict.Model} } from "@${dict.sysName}/client";
8
8
  import { Link } from "@util/ui";
9
9
 
10
- export const Card = ({ ${dict.model}, href }: ModelProps<"${dict.model}", cnst.Light${dict.Model}>>) => {
10
+ export const Card = ({ ${dict.model}, href }: ModelProps<"${dict.model}", cnst.Light${dict.Model}>) => {
11
11
  return (
12
12
  <Link href={href} className="animate-fadeIn w-full h-36 flex rounded-lg shadow-sm hover:shadow-lg duration-300">
13
13
  <div>{${dict.model}.id}</div>
@@ -9,7 +9,7 @@ import { ModelsProps } from "@akanjs/client";
9
9
  import { cnst, ${dict.Model} } from "@${dict.sysName}/client";
10
10
  import { ClientInit, ClientView, DefaultOf } from "@akanjs/signal";
11
11
 
12
- export const Admin = ({ sliceName = "${dict.model}", init, query }: ModelsProps<cnst.${dict.Model}>>) => {
12
+ export const Admin = ({ sliceName = "${dict.model}", init, query }: ModelsProps<cnst.${dict.Model}>) => {
13
13
  return (
14
14
  <Data.ListContainer
15
15
  init={init}
@@ -19,8 +19,8 @@ export const Admin = ({ sliceName = "${dict.model}", init, query }: ModelsProps<
19
19
  renderDashboard={${dict.Model}.Util.Stat}
20
20
  renderInsight={${dict.Model}.Util.Insight}
21
21
  renderTemplate={${dict.Model}.Template.General}
22
- renderTitle={(${dict.model}: DefaultOf<cnst.${dict.Model}>>) => \`${dict.Model} - \${${dict.model}.id ? ${dict.model}.id : "New"}\`}
23
- renderView={(${dict.model}: cnst.${dict.Model}>) => <${dict.Model}.View.General ${dict.model}={${dict.model}} />}
22
+ renderTitle={(${dict.model}: DefaultOf<cnst.${dict.Model}>) => \`${dict.Model} - \${${dict.model}.id ? ${dict.model}.id : "New"}\`}
23
+ renderView={(${dict.model}: cnst.${dict.Model}) => <${dict.Model}.View.General ${dict.model}={${dict.model}} />}
24
24
  columns={[
25
25
  "id",
26
26
  "status",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sourceType": "module",
3
3
  "name": "@akanjs/cli",
4
- "version": "0.0.123",
4
+ "version": "0.0.124",
5
5
  "bin": {
6
6
  "akan": "cjs/index.js"
7
7
  },
@@ -1,3 +1,4 @@
1
+ import { type AppConfigResult } from "@akanjs/config";
1
2
  import { App, AppExecutor, type Workspace } from "@akanjs/devkit";
2
3
  export interface ReleaseSourceOptions {
3
4
  rebuild?: boolean;
@@ -9,7 +10,8 @@ export declare class ApplicationRunner {
9
10
  #private;
10
11
  createApplication(appName: string, workspace: Workspace): Promise<AppExecutor>;
11
12
  removeApplication(app: App): Promise<void>;
12
- scanSync(app: App): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
13
+ getConfig(app: App): Promise<AppConfigResult>;
14
+ scanSync(app: App, akanConfig: AppConfigResult): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
13
15
  buildBackend(app: App): Promise<void>;
14
16
  startBackend(app: App, { open }?: {
15
17
  open?: boolean;
@@ -11,7 +11,7 @@ export declare class ApplicationScript {
11
11
  scanApplication(app: App, verbose?: boolean): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
12
12
  syncApplication(app: App, { recursive }?: {
13
13
  recursive?: boolean;
14
- }): Promise<void>;
14
+ }): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
15
15
  build(app: App): Promise<void>;
16
16
  start(app: App, { open }?: {
17
17
  open?: boolean;
@@ -1,7 +1,6 @@
1
1
  import { Lib, LibExecutor, Workspace } from "@akanjs/devkit";
2
2
  export declare class LibraryRunner {
3
3
  #private;
4
- scanSync(lib: Lib): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
5
4
  createLibrary(libName: string, workspace: Workspace): Promise<LibExecutor>;
6
5
  removeLibrary(lib: Lib): Promise<void>;
7
6
  installLibrary(workspace: Workspace, libName: string): Promise<LibExecutor>;
@@ -4,7 +4,7 @@ export declare class LibraryScript {
4
4
  scanLibrary(lib: Lib, verbose?: boolean): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
5
5
  syncLibrary(lib: Lib, { recursive }?: {
6
6
  recursive?: boolean;
7
- }): Promise<void>;
7
+ }): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
8
8
  createLibrary(libName: string, workspace: Workspace): Promise<void>;
9
9
  removeLibrary(lib: Lib): Promise<void>;
10
10
  installLibrary(workspace: Workspace, libName: string): Promise<void>;