@kithinji/pod 1.0.16 → 1.0.18

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 +1 @@
1
- {"version":3,"file":"j2d.d.ts","sourceRoot":"","sources":["../../../../src/plugins/transformers/j2d.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,UAAU,aAAa;IACrB,KAAK,EAAE,OAAO,UAAU,CAAC;CAC1B;AAED,UAAU,WAAW;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AA23BD,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,aAAa,GAAG,SAAS,CAAC,WAAW,CAAC,CAmKvE"}
1
+ {"version":3,"file":"j2d.d.ts","sourceRoot":"","sources":["../../../../src/plugins/transformers/j2d.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,UAAU,aAAa;IACrB,KAAK,EAAE,OAAO,UAAU,CAAC;CAC1B;AAED,UAAU,WAAW;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AA24BD,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,aAAa,GAAG,SAAS,CAAC,WAAW,CAAC,CAmKvE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kithinji/pod",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "bin": {
6
6
  "pod": "./dist/main.js"
@@ -125,7 +125,7 @@ build
125
125
  }
126
126
 
127
127
  function genEnv() {
128
- return `NODE_ENV=development
128
+ return `host=localhost
129
129
  `;
130
130
  }
131
131
 
@@ -67,7 +67,8 @@ async function selectServices(
67
67
  })),
68
68
  });
69
69
 
70
- if (!response.services) return [];
70
+ // Fixed: Handle empty response when user cancels
71
+ if (!response.services || response.services.length === 0) return [];
71
72
  return detected.filter((s) => response.services.includes(s.name));
72
73
  }
73
74
 
@@ -106,13 +107,14 @@ async function createDockerfile(cwd: string, projectName: string) {
106
107
  WORKDIR /app
107
108
 
108
109
  COPY package*.json ./
109
- RUN npm ci --only=production
110
+
111
+ RUN npm install
110
112
 
111
113
  COPY . .
112
- RUN if [ -f "tsconfig.json" ]; then npm run build || true; fi
113
114
 
114
- EXPOSE 3000
115
- CMD ["npm", "start"]
115
+ EXPOSE 8080
116
+
117
+ CMD ["npm", "run", "dev"]
116
118
  `;
117
119
 
118
120
  await fs.writeFile(dockerfilePath, dockerfile);
@@ -137,25 +139,38 @@ async function setupProduction(
137
139
  "--certificatesresolvers.myresolver.acme.email=admin@example.com",
138
140
  "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json",
139
141
  ],
140
- ports: ["80:80", "443:443", "8080:8080"],
142
+ labels: [
143
+ "traefik.enable=true",
144
+ "traefik.http.routers.dashboard.rule=Host(`traefik.${HOST}`)",
145
+ "traefik.http.routers.dashboard.entrypoints=websecure",
146
+ "traefik.http.routers.dashboard.tls.certresolver=myresolver",
147
+ "traefik.http.routers.dashboard.service=api@internal",
148
+ ],
149
+ ports: ["80:80", "443:443"],
141
150
  volumes: [
142
151
  "/var/run/docker.sock:/var/run/docker.sock:ro",
143
152
  "./letsencrypt:/letsencrypt",
144
153
  ],
145
154
  networks: ["web"],
155
+ env_file: [".env"], // Fixed: Added env_file to read HOST variable
146
156
  },
147
157
  [projectName]: {
148
- build: ".",
158
+ build: {
159
+ context: `./${projectName}`,
160
+ dockerfile: "Dockerfile",
161
+ },
149
162
  labels: [
150
163
  "traefik.enable=true",
151
- "traefik.http.routers.app.rule=Host(`localhost`)",
164
+ "traefik.http.routers.app.rule=Host(`${HOST}`)", // Fixed: Changed from app.${HOST} to ${HOST}
152
165
  "traefik.http.routers.app.entrypoints=websecure",
153
166
  "traefik.http.routers.app.tls.certresolver=myresolver",
154
- "traefik.http.services.app.loadbalancer.server.port=3000",
167
+ "traefik.http.services.app.loadbalancer.server.port=8080",
155
168
  ],
156
169
  env_file: [".env"],
157
- depends_on: [],
158
170
  networks: ["web"],
171
+ volumes: [`./${projectName}:/app`], // Fixed: Changed from ./web to ./${projectName}
172
+ command: "npm run dev",
173
+ depends_on: [], // Fixed: Added missing depends_on array
159
174
  },
160
175
  },
161
176
  networks: {
@@ -163,7 +178,7 @@ async function setupProduction(
163
178
  driver: "bridge",
164
179
  },
165
180
  },
166
- volumes: {},
181
+ volumes: {}, // Fixed: Added missing volumes object
167
182
  };
168
183
 
169
184
  for (const service of services) {
@@ -180,7 +195,6 @@ async function setupProduction(
180
195
  composePath,
181
196
  yaml.dump(compose, { indent: 2, lineWidth: -1 })
182
197
  );
183
- await createEnvTemplate(cwd, services, "prod");
184
198
  }
185
199
 
186
200
  async function setupDevelopment(
@@ -223,7 +237,7 @@ async function setupDevelopment(
223
237
  })),
