@akanjs/cli 0.9.58-canary.3 → 0.9.58-canary.5

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.
Files changed (36) hide show
  1. package/cjs/index.js +87 -68
  2. package/cjs/src/templates/app/akan.config.js +3 -4
  3. package/cjs/src/templates/app/app/[lang]/layout.js +4 -4
  4. package/cjs/src/templates/app/app/layout.js +4 -1
  5. package/cjs/src/templates/env/env.server.type.js +36 -0
  6. package/cjs/src/templates/lib/__lib/lib.signal.js +1 -2
  7. package/cjs/src/templates/lib/sig.js +1 -1
  8. package/cjs/src/templates/libRoot/.gitignore.template +9 -8
  9. package/cjs/src/templates/libRoot/akan.config.js +0 -1
  10. package/cjs/src/templates/module/__model__.signal.js +1 -2
  11. package/cjs/src/templates/module/__model__.signal.spec.js +1 -13
  12. package/cjs/src/templates/module/__model__.signal.test.js +1 -22
  13. package/cjs/src/templates/workspaceRoot/.gitignore.template +1 -0
  14. package/esm/index.js +87 -68
  15. package/esm/src/templates/app/akan.config.js +3 -4
  16. package/esm/src/templates/app/app/[lang]/layout.js +4 -4
  17. package/esm/src/templates/app/app/layout.js +4 -1
  18. package/esm/src/templates/env/env.server.type.js +16 -0
  19. package/esm/src/templates/lib/__lib/lib.signal.js +1 -2
  20. package/esm/src/templates/lib/sig.js +1 -1
  21. package/esm/src/templates/libRoot/.gitignore.template +9 -8
  22. package/esm/src/templates/libRoot/akan.config.js +0 -1
  23. package/esm/src/templates/module/__model__.signal.js +1 -2
  24. package/esm/src/templates/module/__model__.signal.spec.js +1 -13
  25. package/esm/src/templates/module/__model__.signal.test.js +1 -22
  26. package/esm/src/templates/workspaceRoot/.gitignore.template +1 -0
  27. package/package.json +1 -1
  28. package/src/application/application.runner.d.ts +1 -1
  29. package/src/application/application.script.d.ts +2 -1
  30. package/src/templates/app/akan.config.d.ts +3 -1
  31. package/src/templates/app/app/[lang]/layout.d.ts +3 -1
  32. package/src/templates/env/env.server.type.d.ts +4 -0
  33. package/src/templates/module/__model__.signal.spec.d.ts +1 -1
  34. package/src/templates/module/__model__.signal.test.d.ts +1 -1
  35. package/src/workspace/workspace.command.d.ts +1 -1
  36. package/src/workspace/workspace.script.d.ts +1 -1
