fix: address PR review feedback for CLI --custom-content config
- Use module display name in sources (name: moduleMeta.name || code) - Add null guard for empty module.yaml (yaml.parse returns null) - Remove unused paths property to match promptCustomContentSource shape
This commit is contained in:
parent
eeeea6f204
commit
b9b51cd3fe
|
|
@ -305,6 +305,7 @@ class UI {
|
||||||
// Build custom content config similar to promptCustomContentSource
|
// Build custom content config similar to promptCustomContentSource
|
||||||
const customPaths = [];
|
const customPaths = [];
|
||||||
const selectedModuleIds = [];
|
const selectedModuleIds = [];
|
||||||
|
const selectedModuleMetas = [];
|
||||||
|
|
||||||
for (const customPath of paths) {
|
for (const customPath of paths) {
|
||||||
const expandedPath = this.expandUserPath(customPath);
|
const expandedPath = this.expandUserPath(customPath);
|
||||||
|
|
@ -326,6 +327,11 @@ class UI {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!moduleMeta) {
|
||||||
|
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml is empty`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!moduleMeta.code) {
|
if (!moduleMeta.code) {
|
||||||
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`);
|
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -333,16 +339,20 @@ class UI {
|
||||||
|
|
||||||
customPaths.push(expandedPath);
|
customPaths.push(expandedPath);
|
||||||
selectedModuleIds.push(moduleMeta.code);
|
selectedModuleIds.push(moduleMeta.code);
|
||||||
|
selectedModuleMetas.push(moduleMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customPaths.length > 0) {
|
if (customPaths.length > 0) {
|
||||||
const sources = customPaths.map((p, i) => ({ path: p, id: selectedModuleIds[i], name: selectedModuleIds[i] }));
|
const sources = customPaths.map((p, i) => ({
|
||||||
|
path: p,
|
||||||
|
id: selectedModuleIds[i],
|
||||||
|
name: selectedModuleMetas[i].name || selectedModuleIds[i],
|
||||||
|
}));
|
||||||
customModuleResult = {
|
customModuleResult = {
|
||||||
selectedCustomModules: selectedModuleIds,
|
selectedCustomModules: selectedModuleIds,
|
||||||
customContentConfig: {
|
customContentConfig: {
|
||||||
hasCustomContent: true,
|
hasCustomContent: true,
|
||||||
selected: true,
|
selected: true,
|
||||||
paths: customPaths,
|
|
||||||
sources: sources,
|
sources: sources,
|
||||||
selectedFiles: customPaths.map((p) => path.join(p, 'module.yaml')),
|
selectedFiles: customPaths.map((p) => path.join(p, 'module.yaml')),
|
||||||
selectedModuleIds: selectedModuleIds,
|
selectedModuleIds: selectedModuleIds,
|
||||||
|
|
@ -450,6 +460,7 @@ class UI {
|
||||||
// Build custom content config similar to promptCustomContentSource
|
// Build custom content config similar to promptCustomContentSource
|
||||||
const customPaths = [];
|
const customPaths = [];
|
||||||
const selectedModuleIds = [];
|
const selectedModuleIds = [];
|
||||||
|
const selectedModuleMetas = [];
|
||||||
|
|
||||||
for (const customPath of paths) {
|
for (const customPath of paths) {
|
||||||
const expandedPath = this.expandUserPath(customPath);
|
const expandedPath = this.expandUserPath(customPath);
|
||||||
|
|
@ -471,6 +482,11 @@ class UI {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!moduleMeta) {
|
||||||
|
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml is empty`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!moduleMeta.code) {
|
if (!moduleMeta.code) {
|
||||||
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`);
|
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -478,14 +494,18 @@ class UI {
|
||||||
|
|
||||||
customPaths.push(expandedPath);
|
customPaths.push(expandedPath);
|
||||||
selectedModuleIds.push(moduleMeta.code);
|
selectedModuleIds.push(moduleMeta.code);
|
||||||
|
selectedModuleMetas.push(moduleMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customPaths.length > 0) {
|
if (customPaths.length > 0) {
|
||||||
const sources = customPaths.map((p, i) => ({ path: p, id: selectedModuleIds[i], name: selectedModuleIds[i] }));
|
const sources = customPaths.map((p, i) => ({
|
||||||
|
path: p,
|
||||||
|
id: selectedModuleIds[i],
|
||||||
|
name: selectedModuleMetas[i].name || selectedModuleIds[i],
|
||||||
|
}));
|
||||||
customContentConfig = {
|
customContentConfig = {
|
||||||
hasCustomContent: true,
|
hasCustomContent: true,
|
||||||
selected: true,
|
selected: true,
|
||||||
paths: customPaths,
|
|
||||||
sources: sources,
|
sources: sources,
|
||||||
selectedFiles: customPaths.map((p) => path.join(p, 'module.yaml')),
|
selectedFiles: customPaths.map((p) => path.join(p, 'module.yaml')),
|
||||||
selectedModuleIds: selectedModuleIds,
|
selectedModuleIds: selectedModuleIds,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue