@akanjs/cli 0.9.58 → 0.9.60-canary.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.
Files changed (70) hide show
  1. package/cjs/index.js +105 -81
  2. package/cjs/src/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -3
  3. package/cjs/src/templates/app/akan.config.js +3 -4
  4. package/cjs/src/templates/app/app/[lang]/layout.js +4 -4
  5. package/cjs/src/templates/app/app/layout.js +4 -1
  6. package/cjs/src/templates/app/env/env.server.testing.ts.template +2 -3
  7. package/cjs/src/templates/app/lib/___appName__/__appName__.dictionary.js +6 -3
  8. package/cjs/src/templates/app/lib/___appName__/__appName__.service.js +1 -1
  9. package/cjs/src/templates/env/env.server.type.js +36 -0
  10. package/cjs/src/templates/lib/__lib/lib.signal.js +1 -2
  11. package/cjs/src/templates/lib/sig.js +1 -1
  12. package/cjs/src/templates/libRoot/.gitignore.template +9 -8
  13. package/cjs/src/templates/libRoot/akan.config.js +0 -1
  14. package/cjs/src/templates/libRoot/env/env.server.example.ts.template +2 -3
  15. package/cjs/src/templates/libRoot/env/env.server.testing.ts.template +2 -3
  16. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +7 -3
  17. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -1
  18. package/cjs/src/templates/localDev/docker-compose.yaml.template +2 -2
  19. package/cjs/src/templates/module/__model__.dictionary.js +0 -1
  20. package/cjs/src/templates/module/__model__.document.js +1 -1
  21. package/cjs/src/templates/module/__model__.service.js +1 -1
  22. package/cjs/src/templates/module/__model__.signal.js +1 -2
  23. package/cjs/src/templates/module/__model__.signal.spec.js +1 -13
  24. package/cjs/src/templates/module/__model__.signal.test.js +1 -22
  25. package/cjs/src/templates/workspaceRoot/.gitignore.template +1 -0
  26. package/cjs/src/templates/workspaceRoot/package.json.template +9 -9
  27. package/esm/index.js +105 -81
  28. package/esm/src/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -3
  29. package/esm/src/templates/app/akan.config.js +3 -4
  30. package/esm/src/templates/app/app/[lang]/layout.js +4 -4
  31. package/esm/src/templates/app/app/layout.js +4 -1
  32. package/esm/src/templates/app/env/env.server.testing.ts.template +2 -3
  33. package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +6 -3
  34. package/esm/src/templates/app/lib/___appName__/__appName__.service.js +1 -1
  35. package/esm/src/templates/env/env.server.type.js +16 -0
  36. package/esm/src/templates/lib/__lib/lib.signal.js +1 -2
  37. package/esm/src/templates/lib/sig.js +1 -1
  38. package/esm/src/templates/libRoot/.gitignore.template +9 -8
  39. package/esm/src/templates/libRoot/akan.config.js +0 -1
  40. package/esm/src/templates/libRoot/env/env.server.example.ts.template +2 -3
  41. package/esm/src/templates/libRoot/env/env.server.testing.ts.template +2 -3
  42. package/esm/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +7 -3
  43. package/esm/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -1
  44. package/esm/src/templates/localDev/docker-compose.yaml.template +2 -2
  45. package/esm/src/templates/module/__model__.dictionary.js +0 -1
  46. package/esm/src/templates/module/__model__.document.js +1 -1
  47. package/esm/src/templates/module/__model__.service.js +1 -1
  48. package/esm/src/templates/module/__model__.signal.js +1 -2
  49. package/esm/src/templates/module/__model__.signal.spec.js +1 -13
  50. package/esm/src/templates/module/__model__.signal.test.js +1 -22
  51. package/esm/src/templates/workspaceRoot/.gitignore.template +1 -0
  52. package/esm/src/templates/workspaceRoot/package.json.template +9 -9
  53. package/package.json +1 -1
  54. package/src/application/application.runner.d.ts +1 -1
  55. package/src/application/application.script.d.ts +2 -1
  56. package/src/cloud/cloud.command.d.ts +1 -1
  57. package/src/cloud/cloud.runner.d.ts +1 -1
  58. package/src/cloud/cloud.script.d.ts +1 -1
  59. package/src/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -3
  60. package/src/templates/app/akan.config.d.ts +3 -1
  61. package/src/templates/app/app/[lang]/layout.d.ts +3 -1
  62. package/src/templates/env/env.server.type.d.ts +4 -0
  63. package/src/templates/module/__model__.signal.spec.d.ts +1 -1
  64. package/src/templates/module/__model__.signal.test.d.ts +1 -1
  65. package/src/workspace/workspace.command.d.ts +1 -1
  66. package/src/workspace/workspace.script.d.ts +1 -1
  67. package/cjs/src/templates/app/page.test.ts.template +0 -10
  68. package/cjs/src/templates/app/playwright.config.ts.template +0 -6
  69. package/esm/src/templates/app/page.test.ts.template +0 -10
  70. package/esm/src/templates/app/playwright.config.ts.template +0 -6
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)
@@ -5831,8 +5836,8 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
5831
5836
  const tag = isOfficialRelease ? "latest" : patchVersionOfBase.split("-").at(1) ?? "dev";
