cronus-ui 0.6.0 → 0.6.2
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 +2 -2
- package/dist/commands/add-page.js +12 -13
- package/dist/commands/add.js +2 -1
- package/dist/commands/compose.js +23 -4
- package/dist/compose/gold-path.d.ts +46 -0
- package/dist/compose/gold-path.js +923 -0
- package/dist/config.d.ts +2 -2
- package/dist/config.js +1 -1
- package/dist/utils.d.ts +22 -0
- package/dist/utils.js +69 -1
- package/package.json +2 -2
- package/templates/apps/admin.json +58 -0
- package/templates/apps/docs.json +50 -0
- package/templates/apps/saas.json +26 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ Notes that match the commander surface:
|
|
|
49
49
|
`packages/cli/scripts/build-registry.ts` — each item carries its source, its npm
|
|
50
50
|
`dependencies`, and its `registryDependencies` (other components it imports),
|
|
51
51
|
derived by parsing imports.
|
|
52
|
-
- The default registry is pinned to the CLI package version (`v0.6.
|
|
52
|
+
- The default registry is pinned to the CLI package version (`v0.6.2` here), not
|
|
53
53
|
mutable `main`, so a published CLI reads the registry snapshot it was released
|
|
54
54
|
with. Use `-r, --registry ./registry` when testing local registry changes before
|
|
55
55
|
a release tag exists.
|
|
@@ -80,7 +80,7 @@ Notes that match the commander surface:
|
|
|
80
80
|
"lib": "lib",
|
|
81
81
|
"blocks": "components/blocks"
|
|
82
82
|
},
|
|
83
|
-
"registry": "https://raw.githubusercontent.com/pedrogbraz/cronus-ui/v0.6.
|
|
83
|
+
"registry": "https://raw.githubusercontent.com/pedrogbraz/cronus-ui/v0.6.2/registry"
|
|
84
84
|
}
|
|
85
85
|
```
|
|
86
86
|
|
|
@@ -26,7 +26,7 @@ import { baseSnapshotDir, reloadManifest } from "../compose/reload.js";
|
|
|
26
26
|
import { chromeWrapperPath, layoutPath, pagePath, renderChromeWrapper, renderLayout, renderPage, renderShellWrapper, rewriteChromeBlock, } from "../compose/render.js";
|
|
27
27
|
import { CLI_VERSION, hasConfig, readConfig, writeConfig, } from "../config.js";
|
|
28
28
|
import { Registry, registrySourceVersion } from "../registry.js";
|
|
29
|
-
import { closestName, collectDependencies, detectPackageManager, log, resolveSafeDest, runInstall, writeFileEnsured, writeItemFiles, } from "../utils.js";
|
|
29
|
+
import { closestName, collectDependencies, detectPackageManager, log, recordDependencies, resolveSafeDest, rewriteImports, runInstall, writeFileEnsured, writeItemFiles, } from "../utils.js";
|
|
30
30
|
import { readChromeSources, readComposeMeta } from "./compose.js";
|
|
31
31
|
/** Title-case a route into a default page title: "/faq" → "Faq", "/help-center" → "Help Center". */
|
|
32
32
|
function defaultTitle(route) {
|
|
@@ -275,7 +275,7 @@ export async function addPage(options) {
|
|
|
275
275
|
const source = plan.chromeSources[slug];
|
|
276
276
|
if (source === undefined || !existsSync(dest))
|
|
277
277
|
continue;
|
|
278
|
-
const content = rewriteChromeBlock(slug, source, plan);
|
|
278
|
+
const content = rewriteImports(rewriteChromeBlock(slug, source, plan), config);
|
|
279
279
|
await writeFileEnsured(dest, content);
|
|
280
280
|
if (!generatedFiles.includes(rel))
|
|
281
281
|
generatedFiles.push(rel);
|
|
@@ -298,17 +298,16 @@ export async function addPage(options) {
|
|
|
298
298
|
};
|
|
299
299
|
const composed = { ...config.composed, [appName]: nextRecord };
|
|
300
300
|
await writeConfig(targetDir, { ...config, installed, composed });
|
|
301
|
-
// ---
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
301
|
+
// --- Record + install npm deps (best-effort) ------------------------------
|
|
302
|
+
const deps = resolvedItems.length > 0 ? collectDependencies(resolvedItems) : [];
|
|
303
|
+
await recordDependencies(targetDir, deps);
|
|
304
|
+
if (deps.length > 0 && !(options.skipInstall ?? false)) {
|
|
305
|
+
const pm = detectPackageManager(targetDir);
|
|
306
|
+
try {
|
|
307
|
+
await runInstall(pm, deps, targetDir);
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
// Non-fatal.
|
|
312
311
|
}
|
|
313
312
|
}
|
|
314
313
|
return { appName, route: options.route, generatedFiles, skippedFiles, installedBlocks };
|
package/dist/commands/add.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CLI_VERSION, hasConfig, readConfig, writeConfig, } from "../config.js";
|
|
2
2
|
import { Registry, registrySourceVersion } from "../registry.js";
|
|
3
|
-
import { closestName, collectDependencies, detectPackageManager, log, runInstall, writeItemFiles, } from "../utils.js";
|
|
3
|
+
import { closestName, collectDependencies, detectPackageManager, log, recordDependencies, runInstall, writeItemFiles, } from "../utils.js";
|
|
4
4
|
export async function add(names, options) {
|
|
5
5
|
const { cwd } = options;
|
|
6
6
|
if (!hasConfig(cwd)) {
|
|
@@ -94,6 +94,7 @@ export async function add(names, options) {
|
|
|
94
94
|
await writeConfig(cwd, { ...config, installed });
|
|
95
95
|
}
|
|
96
96
|
const deps = collectDependencies(items);
|
|
97
|
+
await recordDependencies(cwd, deps);
|
|
97
98
|
if (deps.length > 0 && !options.skipInstall) {
|
|
98
99
|
const pm = detectPackageManager(cwd);
|
|
99
100
|
log.step(`Installing ${deps.length} dependencies with ${pm}…`);
|
package/dist/commands/compose.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { writeDesignDocuments } from "@cronus-ui/ai-kit";
|
|
5
|
+
import { applyGoldPath, GOLD_PATH_DEPENDENCIES, isGoldPathTemplate } from "../compose/gold-path.js";
|
|
5
6
|
import { manifestFingerprint } from "../compose/manifest.js";
|
|
6
7
|
import { buildComposePlan, ComposePlanError, } from "../compose/plan.js";
|
|
7
8
|
import { renderPreview } from "../compose/preview.js";
|
|
@@ -10,7 +11,7 @@ import { renderPlan } from "../compose/render.js";
|
|
|
10
11
|
import { defaultComposeTemplate, listTemplates, loadManifestFile, loadTemplate, } from "../compose/templates.js";
|
|
11
12
|
import { CLI_VERSION, hasConfig, readConfig, writeConfig, } from "../config.js";
|
|
12
13
|
import { Registry, registrySourceVersion } from "../registry.js";
|
|
13
|
-
import { collectDependencies, detectPackageManager, log, resolveSafeDest, runInstall, writeFileEnsured, writeItemFiles, } from "../utils.js";
|
|
14
|
+
import { collectDependencies, detectPackageManager, log, recordDependencies, resolveSafeDest, rewriteImports, runInstall, writeFileEnsured, writeItemFiles, } from "../utils.js";
|
|
14
15
|
export { listTemplates, loadManifestFile, loadTemplate } from "../compose/templates.js";
|
|
15
16
|
/** Read the chrome block sources named by the manifest's chrome map from the registry. */
|
|
16
17
|
export async function readChromeSources(manifest, registry) {
|
|
@@ -129,7 +130,7 @@ export async function composeApp(options) {
|
|
|
129
130
|
continue;
|
|
130
131
|
}
|
|
131
132
|
const dest = resolveSafeDest(targetDir, ".", rewrite.file);
|
|
132
|
-
await writeFileEnsured(dest, rewrite.content);
|
|
133
|
+
await writeFileEnsured(dest, rewriteImports(rewrite.content, config));
|
|
133
134
|
generatedFiles.push(rewrite.file);
|
|
134
135
|
}
|
|
135
136
|
// --- Write the generated pages/layouts/wrappers (safe writes) -------------
|
|
@@ -147,6 +148,18 @@ export async function composeApp(options) {
|
|
|
147
148
|
const snapDest = resolveSafeDest(targetDir, baseSnapshotDir(plan.templateName), file.path);
|
|
148
149
|
await writeFileEnsured(snapDest, file.content);
|
|
149
150
|
}
|
|
151
|
+
// Authenticated gold path (saas/admin only): sqlite + drizzle + better-auth.
|
|
152
|
+
if (isGoldPathTemplate(plan.templateName)) {
|
|
153
|
+
const gold = await applyGoldPath({
|
|
154
|
+
targetDir,
|
|
155
|
+
config,
|
|
156
|
+
generatedFiles,
|
|
157
|
+
overwrite,
|
|
158
|
+
templateName: plan.templateName,
|
|
159
|
+
});
|
|
160
|
+
generatedFiles.push(...gold.written);
|
|
161
|
+
skippedFiles.push(...gold.skipped);
|
|
162
|
+
}
|
|
150
163
|
// --- Record composed{} + installed{} --------------------------------------
|
|
151
164
|
// Keyed by TEMPLATE name (not project name): a project can compose several
|
|
152
165
|
// templates, and re-composing the same one updates its record in place.
|
|
@@ -172,8 +185,14 @@ export async function composeApp(options) {
|
|
|
172
185
|
const nextConfig = { ...config, installed, composed };
|
|
173
186
|
await writeConfig(targetDir, nextConfig);
|
|
174
187
|
writeDesignDocuments(targetDir, { theme: nextConfig.theme?.name });
|
|
175
|
-
// ---
|
|
176
|
-
|
|
188
|
+
// --- Record + install npm deps --------------------------------------------
|
|
189
|
+
// Always pin registry specs into package.json (lucide-react, recharts, …)
|
|
190
|
+
// even when --no-install: a later `bun install` must match `pm add`.
|
|
191
|
+
const registryDeps = collectDependencies(items);
|
|
192
|
+
await recordDependencies(targetDir, registryDeps);
|
|
193
|
+
const deps = isGoldPathTemplate(plan.templateName)
|
|
194
|
+
? [...new Set([...registryDeps, ...GOLD_PATH_DEPENDENCIES])].sort()
|
|
195
|
+
: registryDeps;
|
|
177
196
|
if (deps.length > 0 && !(options.skipInstall ?? false)) {
|
|
178
197
|
const pm = detectPackageManager(targetDir);
|
|
179
198
|
try {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authenticated gold path for saas/admin compose: SQLite + Drizzle + Better-Auth.
|
|
3
|
+
* Always sqlite — postgres/mysql live in create-cronus-stack.
|
|
4
|
+
*/
|
|
5
|
+
import type { CronusUIConfig } from "../config.js";
|
|
6
|
+
export declare const GOLD_PATH_TEMPLATES: Set<string>;
|
|
7
|
+
export declare function isGoldPathTemplate(name: string): boolean;
|
|
8
|
+
/** Production npm specs installed with the gold path (devDeps are merged into package.json). */
|
|
9
|
+
export declare const GOLD_PATH_DEPENDENCIES: readonly ["drizzle-orm@^0.45.2", "better-sqlite3@^12.0.0", "better-auth@^1.7.2"];
|
|
10
|
+
export interface GoldPathLayout {
|
|
11
|
+
libDir: string;
|
|
12
|
+
dbDir: string;
|
|
13
|
+
appDir: string;
|
|
14
|
+
componentsDir: string;
|
|
15
|
+
middlewareRel: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ApplyGoldPathOptions {
|
|
18
|
+
targetDir: string;
|
|
19
|
+
config: CronusUIConfig;
|
|
20
|
+
/** Paths compose actually wrote this run (used to gate the home-page patch). */
|
|
21
|
+
generatedFiles: string[];
|
|
22
|
+
overwrite: boolean;
|
|
23
|
+
/** Composed{} key; when set, the patched home snapshot is updated too. */
|
|
24
|
+
templateName?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ApplyGoldPathResult {
|
|
27
|
+
written: string[];
|
|
28
|
+
skipped: string[];
|
|
29
|
+
}
|
|
30
|
+
export declare function goldPathLayout(config: CronusUIConfig): GoldPathLayout;
|
|
31
|
+
/**
|
|
32
|
+
* Wire the installed app-shell-chrome copy to live Better-Auth orgs + session.
|
|
33
|
+
* Idempotent: a chrome that already has WorkspaceMenu and SessionUser is left
|
|
34
|
+
* untouched. Returns undefined when the WorkspaceSwitcher / InviteDialog
|
|
35
|
+
* anchors are missing and nothing else can be patched.
|
|
36
|
+
*/
|
|
37
|
+
export declare function patchChromeSource(source: string, workspaceImport: string, inviteImport: string, sessionImport?: string): string | undefined;
|
|
38
|
+
/** Insert ItemsPanel into a generated home page. Returns undefined when there is no main. */
|
|
39
|
+
export declare function patchHomePageSource(source: string, itemsImport: string): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Write sqlite + Drizzle + Better-Auth files into a composed saas/admin app.
|
|
42
|
+
* Overwrites lib/auth-adapter.ts always (replaces the demo adapter). Patches
|
|
43
|
+
* the shell home page only when compose wrote it this run.
|
|
44
|
+
*/
|
|
45
|
+
export declare function applyGoldPath(options: ApplyGoldPathOptions): Promise<ApplyGoldPathResult>;
|
|
46
|
+
//# sourceMappingURL=gold-path.d.ts.map
|