@akanjs/cli 0.9.33 → 0.9.34

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
@@ -717,6 +717,44 @@ import config from "./akan.config";
717
717
  export default getNextConfig(config, appInfo);
718
718
  `;
719
719
 
720
+ // pkgs/@akanjs/config/src/types.ts
721
+ var archs = ["amd64", "arm64"];
722
+ var getDefaultFileScan = () => ({
723
+ constants: {
724
+ databases: [],
725
+ scalars: []
726
+ },
727
+ dictionary: {
728
+ databases: [],
729
+ services: [],
730
+ scalars: []
731
+ },
732
+ documents: {
733
+ databases: [],
734
+ scalars: []
735
+ },
736
+ services: {
737
+ databases: [],
738
+ services: [],
739
+ scalars: []
740
+ },
741
+ signal: {
742
+ databases: [],
743
+ services: [],
744
+ scalars: []
745
+ },
746
+ store: {
747
+ databases: [],
748
+ services: [],
749
+ scalars: []
750
+ },
751
+ components: {
752
+ databases: [],
753
+ services: [],
754
+ scalars: []
755
+ }
756
+ });
757
+
720
758
  // pkgs/@akanjs/config/src/akanConfig.ts
721
759
  var makeAppConfig = (config, props) => {
722
760
  const { name, repoName, serveDomain, env, command = "build" } = props;
@@ -840,7 +878,7 @@ WORKDIR /workspace
840
878
  COPY ./package.json ./package.json
841
879
  RUN npx pnpm i --prod
842
880
  COPY . .
843
- ENV PORT 4200
881
+ ENV PORT=4200
844
882
  ENV NODE_OPTIONS=--max_old_space_size=8192
845
883
  ENV NEXT_PUBLIC_REPO_NAME=${repoName}
846
884
  ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
@@ -859,44 +897,6 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
859
897
  }
860
898
  };
861
899
 
862
- // pkgs/@akanjs/config/src/types.ts
863
- var archs = ["amd64", "arm64"];
864
- var getDefaultFileScan = () => ({
865
- constants: {
866
- databases: [],
867
- scalars: []
868
- },
869
- dictionary: {
870
- databases: [],
871
- services: [],
872
- scalars: []
873
- },
874
- documents: {
875
- databases: [],
876
- scalars: []
877
- },
878
- services: {
879
- databases: [],
880
- services: [],
881
- scalars: []
882
- },
883
- signal: {
884
- databases: [],
885
- services: [],
886
- scalars: []
887
- },
888
- store: {
889
- databases: [],
890
- services: [],
891
- scalars: []
892
- },
893
- components: {
894
- databases: [],
895
- services: [],
896
- scalars: []
897
- }
898
- });
899
-
900
900
  // pkgs/@akanjs/devkit/src/executors.ts
901
901
  var import_chalk3 = __toESM(require("chalk"));
902
902
  var import_child_process = require("child_process");
@@ -1790,10 +1790,11 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1790
1790
  const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? envFile.NEXT_PUBLIC_SERVE_DOMAIN;
1791
1791
  if (!serveDomain)
1792
1792
  throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
1793
+ const portOffset = parseInt(process.env.PORT_OFFSET ?? envFile.PORT_OFFSET ?? "0");
1793
1794
  const env = process.env.NEXT_PUBLIC_ENV ?? envFile.NEXT_PUBLIC_ENV ?? "debug";
1794
1795
  if (!env)
1795
1796
  throw new Error("NEXT_PUBLIC_ENV is not set");
1796
- return { ...appName ? { name: appName } : {}, repoName, serveDomain, env };
1797
+ return { ...appName ? { name: appName } : {}, repoName, serveDomain, env, portOffset };
1797
1798
  }
1798
1799
  async scan() {
1799
1800
  const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
@@ -3412,9 +3413,9 @@ var import_dotenv2 = __toESM(require("dotenv"), 1);
3412
3413
  var LibraryRunner = class {
3413
3414
  async createLibrary(libName, workspace) {
3414
3415
  await workspace.exec(`mkdir -p libs/${libName}`);
3415
- const lib = LibExecutor.from(workspace, libName);
3416
- await lib.applyTemplate({ basePath: ".", template: "libRoot", dict: { libName } });
3416
+ await workspace.applyTemplate({ basePath: `libs/${libName}`, template: "libRoot", dict: { libName } });
3417
3417
  workspace.setTsPaths("lib", libName);
3418
+ const lib = LibExecutor.from(workspace, libName);
3418
3419
  return lib;
3419
3420
  }
3420
3421
  async removeLibrary(lib) {
@@ -3909,17 +3910,23 @@ var ApplicationRunner = class {
3909
3910
  });
3910
3911
  await app.spawn("node", [`scripts/${filename}.js`], {
3911
3912
  stdio: "inherit",
3912
- env: this.#getEnv(app)
3913
+ env: this.#getEnv(app, "backend")
3913
3914
  });
3914
3915
  }
3915
- #getEnv(app, env = {}) {
3916
+ #getEnv(app, target, env = {}) {
3916
3917
  const rootEnv = import_dotenv3.default.parse(app.workspace.readFile(".env"));
3918
+ const basePort = target === "backend" ? 8080 : target === "frontend" ? 4200 : target === "csr" ? 4201 : void 0;
3919
+ const portOffset = app.workspace.getBaseDevEnv().portOffset;
3920
+ const PORT = basePort ? (basePort + portOffset).toString() : void 0;
3921
+ const NEXT_PUBLIC_SERVER_PORT = portOffset ? (8080 + portOffset).toString() : void 0;
3917
3922
  return {
3918
3923
  ...process.env,
3919
3924
  ...rootEnv,
3920
3925
  NEXT_PUBLIC_APP_NAME: app.name,
3921
3926
  AKAN_WORKSPACE_ROOT: app.workspace.workspaceRoot,
3922
3927
  NODE_NO_WARNINGS: "1",
3928
+ ...PORT ? { PORT, NEXT_PUBLIC_CLIENT_PORT: PORT } : {},
3929
+ ...NEXT_PUBLIC_SERVER_PORT ? { NEXT_PUBLIC_SERVER_PORT } : {},
3923
3930
  ...env
3924
3931
  };
3925
3932
  }
@@ -3933,7 +3940,7 @@ var ApplicationRunner = class {
3933
3940
  await app.workspace.exec("rm -rf node_modules/.vite");
3934
3941
  else if (target === "backend")
3935
3942
  await app.cp("assets", import_path4.default.join(app.dist.cwdPath, "backend", "assets"));
3936
- return { env: this.#getEnv(app, { AKAN_COMMAND_TYPE: type }) };
3943
+ return { env: this.#getEnv(app, target, { AKAN_COMMAND_TYPE: type }) };
3937
3944
  }
3938
3945
  async buildBackend(app) {
3939
3946
  await this.#prepareCommand(app, "start", "backend");
@@ -4026,15 +4033,16 @@ var ApplicationRunner = class {
4026
4033
  } = {}) {
4027
4034
  const { env } = await this.#prepareCommand(app, "start", "frontend");
4028
4035
  if (open2)
4029
- setTimeout(() => (0, import_open.default)("http://localhost:4200"), 3e3);
4036
+ setTimeout(() => (0, import_open.default)(`http://localhost:${env.PORT ?? 4200}`), 3e3);
4030
4037
  onStart?.();
