@akanjs/config 0.0.86 → 0.0.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/config",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "type": "commonjs",
5
5
  "module": {
6
6
  "access": "public"
@@ -1,7 +1,7 @@
1
1
  import type { AppConfig, AppConfigResult, DeepPartial, LibConfigResult, RunnerProps } from "@akanjs/config";
2
2
  import type { NextConfig } from "next";
3
- export declare const makeAppConfig: (config: DeepPartial<AppConfigResult>, props?: Partial<RunnerProps>) => AppConfigResult;
3
+ export declare const makeAppConfig: (config: DeepPartial<AppConfigResult>, props: RunnerProps) => AppConfigResult;
4
4
  export declare const getAppConfig: (appRoot: string, props: RunnerProps) => Promise<AppConfigResult>;
5
- export declare const makeLibConfig: (config: DeepPartial<LibConfigResult>, props?: Partial<RunnerProps>) => LibConfigResult;
5
+ export declare const makeLibConfig: (config: DeepPartial<LibConfigResult>, props: RunnerProps) => LibConfigResult;
6
6
  export declare const getLibConfig: (libRoot: string, props: RunnerProps) => Promise<LibConfigResult>;
7
7
  export declare const getNextConfig: (configImp: AppConfig, appData: any) => NextConfig | (() => Promise<NextConfig> | NextConfig);
package/src/akanConfig.js CHANGED
@@ -36,17 +36,9 @@ __export(akanConfig_exports, {
36
36
  module.exports = __toCommonJS(akanConfig_exports);
37
37
  var import_fs = __toESM(require("fs"));
38
38
  var import_path = __toESM(require("path"));
39
- var import_baseConfigEnv = require("./baseConfigEnv");
40
39
  var import_nextConfig = require("./nextConfig");
41
- const makeAppConfig = (config, props = {}) => {
42
- const baseConfigEnv = (0, import_baseConfigEnv.getBaseConfigEnv)(props.appName);
43
- const {
44
- appName = baseConfigEnv.appName,
45
- repoName = baseConfigEnv.repoName,
46
- serveDomain = baseConfigEnv.serveDomain,
47
- env = baseConfigEnv.env,
48
- command = "build"
49
- } = props;
40
+ const makeAppConfig = (config, props) => {
41
+ const { name, repoName, serveDomain, env, command = "build" } = props;
50
42
  return {
51
43
  rootLib: config.rootLib,
52
44
  libs: config.libs ?? [],
@@ -68,7 +60,7 @@ ENV PORT 8080
68
60
  ENV NODE_OPTIONS=--max_old_space_size=8192
69
61
  ENV NEXT_PUBLIC_REPO_NAME=${repoName}
70
62
  ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
71
- ENV NEXT_PUBLIC_APP_NAME=${appName}
63
+ ENV NEXT_PUBLIC_APP_NAME=${name}
72
64
  ENV NEXT_PUBLIC_ENV=${env}
73
65
  ENV NEXT_PUBLIC_OPERATION_MODE=cloud
74
66
  CMD ["node", "main.js"]`,
@@ -87,12 +79,12 @@ ENV PORT 4200
87
79
  ENV NODE_OPTIONS=--max_old_space_size=8192
88
80
  ENV NEXT_PUBLIC_REPO_NAME=${repoName}
89
81
  ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
90
- ENV NEXT_PUBLIC_APP_NAME=${appName}
82
+ ENV NEXT_PUBLIC_APP_NAME=${name}
91
83
  ENV NEXT_PUBLIC_ENV=${env}
92
84
  ENV NEXT_PUBLIC_OPERATION_MODE=cloud
93
85
  CMD ["npm", "start"]`,
94
86
  nextConfig: (0, import_nextConfig.withBase)(
95
- appName,
87
+ name,
96
88
  config.frontend?.nextConfig ? typeof config.frontend.nextConfig === "function" ? config.frontend.nextConfig() : config.frontend.nextConfig : {},
97
89
  config.libs ?? [],
98
90
  config.frontend?.routes
@@ -109,7 +101,7 @@ const getAppConfig = async (appRoot, props) => {
109
101
  const config = typeof configImp === "function" ? configImp(props) : configImp;
110
102
  return makeAppConfig(config, props);
111
103
  };
112
- const makeLibConfig = (config, props = {}) => {
104
+ const makeLibConfig = (config, props) => {
113
105
  return {
114
106
  rootLib: config.rootLib,
115
107
  libs: config.libs ?? [],
@@ -131,12 +123,12 @@ const getLibConfig = async (libRoot, props) => {
131
123
  };
132
124
  const getNextConfig = (configImp, appData) => {
133
125
  const appInfo = appData;
134
- const baseConfigEnv = (0, import_baseConfigEnv.getBaseConfigEnv)(appInfo.name);
135
126
  const props = {
136
- appName: baseConfigEnv.appName,
137
- repoName: baseConfigEnv.repoName,
138
- serveDomain: baseConfigEnv.serveDomain,
139
- env: baseConfigEnv.env,
127
+ type: "app",
128
+ name: appInfo.name,
129
+ repoName: appInfo.repoName,
130
+ serveDomain: appInfo.serveDomain,
131
+ env: process.env.NEXT_PUBLIC_ENV ?? "debug",
140
132
  command: "build"
141
133
  };
142
134
  const config = typeof configImp === "function" ? configImp(props) : configImp;
@@ -1,16 +1,8 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import { getBaseConfigEnv } from "./baseConfigEnv";
4
3
  import { withBase } from "./nextConfig";
5
- const makeAppConfig = (config, props = {}) => {
6
- const baseConfigEnv = getBaseConfigEnv(props.appName);
7
- const {
8
- appName = baseConfigEnv.appName,
9
- repoName = baseConfigEnv.repoName,
10
- serveDomain = baseConfigEnv.serveDomain,
11
- env = baseConfigEnv.env,
12
- command = "build"
13
- } = props;
4
+ const makeAppConfig = (config, props) => {
5
+ const { name, repoName, serveDomain, env, command = "build" } = props;
14
6
  return {
15
7
  rootLib: config.rootLib,
16
8
  libs: config.libs ?? [],
@@ -32,7 +24,7 @@ ENV PORT 8080
32
24
  ENV NODE_OPTIONS=--max_old_space_size=8192
33
25
  ENV NEXT_PUBLIC_REPO_NAME=${repoName}
34
26
  ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
35
- ENV NEXT_PUBLIC_APP_NAME=${appName}
27
+ ENV NEXT_PUBLIC_APP_NAME=${name}
36
28
  ENV NEXT_PUBLIC_ENV=${env}
37
29
  ENV NEXT_PUBLIC_OPERATION_MODE=cloud
38
30
  CMD ["node", "main.js"]`,
@@ -51,12 +43,12 @@ ENV PORT 4200
51
43
  ENV NODE_OPTIONS=--max_old_space_size=8192
52
44
  ENV NEXT_PUBLIC_REPO_NAME=${repoName}
53
45
  ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
54
- ENV NEXT_PUBLIC_APP_NAME=${appName}
46
+ ENV NEXT_PUBLIC_APP_NAME=${name}
55
47
  ENV NEXT_PUBLIC_ENV=${env}
56
48
  ENV NEXT_PUBLIC_OPERATION_MODE=cloud
57
49
  CMD ["npm", "start"]`,
58
50
  nextConfig: withBase(
59
- appName,
51
+ name,
60
52
  config.frontend?.nextConfig ? typeof config.frontend.nextConfig === "function" ? config.frontend.nextConfig() : config.frontend.nextConfig : {},
61
53
  config.libs ?? [],
62
54
  config.frontend?.routes
@@ -73,7 +65,7 @@ const getAppConfig = async (appRoot, props) => {
73
65
  const config = typeof configImp === "function" ? configImp(props) : configImp;
74
66
  return makeAppConfig(config, props);
75
67
  };
76
- const makeLibConfig = (config, props = {}) => {
68
+ const makeLibConfig = (config, props) => {
77
69
  return {
78
70
  rootLib: config.rootLib,
79
71
  libs: config.libs ?? [],
@@ -95,12 +87,12 @@ const getLibConfig = async (libRoot, props) => {
95
87
  };
96
88
  const getNextConfig = (configImp, appData) => {
97
89
  const appInfo = appData;
98
- const baseConfigEnv = getBaseConfigEnv(appInfo.name);
99
90
  const props = {
100
- appName: baseConfigEnv.appName,
101
- repoName: baseConfigEnv.repoName,
102
- serveDomain: baseConfigEnv.serveDomain,
103
- env: baseConfigEnv.env,
91
+ type: "app",
92
+ name: appInfo.name,
93
+ repoName: appInfo.repoName,
94
+ serveDomain: appInfo.serveDomain,
95
+ env: process.env.NEXT_PUBLIC_ENV ?? "debug",
104
96
  command: "build"
105
97
  };
106
98
  const config = typeof configImp === "function" ? configImp(props) : configImp;
package/src/types.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import type { NextConfig } from "next";
2
2
  export interface RunnerProps {
3
- appName: string;
3
+ type: "app" | "lib";
4
+ name: string;
4
5
  repoName: string;
5
6
  serveDomain: string;
6
- env: "testing" | "debug" | "develop" | "main";
7
+ env: "testing" | "local" | "debug" | "develop" | "main";
7
8
  command?: string;
8
9
  }
9
10
  export type Arch = "amd64" | "arm64";
@@ -88,6 +89,8 @@ export declare const getDefaultFileScan: () => FileConventionScanResult;
88
89
  export interface AppScanResult {
89
90
  name: string;
90
91
  type: "app" | "lib";
92
+ repoName: string;
93
+ serveDomain: string;
91
94
  akanConfig: AppConfigResult;
92
95
  files: FileConventionScanResult;
93
96
  libDeps: string[];
@@ -100,6 +103,8 @@ export interface AppScanResult {
100
103
  export interface LibScanResult {
101
104
  name: string;
102
105
  type: "app" | "lib";
106
+ repoName: string;
107
+ serveDomain: string;
103
108
  akanConfig: LibConfigResult;
104
109
  files: FileConventionScanResult;
105
110
  libDeps: string[];
@@ -1,8 +0,0 @@
1
- interface BaseConfigEnv {
2
- appName: string;
3
- repoName: string;
4
- serveDomain: string;
5
- env: "testing" | "debug" | "develop" | "main";
6
- }
7
- export declare const getBaseConfigEnv: (appName?: string | undefined) => BaseConfigEnv;
8
- export {};
@@ -1,36 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var baseConfigEnv_exports = {};
19
- __export(baseConfigEnv_exports, {
20
- getBaseConfigEnv: () => getBaseConfigEnv
21
- });
22
- module.exports = __toCommonJS(baseConfigEnv_exports);
23
- const getBaseConfigEnv = (appName = process.env.NEXT_PUBLIC_APP_NAME) => {
24
- if (!appName)
25
- throw new Error("NEXT_PUBLIC_APP_NAME is not set");
26
- const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
27
- if (!repoName)
28
- throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
29
- const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
30
- if (!serveDomain)
31
- throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
32
- const env = process.env.NEXT_PUBLIC_ENV ?? "debug";
33
- if (!env)
34
- throw new Error("NEXT_PUBLIC_ENV is not set");
35
- return { appName, repoName, serveDomain, env };
36
- };
@@ -1,17 +0,0 @@
1
- const getBaseConfigEnv = (appName = process.env.NEXT_PUBLIC_APP_NAME) => {
2
- if (!appName)
3
- throw new Error("NEXT_PUBLIC_APP_NAME is not set");
4
- const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
5
- if (!repoName)
6
- throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
7
- const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
8
- if (!serveDomain)
9
- throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
10
- const env = process.env.NEXT_PUBLIC_ENV ?? "debug";
11
- if (!env)
12
- throw new Error("NEXT_PUBLIC_ENV is not set");
13
- return { appName, repoName, serveDomain, env };
14
- };
15
- export {
16
- getBaseConfigEnv
17
- };