@@ -10,6 +10,7 @@ import { JsonValue } from '@backstage/types';
|
||||
import { Logger } from 'winston';
|
||||
import { Observable } from '@backstage/types';
|
||||
import { Schema } from 'jsonschema';
|
||||
import { ScmIntegrationRegistry } from '@backstage/integration';
|
||||
import { ScmIntegrations } from '@backstage/integration';
|
||||
import { SpawnOptionsWithoutStdio } from 'child_process';
|
||||
import { TaskSpec } from '@backstage/plugin-scaffolder-common';
|
||||
@@ -44,6 +45,37 @@ export type ActionContext<
|
||||
each?: JsonObject;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export function commitAndPushRepo({
|
||||
dir,
|
||||
auth,
|
||||
logger,
|
||||
commitMessage,
|
||||
gitAuthorInfo,
|
||||
branch,
|
||||
remoteRef,
|
||||
}: {
|
||||
dir: string;
|
||||
auth:
|
||||
| {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
| {
|
||||
token: string;
|
||||
};
|
||||
logger: Logger;
|
||||
commitMessage: string;
|
||||
gitAuthorInfo?: {
|
||||
name?: string;
|
||||
email?: string;
|
||||
};
|
||||
branch?: string;
|
||||
remoteRef?: string;
|
||||
}): Promise<{
|
||||
commitHash: string;
|
||||
}>;
|
||||
|
||||
// @public
|
||||
export const createTemplateAction: <
|
||||
TInputParams extends JsonObject = JsonObject,
|
||||
@@ -73,6 +105,12 @@ export const createTemplateAction: <
|
||||
>,
|
||||
) => TemplateAction<TActionInput, TActionOutput>;
|
||||
|
||||
// @public
|
||||
export function deserializeDirectoryContents(
|
||||
targetPath: string,
|
||||
files: SerializedFile[],
|
||||
): Promise<void>;
|
||||
|
||||
// @public
|
||||
export function executeShellCommand(
|
||||
options: ExecuteShellCommandOptions,
|
||||
@@ -104,6 +142,77 @@ export function fetchFile(options: {
|
||||
outputPath: string;
|
||||
}): Promise<void>;
|
||||
|
||||
// @public (undocumented)
|
||||
export const getRepoSourceDirectory: (
|
||||
workspacePath: string,
|
||||
sourcePath: string | undefined,
|
||||
) => string;
|
||||
|
||||
// @public (undocumented)
|
||||
export function initRepoAndPush({
|
||||
dir,
|
||||
remoteUrl,
|
||||
auth,
|
||||
logger,
|
||||
defaultBranch,
|
||||
commitMessage,
|
||||
gitAuthorInfo,
|
||||
}: {
|
||||
dir: string;
|
||||
remoteUrl: string;
|
||||
auth:
|
||||
| {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
| {
|
||||
token: string;
|
||||
};
|
||||
logger: Logger;
|
||||
defaultBranch?: string;
|
||||
commitMessage?: string;
|
||||
gitAuthorInfo?: {
|
||||
name?: string;
|
||||
email?: string;
|
||||
};
|
||||
}): Promise<{
|
||||
commitHash: string;
|
||||
}>;
|
||||
|
||||
// @public (undocumented)
|
||||
export const parseRepoUrl: (
|
||||
repoUrl: string,
|
||||
integrations: ScmIntegrationRegistry,
|
||||
) => {
|
||||
repo: string;
|
||||
host: string;
|
||||
owner?: string | undefined;
|
||||
organization?: string | undefined;
|
||||
workspace?: string | undefined;
|
||||
project?: string | undefined;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export interface SerializedFile {
|
||||
// (undocumented)
|
||||
content: Buffer;
|
||||
// (undocumented)
|
||||
executable?: boolean;
|
||||
// (undocumented)
|
||||
path: string;
|
||||
// (undocumented)
|
||||
symlink?: boolean;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export function serializeDirectoryContents(
|
||||
sourcePath: string,
|
||||
options?: {
|
||||
gitignore?: boolean;
|
||||
globPatterns?: string[];
|
||||
},
|
||||
): Promise<SerializedFile[]>;
|
||||
|
||||
// @public
|
||||
export type SerializedTask = {
|
||||
id: string;
|
||||
|
||||
+6
@@ -17,6 +17,9 @@
|
||||
import { Git } from '@backstage/backend-common';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function initRepoAndPush({
|
||||
dir,
|
||||
remoteUrl,
|
||||
@@ -75,6 +78,9 @@ export async function initRepoAndPush({
|
||||
return { commitHash };
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function commitAndPushRepo({
|
||||
dir,
|
||||
auth,
|
||||
@@ -25,5 +25,5 @@ export {
|
||||
} from './executeShellCommand';
|
||||
export { fetchContents, fetchFile } from './fetch';
|
||||
export { type ActionContext, type TemplateAction } from './types';
|
||||
export { initRepoAndPush, commitAndPushRepo } from './repoHelpers';
|
||||
export { initRepoAndPush, commitAndPushRepo } from './gitHelpers';
|
||||
export { parseRepoUrl, getRepoSourceDirectory } from './util';
|
||||
|
||||
@@ -19,6 +19,9 @@ import { isChildPath } from '@backstage/backend-common';
|
||||
import { join as joinPath, normalize as normalizePath } from 'path';
|
||||
import { ScmIntegrationRegistry } from '@backstage/integration';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const getRepoSourceDirectory = (
|
||||
workspacePath: string,
|
||||
sourcePath: string | undefined,
|
||||
@@ -37,6 +40,9 @@ export const getRepoSourceDirectory = (
|
||||
return workspacePath;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const parseRepoUrl = (
|
||||
repoUrl: string,
|
||||
integrations: ScmIntegrationRegistry,
|
||||
|
||||
@@ -25,7 +25,7 @@ import { SerializedFile } from './types';
|
||||
* This method uses `resolveSafeChildPath` to make sure that files are
|
||||
* not written outside of the target directory.
|
||||
*
|
||||
* @internal
|
||||
* @public
|
||||
*/
|
||||
export async function deserializeDirectoryContents(
|
||||
targetPath: string,
|
||||
|
||||
@@ -41,6 +41,9 @@ async function asyncFilter<T>(
|
||||
return array.filter((_value, index) => filterMap[index]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function serializeDirectoryContents(
|
||||
sourcePath: string,
|
||||
options?: {
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface SerializedFile {
|
||||
path: string;
|
||||
content: Buffer;
|
||||
|
||||
Reference in New Issue
Block a user