@cellajs/create-cella 0.3.11 → 0.4.0
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/README.md +3 -3
- package/dist/index.js +206 -193
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ pnpm create @cellajs/cella [directory] [options]
|
|
|
16
16
|
| Option | Description |
|
|
17
17
|
| --- | --- |
|
|
18
18
|
| `--template <path>` | Use a custom template (local path or `github:user/repo`) |
|
|
19
|
-
| `--
|
|
19
|
+
| `--app-index <number>` | Set this app's number for its dev ports (0-9, not 4): frontend 3000 + N, services 4000 + 10N, database 5432 + 10N |
|
|
20
20
|
| `--admin-email <email>` | Set the admin email for the initial seed user |
|
|
21
21
|
| `-v, --version` | Output the current version |
|
|
22
22
|
| `-h, --help` | Display the help message |
|
|
@@ -24,8 +24,8 @@ pnpm create @cellajs/cella [directory] [options]
|
|
|
24
24
|
## What It Does
|
|
25
25
|
|
|
26
26
|
1. Creates a new project from a Cella template snapshot
|
|
27
|
-
2. Lets you choose
|
|
28
|
-
3. Cleans the template
|
|
27
|
+
2. Lets you choose an app number that is free on this machine, and the seed admin email
|
|
28
|
+
3. Cleans the template, generates project-specific config and points coding agents at the template's rules and skills
|
|
29
29
|
4. Initializes a fresh git repository with an initial commit
|
|
30
30
|
5. Adds the Cella upstream remote for future syncs
|
|
31
31
|
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/create-cella-cli.ts
|
|
4
4
|
import { existsSync as existsSync2 } from "fs";
|
|
5
|
-
import { rm as
|
|
5
|
+
import { rm as rm2 } from "fs/promises";
|
|
6
6
|
import { basename as basename2, resolve as resolve3 } from "path";
|
|
7
7
|
import { input, select } from "@inquirer/prompts";
|
|
8
8
|
import pc6 from "picocolors";
|
|
@@ -13,7 +13,7 @@ import pc from "picocolors";
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "@cellajs/create-cella",
|
|
16
|
-
version: "0.
|
|
16
|
+
version: "0.4.0",
|
|
17
17
|
private: false,
|
|
18
18
|
license: "MIT",
|
|
19
19
|
description: "Cella is a TypeScript template to create web apps with sync and offline capabilities.",
|
|
@@ -81,7 +81,7 @@ var package_default = {
|
|
|
81
81
|
typescript: "6.0.3",
|
|
82
82
|
vitest: "^5.0.3"
|
|
83
83
|
},
|
|
84
|
-
packageManager: "pnpm@11.
|
|
84
|
+
packageManager: "pnpm@11.28.7",
|
|
85
85
|
commitlint: {
|
|
86
86
|
extends: [
|
|
87
87
|
"@commitlint/config-conventional"
|
|
@@ -115,7 +115,7 @@ var TEMPLATE_URL = "github:cellajs/cella";
|
|
|
115
115
|
var TEMPLATE_REPOSITORY = "cellajs/cella";
|
|
116
116
|
var TEMPLATE_GIT_URL = `https://github.com/${TEMPLATE_REPOSITORY}.git`;
|
|
117
117
|
var SYNC_CONFIG = "cella/cella.config.ts";
|
|
118
|
-
var CELLA_REMOTE_URL =
|
|
118
|
+
var CELLA_REMOTE_URL = TEMPLATE_GIT_URL;
|
|
119
119
|
var CELLA_REMOTE_NAME = "cella-upstream";
|
|
120
120
|
var DESCRIPTION = package_default.description;
|
|
121
121
|
var VERSION = package_default.version;
|
|
@@ -130,16 +130,24 @@ function getHeaderLine() {
|
|
|
130
130
|
var TO_REMOVE = ["./infra/Pulumi.production.yaml", "./infra/Pulumi.staging.yaml"];
|
|
131
131
|
var TO_CLEAN = ["./backend/drizzle"];
|
|
132
132
|
var TO_COPY = {
|
|
133
|
-
"./frontend/.env.example": "./frontend/.env"
|
|
134
|
-
"./cella/QUICKSTART.md": "README.md"
|
|
133
|
+
"./frontend/.env.example": "./frontend/.env"
|
|
135
134
|
};
|
|
135
|
+
var QUICKSTART = "./cella/QUICKSTART.md";
|
|
136
|
+
var AGENT_FILES = {
|
|
137
|
+
"AGENTS.md": "# Agent guidelines\n\nThis app is built from the cella template. Read [cella/AGENTS.md](./cella/AGENTS.md) before changing code: it holds the project rules. Skills, such as `add-entity`, live in [cella/skills](./cella/skills).\n",
|
|
138
|
+
"CLAUDE.md": "@cella/AGENTS.md\n"
|
|
139
|
+
};
|
|
140
|
+
var frontendPort = (appIndex) => 3e3 + appIndex;
|
|
141
|
+
function quickstartToReadme(source, displayName, appIndex) {
|
|
142
|
+
return source.replace(/^# .*$/m, `# ${displayName}`).replace(/^## Create\n[\s\S]*?(?=^## )/m, "").replaceAll("](./", "](./cella/").replaceAll("](../", "](./").replaceAll("http://localhost:3000", `http://localhost:${frontendPort(appIndex)}`);
|
|
143
|
+
}
|
|
136
144
|
var PLACEHOLDER_CONFIG = "shared/config/config.template.ts";
|
|
137
145
|
var INITIAL_VERSION = "0.0.0";
|
|
138
146
|
async function generateEnvFromExample(examplePath, replacements) {
|
|
139
|
-
const { readFile:
|
|
147
|
+
const { readFile: readFile3 } = await import("fs/promises");
|
|
140
148
|
let content;
|
|
141
149
|
try {
|
|
142
|
-
content = await
|
|
150
|
+
content = await readFile3(examplePath, "utf8");
|
|
143
151
|
} catch {
|
|
144
152
|
return null;
|
|
145
153
|
}
|
|
@@ -148,45 +156,38 @@ async function generateEnvFromExample(examplePath, replacements) {
|
|
|
148
156
|
return match;
|
|
149
157
|
});
|
|
150
158
|
}
|
|
151
|
-
function getBackendEnvReplacements(slug, adminEmail,
|
|
152
|
-
const db = 5432 +
|
|
159
|
+
function getBackendEnvReplacements(slug, adminEmail, appIndex) {
|
|
160
|
+
const db = 5432 + appIndex * 10;
|
|
153
161
|
return {
|
|
154
162
|
PROJECT_SLUG: slug,
|
|
155
163
|
DB_PORT: String(db),
|
|
156
|
-
DB_TEST_PORT: String(5434 +
|
|
164
|
+
DB_TEST_PORT: String(5434 + appIndex * 10),
|
|
157
165
|
DATABASE_URL: `postgres://runtime_role:dev_password@0.0.0.0:${db}/postgres`,
|
|
158
166
|
DATABASE_ADMIN_URL: `postgres://postgres:postgres@0.0.0.0:${db}/postgres`,
|
|
159
167
|
DATABASE_CDC_URL: `postgres://admin_role:dev_password@0.0.0.0:${db}/postgres`,
|
|
160
168
|
ADMIN_EMAIL: adminEmail
|
|
161
169
|
};
|
|
162
170
|
}
|
|
163
|
-
function
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
mcp: api + 3,
|
|
172
|
-
oauth: api + 4,
|
|
173
|
-
internal: api + 5,
|
|
174
|
-
jobs: api + 6
|
|
175
|
-
};
|
|
176
|
-
const devPortsExpression = Object.entries(devPorts).map(([key, port]) => `${key}: ${port}`).join(", ");
|
|
171
|
+
function setDevAppIndex(source, appIndex) {
|
|
172
|
+
const pattern = /^(\s*devAppIndex:\s*)\d+/m;
|
|
173
|
+
if (appIndex !== 0 && !pattern.test(source)) {
|
|
174
|
+
throw new Error("This template has no devAppIndex in its config: use app index 0, or a newer template.");
|
|
175
|
+
}
|
|
176
|
+
return source.replace(pattern, (_, head) => `${head}${appIndex}`);
|
|
177
|
+
}
|
|
178
|
+
function generateEnvConfigs(slug, name) {
|
|
177
179
|
const header = "import type { DeepPartial } from '../src/config-builder/types.ts';\nimport type { config as _default } from './config.default.ts';\n";
|
|
178
180
|
const envs = {
|
|
179
181
|
development: {
|
|
180
182
|
props: {
|
|
181
183
|
slug: `${slug}-development`,
|
|
182
184
|
domain: "",
|
|
183
|
-
frontendUrl:
|
|
184
|
-
backendUrl:
|
|
185
|
-
backendAuthUrl:
|
|
186
|
-
yjsUrl:
|
|
187
|
-
mcpUrl:
|
|
188
|
-
oauthUrl:
|
|
189
|
-
devPorts: `={ ${devPortsExpression} }`,
|
|
185
|
+
frontendUrl: "http://localhost:3000",
|
|
186
|
+
backendUrl: "http://localhost:3000/api",
|
|
187
|
+
backendAuthUrl: "http://localhost:3000/api/auth",
|
|
188
|
+
yjsUrl: "ws://localhost:3000/yjs",
|
|
189
|
+
mcpUrl: "http://localhost:3000/mcp",
|
|
190
|
+
oauthUrl: "http://localhost:3000/oauth",
|
|
190
191
|
// The template's shared development buckets hold the seed files and the GeoIP databases,
|
|
191
192
|
// so seeded attachments render before the app has storage of its own.
|
|
192
193
|
s3: "={ region: 'nl-ams', host: 's3.nl-ams.scw.cloud', publicBucket: 'cella-shared-public', privateBucket: 'cella-shared-private' }"
|
|
@@ -224,7 +225,10 @@ function generateEnvConfigs(slug, name, portOffset) {
|
|
|
224
225
|
backendAuthUrl: "=development.backendAuthUrl",
|
|
225
226
|
yjsUrl: "=development.yjsUrl",
|
|
226
227
|
mcpUrl: "=development.mcpUrl",
|
|
227
|
-
oauthUrl: "=development.oauthUrl"
|
|
228
|
+
oauthUrl: "=development.oauthUrl",
|
|
229
|
+
// The suite covers every service and signs storage URLs, as cella's own test config has it
|
|
230
|
+
services: "={ yjs: { enabled: true }, mcp: { enabled: true }, oauth: { enabled: true } }",
|
|
231
|
+
s3: "=development.s3"
|
|
228
232
|
}
|
|
229
233
|
},
|
|
230
234
|
production: { props: { maintenance: false } }
|
|
@@ -251,9 +255,8 @@ ${nameEntry}${body}
|
|
|
251
255
|
|
|
252
256
|
// src/create.ts
|
|
253
257
|
import { existsSync } from "fs";
|
|
254
|
-
import { cp, mkdir
|
|
255
|
-
import { dirname as dirname2, isAbsolute, join as join4, relative
|
|
256
|
-
import { checkbox } from "@inquirer/prompts";
|
|
258
|
+
import { cp, mkdir } from "fs/promises";
|
|
259
|
+
import { dirname as dirname2, isAbsolute, join as join4, relative, resolve as resolve2 } from "path";
|
|
257
260
|
import pc5 from "picocolors";
|
|
258
261
|
|
|
259
262
|
// src/utils/git/command.ts
|
|
@@ -313,6 +316,51 @@ async function addRemote({
|
|
|
313
316
|
import { basename, resolve } from "path";
|
|
314
317
|
import { Command, InvalidArgumentError } from "commander";
|
|
315
318
|
|
|
319
|
+
// src/utils/detect-used-ports.ts
|
|
320
|
+
import { readdir, readFile } from "fs/promises";
|
|
321
|
+
import { dirname, join } from "path";
|
|
322
|
+
async function detectUsedPorts(targetFolder) {
|
|
323
|
+
const parentDir = dirname(targetFolder);
|
|
324
|
+
const used = [];
|
|
325
|
+
let siblings;
|
|
326
|
+
try {
|
|
327
|
+
siblings = await readdir(parentDir);
|
|
328
|
+
} catch {
|
|
329
|
+
return used;
|
|
330
|
+
}
|
|
331
|
+
for (const name of siblings) {
|
|
332
|
+
const configDir = join(parentDir, name, "shared/config");
|
|
333
|
+
try {
|
|
334
|
+
const development = await readFile(join(configDir, "config.development.ts"), "utf8");
|
|
335
|
+
const defaults = await readFile(join(configDir, "config.default.ts"), "utf8").catch(() => "");
|
|
336
|
+
const feMatch = development.match(/frontendUrl:\s*'http:\/\/localhost:(\d+)/);
|
|
337
|
+
if (!feMatch) continue;
|
|
338
|
+
const frontend = Number(feMatch[1]);
|
|
339
|
+
const index = Number(defaults.match(/devAppIndex:\s*(\d+)/)?.[1] ?? 0);
|
|
340
|
+
const apiPattern = /devPorts:\s*\{[^}]*?\bapi:\s*(\d+)/;
|
|
341
|
+
const devPortsMatch = development.match(apiPattern) ?? defaults.match(apiPattern);
|
|
342
|
+
const legacyBeMatch = development.match(/backendUrl:\s*'http:\/\/localhost:(\d+)'/);
|
|
343
|
+
const backend = devPortsMatch ? Number(devPortsMatch[1]) : legacyBeMatch ? Number(legacyBeMatch[1]) : frontend + 1e3;
|
|
344
|
+
used.push({ project: name, frontend: frontend + index, backend: backend + index * 10 });
|
|
345
|
+
} catch {
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return used;
|
|
349
|
+
}
|
|
350
|
+
var isAppIndex = (index) => Number.isInteger(index) && index >= 0 && index <= 9 && index !== 4;
|
|
351
|
+
function findNextAppIndex(usedPorts, isBusy = () => false) {
|
|
352
|
+
for (let index = 0; index <= 9; index += 1) {
|
|
353
|
+
if (!isAppIndex(index) || isBusy(index)) continue;
|
|
354
|
+
const api = 4e3 + index * 10;
|
|
355
|
+
const taken = usedPorts.some((p) => p.frontend === 3e3 + index || p.backend >= api && p.backend < api + 10);
|
|
356
|
+
if (!taken) return index;
|
|
357
|
+
}
|
|
358
|
+
return 0;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/utils/is-email.ts
|
|
362
|
+
var isEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|
363
|
+
|
|
316
364
|
// src/utils/validate-project-name.ts
|
|
317
365
|
import validate from "validate-npm-package-name";
|
|
318
366
|
function validateProjectName(name) {
|
|
@@ -327,24 +375,27 @@ function validateProjectName(name) {
|
|
|
327
375
|
}
|
|
328
376
|
|
|
329
377
|
// src/modules/cli/commands.ts
|
|
330
|
-
function
|
|
378
|
+
function parseAppIndex(value) {
|
|
331
379
|
const parsed = Number(value);
|
|
332
|
-
if (!
|
|
333
|
-
throw new InvalidArgumentError("
|
|
334
|
-
}
|
|
335
|
-
if (parsed % 10 !== 0) {
|
|
336
|
-
throw new InvalidArgumentError("Port offset must be a multiple of 10");
|
|
380
|
+
if (!isAppIndex(parsed)) {
|
|
381
|
+
throw new InvalidArgumentError("App index must be a whole number from 0 to 9, not 4");
|
|
337
382
|
}
|
|
338
383
|
return parsed;
|
|
339
384
|
}
|
|
385
|
+
function parseAdminEmail(value) {
|
|
386
|
+
if (!isEmail(value)) throw new InvalidArgumentError("Admin email must be an address such as admin@example.com");
|
|
387
|
+
return value;
|
|
388
|
+
}
|
|
340
389
|
var directory = null;
|
|
341
390
|
var packageManager = "pnpm";
|
|
342
|
-
var command = new Command(NAME).version(VERSION, "-v, --version", `output the current version of ${NAME}`).argument("[directory]", "the directory name for the new project").usage("[directory] [options]").helpOption("-h, --help", "display this help message").option("--template <path>", "use a custom template (local path or github:user/repo)").option("--
|
|
391
|
+
var command = new Command(NAME).version(VERSION, "-v, --version", `output the current version of ${NAME}`).argument("[directory]", "the directory name for the new project").usage("[directory] [options]").helpOption("-h, --help", "display this help message").option("--template <path>", "use a custom template (local path or github:user/repo)").option("--app-index <number>", "set this app's number for its dev ports (0-9, not 4)", parseAppIndex).option("--admin-email <email>", "set the admin email for the initial seed user", parseAdminEmail).action((name, _options, self) => {
|
|
343
392
|
const trimmedName = typeof name === "string" ? name.trim() : name;
|
|
344
393
|
if (trimmedName) {
|
|
345
394
|
const validation = validateProjectName(basename(resolve(trimmedName)));
|
|
346
395
|
if (!validation.valid) {
|
|
347
|
-
|
|
396
|
+
self.error(
|
|
397
|
+
`error: invalid project name "${trimmedName}": ${validation.problems?.[0] ?? "unknown error"}. Use lowercase letters, digits and dashes, such as my-app.`
|
|
398
|
+
);
|
|
348
399
|
}
|
|
349
400
|
directory = trimmedName;
|
|
350
401
|
}
|
|
@@ -382,7 +433,7 @@ function confirmChoice(label, value) {
|
|
|
382
433
|
console.info(`${pc2.green("\u2713")} ${label} \xB7 ${value}`);
|
|
383
434
|
console.info();
|
|
384
435
|
}
|
|
385
|
-
function showSuccess(projectName, _targetFolder, relativePath, needsCd, packageManager2) {
|
|
436
|
+
function showSuccess(projectName, _targetFolder, relativePath, needsCd, packageManager2, appIndex, adminEmail) {
|
|
386
437
|
console.info();
|
|
387
438
|
console.info(pc2.bold("Next steps"));
|
|
388
439
|
console.info(DIVIDER);
|
|
@@ -396,6 +447,10 @@ function showSuccess(projectName, _targetFolder, relativePath, needsCd, packageM
|
|
|
396
447
|
`${pc2.dim("$")} ${pc2.cyan(`${packageManager2} docker`)} ${pc2.dim("&&")} ${pc2.cyan(`${packageManager2} seed`)} ${pc2.dim("&&")} ${pc2.cyan(`${packageManager2} dev`)}`
|
|
397
448
|
);
|
|
398
449
|
console.info();
|
|
450
|
+
console.info(
|
|
451
|
+
`${pc2.gray("Then open")} ${pc2.cyan(`http://localhost:${frontendPort(appIndex)}`)} ${pc2.gray("and sign in as")} ${pc2.cyan(adminEmail)}${pc2.gray(`: the magic link is printed in the ${packageManager2} dev output.`)}`
|
|
452
|
+
);
|
|
453
|
+
console.info();
|
|
399
454
|
const readmePath = relativePath ? `${relativePath}/README.md` : "README.md";
|
|
400
455
|
console.info(`${pc2.gray("To get started building, please read:")} ${pc2.cyan(readmePath)}`);
|
|
401
456
|
console.info();
|
|
@@ -412,7 +467,7 @@ async function cleanTemplate({
|
|
|
412
467
|
targetFolder,
|
|
413
468
|
projectName,
|
|
414
469
|
displayName,
|
|
415
|
-
|
|
470
|
+
appIndex = 0,
|
|
416
471
|
adminEmail = `admin@${projectName}.example.com`
|
|
417
472
|
}) {
|
|
418
473
|
if (process.cwd() !== targetFolder) {
|
|
@@ -426,10 +481,12 @@ async function cleanTemplate({
|
|
|
426
481
|
const destAbsolutePath = path.resolve(targetFolder, dest);
|
|
427
482
|
await copyFile(srcAbsolutePath, destAbsolutePath);
|
|
428
483
|
}
|
|
429
|
-
await
|
|
484
|
+
await writeReadme(targetFolder, displayName, appIndex);
|
|
485
|
+
await writeAgentEntry(targetFolder);
|
|
486
|
+
await applyPlaceholderConfig(targetFolder, projectName, displayName, appIndex);
|
|
430
487
|
await resetReleaseState(targetFolder, projectName);
|
|
431
488
|
await removeTemplateForks(targetFolder);
|
|
432
|
-
const backendReplacements = getBackendEnvReplacements(projectName, adminEmail,
|
|
489
|
+
const backendReplacements = getBackendEnvReplacements(projectName, adminEmail, appIndex);
|
|
433
490
|
const backendEnv = await generateEnvFromExample(
|
|
434
491
|
path.resolve(targetFolder, "backend/.env.example"),
|
|
435
492
|
backendReplacements
|
|
@@ -437,7 +494,7 @@ async function cleanTemplate({
|
|
|
437
494
|
if (backendEnv) {
|
|
438
495
|
await fs2.writeFile(path.resolve(targetFolder, "backend/.env"), backendEnv, "utf8");
|
|
439
496
|
}
|
|
440
|
-
const envConfigs = generateEnvConfigs(projectName, displayName
|
|
497
|
+
const envConfigs = generateEnvConfigs(projectName, displayName);
|
|
441
498
|
await Promise.all(
|
|
442
499
|
Object.entries(envConfigs).map(
|
|
443
500
|
([filePath, content]) => fs2.writeFile(path.resolve(targetFolder, filePath), content, "utf8")
|
|
@@ -462,6 +519,31 @@ async function cleanTemplate({
|
|
|
462
519
|
})();
|
|
463
520
|
});
|
|
464
521
|
}
|
|
522
|
+
async function writeReadme(targetFolder, displayName, appIndex) {
|
|
523
|
+
try {
|
|
524
|
+
const quickstart = await fs2.readFile(path.resolve(targetFolder, QUICKSTART), "utf8");
|
|
525
|
+
const readme = quickstartToReadme(quickstart, displayName, appIndex);
|
|
526
|
+
await fs2.writeFile(path.resolve(targetFolder, "README.md"), readme, "utf8");
|
|
527
|
+
} catch (err) {
|
|
528
|
+
if (err.code !== "ENOENT") throw err;
|
|
529
|
+
console.info(`
|
|
530
|
+
${warningMark} "${QUICKSTART}" not found > Skip README`);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
async function writeAgentEntry(targetFolder) {
|
|
534
|
+
await Promise.all(
|
|
535
|
+
Object.entries(AGENT_FILES).map(
|
|
536
|
+
([file, content]) => fs2.writeFile(path.resolve(targetFolder, file), content, "utf8")
|
|
537
|
+
)
|
|
538
|
+
);
|
|
539
|
+
try {
|
|
540
|
+
await fs2.mkdir(path.resolve(targetFolder, ".claude"), { recursive: true });
|
|
541
|
+
await fs2.symlink("../cella/skills", path.resolve(targetFolder, ".claude/skills"));
|
|
542
|
+
} catch (err) {
|
|
543
|
+
console.info(`
|
|
544
|
+
${warningMark} skipped .claude/skills: ${err instanceof Error ? err.message : String(err)}`);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
465
547
|
async function removeFolderContents(folderPath) {
|
|
466
548
|
let files;
|
|
467
549
|
try {
|
|
@@ -489,13 +571,14 @@ ${warningMark} Source file "${src}" does not exist > Skip copy`);
|
|
|
489
571
|
}
|
|
490
572
|
}
|
|
491
573
|
}
|
|
492
|
-
async function applyPlaceholderConfig(targetFolder, projectName, displayName) {
|
|
574
|
+
async function applyPlaceholderConfig(targetFolder, projectName, displayName, appIndex) {
|
|
493
575
|
const src = path.resolve(targetFolder, PLACEHOLDER_CONFIG);
|
|
494
576
|
const dest = path.resolve(targetFolder, "./shared/config/config.default.ts");
|
|
495
577
|
try {
|
|
496
578
|
let content = await fs2.readFile(src, "utf8");
|
|
497
579
|
content = content.replaceAll("__project_name__", displayName);
|
|
498
580
|
content = content.replaceAll("__project_slug__", projectName);
|
|
581
|
+
content = setDevAppIndex(content, appIndex);
|
|
499
582
|
await fs2.writeFile(dest, content, "utf8");
|
|
500
583
|
await fs2.rm(src, { force: true });
|
|
501
584
|
} catch (err) {
|
|
@@ -577,7 +660,7 @@ ${warningMark} "release-please-config.json" not found > Skip changelog path rese
|
|
|
577
660
|
// src/utils/download-template.ts
|
|
578
661
|
import fs3 from "fs";
|
|
579
662
|
import { rm } from "fs/promises";
|
|
580
|
-
import { join } from "path";
|
|
663
|
+
import { join as join2 } from "path";
|
|
581
664
|
import git2 from "isomorphic-git";
|
|
582
665
|
import http from "isomorphic-git/http/node";
|
|
583
666
|
function parseGithubRepo(template) {
|
|
@@ -592,23 +675,23 @@ async function downloadGithubTemplate(template, ref, targetFolder) {
|
|
|
592
675
|
const url = `https://github.com/${owner}/${repo}.git`;
|
|
593
676
|
await git2.clone({ fs: fs3, http, dir: targetFolder, url, ref, singleBranch: true, depth: 1 });
|
|
594
677
|
const baseSha = await git2.resolveRef({ fs: fs3, dir: targetFolder, ref: "HEAD" });
|
|
595
|
-
await rm(
|
|
678
|
+
await rm(join2(targetFolder, ".git"), { recursive: true, force: true });
|
|
596
679
|
return baseSha;
|
|
597
680
|
}
|
|
598
681
|
|
|
599
682
|
// src/utils/list-template-files.ts
|
|
600
|
-
import { readdir, readFile } from "fs/promises";
|
|
601
|
-
import { join as
|
|
683
|
+
import { readdir as readdir2, readFile as readFile2 } from "fs/promises";
|
|
684
|
+
import { join as join3 } from "path";
|
|
602
685
|
import ignore from "ignore";
|
|
603
686
|
async function listTemplateFiles(root) {
|
|
604
687
|
const ig = ignore().add([".git", "node_modules"]);
|
|
605
688
|
try {
|
|
606
|
-
ig.add(await
|
|
689
|
+
ig.add(await readFile2(join3(root, ".gitignore"), "utf8"));
|
|
607
690
|
} catch {
|
|
608
691
|
}
|
|
609
692
|
const files = [];
|
|
610
693
|
async function walk(relDir) {
|
|
611
|
-
const entries = await
|
|
694
|
+
const entries = await readdir2(relDir ? join3(root, relDir) : root, { withFileTypes: true });
|
|
612
695
|
for (const entry of entries) {
|
|
613
696
|
const rel = relDir ? `${relDir}/${entry.name}` : entry.name;
|
|
614
697
|
if (ig.ignores(entry.isDirectory() ? `${rel}/` : rel)) continue;
|
|
@@ -676,46 +759,6 @@ function createProgress(title, silent = false) {
|
|
|
676
759
|
};
|
|
677
760
|
}
|
|
678
761
|
|
|
679
|
-
// src/utils/scan-optional-modules.ts
|
|
680
|
-
import { readdir as readdir2, readFile as readFile2 } from "fs/promises";
|
|
681
|
-
import { dirname, join as join3, relative } from "path";
|
|
682
|
-
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "build", ".turbo", "coverage"]);
|
|
683
|
-
async function scanOptionalModules(targetFolder) {
|
|
684
|
-
const files = [];
|
|
685
|
-
await collectModuleFiles(targetFolder, files);
|
|
686
|
-
const modules = [];
|
|
687
|
-
for (const file of files) {
|
|
688
|
-
const src = await readFile2(file, "utf8");
|
|
689
|
-
if (!/optional:\s*true/.test(src)) continue;
|
|
690
|
-
const name = src.match(/name:\s*['"]([^'"]+)['"]/)?.[1];
|
|
691
|
-
const description = src.match(/description:\s*['"]([^'"]+)['"]/)?.[1] ?? "";
|
|
692
|
-
if (!name) continue;
|
|
693
|
-
modules.push({ name, description, folder: relative(targetFolder, dirname(file)) });
|
|
694
|
-
}
|
|
695
|
-
return modules.sort((a, b) => a.name.localeCompare(b.name));
|
|
696
|
-
}
|
|
697
|
-
function optionalModuleFolders({ name, folder }) {
|
|
698
|
-
return [
|
|
699
|
-
folder,
|
|
700
|
-
`frontend/src/routes/_public/_${name}`,
|
|
701
|
-
`frontend/src/routes/_public/${name}`,
|
|
702
|
-
`frontend/src/routes/_app/_${name}`,
|
|
703
|
-
`frontend/src/routes/_app/${name}`,
|
|
704
|
-
`frontend/public/static/${name}`
|
|
705
|
-
];
|
|
706
|
-
}
|
|
707
|
-
async function collectModuleFiles(dir, out) {
|
|
708
|
-
const entries = await readdir2(dir, { withFileTypes: true });
|
|
709
|
-
for (const entry of entries) {
|
|
710
|
-
if (entry.isDirectory()) {
|
|
711
|
-
if (SKIP_DIRS.has(entry.name)) continue;
|
|
712
|
-
await collectModuleFiles(join3(dir, entry.name), out);
|
|
713
|
-
} else if (entry.name.endsWith("-module.ts") || entry.name.endsWith("-module.tsx")) {
|
|
714
|
-
out.push(join3(dir, entry.name));
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
|
|
719
762
|
// src/create.ts
|
|
720
763
|
function isLocalPath(path2) {
|
|
721
764
|
return path2.startsWith("/") || path2.startsWith("./") || path2.startsWith("../");
|
|
@@ -726,7 +769,7 @@ async function create({
|
|
|
726
769
|
packageManager: packageManager2,
|
|
727
770
|
templateUrl,
|
|
728
771
|
templateRef,
|
|
729
|
-
|
|
772
|
+
appIndex,
|
|
730
773
|
adminEmail,
|
|
731
774
|
silent = false
|
|
732
775
|
}) {
|
|
@@ -742,7 +785,7 @@ async function create({
|
|
|
742
785
|
if (isLocalTemplate) {
|
|
743
786
|
progress.step("copying local template");
|
|
744
787
|
const sourcePath = resolve2(originalCwd, templateUrl);
|
|
745
|
-
const rel =
|
|
788
|
+
const rel = relative(sourcePath, targetFolder);
|
|
746
789
|
const targetInsideTemplate = rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
747
790
|
if (targetInsideTemplate) {
|
|
748
791
|
throw new Error(
|
|
@@ -763,10 +806,9 @@ async function create({
|
|
|
763
806
|
progress.step(`downloading cella template${templateRef ? ` (${templateRef})` : ""}`);
|
|
764
807
|
baseSha = await downloadGithubTemplate(template, ref, targetFolder);
|
|
765
808
|
}
|
|
766
|
-
if (!silent) await promptOptionalModules(targetFolder);
|
|
767
809
|
progress.step("cleaning template");
|
|
768
810
|
const displayName = projectName.replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
769
|
-
await cleanTemplate({ targetFolder, projectName, displayName,
|
|
811
|
+
await cleanTemplate({ targetFolder, projectName, displayName, appIndex, adminEmail });
|
|
770
812
|
const gitFolderPath = join4(targetFolder, ".git");
|
|
771
813
|
if (!existsSync(gitFolderPath)) {
|
|
772
814
|
try {
|
|
@@ -793,76 +835,41 @@ Cella-Base: ${baseSha}` : "Initial commit";
|
|
|
793
835
|
throw error;
|
|
794
836
|
}
|
|
795
837
|
const needsCd = originalCwd !== targetFolder;
|
|
796
|
-
const relativePath =
|
|
797
|
-
showSuccess(
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
const keep = await checkbox(
|
|
806
|
-
{
|
|
807
|
-
message: "Optional modules to include",
|
|
808
|
-
// Leading space on the radio icons adds a gap after the cursor (inquirer renders
|
|
809
|
-
// `${cursor}${checkbox} ${name}` with no space between cursor and checkbox).
|
|
810
|
-
theme: { icon: { checked: ` ${pc5.green("\u25C9")}`, unchecked: " \u25EF" } },
|
|
811
|
-
choices: modules.map((m) => ({
|
|
812
|
-
name: `${m.name} ${pc5.dim(`\xB7 ${m.description}`)}`,
|
|
813
|
-
value: m.name,
|
|
814
|
-
checked: true
|
|
815
|
-
}))
|
|
816
|
-
},
|
|
817
|
-
// Clear the answered prompt so we can print a compact, non-bold summary that lists
|
|
818
|
-
// only the kept module names (not their descriptions).
|
|
819
|
-
{ clearPromptOnDone: true }
|
|
838
|
+
const relativePath = relative(originalCwd, targetFolder);
|
|
839
|
+
showSuccess(
|
|
840
|
+
projectName,
|
|
841
|
+
targetFolder,
|
|
842
|
+
relativePath,
|
|
843
|
+
needsCd,
|
|
844
|
+
packageManager2,
|
|
845
|
+
appIndex,
|
|
846
|
+
adminEmail ?? `admin@${projectName}.example.com`
|
|
820
847
|
);
|
|
821
|
-
confirmChoice("Optional modules", keep.length ? keep.join(", ") : pc5.dim("none"));
|
|
822
|
-
resumeSpinner();
|
|
823
|
-
const folders = modules.filter((m) => !keep.includes(m.name)).flatMap(optionalModuleFolders);
|
|
824
|
-
await Promise.all(folders.map((f) => rm2(join4(targetFolder, f), { recursive: true, force: true })));
|
|
825
848
|
}
|
|
826
849
|
|
|
827
|
-
// src/utils/
|
|
828
|
-
import {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
project: name,
|
|
851
|
-
frontend,
|
|
852
|
-
backend,
|
|
853
|
-
offset: frontend - 3e3
|
|
854
|
-
});
|
|
855
|
-
} catch {
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
return used;
|
|
859
|
-
}
|
|
860
|
-
function findNextOffset(usedPorts) {
|
|
861
|
-
const usedOffsets = new Set(usedPorts.map((p) => p.offset));
|
|
862
|
-
for (let offset = 0; offset <= 490; offset += 10) {
|
|
863
|
-
if (!usedOffsets.has(offset)) return offset;
|
|
864
|
-
}
|
|
865
|
-
return 0;
|
|
850
|
+
// src/utils/busy-ports.ts
|
|
851
|
+
import { connect } from "net";
|
|
852
|
+
var SERVICE_PORTS = 7;
|
|
853
|
+
var appPorts = (appIndex) => [
|
|
854
|
+
3e3 + appIndex,
|
|
855
|
+
...Array.from({ length: SERVICE_PORTS }, (_, i) => 4e3 + appIndex * 10 + i),
|
|
856
|
+
5432 + appIndex * 10,
|
|
857
|
+
5434 + appIndex * 10
|
|
858
|
+
];
|
|
859
|
+
var isListening = (port) => new Promise((resolve4) => {
|
|
860
|
+
const socket = connect({ port, host: "127.0.0.1", timeout: 300 });
|
|
861
|
+
const finish = (listening) => {
|
|
862
|
+
socket.destroy();
|
|
863
|
+
resolve4(listening);
|
|
864
|
+
};
|
|
865
|
+
socket.once("connect", () => finish(true));
|
|
866
|
+
socket.once("timeout", () => finish(false));
|
|
867
|
+
socket.once("error", () => finish(false));
|
|
868
|
+
});
|
|
869
|
+
async function findBusyPorts(appIndex) {
|
|
870
|
+
const ports = appPorts(appIndex);
|
|
871
|
+
const listening = await Promise.all(ports.map(isListening));
|
|
872
|
+
return ports.filter((_, i) => listening[i]);
|
|
866
873
|
}
|
|
867
874
|
|
|
868
875
|
// src/utils/fetch-template-metadata.ts
|
|
@@ -925,9 +932,9 @@ async function fetchLatestCommit(branch = "main") {
|
|
|
925
932
|
}
|
|
926
933
|
|
|
927
934
|
// src/utils/is-empty-directory.ts
|
|
928
|
-
import { readdir as
|
|
935
|
+
import { readdir as readdir3 } from "fs/promises";
|
|
929
936
|
async function isEmptyDirectory(path2) {
|
|
930
|
-
const files = await
|
|
937
|
+
const files = await readdir3(path2);
|
|
931
938
|
return files.length === 0 || files.length === 1 && files[0] === ".git";
|
|
932
939
|
}
|
|
933
940
|
|
|
@@ -971,16 +978,24 @@ async function main() {
|
|
|
971
978
|
process.exit(1);
|
|
972
979
|
}
|
|
973
980
|
if (action === "remove") {
|
|
974
|
-
await
|
|
981
|
+
await rm2(targetFolder, { recursive: true, force: true });
|
|
975
982
|
}
|
|
976
983
|
}
|
|
977
|
-
const
|
|
978
|
-
confirmChoice("
|
|
984
|
+
const appIndex = cli.options.appIndex ?? await promptAppIndex(targetFolder, promptTheme, promptContext);
|
|
985
|
+
confirmChoice("App index", formatAppIndex(appIndex));
|
|
986
|
+
const busyPorts = await findBusyPorts(appIndex);
|
|
987
|
+
if (busyPorts.length > 0) {
|
|
988
|
+
console.info(
|
|
989
|
+
`${pc6.yellow("\u26A0")} In use on this machine: ${busyPorts.join(", ")}. Stop what holds them before pnpm docker and pnpm dev.`
|
|
990
|
+
);
|
|
991
|
+
console.info();
|
|
992
|
+
}
|
|
979
993
|
const adminEmail = cli.options.adminEmail ?? await input(
|
|
980
994
|
{
|
|
981
995
|
message: "Admin email for initial seed user",
|
|
982
996
|
default: "admin@example.com",
|
|
983
|
-
theme: promptTheme
|
|
997
|
+
theme: promptTheme,
|
|
998
|
+
validate: (email) => isEmail(email) ? true : "Enter an address such as admin@example.com"
|
|
984
999
|
},
|
|
985
1000
|
promptContext
|
|
986
1001
|
);
|
|
@@ -991,7 +1006,7 @@ async function main() {
|
|
|
991
1006
|
packageManager: cli.packageManager,
|
|
992
1007
|
templateUrl: cli.options.template,
|
|
993
1008
|
templateRef,
|
|
994
|
-
|
|
1009
|
+
appIndex,
|
|
995
1010
|
adminEmail
|
|
996
1011
|
};
|
|
997
1012
|
await create(createOptions);
|
|
@@ -1023,7 +1038,7 @@ async function promptTemplateRef(theme, context) {
|
|
|
1023
1038
|
}
|
|
1024
1039
|
const choice = await select(
|
|
1025
1040
|
{
|
|
1026
|
-
message: "Choose
|
|
1041
|
+
message: "Choose which cella version to start from:",
|
|
1027
1042
|
theme,
|
|
1028
1043
|
choices: [
|
|
1029
1044
|
{ name: "Latest release", value: "release" },
|
|
@@ -1039,32 +1054,35 @@ async function promptTemplateRef(theme, context) {
|
|
|
1039
1054
|
confirmChoice("Latest commit", commit.shortSha);
|
|
1040
1055
|
return "main";
|
|
1041
1056
|
}
|
|
1042
|
-
function
|
|
1043
|
-
return `${
|
|
1057
|
+
function formatAppIndex(i, suffix = "") {
|
|
1058
|
+
return `${i} \u2192 :${3e3 + i} / :${4e3 + i * 10} / :${5432 + i * 10}${suffix}`;
|
|
1044
1059
|
}
|
|
1045
|
-
async function
|
|
1060
|
+
async function promptAppIndex(targetFolder, theme, context) {
|
|
1046
1061
|
const usedPorts = await detectUsedPorts(targetFolder);
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1062
|
+
const presets = [1, 2, 3];
|
|
1063
|
+
const busy = new Map(await Promise.all([0, ...presets].map(async (i) => [i, await findBusyPorts(i)])));
|
|
1064
|
+
const isBusy = (i) => (busy.get(i)?.length ?? 0) > 0;
|
|
1065
|
+
const suggested = findNextAppIndex(usedPorts, isBusy);
|
|
1066
|
+
const label = (i, note = "") => formatAppIndex(i, isBusy(i) ? ` (port ${busy.get(i)?.[0]} in use)` : note);
|
|
1067
|
+
let message = `${pc6.bold("App index")} ${pc6.dim("\xB7 to avoid port conflicts with other apps on this machine")}`;
|
|
1049
1068
|
if (usedPorts.length > 0) {
|
|
1050
1069
|
const count = usedPorts.length;
|
|
1051
1070
|
message += pc6.dim(`
|
|
1052
|
-
Detected ${count} sibling
|
|
1071
|
+
Detected ${count} sibling app${count === 1 ? "" : "s"} \xB7 suggested index ${suggested}`);
|
|
1053
1072
|
}
|
|
1054
1073
|
const portTheme = {
|
|
1055
1074
|
...theme,
|
|
1056
1075
|
style: { ...theme.style ?? {}, message: (text) => text }
|
|
1057
1076
|
};
|
|
1058
|
-
const presets = [10, 20, 30].filter((o) => o !== suggested);
|
|
1059
1077
|
const choice = await select(
|
|
1060
1078
|
{
|
|
1061
1079
|
message,
|
|
1062
1080
|
theme: portTheme,
|
|
1063
1081
|
choices: [
|
|
1064
|
-
...suggested > 0 ? [{ name:
|
|
1065
|
-
{ name:
|
|
1066
|
-
...presets.map((
|
|
1067
|
-
{ name: "Custom
|
|
1082
|
+
...suggested > 0 ? [{ name: formatAppIndex(suggested, " (suggested)"), value: suggested }] : [],
|
|
1083
|
+
{ name: label(0, " (default)"), value: 0 },
|
|
1084
|
+
...presets.filter((i) => i !== suggested).map((i) => ({ name: label(i), value: i })),
|
|
1085
|
+
{ name: "Custom index", value: -1 }
|
|
1068
1086
|
]
|
|
1069
1087
|
},
|
|
1070
1088
|
context
|
|
@@ -1072,15 +1090,10 @@ Detected ${count} sibling fork${count === 1 ? "" : "s"} \xB7 suggested offset ${
|
|
|
1072
1090
|
if (choice !== -1) return choice;
|
|
1073
1091
|
const custom = await input(
|
|
1074
1092
|
{
|
|
1075
|
-
message: "Enter custom
|
|
1093
|
+
message: "Enter custom index (0-9, not 4)",
|
|
1076
1094
|
default: String(suggested),
|
|
1077
1095
|
theme,
|
|
1078
|
-
validate: (val) =>
|
|
1079
|
-
const n = Number(val);
|
|
1080
|
-
if (Number.isNaN(n) || n < 0 || n > 490) return "Must be between 0 and 490";
|
|
1081
|
-
if (n % 10 !== 0) return "Must be a multiple of 10";
|
|
1082
|
-
return true;
|
|
1083
|
-
}
|
|
1096
|
+
validate: (val) => isAppIndex(Number(val)) ? true : "Must be a whole number from 0 to 9, not 4"
|
|
1084
1097
|
},
|
|
1085
1098
|
context
|
|
1086
1099
|
);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-cella-cli.ts","../src/constants.ts","../package.json","../src/create.ts","../src/utils/git/command.ts","../src/add-remote.ts","../src/modules/cli/commands.ts","../src/utils/validate-project-name.ts","../src/modules/cli/display.ts","../src/utils/clean-template.ts","../src/utils/download-template.ts","../src/utils/list-template-files.ts","../src/utils/progress.ts","../src/utils/scan-optional-modules.ts","../src/utils/detect-used-ports.ts","../src/utils/fetch-template-metadata.ts","../src/utils/is-empty-directory.ts"],"sourcesContent":["#!/usr/bin/env tsx\n\nimport { existsSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { basename, resolve } from 'node:path';\nimport { input, select } from '@inquirer/prompts';\nimport pc from 'picocolors';\nimport { TEMPLATE_URL } from '#/constants';\nimport { create } from '#/create';\nimport { type CreateOptions, cli, confirmChoice, showWelcome } from '#/modules/cli';\nimport { detectUsedPorts, findNextOffset } from '#/utils/detect-used-ports';\nimport { fetchLatestCommit, fetchLatestRelease } from '#/utils/fetch-template-metadata';\nimport { isEmptyDirectory } from '#/utils/is-empty-directory';\nimport { validateProjectName } from '#/utils/validate-project-name';\n\nasync function main(): Promise<void> {\n // Display CLI welcome banner\n showWelcome();\n\n // Shared theme to clear prompts after answering\n const promptTheme = { prefix: '', style: { answer: (text: string) => text } };\n const promptContext = { clearPromptOnDone: true };\n\n // Choose which template snapshot to scaffold from: a stable release or the\n // latest commit. Skipped when a custom --template is provided (ref doesn't apply).\n const templateRef = cli.options.template ? undefined : await promptTemplateRef(promptTheme, promptContext);\n\n // Prompt for project name if not provided\n if (!cli.directory) {\n cli.directory = await input(\n {\n message: 'Enter your project name',\n default: 'my-cella-app',\n theme: promptTheme,\n validate: (name) => {\n const validation = validateProjectName(basename(resolve(name)));\n return validation.valid ? true : `Invalid project name: ${validation.problems?.[0] ?? 'unknown error'}`;\n },\n },\n promptContext,\n );\n }\n\n const targetFolder = resolve(cli.directory);\n const projectName = basename(targetFolder)?.toLowerCase() || 'project';\n\n // Check if the target folder exists and is not empty\n if (existsSync(targetFolder) && !(await isEmptyDirectory(targetFolder))) {\n const dirName = cli.directory === '.' ? 'Current directory' : `Target directory \"${targetFolder}\"`;\n const message = `${dirName} is not empty. Please choose how you would like to proceed:`;\n\n const action = await select(\n {\n message,\n theme: promptTheme,\n choices: [\n { name: 'Cancel and exit', value: 'cancel' },\n { name: 'Remove existing files and continue', value: 'remove' },\n ],\n },\n promptContext,\n );\n\n if (action === 'cancel') {\n process.exit(1);\n }\n\n // Wipe the folder so the template clone starts from a clean slate. Leaving stale\n // files behind makes the git checkout fail with conflicts on overlapping paths.\n if (action === 'remove') {\n await rm(targetFolder, { recursive: true, force: true });\n }\n }\n\n // Scan sibling directories and prompt for port offset\n const portOffset = cli.options.portOffset ?? (await promptPortOffset(targetFolder, promptTheme, promptContext));\n confirmChoice('Port offset', formatOffset(portOffset));\n\n // Prompt for admin email. Default uses the reserved `example.com` domain (RFC 2606) so the\n // seed address can never resolve or route real mail — it's a placeholder, not a real inbox.\n const adminEmail =\n cli.options.adminEmail ??\n (await input(\n {\n message: 'Admin email for initial seed user',\n default: 'admin@example.com',\n theme: promptTheme,\n },\n promptContext,\n ));\n confirmChoice('Admin email', adminEmail);\n\n // Proceed with the project creation\n const createOptions: CreateOptions = {\n projectName,\n targetFolder,\n packageManager: cli.packageManager,\n templateUrl: cli.options.template,\n templateRef,\n portOffset,\n adminEmail,\n };\n\n await create(createOptions);\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exit(1);\n});\n\n/**\n * Show a short intro with the two starting points (latest release and latest\n * commit, each with its date) and let the user choose which template snapshot to\n * scaffold from. Returns the template ref to check out (release tag or `main`), or\n * undefined to use the default branch (when metadata is unavailable).\n */\nasync function promptTemplateRef(theme: object, context: object): Promise<string | undefined> {\n const [release, commit] = await Promise.all([fetchLatestRelease(), fetchLatestCommit()]);\n\n // One-sentence intro followed by the data points that are known.\n console.info(pc.dim('This create CLI allows you to get started with cella quickly.'));\n console.info();\n\n if (release)\n console.info(` Latest release: ${release.tag}${release.date ? ` ${pc.dim(`· ${release.date}`)}` : ''}`);\n if (commit) {\n console.info(` Latest commit: ${commit.shortSha} ${pc.dim(`· ${commit.message} · ${commit.date}`)}`);\n // Clickable link to the exact commit on GitHub, in grey below the summary line.\n const repo = TEMPLATE_URL.replace('github:', '');\n console.info(` ${pc.gray(`https://github.com/${repo}/commit/${commit.sha}`)}`);\n }\n if (release || commit) console.info();\n\n // No release known (offline, or the template's tags did not answer): the app starts from the\n // default branch, and the output says so.\n if (!release) {\n console.info(`${pc.yellow('⚠')} Latest release not found · using the latest commit on main`);\n console.info();\n return commit ? 'main' : undefined;\n }\n\n // No commit to offer, or no TTY to render the select on (CI, piped stdin): take the latest\n // release, the stable and reproducible starting point.\n if (!commit || !process.stdin.isTTY) {\n confirmChoice('Latest release', release.tag);\n return release.tag;\n }\n\n const choice = await select(\n {\n message: 'Choose where to fork cella from:',\n theme,\n choices: [\n { name: 'Latest release', value: 'release' },\n { name: 'Latest commit', value: 'commit' },\n ],\n },\n context,\n );\n\n // The prompt clears itself on done, so keep the choice visible with a checkmark.\n if (choice === 'release') {\n confirmChoice('Latest release', release.tag);\n return release.tag;\n }\n // \"Latest commit\" is the tip of main; check out the branch (shallow clones can't\n // reliably fetch an arbitrary SHA over GitHub's smart-HTTP protocol).\n confirmChoice('Latest commit', commit.shortSha);\n return 'main';\n}\n\n/** Format an offset as a port overview string, e.g. \"10 → :3010 / :4010 / :5442\" */\nfunction formatOffset(o: number, suffix = ''): string {\n return `${o} → :${3000 + o} / :${4000 + o} / :${5432 + o}${suffix}`;\n}\n\n/** Scan sibling forks and prompt the user to pick a port offset */\nasync function promptPortOffset(targetFolder: string, theme: object, context: object): Promise<number> {\n const usedPorts = await detectUsedPorts(targetFolder);\n const suggested = findNextOffset(usedPorts);\n\n // Fold a compact hint into the prompt message itself so it's wiped by clearPromptOnDone\n // once an offset is chosen — no leftover \"Detected forks\" trail. Override the default\n // message style (which bolds everything) so only the \"Port offset\" title is bold.\n let message = `${pc.bold('Port offset')} ${pc.dim('· to avoid conflicts with other forks/clones')}`;\n if (usedPorts.length > 0) {\n const count = usedPorts.length;\n message += pc.dim(`\\nDetected ${count} sibling fork${count === 1 ? '' : 's'} · suggested offset ${suggested}`);\n }\n const portTheme = {\n ...(theme as Record<string, unknown>),\n style: { ...((theme as { style?: object }).style ?? {}), message: (text: string) => text },\n };\n\n // Presets exclude 0 (always offered as the explicit default below) and the suggested\n // value (offered first) to avoid duplicate choices.\n const presets = [10, 20, 30].filter((o) => o !== suggested);\n const choice = await select(\n {\n message,\n theme: portTheme,\n choices: [\n ...(suggested > 0 ? [{ name: formatOffset(suggested, ' (suggested)'), value: suggested }] : []),\n { name: formatOffset(0, ' (default)'), value: 0 },\n ...presets.map((o) => ({ name: formatOffset(o), value: o })),\n { name: 'Custom offset', value: -1 },\n ],\n },\n context,\n );\n\n if (choice !== -1) return choice;\n\n const custom = await input(\n {\n message: 'Enter custom offset (0-490, multiples of 10)',\n default: String(suggested),\n theme,\n validate: (val) => {\n const n = Number(val);\n if (Number.isNaN(n) || n < 0 || n > 490) return 'Must be between 0 and 490';\n if (n % 10 !== 0) return 'Must be a multiple of 10';\n return true;\n },\n },\n context,\n );\n return Number(custom);\n}\n","import pc from 'picocolors';\nimport packageJson from '../package.json' with { type: 'json' };\n\n/** Name of this CLI tool */\nexport const NAME = 'create cella';\n\n/** Thin line divider for console output (60 chars wide) */\nexport const DIVIDER = '─'.repeat(60);\n\n/** URL of the template repository */\nexport const TEMPLATE_URL = 'github:cellajs/cella';\n\n/** Canonical owner/repo for template metadata fetched from the GitHub API. */\nexport const TEMPLATE_REPOSITORY = 'cellajs/cella';\n\n/** HTTPS git URL of the template, for reading its release tags without the GitHub API. */\nexport const TEMPLATE_GIT_URL = `https://github.com/${TEMPLATE_REPOSITORY}.git`;\n\n/** The app's sync config, which the template ships with its own settings. */\nexport const SYNC_CONFIG = 'cella/cella.config.ts';\n\n/** URL to the repository */\nexport const CELLA_REMOTE_URL = 'git@github.com:cellajs/cella.git';\n\n/**\n * Git remote name pointing at upstream cella. Matches the name the sync CLI\n * (`pnpm cella`) expects, so scaffolds don't end up with a duplicate remote.\n */\nexport const CELLA_REMOTE_NAME = 'cella-upstream';\n\n/** Export details from package.json */\nexport const DESCRIPTION: string = packageJson.description;\nexport const VERSION: string = packageJson.version;\nexport const WEBSITE: string = packageJson.homepage;\n\nexport function getHeaderLine(): string {\n const leftText = `⧈ ${NAME} · ${VERSION}`;\n const left = `${pc.cyan(`⧈ ${NAME}`)} ${pc.dim(`· ${VERSION}`)}`;\n const right = pc.cyan(WEBSITE);\n const padding = Math.max(1, 60 - leftText.length - WEBSITE.length);\n return `${left}${' '.repeat(padding)}${right}`;\n}\n\n// Files or folders to be removed from the template after downloading.\n// The Pulumi stack files carry cella's own bootstrap markers and encryption\n// salt; a fresh app bootstraps its own. Removing them also keeps the deploy\n// workflow's staging gate false until the app bootstraps, so a fresh scaffold\n// never auto-deploys staging on its first push to main.\nexport const TO_REMOVE: string[] = ['./infra/Pulumi.production.yaml', './infra/Pulumi.staging.yaml'];\n\n// Specific folder contents to be cleaned out from the template\nexport const TO_CLEAN: string[] = ['./backend/drizzle'];\n\n// Files to copy/paste after downloading\nexport const TO_COPY: Record<string, string> = {\n './frontend/.env.example': './frontend/.env',\n './cella/QUICKSTART.md': 'README.md',\n};\n\n/**\n * Fork config template that replaces `shared/config/config.default.ts` in new forks.\n */\nexport const PLACEHOLDER_CONFIG = 'shared/config/config.template.ts';\n\n/**\n * Starting version for a fresh fork. Resets the upstream cella version so\n * release-please cuts the fork's first release from a clean slate.\n */\nexport const INITIAL_VERSION = '0.0.0';\n\n/**\n * Read a `.env.example` file and apply key=value replacements.\n * Comments and unmatched keys are preserved as-is.\n * Returns null if the file doesn't exist (caller should generate from scratch).\n */\nexport async function generateEnvFromExample(\n examplePath: string,\n replacements: Record<string, string>,\n): Promise<string | null> {\n const { readFile } = await import('node:fs/promises');\n let content: string;\n try {\n content = await readFile(examplePath, 'utf8');\n } catch {\n return null;\n }\n\n return content.replace(/^([A-Z_][A-Z0-9_]*)=(.*)$/gm, (match, key, _value) => {\n if (key in replacements) return `${key}=${replacements[key]}`;\n return match;\n });\n}\n\n/**\n * Replacement map for `backend/.env`.\n * The backend `.env` is the single source of truth for the project slug, database\n * ports (consumed by `backend/compose.yaml`), connection URLs and admin email.\n * Service ports deliberately do NOT live here: they come from `devPorts` in\n * `config.development.ts`, and a stale `PORT=` env line would silently override\n * the fork's offset (the pre-devPorts collision failure mode).\n */\nexport function getBackendEnvReplacements(\n slug: string,\n adminEmail: string,\n portOffset: number,\n): Record<string, string> {\n const db = 5432 + portOffset;\n return {\n PROJECT_SLUG: slug,\n DB_PORT: String(db),\n DB_TEST_PORT: String(5434 + portOffset),\n DATABASE_URL: `postgres://runtime_role:dev_password@0.0.0.0:${db}/postgres`,\n DATABASE_ADMIN_URL: `postgres://postgres:postgres@0.0.0.0:${db}/postgres`,\n DATABASE_CDC_URL: `postgres://admin_role:dev_password@0.0.0.0:${db}/postgres`,\n ADMIN_EMAIL: adminEmail,\n };\n}\n\n/**\n * Generate env config files with project-specific values.\n * All configs go through the same data-driven loop.\n * Values prefixed with '=' are emitted as raw TS expressions (not quoted).\n */\nexport function generateEnvConfigs(slug: string, name: string, portOffset: number): Record<string, string> {\n const fe = 3000 + portOffset;\n const api = 4000 + portOffset;\n // Every devPorts key, offset as one block: a key left out keeps its default port and\n // collides with another local stack (the config merge keeps unlisted keys).\n const devPorts = {\n frontend: fe,\n api,\n cdcHealth: api + 1,\n yjs: api + 2,\n mcp: api + 3,\n oauth: api + 4,\n internal: api + 5,\n jobs: api + 6,\n };\n const devPortsExpression = Object.entries(devPorts)\n .map(([key, port]) => `${key}: ${port}`)\n .join(', ');\n\n const header =\n \"import type { DeepPartial } from '../src/config-builder/types.ts';\\nimport type { config as _default } from './config.default.ts';\\n\";\n\n // Per-environment specs: optional imports + object props (= prefix → raw TS expression).\n // URL shapes are same-origin (the Vite dev server / public origin proxies /api, /yjs,\n // /mcp and /oauth), mirroring cella's own config.<mode>.ts files. Service listen ports come\n // from `devPorts`, offset per fork so parallel local stacks never collide on :4000.\n const envs: Record<string, { imports?: string; props: Record<string, string | boolean> }> = {\n development: {\n props: {\n slug: `${slug}-development`,\n domain: '',\n frontendUrl: `http://localhost:${fe}`,\n backendUrl: `http://localhost:${fe}/api`,\n backendAuthUrl: `http://localhost:${fe}/api/auth`,\n yjsUrl: `ws://localhost:${fe}/yjs`,\n mcpUrl: `http://localhost:${fe}/mcp`,\n oauthUrl: `http://localhost:${fe}/oauth`,\n devPorts: `={ ${devPortsExpression} }`,\n // The template's shared development buckets hold the seed files and the GeoIP databases,\n // so seeded attachments render before the app has storage of its own.\n s3: \"={ region: 'nl-ams', host: 's3.nl-ams.scw.cloud', publicBucket: 'cella-shared-public', privateBucket: 'cella-shared-private' }\",\n },\n },\n staging: {\n props: {\n slug: `${slug}-staging`,\n domain: `${slug}.example.com`,\n frontendUrl: `https://staging.${slug}.example.com`,\n backendUrl: `https://staging.${slug}.example.com/api`,\n backendAuthUrl: `https://staging.${slug}.example.com/api/auth`,\n yjsUrl: `wss://staging.${slug}.example.com/yjs`,\n mcpUrl: `https://staging.${slug}.example.com/mcp`,\n oauthUrl: `https://staging.${slug}.example.com/oauth`,\n },\n },\n tunnel: {\n props: {\n slug: `${slug}-tunnel`,\n frontendUrl: `https://${slug}.ngrok.dev`,\n backendUrl: `https://${slug}.ngrok.dev/api`,\n backendAuthUrl: `https://${slug}.ngrok.dev/api/auth`,\n yjsUrl: `wss://${slug}.ngrok.dev/yjs`,\n mcpUrl: `https://${slug}.ngrok.dev/mcp`,\n oauthUrl: `https://${slug}.ngrok.dev/oauth`,\n },\n },\n test: {\n imports: \"import { development } from './config.development.ts';\\n\",\n props: {\n domain: '',\n frontendUrl: '=development.frontendUrl',\n backendUrl: '=development.backendUrl',\n backendAuthUrl: '=development.backendAuthUrl',\n yjsUrl: '=development.yjsUrl',\n mcpUrl: '=development.mcpUrl',\n oauthUrl: '=development.oauthUrl',\n },\n },\n production: { props: { maintenance: false } },\n };\n\n // Serialize value: '=' prefix → raw TS expression, boolean → literal, string → quoted\n const lit = (v: string | boolean) => {\n if (typeof v === 'boolean') return String(v);\n if (v.startsWith('=')) return v.slice(1);\n return `'${v}'`;\n };\n\n const result: Record<string, string> = {};\n\n for (const [mode, { imports = '', props }] of Object.entries(envs)) {\n const nameEntry = mode !== 'production' ? ` name: '${name} ${mode.toUpperCase()}',\\n` : '';\n const body = Object.entries(props)\n .map(([k, v]) => ` ${k}: ${lit(v)},`)\n .join('\\n');\n result[`./shared/config/config.${mode}.ts`] =\n `${header}${imports}\\nexport const ${mode} = {\\n mode: '${mode}',\\n${nameEntry}${body}\\n} satisfies DeepPartial<typeof _default>;\\n`;\n }\n\n return result;\n}\n","{\n \"name\": \"@cellajs/create-cella\",\n \"version\": \"0.3.11\",\n \"private\": false,\n \"license\": \"MIT\",\n \"description\": \"Cella is a TypeScript template to create web apps with sync and offline capabilities.\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/cellajs/create-cella\"\n },\n \"homepage\": \"https://cellajs.com\",\n \"author\": \"CellaJS <info@cellajs.com>\",\n \"engines\": {\n \"node\": \"26.x\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.js\",\n \"files\": [\n \"dist\",\n \"index.js\",\n \"README.md\"\n ],\n \"imports\": {\n \"#/*\": \"./src/*\"\n },\n \"bin\": {\n \"create-cella\": \"index.js\"\n },\n \"scripts\": {\n \"start\": \"tsx ./src/create-cella-cli.ts\",\n \"try\": \"tsx ./src/create-cella-cli.ts ../cella-try-app\",\n \"clean\": \"rimraf ./dist\",\n \"build\": \"tsup\",\n \"test-build\": \"pnpm run build && node index.js\",\n \"prepublishOnly\": \"pnpm run test:release\",\n \"check\": \"pnpm ts && pnpm biome check --write .\",\n \"ts\": \"tsgo --pretty\",\n \"lint\": \"biome check .\",\n \"lint:fix\": \"biome check --write .\",\n \"test\": \"vitest run\",\n \"test:release\": \"pnpm run build && vitest run --config vitest.release.config.ts\",\n \"test:watch\": \"vitest\",\n \"prepare\": \"lefthook install\"\n },\n \"dependencies\": {\n \"@inquirer/prompts\": \"^8.7.2\",\n \"commander\": \"^15.0.0\",\n \"ignore\": \"^7.0.11\",\n \"isomorphic-git\": \"^1.42.5\",\n \"ora\": \"^9.4.1\",\n \"picocolors\": \"^1.1.1\",\n \"validate-npm-package-name\": \"^8.0.0\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^2.5.15\",\n \"@commitlint/cli\": \"^21.2.3\",\n \"@commitlint/config-conventional\": \"^21.2.3\",\n \"@evilmartians/lefthook\": \"^2.1.15\",\n \"@types/node\": \"26.6.3\",\n \"@types/validate-npm-package-name\": \"^4.0.2\",\n \"@typescript/native-preview\": \"7.0.0-dev.20260707.2\",\n \"rimraf\": \"^6.1.3\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.23.15\",\n \"typescript\": \"6.0.3\",\n \"vitest\": \"^5.0.3\"\n },\n \"packageManager\": \"pnpm@11.8.0\",\n \"commitlint\": {\n \"extends\": [\n \"@commitlint/config-conventional\"\n ],\n \"rules\": {\n \"type-enum\": [\n 2,\n \"always\",\n [\n \"feat\",\n \"fix\",\n \"perf\",\n \"refactor\",\n \"revert\",\n \"docs\",\n \"chore\",\n \"build\",\n \"ci\",\n \"style\",\n \"test\"\n ]\n ]\n }\n }\n}\n","import { existsSync } from 'node:fs';\nimport { cp, mkdir, rm } from 'node:fs/promises';\nimport { dirname, isAbsolute, join, relative, resolve } from 'node:path';\nimport { checkbox } from '@inquirer/prompts';\nimport pc from 'picocolors';\nimport { addRemote } from '#/add-remote';\nimport { TEMPLATE_URL } from '#/constants';\nimport { type CreateOptions, confirmChoice, showSuccess } from '#/modules/cli';\nimport { cleanTemplate } from '#/utils/clean-template';\nimport { downloadGithubTemplate } from '#/utils/download-template';\nimport { gitAddAll, gitCommit, gitInit } from '#/utils/git';\nimport { listTemplateFiles } from '#/utils/list-template-files';\nimport { createProgress, pauseSpinner, resumeSpinner } from '#/utils/progress';\nimport { optionalModuleFolders, scanOptionalModules } from '#/utils/scan-optional-modules';\n\n/** Check if a path is a local directory */\nfunction isLocalPath(path: string): boolean {\n return path.startsWith('/') || path.startsWith('./') || path.startsWith('../');\n}\n\nexport async function create({\n projectName,\n targetFolder,\n packageManager,\n templateUrl,\n templateRef,\n portOffset,\n adminEmail,\n silent = false,\n}: CreateOptions): Promise<void> {\n // Save the original working directory\n const originalCwd = process.cwd();\n\n // Use custom template or default\n const template = templateUrl || TEMPLATE_URL;\n const isLocalTemplate = templateUrl && isLocalPath(templateUrl);\n\n const progress = createProgress('creating project', silent);\n\n try {\n // Create the target folder\n progress.step('creating project folder');\n await mkdir(targetFolder, { recursive: true });\n process.chdir(targetFolder);\n\n // Upstream commit the scaffold is based on (only known for remote templates). Stamped\n // as a trailer on the initial commit so the sync CLI can bootstrap the first merge-base.\n let baseSha: string | null = null;\n\n // Download or copy the template\n if (isLocalTemplate) {\n progress.step('copying local template');\n const sourcePath = resolve(originalCwd, templateUrl);\n\n // Check if target is inside source (would cause EINVAL). Use a path-boundary check\n // (not a string prefix) so siblings like `cella-try-app` next to `cella` aren't\n // misdetected as being inside the template.\n const rel = relative(sourcePath, targetFolder);\n const targetInsideTemplate = rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));\n if (targetInsideTemplate) {\n throw new Error(\n 'Cannot create project inside the template directory.\\n' +\n ` Run from outside: cd ~ && pnpm create @cellajs/cella ${projectName} --template ${templateUrl}`,\n );\n }\n\n // Copy only what git would track (respects .gitignore: no build output, no local .env secrets).\n const tracked = await listTemplateFiles(sourcePath);\n for (const rel of tracked) {\n const src = join(sourcePath, rel);\n if (!existsSync(src)) continue; // listed but deleted in the working tree\n const dest = join(targetFolder, rel);\n await mkdir(dirname(dest), { recursive: true });\n await cp(src, dest);\n }\n } else {\n // Pin to the chosen ref (release tag or commit SHA), else the default branch.\n const ref = templateRef ?? 'main';\n progress.step(`downloading cella template${templateRef ? ` (${templateRef})` : ''}`);\n baseSha = await downloadGithubTemplate(template, ref, targetFolder);\n }\n\n // Ask which optional modules to keep, then drop deselected paths\n if (!silent) await promptOptionalModules(targetFolder);\n\n // Clean the template, generate configs\n progress.step('cleaning template');\n const displayName = projectName.replace(/[-_]/g, ' ').replace(/\\b\\w/g, (c) => c.toUpperCase());\n await cleanTemplate({ targetFolder, projectName, displayName, portOffset, adminEmail });\n\n // Initialize git repository. Git runs offline via isomorphic-git with an explicit\n // author, so it can't fail on missing user config — but if it fails for any other\n // reason (permissions, disk) the project files are already written and usable, so\n // warn and continue rather than aborting the whole scaffold.\n const gitFolderPath = join(targetFolder, '.git');\n if (!existsSync(gitFolderPath)) {\n try {\n progress.step('initializing git');\n await gitInit(targetFolder);\n await gitAddAll(targetFolder);\n // The `Cella-Base:` trailer records the upstream commit this scaffold snapshot was\n // taken from. The sync CLI reads it from the root commit to bootstrap the first\n // merge-base — the fork's fresh history otherwise shares no ancestor with upstream.\n const message = baseSha ? `Initial commit\\n\\nCella-Base: ${baseSha}` : 'Initial commit';\n await gitCommit(targetFolder, message);\n } catch (error) {\n if (!silent) {\n pauseSpinner();\n console.warn(`${pc.yellow('⚠')} skipped git init: ${error instanceof Error ? error.message : String(error)}`);\n resumeSpinner();\n }\n }\n }\n\n // Add upstream remote (best-effort: addRemote swallows its own failures via `silent`).\n progress.step('adding upstream remote');\n await addRemote({ targetFolder, silent: true });\n\n // Done\n progress.done(pc.bold(`created ${projectName}`));\n } catch (error) {\n progress.fail(error instanceof Error ? error.message : String(error));\n // Rethrow so callers (CLI entry, tests) see the real failure. The CLI entry\n // turns this into a non-zero exit; swallowing it here with process.exit hid\n // the underlying error from CI and vitest.\n throw error;\n }\n\n // Check if the working directory needs to be changed\n const needsCd = originalCwd !== targetFolder;\n const relativePath = relative(originalCwd, targetFolder);\n\n // Display final success message\n showSuccess(projectName, targetFolder, relativePath, needsCd, packageManager);\n}\n\n/**\n * Scan the downloaded template for optional modules and let the user deselect them.\n * Deselected modules have their whole folder removed before cleaning. Default keeps\n * everything (parity with previous behavior).\n */\nasync function promptOptionalModules(targetFolder: string): Promise<void> {\n const modules = await scanOptionalModules(targetFolder);\n if (modules.length === 0) return;\n\n // Non-interactive (CI, piped stdin, no TTY): can't render a checkbox — keep every module\n // rather than crashing with \"User force closed the prompt\". Matches the default-keep behavior.\n if (!process.stdin.isTTY) return;\n\n pauseSpinner();\n // Blank line to separate the preceding progress step from this prompt.\n console.info();\n const keep = await checkbox(\n {\n message: 'Optional modules to include',\n // Leading space on the radio icons adds a gap after the cursor (inquirer renders\n // `${cursor}${checkbox} ${name}` with no space between cursor and checkbox).\n theme: { icon: { checked: ` ${pc.green('◉')}`, unchecked: ' ◯' } },\n choices: modules.map((m) => ({\n name: `${m.name} ${pc.dim(`· ${m.description}`)}`,\n value: m.name,\n checked: true,\n })),\n },\n // Clear the answered prompt so we can print a compact, non-bold summary that lists\n // only the kept module names (not their descriptions).\n { clearPromptOnDone: true },\n );\n\n // Keep the choice visible after the prompt clears: plain label plus the selected\n // module names only (not their descriptions), or \"none\" when everything was deselected.\n confirmChoice('Optional modules', keep.length ? keep.join(', ') : pc.dim('none'));\n resumeSpinner();\n\n // Remove every folder owned by a deselected module. `optionalModuleFolders` lists more\n // route variants than any single module uses; `force: true` ignores the ones absent here.\n const folders = modules.filter((m) => !keep.includes(m.name)).flatMap(optionalModuleFolders);\n await Promise.all(folders.map((f) => rm(join(targetFolder, f), { recursive: true, force: true })));\n}\n","import fs from 'node:fs';\nimport git from 'isomorphic-git';\n\n/**\n * Git helpers backed by isomorphic-git (pure JS) instead of shelling out to the\n * `git` binary. This keeps `create-cella` free of `child_process` (no shell access)\n * and removes any dependency on the user's global git config — the initial commit\n * uses an explicit author, so scaffolding never fails with \"Author identity unknown\".\n */\n\n/** Author used for the scaffold's initial commit (users re-author their own commits later). */\nconst INITIAL_AUTHOR = { name: 'cella', email: 'info@cellajs.com' } as const;\n\n/**\n * Initializes a new Git repository in the specified directory.\n */\nexport async function gitInit(repoPath: string): Promise<void> {\n await git.init({ fs, dir: repoPath, defaultBranch: 'main' });\n}\n\n/**\n * Stages all files in the repository (respects `.gitignore`).\n */\nexport async function gitAddAll(repoPath: string): Promise<void> {\n await git.add({ fs, dir: repoPath, filepath: '.' });\n}\n\n/**\n * Creates a commit with the specified message and returns the commit SHA.\n */\nexport async function gitCommit(repoPath: string, message: string): Promise<string> {\n return git.commit({ fs, dir: repoPath, message, author: INITIAL_AUTHOR });\n}\n\n/**\n * Gets the URL of a remote. Throws when the remote does not exist (mirrors\n * `git remote get-url` failing) so callers can detect a missing remote.\n */\nexport async function gitRemoteGetUrl(repoPath: string, remoteName: string): Promise<string> {\n const remotes = await git.listRemotes({ fs, dir: repoPath });\n const match = remotes.find((r) => r.remote === remoteName);\n if (!match) throw new Error(`No such remote '${remoteName}'`);\n return match.url;\n}\n\n/**\n * Adds a new remote.\n */\nexport async function gitRemoteAdd(repoPath: string, remoteName: string, remoteUrl: string): Promise<void> {\n await git.addRemote({ fs, dir: repoPath, remote: remoteName, url: remoteUrl });\n}\n\n/**\n * Removes a remote.\n */\nexport async function gitRemoteRemove(repoPath: string, remoteName: string): Promise<void> {\n await git.deleteRemote({ fs, dir: repoPath, remote: remoteName });\n}\n","import { CELLA_REMOTE_NAME, CELLA_REMOTE_URL } from '#/constants';\nimport type { AddRemoteOptions } from '#/modules/cli';\nimport { gitRemoteAdd, gitRemoteGetUrl, gitRemoteRemove } from '#/utils/git';\n\n/**\n * Adds or updates the upstream remote for the Cella template.\n * @param options - Configuration options\n * @param options.silent - If true, don't throw on failure (used when called from progress tracker)\n */\nexport async function addRemote({\n targetFolder,\n remoteUrl = CELLA_REMOTE_URL,\n remoteName = CELLA_REMOTE_NAME,\n silent = false,\n}: AddRemoteOptions): Promise<void> {\n try {\n // Check if the remote exists\n let remote: string | null = null;\n\n try {\n remote = await gitRemoteGetUrl(targetFolder, remoteName);\n } catch {\n // If the remote doesn't exist, it throws a fatal error\n remote = null;\n }\n\n // Add or update the remote if it doesn't exist or differs from `remoteUrl`\n if (!remote) {\n await gitRemoteAdd(targetFolder, remoteName, remoteUrl);\n } else if (remote !== remoteUrl) {\n // Remove existing remote and set the new URL\n await gitRemoteRemove(targetFolder, remoteName);\n await gitRemoteAdd(targetFolder, remoteName, remoteUrl);\n }\n } catch (error) {\n if (!silent) {\n throw error;\n }\n }\n}\n","import { basename, resolve } from 'node:path';\nimport { Command, InvalidArgumentError } from 'commander';\nimport { NAME, VERSION } from '#/constants';\nimport { validateProjectName } from '#/utils/validate-project-name';\nimport type { CLIConfig, CLIOptions } from './types';\n\nfunction parsePortOffset(value: string): number {\n const parsed = Number(value);\n\n if (!Number.isInteger(parsed) || parsed < 0 || parsed > 490) {\n throw new InvalidArgumentError('Port offset must be an integer between 0 and 490');\n }\n\n if (parsed % 10 !== 0) {\n throw new InvalidArgumentError('Port offset must be a multiple of 10');\n }\n\n return parsed;\n}\n\n// Initialize CLI variables\nlet directory: string | null = null;\nconst packageManager = 'pnpm';\n\n/**\n * Defines the root CLI command using Commander.\n * This command accepts CLI options and validates user input.\n */\nexport const command = new Command(NAME)\n .version(VERSION, '-v, --version', `output the current version of ${NAME}`)\n .argument('[directory]', 'the directory name for the new project')\n .usage('[directory] [options]')\n .helpOption('-h, --help', 'display this help message')\n .option('--template <path>', 'use a custom template (local path or github:user/repo)')\n .option('--port-offset <number>', 'set the port offset (0-490 in steps of 10)', parsePortOffset)\n .option('--admin-email <email>', 'set the admin email for the initial seed user')\n .action((name: string) => {\n const trimmedName = typeof name === 'string' ? name.trim() : name;\n\n if (trimmedName) {\n const validation = validateProjectName(basename(resolve(trimmedName)));\n\n if (!validation.valid) {\n throw new InvalidArgumentError(`Invalid project name: ${validation.problems?.[0] ?? 'unknown error'}`);\n }\n\n directory = trimmedName;\n }\n })\n .parse();\n\n// Gather the CLI options and arguments\nconst options: CLIOptions = command.opts<CLIOptions>();\n\n/**\n * Runs the CLI and returns the parsed configuration.\n * This function parses command line arguments and returns the CLI config.\n */\nexport function runCli(): CLIConfig {\n return {\n options,\n args: command.args,\n directory,\n packageManager,\n };\n}\n\n// Export CLI configuration for direct import\nexport const cli: CLIConfig = runCli();\n","import validate from 'validate-npm-package-name';\n\ninterface ValidationResult {\n valid: boolean;\n problems?: string[];\n}\n\nexport function validateProjectName(name: string): ValidationResult {\n const nameValidation = validate(name);\n\n if (nameValidation.validForNewPackages) {\n return { valid: true };\n }\n\n return {\n valid: false,\n problems: [...(nameValidation.errors || []), ...(nameValidation.warnings || [])],\n };\n}\n","import pc from 'picocolors';\nimport { DESCRIPTION, DIVIDER, getHeaderLine } from '#/constants';\n\n/** ASCII art logo for the CLI welcome screen. */\nfunction showAscii(): void {\n console.info(pc.cyan(' _ _ '));\n console.info(pc.cyan('▒▓█████▓▒ ___ ___| | | __ _ '));\n console.info(pc.cyan('▒▓█ █▓▒ / __/ _ \\\\ | |/ _` | '));\n console.info(pc.cyan('▒▓█ █▓▒ | (_| __/ | | (_| | '));\n console.info(pc.cyan('▒▓█████▓▒ \\\\___\\\\___|_|_|\\\\__,_| '));\n}\n\n/**\n * Displays the compact CLI welcome header.\n */\nexport function showWelcome(): void {\n console.info();\n showAscii();\n console.info();\n console.info(pc.dim(DESCRIPTION));\n console.info();\n console.info(getHeaderLine());\n console.info(DIVIDER);\n}\n\n/**\n * Print a cleared prompt's outcome as a persistent confirmation line:\n * `✓ <label> · <value>`, followed by a blank separator line. Used after prompts\n * that clear themselves on done so the chosen value stays visible.\n */\nexport function confirmChoice(label: string, value: string): void {\n console.info(`${pc.green('✓')} ${label} · ${value}`);\n console.info();\n}\n\n/**\n * Displays the final success message after project creation.\n */\nexport function showSuccess(\n projectName: string,\n _targetFolder: string,\n relativePath: string,\n needsCd: boolean,\n packageManager: string,\n): void {\n console.info();\n\n console.info(pc.bold('Next steps'));\n console.info(DIVIDER);\n console.info();\n\n if (needsCd) {\n console.info(`${pc.dim('$')} cd ${pc.cyan(relativePath)}`);\n }\n console.info(`${pc.dim('$')} ${pc.cyan(`${packageManager} install`)}`);\n console.info(`${pc.dim('$')} ${pc.cyan(`${packageManager} generate`)}`);\n console.info(\n `${pc.dim('$')} ${pc.cyan(`${packageManager} docker`)} ${pc.dim('&&')} ${pc.cyan(`${packageManager} seed`)} ${pc.dim('&&')} ${pc.cyan(`${packageManager} dev`)}`,\n );\n console.info();\n\n // Point to the generated README for first-run details and sign-in credentials. Use the\n // path relative to the new project so the terminal linkifies the right file (not this CLI's).\n const readmePath = relativePath ? `${relativePath}/README.md` : 'README.md';\n console.info(`${pc.gray('To get started building, please read:')} ${pc.cyan(readmePath)}`);\n console.info();\n console.info(`🥳 enjoy building ${pc.green(projectName)} with cella!`);\n console.info();\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport pc from 'picocolors';\nimport {\n generateEnvConfigs,\n generateEnvFromExample,\n getBackendEnvReplacements,\n INITIAL_VERSION,\n PLACEHOLDER_CONFIG,\n SYNC_CONFIG,\n TO_CLEAN,\n TO_COPY,\n TO_REMOVE,\n} from '#/constants';\n\nconst warningMark = pc.yellow('⚠');\n\n/**\n * Cleans the specified template by removing designated folders and files.\n * @param params - Parameters containing the target folder, project name, and optional extra edits.\n */\nexport async function cleanTemplate({\n targetFolder,\n projectName,\n displayName,\n portOffset = 0,\n adminEmail = `admin@${projectName}.example.com`,\n}: {\n targetFolder: string;\n projectName: string;\n displayName: string;\n portOffset?: number;\n adminEmail?: string;\n}): Promise<void> {\n // Change the current working directory to targetFolder if not already set\n if (process.cwd() !== targetFolder) {\n process.chdir(targetFolder);\n }\n\n return new Promise<void>((resolve, reject) => {\n (async () => {\n try {\n // Copy specified files\n for (const [src, dest] of Object.entries(TO_COPY)) {\n const srcAbsolutePath = path.resolve(targetFolder, src);\n const destAbsolutePath = path.resolve(targetFolder, dest);\n await copyFile(srcAbsolutePath, destAbsolutePath);\n }\n\n // Replace config.default.ts with interpolated placeholder config\n await applyPlaceholderConfig(targetFolder, projectName, displayName);\n\n // Reset release/versioning state so the fork starts under its own identity\n await resetReleaseState(targetFolder, projectName);\n\n // Drop the template's own list of downstream repos from the sync config\n await removeTemplateForks(targetFolder);\n\n // Generate backend .env from backend/.env.example.\n // The backend .env is the single source of truth for the project slug and DB ports\n // (consumed by backend/compose.yaml). There is no root .env.\n const backendReplacements = getBackendEnvReplacements(projectName, adminEmail, portOffset);\n const backendEnv = await generateEnvFromExample(\n path.resolve(targetFolder, 'backend/.env.example'),\n backendReplacements,\n );\n if (backendEnv) {\n await fs.writeFile(path.resolve(targetFolder, 'backend/.env'), backendEnv, 'utf8');\n }\n\n // Generate minimal env config files with project values and ports baked in\n const envConfigs = generateEnvConfigs(projectName, displayName, portOffset);\n await Promise.all(\n Object.entries(envConfigs).map(([filePath, content]) =>\n fs.writeFile(path.resolve(targetFolder, filePath), content, 'utf8'),\n ),\n );\n\n // Clean specified folder contents\n await Promise.all(\n TO_CLEAN.map((folderPath) => {\n const absolutePath = path.resolve(targetFolder, folderPath);\n return removeFolderContents(absolutePath);\n }),\n );\n\n // Remove specified files and folders\n await Promise.all(\n TO_REMOVE.map((filePath) => {\n const absolutePath = path.resolve(targetFolder, filePath);\n return removeFileOrFolder(absolutePath);\n }),\n );\n\n resolve();\n } catch (err) {\n reject(`Error during the cleaning process: ${err}`);\n }\n })();\n });\n}\n\n/**\n * Removes all contents within a specified folder.\n * @param folderPath - The path of the folder to clean.\n */\nasync function removeFolderContents(folderPath: string): Promise<void> {\n // List all files in the folder. Skip silently if the folder doesn't exist —\n // the template may not include every optional folder (e.g. backend/drizzle).\n let files: string[];\n try {\n files = await fs.readdir(folderPath);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return;\n throw err;\n }\n\n // `recursive: true` handles nested folders; `force: true` ignores races/missing entries.\n await Promise.all(files.map((file) => fs.rm(path.join(folderPath, file), { recursive: true, force: true })));\n}\n\n/**\n * Removes a specified file or folder.\n * @param pathToRemove - The path to the file or folder to remove.\n */\nasync function removeFileOrFolder(pathToRemove: string): Promise<void> {\n await fs.rm(pathToRemove, { recursive: true, force: true });\n}\n\n/**\n * Helper function to copy files if the source exists.\n * @param src - The source file path.\n * @param dest - The destination file path.\n */\nasync function copyFile(src: string, dest: string): Promise<void> {\n try {\n // Check if the source file exists\n await fs.access(src);\n\n // Ensure the destination directory exists\n await fs.mkdir(path.dirname(dest), { recursive: true });\n\n // Copy the file\n await fs.copyFile(src, dest);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n console.info(`\\n${warningMark} Source file \"${src}\" does not exist > Skip copy`);\n } else {\n throw err;\n }\n }\n}\n\n/**\n * Read the fork config template shipped inside the cloned Cella template\n * (`shared/config/config.template.ts`), interpolate project tokens, write the\n * result as `shared/config/config.default.ts` — replacing the original — and\n * delete the now-consumed template from the fork.\n */\nasync function applyPlaceholderConfig(targetFolder: string, projectName: string, displayName: string): Promise<void> {\n const src = path.resolve(targetFolder, PLACEHOLDER_CONFIG);\n const dest = path.resolve(targetFolder, './shared/config/config.default.ts');\n\n try {\n let content = await fs.readFile(src, 'utf8');\n content = content.replaceAll('__project_name__', displayName);\n content = content.replaceAll('__project_slug__', projectName);\n await fs.writeFile(dest, content, 'utf8');\n await fs.rm(src, { force: true });\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n console.info(`\\n${warningMark} Fork config template \"${src}\" not found > Skip`);\n } else {\n throw err;\n }\n }\n}\n\n/**\n * Remove the `forks` property, and a comment line directly above it, from the source of a sync\n * config. Returns the source unchanged when it has no such property.\n */\nexport function stripForks(source: string): string {\n // The closing bracket sits at the property's own indent, or on the same line for a short list\n return source.replace(\n /^(?:[ \\t]*\\/\\/[^\\n]*\\n)?([ \\t]*)forks:\\s*\\[(?:[^\\n]*|[\\s\\S]*?\\n\\1)\\],?[ \\t]*\\n(?:[ \\t]*\\n)?/m,\n '',\n );\n}\n\n/**\n * The template's sync config lists the repos the template itself syncs to. A new app has none,\n * and the sync CLI never merges this file, so the list is removed once here.\n */\nasync function removeTemplateForks(targetFolder: string): Promise<void> {\n const configPath = path.resolve(targetFolder, SYNC_CONFIG);\n try {\n const source = await fs.readFile(configPath, 'utf8');\n const stripped = stripForks(source);\n if (stripped !== source) await fs.writeFile(configPath, stripped, 'utf8');\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n console.info(`\\n${warningMark} \"${SYNC_CONFIG}\" not found > Skip forks removal`);\n } else {\n throw err;\n }\n }\n}\n\n/**\n * Reset the upstream cella release identity so the new fork starts clean:\n * - root `package.json`: `name` → project slug, `version` → INITIAL_VERSION,\n * and blank out `license`/`repository`/`description`/`keywords`/`author`/`homepage`\n * (keys kept visible so the fork can fill in its own metadata)\n * - `.github/release-please-manifest.json` → `{ \".\": INITIAL_VERSION }`\n * - `.github/release-please-config.json`: `changelog-path` → root `CHANGELOG.md`\n * (cella tracks its own changelog in the template docs folder, which the fork\n * keeps as upstream reference; the fork's own releases write to a fresh root changelog)\n * - `CHANGELOG.md` → fresh stub\n */\nasync function resetReleaseState(targetFolder: string, projectName: string): Promise<void> {\n // Root package.json: rewrite only the top-level fields in place to avoid reformatting\n // the whole file. Set name/version to the fork's identity, then blank out the upstream\n // cella metadata (license, repository, description, keywords, author, homepage) while\n // keeping the keys visible so the fork can fill them in.\n const pkgPath = path.resolve(targetFolder, 'package.json');\n try {\n let pkg = await fs.readFile(pkgPath, 'utf8');\n pkg = pkg.replace(/^(\\s*\"name\":\\s*)\"[^\"]*\"/m, `$1\"${projectName}\"`);\n pkg = pkg.replace(/^(\\s*\"version\":\\s*)\"[^\"]*\"/m, `$1\"${INITIAL_VERSION}\"`);\n // Empty each string field, keeping the key so the fork sees the shape.\n for (const field of ['license', 'repository', 'description', 'author', 'homepage']) {\n pkg = pkg.replace(new RegExp(`^(\\\\s*\"${field}\":\\\\s*)\"[^\"]*\"`, 'm'), '$1\"\"');\n }\n // Collapse the multi-line keywords array to an empty one.\n pkg = pkg.replace(/^(\\s*\"keywords\":\\s*)\\[[^\\]]*\\]/m, '$1[]');\n await fs.writeFile(pkgPath, pkg, 'utf8');\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n console.info(`\\n${warningMark} \"package.json\" not found > Skip version reset`);\n } else {\n throw err;\n }\n }\n\n // Point release-please at a root CHANGELOG.md for the fork. The upstream Cella\n // changelog stays wherever the template keeps it; the fork's own releases live at root.\n const configPath = path.resolve(targetFolder, '.github/release-please-config.json');\n try {\n const config = JSON.parse(await fs.readFile(configPath, 'utf8')) as {\n packages?: Record<string, Record<string, unknown>>;\n };\n config.packages ??= {};\n config.packages['.'] ??= {};\n config.packages['.']['changelog-path'] = 'CHANGELOG.md';\n await fs.writeFile(configPath, `${JSON.stringify(config, null, 2)}\\n`, 'utf8');\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n console.info(`\\n${warningMark} \"release-please-config.json\" not found > Skip changelog path reset`);\n } else {\n throw err;\n }\n }\n\n // Reset the release-please manifest and changelog. `force: true` writes even if absent.\n await fs.writeFile(\n path.resolve(targetFolder, '.github/release-please-manifest.json'),\n `{\\n \".\": \"${INITIAL_VERSION}\"\\n}\\n`,\n 'utf8',\n );\n await fs.writeFile(path.resolve(targetFolder, 'CHANGELOG.md'), '# Changelog\\n', 'utf8');\n}\n","import fs from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport git from 'isomorphic-git';\nimport http from 'isomorphic-git/http/node';\n\n/** Parse `github:owner/repo` or `owner/repo` into its owner and repo parts. */\nfunction parseGithubRepo(template: string): { owner: string; repo: string } {\n const [owner, repo] = template.replace(/^github:/, '').split('/');\n if (!owner || !repo) {\n throw new Error(`Invalid template '${template}'. Expected 'github:owner/repo'.`);\n }\n return { owner, repo };\n}\n\n/**\n * Clones a GitHub template into `targetFolder` using isomorphic-git (pure JS).\n *\n * A shallow, single-branch clone over HTTPS — no `git` binary, no `child_process`,\n * so `create-cella` keeps a clean supply-chain profile (no shell access). Unlike a\n * raw tarball parse, isomorphic-git reconstructs the tree itself, so file modes and\n * long paths are always correct. The cloned `.git` history is discarded afterwards;\n * scaffolding re-initialises the repo with a fresh initial commit.\n *\n * @param template - `github:owner/repo` (or `owner/repo`).\n * @param ref - Branch or tag to check out (e.g. `main` or a release tag).\n * @param targetFolder - Directory to clone the template into.\n * @returns The exact upstream commit SHA the template was scaffolded from.\n */\nexport async function downloadGithubTemplate(template: string, ref: string, targetFolder: string): Promise<string> {\n const { owner, repo } = parseGithubRepo(template);\n const url = `https://github.com/${owner}/${repo}.git`;\n\n await git.clone({ fs, http, dir: targetFolder, url, ref, singleBranch: true, depth: 1 });\n\n // Capture the exact commit the scaffold is based on before discarding history. It is\n // stamped as a `Cella-Base:` trailer on the initial commit, where the sync CLI reads it\n // to bootstrap the first merge-base (the fork shares no git history with upstream).\n const baseSha = await git.resolveRef({ fs, dir: targetFolder, ref: 'HEAD' });\n\n // Drop the cloned history — the scaffold gets its own fresh initial commit.\n await rm(join(targetFolder, '.git'), { recursive: true, force: true });\n\n return baseSha;\n}\n","import { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport ignore from 'ignore';\n\n/**\n * Lists the files under `root` that git would track, without shelling out to git.\n *\n * Honors the root `.gitignore` (via the `ignore` package) and always skips `.git`\n * and `node_modules`. Used for the local-template dev flow (`--template ./local`)\n * so build output and local `.env` secrets aren't copied into the new project.\n *\n * Paths are returned relative to `root` using POSIX separators.\n */\nexport async function listTemplateFiles(root: string): Promise<string[]> {\n const ig = ignore().add(['.git', 'node_modules']);\n try {\n ig.add(await readFile(join(root, '.gitignore'), 'utf8'));\n } catch {\n // No .gitignore at the template root — only the defaults above apply.\n }\n\n const files: string[] = [];\n\n async function walk(relDir: string): Promise<void> {\n const entries = await readdir(relDir ? join(root, relDir) : root, { withFileTypes: true });\n for (const entry of entries) {\n const rel = relDir ? `${relDir}/${entry.name}` : entry.name;\n // `ignore` matches directory rules when the path ends with a slash.\n if (ig.ignores(entry.isDirectory() ? `${rel}/` : rel)) continue;\n if (entry.isDirectory()) await walk(rel);\n else if (entry.isFile()) files.push(rel);\n }\n }\n\n await walk('');\n return files;\n}\n","/**\n * Progress Tracker Utility\n *\n * Provides compact progress tracking for CLI operations.\n * Uses a single spinner that updates in place.\n */\n\nimport ora, { type Ora } from 'ora';\nimport pc from 'picocolors';\n\n/** Global reference to the currently active spinner */\nlet activeSpinner: Ora | null = null;\n\n/** Pause the active spinner (for interactive prompts) */\nexport function pauseSpinner(): void {\n if (activeSpinner) {\n activeSpinner.stop();\n }\n}\n\n/** Resume the active spinner after a prompt */\nexport function resumeSpinner(): void {\n if (activeSpinner) {\n activeSpinner.start();\n }\n}\n\nexport interface ProgressTracker {\n /** Update the current step (shown as spinner text) */\n step: (message: string) => void;\n /** Mark the tracker as complete with final message */\n done: (message: string) => void;\n /** Mark the tracker as failed with error message */\n fail: (message: string) => void;\n}\n\n/**\n * Creates a progress tracker for a multi-step operation.\n * Shows a single spinner that updates in place.\n *\n * @param title - The initial title for the spinner\n * @returns A ProgressTracker instance\n *\n * @example\n * const progress = createProgress('creating project');\n * progress.step('downloading template');\n * progress.step('installing dependencies');\n * progress.done('project created');\n */\nexport function createProgress(title: string, silent = false): ProgressTracker {\n const completedSteps: string[] = [];\n\n const spinner = ora({\n text: title,\n isSilent: silent,\n });\n\n activeSpinner = spinner;\n spinner.start();\n\n // Helper to log (respects silent mode)\n const log = (msg: string) => {\n if (!silent) console.info(msg);\n };\n\n return {\n step: (message: string) => {\n // Complete previous step with green check if there was one\n if (completedSteps.length > 0) {\n spinner.stop();\n log(`${pc.green('✓')} ${completedSteps[completedSteps.length - 1]}`);\n }\n completedSteps.push(message);\n spinner.text = message;\n spinner.start();\n },\n\n done: (message: string) => {\n // Complete the last step with green check\n if (completedSteps.length > 0) {\n spinner.stop();\n log(`${pc.green('✓')} ${completedSteps[completedSteps.length - 1]}`);\n } else {\n spinner.stop();\n }\n activeSpinner = null;\n if (message) {\n log('');\n log(`${pc.green('✓')} ${message}`);\n }\n },\n\n fail: (message: string) => {\n spinner.stop();\n activeSpinner = null;\n log(`${pc.red('✗')} ${pc.red(message)}`);\n },\n };\n}\n","import { readdir, readFile } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\n\n/** An optional module discovered in a `*-module.ts` registration. */\nexport interface OptionalModule {\n name: string;\n description: string;\n /** Module folder, relative to the project root, removed when deselected. */\n folder: string;\n}\n\n/** Directories never worth scanning. */\nconst SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'build', '.turbo', 'coverage']);\n\n/**\n * Scan the template for `*-module.ts` files that register `optional: true` and return\n * their name, description and folder. Pure static regex parsing — no imports/eval — so it\n * runs before dependencies are installed. The folder is the module file's directory.\n */\nexport async function scanOptionalModules(targetFolder: string): Promise<OptionalModule[]> {\n const files: string[] = [];\n await collectModuleFiles(targetFolder, files);\n\n const modules: OptionalModule[] = [];\n for (const file of files) {\n const src = await readFile(file, 'utf8');\n if (!/optional:\\s*true/.test(src)) continue;\n\n const name = src.match(/name:\\s*['\"]([^'\"]+)['\"]/)?.[1];\n const description = src.match(/description:\\s*['\"]([^'\"]+)['\"]/)?.[1] ?? '';\n if (!name) continue;\n\n modules.push({ name, description, folder: relative(targetFolder, dirname(file)) });\n }\n return modules.sort((a, b) => a.name.localeCompare(b.name));\n}\n\n/**\n * Every project-root-relative folder removed when an optional module is deselected: its own\n * module folder plus the route and static-asset folders it may own. Route folders are\n * speculative — a module owns either a pathless `_<name>` (URL-transparent) or a path-based\n * `<name>` route, under `routes/_public` and/or `routes/_app` — so callers remove only the\n * variants that actually exist. Single-sourced here so removal and tests stay in sync.\n */\nexport function optionalModuleFolders({ name, folder }: OptionalModule): string[] {\n return [\n folder,\n `frontend/src/routes/_public/_${name}`,\n `frontend/src/routes/_public/${name}`,\n `frontend/src/routes/_app/_${name}`,\n `frontend/src/routes/_app/${name}`,\n `frontend/public/static/${name}`,\n ];\n}\n\nasync function collectModuleFiles(dir: string, out: string[]): Promise<void> {\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory()) {\n if (SKIP_DIRS.has(entry.name)) continue;\n await collectModuleFiles(join(dir, entry.name), out);\n } else if (entry.name.endsWith('-module.ts') || entry.name.endsWith('-module.tsx')) {\n out.push(join(dir, entry.name));\n }\n }\n}\n","import { readdir, readFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\n\ninterface UsedPorts {\n project: string;\n frontend: number;\n backend: number;\n offset: number;\n}\n\n/**\n * Scan sibling directories for existing cella forks and extract their dev ports.\n * Looks for `shared/config/config.development.ts` to identify cella-based projects.\n * Handles both config shapes: same-origin (frontendUrl carries the only URL port,\n * services listen on `devPorts`) and legacy (backendUrl on its own port).\n */\nexport async function detectUsedPorts(targetFolder: string): Promise<UsedPorts[]> {\n const parentDir = dirname(targetFolder);\n const used: UsedPorts[] = [];\n\n let siblings: string[];\n try {\n siblings = await readdir(parentDir);\n } catch {\n return used;\n }\n\n for (const name of siblings) {\n const configPath = join(parentDir, name, 'shared/config/config.development.ts');\n try {\n const content = await readFile(configPath, 'utf8');\n const feMatch = content.match(/frontendUrl:\\s*'http:\\/\\/localhost:(\\d+)/);\n if (!feMatch) continue;\n const frontend = Number(feMatch[1]);\n // Same-origin shape: service ports live in devPorts. Legacy shape: backendUrl\n // has its own port. Oldest forks predate both; assume the paired offset then.\n const devPortsMatch = content.match(/devPorts:\\s*\\{[^}]*?\\bapi:\\s*(\\d+)/);\n const legacyBeMatch = content.match(/backendUrl:\\s*'http:\\/\\/localhost:(\\d+)'/);\n const backend = devPortsMatch\n ? Number(devPortsMatch[1])\n : legacyBeMatch\n ? Number(legacyBeMatch[1])\n : frontend + 1000;\n used.push({\n project: name,\n frontend,\n backend,\n offset: frontend - 3000,\n });\n } catch {\n // Not a cella fork, skip\n }\n }\n\n return used;\n}\n\n/** Find the next available offset (in steps of 10) that doesn't collide with existing forks. */\nexport function findNextOffset(usedPorts: UsedPorts[]): number {\n const usedOffsets = new Set(usedPorts.map((p) => p.offset));\n for (let offset = 0; offset <= 490; offset += 10) {\n if (!usedOffsets.has(offset)) return offset;\n }\n return 0;\n}\n","/**\n * Fetch lightweight metadata about the cella template so the scaffolder can offer\n * \"latest release\" vs \"latest commit\" as a starting point.\n *\n * The release tag is read from the template's git tags, over the transport the clone uses, so\n * it does not depend on the GitHub API and its limit for callers without a token. Dates and the\n * commit subject come from that API. Every helper fails soft; the caller falls back to the\n * default branch when no release is known.\n */\nimport git from 'isomorphic-git';\nimport http from 'isomorphic-git/http/node';\nimport { TEMPLATE_GIT_URL, TEMPLATE_REPOSITORY } from '#/constants';\n\nconst TEMPLATE_METADATA_API_BASE = `https://api.github.com/repos/${TEMPLATE_REPOSITORY}`;\n\n/** Format an ISO timestamp as a locale-independent YYYY-MM-DD date. */\nfunction toDate(iso?: string): string {\n return iso ? iso.slice(0, 10) : 'unknown';\n}\n\nconst GITHUB_HEADERS = { Accept: 'application/vnd.github+json' } as const;\n\nexport interface ReleaseInfo {\n /** Release tag, e.g. '0.18.1' */\n tag: string;\n /** Publication date, YYYY-MM-DD; absent when the GitHub API did not answer */\n date?: string;\n}\n\nexport interface CommitInfo {\n /** Full commit SHA (used for a reproducible checkout) */\n sha: string;\n /** Short 7-char SHA for display */\n shortSha: string;\n /** First line of the commit message */\n message: string;\n /** Commit date, YYYY-MM-DD */\n date: string;\n}\n\n/**\n * Pick the latest template release from tag names: the highest plain version, with or without\n * the `v` prefix. Tags of another series (`create-cella-0.2.3`, `archive/pre-release`) and\n * pre-releases are no template release.\n */\nexport function pickLatestReleaseTag(tags: string[]): string | null {\n let latest: { tag: string; version: number[] } | null = null;\n for (const tag of tags) {\n const match = /^v?(\\d+)\\.(\\d+)\\.(\\d+)$/.exec(tag);\n if (!match) continue;\n const version = match.slice(1).map(Number);\n if (!latest || isNewer(version, latest.version)) latest = { tag, version };\n }\n return latest?.tag ?? null;\n}\n\n/** Whether version `a` is higher than `b`, both as [major, minor, patch]. */\nfunction isNewer(a: number[], b: number[]): boolean {\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return a[i] > b[i];\n }\n return false;\n}\n\n/** Fetch the latest template release: its tag from the git tags, its date from the GitHub API. */\nexport async function fetchLatestRelease(): Promise<ReleaseInfo | null> {\n let tag: string | null;\n try {\n const refs = await git.listServerRefs({ http, url: TEMPLATE_GIT_URL, prefix: 'refs/tags/' });\n tag = pickLatestReleaseTag(refs.map(({ ref }) => ref.slice('refs/tags/'.length)));\n } catch {\n return null;\n }\n if (!tag) return null;\n\n return { tag, date: await fetchReleaseDate(tag) };\n}\n\n/** Publication date of a release, undefined when the GitHub API does not answer. */\nasync function fetchReleaseDate(tag: string): Promise<string | undefined> {\n try {\n const response = await fetch(`${TEMPLATE_METADATA_API_BASE}/releases/tags/${tag}`, { headers: GITHUB_HEADERS });\n if (!response.ok) return undefined;\n\n const release = (await response.json()) as { published_at?: string };\n return release.published_at ? toDate(release.published_at) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Fetch the latest commit on a branch (defaults to 'main'). */\nexport async function fetchLatestCommit(branch = 'main'): Promise<CommitInfo | null> {\n const apiUrl = `${TEMPLATE_METADATA_API_BASE}/commits/${branch}`;\n\n try {\n const response = await fetch(apiUrl, { headers: GITHUB_HEADERS });\n if (!response.ok) return null;\n\n const data = (await response.json()) as {\n sha?: string;\n commit?: { message?: string; author?: { date?: string } };\n };\n if (!data.sha) return null;\n\n const message = (data.commit?.message ?? '').split('\\n')[0];\n return { sha: data.sha, shortSha: data.sha.slice(0, 7), message, date: toDate(data.commit?.author?.date) };\n } catch {\n return null;\n }\n}\n","import { readdir } from 'node:fs/promises';\n\n/**\n * Checks if a directory is empty or only contains a .git directory.\n *\n * @param path - The path of the directory to check.\n * @returns Resolves to true if the directory is empty or contains only a .git folder, false otherwise.\n * @throws Throws an error if the path is not a directory or if there's an issue reading the directory.\n */\nexport async function isEmptyDirectory(path: string): Promise<boolean> {\n const files = await readdir(path);\n\n // Check if directory is empty or contains only the .git directory\n return files.length === 0 || (files.length === 1 && files[0] === '.git');\n}\n"],"mappings":";;;AAEA,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,MAAAC,WAAU;AACnB,SAAS,YAAAC,WAAU,WAAAC,gBAAe;AAClC,SAAS,OAAO,cAAc;AAC9B,OAAOC,SAAQ;;;ACNf,OAAO,QAAQ;;;ACAf;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,SAAW;AAAA,EACX,SAAW;AAAA,EACX,aAAe;AAAA,EACf,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,QAAU;AAAA,EACV,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,KAAO;AAAA,IACL,gBAAgB;AAAA,EAClB;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,OAAS;AAAA,IACT,OAAS;AAAA,IACT,cAAc;AAAA,IACd,gBAAkB;AAAA,IAClB,OAAS;AAAA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,GAAG,OAAO,EAAE;AAAA,QAChD,GAAG,QAAQ,IAAI,CAAC,OAAO,EAAE,MAAM,aAAa,CAAC,GAAG,OAAO,EAAE,EAAE;AAAA,QAC3D,EAAE,MAAM,iBAAiB,OAAO,GAAG;AAAA,MACrC;AAAA,IACF;AAAA,IACA;AAAA,EACF;AAEA,MAAI,WAAW,GAAI,QAAO;AAE1B,QAAM,SAAS,MAAM;AAAA,IACnB;AAAA,MACE,SAAS;AAAA,MACT,SAAS,OAAO,SAAS;AAAA,MACzB;AAAA,MACA,UAAU,CAAC,QAAQ;AACjB,cAAM,IAAI,OAAO,GAAG;AACpB,YAAI,OAAO,MAAM,CAAC,KAAK,IAAI,KAAK,IAAI,IAAK,QAAO;AAChD,YAAI,IAAI,OAAO,EAAG,QAAO;AACzB,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACA,SAAO,OAAO,MAAM;AACtB;","names":["existsSync","rm","basename","resolve","pc","readFile","rm","dirname","join","relative","resolve","pc","pc","pc","packageManager","fs","pc","pc","resolve","fs","fs","git","join","pc","readdir","readFile","join","path","packageManager","resolve","relative","rel","join","dirname","pc","rm","readdir","readFile","dirname","join","git","http","git","http","readdir","path","basename","resolve","existsSync","rm","pc"]}
|
|
1
|
+
{"version":3,"sources":["../src/create-cella-cli.ts","../src/constants.ts","../package.json","../src/create.ts","../src/utils/git/command.ts","../src/add-remote.ts","../src/modules/cli/commands.ts","../src/utils/detect-used-ports.ts","../src/utils/is-email.ts","../src/utils/validate-project-name.ts","../src/modules/cli/display.ts","../src/utils/clean-template.ts","../src/utils/download-template.ts","../src/utils/list-template-files.ts","../src/utils/progress.ts","../src/utils/busy-ports.ts","../src/utils/fetch-template-metadata.ts","../src/utils/is-empty-directory.ts"],"sourcesContent":["#!/usr/bin/env tsx\n\nimport { existsSync } from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { basename, resolve } from 'node:path';\nimport { input, select } from '@inquirer/prompts';\nimport pc from 'picocolors';\nimport { TEMPLATE_URL } from '#/constants';\nimport { create } from '#/create';\nimport { type CreateOptions, cli, confirmChoice, showWelcome } from '#/modules/cli';\nimport { findBusyPorts } from '#/utils/busy-ports';\nimport { detectUsedPorts, findNextAppIndex, isAppIndex } from '#/utils/detect-used-ports';\nimport { fetchLatestCommit, fetchLatestRelease } from '#/utils/fetch-template-metadata';\nimport { isEmail } from '#/utils/is-email';\nimport { isEmptyDirectory } from '#/utils/is-empty-directory';\nimport { validateProjectName } from '#/utils/validate-project-name';\n\nasync function main(): Promise<void> {\n // Display CLI welcome banner\n showWelcome();\n\n // Shared theme to clear prompts after answering\n const promptTheme = { prefix: '', style: { answer: (text: string) => text } };\n const promptContext = { clearPromptOnDone: true };\n\n // Choose which template snapshot to scaffold from: a stable release or the\n // latest commit. Skipped when a custom --template is provided (ref doesn't apply).\n const templateRef = cli.options.template ? undefined : await promptTemplateRef(promptTheme, promptContext);\n\n // Prompt for project name if not provided\n if (!cli.directory) {\n cli.directory = await input(\n {\n message: 'Enter your project name',\n default: 'my-cella-app',\n theme: promptTheme,\n validate: (name) => {\n const validation = validateProjectName(basename(resolve(name)));\n return validation.valid ? true : `Invalid project name: ${validation.problems?.[0] ?? 'unknown error'}`;\n },\n },\n promptContext,\n );\n }\n\n const targetFolder = resolve(cli.directory);\n const projectName = basename(targetFolder)?.toLowerCase() || 'project';\n\n // Check if the target folder exists and is not empty\n if (existsSync(targetFolder) && !(await isEmptyDirectory(targetFolder))) {\n const dirName = cli.directory === '.' ? 'Current directory' : `Target directory \"${targetFolder}\"`;\n const message = `${dirName} is not empty. Please choose how you would like to proceed:`;\n\n const action = await select(\n {\n message,\n theme: promptTheme,\n choices: [\n { name: 'Cancel and exit', value: 'cancel' },\n { name: 'Remove existing files and continue', value: 'remove' },\n ],\n },\n promptContext,\n );\n\n if (action === 'cancel') {\n process.exit(1);\n }\n\n // Wipe the folder so the template clone starts from a clean slate. Leaving stale\n // files behind makes the git checkout fail with conflicts on overlapping paths.\n if (action === 'remove') {\n await rm(targetFolder, { recursive: true, force: true });\n }\n }\n\n // Scan sibling directories and prompt for the app index\n const appIndex = cli.options.appIndex ?? (await promptAppIndex(targetFolder, promptTheme, promptContext));\n confirmChoice('App index', formatAppIndex(appIndex));\n const busyPorts = await findBusyPorts(appIndex);\n if (busyPorts.length > 0) {\n console.info(\n `${pc.yellow('⚠')} In use on this machine: ${busyPorts.join(', ')}. Stop what holds them before pnpm docker and pnpm dev.`,\n );\n console.info();\n }\n\n // Prompt for admin email. Default uses the reserved `example.com` domain (RFC 2606) so the\n // seed address can never resolve or route real mail — it's a placeholder, not a real inbox.\n const adminEmail =\n cli.options.adminEmail ??\n (await input(\n {\n message: 'Admin email for initial seed user',\n default: 'admin@example.com',\n theme: promptTheme,\n validate: (email) => (isEmail(email) ? true : 'Enter an address such as admin@example.com'),\n },\n promptContext,\n ));\n confirmChoice('Admin email', adminEmail);\n\n // Proceed with the project creation\n const createOptions: CreateOptions = {\n projectName,\n targetFolder,\n packageManager: cli.packageManager,\n templateUrl: cli.options.template,\n templateRef,\n appIndex,\n adminEmail,\n };\n\n await create(createOptions);\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exit(1);\n});\n\n/**\n * Show a short intro with the two starting points (latest release and latest\n * commit, each with its date) and let the user choose which template snapshot to\n * scaffold from. Returns the template ref to check out (release tag or `main`), or\n * undefined to use the default branch (when metadata is unavailable).\n */\nasync function promptTemplateRef(theme: object, context: object): Promise<string | undefined> {\n const [release, commit] = await Promise.all([fetchLatestRelease(), fetchLatestCommit()]);\n\n // One-sentence intro followed by the data points that are known.\n console.info(pc.dim('This create CLI allows you to get started with cella quickly.'));\n console.info();\n\n if (release)\n console.info(` Latest release: ${release.tag}${release.date ? ` ${pc.dim(`· ${release.date}`)}` : ''}`);\n if (commit) {\n console.info(` Latest commit: ${commit.shortSha} ${pc.dim(`· ${commit.message} · ${commit.date}`)}`);\n // Clickable link to the exact commit on GitHub, in grey below the summary line.\n const repo = TEMPLATE_URL.replace('github:', '');\n console.info(` ${pc.gray(`https://github.com/${repo}/commit/${commit.sha}`)}`);\n }\n if (release || commit) console.info();\n\n // No release known (offline, or the template's tags did not answer): the app starts from the\n // default branch, and the output says so.\n if (!release) {\n console.info(`${pc.yellow('⚠')} Latest release not found · using the latest commit on main`);\n console.info();\n return commit ? 'main' : undefined;\n }\n\n // No commit to offer, or no TTY to render the select on (CI, piped stdin): take the latest\n // release, the stable and reproducible starting point.\n if (!commit || !process.stdin.isTTY) {\n confirmChoice('Latest release', release.tag);\n return release.tag;\n }\n\n const choice = await select(\n {\n message: 'Choose which cella version to start from:',\n theme,\n choices: [\n { name: 'Latest release', value: 'release' },\n { name: 'Latest commit', value: 'commit' },\n ],\n },\n context,\n );\n\n // The prompt clears itself on done, so keep the choice visible with a checkmark.\n if (choice === 'release') {\n confirmChoice('Latest release', release.tag);\n return release.tag;\n }\n // \"Latest commit\" is the tip of main; check out the branch (shallow clones can't\n // reliably fetch an arbitrary SHA over GitHub's smart-HTTP protocol).\n confirmChoice('Latest commit', commit.shortSha);\n return 'main';\n}\n\n/** Format an app index as a port overview string, e.g. \"1 → :3001 / :4010 / :5442\" */\nfunction formatAppIndex(i: number, suffix = ''): string {\n return `${i} → :${3000 + i} / :${4000 + i * 10} / :${5432 + i * 10}${suffix}`;\n}\n\n/** Scan sibling apps and prompt the user to pick an app index */\nasync function promptAppIndex(targetFolder: string, theme: object, context: object): Promise<number> {\n const usedPorts = await detectUsedPorts(targetFolder);\n const presets = [1, 2, 3];\n const busy = new Map(await Promise.all([0, ...presets].map(async (i) => [i, await findBusyPorts(i)] as const)));\n const isBusy = (i: number) => (busy.get(i)?.length ?? 0) > 0;\n const suggested = findNextAppIndex(usedPorts, isBusy);\n const label = (i: number, note = '') => formatAppIndex(i, isBusy(i) ? ` (port ${busy.get(i)?.[0]} in use)` : note);\n\n // Fold a compact hint into the prompt message itself so it's wiped by clearPromptOnDone\n // once an index is chosen — no leftover \"Detected forks\" trail. Override the default\n // message style (which bolds everything) so only the \"App index\" title is bold.\n let message = `${pc.bold('App index')} ${pc.dim('· to avoid port conflicts with other apps on this machine')}`;\n if (usedPorts.length > 0) {\n const count = usedPorts.length;\n message += pc.dim(`\\nDetected ${count} sibling app${count === 1 ? '' : 's'} · suggested index ${suggested}`);\n }\n const portTheme = {\n ...(theme as Record<string, unknown>),\n style: { ...((theme as { style?: object }).style ?? {}), message: (text: string) => text },\n };\n\n // Presets exclude 0 (always offered as the explicit default below) and the suggested\n // value (offered first) to avoid duplicate choices.\n const choice = await select(\n {\n message,\n theme: portTheme,\n choices: [\n ...(suggested > 0 ? [{ name: formatAppIndex(suggested, ' (suggested)'), value: suggested }] : []),\n { name: label(0, ' (default)'), value: 0 },\n ...presets.filter((i) => i !== suggested).map((i) => ({ name: label(i), value: i })),\n { name: 'Custom index', value: -1 },\n ],\n },\n context,\n );\n\n if (choice !== -1) return choice;\n\n const custom = await input(\n {\n message: 'Enter custom index (0-9, not 4)',\n default: String(suggested),\n theme,\n validate: (val) => (isAppIndex(Number(val)) ? true : 'Must be a whole number from 0 to 9, not 4'),\n },\n context,\n );\n return Number(custom);\n}\n","import pc from 'picocolors';\nimport packageJson from '../package.json' with { type: 'json' };\n\n/** Name of this CLI tool */\nexport const NAME = 'create cella';\n\n/** Thin line divider for console output (60 chars wide) */\nexport const DIVIDER = '─'.repeat(60);\n\n/** URL of the template repository */\nexport const TEMPLATE_URL = 'github:cellajs/cella';\n\n/** Canonical owner/repo for template metadata fetched from the GitHub API. */\nexport const TEMPLATE_REPOSITORY = 'cellajs/cella';\n\n/** HTTPS git URL of the template, for reading its release tags without the GitHub API. */\nexport const TEMPLATE_GIT_URL = `https://github.com/${TEMPLATE_REPOSITORY}.git`;\n\n/** The app's sync config, which the template ships with its own settings. */\nexport const SYNC_CONFIG = 'cella/cella.config.ts';\n\n/** Upstream remote of a new app: HTTPS, so reading a public template needs no SSH key. */\nexport const CELLA_REMOTE_URL = TEMPLATE_GIT_URL;\n\n/**\n * Git remote name pointing at upstream cella. Matches the name the sync CLI\n * (`pnpm cella`) expects, so scaffolds don't end up with a duplicate remote.\n */\nexport const CELLA_REMOTE_NAME = 'cella-upstream';\n\n/** Export details from package.json */\nexport const DESCRIPTION: string = packageJson.description;\nexport const VERSION: string = packageJson.version;\nexport const WEBSITE: string = packageJson.homepage;\n\nexport function getHeaderLine(): string {\n const leftText = `⧈ ${NAME} · ${VERSION}`;\n const left = `${pc.cyan(`⧈ ${NAME}`)} ${pc.dim(`· ${VERSION}`)}`;\n const right = pc.cyan(WEBSITE);\n const padding = Math.max(1, 60 - leftText.length - WEBSITE.length);\n return `${left}${' '.repeat(padding)}${right}`;\n}\n\n// Files or folders to be removed from the template after downloading.\n// The Pulumi stack files carry cella's own bootstrap markers and encryption\n// salt; a fresh app bootstraps its own. Removing them also keeps the deploy\n// workflow's staging gate false until the app bootstraps, so a fresh scaffold\n// never auto-deploys staging on its first push to main.\nexport const TO_REMOVE: string[] = ['./infra/Pulumi.production.yaml', './infra/Pulumi.staging.yaml'];\n\n// Specific folder contents to be cleaned out from the template\nexport const TO_CLEAN: string[] = ['./backend/drizzle'];\n\n// Files to copy/paste after downloading\nexport const TO_COPY: Record<string, string> = {\n './frontend/.env.example': './frontend/.env',\n};\n\n/** The template's quickstart, which becomes the new app's README. */\nexport const QUICKSTART = './cella/QUICKSTART.md';\n\n/** Entry points a coding agent reads from the repo root; the rules and skills live in the template's `cella/` folder. */\nexport const AGENT_FILES: Record<string, string> = {\n 'AGENTS.md':\n '# Agent guidelines\\n\\nThis app is built from the cella template. Read [cella/AGENTS.md](./cella/AGENTS.md) before changing code: it holds the project rules. Skills, such as `add-entity`, live in [cella/skills](./cella/skills).\\n',\n 'CLAUDE.md': '@cella/AGENTS.md\\n',\n};\n\n/** Frontend dev port of an app number. */\nexport const frontendPort = (appIndex: number): number => 3000 + appIndex;\n\n/**\n * The quickstart as the README of a new app: at the repo root, with this app's port and without the step that just ran.\n * Its links are relative to `cella/` in the template, so `./x` becomes `./cella/x` and `../x` becomes `./x`.\n */\nexport function quickstartToReadme(source: string, displayName: string, appIndex: number): string {\n return source\n .replace(/^# .*$/m, `# ${displayName}`)\n .replace(/^## Create\\n[\\s\\S]*?(?=^## )/m, '')\n .replaceAll('](./', '](./cella/')\n .replaceAll('](../', '](./')\n .replaceAll('http://localhost:3000', `http://localhost:${frontendPort(appIndex)}`);\n}\n\n/**\n * Fork config template that replaces `shared/config/config.default.ts` in new forks.\n */\nexport const PLACEHOLDER_CONFIG = 'shared/config/config.template.ts';\n\n/**\n * Starting version for a fresh fork. Resets the upstream cella version so\n * release-please cuts the fork's first release from a clean slate.\n */\nexport const INITIAL_VERSION = '0.0.0';\n\n/**\n * Read a `.env.example` file and apply key=value replacements.\n * Comments and unmatched keys are preserved as-is.\n * Returns null if the file doesn't exist (caller should generate from scratch).\n */\nexport async function generateEnvFromExample(\n examplePath: string,\n replacements: Record<string, string>,\n): Promise<string | null> {\n const { readFile } = await import('node:fs/promises');\n let content: string;\n try {\n content = await readFile(examplePath, 'utf8');\n } catch {\n return null;\n }\n\n return content.replace(/^([A-Z_][A-Z0-9_]*)=(.*)$/gm, (match, key, _value) => {\n if (key in replacements) return `${key}=${replacements[key]}`;\n return match;\n });\n}\n\n/**\n * Replacement map for `backend/.env`.\n * The backend `.env` is the single source of truth for the project slug, database\n * ports (consumed by `backend/compose.yaml`), connection URLs and admin email.\n * Service ports deliberately do NOT live here: they come from `devPorts` in\n * shared config, and a stale `PORT=` env line would silently override the app's\n * `devAppIndex` (the pre-devPorts collision failure mode).\n */\nexport function getBackendEnvReplacements(slug: string, adminEmail: string, appIndex: number): Record<string, string> {\n const db = 5432 + appIndex * 10;\n return {\n PROJECT_SLUG: slug,\n DB_PORT: String(db),\n DB_TEST_PORT: String(5434 + appIndex * 10),\n DATABASE_URL: `postgres://runtime_role:dev_password@0.0.0.0:${db}/postgres`,\n DATABASE_ADMIN_URL: `postgres://postgres:postgres@0.0.0.0:${db}/postgres`,\n DATABASE_CDC_URL: `postgres://admin_role:dev_password@0.0.0.0:${db}/postgres`,\n ADMIN_EMAIL: adminEmail,\n };\n}\n\n/** Set the app's number in the source of `config.default.ts`; a template without the key can only give index 0. */\nexport function setDevAppIndex(source: string, appIndex: number): string {\n const pattern = /^(\\s*devAppIndex:\\s*)\\d+/m;\n if (appIndex !== 0 && !pattern.test(source)) {\n throw new Error('This template has no devAppIndex in its config: use app index 0, or a newer template.');\n }\n return source.replace(pattern, (_, head: string) => `${head}${appIndex}`);\n}\n\n/**\n * Generate env config files with project-specific values.\n * All configs go through the same data-driven loop.\n * Values prefixed with '=' are emitted as raw TS expressions (not quoted).\n */\nexport function generateEnvConfigs(slug: string, name: string): Record<string, string> {\n const header =\n \"import type { DeepPartial } from '../src/config-builder/types.ts';\\nimport type { config as _default } from './config.default.ts';\\n\";\n\n // Per-environment specs: optional imports + object props (= prefix → raw TS expression).\n // URL shapes are same-origin (the Vite dev server / public origin proxies /api, /yjs,\n // /mcp and /oauth), mirroring cella's own config.<mode>.ts files. The URLs carry app number 0's\n // port: `devAppIndex` in config.default.ts moves them and `devPorts` when the config builds.\n const envs: Record<string, { imports?: string; props: Record<string, string | boolean> }> = {\n development: {\n props: {\n slug: `${slug}-development`,\n domain: '',\n frontendUrl: 'http://localhost:3000',\n backendUrl: 'http://localhost:3000/api',\n backendAuthUrl: 'http://localhost:3000/api/auth',\n yjsUrl: 'ws://localhost:3000/yjs',\n mcpUrl: 'http://localhost:3000/mcp',\n oauthUrl: 'http://localhost:3000/oauth',\n // The template's shared development buckets hold the seed files and the GeoIP databases,\n // so seeded attachments render before the app has storage of its own.\n s3: \"={ region: 'nl-ams', host: 's3.nl-ams.scw.cloud', publicBucket: 'cella-shared-public', privateBucket: 'cella-shared-private' }\",\n },\n },\n staging: {\n props: {\n slug: `${slug}-staging`,\n domain: `${slug}.example.com`,\n frontendUrl: `https://staging.${slug}.example.com`,\n backendUrl: `https://staging.${slug}.example.com/api`,\n backendAuthUrl: `https://staging.${slug}.example.com/api/auth`,\n yjsUrl: `wss://staging.${slug}.example.com/yjs`,\n mcpUrl: `https://staging.${slug}.example.com/mcp`,\n oauthUrl: `https://staging.${slug}.example.com/oauth`,\n },\n },\n tunnel: {\n props: {\n slug: `${slug}-tunnel`,\n frontendUrl: `https://${slug}.ngrok.dev`,\n backendUrl: `https://${slug}.ngrok.dev/api`,\n backendAuthUrl: `https://${slug}.ngrok.dev/api/auth`,\n yjsUrl: `wss://${slug}.ngrok.dev/yjs`,\n mcpUrl: `https://${slug}.ngrok.dev/mcp`,\n oauthUrl: `https://${slug}.ngrok.dev/oauth`,\n },\n },\n test: {\n imports: \"import { development } from './config.development.ts';\\n\",\n props: {\n domain: '',\n frontendUrl: '=development.frontendUrl',\n backendUrl: '=development.backendUrl',\n backendAuthUrl: '=development.backendAuthUrl',\n yjsUrl: '=development.yjsUrl',\n mcpUrl: '=development.mcpUrl',\n oauthUrl: '=development.oauthUrl',\n // The suite covers every service and signs storage URLs, as cella's own test config has it\n services: '={ yjs: { enabled: true }, mcp: { enabled: true }, oauth: { enabled: true } }',\n s3: '=development.s3',\n },\n },\n production: { props: { maintenance: false } },\n };\n\n // Serialize value: '=' prefix → raw TS expression, boolean → literal, string → quoted\n const lit = (v: string | boolean) => {\n if (typeof v === 'boolean') return String(v);\n if (v.startsWith('=')) return v.slice(1);\n return `'${v}'`;\n };\n\n const result: Record<string, string> = {};\n\n for (const [mode, { imports = '', props }] of Object.entries(envs)) {\n const nameEntry = mode !== 'production' ? ` name: '${name} ${mode.toUpperCase()}',\\n` : '';\n const body = Object.entries(props)\n .map(([k, v]) => ` ${k}: ${lit(v)},`)\n .join('\\n');\n result[`./shared/config/config.${mode}.ts`] =\n `${header}${imports}\\nexport const ${mode} = {\\n mode: '${mode}',\\n${nameEntry}${body}\\n} satisfies DeepPartial<typeof _default>;\\n`;\n }\n\n return result;\n}\n","{\n \"name\": \"@cellajs/create-cella\",\n \"version\": \"0.4.0\",\n \"private\": false,\n \"license\": \"MIT\",\n \"description\": \"Cella is a TypeScript template to create web apps with sync and offline capabilities.\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/cellajs/create-cella\"\n },\n \"homepage\": \"https://cellajs.com\",\n \"author\": \"CellaJS <info@cellajs.com>\",\n \"engines\": {\n \"node\": \"26.x\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.js\",\n \"files\": [\n \"dist\",\n \"index.js\",\n \"README.md\"\n ],\n \"imports\": {\n \"#/*\": \"./src/*\"\n },\n \"bin\": {\n \"create-cella\": \"index.js\"\n },\n \"scripts\": {\n \"start\": \"tsx ./src/create-cella-cli.ts\",\n \"try\": \"tsx ./src/create-cella-cli.ts ../cella-try-app\",\n \"clean\": \"rimraf ./dist\",\n \"build\": \"tsup\",\n \"test-build\": \"pnpm run build && node index.js\",\n \"prepublishOnly\": \"pnpm run test:release\",\n \"check\": \"pnpm ts && pnpm biome check --write .\",\n \"ts\": \"tsgo --pretty\",\n \"lint\": \"biome check .\",\n \"lint:fix\": \"biome check --write .\",\n \"test\": \"vitest run\",\n \"test:release\": \"pnpm run build && vitest run --config vitest.release.config.ts\",\n \"test:watch\": \"vitest\",\n \"prepare\": \"lefthook install\"\n },\n \"dependencies\": {\n \"@inquirer/prompts\": \"^8.7.2\",\n \"commander\": \"^15.0.0\",\n \"ignore\": \"^7.0.11\",\n \"isomorphic-git\": \"^1.42.5\",\n \"ora\": \"^9.4.1\",\n \"picocolors\": \"^1.1.1\",\n \"validate-npm-package-name\": \"^8.0.0\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^2.5.15\",\n \"@commitlint/cli\": \"^21.2.3\",\n \"@commitlint/config-conventional\": \"^21.2.3\",\n \"@evilmartians/lefthook\": \"^2.1.15\",\n \"@types/node\": \"26.6.3\",\n \"@types/validate-npm-package-name\": \"^4.0.2\",\n \"@typescript/native-preview\": \"7.0.0-dev.20260707.2\",\n \"rimraf\": \"^6.1.3\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.23.15\",\n \"typescript\": \"6.0.3\",\n \"vitest\": \"^5.0.3\"\n },\n \"packageManager\": \"pnpm@11.28.7\",\n \"commitlint\": {\n \"extends\": [\n \"@commitlint/config-conventional\"\n ],\n \"rules\": {\n \"type-enum\": [\n 2,\n \"always\",\n [\n \"feat\",\n \"fix\",\n \"perf\",\n \"refactor\",\n \"revert\",\n \"docs\",\n \"chore\",\n \"build\",\n \"ci\",\n \"style\",\n \"test\"\n ]\n ]\n }\n }\n}\n","import { existsSync } from 'node:fs';\nimport { cp, mkdir } from 'node:fs/promises';\nimport { dirname, isAbsolute, join, relative, resolve } from 'node:path';\nimport pc from 'picocolors';\nimport { addRemote } from '#/add-remote';\nimport { TEMPLATE_URL } from '#/constants';\nimport { type CreateOptions, showSuccess } from '#/modules/cli';\nimport { cleanTemplate } from '#/utils/clean-template';\nimport { downloadGithubTemplate } from '#/utils/download-template';\nimport { gitAddAll, gitCommit, gitInit } from '#/utils/git';\nimport { listTemplateFiles } from '#/utils/list-template-files';\nimport { createProgress, pauseSpinner, resumeSpinner } from '#/utils/progress';\n\n/** Check if a path is a local directory */\nfunction isLocalPath(path: string): boolean {\n return path.startsWith('/') || path.startsWith('./') || path.startsWith('../');\n}\n\nexport async function create({\n projectName,\n targetFolder,\n packageManager,\n templateUrl,\n templateRef,\n appIndex,\n adminEmail,\n silent = false,\n}: CreateOptions): Promise<void> {\n // Save the original working directory\n const originalCwd = process.cwd();\n\n // Use custom template or default\n const template = templateUrl || TEMPLATE_URL;\n const isLocalTemplate = templateUrl && isLocalPath(templateUrl);\n\n const progress = createProgress('creating project', silent);\n\n try {\n // Create the target folder\n progress.step('creating project folder');\n await mkdir(targetFolder, { recursive: true });\n process.chdir(targetFolder);\n\n // Upstream commit the scaffold is based on (only known for remote templates). Stamped\n // as a trailer on the initial commit so the sync CLI can bootstrap the first merge-base.\n let baseSha: string | null = null;\n\n // Download or copy the template\n if (isLocalTemplate) {\n progress.step('copying local template');\n const sourcePath = resolve(originalCwd, templateUrl);\n\n // Check if target is inside source (would cause EINVAL). Use a path-boundary check\n // (not a string prefix) so siblings like `cella-try-app` next to `cella` aren't\n // misdetected as being inside the template.\n const rel = relative(sourcePath, targetFolder);\n const targetInsideTemplate = rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));\n if (targetInsideTemplate) {\n throw new Error(\n 'Cannot create project inside the template directory.\\n' +\n ` Run from outside: cd ~ && pnpm create @cellajs/cella ${projectName} --template ${templateUrl}`,\n );\n }\n\n // Copy only what git would track (respects .gitignore: no build output, no local .env secrets).\n const tracked = await listTemplateFiles(sourcePath);\n for (const rel of tracked) {\n const src = join(sourcePath, rel);\n if (!existsSync(src)) continue; // listed but deleted in the working tree\n const dest = join(targetFolder, rel);\n await mkdir(dirname(dest), { recursive: true });\n await cp(src, dest);\n }\n } else {\n // Pin to the chosen ref (release tag or commit SHA), else the default branch.\n const ref = templateRef ?? 'main';\n progress.step(`downloading cella template${templateRef ? ` (${templateRef})` : ''}`);\n baseSha = await downloadGithubTemplate(template, ref, targetFolder);\n }\n\n // Clean the template, generate configs\n progress.step('cleaning template');\n const displayName = projectName.replace(/[-_]/g, ' ').replace(/\\b\\w/g, (c) => c.toUpperCase());\n await cleanTemplate({ targetFolder, projectName, displayName, appIndex, adminEmail });\n\n // Initialize git repository. Git runs offline via isomorphic-git with an explicit\n // author, so it can't fail on missing user config — but if it fails for any other\n // reason (permissions, disk) the project files are already written and usable, so\n // warn and continue rather than aborting the whole scaffold.\n const gitFolderPath = join(targetFolder, '.git');\n if (!existsSync(gitFolderPath)) {\n try {\n progress.step('initializing git');\n await gitInit(targetFolder);\n await gitAddAll(targetFolder);\n // The `Cella-Base:` trailer records the upstream commit this scaffold snapshot was\n // taken from. The sync CLI reads it from the root commit to bootstrap the first\n // merge-base — the fork's fresh history otherwise shares no ancestor with upstream.\n const message = baseSha ? `Initial commit\\n\\nCella-Base: ${baseSha}` : 'Initial commit';\n await gitCommit(targetFolder, message);\n } catch (error) {\n if (!silent) {\n pauseSpinner();\n console.warn(`${pc.yellow('⚠')} skipped git init: ${error instanceof Error ? error.message : String(error)}`);\n resumeSpinner();\n }\n }\n }\n\n // Add upstream remote (best-effort: addRemote swallows its own failures via `silent`).\n progress.step('adding upstream remote');\n await addRemote({ targetFolder, silent: true });\n\n // Done\n progress.done(pc.bold(`created ${projectName}`));\n } catch (error) {\n progress.fail(error instanceof Error ? error.message : String(error));\n // Rethrow so callers (CLI entry, tests) see the real failure. The CLI entry\n // turns this into a non-zero exit; swallowing it here with process.exit hid\n // the underlying error from CI and vitest.\n throw error;\n }\n\n // Check if the working directory needs to be changed\n const needsCd = originalCwd !== targetFolder;\n const relativePath = relative(originalCwd, targetFolder);\n\n // Display final success message\n showSuccess(\n projectName,\n targetFolder,\n relativePath,\n needsCd,\n packageManager,\n appIndex,\n adminEmail ?? `admin@${projectName}.example.com`,\n );\n}\n","import fs from 'node:fs';\nimport git from 'isomorphic-git';\n\n/**\n * Git helpers backed by isomorphic-git (pure JS) instead of shelling out to the\n * `git` binary. This keeps `create-cella` free of `child_process` (no shell access)\n * and removes any dependency on the user's global git config — the initial commit\n * uses an explicit author, so scaffolding never fails with \"Author identity unknown\".\n */\n\n/** Author used for the scaffold's initial commit (users re-author their own commits later). */\nconst INITIAL_AUTHOR = { name: 'cella', email: 'info@cellajs.com' } as const;\n\n/**\n * Initializes a new Git repository in the specified directory.\n */\nexport async function gitInit(repoPath: string): Promise<void> {\n await git.init({ fs, dir: repoPath, defaultBranch: 'main' });\n}\n\n/**\n * Stages all files in the repository (respects `.gitignore`).\n */\nexport async function gitAddAll(repoPath: string): Promise<void> {\n await git.add({ fs, dir: repoPath, filepath: '.' });\n}\n\n/**\n * Creates a commit with the specified message and returns the commit SHA.\n */\nexport async function gitCommit(repoPath: string, message: string): Promise<string> {\n return git.commit({ fs, dir: repoPath, message, author: INITIAL_AUTHOR });\n}\n\n/**\n * Gets the URL of a remote. Throws when the remote does not exist (mirrors\n * `git remote get-url` failing) so callers can detect a missing remote.\n */\nexport async function gitRemoteGetUrl(repoPath: string, remoteName: string): Promise<string> {\n const remotes = await git.listRemotes({ fs, dir: repoPath });\n const match = remotes.find((r) => r.remote === remoteName);\n if (!match) throw new Error(`No such remote '${remoteName}'`);\n return match.url;\n}\n\n/**\n * Adds a new remote.\n */\nexport async function gitRemoteAdd(repoPath: string, remoteName: string, remoteUrl: string): Promise<void> {\n await git.addRemote({ fs, dir: repoPath, remote: remoteName, url: remoteUrl });\n}\n\n/**\n * Removes a remote.\n */\nexport async function gitRemoteRemove(repoPath: string, remoteName: string): Promise<void> {\n await git.deleteRemote({ fs, dir: repoPath, remote: remoteName });\n}\n","import { CELLA_REMOTE_NAME, CELLA_REMOTE_URL } from '#/constants';\nimport type { AddRemoteOptions } from '#/modules/cli';\nimport { gitRemoteAdd, gitRemoteGetUrl, gitRemoteRemove } from '#/utils/git';\n\n/**\n * Adds or updates the upstream remote for the Cella template.\n * @param options - Configuration options\n * @param options.silent - If true, don't throw on failure (used when called from progress tracker)\n */\nexport async function addRemote({\n targetFolder,\n remoteUrl = CELLA_REMOTE_URL,\n remoteName = CELLA_REMOTE_NAME,\n silent = false,\n}: AddRemoteOptions): Promise<void> {\n try {\n // Check if the remote exists\n let remote: string | null = null;\n\n try {\n remote = await gitRemoteGetUrl(targetFolder, remoteName);\n } catch {\n // If the remote doesn't exist, it throws a fatal error\n remote = null;\n }\n\n // Add or update the remote if it doesn't exist or differs from `remoteUrl`\n if (!remote) {\n await gitRemoteAdd(targetFolder, remoteName, remoteUrl);\n } else if (remote !== remoteUrl) {\n // Remove existing remote and set the new URL\n await gitRemoteRemove(targetFolder, remoteName);\n await gitRemoteAdd(targetFolder, remoteName, remoteUrl);\n }\n } catch (error) {\n if (!silent) {\n throw error;\n }\n }\n}\n","import { basename, resolve } from 'node:path';\nimport { Command, InvalidArgumentError } from 'commander';\nimport { NAME, VERSION } from '#/constants';\nimport { isAppIndex } from '#/utils/detect-used-ports';\nimport { isEmail } from '#/utils/is-email';\nimport { validateProjectName } from '#/utils/validate-project-name';\nimport type { CLIConfig, CLIOptions } from './types';\n\nfunction parseAppIndex(value: string): number {\n const parsed = Number(value);\n\n if (!isAppIndex(parsed)) {\n throw new InvalidArgumentError('App index must be a whole number from 0 to 9, not 4');\n }\n\n return parsed;\n}\n\nfunction parseAdminEmail(value: string): string {\n if (!isEmail(value)) throw new InvalidArgumentError('Admin email must be an address such as admin@example.com');\n return value;\n}\n\n// Initialize CLI variables\nlet directory: string | null = null;\nconst packageManager = 'pnpm';\n\n/**\n * Defines the root CLI command using Commander.\n * This command accepts CLI options and validates user input.\n */\nexport const command = new Command(NAME)\n .version(VERSION, '-v, --version', `output the current version of ${NAME}`)\n .argument('[directory]', 'the directory name for the new project')\n .usage('[directory] [options]')\n .helpOption('-h, --help', 'display this help message')\n .option('--template <path>', 'use a custom template (local path or github:user/repo)')\n .option('--app-index <number>', \"set this app's number for its dev ports (0-9, not 4)\", parseAppIndex)\n .option('--admin-email <email>', 'set the admin email for the initial seed user', parseAdminEmail)\n .action((name: string, _options: CLIOptions, self: Command) => {\n const trimmedName = typeof name === 'string' ? name.trim() : name;\n\n if (trimmedName) {\n const validation = validateProjectName(basename(resolve(trimmedName)));\n\n if (!validation.valid) {\n self.error(\n `error: invalid project name \"${trimmedName}\": ${validation.problems?.[0] ?? 'unknown error'}. Use lowercase letters, digits and dashes, such as my-app.`,\n );\n }\n\n directory = trimmedName;\n }\n })\n .parse();\n\n// Gather the CLI options and arguments\nconst options: CLIOptions = command.opts<CLIOptions>();\n\n/**\n * Runs the CLI and returns the parsed configuration.\n * This function parses command line arguments and returns the CLI config.\n */\nexport function runCli(): CLIConfig {\n return {\n options,\n args: command.args,\n directory,\n packageManager,\n };\n}\n\n// Export CLI configuration for direct import\nexport const cli: CLIConfig = runCli();\n","import { readdir, readFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\n\ninterface UsedPorts {\n project: string;\n frontend: number;\n backend: number;\n}\n\n/**\n * Scan sibling directories for existing cella apps and extract their dev ports.\n * Looks for `shared/config/config.development.ts` to identify cella-based projects.\n * `devPorts` sits in that file or in `config.default.ts`, and `devAppIndex` in the latter moves\n * whatever ports the two files carry. Handles legacy configs with backendUrl on its own port.\n */\nexport async function detectUsedPorts(targetFolder: string): Promise<UsedPorts[]> {\n const parentDir = dirname(targetFolder);\n const used: UsedPorts[] = [];\n\n let siblings: string[];\n try {\n siblings = await readdir(parentDir);\n } catch {\n return used;\n }\n\n for (const name of siblings) {\n const configDir = join(parentDir, name, 'shared/config');\n try {\n const development = await readFile(join(configDir, 'config.development.ts'), 'utf8');\n const defaults = await readFile(join(configDir, 'config.default.ts'), 'utf8').catch(() => '');\n const feMatch = development.match(/frontendUrl:\\s*'http:\\/\\/localhost:(\\d+)/);\n if (!feMatch) continue;\n const frontend = Number(feMatch[1]);\n const index = Number(defaults.match(/devAppIndex:\\s*(\\d+)/)?.[1] ?? 0);\n // Oldest forks predate devPorts and a backendUrl port; assume the paired port then.\n const apiPattern = /devPorts:\\s*\\{[^}]*?\\bapi:\\s*(\\d+)/;\n const devPortsMatch = development.match(apiPattern) ?? defaults.match(apiPattern);\n const legacyBeMatch = development.match(/backendUrl:\\s*'http:\\/\\/localhost:(\\d+)'/);\n const backend = devPortsMatch\n ? Number(devPortsMatch[1])\n : legacyBeMatch\n ? Number(legacyBeMatch[1])\n : frontend + 1000;\n used.push({ project: name, frontend: frontend + index, backend: backend + index * 10 });\n } catch {\n // Not a cella app, skip\n }\n }\n\n return used;\n}\n\n/** Index 4 is never offered: its internal listener would sit on 4045, which fetch refuses. */\nexport const isAppIndex = (index: number): boolean =>\n Number.isInteger(index) && index >= 0 && index <= 9 && index !== 4;\n\n/** Find the first app index whose frontend port and service block no sibling uses and that `isBusy` leaves free. */\nexport function findNextAppIndex(usedPorts: UsedPorts[], isBusy: (index: number) => boolean = () => false): number {\n for (let index = 0; index <= 9; index += 1) {\n if (!isAppIndex(index) || isBusy(index)) continue;\n const api = 4000 + index * 10;\n const taken = usedPorts.some((p) => p.frontend === 3000 + index || (p.backend >= api && p.backend < api + 10));\n if (!taken) return index;\n }\n return 0;\n}\n","/** A plain shape check: the value lands on one line of `backend/.env` and is the seed user's sign-in address. */\nexport const isEmail = (value: string): boolean => /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value);\n","import validate from 'validate-npm-package-name';\n\ninterface ValidationResult {\n valid: boolean;\n problems?: string[];\n}\n\nexport function validateProjectName(name: string): ValidationResult {\n const nameValidation = validate(name);\n\n if (nameValidation.validForNewPackages) {\n return { valid: true };\n }\n\n return {\n valid: false,\n problems: [...(nameValidation.errors || []), ...(nameValidation.warnings || [])],\n };\n}\n","import pc from 'picocolors';\nimport { DESCRIPTION, DIVIDER, frontendPort, getHeaderLine } from '#/constants';\n\n/** ASCII art logo for the CLI welcome screen. */\nfunction showAscii(): void {\n console.info(pc.cyan(' _ _ '));\n console.info(pc.cyan('▒▓█████▓▒ ___ ___| | | __ _ '));\n console.info(pc.cyan('▒▓█ █▓▒ / __/ _ \\\\ | |/ _` | '));\n console.info(pc.cyan('▒▓█ █▓▒ | (_| __/ | | (_| | '));\n console.info(pc.cyan('▒▓█████▓▒ \\\\___\\\\___|_|_|\\\\__,_| '));\n}\n\n/**\n * Displays the compact CLI welcome header.\n */\nexport function showWelcome(): void {\n console.info();\n showAscii();\n console.info();\n console.info(pc.dim(DESCRIPTION));\n console.info();\n console.info(getHeaderLine());\n console.info(DIVIDER);\n}\n\n/**\n * Print a cleared prompt's outcome as a persistent confirmation line:\n * `✓ <label> · <value>`, followed by a blank separator line. Used after prompts\n * that clear themselves on done so the chosen value stays visible.\n */\nexport function confirmChoice(label: string, value: string): void {\n console.info(`${pc.green('✓')} ${label} · ${value}`);\n console.info();\n}\n\n/**\n * Displays the final success message after project creation.\n */\nexport function showSuccess(\n projectName: string,\n _targetFolder: string,\n relativePath: string,\n needsCd: boolean,\n packageManager: string,\n appIndex: number,\n adminEmail: string,\n): void {\n console.info();\n\n console.info(pc.bold('Next steps'));\n console.info(DIVIDER);\n console.info();\n\n if (needsCd) {\n console.info(`${pc.dim('$')} cd ${pc.cyan(relativePath)}`);\n }\n console.info(`${pc.dim('$')} ${pc.cyan(`${packageManager} install`)}`);\n console.info(`${pc.dim('$')} ${pc.cyan(`${packageManager} generate`)}`);\n console.info(\n `${pc.dim('$')} ${pc.cyan(`${packageManager} docker`)} ${pc.dim('&&')} ${pc.cyan(`${packageManager} seed`)} ${pc.dim('&&')} ${pc.cyan(`${packageManager} dev`)}`,\n );\n console.info();\n console.info(\n `${pc.gray('Then open')} ${pc.cyan(`http://localhost:${frontendPort(appIndex)}`)} ${pc.gray('and sign in as')} ${pc.cyan(adminEmail)}${pc.gray(`: the magic link is printed in the ${packageManager} dev output.`)}`,\n );\n console.info();\n\n // Point to the generated README for first-run details and sign-in credentials. Use the\n // path relative to the new project so the terminal linkifies the right file (not this CLI's).\n const readmePath = relativePath ? `${relativePath}/README.md` : 'README.md';\n console.info(`${pc.gray('To get started building, please read:')} ${pc.cyan(readmePath)}`);\n console.info();\n console.info(`🥳 enjoy building ${pc.green(projectName)} with cella!`);\n console.info();\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport pc from 'picocolors';\nimport {\n AGENT_FILES,\n generateEnvConfigs,\n generateEnvFromExample,\n getBackendEnvReplacements,\n INITIAL_VERSION,\n PLACEHOLDER_CONFIG,\n QUICKSTART,\n quickstartToReadme,\n SYNC_CONFIG,\n setDevAppIndex,\n TO_CLEAN,\n TO_COPY,\n TO_REMOVE,\n} from '#/constants';\n\nconst warningMark = pc.yellow('⚠');\n\n/**\n * Cleans the specified template by removing designated folders and files.\n * @param params - Parameters containing the target folder, project name, and optional extra edits.\n */\nexport async function cleanTemplate({\n targetFolder,\n projectName,\n displayName,\n appIndex = 0,\n adminEmail = `admin@${projectName}.example.com`,\n}: {\n targetFolder: string;\n projectName: string;\n displayName: string;\n appIndex?: number;\n adminEmail?: string;\n}): Promise<void> {\n // Change the current working directory to targetFolder if not already set\n if (process.cwd() !== targetFolder) {\n process.chdir(targetFolder);\n }\n\n return new Promise<void>((resolve, reject) => {\n (async () => {\n try {\n // Copy specified files\n for (const [src, dest] of Object.entries(TO_COPY)) {\n const srcAbsolutePath = path.resolve(targetFolder, src);\n const destAbsolutePath = path.resolve(targetFolder, dest);\n await copyFile(srcAbsolutePath, destAbsolutePath);\n }\n\n await writeReadme(targetFolder, displayName, appIndex);\n await writeAgentEntry(targetFolder);\n\n // Replace config.default.ts with interpolated placeholder config\n await applyPlaceholderConfig(targetFolder, projectName, displayName, appIndex);\n\n // Reset release/versioning state so the fork starts under its own identity\n await resetReleaseState(targetFolder, projectName);\n\n // Drop the template's own list of downstream repos from the sync config\n await removeTemplateForks(targetFolder);\n\n // Generate backend .env from backend/.env.example.\n // The backend .env is the single source of truth for the project slug and DB ports\n // (consumed by backend/compose.yaml). There is no root .env.\n const backendReplacements = getBackendEnvReplacements(projectName, adminEmail, appIndex);\n const backendEnv = await generateEnvFromExample(\n path.resolve(targetFolder, 'backend/.env.example'),\n backendReplacements,\n );\n if (backendEnv) {\n await fs.writeFile(path.resolve(targetFolder, 'backend/.env'), backendEnv, 'utf8');\n }\n\n // Generate minimal env config files with project values baked in\n const envConfigs = generateEnvConfigs(projectName, displayName);\n await Promise.all(\n Object.entries(envConfigs).map(([filePath, content]) =>\n fs.writeFile(path.resolve(targetFolder, filePath), content, 'utf8'),\n ),\n );\n\n // Clean specified folder contents\n await Promise.all(\n TO_CLEAN.map((folderPath) => {\n const absolutePath = path.resolve(targetFolder, folderPath);\n return removeFolderContents(absolutePath);\n }),\n );\n\n // Remove specified files and folders\n await Promise.all(\n TO_REMOVE.map((filePath) => {\n const absolutePath = path.resolve(targetFolder, filePath);\n return removeFileOrFolder(absolutePath);\n }),\n );\n\n resolve();\n } catch (err) {\n reject(`Error during the cleaning process: ${err}`);\n }\n })();\n });\n}\n\n/** Write the app's README from the template's quickstart. A template without one keeps its own README. */\nasync function writeReadme(targetFolder: string, displayName: string, appIndex: number): Promise<void> {\n try {\n const quickstart = await fs.readFile(path.resolve(targetFolder, QUICKSTART), 'utf8');\n const readme = quickstartToReadme(quickstart, displayName, appIndex);\n await fs.writeFile(path.resolve(targetFolder, 'README.md'), readme, 'utf8');\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err;\n console.info(`\\n${warningMark} \"${QUICKSTART}\" not found > Skip README`);\n }\n}\n\n/** Point coding agents at the template's rules and skills, which sit in `cella/`, out of a root they would not search. */\nasync function writeAgentEntry(targetFolder: string): Promise<void> {\n await Promise.all(\n Object.entries(AGENT_FILES).map(([file, content]) =>\n fs.writeFile(path.resolve(targetFolder, file), content, 'utf8'),\n ),\n );\n\n // Local to this clone: `.claude` is gitignored, and the check scripts read tracked paths as files. AGENTS.md names the folder for a new clone.\n try {\n await fs.mkdir(path.resolve(targetFolder, '.claude'), { recursive: true });\n await fs.symlink('../cella/skills', path.resolve(targetFolder, '.claude/skills'));\n } catch (err: unknown) {\n // Windows refuses a symlink without developer mode; the skills stay readable under cella/skills\n console.info(`\\n${warningMark} skipped .claude/skills: ${err instanceof Error ? err.message : String(err)}`);\n }\n}\n\n/**\n * Removes all contents within a specified folder.\n * @param folderPath - The path of the folder to clean.\n */\nasync function removeFolderContents(folderPath: string): Promise<void> {\n // List all files in the folder. Skip silently if the folder doesn't exist —\n // the template may not include every optional folder (e.g. backend/drizzle).\n let files: string[];\n try {\n files = await fs.readdir(folderPath);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return;\n throw err;\n }\n\n // `recursive: true` handles nested folders; `force: true` ignores races/missing entries.\n await Promise.all(files.map((file) => fs.rm(path.join(folderPath, file), { recursive: true, force: true })));\n}\n\n/**\n * Removes a specified file or folder.\n * @param pathToRemove - The path to the file or folder to remove.\n */\nasync function removeFileOrFolder(pathToRemove: string): Promise<void> {\n await fs.rm(pathToRemove, { recursive: true, force: true });\n}\n\n/**\n * Helper function to copy files if the source exists.\n * @param src - The source file path.\n * @param dest - The destination file path.\n */\nasync function copyFile(src: string, dest: string): Promise<void> {\n try {\n // Check if the source file exists\n await fs.access(src);\n\n // Ensure the destination directory exists\n await fs.mkdir(path.dirname(dest), { recursive: true });\n\n // Copy the file\n await fs.copyFile(src, dest);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n console.info(`\\n${warningMark} Source file \"${src}\" does not exist > Skip copy`);\n } else {\n throw err;\n }\n }\n}\n\n/**\n * Read the fork config template shipped inside the cloned Cella template\n * (`shared/config/config.template.ts`), interpolate project tokens, write the\n * result as `shared/config/config.default.ts` — replacing the original — and\n * delete the now-consumed template from the fork.\n */\nasync function applyPlaceholderConfig(\n targetFolder: string,\n projectName: string,\n displayName: string,\n appIndex: number,\n): Promise<void> {\n const src = path.resolve(targetFolder, PLACEHOLDER_CONFIG);\n const dest = path.resolve(targetFolder, './shared/config/config.default.ts');\n\n try {\n let content = await fs.readFile(src, 'utf8');\n content = content.replaceAll('__project_name__', displayName);\n content = content.replaceAll('__project_slug__', projectName);\n content = setDevAppIndex(content, appIndex);\n await fs.writeFile(dest, content, 'utf8');\n await fs.rm(src, { force: true });\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n console.info(`\\n${warningMark} Fork config template \"${src}\" not found > Skip`);\n } else {\n throw err;\n }\n }\n}\n\n/**\n * Remove the `forks` property, and a comment line directly above it, from the source of a sync\n * config. Returns the source unchanged when it has no such property.\n */\nexport function stripForks(source: string): string {\n // The closing bracket sits at the property's own indent, or on the same line for a short list\n return source.replace(\n /^(?:[ \\t]*\\/\\/[^\\n]*\\n)?([ \\t]*)forks:\\s*\\[(?:[^\\n]*|[\\s\\S]*?\\n\\1)\\],?[ \\t]*\\n(?:[ \\t]*\\n)?/m,\n '',\n );\n}\n\n/**\n * The template's sync config lists the repos the template itself syncs to. A new app has none,\n * and the sync CLI never merges this file, so the list is removed once here.\n */\nasync function removeTemplateForks(targetFolder: string): Promise<void> {\n const configPath = path.resolve(targetFolder, SYNC_CONFIG);\n try {\n const source = await fs.readFile(configPath, 'utf8');\n const stripped = stripForks(source);\n if (stripped !== source) await fs.writeFile(configPath, stripped, 'utf8');\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n console.info(`\\n${warningMark} \"${SYNC_CONFIG}\" not found > Skip forks removal`);\n } else {\n throw err;\n }\n }\n}\n\n/**\n * Reset the upstream cella release identity so the new fork starts clean:\n * - root `package.json`: `name` → project slug, `version` → INITIAL_VERSION,\n * and blank out `license`/`repository`/`description`/`keywords`/`author`/`homepage`\n * (keys kept visible so the fork can fill in its own metadata)\n * - `.github/release-please-manifest.json` → `{ \".\": INITIAL_VERSION }`\n * - `.github/release-please-config.json`: `changelog-path` → root `CHANGELOG.md`\n * (cella tracks its own changelog in the template docs folder, which the fork\n * keeps as upstream reference; the fork's own releases write to a fresh root changelog)\n * - `CHANGELOG.md` → fresh stub\n */\nasync function resetReleaseState(targetFolder: string, projectName: string): Promise<void> {\n // Root package.json: rewrite only the top-level fields in place to avoid reformatting\n // the whole file. Set name/version to the fork's identity, then blank out the upstream\n // cella metadata (license, repository, description, keywords, author, homepage) while\n // keeping the keys visible so the fork can fill them in.\n const pkgPath = path.resolve(targetFolder, 'package.json');\n try {\n let pkg = await fs.readFile(pkgPath, 'utf8');\n pkg = pkg.replace(/^(\\s*\"name\":\\s*)\"[^\"]*\"/m, `$1\"${projectName}\"`);\n pkg = pkg.replace(/^(\\s*\"version\":\\s*)\"[^\"]*\"/m, `$1\"${INITIAL_VERSION}\"`);\n // Empty each string field, keeping the key so the fork sees the shape.\n for (const field of ['license', 'repository', 'description', 'author', 'homepage']) {\n pkg = pkg.replace(new RegExp(`^(\\\\s*\"${field}\":\\\\s*)\"[^\"]*\"`, 'm'), '$1\"\"');\n }\n // Collapse the multi-line keywords array to an empty one.\n pkg = pkg.replace(/^(\\s*\"keywords\":\\s*)\\[[^\\]]*\\]/m, '$1[]');\n await fs.writeFile(pkgPath, pkg, 'utf8');\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n console.info(`\\n${warningMark} \"package.json\" not found > Skip version reset`);\n } else {\n throw err;\n }\n }\n\n // Point release-please at a root CHANGELOG.md for the fork. The upstream Cella\n // changelog stays wherever the template keeps it; the fork's own releases live at root.\n const configPath = path.resolve(targetFolder, '.github/release-please-config.json');\n try {\n const config = JSON.parse(await fs.readFile(configPath, 'utf8')) as {\n packages?: Record<string, Record<string, unknown>>;\n };\n config.packages ??= {};\n config.packages['.'] ??= {};\n config.packages['.']['changelog-path'] = 'CHANGELOG.md';\n await fs.writeFile(configPath, `${JSON.stringify(config, null, 2)}\\n`, 'utf8');\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n console.info(`\\n${warningMark} \"release-please-config.json\" not found > Skip changelog path reset`);\n } else {\n throw err;\n }\n }\n\n // Reset the release-please manifest and changelog. `force: true` writes even if absent.\n await fs.writeFile(\n path.resolve(targetFolder, '.github/release-please-manifest.json'),\n `{\\n \".\": \"${INITIAL_VERSION}\"\\n}\\n`,\n 'utf8',\n );\n await fs.writeFile(path.resolve(targetFolder, 'CHANGELOG.md'), '# Changelog\\n', 'utf8');\n}\n","import fs from 'node:fs';\nimport { rm } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport git from 'isomorphic-git';\nimport http from 'isomorphic-git/http/node';\n\n/** Parse `github:owner/repo` or `owner/repo` into its owner and repo parts. */\nfunction parseGithubRepo(template: string): { owner: string; repo: string } {\n const [owner, repo] = template.replace(/^github:/, '').split('/');\n if (!owner || !repo) {\n throw new Error(`Invalid template '${template}'. Expected 'github:owner/repo'.`);\n }\n return { owner, repo };\n}\n\n/**\n * Clones a GitHub template into `targetFolder` using isomorphic-git (pure JS).\n *\n * A shallow, single-branch clone over HTTPS — no `git` binary, no `child_process`,\n * so `create-cella` keeps a clean supply-chain profile (no shell access). Unlike a\n * raw tarball parse, isomorphic-git reconstructs the tree itself, so file modes and\n * long paths are always correct. The cloned `.git` history is discarded afterwards;\n * scaffolding re-initialises the repo with a fresh initial commit.\n *\n * @param template - `github:owner/repo` (or `owner/repo`).\n * @param ref - Branch or tag to check out (e.g. `main` or a release tag).\n * @param targetFolder - Directory to clone the template into.\n * @returns The exact upstream commit SHA the template was scaffolded from.\n */\nexport async function downloadGithubTemplate(template: string, ref: string, targetFolder: string): Promise<string> {\n const { owner, repo } = parseGithubRepo(template);\n const url = `https://github.com/${owner}/${repo}.git`;\n\n await git.clone({ fs, http, dir: targetFolder, url, ref, singleBranch: true, depth: 1 });\n\n // Capture the exact commit the scaffold is based on before discarding history. It is\n // stamped as a `Cella-Base:` trailer on the initial commit, where the sync CLI reads it\n // to bootstrap the first merge-base (the fork shares no git history with upstream).\n const baseSha = await git.resolveRef({ fs, dir: targetFolder, ref: 'HEAD' });\n\n // Drop the cloned history — the scaffold gets its own fresh initial commit.\n await rm(join(targetFolder, '.git'), { recursive: true, force: true });\n\n return baseSha;\n}\n","import { readdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport ignore from 'ignore';\n\n/**\n * Lists the files under `root` that git would track, without shelling out to git.\n *\n * Honors the root `.gitignore` (via the `ignore` package) and always skips `.git`\n * and `node_modules`. Used for the local-template dev flow (`--template ./local`)\n * so build output and local `.env` secrets aren't copied into the new project.\n *\n * Paths are returned relative to `root` using POSIX separators.\n */\nexport async function listTemplateFiles(root: string): Promise<string[]> {\n const ig = ignore().add(['.git', 'node_modules']);\n try {\n ig.add(await readFile(join(root, '.gitignore'), 'utf8'));\n } catch {\n // No .gitignore at the template root — only the defaults above apply.\n }\n\n const files: string[] = [];\n\n async function walk(relDir: string): Promise<void> {\n const entries = await readdir(relDir ? join(root, relDir) : root, { withFileTypes: true });\n for (const entry of entries) {\n const rel = relDir ? `${relDir}/${entry.name}` : entry.name;\n // `ignore` matches directory rules when the path ends with a slash.\n if (ig.ignores(entry.isDirectory() ? `${rel}/` : rel)) continue;\n if (entry.isDirectory()) await walk(rel);\n else if (entry.isFile()) files.push(rel);\n }\n }\n\n await walk('');\n return files;\n}\n","/**\n * Progress Tracker Utility\n *\n * Provides compact progress tracking for CLI operations.\n * Uses a single spinner that updates in place.\n */\n\nimport ora, { type Ora } from 'ora';\nimport pc from 'picocolors';\n\n/** Global reference to the currently active spinner */\nlet activeSpinner: Ora | null = null;\n\n/** Pause the active spinner (for interactive prompts) */\nexport function pauseSpinner(): void {\n if (activeSpinner) {\n activeSpinner.stop();\n }\n}\n\n/** Resume the active spinner after a prompt */\nexport function resumeSpinner(): void {\n if (activeSpinner) {\n activeSpinner.start();\n }\n}\n\nexport interface ProgressTracker {\n /** Update the current step (shown as spinner text) */\n step: (message: string) => void;\n /** Mark the tracker as complete with final message */\n done: (message: string) => void;\n /** Mark the tracker as failed with error message */\n fail: (message: string) => void;\n}\n\n/**\n * Creates a progress tracker for a multi-step operation.\n * Shows a single spinner that updates in place.\n *\n * @param title - The initial title for the spinner\n * @returns A ProgressTracker instance\n *\n * @example\n * const progress = createProgress('creating project');\n * progress.step('downloading template');\n * progress.step('installing dependencies');\n * progress.done('project created');\n */\nexport function createProgress(title: string, silent = false): ProgressTracker {\n const completedSteps: string[] = [];\n\n const spinner = ora({\n text: title,\n isSilent: silent,\n });\n\n activeSpinner = spinner;\n spinner.start();\n\n // Helper to log (respects silent mode)\n const log = (msg: string) => {\n if (!silent) console.info(msg);\n };\n\n return {\n step: (message: string) => {\n // Complete previous step with green check if there was one\n if (completedSteps.length > 0) {\n spinner.stop();\n log(`${pc.green('✓')} ${completedSteps[completedSteps.length - 1]}`);\n }\n completedSteps.push(message);\n spinner.text = message;\n spinner.start();\n },\n\n done: (message: string) => {\n // Complete the last step with green check\n if (completedSteps.length > 0) {\n spinner.stop();\n log(`${pc.green('✓')} ${completedSteps[completedSteps.length - 1]}`);\n } else {\n spinner.stop();\n }\n activeSpinner = null;\n if (message) {\n log('');\n log(`${pc.green('✓')} ${message}`);\n }\n },\n\n fail: (message: string) => {\n spinner.stop();\n activeSpinner = null;\n log(`${pc.red('✗')} ${pc.red(message)}`);\n },\n };\n}\n","import { connect } from 'node:net';\n\nconst SERVICE_PORTS = 7;\n\n/** Every local port an app number takes: the frontend, its service block, and the dev and test databases. */\nconst appPorts = (appIndex: number): number[] => [\n 3000 + appIndex,\n ...Array.from({ length: SERVICE_PORTS }, (_, i) => 4000 + appIndex * 10 + i),\n 5432 + appIndex * 10,\n 5434 + appIndex * 10,\n];\n\n/** Whether something on this machine accepts a connection on the port. */\nconst isListening = (port: number): Promise<boolean> =>\n new Promise((resolve) => {\n const socket = connect({ port, host: '127.0.0.1', timeout: 300 });\n const finish = (listening: boolean) => {\n socket.destroy();\n resolve(listening);\n };\n socket.once('connect', () => finish(true));\n socket.once('timeout', () => finish(false));\n socket.once('error', () => finish(false));\n });\n\n/** The ports of an app number that are already taken, lowest first. */\nexport async function findBusyPorts(appIndex: number): Promise<number[]> {\n const ports = appPorts(appIndex);\n const listening = await Promise.all(ports.map(isListening));\n return ports.filter((_, i) => listening[i]);\n}\n","/**\n * Fetch lightweight metadata about the cella template so the scaffolder can offer\n * \"latest release\" vs \"latest commit\" as a starting point.\n *\n * The release tag is read from the template's git tags, over the transport the clone uses, so\n * it does not depend on the GitHub API and its limit for callers without a token. Dates and the\n * commit subject come from that API. Every helper fails soft; the caller falls back to the\n * default branch when no release is known.\n */\nimport git from 'isomorphic-git';\nimport http from 'isomorphic-git/http/node';\nimport { TEMPLATE_GIT_URL, TEMPLATE_REPOSITORY } from '#/constants';\n\nconst TEMPLATE_METADATA_API_BASE = `https://api.github.com/repos/${TEMPLATE_REPOSITORY}`;\n\n/** Format an ISO timestamp as a locale-independent YYYY-MM-DD date. */\nfunction toDate(iso?: string): string {\n return iso ? iso.slice(0, 10) : 'unknown';\n}\n\nconst GITHUB_HEADERS = { Accept: 'application/vnd.github+json' } as const;\n\nexport interface ReleaseInfo {\n /** Release tag, e.g. '0.18.1' */\n tag: string;\n /** Publication date, YYYY-MM-DD; absent when the GitHub API did not answer */\n date?: string;\n}\n\nexport interface CommitInfo {\n /** Full commit SHA (used for a reproducible checkout) */\n sha: string;\n /** Short 7-char SHA for display */\n shortSha: string;\n /** First line of the commit message */\n message: string;\n /** Commit date, YYYY-MM-DD */\n date: string;\n}\n\n/**\n * Pick the latest template release from tag names: the highest plain version, with or without\n * the `v` prefix. Tags of another series (`create-cella-0.2.3`, `archive/pre-release`) and\n * pre-releases are no template release.\n */\nexport function pickLatestReleaseTag(tags: string[]): string | null {\n let latest: { tag: string; version: number[] } | null = null;\n for (const tag of tags) {\n const match = /^v?(\\d+)\\.(\\d+)\\.(\\d+)$/.exec(tag);\n if (!match) continue;\n const version = match.slice(1).map(Number);\n if (!latest || isNewer(version, latest.version)) latest = { tag, version };\n }\n return latest?.tag ?? null;\n}\n\n/** Whether version `a` is higher than `b`, both as [major, minor, patch]. */\nfunction isNewer(a: number[], b: number[]): boolean {\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return a[i] > b[i];\n }\n return false;\n}\n\n/** Fetch the latest template release: its tag from the git tags, its date from the GitHub API. */\nexport async function fetchLatestRelease(): Promise<ReleaseInfo | null> {\n let tag: string | null;\n try {\n const refs = await git.listServerRefs({ http, url: TEMPLATE_GIT_URL, prefix: 'refs/tags/' });\n tag = pickLatestReleaseTag(refs.map(({ ref }) => ref.slice('refs/tags/'.length)));\n } catch {\n return null;\n }\n if (!tag) return null;\n\n return { tag, date: await fetchReleaseDate(tag) };\n}\n\n/** Publication date of a release, undefined when the GitHub API does not answer. */\nasync function fetchReleaseDate(tag: string): Promise<string | undefined> {\n try {\n const response = await fetch(`${TEMPLATE_METADATA_API_BASE}/releases/tags/${tag}`, { headers: GITHUB_HEADERS });\n if (!response.ok) return undefined;\n\n const release = (await response.json()) as { published_at?: string };\n return release.published_at ? toDate(release.published_at) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Fetch the latest commit on a branch (defaults to 'main'). */\nexport async function fetchLatestCommit(branch = 'main'): Promise<CommitInfo | null> {\n const apiUrl = `${TEMPLATE_METADATA_API_BASE}/commits/${branch}`;\n\n try {\n const response = await fetch(apiUrl, { headers: GITHUB_HEADERS });\n if (!response.ok) return null;\n\n const data = (await response.json()) as {\n sha?: string;\n commit?: { message?: string; author?: { date?: string } };\n };\n if (!data.sha) return null;\n\n const message = (data.commit?.message ?? '').split('\\n')[0];\n return { sha: data.sha, shortSha: data.sha.slice(0, 7), message, date: toDate(data.commit?.author?.date) };\n } catch {\n return null;\n }\n}\n","import { readdir } from 'node:fs/promises';\n\n/**\n * Checks if a directory is empty or only contains a .git directory.\n *\n * @param path - The path of the directory to check.\n * @returns Resolves to true if the directory is empty or contains only a .git folder, false otherwise.\n * @throws Throws an error if the path is not a directory or if there's an issue reading the directory.\n */\nexport async function isEmptyDirectory(path: string): Promise<boolean> {\n const files = await readdir(path);\n\n // Check if directory is empty or contains only the .git directory\n return files.length === 0 || (files.length === 1 && files[0] === '.git');\n}\n"],"mappings":";;;AAEA,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,MAAAC,WAAU;AACnB,SAAS,YAAAC,WAAU,WAAAC,gBAAe;AAClC,SAAS,OAAO,cAAc;AAC9B,OAAOC,SAAQ;;;ACNf,OAAO,QAAQ;;;ACAf;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,SAAW;AAAA,EACX,SAAW;AAAA,EACX,aAAe;AAAA,EACf,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,QAAU;AAAA,EACV,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,IACT,OAAO;AAAA,EACT;AAAA,EACA,KAAO;AAAA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,CAAC,GAAG,OAAO,EAAE,EAAE;AAAA,QACnF,EAAE,MAAM,gBAAgB,OAAO,GAAG;AAAA,MACpC;AAAA,IACF;AAAA,IACA;AAAA,EACF;AAEA,MAAI,WAAW,GAAI,QAAO;AAE1B,QAAM,SAAS,MAAM;AAAA,IACnB;AAAA,MACE,SAAS;AAAA,MACT,SAAS,OAAO,SAAS;AAAA,MACzB;AAAA,MACA,UAAU,CAAC,QAAS,WAAW,OAAO,GAAG,CAAC,IAAI,OAAO;AAAA,IACvD;AAAA,IACA;AAAA,EACF;AACA,SAAO,OAAO,MAAM;AACtB;","names":["existsSync","rm","basename","resolve","pc","readFile","dirname","join","resolve","pc","pc","pc","packageManager","fs","pc","pc","resolve","fs","fs","join","git","readdir","readFile","join","pc","path","packageManager","resolve","rel","join","dirname","pc","resolve","git","http","git","http","readdir","path","basename","resolve","existsSync","rm","pc"]}
|