create-innovator 0.3.2 → 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/dist/cli.js +57 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { readFileSync } from "fs";
|
|
5
5
|
import { defineCommand, runMain } from "citty";
|
|
6
6
|
import logo from "cli-ascii-logo";
|
|
7
|
-
import { intro, text, isCancel as isCancel3, outro, log } from "@clack/prompts";
|
|
7
|
+
import { intro, text, isCancel as isCancel3, outro, log as log2 } from "@clack/prompts";
|
|
8
8
|
|
|
9
9
|
// src/auth/github.ts
|
|
10
10
|
import { Octokit } from "@octokit/rest";
|
|
@@ -252,7 +252,7 @@ async function cloneTemplate(name, tag) {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
// src/scaffold/template.ts
|
|
255
|
-
import { readFile as readFile2, writeFile as writeFile2, readdir } from "fs/promises";
|
|
255
|
+
import { readFile as readFile2, writeFile as writeFile2, readdir, rm } from "fs/promises";
|
|
256
256
|
import { join as join2, relative } from "path";
|
|
257
257
|
import * as p4 from "@clack/prompts";
|
|
258
258
|
import { toCamelCase as toCamelCase2, toTitleCase } from "remeda";
|
|
@@ -301,6 +301,58 @@ async function replaceTemplateNames(dir, projectName) {
|
|
|
301
301
|
}
|
|
302
302
|
s.stop(`Replaced template names in ${replacedCount} file(s)`);
|
|
303
303
|
}
|
|
304
|
+
var TEMPLATE_FILES_TO_REMOVE = ["changelog.md", "claude.md", "readme.md"];
|
|
305
|
+
async function removeTemplateFiles(dir) {
|
|
306
|
+
const s = p4.spinner();
|
|
307
|
+
s.start("Removing template files");
|
|
308
|
+
const allFiles = await readdir(dir);
|
|
309
|
+
const filesToRemove = allFiles.filter((f) => TEMPLATE_FILES_TO_REMOVE.includes(f.toLowerCase()));
|
|
310
|
+
for (const file of filesToRemove) {
|
|
311
|
+
await rm(join2(dir, file));
|
|
312
|
+
}
|
|
313
|
+
s.stop(`Removed ${filesToRemove.length} template file(s)`);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/scaffold/setup.ts
|
|
317
|
+
import { execFile as execFileCb2 } from "child_process";
|
|
318
|
+
import { promisify as promisify2 } from "util";
|
|
319
|
+
import * as p5 from "@clack/prompts";
|
|
320
|
+
var execFile2 = promisify2(execFileCb2);
|
|
321
|
+
async function setupProject(projectName) {
|
|
322
|
+
const s = p5.spinner();
|
|
323
|
+
try {
|
|
324
|
+
s.start("Checking pnpm availability");
|
|
325
|
+
try {
|
|
326
|
+
await execFile2("pnpm", ["--version"]);
|
|
327
|
+
} catch {
|
|
328
|
+
s.message("Enabling corepack");
|
|
329
|
+
await execFile2("corepack", ["enable"]);
|
|
330
|
+
}
|
|
331
|
+
s.stop("pnpm is available");
|
|
332
|
+
s.start("Installing dependencies");
|
|
333
|
+
await execFile2("pnpm", ["install"], { cwd: projectName });
|
|
334
|
+
s.stop("Dependencies installed");
|
|
335
|
+
s.start("Updating test snapshots");
|
|
336
|
+
await execFile2("pnpm", ["test", "-u"], { cwd: projectName });
|
|
337
|
+
s.stop("Test snapshots updated");
|
|
338
|
+
s.start("Creating initial commit");
|
|
339
|
+
await execFile2("git", ["add", "."], { cwd: projectName });
|
|
340
|
+
await execFile2("git", ["commit", "--no-verify", "-m", `feat(${projectName}): initial commit`], {
|
|
341
|
+
cwd: projectName
|
|
342
|
+
});
|
|
343
|
+
s.stop("Initial commit created");
|
|
344
|
+
} catch {
|
|
345
|
+
s.stop("Setup incomplete");
|
|
346
|
+
p5.log.warn("Automatic setup failed. Run these commands manually:");
|
|
347
|
+
p5.log.info(
|
|
348
|
+
` cd ${projectName}
|
|
349
|
+
corepack enable
|
|
350
|
+
pnpm install
|
|
351
|
+
pnpm test -u
|
|
352
|
+
git add . && git commit --no-verify -m "feat(${projectName}): initial commit"`
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
304
356
|
|
|
305
357
|
// src/cli.ts
|
|
306
358
|
var pkgUrl = new URL("../package.json", import.meta.url);
|
|
@@ -344,10 +396,12 @@ var main = defineCommand({
|
|
|
344
396
|
const tag = await selectVersion(token, args.experimental);
|
|
345
397
|
await cloneTemplate(projectName, tag);
|
|
346
398
|
await replaceTemplateNames(projectName, projectName);
|
|
399
|
+
await removeTemplateFiles(projectName);
|
|
347
400
|
} catch (error) {
|
|
348
|
-
|
|
401
|
+
log2.error(error instanceof Error ? error.message : "Scaffolding failed.");
|
|
349
402
|
process.exit(1);
|
|
350
403
|
}
|
|
404
|
+
await setupProject(projectName);
|
|
351
405
|
outro(`Project ${projectName} is ready!`);
|
|
352
406
|
}
|
|
353
407
|
});
|