create-bunspace 0.3.0 → 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/bin.js +237 -34
- package/dist/templates/fumadocs/MUST-FOLLOW-GUIDELINES.md +1496 -33
- package/dist/templates/monorepo/MUST-FOLLOW-GUIDELINES.md +1496 -33
- package/dist/templates/monorepo/apps/example/package.json +1 -1
- package/dist/templates/monorepo/core/packages/utils/rolldown.config.ts +30 -0
- package/dist/templates/monorepo/tsconfig.json +3 -1
- package/dist/templates/telegram-bot/MUST-FOLLOW-GUIDELINES.md +1732 -0
- package/dist/templates/telegram-bot/bun.lock +6 -20
- package/dist/templates/telegram-bot/core/package.json +11 -0
- package/dist/templates/telegram-bot/core/rolldown.config.ts +11 -0
- package/dist/templates/telegram-bot/core/src/config/logging.ts +1 -3
- package/dist/templates/telegram-bot/core/src/handlers/config-export.ts +10 -9
- package/dist/templates/telegram-bot/core/src/handlers/control.ts +30 -21
- package/dist/templates/telegram-bot/core/src/handlers/demo-full.ts +58 -0
- package/dist/templates/telegram-bot/core/src/handlers/demo-keyboard.ts +49 -0
- package/dist/templates/telegram-bot/core/src/handlers/demo-media.ts +163 -0
- package/dist/templates/telegram-bot/core/src/handlers/demo-text.ts +27 -0
- package/dist/templates/telegram-bot/core/src/handlers/health.ts +22 -14
- package/dist/templates/telegram-bot/core/src/handlers/info.ts +21 -23
- package/dist/templates/telegram-bot/core/src/handlers/logs.ts +8 -6
- package/dist/templates/telegram-bot/core/src/index.ts +20 -1
- package/dist/templates/telegram-bot/core/src/utils/formatters.ts +5 -60
- package/dist/templates/telegram-bot/core/tsconfig.json +2 -0
- package/dist/templates/telegram-bot/package.json +3 -2
- package/dist/templates/telegram-bot/packages/utils/package.json +12 -1
- package/dist/templates/telegram-bot/packages/utils/rolldown.config.ts +11 -0
- package/dist/templates/telegram-bot/packages/utils/tsconfig.json +10 -0
- package/dist/templates/telegram-bot/tsconfig.json +7 -2
- package/package.json +6 -3
- package/templates/fumadocs/MUST-FOLLOW-GUIDELINES.md +1496 -33
- package/templates/monorepo/MUST-FOLLOW-GUIDELINES.md +1496 -33
- package/templates/monorepo/apps/example/package.json +1 -1
- package/templates/monorepo/core/packages/utils/rolldown.config.ts +30 -0
- package/templates/monorepo/tsconfig.json +3 -1
- package/templates/telegram-bot/MUST-FOLLOW-GUIDELINES.md +1732 -0
- package/templates/telegram-bot/bun.lock +6 -20
- package/templates/telegram-bot/core/package.json +11 -0
- package/templates/telegram-bot/core/rolldown.config.ts +11 -0
- package/templates/telegram-bot/core/src/config/logging.ts +1 -3
- package/templates/telegram-bot/core/src/handlers/config-export.ts +10 -9
- package/templates/telegram-bot/core/src/handlers/control.ts +30 -21
- package/templates/telegram-bot/core/src/handlers/demo-full.ts +58 -0
- package/templates/telegram-bot/core/src/handlers/demo-keyboard.ts +49 -0
- package/templates/telegram-bot/core/src/handlers/demo-media.ts +163 -0
- package/templates/telegram-bot/core/src/handlers/demo-text.ts +27 -0
- package/templates/telegram-bot/core/src/handlers/health.ts +22 -14
- package/templates/telegram-bot/core/src/handlers/info.ts +21 -23
- package/templates/telegram-bot/core/src/handlers/logs.ts +8 -6
- package/templates/telegram-bot/core/src/index.ts +20 -1
- package/templates/telegram-bot/core/src/utils/formatters.ts +5 -60
- package/templates/telegram-bot/core/tsconfig.json +2 -0
- package/templates/telegram-bot/package.json +3 -2
- package/templates/telegram-bot/packages/utils/package.json +12 -1
- package/templates/telegram-bot/packages/utils/rolldown.config.ts +11 -0
- package/templates/telegram-bot/packages/utils/tsconfig.json +10 -0
- package/templates/telegram-bot/tsconfig.json +7 -2
- package/templates/telegram-bot/core/src/utils/message-builder.ts +0 -180
package/dist/bin.js
CHANGED
|
@@ -5516,9 +5516,170 @@ async function getDefaults(args, templateType) {
|
|
|
5516
5516
|
}
|
|
5517
5517
|
|
|
5518
5518
|
// src/generator.ts
|
|
5519
|
-
import { mkdir, readdir, stat, readFile, writeFile, copyFile, rename } from "fs/promises";
|
|
5520
|
-
import { join, dirname } from "path";
|
|
5519
|
+
import { mkdir, readdir, stat as stat2, readFile as readFile2, writeFile as writeFile2, copyFile, rename } from "fs/promises";
|
|
5520
|
+
import { join as join2, dirname } from "path";
|
|
5521
|
+
import { existsSync as existsSync2 } from "fs";
|
|
5522
|
+
|
|
5523
|
+
// src/guidelines-service.ts
|
|
5521
5524
|
import { existsSync } from "fs";
|
|
5525
|
+
import { readFile, writeFile } from "fs/promises";
|
|
5526
|
+
import { join } from "path";
|
|
5527
|
+
import { homedir } from "os";
|
|
5528
|
+
var LOCAL_DOTFILES_PATH = join(homedir(), "dotfiles", "MUST-FOLLOW-GUIDELINES.md");
|
|
5529
|
+
var GITHUB_RAW_URL = "https://raw.githubusercontent.com/MKS2508/dotfiles/main/MUST-FOLLOW-GUIDELINES.md";
|
|
5530
|
+
var GUIDELINES_FILENAME = "MUST-FOLLOW-GUIDELINES.md";
|
|
5531
|
+
async function fetchGuidelines() {
|
|
5532
|
+
if (existsSync(LOCAL_DOTFILES_PATH)) {
|
|
5533
|
+
try {
|
|
5534
|
+
const content = await readFile(LOCAL_DOTFILES_PATH, "utf-8");
|
|
5535
|
+
const lines = content.split(`
|
|
5536
|
+
`).length;
|
|
5537
|
+
return { content, source: "local", lines };
|
|
5538
|
+
} catch {
|
|
5539
|
+
console.log(kleur_default.yellow(" \u26A0\uFE0F Failed to read local dotfiles, trying GitHub..."));
|
|
5540
|
+
}
|
|
5541
|
+
}
|
|
5542
|
+
try {
|
|
5543
|
+
const response = await fetch(GITHUB_RAW_URL);
|
|
5544
|
+
if (response.ok) {
|
|
5545
|
+
const content = await response.text();
|
|
5546
|
+
const lines = content.split(`
|
|
5547
|
+
`).length;
|
|
5548
|
+
return { content, source: "github", lines };
|
|
5549
|
+
}
|
|
5550
|
+
} catch {}
|
|
5551
|
+
return null;
|
|
5552
|
+
}
|
|
5553
|
+
async function getGuidelinesForGeneration() {
|
|
5554
|
+
const result = await fetchGuidelines();
|
|
5555
|
+
return result?.content ?? null;
|
|
5556
|
+
}
|
|
5557
|
+
async function syncGuidelinesToTemplate(templatePath, templateName, guidelinesContent) {
|
|
5558
|
+
const guidelinesPath = join(templatePath, GUIDELINES_FILENAME);
|
|
5559
|
+
const linesCount = guidelinesContent.split(`
|
|
5560
|
+
`).length;
|
|
5561
|
+
if (!existsSync(templatePath)) {
|
|
5562
|
+
return {
|
|
5563
|
+
templateName,
|
|
5564
|
+
success: false,
|
|
5565
|
+
action: "skipped",
|
|
5566
|
+
error: "Template directory not found"
|
|
5567
|
+
};
|
|
5568
|
+
}
|
|
5569
|
+
try {
|
|
5570
|
+
if (existsSync(guidelinesPath)) {
|
|
5571
|
+
const existingContent = await readFile(guidelinesPath, "utf-8");
|
|
5572
|
+
if (existingContent === guidelinesContent) {
|
|
5573
|
+
return {
|
|
5574
|
+
templateName,
|
|
5575
|
+
success: true,
|
|
5576
|
+
action: "unchanged",
|
|
5577
|
+
linesCount
|
|
5578
|
+
};
|
|
5579
|
+
}
|
|
5580
|
+
await writeFile(guidelinesPath, guidelinesContent, "utf-8");
|
|
5581
|
+
return {
|
|
5582
|
+
templateName,
|
|
5583
|
+
success: true,
|
|
5584
|
+
action: "updated",
|
|
5585
|
+
linesCount
|
|
5586
|
+
};
|
|
5587
|
+
}
|
|
5588
|
+
await writeFile(guidelinesPath, guidelinesContent, "utf-8");
|
|
5589
|
+
return {
|
|
5590
|
+
templateName,
|
|
5591
|
+
success: true,
|
|
5592
|
+
action: "created",
|
|
5593
|
+
linesCount
|
|
5594
|
+
};
|
|
5595
|
+
} catch (error) {
|
|
5596
|
+
return {
|
|
5597
|
+
templateName,
|
|
5598
|
+
success: false,
|
|
5599
|
+
action: "skipped",
|
|
5600
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
5601
|
+
};
|
|
5602
|
+
}
|
|
5603
|
+
}
|
|
5604
|
+
async function syncGuidelinesToAllTemplates(templatesDir, templateNames) {
|
|
5605
|
+
const guidelines = await fetchGuidelines();
|
|
5606
|
+
if (!guidelines) {
|
|
5607
|
+
console.log(kleur_default.yellow(`
|
|
5608
|
+
\u26A0\uFE0F Guidelines not available (no local dotfiles or internet)`));
|
|
5609
|
+
return templateNames.map((name) => ({
|
|
5610
|
+
templateName: name,
|
|
5611
|
+
success: false,
|
|
5612
|
+
action: "skipped",
|
|
5613
|
+
error: "Guidelines source unavailable"
|
|
5614
|
+
}));
|
|
5615
|
+
}
|
|
5616
|
+
console.log(`
|
|
5617
|
+
\uD83D\uDCCB Syncing ${kleur_default.cyan(GUIDELINES_FILENAME)} from ${kleur_default.dim(guidelines.source)}...`);
|
|
5618
|
+
console.log(` ${kleur_default.dim(`(${guidelines.lines} lines)`)}
|
|
5619
|
+
`);
|
|
5620
|
+
const results = [];
|
|
5621
|
+
for (const name of templateNames) {
|
|
5622
|
+
const templatePath = join(templatesDir, name);
|
|
5623
|
+
const result = await syncGuidelinesToTemplate(templatePath, name, guidelines.content);
|
|
5624
|
+
results.push(result);
|
|
5625
|
+
const icon = result.success ? result.action === "unchanged" ? "\u2713" : "\u2705" : "\u274C";
|
|
5626
|
+
const actionText = result.action === "created" ? kleur_default.green("created") : result.action === "updated" ? kleur_default.yellow("updated") : result.action === "unchanged" ? kleur_default.dim("unchanged") : kleur_default.red("skipped");
|
|
5627
|
+
console.log(` ${icon} ${kleur_default.cyan(name)}: ${actionText}${result.error ? ` - ${result.error}` : ""}`);
|
|
5628
|
+
}
|
|
5629
|
+
return results;
|
|
5630
|
+
}
|
|
5631
|
+
async function checkGuidelinesStatus(templatesDir, templateNames) {
|
|
5632
|
+
console.log(`
|
|
5633
|
+
\uD83D\uDCCB ${kleur_default.bold("Guidelines Status Check")}
|
|
5634
|
+
`);
|
|
5635
|
+
const guidelines = await fetchGuidelines();
|
|
5636
|
+
if (guidelines) {
|
|
5637
|
+
console.log(` ${kleur_default.green("\u2713")} Source: ${kleur_default.cyan(guidelines.source)}`);
|
|
5638
|
+
console.log(` ${kleur_default.green("\u2713")} Lines: ${kleur_default.cyan(guidelines.lines.toString())}`);
|
|
5639
|
+
if (guidelines.source === "local") {
|
|
5640
|
+
console.log(` ${kleur_default.dim(` Path: ${LOCAL_DOTFILES_PATH}`)}`);
|
|
5641
|
+
} else {
|
|
5642
|
+
console.log(` ${kleur_default.dim(` URL: ${GITHUB_RAW_URL}`)}`);
|
|
5643
|
+
}
|
|
5644
|
+
} else {
|
|
5645
|
+
console.log(` ${kleur_default.red("\u2717")} Guidelines unavailable`);
|
|
5646
|
+
console.log(` ${kleur_default.dim(` Local: ${LOCAL_DOTFILES_PATH} (not found)`)}`);
|
|
5647
|
+
console.log(` ${kleur_default.dim(` GitHub: ${GITHUB_RAW_URL} (unreachable)`)}`);
|
|
5648
|
+
return;
|
|
5649
|
+
}
|
|
5650
|
+
console.log(`
|
|
5651
|
+
${kleur_default.bold("Template Status:")}
|
|
5652
|
+
`);
|
|
5653
|
+
for (const name of templateNames) {
|
|
5654
|
+
const templatePath = join(templatesDir, name);
|
|
5655
|
+
const guidelinesPath = join(templatePath, GUIDELINES_FILENAME);
|
|
5656
|
+
if (!existsSync(templatePath)) {
|
|
5657
|
+
console.log(` ${kleur_default.red("\u2717")} ${kleur_default.cyan(name)}: ${kleur_default.dim("template not found")}`);
|
|
5658
|
+
continue;
|
|
5659
|
+
}
|
|
5660
|
+
if (!existsSync(guidelinesPath)) {
|
|
5661
|
+
console.log(` ${kleur_default.yellow("\u26A0")} ${kleur_default.cyan(name)}: ${kleur_default.yellow("missing")}`);
|
|
5662
|
+
continue;
|
|
5663
|
+
}
|
|
5664
|
+
try {
|
|
5665
|
+
const content = await readFile(guidelinesPath, "utf-8");
|
|
5666
|
+
const templateLines = content.split(`
|
|
5667
|
+
`).length;
|
|
5668
|
+
const isUpToDate = content === guidelines.content;
|
|
5669
|
+
if (isUpToDate) {
|
|
5670
|
+
console.log(` ${kleur_default.green("\u2713")} ${kleur_default.cyan(name)}: ${kleur_default.green("up to date")} (${templateLines} lines)`);
|
|
5671
|
+
} else {
|
|
5672
|
+
console.log(` ${kleur_default.yellow("\u26A0")} ${kleur_default.cyan(name)}: ${kleur_default.yellow("outdated")} (${templateLines} lines vs ${guidelines.lines})`);
|
|
5673
|
+
}
|
|
5674
|
+
} catch {
|
|
5675
|
+
console.log(` ${kleur_default.red("\u2717")} ${kleur_default.cyan(name)}: ${kleur_default.red("error reading file")}`);
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5678
|
+
console.log("");
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5681
|
+
// src/generator.ts
|
|
5682
|
+
var GUIDELINES_FILENAME2 = "MUST-FOLLOW-GUIDELINES.md";
|
|
5522
5683
|
var TEXT_EXTENSIONS = new Set([
|
|
5523
5684
|
".ts",
|
|
5524
5685
|
".tsx",
|
|
@@ -5557,12 +5718,12 @@ var EXCLUDED_FILES = new Set([
|
|
|
5557
5718
|
".DS_Store"
|
|
5558
5719
|
]);
|
|
5559
5720
|
async function getTemplateDir(templateType) {
|
|
5560
|
-
const submodulePath =
|
|
5561
|
-
if (
|
|
5721
|
+
const submodulePath = join2(import.meta.dir, "..", "templates", templateType);
|
|
5722
|
+
if (existsSync2(submodulePath)) {
|
|
5562
5723
|
return submodulePath;
|
|
5563
5724
|
}
|
|
5564
|
-
const distPath =
|
|
5565
|
-
if (
|
|
5725
|
+
const distPath = join2(import.meta.dir, "..", "..", "templates", templateType);
|
|
5726
|
+
if (existsSync2(distPath)) {
|
|
5566
5727
|
return distPath;
|
|
5567
5728
|
}
|
|
5568
5729
|
throw new Error(`Template '${templateType}' not found. Checked submodules and embedded templates.`);
|
|
@@ -5570,7 +5731,7 @@ async function getTemplateDir(templateType) {
|
|
|
5570
5731
|
async function generateProject(config, templateType) {
|
|
5571
5732
|
const templateDir = await getTemplateDir(templateType);
|
|
5572
5733
|
const targetDir = config.targetDir;
|
|
5573
|
-
if (
|
|
5734
|
+
if (existsSync2(targetDir)) {
|
|
5574
5735
|
const entries = await readdir(targetDir);
|
|
5575
5736
|
if (entries.length > 0) {
|
|
5576
5737
|
printError(`Directory ${targetDir} is not empty`);
|
|
@@ -5583,12 +5744,23 @@ async function generateProject(config, templateType) {
|
|
|
5583
5744
|
printStep("Copying template files...");
|
|
5584
5745
|
await copyTemplateDir(templateDir, targetDir, placeholders);
|
|
5585
5746
|
if (templateType === "fumadocs") {
|
|
5586
|
-
const contentTemplatePath =
|
|
5587
|
-
const contentPath =
|
|
5588
|
-
if (
|
|
5747
|
+
const contentTemplatePath = join2(targetDir, "content-template");
|
|
5748
|
+
const contentPath = join2(targetDir, "content");
|
|
5749
|
+
if (existsSync2(contentTemplatePath)) {
|
|
5589
5750
|
await rename(contentTemplatePath, contentPath);
|
|
5590
5751
|
}
|
|
5591
5752
|
}
|
|
5753
|
+
printStep("Syncing MUST-FOLLOW-GUIDELINES.md...");
|
|
5754
|
+
const guidelinesContent = await getGuidelinesForGeneration();
|
|
5755
|
+
if (guidelinesContent) {
|
|
5756
|
+
const guidelinesPath = join2(targetDir, GUIDELINES_FILENAME2);
|
|
5757
|
+
await writeFile2(guidelinesPath, guidelinesContent, "utf-8");
|
|
5758
|
+
const lines = guidelinesContent.split(`
|
|
5759
|
+
`).length;
|
|
5760
|
+
printStep(`Guidelines synced (${lines} lines)`);
|
|
5761
|
+
} else {
|
|
5762
|
+
printStep("Guidelines source unavailable, using template version");
|
|
5763
|
+
}
|
|
5592
5764
|
if (config.initGit) {
|
|
5593
5765
|
printStep("Initializing git repository...");
|
|
5594
5766
|
await initGit(targetDir);
|
|
@@ -5638,9 +5810,9 @@ async function copyTemplateDir(src, dest, placeholders) {
|
|
|
5638
5810
|
for (const entry of entries) {
|
|
5639
5811
|
if (EXCLUDED_FILES.has(entry))
|
|
5640
5812
|
continue;
|
|
5641
|
-
const srcPath =
|
|
5642
|
-
const destPath =
|
|
5643
|
-
const stats = await
|
|
5813
|
+
const srcPath = join2(src, entry);
|
|
5814
|
+
const destPath = join2(dest, entry);
|
|
5815
|
+
const stats = await stat2(srcPath);
|
|
5644
5816
|
if (stats.isDirectory()) {
|
|
5645
5817
|
await mkdir(destPath, { recursive: true });
|
|
5646
5818
|
await copyTemplateDir(srcPath, destPath, placeholders);
|
|
@@ -5660,9 +5832,9 @@ function shouldReplacePlaceholders(filepath) {
|
|
|
5660
5832
|
async function copyTemplateFile(src, dest, placeholders) {
|
|
5661
5833
|
await mkdir(dirname(dest), { recursive: true });
|
|
5662
5834
|
if (shouldReplacePlaceholders(src)) {
|
|
5663
|
-
const content = await
|
|
5835
|
+
const content = await readFile2(src, "utf-8");
|
|
5664
5836
|
const replaced = replacePlaceholders(content, placeholders);
|
|
5665
|
-
await
|
|
5837
|
+
await writeFile2(dest, replaced, "utf-8");
|
|
5666
5838
|
} else {
|
|
5667
5839
|
await copyFile(src, dest);
|
|
5668
5840
|
}
|
|
@@ -5694,24 +5866,25 @@ async function runBunInstall(targetDir) {
|
|
|
5694
5866
|
|
|
5695
5867
|
// src/template-manager.ts
|
|
5696
5868
|
import { spawn } from "child_process";
|
|
5697
|
-
import { existsSync as
|
|
5698
|
-
import { join as
|
|
5699
|
-
var ROOT_DIR =
|
|
5700
|
-
var TEMPLATES_DIR =
|
|
5869
|
+
import { existsSync as existsSync3 } from "fs";
|
|
5870
|
+
import { join as join3 } from "path";
|
|
5871
|
+
var ROOT_DIR = join3(import.meta.dir, "..");
|
|
5872
|
+
var TEMPLATES_DIR = join3(ROOT_DIR, "templates");
|
|
5873
|
+
var ALL_TEMPLATES = ["monorepo", "telegram-bot", "fumadocs"];
|
|
5701
5874
|
async function listTemplates() {
|
|
5702
5875
|
console.log(`
|
|
5703
5876
|
\uD83D\uDCE6 Templates Status:
|
|
5704
5877
|
`);
|
|
5705
5878
|
const templates = ["monorepo", "telegram-bot", "fumadocs"];
|
|
5706
5879
|
for (const name of templates) {
|
|
5707
|
-
const templatePath =
|
|
5708
|
-
if (!
|
|
5880
|
+
const templatePath = join3(TEMPLATES_DIR, name);
|
|
5881
|
+
if (!existsSync3(templatePath)) {
|
|
5709
5882
|
console.log(` \u274C ${name} (missing)
|
|
5710
5883
|
`);
|
|
5711
5884
|
continue;
|
|
5712
5885
|
}
|
|
5713
|
-
const gitDir =
|
|
5714
|
-
if (
|
|
5886
|
+
const gitDir = join3(templatePath, ".git");
|
|
5887
|
+
if (existsSync3(gitDir)) {
|
|
5715
5888
|
try {
|
|
5716
5889
|
const url = await execGit(["config", "remote.origin.url"], { cwd: templatePath, silent: true });
|
|
5717
5890
|
const branch = await execGit(["rev-parse", "--abbrev-ref", "HEAD"], { cwd: templatePath, silent: true });
|
|
@@ -5731,19 +5904,19 @@ async function listTemplates() {
|
|
|
5731
5904
|
}
|
|
5732
5905
|
}
|
|
5733
5906
|
async function syncTemplates(templateName) {
|
|
5734
|
-
const templates = templateName ? [templateName] :
|
|
5907
|
+
const templates = templateName ? [templateName] : ALL_TEMPLATES;
|
|
5735
5908
|
console.log(`
|
|
5736
5909
|
\uD83D\uDD04 Syncing ${templateName ? kleur_default.cyan(templateName) : "all templates"}...
|
|
5737
5910
|
`);
|
|
5738
5911
|
for (const name of templates) {
|
|
5739
|
-
const templatePath =
|
|
5740
|
-
if (!
|
|
5912
|
+
const templatePath = join3(TEMPLATES_DIR, name);
|
|
5913
|
+
if (!existsSync3(templatePath)) {
|
|
5741
5914
|
console.log(` \u26A0\uFE0F Template '${name}' not found. Skipping.
|
|
5742
5915
|
`);
|
|
5743
5916
|
continue;
|
|
5744
5917
|
}
|
|
5745
|
-
const gitDir =
|
|
5746
|
-
if (
|
|
5918
|
+
const gitDir = join3(templatePath, ".git");
|
|
5919
|
+
if (existsSync3(gitDir)) {
|
|
5747
5920
|
console.log(` \uD83D\uDCE5 ${kleur_default.cyan(name)}:`);
|
|
5748
5921
|
try {
|
|
5749
5922
|
await execGit(["pull", "--ff-only"], { cwd: templatePath });
|
|
@@ -5758,21 +5931,22 @@ async function syncTemplates(templateName) {
|
|
|
5758
5931
|
`);
|
|
5759
5932
|
}
|
|
5760
5933
|
}
|
|
5934
|
+
await syncGuidelinesToAllTemplates(TEMPLATES_DIR, templates);
|
|
5761
5935
|
console.log(`${kleur_default.green("\u2728")} Sync complete!
|
|
5762
5936
|
`);
|
|
5763
5937
|
}
|
|
5764
5938
|
async function importTemplate(name, sourcePath) {
|
|
5765
|
-
const targetPath =
|
|
5939
|
+
const targetPath = join3(TEMPLATES_DIR, name);
|
|
5766
5940
|
console.log(`
|
|
5767
5941
|
\uD83D\uDCE6 Importing '${kleur_default.cyan(name)}' from ${sourcePath}...
|
|
5768
5942
|
`);
|
|
5769
|
-
if (
|
|
5943
|
+
if (existsSync3(targetPath)) {
|
|
5770
5944
|
console.log(` \u26A0\uFE0F Template '${name}' already exists.
|
|
5771
5945
|
`);
|
|
5772
5946
|
return;
|
|
5773
5947
|
}
|
|
5774
|
-
const sourceGitDir =
|
|
5775
|
-
if (
|
|
5948
|
+
const sourceGitDir = join3(sourcePath, ".git");
|
|
5949
|
+
if (existsSync3(sourceGitDir)) {
|
|
5776
5950
|
console.log(` \uD83D\uDD17 Adding as submodule...`);
|
|
5777
5951
|
try {
|
|
5778
5952
|
await execGit(["submodule", "add", sourcePath, `templates/${name}`]);
|
|
@@ -5846,6 +6020,10 @@ async function main(args) {
|
|
|
5846
6020
|
await handleTemplatesCommand(args.slice(1));
|
|
5847
6021
|
return;
|
|
5848
6022
|
}
|
|
6023
|
+
if (args[0] === "guidelines") {
|
|
6024
|
+
await handleGuidelinesCommand(args.slice(1));
|
|
6025
|
+
return;
|
|
6026
|
+
}
|
|
5849
6027
|
try {
|
|
5850
6028
|
const templateType = await selectTemplate(parsedArgs);
|
|
5851
6029
|
const config = parsedArgs.yes ? await getDefaults(parsedArgs, templateType) : await promptUser(parsedArgs, templateType);
|
|
@@ -5878,9 +6056,9 @@ async function handleTemplatesCommand(args) {
|
|
|
5878
6056
|
break;
|
|
5879
6057
|
default:
|
|
5880
6058
|
console.error(`
|
|
5881
|
-
|
|
6059
|
+
Unknown template command: ${command}
|
|
5882
6060
|
|
|
5883
|
-
|
|
6061
|
+
Available commands:
|
|
5884
6062
|
bun run cli templates list List all templates
|
|
5885
6063
|
bun run cli templates sync [name] Sync templates from git
|
|
5886
6064
|
bun run cli templates import <name> <path> Import template from local path
|
|
@@ -5888,6 +6066,31 @@ ${printError.info("Available commands:")}
|
|
|
5888
6066
|
process.exit(1);
|
|
5889
6067
|
}
|
|
5890
6068
|
}
|
|
6069
|
+
async function handleGuidelinesCommand(args) {
|
|
6070
|
+
const command = args[0];
|
|
6071
|
+
const templateName = args[1];
|
|
6072
|
+
const templates = templateName ? [templateName] : ALL_TEMPLATES;
|
|
6073
|
+
switch (command) {
|
|
6074
|
+
case "sync":
|
|
6075
|
+
await syncGuidelinesToAllTemplates(TEMPLATES_DIR, templates);
|
|
6076
|
+
console.log(`
|
|
6077
|
+
\u2728 Guidelines sync complete!
|
|
6078
|
+
`);
|
|
6079
|
+
break;
|
|
6080
|
+
case "check":
|
|
6081
|
+
await checkGuidelinesStatus(TEMPLATES_DIR, ALL_TEMPLATES);
|
|
6082
|
+
break;
|
|
6083
|
+
default:
|
|
6084
|
+
console.error(`
|
|
6085
|
+
Unknown guidelines command: ${command || "(none)"}
|
|
6086
|
+
|
|
6087
|
+
Available commands:
|
|
6088
|
+
bun run cli guidelines sync [template] Sync MUST-FOLLOW-GUIDELINES.md to templates
|
|
6089
|
+
bun run cli guidelines check Check guidelines status across templates
|
|
6090
|
+
`);
|
|
6091
|
+
process.exit(1);
|
|
6092
|
+
}
|
|
6093
|
+
}
|
|
5891
6094
|
|
|
5892
6095
|
// bin.ts
|
|
5893
6096
|
main(process.argv.slice(2));
|