@kithinji/pod 1.0.17 → 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 +42 -63
- package/dist/main.js.map +2 -2
- package/package.json +1 -1
- package/src/add/new/index.ts +1 -1
- package/src/docker/docker.ts +34 -40
- package/src/main.ts +1 -1
package/dist/main.js
CHANGED
|
@@ -4266,7 +4266,7 @@ build
|
|
|
4266
4266
|
`;
|
|
4267
4267
|
}
|
|
4268
4268
|
function genEnv() {
|
|
4269
|
-
return `
|
|
4269
|
+
return `host=localhost
|
|
4270
4270
|
`;
|
|
4271
4271
|
}
|
|
4272
4272
|
function genIndexHtml(name) {
|
|
@@ -4384,7 +4384,7 @@ async function selectServices(detected) {
|
|
|
4384
4384
|
selected: true
|
|
4385
4385
|
}))
|
|
4386
4386
|
});
|
|
4387
|
-
if (!response.services) return [];
|
|
4387
|
+
if (!response.services || response.services.length === 0) return [];
|
|
4388
4388
|
return detected.filter((s) => response.services.includes(s.name));
|
|
4389
4389
|
}
|
|
4390
4390
|
async function restructureProject(cwd, projectName) {
|
|
@@ -4414,13 +4414,14 @@ async function createDockerfile(cwd, projectName) {
|
|
|
4414
4414
|
WORKDIR /app
|
|
4415
4415
|
|
|
4416
4416
|
COPY package*.json ./
|
|
4417
|
-
|
|
4417
|
+
|
|
4418
|
+
RUN npm install
|
|
4418
4419
|
|
|
4419
4420
|
COPY . .
|
|
4420
|
-
RUN if [ -f "tsconfig.json" ]; then npm run build || true; fi
|
|
4421
4421
|
|
|
4422
|
-
EXPOSE
|
|
4423
|
-
|
|
4422
|
+
EXPOSE 8080
|
|
4423
|
+
|
|
4424
|
+
CMD ["npm", "run", "dev"]
|
|
4424
4425
|
`;
|
|
4425
4426
|
await fs9.writeFile(dockerfilePath, dockerfile);
|
|
4426
4427
|
}
|
|
@@ -4439,25 +4440,42 @@ async function setupProduction(cwd, projectName, services) {
|
|
|
4439
4440
|
"--certificatesresolvers.myresolver.acme.email=admin@example.com",
|
|
4440
4441
|
"--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
|
|
4441
4442
|
],
|
|
4442
|
-
|
|
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"],
|
|
4443
4451
|
volumes: [
|
|
4444
4452
|
"/var/run/docker.sock:/var/run/docker.sock:ro",
|
|
4445
4453
|
"./letsencrypt:/letsencrypt"
|
|
4446
4454
|
],
|
|
4447
|
-
networks: ["web"]
|
|
4455
|
+
networks: ["web"],
|
|
4456
|
+
env_file: [".env"]
|
|
4457
|
+
// Fixed: Added env_file to read HOST variable
|
|
4448
4458
|
},
|
|
4449
4459
|
[projectName]: {
|
|
4450
|
-
build:
|
|
4460
|
+
build: {
|
|
4461
|
+
context: `./${projectName}`,
|
|
4462
|
+
dockerfile: "Dockerfile"
|
|
4463
|
+
},
|
|
4451
4464
|
labels: [
|
|
4452
4465
|
"traefik.enable=true",
|
|
4453
|
-
"traefik.http.routers.app.rule=Host(`
|
|
4466
|
+
"traefik.http.routers.app.rule=Host(`${HOST}`)",
|
|
4467
|
+
// Fixed: Changed from app.${HOST} to ${HOST}
|
|
4454
4468
|
"traefik.http.routers.app.entrypoints=websecure",
|
|
4455
4469
|
"traefik.http.routers.app.tls.certresolver=myresolver",
|
|
4456
|
-
"traefik.http.services.app.loadbalancer.server.port=
|
|
4470
|
+
"traefik.http.services.app.loadbalancer.server.port=8080"
|
|
4457
4471
|
],
|
|
4458
4472
|
env_file: [".env"],
|
|
4459
|
-
|
|
4460
|
-
|
|
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
|
|
4461
4479
|
}
|
|
4462
4480
|
},
|
|
4463
4481
|
networks: {
|
|
@@ -4466,6 +4484,7 @@ async function setupProduction(cwd, projectName, services) {
|
|
|
4466
4484
|
}
|
|
4467
4485
|
},
|
|
4468
4486
|
volumes: {}
|
|
4487
|
+
// Fixed: Added missing volumes object
|
|
4469
4488
|
};
|
|
4470
4489
|
for (const service of services) {
|
|
4471
4490
|
const config = getServiceConfig(service.name);
|
|
@@ -4480,7 +4499,6 @@ async function setupProduction(cwd, projectName, services) {
|
|
|
4480
4499
|
composePath,
|
|
4481
4500
|
yaml.dump(compose, { indent: 2, lineWidth: -1 })
|
|
4482
4501
|
);
|
|
4483
|
-
await createEnvTemplate(cwd, services, "prod");
|
|
4484
4502
|
}
|
|
4485
4503
|
async function setupDevelopment(cwd, projectName, services) {
|
|
4486
4504
|
const existingCompose = path12.join(cwd, "docker-compose.yml");
|
|
@@ -4510,7 +4528,7 @@ async function setupDevelopment(cwd, projectName, services) {
|
|
|
4510
4528
|
value: s.name
|
|
4511
4529
|
}))
|
|
4512
4530
|
});
|
|
4513
|
-
if (selected) {
|
|
4531
|
+
if (selected && selected.length > 0) {
|
|
4514
4532
|
servicesToTunnel.push(
|
|
4515
4533
|
...existingServices.filter((s) => selected.includes(s.name)).map((s) => ({ ...s, needsTunnel: true }))
|
|
4516
4534
|
);
|
|
@@ -4523,10 +4541,14 @@ async function setupDevelopment(cwd, projectName, services) {
|
|
|
4523
4541
|
const compose = {
|
|
4524
4542
|
services: {
|
|
4525
4543
|
[projectName]: {
|
|
4526
|
-
build:
|
|
4527
|
-
|
|
4544
|
+
build: {
|
|
4545
|
+
context: `./${projectName}`,
|
|
4546
|
+
dockerfile: "Dockerfile"
|
|
4547
|
+
},
|
|
4548
|
+
ports: ["8080:8080"],
|
|
4528
4549
|
env_file: [".env"],
|
|
4529
|
-
volumes: [
|
|
4550
|
+
volumes: [`./${projectName}:/app`, `/app/node_modules`],
|
|
4551
|
+
// Fixed: Changed from . to ./${projectName}
|
|
4530
4552
|
command: "npm run dev",
|
|
4531
4553
|
depends_on: []
|
|
4532
4554
|
}
|
|
@@ -4557,7 +4579,6 @@ async function setupDevelopment(cwd, projectName, services) {
|
|
|
4557
4579
|
devComposePath,
|
|
4558
4580
|
yaml.dump(compose, { indent: 2, lineWidth: -1 })
|
|
4559
4581
|
);
|
|
4560
|
-
await createEnvTemplate(cwd, services, "dev");
|
|
4561
4582
|
}
|
|
4562
4583
|
async function createTunnelService(projectDir, serviceName) {
|
|
4563
4584
|
const tunnelDir = path12.join(projectDir, `${serviceName}-tunnel`);
|
|
@@ -4592,21 +4613,6 @@ ssh -i $SSH_KEY \\
|
|
|
4592
4613
|
await fs9.writeFile(path12.join(tunnelDir, "Dockerfile"), dockerfile);
|
|
4593
4614
|
await fs9.writeFile(path12.join(tunnelDir, "tunnel.sh"), tunnelScript);
|
|
4594
4615
|
}
|
|
4595
|
-
async function createEnvTemplate(projectDir, services, env) {
|
|
4596
|
-
const envPath = path12.join(projectDir, ".env.example");
|
|
4597
|
-
let content = `NODE_ENV=${env === "prod" ? "production" : "development"}
|
|
4598
|
-
PORT=3000
|
|
4599
|
-
`;
|
|
4600
|
-
if (services.length > 0) {
|
|
4601
|
-
content += `
|
|
4602
|
-
`;
|
|
4603
|
-
for (const service of services) {
|
|
4604
|
-
const vars = getEnvVars(service.name);
|
|
4605
|
-
content += vars.join("\n") + "\n\n";
|
|
4606
|
-
}
|
|
4607
|
-
}
|
|
4608
|
-
await fs9.writeFile(envPath, content);
|
|
4609
|
-
}
|
|
4610
4616
|
function getServiceConfig(serviceName) {
|
|
4611
4617
|
const configs = {
|
|
4612
4618
|
postgres: {
|
|
@@ -4659,33 +4665,6 @@ function getServiceConfig(serviceName) {
|
|
|
4659
4665
|
};
|
|
4660
4666
|
return configs[serviceName];
|
|
4661
4667
|
}
|
|
4662
|
-
function getEnvVars(serviceName) {
|
|
4663
|
-
const vars = {
|
|
4664
|
-
postgres: [
|
|
4665
|
-
"DB_HOST=postgres",
|
|
4666
|
-
"DB_PORT=5432",
|
|
4667
|
-
"DB_USER=myuser",
|
|
4668
|
-
"DB_PASSWORD=mypassword",
|
|
4669
|
-
"DB_NAME=mydb"
|
|
4670
|
-
],
|
|
4671
|
-
mysql: [
|
|
4672
|
-
"DB_HOST=mysql",
|
|
4673
|
-
"DB_PORT=3306",
|
|
4674
|
-
"DB_USER=myuser",
|
|
4675
|
-
"DB_PASSWORD=mypassword",
|
|
4676
|
-
"DB_NAME=mydb",
|
|
4677
|
-
"DB_ROOT_PASSWORD=rootpassword"
|
|
4678
|
-
],
|
|
4679
|
-
redis: ["REDIS_HOST=redis", "REDIS_PORT=6379"],
|
|
4680
|
-
mongodb: [
|
|
4681
|
-
"MONGO_HOST=mongodb",
|
|
4682
|
-
"MONGO_PORT=27017",
|
|
4683
|
-
"MONGO_USER=myuser",
|
|
4684
|
-
"MONGO_PASSWORD=mypassword"
|
|
4685
|
-
]
|
|
4686
|
-
};
|
|
4687
|
-
return vars[serviceName] || [];
|
|
4688
|
-
}
|
|
4689
4668
|
function getDefaultPort(service) {
|
|
4690
4669
|
const ports = {
|
|
4691
4670
|
postgres: 5432,
|
|
@@ -4702,7 +4681,7 @@ function printNextSteps(projectName, env, services) {
|
|
|
4702
4681
|
if (env === "prod") {
|
|
4703
4682
|
console.log(` # Edit .env with your settings`);
|
|
4704
4683
|
console.log(` docker-compose up -d`);
|
|
4705
|
-
console.log(` # Access at https
|
|
4684
|
+
console.log(` # Access at https://\${HOST}
|
|
4706
4685
|
`);
|
|
4707
4686
|
} else {
|
|
4708
4687
|
console.log(` # Edit .env with your settings`);
|
|
@@ -4716,7 +4695,7 @@ function printNextSteps(projectName, env, services) {
|
|
|
4716
4695
|
|
|
4717
4696
|
// src/main.ts
|
|
4718
4697
|
var program = new Command();
|
|
4719
|
-
program.name("pod").description("Pod cli tool").version("1.0.
|
|
4698
|
+
program.name("pod").description("Pod cli tool").version("1.0.18");
|
|
4720
4699
|
program.command("new <name>").description("Start a new Pod Project").action(async (name) => {
|
|
4721
4700
|
await addNew(name);
|
|
4722
4701
|
const appDir = path13.resolve(process.cwd(), name);
|