@akanjs/cli 0.9.58-canary.0 → 0.9.58-canary.2

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 (25) hide show
  1. package/cjs/index.js +555 -133
  2. package/cjs/src/templates/app/lib/___appName__/__appName__.dictionary.js +6 -3
  3. package/cjs/src/templates/app/lib/___appName__/__appName__.service.js +1 -1
  4. package/cjs/src/templates/app/{middleware.js → proxy.js} +5 -5
  5. package/cjs/src/templates/lib/cnst.js +1 -1
  6. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +7 -3
  7. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -1
  8. package/cjs/src/templates/localDev/docker-compose.yaml.template +7 -1
  9. package/cjs/src/templates/module/__model__.service.js +1 -1
  10. package/cjs/src/templates/workspaceRoot/package.json.template +9 -9
  11. package/esm/index.js +549 -127
  12. package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +6 -3
  13. package/esm/src/templates/app/lib/___appName__/__appName__.service.js +1 -1
  14. package/esm/src/templates/app/{middleware.js → proxy.js} +2 -2
  15. package/esm/src/templates/lib/cnst.js +1 -1
  16. package/esm/src/templates/libRoot/lib/___libName__/__libName__.dictionary.js +7 -3
  17. package/esm/src/templates/libRoot/lib/___libName__/__libName__.service.js +1 -1
  18. package/esm/src/templates/localDev/docker-compose.yaml.template +7 -1
  19. package/esm/src/templates/module/__model__.service.js +1 -1
  20. package/esm/src/templates/workspaceRoot/package.json.template +9 -9
  21. package/package.json +4 -4
  22. package/src/application/application.command.d.ts +3 -3
  23. package/src/application/application.runner.d.ts +14 -5
  24. package/src/application/application.script.d.ts +7 -6
  25. /package/src/templates/app/{middleware.d.ts → proxy.d.ts} +0 -0
