@akanjs/config 0.9.14 → 0.9.16

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.
@@ -35,6 +35,7 @@ __export(akanConfig_exports, {
35
35
  makeLibConfig: () => makeLibConfig
36
36
  });
37
37
  module.exports = __toCommonJS(akanConfig_exports);
38
+ var import_config = require("@akanjs/config");
38
39
  var import_fs = __toESM(require("fs"));
39
40
  var import_path = __toESM(require("path"));
40
41
  var import_nextConfig = require("./nextConfig");
@@ -113,14 +114,16 @@ const getDockerRunScripts = (runs) => {
113
114
  if (typeof run === "string")
114
115
  return `RUN ${run}`;
115
116
  else
116
- return Object.entries(run).map(([arch, script]) => `RUN if [ "$TARGETARCH" = "${arch}" ]; then ${script}; fi`).join("\n");
117
+ return Object.entries(run).map(
118
+ ([arch, script]) => `RUN if [ "$TARGETARCH" = "${arch}" ]; then ${script}; fi`
119
+ ).join("\n");
117
120
  });
118
121
  };
119
- const getDockerImageScript = (image) => {
122
+ const getDockerImageScript = (image, defaultImage) => {
120
123
  if (typeof image === "string")
121
124
  return `FROM ${image}`;
122
125
  else
123
- return Object.entries(image).map(([arch, image2]) => `FROM ${image2} AS ${arch}`).join("\n");
126
+ return import_config.archs.map((arch) => `FROM ${image[arch] ?? defaultImage} AS ${arch}`).join("\n");
124
127
  };
125
128
  const makeDockerfile = (type, config, props) => {
126
129
  const { name, repoName, serveDomain, env } = props;
@@ -129,7 +132,7 @@ const makeDockerfile = (type, config, props) => {
129
132
  const preRunScripts = getDockerRunScripts(config.preRuns ?? []);
130
133
  const postRunScripts = getDockerRunScripts(config.postRuns ?? []);
131
134
  if (type === "backend") {
132
- const imageScript = config.image ? getDockerImageScript(config.image) : "FROM node:22-slim";
135
+ const imageScript = config.image ? getDockerImageScript(config.image, "node:22-slim") : "FROM node:22-slim";
133
136
  const command = config.command ?? ["node", "main.js"];
134
137
  const content = `${imageScript}
135
138
  RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
@@ -143,7 +146,7 @@ WORKDIR /workspace
143
146
  COPY ./package.json ./package.json
144
147
  RUN npx pnpm i --prod
145
148
  COPY . .
146
- ENV PORT 8080
149
+ ENV PORT=8080
147
150
  ENV NODE_OPTIONS=--max_old_space_size=8192
148
151
  ENV NEXT_PUBLIC_REPO_NAME=${repoName}
149
152
  ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
@@ -160,7 +163,7 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
160
163
  command
161
164
  };
162
165
  } else {
163
- const imageScript = config.image ? getDockerImageScript(config.image) : "FROM node:22-alpine";
166
+ const imageScript = config.image ? getDockerImageScript(config.image, "node:22-alpine") : "FROM node:22-alpine";
164
167
  const command = config.command ?? ["npm", "start"];
165
168
  const content = `${imageScript}
166
169
  RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
package/cjs/src/types.js CHANGED
@@ -17,9 +17,11 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var types_exports = {};
19
19
  __export(types_exports, {
20
+ archs: () => archs,
20
21
  getDefaultFileScan: () => getDefaultFileScan
21
22
  });
22
23
  module.exports = __toCommonJS(types_exports);
24
+ const archs = ["amd64", "arm64"];
23
25
  const getDefaultFileScan = () => ({
24
26
  constants: {
25
27
  databases: [],
@@ -1,3 +1,6 @@
1
+ import {
2
+ archs
3
+ } from "@akanjs/config";
1
4
  import fs from "fs";
2
5
  import path from "path";
3
6
  import { withBase } from "./nextConfig";
@@ -76,14 +79,16 @@ const getDockerRunScripts = (runs) => {
76
79
  if (typeof run === "string")
77
80
  return `RUN ${run}`;
78
81
  else
79
- return Object.entries(run).map(([arch, script]) => `RUN if [ "$TARGETARCH" = "${arch}" ]; then ${script}; fi`).join("\n");
82
+ return Object.entries(run).map(
83
+ ([arch, script]) => `RUN if [ "$TARGETARCH" = "${arch}" ]; then ${script}; fi`
84
+ ).join("\n");
80
85
  });
81
86
  };
82
- const getDockerImageScript = (image) => {
87
+ const getDockerImageScript = (image, defaultImage) => {
83
88
  if (typeof image === "string")
84
89
  return `FROM ${image}`;
85
90
  else
86
- return Object.entries(image).map(([arch, image2]) => `FROM ${image2} AS ${arch}`).join("\n");
91
+ return archs.map((arch) => `FROM ${image[arch] ?? defaultImage} AS ${arch}`).join("\n");
87
92
  };
88
93
  const makeDockerfile = (type, config, props) => {
89
94
  const { name, repoName, serveDomain, env } = props;
@@ -92,7 +97,7 @@ const makeDockerfile = (type, config, props) => {
92
97
  const preRunScripts = getDockerRunScripts(config.preRuns ?? []);
93
98
  const postRunScripts = getDockerRunScripts(config.postRuns ?? []);
94
99
  if (type === "backend") {
95
- const imageScript = config.image ? getDockerImageScript(config.image) : "FROM node:22-slim";
100
+ const imageScript = config.image ? getDockerImageScript(config.image, "node:22-slim") : "FROM node:22-slim";
96
101
  const command = config.command ?? ["node", "main.js"];
97
102
  const content = `${imageScript}
98
103
  RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
@@ -106,7 +111,7 @@ WORKDIR /workspace
106
111
  COPY ./package.json ./package.json
107
112
  RUN npx pnpm i --prod
108
113
  COPY . .
109
- ENV PORT 8080
114
+ ENV PORT=8080
110
115
  ENV NODE_OPTIONS=--max_old_space_size=8192
111
116
  ENV NEXT_PUBLIC_REPO_NAME=${repoName}
112
117
  ENV NEXT_PUBLIC_SERVE_DOMAIN=${serveDomain}
@@ -123,7 +128,7 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
123
128
  command
124
129
  };
125
130
  } else {
126
- const imageScript = config.image ? getDockerImageScript(config.image) : "FROM node:22-alpine";
131
+ const imageScript = config.image ? getDockerImageScript(config.image, "node:22-alpine") : "FROM node:22-alpine";
127
132
  const command = config.command ?? ["npm", "start"];
128
133
  const content = `${imageScript}
129
134
  RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
package/esm/src/types.js CHANGED
@@ -1,3 +1,4 @@
1
+ const archs = ["amd64", "arm64"];
1
2
  const getDefaultFileScan = () => ({
2
3
  constants: {
3
4
  databases: [],
@@ -34,5 +35,6 @@ const getDefaultFileScan = () => ({
34
35
  }
35
36
  });
36
37
  export {
38
+ archs,
37
39
  getDefaultFileScan
38
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/config",
3
- "version": "0.9.14",
3
+ "version": "0.9.16",
4
4
  "sourceType": "module",
5
5
  "module": {
6
6
  "access": "public"
@@ -1,4 +1,4 @@
1
- import type { AppConfig, AppConfigResult, DeepPartial, DockerConfig, LibConfigResult, RunnerProps } from "@akanjs/config";
1
+ import { type AppConfig, type AppConfigResult, type DeepPartial, type DockerConfig, type LibConfigResult, type RunnerProps } from "@akanjs/config";
2
2
  import type { NextConfig } from "next";
3
3
  export declare const makeAppConfig: (config: DeepPartial<AppConfigResult>, props: RunnerProps) => AppConfigResult;
4
4
  export declare const getAppConfig: (appRoot: string, props: RunnerProps) => Promise<AppConfigResult>;
package/src/types.d.ts CHANGED
@@ -7,7 +7,8 @@ export interface RunnerProps {
7
7
  env: "testing" | "local" | "debug" | "develop" | "main";
8
8
  command?: string;
9
9
  }
10
- export type Arch = "amd64" | "arm64";
10
+ export declare const archs: readonly ["amd64", "arm64"];
11
+ export type Arch = (typeof archs)[number];
11
12
  export type ExplicitDependencies = string[] | {
12
13
  [key in Arch]: string[];
13
14
  };