package/cjs/index.js CHANGED
@@ -272,8 +272,8 @@ var import_ora = __toESM(require("ora"));
272
272
  var Spinner = class _Spinner {
273
273
  static padding = 12;
274
274
  spinner;
275
- stopWatch;
276
- startAt;
275
+ stopWatch = null;
276
+ startAt = /* @__PURE__ */ new Date();
277
277
  prefix;
278
278
  message;
279
279
  enableSpin;
@@ -711,7 +711,6 @@ var import_meta = {};
711
711
  var makeAppConfig = (config, props) => {
712
712
  const { name, repoName } = props;
713
713
  return {
714
- rootLib: config.rootLib,
715
714
  libs: config.libs ?? [],
716
715
  backend: {
717
716
  docker: makeDockerfile("backend", config.backend?.docker ?? {}, props),
@@ -753,7 +752,6 @@ var getAppConfig = async (appRoot, props) => {
753
752
  };
754
753
  var makeLibConfig = (config, props) => {
755
754
  return {
756
- rootLib: config.rootLib,
757
755
  libs: config.libs ?? [],
758
756
  backend: {
759
757
  explicitDependencies: config.backend?.explicitDependencies ?? []
@@ -1429,32 +1427,31 @@ var ScanInfo = class {
1429
1427
  constructor(scanResult) {
1430
1428
  this.name = scanResult.name;
1431
1429
  this.scanResult = scanResult;
1432
- Object.entries(scanResult.files).forEach(
1433
- ([key, value]) => {
1434
- const { databases, services, scalars } = value;
1435
- databases.forEach((modelName) => {
1436
- const model = this.database.get(modelName) ?? /* @__PURE__ */ new Set();
1437
- model.add(key);
1438
- this.database.set(modelName, model);
1439
- this.file[key].all.add(modelName);
1440
- this.file[key].databases.add(modelName);
1441
- });
1442
- services?.forEach((serviceName) => {
1443
- const service = this.service.get(serviceName) ?? /* @__PURE__ */ new Set();
1444
- service.add(key);
1445
- this.service.set(serviceName, service);
1446
- this.file[key].all.add(serviceName);
1447
- this.file[key].services.add(serviceName);
1448
- });
1449
- scalars?.forEach((scalarName) => {
1450
- const scalar = this.scalar.get(scalarName) ?? /* @__PURE__ */ new Set();
1451
- scalar.add(key);
1452
- this.scalar.set(scalarName, scalar);
1453
- this.file[key].all.add(scalarName);
1454
- this.file[key].scalars.add(scalarName);
1455
- });
1456
- }
1457
- );
1430
+ Object.entries(scanResult.files).forEach(([_key, value]) => {
1431
+ const key = _key;
1432
+ const { databases, services, scalars } = value;
1433
+ databases.forEach((modelName) => {
1434
+ const model = this.database.get(modelName) ?? /* @__PURE__ */ new Set();
1435
+ model.add(key);
1436
+ this.database.set(modelName, model);
1437
+ this.file[key].all.add(modelName);
1438
+ this.file[key].databases.add(modelName);
1439
+ });
1440
+ services?.forEach((serviceName) => {
1441
+ const service = this.service.get(serviceName) ?? /* @__PURE__ */ new Set();
1442
+ service.add(key);
1443
+ this.service.set(serviceName, service);
1444
+ this.file[key].all.add(serviceName);
1445
+ this.file[key].services.add(serviceName);
1446
+ });
1447
+ scalars?.forEach((scalarName) => {
1448
+ const scalar = this.scalar.get(scalarName) ?? /* @__PURE__ */ new Set();
1449
+ scalar.add(key);
1450
+ this.scalar.set(scalarName, scalar);
1451
+ this.file[key].all.add(scalarName);
1452
+ this.file[key].scalars.add(scalarName);
1453
+ });
1454
+ });
1458
1455
  }
1459
1456
  getScanResult() {
1460
1457
  return this.scanResult;
@@ -2145,10 +2142,10 @@ var Executor = class _Executor {
2145
2142
  targetPath,
2146
2143
  scanInfo,
2147
2144
  overwrite = true
2148
- }, dict = {}) {
2145
+ }, dict = {}, options = {}) {
2149
2146
  if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
2150
2147
  const getContent = await import(templatePath);
2151
- const result = getContent.default(scanInfo ?? null, dict);
2148
+ const result = getContent.default(scanInfo ?? null, dict, options);
2152
2149
  if (result === null)
2153
2150
  return null;
2154
2151
  const filename = typeof result === "object" ? result.filename : import_path4.default.basename(targetPath).replace(".js", ".ts");
@@ -2180,6 +2177,7 @@ var Executor = class _Executor {
2180
2177
  template,
2181
2178
  scanInfo,
2182
2179
  dict = {},
2180
+ options = {},
2183
2181
  overwrite = true
2184
2182
  }) {
2185
2183
  const templatePath = `${getDirname(import_meta2.url)}/src/templates${template ? `/${template}` : ""}`;
@@ -2188,7 +2186,8 @@ var Executor = class _Executor {
2188
2186
  const filename = import_path4.default.basename(prefixTemplatePath);
2189
2187
  const fileContent = await this.#applyTemplateFile(
2190
2188
  { templatePath: prefixTemplatePath, targetPath: import_path4.default.join(basePath2, filename), scanInfo, overwrite },
2191
- dict
2189
+ dict,
2190
+ options
2192
2191
  );
2193
2192
  return fileContent ? [fileContent] : [];
2194
2193
  } else {
@@ -2199,7 +2198,8 @@ var Executor = class _Executor {
2199
2198
  if (import_fs4.default.statSync(subpath).isFile()) {
2200
2199
  const fileContent = await this.#applyTemplateFile(
2201
2200
  { templatePath: subpath, targetPath: import_path4.default.join(basePath2, subdir), scanInfo, overwrite },
2202
- dict
2201
+ dict,
2202
+ options
2203
2203
  );
2204
2204
  return fileContent ? [fileContent] : [];
2205
2205
  } else
@@ -2208,7 +2208,8 @@ var Executor = class _Executor {
2208
2208
  template: import_path4.default.join(template, subdir),
2209
2209
  scanInfo,
2210
2210
  dict,
2211
- overwrite
2211
+ overwrite,
2212
+ options
2212
2213
  });
2213
2214
  })
2214
2215
  )).flat();
@@ -2449,6 +2450,7 @@ var SysExecutor = class extends Executor {
2449
2450
  const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this, { refresh }) : await LibInfo.fromExecutor(this, { refresh });
2450
2451
  if (write) {
2451
2452
  await Promise.all([
2453
+ this._applyTemplate({ basePath: "env", template: "env", scanInfo }),
2452
2454
  this._applyTemplate({ basePath: "lib", template: "lib", scanInfo }),
2453
2455
  this._applyTemplate({ basePath: ".", template: "server.ts", scanInfo }),
2454
2456
  this._applyTemplate({ basePath: ".", template: "client.ts", scanInfo }),
@@ -2477,6 +2479,7 @@ var SysExecutor = class extends Executor {
2477
2479
  const libInfos = [...scanInfo.getLibInfos().values()];
2478
2480
  await Promise.all(
2479
2481
  libInfos.map((libInfo) => [
2482
+ libInfo.exec._applyTemplate({ basePath: "env", template: "env", scanInfo: libInfo }),
2480
2483
  libInfo.exec._applyTemplate({ basePath: "lib", template: "lib", scanInfo: libInfo }),
2481
2484
  libInfo.exec._applyTemplate({ basePath: ".", template: "server.ts", scanInfo: libInfo }),
2482
2485
  libInfo.exec._applyTemplate({ basePath: ".", template: "client.ts", scanInfo: libInfo }),
@@ -2674,8 +2677,6 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2674
2677
  }
2675
2678
  };
2676
2679
  var LibExecutor = class _LibExecutor extends SysExecutor {
2677
- workspaceRoot;
2678
- repoName;
2679
2680
  dist;
2680
2681
  emoji = execEmoji.lib;
2681
2682
  constructor({ workspace, name }) {
@@ -2767,7 +2768,7 @@ var getHostConfig = (host = akanCloudHost) => {
2767
2768
  };
2768
2769
  var setHostConfig = (host = akanCloudHost, config = {}) => {
2769
2770
  const akanConfig = getAkanGlobalConfig();
2770
- akanConfig[host] = config;
2771
+ akanConfig.cloudHost[host] = config;
2771
2772
  setAkanGlobalConfig(akanConfig);
2772
2773
  };
2773
2774
  var getSelf = async (token) => {
@@ -2874,24 +2875,24 @@ var FileEditor = class {
2874
2875
  var CapacitorApp = class {
2875
2876
  constructor(app) {
2876
2877
  this.app = app;
2878
+ this.project = new import_project.MobileProject(this.app.cwdPath, {
2879
+ android: { path: "android" },
2880
+ ios: { path: "ios/App" }
2881
+ });
2877
2882
  }
2878
2883
  project;
2879
2884
  iosTargetName = "App";
2880
2885
  async init() {
2881
- const project = new import_project.MobileProject(this.app.cwdPath, {
2882
- android: { path: "android" },
2883
- ios: { path: "ios/App" }
2884
- });
2885
- await project.load();
2886
+ const project = this.project;
2887
+ await this.project.load();
2886
2888
  if (!project.android) {
2887
2889
  await this.app.spawn("npx", ["cap", "add", "android"]);
2888
- await project.load();
2890
+ await this.project.load();
2889
2891
  }
2890
2892
  if (!project.ios) {
2891
2893
  await this.app.spawn("npx", ["cap", "add", "ios"]);
2892
- await project.load();
2894
+ await this.project.load();
2893
2895
  }
2894
- this.project = project;
2895
2896
  return this;
2896
2897
  }
2897
2898
  async save() {
@@ -3314,13 +3315,16 @@ var handleOption = (programCommand, argMeta) => {
3314
3315
  flag = argMeta.name.slice(0, 1).toLowerCase(),
3315
3316
  desc = argMeta.name,
3316
3317
  example,
3317
- enum: choices,
3318
+ enum: enumChoices,
3318
3319
  ask
3319
3320
  } = argMeta.argsOption;
3320
3321
  const kebabName = camelToKebabCase(argMeta.name);
3322
+ const choices = enumChoices?.map(
3323
+ (choice) => typeof choice === "object" ? { value: choice.value, name: choice.label } : { value: choice, name: choice.toString() }
3324
+ );
3321
3325
  programCommand.option(
3322
3326
  `-${flag}, --${kebabName}${type === "boolean" ? " [boolean]" : ` <${kebabName}>`}`,
3323
- `${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.join(", ")})` : ""}`
3327
+ `${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.map((choice) => choice.name).join(", ")})` : ""}`
3324
3328
  );
3325
3329
  return programCommand;
3326
3330
  };
@@ -3345,7 +3349,7 @@ var convertOptionValue = (value, type) => {
3345
3349
  var getOptionValue = async (argMeta, opt) => {
3346
3350
  const {
3347
3351
  name,
3348
- argsOption: { enum: choices, default: defaultValue, type, desc, nullable, example, ask }
3352
+ argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, example, ask }
3349
3353
  } = argMeta;
3350
3354
  if (opt[argMeta.name] !== void 0)
3351
3355
  return convertOptionValue(opt[argMeta.name], type ?? "string");
@@ -3353,11 +3357,11 @@ var getOptionValue = async (argMeta, opt) => {
3353
3357
  return defaultValue;
3354
3358
  else if (nullable)
3355
3359
  return null;
3356
- if (choices) {
3357
- const choice = await (0, import_prompts3.select)({
3358
- message: ask ?? desc ?? `Select the ${name} value`,
3359
- choices: choices.map((choice2) => choice2.toString())
3360
- });
3360
+ if (enumChoices) {
3361
+ const choices = enumChoices.map(
3362
+ (choice2) => typeof choice2 === "object" ? { value: choice2.value, name: choice2.label } : { value: choice2, name: choice2.toString() }
3363
+ );
3364
+ const choice = await (0, import_prompts3.select)({ message: ask ?? desc ?? `Select the ${name} value`, choices });
3361
3365
  return choice;
3362
3366
  } else if (type === "boolean") {
3363
3367
  const message = ask ?? desc ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
@@ -3647,7 +3651,7 @@ var AiSession = class _AiSession {
3647
3651
  }
3648
3652
  messageHistory = [];
3649
3653
  sessionKey;
3650
- isCacheLoaded;
3654
+ isCacheLoaded = false;
3651
3655
  workspace;
3652
3656
  constructor(type, { workspace, cacheKey, isContinued }) {
3653
3657
  this.workspace = workspace;
@@ -4453,11 +4457,12 @@ var import_vite_plugin_commonjs = __toESM(require("vite-plugin-commonjs"), 1);
4453
4457
  var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
4454
4458
  var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
4455
4459
  var ApplicationRunner = class {
4456
- async createApplication(appName, workspace) {
4460
+ async createApplication(appName, workspace, libs = []) {
4457
4461
  await workspace.applyTemplate({
4458
4462
  basePath: `apps/${appName}`,
4459
4463
  template: "app",
4460
- dict: { appName, companyName: workspace.repoName, startDomain: "localhost" }
4464
+ dict: { appName, companyName: workspace.repoName, startDomain: "localhost" },
4465
+ options: { libs }
4461
4466
  });
4462
4467
  workspace.setTsPaths("app", appName);
4463
4468
  return AppExecutor.from(workspace, appName);
@@ -4547,7 +4552,7 @@ var ApplicationRunner = class {
4547
4552
  });
4548
4553
  const rootPackageJson = app.workspace.getPackageJson();
4549
4554
  const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson);
4550
- buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
4555
+ buildResult.outputFiles.forEach((file) => app.dist.writeFile(file.path, file.text));
4551
4556
  const appPackageJson = {
4552
4557
  name: `${app.name}/backend`,
4553
4558
  description: `${app.name} backend`,
@@ -4605,7 +4610,7 @@ var ApplicationRunner = class {
4605
4610
  "react-dom",
4606
4611
  "typescript"
4607
4612
  ]);
4608
- buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
4613
+ buildResult.outputFiles.forEach((file) => app.dist.writeFile(file.path, file.text));
4609
4614
  const appPackageJson = {
4610
4615
  name: `${app.name}/frontend`,
4611
4616
  description: `${app.name} frontend`,
@@ -5173,9 +5178,9 @@ var ApplicationRunner = class {
5173
5178
  var ApplicationScript = class {
5174
5179
  #runner = new ApplicationRunner();
5175
5180
  libraryScript = new LibraryScript();
5176
- async createApplication(appName, workspace, { start = false } = {}) {
5181
+ async createApplication(appName, workspace, { start = false, libs = [] } = {}) {
5177
5182
  const spinner = workspace.spinning("Creating application...");
5178
- const app = await this.#runner.createApplication(appName, workspace);
5183
+ const app = await this.#runner.createApplication(appName, workspace, libs);
5179
5184
  spinner.succeed(`Application created in apps/${app.name}`);
5180
5185
  await this.syncApplication(app);
5181
5186
  if (start)
@@ -6777,11 +6782,13 @@ var WorkspaceScript = class {
6777
6782
  #runner = new WorkspaceRunner();
6778
6783
  applicationScript = new ApplicationScript();
6779
6784
  libraryScript = new LibraryScript();
6780
- async createWorkspace(repoName, appName, dirname3 = ".") {
6785
+ async createWorkspace(repoName, appName, dirname3 = ".", installLibs) {
6781
6786
  const workspace = await this.#runner.createWorkspace(repoName, appName, dirname3);
6782
- await this.libraryScript.installLibrary(workspace, "util");
6783
- await this.libraryScript.installLibrary(workspace, "shared");
6784
- await this.applicationScript.createApplication(appName, workspace);
6787
+ if (installLibs) {
6788
+ await this.libraryScript.installLibrary(workspace, "util");
6789
+ await this.libraryScript.installLibrary(workspace, "shared");
6790
+ }
6791
+ await this.applicationScript.createApplication(appName, workspace, { libs: installLibs ? ["util", "shared"] : [] });
6785
6792
  Logger.rawLog(`
6786
6793
  \u{1F389} Welcome aboard! Workspace created in ${dirname3}/${repoName}`);
6787
6794
  Logger.rawLog(`\u{1F680} Run \`cd ${repoName} && akan start ${appName}\` to start the development server.`);
@@ -6841,11 +6848,12 @@ var WorkspaceScript = class {
6841
6848
  // pkgs/@akanjs/cli/src/workspace/workspace.command.ts
6842
6849
  var WorkspaceCommand = class {
6843
6850
  workspaceScript = new WorkspaceScript();
6844
- async createWorkspace(workspaceName, app, dir) {
6851
+ async createWorkspace(workspaceName, app, dir, libs) {
6845
6852
  await this.workspaceScript.createWorkspace(
6846
6853
  workspaceName.toLowerCase().replace(/ /g, "-"),
6847
6854
  app.toLowerCase().replace(/ /g, "-"),
6848
- dir
6855
+ dir,
6856
+ libs
6849
6857
  );
6850
6858
  }
6851
6859
  async generateMongo(workspace) {
@@ -6871,7 +6879,18 @@ __decorateClass([
6871
6879
  Target.Public(),
6872
6880
  __decorateParam(0, Argument("workspaceName", { desc: "what is the name of your organization?" })),
6873
6881
  __decorateParam(1, Option("app", { desc: "what is the codename of your first application? (e.g. myapp)" })),
6874
- __decorateParam(2, Option("dir", { desc: "directory of workspace", default: process.env.USE_AKANJS_PKGS === "true" ? "local" : "." }))
6882
+ __decorateParam(2, Option("dir", { desc: "directory of workspace", default: process.env.USE_AKANJS_PKGS === "true" ? "local" : "." })),
6883
+ __decorateParam(3, Option("libs", {
6884
+ type: "boolean",
6885
+ desc: "Do you want to install shared and util libraries? (admin, user file, etc.)",
6886
+ enum: [
6887
+ { label: "No, I want to start with empty workspace (Recommended)", value: false },
6888
+ {
6889
+ label: "Yes, I want to accelerate development by installing shared and util libraries (for akanjs experts)",
6890
+ value: true
6891
+ }
6892
+ ]
6893
+ }))
6875
6894
  ], WorkspaceCommand.prototype, "createWorkspace", 1);
6876
6895
  __decorateClass([
6877
6896
  Target.Public(),
@@ -22,14 +22,13 @@ __export(akan_config_exports, {
22
22
  default: () => getContent
23
23
  });
24
24
  module.exports = __toCommonJS(akan_config_exports);
25
- function getContent(scanInfo, dict) {
25
+ function getContent(scanInfo, dict, options) {
26
26
  return `
27
27
  import type { AppConfig } from "@akanjs/config";
28
28
 
29
- const config: AppConfig = {
30
- rootLib: "shared",
29
+ const config: AppConfig = ${options.libs.length ? `{
31
30
  libs: ["util", "shared"],
32
- };
31
+ }` : "{}"};
33
32
 
34
33
  export default config;
35
34
  `;
@@ -22,7 +22,8 @@ __export(layout_exports, {
22
22
  default: () => getContent
23
23
  });
24
24
  module.exports = __toCommonJS(layout_exports);
25
- function getContent(scanInfo, dict) {
25
+ function getContent(scanInfo, dict, options) {
26
+ const isUsingShared = options.libs.includes("shared");
26
27
  return {
27
28
  filename: "layout.tsx",
28
29
  content: `
@@ -31,7 +32,7 @@ import { RootLayoutProps } from "@akanjs/client";
31
32
  import { System } from "@akanjs/ui";
32
33
  import { env } from "@${dict.appName}/env/env.client";
33
34
  import { fetch } from "@${dict.appName}/client";
34
- import { Auth } from "@shared/ui";
35
+ ${isUsingShared ? "import { Auth } from '@shared/ui';" : ""}
35
36
 
36
37
  export const metadata = { title: "${dict.appName}" };
37
38
 
@@ -45,8 +46,7 @@ export default function Layout({ children, params }: RootLayoutProps) {
45
46
  // className="bg-base-100"
46
47
  env={env}
47
48
  >
48
- {children}
49
- <Auth.User />
49
+ {children}${isUsingShared ? "\n <Auth.User />\n <Auth.Admin />" : ""}
50
50
  </System.Provider>
51
51
  );
52
52
  }
@@ -30,7 +30,10 @@ function getContent(scanInfo, dict) {
30
30
  import { st } from "@${dict.appName}/client";
31
31
  import { System } from "@akanjs/ui";
32
32
 
33
- export default function Layout({ children }) {
33
+ interface LayoutProps {
34
+ children: React.ReactNode;
35
+ }
36
+ export default function Layout({ children }: LayoutProps) {
34
37
  return <System.Root st={st}>{children}</System.Root>;
35
38
  }
36
39
  `
@@ -0,0 +1,36 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // pkgs/@akanjs/cli/src/templates/env/env.server.type.ts
20
+ var env_server_type_exports = {};
21
+ __export(env_server_type_exports, {
22
+ default: () => getContent
23
+ });
24
+ module.exports = __toCommonJS(env_server_type_exports);
25
+ function getContent(scanInfo, dict = {}) {
26
+ if (!scanInfo)
27
+ return null;
28
+ const libs = scanInfo.getLibs();
29
+ return `
30
+ ${libs.length ? libs.map((lib) => `import { env as ${lib}Option } from "@${lib}/server";`).join("\n") : 'import { baseEnv } from "@akanjs/base";'}
31
+
32
+ export const libEnv = {
33
+ ${libs.length ? libs.map((lib) => ` ...${lib}Option,`).join("\n") : " ...baseEnv,"}
34
+ };
35
+ `;
36
+ }
@@ -27,7 +27,6 @@ function getContent(scanInfo, dict = {}) {
27
27
  if (!scanInfo)
28
28
  return null;
29
29
  const libs = scanInfo.getLibs();
30
- const rootLib = scanInfo.akanConfig.rootLib;
31
30
  const libInfos = [...scanInfo.getLibInfos().values()];
32
31
  const extendedModels = Object.fromEntries(
33
32
  [...scanInfo.file.signal.databases].map(
@@ -50,7 +49,7 @@ ${Object.entries(extendedModels).map(([modelName, extendedModels2]) => {
50
49
  }`;
51
50
  }).join("\n")}
52
51
 
53
- export const root = ${libs.length ? rootLib ?? libs[0] : "baseFetch"};
52
+ export const root = ${libs.length ? libs[0] : "baseFetch"};
54
53
  export const libFetches = [${libs.length ? libs.map((lib) => `${lib}.fetch`).join(", ") : "baseFetch"}] as const;
55
54
  `;
56
55
  }
@@ -57,7 +57,7 @@ ${[...databaseModules, ...serviceModules].map((module2) => ` ${capitalize(modul
57
57
  );
58
58
  export const serializedSignals = signals.map((signal) => signalInfo.serialize(signal));
59
59
 
60
- ${databaseModules.map((module2) => `export const ${module2} = gqlOf(cnst.${module2}, db.${module2}.Filter, ${capitalize(module2)}Signal${scanInfo.name !== "shared" && ["user", "setting", "summary"].includes(module2) ? `, { overwrite: root.${module2} }` : ""});`).join("\n")}
60
+ ${databaseModules.map((module2) => `export const ${module2} = gqlOf(cnst.${module2}, db.${module2}.Filter, ${capitalize(module2)}Signal);`).join("\n")}
61
61
 
62
62
  export const fetch = makeFetch(...libFetches, {
63
63
  ${databaseModules.map((module2) => `...${module2},`).join("\n")}
@@ -1,14 +1,15 @@
1
1
  **/script.ts
2
2
  **/script*.ts
3
3
  **/.env
4
- **/env.client.debug.ts*
5
- **/env.client.develop.ts*
6
- **/env.client.main.ts*
7
- **/env.client.testing.ts*
8
- **/env.server.debug.ts*
9
- **/env.server.develop.ts*
10
- **/env.server.main.ts*
11
- **/env.server.testing.ts*
4
+ **/env.client.debug.ts
5
+ **/env.client.develop.ts
6
+ **/env.client.main.ts
7
+ **/env.client.testing.ts
8
+ **/env.server.debug.ts
9
+ **/env.server.develop.ts
10
+ **/env.server.main.ts
11
+ **/env.server.testing.ts
12
+ **/env.server.type.ts
12
13
 
13
14
  # System Files
14
15
  .DS_Store
@@ -27,7 +27,6 @@ function getContent(scanInfo, dict) {
27
27
  import type { LibConfig } from "@akanjs/config";
28
28
 
29
29
  const config: LibConfig = {
30
- rootLib: "shared",
31
30
  libs: ["util", "shared"],
32
31
  };
33
32
 
@@ -26,14 +26,13 @@ function getContent(scanInfo, dict) {
26
26
  return `
27
27
  import { Public } from "@akanjs/nest";
28
28
  import { endpoint, internal, slice } from "@akanjs/signal";
29
- import { Admin } from "@shared/nest";
30
29
 
31
30
  import * as cnst from "../cnst";
32
31
  import * as srv from "../srv";
33
32
 
34
33
  export class ${dict.Model}Internal extends internal(srv.${dict.model}, () => ({})) {}
35
34
 
36
- export class ${dict.Model}Slice extends slice(srv.${dict.model}, { guards: { root: Admin, get: Public, cru: Public } }, (init) => ({
35
+ export class ${dict.Model}Slice extends slice(srv.${dict.model}, { guards: { root: Public, get: Public, cru: Public } }, (init) => ({
37
36
  inPublic: init()
38
37
  .exec(function () {
39
38
  return this.${dict.model}Service.queryAny();
@@ -23,17 +23,5 @@ __export(model_signal_spec_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(model_signal_spec_exports);
25
25
  function getContent(scanInfo, dict) {
26
- return `
27
- import * as adminSpec from "@shared/lib/admin/admin.signal.spec";
28
- import * as userSpec from "@${dict.sysName}/lib/user/user.signal.spec";
29
- import * as cnst from "../cnst";
30
- import { fetch } from "../sig";
31
- import { sampleOf } from "@akanjs/test";
32
-
33
- export const create${dict.Model} = async (adminAgent: userSpec.AdminAgent, userAgent: userSpec.UserAgent) => {
34
- const ${dict.model}Input = sampleOf(cnst.${dict.Model}Input);
35
- const ${dict.model} = await adminAgent.fetch.create${dict.Model}(${dict.model}Input);
36
- return ${dict.model};
37
- };
38
- `;
26
+ return null;
39
27
  }
@@ -23,26 +23,5 @@ __export(model_signal_test_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(model_signal_test_exports);
25
25
  function getContent(scanInfo, dict) {
26
- return `
27
- import * as adminSpec from "@shared/lib/admin/admin.signal.spec";
28
- import * as userSpec from "@${dict.sysName}/lib/user/user.signal.spec";
29
- import * as ${dict.model}Spec from "@${dict.sysName}/lib/${dict.model}/${dict.model}.signal.spec";
30
- import * as cnst from "../cnst";
31
- import { fetch } from "../sig";
32
-
33
- describe("${dict.Model} Signal", () => {
34
- describe("${dict.Model} Service", () => {
35
- let adminAgent: userSpec.AdminAgent;
36
- let userAgent: userSpec.UserAgent;
37
- let ${dict.model}: cnst.${dict.Model};
38
- beforeAll(async () => {
39
- // adminAgent = await adminSpec.getAdminAgentWithInitialize();
40
- // userAgent = await userSpec.getUserAgentWithPhone();
41
- });
42
- it("can create ${dict.model}", async () => {
43
- // ${dict.model} = await ${dict.model}Spec.create${dict.Model}(adminAgent, userAgent);
44
- });
45
- });
46
- });
47
- `;
26
+ return null;
48
27
  }
@@ -21,6 +21,7 @@ apps/*/scripts
21
21
  **/env.server.develop.ts
22
22
  **/env.server.main.ts
23
23
  **/env.server.testing.ts
24
+ **/env.server.type.ts
24
25
  **/*secrets.yaml
25
26
  **/kubeconfig.yaml
26
27
  **/secrets.*
package/esm/index.js CHANGED
@@ -252,8 +252,8 @@ import ora from "ora";
252
252
  var Spinner = class _Spinner {
253
253
  static padding = 12;
254
254
  spinner;
255
- stopWatch;
256
- startAt;
255
+ stopWatch = null;
256
+ startAt = /* @__PURE__ */ new Date();
257
257
  prefix;
258
258
  message;
259
259
  enableSpin;
@@ -690,7 +690,6 @@ var archs = ["amd64", "arm64"];
690
690
  var makeAppConfig = (config, props) => {
691
691
  const { name, repoName } = props;
692
692
  return {
693
- rootLib: config.rootLib,
694
693
  libs: config.libs ?? [],
695
694
  backend: {
696
695
  docker: makeDockerfile("backend", config.backend?.docker ?? {}, props),
@@ -732,7 +731,6 @@ var getAppConfig = async (appRoot, props) => {
732
731
  };
733
732
  var makeLibConfig = (config, props) => {
734
733
  return {
735
- rootLib: config.rootLib,
736
734
  libs: config.libs ?? [],
737
735
  backend: {
738
736
  explicitDependencies: config.backend?.explicitDependencies ?? []
@@ -1408,32 +1406,31 @@ var ScanInfo = class {
1408
1406
  constructor(scanResult) {
1409
1407
  this.name = scanResult.name;
1410
1408
  this.scanResult = scanResult;
1411
- Object.entries(scanResult.files).forEach(
1412
- ([key, value]) => {
1413
- const { databases, services, scalars } = value;
1414
- databases.forEach((modelName) => {
1415
- const model = this.database.get(modelName) ?? /* @__PURE__ */ new Set();
1416
- model.add(key);
1417
- this.database.set(modelName, model);
1418
- this.file[key].all.add(modelName);
1419
- this.file[key].databases.add(modelName);
1420
- });
1421
- services?.forEach((serviceName) => {
1422
- const service = this.service.get(serviceName) ?? /* @__PURE__ */ new Set();
1423
- service.add(key);
1424
- this.service.set(serviceName, service);
1425
- this.file[key].all.add(serviceName);
1426
- this.file[key].services.add(serviceName);
1427
- });
1428
- scalars?.forEach((scalarName) => {
1429
- const scalar = this.scalar.get(scalarName) ?? /* @__PURE__ */ new Set();
1430
- scalar.add(key);
1431
- this.scalar.set(scalarName, scalar);
1432
- this.file[key].all.add(scalarName);
1433
- this.file[key].scalars.add(scalarName);
1434
- });
1435
- }
1436
- );
1409
+ Object.entries(scanResult.files).forEach(([_key, value]) => {
1410
+ const key = _key;
1411
+ const { databases, services, scalars } = value;
1412
+ databases.forEach((modelName) => {
1413
+ const model = this.database.get(modelName) ?? /* @__PURE__ */ new Set();
1414
+ model.add(key);
1415
+ this.database.set(modelName, model);
1416
+ this.file[key].all.add(modelName);
1417
+ this.file[key].databases.add(modelName);
1418
+ });
1419
+ services?.forEach((serviceName) => {
1420
+ const service = this.service.get(serviceName) ?? /* @__PURE__ */ new Set();
1421
+ service.add(key);
1422
+ this.service.set(serviceName, service);
1423
+ this.file[key].all.add(serviceName);
1424
+ this.file[key].services.add(serviceName);
1425
+ });
1426
+ scalars?.forEach((scalarName) => {
1427
+ const scalar = this.scalar.get(scalarName) ?? /* @__PURE__ */ new Set();
1428
+ scalar.add(key);
1429
+ this.scalar.set(scalarName, scalar);
1430
+ this.file[key].all.add(scalarName);
1431
+ this.file[key].scalars.add(scalarName);
1432
+ });
1433
+ });
1437
1434
  }
1438
1435
  getScanResult() {
1439
1436
  return this.scanResult;
@@ -2123,10 +2120,10 @@ var Executor = class _Executor {
2123
2120
  targetPath,
2124
2121
  scanInfo,
2125
2122
  overwrite = true
2126
- }, dict = {}) {
2123
+ }, dict = {}, options = {}) {
2127
2124
  if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
2128
2125
  const getContent = await import(templatePath);
2129
- const result = getContent.default(scanInfo ?? null, dict);
2126
+ const result = getContent.default(scanInfo ?? null, dict, options);
2130
2127
  if (result === null)
2131
2128
  return null;
2132
2129
  const filename = typeof result === "object" ? result.filename : path7.basename(targetPath).replace(".js", ".ts");
@@ -2158,6 +2155,7 @@ var Executor = class _Executor {
2158
2155
  template,
2159
2156
  scanInfo,
2160
2157
  dict = {},
2158
+ options = {},
2161
2159
  overwrite = true
2162
2160
  }) {
2163
2161
  const templatePath = `${getDirname(import.meta.url)}/src/templates${template ? `/${template}` : ""}`;
@@ -2166,7 +2164,8 @@ var Executor = class _Executor {
2166
2164
  const filename = path7.basename(prefixTemplatePath);
2167
2165
  const fileContent = await this.#applyTemplateFile(
2168
2166
  { templatePath: prefixTemplatePath, targetPath: path7.join(basePath2, filename), scanInfo, overwrite },
2169
- dict
2167
+ dict,
2168
+ options
2170
2169
  );
2171
2170
  return fileContent ? [fileContent] : [];
2172
2171
  } else {
@@ -2177,7 +2176,8 @@ var Executor = class _Executor {
2177
2176
  if (fs8.statSync(subpath).isFile()) {
2178
2177
  const fileContent = await this.#applyTemplateFile(
2179
2178
  { templatePath: subpath, targetPath: path7.join(basePath2, subdir), scanInfo, overwrite },
2180
- dict
2179
+ dict,
2180
+ options
2181
2181
  );
2182
2182
  return fileContent ? [fileContent] : [];
2183
2183
  } else
@@ -2186,7 +2186,8 @@ var Executor = class _Executor {
2186
2186
  template: path7.join(template, subdir),
2187
2187
  scanInfo,
2188
2188
  dict,
2189
- overwrite
2189
+ overwrite,
2190
+ options
2190
2191
  });
2191
2192
  })
2192
2193
  )).flat();
@@ -2427,6 +2428,7 @@ var SysExecutor = class extends Executor {
2427
2428
  const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this, { refresh }) : await LibInfo.fromExecutor(this, { refresh });
2428
2429
  if (write) {
2429
2430
  await Promise.all([
2431
+ this._applyTemplate({ basePath: "env", template: "env", scanInfo }),
2430
2432
  this._applyTemplate({ basePath: "lib", template: "lib", scanInfo }),
2431
2433
  this._applyTemplate({ basePath: ".", template: "server.ts", scanInfo }),
2432
2434
  this._applyTemplate({ basePath: ".", template: "client.ts", scanInfo }),
@@ -2455,6 +2457,7 @@ var SysExecutor = class extends Executor {
2455
2457
  const libInfos = [...scanInfo.getLibInfos().values()];
2456
2458
  await Promise.all(
2457
2459
  libInfos.map((libInfo) => [
2460
+ libInfo.exec._applyTemplate({ basePath: "env", template: "env", scanInfo: libInfo }),
2458
2461
  libInfo.exec._applyTemplate({ basePath: "lib", template: "lib", scanInfo: libInfo }),
2459
2462
  libInfo.exec._applyTemplate({ basePath: ".", template: "server.ts", scanInfo: libInfo }),
2460
2463
  libInfo.exec._applyTemplate({ basePath: ".", template: "client.ts", scanInfo: libInfo }),
@@ -2652,8 +2655,6 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2652
2655
  }
2653
2656
  };
2654
2657
  var LibExecutor = class _LibExecutor extends SysExecutor {
2655
- workspaceRoot;
2656
- repoName;
2657
2658
  dist;
2658
2659
  emoji = execEmoji.lib;
2659
2660
  constructor({ workspace, name }) {
@@ -2745,7 +2746,7 @@ var getHostConfig = (host = akanCloudHost) => {
2745
2746
  };
2746
2747
  var setHostConfig = (host = akanCloudHost, config = {}) => {
2747
2748
  const akanConfig = getAkanGlobalConfig();
2748
- akanConfig[host] = config;
2749
+ akanConfig.cloudHost[host] = config;
2749
2750
  setAkanGlobalConfig(akanConfig);
2750
2751
  };
2751
2752
  var getSelf = async (token) => {
@@ -2852,24 +2853,24 @@ var FileEditor = class {
2852
2853
  var CapacitorApp = class {
2853
2854
  constructor(app) {
2854
2855
  this.app = app;
2856
+ this.project = new MobileProject(this.app.cwdPath, {
2857
+ android: { path: "android" },
2858
+ ios: { path: "ios/App" }
2859
+ });
2855
2860
  }
2856
2861
  project;
2857
2862
  iosTargetName = "App";
2858
2863
  async init() {
2859
- const project = new MobileProject(this.app.cwdPath, {
2860
- android: { path: "android" },
2861
- ios: { path: "ios/App" }
2862
- });
2863
- await project.load();
2864
+ const project = this.project;
2865
+ await this.project.load();
2864
2866
  if (!project.android) {
2865
2867
  await this.app.spawn("npx", ["cap", "add", "android"]);
2866
- await project.load();
2868
+ await this.project.load();
2867
2869
  }
2868
2870
  if (!project.ios) {
2869
2871
  await this.app.spawn("npx", ["cap", "add", "ios"]);
2870
- await project.load();
2872
+ await this.project.load();
2871
2873
  }
2872
- this.project = project;
2873
2874
  return this;
2874
2875
  }
2875
2876
  async save() {
@@ -3291,13 +3292,16 @@ var handleOption = (programCommand, argMeta) => {
3291
3292
  flag = argMeta.name.slice(0, 1).toLowerCase(),
3292
3293
  desc = argMeta.name,
3293
3294
  example,
3294
- enum: choices,
3295
+ enum: enumChoices,
3295
3296
  ask
3296
3297
  } = argMeta.argsOption;
3297
3298
  const kebabName = camelToKebabCase(argMeta.name);
3299
+ const choices = enumChoices?.map(
3300
+ (choice) => typeof choice === "object" ? { value: choice.value, name: choice.label } : { value: choice, name: choice.toString() }
3301
+ );
3298
3302
  programCommand.option(
3299
3303
  `-${flag}, --${kebabName}${type === "boolean" ? " [boolean]" : ` <${kebabName}>`}`,
3300
- `${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.join(", ")})` : ""}`
3304
+ `${desc}${ask ? ` (${ask})` : ""}${example ? ` (example: ${example})` : ""}${choices ? ` (choices: ${choices.map((choice) => choice.name).join(", ")})` : ""}`
3301
3305
  );
3302
3306
  return programCommand;
3303
3307
  };
@@ -3322,7 +3326,7 @@ var convertOptionValue = (value, type) => {
3322
3326
  var getOptionValue = async (argMeta, opt) => {
3323
3327
  const {
3324
3328
  name,
3325
- argsOption: { enum: choices, default: defaultValue, type, desc, nullable, example, ask }
3329
+ argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, example, ask }
3326
3330
  } = argMeta;
3327
3331
  if (opt[argMeta.name] !== void 0)
3328
3332
  return convertOptionValue(opt[argMeta.name], type ?? "string");
@@ -3330,11 +3334,11 @@ var getOptionValue = async (argMeta, opt) => {
3330
3334
  return defaultValue;
3331
3335
  else if (nullable)
3332
3336
  return null;
3333
- if (choices) {
3334
- const choice = await select2({
3335
- message: ask ?? desc ?? `Select the ${name} value`,
3336
- choices: choices.map((choice2) => choice2.toString())
3337
- });
3337
+ if (enumChoices) {
3338
+ const choices = enumChoices.map(
3339
+ (choice2) => typeof choice2 === "object" ? { value: choice2.value, name: choice2.label } : { value: choice2, name: choice2.toString() }
3340
+ );
3341
+ const choice = await select2({ message: ask ?? desc ?? `Select the ${name} value`, choices });
3338
3342
  return choice;
3339
3343
  } else if (type === "boolean") {
3340
3344
  const message = ask ?? desc ?? `Do you want to set ${name}? ${desc ? ` (${desc})` : ""}: `;
@@ -3629,7 +3633,7 @@ var AiSession = class _AiSession {
3629
3633
  }
3630
3634
  messageHistory = [];
3631
3635
  sessionKey;
3632
- isCacheLoaded;
3636
+ isCacheLoaded = false;
3633
3637
  workspace;
3634
3638
  constructor(type, { workspace, cacheKey, isContinued }) {
3635
3639
  this.workspace = workspace;
@@ -4434,11 +4438,12 @@ import commonjs from "vite-plugin-commonjs";
4434
4438
  import { nodePolyfills } from "vite-plugin-node-polyfills";
4435
4439
  import tsconfigPaths from "vite-tsconfig-paths";
4436
4440
  var ApplicationRunner = class {
4437
- async createApplication(appName, workspace) {
4441
+ async createApplication(appName, workspace, libs = []) {
4438
4442
  await workspace.applyTemplate({
4439
4443
  basePath: `apps/${appName}`,
4440
4444
  template: "app",
4441
- dict: { appName, companyName: workspace.repoName, startDomain: "localhost" }
4445
+ dict: { appName, companyName: workspace.repoName, startDomain: "localhost" },
4446
+ options: { libs }
4442
4447
  });
4443
4448
  workspace.setTsPaths("app", appName);
4444
4449
  return AppExecutor.from(workspace, appName);
@@ -4528,7 +4533,7 @@ var ApplicationRunner = class {
4528
4533
  });
4529
4534
  const rootPackageJson = app.workspace.getPackageJson();
4530
4535
  const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson);
4531
- buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
4536
+ buildResult.outputFiles.forEach((file) => app.dist.writeFile(file.path, file.text));
4532
4537
  const appPackageJson = {
4533
4538
  name: `${app.name}/backend`,
4534
4539
  description: `${app.name} backend`,
@@ -4586,7 +4591,7 @@ var ApplicationRunner = class {
4586
4591
  "react-dom",
4587
4592
  "typescript"
4588
4593
  ]);
4589
- buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
4594
+ buildResult.outputFiles.forEach((file) => app.dist.writeFile(file.path, file.text));
4590
4595
  const appPackageJson = {
4591
4596
  name: `${app.name}/frontend`,
4592
4597
  description: `${app.name} frontend`,
@@ -5154,9 +5159,9 @@ var ApplicationRunner = class {
5154
5159
  var ApplicationScript = class {
5155
5160
  #runner = new ApplicationRunner();
5156
5161
  libraryScript = new LibraryScript();
5157
- async createApplication(appName, workspace, { start = false } = {}) {
5162
+ async createApplication(appName, workspace, { start = false, libs = [] } = {}) {
5158
5163
  const spinner = workspace.spinning("Creating application...");
5159
- const app = await this.#runner.createApplication(appName, workspace);
5164
+ const app = await this.#runner.createApplication(appName, workspace, libs);
5160
5165
  spinner.succeed(`Application created in apps/${app.name}`);
5161
5166
  await this.syncApplication(app);
5162
5167
  if (start)
@@ -6758,11 +6763,13 @@ var WorkspaceScript = class {
6758
6763
  #runner = new WorkspaceRunner();
6759
6764
  applicationScript = new ApplicationScript();
6760
6765
  libraryScript = new LibraryScript();
6761
- async createWorkspace(repoName, appName, dirname3 = ".") {
6766
+ async createWorkspace(repoName, appName, dirname3 = ".", installLibs) {
6762
6767
  const workspace = await this.#runner.createWorkspace(repoName, appName, dirname3);
6763
- await this.libraryScript.installLibrary(workspace, "util");
6764
- await this.libraryScript.installLibrary(workspace, "shared");
6765
- await this.applicationScript.createApplication(appName, workspace);
6768
+ if (installLibs) {
6769
+ await this.libraryScript.installLibrary(workspace, "util");
6770
+ await this.libraryScript.installLibrary(workspace, "shared");
6771
+ }
6772
+ await this.applicationScript.createApplication(appName, workspace, { libs: installLibs ? ["util", "shared"] : [] });
6766
6773
  Logger.rawLog(`
6767
6774
  \u{1F389} Welcome aboard! Workspace created in ${dirname3}/${repoName}`);
6768
6775
  Logger.rawLog(`\u{1F680} Run \`cd ${repoName} && akan start ${appName}\` to start the development server.`);
@@ -6822,11 +6829,12 @@ var WorkspaceScript = class {
6822
6829
  // pkgs/@akanjs/cli/src/workspace/workspace.command.ts
6823
6830
  var WorkspaceCommand = class {
6824
6831
  workspaceScript = new WorkspaceScript();
6825
- async createWorkspace(workspaceName, app, dir) {
6832
+ async createWorkspace(workspaceName, app, dir, libs) {
6826
6833
  await this.workspaceScript.createWorkspace(
6827
6834
  workspaceName.toLowerCase().replace(/ /g, "-"),
6828
6835
  app.toLowerCase().replace(/ /g, "-"),
6829
- dir
6836
+ dir,
6837
+ libs
6830
6838
  );
6831
6839
  }
6832
6840
  async generateMongo(workspace) {
@@ -6852,7 +6860,18 @@ __decorateClass([
6852
6860
  Target.Public(),
6853
6861
  __decorateParam(0, Argument("workspaceName", { desc: "what is the name of your organization?" })),
6854
6862
  __decorateParam(1, Option("app", { desc: "what is the codename of your first application? (e.g. myapp)" })),
6855
- __decorateParam(2, Option("dir", { desc: "directory of workspace", default: process.env.USE_AKANJS_PKGS === "true" ? "local" : "." }))
6863
+ __decorateParam(2, Option("dir", { desc: "directory of workspace", default: process.env.USE_AKANJS_PKGS === "true" ? "local" : "." })),
6864
+ __decorateParam(3, Option("libs", {
6865
+ type: "boolean",
6866
+ desc: "Do you want to install shared and util libraries? (admin, user file, etc.)",
6867
+ enum: [
6868
+ { label: "No, I want to start with empty workspace (Recommended)", value: false },
6869
+ {
6870
+ label: "Yes, I want to accelerate development by installing shared and util libraries (for akanjs experts)",
6871
+ value: true
6872
+ }
6873
+ ]
6874
+ }))
6856
6875
  ], WorkspaceCommand.prototype, "createWorkspace", 1);
6857
6876
  __decorateClass([
6858
6877
  Target.Public(),
@@ -1,12 +1,11 @@
1
1
  // pkgs/@akanjs/cli/src/templates/app/akan.config.ts
2
- function getContent(scanInfo, dict) {
2
+ function getContent(scanInfo, dict, options) {
3
3
  return `
4
4
  import type { AppConfig } from "@akanjs/config";
5
5
 
6
- const config: AppConfig = {
7
- rootLib: "shared",
6
+ const config: AppConfig = ${options.libs.length ? `{
8
7
  libs: ["util", "shared"],
9
- };
8
+ }` : "{}"};
10
9
 
11
10
  export default config;
12
11
  `;
@@ -1,5 +1,6 @@
1
1
  // pkgs/@akanjs/cli/src/templates/app/app/[lang]/layout.tsx
2
- function getContent(scanInfo, dict) {
2
+ function getContent(scanInfo, dict, options) {
3
+ const isUsingShared = options.libs.includes("shared");
3
4
  return {
4
5
  filename: "layout.tsx",
5
6
  content: `
@@ -8,7 +9,7 @@ import { RootLayoutProps } from "@akanjs/client";
8
9
  import { System } from "@akanjs/ui";
9
10
  import { env } from "@${dict.appName}/env/env.client";
10
11
  import { fetch } from "@${dict.appName}/client";
11
- import { Auth } from "@shared/ui";
12
+ ${isUsingShared ? "import { Auth } from '@shared/ui';" : ""}
12
13
 
13
14
  export const metadata = { title: "${dict.appName}" };
14
15
 
@@ -22,8 +23,7 @@ export default function Layout({ children, params }: RootLayoutProps) {
22
23
  // className="bg-base-100"
23
24
  env={env}
24
25
  >
25
- {children}
26
- <Auth.User />
26
+ {children}${isUsingShared ? "\n <Auth.User />\n <Auth.Admin />" : ""}
27
27
  </System.Provider>
28
28
  );
29
29
  }
@@ -7,7 +7,10 @@ function getContent(scanInfo, dict) {
7
7
  import { st } from "@${dict.appName}/client";
8
8
  import { System } from "@akanjs/ui";
9
9
 
10
- export default function Layout({ children }) {
10
+ interface LayoutProps {
11
+ children: React.ReactNode;
12
+ }
13
+ export default function Layout({ children }: LayoutProps) {
11
14
  return <System.Root st={st}>{children}</System.Root>;
12
15
  }
13
16
  `
@@ -0,0 +1,16 @@
1
+ // pkgs/@akanjs/cli/src/templates/env/env.server.type.ts
2
+ function getContent(scanInfo, dict = {}) {
3
+ if (!scanInfo)
4
+ return null;
5
+ const libs = scanInfo.getLibs();
6
+ return `
7
+ ${libs.length ? libs.map((lib) => `import { env as ${lib}Option } from "@${lib}/server";`).join("\n") : 'import { baseEnv } from "@akanjs/base";'}
8
+
9
+ export const libEnv = {
10
+ ${libs.length ? libs.map((lib) => ` ...${lib}Option,`).join("\n") : " ...baseEnv,"}
11
+ };
12
+ `;
13
+ }
14
+ export {
15
+ getContent as default
16
+ };
@@ -4,7 +4,6 @@ function getContent(scanInfo, dict = {}) {
4
4
  if (!scanInfo)
5
5
  return null;
6
6
  const libs = scanInfo.getLibs();
7
- const rootLib = scanInfo.akanConfig.rootLib;
8
7
  const libInfos = [...scanInfo.getLibInfos().values()];
9
8
  const extendedModels = Object.fromEntries(
10
9
  [...scanInfo.file.signal.databases].map(
@@ -27,7 +26,7 @@ ${Object.entries(extendedModels).map(([modelName, extendedModels2]) => {
27
26
  }`;
28
27
  }).join("\n")}
29
28
 
30
- export const root = ${libs.length ? rootLib ?? libs[0] : "baseFetch"};
29
+ export const root = ${libs.length ? libs[0] : "baseFetch"};
31
30
  export const libFetches = [${libs.length ? libs.map((lib) => `${lib}.fetch`).join(", ") : "baseFetch"}] as const;
32
31
  `;
33
32
  }
@@ -34,7 +34,7 @@ ${[...databaseModules, ...serviceModules].map((module) => ` ${capitalize(module
34
34
  );
35
35
  export const serializedSignals = signals.map((signal) => signalInfo.serialize(signal));
36
36
 
37
- ${databaseModules.map((module) => `export const ${module} = gqlOf(cnst.${module}, db.${module}.Filter, ${capitalize(module)}Signal${scanInfo.name !== "shared" && ["user", "setting", "summary"].includes(module) ? `, { overwrite: root.${module} }` : ""});`).join("\n")}
37
+ ${databaseModules.map((module) => `export const ${module} = gqlOf(cnst.${module}, db.${module}.Filter, ${capitalize(module)}Signal);`).join("\n")}
38
38
 
39
39
  export const fetch = makeFetch(...libFetches, {
40
40
  ${databaseModules.map((module) => `...${module},`).join("\n")}
@@ -1,14 +1,15 @@
1
1
  **/script.ts
2
2
  **/script*.ts
3
3
  **/.env
4
- **/env.client.debug.ts*
5
- **/env.client.develop.ts*
6
- **/env.client.main.ts*
7
- **/env.client.testing.ts*
8
- **/env.server.debug.ts*
9
- **/env.server.develop.ts*
10
- **/env.server.main.ts*
11
- **/env.server.testing.ts*
4
+ **/env.client.debug.ts
5
+ **/env.client.develop.ts
6
+ **/env.client.main.ts
7
+ **/env.client.testing.ts
8
+ **/env.server.debug.ts
9
+ **/env.server.develop.ts
10
+ **/env.server.main.ts
11
+ **/env.server.testing.ts
12
+ **/env.server.type.ts
12
13
 
13
14
  # System Files
14
15
  .DS_Store
@@ -4,7 +4,6 @@ function getContent(scanInfo, dict) {
4
4
  import type { LibConfig } from "@akanjs/config";
5
5
 
6
6
  const config: LibConfig = {
7
- rootLib: "shared",
8
7
  libs: ["util", "shared"],
9
8
  };
10
9
 
@@ -3,14 +3,13 @@ function getContent(scanInfo, dict) {
3
3
  return `
4
4
  import { Public } from "@akanjs/nest";
5
5
  import { endpoint, internal, slice } from "@akanjs/signal";
6
- import { Admin } from "@shared/nest";
7
6
 
8
7
  import * as cnst from "../cnst";
9
8
  import * as srv from "../srv";
10
9
 
11
10
  export class ${dict.Model}Internal extends internal(srv.${dict.model}, () => ({})) {}
12
11
 
13
- export class ${dict.Model}Slice extends slice(srv.${dict.model}, { guards: { root: Admin, get: Public, cru: Public } }, (init) => ({
12
+ export class ${dict.Model}Slice extends slice(srv.${dict.model}, { guards: { root: Public, get: Public, cru: Public } }, (init) => ({
14
13
  inPublic: init()
15
14
  .exec(function () {
16
15
  return this.${dict.model}Service.queryAny();
@@ -1,18 +1,6 @@
1
1
  // pkgs/@akanjs/cli/src/templates/module/__model__.signal.spec.ts
2
2
  function getContent(scanInfo, dict) {
3
- return `
4
- import * as adminSpec from "@shared/lib/admin/admin.signal.spec";
5
- import * as userSpec from "@${dict.sysName}/lib/user/user.signal.spec";
6
- import * as cnst from "../cnst";
7
- import { fetch } from "../sig";
8
- import { sampleOf } from "@akanjs/test";
9
-
10
- export const create${dict.Model} = async (adminAgent: userSpec.AdminAgent, userAgent: userSpec.UserAgent) => {
11
- const ${dict.model}Input = sampleOf(cnst.${dict.Model}Input);
12
- const ${dict.model} = await adminAgent.fetch.create${dict.Model}(${dict.model}Input);
13
- return ${dict.model};
14
- };
15
- `;
3
+ return null;
16
4
  }
17
5
  export {
18
6
  getContent as default
@@ -1,27 +1,6 @@
1
1
  // pkgs/@akanjs/cli/src/templates/module/__model__.signal.test.ts
2
2
  function getContent(scanInfo, dict) {
3
- return `
4
- import * as adminSpec from "@shared/lib/admin/admin.signal.spec";
5
- import * as userSpec from "@${dict.sysName}/lib/user/user.signal.spec";
6
- import * as ${dict.model}Spec from "@${dict.sysName}/lib/${dict.model}/${dict.model}.signal.spec";
7
- import * as cnst from "../cnst";
8
- import { fetch } from "../sig";
9
-
10
- describe("${dict.Model} Signal", () => {
11
- describe("${dict.Model} Service", () => {
12
- let adminAgent: userSpec.AdminAgent;
13
- let userAgent: userSpec.UserAgent;
14
- let ${dict.model}: cnst.${dict.Model};
15
- beforeAll(async () => {
16
- // adminAgent = await adminSpec.getAdminAgentWithInitialize();
17
- // userAgent = await userSpec.getUserAgentWithPhone();
18
- });
19
- it("can create ${dict.model}", async () => {
20
- // ${dict.model} = await ${dict.model}Spec.create${dict.Model}(adminAgent, userAgent);
21
- });
22
- });
23
- });
24
- `;
3
+ return null;
25
4
  }
26
5
  export {
27
6
  getContent as default
@@ -21,6 +21,7 @@ apps/*/scripts
21
21
  **/env.server.develop.ts
22
22
  **/env.server.main.ts
23
23
  **/env.server.testing.ts
24
+ **/env.server.type.ts
24
25
  **/*secrets.yaml
25
26
  **/kubeconfig.yaml
26
27
  **/secrets.*
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "sourceType": "module",
4
4
  "name": "@akanjs/cli",
5
- "version": "0.9.58-canary.3",
5
+ "version": "0.9.58-canary.5",
6
6
  "bin": {
7
7
  "akan": "esm/index.js"
8
8
  },
@@ -10,7 +10,7 @@ export interface ReleaseSourceOptions {
10
10
  }
11
11
  export declare class ApplicationRunner {
12
12
  #private;
13
- createApplication(appName: string, workspace: Workspace): Promise<AppExecutor>;
13
+ createApplication(appName: string, workspace: Workspace, libs?: string[]): Promise<AppExecutor>;
14
14
  removeApplication(app: App): Promise<void>;
15
15
  getConfig(app: App): Promise<import("@akanjs/config").AppConfigResult>;
16
16
  scanSync(app: App, { refresh }?: {
@@ -4,8 +4,9 @@ import { type ReleaseSourceOptions } from "./application.runner";
4
4
  export declare class ApplicationScript {
5
5
  #private;
6
6
  libraryScript: LibraryScript;
7
- createApplication(appName: string, workspace: Workspace, { start }?: {
7
+ createApplication(appName: string, workspace: Workspace, { start, libs }?: {
8
8
  start?: boolean;
9
+ libs?: string[];
9
10
  }): Promise<void>;
10
11
  removeApplication(app: App): Promise<void>;
11
12
  sync(sys: Sys): Promise<void>;
@@ -2,5 +2,7 @@ import type { AppInfo, LibInfo } from "@akanjs/devkit";
2
2
  interface Dict {
3
3
  appName: string;
4
4
  }
5
- export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): string;
5
+ export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict, options: {
6
+ libs: string[];
7
+ }): string;
6
8
  export {};
@@ -2,7 +2,9 @@ import type { AppInfo, LibInfo } from "@akanjs/devkit";
2
2
  interface Dict {
3
3
  appName: string;
4
4
  }
5
- export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): {
5
+ export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict, options: {
6
+ libs: string[];
7
+ }): {
6
8
  filename: string;
7
9
  content: string;
8
10
  };
@@ -0,0 +1,4 @@
1
+ import type { AppInfo, LibInfo } from "@akanjs/devkit";
2
+ export default function getContent(scanInfo: AppInfo | LibInfo | null, dict?: {
3
+ [key: string]: string;
4
+ }): string | null;
@@ -4,5 +4,5 @@ interface Dict {
4
4
  model: string;
5
5
  sysName: string;
6
6
  }
7
- export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): string;
7
+ export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): null;
8
8
  export {};
@@ -4,5 +4,5 @@ interface Dict {
4
4
  model: string;
5
5
  sysName: string;
6
6
  }
7
- export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): string;
7
+ export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): null;
8
8
  export {};
@@ -2,7 +2,7 @@ import { Exec, Workspace } from "@akanjs/devkit";
2
2
  import { WorkspaceScript } from "./workspace.script";
3
3
  export declare class WorkspaceCommand {
4
4
  workspaceScript: WorkspaceScript;
5
- createWorkspace(workspaceName: string, app: string, dir: string): Promise<void>;
5
+ createWorkspace(workspaceName: string, app: string, dir: string, libs: boolean): Promise<void>;
6
6
  generateMongo(workspace: Workspace): Promise<void>;
7
7
  lint(exec: Exec, fix: boolean, workspace: Workspace): Promise<void>;
8
8
  lintAll(fix: boolean, workspace: Workspace): Promise<void>;
@@ -5,7 +5,7 @@ export declare class WorkspaceScript {
5
5
  #private;
6
6
  applicationScript: ApplicationScript;
7
7
  libraryScript: LibraryScript;
8
- createWorkspace(repoName: string, appName: string, dirname?: string): Promise<void>;
8
+ createWorkspace(repoName: string, appName: string, dirname: string | undefined, installLibs: boolean): Promise<void>;
9
9
  generateMongo(workspace: Workspace): Promise<void>;
10
10
  lint(exec: Exec, workspace: Workspace, { fix }?: {
11
11
  fix?: boolean;