@backstage/plugin-scaffolder-node 0.7.1-next.1 → 0.8.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +84 -0
- package/dist/actions/createTemplateAction.cjs.js +6 -9
- package/dist/actions/createTemplateAction.cjs.js.map +1 -1
- package/dist/actions/gitHelpers.cjs.js +12 -6
- package/dist/actions/gitHelpers.cjs.js.map +1 -1
- package/dist/actions/util.cjs.js +45 -0
- package/dist/actions/util.cjs.js.map +1 -1
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/alpha.d.ts +3 -4
- package/dist/index.d.ts +101 -12
- package/dist/scm/git.cjs.js +15 -4
- package/dist/scm/git.cjs.js.map +1 -1
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-node
|
|
2
2
|
|
|
3
|
+
## 0.8.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1a58846: **DEPRECATION**: We've deprecated the old way of defining actions using `createTemplateAction` with raw `JSONSchema` and type parameters, as well as using `zod` through an import. You can now use the new format to define `createTemplateActions` with `zod` provided by the framework. This change also removes support for `logStream` in the `context` as well as moving the `logger` to an instance of `LoggerService`.
|
|
8
|
+
|
|
9
|
+
Before:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
createTemplateAction<{ repoUrl: string }, { test: string }>({
|
|
13
|
+
id: 'test',
|
|
14
|
+
schema: {
|
|
15
|
+
input: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
required: ['repoUrl'],
|
|
18
|
+
properties: {
|
|
19
|
+
repoUrl: { type: 'string' },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
output: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
required: ['test'],
|
|
25
|
+
properties: {
|
|
26
|
+
test: { type: 'string' },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
handler: async ctx => {
|
|
31
|
+
ctx.logStream.write('blob');
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// or
|
|
36
|
+
|
|
37
|
+
createTemplateAction({
|
|
38
|
+
id: 'test',
|
|
39
|
+
schema: {
|
|
40
|
+
input: z.object({
|
|
41
|
+
repoUrl: z.string(),
|
|
42
|
+
}),
|
|
43
|
+
output: z.object({
|
|
44
|
+
test: z.string(),
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
handler: async ctx => {
|
|
48
|
+
ctx.logStream.write('something');
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
After:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
createTemplateAction({
|
|
57
|
+
id: 'test',
|
|
58
|
+
schema: {
|
|
59
|
+
input: {
|
|
60
|
+
repoUrl: d => d.string(),
|
|
61
|
+
},
|
|
62
|
+
output: {
|
|
63
|
+
test: d => d.string(),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
handler: async ctx => {
|
|
67
|
+
// you can just use ctx.logger.log('...'), or if you really need a log stream you can do this:
|
|
68
|
+
const logStream = new PassThrough();
|
|
69
|
+
logStream.on('data', chunk => {
|
|
70
|
+
ctx.logger.info(chunk.toString());
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- 4f8b5b6: Allow signing git commits using configured private PGP key in scaffolder
|
|
79
|
+
- Updated dependencies
|
|
80
|
+
- @backstage/integration@1.16.2-next.0
|
|
81
|
+
- @backstage/backend-plugin-api@1.2.1-next.1
|
|
82
|
+
- @backstage/catalog-model@1.7.3
|
|
83
|
+
- @backstage/errors@1.2.7
|
|
84
|
+
- @backstage/types@1.2.1
|
|
85
|
+
- @backstage/plugin-scaffolder-common@1.5.10-next.0
|
|
86
|
+
|
|
3
87
|
## 0.7.1-next.1
|
|
4
88
|
|
|
5
89
|
### Patch Changes
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var util = require('./util.cjs.js');
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const createTemplateAction = (action) => {
|
|
10
|
-
const inputSchema = action.schema?.input && "safeParseAsync" in action.schema.input ? zodToJsonSchema__default.default(action.schema.input) : action.schema?.input;
|
|
11
|
-
const outputSchema = action.schema?.output && "safeParseAsync" in action.schema.output ? zodToJsonSchema__default.default(action.schema.output) : action.schema?.output;
|
|
5
|
+
function createTemplateAction(action) {
|
|
6
|
+
const { inputSchema, outputSchema } = util.parseSchemas(
|
|
7
|
+
action
|
|
8
|
+
);
|
|
12
9
|
return {
|
|
13
10
|
...action,
|
|
14
11
|
schema: {
|
|
@@ -17,7 +14,7 @@ const createTemplateAction = (action) => {
|
|
|
17
14
|
output: outputSchema
|
|
18
15
|
}
|
|
19
16
|
};
|
|
20
|
-
}
|
|
17
|
+
}
|
|
21
18
|
|
|
22
19
|
exports.createTemplateAction = createTemplateAction;
|
|
23
20
|
//# sourceMappingURL=createTemplateAction.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTemplateAction.cjs.js","sources":["../../src/actions/createTemplateAction.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActionContext, TemplateAction } from './types';\nimport { z } from 'zod';\nimport {
|
|
1
|
+
{"version":3,"file":"createTemplateAction.cjs.js","sources":["../../src/actions/createTemplateAction.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActionContext, TemplateAction } from './types';\nimport { z } from 'zod';\nimport { Expand, JsonObject } from '@backstage/types';\nimport { parseSchemas } from './util';\n\n/** @public */\nexport type TemplateExample = {\n description: string;\n example: string;\n};\n\n/** @public */\nexport type TemplateActionOptions<\n TActionInput extends JsonObject = {},\n TActionOutput extends JsonObject = {},\n TInputSchema extends\n | JsonObject\n | z.ZodType\n | { [key in string]: (zImpl: typeof z) => z.ZodType } = JsonObject,\n TOutputSchema extends\n | JsonObject\n | z.ZodType\n | { [key in string]: (zImpl: typeof z) => z.ZodType } = JsonObject,\n TSchemaType extends 'v1' | 'v2' = 'v1' | 'v2',\n> = {\n id: string;\n description?: string;\n examples?: TemplateExample[];\n supportsDryRun?: boolean;\n schema?: {\n input?: TInputSchema;\n output?: TOutputSchema;\n };\n handler: (\n ctx: ActionContext<TActionInput, TActionOutput, TSchemaType>,\n ) => Promise<void>;\n};\n\n/**\n * @ignore\n */\ntype FlattenOptionalProperties<T extends { [key in string]: unknown }> = Expand<\n {\n [K in keyof T as undefined extends T[K] ? never : K]: T[K];\n } & {\n [K in keyof T as undefined extends T[K] ? K : never]?: T[K];\n }\n>;\n\n/**\n * @public\n * @deprecated migrate to using the new built in zod schema definitions for schemas\n */\nexport function createTemplateAction<\n TInputParams extends JsonObject = JsonObject,\n TOutputParams extends JsonObject = JsonObject,\n TInputSchema extends JsonObject = JsonObject,\n TOutputSchema extends JsonObject = JsonObject,\n TActionInput extends JsonObject = TInputParams,\n TActionOutput extends JsonObject = TOutputParams,\n>(\n action: TemplateActionOptions<\n TActionInput,\n TActionOutput,\n TInputSchema,\n TOutputSchema,\n 'v1'\n >,\n): TemplateAction<TActionInput, TActionOutput, 'v1'>;\n/**\n * @public\n * @deprecated migrate to using the new built in zod schema definitions for schemas\n */\nexport function createTemplateAction<\n TInputParams extends JsonObject = JsonObject,\n TOutputParams extends JsonObject = JsonObject,\n TInputSchema extends z.ZodType = z.ZodType,\n TOutputSchema extends z.ZodType = z.ZodType,\n TActionInput extends JsonObject = z.infer<TInputSchema>,\n TActionOutput extends JsonObject = z.infer<TOutputSchema>,\n>(\n action: TemplateActionOptions<\n TActionInput,\n TActionOutput,\n TInputSchema,\n TOutputSchema,\n 'v1'\n >,\n): TemplateAction<TActionInput, TActionOutput, 'v1'>;\n/**\n * This function is used to create new template actions to get type safety.\n * Will convert zod schemas to json schemas for use throughout the system.\n * @public\n */\nexport function createTemplateAction<\n TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType },\n TOutputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType },\n>(\n action: TemplateActionOptions<\n {\n [key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;\n },\n {\n [key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>;\n },\n TInputSchema,\n TOutputSchema,\n 'v2'\n >,\n): TemplateAction<\n FlattenOptionalProperties<{\n [key in keyof TInputSchema]: z.output<ReturnType<TInputSchema[key]>>;\n }>,\n FlattenOptionalProperties<{\n [key in keyof TOutputSchema]: z.output<ReturnType<TOutputSchema[key]>>;\n }>,\n 'v2'\n>;\nexport function createTemplateAction<\n TInputParams extends JsonObject = JsonObject,\n TOutputParams extends JsonObject = JsonObject,\n TInputSchema extends\n | JsonObject\n | z.ZodType\n | { [key in string]: (zImpl: typeof z) => z.ZodType } = JsonObject,\n TOutputSchema extends\n | JsonObject\n | z.ZodType\n | { [key in string]: (zImpl: typeof z) => z.ZodType } = JsonObject,\n TActionInput extends JsonObject = TInputSchema extends z.ZodType<\n any,\n any,\n infer IReturn\n >\n ? IReturn\n : TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? Expand<{\n [key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;\n }>\n : TInputParams,\n TActionOutput extends JsonObject = TOutputSchema extends z.ZodType<\n any,\n any,\n infer IReturn\n >\n ? IReturn\n : TOutputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? Expand<{\n [key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>;\n }>\n : TOutputParams,\n>(\n action: TemplateActionOptions<\n TActionInput,\n TActionOutput,\n TInputSchema,\n TOutputSchema\n >,\n): TemplateAction<\n TActionInput,\n TActionOutput,\n TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? 'v2'\n : 'v1'\n> {\n const { inputSchema, outputSchema } = parseSchemas(\n action as TemplateActionOptions<any, any, any>,\n );\n\n return {\n ...action,\n schema: {\n ...action.schema,\n input: inputSchema,\n output: outputSchema,\n },\n };\n}\n"],"names":["parseSchemas"],"mappings":";;;;AAsIO,SAAS,qBAkCd,MAYA,EAAA;AACA,EAAM,MAAA,EAAE,WAAa,EAAA,YAAA,EAAiB,GAAAA,iBAAA;AAAA,IACpC;AAAA,GACF;AAEA,EAAO,OAAA;AAAA,IACL,GAAG,MAAA;AAAA,IACH,MAAQ,EAAA;AAAA,MACN,GAAG,MAAO,CAAA,MAAA;AAAA,MACV,KAAO,EAAA,WAAA;AAAA,MACP,MAAQ,EAAA;AAAA;AACV,GACF;AACF;;;;"}
|
|
@@ -10,7 +10,8 @@ async function initRepoAndPush(input) {
|
|
|
10
10
|
logger,
|
|
11
11
|
defaultBranch = "master",
|
|
12
12
|
commitMessage = "Initial commit",
|
|
13
|
-
gitAuthorInfo
|
|
13
|
+
gitAuthorInfo,
|
|
14
|
+
signingKey
|
|
14
15
|
} = input;
|
|
15
16
|
const git$1 = git.Git.fromAuth({
|
|
16
17
|
...auth,
|
|
@@ -29,7 +30,8 @@ async function initRepoAndPush(input) {
|
|
|
29
30
|
dir,
|
|
30
31
|
message: commitMessage,
|
|
31
32
|
author: authorInfo,
|
|
32
|
-
committer: authorInfo
|
|
33
|
+
committer: authorInfo,
|
|
34
|
+
signingKey
|
|
33
35
|
});
|
|
34
36
|
await git$1.push({
|
|
35
37
|
dir,
|
|
@@ -46,7 +48,8 @@ async function commitAndPushRepo(input) {
|
|
|
46
48
|
commitMessage,
|
|
47
49
|
gitAuthorInfo,
|
|
48
50
|
branch = "master",
|
|
49
|
-
remoteRef
|
|
51
|
+
remoteRef,
|
|
52
|
+
signingKey
|
|
50
53
|
} = input;
|
|
51
54
|
const git$1 = git.Git.fromAuth({
|
|
52
55
|
...auth,
|
|
@@ -63,7 +66,8 @@ async function commitAndPushRepo(input) {
|
|
|
63
66
|
dir,
|
|
64
67
|
message: commitMessage,
|
|
65
68
|
author: authorInfo,
|
|
66
|
-
committer: authorInfo
|
|
69
|
+
committer: authorInfo,
|
|
70
|
+
signingKey
|
|
67
71
|
});
|
|
68
72
|
await git$1.push({
|
|
69
73
|
dir,
|
|
@@ -105,7 +109,8 @@ async function commitAndPushBranch(options) {
|
|
|
105
109
|
gitAuthorInfo,
|
|
106
110
|
branch = "master",
|
|
107
111
|
remoteRef,
|
|
108
|
-
remote = "origin"
|
|
112
|
+
remote = "origin",
|
|
113
|
+
signingKey
|
|
109
114
|
} = options;
|
|
110
115
|
const git$1 = git.Git.fromAuth({
|
|
111
116
|
...auth,
|
|
@@ -119,7 +124,8 @@ async function commitAndPushBranch(options) {
|
|
|
119
124
|
dir,
|
|
120
125
|
message: commitMessage,
|
|
121
126
|
author: authorInfo,
|
|
122
|
-
committer: authorInfo
|
|
127
|
+
committer: authorInfo,
|
|
128
|
+
signingKey
|
|
123
129
|
});
|
|
124
130
|
await git$1.push({
|
|
125
131
|
dir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitHelpers.cjs.js","sources":["../../src/actions/gitHelpers.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Logger } from 'winston';\nimport { Git } from '../scm';\n\n/**\n * @public\n */\nexport async function initRepoAndPush(input: {\n dir: string;\n remoteUrl: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger: Logger;\n defaultBranch?: string;\n commitMessage?: string;\n gitAuthorInfo?: { name?: string; email?: string };\n}): Promise<{ commitHash: string }> {\n const {\n dir,\n remoteUrl,\n auth,\n logger,\n defaultBranch = 'master',\n commitMessage = 'Initial commit',\n gitAuthorInfo,\n } = input;\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n await git.init({\n dir,\n defaultBranch,\n });\n\n await git.add({ dir, filepath: '.' });\n\n // use provided info if possible, otherwise use fallbacks\n const authorInfo = {\n name: gitAuthorInfo?.name ?? 'Scaffolder',\n email: gitAuthorInfo?.email ?? 'scaffolder@backstage.io',\n };\n\n const commitHash = await git.commit({\n dir,\n message: commitMessage,\n author: authorInfo,\n committer: authorInfo,\n });\n\n await git.push({\n dir,\n remote: 'origin',\n url: remoteUrl,\n });\n\n return { commitHash };\n}\n\n/**\n * @public\n */\nexport async function commitAndPushRepo(input: {\n dir: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger: Logger;\n commitMessage: string;\n gitAuthorInfo?: { name?: string; email?: string };\n branch?: string;\n remoteRef?: string;\n}): Promise<{ commitHash: string }> {\n const {\n dir,\n auth,\n logger,\n commitMessage,\n gitAuthorInfo,\n branch = 'master',\n remoteRef,\n } = input;\n\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n await git.fetch({ dir });\n await git.checkout({ dir, ref: branch });\n await git.add({ dir, filepath: '.' });\n\n // use provided info if possible, otherwise use fallbacks\n const authorInfo = {\n name: gitAuthorInfo?.name ?? 'Scaffolder',\n email: gitAuthorInfo?.email ?? 'scaffolder@backstage.io',\n };\n\n const commitHash = await git.commit({\n dir,\n message: commitMessage,\n author: authorInfo,\n committer: authorInfo,\n });\n\n await git.push({\n dir,\n remote: 'origin',\n remoteRef: remoteRef ?? `refs/heads/${branch}`,\n });\n\n return { commitHash };\n}\n\n/**\n * @public\n */\nexport async function cloneRepo(options: {\n url: string;\n dir: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger?: Logger | undefined;\n ref?: string | undefined;\n depth?: number | undefined;\n noCheckout?: boolean | undefined;\n}): Promise<void> {\n const { url, dir, auth, logger, ref, depth, noCheckout } = options;\n\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n await git.clone({ url, dir, ref, depth, noCheckout });\n}\n\n/**\n * @public\n */\nexport async function createBranch(options: {\n dir: string;\n ref: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger?: Logger | undefined;\n}): Promise<void> {\n const { dir, ref, auth, logger } = options;\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n await git.branch({ dir, ref });\n}\n\n/**\n * @public\n */\nexport async function addFiles(options: {\n dir: string;\n filepath: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger?: Logger | undefined;\n}): Promise<void> {\n const { dir, filepath, auth, logger } = options;\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n await git.add({ dir, filepath });\n}\n\n/**\n * @public\n */\nexport async function commitAndPushBranch(options: {\n dir: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger?: Logger | undefined;\n commitMessage: string;\n gitAuthorInfo?: { name?: string; email?: string };\n branch?: string;\n remoteRef?: string;\n remote?: string;\n}): Promise<{ commitHash: string }> {\n const {\n dir,\n auth,\n logger,\n commitMessage,\n gitAuthorInfo,\n branch = 'master',\n remoteRef,\n remote = 'origin',\n } = options;\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n // use provided info if possible, otherwise use fallbacks\n const authorInfo = {\n name: gitAuthorInfo?.name ?? 'Scaffolder',\n email: gitAuthorInfo?.email ?? 'scaffolder@backstage.io',\n };\n\n const commitHash = await git.commit({\n dir,\n message: commitMessage,\n author: authorInfo,\n committer: authorInfo,\n });\n\n await git.push({\n dir,\n remote,\n remoteRef: remoteRef ?? `refs/heads/${branch}`,\n });\n\n return { commitHash };\n}\n"],"names":["git","Git"],"mappings":";;;;AAsBA,eAAsB,gBAAgB,KAWF,EAAA;AAClC,EAAM,MAAA;AAAA,IACJ,GAAA;AAAA,IACA,SAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAgB,GAAA,QAAA;AAAA,IAChB,aAAgB,GAAA,gBAAA;AAAA,IAChB;AAAA,GACE,GAAA,KAAA;AACJ,EAAM,MAAAA,KAAA,GAAMC,QAAI,QAAS,CAAA;AAAA,IACvB,GAAG,IAAA;AAAA,IACH;AAAA,GACD,CAAA;AAED,EAAA,MAAMD,MAAI,IAAK,CAAA;AAAA,IACb,GAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAMA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AAA,GAAA,CAAI,EAAE,GAAA,EAAK,UAAU,CAAA;AACjC;AAKA,eAAsB,oBAAoB,OAYN,EAAA;AAClC,EAAM,MAAA;AAAA,IACJ,GAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA;AAAA,IACA,aAAA;AAAA,IACA,MAAS,GAAA,QAAA;AAAA,IACT,SAAA;AAAA,IACA,MAAS,GAAA;AAAA,GACP,GAAA,OAAA;AACJ,EAAM,MAAAA,KAAA,GAAMC,QAAI,QAAS,CAAA;AAAA,IACvB,GAAG,IAAA;AAAA,IACH;AAAA,GACD,CAAA;AAGD,EAAA,MAAM,UAAa,GAAA;AAAA,IACjB,IAAA,EAAM,eAAe,IAAQ,IAAA,YAAA;AAAA,IAC7B,KAAA,EAAO,eAAe,KAAS,IAAA;AAAA,GACjC;AAEA,EAAM,MAAA,UAAA,GAAa,MAAMD,KAAA,CAAI,MAAO,CAAA;AAAA,IAClC,GAAA;AAAA,IACA,OAAS,EAAA,aAAA;AAAA,IACT,MAAQ,EAAA,UAAA;AAAA,IACR,SAAW,EAAA;AAAA,GACZ,CAAA;AAED,EAAA,MAAMA,MAAI,IAAK,CAAA;AAAA,IACb,GAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA,EAAW,SAAa,IAAA,CAAA,WAAA,EAAc,MAAM,CAAA;AAAA,GAC7C,CAAA;AAED,EAAA,OAAO,EAAE,UAAW,EAAA;AACtB;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"gitHelpers.cjs.js","sources":["../../src/actions/gitHelpers.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Logger } from 'winston';\nimport { Git } from '../scm';\n\n/**\n * @public\n */\nexport async function initRepoAndPush(input: {\n dir: string;\n remoteUrl: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger: Logger;\n defaultBranch?: string;\n commitMessage?: string;\n gitAuthorInfo?: { name?: string; email?: string };\n signingKey?: string;\n}): Promise<{ commitHash: string }> {\n const {\n dir,\n remoteUrl,\n auth,\n logger,\n defaultBranch = 'master',\n commitMessage = 'Initial commit',\n gitAuthorInfo,\n signingKey,\n } = input;\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n await git.init({\n dir,\n defaultBranch,\n });\n\n await git.add({ dir, filepath: '.' });\n\n // use provided info if possible, otherwise use fallbacks\n const authorInfo = {\n name: gitAuthorInfo?.name ?? 'Scaffolder',\n email: gitAuthorInfo?.email ?? 'scaffolder@backstage.io',\n };\n\n const commitHash = await git.commit({\n dir,\n message: commitMessage,\n author: authorInfo,\n committer: authorInfo,\n signingKey,\n });\n\n await git.push({\n dir,\n remote: 'origin',\n url: remoteUrl,\n });\n\n return { commitHash };\n}\n\n/**\n * @public\n */\nexport async function commitAndPushRepo(input: {\n dir: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger: Logger;\n commitMessage: string;\n gitAuthorInfo?: { name?: string; email?: string };\n branch?: string;\n remoteRef?: string;\n signingKey?: string;\n}): Promise<{ commitHash: string }> {\n const {\n dir,\n auth,\n logger,\n commitMessage,\n gitAuthorInfo,\n branch = 'master',\n remoteRef,\n signingKey,\n } = input;\n\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n await git.fetch({ dir });\n await git.checkout({ dir, ref: branch });\n await git.add({ dir, filepath: '.' });\n\n // use provided info if possible, otherwise use fallbacks\n const authorInfo = {\n name: gitAuthorInfo?.name ?? 'Scaffolder',\n email: gitAuthorInfo?.email ?? 'scaffolder@backstage.io',\n };\n\n const commitHash = await git.commit({\n dir,\n message: commitMessage,\n author: authorInfo,\n committer: authorInfo,\n signingKey,\n });\n\n await git.push({\n dir,\n remote: 'origin',\n remoteRef: remoteRef ?? `refs/heads/${branch}`,\n });\n\n return { commitHash };\n}\n\n/**\n * @public\n */\nexport async function cloneRepo(options: {\n url: string;\n dir: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger?: Logger | undefined;\n ref?: string | undefined;\n depth?: number | undefined;\n noCheckout?: boolean | undefined;\n}): Promise<void> {\n const { url, dir, auth, logger, ref, depth, noCheckout } = options;\n\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n await git.clone({ url, dir, ref, depth, noCheckout });\n}\n\n/**\n * @public\n */\nexport async function createBranch(options: {\n dir: string;\n ref: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger?: Logger | undefined;\n}): Promise<void> {\n const { dir, ref, auth, logger } = options;\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n await git.branch({ dir, ref });\n}\n\n/**\n * @public\n */\nexport async function addFiles(options: {\n dir: string;\n filepath: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger?: Logger | undefined;\n}): Promise<void> {\n const { dir, filepath, auth, logger } = options;\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n await git.add({ dir, filepath });\n}\n\n/**\n * @public\n */\nexport async function commitAndPushBranch(options: {\n dir: string;\n // For use cases where token has to be used with Basic Auth\n // it has to be provided as password together with a username\n // which may be a fixed value defined by the provider.\n auth: { username: string; password: string } | { token: string };\n logger?: Logger | undefined;\n commitMessage: string;\n gitAuthorInfo?: { name?: string; email?: string };\n branch?: string;\n remoteRef?: string;\n remote?: string;\n signingKey?: string;\n}): Promise<{ commitHash: string }> {\n const {\n dir,\n auth,\n logger,\n commitMessage,\n gitAuthorInfo,\n branch = 'master',\n remoteRef,\n remote = 'origin',\n signingKey,\n } = options;\n const git = Git.fromAuth({\n ...auth,\n logger,\n });\n\n // use provided info if possible, otherwise use fallbacks\n const authorInfo = {\n name: gitAuthorInfo?.name ?? 'Scaffolder',\n email: gitAuthorInfo?.email ?? 'scaffolder@backstage.io',\n };\n\n const commitHash = await git.commit({\n dir,\n message: commitMessage,\n author: authorInfo,\n committer: authorInfo,\n signingKey,\n });\n\n await git.push({\n dir,\n remote,\n remoteRef: remoteRef ?? `refs/heads/${branch}`,\n });\n\n return { commitHash };\n}\n"],"names":["git","Git"],"mappings":";;;;AAsBA,eAAsB,gBAAgB,KAYF,EAAA;AAClC,EAAM,MAAA;AAAA,IACJ,GAAA;AAAA,IACA,SAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAgB,GAAA,QAAA;AAAA,IAChB,aAAgB,GAAA,gBAAA;AAAA,IAChB,aAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EAAM,MAAAA,KAAA,GAAMC,QAAI,QAAS,CAAA;AAAA,IACvB,GAAG,IAAA;AAAA,IACH;AAAA,GACD,CAAA;AAED,EAAA,MAAMD,MAAI,IAAK,CAAA;AAAA,IACb,GAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAMA,MAAI,GAAI,CAAA,EAAE,GAAK,EAAA,QAAA,EAAU,KAAK,CAAA;AAGpC,EAAA,MAAM,UAAa,GAAA;AAAA,IACjB,IAAA,EAAM,eAAe,IAAQ,IAAA,YAAA;AAAA,IAC7B,KAAA,EAAO,eAAe,KAAS,IAAA;AAAA,GACjC;AAEA,EAAM,MAAA,UAAA,GAAa,MAAMA,KAAA,CAAI,MAAO,CAAA;AAAA,IACl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AAA,IACT,SAAA;AAAA,IACA,MAAS,GAAA,QAAA;AAAA,IACT;AAAA,GACE,GAAA,OAAA;AACJ,EAAM,MAAAA,KAAA,GAAMC,QAAI,QAAS,CAAA;AAAA,IACvB,GAAG,IAAA;AAAA,IACH;AAAA,GACD,CAAA;AAGD,EAAA,MAAM,UAAa,GAAA;AAAA,IACjB,IAAA,EAAM,eAAe,IAAQ,IAAA,YAAA;AAAA,IAC7B,KAAA,EAAO,eAAe,KAAS,IAAA;AAAA,GACjC;AAEA,EAAM,MAAA,UAAA,GAAa,MAAMD,KAAA,CAAI,MAAO,CAAA;AAAA,IAClC,GAAA;AAAA,IACA,OAAS,EAAA,aAAA;AAAA,IACT,MAAQ,EAAA,UAAA;AAAA,IACR,SAAW,EAAA,UAAA;AAAA,IACX;AAAA,GACD,CAAA;AAED,EAAA,MAAMA,MAAI,IAAK,CAAA;AAAA,IACb,GAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA,EAAW,SAAa,IAAA,CAAA,WAAA,EAAc,MAAM,CAAA;AAAA,GAC7C,CAAA;AAED,EAAA,OAAO,EAAE,UAAW,EAAA;AACtB;;;;;;;;;"}
|
package/dist/actions/util.cjs.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
var errors = require('@backstage/errors');
|
|
4
4
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
5
5
|
var path = require('path');
|
|
6
|
+
var zodToJsonSchema = require('zod-to-json-schema');
|
|
7
|
+
var zod = require('zod');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var zodToJsonSchema__default = /*#__PURE__*/_interopDefaultCompat(zodToJsonSchema);
|
|
6
12
|
|
|
7
13
|
const getRepoSourceDirectory = (workspacePath, sourcePath) => {
|
|
8
14
|
if (sourcePath) {
|
|
@@ -81,7 +87,46 @@ function checkRequiredParams(repoUrl, ...params) {
|
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
}
|
|
90
|
+
const isZodSchema = (schema) => {
|
|
91
|
+
return typeof schema === "object" && !!schema && "safeParseAsync" in schema;
|
|
92
|
+
};
|
|
93
|
+
const isNativeZodSchema = (schema) => {
|
|
94
|
+
return typeof schema === "object" && !!schema && Object.values(schema).every((v) => typeof v === "function");
|
|
95
|
+
};
|
|
96
|
+
const parseSchemas = (action) => {
|
|
97
|
+
if (!action.schema) {
|
|
98
|
+
return { inputSchema: void 0, outputSchema: void 0 };
|
|
99
|
+
}
|
|
100
|
+
if (isZodSchema(action.schema.input)) {
|
|
101
|
+
return {
|
|
102
|
+
inputSchema: zodToJsonSchema__default.default(action.schema.input),
|
|
103
|
+
outputSchema: isZodSchema(action.schema.output) ? zodToJsonSchema__default.default(action.schema.output) : void 0
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (isNativeZodSchema(action.schema.input)) {
|
|
107
|
+
const input = zod.z.object(
|
|
108
|
+
Object.fromEntries(
|
|
109
|
+
Object.entries(action.schema.input).map(([k, v]) => [k, v(zod.z)])
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
return {
|
|
113
|
+
inputSchema: zodToJsonSchema__default.default(input),
|
|
114
|
+
outputSchema: isNativeZodSchema(action.schema.output) ? zodToJsonSchema__default.default(
|
|
115
|
+
zod.z.object(
|
|
116
|
+
Object.fromEntries(
|
|
117
|
+
Object.entries(action.schema.output).map(([k, v]) => [k, v(zod.z)])
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
) : void 0
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
inputSchema: action.schema.input,
|
|
125
|
+
outputSchema: action.schema.output
|
|
126
|
+
};
|
|
127
|
+
};
|
|
84
128
|
|
|
85
129
|
exports.getRepoSourceDirectory = getRepoSourceDirectory;
|
|
86
130
|
exports.parseRepoUrl = parseRepoUrl;
|
|
131
|
+
exports.parseSchemas = parseSchemas;
|
|
87
132
|
//# sourceMappingURL=util.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.cjs.js","sources":["../../src/actions/util.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport { isChildPath } from '@backstage/backend-plugin-api';\nimport { join as joinPath, normalize as normalizePath } from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\n\n/**\n * @public\n */\nexport const getRepoSourceDirectory = (\n workspacePath: string,\n sourcePath: string | undefined,\n) => {\n if (sourcePath) {\n const safeSuffix = normalizePath(sourcePath).replace(\n /^(\\.\\.(\\/|\\\\|$))+/,\n '',\n );\n const path = joinPath(workspacePath, safeSuffix);\n if (!isChildPath(workspacePath, path)) {\n throw new Error('Invalid source path');\n }\n return path;\n }\n return workspacePath;\n};\n\n/**\n * @public\n */\nexport const parseRepoUrl = (\n repoUrl: string,\n integrations: ScmIntegrationRegistry,\n): {\n repo: string;\n host: string;\n owner?: string;\n organization?: string;\n workspace?: string;\n project?: string;\n} => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n const host = parsed.host;\n const owner = parsed.searchParams.get('owner') ?? undefined;\n const organization = parsed.searchParams.get('organization') ?? undefined;\n const workspace = parsed.searchParams.get('workspace') ?? undefined;\n const project = parsed.searchParams.get('project') ?? undefined;\n\n const type = integrations.byHost(host)?.type;\n\n if (!type) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const repo: string = parsed.searchParams.get('repo')!;\n switch (type) {\n case 'bitbucket': {\n if (host === 'www.bitbucket.org') {\n checkRequiredParams(parsed, 'workspace');\n }\n checkRequiredParams(parsed, 'project', 'repo');\n break;\n }\n case 'azure': {\n checkRequiredParams(parsed, 'project', 'repo');\n break;\n }\n case 'gitlab': {\n // project is the projectID, and if defined, owner and repo won't be needed.\n if (!project) {\n checkRequiredParams(parsed, 'owner', 'repo');\n }\n break;\n }\n case 'gitea': {\n checkRequiredParams(parsed, 'repo');\n break;\n }\n case 'gerrit': {\n checkRequiredParams(parsed, 'repo');\n break;\n }\n default: {\n checkRequiredParams(parsed, 'repo', 'owner');\n break;\n }\n }\n\n return { host, owner, repo, organization, workspace, project };\n};\n\nfunction checkRequiredParams(repoUrl: URL, ...params: string[]) {\n for (let i = 0; i < params.length; i++) {\n if (!repoUrl.searchParams.get(params[i])) {\n throw new InputError(\n `Invalid repo URL passed to publisher: ${repoUrl.toString()}, missing ${\n params[i]\n }`,\n );\n }\n }\n}\n"],"names":["normalizePath","path","joinPath","isChildPath","InputError"],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.cjs.js","sources":["../../src/actions/util.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport { isChildPath } from '@backstage/backend-plugin-api';\nimport { join as joinPath, normalize as normalizePath } from 'path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { TemplateActionOptions } from './createTemplateAction';\nimport zodToJsonSchema from 'zod-to-json-schema';\nimport { z } from 'zod';\nimport { Schema } from 'jsonschema';\n\n/**\n * @public\n */\nexport const getRepoSourceDirectory = (\n workspacePath: string,\n sourcePath: string | undefined,\n) => {\n if (sourcePath) {\n const safeSuffix = normalizePath(sourcePath).replace(\n /^(\\.\\.(\\/|\\\\|$))+/,\n '',\n );\n const path = joinPath(workspacePath, safeSuffix);\n if (!isChildPath(workspacePath, path)) {\n throw new Error('Invalid source path');\n }\n return path;\n }\n return workspacePath;\n};\n\n/**\n * @public\n */\nexport const parseRepoUrl = (\n repoUrl: string,\n integrations: ScmIntegrationRegistry,\n): {\n repo: string;\n host: string;\n owner?: string;\n organization?: string;\n workspace?: string;\n project?: string;\n} => {\n let parsed;\n try {\n parsed = new URL(`https://${repoUrl}`);\n } catch (error) {\n throw new InputError(\n `Invalid repo URL passed to publisher, got ${repoUrl}, ${error}`,\n );\n }\n const host = parsed.host;\n const owner = parsed.searchParams.get('owner') ?? undefined;\n const organization = parsed.searchParams.get('organization') ?? undefined;\n const workspace = parsed.searchParams.get('workspace') ?? undefined;\n const project = parsed.searchParams.get('project') ?? undefined;\n\n const type = integrations.byHost(host)?.type;\n\n if (!type) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const repo: string = parsed.searchParams.get('repo')!;\n switch (type) {\n case 'bitbucket': {\n if (host === 'www.bitbucket.org') {\n checkRequiredParams(parsed, 'workspace');\n }\n checkRequiredParams(parsed, 'project', 'repo');\n break;\n }\n case 'azure': {\n checkRequiredParams(parsed, 'project', 'repo');\n break;\n }\n case 'gitlab': {\n // project is the projectID, and if defined, owner and repo won't be needed.\n if (!project) {\n checkRequiredParams(parsed, 'owner', 'repo');\n }\n break;\n }\n case 'gitea': {\n checkRequiredParams(parsed, 'repo');\n break;\n }\n case 'gerrit': {\n checkRequiredParams(parsed, 'repo');\n break;\n }\n default: {\n checkRequiredParams(parsed, 'repo', 'owner');\n break;\n }\n }\n\n return { host, owner, repo, organization, workspace, project };\n};\n\nfunction checkRequiredParams(repoUrl: URL, ...params: string[]) {\n for (let i = 0; i < params.length; i++) {\n if (!repoUrl.searchParams.get(params[i])) {\n throw new InputError(\n `Invalid repo URL passed to publisher: ${repoUrl.toString()}, missing ${\n params[i]\n }`,\n );\n }\n }\n}\n\nconst isZodSchema = (schema: unknown): schema is z.ZodType => {\n return typeof schema === 'object' && !!schema && 'safeParseAsync' in schema;\n};\n\nconst isNativeZodSchema = (\n schema: unknown,\n): schema is { [key in string]: (zImpl: typeof z) => z.ZodType } => {\n return (\n typeof schema === 'object' &&\n !!schema &&\n Object.values(schema).every(v => typeof v === 'function')\n );\n};\n\nexport const parseSchemas = (\n action: TemplateActionOptions,\n): { inputSchema?: Schema; outputSchema?: Schema } => {\n if (!action.schema) {\n return { inputSchema: undefined, outputSchema: undefined };\n }\n\n if (isZodSchema(action.schema.input)) {\n return {\n inputSchema: zodToJsonSchema(action.schema.input) as Schema,\n outputSchema: isZodSchema(action.schema.output)\n ? (zodToJsonSchema(action.schema.output) as Schema)\n : undefined,\n };\n }\n\n if (isNativeZodSchema(action.schema.input)) {\n const input = z.object(\n Object.fromEntries(\n Object.entries(action.schema.input).map(([k, v]) => [k, v(z)]),\n ),\n );\n\n return {\n inputSchema: zodToJsonSchema(input) as Schema,\n outputSchema: isNativeZodSchema(action.schema.output)\n ? (zodToJsonSchema(\n z.object(\n Object.fromEntries(\n Object.entries(action.schema.output).map(([k, v]) => [k, v(z)]),\n ),\n ),\n ) as Schema)\n : undefined,\n };\n }\n\n return {\n inputSchema: action.schema.input,\n outputSchema: action.schema.output,\n };\n};\n"],"names":["normalizePath","path","joinPath","isChildPath","InputError","zodToJsonSchema","z"],"mappings":";;;;;;;;;;;;AA4Ba,MAAA,sBAAA,GAAyB,CACpC,aAAA,EACA,UACG,KAAA;AACH,EAAA,IAAI,UAAY,EAAA;AACd,IAAM,MAAA,UAAA,GAAaA,cAAc,CAAA,UAAU,CAAE,CAAA,OAAA;AAAA,MAC3C,mBAA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AAAA,KAAC,CAAC,CAAC;AAAA;AAC/D,KACF;AAEA,IAAO,OAAA;AAAA,MACL,WAAA,EAAaD,iCAAgB,KAAK,CAAA;AAAA,MAClC,YAAc,EAAA,iBAAA,CAAkB,MAAO,CAAA,MAAA,CAAO,MAAM,CAC/C,GAAAA,gCAAA;AAAA,QACCC,KAAE,CAAA,MAAA;AAAA,UACA,MAAO,CAAA,WAAA;AAAA,YACL,OAAO,OAAQ,CAAA,MAAA,CAAO,MAAO,CAAA,MAAM,EAAE,GAAI,CAAA,CAAC,CAAC,CAAA,EAAG,CAAC,CAAM,KAAA,CAAC,GAAG,CAAE,CAAAA,KAAC,CAAC,CAAC;AAAA;AAChE;AACF,OAEF,GAAA,KAAA;AAAA,KACN;AAAA;AAGF,EAAO,OAAA;AAAA,IACL,WAAA,EAAa,OAAO,MAAO,CAAA,KAAA;AAAA,IAC3B,YAAA,EAAc,OAAO,MAAO,CAAA;AAAA,GAC9B;AACF;;;;;;"}
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":["../src/alpha/index.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n TaskBroker,\n TemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { CreatedTemplateFilter } from './filters';\nimport { CreatedTemplateGlobal } from './globals';\n\nexport * from '../tasks/alpha';\nexport * from './filters';\nexport * from './globals';\n\n/**\n * Extension point for managing scaffolder actions.\n *\n * @alpha\n */\nexport interface ScaffolderActionsExtensionPoint {\n addActions(...actions: TemplateAction<any, any>[]): void;\n}\n\n/**\n * Extension point for managing scaffolder actions.\n *\n * @alpha\n */\nexport const scaffolderActionsExtensionPoint =\n createExtensionPoint<ScaffolderActionsExtensionPoint>({\n id: 'scaffolder.actions',\n });\n\n/**\n * Extension point for replacing the scaffolder task broker.\n *\n * @alpha\n */\nexport interface ScaffolderTaskBrokerExtensionPoint {\n setTaskBroker(taskBroker: TaskBroker): void;\n}\n\n/**\n * Extension point for replacing the scaffolder task broker.\n *\n * @alpha\n */\nexport const scaffolderTaskBrokerExtensionPoint =\n createExtensionPoint<ScaffolderTaskBrokerExtensionPoint>({\n id: 'scaffolder.taskBroker',\n });\n\n/**\n * Extension point for adding template filters and globals.\n *\n * @alpha\n */\nexport interface ScaffolderTemplatingExtensionPoint {\n addTemplateFilters(\n filters: Record<string, TemplateFilter> | CreatedTemplateFilter[],\n ): void;\n\n addTemplateGlobals(\n globals: Record<string, TemplateGlobal> | CreatedTemplateGlobal[],\n ): void;\n}\n\n/**\n * Extension point for adding template filters and globals.\n *\n * @alpha\n */\nexport const scaffolderTemplatingExtensionPoint =\n createExtensionPoint<ScaffolderTemplatingExtensionPoint>({\n id: 'scaffolder.templating',\n });\n\n/**\n * Autocomplete handler for the scaffolder.\n * @alpha\n */\nexport type AutocompleteHandler = ({\n resource,\n token,\n context,\n}: {\n resource: string;\n token: string;\n context: Record<string, string>;\n}) => Promise<{ results: { title?: string; id: string }[] }>;\n\n/**\n * Extension point for adding autocomplete handler providers\n * @alpha\n */\nexport interface ScaffolderAutocompleteExtensionPoint {\n addAutocompleteProvider({\n id,\n handler,\n }: {\n id: string;\n handler: AutocompleteHandler;\n }): void;\n}\n\n/**\n * Extension point for adding autocomplete handlers.\n *\n * @alpha\n */\nexport const scaffolderAutocompleteExtensionPoint =\n createExtensionPoint<ScaffolderAutocompleteExtensionPoint>({\n id: 'scaffolder.autocomplete',\n });\n\n/**\n * This provider has to be implemented to make it possible to serialize/deserialize scaffolder workspace.\n *\n * @alpha\n */\nexport interface WorkspaceProvider {\n serializeWorkspace({\n path,\n taskId,\n }: {\n path: string;\n taskId: string;\n }): Promise<void>;\n\n cleanWorkspace(options: { taskId: string }): Promise<void>;\n\n rehydrateWorkspace(options: {\n taskId: string;\n targetPath: string;\n }): Promise<void>;\n}\n\n/**\n * Extension point for adding workspace providers.\n *\n * @alpha\n */\nexport interface ScaffolderWorkspaceProviderExtensionPoint {\n addProviders(providers: Record<string, WorkspaceProvider>): void;\n}\n\n/**\n * Extension point for adding workspace providers.\n *\n * @alpha\n */\nexport const scaffolderWorkspaceProviderExtensionPoint =\n createExtensionPoint<ScaffolderWorkspaceProviderExtensionPoint>({\n id: 'scaffolder.workspace.provider',\n });\n"],"names":["createExtensionPoint"],"mappings":";;;;;;;AA4CO,MAAM,kCACXA,qCAAsD,CAAA;AAAA,EACpD,EAAI,EAAA;AACN,CAAC;AAgBI,MAAM,qCACXA,qCAAyD,CAAA;AAAA,EACvD,EAAI,EAAA;AACN,CAAC;AAsBI,MAAM,qCACXA,qCAAyD,CAAA;AAAA,EACvD,EAAI,EAAA;AACN,CAAC;AAmCI,MAAM,uCACXA,qCAA2D,CAAA;AAAA,EACzD,EAAI,EAAA;AACN,CAAC;AAsCI,MAAM,4CACXA,qCAAgE,CAAA;AAAA,EAC9D,EAAI,EAAA;AACN,CAAC;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":["../src/alpha/index.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport {\n TaskBroker,\n TemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { CreatedTemplateFilter } from './filters';\nimport { CreatedTemplateGlobal } from './globals';\n\nexport * from '../tasks/alpha';\nexport * from './filters';\nexport * from './globals';\n\n/**\n * Extension point for managing scaffolder actions.\n *\n * @alpha\n */\nexport interface ScaffolderActionsExtensionPoint {\n addActions(...actions: TemplateAction<any, any, any>[]): void;\n}\n\n/**\n * Extension point for managing scaffolder actions.\n *\n * @alpha\n */\nexport const scaffolderActionsExtensionPoint =\n createExtensionPoint<ScaffolderActionsExtensionPoint>({\n id: 'scaffolder.actions',\n });\n\n/**\n * Extension point for replacing the scaffolder task broker.\n *\n * @alpha\n */\nexport interface ScaffolderTaskBrokerExtensionPoint {\n setTaskBroker(taskBroker: TaskBroker): void;\n}\n\n/**\n * Extension point for replacing the scaffolder task broker.\n *\n * @alpha\n */\nexport const scaffolderTaskBrokerExtensionPoint =\n createExtensionPoint<ScaffolderTaskBrokerExtensionPoint>({\n id: 'scaffolder.taskBroker',\n });\n\n/**\n * Extension point for adding template filters and globals.\n *\n * @alpha\n */\nexport interface ScaffolderTemplatingExtensionPoint {\n addTemplateFilters(\n filters: Record<string, TemplateFilter> | CreatedTemplateFilter[],\n ): void;\n\n addTemplateGlobals(\n globals: Record<string, TemplateGlobal> | CreatedTemplateGlobal[],\n ): void;\n}\n\n/**\n * Extension point for adding template filters and globals.\n *\n * @alpha\n */\nexport const scaffolderTemplatingExtensionPoint =\n createExtensionPoint<ScaffolderTemplatingExtensionPoint>({\n id: 'scaffolder.templating',\n });\n\n/**\n * Autocomplete handler for the scaffolder.\n * @alpha\n */\nexport type AutocompleteHandler = ({\n resource,\n token,\n context,\n}: {\n resource: string;\n token: string;\n context: Record<string, string>;\n}) => Promise<{ results: { title?: string; id: string }[] }>;\n\n/**\n * Extension point for adding autocomplete handler providers\n * @alpha\n */\nexport interface ScaffolderAutocompleteExtensionPoint {\n addAutocompleteProvider({\n id,\n handler,\n }: {\n id: string;\n handler: AutocompleteHandler;\n }): void;\n}\n\n/**\n * Extension point for adding autocomplete handlers.\n *\n * @alpha\n */\nexport const scaffolderAutocompleteExtensionPoint =\n createExtensionPoint<ScaffolderAutocompleteExtensionPoint>({\n id: 'scaffolder.autocomplete',\n });\n\n/**\n * This provider has to be implemented to make it possible to serialize/deserialize scaffolder workspace.\n *\n * @alpha\n */\nexport interface WorkspaceProvider {\n serializeWorkspace({\n path,\n taskId,\n }: {\n path: string;\n taskId: string;\n }): Promise<void>;\n\n cleanWorkspace(options: { taskId: string }): Promise<void>;\n\n rehydrateWorkspace(options: {\n taskId: string;\n targetPath: string;\n }): Promise<void>;\n}\n\n/**\n * Extension point for adding workspace providers.\n *\n * @alpha\n */\nexport interface ScaffolderWorkspaceProviderExtensionPoint {\n addProviders(providers: Record<string, WorkspaceProvider>): void;\n}\n\n/**\n * Extension point for adding workspace providers.\n *\n * @alpha\n */\nexport const scaffolderWorkspaceProviderExtensionPoint =\n createExtensionPoint<ScaffolderWorkspaceProviderExtensionPoint>({\n id: 'scaffolder.workspace.provider',\n });\n"],"names":["createExtensionPoint"],"mappings":";;;;;;;AA4CO,MAAM,kCACXA,qCAAsD,CAAA;AAAA,EACpD,EAAI,EAAA;AACN,CAAC;AAgBI,MAAM,qCACXA,qCAAyD,CAAA;AAAA,EACvD,EAAI,EAAA;AACN,CAAC;AAsBI,MAAM,qCACXA,qCAAyD,CAAA;AAAA,EACvD,EAAI,EAAA;AACN,CAAC;AAmCI,MAAM,uCACXA,qCAA2D,CAAA;AAAA,EACzD,EAAI,EAAA;AACN,CAAC;AAsCI,MAAM,4CACXA,qCAAgE,CAAA;AAAA,EAC9D,EAAI,EAAA;AACN,CAAC;;;;;;;;;;;;;"}
|
package/dist/alpha.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
3
2
|
import { TemplateAction, TaskBroker, TemplateFilter as TemplateFilter$1, TemplateGlobal as TemplateGlobal$1 } from '@backstage/plugin-scaffolder-node';
|
|
4
3
|
import { z } from 'zod';
|
|
@@ -26,7 +25,7 @@ type CreatedTemplateFilter<TSchema extends TemplateFilterSchema<any, any> | unde
|
|
|
26
25
|
* This function is used to create new template filters in type-safe manner.
|
|
27
26
|
* @alpha
|
|
28
27
|
*/
|
|
29
|
-
declare const createTemplateFilter: <TSchema extends TemplateFilterSchema<any, any> | undefined, TFunctionSchema extends TSchema extends TemplateFilterSchema<any, any> ? z.
|
|
28
|
+
declare const createTemplateFilter: <TSchema extends TemplateFilterSchema<any, any> | undefined, TFunctionSchema extends TSchema extends TemplateFilterSchema<any, any> ? z.infer<ReturnType<TSchema>> : (arg: JsonValue, ...rest: JsonValue[]) => JsonValue | undefined>(filter: CreatedTemplateFilter<TSchema, TFunctionSchema>) => CreatedTemplateFilter<unknown, unknown>;
|
|
30
29
|
|
|
31
30
|
/** @alpha */
|
|
32
31
|
type CreatedTemplateGlobalValue<T extends JsonValue = JsonValue> = {
|
|
@@ -67,7 +66,7 @@ declare const createTemplateGlobalValue: (v: CreatedTemplateGlobalValue) => Crea
|
|
|
67
66
|
* @returns fn
|
|
68
67
|
* @alpha
|
|
69
68
|
*/
|
|
70
|
-
declare const createTemplateGlobalFunction: <TSchema extends TemplateGlobalFunctionSchema<any, any> | undefined, TFilterSchema extends TSchema extends TemplateGlobalFunctionSchema<any, any> ? z.
|
|
69
|
+
declare const createTemplateGlobalFunction: <TSchema extends TemplateGlobalFunctionSchema<any, any> | undefined, TFilterSchema extends TSchema extends TemplateGlobalFunctionSchema<any, any> ? z.infer<ReturnType<TSchema>> : (...args: JsonValue[]) => JsonValue | undefined>(fn: CreatedTemplateGlobalFunction<TSchema, TFilterSchema>) => CreatedTemplateGlobalFunction<any, any>;
|
|
71
70
|
|
|
72
71
|
/**
|
|
73
72
|
* Serializes provided path into tar archive
|
|
@@ -95,7 +94,7 @@ declare const restoreWorkspace: (opts: {
|
|
|
95
94
|
* @alpha
|
|
96
95
|
*/
|
|
97
96
|
interface ScaffolderActionsExtensionPoint {
|
|
98
|
-
addActions(...actions: TemplateAction<any, any>[]): void;
|
|
97
|
+
addActions(...actions: TemplateAction<any, any, any>[]): void;
|
|
99
98
|
}
|
|
100
99
|
/**
|
|
101
100
|
* Extension point for managing scaffolder actions.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Logger } from 'winston';
|
|
3
2
|
import { Writable } from 'stream';
|
|
4
|
-
import { JsonObject, JsonValue, Observable } from '@backstage/types';
|
|
3
|
+
import { JsonObject, JsonValue, Observable, Expand } from '@backstage/types';
|
|
5
4
|
import { BackstageCredentials, LoggerService, UrlReaderService } from '@backstage/backend-plugin-api';
|
|
6
5
|
import { TaskSpec, TemplateInfo } from '@backstage/plugin-scaffolder-common';
|
|
7
6
|
import { UserEntity } from '@backstage/catalog-model';
|
|
@@ -176,7 +175,58 @@ interface TaskBroker {
|
|
|
176
175
|
* ActionContext is passed into scaffolder actions.
|
|
177
176
|
* @public
|
|
178
177
|
*/
|
|
179
|
-
type ActionContext<TActionInput extends JsonObject, TActionOutput extends JsonObject = JsonObject> = {
|
|
178
|
+
type ActionContext<TActionInput extends JsonObject, TActionOutput extends JsonObject = JsonObject, TSchemaType extends 'v1' | 'v2' = 'v1'> = TSchemaType extends 'v2' ? {
|
|
179
|
+
logger: LoggerService;
|
|
180
|
+
secrets?: TaskSecrets;
|
|
181
|
+
workspacePath: string;
|
|
182
|
+
input: TActionInput;
|
|
183
|
+
checkpoint<T extends JsonValue | void>(opts: {
|
|
184
|
+
key: string;
|
|
185
|
+
fn: () => Promise<T> | T;
|
|
186
|
+
}): Promise<T>;
|
|
187
|
+
output(name: keyof TActionOutput, value: TActionOutput[keyof TActionOutput]): void;
|
|
188
|
+
/**
|
|
189
|
+
* Creates a temporary directory for use by the action, which is then cleaned up automatically.
|
|
190
|
+
*/
|
|
191
|
+
createTemporaryDirectory(): Promise<string>;
|
|
192
|
+
/**
|
|
193
|
+
* Get the credentials for the current request
|
|
194
|
+
*/
|
|
195
|
+
getInitiatorCredentials(): Promise<BackstageCredentials>;
|
|
196
|
+
/**
|
|
197
|
+
* Task information
|
|
198
|
+
*/
|
|
199
|
+
task: {
|
|
200
|
+
id: string;
|
|
201
|
+
};
|
|
202
|
+
templateInfo?: TemplateInfo;
|
|
203
|
+
/**
|
|
204
|
+
* Whether this action invocation is a dry-run or not.
|
|
205
|
+
* This will only ever be true if the actions as marked as supporting dry-runs.
|
|
206
|
+
*/
|
|
207
|
+
isDryRun?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* The user which triggered the action.
|
|
210
|
+
*/
|
|
211
|
+
user?: {
|
|
212
|
+
/**
|
|
213
|
+
* The decorated entity from the Catalog
|
|
214
|
+
*/
|
|
215
|
+
entity?: UserEntity;
|
|
216
|
+
/**
|
|
217
|
+
* An entity ref for the author of the task
|
|
218
|
+
*/
|
|
219
|
+
ref?: string;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Implement the signal to make your custom step abortable https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
|
|
223
|
+
*/
|
|
224
|
+
signal?: AbortSignal;
|
|
225
|
+
/**
|
|
226
|
+
* Optional value of each invocation
|
|
227
|
+
*/
|
|
228
|
+
each?: JsonObject;
|
|
229
|
+
} : {
|
|
180
230
|
logger: Logger;
|
|
181
231
|
/** @deprecated - use `ctx.logger` instead */
|
|
182
232
|
logStream: Writable;
|
|
@@ -231,7 +281,7 @@ type ActionContext<TActionInput extends JsonObject, TActionOutput extends JsonOb
|
|
|
231
281
|
each?: JsonObject;
|
|
232
282
|
};
|
|
233
283
|
/** @public */
|
|
234
|
-
type TemplateAction<TActionInput extends JsonObject = JsonObject, TActionOutput extends JsonObject = JsonObject> = {
|
|
284
|
+
type TemplateAction<TActionInput extends JsonObject = JsonObject, TActionOutput extends JsonObject = JsonObject, TSchemaType extends 'v1' | 'v2' = 'v1'> = {
|
|
235
285
|
id: string;
|
|
236
286
|
description?: string;
|
|
237
287
|
examples?: {
|
|
@@ -243,7 +293,7 @@ type TemplateAction<TActionInput extends JsonObject = JsonObject, TActionOutput
|
|
|
243
293
|
input?: Schema;
|
|
244
294
|
output?: Schema;
|
|
245
295
|
};
|
|
246
|
-
handler: (ctx: ActionContext<TActionInput, TActionOutput>) => Promise<void>;
|
|
296
|
+
handler: (ctx: ActionContext<TActionInput, TActionOutput, TSchemaType>) => Promise<void>;
|
|
247
297
|
};
|
|
248
298
|
|
|
249
299
|
/** @public */
|
|
@@ -252,7 +302,11 @@ type TemplateExample = {
|
|
|
252
302
|
example: string;
|
|
253
303
|
};
|
|
254
304
|
/** @public */
|
|
255
|
-
type TemplateActionOptions<TActionInput extends JsonObject = {}, TActionOutput extends JsonObject = {}, TInputSchema extends
|
|
305
|
+
type TemplateActionOptions<TActionInput extends JsonObject = {}, TActionOutput extends JsonObject = {}, TInputSchema extends JsonObject | z.ZodType | {
|
|
306
|
+
[key in string]: (zImpl: typeof z) => z.ZodType;
|
|
307
|
+
} = JsonObject, TOutputSchema extends JsonObject | z.ZodType | {
|
|
308
|
+
[key in string]: (zImpl: typeof z) => z.ZodType;
|
|
309
|
+
} = JsonObject, TSchemaType extends 'v1' | 'v2' = 'v1' | 'v2'> = {
|
|
256
310
|
id: string;
|
|
257
311
|
description?: string;
|
|
258
312
|
examples?: TemplateExample[];
|
|
@@ -261,14 +315,46 @@ type TemplateActionOptions<TActionInput extends JsonObject = {}, TActionOutput e
|
|
|
261
315
|
input?: TInputSchema;
|
|
262
316
|
output?: TOutputSchema;
|
|
263
317
|
};
|
|
264
|
-
handler: (ctx: ActionContext<TActionInput, TActionOutput>) => Promise<void>;
|
|
318
|
+
handler: (ctx: ActionContext<TActionInput, TActionOutput, TSchemaType>) => Promise<void>;
|
|
265
319
|
};
|
|
320
|
+
/**
|
|
321
|
+
* @ignore
|
|
322
|
+
*/
|
|
323
|
+
type FlattenOptionalProperties<T extends {
|
|
324
|
+
[key in string]: unknown;
|
|
325
|
+
}> = Expand<{
|
|
326
|
+
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
|
|
327
|
+
} & {
|
|
328
|
+
[K in keyof T as undefined extends T[K] ? K : never]?: T[K];
|
|
329
|
+
}>;
|
|
330
|
+
/**
|
|
331
|
+
* @public
|
|
332
|
+
* @deprecated migrate to using the new built in zod schema definitions for schemas
|
|
333
|
+
*/
|
|
334
|
+
declare function createTemplateAction<TInputParams extends JsonObject = JsonObject, TOutputParams extends JsonObject = JsonObject, TInputSchema extends JsonObject = JsonObject, TOutputSchema extends JsonObject = JsonObject, TActionInput extends JsonObject = TInputParams, TActionOutput extends JsonObject = TOutputParams>(action: TemplateActionOptions<TActionInput, TActionOutput, TInputSchema, TOutputSchema, 'v1'>): TemplateAction<TActionInput, TActionOutput, 'v1'>;
|
|
335
|
+
/**
|
|
336
|
+
* @public
|
|
337
|
+
* @deprecated migrate to using the new built in zod schema definitions for schemas
|
|
338
|
+
*/
|
|
339
|
+
declare function createTemplateAction<TInputParams extends JsonObject = JsonObject, TOutputParams extends JsonObject = JsonObject, TInputSchema extends z.ZodType = z.ZodType, TOutputSchema extends z.ZodType = z.ZodType, TActionInput extends JsonObject = z.infer<TInputSchema>, TActionOutput extends JsonObject = z.infer<TOutputSchema>>(action: TemplateActionOptions<TActionInput, TActionOutput, TInputSchema, TOutputSchema, 'v1'>): TemplateAction<TActionInput, TActionOutput, 'v1'>;
|
|
266
340
|
/**
|
|
267
341
|
* This function is used to create new template actions to get type safety.
|
|
268
342
|
* Will convert zod schemas to json schemas for use throughout the system.
|
|
269
343
|
* @public
|
|
270
344
|
*/
|
|
271
|
-
declare
|
|
345
|
+
declare function createTemplateAction<TInputSchema extends {
|
|
346
|
+
[key in string]: (zImpl: typeof z) => z.ZodType;
|
|
347
|
+
}, TOutputSchema extends {
|
|
348
|
+
[key in string]: (zImpl: typeof z) => z.ZodType;
|
|
349
|
+
}>(action: TemplateActionOptions<{
|
|
350
|
+
[key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;
|
|
351
|
+
}, {
|
|
352
|
+
[key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>;
|
|
353
|
+
}, TInputSchema, TOutputSchema, 'v2'>): TemplateAction<FlattenOptionalProperties<{
|
|
354
|
+
[key in keyof TInputSchema]: z.output<ReturnType<TInputSchema[key]>>;
|
|
355
|
+
}>, FlattenOptionalProperties<{
|
|
356
|
+
[key in keyof TOutputSchema]: z.output<ReturnType<TOutputSchema[key]>>;
|
|
357
|
+
}>, 'v2'>;
|
|
272
358
|
|
|
273
359
|
/**
|
|
274
360
|
* Options for {@link executeShellCommand}.
|
|
@@ -345,6 +431,7 @@ declare function initRepoAndPush(input: {
|
|
|
345
431
|
name?: string;
|
|
346
432
|
email?: string;
|
|
347
433
|
};
|
|
434
|
+
signingKey?: string;
|
|
348
435
|
}): Promise<{
|
|
349
436
|
commitHash: string;
|
|
350
437
|
}>;
|
|
@@ -367,6 +454,7 @@ declare function commitAndPushRepo(input: {
|
|
|
367
454
|
};
|
|
368
455
|
branch?: string;
|
|
369
456
|
remoteRef?: string;
|
|
457
|
+
signingKey?: string;
|
|
370
458
|
}): Promise<{
|
|
371
459
|
commitHash: string;
|
|
372
460
|
}>;
|
|
@@ -435,6 +523,7 @@ declare function commitAndPushBranch(options: {
|
|
|
435
523
|
branch?: string;
|
|
436
524
|
remoteRef?: string;
|
|
437
525
|
remote?: string;
|
|
526
|
+
signingKey?: string;
|
|
438
527
|
}): Promise<{
|
|
439
528
|
commitHash: string;
|
|
440
529
|
}>;
|
|
@@ -449,10 +538,10 @@ declare const getRepoSourceDirectory: (workspacePath: string, sourcePath: string
|
|
|
449
538
|
declare const parseRepoUrl: (repoUrl: string, integrations: ScmIntegrationRegistry) => {
|
|
450
539
|
repo: string;
|
|
451
540
|
host: string;
|
|
452
|
-
owner?: string
|
|
453
|
-
organization?: string
|
|
454
|
-
workspace?: string
|
|
455
|
-
project?: string
|
|
541
|
+
owner?: string;
|
|
542
|
+
organization?: string;
|
|
543
|
+
workspace?: string;
|
|
544
|
+
project?: string;
|
|
456
545
|
};
|
|
457
546
|
|
|
458
547
|
/**
|
package/dist/scm/git.cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var git = require('isomorphic-git');
|
|
4
4
|
var http = require('isomorphic-git/http/node');
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
|
+
var pgpPlugin = require('@isomorphic-git/pgp-plugin');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -51,11 +52,19 @@ class Git {
|
|
|
51
52
|
return git__default.default.branch({ fs: fs__default.default, dir, ref });
|
|
52
53
|
}
|
|
53
54
|
async commit(options) {
|
|
54
|
-
const { dir, message, author, committer } = options;
|
|
55
|
+
const { dir, message, author, committer, signingKey } = options;
|
|
55
56
|
this.config.logger?.info(
|
|
56
57
|
`Committing file to repo {dir=${dir},message=${message}}`
|
|
57
58
|
);
|
|
58
|
-
return git__default.default.commit({
|
|
59
|
+
return git__default.default.commit({
|
|
60
|
+
fs: fs__default.default,
|
|
61
|
+
dir,
|
|
62
|
+
message,
|
|
63
|
+
author,
|
|
64
|
+
committer,
|
|
65
|
+
signingKey,
|
|
66
|
+
onSign: signingKey ? pgpPlugin.pgp.sign : void 0
|
|
67
|
+
});
|
|
59
68
|
}
|
|
60
69
|
/** https://isomorphic-git.org/docs/en/clone */
|
|
61
70
|
async clone(options) {
|
|
@@ -126,7 +135,7 @@ class Git {
|
|
|
126
135
|
}
|
|
127
136
|
/** https://isomorphic-git.org/docs/en/merge */
|
|
128
137
|
async merge(options) {
|
|
129
|
-
const { dir, theirs, ours, author, committer } = options;
|
|
138
|
+
const { dir, theirs, ours, author, committer, signingKey } = options;
|
|
130
139
|
this.config.logger?.info(
|
|
131
140
|
`Merging branch '${theirs}' into '${ours}' for repository {dir=${dir}}`
|
|
132
141
|
);
|
|
@@ -136,7 +145,9 @@ class Git {
|
|
|
136
145
|
ours,
|
|
137
146
|
theirs,
|
|
138
147
|
author,
|
|
139
|
-
committer
|
|
148
|
+
committer,
|
|
149
|
+
signingKey,
|
|
150
|
+
onSign: signingKey ? pgpPlugin.pgp.sign : void 0
|
|
140
151
|
});
|
|
141
152
|
}
|
|
142
153
|
async push(options) {
|
package/dist/scm/git.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.cjs.js","sources":["../../src/scm/git.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport git, {\n ProgressCallback,\n MergeResult,\n ReadCommitResult,\n AuthCallback,\n} from 'isomorphic-git';\nimport http from 'isomorphic-git/http/node';\nimport fs from 'fs-extra';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nfunction isAuthCallbackOptions(\n options: StaticAuthOptions | AuthCallbackOptions,\n): options is AuthCallbackOptions {\n return 'onAuth' in options;\n}\n\n/**\n * Configure static credential for authentication\n *\n * @public\n */\nexport type StaticAuthOptions = {\n username?: string;\n password?: string;\n token?: string;\n logger?: LoggerService;\n};\n\n/**\n * Configure an authentication callback that can provide credentials on demand\n *\n * @public\n */\nexport type AuthCallbackOptions = {\n onAuth: AuthCallback;\n logger?: LoggerService;\n};\n\n/*\nprovider username password\nAzure 'notempty' token\nBitbucket Cloud 'x-token-auth' token\nBitbucket Server username password or token\nGitHub 'x-access-token' token\nGitLab 'oauth2' token\n\nFrom : https://isomorphic-git.org/docs/en/onAuth with fix for GitHub\n\nOr token provided as `token` for Bearer auth header\ninstead of Basic Auth (e.g., Bitbucket Server).\n*/\n\n/**\n * A convenience wrapper around the `isomorphic-git` library.\n *\n * @public\n */\n\nexport class Git {\n private readonly headers: {\n [x: string]: string;\n };\n\n private constructor(\n private readonly config: {\n onAuth: AuthCallback;\n token?: string;\n logger?: LoggerService;\n },\n ) {\n this.onAuth = config.onAuth;\n\n this.headers = {\n 'user-agent': 'git/@isomorphic-git',\n ...(config.token ? { Authorization: `Bearer ${config.token}` } : {}),\n };\n }\n\n async add(options: { dir: string; filepath: string }): Promise<void> {\n const { dir, filepath } = options;\n this.config.logger?.info(`Adding file {dir=${dir},filepath=${filepath}}`);\n\n return git.add({ fs, dir, filepath });\n }\n\n async addRemote(options: {\n dir: string;\n remote: string;\n url: string;\n force?: boolean;\n }): Promise<void> {\n const { dir, url, remote, force } = options;\n this.config.logger?.info(\n `Creating new remote {dir=${dir},remote=${remote},url=${url}}`,\n );\n return git.addRemote({ fs, dir, remote, url, force });\n }\n\n async deleteRemote(options: { dir: string; remote: string }): Promise<void> {\n const { dir, remote } = options;\n this.config.logger?.info(`Deleting remote {dir=${dir},remote=${remote}}`);\n return git.deleteRemote({ fs, dir, remote });\n }\n\n async checkout(options: { dir: string; ref: string }): Promise<void> {\n const { dir, ref } = options;\n this.config.logger?.info(`Checking out branch {dir=${dir},ref=${ref}}`);\n\n return git.checkout({ fs, dir, ref });\n }\n\n async branch(options: { dir: string; ref: string }): Promise<void> {\n const { dir, ref } = options;\n this.config.logger?.info(`Creating branch {dir=${dir},ref=${ref}`);\n\n return git.branch({ fs, dir, ref });\n }\n\n async commit(options: {\n dir: string;\n message: string;\n author: { name: string; email: string };\n committer: { name: string; email: string };\n }): Promise<string> {\n const { dir, message, author, committer } = options;\n this.config.logger?.info(\n `Committing file to repo {dir=${dir},message=${message}}`,\n );\n return git.commit({ fs, dir, message, author, committer });\n }\n\n /** https://isomorphic-git.org/docs/en/clone */\n async clone(options: {\n url: string;\n dir: string;\n ref?: string;\n depth?: number;\n noCheckout?: boolean;\n }): Promise<void> {\n const { url, dir, ref, depth, noCheckout } = options;\n this.config.logger?.info(`Cloning repo {dir=${dir},url=${url}}`);\n\n try {\n return await git.clone({\n fs,\n http,\n url,\n dir,\n ref,\n singleBranch: true,\n depth: depth ?? 1,\n noCheckout,\n onProgress: this.onProgressHandler(),\n headers: this.headers,\n onAuth: this.onAuth,\n });\n } catch (ex) {\n this.config.logger?.error(`Failed to clone repo {dir=${dir},url=${url}}`);\n if (ex.data) {\n throw new Error(`${ex.message} {data=${JSON.stringify(ex.data)}}`);\n }\n throw ex;\n }\n }\n\n /** https://isomorphic-git.org/docs/en/currentBranch */\n async currentBranch(options: {\n dir: string;\n fullName?: boolean;\n }): Promise<string | undefined> {\n const { dir, fullName = false } = options;\n return git.currentBranch({ fs, dir, fullname: fullName }) as Promise<\n string | undefined\n >;\n }\n\n /** https://isomorphic-git.org/docs/en/fetch */\n async fetch(options: {\n dir: string;\n remote?: string;\n tags?: boolean;\n }): Promise<void> {\n const { dir, remote = 'origin', tags = false } = options;\n this.config.logger?.info(\n `Fetching remote=${remote} for repository {dir=${dir}}`,\n );\n\n try {\n await git.fetch({\n fs,\n http,\n dir,\n remote,\n tags,\n onProgress: this.onProgressHandler(),\n headers: this.headers,\n onAuth: this.onAuth,\n });\n } catch (ex) {\n this.config.logger?.error(\n `Failed to fetch repo {dir=${dir},remote=${remote}}`,\n );\n if (ex.data) {\n throw new Error(`${ex.message} {data=${JSON.stringify(ex.data)}}`);\n }\n throw ex;\n }\n }\n\n async init(options: { dir: string; defaultBranch?: string }): Promise<void> {\n const { dir, defaultBranch = 'master' } = options;\n this.config.logger?.info(`Init git repository {dir=${dir}}`);\n\n return git.init({\n fs,\n dir,\n defaultBranch,\n });\n }\n\n /** https://isomorphic-git.org/docs/en/merge */\n async merge(options: {\n dir: string;\n theirs: string;\n ours?: string;\n author: { name: string; email: string };\n committer: { name: string; email: string };\n }): Promise<MergeResult> {\n const { dir, theirs, ours, author, committer } = options;\n this.config.logger?.info(\n `Merging branch '${theirs}' into '${ours}' for repository {dir=${dir}}`,\n );\n\n // If ours is undefined, current branch is used.\n return git.merge({\n fs,\n dir,\n ours,\n theirs,\n author,\n committer,\n });\n }\n\n async push(options: {\n dir: string;\n remote: string;\n remoteRef?: string;\n url?: string;\n force?: boolean;\n }) {\n const { dir, remote, url, remoteRef, force } = options;\n this.config.logger?.info(\n `Pushing directory to remote {dir=${dir},remote=${remote}}`,\n );\n try {\n return await git.push({\n fs,\n dir,\n http,\n onProgress: this.onProgressHandler(),\n remoteRef,\n force,\n headers: this.headers,\n remote,\n url,\n onAuth: this.onAuth,\n corsProxy: '',\n });\n } catch (ex) {\n this.config.logger?.error(\n `Failed to push to repo {dir=${dir}, remote=${remote}}`,\n );\n if (ex.data) {\n throw new Error(`${ex.message} {data=${JSON.stringify(ex.data)}}`);\n }\n throw ex;\n }\n }\n\n /** https://isomorphic-git.org/docs/en/readCommit */\n async readCommit(options: {\n dir: string;\n sha: string;\n }): Promise<ReadCommitResult> {\n const { dir, sha } = options;\n return git.readCommit({ fs, dir, oid: sha });\n }\n\n /** https://isomorphic-git.org/docs/en/remove */\n async remove(options: { dir: string; filepath: string }): Promise<void> {\n const { dir, filepath } = options;\n this.config.logger?.info(\n `Removing file from git index {dir=${dir},filepath=${filepath}}`,\n );\n return git.remove({ fs, dir, filepath });\n }\n\n /** https://isomorphic-git.org/docs/en/resolveRef */\n async resolveRef(options: { dir: string; ref: string }): Promise<string> {\n const { dir, ref } = options;\n return git.resolveRef({ fs, dir, ref });\n }\n\n /** https://isomorphic-git.org/docs/en/log */\n async log(options: {\n dir: string;\n ref?: string;\n }): Promise<ReadCommitResult[]> {\n const { dir, ref } = options;\n return git.log({\n fs,\n dir,\n ref: ref ?? 'HEAD',\n });\n }\n\n private onAuth: AuthCallback;\n\n private onProgressHandler = (): ProgressCallback => {\n let currentPhase = '';\n\n return event => {\n if (currentPhase !== event.phase) {\n currentPhase = event.phase;\n this.config.logger?.info(event.phase);\n }\n const total = event.total\n ? `${Math.round((event.loaded / event.total) * 100)}%`\n : event.loaded;\n this.config.logger?.debug(`status={${event.phase},total={${total}}}`);\n };\n };\n\n static fromAuth = (options: StaticAuthOptions | AuthCallbackOptions) => {\n if (isAuthCallbackOptions(options)) {\n const { onAuth, logger } = options;\n return new Git({ onAuth, logger });\n }\n\n const { username, password, token, logger } = options;\n return new Git({ onAuth: () => ({ username, password }), token, logger });\n };\n}\n"],"names":["git","fs","http","logger"],"mappings":";;;;;;;;;;;;AA0BA,SAAS,sBACP,OACgC,EAAA;AAChC,EAAA,OAAO,QAAY,IAAA,OAAA;AACrB;AA4CO,MAAM,GAAI,CAAA;AAAA,EAKP,YACW,MAKjB,EAAA;AALiB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAMjB,IAAA,IAAA,CAAK,SAAS,MAAO,CAAA,MAAA;AAErB,IAAA,IAAA,CAAK,OAAU,GAAA;AAAA,MACb,YAAc,EAAA,qBAAA;AAAA,MACd,GAAI,MAAO,CAAA,KAAA,GAAQ,EAAE,aAAA,EAAe,UAAU,MAAO,CAAA,KAAK,CAAG,CAAA,EAAA,GAAI;AAAC,KACpE;AAAA;AACF,EAjBiB,OAAA;AAAA,EAmBjB,MAAM,IAAI,OAA2D,EAAA;AACnE,IAAM,MAAA,EAAE,GAAK,EAAA,QAAA,EAAa,GAAA,OAAA;AAC1B,IAAA,IAAA,CAAK,OAAO,MAAQ,EAAA,IAAA,CAAK,oBAAoB,GAAG,CAAA,UAAA,EAAa,QAAQ,CAAG,CAAA,CAAA,CAAA;AAExE,IAAA,OAAOA,qBAAI,GAAI,CAAA,MAAEC,mBAAI,EAAA,GAAA,EAAK,UAAU,CAAA;AAAA;AACtC,EAEA,M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;AAGnC,IAAA,MAAM,EAAE,QAAA,EAAU,QAAU,EAAA,KAAA,EAAO,QAAW,GAAA,OAAA;AAC9C,IAAO,OAAA,IAAI,GAAI,CAAA,EAAE,MAAQ,EAAA,OAAO,EAAE,QAAA,EAAU,QAAS,EAAA,CAAA,EAAI,KAAO,EAAA,MAAA,EAAQ,CAAA;AAAA,GAC1E;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"git.cjs.js","sources":["../../src/scm/git.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport git, {\n AuthCallback,\n MergeResult,\n ProgressCallback,\n ReadCommitResult,\n} from 'isomorphic-git';\nimport http from 'isomorphic-git/http/node';\nimport fs from 'fs-extra';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n// @ts-ignore\nimport { pgp } from '@isomorphic-git/pgp-plugin';\n\nfunction isAuthCallbackOptions(\n options: StaticAuthOptions | AuthCallbackOptions,\n): options is AuthCallbackOptions {\n return 'onAuth' in options;\n}\n\n/**\n * Configure static credential for authentication\n *\n * @public\n */\nexport type StaticAuthOptions = {\n username?: string;\n password?: string;\n token?: string;\n logger?: LoggerService;\n};\n\n/**\n * Configure an authentication callback that can provide credentials on demand\n *\n * @public\n */\nexport type AuthCallbackOptions = {\n onAuth: AuthCallback;\n logger?: LoggerService;\n};\n\n/*\nprovider username password\nAzure 'notempty' token\nBitbucket Cloud 'x-token-auth' token\nBitbucket Server username password or token\nGitHub 'x-access-token' token\nGitLab 'oauth2' token\n\nFrom : https://isomorphic-git.org/docs/en/onAuth with fix for GitHub\n\nOr token provided as `token` for Bearer auth header\ninstead of Basic Auth (e.g., Bitbucket Server).\n*/\n\n/**\n * A convenience wrapper around the `isomorphic-git` library.\n *\n * @public\n */\n\nexport class Git {\n private readonly headers: {\n [x: string]: string;\n };\n\n private constructor(\n private readonly config: {\n onAuth: AuthCallback;\n token?: string;\n logger?: LoggerService;\n },\n ) {\n this.onAuth = config.onAuth;\n\n this.headers = {\n 'user-agent': 'git/@isomorphic-git',\n ...(config.token ? { Authorization: `Bearer ${config.token}` } : {}),\n };\n }\n\n async add(options: { dir: string; filepath: string }): Promise<void> {\n const { dir, filepath } = options;\n this.config.logger?.info(`Adding file {dir=${dir},filepath=${filepath}}`);\n\n return git.add({ fs, dir, filepath });\n }\n\n async addRemote(options: {\n dir: string;\n remote: string;\n url: string;\n force?: boolean;\n }): Promise<void> {\n const { dir, url, remote, force } = options;\n this.config.logger?.info(\n `Creating new remote {dir=${dir},remote=${remote},url=${url}}`,\n );\n return git.addRemote({ fs, dir, remote, url, force });\n }\n\n async deleteRemote(options: { dir: string; remote: string }): Promise<void> {\n const { dir, remote } = options;\n this.config.logger?.info(`Deleting remote {dir=${dir},remote=${remote}}`);\n return git.deleteRemote({ fs, dir, remote });\n }\n\n async checkout(options: { dir: string; ref: string }): Promise<void> {\n const { dir, ref } = options;\n this.config.logger?.info(`Checking out branch {dir=${dir},ref=${ref}}`);\n\n return git.checkout({ fs, dir, ref });\n }\n\n async branch(options: { dir: string; ref: string }): Promise<void> {\n const { dir, ref } = options;\n this.config.logger?.info(`Creating branch {dir=${dir},ref=${ref}`);\n\n return git.branch({ fs, dir, ref });\n }\n\n async commit(options: {\n dir: string;\n message: string;\n author: { name: string; email: string };\n committer: { name: string; email: string };\n signingKey?: string;\n }): Promise<string> {\n const { dir, message, author, committer, signingKey } = options;\n this.config.logger?.info(\n `Committing file to repo {dir=${dir},message=${message}}`,\n );\n return git.commit({\n fs,\n dir,\n message,\n author,\n committer,\n signingKey,\n onSign: signingKey ? pgp.sign : undefined,\n });\n }\n\n /** https://isomorphic-git.org/docs/en/clone */\n async clone(options: {\n url: string;\n dir: string;\n ref?: string;\n depth?: number;\n noCheckout?: boolean;\n }): Promise<void> {\n const { url, dir, ref, depth, noCheckout } = options;\n this.config.logger?.info(`Cloning repo {dir=${dir},url=${url}}`);\n\n try {\n return await git.clone({\n fs,\n http,\n url,\n dir,\n ref,\n singleBranch: true,\n depth: depth ?? 1,\n noCheckout,\n onProgress: this.onProgressHandler(),\n headers: this.headers,\n onAuth: this.onAuth,\n });\n } catch (ex) {\n this.config.logger?.error(`Failed to clone repo {dir=${dir},url=${url}}`);\n if (ex.data) {\n throw new Error(`${ex.message} {data=${JSON.stringify(ex.data)}}`);\n }\n throw ex;\n }\n }\n\n /** https://isomorphic-git.org/docs/en/currentBranch */\n async currentBranch(options: {\n dir: string;\n fullName?: boolean;\n }): Promise<string | undefined> {\n const { dir, fullName = false } = options;\n return git.currentBranch({ fs, dir, fullname: fullName }) as Promise<\n string | undefined\n >;\n }\n\n /** https://isomorphic-git.org/docs/en/fetch */\n async fetch(options: {\n dir: string;\n remote?: string;\n tags?: boolean;\n }): Promise<void> {\n const { dir, remote = 'origin', tags = false } = options;\n this.config.logger?.info(\n `Fetching remote=${remote} for repository {dir=${dir}}`,\n );\n\n try {\n await git.fetch({\n fs,\n http,\n dir,\n remote,\n tags,\n onProgress: this.onProgressHandler(),\n headers: this.headers,\n onAuth: this.onAuth,\n });\n } catch (ex) {\n this.config.logger?.error(\n `Failed to fetch repo {dir=${dir},remote=${remote}}`,\n );\n if (ex.data) {\n throw new Error(`${ex.message} {data=${JSON.stringify(ex.data)}}`);\n }\n throw ex;\n }\n }\n\n async init(options: { dir: string; defaultBranch?: string }): Promise<void> {\n const { dir, defaultBranch = 'master' } = options;\n this.config.logger?.info(`Init git repository {dir=${dir}}`);\n\n return git.init({\n fs,\n dir,\n defaultBranch,\n });\n }\n\n /** https://isomorphic-git.org/docs/en/merge */\n async merge(options: {\n dir: string;\n theirs: string;\n ours?: string;\n author: { name: string; email: string };\n committer: { name: string; email: string };\n signingKey?: string;\n }): Promise<MergeResult> {\n const { dir, theirs, ours, author, committer, signingKey } = options;\n this.config.logger?.info(\n `Merging branch '${theirs}' into '${ours}' for repository {dir=${dir}}`,\n );\n\n // If ours is undefined, current branch is used.\n return git.merge({\n fs,\n dir,\n ours,\n theirs,\n author,\n committer,\n signingKey,\n onSign: signingKey ? pgp.sign : undefined,\n });\n }\n\n async push(options: {\n dir: string;\n remote: string;\n remoteRef?: string;\n url?: string;\n force?: boolean;\n }) {\n const { dir, remote, url, remoteRef, force } = options;\n this.config.logger?.info(\n `Pushing directory to remote {dir=${dir},remote=${remote}}`,\n );\n try {\n return await git.push({\n fs,\n dir,\n http,\n onProgress: this.onProgressHandler(),\n remoteRef,\n force,\n headers: this.headers,\n remote,\n url,\n onAuth: this.onAuth,\n corsProxy: '',\n });\n } catch (ex) {\n this.config.logger?.error(\n `Failed to push to repo {dir=${dir}, remote=${remote}}`,\n );\n if (ex.data) {\n throw new Error(`${ex.message} {data=${JSON.stringify(ex.data)}}`);\n }\n throw ex;\n }\n }\n\n /** https://isomorphic-git.org/docs/en/readCommit */\n async readCommit(options: {\n dir: string;\n sha: string;\n }): Promise<ReadCommitResult> {\n const { dir, sha } = options;\n return git.readCommit({ fs, dir, oid: sha });\n }\n\n /** https://isomorphic-git.org/docs/en/remove */\n async remove(options: { dir: string; filepath: string }): Promise<void> {\n const { dir, filepath } = options;\n this.config.logger?.info(\n `Removing file from git index {dir=${dir},filepath=${filepath}}`,\n );\n return git.remove({ fs, dir, filepath });\n }\n\n /** https://isomorphic-git.org/docs/en/resolveRef */\n async resolveRef(options: { dir: string; ref: string }): Promise<string> {\n const { dir, ref } = options;\n return git.resolveRef({ fs, dir, ref });\n }\n\n /** https://isomorphic-git.org/docs/en/log */\n async log(options: {\n dir: string;\n ref?: string;\n }): Promise<ReadCommitResult[]> {\n const { dir, ref } = options;\n return git.log({\n fs,\n dir,\n ref: ref ?? 'HEAD',\n });\n }\n\n private onAuth: AuthCallback;\n\n private onProgressHandler = (): ProgressCallback => {\n let currentPhase = '';\n\n return event => {\n if (currentPhase !== event.phase) {\n currentPhase = event.phase;\n this.config.logger?.info(event.phase);\n }\n const total = event.total\n ? `${Math.round((event.loaded / event.total) * 100)}%`\n : event.loaded;\n this.config.logger?.debug(`status={${event.phase},total={${total}}}`);\n };\n };\n\n static fromAuth = (options: StaticAuthOptions | AuthCallbackOptions) => {\n if (isAuthCallbackOptions(options)) {\n const { onAuth, logger } = options;\n return new Git({ onAuth, logger });\n }\n\n const { username, password, token, logger } = options;\n return new Git({ onAuth: () => ({ username, password }), token, logger });\n };\n}\n"],"names":["git","fs","pgp","http","logger"],"mappings":";;;;;;;;;;;;;AA4BA,SAAS,sBACP,OACgC,EAAA;AAChC,EAAA,OAAO,QAAY,IAAA,OAAA;AACrB;AA4CO,MAAM,GAAI,CAAA;AAAA,EAKP,YACW,MAKjB,EAAA;AALiB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAMjB,IAAA,IAAA,CAAK,SAAS,MAAO,CAAA,MAAA;AAErB,IAAA,IAAA,CAAK,OAAU,GAAA;AAAA,MACb,YAAc,EAAA,qBAAA;AAAA,MACd,GAAI,MAAO,CAAA,KAAA,GAAQ,EAAE,aAAA,EAAe,UAAU,MAAO,CAAA,KAAK,CAAG,CAAA,EAAA,GAAI;AAAC,KACpE;AAAA;AACF,EAjBiB,OAAA;AAAA,EAmBjB,MAAM,IAAI,OAA2D,EAAA;AACnE,IAAM,MAAA,EAAE,GAAK,EAAA,QAAA,EAAa,GAAA,OAAA;AAC1B,IAAA,IAAA,CAAK,OAAO,MAAQ,EAAA,IAAA,CAAK,oBAAoB,GAAG,CAAA,UAAA,EAAa,QAAQ,CAAG,CAAA,CAAA,CAAA;AAExE,IAAA,OAAOA,qBAAI,GAAI,CAAA,MAAEC,mBAAI,EAAA,GAAA,EAAK,UAAU,CAAA;AAAA;AACtC,EAEA,MAAM,UAAU,OAKE,E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AACtE,IAAI,IAAA,qBAAA,CAAsB,OAAO,CAAG,EAAA;AAClC,MAAA,MAAM,EAAE,MAAA,EAAQ,MAAAG,EAAAA,OAAAA,EAAW,GAAA,OAAA;AAC3B,MAAA,OAAO,IAAI,GAAI,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAAA,SAAQ,CAAA;AAAA;AAGnC,IAAA,MAAM,EAAE,QAAA,EAAU,QAAU,EAAA,KAAA,EAAO,QAAW,GAAA,OAAA;AAC9C,IAAO,OAAA,IAAI,GAAI,CAAA,EAAE,MAAQ,EAAA,OAAO,EAAE,QAAA,EAAU,QAAS,EAAA,CAAA,EAAI,KAAO,EAAA,MAAA,EAAQ,CAAA;AAAA,GAC1E;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-next.2",
|
|
4
4
|
"description": "The plugin-scaffolder-node module for @backstage/plugin-scaffolder-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"types": "./dist/index.d.ts",
|
|
42
42
|
"typesVersions": {
|
|
43
43
|
"*": {
|
|
44
|
-
"
|
|
44
|
+
"*": [
|
|
45
45
|
"dist/index.d.ts"
|
|
46
46
|
],
|
|
47
47
|
"alpha": [
|
|
@@ -65,14 +65,15 @@
|
|
|
65
65
|
"@backstage/backend-plugin-api": "1.2.1-next.1",
|
|
66
66
|
"@backstage/catalog-model": "1.7.3",
|
|
67
67
|
"@backstage/errors": "1.2.7",
|
|
68
|
-
"@backstage/integration": "1.16.
|
|
68
|
+
"@backstage/integration": "1.16.2-next.0",
|
|
69
69
|
"@backstage/plugin-scaffolder-common": "1.5.10-next.0",
|
|
70
70
|
"@backstage/types": "1.2.1",
|
|
71
|
+
"@isomorphic-git/pgp-plugin": "^0.0.7",
|
|
71
72
|
"concat-stream": "^2.0.0",
|
|
72
73
|
"fs-extra": "^11.2.0",
|
|
73
74
|
"globby": "^11.0.0",
|
|
74
75
|
"isomorphic-git": "^1.23.0",
|
|
75
|
-
"jsonschema": "^1.
|
|
76
|
+
"jsonschema": "^1.5.0",
|
|
76
77
|
"p-limit": "^3.1.0",
|
|
77
78
|
"tar": "^6.1.12",
|
|
78
79
|
"winston": "^3.2.1",
|
|
@@ -81,8 +82,8 @@
|
|
|
81
82
|
"zod-to-json-schema": "^3.20.4"
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
84
|
-
"@backstage/backend-test-utils": "1.3.1-next.
|
|
85
|
-
"@backstage/cli": "0.
|
|
85
|
+
"@backstage/backend-test-utils": "1.3.1-next.2",
|
|
86
|
+
"@backstage/cli": "0.31.0-next.1",
|
|
86
87
|
"@backstage/config": "1.3.2"
|
|
87
88
|
}
|
|
88
89
|
}
|