@akanjs/devkit 0.0.42 → 0.0.44

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/index.js CHANGED
@@ -30,34 +30,39 @@
30
30
  ));
31
31
 
32
32
  // pkgs/@akanjs/devkit/src/baseDevEnv.ts
33
- var appName = process.env.NEXT_PUBLIC_APP_NAME;
34
- var repoName = process.env.NEXT_PUBLIC_REPO_NAME;
35
- if (!repoName)
36
- throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
37
- var serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
38
- if (!serveDomain)
39
- throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
40
- var env = process.env.NEXT_PUBLIC_ENV ?? "debug";
41
- if (!env)
42
- throw new Error("NEXT_PUBLIC_ENV is not set");
43
- var baseDevEnv = { ...appName ? { appName } : {}, repoName, serveDomain, env };
44
- var getSshTunnelOptions = (appName2, environment) => ({
45
- host: `${appName2}-${environment}.${serveDomain}`,
46
- port: process.env.SSU_TUNNEL_PORT ? parseInt(process.env.SSU_TUNNEL_PORT) : 32767,
47
- username: process.env.SSU_TUNNEL_USERNAME ?? "root",
48
- password: process.env.SSU_TUNNEL_PASSWORD ?? repoName
49
- });
33
+ var getBaseDevEnv = () => {
34
+ const appName = process.env.NEXT_PUBLIC_APP_NAME;
35
+ const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
36
+ if (!repoName)
37
+ throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
38
+ const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
39
+ if (!serveDomain)
40
+ throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
41
+ const env = process.env.NEXT_PUBLIC_ENV ?? "debug";
42
+ if (!env)
43
+ throw new Error("NEXT_PUBLIC_ENV is not set");
44
+ return { ...appName ? { appName } : {}, repoName, serveDomain, env };
45
+ };
46
+ var getSshTunnelOptions = (appName, environment) => {
47
+ const { serveDomain, repoName } = getBaseDevEnv();
48
+ return {
49
+ host: `${appName}-${environment}.${serveDomain}`,
50
+ port: process.env.SSU_TUNNEL_PORT ? parseInt(process.env.SSU_TUNNEL_PORT) : 32767,
51
+ username: process.env.SSU_TUNNEL_USERNAME ?? "root",
52
+ password: process.env.SSU_TUNNEL_PASSWORD ?? repoName
53
+ };
54
+ };
50
55
 
51
56
  // pkgs/@akanjs/devkit/src/createTunnel.ts
52
57
  var import_tunnel_ssh = __require("tunnel-ssh");
