Rename publish:log to debug:log

Signed-off-by: Oliver Sand <oliver.sand@sda-se.com>
This commit is contained in:
Oliver Sand
2021-06-08 09:57:20 +02:00
parent 69f9a35c94
commit fff062301c
8 changed files with 36 additions and 19 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
'@backstage/plugin-scaffolder-backend': patch
---
Add `publish:log` action for debugging.
Add `debug:log` action for debugging.
@@ -94,7 +94,7 @@ spec:
- name: Results
if: '{{ parameters.dryRun }}'
action: publish:log
action: debug:log
input:
listWorkspace: true
@@ -19,6 +19,7 @@ import { CatalogApi } from '@backstage/catalog-client';
import { ScmIntegrations } from '@backstage/integration';
import { TemplaterBuilder } from '../../stages';
import { createCatalogRegisterAction } from './catalog';
import { createDebugLogAction } from './debug';
import { createFetchCookiecutterAction, createFetchPlainAction } from './fetch';
import {
createPublishAzureAction,
@@ -26,7 +27,6 @@ import {
createPublishGithubAction,
createPublishGithubPullRequestAction,
createPublishGitlabAction,
createPublishLogAction,
} from './publish';
export const createBuiltinActions = (options: {
@@ -62,7 +62,7 @@ export const createBuiltinActions = (options: {
createPublishAzureAction({
integrations,
}),
createPublishLogAction(),
createDebugLogAction(),
createCatalogRegisterAction({ catalogClient, integrations }),
];
};
@@ -0,0 +1,17 @@
/*
* Copyright 2021 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { createDebugLogAction } from './log';
@@ -18,9 +18,10 @@ import { getVoidLogger } from '@backstage/backend-common';
import mock from 'mock-fs';
import os from 'os';
import { Writable } from 'stream';
import { createPublishLogAction } from './log';
import { createDebugLogAction } from './log';
import { join } from 'path';
describe('publish:log', () => {
describe('debug:log', () => {
const logStream = ({
write: jest.fn(),
} as jest.Mocked<Partial<Writable>>) as jest.Mocked<Writable>;
@@ -36,7 +37,7 @@ describe('publish:log', () => {
createTemporaryDirectory: jest.fn().mockResolvedValue(mockTmpDir),
};
const action = createPublishLogAction();
const action = createDebugLogAction();
beforeEach(() => {
mock({
@@ -68,10 +69,10 @@ describe('publish:log', () => {
expect(logStream.write).toBeCalledTimes(1);
expect(logStream.write).toBeCalledWith(
expect.stringContaining('./README.md'),
expect.stringContaining('README.md'),
);
expect(logStream.write).toBeCalledWith(
expect.stringContaining('a-directory/index.md'),
expect.stringContaining(join('a-directory', 'index.md')),
);
});
@@ -22,9 +22,9 @@ import { createTemplateAction } from '../../createTemplateAction';
* This task is useful for local development and testing of both the scaffolder
* and scaffolder templates.
*/
export function createPublishLogAction() {
export function createDebugLogAction() {
return createTemplateAction<{ message?: string; listWorkspace?: boolean }>({
id: 'publish:log',
id: 'debug:log',
description:
'Writes a message into the log or list all files in the workspace.',
schema: {
@@ -43,16 +43,15 @@ export function createPublishLogAction() {
},
},
async handler(ctx) {
const files = await recursiveReadDir(ctx.workspacePath);
if (ctx.input?.message) {
ctx.logStream.write(ctx.input.message);
}
if (ctx.input?.listWorkspace) {
const files = await recursiveReadDir(ctx.workspacePath);
ctx.logStream.write(
`Workspace:\n${files
.map(f => ` - ./${relative(ctx.workspacePath, f)}`)
.map(f => ` - ${relative(ctx.workspacePath, f)}`)
.join('\n')}`,
);
}
@@ -15,6 +15,7 @@
*/
export * from './catalog';
export { createBuiltinActions } from './createBuiltinActions';
export * from './debug';
export * from './fetch';
export * from './publish';
export { createBuiltinActions } from './createBuiltinActions';
@@ -14,10 +14,9 @@
* limitations under the License.
*/
export { createPublishGithubAction } from './github';
export { createPublishGithubPullRequestAction } from './githubPullRequest';
export { createPublishAzureAction } from './azure';
export { createPublishGitlabAction } from './gitlab';
export { createPublishBitbucketAction } from './bitbucket';
export { createPublishFileAction } from './file';
export { createPublishLogAction } from './log';
export { createPublishGithubAction } from './github';
export { createPublishGithubPullRequestAction } from './githubPullRequest';
export { createPublishGitlabAction } from './gitlab';