create-forgeon 0.1.5 → 0.1.7

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": "create-forgeon",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Forgeon project generator CLI",
5
5
  "license": "MIT",
6
6
  "author": "Forgeon",
@@ -105,6 +105,20 @@ describe('addModule', () => {
105
105
  const appTsx = fs.readFileSync(path.join(projectRoot, 'apps', 'web', 'src', 'App.tsx'), 'utf8');
106
106
  assert.match(appTsx, /@forgeon\/i18n-web/);
107
107
  assert.match(appTsx, /Language:/);
108
+
109
+ const caddyDockerfile = fs.readFileSync(
110
+ path.join(projectRoot, 'infra', 'docker', 'caddy.Dockerfile'),
111
+ 'utf8',
112
+ );
113
+ assert.match(caddyDockerfile, /COPY tsconfig\.base\.json \.\//);
114
+ assert.match(
115
+ caddyDockerfile,
116
+ /COPY packages\/i18n-contracts\/package\.json packages\/i18n-contracts\/package\.json/,
117
+ );
118
+ assert.match(
119
+ caddyDockerfile,
120
+ /COPY packages\/i18n-web\/package\.json packages\/i18n-web\/package\.json/,
121
+ );
108
122
  } finally {
109
123
  fs.rmSync(targetRoot, { recursive: true, force: true });
110
124
  }
@@ -134,6 +134,47 @@ function patchApiDockerfile(targetRoot) {
134
134
  fs.writeFileSync(dockerfilePath, `${content.trimEnd()}\n`, 'utf8');
135
135
  }
136
136
 
137
+ function patchProxyDockerfile(filePath) {
138
+ if (!fs.existsSync(filePath)) {
139
+ return;
140
+ }
141
+
142
+ let content = fs.readFileSync(filePath, 'utf8').replace(/\r\n/g, '\n');
143
+
144
+ content = ensureLineAfter(
145
+ content,
146
+ 'COPY package.json pnpm-workspace.yaml ./',
147
+ 'COPY tsconfig.base.json ./',
148
+ );
149
+ content = ensureLineAfter(
150
+ content,
151
+ 'COPY apps/web/package.json apps/web/package.json',
152
+ 'COPY packages/i18n-contracts/package.json packages/i18n-contracts/package.json',
153
+ );
154
+ content = ensureLineAfter(
155
+ content,
156
+ 'COPY packages/i18n-contracts/package.json packages/i18n-contracts/package.json',
157
+ 'COPY packages/i18n-web/package.json packages/i18n-web/package.json',
158
+ );
159
+ content = ensureLineAfter(
160
+ content,
161
+ 'COPY apps/web apps/web',
162
+ 'COPY packages/i18n-contracts packages/i18n-contracts',
163
+ );
164
+ content = ensureLineAfter(
165
+ content,
166
+ 'COPY packages/i18n-contracts packages/i18n-contracts',
167
+ 'COPY packages/i18n-web packages/i18n-web',
168
+ );
169
+
170
+ fs.writeFileSync(filePath, `${content.trimEnd()}\n`, 'utf8');
171
+ }
172
+
173
+ function patchProxyDockerfiles(targetRoot) {
174
+ patchProxyDockerfile(path.join(targetRoot, 'infra', 'docker', 'caddy.Dockerfile'));
175
+ patchProxyDockerfile(path.join(targetRoot, 'infra', 'docker', 'nginx.Dockerfile'));
176
+ }
177
+
137
178
  function patchCompose(targetRoot) {
138
179
  const composePath = path.join(targetRoot, 'infra', 'docker', 'compose.yml');
139
180
  if (!fs.existsSync(composePath)) {
@@ -230,6 +271,7 @@ export function applyI18nModule({ packageRoot, targetRoot }) {
230
271
  patchApiPackage(targetRoot);
231
272
  patchWebPackage(targetRoot);
232
273
  patchApiDockerfile(targetRoot);
274
+ patchProxyDockerfiles(targetRoot);
233
275
 
234
276
  upsertEnvLines(path.join(targetRoot, 'apps', 'api', '.env.example'), [
235
277
  'I18N_ENABLED=true',
@@ -26,8 +26,8 @@ export function applyI18nDisabled(targetRoot) {
26
26
  }
27
27
 
28
28
  const apiDockerfile = path.join(targetRoot, 'apps', 'api', 'Dockerfile');
29
- if (fs.existsSync(apiDockerfile)) {
30
- let content = fs.readFileSync(apiDockerfile, 'utf8');
29
+ if (fs.existsSync(apiDockerfile)) {
30
+ let content = fs.readFileSync(apiDockerfile, 'utf8');
31
31
  content = content
32
32
  .replace(/^COPY packages\/i18n\/package\.json packages\/i18n\/package\.json\r?\n/gm, '')
33
33
  .replace(
@@ -41,6 +41,28 @@ export function applyI18nDisabled(targetRoot) {
41
41
  fs.writeFileSync(apiDockerfile, content, 'utf8');
42
42
  }
43
43
 
44
+ const proxyDockerfiles = [
45
+ path.join(targetRoot, 'infra', 'docker', 'caddy.Dockerfile'),
46
+ path.join(targetRoot, 'infra', 'docker', 'nginx.Dockerfile'),
47
+ ];
48
+ for (const dockerfilePath of proxyDockerfiles) {
49
+ if (!fs.existsSync(dockerfilePath)) {
50
+ continue;
51
+ }
52
+
53
+ const content = fs
54
+ .readFileSync(dockerfilePath, 'utf8')
55
+ .replace(
56
+ /^COPY packages\/i18n-contracts\/package\.json packages\/i18n-contracts\/package\.json\r?\n/gm,
57
+ '',
58
+ )
59
+ .replace(/^COPY packages\/i18n-web\/package\.json packages\/i18n-web\/package\.json\r?\n/gm, '')
60
+ .replace(/^COPY packages\/i18n-contracts packages\/i18n-contracts\r?\n/gm, '')
61
+ .replace(/^COPY packages\/i18n-web packages\/i18n-web\r?\n/gm, '');
62
+
63
+ fs.writeFileSync(dockerfilePath, content, 'utf8');
64
+ }
65
+
44
66
  const webPackagePath = path.join(targetRoot, 'apps', 'web', 'package.json');
45
67
  if (fs.existsSync(webPackagePath)) {
46
68
  const webPackage = JSON.parse(fs.readFileSync(webPackagePath, 'utf8'));
@@ -3,9 +3,10 @@ FROM node:20-alpine AS web-builder
3
3
  WORKDIR /app
4
4
  RUN corepack enable
5
5
 
6
- COPY package.json pnpm-workspace.yaml ./
7
- COPY apps/web/package.json apps/web/package.json
8
- RUN pnpm install --frozen-lockfile=false
6
+ COPY package.json pnpm-workspace.yaml ./
7
+ COPY tsconfig.base.json ./
8
+ COPY apps/web/package.json apps/web/package.json
9
+ RUN pnpm install --frozen-lockfile=false
9
10
 
10
11
  COPY apps/web apps/web
11
12
  WORKDIR /app/apps/web
@@ -13,4 +14,4 @@ RUN pnpm build
13
14
 
14
15
  FROM caddy:2-alpine
15
16
  COPY infra/caddy/Caddyfile /etc/caddy/Caddyfile
16
- COPY --from=web-builder /app/apps/web/dist /srv
17
+ COPY --from=web-builder /app/apps/web/dist /srv
@@ -3,9 +3,10 @@ FROM node:20-alpine AS web-builder
3
3
  WORKDIR /app
4
4
  RUN corepack enable
5
5
 
6
- COPY package.json pnpm-workspace.yaml ./
7
- COPY apps/web/package.json apps/web/package.json
8
- RUN pnpm install --frozen-lockfile=false
6
+ COPY package.json pnpm-workspace.yaml ./
7
+ COPY tsconfig.base.json ./
8
+ COPY apps/web/package.json apps/web/package.json
9
+ RUN pnpm install --frozen-lockfile=false
9
10
 
10
11
  COPY apps/web apps/web
11
12
  WORKDIR /app/apps/web