53
- var createTunnel = async ({ appName: appName2, environment, port = 27017 }) => {
58
+ var createTunnel = async ({ appName, environment, port = 27017 }) => {
54
59
  const tunnelOptions = { autoClose: true, reconnectOnError: true };
55
- const sshOptions = getSshTunnelOptions(appName2, environment);
60
+ const sshOptions = getSshTunnelOptions(appName, environment);
56
61
  const serverOptions = { port };
57
62
  const forwardOptions = {
58
63
  srcAddr: "0.0.0.0",
59
64
  srcPort: port,
60
- dstAddr: `mongo-0.mongo-svc.${appName2}-${environment}`,
65
+ dstAddr: `mongo-0.mongo-svc.${appName}-${environment}`,
61
66
  dstPort: 27017
62
67
  };
63
68
  const [server, client] = await (0, import_tunnel_ssh.createTunnel)(tunnelOptions, serverOptions, sshOptions, forwardOptions);
@@ -507,19 +512,19 @@
507
512
  var import_path2 = __toESM(__require("path"));
508
513
 
509
514
  // pkgs/@akanjs/config/src/baseConfigEnv.ts
510
- var getBaseConfigEnv = (appName2 = process.env.NEXT_PUBLIC_APP_NAME) => {
511
- if (!appName2)
515
+ var getBaseConfigEnv = (appName = process.env.NEXT_PUBLIC_APP_NAME) => {
516
+ if (!appName)
512
517
  throw new Error("NEXT_PUBLIC_APP_NAME is not set");
513
- const repoName2 = process.env.NEXT_PUBLIC_REPO_NAME;
514
- if (!repoName2)
518
+ const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
519
+ if (!repoName)
515
520
  throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
516
- const serveDomain2 = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
517
- if (!serveDomain2)
521
+ const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
522
+ if (!serveDomain)
518
523
  throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
519
- const env2 = process.env.NEXT_PUBLIC_ENV ?? "debug";
520
- if (!env2)
524
+ const env = process.env.NEXT_PUBLIC_ENV ?? "debug";
525
+ if (!env)
521
526
  throw new Error("NEXT_PUBLIC_ENV is not set");
522
- return { appName: appName2, repoName: repoName2, serveDomain: serveDomain2, env: env2 };
527
+ return { appName, repoName, serveDomain, env };
523
528
  };
524
529
 
525
530
  // pkgs/@akanjs/config/src/nextConfig.ts
@@ -553,7 +558,7 @@
553
558
  disable: commandType === "serve"
554
559
  });
555
560
  var devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
556
- var withBase = (appName2, config, libs, routes = []) => {
561
+ var withBase = (appName, config, libs, routes = []) => {
557
562
  return composePlugins(
558
563
  (0, import_bundle_analyzer.default)({ enabled: process.env.ANALYZE === "true" }),
559
564
  ...commandType !== "serve" || process.env.USE_PWA === "true" ? [withPWA] : []
@@ -587,7 +592,7 @@
587
592
  experimental: {
588
593
  ...config.experimental ?? {},
589
594
  optimizePackageImports: [
590
- ...[appName2, ...libs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
595
+ ...[appName, ...libs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
591
596
  "@contract",
592
597
  "@akanjs/next",
593
598
  "@akanjs/common"
@@ -680,10 +685,10 @@
680
685
  var makeAppConfig = (config, props = {}) => {
681
686
  const baseConfigEnv = getBaseConfigEnv(props.appName);
682
687
  const {
683
- appName: appName2 = baseConfigEnv.appName,
684
- repoName: repoName2 = baseConfigEnv.repoName,
685
- serveDomain: serveDomain2 = baseConfigEnv.serveDomain,
686
- env: env2 = baseConfigEnv.env,
688
+ appName = baseConfigEnv.appName,
689
+ repoName = baseConfigEnv.repoName,
690
+ serveDomain = baseConfigEnv.serveDomain,
691
+ env = baseConfigEnv.env,
687
692
  command = "build"
688
693
  } = props;
689
694
  return {
@@ -705,10 +710,10 @@ RUN npx pnpm i --prod
705
710
  COPY . .
706
711
  ENV PORT 8080
707
712
  ENV NODE_OPTIONS=--max_old_space_size=8192
708
- ENV NEXT_PUBLIC_REPO_NAME=${repoName2}
709
- ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain2}
710
- ENV NEXT_PUBLIC_APP_NAME=${appName2}
711
- ENV NEXT_PUBLIC_ENV=${env2}
713
+ ENV NEXT_PUBLIC_REPO_NAME=${repoName}
714
+ ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
715
+ ENV NEXT_PUBLIC_APP_NAME=${appName}
716
+ ENV NEXT_PUBLIC_ENV=${env}
712
717
  ENV NEXT_PUBLIC_OPERATION_MODE=cloud
713
718
  CMD ["node", "main.js"]`,
714
719
  explicitDependencies: config.backend?.explicitDependencies ?? []
@@ -724,14 +729,14 @@ RUN npx pnpm i --prod
724
729
  COPY . .
725
730
  ENV PORT 4200
726
731
  ENV NODE_OPTIONS=--max_old_space_size=8192
727
- ENV NEXT_PUBLIC_REPO_NAME=${repoName2}
728
- ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain2}
729
- ENV NEXT_PUBLIC_APP_NAME=${appName2}
730
- ENV NEXT_PUBLIC_ENV=${env2}
732
+ ENV NEXT_PUBLIC_REPO_NAME=${repoName}
733
+ ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
734
+ ENV NEXT_PUBLIC_APP_NAME=${appName}
735
+ ENV NEXT_PUBLIC_ENV=${env}
731
736
  ENV NEXT_PUBLIC_OPERATION_MODE=cloud
732
737
  CMD ["npm", "start"]`,
733
738
  nextConfig: withBase(
734
- appName2,
739
+ appName,
735
740
  config.frontend?.nextConfig ? typeof config.frontend.nextConfig === "function" ? config.frontend.nextConfig() : config.frontend.nextConfig : {},
736
741
  config.libs ?? [],
737
742
  config.frontend?.routes
@@ -1021,11 +1026,11 @@ CMD ["npm", "start"]`,
1021
1026
  this.logger.verbose(`File ${writePath} is unchanged`);
1022
1027
  else {
1023
1028
  import_fs7.default.writeFileSync(writePath, contentStr, "utf8");
1024
- this.logger.debug(`File ${writePath} is changed`);
1029
+ this.logger.verbose(`File ${writePath} is changed`);
1025
1030
  }
1026
1031
  } else {
1027
1032
  import_fs7.default.writeFileSync(writePath, contentStr, "utf8");
1028
- this.logger.debug(`File ${writePath} is created`);
1033
+ this.logger.verbose(`File ${writePath} is created`);
1029
1034
  }
1030
1035
  return this;
1031
1036
  }
@@ -1133,21 +1138,21 @@ CMD ["npm", "start"]`,
1133
1138
  var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
1134
1139
  workspaceRoot;
1135
1140
  repoName;
1136
- constructor({ workspaceRoot, repoName: repoName2 }) {
1137
- super(`${repoName2} Executor`, workspaceRoot);
1141
+ constructor({ workspaceRoot, repoName }) {
1142
+ super(`${repoName} Executor`, workspaceRoot);
1138
1143
  this.workspaceRoot = workspaceRoot;
1139
- this.repoName = repoName2;
1144
+ this.repoName = repoName;
1140
1145
  }
1141
1146
  static fromRoot() {
1142
- const repoName2 = import_path3.default.basename(process.cwd());
1143
- return new _WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName: repoName2 });
1147
+ const repoName = import_path3.default.basename(process.cwd());
1148
+ return new _WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
1144
1149
  }
1145
1150
  async scan() {
1146
1151
  const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
1147
1152
  const [appScanResults, libScanResults, pkgScanResults] = await Promise.all([
1148
1153
  Promise.all(
1149
- appNames.map(async (appName2) => {
1150
- const app = AppExecutor.from(this, appName2);
1154
+ appNames.map(async (appName) => {
1155
+ const app = AppExecutor.from(this, appName);
1151
1156
  const akanConfig = await app.getConfig("scan");
1152
1157
  return await app.scan({ akanConfig });
1153
1158
  })
@@ -1221,7 +1226,7 @@ CMD ["npm", "start"]`,
1221
1226
  this.type = type;
1222
1227
  }
1223
1228
  async getConfig(command) {
1224
- return this.type === "app" ? await getAppConfig(this.cwdPath, { ...baseDevEnv, appName: this.name, command }) : await getLibConfig(this.cwdPath, { ...baseDevEnv, appName: this.name, command });
1229
+ return this.type === "app" ? await getAppConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command }) : await getLibConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
1225
1230
  }
1226
1231
  async scan({
1227
1232
  tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
@@ -1375,7 +1380,7 @@ CMD ["npm", "start"]`,
1375
1380
  return new _AppExecutor({ workspace: executor.workspace, name });
1376
1381
  }
1377
1382
  async getConfig(command) {
1378
- return await getAppConfig(this.cwdPath, { ...baseDevEnv, appName: this.name, command });
1383
+ return await getAppConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
1379
1384
  }
1380
1385
  async syncAssets(libDeps) {
1381
1386
  const projectPublicLibPath = `${this.cwdPath}/public/libs`;
@@ -1416,7 +1421,7 @@ CMD ["npm", "start"]`,
1416
1421
  return new _LibExecutor({ workspace: executor.workspace, name });
1417
1422
  }
1418
1423
  async getConfig(command) {
1419
- return await getLibConfig(this.cwdPath, { ...baseDevEnv, appName: this.name, command });
1424
+ return await getLibConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
1420
1425
  }
1421
1426
  };
1422
1427
  var DistLibExecutor = class _DistLibExecutor extends Executor {
@@ -1471,10 +1476,10 @@ CMD ["npm", "start"]`,
1471
1476
  workspaceRoot;
1472
1477
  repoName;
1473
1478
  name;
1474
- constructor({ workspaceRoot, repoName: repoName2, name }) {
1479
+ constructor({ workspaceRoot, repoName, name }) {
1475
1480
  super(`${name} Dist Pkg Executor`, `${workspaceRoot}/dist/pkgs/${name}`);
1476
1481
  this.workspaceRoot = workspaceRoot;
1477
- this.repoName = repoName2;
1482
+ this.repoName = repoName;
1478
1483
  this.name = name;
1479
1484
  }
1480
1485
  static from(workspaceExecutor, name) {
@@ -1805,6 +1810,7 @@ CMD ["npm", "start"]`,
1805
1810
  // pkgs/@akanjs/devkit/src/commandDecorators/command.ts
1806
1811
  var import_prompts3 = __require("@inquirer/prompts");
1807
1812
  var import_commander = __require("commander");
1813
+ var import_dotenv = __toESM(__require("dotenv"));
1808
1814
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
1809
1815
  var handleOption = (programCommand, argMeta) => {
1810
1816
  const {
@@ -1876,8 +1882,8 @@ CMD ["npm", "start"]`,
1876
1882
  if (value)
1877
1883
  return AppExecutor.from(workspace, value);
1878
1884
  const apps = await workspace.getApps();
1879
- const appName2 = await (0, import_prompts3.select)({ message: `Select the ${sysType} name`, choices: apps });
1880
- return AppExecutor.from(workspace, appName2);
1885
+ const appName = await (0, import_prompts3.select)({ message: `Select the ${sysType} name`, choices: apps });
1886
+ return AppExecutor.from(workspace, appName);
1881
1887
  } else if (sysType === "lib") {
1882
1888
  if (value)
1883
1889
  return LibExecutor.from(workspace, value);
@@ -1894,6 +1900,7 @@ CMD ["npm", "start"]`,
1894
1900
  throw new Error(`Invalid system type: ${argMeta.type}`);
1895
1901
  };
1896
1902
  var runCommands = async (...commands) => {
1903
+ import_dotenv.default.config();
1897
1904
  import_commander.program.version("0.0.1").description("An example CLI for managing a directory");
1898
1905
  for (const command of commands) {
1899
1906
  const targetMetas = getTargetMetas(command);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,6 +24,7 @@
24
24
  "axios": "^1.7.9",
25
25
  "commander": "^13.1.0",
26
26
  "dayjs": "^1.11.13",
27
+ "dotenv": "^16.4.7",
27
28
  "form-data": "^4.0.1",
28
29
  "js-yaml": "^4.1.0",
29
30
  "next-pwa": "^5.6.0",
@@ -5,6 +5,6 @@ interface BaseDevEnv {
5
5
  serveDomain: string;
6
6
  env: "testing" | "debug" | "develop" | "main";
7
7
  }
8
- export declare const baseDevEnv: BaseDevEnv;
8
+ export declare const getBaseDevEnv: () => BaseDevEnv;
9
9
  export declare const getSshTunnelOptions: (appName: string, environment: string) => SshOptions;
10
10
  export {};