Skip to content

Commit 0acb805

Browse files
committed
fix: separated manifests + autocleanup
1 parent c636a33 commit 0acb805

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

packages/cli/src/commands/gen-manifests/index.ts

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,14 @@ async function genManifestsAction(
382382
process.exit(1)
383383
}
384384

385-
// Create the manifests directory if it doesn't exist
385+
// Clean up and recreate the manifests directory
386386
const manifestsDir = path.join(cwd(), "manifests")
387-
if (!fs.existsSync(manifestsDir)) {
388-
moduleLogger.info(`Creating manifests directory: ${manifestsDir}`)
389-
fs.mkdirSync(manifestsDir)
387+
if (fs.existsSync(manifestsDir)) {
388+
moduleLogger.info(`Removing existing manifests directory: ${manifestsDir}`)
389+
fs.rmSync(manifestsDir, { recursive: true, force: true })
390390
}
391+
moduleLogger.info(`Creating fresh manifests directory: ${manifestsDir}`)
392+
fs.mkdirSync(manifestsDir, { recursive: true })
391393

392394
// Get all direct subdirectories of the functions directory
393395
const functionDirs = fs
@@ -649,30 +651,24 @@ async function genManifestsAction(
649651
}
650652
}
651653

652-
// Generate final output using the already loaded XRD data
653-
let finalOutput: string
654-
655-
if (xrdManifest && xrdContent) {
656-
// Generate multi-document YAML with XRD first, then composition
657-
const xrdYaml = YAML.stringify(xrdManifest)
658-
const compositionYaml = YAML.stringify(manifest)
659-
660-
// Combine with document separator
661-
finalOutput = `${xrdYaml}---\n${compositionYaml}`
662-
663-
moduleLogger.info(`Including XRD from ${xrdFilePath} for ${functionName}`)
664-
} else {
665-
// No XRD file, use composition only (existing behavior)
666-
finalOutput = YAML.stringify(manifest)
654+
// Create function-specific directory in manifests
655+
const functionManifestDir = path.join(manifestsDir, functionName)
656+
if (!fs.existsSync(functionManifestDir)) {
657+
fs.mkdirSync(functionManifestDir, { recursive: true })
658+
moduleLogger.debug(`Created function manifest directory: ${functionManifestDir}`)
667659
}
668660

669-
// Generate the output file
670-
const outputPath = path.join(manifestsDir, `${functionName}.compo.yaml`)
661+
// Copy XRD file directly (no need to read content)
662+
const outputXrdPath = path.join(functionManifestDir, "xrd.yaml")
663+
fs.copyFileSync(xrdFilePath, outputXrdPath)
664+
moduleLogger.info(`Copied XRD file for ${functionName}: ${outputXrdPath}`)
671665

672-
// Write the output file
673-
fs.writeFileSync(outputPath, finalOutput)
666+
// Generate composition file separately
667+
const compositionYaml = YAML.stringify(manifest)
668+
const outputCompositionPath = path.join(functionManifestDir, "composition.yaml")
669+
fs.writeFileSync(outputCompositionPath, compositionYaml)
674670

675-
moduleLogger.info(`Generated manifest for ${functionName}: ${outputPath}`)
671+
moduleLogger.info(`Generated composition for ${functionName}: ${outputCompositionPath}`)
676672
}
677673

678674
moduleLogger.info("Composition manifest generation completed")

packages/cli/src/commands/gen-models/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,13 @@ async function genModelsAction(): Promise<void> {
9898
const xrdFiles = await findXRDFiles()
9999
moduleLogger.info(`Found ${xrdFiles.length} XRD file(s): ${xrdFiles.join(", ")}`)
100100

101-
// Ensure models directory exists
101+
// Clean up and recreate the models directory
102102
const modelsDir = "models"
103+
if (await fs.pathExists(modelsDir)) {
104+
moduleLogger.info(`Removing existing models directory: ${modelsDir}`)
105+
await fs.remove(modelsDir)
106+
}
107+
moduleLogger.info(`Creating fresh models directory: ${modelsDir}`)
103108
await fs.ensureDir(modelsDir)
104109

105110
// Process each XRD file

tests/test-xfuncjs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ yarn --cwd tests/fixtures/domain-sdk gen-manifests
5353

5454
# Apply CRDs and Compositions
5555
echo "Applying XRD and Compositions..."
56-
kubectl apply -f tests/fixtures/domain-sdk/manifests
56+
kubectl apply -f tests/fixtures/domain-sdk/manifests/simpleconfigmaps
5757

5858
# Wait for XRD to be established
5959
echo "Waiting for XRD to be established..."

0 commit comments

Comments
 (0)