@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.
package/dist/main.js CHANGED
@@ -1672,8 +1672,9 @@ var ElementTransformer = class {
1672
1672
  );
1673
1673
  }
1674
1674
  if (hasDangerousHTML && dangerousHTMLValue) {
1675
- statements.push(
1676
- this.t.expressionStatement(
1675
+ const effectCall = this.t.callExpression(this.t.identifier("$effect"), [
1676
+ this.t.arrowFunctionExpression(
1677
+ [],
1677
1678
  this.t.assignmentExpression(
1678
1679
  "=",
1679
1680
  this.t.memberExpression(elId, this.t.identifier("innerHTML")),
@@ -1683,7 +1684,12 @@ var ElementTransformer = class {
1683
1684
  )
1684
1685
  )
1685
1686
  )
1687
+ ]);
1688
+ const cleanupStatements = this.astUtils.addEffectCleanup(
1689
+ scope,
1690
+ effectCall
1686
1691
  );
1692
+ statements.push(...cleanupStatements);
1687
1693
  }
1688
1694
  if (!hasDangerousHTML) {
1689
1695
  this.processDOMChildren(
@@ -4260,7 +4266,7 @@ build
4260
4266
  `;
4261
4267
  }
4262
4268
  function genEnv() {
4263
- return `NODE_ENV=development
4269
+ return `host=localhost
4264
4270
  `;
4265
4271
  }
4266
4272
  function genIndexHtml(name) {
@@ -4378,7 +4384,7 @@ async function selectServices(detected) {
4378
4384
  selected: true
4379
4385
  }))
4380
4386
  });
4381
- if (!response.services) return [];
4387
+ if (!response.services || response.services.length === 0) return [];
4382
4388
  return detected.filter((s) => response.services.includes(s.name));
4383
4389
  }
