@nuasite/cms-sidecar 0.70.3 → 0.70.4
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.bundle.js +399 -404
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/cli.bundle.js
CHANGED
|
@@ -23202,7 +23202,6 @@ function parseSource(source) {
|
|
|
23202
23202
|
return null;
|
|
23203
23203
|
}
|
|
23204
23204
|
}
|
|
23205
|
-
var CONTENT_CONFIG_PATHS = ["src/content/config.ts", "src/content.config.ts"];
|
|
23206
23205
|
var ASTRO_CONTENT_CONFIG_ORDER = [
|
|
23207
23206
|
"src/content.config.mjs",
|
|
23208
23207
|
"src/content.config.js",
|
|
@@ -23213,55 +23212,47 @@ var ASTRO_CONTENT_CONFIG_ORDER = [
|
|
|
23213
23212
|
"src/content/config.mjs",
|
|
23214
23213
|
"src/content/config.mts"
|
|
23215
23214
|
];
|
|
23215
|
+
var CONTENT_CONFIG_PATHS = ASTRO_CONTENT_CONFIG_ORDER.filter((configPath) => configPath.endsWith(".ts"));
|
|
23216
23216
|
var READ_CONTENT_CONFIG_PATHS = new Set(CONTENT_CONFIG_PATHS);
|
|
23217
23217
|
var UNREAD_CONTENT_CONFIG_PATHS = ASTRO_CONTENT_CONFIG_ORDER.filter((configPath) => !READ_CONTENT_CONFIG_PATHS.has(configPath));
|
|
23218
|
-
|
|
23218
|
+
var inSrcDir = (configPath, srcDir) => `${srcDir}${configPath.slice("src".length)}`;
|
|
23219
|
+
async function findLoadedContentConfig(fs3, srcDir = "src") {
|
|
23219
23220
|
for (const configPath of ASTRO_CONTENT_CONFIG_ORDER) {
|
|
23220
|
-
|
|
23221
|
-
|
|
23221
|
+
const file = inSrcDir(configPath, srcDir);
|
|
23222
|
+
if (await fs3.exists(file))
|
|
23223
|
+
return { file, read: READ_CONTENT_CONFIG_PATHS.has(configPath), legacy: configPath.startsWith("src/content/") };
|
|
23222
23224
|
}
|
|
23223
23225
|
return null;
|
|
23224
23226
|
}
|
|
23225
|
-
|
|
23226
|
-
|
|
23227
|
-
const loaded = await findLoadedContentConfig(fs3);
|
|
23227
|
+
async function classifyEmptyContentConfig(fs3, srcDir = "src") {
|
|
23228
|
+
const loaded = await findLoadedContentConfig(fs3, srcDir);
|
|
23228
23229
|
if (loaded === null)
|
|
23229
23230
|
return "missing";
|
|
23230
|
-
if (!
|
|
23231
|
+
if (!loaded.read)
|
|
23231
23232
|
return "unread";
|
|
23232
|
-
|
|
23233
|
-
if (!await fs3.exists(configPath))
|
|
23234
|
-
continue;
|
|
23235
|
-
if (parseSource(await fs3.readFile(configPath)) === null) {
|
|
23236
|
-
return "unparseable";
|
|
23237
|
-
}
|
|
23238
|
-
}
|
|
23239
|
-
return "no-collections";
|
|
23233
|
+
return parseSource(await fs3.readFile(loaded.file)) === null ? "unparseable" : "no-collections";
|
|
23240
23234
|
}
|
|
23241
|
-
async function parseContentConfig(fs3, cache) {
|
|
23242
|
-
return (await readContentConfig(fs3, cache)).parsed;
|
|
23235
|
+
async function parseContentConfig(fs3, cache, srcDir = "src") {
|
|
23236
|
+
return (await readContentConfig(fs3, cache, srcDir)).parsed;
|
|
23243
23237
|
}
|
|
23244
|
-
async function readContentConfig(fs3, cache) {
|
|
23245
|
-
let unparsed;
|
|
23238
|
+
async function readContentConfig(fs3, cache, srcDir = "src") {
|
|
23246
23239
|
for (const configPath of CONTENT_CONFIG_PATHS) {
|
|
23240
|
+
const file = inSrcDir(configPath, srcDir);
|
|
23247
23241
|
let stat;
|
|
23248
23242
|
try {
|
|
23249
|
-
stat = await fs3.stat(
|
|
23243
|
+
stat = await fs3.stat(file);
|
|
23250
23244
|
} catch {
|
|
23251
23245
|
continue;
|
|
23252
23246
|
}
|
|
23253
|
-
let cached = cache.get(
|
|
23247
|
+
let cached = cache.get(file);
|
|
23254
23248
|
if (!cached || cached.mtimeMs !== stat.mtimeMs) {
|
|
23255
|
-
const content = await fs3.readFile(
|
|
23249
|
+
const content = await fs3.readFile(file);
|
|
23256
23250
|
cached = { mtimeMs: stat.mtimeMs, ...readConfigSource(content) };
|
|
23257
|
-
cache.set(
|
|
23251
|
+
cache.set(file, cached);
|
|
23258
23252
|
}
|
|
23259
|
-
|
|
23260
|
-
return cached;
|
|
23261
|
-
if (!unparsed && (cached.declared.length > 0 || cached.exportsCollections))
|
|
23262
|
-
unparsed = cached;
|
|
23253
|
+
return cached;
|
|
23263
23254
|
}
|
|
23264
|
-
return
|
|
23255
|
+
return { parsed: new Map, declared: [], partial: false, exportsCollections: false };
|
|
23265
23256
|
}
|
|
23266
23257
|
function readConfigSource(source) {
|
|
23267
23258
|
const result = new Map;
|
|
@@ -24307,9 +24298,284 @@ function dropNestedDerivedFrom(collectionName, path3, fields) {
|
|
|
24307
24298
|
dropNestedDerivedFrom(collectionName, fieldPath, field.fields);
|
|
24308
24299
|
}
|
|
24309
24300
|
}
|
|
24301
|
+
|
|
24302
|
+
// ../cms-core/src/project-config-ast.ts
|
|
24303
|
+
var import_parser4 = __toESM(require_lib(), 1);
|
|
24304
|
+
import path4 from "path";
|
|
24305
|
+
|
|
24306
|
+
// ../cms-core/src/base-path.ts
|
|
24307
|
+
import path3 from "path";
|
|
24308
|
+
function normalizeBasePath(basePath) {
|
|
24309
|
+
return path3.normalize(basePath.replace(/^\.[/\\]+/, "")).replace(/[/\\]+$/, "");
|
|
24310
|
+
}
|
|
24311
|
+
|
|
24312
|
+
// ../cms-core/src/project-config-ast.ts
|
|
24313
|
+
var EMPTY_CONFIG = { listStyles: [] };
|
|
24314
|
+
function parseSource2(source) {
|
|
24315
|
+
try {
|
|
24316
|
+
return import_parser4.parse(source, {
|
|
24317
|
+
sourceType: "module",
|
|
24318
|
+
plugins: ["typescript"],
|
|
24319
|
+
errorRecovery: true
|
|
24320
|
+
});
|
|
24321
|
+
} catch {
|
|
24322
|
+
return null;
|
|
24323
|
+
}
|
|
24324
|
+
}
|
|
24325
|
+
function collectBindings2(ast) {
|
|
24326
|
+
const bindings = new Map;
|
|
24327
|
+
for (const stmt of ast.program.body) {
|
|
24328
|
+
const varDecl = stmt.type === "ExportNamedDeclaration" && stmt.declaration?.type === "VariableDeclaration" ? stmt.declaration : stmt.type === "VariableDeclaration" ? stmt : null;
|
|
24329
|
+
if (!varDecl)
|
|
24330
|
+
continue;
|
|
24331
|
+
for (const decl of varDecl.declarations) {
|
|
24332
|
+
if (decl.id.type === "Identifier" && decl.init)
|
|
24333
|
+
bindings.set(decl.id.name, decl.init);
|
|
24334
|
+
}
|
|
24335
|
+
}
|
|
24336
|
+
return bindings;
|
|
24337
|
+
}
|
|
24338
|
+
function withoutTypeWrappers(node) {
|
|
24339
|
+
let current = node;
|
|
24340
|
+
while (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSNonNullExpression" || current.type === "TSTypeAssertion") {
|
|
24341
|
+
current = current.expression;
|
|
24342
|
+
}
|
|
24343
|
+
return current;
|
|
24344
|
+
}
|
|
24345
|
+
function resolveExpression2(node, bindings, visited = new Set) {
|
|
24346
|
+
let current = withoutTypeWrappers(node);
|
|
24347
|
+
while (current.type === "Identifier") {
|
|
24348
|
+
if (visited.has(current.name))
|
|
24349
|
+
return current;
|
|
24350
|
+
visited.add(current.name);
|
|
24351
|
+
const next = bindings.get(current.name);
|
|
24352
|
+
if (!next)
|
|
24353
|
+
return current;
|
|
24354
|
+
current = withoutTypeWrappers(next);
|
|
24355
|
+
}
|
|
24356
|
+
return current;
|
|
24357
|
+
}
|
|
24358
|
+
function propertyKeyName2(key) {
|
|
24359
|
+
if (key.type === "Identifier")
|
|
24360
|
+
return key.name;
|
|
24361
|
+
if (key.type === "StringLiteral")
|
|
24362
|
+
return key.value;
|
|
24363
|
+
return null;
|
|
24364
|
+
}
|
|
24365
|
+
function objectPropertyValue(node, keyName, bindings) {
|
|
24366
|
+
for (const prop of node.properties) {
|
|
24367
|
+
if (prop.type !== "ObjectProperty")
|
|
24368
|
+
continue;
|
|
24369
|
+
if (propertyKeyName2(prop.key) !== keyName)
|
|
24370
|
+
continue;
|
|
24371
|
+
return resolveExpression2(prop.value, bindings);
|
|
24372
|
+
}
|
|
24373
|
+
return null;
|
|
24374
|
+
}
|
|
24375
|
+
function objectAtPath(root, keys, bindings) {
|
|
24376
|
+
let current = root;
|
|
24377
|
+
for (const key of keys) {
|
|
24378
|
+
const value = objectPropertyValue(current, key, bindings);
|
|
24379
|
+
if (!value || value.type !== "ObjectExpression")
|
|
24380
|
+
return null;
|
|
24381
|
+
current = value;
|
|
24382
|
+
}
|
|
24383
|
+
return current;
|
|
24384
|
+
}
|
|
24385
|
+
function staticString2(node, bindings) {
|
|
24386
|
+
const resolved = resolveExpression2(node, bindings);
|
|
24387
|
+
if (resolved.type === "StringLiteral")
|
|
24388
|
+
return resolved.value;
|
|
24389
|
+
if (resolved.type === "TemplateLiteral" && resolved.expressions.length === 0) {
|
|
24390
|
+
return resolved.quasis[0]?.value.cooked ?? resolved.quasis[0]?.value.raw;
|
|
24391
|
+
}
|
|
24392
|
+
return;
|
|
24393
|
+
}
|
|
24394
|
+
function parseListStyle(node, bindings) {
|
|
24395
|
+
const resolved = resolveExpression2(node, bindings);
|
|
24396
|
+
if (resolved.type !== "ObjectExpression")
|
|
24397
|
+
return null;
|
|
24398
|
+
const labelNode = objectPropertyValue(resolved, "label", bindings);
|
|
24399
|
+
const classNode = objectPropertyValue(resolved, "class", bindings);
|
|
24400
|
+
if (!labelNode || !classNode)
|
|
24401
|
+
return null;
|
|
24402
|
+
const label = staticString2(labelNode, bindings);
|
|
24403
|
+
const className = staticString2(classNode, bindings);
|
|
24404
|
+
if (label === undefined || className === undefined)
|
|
24405
|
+
return null;
|
|
24406
|
+
return { label, class: className };
|
|
24407
|
+
}
|
|
24408
|
+
function parseListStyles(node, bindings) {
|
|
24409
|
+
const styles = [];
|
|
24410
|
+
for (const element of node.elements) {
|
|
24411
|
+
if (!element || element.type === "SpreadElement")
|
|
24412
|
+
continue;
|
|
24413
|
+
const style = parseListStyle(element, bindings);
|
|
24414
|
+
if (style)
|
|
24415
|
+
styles.push(style);
|
|
24416
|
+
}
|
|
24417
|
+
return styles;
|
|
24418
|
+
}
|
|
24419
|
+
function configObjectFromDefaultExport(ast, bindings) {
|
|
24420
|
+
for (const stmt of ast.program.body) {
|
|
24421
|
+
if (stmt.type !== "ExportDefaultDeclaration")
|
|
24422
|
+
continue;
|
|
24423
|
+
const declaration = resolveExpression2(stmt.declaration, bindings);
|
|
24424
|
+
if (declaration.type === "ObjectExpression")
|
|
24425
|
+
return declaration;
|
|
24426
|
+
if (declaration.type === "CallExpression") {
|
|
24427
|
+
const firstArg = declaration.arguments[0];
|
|
24428
|
+
if (!firstArg || firstArg.type === "SpreadElement")
|
|
24429
|
+
return null;
|
|
24430
|
+
const resolvedArg = resolveExpression2(firstArg, bindings);
|
|
24431
|
+
if (resolvedArg.type === "ObjectExpression")
|
|
24432
|
+
return resolvedArg;
|
|
24433
|
+
}
|
|
24434
|
+
}
|
|
24435
|
+
return null;
|
|
24436
|
+
}
|
|
24437
|
+
var CMS_INTEGRATION_OPTIONS_PATH = {
|
|
24438
|
+
"@nuasite/cms": [],
|
|
24439
|
+
"@nuasite/nua": ["cms"],
|
|
24440
|
+
"@nuasite/nua/integration": ["cms"]
|
|
24441
|
+
};
|
|
24442
|
+
function collectCmsIntegrationImports(ast) {
|
|
24443
|
+
const imports = new Map;
|
|
24444
|
+
for (const stmt of ast.program.body) {
|
|
24445
|
+
if (stmt.type !== "ImportDeclaration")
|
|
24446
|
+
continue;
|
|
24447
|
+
const optionsPath = CMS_INTEGRATION_OPTIONS_PATH[stmt.source.value];
|
|
24448
|
+
if (!optionsPath)
|
|
24449
|
+
continue;
|
|
24450
|
+
for (const specifier of stmt.specifiers) {
|
|
24451
|
+
const importedName2 = specifier.type === "ImportDefaultSpecifier" ? "default" : specifier.type === "ImportSpecifier" ? propertyKeyName2(specifier.imported) : null;
|
|
24452
|
+
if (importedName2 === "default" || importedName2 === "nua" && optionsPath.length > 0)
|
|
24453
|
+
imports.set(specifier.local.name, optionsPath);
|
|
24454
|
+
}
|
|
24455
|
+
}
|
|
24456
|
+
return imports;
|
|
24457
|
+
}
|
|
24458
|
+
function defaultExportWrapper(ast, bindings) {
|
|
24459
|
+
const exported = ast.program.body.find((stmt) => stmt.type === "ExportDefaultDeclaration");
|
|
24460
|
+
const declaration = exported?.type === "ExportDefaultDeclaration" ? resolveExpression2(exported.declaration, bindings) : null;
|
|
24461
|
+
if (declaration?.type !== "CallExpression")
|
|
24462
|
+
return "astro";
|
|
24463
|
+
const callee = withoutTypeWrappers(declaration.callee);
|
|
24464
|
+
if (callee.type !== "Identifier")
|
|
24465
|
+
return "unknown";
|
|
24466
|
+
for (const stmt of ast.program.body) {
|
|
24467
|
+
if (stmt.type !== "ImportDeclaration" || !stmt.specifiers.some((specifier) => specifier.local.name === callee.name))
|
|
24468
|
+
continue;
|
|
24469
|
+
if (stmt.source.value === "@nuasite/nua/config")
|
|
24470
|
+
return "nua";
|
|
24471
|
+
if (stmt.source.value === "astro/config")
|
|
24472
|
+
return "astro";
|
|
24473
|
+
}
|
|
24474
|
+
return "unknown";
|
|
24475
|
+
}
|
|
24476
|
+
function nuaCmsInstance(cms, bindings) {
|
|
24477
|
+
if (cms?.type === "BooleanLiteral" && !cms.value)
|
|
24478
|
+
return;
|
|
24479
|
+
return cms?.type === "ObjectExpression" ? objectAtPath(cms, ["cmsConfig"], bindings) : null;
|
|
24480
|
+
}
|
|
24481
|
+
function wrapperCmsInstance(ast, configObject, bindings) {
|
|
24482
|
+
const wrapper = defaultExportWrapper(ast, bindings);
|
|
24483
|
+
if (wrapper === "astro")
|
|
24484
|
+
return;
|
|
24485
|
+
const nua = objectPropertyValue(configObject, "nua", bindings);
|
|
24486
|
+
const cms = nua?.type === "ObjectExpression" ? objectPropertyValue(nua, "cms", bindings) : null;
|
|
24487
|
+
if (wrapper === "unknown") {
|
|
24488
|
+
return cms?.type === "ObjectExpression" ? nuaCmsInstance(cms, bindings) : undefined;
|
|
24489
|
+
}
|
|
24490
|
+
if (nua?.type === "BooleanLiteral" && !nua.value)
|
|
24491
|
+
return;
|
|
24492
|
+
return nuaCmsInstance(cms, bindings);
|
|
24493
|
+
}
|
|
24494
|
+
function effectiveCmsConfig(ast, configObject, bindings) {
|
|
24495
|
+
let fromNua = wrapperCmsInstance(ast, configObject, bindings);
|
|
24496
|
+
let fromCms;
|
|
24497
|
+
const integrations = objectPropertyValue(configObject, "integrations", bindings);
|
|
24498
|
+
const integrationImports = collectCmsIntegrationImports(ast);
|
|
24499
|
+
for (const element of integrations?.type === "ArrayExpression" ? integrations.elements : []) {
|
|
24500
|
+
if (!element || element.type === "SpreadElement")
|
|
24501
|
+
continue;
|
|
24502
|
+
const call = resolveExpression2(element, bindings);
|
|
24503
|
+
const callee = call.type === "CallExpression" ? withoutTypeWrappers(call.callee) : null;
|
|
24504
|
+
if (call.type !== "CallExpression" || callee?.type !== "Identifier")
|
|
24505
|
+
continue;
|
|
24506
|
+
const optionsPath = integrationImports.get(callee.name);
|
|
24507
|
+
if (!optionsPath)
|
|
24508
|
+
continue;
|
|
24509
|
+
const firstArg = call.arguments[0];
|
|
24510
|
+
const options = firstArg && firstArg.type !== "SpreadElement" ? resolveExpression2(firstArg, bindings) : null;
|
|
24511
|
+
const optionsObject = options?.type === "ObjectExpression" ? options : null;
|
|
24512
|
+
if (optionsPath.length === 0) {
|
|
24513
|
+
fromCms = optionsObject && objectAtPath(optionsObject, ["cmsConfig"], bindings);
|
|
24514
|
+
} else if (fromNua === undefined) {
|
|
24515
|
+
fromNua = nuaCmsInstance(optionsObject && objectPropertyValue(optionsObject, "cms", bindings), bindings);
|
|
24516
|
+
}
|
|
24517
|
+
}
|
|
24518
|
+
return fromNua !== undefined ? fromNua : fromCms ?? null;
|
|
24519
|
+
}
|
|
24520
|
+
function parseConfigListStyles(cmsConfig, bindings) {
|
|
24521
|
+
const listStylesNode = cmsConfig ? objectPropertyValue(cmsConfig, "listStyles", bindings) : null;
|
|
24522
|
+
return listStylesNode?.type === "ArrayExpression" ? parseListStyles(listStylesNode, bindings) : [];
|
|
24523
|
+
}
|
|
24524
|
+
function staticStringOf(object, key, bindings) {
|
|
24525
|
+
const node = object ? objectPropertyValue(object, key, bindings) : null;
|
|
24526
|
+
return node && staticString2(node, bindings) || undefined;
|
|
24527
|
+
}
|
|
24528
|
+
function parseLocale(cmsConfig, configObject, bindings) {
|
|
24529
|
+
return staticStringOf(cmsConfig, "locale", bindings) ?? staticStringOf(objectAtPath(configObject, ["i18n"], bindings), "defaultLocale", bindings);
|
|
24530
|
+
}
|
|
24531
|
+
function parseProjectCmsConfigSource(source) {
|
|
24532
|
+
const ast = parseSource2(source);
|
|
24533
|
+
if (!ast)
|
|
24534
|
+
return EMPTY_CONFIG;
|
|
24535
|
+
const bindings = collectBindings2(ast);
|
|
24536
|
+
const configObject = configObjectFromDefaultExport(ast, bindings);
|
|
24537
|
+
if (!configObject)
|
|
24538
|
+
return EMPTY_CONFIG;
|
|
24539
|
+
const cmsConfig = effectiveCmsConfig(ast, configObject, bindings);
|
|
24540
|
+
const locale = parseLocale(cmsConfig, configObject, bindings);
|
|
24541
|
+
return { listStyles: parseConfigListStyles(cmsConfig, bindings), ...locale ? { locale } : {} };
|
|
24542
|
+
}
|
|
24543
|
+
var ASTRO_CONFIG_FILES = ["astro.config.mjs", "astro.config.js", "astro.config.ts", "astro.config.mts"];
|
|
24544
|
+
async function readAstroConfigSource(fs3) {
|
|
24545
|
+
for (const file of ASTRO_CONFIG_FILES) {
|
|
24546
|
+
try {
|
|
24547
|
+
return await fs3.readFile(file);
|
|
24548
|
+
} catch {
|
|
24549
|
+
continue;
|
|
24550
|
+
}
|
|
24551
|
+
}
|
|
24552
|
+
return null;
|
|
24553
|
+
}
|
|
24554
|
+
async function parseProjectCmsConfig(fs3) {
|
|
24555
|
+
const source = await readAstroConfigSource(fs3);
|
|
24556
|
+
return source === null ? EMPTY_CONFIG : parseProjectCmsConfigSource(source);
|
|
24557
|
+
}
|
|
24558
|
+
async function readAstroSrcDir(fs3) {
|
|
24559
|
+
const source = await readAstroConfigSource(fs3);
|
|
24560
|
+
return source === null ? "src" : astroSrcDirOf(source);
|
|
24561
|
+
}
|
|
24562
|
+
function astroSrcDirOf(source) {
|
|
24563
|
+
const roots = configOptionMentions(source, "root");
|
|
24564
|
+
const srcDirs = configOptionMentions(source, "srcDir");
|
|
24565
|
+
if (roots === null || srcDirs === null)
|
|
24566
|
+
return null;
|
|
24567
|
+
if (roots.some((root) => root === null || normalizeBasePath(root) !== "."))
|
|
24568
|
+
return null;
|
|
24569
|
+
if (srcDirs.length === 0)
|
|
24570
|
+
return "src";
|
|
24571
|
+
const [srcDir, ...others] = srcDirs.map((literal) => literal === null ? null : normalizeBasePath(literal));
|
|
24572
|
+
if (srcDir === null || srcDir === undefined || others.some((other) => other !== srcDir))
|
|
24573
|
+
return null;
|
|
24574
|
+
return path4.isAbsolute(srcDir) || srcDir.startsWith("..") ? null : srcDir;
|
|
24575
|
+
}
|
|
24310
24576
|
// ../cms-core/src/collection-scanner.ts
|
|
24311
24577
|
var import_yaml2 = __toESM(require_dist(), 1);
|
|
24312
|
-
import
|
|
24578
|
+
import path5 from "path";
|
|
24313
24579
|
var DATE_PATTERN = /^\d{4}-\d{2}-\d{2}/;
|
|
24314
24580
|
var URL_PATTERN = /^(https?:\/\/|\/)/;
|
|
24315
24581
|
var IMAGE_EXTENSIONS = /\.(jpg|jpeg|png|gif|webp|svg|avif)$/i;
|
|
@@ -24582,7 +24848,7 @@ function assembleCollectionDefinition(collectionName, contentDir, fieldMap, entr
|
|
|
24582
24848
|
return {
|
|
24583
24849
|
name: collectionName,
|
|
24584
24850
|
label,
|
|
24585
|
-
path:
|
|
24851
|
+
path: path5.join(contentDir, collectionName),
|
|
24586
24852
|
entryCount,
|
|
24587
24853
|
fields,
|
|
24588
24854
|
fileExtension: "md",
|
|
@@ -24591,10 +24857,10 @@ function assembleCollectionDefinition(collectionName, contentDir, fieldMap, entr
|
|
|
24591
24857
|
};
|
|
24592
24858
|
}
|
|
24593
24859
|
function getCollectionSourceBasePath(basePath, collectionName, contentDir) {
|
|
24594
|
-
const defaultCollectionPath =
|
|
24860
|
+
const defaultCollectionPath = path5.join(contentDir, collectionName);
|
|
24595
24861
|
const normalizedBasePath = normalizeBasePath(basePath);
|
|
24596
|
-
if (normalizedBasePath ===
|
|
24597
|
-
return
|
|
24862
|
+
if (normalizedBasePath === path5.normalize(defaultCollectionPath)) {
|
|
24863
|
+
return path5.join(contentDir, collectionName);
|
|
24598
24864
|
}
|
|
24599
24865
|
return normalizedBasePath;
|
|
24600
24866
|
}
|
|
@@ -24608,13 +24874,13 @@ async function buildCollectionDefinition(fs3, basePath, sources, collectionName,
|
|
|
24608
24874
|
const allDirectives = {};
|
|
24609
24875
|
const entryInfos = [];
|
|
24610
24876
|
let hasDraft = false;
|
|
24611
|
-
const fileContents = await Promise.all(sources.map((s) => fs3.readFile(
|
|
24877
|
+
const fileContents = await Promise.all(sources.map((s) => fs3.readFile(path5.join(basePath, s.relPath)).catch(() => null)));
|
|
24612
24878
|
for (let i = 0;i < sources.length; i++) {
|
|
24613
24879
|
const source = sources[i];
|
|
24614
24880
|
const content = fileContents[i];
|
|
24615
24881
|
if (content === null)
|
|
24616
24882
|
continue;
|
|
24617
|
-
const parsed = parseFrontmatter(content,
|
|
24883
|
+
const parsed = parseFrontmatter(content, path5.join(basePath, source.relPath), frontmatterMemo);
|
|
24618
24884
|
const frontmatter = parsed?.data ?? null;
|
|
24619
24885
|
for (const [key, value] of Object.entries(parsed?.directives ?? {})) {
|
|
24620
24886
|
if (!allDirectives[key]) {
|
|
@@ -24623,7 +24889,7 @@ async function buildCollectionDefinition(fs3, basePath, sources, collectionName,
|
|
|
24623
24889
|
}
|
|
24624
24890
|
const entryInfo = {
|
|
24625
24891
|
slug: source.slug,
|
|
24626
|
-
sourcePath:
|
|
24892
|
+
sourcePath: path5.join(sourceBasePath, source.relPath)
|
|
24627
24893
|
};
|
|
24628
24894
|
if (frontmatter) {
|
|
24629
24895
|
const title = deriveEntryTitle(frontmatter);
|
|
@@ -24657,7 +24923,7 @@ async function buildDataCollectionDefinition(fs3, basePath, sources, collectionN
|
|
|
24657
24923
|
const fieldMap = new Map;
|
|
24658
24924
|
const entryInfos = [];
|
|
24659
24925
|
const ext = sources.some((s) => s.relPath.endsWith(".json")) ? "json" : sources.some((s) => s.relPath.endsWith(".yaml")) ? "yaml" : "yml";
|
|
24660
|
-
const fileContents = await Promise.all(sources.map((s) => fs3.readFile(
|
|
24926
|
+
const fileContents = await Promise.all(sources.map((s) => fs3.readFile(path5.join(basePath, s.relPath)).catch(() => null)));
|
|
24661
24927
|
for (let i = 0;i < sources.length; i++) {
|
|
24662
24928
|
const source = sources[i];
|
|
24663
24929
|
const raw = fileContents[i];
|
|
@@ -24675,7 +24941,7 @@ async function buildDataCollectionDefinition(fs3, basePath, sources, collectionN
|
|
|
24675
24941
|
entryInfos.push({
|
|
24676
24942
|
slug: source.slug,
|
|
24677
24943
|
title,
|
|
24678
|
-
sourcePath:
|
|
24944
|
+
sourcePath: path5.join(sourceBasePath, source.relPath),
|
|
24679
24945
|
data
|
|
24680
24946
|
});
|
|
24681
24947
|
collectFieldObservations(fieldMap, data, sources.length);
|
|
@@ -24706,8 +24972,8 @@ async function scanCollection(fs3, collectionPath, collectionName, contentDir, f
|
|
|
24706
24972
|
if (takenSlugs.has(dir.name))
|
|
24707
24973
|
return null;
|
|
24708
24974
|
for (const ext of ["md", "mdx"]) {
|
|
24709
|
-
const relPath =
|
|
24710
|
-
if (await fs3.exists(
|
|
24975
|
+
const relPath = path5.join(dir.name, `index.${ext}`);
|
|
24976
|
+
if (await fs3.exists(path5.join(collectionPath, relPath))) {
|
|
24711
24977
|
return { slug: dir.name, relPath };
|
|
24712
24978
|
}
|
|
24713
24979
|
}
|
|
@@ -24723,8 +24989,8 @@ async function scanCollection(fs3, collectionPath, collectionName, contentDir, f
|
|
|
24723
24989
|
}
|
|
24724
24990
|
async function globLoaderFiles(fs3, baseRel, pattern, options) {
|
|
24725
24991
|
const isPrivate = (relToBase) => relToBase.split("/").some((seg) => seg.startsWith("_") || seg.startsWith("."));
|
|
24726
|
-
const matches = await fs3.glob(
|
|
24727
|
-
return matches.map((rel) =>
|
|
24992
|
+
const matches = await fs3.glob(path5.join(baseRel, pattern), { ...options, skipDirectory: (dir) => isPrivate(path5.relative(baseRel, dir)) });
|
|
24993
|
+
return matches.map((rel) => path5.relative(baseRel, rel)).filter((relToBase) => !isPrivate(relToBase));
|
|
24728
24994
|
}
|
|
24729
24995
|
async function scanGlobCollection(fs3, collectionName, baseRel, pattern, contentDir, frontmatterMemo) {
|
|
24730
24996
|
const rels = await globLoaderFiles(fs3, baseRel, pattern);
|
|
@@ -25093,8 +25359,8 @@ async function scanDataCollection(fs3, collectionPath, collectionName, contentDi
|
|
|
25093
25359
|
if (takenSlugs.has(dir.name))
|
|
25094
25360
|
return null;
|
|
25095
25361
|
for (const indexExt of ["json", "yaml", "yml"]) {
|
|
25096
|
-
const relPath =
|
|
25097
|
-
if (await fs3.exists(
|
|
25362
|
+
const relPath = path5.join(dir.name, `index.${indexExt}`);
|
|
25363
|
+
if (await fs3.exists(path5.join(collectionPath, relPath))) {
|
|
25098
25364
|
return { slug: dir.name, relPath };
|
|
25099
25365
|
}
|
|
25100
25366
|
}
|
|
@@ -25106,9 +25372,6 @@ async function scanDataCollection(fs3, collectionPath, collectionName, contentDi
|
|
|
25106
25372
|
}
|
|
25107
25373
|
return await buildDataCollectionDefinition(fs3, collectionPath, sources, collectionName, contentDir);
|
|
25108
25374
|
}
|
|
25109
|
-
function normalizeBasePath(basePath) {
|
|
25110
|
-
return path3.normalize(basePath.replace(/^\.[/\\]+/, "")).replace(/[/\\]+$/, "");
|
|
25111
|
-
}
|
|
25112
25375
|
var WHOLE_DIRECTORY_PATTERN = /^(?:\*\*[/\\])*\*(?:\.(?:\{([^{}/\\]*)\}|([A-Za-z0-9]+)))?$/;
|
|
25113
25376
|
function patternCoversWholeCollection(pattern, definition) {
|
|
25114
25377
|
const match = pattern.trim().replace(/^\.[/\\]+/, "").match(WHOLE_DIRECTORY_PATTERN);
|
|
@@ -25118,7 +25381,7 @@ function patternCoversWholeCollection(pattern, definition) {
|
|
|
25118
25381
|
if (braceGroup === undefined && singleExtension === undefined)
|
|
25119
25382
|
return true;
|
|
25120
25383
|
const patternExtensions = new Set((braceGroup !== undefined ? braceGroup.split(",") : [singleExtension]).map((ext) => ext.trim().replace(/^\./, "").toLowerCase()).filter(Boolean));
|
|
25121
|
-
const scannedExtensions = new Set((definition.entries ?? []).map((entry) =>
|
|
25384
|
+
const scannedExtensions = new Set((definition.entries ?? []).map((entry) => path5.extname(entry.sourcePath).slice(1).toLowerCase()).filter(Boolean));
|
|
25122
25385
|
if (scannedExtensions.size === 0)
|
|
25123
25386
|
return false;
|
|
25124
25387
|
for (const ext of scannedExtensions) {
|
|
@@ -25134,14 +25397,14 @@ async function scanCollections(fs3, contentDir = "src/content", parseCache = new
|
|
|
25134
25397
|
const entries = await fs3.list(contentDir);
|
|
25135
25398
|
const scanPromises = entries.filter((entry) => entry.isDirectory && !entry.name.startsWith("_") && !entry.name.startsWith(".")).map(async (entry) => {
|
|
25136
25399
|
try {
|
|
25137
|
-
const collectionPath =
|
|
25400
|
+
const collectionPath = path5.join(contentDir, entry.name);
|
|
25138
25401
|
const definition = await scanCollection(fs3, collectionPath, entry.name, contentDir, frontmatterMemo) ?? await scanDataCollection(fs3, collectionPath, entry.name, contentDir);
|
|
25139
25402
|
if (definition) {
|
|
25140
25403
|
collections[entry.name] = definition;
|
|
25141
25404
|
}
|
|
25142
25405
|
} catch (error) {
|
|
25143
25406
|
console.warn(`[cms] Skipping collection "${entry.name}" \u2014 scan failed:`, error);
|
|
25144
|
-
failedScans.set(entry.name, { name: entry.name, reason: "scan-failed", base:
|
|
25407
|
+
failedScans.set(entry.name, { name: entry.name, reason: "scan-failed", base: path5.join(contentDir, entry.name) });
|
|
25145
25408
|
}
|
|
25146
25409
|
});
|
|
25147
25410
|
await Promise.all(scanPromises);
|
|
@@ -25226,7 +25489,7 @@ function readsAsRelativeDirectory(base) {
|
|
|
25226
25489
|
return false;
|
|
25227
25490
|
try {
|
|
25228
25491
|
const asUrl = decodeURIComponent(new URL(base, "file:///project-root/").pathname).replace(/\/{2,}/g, "/").replace(/\/+$/, "");
|
|
25229
|
-
const asPath = normalizeBasePath(base).split(
|
|
25492
|
+
const asPath = normalizeBasePath(base).split(path5.sep).join("/");
|
|
25230
25493
|
return asUrl === (asPath === "." ? "/project-root" : `/project-root/${asPath}`);
|
|
25231
25494
|
} catch {
|
|
25232
25495
|
return false;
|
|
@@ -25235,7 +25498,7 @@ function readsAsRelativeDirectory(base) {
|
|
|
25235
25498
|
function declaredLocation(declaration, contentDir) {
|
|
25236
25499
|
const location = {};
|
|
25237
25500
|
if (declaration.noLoader)
|
|
25238
|
-
location.base =
|
|
25501
|
+
location.base = path5.join(contentDir, declaration.name);
|
|
25239
25502
|
if (declaration.loaderBase !== undefined)
|
|
25240
25503
|
location.base = normalizeBasePath(declaration.loaderBase);
|
|
25241
25504
|
if (declaration.loaderPattern !== undefined)
|
|
@@ -25246,13 +25509,13 @@ function declaredLocation(declaration, contentDir) {
|
|
|
25246
25509
|
}
|
|
25247
25510
|
async function contentDirectoryFiles(fs3, directory, entryFile) {
|
|
25248
25511
|
const files = await globLoaderFiles(fs3, directory, "**/*", { followSymlinks: true, maxLinkedDirectories: REPORT_LINKED_DIRECTORY_LIMIT });
|
|
25249
|
-
return files.filter((file) => entryFile.test(file)).map((file) =>
|
|
25512
|
+
return files.filter((file) => entryFile.test(file)).map((file) => path5.join(directory, file));
|
|
25250
25513
|
}
|
|
25251
25514
|
async function declaredEntryFiles(fs3, contentDir, declaration) {
|
|
25252
25515
|
if (declaration.noLoader) {
|
|
25253
25516
|
if (!readsAsRelativeDirectory(declaration.name))
|
|
25254
25517
|
return null;
|
|
25255
|
-
return { exact: true, files: await contentDirectoryFiles(fs3,
|
|
25518
|
+
return { exact: true, files: await contentDirectoryFiles(fs3, path5.join(contentDir, declaration.name), ENTRY_FILE) };
|
|
25256
25519
|
}
|
|
25257
25520
|
const declaredBase = declaration.loaderBase;
|
|
25258
25521
|
if (declaredBase === undefined || !readsAsRelativeDirectory(declaredBase))
|
|
@@ -25262,14 +25525,14 @@ async function declaredEntryFiles(fs3, contentDir, declaration) {
|
|
|
25262
25525
|
const patterns = pattern !== undefined ? [pattern] : declaration.loaderPatterns;
|
|
25263
25526
|
if (patterns === undefined)
|
|
25264
25527
|
return null;
|
|
25265
|
-
const exact = pattern !== undefined && !UNSUPPORTED_GLOB_SYNTAX.test(pattern) && !UNSUPPORTED_GLOB_SYNTAX.test(
|
|
25528
|
+
const exact = pattern !== undefined && !UNSUPPORTED_GLOB_SYNTAX.test(pattern) && !UNSUPPORTED_GLOB_SYNTAX.test(path5.posix.normalize(pattern));
|
|
25266
25529
|
if (!exact && (base === "." || patterns.some((one) => LEAVES_THE_BASE.test(one))))
|
|
25267
25530
|
return null;
|
|
25268
|
-
const matches = await fs3.glob(
|
|
25531
|
+
const matches = await fs3.glob(path5.join(base, exact ? pattern : "**/*"), {
|
|
25269
25532
|
followSymlinks: true,
|
|
25270
25533
|
maxLinkedDirectories: REPORT_LINKED_DIRECTORY_LIMIT
|
|
25271
25534
|
});
|
|
25272
|
-
const files = matches.filter((file) => ENTRY_FILE.test(file) && patterns.some((one) => mayTakeDotPath(one,
|
|
25535
|
+
const files = matches.filter((file) => ENTRY_FILE.test(file) && patterns.some((one) => mayTakeDotPath(one, path5.relative(base, file))));
|
|
25273
25536
|
return { exact, files };
|
|
25274
25537
|
}
|
|
25275
25538
|
function mayTakeDotPath(pattern, file) {
|
|
@@ -25285,37 +25548,14 @@ function mayTakeDotPath(pattern, file) {
|
|
|
25285
25548
|
const takesDot = (part) => /[[(]/.test(blurred ? pattern : part);
|
|
25286
25549
|
return (!dotFile || takesDot(pattern.slice(cut + 1))) && (!dotDirectory || takesDot(pattern.slice(0, Math.max(cut, 0))));
|
|
25287
25550
|
}
|
|
25288
|
-
var ASTRO_CONFIG_PATHS = ["astro.config.mjs", "astro.config.js", "astro.config.ts", "astro.config.mts"];
|
|
25289
|
-
async function customSrcDir(fs3) {
|
|
25290
|
-
for (const configPath of ASTRO_CONFIG_PATHS) {
|
|
25291
|
-
const source = await fs3.readFile(configPath).catch(() => null);
|
|
25292
|
-
if (source === null)
|
|
25293
|
-
continue;
|
|
25294
|
-
const roots = configOptionMentions(source, "root");
|
|
25295
|
-
const srcDirs = configOptionMentions(source, "srcDir");
|
|
25296
|
-
if (roots === null || srcDirs === null)
|
|
25297
|
-
return null;
|
|
25298
|
-
if (roots.some((root) => root === null || normalizeBasePath(root) !== "."))
|
|
25299
|
-
return null;
|
|
25300
|
-
if (srcDirs.length === 0)
|
|
25301
|
-
return;
|
|
25302
|
-
const [srcDir, ...others] = srcDirs.map((literal) => literal === null ? null : normalizeBasePath(literal));
|
|
25303
|
-
if (srcDir === null || srcDir === undefined || others.some((other) => other !== srcDir))
|
|
25304
|
-
return null;
|
|
25305
|
-
if (srcDir === "src")
|
|
25306
|
-
return;
|
|
25307
|
-
return path3.isAbsolute(srcDir) || srcDir.startsWith("..") ? null : srcDir;
|
|
25308
|
-
}
|
|
25309
|
-
return;
|
|
25310
|
-
}
|
|
25311
25551
|
async function contentConfigStatus(fs3, config) {
|
|
25312
25552
|
const configPaths = [...CONTENT_CONFIG_PATHS, ...UNREAD_CONTENT_CONFIG_PATHS];
|
|
25313
|
-
const srcDir = await
|
|
25553
|
+
const srcDir = await readAstroSrcDir(fs3);
|
|
25314
25554
|
if (srcDir === null)
|
|
25315
25555
|
return "unreadable";
|
|
25316
|
-
if (srcDir !==
|
|
25556
|
+
if (srcDir !== "src") {
|
|
25317
25557
|
for (const configPath of configPaths) {
|
|
25318
|
-
if (await fs3.exists(
|
|
25558
|
+
if (await fs3.exists(path5.join(srcDir, path5.relative("src", configPath))))
|
|
25319
25559
|
return "unreadable";
|
|
25320
25560
|
}
|
|
25321
25561
|
}
|
|
@@ -25339,7 +25579,7 @@ async function buildScanReport(fs3, contentDir, collections, config, failedScans
|
|
|
25339
25579
|
const listed = new Set;
|
|
25340
25580
|
for (const definition of Object.values(collections)) {
|
|
25341
25581
|
for (const entry of definition.entries ?? [])
|
|
25342
|
-
listed.add(
|
|
25582
|
+
listed.add(path5.normalize(entry.sourcePath));
|
|
25343
25583
|
if ((definition.entries?.length ?? 0) >= definition.entryCount)
|
|
25344
25584
|
continue;
|
|
25345
25585
|
const declaration = declaredByName.get(definition.name);
|
|
@@ -25369,7 +25609,7 @@ async function buildScanReport(fs3, contentDir, collections, config, failedScans
|
|
|
25369
25609
|
}
|
|
25370
25610
|
if (loads === null) {
|
|
25371
25611
|
unresolved.set(name, { name, reason: "unsupported-loader", ...location });
|
|
25372
|
-
} else if (!loads.files.every((file) => listed.has(
|
|
25612
|
+
} else if (!loads.files.every((file) => listed.has(path5.normalize(file)))) {
|
|
25373
25613
|
unresolved.set(name, { name, reason: loads.exact ? "unlisted-entries" : "unsupported-loader", ...location });
|
|
25374
25614
|
}
|
|
25375
25615
|
}
|
|
@@ -25378,11 +25618,11 @@ async function buildScanReport(fs3, contentDir, collections, config, failedScans
|
|
|
25378
25618
|
for (const name of contentDirectories) {
|
|
25379
25619
|
if (declaredByName.has(name) || unresolved.has(name) || failedScans.has(name))
|
|
25380
25620
|
continue;
|
|
25381
|
-
const directory =
|
|
25621
|
+
const directory = path5.join(contentDir, name);
|
|
25382
25622
|
const files = await contentDirectoryFiles(fs3, directory, MARKDOWN_FILE).catch(() => null);
|
|
25383
25623
|
if (files === null)
|
|
25384
25624
|
unresolved.set(name, { name, reason: "scan-failed", base: directory });
|
|
25385
|
-
else if (!files.every((file) => listed.has(
|
|
25625
|
+
else if (!files.every((file) => listed.has(path5.normalize(file))))
|
|
25386
25626
|
unresolved.set(name, { name, reason: "unlisted-entries", base: directory });
|
|
25387
25627
|
}
|
|
25388
25628
|
}
|
|
@@ -25417,8 +25657,8 @@ function warnOnPathnameCollisions(collections) {
|
|
|
25417
25657
|
}
|
|
25418
25658
|
}
|
|
25419
25659
|
// ../cms-core/src/component-registry.ts
|
|
25420
|
-
var
|
|
25421
|
-
import
|
|
25660
|
+
var import_parser5 = __toESM(require_lib(), 1);
|
|
25661
|
+
import path6 from "path";
|
|
25422
25662
|
async function scanComponentDefinitions(fs3, componentDirs = ["src/components"]) {
|
|
25423
25663
|
const components = {};
|
|
25424
25664
|
for (const dir of componentDirs) {
|
|
@@ -25439,7 +25679,7 @@ async function scanDirectory(fs3, relativePath, components) {
|
|
|
25439
25679
|
}
|
|
25440
25680
|
async function parseComponent(fs3, relativePath, components) {
|
|
25441
25681
|
const content = await fs3.readFile(relativePath);
|
|
25442
|
-
const componentName =
|
|
25682
|
+
const componentName = path6.basename(relativePath, ".astro");
|
|
25443
25683
|
const props = extractProps(content);
|
|
25444
25684
|
const slots = extractSlots(content);
|
|
25445
25685
|
const description = extractDescription(content);
|
|
@@ -25460,7 +25700,7 @@ ${propsContent}
|
|
|
25460
25700
|
}`;
|
|
25461
25701
|
let ast;
|
|
25462
25702
|
try {
|
|
25463
|
-
ast =
|
|
25703
|
+
ast = import_parser5.parse(synthetic, {
|
|
25464
25704
|
sourceType: "module",
|
|
25465
25705
|
plugins: ["typescript"],
|
|
25466
25706
|
errorRecovery: true
|
|
@@ -25677,9 +25917,9 @@ class CmsCommitConflictError extends Error {
|
|
|
25677
25917
|
function digestBytes(content) {
|
|
25678
25918
|
return `sha256:${createHash("sha256").update(content).digest("hex")}`;
|
|
25679
25919
|
}
|
|
25680
|
-
function normalize(
|
|
25920
|
+
function normalize(path7) {
|
|
25681
25921
|
const segments = [];
|
|
25682
|
-
for (const segment of
|
|
25922
|
+
for (const segment of path7.split("/")) {
|
|
25683
25923
|
if (segment === "" || segment === ".")
|
|
25684
25924
|
continue;
|
|
25685
25925
|
if (segment === ".." && segments.length > 0 && segments.at(-1) !== "..")
|
|
@@ -25689,67 +25929,67 @@ function normalize(path5) {
|
|
|
25689
25929
|
}
|
|
25690
25930
|
return segments.join("/");
|
|
25691
25931
|
}
|
|
25692
|
-
function isBelow(
|
|
25693
|
-
return dir === "" ||
|
|
25932
|
+
function isBelow(path7, dir) {
|
|
25933
|
+
return dir === "" || path7.startsWith(`${dir}/`);
|
|
25694
25934
|
}
|
|
25695
|
-
function missing(
|
|
25696
|
-
return Object.assign(new Error(`ENOENT: no such file, '${
|
|
25935
|
+
function missing(path7) {
|
|
25936
|
+
return Object.assign(new Error(`ENOENT: no such file, '${path7}'`), { code: "ENOENT" });
|
|
25697
25937
|
}
|
|
25698
25938
|
function createStagedFileSystem(base) {
|
|
25699
25939
|
const reads = new Map;
|
|
25700
25940
|
const staged = new Map;
|
|
25701
25941
|
const encoder = new TextEncoder;
|
|
25702
25942
|
const decoder = new TextDecoder;
|
|
25703
|
-
function observe(
|
|
25704
|
-
const recorded = reads.get(
|
|
25943
|
+
function observe(path7, version) {
|
|
25944
|
+
const recorded = reads.get(path7);
|
|
25705
25945
|
if (recorded === undefined || recorded.kind === "present" && version.kind === "content")
|
|
25706
|
-
reads.set(
|
|
25946
|
+
reads.set(path7, version);
|
|
25707
25947
|
}
|
|
25708
|
-
async function observeBeforeChange(
|
|
25709
|
-
if (staged.has(
|
|
25948
|
+
async function observeBeforeChange(path7) {
|
|
25949
|
+
if (staged.has(path7))
|
|
25710
25950
|
return;
|
|
25711
|
-
const recorded = reads.get(
|
|
25951
|
+
const recorded = reads.get(path7);
|
|
25712
25952
|
if (recorded !== undefined && recorded.kind !== "present")
|
|
25713
25953
|
return;
|
|
25714
|
-
observe(
|
|
25954
|
+
observe(path7, await versionOf(base, path7));
|
|
25715
25955
|
}
|
|
25716
25956
|
async function readBytes(rawPath) {
|
|
25717
|
-
const
|
|
25718
|
-
const change = staged.get(
|
|
25957
|
+
const path7 = normalize(rawPath);
|
|
25958
|
+
const change = staged.get(path7);
|
|
25719
25959
|
if (change === null)
|
|
25720
|
-
throw missing(
|
|
25960
|
+
throw missing(path7);
|
|
25721
25961
|
if (change !== undefined)
|
|
25722
25962
|
return change.content.slice();
|
|
25723
25963
|
try {
|
|
25724
|
-
const content = await base.readBytes(
|
|
25725
|
-
observe(
|
|
25964
|
+
const content = await base.readBytes(path7);
|
|
25965
|
+
observe(path7, { kind: "content", digest: digestBytes(content) });
|
|
25726
25966
|
return content;
|
|
25727
25967
|
} catch (error) {
|
|
25728
|
-
if (!await base.exists(
|
|
25729
|
-
observe(
|
|
25968
|
+
if (!await base.exists(path7))
|
|
25969
|
+
observe(path7, { kind: "absent" });
|
|
25730
25970
|
throw error;
|
|
25731
25971
|
}
|
|
25732
25972
|
}
|
|
25733
25973
|
async function write(rawPath, content) {
|
|
25734
|
-
const
|
|
25735
|
-
await observeBeforeChange(
|
|
25736
|
-
staged.set(
|
|
25974
|
+
const path7 = normalize(rawPath);
|
|
25975
|
+
await observeBeforeChange(path7);
|
|
25976
|
+
staged.set(path7, { content: content.slice(), mtimeMs: Date.now() });
|
|
25737
25977
|
}
|
|
25738
25978
|
async function remove(rawPath) {
|
|
25739
|
-
const
|
|
25740
|
-
await observeBeforeChange(
|
|
25741
|
-
staged.set(
|
|
25979
|
+
const path7 = normalize(rawPath);
|
|
25980
|
+
await observeBeforeChange(path7);
|
|
25981
|
+
staged.set(path7, null);
|
|
25742
25982
|
}
|
|
25743
25983
|
function stagedBelow(dir) {
|
|
25744
|
-
return [...staged].filter(([
|
|
25984
|
+
return [...staged].filter(([path7, change]) => change !== null && isBelow(path7, dir)).map(([path7]) => path7);
|
|
25745
25985
|
}
|
|
25746
25986
|
return {
|
|
25747
|
-
async readFile(
|
|
25748
|
-
return decoder.decode(await readBytes(
|
|
25987
|
+
async readFile(path7) {
|
|
25988
|
+
return decoder.decode(await readBytes(path7));
|
|
25749
25989
|
},
|
|
25750
25990
|
readBytes,
|
|
25751
|
-
writeFile(
|
|
25752
|
-
return write(
|
|
25991
|
+
writeFile(path7, content) {
|
|
25992
|
+
return write(path7, encoder.encode(content));
|
|
25753
25993
|
},
|
|
25754
25994
|
writeBytes: write,
|
|
25755
25995
|
async rename(from, to) {
|
|
@@ -25759,23 +25999,23 @@ function createStagedFileSystem(base) {
|
|
|
25759
25999
|
},
|
|
25760
26000
|
remove,
|
|
25761
26001
|
async exists(rawPath) {
|
|
25762
|
-
const
|
|
25763
|
-
const change = staged.get(
|
|
26002
|
+
const path7 = normalize(rawPath);
|
|
26003
|
+
const change = staged.get(path7);
|
|
25764
26004
|
if (change !== undefined)
|
|
25765
26005
|
return change !== null;
|
|
25766
|
-
if (stagedBelow(
|
|
26006
|
+
if (stagedBelow(path7).length > 0)
|
|
25767
26007
|
return true;
|
|
25768
|
-
const exists = await base.exists(
|
|
25769
|
-
observe(
|
|
26008
|
+
const exists = await base.exists(path7);
|
|
26009
|
+
observe(path7, exists ? { kind: "present" } : { kind: "absent" });
|
|
25770
26010
|
return exists;
|
|
25771
26011
|
},
|
|
25772
26012
|
async list(rawDir) {
|
|
25773
26013
|
const dir = normalize(rawDir);
|
|
25774
26014
|
const entries = new Map((await base.list(dir)).map((entry) => [entry.name, entry.isDirectory]));
|
|
25775
|
-
for (const [
|
|
25776
|
-
if (!isBelow(
|
|
26015
|
+
for (const [path7, change] of staged) {
|
|
26016
|
+
if (!isBelow(path7, dir))
|
|
25777
26017
|
continue;
|
|
25778
|
-
const rest = dir === "" ?
|
|
26018
|
+
const rest = dir === "" ? path7 : path7.slice(dir.length + 1);
|
|
25779
26019
|
const [name, ...deeper] = rest.split("/");
|
|
25780
26020
|
if (name === undefined)
|
|
25781
26021
|
continue;
|
|
@@ -25793,36 +26033,36 @@ function createStagedFileSystem(base) {
|
|
|
25793
26033
|
async glob(pattern, options) {
|
|
25794
26034
|
const matcher = globToRegExp(pattern);
|
|
25795
26035
|
const files = new Set(await base.glob(pattern, options));
|
|
25796
|
-
for (const [
|
|
26036
|
+
for (const [path7, change] of staged) {
|
|
25797
26037
|
if (change === null)
|
|
25798
|
-
files.delete(
|
|
25799
|
-
else if (matcher.test(
|
|
25800
|
-
files.add(
|
|
26038
|
+
files.delete(path7);
|
|
26039
|
+
else if (matcher.test(path7))
|
|
26040
|
+
files.add(path7);
|
|
25801
26041
|
}
|
|
25802
26042
|
return [...files];
|
|
25803
26043
|
},
|
|
25804
26044
|
async stat(rawPath) {
|
|
25805
|
-
const
|
|
25806
|
-
const change = staged.get(
|
|
26045
|
+
const path7 = normalize(rawPath);
|
|
26046
|
+
const change = staged.get(path7);
|
|
25807
26047
|
if (change === null)
|
|
25808
|
-
throw missing(
|
|
26048
|
+
throw missing(path7);
|
|
25809
26049
|
if (change !== undefined)
|
|
25810
26050
|
return { mtimeMs: change.mtimeMs, size: change.content.byteLength };
|
|
25811
|
-
const stat = await base.stat(
|
|
25812
|
-
observe(
|
|
26051
|
+
const stat = await base.stat(path7);
|
|
26052
|
+
observe(path7, { kind: "present" });
|
|
25813
26053
|
return stat;
|
|
25814
26054
|
},
|
|
25815
26055
|
changeset() {
|
|
25816
|
-
const changes = [...staged].map(([
|
|
26056
|
+
const changes = [...staged].map(([path7, change]) => change === null ? { kind: "remove", path: path7 } : { kind: "write", path: path7, content: change.content });
|
|
25817
26057
|
return { reads: new Map(reads), changes };
|
|
25818
26058
|
}
|
|
25819
26059
|
};
|
|
25820
26060
|
}
|
|
25821
|
-
async function versionOf(fs3,
|
|
25822
|
-
if (!await fs3.exists(
|
|
26061
|
+
async function versionOf(fs3, path7) {
|
|
26062
|
+
if (!await fs3.exists(path7))
|
|
25823
26063
|
return { kind: "absent" };
|
|
25824
26064
|
try {
|
|
25825
|
-
return { kind: "content", digest: digestBytes(await fs3.readBytes(
|
|
26065
|
+
return { kind: "content", digest: digestBytes(await fs3.readBytes(path7)) };
|
|
25826
26066
|
} catch {
|
|
25827
26067
|
return { kind: "present" };
|
|
25828
26068
|
}
|
|
@@ -25830,7 +26070,7 @@ async function versionOf(fs3, path5) {
|
|
|
25830
26070
|
|
|
25831
26071
|
// ../cms-core/src/handlers/entry-ops.ts
|
|
25832
26072
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
25833
|
-
import
|
|
26073
|
+
import path7 from "path";
|
|
25834
26074
|
var MARKDOWN_EXTENSIONS = ["md", "mdx"];
|
|
25835
26075
|
function fileExtension(filePath) {
|
|
25836
26076
|
const idx = filePath.lastIndexOf(".");
|
|
@@ -25851,12 +26091,12 @@ async function resolveEntryPath(deps, collection, slug) {
|
|
|
25851
26091
|
const base = await resolveCollectionDir(deps, collection);
|
|
25852
26092
|
const flatExts = ["md", "mdx", "json", "yaml", "yml"];
|
|
25853
26093
|
for (const ext of flatExts) {
|
|
25854
|
-
const candidate =
|
|
26094
|
+
const candidate = path7.posix.join(base, `${slug}.${ext}`);
|
|
25855
26095
|
if (await deps.fs.exists(candidate))
|
|
25856
26096
|
return candidate;
|
|
25857
26097
|
}
|
|
25858
26098
|
for (const ext of MARKDOWN_EXTENSIONS) {
|
|
25859
|
-
const candidate =
|
|
26099
|
+
const candidate = path7.posix.join(base, slug, `index.${ext}`);
|
|
25860
26100
|
if (await deps.fs.exists(candidate))
|
|
25861
26101
|
return candidate;
|
|
25862
26102
|
}
|
|
@@ -26022,7 +26262,7 @@ async function inferLayoutFromExistingEntries(deps, collection) {
|
|
|
26022
26262
|
if (flatSlugs.has(dir.name))
|
|
26023
26263
|
return false;
|
|
26024
26264
|
for (const ext of MARKDOWN_EXTENSIONS) {
|
|
26025
|
-
if (await deps.fs.exists(
|
|
26265
|
+
if (await deps.fs.exists(path7.posix.join(collectionPath, dir.name, `index.${ext}`)))
|
|
26026
26266
|
return true;
|
|
26027
26267
|
}
|
|
26028
26268
|
return false;
|
|
@@ -26124,7 +26364,7 @@ async function createEntry(deps, input) {
|
|
|
26124
26364
|
const isData = ext === "json" || ext === "yaml" || ext === "yml";
|
|
26125
26365
|
const layout = isData ? "flat" : await detectCollectionMarkdownLayout(deps, collection);
|
|
26126
26366
|
const collectionDir = await resolveCollectionDir(deps, collection);
|
|
26127
|
-
const sourcePath = layout === "index" ?
|
|
26367
|
+
const sourcePath = layout === "index" ? path7.posix.join(collectionDir, normalizedSlug, `index.${ext}`) : path7.posix.join(collectionDir, `${normalizedSlug}.${ext}`);
|
|
26128
26368
|
let fileContent;
|
|
26129
26369
|
if (isData) {
|
|
26130
26370
|
fileContent = ext === "json" ? JSON.stringify({ ...resolved }, null, 2) + `
|
|
@@ -26916,7 +27156,7 @@ async function scanDirectory2(fs3, currentDir, baseDir, relativeToRoot, excludeD
|
|
|
26916
27156
|
}
|
|
26917
27157
|
// ../cms-core/src/media/s3.ts
|
|
26918
27158
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
26919
|
-
import
|
|
27159
|
+
import path8 from "path";
|
|
26920
27160
|
function normalizeFolder(folder) {
|
|
26921
27161
|
return (folder ?? "").split("/").filter(Boolean).join("/");
|
|
26922
27162
|
}
|
|
@@ -26983,7 +27223,7 @@ function createS3StorageAdapter(options) {
|
|
|
26983
27223
|
id: key,
|
|
26984
27224
|
url: getUrl(key),
|
|
26985
27225
|
filename,
|
|
26986
|
-
contentType: mimeFromExt(
|
|
27226
|
+
contentType: mimeFromExt(path8.extname(key).toLowerCase()),
|
|
26987
27227
|
uploadedAt: obj.LastModified?.toISOString(),
|
|
26988
27228
|
folder: folder || undefined
|
|
26989
27229
|
};
|
|
@@ -27149,251 +27389,6 @@ async function listFilteredMedia(list, options, maxScanned = MAX_SCANNED) {
|
|
|
27149
27389
|
position = next;
|
|
27150
27390
|
}
|
|
27151
27391
|
}
|
|
27152
|
-
// ../cms-core/src/project-config-ast.ts
|
|
27153
|
-
var import_parser5 = __toESM(require_lib(), 1);
|
|
27154
|
-
var EMPTY_CONFIG = { listStyles: [] };
|
|
27155
|
-
function parseSource2(source) {
|
|
27156
|
-
try {
|
|
27157
|
-
return import_parser5.parse(source, {
|
|
27158
|
-
sourceType: "module",
|
|
27159
|
-
plugins: ["typescript"],
|
|
27160
|
-
errorRecovery: true
|
|
27161
|
-
});
|
|
27162
|
-
} catch {
|
|
27163
|
-
return null;
|
|
27164
|
-
}
|
|
27165
|
-
}
|
|
27166
|
-
function collectBindings2(ast) {
|
|
27167
|
-
const bindings = new Map;
|
|
27168
|
-
for (const stmt of ast.program.body) {
|
|
27169
|
-
const varDecl = stmt.type === "ExportNamedDeclaration" && stmt.declaration?.type === "VariableDeclaration" ? stmt.declaration : stmt.type === "VariableDeclaration" ? stmt : null;
|
|
27170
|
-
if (!varDecl)
|
|
27171
|
-
continue;
|
|
27172
|
-
for (const decl of varDecl.declarations) {
|
|
27173
|
-
if (decl.id.type === "Identifier" && decl.init)
|
|
27174
|
-
bindings.set(decl.id.name, decl.init);
|
|
27175
|
-
}
|
|
27176
|
-
}
|
|
27177
|
-
return bindings;
|
|
27178
|
-
}
|
|
27179
|
-
function withoutTypeWrappers(node) {
|
|
27180
|
-
let current = node;
|
|
27181
|
-
while (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSNonNullExpression" || current.type === "TSTypeAssertion") {
|
|
27182
|
-
current = current.expression;
|
|
27183
|
-
}
|
|
27184
|
-
return current;
|
|
27185
|
-
}
|
|
27186
|
-
function resolveExpression2(node, bindings, visited = new Set) {
|
|
27187
|
-
let current = withoutTypeWrappers(node);
|
|
27188
|
-
while (current.type === "Identifier") {
|
|
27189
|
-
if (visited.has(current.name))
|
|
27190
|
-
return current;
|
|
27191
|
-
visited.add(current.name);
|
|
27192
|
-
const next = bindings.get(current.name);
|
|
27193
|
-
if (!next)
|
|
27194
|
-
return current;
|
|
27195
|
-
current = withoutTypeWrappers(next);
|
|
27196
|
-
}
|
|
27197
|
-
return current;
|
|
27198
|
-
}
|
|
27199
|
-
function propertyKeyName2(key) {
|
|
27200
|
-
if (key.type === "Identifier")
|
|
27201
|
-
return key.name;
|
|
27202
|
-
if (key.type === "StringLiteral")
|
|
27203
|
-
return key.value;
|
|
27204
|
-
return null;
|
|
27205
|
-
}
|
|
27206
|
-
function objectPropertyValue(node, keyName, bindings) {
|
|
27207
|
-
for (const prop of node.properties) {
|
|
27208
|
-
if (prop.type !== "ObjectProperty")
|
|
27209
|
-
continue;
|
|
27210
|
-
if (propertyKeyName2(prop.key) !== keyName)
|
|
27211
|
-
continue;
|
|
27212
|
-
return resolveExpression2(prop.value, bindings);
|
|
27213
|
-
}
|
|
27214
|
-
return null;
|
|
27215
|
-
}
|
|
27216
|
-
function objectAtPath(root, keys, bindings) {
|
|
27217
|
-
let current = root;
|
|
27218
|
-
for (const key of keys) {
|
|
27219
|
-
const value = objectPropertyValue(current, key, bindings);
|
|
27220
|
-
if (!value || value.type !== "ObjectExpression")
|
|
27221
|
-
return null;
|
|
27222
|
-
current = value;
|
|
27223
|
-
}
|
|
27224
|
-
return current;
|
|
27225
|
-
}
|
|
27226
|
-
function staticString2(node, bindings) {
|
|
27227
|
-
const resolved = resolveExpression2(node, bindings);
|
|
27228
|
-
if (resolved.type === "StringLiteral")
|
|
27229
|
-
return resolved.value;
|
|
27230
|
-
if (resolved.type === "TemplateLiteral" && resolved.expressions.length === 0) {
|
|
27231
|
-
return resolved.quasis[0]?.value.cooked ?? resolved.quasis[0]?.value.raw;
|
|
27232
|
-
}
|
|
27233
|
-
return;
|
|
27234
|
-
}
|
|
27235
|
-
function parseListStyle(node, bindings) {
|
|
27236
|
-
const resolved = resolveExpression2(node, bindings);
|
|
27237
|
-
if (resolved.type !== "ObjectExpression")
|
|
27238
|
-
return null;
|
|
27239
|
-
const labelNode = objectPropertyValue(resolved, "label", bindings);
|
|
27240
|
-
const classNode = objectPropertyValue(resolved, "class", bindings);
|
|
27241
|
-
if (!labelNode || !classNode)
|
|
27242
|
-
return null;
|
|
27243
|
-
const label = staticString2(labelNode, bindings);
|
|
27244
|
-
const className = staticString2(classNode, bindings);
|
|
27245
|
-
if (label === undefined || className === undefined)
|
|
27246
|
-
return null;
|
|
27247
|
-
return { label, class: className };
|
|
27248
|
-
}
|
|
27249
|
-
function parseListStyles(node, bindings) {
|
|
27250
|
-
const styles = [];
|
|
27251
|
-
for (const element of node.elements) {
|
|
27252
|
-
if (!element || element.type === "SpreadElement")
|
|
27253
|
-
continue;
|
|
27254
|
-
const style = parseListStyle(element, bindings);
|
|
27255
|
-
if (style)
|
|
27256
|
-
styles.push(style);
|
|
27257
|
-
}
|
|
27258
|
-
return styles;
|
|
27259
|
-
}
|
|
27260
|
-
function configObjectFromDefaultExport(ast, bindings) {
|
|
27261
|
-
for (const stmt of ast.program.body) {
|
|
27262
|
-
if (stmt.type !== "ExportDefaultDeclaration")
|
|
27263
|
-
continue;
|
|
27264
|
-
const declaration = resolveExpression2(stmt.declaration, bindings);
|
|
27265
|
-
if (declaration.type === "ObjectExpression")
|
|
27266
|
-
return declaration;
|
|
27267
|
-
if (declaration.type === "CallExpression") {
|
|
27268
|
-
const firstArg = declaration.arguments[0];
|
|
27269
|
-
if (!firstArg || firstArg.type === "SpreadElement")
|
|
27270
|
-
return null;
|
|
27271
|
-
const resolvedArg = resolveExpression2(firstArg, bindings);
|
|
27272
|
-
if (resolvedArg.type === "ObjectExpression")
|
|
27273
|
-
return resolvedArg;
|
|
27274
|
-
}
|
|
27275
|
-
}
|
|
27276
|
-
return null;
|
|
27277
|
-
}
|
|
27278
|
-
var CMS_INTEGRATION_OPTIONS_PATH = {
|
|
27279
|
-
"@nuasite/cms": [],
|
|
27280
|
-
"@nuasite/nua": ["cms"],
|
|
27281
|
-
"@nuasite/nua/integration": ["cms"]
|
|
27282
|
-
};
|
|
27283
|
-
function collectCmsIntegrationImports(ast) {
|
|
27284
|
-
const imports = new Map;
|
|
27285
|
-
for (const stmt of ast.program.body) {
|
|
27286
|
-
if (stmt.type !== "ImportDeclaration")
|
|
27287
|
-
continue;
|
|
27288
|
-
const optionsPath = CMS_INTEGRATION_OPTIONS_PATH[stmt.source.value];
|
|
27289
|
-
if (!optionsPath)
|
|
27290
|
-
continue;
|
|
27291
|
-
for (const specifier of stmt.specifiers) {
|
|
27292
|
-
const importedName2 = specifier.type === "ImportDefaultSpecifier" ? "default" : specifier.type === "ImportSpecifier" ? propertyKeyName2(specifier.imported) : null;
|
|
27293
|
-
if (importedName2 === "default" || importedName2 === "nua" && optionsPath.length > 0)
|
|
27294
|
-
imports.set(specifier.local.name, optionsPath);
|
|
27295
|
-
}
|
|
27296
|
-
}
|
|
27297
|
-
return imports;
|
|
27298
|
-
}
|
|
27299
|
-
function defaultExportWrapper(ast, bindings) {
|
|
27300
|
-
const exported = ast.program.body.find((stmt) => stmt.type === "ExportDefaultDeclaration");
|
|
27301
|
-
const declaration = exported?.type === "ExportDefaultDeclaration" ? resolveExpression2(exported.declaration, bindings) : null;
|
|
27302
|
-
if (declaration?.type !== "CallExpression")
|
|
27303
|
-
return "astro";
|
|
27304
|
-
const callee = withoutTypeWrappers(declaration.callee);
|
|
27305
|
-
if (callee.type !== "Identifier")
|
|
27306
|
-
return "unknown";
|
|
27307
|
-
for (const stmt of ast.program.body) {
|
|
27308
|
-
if (stmt.type !== "ImportDeclaration" || !stmt.specifiers.some((specifier) => specifier.local.name === callee.name))
|
|
27309
|
-
continue;
|
|
27310
|
-
if (stmt.source.value === "@nuasite/nua/config")
|
|
27311
|
-
return "nua";
|
|
27312
|
-
if (stmt.source.value === "astro/config")
|
|
27313
|
-
return "astro";
|
|
27314
|
-
}
|
|
27315
|
-
return "unknown";
|
|
27316
|
-
}
|
|
27317
|
-
function nuaCmsInstance(cms, bindings) {
|
|
27318
|
-
if (cms?.type === "BooleanLiteral" && !cms.value)
|
|
27319
|
-
return;
|
|
27320
|
-
return cms?.type === "ObjectExpression" ? objectAtPath(cms, ["cmsConfig"], bindings) : null;
|
|
27321
|
-
}
|
|
27322
|
-
function wrapperCmsInstance(ast, configObject, bindings) {
|
|
27323
|
-
const wrapper = defaultExportWrapper(ast, bindings);
|
|
27324
|
-
if (wrapper === "astro")
|
|
27325
|
-
return;
|
|
27326
|
-
const nua = objectPropertyValue(configObject, "nua", bindings);
|
|
27327
|
-
const cms = nua?.type === "ObjectExpression" ? objectPropertyValue(nua, "cms", bindings) : null;
|
|
27328
|
-
if (wrapper === "unknown") {
|
|
27329
|
-
return cms?.type === "ObjectExpression" ? nuaCmsInstance(cms, bindings) : undefined;
|
|
27330
|
-
}
|
|
27331
|
-
if (nua?.type === "BooleanLiteral" && !nua.value)
|
|
27332
|
-
return;
|
|
27333
|
-
return nuaCmsInstance(cms, bindings);
|
|
27334
|
-
}
|
|
27335
|
-
function effectiveCmsConfig(ast, configObject, bindings) {
|
|
27336
|
-
let fromNua = wrapperCmsInstance(ast, configObject, bindings);
|
|
27337
|
-
let fromCms;
|
|
27338
|
-
const integrations = objectPropertyValue(configObject, "integrations", bindings);
|
|
27339
|
-
const integrationImports = collectCmsIntegrationImports(ast);
|
|
27340
|
-
for (const element of integrations?.type === "ArrayExpression" ? integrations.elements : []) {
|
|
27341
|
-
if (!element || element.type === "SpreadElement")
|
|
27342
|
-
continue;
|
|
27343
|
-
const call = resolveExpression2(element, bindings);
|
|
27344
|
-
const callee = call.type === "CallExpression" ? withoutTypeWrappers(call.callee) : null;
|
|
27345
|
-
if (call.type !== "CallExpression" || callee?.type !== "Identifier")
|
|
27346
|
-
continue;
|
|
27347
|
-
const optionsPath = integrationImports.get(callee.name);
|
|
27348
|
-
if (!optionsPath)
|
|
27349
|
-
continue;
|
|
27350
|
-
const firstArg = call.arguments[0];
|
|
27351
|
-
const options = firstArg && firstArg.type !== "SpreadElement" ? resolveExpression2(firstArg, bindings) : null;
|
|
27352
|
-
const optionsObject = options?.type === "ObjectExpression" ? options : null;
|
|
27353
|
-
if (optionsPath.length === 0) {
|
|
27354
|
-
fromCms = optionsObject && objectAtPath(optionsObject, ["cmsConfig"], bindings);
|
|
27355
|
-
} else if (fromNua === undefined) {
|
|
27356
|
-
fromNua = nuaCmsInstance(optionsObject && objectPropertyValue(optionsObject, "cms", bindings), bindings);
|
|
27357
|
-
}
|
|
27358
|
-
}
|
|
27359
|
-
return fromNua !== undefined ? fromNua : fromCms ?? null;
|
|
27360
|
-
}
|
|
27361
|
-
function parseConfigListStyles(cmsConfig, bindings) {
|
|
27362
|
-
const listStylesNode = cmsConfig ? objectPropertyValue(cmsConfig, "listStyles", bindings) : null;
|
|
27363
|
-
return listStylesNode?.type === "ArrayExpression" ? parseListStyles(listStylesNode, bindings) : [];
|
|
27364
|
-
}
|
|
27365
|
-
function staticStringOf(object, key, bindings) {
|
|
27366
|
-
const node = object ? objectPropertyValue(object, key, bindings) : null;
|
|
27367
|
-
return node && staticString2(node, bindings) || undefined;
|
|
27368
|
-
}
|
|
27369
|
-
function parseLocale(cmsConfig, configObject, bindings) {
|
|
27370
|
-
return staticStringOf(cmsConfig, "locale", bindings) ?? staticStringOf(objectAtPath(configObject, ["i18n"], bindings), "defaultLocale", bindings);
|
|
27371
|
-
}
|
|
27372
|
-
function parseProjectCmsConfigSource(source) {
|
|
27373
|
-
const ast = parseSource2(source);
|
|
27374
|
-
if (!ast)
|
|
27375
|
-
return EMPTY_CONFIG;
|
|
27376
|
-
const bindings = collectBindings2(ast);
|
|
27377
|
-
const configObject = configObjectFromDefaultExport(ast, bindings);
|
|
27378
|
-
if (!configObject)
|
|
27379
|
-
return EMPTY_CONFIG;
|
|
27380
|
-
const cmsConfig = effectiveCmsConfig(ast, configObject, bindings);
|
|
27381
|
-
const locale = parseLocale(cmsConfig, configObject, bindings);
|
|
27382
|
-
return { listStyles: parseConfigListStyles(cmsConfig, bindings), ...locale ? { locale } : {} };
|
|
27383
|
-
}
|
|
27384
|
-
var ASTRO_CONFIG_FILES = ["astro.config.ts", "astro.config.mts", "astro.config.mjs", "astro.config.js"];
|
|
27385
|
-
async function parseProjectCmsConfig(fs3) {
|
|
27386
|
-
for (const file of ASTRO_CONFIG_FILES) {
|
|
27387
|
-
let source;
|
|
27388
|
-
try {
|
|
27389
|
-
source = await fs3.readFile(file);
|
|
27390
|
-
} catch {
|
|
27391
|
-
continue;
|
|
27392
|
-
}
|
|
27393
|
-
return parseProjectCmsConfigSource(source);
|
|
27394
|
-
}
|
|
27395
|
-
return EMPTY_CONFIG;
|
|
27396
|
-
}
|
|
27397
27392
|
// ../cms-core/src/route-map.ts
|
|
27398
27393
|
var ROUTE_MAP_PATH = ".astro/integrations/_nuasite_cms/routes.json";
|
|
27399
27394
|
var ROUTE_MAP_VERSION = 1;
|
|
@@ -27402,10 +27397,10 @@ function normalizeSiteBase(base) {
|
|
|
27402
27397
|
return trimmed === "" ? "" : trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
27403
27398
|
}
|
|
27404
27399
|
function sitePathname(pathname, site) {
|
|
27405
|
-
const
|
|
27406
|
-
if (
|
|
27400
|
+
const path9 = `${site.base}${pathname === "/" ? "" : pathname.replace(/\/+$/, "")}`;
|
|
27401
|
+
if (path9 === "")
|
|
27407
27402
|
return "/";
|
|
27408
|
-
return site.trailingSlash === "always" ? `${
|
|
27403
|
+
return site.trailingSlash === "always" ? `${path9}/` : path9;
|
|
27409
27404
|
}
|
|
27410
27405
|
function parseRouteMap(json) {
|
|
27411
27406
|
let data;
|
|
@@ -27465,7 +27460,7 @@ function scanRouteCollections(source) {
|
|
|
27465
27460
|
// src/cli.ts
|
|
27466
27461
|
import fs3 from "fs";
|
|
27467
27462
|
import { createRequire } from "module";
|
|
27468
|
-
import
|
|
27463
|
+
import path9 from "path";
|
|
27469
27464
|
|
|
27470
27465
|
// src/media-from-env.ts
|
|
27471
27466
|
var VALID_KINDS = ["contember", "s3", "local", "none"];
|
|
@@ -28485,16 +28480,16 @@ function createServer(opts) {
|
|
|
28485
28480
|
function resolveCoreVersion() {
|
|
28486
28481
|
try {
|
|
28487
28482
|
const require2 = createRequire(import.meta.url);
|
|
28488
|
-
let dir =
|
|
28483
|
+
let dir = path9.dirname(require2.resolve("@nuasite/cms-core"));
|
|
28489
28484
|
for (;; ) {
|
|
28490
|
-
const pkgPath =
|
|
28485
|
+
const pkgPath = path9.join(dir, "package.json");
|
|
28491
28486
|
if (fs3.existsSync(pkgPath)) {
|
|
28492
28487
|
const parsed = JSON.parse(fs3.readFileSync(pkgPath, "utf-8"));
|
|
28493
28488
|
if (parsed && typeof parsed === "object" && "name" in parsed && parsed.name === "@nuasite/cms-core" && "version" in parsed && typeof parsed.version === "string") {
|
|
28494
28489
|
return parsed.version;
|
|
28495
28490
|
}
|
|
28496
28491
|
}
|
|
28497
|
-
const parent =
|
|
28492
|
+
const parent = path9.dirname(dir);
|
|
28498
28493
|
if (parent === dir)
|
|
28499
28494
|
break;
|
|
28500
28495
|
dir = parent;
|
|
@@ -28520,7 +28515,7 @@ function parseServeArgs(args) {
|
|
|
28520
28515
|
throw new Error("serve requires a valid --port <0-65535>");
|
|
28521
28516
|
}
|
|
28522
28517
|
const rawRoot = readFlag(args, "root");
|
|
28523
|
-
const root =
|
|
28518
|
+
const root = path9.resolve(rawRoot ?? process.cwd());
|
|
28524
28519
|
const contentDir = readFlag(args, "content-dir");
|
|
28525
28520
|
return { port, root, contentDir };
|
|
28526
28521
|
}
|