@akanjs/config 0.9.57 → 0.9.58-canary.1

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.
@@ -1,2 +1,2 @@
1
1
  import type { CapacitorConfig } from "@capacitor/cli";
2
- export declare const withBase: (applyConfig: (config: CapacitorConfig) => CapacitorConfig) => CapacitorConfig;
2
+ export declare const withBase: (configImp: (config: CapacitorConfig) => CapacitorConfig, appData?: any) => CapacitorConfig;
@@ -44,26 +44,32 @@ const getLocalIP = () => {
44
44
  }
45
45
  return "127.0.0.1";
46
46
  };
47
- const withBase = (applyConfig) => {
48
- const appName = process.env.NEXT_PUBLIC_APP_NAME ?? "seon";
49
- if (!appName)
50
- throw new Error("appName is not defined, please run with akan command");
47
+ const withBase = (configImp, appData) => {
51
48
  const ip = getLocalIP();
49
+ const appInfo = appData;
52
50
  const baseConfig = {
53
- //! appId 바꿔야됨.
54
- appId: `com.${appName}.${process.env.NEXT_PUBLIC_ENV}`,
55
- appName,
56
- webDir: `../../dist/apps/${appName}/csr`,
57
- // bundledWebRuntime: false, !not used
51
+ appId: `com.${appInfo.name}.${process.env.NEXT_PUBLIC_ENV}`,
52
+ appName: appInfo.akanConfig.mobile.appName,
53
+ webDir: `../../dist/apps/${appInfo.name}/csr`,
58
54
  server: process.env.APP_OPERATION_MODE !== "release" ? {
59
55
  androidScheme: "http",
60
56
  url: `http://${ip}:4201`,
61
57
  cleartext: true,
62
58
  allowNavigation: [`http://${ip}:8080/*`]
63
- } : void 0,
59
+ } : {
60
+ allowNavigation: ["*"]
61
+ },
64
62
  plugins: {
65
- CapacitorCookies: { enabled: true }
63
+ CapacitorCookies: { enabled: true },
64
+ ...appInfo.akanConfig.mobile.plugins
65
+ },
66
+ ...appInfo.akanConfig.mobile,
67
+ android: {
68
+ ...appInfo.akanConfig.mobile.android
69
+ },
70
+ ios: {
71
+ ...appInfo.akanConfig.mobile.ios
66
72
  }
67
73
  };
68
- return applyConfig(baseConfig);
74
+ return baseConfig;
69
75
  };
