@bobbykim/manguito-cms-cli 0.10.0 → 0.10.1
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/index.js +48 -63
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -25570,18 +25570,18 @@ async function runDev(options, deps) {
|
|
|
25570
25570
|
await mkdir2(manguitoDir, { recursive: true });
|
|
25571
25571
|
const drizzleConfigPath = resolve6(manguitoDir, "drizzle.config.ts");
|
|
25572
25572
|
const needsSeed = !await db.tableExists("users");
|
|
25573
|
-
const
|
|
25574
|
-
|
|
25575
|
-
|
|
25576
|
-
printValidationErrors(crossRefErrors, "Schema reference errors", "manguito validate");
|
|
25573
|
+
const loaded = loadValidatedSchema(cwd, config2);
|
|
25574
|
+
if (!loaded.ok) {
|
|
25575
|
+
printValidationErrors(loaded.errors, "Schema errors", "manguito validate");
|
|
25577
25576
|
process.exit(1);
|
|
25578
25577
|
}
|
|
25578
|
+
const { registry, versionModel } = loaded.value;
|
|
25579
25579
|
await generateDrizzleConfig(config2, manguitoDir);
|
|
25580
|
-
await writeFile9(join11(manguitoDir, "schema.ts"), generateSchemaFile(
|
|
25580
|
+
await writeFile9(join11(manguitoDir, "schema.ts"), generateSchemaFile(registry), "utf8");
|
|
25581
25581
|
await runDevMigration(drizzleConfigPath);
|
|
25582
25582
|
printSuccess(needsSeed ? "Schema tables created" : "Schema tables up to date");
|
|
25583
25583
|
if (needsSeed) {
|
|
25584
|
-
await seedSystemTables(db.getDb(),
|
|
25584
|
+
await seedSystemTables(db.getDb(), registry);
|
|
25585
25585
|
printSuccess("System tables seeded");
|
|
25586
25586
|
}
|
|
25587
25587
|
const adminCountResult = await db.getDb().execute(sql`
|
|
@@ -25614,7 +25614,6 @@ async function runDev(options, deps) {
|
|
|
25614
25614
|
process.stdout.write("\n");
|
|
25615
25615
|
printSuccess("Admin account created");
|
|
25616
25616
|
}
|
|
25617
|
-
const registry = bootstrapRegistry;
|
|
25618
25617
|
const contentCount = Object.keys(registry.content_types).length;
|
|
25619
25618
|
const paragraphCount = Object.keys(registry.paragraph_types).length;
|
|
25620
25619
|
const taxonomyCount = Object.keys(registry.taxonomy_types).length;
|
|
@@ -25625,12 +25624,6 @@ async function runDev(options, deps) {
|
|
|
25625
25624
|
await generateRoutes2(registry, manguitoDir);
|
|
25626
25625
|
await generateForms(registry, join11(manguitoDir, "forms"));
|
|
25627
25626
|
await generateNav(registry, manguitoDir);
|
|
25628
|
-
const versionsResult = loadProjectVersionModel(resolveSchemaConfig(cwd, config2), registry);
|
|
25629
|
-
if (!versionsResult.ok) {
|
|
25630
|
-
printValidationErrors(versionsResult.errors, "Version model errors", "manguito validate");
|
|
25631
|
-
process.exit(1);
|
|
25632
|
-
}
|
|
25633
|
-
const versionModel = reduceVersionModel(versionsResult.value.model);
|
|
25634
25627
|
const resolverMap = await loadProgrammaticResolvers(cwd, config2.programmatic.dir);
|
|
25635
25628
|
const adapter = createCmsApp({
|
|
25636
25629
|
name: config2.name,
|
|
@@ -25718,7 +25711,7 @@ async function runDev(options, deps) {
|
|
|
25718
25711
|
void (async () => {
|
|
25719
25712
|
for await (const event of watcher) {
|
|
25720
25713
|
if (event.filename && /\.(json|ya?ml)$/.test(event.filename)) {
|
|
25721
|
-
await
|
|
25714
|
+
await reloadSafely({
|
|
25722
25715
|
cwd,
|
|
25723
25716
|
config: config2,
|
|
25724
25717
|
manguitoDir,
|
|
@@ -25738,7 +25731,7 @@ async function runDev(options, deps) {
|
|
|
25738
25731
|
void (async () => {
|
|
25739
25732
|
for await (const event of progWatcher) {
|
|
25740
25733
|
if (event.filename && /\.(ts|mjs|js)$/.test(event.filename)) {
|
|
25741
|
-
await
|
|
25734
|
+
await reloadSafely({
|
|
25742
25735
|
cwd,
|
|
25743
25736
|
config: config2,
|
|
25744
25737
|
manguitoDir,
|
|
@@ -25754,34 +25747,32 @@ async function runDev(options, deps) {
|
|
|
25754
25747
|
})();
|
|
25755
25748
|
}
|
|
25756
25749
|
}
|
|
25757
|
-
async function
|
|
25758
|
-
const { cwd, config: config2, manguitoDir, drizzleConfigPath, db, updateFetch, getResolvers } = args;
|
|
25759
|
-
let registry;
|
|
25750
|
+
async function reloadSafely(args) {
|
|
25760
25751
|
try {
|
|
25761
|
-
|
|
25762
|
-
} catch {
|
|
25763
|
-
process.stderr.write(
|
|
25764
|
-
|
|
25752
|
+
await onSchemaFileChange(args);
|
|
25753
|
+
} catch (err) {
|
|
25754
|
+
process.stderr.write(
|
|
25755
|
+
`\u26A0 Reload failed: ${err instanceof Error ? err.message : String(err)}
|
|
25756
|
+
\u26A0 Still serving the previous version.
|
|
25757
|
+
`
|
|
25758
|
+
);
|
|
25765
25759
|
}
|
|
25766
|
-
|
|
25767
|
-
|
|
25768
|
-
|
|
25760
|
+
}
|
|
25761
|
+
async function onSchemaFileChange(args) {
|
|
25762
|
+
const { cwd, config: config2, manguitoDir, drizzleConfigPath, db, updateFetch, getResolvers } = args;
|
|
25763
|
+
const loaded = loadValidatedSchema(cwd, config2);
|
|
25764
|
+
if (!loaded.ok) {
|
|
25765
|
+
printValidationErrors(loaded.errors, "Schema errors", "manguito validate");
|
|
25769
25766
|
process.stderr.write("\u26A0 Changes not applied.\n");
|
|
25770
25767
|
return;
|
|
25771
25768
|
}
|
|
25769
|
+
const { registry, versionModel } = loaded.value;
|
|
25772
25770
|
await generateDrizzleConfig(config2, manguitoDir);
|
|
25773
25771
|
await writeFile9(join11(manguitoDir, "schema.ts"), generateSchemaFile(registry), "utf8");
|
|
25774
25772
|
await generateSchemaRegistry(registry, manguitoDir);
|
|
25775
25773
|
await generateRoutes2(registry, manguitoDir);
|
|
25776
25774
|
await generateForms(registry, join11(manguitoDir, "forms"));
|
|
25777
25775
|
await generateNav(registry, manguitoDir);
|
|
25778
|
-
const versionsResult = loadProjectVersionModel(resolveSchemaConfig(cwd, config2), registry);
|
|
25779
|
-
if (!versionsResult.ok) {
|
|
25780
|
-
printValidationErrors(versionsResult.errors, "Version model errors", "manguito validate");
|
|
25781
|
-
process.stderr.write("\u26A0 Changes not applied.\n");
|
|
25782
|
-
return;
|
|
25783
|
-
}
|
|
25784
|
-
const versionModel = reduceVersionModel(versionsResult.value.model);
|
|
25785
25776
|
try {
|
|
25786
25777
|
await runDevMigration(drizzleConfigPath);
|
|
25787
25778
|
} catch (err) {
|
|
@@ -25806,46 +25797,40 @@ async function onSchemaFileChange(args) {
|
|
|
25806
25797
|
updateFetch((req) => newAdapter.app.fetch(req));
|
|
25807
25798
|
printSuccess("Schema updated");
|
|
25808
25799
|
}
|
|
25809
|
-
|
|
25800
|
+
function loadValidatedSchema(cwd, config2) {
|
|
25801
|
+
const parsed = parseAllSchemas(cwd, config2);
|
|
25802
|
+
if (!parsed.ok) return parsed;
|
|
25803
|
+
const registry = parsed.value;
|
|
25804
|
+
const crossRefErrors = validateCrossReferences(registry, config2.api.media?.max_file_size);
|
|
25805
|
+
if (crossRefErrors.length > 0) return { ok: false, errors: crossRefErrors };
|
|
25806
|
+
const versions = loadProjectVersionModel(resolveSchemaConfig(cwd, config2), registry);
|
|
25807
|
+
if (!versions.ok) return { ok: false, errors: versions.errors };
|
|
25808
|
+
printSchemaDeprecations(findSchemaDeprecations(registry));
|
|
25809
|
+
return { ok: true, value: { registry, versionModel: reduceVersionModel(versions.value.model) } };
|
|
25810
|
+
}
|
|
25811
|
+
function parseAllSchemas(cwd, config2) {
|
|
25812
|
+
const errors = [];
|
|
25810
25813
|
const parsedSchemas = [];
|
|
25811
25814
|
const walkResult = walkSchemaDirectory(config2.schema);
|
|
25812
25815
|
if (!walkResult.ok) {
|
|
25813
|
-
|
|
25814
|
-
|
|
25815
|
-
|
|
25816
|
-
|
|
25817
|
-
|
|
25818
|
-
|
|
25819
|
-
printGuidedError("Schema parse errors \u2014 run `manguito validate` for details.");
|
|
25820
|
-
process.exit(1);
|
|
25816
|
+
errors.push(...walkResult.errors);
|
|
25817
|
+
} else {
|
|
25818
|
+
for (const file of walkResult.value) {
|
|
25819
|
+
const parseResult = parseSchema(file.raw, file.schema_type, file.path);
|
|
25820
|
+
if (parseResult.ok) parsedSchemas.push(parseResult.schema);
|
|
25821
|
+
else errors.push(...parseResult.errors);
|
|
25821
25822
|
}
|
|
25822
|
-
parsedSchemas.push(parseResult.schema);
|
|
25823
25823
|
}
|
|
25824
25824
|
const rolesPath = resolve6(cwd, config2.schema.base_path, "roles.json");
|
|
25825
25825
|
const rolesLoad = loadSchemaFile(rolesPath);
|
|
25826
|
-
|
|
25827
|
-
|
|
25828
|
-
process.exit(1);
|
|
25829
|
-
}
|
|
25830
|
-
const rolesResult = parseRoles(rolesLoad.value, rolesPath);
|
|
25831
|
-
if (!rolesResult.ok) {
|
|
25832
|
-
printGuidedError("roles.json parse errors \u2014 run `manguito validate` for details.");
|
|
25833
|
-
process.exit(1);
|
|
25834
|
-
}
|
|
25826
|
+
const rolesResult = rolesLoad.ok ? parseRoles(rolesLoad.value, rolesPath) : rolesLoad;
|
|
25827
|
+
if (!rolesResult.ok) errors.push(...rolesResult.errors);
|
|
25835
25828
|
const routesPath = resolve6(cwd, config2.schema.base_path, "routes.json");
|
|
25836
25829
|
const routesLoad = loadSchemaFile(routesPath);
|
|
25837
|
-
|
|
25838
|
-
|
|
25839
|
-
|
|
25840
|
-
}
|
|
25841
|
-
const routesResult = parseRoutes(routesLoad.value, routesPath);
|
|
25842
|
-
if (!routesResult.ok) {
|
|
25843
|
-
printGuidedError("routes.json parse errors \u2014 run `manguito validate` for details.");
|
|
25844
|
-
process.exit(1);
|
|
25845
|
-
}
|
|
25846
|
-
const registry = buildSchemaRegistry(parsedSchemas, routesResult.value, rolesResult.value);
|
|
25847
|
-
printSchemaDeprecations(findSchemaDeprecations(registry));
|
|
25848
|
-
return registry;
|
|
25830
|
+
const routesResult = routesLoad.ok ? parseRoutes(routesLoad.value, routesPath) : routesLoad;
|
|
25831
|
+
if (!routesResult.ok) errors.push(...routesResult.errors);
|
|
25832
|
+
if (errors.length > 0 || !rolesResult.ok || !routesResult.ok) return { ok: false, errors };
|
|
25833
|
+
return { ok: true, value: buildSchemaRegistry(parsedSchemas, routesResult.value, rolesResult.value) };
|
|
25849
25834
|
}
|
|
25850
25835
|
function resolveAdminRoot2(cwd) {
|
|
25851
25836
|
const cwdRequire = createRequire2(join11(cwd, "package.json"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobbykim/manguito-cms-cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Bobby Kim <bobby.sihun.kim@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/bobbykim89/manguito-cms",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"vite": "^8.1.3",
|
|
32
32
|
"@bobbykim/manguito-cms-admin": "0.5.3",
|
|
33
33
|
"@bobbykim/manguito-cms-api": "0.8.4",
|
|
34
|
-
"@bobbykim/manguito-cms-
|
|
35
|
-
"@bobbykim/manguito-cms-
|
|
34
|
+
"@bobbykim/manguito-cms-db": "0.1.9",
|
|
35
|
+
"@bobbykim/manguito-cms-core": "0.9.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^25.9.5",
|