Merge pull request #25764 from Teo-ShaoWei/shaowei/fix-scaffolder-catalog-write
fix: scaffolder action catalog:write not working in nested folders
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': patch
|
||||
---
|
||||
|
||||
Fix scaffolder action `catalog:write` to write to directories that don't already exist
|
||||
+2
-2
@@ -55,8 +55,8 @@ describe('catalog:write', () => {
|
||||
input: yaml.parse(examples[0].example).steps[0].input,
|
||||
});
|
||||
|
||||
expect(fsMock.writeFile).toHaveBeenCalledTimes(1);
|
||||
expect(fsMock.writeFile).toHaveBeenCalledWith(
|
||||
expect(fsMock.outputFile).toHaveBeenCalledTimes(1);
|
||||
expect(fsMock.outputFile).toHaveBeenCalledWith(
|
||||
resolvePath(mockContext.workspacePath, 'catalog-info.yaml'),
|
||||
yaml.stringify(entity),
|
||||
);
|
||||
|
||||
@@ -59,8 +59,8 @@ describe('catalog:write', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(fsMock.writeFile).toHaveBeenCalledTimes(1);
|
||||
expect(fsMock.writeFile).toHaveBeenCalledWith(
|
||||
expect(fsMock.outputFile).toHaveBeenCalledTimes(1);
|
||||
expect(fsMock.outputFile).toHaveBeenCalledWith(
|
||||
resolvePath(mockContext.workspacePath, 'catalog-info.yaml'),
|
||||
yaml.stringify(entity),
|
||||
);
|
||||
@@ -88,8 +88,8 @@ describe('catalog:write', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(fsMock.writeFile).toHaveBeenCalledTimes(1);
|
||||
expect(fsMock.writeFile).toHaveBeenCalledWith(
|
||||
expect(fsMock.outputFile).toHaveBeenCalledTimes(1);
|
||||
expect(fsMock.outputFile).toHaveBeenCalledWith(
|
||||
resolvePath(mockContext.workspacePath, 'some-dir/entity-info.yaml'),
|
||||
yaml.stringify(entity),
|
||||
);
|
||||
@@ -118,8 +118,8 @@ describe('catalog:write', () => {
|
||||
'backstage.io/source-template': 'template:default/test-skeleton',
|
||||
};
|
||||
|
||||
expect(fsMock.writeFile).toHaveBeenCalledTimes(1);
|
||||
expect(fsMock.writeFile).toHaveBeenCalledWith(
|
||||
expect(fsMock.outputFile).toHaveBeenCalledTimes(1);
|
||||
expect(fsMock.outputFile).toHaveBeenCalledWith(
|
||||
resolvePath(mockContext.workspacePath, 'catalog-info.yaml'),
|
||||
yaml.stringify(expectedEntity),
|
||||
);
|
||||
|
||||
@@ -54,7 +54,7 @@ export function createCatalogWriteAction() {
|
||||
const path = filePath ?? 'catalog-info.yaml';
|
||||
ctx.logger.info(`Writing ${path}`);
|
||||
|
||||
await fs.writeFile(
|
||||
await fs.outputFile(
|
||||
resolveSafeChildPath(ctx.workspacePath, path),
|
||||
yaml.stringify({
|
||||
...entity,
|
||||
|
||||
Reference in New Issue
Block a user