5832
5837
  const getNextVersion = async (prefix, tag2) => {
5833
5838
  try {
5834
- const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base", { version: prefix });
5835
- const latestPatch = parseInt(latestPublishedVersionOfBase.split(".").at(-1) ?? "0");
5839
+ const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base", { version: tag2 });
5840
+ const latestPatch = latestPublishedVersionOfBase.startsWith(prefix) ? parseInt(latestPublishedVersionOfBase.split(".").at(-1) ?? "-1") : -1;
5836
5841
  const nextVersion2 = `${prefix}.${latestPatch + 1}`;
5837
5842
  return { nextVersion: nextVersion2, latestPublishedVersion: latestPublishedVersionOfBase };
5838
5843
  } catch (e) {
@@ -5866,17 +5871,17 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
5866
5871
  );
5867
5872
  Logger.info("All libraries are published to npm");
5868
5873
  }
5869
- async update(workspace) {
5874
+ async update(workspace, tag = "latest") {
5870
5875
  if (!workspace.exists("package.json"))
5871
- await workspace.spawn("npm", ["update", "-g", "@akanjs/cli", "--latest"]);
5876
+ await workspace.spawn("npm", ["update", "-g", "@akanjs/cli", "--latest", `--tag=${tag}`]);
5872
5877
  else
5873
5878
  await Promise.all([
5874
- workspace.spawn("npm", ["update", "-g", "@akanjs/cli", "--latest"]),
5875
- this.#updateAkanPkgs(workspace)
5879
+ workspace.spawn("npm", ["update", "-g", "@akanjs/cli", "--latest", `--tag=${tag}`]),
5880
+ this.#updateAkanPkgs(workspace, tag)
5876
5881
  ]);
5877
5882
  }
5878
- async #updateAkanPkgs(workspace) {
5879
- const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base");
5883
+ async #updateAkanPkgs(workspace, tag = "latest") {
5884
+ const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base", { version: tag });
5880
5885
  const rootPackageJson = workspace.getPackageJson();
5881
5886
  if (!rootPackageJson.dependencies)
5882
5887
  throw new Error("No dependencies found in package.json");
@@ -5920,9 +5925,9 @@ var CloudScript = class {
5920
5925
  );
5921
5926
  await this.#runner.deployAkan(workspace, akanPkgs);
5922
5927
  }