4384
4390
  async function restructureProject(cwd, projectName) {
@@ -4408,13 +4414,14 @@ async function createDockerfile(cwd, projectName) {
4408
4414
  WORKDIR /app
4409
4415
 
4410
4416
  COPY package*.json ./
4411
- RUN npm ci --only=production
4417
+
4418
+ RUN npm install
4412
4419
 
4413
4420
  COPY . .
4414
- RUN if [ -f "tsconfig.json" ]; then npm run build || true; fi
4415
4421
 
4416
- EXPOSE 3000
4417
- CMD ["npm", "start"]
4422
+ EXPOSE 8080
4423
+
4424
+ CMD ["npm", "run", "dev"]
4418
4425
  `;
4419
4426
  await fs9.writeFile(dockerfilePath, dockerfile);
4420
4427
  }
@@ -4433,25 +4440,42 @@ async function setupProduction(cwd, projectName, services) {
4433
4440
  "--certificatesresolvers.myresolver.acme.email=admin@example.com",
4434
4441
  "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
4435
4442
  ],
4436
- ports: ["80:80", "443:443", "8080:8080"],
4443
+ labels: [
4444
+ "traefik.enable=true",
4445
+ "traefik.http.routers.dashboard.rule=Host(`traefik.${HOST}`)",
4446
+ "traefik.http.routers.dashboard.entrypoints=websecure",
4447
+ "traefik.http.routers.dashboard.tls.certresolver=myresolver",
4448
+ "traefik.http.routers.dashboard.service=api@internal"
4449
+ ],
4450
+ ports: ["80:80", "443:443"],
4437
4451
  volumes: [
4438
4452
  "/var/run/docker.sock:/var/run/docker.sock:ro",
4439
4453
  "./letsencrypt:/letsencrypt"
4440
4454
  ],
4441
- networks: ["web"]
4455
+ networks: ["web"],
4456
+ env_file: [".env"]
4457
+ // Fixed: Added env_file to read HOST variable
4442
4458
  },
4443
4459
  [projectName]: {
4444
- build: ".",
4460
+ build: {
4461
+ context: `./${projectName}`,
4462
+ dockerfile: "Dockerfile"
4463
+ },
4445
4464
  labels: [
4446
4465
  "traefik.enable=true",
4447
- "traefik.http.routers.app.rule=Host(`localhost`)",
4466
+ "traefik.http.routers.app.rule=Host(`${HOST}`)",
4467
+ // Fixed: Changed from app.${HOST} to ${HOST}
4448
4468
  "traefik.http.routers.app.entrypoints=websecure",
4449
4469
  "traefik.http.routers.app.tls.certresolver=myresolver",
4450
- "traefik.http.services.app.loadbalancer.server.port=3000"
4470
+ "traefik.http.services.app.loadbalancer.server.port=8080"
4451
4471
  ],
4452
4472
  env_file: [".env"],
4453
- depends_on: [],
4454
- networks: ["web"]
4473
+ networks: ["web"],
4474
+ volumes: [`./${projectName}:/app`],
4475
+ // Fixed: Changed from ./web to ./${projectName}
4476
+ command: "npm run dev",
4477
+ depends_on: []
4478
+ // Fixed: Added missing depends_on array
4455
4479
  }
4456
4480
  },
4457
4481
  networks: {
@@ -4460,6 +4484,7 @@ async function setupProduction(cwd, projectName, services) {
4460
4484
  }
4461
4485
  },
4462
4486
  volumes: {}
4487
+ // Fixed: Added missing volumes object
4463
4488
  };
4464
4489
  for (const service of services) {
4465
4490
  const config = getServiceConfig(service.name);
@@ -4474,7 +4499,6 @@ async function setupProduction(cwd, projectName, services) {
4474
4499
  composePath,
4475
4500
  yaml.dump(compose, { indent: 2, lineWidth: -1 })
4476
4501
  );
4477
- await createEnvTemplate(cwd, services, "prod");
4478
4502
  }
4479
4503
  async function setupDevelopment(cwd, projectName, services) {
4480
4504
  const existingCompose = path12.join(cwd, "docker-compose.yml");
@@ -4504,7 +4528,7 @@ async function setupDevelopment(cwd, projectName, services) {
4504
4528
  value: s.name
4505
4529
  }))
4506
4530
  });
4507
- if (selected) {
4531
+ if (selected && selected.length > 0) {
4508
4532
  servicesToTunnel.push(
4509
4533
  ...existingServices.filter((s) => selected.includes(s.name)).map((s) => ({ ...s, needsTunnel: true }))
4510
4534
  );
@@ -4517,10 +4541,14 @@ async function setupDevelopment(cwd, projectName, services) {
4517
4541
  const compose = {
4518
4542
  services: {
4519
4543
  [projectName]: {
4520
- build: ".",
4521
- ports: ["3000:3000"],
4544
+ build: {
4545
+ context: `./${projectName}`,
4546
+ dockerfile: "Dockerfile"
4547
+ },
4548
+ ports: ["8080:8080"],
4522
4549
  env_file: [".env"],
4523
- volumes: [".:/app", "/app/node_modules"],
4550
+ volumes: [`./${projectName}:/app`, `/app/node_modules`],
4551
+ // Fixed: Changed from . to ./${projectName}
4524
4552
  command: "npm run dev",
4525
4553
  depends_on: []
4526
4554
  }
@@ -4551,7 +4579,6 @@ async function setupDevelopment(cwd, projectName, services) {
4551
4579
  devComposePath,
4552
4580
  yaml.dump(compose, { indent: 2, lineWidth: -1 })
4553
4581
  );
4554
- await createEnvTemplate(cwd, services, "dev");
4555
4582
  }
4556
4583
  async function createTunnelService(projectDir, serviceName) {
4557
4584
  const tunnelDir = path12.join(projectDir, `${serviceName}-tunnel`);
@@ -4586,21 +4613,6 @@ ssh -i $SSH_KEY \\
4586
4613
  await fs9.writeFile(path12.join(tunnelDir, "Dockerfile"), dockerfile);
4587
4614
  await fs9.writeFile(path12.join(tunnelDir, "tunnel.sh"), tunnelScript);
4588
4615
  }
4589
- async function createEnvTemplate(projectDir, services, env) {
4590
- const envPath = path12.join(projectDir, ".env.example");
4591
- let content = `NODE_ENV=${env === "prod" ? "production" : "development"}
4592
- PORT=3000
4593
- `;
4594
- if (services.length > 0) {
4595
- content += `
4596
- `;
4597
- for (const service of services) {
4598
- const vars = getEnvVars(service.name);
4599
- content += vars.join("\n") + "\n\n";
4600
- }
4601
- }
4602
- await fs9.writeFile(envPath, content);
4603
- }
4604
4616
  function getServiceConfig(serviceName) {
4605
4617
  const configs = {
4606
4618
  postgres: {
@@ -4653,33 +4665,6 @@ function getServiceConfig(serviceName) {
4653
4665
  };
4654
4666
  return configs[serviceName];
4655
4667
  }
4656
- function getEnvVars(serviceName) {
4657
- const vars = {
4658
- postgres: [
4659
- "DB_HOST=postgres",
4660
- "DB_PORT=5432",
4661
- "DB_USER=myuser",
4662
- "DB_PASSWORD=mypassword",
4663
- "DB_NAME=mydb"
4664
- ],
4665
- mysql: [
4666
- "DB_HOST=mysql",
4667
- "DB_PORT=3306",
4668
- "DB_USER=myuser",
4669
- "DB_PASSWORD=mypassword",
4670
- "DB_NAME=mydb",
4671
- "DB_ROOT_PASSWORD=rootpassword"
4672
- ],
4673
- redis: ["REDIS_HOST=redis", "REDIS_PORT=6379"],
4674
- mongodb: [
4675
- "MONGO_HOST=mongodb",
4676
- "MONGO_PORT=27017",
4677
- "MONGO_USER=myuser",
4678
- "MONGO_PASSWORD=mypassword"
4679
- ]
4680
- };
4681
- return vars[serviceName] || [];
4682
- }
4683
4668
  function getDefaultPort(service) {
4684
4669
  const ports = {
4685
4670
  postgres: 5432,
@@ -4696,7 +4681,7 @@ function printNextSteps(projectName, env, services) {
4696
4681
  if (env === "prod") {
4697
4682
  console.log(` # Edit .env with your settings`);
4698
4683
  console.log(` docker-compose up -d`);
4699
- console.log(` # Access at https://localhost
4684
+ console.log(` # Access at https://\${HOST}
4700
4685
  `);
4701
4686
  } else {
4702
4687
  console.log(` # Edit .env with your settings`);
@@ -4710,7 +4695,7 @@ function printNextSteps(projectName, env, services) {
4710
4695
 
4711
4696
  // src/main.ts
4712
4697
  var program = new Command();
4713
- program.name("pod").description("Pod cli tool").version("1.0.16");
4698
+ program.name("pod").description("Pod cli tool").version("1.0.18");
4714
4699
  program.command("new <name>").description("Start a new Pod Project").action(async (name) => {
4715
4700
  await addNew(name);
4716
4701
  const appDir = path13.resolve(process.cwd(), name);