@@ -27,9 +27,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var akanConfig_exports = {};
29
29
  __export(akanConfig_exports, {
30
+ decreaseBuildNum: () => decreaseBuildNum,
30
31
  getAppConfig: () => getAppConfig,
32
+ getCapacitorConfig: () => getCapacitorConfig,
31
33
  getLibConfig: () => getLibConfig,
32
34
  getNextConfig: () => getNextConfig,
35
+ increaseBuildNum: () => increaseBuildNum,
33
36
  makeAppConfig: () => makeAppConfig,
34
37
  makeDockerfile: () => makeDockerfile,
35
38
  makeLibConfig: () => makeLibConfig
@@ -41,7 +44,6 @@ var import_path = __toESM(require("path"));
41
44
  var import_nextConfig = require("./nextConfig");
42
45
  var import_types = require("./types");
43
46
  const import_meta = {};
44
- const jiti = (0, import_jiti.createJiti)(import_meta.url);
45
47
  const makeAppConfig = (config, props) => {
46
48
  const { name, repoName } = props;
47
49
  return {
@@ -63,10 +65,12 @@ const makeAppConfig = (config, props) => {
63
65
  explicitDependencies: config.frontend?.explicitDependencies ?? []
64
66
  },
65
67
  mobile: {
68
+ ...config.mobile,
66
69
  appName: config.mobile?.appName ?? name,
67
- bundleId: config.mobile?.bundleId ?? `com.${repoName}.${name}`,
68
- version: config.mobile?.version,
69
- buildNum: config.mobile?.buildNum
70
+ appId: config.mobile?.appId ?? `com.${repoName}.app`,
71
+ version: config.mobile?.version ?? "0.0.1",
72
+ buildNum: config.mobile?.buildNum ?? 1,
73
+ plugins: config.mobile?.plugins
70
74
  }
71
75
  };
72
76
  };
@@ -74,6 +78,11 @@ const getAppConfig = async (appRoot, props) => {
74
78
  const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
75
79
  if (!import_fs.default.existsSync(akanConfigPath))
76
80
  throw new Error(`application akan.config.ts is not found ${appRoot}`);
81
+ const jiti = (0, import_jiti.createJiti)(import_meta.url, {
82
+ fsCache: false,
83
+ requireCache: false,
84
+ interopDefault: true
85
+ });
77
86
  const configImp = (await jiti.import(akanConfigPath)).default;
78
87
  const config = typeof configImp === "function" ? configImp(props) : configImp;
79
88
  return makeAppConfig(config, props);
@@ -94,6 +103,9 @@ const getLibConfig = async (libRoot, props) => {
94
103
  const akanConfigPath = import_path.default.join(libRoot, "akan.config.ts");
95
104
  if (!import_fs.default.existsSync(akanConfigPath))
96
105
  throw new Error(`library akan.config.ts is not found ${libRoot}`);
106
+ const jiti = (0, import_jiti.createJiti)(import_meta.url, {
107
+ cache: false
108
+ });
97
109
  const configImp = (await jiti.import(akanConfigPath)).default;
98
110
  const config = typeof configImp === "function" ? configImp(props) : configImp;
99
111
  return makeLibConfig(config, props);
@@ -111,6 +123,18 @@ const getNextConfig = (configImp, appData) => {
111
123
  const akanConfig = makeAppConfig(config, props);
112
124
  return akanConfig.frontend.nextConfig;
113
125
  };
126
+ const getCapacitorConfig = (configImp, appInfo) => {
127
+ const props = {
128
+ type: "app",
129
+ name: appInfo.name,
130
+ repoName: appInfo.repoName,
131
+ serveDomain: appInfo.serveDomain,
132
+ env: process.env.NEXT_PUBLIC_ENV ?? "debug"
133
+ };
134
+ const config = typeof configImp === "function" ? configImp(props) : configImp;
135
+ const akanConfig = makeAppConfig(config, props);
136
+ return akanConfig;
137
+ };
114
138
  const getDockerRunScripts = (runs) => {
115
139
  return runs.map((run) => {
116
140
  if (typeof run === "string")
@@ -195,3 +219,23 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
195
219
  };
196
220
  }
197
221
  };
222
+ const increaseBuildNum = async (appRoot, props) => {
223
+ const appConfig = await getAppConfig(appRoot, props);
224
+ const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
225
+ const akanConfig = import_fs.default.readFileSync(akanConfigPath, "utf8");
226
+ const akanConfigContent = akanConfig.replace(
227
+ `buildNum: ${appConfig.mobile.buildNum}`,
228
+ `buildNum: ${appConfig.mobile.buildNum + 1}`
229
+ );
230
+ import_fs.default.writeFileSync(akanConfigPath, akanConfigContent);
231
+ };
232
+ const decreaseBuildNum = async (appRoot, props) => {
233
+ const appConfig = await getAppConfig(appRoot, props);
234
+ const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
235
+ const akanConfig = import_fs.default.readFileSync(akanConfigPath, "utf8");
236
+ const akanConfigContent = akanConfig.replace(
237
+ `buildNum: ${appConfig.mobile.buildNum}`,
238
+ `buildNum: ${appConfig.mobile.buildNum - 1}`
239
+ );
240
+ import_fs.default.writeFileSync(akanConfigPath, akanConfigContent);
241
+ };
@@ -67,7 +67,7 @@ const withBase = (appName, config, libs, routes = []) => {
67
67
  ...commandType !== "start" || process.env.USE_PWA === "true" ? [withPWA] : []
68
68
  )({
69
69
  ...config,
70
- eslint: { ...config.eslint, ignoreDuringBuilds: true },
70
+ // eslint: { ...config.eslint, ignoreDuringBuilds: true },
71
71
  env: {
72
72
  ...config.env,
73
73
  basePaths: [...new Set(routes.map(({ basePath }) => basePath))].join(",")
@@ -99,8 +99,6 @@ const withBase = (appName, config, libs, routes = []) => {
99
99
  },
100
100
  webpack: (config2) => {
101
101
  const watchOptions = config2.watchOptions;
102
- config2.resolve.alias.canvas = false;
103
- config2.resolve.alias.encoding = false;
104
102
  const ignored = watchOptions?.ignored ? typeof watchOptions.ignored === "string" ? [watchOptions.ignored] : Array.isArray(watchOptions.ignored) ? watchOptions.ignored.filter((ignore) => typeof ignore === "string") : [] : [];
105
103
  config2.watchOptions = {
106
104
  ...config2.watchOptions ?? {},
@@ -109,10 +107,11 @@ const withBase = (appName, config, libs, routes = []) => {
109
107
  return config2;
110
108
  },
111
109
  turbopack: {
110
+ ...config.turbopack ?? {},
112
111
  resolveAlias: {
113
112
  // canvas: false,
114
113
  // encoding: false,
115
- // ...(process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": "../../pkgs/@akanjs/config" } : {}),
114
+ ...process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": "../../pkgs/@akanjs/config" } : {},
116
115
  ...config.turbopack?.resolveAlias ?? {}
117
116
  }
118
117
  },
@@ -156,7 +155,7 @@ const withBase = (appName, config, libs, routes = []) => {
156
155
  };
157
156
  const defaultNextConfigFile = `import "tsconfig-paths/register.js";
158
157
 
159
- import { getNextConfig } from "@akanjs/config";
158
+ import { getNextConfig } from "${process.env.USE_AKANJS_PKGS === "true" ? "../../pkgs/@akanjs/config" : "@akanjs/config"}";
160
159
 
161
160
  import appInfo from "./akan.app.json";
162
161
  import config from "./akan.config";
@@ -12,28 +12,34 @@ const getLocalIP = () => {
12
12
  }
13
13
  return "127.0.0.1";
14
14
  };
15
- const withBase = (applyConfig) => {
16
- const appName = process.env.NEXT_PUBLIC_APP_NAME ?? "seon";
17
- if (!appName)
18
- throw new Error("appName is not defined, please run with akan command");
15
+ const withBase = (configImp, appData) => {
19
16
  const ip = getLocalIP();
17
+ const appInfo = appData;
20
18
  const baseConfig = {
21
- //! appId 바꿔야됨.
22
- appId: `com.${appName}.${process.env.NEXT_PUBLIC_ENV}`,
23
- appName,
24
- webDir: `../../dist/apps/${appName}/csr`,
25
- // bundledWebRuntime: false, !not used
19
+ appId: `com.${appInfo.name}.${process.env.NEXT_PUBLIC_ENV}`,
20
+ appName: appInfo.akanConfig.mobile.appName,
21
+ webDir: `../../dist/apps/${appInfo.name}/csr`,
26
22
  server: process.env.APP_OPERATION_MODE !== "release" ? {
27
23
  androidScheme: "http",
28
24
  url: `http://${ip}:4201`,
29
25
  cleartext: true,
30
26
  allowNavigation: [`http://${ip}:8080/*`]
31
- } : void 0,
27
+ } : {
28
+ allowNavigation: ["*"]
29
+ },
32
30
  plugins: {
33
- CapacitorCookies: { enabled: true }
31
+ CapacitorCookies: { enabled: true },
32
+ ...appInfo.akanConfig.mobile.plugins
33
+ },
34
+ ...appInfo.akanConfig.mobile,
35
+ android: {
36
+ ...appInfo.akanConfig.mobile.android
37
+ },
38
+ ios: {
39
+ ...appInfo.akanConfig.mobile.ios
34
40
  }
35
41
  };
36
- return applyConfig(baseConfig);
42
+ return baseConfig;
37
43
  };
38
44
  export {
39
45
  withBase
@@ -5,7 +5,6 @@ import { withBase } from "./nextConfig";
5
5
  import {
6
6
  archs
7
7
  } from "./types";
8
- const jiti = createJiti(import.meta.url);
9
8
  const makeAppConfig = (config, props) => {
10
9
  const { name, repoName } = props;
11
10
  return {
@@ -27,10 +26,12 @@ const makeAppConfig = (config, props) => {
27
26
  explicitDependencies: config.frontend?.explicitDependencies ?? []
28
27
  },
29
28
  mobile: {
29
+ ...config.mobile,
30
30
  appName: config.mobile?.appName ?? name,
31
- bundleId: config.mobile?.bundleId ?? `com.${repoName}.${name}`,
32
- version: config.mobile?.version,
33
- buildNum: config.mobile?.buildNum
31
+ appId: config.mobile?.appId ?? `com.${repoName}.app`,
32
+ version: config.mobile?.version ?? "0.0.1",
33
+ buildNum: config.mobile?.buildNum ?? 1,
34
+ plugins: config.mobile?.plugins
34
35
  }
35
36
  };
36
37
  };
@@ -38,6 +39,11 @@ const getAppConfig = async (appRoot, props) => {
38
39
  const akanConfigPath = path.join(appRoot, "akan.config.ts");
39
40
  if (!fs.existsSync(akanConfigPath))
40
41
  throw new Error(`application akan.config.ts is not found ${appRoot}`);
42
+ const jiti = createJiti(import.meta.url, {
43
+ fsCache: false,
44
+ requireCache: false,
45
+ interopDefault: true
46
+ });
41
47
  const configImp = (await jiti.import(akanConfigPath)).default;
42
48
  const config = typeof configImp === "function" ? configImp(props) : configImp;
43
49
  return makeAppConfig(config, props);
@@ -58,6 +64,9 @@ const getLibConfig = async (libRoot, props) => {
58
64
  const akanConfigPath = path.join(libRoot, "akan.config.ts");
59
65
  if (!fs.existsSync(akanConfigPath))
60
66
  throw new Error(`library akan.config.ts is not found ${libRoot}`);
67
+ const jiti = createJiti(import.meta.url, {
68
+ cache: false
69
+ });
61
70
  const configImp = (await jiti.import(akanConfigPath)).default;
62
71
  const config = typeof configImp === "function" ? configImp(props) : configImp;
63
72
  return makeLibConfig(config, props);
@@ -75,6 +84,18 @@ const getNextConfig = (configImp, appData) => {
75
84
  const akanConfig = makeAppConfig(config, props);
76
85
  return akanConfig.frontend.nextConfig;
77
86
  };
87
+ const getCapacitorConfig = (configImp, appInfo) => {
88
+ const props = {
89
+ type: "app",
90
+ name: appInfo.name,
91
+ repoName: appInfo.repoName,
92
+ serveDomain: appInfo.serveDomain,
93
+ env: process.env.NEXT_PUBLIC_ENV ?? "debug"
94
+ };
95
+ const config = typeof configImp === "function" ? configImp(props) : configImp;
96
+ const akanConfig = makeAppConfig(config, props);
97
+ return akanConfig;
98
+ };
78
99
  const getDockerRunScripts = (runs) => {
79
100
  return runs.map((run) => {
80
101
  if (typeof run === "string")
@@ -159,10 +180,33 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
159
180
  };
160
181
  }
161
182
  };
183
+ const increaseBuildNum = async (appRoot, props) => {
184
+ const appConfig = await getAppConfig(appRoot, props);
185
+ const akanConfigPath = path.join(appRoot, "akan.config.ts");
186
+ const akanConfig = fs.readFileSync(akanConfigPath, "utf8");
187
+ const akanConfigContent = akanConfig.replace(
188
+ `buildNum: ${appConfig.mobile.buildNum}`,
189
+ `buildNum: ${appConfig.mobile.buildNum + 1}`
190
+ );
191
+ fs.writeFileSync(akanConfigPath, akanConfigContent);
192
+ };
193
+ const decreaseBuildNum = async (appRoot, props) => {
194
+ const appConfig = await getAppConfig(appRoot, props);
195
+ const akanConfigPath = path.join(appRoot, "akan.config.ts");
196
+ const akanConfig = fs.readFileSync(akanConfigPath, "utf8");
197
+ const akanConfigContent = akanConfig.replace(
198
+ `buildNum: ${appConfig.mobile.buildNum}`,
199
+ `buildNum: ${appConfig.mobile.buildNum - 1}`
200
+ );
201
+ fs.writeFileSync(akanConfigPath, akanConfigContent);
202
+ };
162
203
  export {
204
+ decreaseBuildNum,
163
205
  getAppConfig,
206
+ getCapacitorConfig,
164
207
  getLibConfig,
165
208
  getNextConfig,
209
+ increaseBuildNum,
166
210
  makeAppConfig,
167
211
  makeDockerfile,
168
212
  makeLibConfig
@@ -33,7 +33,7 @@ const withBase = (appName, config, libs, routes = []) => {
33
33
  ...commandType !== "start" || process.env.USE_PWA === "true" ? [withPWA] : []
34
34
  )({
35
35
  ...config,
36
- eslint: { ...config.eslint, ignoreDuringBuilds: true },
36
+ // eslint: { ...config.eslint, ignoreDuringBuilds: true },
37
37
  env: {
38
38
  ...config.env,
39
39
  basePaths: [...new Set(routes.map(({ basePath }) => basePath))].join(",")
@@ -65,8 +65,6 @@ const withBase = (appName, config, libs, routes = []) => {
65
65
  },
66
66
  webpack: (config2) => {
67
67
  const watchOptions = config2.watchOptions;
68
- config2.resolve.alias.canvas = false;
69
- config2.resolve.alias.encoding = false;
70
68
  const ignored = watchOptions?.ignored ? typeof watchOptions.ignored === "string" ? [watchOptions.ignored] : Array.isArray(watchOptions.ignored) ? watchOptions.ignored.filter((ignore) => typeof ignore === "string") : [] : [];
71
69
  config2.watchOptions = {
72
70
  ...config2.watchOptions ?? {},
@@ -75,10 +73,11 @@ const withBase = (appName, config, libs, routes = []) => {
75
73
  return config2;
76
74
  },
77
75
  turbopack: {
76
+ ...config.turbopack ?? {},
78
77
  resolveAlias: {
79
78
  // canvas: false,
80
79
  // encoding: false,
81
- // ...(process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": "../../pkgs/@akanjs/config" } : {}),
80
+ ...process.env.USE_AKANJS_PKGS === "true" ? { "@akanjs/config": "../../pkgs/@akanjs/config" } : {},
82
81
  ...config.turbopack?.resolveAlias ?? {}
83
82
  }
84
83
  },
@@ -122,7 +121,7 @@ const withBase = (appName, config, libs, routes = []) => {
122
121
  };
123
122
  const defaultNextConfigFile = `import "tsconfig-paths/register.js";
124
123
 
125
- import { getNextConfig } from "@akanjs/config";
124
+ import { getNextConfig } from "${process.env.USE_AKANJS_PKGS === "true" ? "../../pkgs/@akanjs/config" : "@akanjs/config"}";
126
125
 
127
126
  import appInfo from "./akan.app.json";
128
127
  import config from "./akan.config";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/config",
3
- "version": "0.9.57",
3
+ "version": "0.9.58-canary.1",
4
4
  "sourceType": "module",
5
5
  "module": {
6
6
  "access": "public"
@@ -12,12 +12,12 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@capacitor/cli": "^7.0.0",
15
- "@next/bundle-analyzer": "^15.1.3",
15
+ "@next/bundle-analyzer": "^16.0.3",
16
16
  "@tailwindcss/postcss": "^4.1.11",
17
17
  "@types/node": "~22.10.4",
18
- "@types/react": "19.1.1",
18
+ "@types/react": "19.2.0",
19
19
  "@types/webpack-env": "^1.18.8",
20
- "daisyui": "^5.0.35",
20
+ "daisyui": "^5.5.5",
21
21
  "jest": "^29.7.0",
22
22
  "jiti": "^2.4.2",
23
23
  "kakao.maps.d.ts": "^0.1.40",
@@ -1,8 +1,11 @@
1
1
  import type { NextConfig } from "next";
2
- import { type AppConfig, type AppConfigResult, type DeepPartial, type DockerConfig, type LibConfigResult, type RunnerProps } from "./types";
2
+ import { type AppConfig, type AppConfigResult, type AppScanResult, type DeepPartial, type DockerConfig, type LibConfigResult, type RunnerProps } from "./types";
3
3
  export declare const makeAppConfig: (config: DeepPartial<AppConfigResult>, props: RunnerProps) => AppConfigResult;
4
4
  export declare const getAppConfig: (appRoot: string, props: RunnerProps) => Promise<AppConfigResult>;
5
5
  export declare const makeLibConfig: (config: DeepPartial<LibConfigResult>, props: RunnerProps) => LibConfigResult;
6
6
  export declare const getLibConfig: (libRoot: string, props: RunnerProps) => Promise<LibConfigResult>;
7
- export declare const getNextConfig: (configImp: AppConfig, appData: any) => NextConfig | (() => Promise<NextConfig> | NextConfig);
7
+ export declare const getNextConfig: (configImp: AppConfig, appData: any) => NextConfig | import("./nextConfig").NextConfigFn | ((baseConfig?: NextConfig) => Promise<NextConfig> | NextConfig | import("./nextConfig").NextConfigFn);
8
+ export declare const getCapacitorConfig: (configImp: AppConfig, appInfo: AppScanResult) => AppConfigResult;
8
9
  export declare const makeDockerfile: (type: "backend" | "frontend", config: DeepPartial<DockerConfig>, props: RunnerProps) => DockerConfig;
10
+ export declare const increaseBuildNum: (appRoot: string, props: RunnerProps) => Promise<void>;
11
+ export declare const decreaseBuildNum: (appRoot: string, props: RunnerProps) => Promise<void>;
@@ -11,4 +11,4 @@ export declare const withBase: (appName: string, config: NextConfig, libs: strin
11
11
  debug?: string[];
12
12
  };
13
13
  }[]) => NextConfigFn;
14
- export declare const defaultNextConfigFile = "import \"tsconfig-paths/register.js\";\n\nimport { getNextConfig } from \"@akanjs/config\";\n\nimport appInfo from \"./akan.app.json\";\nimport config from \"./akan.config\";\n\nexport default getNextConfig(config, appInfo);\n";
14
+ export declare const defaultNextConfigFile: string;
package/src/types.d.ts CHANGED
@@ -1,4 +1,6 @@
1
+ import { CapacitorConfig } from "@capacitor/cli";
1
2
  import type { NextConfig } from "next";
3
+ import { NextConfigFn } from "./nextConfig";
2
4
  export interface RunnerProps {
3
5
  type: "app" | "lib";
4
6
  name: string;
@@ -33,7 +35,7 @@ export interface AppConfigResult {
33
35
  };
34
36
  frontend: {
35
37
  docker: DockerConfig;
36
- nextConfig: NextConfig | (() => Promise<NextConfig> | NextConfig);
38
+ nextConfig: NextConfig | NextConfigFn | ((baseConfig?: NextConfig) => Promise<NextConfig> | NextConfig | NextConfigFn);
37
39
  routes?: {
38
40
  basePath?: string;
39
41
  domains: {
@@ -44,11 +46,9 @@ export interface AppConfigResult {
44
46
  }[];
45
47
  explicitDependencies: ExplicitDependencies;
46
48
  };
47
- mobile: {
48
- appName: string;
49
- bundleId: string;
50
- version?: string;
51
- buildNum?: number;
49
+ mobile: CapacitorConfig & {
50
+ version: string;
51
+ buildNum: number;
52
52
  };
53
53
  }
54
54
  export interface LibConfigResult {