5923
- async update(workspace) {
5928
+ async update(workspace, tag = "latest") {
5924
5929
  const spinner = workspace.spinning("Updating Akan.js packages and CLI...");
5925
- await this.#runner.update(workspace);
5930
+ await this.#runner.update(workspace, tag);
5926
5931
  spinner.succeed("Akan.js packages and CLI updated, global version is below");
5927
5932
  Logger.raw("> Akan version: ");
5928
5933
  await workspace.spawn("akan", ["--version"], { stdio: "inherit" });
@@ -5950,8 +5955,8 @@ var CloudCommand = class {
5950
5955
  async deployAkan(workspace) {
5951
5956
  await this.cloudScript.deployAkan(workspace);
5952
5957
  }
5953
- async update(workspace) {
5954
- await this.cloudScript.update(workspace);
5958
+ async update(workspace, tag) {
5959
+ await this.cloudScript.update(workspace, tag);
5955
5960
  }
5956
5961
  };
5957
5962
  __decorateClass([
@@ -5981,7 +5986,12 @@ __decorateClass([
5981
5986
  ], CloudCommand.prototype, "deployAkan", 1);
5982
5987
  __decorateClass([
5983
5988
  Target.Public(),
5984
- __decorateParam(0, Workspace())
5989
+ __decorateParam(0, Workspace()),
5990
+ __decorateParam(1, Option("tag", {
5991
+ desc: "tag of the update",
5992
+ default: "latest",
5993
+ enum: ["latest", "dev", "canary", "beta", "rc", "alpha"]
5994
+ }))
5985
5995
  ], CloudCommand.prototype, "update", 1);
5986
5996
  CloudCommand = __decorateClass([
5987
5997
  Commands()
@@ -6777,11 +6787,13 @@ var WorkspaceScript = class {
6777
6787
  #runner = new WorkspaceRunner();
6778
6788
  applicationScript = new ApplicationScript();
6779
6789
  libraryScript = new LibraryScript();
6780
- async createWorkspace(repoName, appName, dirname3 = ".") {
6790
+ async createWorkspace(repoName, appName, dirname3 = ".", installLibs) {
6781
6791
  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);
6792
+ if (installLibs) {
6793
+ await this.libraryScript.installLibrary(workspace, "util");
6794
+ await this.libraryScript.installLibrary(workspace, "shared");
6795
+ }
6796
+ await this.applicationScript.createApplication(appName, workspace, { libs: installLibs ? ["util", "shared"] : [] });
6785
6797
  Logger.rawLog(`
6786
6798
  \u{1F389} Welcome aboard! Workspace created in ${dirname3}/${repoName}`);
6787
6799
  Logger.rawLog(`\u{1F680} Run \`cd ${repoName} && akan start ${appName}\` to start the development server.`);
@@ -6841,11 +6853,12 @@ var WorkspaceScript = class {
6841
6853
  // pkgs/@akanjs/cli/src/workspace/workspace.command.ts
6842
6854
  var WorkspaceCommand = class {
6843
6855
  workspaceScript = new WorkspaceScript();
6844
- async createWorkspace(workspaceName, app, dir) {
6856
+ async createWorkspace(workspaceName, app, dir, libs) {
6845
6857
  await this.workspaceScript.createWorkspace(
6846
6858
  workspaceName.toLowerCase().replace(/ /g, "-"),
6847
6859
  app.toLowerCase().replace(/ /g, "-"),
6848
- dir
6860
+ dir,
6861
+ libs
6849
6862
  );
6850
6863
  }
6851
6864
  async generateMongo(workspace) {
@@ -6871,7 +6884,18 @@ __decorateClass([
6871
6884
  Target.Public(),
6872
6885
  __decorateParam(0, Argument("workspaceName", { desc: "what is the name of your organization?" })),
6873
6886
  __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" : "." }))
6887
+ __decorateParam(2, Option("dir", { desc: "directory of workspace", default: process.env.USE_AKANJS_PKGS === "true" ? "local" : "." })),
6888
+ __decorateParam(3, Option("libs", {
6889
+ type: "boolean",
6890
+ desc: "Do you want to install shared and util libraries? (admin, user file, etc.)",
6891
+ enum: [
6892
+ { label: "No, I want to start with empty workspace (Recommended)", value: false },
6893
+ {
6894
+ label: "Yes, I want to accelerate development by installing shared and util libraries (for akanjs experts)",
6895
+ value: true
6896
+ }
6897
+ ]
6898
+ }))
6875
6899
  ], WorkspaceCommand.prototype, "createWorkspace", 1);
6876
6900
  __decorateClass([
6877
6901
  Target.Public(),
@@ -88,8 +88,6 @@ const MyComponent = () => {
88
88
  value={formState.status}
89
89
  items={cnst.Status}
90
90
  onChange={(status) => st.do.setStatusOnMyModel(status)}
91
- model="myModel"
92
- field="status"
93
91
  />
94
92
  </>
95
93
  );
@@ -280,7 +278,6 @@ Components seamlessly integrate with the state management:
280
278
  ## Best Practices
281
279
 
282
280
  1. **Use the appropriate component type** for each part of your feature:
283
-
284
281
  - Use **Field** components for data entry
285
282
  - Use **Data** components for data visualization and management
286
283
  - Use **Load** components for data fetching
@@ -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
  `
@@ -1,7 +1,6 @@
1
- import { env as shared } from "@shared/server";
2
-
3
1
  import type { ModulesOptions } from "../lib/option";
2
+ import { libEnv } from "./env.server.type";
4
3
 
5
4
  export const env: ModulesOptions = {
6
- ...shared,
5
+ ...libEnv,
7
6
  };
@@ -24,9 +24,12 @@ __export(appName_dictionary_exports, {
24
24
  module.exports = __toCommonJS(appName_dictionary_exports);
25
25
  function getContent(scanInfo, dict) {
26
26
  return `
27
- import type { SignalDictionary } from "@akanjs/dictionary";
27
+ import { serviceDictionary } from "@akanjs/dictionary";
28
+
28
29
  import type { ${dict.AppName}Endpoint } from "./${dict.appName}.signal";
29
30
 
30
- export const dictionary = {} satisfies SignalDictionary<${dict.AppName}Endpoint>;
31
- `;
31
+ export const dictionary = serviceDictionary(["en", "ko"])
32
+ .endpoint<${dict.AppName}Endpoint>((fn) => ({}))
33
+ .translate({});
34
+ `;
32
35
  }
@@ -26,6 +26,6 @@ function getContent(scanInfo, dict) {
26
26
  return `
27
27
  import { serve } from "@akanjs/service";
28
28
 
29
- export class ${dict.AppName}Service extends serve("${dict.appName}" as const, { serverMode: "batch" }) {}
29
+ export class ${dict.AppName}Service extends serve("${dict.appName}" as const, { serverMode: "batch" }, () => ({})) {}
30
30
  `;
31
31
  }
@@ -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
 
@@ -1,7 +1,6 @@
1
- import { env as shared } from "@shared/server";
2
-
3
1
  import type { ModulesOptions } from "../lib/option";
2
+ import { libEnv } from "./env.server.type";
4
3
 
5
4
  export const env: ModulesOptions = {
6
- ...shared,
5
+ ...libEnv,
7
6
  };
@@ -1,7 +1,6 @@
1
- import { env as shared } from "@shared/server";
2
-
3
1
  import type { ModulesOptions } from "../lib/option";
2
+ import { libEnv } from "./env.server.type";
4
3
 
5
4
  export const env: ModulesOptions = {
6
- ...shared,
5
+ ...libEnv,
7
6
  };