224
238
  });
225
239
 
226
- if (selected) {
240
+ if (selected && selected.length > 0) {
227
241
  servicesToTunnel.push(
228
242
  ...existingServices
229
243
  .filter((s) => selected.includes(s.name))
@@ -240,10 +254,13 @@ async function setupDevelopment(
240
254
  const compose: any = {
241
255
  services: {
242
256
  [projectName]: {
243
- build: ".",
244
- ports: ["3000:3000"],
257
+ build: {
258
+ context: `./${projectName}`,
259
+ dockerfile: "Dockerfile",
260
+ },
261
+ ports: ["8080:8080"],
245
262
  env_file: [".env"],
246
- volumes: [".:/app", "/app/node_modules"],
263
+ volumes: [`./${projectName}:/app`, `/app/node_modules`], // Fixed: Changed from . to ./${projectName}
247
264
  command: "npm run dev",
248
265
  depends_on: [],
249
266
  },
@@ -276,7 +293,6 @@ async function setupDevelopment(
276
293
  devComposePath,
277
294
  yaml.dump(compose, { indent: 2, lineWidth: -1 })
278
295
  );
279
- await createEnvTemplate(cwd, services, "dev");
280
296
  }
281
297
 
282
298
  async function createTunnelService(projectDir: string, serviceName: string) {
@@ -316,28 +332,6 @@ ssh -i $SSH_KEY \\
316
332
  await fs.writeFile(path.join(tunnelDir, "tunnel.sh"), tunnelScript);
317
333
  }
318
334
 
319
- async function createEnvTemplate(
320
- projectDir: string,
321
- services: DockerService[],
322
- env: "dev" | "prod"
323
- ) {
324
- const envPath = path.join(projectDir, ".env.example");
325
-
326
- let content = `NODE_ENV=${
327
- env === "prod" ? "production" : "development"
328
- }\nPORT=3000\n`;
329
-
330
- if (services.length > 0) {
331
- content += `\n`;
332
- for (const service of services) {
333
- const vars = getEnvVars(service.name);
334
- content += vars.join("\n") + "\n\n";
335
- }
336
- }
337
-
338
- await fs.writeFile(envPath, content);
339
- }
340
-
341
335
  function getServiceConfig(serviceName: string) {
342
336
  const configs: Record<string, any> = {
343
337
  postgres: {
@@ -441,7 +435,7 @@ function printNextSteps(
441
435
  if (env === "prod") {
442
436
  console.log(` # Edit .env with your settings`);
443
437
  console.log(` docker-compose up -d`);
444
- console.log(` # Access at https://localhost\n`);
438
+ console.log(` # Access at https://\${HOST}\n`);
445
439
  } else {
446
440
  console.log(` # Edit .env with your settings`);
447
441
  if (services.some((s) => s.needsTunnel)) {
package/src/main.ts CHANGED
@@ -28,7 +28,7 @@ import { dockerize } from "./docker";
28
28
 
29
29
  const program = new Command();
30
30
 
31
- program.name("pod").description("Pod cli tool").version("1.0.16");
31
+ program.name("pod").description("Pod cli tool").version("1.0.18");
32
32
 
33
33
  program
34
34
  .command("new <name>")
@@ -419,9 +419,18 @@ class ElementTransformer {
419
419
  );
420
420
  }
421
421
 
422
+ /*
423
+ let cleanup = effect(() => {
424
+ el.innerHTML = {
425
+ __html: value
426
+ }.__html
427
+ })
428
+ */
429
+
422
430
  if (hasDangerousHTML && dangerousHTMLValue) {
423
- statements.push(
424
- this.t.expressionStatement(
431
+ const effectCall = this.t.callExpression(this.t.identifier("$effect"), [
432
+ this.t.arrowFunctionExpression(
433
+ [],
425
434
  this.t.assignmentExpression(
426
435
  "=",
427
436
  this.t.memberExpression(elId, this.t.identifier("innerHTML")),
@@ -430,8 +439,15 @@ class ElementTransformer {
430
439
  this.t.identifier("__html")
431
440
  )
432
441
  )
433
- )
442
+ ),
443
+ ]);
444
+
445
+ const cleanupStatements = this.astUtils.addEffectCleanup(
446
+ scope,
447
+ effectCall
434
448
  );
449
+
450
+ statements.push(...cleanupStatements);
435
451
  }
436
452
 
437
453
  if (!hasDangerousHTML) {