package/cjs/index.js CHANGED
@@ -336,6 +336,7 @@ var uploadRelease = async (appName, {
336
336
  environment,
337
337
  buildNum,
338
338
  platformVersion,
339
+ os,
339
340
  local
340
341
  }) => {
341
342
  const logger = new Logger("uploadRelease");
@@ -379,7 +380,7 @@ var uploadRelease = async (appName, {
379
380
  fetchingAppSpinner.succeed(`Fetching dev app information for ${appName}... done`);
380
381
  const pushingReleaseSpinner = spinning(`Pushing release to ${environment} environment...`);
381
382
  const release = (await import_axios.default.post(
382
- `${basePath2}/release/pushRelease/${devApp.id}/${environment}/${major}/${minor}/${sourceFile.id}/${buildFile.id}/${appBuildFile.id}`
383
+ `${basePath2}/release/pushRelease/${devApp.id}/${environment}/${major}/${minor}/${patch}/${sourceFile.id}/${buildFile.id}/${appBuildFile.id}${os ? `/${os}` : ""}`
383
384
  )).data;
384
385
  pushingReleaseSpinner.succeed(`Pushing release to ${environment} environment... done`);
385
386
  new Spinner(`Successfully pushed release to ${appName}-${environment} server. `, {
@@ -606,7 +607,7 @@ var withBase = (appName, config, libs, routes = []) => {
606
607
  ...commandType !== "start" || process.env.USE_PWA === "true" ? [withPWA] : []
607
608
  )({
608
609
  ...config,
609
- eslint: { ...config.eslint, ignoreDuringBuilds: true },
610
+ // eslint: { ...config.eslint, ignoreDuringBuilds: true },
610
611
  env: {
611
612
  ...config.env,
612
613
  basePaths: [...new Set(routes.map(({ basePath: basePath2 }) => basePath2))].join(",")
@@ -638,8 +639,6 @@ var withBase = (appName, config, libs, routes = []) => {
638
639
  },
639
640
  webpack: (config2) => {
640
641
  const watchOptions = config2.watchOptions;
641
- config2.resolve.alias.canvas = false;
642
- config2.resolve.alias.encoding = false;
643
642
  const ignored = watchOptions?.ignored ? typeof watchOptions.ignored === "string" ? [watchOptions.ignored] : Array.isArray(watchOptions.ignored) ? watchOptions.ignored.filter((ignore) => typeof ignore === "string") : [] : [];
644
643
  config2.watchOptions = {
645
644
  ...config2.watchOptions ?? {},
@@ -648,10 +647,11 @@ var withBase = (appName, config, libs, routes = []) => {
648
647
  return config2;
649
648
  },
650
649
  turbopack: {
650
+ ...config.turbopack ?? {},
651
651
  resolveAlias: {
652
652
  // canvas: false,
653
653
  // encoding: false,
654
- // ...(process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": "../../pkgs/@akanjs/config" } : {}),
654
+ ...process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": "../../pkgs/@akanjs/config" } : {},
655
655
  ...config.turbopack?.resolveAlias ?? {}
656
656
  }
657
657
  },
@@ -695,7 +695,7 @@ var withBase = (appName, config, libs, routes = []) => {
695
695
  };
696
696
  var defaultNextConfigFile = `import "tsconfig-paths/register.js";
697
697
 
698
- import { getNextConfig } from "@akanjs/config";
698
+ import { getNextConfig } from "${process.env.USE_AKANJS_PKGS === "true" ? "../../pkgs/@akanjs/config" : "@akanjs/config"}";
699
699
 
700
700
  import appInfo from "./akan.app.json";
701
701
  import config from "./akan.config";
@@ -708,7 +708,6 @@ var archs = ["amd64", "arm64"];
708
708
 
709
709
  // pkgs/@akanjs/config/src/akanConfig.ts
710
710
  var import_meta = {};
711
- var jiti = (0, import_jiti.createJiti)(import_meta.url);
712
711
  var makeAppConfig = (config, props) => {
713
712
  const { name, repoName } = props;
714
713
  return {
@@ -730,10 +729,12 @@ var makeAppConfig = (config, props) => {
730
729
  explicitDependencies: config.frontend?.explicitDependencies ?? []
731
730
  },
732
731
  mobile: {
732
+ ...config.mobile,
733
733
  appName: config.mobile?.appName ?? name,
734
- bundleId: config.mobile?.bundleId ?? `com.${repoName}.${name}`,
735
- version: config.mobile?.version,
736
- buildNum: config.mobile?.buildNum
734
+ appId: config.mobile?.appId ?? `com.${repoName}.app`,
735
+ version: config.mobile?.version ?? "0.0.1",
736
+ buildNum: config.mobile?.buildNum ?? 1,
737
+ plugins: config.mobile?.plugins
737
738
  }
738
739
  };
739
740
  };
@@ -741,6 +742,11 @@ var getAppConfig = async (appRoot, props) => {
741
742
  const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
742
743
  if (!import_fs3.default.existsSync(akanConfigPath))
743
744
  throw new Error(`application akan.config.ts is not found ${appRoot}`);
745
+ const jiti = (0, import_jiti.createJiti)(import_meta.url, {
746
+ fsCache: false,
747
+ requireCache: false,
748
+ interopDefault: true
749
+ });
744
750
  const configImp = (await jiti.import(akanConfigPath)).default;
745
751
  const config = typeof configImp === "function" ? configImp(props) : configImp;
746
752
  return makeAppConfig(config, props);
@@ -761,6 +767,9 @@ var getLibConfig = async (libRoot, props) => {
761
767
  const akanConfigPath = import_path.default.join(libRoot, "akan.config.ts");
762
768
  if (!import_fs3.default.existsSync(akanConfigPath))
763
769
  throw new Error(`library akan.config.ts is not found ${libRoot}`);
770
+ const jiti = (0, import_jiti.createJiti)(import_meta.url, {
771
+ cache: false
772
+ });
764
773
  const configImp = (await jiti.import(akanConfigPath)).default;
765
774
  const config = typeof configImp === "function" ? configImp(props) : configImp;
766
775
  return makeLibConfig(config, props);
@@ -849,6 +858,26 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
849
858
  };
850
859
  }
851
860
  };
861
+ var increaseBuildNum = async (appRoot, props) => {
862
+ const appConfig = await getAppConfig(appRoot, props);
863
+ const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
864
+ const akanConfig = import_fs3.default.readFileSync(akanConfigPath, "utf8");
865
+ const akanConfigContent = akanConfig.replace(
866
+ `buildNum: ${appConfig.mobile.buildNum}`,
867
+ `buildNum: ${appConfig.mobile.buildNum + 1}`
868
+ );
869
+ import_fs3.default.writeFileSync(akanConfigPath, akanConfigContent);
870
+ };
871
+ var decreaseBuildNum = async (appRoot, props) => {
872
+ const appConfig = await getAppConfig(appRoot, props);
873
+ const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
874
+ const akanConfig = import_fs3.default.readFileSync(akanConfigPath, "utf8");
875
+ const akanConfigContent = akanConfig.replace(
876
+ `buildNum: ${appConfig.mobile.buildNum}`,
877
+ `buildNum: ${appConfig.mobile.buildNum - 1}`
878
+ );
879
+ import_fs3.default.writeFileSync(akanConfigPath, akanConfigContent);
880
+ };
852
881
 
853
882
  // pkgs/@akanjs/devkit/src/executors.ts
854
883
  var import_chalk3 = __toESM(require("chalk"));
@@ -1900,13 +1929,13 @@ var Executor = class _Executor {
1900
1929
  let stdout = "";
1901
1930
  let stderr = "";
1902
1931
  proc.stdout?.on("data", (data) => {
1903
- stdout += data;
1904
- this.logs.push(data);
1932
+ stdout += data.toString();
1933
+ this.logs.push(data.toString());
1905
1934
  this.#stdout(data);
1906
1935
  });
1907
1936
  proc.stderr?.on("data", (data) => {
1908
- stderr += data;
1909
- this.logs.push(data);
1937
+ stderr += data.toString();
1938
+ this.logs.push(data.toString());
1910
1939
  this.#stdout(data);
1911
1940
  });
1912
1941
  return new Promise((resolve, reject) => {
@@ -2072,6 +2101,10 @@ var Executor = class _Executor {
2072
2101
  this.logger.verbose(msg);
2073
2102
  return this;
2074
2103
  }
2104
+ debug(msg) {
2105
+ this.logger.debug(msg);
2106
+ return this;
2107
+ }
2075
2108
  spinning(msg, { prefix = `${this.emoji}${this.name}`, indent = 0, enableSpin = !_Executor.verbose } = {}) {
2076
2109
  return new Spinner(msg, { prefix, indent, enableSpin }).start();
2077
2110
  }
@@ -2622,10 +2655,8 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2622
2655
  await Promise.all([this.removeDir(projectPublicLibPath), this.removeDir(projectAssetsLibPath)]);
2623
2656
  const targetPublicDeps = libDeps.filter((dep) => this.exists(`${this.workspace.workspaceRoot}/libs/${dep}/public`));
2624
2657
  const targetAssetsDeps = libDeps.filter((dep) => this.exists(`${this.workspace.workspaceRoot}/libs/${dep}/assets`));
2625
- await Promise.all([
2626
- ...targetPublicDeps.map((dep) => this.mkdir(`${projectPublicLibPath}/${dep}`)),
2627
- ...targetAssetsDeps.map((dep) => this.mkdir(`${projectAssetsLibPath}/${dep}`))
2628
- ]);
2658
+ targetPublicDeps.forEach((dep) => this.mkdir(`${projectPublicLibPath}/${dep}`));
2659
+ targetAssetsDeps.forEach((dep) => this.mkdir(`${projectAssetsLibPath}/${dep}`));
2629
2660
  await Promise.all([
2630
2661
  ...targetPublicDeps.map(
2631
2662
  (dep) => this.cp(`${this.workspace.workspaceRoot}/libs/${dep}/public`, `${projectPublicLibPath}/${dep}`)
@@ -2635,6 +2666,12 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
2635
2666
  )
2636
2667
  ]);
2637
2668
  }
2669
+ async increaseBuildNum() {
2670
+ await increaseBuildNum(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name });
2671
+ }
2672
+ async decreaseBuildNum() {
2673
+ await decreaseBuildNum(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name });
2674
+ }
2638
2675
  };
2639
2676
  var LibExecutor = class _LibExecutor extends SysExecutor {
2640
2677
  workspaceRoot;
@@ -2745,7 +2782,95 @@ var getSelf = async (token) => {
2745
2782
 
2746
2783
  // pkgs/@akanjs/devkit/src/capacitorApp.ts
2747
2784
  var import_project = require("@trapezedev/project");
2785
+ var import_fs7 = __toESM(require("fs"));
2786
+
2787
+ // pkgs/@akanjs/devkit/src/fileEditor.ts
2748
2788
  var import_fs6 = __toESM(require("fs"));
2789
+ var FileEditor = class {
2790
+ filePath;
2791
+ content;
2792
+ constructor(filePath) {
2793
+ this.filePath = filePath;
2794
+ this.content = this.#readFile();
2795
+ }
2796
+ #readFile() {
2797
+ try {
2798
+ return import_fs6.default.readFileSync(this.filePath, "utf-8");
2799
+ } catch (error) {
2800
+ throw new Error(`Failed to read file: ${this.filePath}`);
2801
+ }
2802
+ }
2803
+ find(pattern) {
2804
+ const lines = this.content.split("\n");
2805
+ const regex = typeof pattern === "string" ? new RegExp(pattern) : pattern;
2806
+ for (let i = 0; i < lines.length; i++) {
2807
+ if (regex.test(lines[i])) {
2808
+ return i;
2809
+ }
2810
+ }
2811
+ return -1;
2812
+ }
2813
+ findAll(pattern) {
2814
+ const lines = this.content.split("\n");
2815
+ const regex = typeof pattern === "string" ? new RegExp(pattern) : pattern;
2816
+ const matches = [];
2817
+ for (let i = 0; i < lines.length; i++) {
2818
+ if (regex.test(lines[i])) {
2819
+ matches.push(i);
2820
+ }
2821
+ }
2822
+ return matches;
2823
+ }
2824
+ insertAfter(pattern, data) {
2825
+ const lineIndex = this.find(pattern);
2826
+ if (lineIndex === -1) {
2827
+ throw new Error(`Pattern not found: ${pattern}`);
2828
+ }
2829
+ const lines = this.content.split("\n");
2830
+ lines.splice(lineIndex + 1, 0, data);
2831
+ this.content = lines.join("\n");
2832
+ return this;
2833
+ }
2834
+ insertBefore(pattern, data) {
2835
+ const lineIndex = this.find(pattern);
2836
+ if (lineIndex === -1) {
2837
+ throw new Error(`Pattern not found: ${pattern}`);
2838
+ }
2839
+ const lines = this.content.split("\n");
2840
+ lines.splice(lineIndex, 0, data);
2841
+ this.content = lines.join("\n");
2842
+ return this;
2843
+ }
2844
+ replace(pattern, replacement) {
2845
+ const regex = typeof pattern === "string" ? new RegExp(pattern, "g") : pattern;
2846
+ this.content = this.content.replace(regex, replacement);
2847
+ return this;
2848
+ }
2849
+ append(data) {
2850
+ this.content += "\n" + data;
2851
+ return this;
2852
+ }
2853
+ prepend(data) {
2854
+ this.content = data + "\n" + this.content;
2855
+ return this;
2856
+ }
2857
+ save() {
2858
+ try {
2859
+ import_fs6.default.writeFileSync(this.filePath, this.content, "utf-8");
2860
+ } catch (error) {
2861
+ throw new Error(`Failed to save file: ${this.filePath}`);
2862
+ }
2863
+ }
2864
+ getContent() {
2865
+ return this.content;
2866
+ }
2867
+ setContent(content) {
2868
+ this.content = content;
2869
+ return this;
2870
+ }
2871
+ };
2872
+
2873
+ // pkgs/@akanjs/devkit/src/capacitorApp.ts
2749
2874
  var CapacitorApp = class {
2750
2875
  constructor(app) {
2751
2876
  this.app = app;
@@ -2773,78 +2898,160 @@ var CapacitorApp = class {
2773
2898
  await this.project.commit();
2774
2899
  }
2775
2900
  async #prepareIos() {
2776
- const isAdded = import_fs6.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
2901
+ const isAdded = import_fs7.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
2777
2902
  if (!isAdded) {
2778
2903
  await this.app.spawn("npx", ["cap", "add", "ios"]);
2779
2904
  await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
2780
2905
  } else
2781
2906
  this.app.verbose(`iOS already added, skip adding process`);
2907
+ this.app.verbose(`syncing iOS`);
2782
2908
  await this.app.spawn("npx", ["cap", "sync", "ios"]);
2909
+ this.app.verbose(`sync completed.`);
2783
2910
  }
2784
2911
  async buildIos() {
2785
2912
  await this.#prepareIos();
2786
- await this.app.spawn("npx", ["cap", "run", "ios"]);
2913
+ this.app.verbose(`build completed iOS.`);
2914
+ return;
2915
+ }
2916
+ async syncIos() {
2917
+ await this.app.spawn("npx", ["cap", "sync", "ios"]);
2787
2918
  }
2788
2919
  async openIos() {
2789
2920
  await this.app.spawn("npx", ["cap", "open", "ios"]);
2790
2921
  }
2791
- async runIos({ operation, bundleId, version = "0.0.1", buildNum = 1 }) {
2922
+ async runIos({ operation, appId, version = "0.0.1", buildNum = 1, host = "local" }) {
2923
+ const defaultAppId = `com.${this.app.name}.app`;
2792
2924
  await this.#prepareIos();
2793
- this.project.ios.setBundleId("App", "Debug", bundleId);
2794
- this.project.ios.setBundleId("App", "Release", bundleId);
2925
+ this.project.ios.setBundleId("App", "Debug", appId ?? defaultAppId);
2926
+ this.project.ios.setBundleId("App", "Release", appId ?? defaultAppId);
2795
2927
  await this.project.ios.setVersion("App", "Debug", version);
2796
2928
  await this.project.ios.setVersion("App", "Release", version);
2797
2929
  await this.project.ios.setBuild("App", "Debug", buildNum);
2798
2930
  await this.project.ios.setBuild("App", "Release", buildNum);
2799
2931
  await this.project.commit();
2800
- await this.app.spawn("npx", [
2801
- "cross-env",
2802
- `APP_OPERATION_MODE=${operation}`,
2932
+ await this.app.spawn(
2803
2933
  "npx",
2804
- "cap",
2805
- "run",
2806
- "ios",
2807
- "--live-reload",
2808
- "--port",
2809
- "4201"
2810
- ]);
2934
+ [
2935
+ "cross-env",
2936
+ `APP_OPERATION_MODE=${operation}`,
2937
+ `NEXT_PUBLIC_ENV=${host}`,
2938
+ "npx",
2939
+ "cap",
2940
+ "run",
2941
+ "ios",
2942
+ "--live-reload",
2943
+ operation === "release" ? "" : "--live-reload",
2944
+ operation === "release" ? "" : "--port",
2945
+ operation === "release" ? "" : "4201"
2946
+ ],
2947
+ {
2948
+ stdio: "inherit"
2949
+ }
2950
+ );
2811
2951
  }
2812
2952
  async #prepareAndroid() {
2813
- const isAdded = import_fs6.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
2953
+ const isAdded = import_fs7.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
2814
2954
  if (!isAdded) {
2815
2955
  await this.app.spawn("npx", ["cap", "add", "android"]);
2816
- await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
2817
2956
  } else
2818
2957
  this.app.verbose(`Android already added, skip adding process`);
2958
+ await this.app.spawn("npx", ["@capacitor/assets", "generate"]);
2819
2959
  await this.app.spawn("npx", ["cap", "sync", "android"]);
2820
2960
  }
2821
- async buildAndroid() {
2961
+ #updateAndroidBuildTypes() {
2962
+ const appGradle = new FileEditor(`${this.app.cwdPath}/android/app/build.gradle`);
2963
+ const buildTypesBlock = `
2964
+ debug {
2965
+ applicationIdSuffix ".debug"
2966
+ versionNameSuffix "-DEBUG"
2967
+ debuggable true
2968
+ minifyEnabled false
2969
+ }
2970
+ `;
2971
+ const singinConfigBlock = `
2972
+ signingConfigs {
2973
+ debug {
2974
+ storeFile file('debug.keystore')
2975
+ storePassword 'android'
2976
+ keyAlias 'androiddebugkey'
2977
+ keyPassword 'android'
2978
+ }
2979
+ release {
2980
+ if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
2981
+ storeFile file(MYAPP_RELEASE_STORE_FILE)
2982
+ storePassword MYAPP_RELEASE_STORE_PASSWORD
2983
+ keyAlias MYAPP_RELEASE_KEY_ALIAS
2984
+ keyPassword MYAPP_RELEASE_KEY_PASSWORD
2985
+ }
2986
+ }
2987
+ }
2988
+ `;
2989
+ if (appGradle.find("signingConfigs {") === -1) {
2990
+ appGradle.insertBefore("buildTypes {", singinConfigBlock);
2991
+ }
2992
+ if (appGradle.find(`applicationIdSuffix ".debug"`) === -1) {
2993
+ appGradle.insertAfter("buildTypes {", buildTypesBlock);
2994
+ }
2995
+ appGradle.save();
2996
+ }
2997
+ async buildAndroid(assembleType) {
2822
2998
  await this.#prepareAndroid();
2823
- await this.app.spawn("npx", ["cap", "build", "android"]);
2999
+ this.#updateAndroidBuildTypes();
3000
+ const isWindows = process.platform === "win32";
3001
+ const gradleCommand = isWindows ? "gradlew.bat" : "./gradlew";
3002
+ await this.app.spawn(gradleCommand, [assembleType === "apk" ? "assembleRelease" : "bundleRelease"], {
3003
+ stdio: "inherit",
3004
+ cwd: `${this.app.cwdPath}/android`
3005
+ });
2824
3006
  }
2825
3007
  async openAndroid() {
2826
3008
  await this.app.spawn("npx", ["cap", "open", "android"]);
2827
3009
  }
2828
- async runAndroid({ operation, appName, bundleId, version = "0.0.1", buildNum = 1 }) {
3010
+ async syncAndroid() {
3011
+ await this.#prepareAndroid();
3012
+ this.app.log(`Sync Android Completed.`);
3013
+ }
3014
+ async runAndroid({ operation, appName, appId, version = "0.0.1", buildNum = 1, host = "local" }) {
3015
+ const defaultAppId = `com.${this.app.name}.app`;
3016
+ const defaultAppName = this.app.name;
2829
3017
  await this.project.android.setVersionName(version);
3018
+ await this.project.android.setPackageName(appId ?? defaultAppId);
2830
3019
  await this.project.android.setVersionCode(buildNum);
2831
- await this.project.android.setPackageName(bundleId);
2832
- await this.project.android.setAppName(appName);
2833
- await this.app.spawn("npx", [
2834
- "cross-env",
2835
- `APP_OPERATION_MODE=${operation}`,
3020
+ const versionName = await this.project.android.getVersionName();
3021
+ const versionCode = await this.project.android.getVersionCode();
3022
+ await this.project.android.setAppName(appName ?? defaultAppName);
3023
+ await this.project.commit();
3024
+ await this.#prepareAndroid();
3025
+ this.app.logger.info(`Running Android in ${operation} mode on ${host} host`);
3026
+ await this.app.spawn(
2836
3027
  "npx",
2837
- "cap",
2838
- "run",
2839
- "android",
2840
- "--live-reload",
2841
- "--port",
2842
- "--list",
2843
- "4201"
2844
- ]);
3028
+ [
3029
+ "cross-env",
3030
+ `NEXT_PUBLIC_ENV=${host}`,
3031
+ `APP_OPERATION_MODE=${operation}`,
3032
+ "npx",
3033
+ "cap",
3034
+ "run",
3035
+ "android",
3036
+ operation === "release" ? "" : "--live-reload",
3037
+ operation === "release" ? "" : "--port",
3038
+ operation === "release" ? "" : "4201"
3039
+ ],
3040
+ {
3041
+ stdio: "inherit"
3042
+ }
3043
+ );
3044
+ }
3045
+ //? 릴리즈시 buildNum +1 version 파라미터 받아서 업데이트
3046
+ async updateAndroidVersion(version, buildNum) {
3047
+ await this.project.android.setVersionName(version);
3048
+ await this.project.android.setVersionCode(buildNum);
3049
+ const versionName = await this.project.android.getVersionName();
3050
+ const versionCode = await this.project.android.getVersionCode();
3051
+ await this.project.commit();
2845
3052
  }
2846
3053
  async releaseIos() {
2847
- const isAdded = import_fs6.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
3054
+ const isAdded = import_fs7.default.existsSync(`${this.app.cwdPath}/ios/App/Podfile`);
2848
3055
  if (!isAdded) {
2849
3056
  await this.app.spawn("npx cap add ios");
2850
3057
  await this.app.spawn("npx @capacitor/assets generate");
@@ -2853,7 +3060,7 @@ var CapacitorApp = class {
2853
3060
  await this.app.spawn("cross-env", ["APP_OPERATION_MODE=release", "npx", "cap", "sync", "ios"]);
2854
3061
  }
2855
3062
  async releaseAndroid() {
2856
- const isAdded = import_fs6.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
3063
+ const isAdded = import_fs7.default.existsSync(`${this.app.cwdPath}/android/app/build.gradle`);
2857
3064
  if (!isAdded) {
2858
3065
  await this.app.spawn("npx cap add android");
2859
3066
  await this.app.spawn("npx @capacitor/assets generate");
@@ -3098,7 +3305,7 @@ var Target = {
3098
3305
  var import_prompts3 = require("@inquirer/prompts");
3099
3306
  var import_chalk4 = __toESM(require("chalk"));
3100
3307
  var import_commander = require("commander");
3101
- var import_fs7 = __toESM(require("fs"));
3308
+ var import_fs8 = __toESM(require("fs"));
3102
3309
  var import_meta3 = {};
3103
3310
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
3104
3311
  var handleOption = (programCommand, argMeta) => {
@@ -3276,10 +3483,10 @@ var runCommands = async (...commands) => {
3276
3483
  process.exit(1);
3277
3484
  });
3278
3485
  const __dirname = getDirname(import_meta3.url);
3279
- const hasPackageJson = import_fs7.default.existsSync(`${__dirname}/../package.json`);
3280
- process.env.AKAN_VERSION = hasPackageJson ? JSON.parse(import_fs7.default.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
3486
+ const hasPackageJson = import_fs8.default.existsSync(`${__dirname}/../package.json`);
3487
+ process.env.AKAN_VERSION = hasPackageJson ? JSON.parse(import_fs8.default.readFileSync(`${__dirname}/../package.json`, "utf8")).version : "0.0.1";
3281
3488
  import_commander.program.version(process.env.AKAN_VERSION).description("Akan CLI");
3282
- const akanBasePackageJson = import_fs7.default.existsSync("./node_modules/@akanjs/base/package.json") ? JSON.parse(import_fs7.default.readFileSync("./node_modules/@akanjs/base/package.json", "utf8")) : null;
3489
+ const akanBasePackageJson = import_fs8.default.existsSync("./node_modules/@akanjs/base/package.json") ? JSON.parse(import_fs8.default.readFileSync("./node_modules/@akanjs/base/package.json", "utf8")) : null;
3283
3490
  if (akanBasePackageJson && akanBasePackageJson.version !== process.env.AKAN_VERSION) {
3284
3491
  Logger.rawLog(
3285
3492
  import_chalk4.default.yellow(
@@ -3368,7 +3575,7 @@ var import_messages = require("@langchain/core/messages");
3368
3575
  var import_deepseek = require("@langchain/deepseek");
3369
3576
  var import_openai2 = require("@langchain/openai");
3370
3577
  var import_chalk5 = __toESM(require("chalk"));
3371
- var import_fs8 = __toESM(require("fs"));
3578
+ var import_fs9 = __toESM(require("fs"));
3372
3579
  var MAX_ASK_TRY = 300;
3373
3580
  var supportedLlmModels = ["deepseek-chat", "deepseek-reasoner"];
3374
3581
  var AiSession = class _AiSession {
@@ -3436,7 +3643,7 @@ var AiSession = class _AiSession {
3436
3643
  }
3437
3644
  static clearCache(workspaceRoot) {
3438
3645
  const cacheDir = `${workspaceRoot}/${this.#cacheDir}`;
3439
- import_fs8.default.rmSync(cacheDir, { recursive: true, force: true });
3646
+ import_fs9.default.rmSync(cacheDir, { recursive: true, force: true });
3440
3647
  }
3441
3648
  messageHistory = [];
3442
3649
  sessionKey;
@@ -3636,7 +3843,7 @@ ${fileCheck.lintResult.message}`
3636
3843
  // pkgs/@akanjs/devkit/src/builder.ts
3637
3844
  var esbuild = __toESM(require("esbuild"));
3638
3845
  var import_esbuild_plugin_d = require("esbuild-plugin-d.ts");
3639
- var import_fs9 = __toESM(require("fs"));
3846
+ var import_fs10 = __toESM(require("fs"));
3640
3847
  var assetExtensions = [".css", ".md", ".js", ".png", ".ico", ".svg", ".json", ".template"];
3641
3848
  var assetLoader = Object.fromEntries(assetExtensions.map((ext) => [ext, "copy"]));
3642
3849
  var Builder = class {
@@ -3682,7 +3889,7 @@ var Builder = class {
3682
3889
  };
3683
3890
  }
3684
3891
  async build(options = {}) {
3685
- if (import_fs9.default.existsSync(this.#distExecutor.cwdPath))
3892
+ if (import_fs10.default.existsSync(this.#distExecutor.cwdPath))
3686
3893
  await this.#distExecutor.exec(`rm -rf ${this.#distExecutor.cwdPath}`);
3687
3894
  const plugins = [(0, import_esbuild_plugin_d.dtsPlugin)({ tsconfig: `${this.#executor.cwdPath}/tsconfig.json` })];
3688
3895
  const [buildResult] = await Promise.all([
@@ -3780,6 +3987,9 @@ var useStdoutDimensions = () => {
3780
3987
  return dimensions;
3781
3988
  };
3782
3989
 
3990
+ // pkgs/@akanjs/cli/src/application/application.command.ts
3991
+ var import_prompts8 = require("@inquirer/prompts");
3992
+
3783
3993
  // pkgs/@akanjs/cli/src/library/library.runner.ts
3784
3994
  var import_compare_versions = require("compare-versions");
3785
3995
  var import_dotenv2 = __toESM(require("dotenv"), 1);
@@ -4233,9 +4443,8 @@ var import_openai3 = require("@langchain/openai");
4233
4443
  var import_plugin_react = __toESM(require("@vitejs/plugin-react"), 1);
4234
4444
  var import_dotenv3 = __toESM(require("dotenv"), 1);
4235
4445
  var esbuild2 = __toESM(require("esbuild"), 1);
4236
- var import_fs10 = __toESM(require("fs"), 1);
4446
+ var import_fs11 = __toESM(require("fs"), 1);
4237
4447
  var import_promises3 = __toESM(require("fs/promises"), 1);
4238
- var import_js_yaml2 = __toESM(require("js-yaml"), 1);
4239
4448
  var import_open = __toESM(require("open"), 1);
4240
4449
  var import_ora3 = __toESM(require("ora"), 1);
4241
4450
  var import_path5 = __toESM(require("path"), 1);
@@ -4260,8 +4469,8 @@ var ApplicationRunner = class {
4260
4469
  async getConfig(app) {
4261
4470
  return await app.getConfig();
4262
4471
  }
4263
- async scanSync(app) {
4264
- const scanInfo = await app.scan();
4472
+ async scanSync(app, { refresh = false } = {}) {
4473
+ const scanInfo = await app.scan({ refresh });
4265
4474
  await app.syncAssets(scanInfo.getScanResult().akanConfig.libs);
4266
4475
  return scanInfo;
4267
4476
  }
@@ -4378,7 +4587,7 @@ var ApplicationRunner = class {
4378
4587
  async buildFrontend(app, { spawnOptions } = {}) {
4379
4588
  const { env } = await this.#prepareCommand(app, "build", "frontend");
4380
4589
  const akanConfig = await app.getConfig();
4381
- await app.spawn("npx", ["next", "build", "--no-lint"], { env, ...spawnOptions });
4590
+ await app.spawn("npx", ["next", "build"], { env, ...spawnOptions });
4382
4591
  const buildResult = await esbuild2.build({
4383
4592
  entryPoints: [`${app.cwdPath}/next.config.ts`],
4384
4593
  outfile: `${app.dist.cwdPath}/frontend/next.config.ts`,
@@ -4390,7 +4599,12 @@ var ApplicationRunner = class {
4390
4599
  logLevel: "warning"
4391
4600
  });
4392
4601
  const rootPackageJson = app.workspace.getPackageJson();
4393
- const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson, ["next", "react", "react-dom"]);
4602
+ const dependencies = extractDependencies(buildResult.outputFiles, rootPackageJson, [
4603
+ "next",
4604
+ "react",
4605
+ "react-dom",
4606
+ "typescript"
4607
+ ]);
4394
4608
  buildResult.outputFiles.map((file) => app.dist.writeFile(file.path, file.text));
4395
4609
  const appPackageJson = {
4396
4610
  name: `${app.name}/frontend`,
@@ -4398,7 +4612,8 @@ var ApplicationRunner = class {
4398
4612
  version: "1.0.0",
4399
4613
  engines: { node: ">=20" },
4400
4614
  dependencies,
4401
- scripts: { start: "next start" }
4615
+ scripts: { start: "next start" },
4616
+ browserslist: "> 1%"
4402
4617
  };
4403
4618
  app.dist.writeJson("frontend/package.json", appPackageJson);
4404
4619
  await Promise.all([
@@ -4422,7 +4637,7 @@ var ApplicationRunner = class {
4422
4637
  stdio: withInk ? ["ignore", "pipe", "pipe"] : "inherit"
4423
4638
  });
4424
4639
  }
4425
- async #getViteConfig(app, command, viteConfig = {}) {
4640
+ async #getViteConfig(app, command, viteConfig = {}, options = {}) {
4426
4641
  const { env } = await this.#prepareCommand(app, command, "csr");
4427
4642
  const { NODE_ENV, NODE_NO_WARNINGS, ...applyEnvs } = env;
4428
4643
  const tsconfig = app.workspace.getTsConfig();
@@ -4490,10 +4705,10 @@ var ApplicationRunner = class {
4490
4705
  AKAN_COMMAND_TYPE: "start",
4491
4706
  NEXT_PUBLIC_REPO_NAME: app.workspace.repoName,
4492
4707
  NEXT_PUBLIC_SERVE_DOMAIN: processEnv.NEXT_PUBLIC_SERVE_DOMAIN ?? "localhost",
4493
- NEXT_PUBLIC_ENV: processEnv.NEXT_PUBLIC_ENV ?? "debug",
4708
+ NEXT_PUBLIC_ENV: options.host ?? processEnv.NEXT_PUBLIC_ENV ?? "debug",
4494
4709
  NEXT_PUBLIC_OPERATION_MODE: processEnv.NEXT_PUBLIC_OPERATION_MODE ?? "local",
4495
4710
  NEXT_PUBLIC_LOG_LEVEL: processEnv.NEXT_PUBLIC_LOG_LEVEL ?? "log",
4496
- APP_OPERATION_MODE: processEnv.APP_OPERATION_MODE ?? "local",
4711
+ APP_OPERATION_MODE: options.operation ?? processEnv.APP_OPERATION_MODE ?? "local",
4497
4712
  AKAN_WORKSPACE_ROOT: app.workspace.workspaceRoot,
4498
4713
  AKAN_APP_ROOT: app.cwdPath,
4499
4714
  RENDER_ENV: "csr",
@@ -4507,8 +4722,8 @@ var ApplicationRunner = class {
4507
4722
  });
4508
4723
  return config;
4509
4724
  }
4510
- async buildCsr(app) {
4511
- const config = await this.#getViteConfig(app, "build");
4725
+ async buildCsr(app, { operation, host } = {}) {
4726
+ const config = await this.#getViteConfig(app, "build", {}, { operation, host });
4512
4727
  await vite.build(config);
4513
4728
  }
4514
4729
  async startCsr(app, { open: open2 = false, onStart, withInk = false } = {}) {
@@ -4551,10 +4766,15 @@ var ApplicationRunner = class {
4551
4766
  const capacitorApp = await new CapacitorApp(app).init();
4552
4767
  await capacitorApp.buildIos();
4553
4768
  }
4554
- async startIos(app, { open: open2 = false, operation = "local" } = {}) {
4769
+ async startIos(app, {
4770
+ open: open2 = false,
4771
+ operation = "local",
4772
+ host = "local"
4773
+ } = {}) {
4555
4774
  const akanConfig = await app.getConfig();
4775
+ await this.buildCsr(app, { operation, host });
4556
4776
  const capacitorApp = await new CapacitorApp(app).init();
4557
- await capacitorApp.runIos({ ...akanConfig.mobile, operation });
4777
+ await capacitorApp.runIos({ ...akanConfig.mobile, operation, host });
4558
4778
  if (open2)
4559
4779
  await capacitorApp.openIos();
4560
4780
  }
@@ -4564,18 +4784,34 @@ var ApplicationRunner = class {
4564
4784
  await capacitorApp.releaseIos();
4565
4785
  }
4566
4786
  async buildAndroid(app) {
4567
- const capacitorApp = await new CapacitorApp(app).init();
4568
- await capacitorApp.buildAndroid();
4787
+ const capacitorApp = new CapacitorApp(app);
4788
+ await capacitorApp.init();
4789
+ await capacitorApp.syncAndroid();
4569
4790
  }
4570
- async startAndroid(app, { open: open2 = false, operation = "local" } = {}) {
4791
+ async startAndroid(app, {
4792
+ open: open2 = false,
4793
+ operation = "local",
4794
+ host = "local"
4795
+ } = {}) {
4571
4796
  const akanConfig = await app.getConfig();
4797
+ await this.buildCsr(app, { operation, host });
4572
4798
  const capacitorApp = await new CapacitorApp(app).init();
4573
- await capacitorApp.runAndroid({ ...akanConfig.mobile, operation });
4799
+ await capacitorApp.runAndroid({ ...akanConfig.mobile, operation, host });
4574
4800
  }
4575
- async releaseAndroid(app) {
4801
+ async releaseAndroid(app, assembleType) {
4802
+ const capacitorApp = new CapacitorApp(app);
4803
+ const akanConfig = await app.getConfig();
4804
+ await capacitorApp.init();
4805
+ await capacitorApp.updateAndroidVersion(akanConfig.mobile.version, akanConfig.mobile.buildNum);
4806
+ await capacitorApp.buildAndroid(assembleType);
4807
+ app.log(
4808
+ `Release Android ${app.name} ${assembleType} Completed. app-${assembleType === "apk" ? "release" : "release"}.${assembleType === "apk" ? "apk" : "aab"}`
4809
+ );
4810
+ app.log(`Path : ${app.cwdPath}/android/app/build/outputs/${assembleType === "apk" ? "apk" : "bundle"}/release`);
4811
+ }
4812
+ async codepush(app, os) {
4576
4813
  const capacitorApp = new CapacitorApp(app);
4577
4814
  await capacitorApp.init();
4578
- await capacitorApp.releaseAndroid();
4579
4815
  }
4580
4816
  async #prepareMongo(app, environment) {
4581
4817
  if (environment === "local")
@@ -4631,17 +4867,17 @@ var ApplicationRunner = class {
4631
4867
  await capacitorApp.save();
4632
4868
  }
4633
4869
  async releaseSource(app, { rebuild, buildNum = 0, environment = "debug", local = true } = {}) {
4870
+ const akanConfig = await app.getConfig();
4634
4871
  const buildRoot = `${app.workspace.workspaceRoot}/releases/builds/${app.name}`;
4635
- const appVersionInfo = import_js_yaml2.default.load(app.readFile("config.yaml"));
4636
- const platformVersion = appVersionInfo.platforms.android.versionName;
4637
- if (import_fs10.default.existsSync(buildRoot))
4872
+ const platformVersion = akanConfig.mobile.version;
4873
+ if (import_fs11.default.existsSync(buildRoot))
4638
4874
  await import_promises3.default.rm(buildRoot, { recursive: true, force: true });
4639
4875
  await import_promises3.default.mkdir(buildRoot, { recursive: true });
4640
- if (rebuild || !import_fs10.default.existsSync(`${app.dist.cwdPath}/backend`))
4876
+ if (rebuild || !import_fs11.default.existsSync(`${app.dist.cwdPath}/backend`))
4641
4877
  await this.buildBackend(app);
4642
- if (rebuild || !import_fs10.default.existsSync(`${app.dist.cwdPath}/frontend`))
4878
+ if (rebuild || !import_fs11.default.existsSync(`${app.dist.cwdPath}/frontend`))
4643
4879
  await this.buildFrontend(app);
4644
- if (rebuild || !import_fs10.default.existsSync(`${app.dist.cwdPath}/csr`))
4880
+ if (rebuild || !import_fs11.default.existsSync(`${app.dist.cwdPath}/csr`))
4645
4881
  await this.buildCsr(app);
4646
4882
  const buildVersion = `${platformVersion}-${buildNum}`;
4647
4883
  const buildPath = `${buildRoot}/${buildVersion}`;
@@ -4656,7 +4892,7 @@ var ApplicationRunner = class {
4656
4892
  buildRoot,
4657
4893
  "./"
4658
4894
  ]);
4659
- if (import_fs10.default.existsSync(`${app.dist.cwdPath}/csr`)) {
4895
+ if (import_fs11.default.existsSync(`${app.dist.cwdPath}/csr`)) {
4660
4896
  await import_promises3.default.cp(`${app.dist.cwdPath}/csr`, "./csr", { recursive: true });
4661
4897
  await app.workspace.spawn("zip", [
4662
4898
  "-r",
@@ -4666,7 +4902,7 @@ var ApplicationRunner = class {
4666
4902
  await import_promises3.default.rm("./csr", { recursive: true, force: true });
4667
4903
  }
4668
4904
  const sourceRoot = `${app.workspace.workspaceRoot}/releases/sources/${app.name}`;
4669
- if (import_fs10.default.existsSync(sourceRoot)) {
4905
+ if (import_fs11.default.existsSync(sourceRoot)) {
4670
4906
  const MAX_RETRY = 3;
4671
4907
  for (let i = 0; i < MAX_RETRY; i++) {
4672
4908
  try {
@@ -4686,7 +4922,7 @@ var ApplicationRunner = class {
4686
4922
  await Promise.all(
4687
4923
  [".next", "ios", "android", "public/libs"].map(async (path10) => {
4688
4924
  const targetPath = `${sourceRoot}/apps/${app.name}/${path10}`;
4689
- if (import_fs10.default.existsSync(targetPath))
4925
+ if (import_fs11.default.existsSync(targetPath))
4690
4926
  await import_promises3.default.rm(targetPath, { recursive: true, force: true });
4691
4927
  })
4692
4928
  );
@@ -4714,8 +4950,8 @@ var ApplicationRunner = class {
4714
4950
  []
4715
4951
  )
4716
4952
  ]);
4717
- import_fs10.default.writeFileSync(`${sourceRoot}/tsconfig.json`, JSON.stringify(tsconfig, null, 2));
4718
- import_fs10.default.writeFileSync(
4953
+ import_fs11.default.writeFileSync(`${sourceRoot}/tsconfig.json`, JSON.stringify(tsconfig, null, 2));
4954
+ import_fs11.default.writeFileSync(
4719
4955
  `${sourceRoot}/README.md`,
4720
4956
  `# ${app.name}
4721
4957
  \uBCF8 \uD504\uB85C\uC81D\uD2B8\uC758 \uC18C\uC2A4\uCF54\uB4DC \uBC0F \uAD00\uB828\uC790\uB8CC\uB294 \uBAA8\uB450 \uBE44\uBC00\uC815\uBCF4\uB85C \uAD00\uB9AC\uB429\uB2C8\uB2E4.
@@ -4756,16 +4992,142 @@ var ApplicationRunner = class {
4756
4992
  "./"
4757
4993
  ]);
4758
4994
  await uploadRelease(app.name, {
4759
- workspaceRoot: app.workspace.cwdPath,
4760
- environment,
4995
+ local,
4761
4996
  buildNum,
4997
+ environment,
4762
4998
  platformVersion,
4763
- local
4999
+ workspaceRoot: app.workspace.cwdPath
4764
5000
  });
4765
5001
  }
4766
5002
  async createApplicationTemplate(workspace, appName) {
4767
5003
  await workspace.applyTemplate({ basePath: `apps/${appName}`, template: "appRoot", dict: { appName } });
4768
5004
  }
5005
+ async compressProjectFiles(app, { rebuild, buildNum = 0, environment = "debug", local = true } = {}) {
5006
+ const akanConfig = await app.getConfig();
5007
+ const buildRoot = `${app.workspace.workspaceRoot}/releases/builds/${app.name}`;
5008
+ const platformVersion = akanConfig.mobile.version;
5009
+ if (import_fs11.default.existsSync(buildRoot))
5010
+ await import_promises3.default.rm(buildRoot, { recursive: true, force: true });
5011
+ await import_promises3.default.mkdir(buildRoot, { recursive: true });
5012
+ if (rebuild || !import_fs11.default.existsSync(`${app.dist.cwdPath}/backend`))
5013
+ await this.buildBackend(app);
5014
+ if (rebuild || !import_fs11.default.existsSync(`${app.dist.cwdPath}/frontend`))
5015
+ await this.buildFrontend(app);
5016
+ if (rebuild || !import_fs11.default.existsSync(`${app.dist.cwdPath}/csr`))
5017
+ await this.buildCsr(app);
5018
+ const buildVersion = `${platformVersion}-${buildNum}`;
5019
+ const buildPath = `${buildRoot}/${buildVersion}`;
5020
+ await import_promises3.default.mkdir(buildPath, { recursive: true });
5021
+ await import_promises3.default.cp(`${app.dist.cwdPath}/backend`, `${buildPath}/backend`, { recursive: true });
5022
+ await import_promises3.default.cp(app.dist.cwdPath, buildRoot, { recursive: true });
5023
+ await import_promises3.default.rm(`${buildRoot}/frontend/.next`, { recursive: true, force: true });
5024
+ await app.workspace.spawn("tar", [
5025
+ "-zcf",
5026
+ `${app.workspace.workspaceRoot}/releases/builds/${app.name}-release.tar.gz`,
5027
+ "-C",
5028
+ buildRoot,
5029
+ "./"
5030
+ ]);
5031
+ if (import_fs11.default.existsSync(`${app.dist.cwdPath}/csr`)) {
5032
+ await import_promises3.default.cp(`${app.dist.cwdPath}/csr`, "./csr", { recursive: true });
5033
+ await app.workspace.spawn("zip", [
5034
+ "-r",
5035
+ `${app.workspace.workspaceRoot}/releases/builds/${app.name}-appBuild.zip`,
5036
+ "./csr"
5037
+ ]);
5038
+ await import_promises3.default.rm("./csr", { recursive: true, force: true });
5039
+ }
5040
+ const sourceRoot = `${app.workspace.workspaceRoot}/releases/sources/${app.name}`;
5041
+ if (import_fs11.default.existsSync(sourceRoot)) {
5042
+ const MAX_RETRY = 3;
5043
+ for (let i = 0; i < MAX_RETRY; i++) {
5044
+ try {
5045
+ await import_promises3.default.rm(sourceRoot, { recursive: true, force: true });
5046
+ } catch (e) {
5047
+ }
5048
+ }
5049
+ }
5050
+ await import_promises3.default.mkdir(sourceRoot, { recursive: true });
5051
+ await import_promises3.default.cp(app.dist.cwdPath, `${sourceRoot}/apps/${app.name}`, { recursive: true });
5052
+ const libDeps = ["social", "shared", "platform", "util"];
5053
+ await Promise.all(
5054
+ libDeps.map(
5055
+ (lib) => import_promises3.default.cp(`${app.workspace.cwdPath}/libs/${lib}`, `${sourceRoot}/libs/${lib}`, { recursive: true })
5056
+ )
5057
+ );
5058
+ await Promise.all(
5059
+ [".next", "ios", "android", "public/libs"].map(async (path10) => {
5060
+ const targetPath = `${sourceRoot}/apps/${app.name}/${path10}`;
5061
+ if (import_fs11.default.existsSync(targetPath))
5062
+ await import_promises3.default.rm(targetPath, { recursive: true, force: true });
5063
+ })
5064
+ );
5065
+ const syncPaths = [
5066
+ ".husky",
5067
+ // ".vscode",
5068
+ ".editorconfig",
5069
+ // ".eslintrc.json",
5070
+ ".gitignore",
5071
+ ".prettierignore",
5072
+ ".prettierrc.json",
5073
+ // "jest.config.ts",
5074
+ "package.json"
5075
+ ];
5076
+ await Promise.all(
5077
+ syncPaths.map(
5078
+ (path10) => import_promises3.default.cp(`${app.workspace.cwdPath}/${path10}`, `${sourceRoot}/${path10}`, { recursive: true })
5079
+ )
5080
+ );
5081
+ const tsconfig = app.workspace.readJson("tsconfig.json");
5082
+ tsconfig.compilerOptions.paths = Object.fromEntries([
5083
+ [`@${app.name}/*`, [`apps/${app.name}/*`]],
5084
+ ...libDeps.reduce(
5085
+ (acc, lib) => [...acc, [`@${lib}`, [`libs/${lib}/index.ts`]], [`@${lib}/*`, [`libs/${lib}/*`]]],
5086
+ []
5087
+ )
5088
+ ]);
5089
+ import_fs11.default.writeFileSync(`${sourceRoot}/tsconfig.json`, JSON.stringify(tsconfig, null, 2));
5090
+ import_fs11.default.writeFileSync(
5091
+ `${sourceRoot}/README.md`,
5092
+ `# ${app.name}
5093
+ \uBCF8 \uD504\uB85C\uC81D\uD2B8\uC758 \uC18C\uC2A4\uCF54\uB4DC \uBC0F \uAD00\uB828\uC790\uB8CC\uB294 \uBAA8\uB450 \uBE44\uBC00\uC815\uBCF4\uB85C \uAD00\uB9AC\uB429\uB2C8\uB2E4.
5094
+
5095
+ ## Get Started
5096
+ Run the code below.
5097
+ \`\`\`
5098
+ npm i -g nx pnpm
5099
+ pnpm i -w
5100
+
5101
+ cat <<EOF >> .env
5102
+ # ENV For Server => debug | debug.local | develop | develop.local | main | main.local
5103
+ SERVER_ENV=debug.local
5104
+ # Run Mode For Server => federation | batch | all
5105
+ SERVER_MODE=federation
5106
+ # ENV For Client => debug | debug.local | develop | develop.local | main | main.local
5107
+ NEXT_PUBLIC_CLIENT_ENV=debug.local
5108
+ ANALYZE=false
5109
+ EOF
5110
+
5111
+ akn start-backend ${app.name}
5112
+ # or akn start-frontend ${app.name}, etc
5113
+ \`\`\`
5114
+
5115
+ ## Build
5116
+ Run the code below.
5117
+ \`\`\`
5118
+ akn build-backend ${app.name}
5119
+ # or akn build-frontend ${app.name}, etc
5120
+ \`\`\`
5121
+ `
5122
+ );
5123
+ await app.workspace.spawn("tar", [
5124
+ "-zcf",
5125
+ `${app.workspace.cwdPath}/releases/sources/${app.name}-source.tar.gz`,
5126
+ "-C",
5127
+ sourceRoot,
5128
+ "./"
5129
+ ]);
5130
+ }
4769
5131
  async generateApplicationTemplate(app) {
4770
5132
  const openAIApiKey = process.env.OPENAI_API_KEY;
4771
5133
  if (!openAIApiKey)
@@ -4955,8 +5317,9 @@ var ApplicationScript = class {
4955
5317
  async startIos(app, {
4956
5318
  open: open2 = false,
4957
5319
  operation = "local",
5320
+ host = "local",
4958
5321
  sync = true
4959
- } = {}) {
5322
+ }) {
4960
5323
  if (sync)
4961
5324
  await this.syncApplication(app);
4962
5325
  await this.#runner.startIos(app, { open: open2, operation });
@@ -4973,15 +5336,22 @@ var ApplicationScript = class {
4973
5336
  async startAndroid(app, {
4974
5337
  open: open2 = false,
4975
5338
  operation = "local",
5339
+ host = "local",
4976
5340
  sync = true
4977
5341
  } = {}) {
4978
5342
  if (sync)
4979
5343
  await this.syncApplication(app);
4980
- await this.#runner.startAndroid(app, { open: open2, operation });
5344
+ await this.#runner.startAndroid(app, { open: open2, operation, host });
4981
5345
  }
4982
- async releaseAndroid(app, { sync = true } = {}) {
4983
- await this.buildCsr(app, { sync });
4984
- await this.#runner.releaseAndroid(app);
5346
+ //* 안드로이드 릴리즈(apk or aab 추출) 메서드
5347
+ async releaseAndroid(app, assembleType) {
5348
+ try {
5349
+ await app.increaseBuildNum();
5350
+ await this.buildCsr(app, { sync: true });
5351
+ await this.#runner.releaseAndroid(app, assembleType);
5352
+ } catch (e) {
5353
+ await app.decreaseBuildNum();
5354
+ }
4985
5355
  }
4986
5356
  async dumpDatabase(app, environment) {
4987
5357
  await this.dbdown(app.workspace);
@@ -5007,6 +5377,9 @@ var ApplicationScript = class {
5007
5377
  async releaseSource(app, options) {
5008
5378
  await this.#runner.releaseSource(app, options);
5009
5379
  }
5380
+ async codepush(app, os) {
5381
+ await this.#runner.codepush(app, os);
5382
+ }
5010
5383
  async dbup(workspace) {
5011
5384
  const spinner = workspace.spinning("Starting local database...");
5012
5385
  await this.#runner.dbup(workspace);
@@ -5076,20 +5449,62 @@ var ApplicationCommand = class {
5076
5449
  await this.applicationScript.startCsr(app, { open: open2, sync });
5077
5450
  }
5078
5451
  async startIos(app, open2, release, sync) {
5079
- await this.applicationScript.startIos(app, { open: open2, operation: release ? "release" : "local", sync });
5452
+ const operation_ = await (0, import_prompts8.select)({
5453
+ message: "Select ios operation mode",
5454
+ choices: [
5455
+ { value: "local", name: "local", description: "Connect to the React web server." },
5456
+ { value: "release", name: "release", description: "Real production package environment." }
5457
+ ]
5458
+ });
5459
+ const host_ = await (0, import_prompts8.select)({
5460
+ message: "Select connect backend server.",
5461
+ choices: [
5462
+ { value: "local", name: "local", description: "connect to the localhost backend server." },
5463
+ { value: "debug", name: "debug", description: "connect to the debug cloud backend server." },
5464
+ { value: "develop", name: "develop", description: "connect to the develop cloud backend server." },
5465
+ { value: "main", name: "main", description: "connect to the main cloud backend server." }
5466
+ ]
5467
+ });
5468
+ await this.applicationScript.startIos(app, { open: open2, host: host_, operation: operation_, sync });
5080
5469
  }
5081
- async startAndroid(app, open2, release, sync) {
5082
- await this.applicationScript.startAndroid(app, { open: open2, operation: release ? "release" : "local", sync });
5470
+ async startAndroid(app, host, release, open2, sync) {
5471
+ const host_ = await (0, import_prompts8.select)({
5472
+ message: "Select connect backend server.",
5473
+ choices: [
5474
+ { value: "local", name: "local", description: "connect to the localhost backend server." },
5475
+ { value: "debug", name: "debug", description: "connect to the debug cloud backend server." },
5476
+ { value: "develop", name: "develop", description: "connect to the develop cloud backend server." },
5477
+ { value: "main", name: "main", description: "connect to the main cloud backend server." }
5478
+ ]
5479
+ });
5480
+ const operation_ = await (0, import_prompts8.select)({
5481
+ message: "Select android operation mode",
5482
+ choices: [
5483
+ { value: "local", name: "local", description: "Connect to the React web server." },
5484
+ { value: "release", name: "release", description: "Real production package environment." }
5485
+ ]
5486
+ });
5487
+ await this.applicationScript.startAndroid(app, { open: open2, operation: operation_, host: host_, sync });
5083
5488
  }
5084
5489
  async releaseIos(app) {
5085
5490
  await this.applicationScript.releaseIos(app);
5086
5491
  }
5087
- async releaseAndroid(app) {
5088
- await this.applicationScript.releaseAndroid(app);
5492
+ async releaseAndroid(app, assembleType) {
5493
+ await this.applicationScript.releaseAndroid(app, assembleType);
5089
5494
  }
5090
5495
  async releaseSource(app, rebuild, buildNum, environment, local) {
5091
5496
  await this.applicationScript.releaseSource(app, { rebuild, buildNum, environment, local });
5092
5497
  }
5498
+ async codepush(app) {
5499
+ const os = await (0, import_prompts8.select)({
5500
+ message: "Select os",
5501
+ choices: [
5502
+ { value: "ios", name: "ios", description: "ios" },
5503
+ { value: "android", name: "android", description: "android" }
5504
+ ]
5505
+ });
5506
+ await this.applicationScript.codepush(app, os);
5507
+ }
5093
5508
  async dumpDatabase(app, environment) {
5094
5509
  await this.applicationScript.dumpDatabase(app, environment);
5095
5510
  }
@@ -5108,9 +5523,6 @@ var ApplicationCommand = class {
5108
5523
  async configureApp(app) {
5109
5524
  await this.applicationScript.configureApp(app);
5110
5525
  }
5111
- async test(sys3) {
5112
- await this.applicationScript.testSys(sys3);
5113
- }
5114
5526
  };
5115
5527
  __decorateClass([
5116
5528
  Target.Public(),
@@ -5190,9 +5602,15 @@ __decorateClass([
5190
5602
  __decorateClass([
5191
5603
  Target.Public({ short: true }),
5192
5604
  __decorateParam(0, App()),
5193
- __decorateParam(1, Option("open", { type: "boolean", desc: "open android simulator", default: false })),
5605
+ __decorateParam(1, Option("host", {
5606
+ type: "string",
5607
+ enum: ["local", "debug", "develop", "main"],
5608
+ desc: "host sever",
5609
+ default: "local"
5610
+ })),
5194
5611
  __decorateParam(2, Option("release", { type: "boolean", desc: "release mode", default: false })),
5195
- __decorateParam(3, Option("sync", { type: "boolean", desc: "sync application", default: true }))
5612
+ __decorateParam(3, Option("open", { type: "boolean", desc: "open android simulator", default: false })),
5613
+ __decorateParam(4, Option("sync", { type: "boolean", desc: "sync application", default: true }))
5196
5614
  ], ApplicationCommand.prototype, "startAndroid", 1);
5197
5615
  __decorateClass([
5198
5616
  Target.Public(),
@@ -5200,7 +5618,8 @@ __decorateClass([
5200
5618
  ], ApplicationCommand.prototype, "releaseIos", 1);
5201
5619
  __decorateClass([
5202
5620
  Target.Public(),
5203
- __decorateParam(0, App())
5621
+ __decorateParam(0, App()),
5622
+ __decorateParam(1, Option("assembleType", { type: "string", enum: ["apk", "aab"], default: "apk" }))
5204
5623
  ], ApplicationCommand.prototype, "releaseAndroid", 1);
5205
5624
  __decorateClass([
5206
5625
  Target.Public(),
@@ -5210,6 +5629,10 @@ __decorateClass([
5210
5629
  __decorateParam(3, Option("environment", { desc: "environment", default: "debug" })),
5211
5630
  __decorateParam(4, Option("local", { type: "boolean", desc: "local", default: true }))
5212
5631
  ], ApplicationCommand.prototype, "releaseSource", 1);
5632
+ __decorateClass([
5633
+ Target.Public(),
5634
+ __decorateParam(0, App())
5635
+ ], ApplicationCommand.prototype, "codepush", 1);
5213
5636
  __decorateClass([
5214
5637
  Target.Public(),
5215
5638
  __decorateParam(0, App()),
@@ -5252,10 +5675,6 @@ __decorateClass([
5252
5675
  Target.Public(),
5253
5676
  __decorateParam(0, App())
5254
5677
  ], ApplicationCommand.prototype, "configureApp", 1);
5255
- __decorateClass([
5256
- Target.Public(),
5257
- __decorateParam(0, Sys())
5258
- ], ApplicationCommand.prototype, "test", 1);
5259
5678
  ApplicationCommand = __decorateClass([
5260
5679
  Commands()
5261
5680
  ], ApplicationCommand);
@@ -5324,7 +5743,7 @@ var PackageScript = class {
5324
5743
  };
5325
5744
 
5326
5745
  // pkgs/@akanjs/cli/src/cloud/cloud.runner.ts
5327
- var import_prompts8 = require("@inquirer/prompts");
5746
+ var import_prompts9 = require("@inquirer/prompts");
5328
5747
  var import_chalk6 = __toESM(require("chalk"), 1);
5329
5748
  var import_latest_version = __toESM(require("latest-version"), 1);
5330
5749
  var import_open2 = __toESM(require("open"), 1);
@@ -5407,18 +5826,20 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
5407
5826
  async deployAkan(workspace, akanPkgs) {
5408
5827
  const basePackageJson = workspace.readJson("pkgs/@akanjs/base/package.json");
5409
5828
  const [majorVersionOfBase, minorVersionOfBase, patchVersionOfBase, devPatchVersionOfBase] = basePackageJson.version.split(".");
5410
- const targetVersionPrefix = devPatchVersionOfBase ? `${majorVersionOfBase}.${minorVersionOfBase}.${patchVersionOfBase}` : `${majorVersionOfBase}.${minorVersionOfBase}`;
5411
- const getNextVersion = async (prefix) => {
5829
+ const isOfficialRelease = !devPatchVersionOfBase;
5830
+ const targetVersionPrefix = isOfficialRelease ? `${majorVersionOfBase}.${minorVersionOfBase}` : `${majorVersionOfBase}.${minorVersionOfBase}.${patchVersionOfBase}`;
5831
+ const tag = isOfficialRelease ? "latest" : patchVersionOfBase.split("-").at(1) ?? "dev";
5832
+ const getNextVersion = async (prefix, tag2) => {
5412
5833
  try {
5413
- const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base", { version: prefix });
5414
- const latestPatch = parseInt(latestPublishedVersionOfBase.split(".")[2]);
5834
+ const latestPublishedVersionOfBase = await (0, import_latest_version.default)("@akanjs/base", { version: tag2 });
5835
+ const latestPatch = parseInt(latestPublishedVersionOfBase.split(".").at(-1) ?? "0");
5415
5836
  const nextVersion2 = `${prefix}.${latestPatch + 1}`;
5416
5837
  return { nextVersion: nextVersion2, latestPublishedVersion: latestPublishedVersionOfBase };
5417
5838
  } catch (e) {
5418
5839
  return { nextVersion: `${prefix}.0`, latestPublishedVersion: null };
5419
5840
  }
5420
5841
  };
5421
- const { nextVersion, latestPublishedVersion } = await getNextVersion(targetVersionPrefix);
5842
+ const { nextVersion, latestPublishedVersion } = await getNextVersion(targetVersionPrefix, tag);
5422
5843
  Logger.info(`Latest published version of @akanjs/base: ${latestPublishedVersion ?? "none"}`);
5423
5844
  Logger.info(`Next version of @akanjs/base: ${nextVersion}`);
5424
5845
  for (const library of akanPkgs) {
@@ -5429,7 +5850,7 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
5429
5850
  const newDistPackageJson = { ...distPackageJson, version: nextVersion };
5430
5851
  workspace.writeJson(`dist/pkgs/${library}/package.json`, newDistPackageJson);
5431
5852
  }
5432
- const isDeployConfirmed = await (0, import_prompts8.confirm)({
5853
+ const isDeployConfirmed = await (0, import_prompts9.confirm)({
5433
5854
  message: "Are you sure you want to deploy the libraries?"
5434
5855
  });
5435
5856
  if (!isDeployConfirmed) {
@@ -5439,7 +5860,7 @@ ${import_chalk6.default.green("\u27A4")} Authentication Required`));
5439
5860
  await Promise.all(
5440
5861
  akanPkgs.map(async (library) => {
5441
5862
  Logger.info(`Publishing ${library}@${nextVersion} to npm...`);
5442
- await workspace.exec(`npm publish`, { cwd: `dist/pkgs/${library}` });
5863
+ await workspace.exec(`npm publish --tag ${tag}`, { cwd: `dist/pkgs/${library}` });
5443
5864
  Logger.info(`${library}@${nextVersion} is published to npm`);
5444
5865
  })
5445
5866
  );
@@ -5621,7 +6042,7 @@ LibraryCommand = __decorateClass([
5621
6042
  ], LibraryCommand);
5622
6043
 
5623
6044
  // pkgs/@akanjs/cli/src/module/module.script.ts
5624
- var import_fs11 = __toESM(require("fs"), 1);
6045
+ var import_fs12 = __toESM(require("fs"), 1);
5625
6046
 
5626
6047
  // pkgs/@akanjs/cli/src/page/page.runner.ts
5627
6048
  var PageRunner = class {
@@ -6086,7 +6507,7 @@ var ModuleScript = class {
6086
6507
  );
6087
6508
  const Name = capitalize(mod.name);
6088
6509
  const relatedCnsts = getRelatedCnsts(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`);
6089
- const constant = import_fs11.default.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
6510
+ const constant = import_fs12.default.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
6090
6511
  const session = new AiSession("createTemplate", { workspace: mod.sys.workspace, cacheKey: mod.name });
6091
6512
  const promptRst = requestTemplate({
6092
6513
  sysName: mod.sys.name,
@@ -6107,7 +6528,7 @@ var ModuleScript = class {
6107
6528
  (f) => !f.filePath.includes(`${mod.name}.Unit.tsx`)
6108
6529
  );
6109
6530
  const relatedCnsts = getRelatedCnsts(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`);
6110
- const constant = import_fs11.default.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
6531
+ const constant = import_fs12.default.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
6111
6532
  const session = new AiSession("createUnit", { workspace: mod.sys.workspace, cacheKey: mod.name });
6112
6533
  const promptRst = requestUnit({
6113
6534
  sysName: mod.sys.name,
@@ -6128,7 +6549,7 @@ var ModuleScript = class {
6128
6549
  );
6129
6550
  const Name = capitalize(mod.name);
6130
6551
  const relatedCnsts = getRelatedCnsts(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`);
6131
- const constant = import_fs11.default.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
6552
+ const constant = import_fs12.default.readFileSync(`${mod.sys.cwdPath}/lib/${mod.name}/${mod.name}.constant.ts`, "utf-8");
6132
6553
  const session = new AiSession("createView", { workspace: mod.sys.workspace, cacheKey: mod.name });
6133
6554
  const promptRst = requestView({
6134
6555
  sysName: mod.sys.name,
@@ -6500,7 +6921,7 @@ WorkspaceCommand = __decorateClass([
6500
6921
  ], WorkspaceCommand);
6501
6922
 
6502
6923
  // pkgs/@akanjs/cli/src/guideline/guideline.prompt.ts
6503
- var import_fs12 = __toESM(require("fs"), 1);
6924
+ var import_fs13 = __toESM(require("fs"), 1);
6504
6925
  var import_promises5 = __toESM(require("fs/promises"), 1);
6505
6926
  var import_meta5 = {};
6506
6927
  var GuidelinePrompt = class extends Prompter {
@@ -6516,7 +6937,7 @@ var GuidelinePrompt = class extends Prompter {
6516
6937
  });
6517
6938
  const paths = [];
6518
6939
  for await (const path10 of matchingPaths) {
6519
- const fileContent = import_fs12.default.readFileSync(path10, "utf-8");
6940
+ const fileContent = import_fs13.default.readFileSync(path10, "utf-8");
6520
6941
  const textFilter = filterText ? new RegExp(filterText) : null;
6521
6942
  if (filterText && !textFilter?.test(fileContent))
6522
6943
  continue;
@@ -6831,7 +7252,7 @@ GuidelineCommand = __decorateClass([
6831
7252
  var import_pluralize3 = __toESM(require("pluralize"), 1);
6832
7253
 
6833
7254
  // pkgs/@akanjs/cli/src/scalar/scalar.prompt.ts
6834
- var import_prompts9 = require("@inquirer/prompts");
7255
+ var import_prompts10 = require("@inquirer/prompts");
6835
7256
  var ScalarPrompt = class extends Prompter {
6836
7257
  constructor(sys3, name) {
6837
7258
  super();
@@ -6839,13 +7260,13 @@ var ScalarPrompt = class extends Prompter {
6839
7260
  this.name = name;
6840
7261
  }
6841
7262
  async requestUpdateConstant() {
6842
- const request = await (0, import_prompts9.input)({ message: `What do you want to change?` });
7263
+ const request = await (0, import_prompts10.input)({ message: `What do you want to change?` });
6843
7264
  return { request, validate: void 0 };
6844
7265
  }
6845
7266
  async requestCreateConstant() {
6846
7267
  const constantFiles = await this.sys.getConstantFilesWithLibs();
6847
- const description = await (0, import_prompts9.input)({ message: "description of scalar scalar" });
6848
- const schemaDescription = await (0, import_prompts9.input)({ message: "schema description of scalar scalar" });
7268
+ const description = await (0, import_prompts10.input)({ message: "description of scalar scalar" });
7269
+ const schemaDescription = await (0, import_prompts10.input)({ message: "schema description of scalar scalar" });
6849
7270
  await this.sys.applyTemplate({
6850
7271
  basePath: "./lib/__scalar",
6851
7272
  template: "__scalar",
@@ -7041,5 +7462,6 @@ void runCommands(
7041
7462
  //! 2. csr폴더를 현 위치로 복사 후 압축 후 삭제
7042
7463
  //! execSync를 가져오기 싫으니 일단 2번 방법으로 해보자
7043
7464
  //! add path in tsconfig.json
7465
+ //! 추후 param에서 select할 수 있도록 수정 필요
7044
7466
  //! 파일을 {name}.View.tsx에 저장.
7045
7467
  //! 파일을 {name}.Unit.tsx에 저장.