@akanjs/config 0.9.59 → 0.9.60-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.
@@ -44,10 +44,9 @@ var import_path = __toESM(require("path"));
44
44
  var import_nextConfig = require("./nextConfig");
45
45
  var import_types = require("./types");
46
46
  const import_meta = {};
47
- const makeAppConfig = (config, props) => {
47
+ const makeAppConfig = (config, props, optimizeLibs) => {
48
48
  const { name, repoName } = props;
49
49
  return {
50
- libs: config.libs ?? [],
51
50
  backend: {
52
51
  docker: makeDockerfile("backend", config.backend?.docker ?? {}, props),
53
52
  explicitDependencies: config.backend?.explicitDependencies ?? []
@@ -57,7 +56,7 @@ const makeAppConfig = (config, props) => {
57
56
  nextConfig: (0, import_nextConfig.withBase)(
58
57
  name,
59
58
  config.frontend?.nextConfig ? typeof config.frontend.nextConfig === "function" ? config.frontend.nextConfig() : config.frontend.nextConfig : {},
60
- config.libs ?? [],
59
+ optimizeLibs,
61
60
  config.frontend?.routes
62
61
  ),
63
62
  routes: config.frontend?.routes,
@@ -73,7 +72,7 @@ const makeAppConfig = (config, props) => {
73
72
  }
74
73
  };
75
74
  };
76
- const getAppConfig = async (appRoot, props) => {
75
+ const getAppConfig = async (appRoot, props, tsconfig) => {
77
76
  const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
78
77
  if (!import_fs.default.existsSync(akanConfigPath))
79
78
  throw new Error(`application akan.config.ts is not found ${appRoot}`);
@@ -84,11 +83,13 @@ const getAppConfig = async (appRoot, props) => {
84
83
  });
85
84
  const configImp = (await jiti.import(akanConfigPath)).default;
86
85
  const config = typeof configImp === "function" ? configImp(props) : configImp;
87
- return makeAppConfig(config, props);
86
+ const optimizeLibs = Object.entries(tsconfig.compilerOptions.paths ?? {}).filter(
87
+ ([key, resolves]) => key.startsWith("@") && resolves.at(0)?.startsWith("libs/") && resolves.at(0)?.endsWith("/index.ts")
88
+ ).map(([key]) => key.slice(1));
89
+ return makeAppConfig(config, props, optimizeLibs);
88
90
  };
89
91
  const makeLibConfig = (config, props) => {
90
92
  return {
91
- libs: config.libs ?? [],
92
93
  backend: {
93
94
  explicitDependencies: config.backend?.explicitDependencies ?? []
94
95
  },
@@ -118,7 +119,7 @@ const getNextConfig = (configImp, appData) => {
118
119
  env: process.env.NEXT_PUBLIC_ENV ?? "debug"
119
120
  };
120
121
  const config = typeof configImp === "function" ? configImp(props) : configImp;
121
- const akanConfig = makeAppConfig(config, props);
122
+ const akanConfig = makeAppConfig(config, props, appInfo.libDeps);
122
123
  return akanConfig.frontend.nextConfig;
123
124
  };
124
125
  const getCapacitorConfig = (configImp, appInfo) => {
@@ -130,7 +131,7 @@ const getCapacitorConfig = (configImp, appInfo) => {
130
131
  env: process.env.NEXT_PUBLIC_ENV ?? "debug"
131
132
  };
132
133
  const config = typeof configImp === "function" ? configImp(props) : configImp;
133
- const akanConfig = makeAppConfig(config, props);
134
+ const akanConfig = makeAppConfig(config, props, appInfo.libDeps);
134
135
  return akanConfig;
135
136
  };
136
137
  const getDockerRunScripts = (runs) => {
@@ -217,8 +218,8 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
217
218
  };
218
219
  }
219
220
  };
220
- const increaseBuildNum = async (appRoot, props) => {
221
- const appConfig = await getAppConfig(appRoot, props);
221
+ const increaseBuildNum = async (appRoot, props, tsconfig) => {
222
+ const appConfig = await getAppConfig(appRoot, props, tsconfig);
222
223
  const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
223
224
  const akanConfig = import_fs.default.readFileSync(akanConfigPath, "utf8");
224
225
  const akanConfigContent = akanConfig.replace(
@@ -227,8 +228,8 @@ const increaseBuildNum = async (appRoot, props) => {
227
228
  );
228
229
  import_fs.default.writeFileSync(akanConfigPath, akanConfigContent);
229
230
  };
230
- const decreaseBuildNum = async (appRoot, props) => {
231
- const appConfig = await getAppConfig(appRoot, props);
231
+ const decreaseBuildNum = async (appRoot, props, tsconfig) => {
232
+ const appConfig = await getAppConfig(appRoot, props, tsconfig);
232
233
  const akanConfigPath = import_path.default.join(appRoot, "akan.config.ts");
233
234
  const akanConfig = import_fs.default.readFileSync(akanConfigPath, "utf8");
234
235
  const akanConfigContent = akanConfig.replace(
@@ -53,7 +53,7 @@ const composePlugins = (...plugins) => {
53
53
  };
54
54
  const commandType = process.env.AKAN_COMMAND_TYPE?.includes("start") ? "start" : process.env.AKAN_COMMAND_TYPE?.includes("build") ? "build" : "deploy";
55
55
  const devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
56
- const withBase = (appName, config, libs, routes = []) => {
56
+ const withBase = (appName, config, optimizeLibs, routes = []) => {
57
57
  const withPWA = (0, import_next_pwa.default)({
58
58
  dest: "public",
59
59
  register: true,
@@ -77,8 +77,7 @@ const withBase = (appName, config, libs, routes = []) => {
77
77
  experimental: {
78
78
  ...config.experimental ?? {},
79
79
  optimizePackageImports: [
80
- ...[appName, ...libs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
81
- "@contract",
80
+ ...[appName, ...optimizeLibs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
82
81
  "@akanjs/next",
83
82
  "@akanjs/common",
84
83
  "@akanjs/ui"
@@ -5,10 +5,9 @@ import { withBase } from "./nextConfig";
5
5
  import {
6
6
  archs
7
7
  } from "./types";
8
- const makeAppConfig = (config, props) => {
8
+ const makeAppConfig = (config, props, optimizeLibs) => {
9
9
  const { name, repoName } = props;
10
10
  return {
11
- libs: config.libs ?? [],
12
11
  backend: {
13
12
  docker: makeDockerfile("backend", config.backend?.docker ?? {}, props),
14
13
  explicitDependencies: config.backend?.explicitDependencies ?? []
@@ -18,7 +17,7 @@ const makeAppConfig = (config, props) => {
18
17
  nextConfig: withBase(
19
18
  name,
20
19
  config.frontend?.nextConfig ? typeof config.frontend.nextConfig === "function" ? config.frontend.nextConfig() : config.frontend.nextConfig : {},
21
- config.libs ?? [],
20
+ optimizeLibs,
22
21
  config.frontend?.routes
23
22
  ),
24
23
  routes: config.frontend?.routes,
@@ -34,7 +33,7 @@ const makeAppConfig = (config, props) => {
34
33
  }
35
34
  };
36
35
  };
37
- const getAppConfig = async (appRoot, props) => {
36
+ const getAppConfig = async (appRoot, props, tsconfig) => {
38
37
  const akanConfigPath = path.join(appRoot, "akan.config.ts");
39
38
  if (!fs.existsSync(akanConfigPath))
40
39
  throw new Error(`application akan.config.ts is not found ${appRoot}`);
@@ -45,11 +44,13 @@ const getAppConfig = async (appRoot, props) => {
45
44
  });
46
45
  const configImp = (await jiti.import(akanConfigPath)).default;
47
46
  const config = typeof configImp === "function" ? configImp(props) : configImp;
48
- return makeAppConfig(config, props);
47
+ const optimizeLibs = Object.entries(tsconfig.compilerOptions.paths ?? {}).filter(
48
+ ([key, resolves]) => key.startsWith("@") && resolves.at(0)?.startsWith("libs/") && resolves.at(0)?.endsWith("/index.ts")
49
+ ).map(([key]) => key.slice(1));
50
+ return makeAppConfig(config, props, optimizeLibs);
49
51
  };
50
52
  const makeLibConfig = (config, props) => {
51
53
  return {
52
- libs: config.libs ?? [],
53
54
  backend: {
54
55
  explicitDependencies: config.backend?.explicitDependencies ?? []
55
56
  },
@@ -79,7 +80,7 @@ const getNextConfig = (configImp, appData) => {
79
80
  env: process.env.NEXT_PUBLIC_ENV ?? "debug"
80
81
  };
81
82
  const config = typeof configImp === "function" ? configImp(props) : configImp;
82
- const akanConfig = makeAppConfig(config, props);
83
+ const akanConfig = makeAppConfig(config, props, appInfo.libDeps);
83
84
  return akanConfig.frontend.nextConfig;
84
85
  };
85
86
  const getCapacitorConfig = (configImp, appInfo) => {
@@ -91,7 +92,7 @@ const getCapacitorConfig = (configImp, appInfo) => {
91
92
  env: process.env.NEXT_PUBLIC_ENV ?? "debug"
92
93
  };
93
94
  const config = typeof configImp === "function" ? configImp(props) : configImp;
94
- const akanConfig = makeAppConfig(config, props);
95
+ const akanConfig = makeAppConfig(config, props, appInfo.libDeps);
95
96
  return akanConfig;
96
97
  };
97
98
  const getDockerRunScripts = (runs) => {
@@ -178,8 +179,8 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
178
179
  };
179
180
  }
180
181
  };
181
- const increaseBuildNum = async (appRoot, props) => {
182
- const appConfig = await getAppConfig(appRoot, props);
182
+ const increaseBuildNum = async (appRoot, props, tsconfig) => {
183
+ const appConfig = await getAppConfig(appRoot, props, tsconfig);
183
184
  const akanConfigPath = path.join(appRoot, "akan.config.ts");
184
185
  const akanConfig = fs.readFileSync(akanConfigPath, "utf8");
185
186
  const akanConfigContent = akanConfig.replace(
@@ -188,8 +189,8 @@ const increaseBuildNum = async (appRoot, props) => {
188
189
  );
189
190
  fs.writeFileSync(akanConfigPath, akanConfigContent);
190
191
  };
191
- const decreaseBuildNum = async (appRoot, props) => {
192
- const appConfig = await getAppConfig(appRoot, props);
192
+ const decreaseBuildNum = async (appRoot, props, tsconfig) => {
193
+ const appConfig = await getAppConfig(appRoot, props, tsconfig);
193
194
  const akanConfigPath = path.join(appRoot, "akan.config.ts");
194
195
  const akanConfig = fs.readFileSync(akanConfigPath, "utf8");
195
196
  const akanConfigContent = akanConfig.replace(
@@ -19,7 +19,7 @@ const composePlugins = (...plugins) => {
19
19
  };
20
20
  const commandType = process.env.AKAN_COMMAND_TYPE?.includes("start") ? "start" : process.env.AKAN_COMMAND_TYPE?.includes("build") ? "build" : "deploy";
21
21
  const devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
22
- const withBase = (appName, config, libs, routes = []) => {
22
+ const withBase = (appName, config, optimizeLibs, routes = []) => {
23
23
  const withPWA = pwa({
24
24
  dest: "public",
25
25
  register: true,
@@ -43,8 +43,7 @@ const withBase = (appName, config, libs, routes = []) => {
43
43
  experimental: {
44
44
  ...config.experimental ?? {},
45
45
  optimizePackageImports: [
46
- ...[appName, ...libs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
47
- "@contract",
46
+ ...[appName, ...optimizeLibs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
48
47
  "@akanjs/next",
49
48
  "@akanjs/common",
50
49
  "@akanjs/ui"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/config",
3
- "version": "0.9.59",
3
+ "version": "0.9.60-canary.1",
4
4
  "sourceType": "module",
5
5
  "module": {
6
6
  "access": "public"
@@ -1,11 +1,27 @@
1
1
  import type { NextConfig } from "next";
2
2
  import { type AppConfig, type AppConfigResult, type AppScanResult, type DeepPartial, type DockerConfig, type LibConfigResult, type RunnerProps } from "./types";
3
- export declare const makeAppConfig: (config: DeepPartial<AppConfigResult>, props: RunnerProps) => AppConfigResult;
4
- export declare const getAppConfig: (appRoot: string, props: RunnerProps) => Promise<AppConfigResult>;
3
+ export declare const makeAppConfig: (config: DeepPartial<AppConfigResult>, props: RunnerProps, optimizeLibs: string[]) => AppConfigResult;
4
+ export declare const getAppConfig: (appRoot: string, props: RunnerProps, tsconfig: {
5
+ compilerOptions: {
6
+ paths?: Record<string, string[]>;
7
+ };
8
+ }) => Promise<AppConfigResult>;
5
9
  export declare const makeLibConfig: (config: DeepPartial<LibConfigResult>, props: RunnerProps) => LibConfigResult;
6
10
  export declare const getLibConfig: (libRoot: string, props: RunnerProps) => Promise<LibConfigResult>;
7
11
  export declare const getNextConfig: (configImp: AppConfig, appData: any) => NextConfig | import("./nextConfig").NextConfigFn | ((baseConfig?: NextConfig) => Promise<NextConfig> | NextConfig | import("./nextConfig").NextConfigFn);
8
12
  export declare const getCapacitorConfig: (configImp: AppConfig, appInfo: AppScanResult) => AppConfigResult;
9
13
  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>;
14
+ export declare const increaseBuildNum: (appRoot: string, props: RunnerProps, tsconfig: {
15
+ compilerOptions: {
16
+ paths?: {
17
+ [key: string]: string[];
18
+ };
19
+ };
20
+ }) => Promise<void>;
21
+ export declare const decreaseBuildNum: (appRoot: string, props: RunnerProps, tsconfig: {
22
+ compilerOptions: {
23
+ paths?: {
24
+ [key: string]: string[];
25
+ };
26
+ };
27
+ }) => Promise<void>;
@@ -3,7 +3,7 @@ export type NextConfigFn = (phase: string, context?: any) => Promise<NextConfig>
3
3
  export type NextPlugin = (config: NextConfig) => NextConfig;
4
4
  export type NextPluginThatReturnsConfigFn = (config: NextConfig) => NextConfigFn;
5
5
  export declare const composePlugins: (...plugins: (NextPlugin | NextPluginThatReturnsConfigFn)[]) => ((baseConfig: NextConfig) => NextConfigFn);
6
- export declare const withBase: (appName: string, config: NextConfig, libs: string[], routes?: {
6
+ export declare const withBase: (appName: string, config: NextConfig, optimizeLibs: string[], routes?: {
7
7
  basePath?: string;
8
8
  domains: {
9
9
  main?: string[];
package/src/types.d.ts CHANGED
@@ -27,7 +27,6 @@ export interface DockerConfig {
27
27
  command: string[];
28
28
  }
29
29
  export interface AppConfigResult {
30
- libs: string[];
31
30
  backend: {
32
31
  docker: DockerConfig;
33
32
  explicitDependencies: ExplicitDependencies;
@@ -51,7 +50,6 @@ export interface AppConfigResult {
51
50
  };
52
51
  }
53
52
  export interface LibConfigResult {
54
- libs: string[];
55
53
  backend: {
56
54
  explicitDependencies: ExplicitDependencies;
57
55
  };