@betterstart/cli 0.1.49 → 0.1.51
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 +169 -22
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-6JCWMKSY.js";
|
|
5
5
|
|
|
6
6
|
// src/cli.ts
|
|
7
|
-
import { Command as
|
|
7
|
+
import { Command as Command10 } from "commander";
|
|
8
8
|
|
|
9
9
|
// src/commands/generate.ts
|
|
10
10
|
import path30 from "path";
|
|
@@ -15521,18 +15521,164 @@ var uninstallCommand = new Command6("uninstall").description("Remove all CMS fil
|
|
|
15521
15521
|
p6.outro("Uninstall complete");
|
|
15522
15522
|
});
|
|
15523
15523
|
|
|
15524
|
-
// src/commands/update-
|
|
15524
|
+
// src/commands/update-component.ts
|
|
15525
|
+
import fs45 from "fs";
|
|
15525
15526
|
import path49 from "path";
|
|
15526
15527
|
import * as clack2 from "@clack/prompts";
|
|
15527
15528
|
import { Command as Command7 } from "commander";
|
|
15528
|
-
|
|
15529
|
+
import fsExtra from "fs-extra";
|
|
15530
|
+
var TEMPLATE_REGISTRY = {
|
|
15531
|
+
// CSS
|
|
15532
|
+
"cms-globals": { relPath: "cms-globals.css", content: cmsGlobalsCssTemplate },
|
|
15533
|
+
// Layout
|
|
15534
|
+
"cms-providers": { relPath: "components/layout/cms-providers.tsx", content: cmsProvidersTemplate },
|
|
15535
|
+
"cms-nav-link": { relPath: "components/layout/cms-nav-link.tsx", content: cmsNavLinkTemplate },
|
|
15536
|
+
"cms-sidebar": { relPath: "components/layout/cms-sidebar.tsx", content: cmsSidebarTemplate },
|
|
15537
|
+
"cms-header": { relPath: "components/layout/cms-header.tsx", content: cmsHeaderTemplate },
|
|
15538
|
+
"cms-search": { relPath: "components/layout/cms-search.tsx", content: cmsSearchTemplate },
|
|
15539
|
+
// Shared
|
|
15540
|
+
"page-header": { relPath: "components/shared/page-header.tsx", content: pageHeaderTemplate },
|
|
15541
|
+
"delete-dialog": { relPath: "components/shared/delete-dialog.tsx", content: deleteDialogTemplate },
|
|
15542
|
+
"status-badge": { relPath: "components/shared/status-badge.tsx", content: statusBadgeTemplate },
|
|
15543
|
+
// Data table
|
|
15544
|
+
"data-table": { relPath: "components/data-table/data-table.tsx", content: dataTableTemplate },
|
|
15545
|
+
"data-table-pagination": { relPath: "components/data-table/data-table-pagination.tsx", content: dataTablePaginationTemplate },
|
|
15546
|
+
"data-table-toolbar": { relPath: "components/data-table/data-table-toolbar.tsx", content: dataTableToolbarTemplate },
|
|
15547
|
+
// Hooks
|
|
15548
|
+
"use-upload": { relPath: "hooks/use-upload.ts", content: useUploadHookTemplate },
|
|
15549
|
+
"use-editor-image-upload": { relPath: "hooks/use-editor-image-upload.ts", content: useEditorImageUploadHookTemplate },
|
|
15550
|
+
"use-local-storage": { relPath: "hooks/use-local-storage.ts", content: useLocalStorageHookTemplate },
|
|
15551
|
+
"use-cms-theme": { relPath: "hooks/use-cms-theme.tsx", content: useCmsThemeTemplate },
|
|
15552
|
+
"use-users": { relPath: "hooks/use-users.ts", content: useUsersHookTemplate },
|
|
15553
|
+
"use-mobile": { relPath: "hooks/use-mobile.ts", content: useMobileHookTemplate },
|
|
15554
|
+
// Types
|
|
15555
|
+
"types-index": { relPath: "types/index.ts", content: typesIndexTemplate },
|
|
15556
|
+
"auth-types": { relPath: "types/auth.ts", content: authTypesTemplate },
|
|
15557
|
+
"table-meta": { relPath: "types/table-meta.ts", content: tableMetaTypesTemplate },
|
|
15558
|
+
// Utils
|
|
15559
|
+
cn: { relPath: "utils/cn.ts", content: cnUtilTemplate },
|
|
15560
|
+
seo: { relPath: "utils/seo.ts", content: seoUtilTemplate },
|
|
15561
|
+
validation: { relPath: "utils/validation.ts", content: validationUtilTemplate },
|
|
15562
|
+
webhook: { relPath: "utils/webhook.ts", content: webhookUtilTemplate },
|
|
15563
|
+
mailchimp: { relPath: "utils/mailchimp.ts", content: mailchimpUtilTemplate },
|
|
15564
|
+
// Lib
|
|
15565
|
+
r2: { relPath: "lib/r2.ts", content: r2ClientTemplate },
|
|
15566
|
+
"form-settings-action": { relPath: "lib/actions/form-settings.ts", content: formSettingsActionTemplate },
|
|
15567
|
+
"upload-action": { relPath: "lib/actions/upload.ts", content: uploadActionTemplate },
|
|
15568
|
+
"users-action": { relPath: "lib/actions/users.ts", content: usersActionTemplate },
|
|
15569
|
+
// Markdown
|
|
15570
|
+
"markdown-render": { relPath: "lib/markdown/render.ts", content: markdownRenderTemplate },
|
|
15571
|
+
"markdown-format": { relPath: "lib/markdown/format.ts", content: markdownFormatTemplate },
|
|
15572
|
+
"markdown-cached": { relPath: "lib/markdown/cached.ts", content: markdownCachedTemplate }
|
|
15573
|
+
};
|
|
15574
|
+
function findCliRoot2() {
|
|
15575
|
+
let dir = new URL(".", import.meta.url).pathname;
|
|
15576
|
+
for (let i = 0; i < 5; i++) {
|
|
15577
|
+
const pkgPath = path49.join(dir, "package.json");
|
|
15578
|
+
if (fs45.existsSync(pkgPath)) {
|
|
15579
|
+
try {
|
|
15580
|
+
const pkg = JSON.parse(fs45.readFileSync(pkgPath, "utf-8"));
|
|
15581
|
+
if (pkg.name === "@betterstart/cli") {
|
|
15582
|
+
return dir;
|
|
15583
|
+
}
|
|
15584
|
+
} catch {
|
|
15585
|
+
}
|
|
15586
|
+
}
|
|
15587
|
+
dir = path49.dirname(dir);
|
|
15588
|
+
}
|
|
15589
|
+
return path49.resolve(new URL(".", import.meta.url).pathname, "..", "..");
|
|
15590
|
+
}
|
|
15591
|
+
function getStaticUiComponents() {
|
|
15592
|
+
const cliRoot = findCliRoot2();
|
|
15593
|
+
const uiDir = path49.join(cliRoot, "templates", "ui");
|
|
15594
|
+
if (!fs45.existsSync(uiDir)) return [];
|
|
15595
|
+
return fs45.readdirSync(uiDir).filter((f) => f.endsWith(".tsx") || f.endsWith(".ts")).map((f) => f.replace(/\.(tsx|ts)$/, ""));
|
|
15596
|
+
}
|
|
15597
|
+
function getAllComponentNames() {
|
|
15598
|
+
const staticUi = getStaticUiComponents();
|
|
15599
|
+
const templateKeys = Object.keys(TEMPLATE_REGISTRY);
|
|
15600
|
+
return [.../* @__PURE__ */ new Set([...staticUi, ...templateKeys, "tiptap"])].sort();
|
|
15601
|
+
}
|
|
15602
|
+
var updateComponentCommand = new Command7("update-component").description("Update individual CMS components from the latest CLI templates").argument("[components...]", "Component names to update (e.g., media-upload-field button)").option("--list", "List all available components").option("--all", "Update all components").option("--cwd <path>", "Project root path").action(async (components, options) => {
|
|
15529
15603
|
const cwd = options.cwd ? path49.resolve(options.cwd) : process.cwd();
|
|
15530
|
-
|
|
15604
|
+
if (options.list) {
|
|
15605
|
+
const all = getAllComponentNames();
|
|
15606
|
+
clack2.intro("Available components");
|
|
15607
|
+
const uiComponents = getStaticUiComponents();
|
|
15608
|
+
clack2.log.info(`UI components (${uiComponents.length}): ${uiComponents.join(", ")}`);
|
|
15609
|
+
clack2.log.info(`Template components (${Object.keys(TEMPLATE_REGISTRY).length}): ${Object.keys(TEMPLATE_REGISTRY).sort().join(", ")}`);
|
|
15610
|
+
clack2.log.info("Special: tiptap (updates entire tiptap editor)");
|
|
15611
|
+
clack2.outro(`${all.length} components available`);
|
|
15612
|
+
return;
|
|
15613
|
+
}
|
|
15614
|
+
if (!options.all && components.length === 0) {
|
|
15615
|
+
clack2.log.error("Provide component names or use --all. Run with --list to see available components.");
|
|
15616
|
+
process.exit(1);
|
|
15617
|
+
}
|
|
15618
|
+
const config = await resolveConfig(cwd);
|
|
15619
|
+
const cms = path49.resolve(cwd, config.paths.cms);
|
|
15620
|
+
if (!fs45.existsSync(cms)) {
|
|
15621
|
+
clack2.cancel(`CMS directory not found at ${config.paths.cms}. Run 'betterstart init' first.`);
|
|
15622
|
+
process.exit(1);
|
|
15623
|
+
}
|
|
15624
|
+
clack2.intro("BetterStart Update Components");
|
|
15625
|
+
const toUpdate = options.all ? getAllComponentNames() : components;
|
|
15626
|
+
const cliRoot = findCliRoot2();
|
|
15627
|
+
const uiDir = path49.join(cliRoot, "templates", "ui");
|
|
15628
|
+
let updated = 0;
|
|
15629
|
+
let skipped = 0;
|
|
15630
|
+
for (const name of toUpdate) {
|
|
15631
|
+
if (TEMPLATE_REGISTRY[name]) {
|
|
15632
|
+
const entry = TEMPLATE_REGISTRY[name];
|
|
15633
|
+
const destPath = path49.join(cms, entry.relPath);
|
|
15634
|
+
fsExtra.ensureDirSync(path49.dirname(destPath));
|
|
15635
|
+
fs45.writeFileSync(destPath, entry.content(), "utf-8");
|
|
15636
|
+
clack2.log.success(`Updated ${entry.relPath}`);
|
|
15637
|
+
updated++;
|
|
15638
|
+
continue;
|
|
15639
|
+
}
|
|
15640
|
+
const uiFile = fs45.readdirSync(uiDir).find(
|
|
15641
|
+
(f) => f.replace(/\.(tsx|ts)$/, "") === name
|
|
15642
|
+
);
|
|
15643
|
+
if (uiFile) {
|
|
15644
|
+
const destPath = path49.join(cms, "components", "ui", uiFile);
|
|
15645
|
+
fsExtra.ensureDirSync(path49.dirname(destPath));
|
|
15646
|
+
fs45.copyFileSync(path49.join(uiDir, uiFile), destPath);
|
|
15647
|
+
clack2.log.success(`Updated components/ui/${uiFile}`);
|
|
15648
|
+
updated++;
|
|
15649
|
+
continue;
|
|
15650
|
+
}
|
|
15651
|
+
if (name === "tiptap") {
|
|
15652
|
+
const srcDir = path49.join(cliRoot, "templates", "tiptap");
|
|
15653
|
+
const destDir = path49.join(cms, "components", "ui", "tiptap");
|
|
15654
|
+
if (fs45.existsSync(srcDir)) {
|
|
15655
|
+
fsExtra.copySync(srcDir, destDir, { overwrite: true });
|
|
15656
|
+
clack2.log.success("Updated components/ui/tiptap/ (all files)");
|
|
15657
|
+
updated++;
|
|
15658
|
+
} else {
|
|
15659
|
+
clack2.log.warning("tiptap templates not found");
|
|
15660
|
+
skipped++;
|
|
15661
|
+
}
|
|
15662
|
+
continue;
|
|
15663
|
+
}
|
|
15664
|
+
clack2.log.warning(`Unknown component: ${name}`);
|
|
15665
|
+
skipped++;
|
|
15666
|
+
}
|
|
15667
|
+
clack2.outro(`Updated ${updated} component${updated !== 1 ? "s" : ""}${skipped > 0 ? `, ${skipped} skipped` : ""}`);
|
|
15668
|
+
});
|
|
15669
|
+
|
|
15670
|
+
// src/commands/update-deps.ts
|
|
15671
|
+
import path50 from "path";
|
|
15672
|
+
import * as clack3 from "@clack/prompts";
|
|
15673
|
+
import { Command as Command8 } from "commander";
|
|
15674
|
+
var updateDepsCommand = new Command8("update-deps").description("Install or update all CMS dependencies").option("--cwd <path>", "Project root path").action(async (options) => {
|
|
15675
|
+
const cwd = options.cwd ? path50.resolve(options.cwd) : process.cwd();
|
|
15676
|
+
clack3.intro("BetterStart Update Dependencies");
|
|
15531
15677
|
const pm = detectPackageManager(cwd);
|
|
15532
|
-
|
|
15678
|
+
clack3.log.info(`Package manager: ${pm}`);
|
|
15533
15679
|
const config = await resolveConfig(cwd);
|
|
15534
15680
|
const includeEmail = config.features?.email ?? true;
|
|
15535
|
-
const s =
|
|
15681
|
+
const s = clack3.spinner();
|
|
15536
15682
|
s.start("Installing dependencies...");
|
|
15537
15683
|
const result = await installDependenciesAsync({
|
|
15538
15684
|
cwd,
|
|
@@ -15544,34 +15690,34 @@ var updateDepsCommand = new Command7("update-deps").description("Install or upda
|
|
|
15544
15690
|
s.stop(`Installed ${result.coreDeps.length} deps + ${result.devDeps.length} dev deps`);
|
|
15545
15691
|
} else {
|
|
15546
15692
|
s.stop("Dependency install failed");
|
|
15547
|
-
|
|
15693
|
+
clack3.log.error(result.error ?? "Unknown error");
|
|
15548
15694
|
process.exit(1);
|
|
15549
15695
|
}
|
|
15550
|
-
|
|
15696
|
+
clack3.outro("Dependencies updated");
|
|
15551
15697
|
});
|
|
15552
15698
|
|
|
15553
15699
|
// src/commands/update-styles.ts
|
|
15554
|
-
import
|
|
15555
|
-
import
|
|
15556
|
-
import * as
|
|
15557
|
-
import { Command as
|
|
15558
|
-
var updateStylesCommand = new
|
|
15559
|
-
const cwd = options.cwd ?
|
|
15560
|
-
|
|
15700
|
+
import fs46 from "fs";
|
|
15701
|
+
import path51 from "path";
|
|
15702
|
+
import * as clack4 from "@clack/prompts";
|
|
15703
|
+
import { Command as Command9 } from "commander";
|
|
15704
|
+
var updateStylesCommand = new Command9("update-styles").description("Replace cms-globals.css with the latest version from the CLI").option("--cwd <path>", "Project root path").action(async (options) => {
|
|
15705
|
+
const cwd = options.cwd ? path51.resolve(options.cwd) : process.cwd();
|
|
15706
|
+
clack4.intro("BetterStart Update Styles");
|
|
15561
15707
|
const config = await resolveConfig(cwd);
|
|
15562
15708
|
const cmsDir = config.paths?.cms ?? "./cms";
|
|
15563
|
-
const targetPath =
|
|
15564
|
-
if (!
|
|
15565
|
-
|
|
15709
|
+
const targetPath = path51.join(cwd, cmsDir, "cms-globals.css");
|
|
15710
|
+
if (!fs46.existsSync(targetPath)) {
|
|
15711
|
+
clack4.cancel(`cms-globals.css not found at ${path51.relative(cwd, targetPath)}`);
|
|
15566
15712
|
process.exit(1);
|
|
15567
15713
|
}
|
|
15568
|
-
|
|
15569
|
-
|
|
15570
|
-
|
|
15714
|
+
fs46.writeFileSync(targetPath, cmsGlobalsCssTemplate(), "utf-8");
|
|
15715
|
+
clack4.log.success(`Updated ${path51.relative(cwd, targetPath)}`);
|
|
15716
|
+
clack4.outro("Styles updated");
|
|
15571
15717
|
});
|
|
15572
15718
|
|
|
15573
15719
|
// src/cli.ts
|
|
15574
|
-
var program = new
|
|
15720
|
+
var program = new Command10();
|
|
15575
15721
|
program.name("betterstart").description("Scaffold a full-featured CMS into any Next.js 16 application").version("0.1.0");
|
|
15576
15722
|
program.addCommand(initCommand);
|
|
15577
15723
|
program.addCommand(generateCommand);
|
|
@@ -15579,6 +15725,7 @@ program.addCommand(removeCommand);
|
|
|
15579
15725
|
program.addCommand(seedCommand);
|
|
15580
15726
|
program.addCommand(setupR2Command);
|
|
15581
15727
|
program.addCommand(uninstallCommand);
|
|
15728
|
+
program.addCommand(updateComponentCommand);
|
|
15582
15729
|
program.addCommand(updateDepsCommand);
|
|
15583
15730
|
program.addCommand(updateStylesCommand);
|
|
15584
15731
|
program.parse();
|