4031
- return app.spawnSync("npx", ["next", "dev", "-p", "4200", ...turbo ? ["--turbo"] : []], {
4038
+ return app.spawnSync("npx", ["next", "dev", ...env.PORT ? ["-p", env.PORT] : [], ...turbo ? ["--turbo"] : []], {
4032
4039
  env,
4033
4040
  stdio: withInk ? ["ignore", "pipe", "pipe"] : "inherit"
4034
4041
  });
4035
4042
  }
4036
4043
  async #getViteConfig(app, command, viteConfig = {}) {
4037
4044
  const { env } = await this.#prepareCommand(app, command, "csr");
4045
+ const { NODE_ENV, NODE_NO_WARNINGS, ...applyEnvs } = env;
4038
4046
  const tsconfig = app.workspace.getTsConfig();
4039
4047
  const akanConfig = await app.getConfig();
4040
4048
  const basePaths = akanConfig.frontend.routes ? [...new Set(akanConfig.frontend.routes.map(({ basePath: basePath2 }) => basePath2))].join(",") : void 0;
@@ -4094,13 +4102,13 @@ var ApplicationRunner = class {
4094
4102
  },
4095
4103
  define: {
4096
4104
  "process.env": {
4105
+ ...applyEnvs,
4097
4106
  AKAN_COMMAND_TYPE: "start",
4098
4107
  NEXT_PUBLIC_REPO_NAME: app.workspace.repoName,
4099
4108
  NEXT_PUBLIC_SERVE_DOMAIN: processEnv.NEXT_PUBLIC_SERVE_DOMAIN ?? "localhost",
4100
4109
  NEXT_PUBLIC_ENV: processEnv.NEXT_PUBLIC_ENV ?? "debug",
4101
4110
  NEXT_PUBLIC_OPERATION_MODE: processEnv.NEXT_PUBLIC_OPERATION_MODE ?? "local",
4102
4111
  NEXT_PUBLIC_LOG_LEVEL: processEnv.NEXT_PUBLIC_LOG_LEVEL ?? "log",
4103
- NEXT_PUBLIC_APP_NAME: app.name,
4104
4112
  APP_OPERATION_MODE: processEnv.APP_OPERATION_MODE ?? "local",
4105
4113
  AKAN_WORKSPACE_ROOT: app.workspace.workspaceRoot,
4106
4114
  AKAN_APP_ROOT: app.cwdPath,
@@ -4149,7 +4157,7 @@ var ApplicationRunner = class {
4149
4157
  } : {}
4150
4158
  );
4151
4159
  const server = await vite.createServer(config);
4152
- await server.listen(4201);
4160
+ await server.listen(4201 + app.workspace.getBaseDevEnv().portOffset);
4153
4161
  onStart?.();
4154
4162
  if (open2)
4155
4163
  setTimeout(() => (0, import_open.default)("http://localhost:4201"), 3e3);
@@ -4399,7 +4407,7 @@ var ApplicationRunner = class {
4399
4407
  ["node_modules/jest/bin/jest.js", `apps/${app.name}`, "-c", `apps/${app.name}/jest.config.ts`],
4400
4408
  {
4401
4409
  env: {
4402
- ...this.#getEnv(app),
4410
+ ...this.#getEnv(app, "backend"),
4403
4411
  NEXT_PUBLIC_ENV: "testing",
4404
4412
  NEXT_PUBLIC_OPERATION_MODE: "local",
4405
4413
  NEXT_PUBLIC_APP_NAME: app.name,
@@ -27,19 +27,18 @@ function getContent(scanResult, dict) {
27
27
  filename: `${dict.Model}.View.tsx`,
28
28
  content: `
29
29
  import { clsx } from "@akanjs/client";
30
- import { cnst } from "@${dict.sysName}/client";
31
- import { Image } from "@akanjs/ui";
30
+ import { cnst, usePage } from "@${dict.sysName}/client";
32
31
 
33
32
  interface ${dict.Model}ViewProps {
34
33
  className?: string;
35
34
  ${dict.model}: cnst.${dict.Model};
36
- self?: { id?: string } | null;
37
35
  }
38
36
 
39
- export const General = ({ className, ${dict.model}, self }: ${dict.Model}ViewProps) => {
37
+ export const General = ({ className, ${dict.model} }: ${dict.Model}ViewProps) => {
38
+ const { l } = usePage();
40
39
  return (
41
- <div className={clsx(className, "animate-fadeIn w-full")}>
42
- <div>{${dict.model}.id}</div>
40
+ <div className={clsx("w-full", className)}>
41
+ <div>{l("${dict.model}.id")}: {${dict.model}.id}</div>
43
42
  </div>
44
43
  );
45
44
  };
package/esm/index.js CHANGED
@@ -697,6 +697,44 @@ import config from "./akan.config";
697
697
  export default getNextConfig(config, appInfo);
698
698
  `;
699
699
 
700
+ // pkgs/@akanjs/config/src/types.ts
701
+ var archs = ["amd64", "arm64"];
702
+ var getDefaultFileScan = () => ({
703
+ constants: {
704
+ databases: [],
705
+ scalars: []
706
+ },
707
+ dictionary: {
708
+ databases: [],
709
+ services: [],
710
+ scalars: []
711
+ },
712
+ documents: {
713
+ databases: [],
714
+ scalars: []
715
+ },
716
+ services: {
717
+ databases: [],
718
+ services: [],
719
+ scalars: []
720
+ },
721
+ signal: {
722
+ databases: [],
723
+ services: [],
724
+ scalars: []
725
+ },
726
+ store: {
727
+ databases: [],
728
+ services: [],
729
+ scalars: []
730
+ },
731
+ components: {
732
+ databases: [],
733
+ services: [],
734
+ scalars: []
735
+ }
736
+ });
737
+
700
738
  // pkgs/@akanjs/config/src/akanConfig.ts
701
739
  var makeAppConfig = (config, props) => {
702
740
  const { name, repoName, serveDomain, env, command = "build" } = props;
@@ -820,7 +858,7 @@ WORKDIR /workspace
820
858
  COPY ./package.json ./package.json
821
859
  RUN npx pnpm i --prod
822
860
  COPY . .
823
- ENV PORT 4200
861
+ ENV PORT=4200
824
862
  ENV NODE_OPTIONS=--max_old_space_size=8192
825
863
  ENV NEXT_PUBLIC_REPO_NAME=${repoName}
826
864
  ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
@@ -839,44 +877,6 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
839
877
  }
840
878
  };
841
879
 
842
- // pkgs/@akanjs/config/src/types.ts
843
- var archs = ["amd64", "arm64"];
844
- var getDefaultFileScan = () => ({
845
- constants: {
846
- databases: [],
847
- scalars: []
848
- },
849
- dictionary: {
850
- databases: [],
851
- services: [],
852
- scalars: []
853
- },
854
- documents: {
855
- databases: [],
856
- scalars: []
857
- },
858
- services: {
859
- databases: [],
860
- services: [],
861
- scalars: []
862
- },
863
- signal: {
864
- databases: [],
865
- services: [],
866
- scalars: []
867
- },
868
- store: {
869
- databases: [],
870
- services: [],
871
- scalars: []
872
- },
873
- components: {
874
- databases: [],
875
- services: [],
876
- scalars: []
877
- }
878
- });
879
-
880
880
  // pkgs/@akanjs/devkit/src/executors.ts
881
881
  import chalk3 from "chalk";
882
882
  import { exec, fork, spawn } from "child_process";
@@ -1769,10 +1769,11 @@ var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1769
1769
  const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? envFile.NEXT_PUBLIC_SERVE_DOMAIN;
1770
1770
  if (!serveDomain)
1771
1771
  throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
1772
+ const portOffset = parseInt(process.env.PORT_OFFSET ?? envFile.PORT_OFFSET ?? "0");
1772
1773
  const env = process.env.NEXT_PUBLIC_ENV ?? envFile.NEXT_PUBLIC_ENV ?? "debug";
1773
1774
  if (!env)
1774
1775
  throw new Error("NEXT_PUBLIC_ENV is not set");
1775
- return { ...appName ? { name: appName } : {}, repoName, serveDomain, env };
1776
+ return { ...appName ? { name: appName } : {}, repoName, serveDomain, env, portOffset };
1776
1777
  }
1777
1778
  async scan() {
1778
1779
  const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
@@ -3394,9 +3395,9 @@ import dotenv2 from "dotenv";
3394
3395
  var LibraryRunner = class {
3395
3396
  async createLibrary(libName, workspace) {
3396
3397
  await workspace.exec(`mkdir -p libs/${libName}`);
3397
- const lib = LibExecutor.from(workspace, libName);
3398
- await lib.applyTemplate({ basePath: ".", template: "libRoot", dict: { libName } });
3398
+ await workspace.applyTemplate({ basePath: `libs/${libName}`, template: "libRoot", dict: { libName } });
3399
3399
  workspace.setTsPaths("lib", libName);
3400
+ const lib = LibExecutor.from(workspace, libName);
3400
3401
  return lib;
3401
3402
  }
3402
3403
  async removeLibrary(lib) {
@@ -3891,17 +3892,23 @@ var ApplicationRunner = class {
3891
3892
  });
3892
3893
  await app.spawn("node", [`scripts/${filename}.js`], {
3893
3894
  stdio: "inherit",
3894
- env: this.#getEnv(app)
3895
+ env: this.#getEnv(app, "backend")
3895
3896
  });
3896
3897
  }
3897
- #getEnv(app, env = {}) {
3898
+ #getEnv(app, target, env = {}) {
3898
3899
  const rootEnv = dotenv3.parse(app.workspace.readFile(".env"));
3900
+ const basePort = target === "backend" ? 8080 : target === "frontend" ? 4200 : target === "csr" ? 4201 : void 0;
3901
+ const portOffset = app.workspace.getBaseDevEnv().portOffset;
3902
+ const PORT = basePort ? (basePort + portOffset).toString() : void 0;
3903
+ const NEXT_PUBLIC_SERVER_PORT = portOffset ? (8080 + portOffset).toString() : void 0;
3899
3904
  return {
3900
3905
  ...process.env,
3901
3906
  ...rootEnv,
3902
3907
  NEXT_PUBLIC_APP_NAME: app.name,
3903
3908
  AKAN_WORKSPACE_ROOT: app.workspace.workspaceRoot,
3904
3909
  NODE_NO_WARNINGS: "1",
3910
+ ...PORT ? { PORT, NEXT_PUBLIC_CLIENT_PORT: PORT } : {},
3911
+ ...NEXT_PUBLIC_SERVER_PORT ? { NEXT_PUBLIC_SERVER_PORT } : {},
3905
3912
  ...env
3906
3913
  };
3907
3914
  }
@@ -3915,7 +3922,7 @@ var ApplicationRunner = class {
3915
3922
  await app.workspace.exec("rm -rf node_modules/.vite");
3916
3923
  else if (target === "backend")
3917
3924
  await app.cp("assets", path7.join(app.dist.cwdPath, "backend", "assets"));
3918
- return { env: this.#getEnv(app, { AKAN_COMMAND_TYPE: type }) };
3925
+ return { env: this.#getEnv(app, target, { AKAN_COMMAND_TYPE: type }) };
3919
3926
  }
3920
3927
  async buildBackend(app) {
3921
3928
  await this.#prepareCommand(app, "start", "backend");
@@ -4008,15 +4015,16 @@ var ApplicationRunner = class {
4008
4015
  } = {}) {
4009
4016
  const { env } = await this.#prepareCommand(app, "start", "frontend");
4010
4017
  if (open2)
4011
- setTimeout(() => openBrowser("http://localhost:4200"), 3e3);
4018
+ setTimeout(() => openBrowser(`http://localhost:${env.PORT ?? 4200}`), 3e3);
4012
4019
  onStart?.();
4013
- return app.spawnSync("npx", ["next", "dev", "-p", "4200", ...turbo ? ["--turbo"] : []], {
4020
+ return app.spawnSync("npx", ["next", "dev", ...env.PORT ? ["-p", env.PORT] : [], ...turbo ? ["--turbo"] : []], {
4014
4021
  env,
4015
4022
  stdio: withInk ? ["ignore", "pipe", "pipe"] : "inherit"
4016
4023
  });
4017
4024
  }
4018
4025
  async #getViteConfig(app, command, viteConfig = {}) {
4019
4026
  const { env } = await this.#prepareCommand(app, command, "csr");
4027
+ const { NODE_ENV, NODE_NO_WARNINGS, ...applyEnvs } = env;
4020
4028
  const tsconfig = app.workspace.getTsConfig();
4021
4029
  const akanConfig = await app.getConfig();
4022
4030
  const basePaths = akanConfig.frontend.routes ? [...new Set(akanConfig.frontend.routes.map(({ basePath: basePath2 }) => basePath2))].join(",") : void 0;
@@ -4076,13 +4084,13 @@ var ApplicationRunner = class {
4076
4084
  },
4077
4085
  define: {
4078
4086
  "process.env": {
4087
+ ...applyEnvs,
4079
4088
  AKAN_COMMAND_TYPE: "start",
4080
4089
  NEXT_PUBLIC_REPO_NAME: app.workspace.repoName,
4081
4090
  NEXT_PUBLIC_SERVE_DOMAIN: processEnv.NEXT_PUBLIC_SERVE_DOMAIN ?? "localhost",
4082
4091
  NEXT_PUBLIC_ENV: processEnv.NEXT_PUBLIC_ENV ?? "debug",
4083
4092
  NEXT_PUBLIC_OPERATION_MODE: processEnv.NEXT_PUBLIC_OPERATION_MODE ?? "local",
4084
4093
  NEXT_PUBLIC_LOG_LEVEL: processEnv.NEXT_PUBLIC_LOG_LEVEL ?? "log",
4085
- NEXT_PUBLIC_APP_NAME: app.name,
4086
4094
  APP_OPERATION_MODE: processEnv.APP_OPERATION_MODE ?? "local",
4087
4095
  AKAN_WORKSPACE_ROOT: app.workspace.workspaceRoot,
4088
4096
  AKAN_APP_ROOT: app.cwdPath,
@@ -4131,7 +4139,7 @@ var ApplicationRunner = class {
4131
4139
  } : {}
4132
4140
  );
4133
4141
  const server = await vite.createServer(config);
4134
- await server.listen(4201);
4142
+ await server.listen(4201 + app.workspace.getBaseDevEnv().portOffset);
4135
4143
  onStart?.();
4136
4144
  if (open2)
4137
4145
  setTimeout(() => openBrowser("http://localhost:4201"), 3e3);
@@ -4381,7 +4389,7 @@ var ApplicationRunner = class {
4381
4389
  ["node_modules/jest/bin/jest.js", `apps/${app.name}`, "-c", `apps/${app.name}/jest.config.ts`],
4382
4390
  {
4383
4391
  env: {
4384
- ...this.#getEnv(app),
4392
+ ...this.#getEnv(app, "backend"),
4385
4393
  NEXT_PUBLIC_ENV: "testing",
4386
4394
  NEXT_PUBLIC_OPERATION_MODE: "local",
4387
4395
  NEXT_PUBLIC_APP_NAME: app.name,
@@ -4,19 +4,18 @@ function getContent(scanResult, dict) {
4
4
  filename: `${dict.Model}.View.tsx`,
5
5
  content: `
6
6
  import { clsx } from "@akanjs/client";
7
- import { cnst } from "@${dict.sysName}/client";
8
- import { Image } from "@akanjs/ui";
7
+ import { cnst, usePage } from "@${dict.sysName}/client";
9
8
 
10
9
  interface ${dict.Model}ViewProps {
11
10
  className?: string;
12
11
  ${dict.model}: cnst.${dict.Model};
13
- self?: { id?: string } | null;
14
12
  }
15
13
 
16
- export const General = ({ className, ${dict.model}, self }: ${dict.Model}ViewProps) => {
14
+ export const General = ({ className, ${dict.model} }: ${dict.Model}ViewProps) => {
15
+ const { l } = usePage();
17
16
  return (
18
- <div className={clsx(className, "animate-fadeIn w-full")}>
19
- <div>{${dict.model}.id}</div>
17
+ <div className={clsx("w-full", className)}>
18
+ <div>{l("${dict.model}.id")}: {${dict.model}.id}</div>
20
19
  </div>
21
20
  );
22
21
  };
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.33",
5
+ "version": "0.9.34",
6
6
  "bin": {
7
7
  "akan": "esm/index.js"
8
8
  },