@backstage/plugin-scaffolder-node 0.13.0-next.1 → 0.13.0

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 CHANGED
@@ -1,5 +1,34 @@
1
1
  # @backstage/plugin-scaffolder-node
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e27bd4e: **BREAKING** Removed deprecated `bitbucket` integration from being used in the `parseRepoUrl` function. It will use the `bitbucketCloud` or `bitbucketServer` integrations instead.
8
+
9
+ ### Patch Changes
10
+
11
+ - cd0ecc5: Added `removeFiles` helper function for staging file removals in Git.
12
+ - f598909: Added `scaffolderServiceRef` and `ScaffolderService` interface for backend plugins that need to interact with the scaffolder API using `BackstageCredentials` instead of raw tokens.
13
+ - a49a40d: Updated dependency `zod` to `^3.25.76 || ^4.0.0` & migrated to `/v3` or `/v4` imports.
14
+ - Updated dependencies
15
+ - @backstage/backend-plugin-api@1.8.0
16
+ - @backstage/backend-test-utils@1.11.1
17
+ - @backstage/integration@2.0.0
18
+ - @backstage/plugin-scaffolder-common@2.0.0
19
+ - @backstage/plugin-permission-common@0.9.7
20
+ - @backstage/catalog-model@1.7.7
21
+
22
+ ## 0.13.0-next.2
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies
27
+ - @backstage/backend-test-utils@1.11.1-next.2
28
+ - @backstage/backend-plugin-api@1.8.0-next.1
29
+ - @backstage/integration@2.0.0-next.2
30
+ - @backstage/plugin-scaffolder-common@2.0.0-next.2
31
+
3
32
  ## 0.13.0-next.1
4
33
 
5
34
  ### Minor Changes
@@ -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 { 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 | { [key in string]: (zImpl: typeof z) => z.ZodType }\n | ((zImpl: typeof z) => z.ZodType) = {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n TOutputSchema extends\n | {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n }\n | ((zImpl: typeof z) => z.ZodType) = {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n TSchemaType extends 'v2' = '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 * 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\n | { [key in string]: (zImpl: typeof z) => z.ZodType }\n | ((zImpl: typeof z) => z.ZodType),\n TOutputSchema extends\n | { [key in string]: (zImpl: typeof z) => z.ZodType }\n | ((zImpl: typeof z) => z.ZodType),\n>(\n action: TemplateActionOptions<\n TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? {\n [key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;\n }\n : TInputSchema extends (zImpl: typeof z) => z.ZodType\n ? z.infer<ReturnType<TInputSchema>>\n : never,\n TOutputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? {\n [key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>;\n }\n : TOutputSchema extends (zImpl: typeof z) => z.ZodType\n ? z.infer<ReturnType<TOutputSchema>>\n : never,\n TInputSchema,\n TOutputSchema,\n 'v2'\n >,\n): TemplateAction<\n FlattenOptionalProperties<\n TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? {\n [key in keyof TInputSchema]: z.output<ReturnType<TInputSchema[key]>>;\n }\n : TInputSchema extends (zImpl: typeof z) => z.ZodType\n ? z.output<ReturnType<TInputSchema>>\n : never\n >,\n FlattenOptionalProperties<\n TOutputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? {\n [key in keyof TOutputSchema]: z.output<\n ReturnType<TOutputSchema[key]>\n >;\n }\n : TOutputSchema extends (zImpl: typeof z) => z.ZodType\n ? z.output<ReturnType<TOutputSchema>>\n : never\n >,\n 'v2'\n>;\nexport function createTemplateAction<\n TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType } = {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n TOutputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType } = {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n TActionInput extends JsonObject = TInputSchema extends {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n }\n ? Expand<{\n [key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;\n }>\n : never,\n TActionOutput extends JsonObject = TOutputSchema extends {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n }\n ? Expand<{\n [key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>;\n }>\n : never,\n>(\n action: TemplateActionOptions<\n TActionInput,\n TActionOutput,\n TInputSchema,\n TOutputSchema\n >,\n): TemplateAction<TActionInput, TActionOutput, 'v2'> {\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":";;;;AA2HO,SAAS,qBAsBd,MAAA,EAMmD;AACnD,EAAA,MAAM,EAAE,WAAA,EAAa,YAAA,EAAa,GAAIA,iBAAA;AAAA,IACpC;AAAA,GACF;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,MAAA,EAAQ;AAAA,MACN,GAAG,MAAA,CAAO,MAAA;AAAA,MACV,KAAA,EAAO,WAAA;AAAA,MACP,MAAA,EAAQ;AAAA;AACV,GACF;AACF;;;;"}
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/v3';\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 | { [key in string]: (zImpl: typeof z) => z.ZodType }\n | ((zImpl: typeof z) => z.ZodType) = {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n TOutputSchema extends\n | {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n }\n | ((zImpl: typeof z) => z.ZodType) = {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n TSchemaType extends 'v2' = '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 * 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\n | { [key in string]: (zImpl: typeof z) => z.ZodType }\n | ((zImpl: typeof z) => z.ZodType),\n TOutputSchema extends\n | { [key in string]: (zImpl: typeof z) => z.ZodType }\n | ((zImpl: typeof z) => z.ZodType),\n>(\n action: TemplateActionOptions<\n TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? {\n [key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;\n }\n : TInputSchema extends (zImpl: typeof z) => z.ZodType\n ? z.infer<ReturnType<TInputSchema>>\n : never,\n TOutputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? {\n [key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>;\n }\n : TOutputSchema extends (zImpl: typeof z) => z.ZodType\n ? z.infer<ReturnType<TOutputSchema>>\n : never,\n TInputSchema,\n TOutputSchema,\n 'v2'\n >,\n): TemplateAction<\n FlattenOptionalProperties<\n TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? {\n [key in keyof TInputSchema]: z.output<ReturnType<TInputSchema[key]>>;\n }\n : TInputSchema extends (zImpl: typeof z) => z.ZodType\n ? z.output<ReturnType<TInputSchema>>\n : never\n >,\n FlattenOptionalProperties<\n TOutputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType }\n ? {\n [key in keyof TOutputSchema]: z.output<\n ReturnType<TOutputSchema[key]>\n >;\n }\n : TOutputSchema extends (zImpl: typeof z) => z.ZodType\n ? z.output<ReturnType<TOutputSchema>>\n : never\n >,\n 'v2'\n>;\nexport function createTemplateAction<\n TInputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType } = {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n TOutputSchema extends { [key in string]: (zImpl: typeof z) => z.ZodType } = {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n TActionInput extends JsonObject = TInputSchema extends {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n }\n ? Expand<{\n [key in keyof TInputSchema]: z.infer<ReturnType<TInputSchema[key]>>;\n }>\n : never,\n TActionOutput extends JsonObject = TOutputSchema extends {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n }\n ? Expand<{\n [key in keyof TOutputSchema]: z.infer<ReturnType<TOutputSchema[key]>>;\n }>\n : never,\n>(\n action: TemplateActionOptions<\n TActionInput,\n TActionOutput,\n TInputSchema,\n TOutputSchema\n >,\n): TemplateAction<TActionInput, TActionOutput, 'v2'> {\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":";;;;AA2HO,SAAS,qBAsBd,MAAA,EAMmD;AACnD,EAAA,MAAM,EAAE,WAAA,EAAa,YAAA,EAAa,GAAIA,iBAAA;AAAA,IACpC;AAAA,GACF;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,MAAA,EAAQ;AAAA,MACN,GAAG,MAAA,CAAO,MAAA;AAAA,MACV,KAAA,EAAO,WAAA;AAAA,MACP,MAAA,EAAQ;AAAA;AACV,GACF;AACF;;;;"}
@@ -100,6 +100,14 @@ async function addFiles(options) {
100
100
  });
101
101
  await git$1.add({ dir, filepath });
102
102
  }
103
+ async function removeFiles(options) {
104
+ const { dir, filepath, auth, logger } = options;
105
+ const git$1 = git.Git.fromAuth({
106
+ ...auth,
107
+ logger
108
+ });
109
+ await git$1.remove({ dir, filepath });
110
+ }
103
111
  async function commitAndPushBranch(options) {
104
112
  const {
105
113
  dir,
@@ -141,4 +149,5 @@ exports.commitAndPushBranch = commitAndPushBranch;
141
149
  exports.commitAndPushRepo = commitAndPushRepo;
142
150
  exports.createBranch = createBranch;
143
151
  exports.initRepoAndPush = initRepoAndPush;
152
+ exports.removeFiles = removeFiles;
144
153
  //# sourceMappingURL=gitHelpers.cjs.js.map
@@ -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 { Git } from '../scm';\nimport { LoggerService } from '@backstage/backend-plugin-api';\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: LoggerService;\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: LoggerService;\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?: LoggerService | 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?: LoggerService | 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?: LoggerService | 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?: LoggerService | 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,KAAA,EAYF;AAClC,EAAA,MAAM;AAAA,IACJ,GAAA;AAAA,IACA,SAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA,GAAgB,QAAA;AAAA,IAChB,aAAA,GAAgB,gBAAA;AAAA,IAChB,aAAA;AAAA,IACA;AAAA,GACF,GAAI,KAAA;AACJ,EAAA,MAAMA,KAAA,GAAMC,QAAI,QAAA,CAAS;AAAA,IACvB,GAAG,IAAA;AAAA,IACH;AAAA,GACD,CAAA;AAED,EAAA,MAAMD,MAAI,IAAA,CAAK;AAAA,IACb,GAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAMA,MAAI,GAAA,CAAI,EAAE,GAAA,EAAK,QAAA,EAAU,KAAK,CAAA;AAGpC,EAAA,MAAM,UAAA,GAAa;AAAA,IACjB,IAAA,EAAM,eAAe,IAAA,IAAQ,YAAA;AAAA,IAC7B,KAAA,EAAO,eAAe,KAAA,IAAS;AAAA,GACjC;AAEA,EAAA,MAAM,UAAA,GAAa,MAAMA,KAAA,CAAI,MAAA,CAAO;AAAA,IAClC,GAAA;AAAA,IACA,OAAA,EAAS,aAAA;AAAA,IACT,MAAA,EAAQ,UAAA;AAAA,IACR,SAAA,EAAW,UAAA;AAAA,IACX;AAAA,GACD,CAAA;AAED,EAAA,MAAMA,MAAI,IAAA,CAAK;AAAA,IACb,GAAA;AAAA,IACA,MAAA,EAAQ,QAAA;AAAA,IACR,GAAA,EAAK;AAAA,GACN,CAAA;AAED,EAAA,OAAO,EAAE,UAAA,EAAW;AACtB;AAKA,eAAsB,kBAAkB,KAAA,EAYJ;AAClC,EAAA,MAAM;AAAA,IACJ,GAAA;AAAA,IACA,IAAA;AAAA,IACA,MAA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AAA;AAAA,IACA,OAAA,EAAS,aAAA;AAAA,IACT,MAAA,EAAQ,UAAA;AAAA,IACR,SAAA,EAAW,UAAA;AAAA,IACX;AAAA,GACD,CAAA;AAED,EAAA,MAAMA,MAAI,IAAA,CAAK;AAAA,IACb,GAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA,EAAW,SAAA,IAAa,CAAA,WAAA,EAAc,MAAM,CAAA;AAAA,GAC7C,CAAA;AAED,EAAA,OAAO,EAAE,UAAA,EAAW;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 { Git } from '../scm';\nimport { LoggerService } from '@backstage/backend-plugin-api';\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: LoggerService;\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: LoggerService;\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?: LoggerService | 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?: LoggerService | 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?: LoggerService | 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 removeFiles(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?: LoggerService | 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.remove({ 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?: LoggerService | 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,KAAA,EAYF;AAClC,EAAA,MAAM;AAAA,IACJ,GAAA;AAAA,IACA,SAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA,GAAgB,QAAA;AAAA,IAChB,aAAA,GAAgB,gBAAA;AAAA,IAChB,aAAA;AAAA,IACA;AAAA,GACF,GAAI,KAAA;AACJ,EAAA,MAAMA,KAAA,GAAMC,QAAI,QAAA,CAAS;AAAA,IACvB,GAAG,IAAA;AAAA,IACH;AAAA,GACD,CAAA;AAED,EAAA,MAAMD,MAAI,IAAA,CAAK;AAAA,IACb,GAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAMA,MAAI,GAAA,CAAI,EAAE,GAAA,EAAK,QAAA,EAAU,KAAK,CAAA;AAGpC,EAAA,MAAM,UAAA,GAAa;AAAA,IACjB,IAAA,EAAM,eAAe,IAAA,IAAQ,YAAA;AAAA,IAC7B,KAAA,EAAO,eAAe,KAAA,IAAS;AAAA,GACjC;AAEA,EAAA,MAAM,UAAA,GAAa,MAAMA,KAAA,CAAI,MAAA,CAAO;AAAA,IAClC,GAAA;AAAA,IACA,OAAA,EAAS,aAAA;AAAA,IACT,MAAA,EAAQ,UAAA;AAAA,IACR,SAAA,EAAW,UAAA;AAAA,IACX;AAAA,GACD,CAAA;AAED,EAAA,MAAMA,MAAI,IAAA,CAAK;AAAA,IACb,GAAA;AAAA,IACA,MAAA,EAAQ,QAAA;AAAA,IACR,GAAA,EAAK;AAAA,GACN,CAAA;AAED,EAAA,OAAO,EAAE,UAAA,EAAW;AACtB;AAKA,eAAs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T,SAAA;AAAA,IACA,MAAA,GAAS,QAAA;AAAA,IACT;AAAA,GACF,GAAI,OAAA;AACJ,EAAA,MAAMA,KAAA,GAAMC,QAAI,QAAA,CAAS;AAAA,IACvB,GAAG,IAAA;AAAA,IACH;AAAA,GACD,CAAA;AAGD,EAAA,MAAM,UAAA,GAAa;AAAA,IACjB,IAAA,EAAM,eAAe,IAAA,IAAQ,YAAA;AAAA,IAC7B,KAAA,EAAO,eAAe,KAAA,IAAS;AAAA,GACjC;AAEA,EAAA,MAAM,UAAA,GAAa,MAAMD,KAAA,CAAI,MAAA,CAAO;AAAA,IAClC,GAAA;AAAA,IACA,OAAA,EAAS,aAAA;AAAA,IACT,MAAA,EAAQ,UAAA;AAAA,IACR,SAAA,EAAW,UAAA;AAAA,IACX;AAAA,GACD,CAAA;AAED,EAAA,MAAMA,MAAI,IAAA,CAAK;AAAA,IACb,GAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA,EAAW,SAAA,IAAa,CAAA,WAAA,EAAc,MAAM,CAAA;AAAA,GAC7C,CAAA;AAED,EAAA,OAAO,EAAE,UAAA,EAAW;AACtB;;;;;;;;;;"}
@@ -4,7 +4,7 @@ var errors = require('@backstage/errors');
4
4
  var backendPluginApi = require('@backstage/backend-plugin-api');
5
5
  var path = require('node:path');
6
6
  var zodToJsonSchema = require('zod-to-json-schema');
7
- var zod = require('zod');
7
+ var v3 = require('zod/v3');
8
8
  var lodash = require('lodash');
9
9
 
10
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
@@ -101,17 +101,17 @@ const parseSchemas = (action) => {
101
101
  return { inputSchema: void 0, outputSchema: void 0 };
102
102
  }
103
103
  if (isKeyValueZodCallback(action.schema.input)) {
104
- const input = zod.z.object(
104
+ const input = v3.z.object(
105
105
  Object.fromEntries(
106
- Object.entries(action.schema.input).map(([k, v]) => [k, v(zod.z)])
106
+ Object.entries(action.schema.input).map(([k, v]) => [k, v(v3.z)])
107
107
  )
108
108
  );
109
109
  return {
110
110
  inputSchema: zodToJsonSchema__default.default(input),
111
111
  outputSchema: isKeyValueZodCallback(action.schema.output) ? zodToJsonSchema__default.default(
112
- zod.z.object(
112
+ v3.z.object(
113
113
  Object.fromEntries(
114
- Object.entries(action.schema.output).map(([k, v]) => [k, v(zod.z)])
114
+ Object.entries(action.schema.output).map(([k, v]) => [k, v(v3.z)])
115
115
  )
116
116
  )
117
117
  ) : void 0
@@ -119,8 +119,8 @@ const parseSchemas = (action) => {
119
119
  }
120
120
  if (isZodFunctionDefinition(action.schema.input)) {
121
121
  return {
122
- inputSchema: zodToJsonSchema__default.default(action.schema.input(zod.z)),
123
- outputSchema: isZodFunctionDefinition(action.schema.output) ? zodToJsonSchema__default.default(action.schema.output(zod.z)) : void 0
122
+ inputSchema: zodToJsonSchema__default.default(action.schema.input(v3.z)),
123
+ outputSchema: isZodFunctionDefinition(action.schema.output) ? zodToJsonSchema__default.default(action.schema.output(v3.z)) : void 0
124
124
  };
125
125
  }
126
126
  return {
@@ -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 'node: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';\nimport { trim } from 'lodash';\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 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 const { owner, organization, workspace, project, repo } = Object.fromEntries(\n ['owner', 'organization', 'workspace', 'project', 'repo'].map(param => [\n param,\n parsed.searchParams.has(param)\n ? trim(parsed.searchParams.get(param)!, '/')\n : undefined,\n ]),\n );\n switch (type) {\n case 'bitbucketCloud': {\n checkRequiredParams(parsed, 'workspace', 'project', 'repo');\n break;\n }\n case 'bitbucketServer': {\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 return { host, owner, repo: 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 isKeyValueZodCallback = (\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\nconst isZodFunctionDefinition = (\n schema: unknown,\n): schema is (zImpl: typeof z) => z.ZodType => {\n return typeof schema === 'function';\n};\n\nexport const parseSchemas = (\n action: TemplateActionOptions<any, any, any>,\n): { inputSchema?: Schema; outputSchema?: Schema } => {\n if (!action.schema) {\n return { inputSchema: undefined, outputSchema: undefined };\n }\n\n if (isKeyValueZodCallback(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: isKeyValueZodCallback(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 if (isZodFunctionDefinition(action.schema.input)) {\n return {\n inputSchema: zodToJsonSchema(action.schema.input(z)) as Schema,\n outputSchema: isZodFunctionDefinition(action.schema.output)\n ? (zodToJsonSchema(action.schema.output(z)) as Schema)\n : undefined,\n };\n }\n\n return {\n inputSchema: undefined,\n outputSchema: undefined,\n };\n};\n\n/**\n * Filter function to exclude the .git directory and its contents\n * while keeping other files like .gitignore\n * @public\n */\nexport function isNotGitDirectoryOrContents(path: string): boolean {\n return !(path.endsWith('.git') || path.includes('.git/'));\n}\n"],"names":["normalizePath","path","joinPath","isChildPath","InputError","trim","z","zodToJsonSchema"],"mappings":";;;;;;;;;;;;;AA6BO,MAAM,sBAAA,GAAyB,CACpC,aAAA,EACA,UAAA,KACG;AACH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AA,UACA,MAAA,CAAO,WAAA;AAAA,YACL,OAAO,OAAA,CAAQ,MAAA,CAAO,MAAA,CAAO,MAAM,EAAE,GAAA,CAAI,CAAC,CAAC,CAAA,EAAG,CAAC,CAAA,KAAM,CAAC,GAAG,CAAA,CAAEA,KAAC,CAAC,CAAC;AAAA;AAChE;AACF,OACF,GACA;AAAA,KACN;AAAA,EACF;AAEA,EAAA,IAAI,uBAAA,CAAwB,MAAA,CAAO,MAAA,CAAO,KAAK,CAAA,EAAG;AAChD,IAAA,OAAO;AAAA,MACL,aAAaC,gCAAA,CAAgB,MAAA,CAAO,MAAA,CAAO,KAAA,CAAMD,KAAC,CAAC,CAAA;AAAA,MACnD,YAAA,EAAc,uBAAA,CAAwB,MAAA,CAAO,MAAA,CAAO,MAAM,CAAA,GACrDC,gCAAA,CAAgB,MAAA,CAAO,MAAA,CAAO,MAAA,CAAOD,KAAC,CAAC,CAAA,GACxC;AAAA,KACN;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,WAAA,EAAa,MAAA;AAAA,IACb,YAAA,EAAc;AAAA,GAChB;AACF;AAOO,SAAS,4BAA4B,IAAA,EAAuB;AACjE,EAAA,OAAO,EAAE,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA,IAAK,IAAA,CAAK,SAAS,OAAO,CAAA,CAAA;AACzD;;;;;;;"}
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 'node:path';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { TemplateActionOptions } from './createTemplateAction';\nimport zodToJsonSchema from 'zod-to-json-schema';\nimport { z } from 'zod/v3';\nimport { Schema } from 'jsonschema';\nimport { trim } from 'lodash';\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 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 const { owner, organization, workspace, project, repo } = Object.fromEntries(\n ['owner', 'organization', 'workspace', 'project', 'repo'].map(param => [\n param,\n parsed.searchParams.has(param)\n ? trim(parsed.searchParams.get(param)!, '/')\n : undefined,\n ]),\n );\n switch (type) {\n case 'bitbucketCloud': {\n checkRequiredParams(parsed, 'workspace', 'project', 'repo');\n break;\n }\n case 'bitbucketServer': {\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 return { host, owner, repo: 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 isKeyValueZodCallback = (\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\nconst isZodFunctionDefinition = (\n schema: unknown,\n): schema is (zImpl: typeof z) => z.ZodType => {\n return typeof schema === 'function';\n};\n\nexport const parseSchemas = (\n action: TemplateActionOptions<any, any, any>,\n): { inputSchema?: Schema; outputSchema?: Schema } => {\n if (!action.schema) {\n return { inputSchema: undefined, outputSchema: undefined };\n }\n\n if (isKeyValueZodCallback(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: isKeyValueZodCallback(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 if (isZodFunctionDefinition(action.schema.input)) {\n return {\n inputSchema: zodToJsonSchema(action.schema.input(z)) as Schema,\n outputSchema: isZodFunctionDefinition(action.schema.output)\n ? (zodToJsonSchema(action.schema.output(z)) as Schema)\n : undefined,\n };\n }\n\n return {\n inputSchema: undefined,\n outputSchema: undefined,\n };\n};\n\n/**\n * Filter function to exclude the .git directory and its contents\n * while keeping other files like .gitignore\n * @public\n */\nexport function isNotGitDirectoryOrContents(path: string): boolean {\n return !(path.endsWith('.git') || path.includes('.git/'));\n}\n"],"names":["normalizePath","path","joinPath","isChildPath","InputError","trim","z","zodToJsonSchema"],"mappings":";;;;;;;;;;;;;AA6BO,MAAM,sBAAA,GAAyB,CACpC,aAAA,EACA,UAAA,KACG;AACH,EAAA,IAAI,UAAA,EAAY;AACd,IAAA,MAAM,UAAA,GAAaA,cAAA,CAAc,UAAU,CAAA,CAAE,OAAA;AAAA,MAC3C,mBAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAMC,MAAA,GAAOC,SAAA,CAAS,aAAA,EAAe,UAAU,CAAA;AAC/C,IAAA,IAAI,CAACC,4BAAA,CAAY,aAAA,EAAeF,MAAI,CAAA,EAAG;AACrC,MAAA,MAAM,IAAI,MAAM,qBAAqB,CAAA;AAAA,IACvC;AACA,IAAA,OAAOA,MAAA;AAAA,EACT;AACA,EAAA,OAAO,aAAA;AACT;AAKO,MAAM,YAAA,GAAe,CAC1B,OAAA,EACA,YAAA,KAQG;AACH,EAAA,IAAI,MAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAA,GAAS,IAAI,GAAA,CAAI,CAAA,QAAA,EAAW,OAAO,CAAA,CAAE,CAAA;AAAA,EACvC,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIG,iBAAA;AAAA,MACR,CAAA,0CAAA,EAA6C,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA;AAAA,KAChE;AAAA,EACF;AACA,EAAA,MAAM,OAAO,MAAA,CAAO,IAAA;AACpB,EAAA,MAAM,IAAA,GAAO,YAAA,CAAa,MAAA,CAAO,IAAI,CAAA,EAAG,IAAA;AAExC,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,MAAM,IAAIA,iBAAA;AAAA,MACR,kDAAkD,IAAI,CAAA,uCAAA;AAAA,KACxD;AAAA,EACF;AACA,EAAA,MAAM,EAAE,KAAA,EAAO,YAAA,EAAc,WAAW,OAAA,EAAS,IAA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AAC/D,KACF;AAEA,IAAA,OAAO;AAAA,MACL,WAAA,EAAaC,iCAAgB,KAAK,CAAA;AAAA,MAClC,YAAA,EAAc,qBAAA,CAAsB,MAAA,CAAO,MAAA,CAAO,MAAM,CAAA,GACnDA,gCAAA;AAAA,QACCD,IAAA,CAAE,MAAA;AAAA,UACA,MAAA,CAAO,WAAA;AAAA,YACL,OAAO,OAAA,CAAQ,MAAA,CAAO,MAAA,CAAO,MAAM,EAAE,GAAA,CAAI,CAAC,CAAC,CAAA,EAAG,CAAC,CAAA,KAAM,CAAC,GAAG,CAAA,CAAEA,IAAC,CAAC,CAAC;AAAA;AAChE;AACF,OACF,GACA;AAAA,KACN;AAAA,EACF;AAEA,EAAA,IAAI,uBAAA,CAAwB,MAAA,CAAO,MAAA,CAAO,KAAK,CAAA,EAAG;AAChD,IAAA,OAAO;AAAA,MACL,aAAaC,gCAAA,CAAgB,MAAA,CAAO,MAAA,CAAO,KAAA,CAAMD,IAAC,CAAC,CAAA;AAAA,MACnD,YAAA,EAAc,uBAAA,CAAwB,MAAA,CAAO,MAAA,CAAO,MAAM,CAAA,GACrDC,gCAAA,CAAgB,MAAA,CAAO,MAAA,CAAO,MAAA,CAAOD,IAAC,CAAC,CAAA,GACxC;AAAA,KACN;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,WAAA,EAAa,MAAA;AAAA,IACb,YAAA,EAAc;AAAA,GAChB;AACF;AAOO,SAAS,4BAA4B,IAAA,EAAuB;AACjE,EAAA,OAAO,EAAE,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA,IAAK,IAAA,CAAK,SAAS,OAAO,CAAA,CAAA;AACzD;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createTemplateFilter.cjs.js","sources":["../../../src/alpha/filters/createTemplateFilter.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { ZodFunctionSchema } from '../types';\nimport { CreatedTemplateFilter, TemplateFilterExample } from './types';\nimport { z } from 'zod';\n\n/**\n * This function is used to create new template filters in type-safe manner.\n * @alpha\n */\nexport const createTemplateFilter = <\n TFunctionArgs extends [z.ZodTypeAny, ...z.ZodTypeAny[]],\n TReturnType extends z.ZodTypeAny,\n>(options: {\n id: string;\n description?: string;\n examples?: TemplateFilterExample[];\n schema?: ZodFunctionSchema<TFunctionArgs, TReturnType>;\n filter: (...args: z.infer<z.ZodTuple<TFunctionArgs>>) => z.infer<TReturnType>;\n}): CreatedTemplateFilter<TFunctionArgs, TReturnType> => options;\n"],"names":[],"mappings":";;AAwBO,MAAM,oBAAA,GAAuB,CAGlC,OAAA,KAMuD;;;;"}
1
+ {"version":3,"file":"createTemplateFilter.cjs.js","sources":["../../../src/alpha/filters/createTemplateFilter.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { ZodFunctionSchema } from '../types';\nimport { CreatedTemplateFilter, TemplateFilterExample } from './types';\nimport { z } from 'zod/v3';\n\n/**\n * This function is used to create new template filters in type-safe manner.\n * @alpha\n */\nexport const createTemplateFilter = <\n TFunctionArgs extends [z.ZodTypeAny, ...z.ZodTypeAny[]],\n TReturnType extends z.ZodTypeAny,\n>(options: {\n id: string;\n description?: string;\n examples?: TemplateFilterExample[];\n schema?: ZodFunctionSchema<TFunctionArgs, TReturnType>;\n filter: (...args: z.infer<z.ZodTuple<TFunctionArgs>>) => z.infer<TReturnType>;\n}): CreatedTemplateFilter<TFunctionArgs, TReturnType> => options;\n"],"names":[],"mappings":";;AAwBO,MAAM,oBAAA,GAAuB,CAGlC,OAAA,KAMuD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createTemplateGlobal.cjs.js","sources":["../../../src/alpha/globals/createTemplateGlobal.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { z } from 'zod';\nimport {\n CreatedTemplateGlobalFunction,\n CreatedTemplateGlobalValue,\n TemplateGlobalFunctionExample,\n} from './types';\nimport { ZodFunctionSchema } from '../types';\n\n/**\n * This function is used to create new template global values in type-safe manner.\n * @param t - CreatedTemplateGlobalValue | CreatedTemplateGlobalFunction\n * @returns t\n * @alpha\n */\nexport const createTemplateGlobalValue = (\n v: CreatedTemplateGlobalValue,\n): CreatedTemplateGlobalValue => v;\n\n/**\n * This function is used to create new template global functions in type-safe manner.\n * @param fn - CreatedTemplateGlobalFunction\n * @returns fn\n * @alpha\n */\nexport const createTemplateGlobalFunction = <\n TFunctionArgs extends [z.ZodTypeAny, ...z.ZodTypeAny[]],\n TReturnType extends z.ZodTypeAny,\n>(options: {\n id: string;\n description?: string;\n examples?: TemplateGlobalFunctionExample[];\n schema?: ZodFunctionSchema<TFunctionArgs, TReturnType>;\n fn: (...args: z.infer<z.ZodTuple<TFunctionArgs>>) => z.infer<TReturnType>;\n}): CreatedTemplateGlobalFunction<TFunctionArgs, TReturnType> => options;\n"],"names":[],"mappings":";;AA8BO,MAAM,yBAAA,GAA4B,CACvC,CAAA,KAC+B;AAQ1B,MAAM,4BAAA,GAA+B,CAG1C,OAAA,KAM+D;;;;;"}
1
+ {"version":3,"file":"createTemplateGlobal.cjs.js","sources":["../../../src/alpha/globals/createTemplateGlobal.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { z } from 'zod/v3';\nimport {\n CreatedTemplateGlobalFunction,\n CreatedTemplateGlobalValue,\n TemplateGlobalFunctionExample,\n} from './types';\nimport { ZodFunctionSchema } from '../types';\n\n/**\n * This function is used to create new template global values in type-safe manner.\n * @param t - CreatedTemplateGlobalValue | CreatedTemplateGlobalFunction\n * @returns t\n * @alpha\n */\nexport const createTemplateGlobalValue = (\n v: CreatedTemplateGlobalValue,\n): CreatedTemplateGlobalValue => v;\n\n/**\n * This function is used to create new template global functions in type-safe manner.\n * @param fn - CreatedTemplateGlobalFunction\n * @returns fn\n * @alpha\n */\nexport const createTemplateGlobalFunction = <\n TFunctionArgs extends [z.ZodTypeAny, ...z.ZodTypeAny[]],\n TReturnType extends z.ZodTypeAny,\n>(options: {\n id: string;\n description?: string;\n examples?: TemplateGlobalFunctionExample[];\n schema?: ZodFunctionSchema<TFunctionArgs, TReturnType>;\n fn: (...args: z.infer<z.ZodTuple<TFunctionArgs>>) => z.infer<TReturnType>;\n}): CreatedTemplateGlobalFunction<TFunctionArgs, TReturnType> => options;\n"],"names":[],"mappings":";;AA8BO,MAAM,yBAAA,GAA4B,CACvC,CAAA,KAC+B;AAQ1B,MAAM,4BAAA,GAA+B,CAG1C,OAAA,KAM+D;;;;;"}
package/dist/alpha.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
2
  import { TaskBroker, TemplateFilter, TemplateGlobal } from '@backstage/plugin-scaffolder-node';
3
- import { z } from 'zod';
3
+ import { z } from 'zod/v3';
4
4
  import { JsonValue } from '@backstage/types';
5
5
  export { T as TemplateFilter, a as TemplateGlobal } from './types/types.d-C0fXdKnD.js';
6
6
 
package/dist/index.cjs.js CHANGED
@@ -22,6 +22,7 @@ exports.commitAndPushBranch = gitHelpers.commitAndPushBranch;
22
22
  exports.commitAndPushRepo = gitHelpers.commitAndPushRepo;
23
23
  exports.createBranch = gitHelpers.createBranch;
24
24
  exports.initRepoAndPush = gitHelpers.initRepoAndPush;
25
+ exports.removeFiles = gitHelpers.removeFiles;
25
26
  exports.getRepoSourceDirectory = util.getRepoSourceDirectory;
26
27
  exports.isNotGitDirectoryOrContents = util.isNotGitDirectoryOrContents;
27
28
  exports.parseRepoUrl = util.parseRepoUrl;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import { TaskSpec, TemplateInfo } from '@backstage/plugin-scaffolder-common';
6
6
  import { UpdateTaskCheckpointOptions, CheckpointContext } from '@backstage/plugin-scaffolder-node/alpha';
7
7
  import { UserEntity } from '@backstage/catalog-model';
8
8
  import { Schema } from 'jsonschema';
9
- import { z } from 'zod';
9
+ import { z } from 'zod/v3';
10
10
  import { SpawnOptionsWithoutStdio } from 'node:child_process';
11
11
  import { Writable } from 'node:stream';
12
12
  import { ScmIntegrations, ScmIntegrationRegistry } from '@backstage/integration';
@@ -497,6 +497,20 @@ declare function addFiles(options: {
497
497
  };
498
498
  logger?: LoggerService | undefined;
499
499
  }): Promise<void>;
500
+ /**
501
+ * @public
502
+ */
503
+ declare function removeFiles(options: {
504
+ dir: string;
505
+ filepath: string;
506
+ auth: {
507
+ username: string;
508
+ password: string;
509
+ } | {
510
+ token: string;
511
+ };
512
+ logger?: LoggerService | undefined;
513
+ }): Promise<void>;
500
514
  /**
501
515
  * @public
502
516
  */
@@ -587,5 +601,5 @@ interface ScaffolderActionsExtensionPoint {
587
601
  */
588
602
  declare const scaffolderActionsExtensionPoint: _backstage_backend_plugin_api.ExtensionPoint<ScaffolderActionsExtensionPoint>;
589
603
 
590
- export { addFiles, cloneRepo, commitAndPushBranch, commitAndPushRepo, createBranch, createTemplateAction, deserializeDirectoryContents, executeShellCommand, fetchContents, fetchFile, getRepoSourceDirectory, initRepoAndPush, isNotGitDirectoryOrContents, parseRepoUrl, scaffolderActionsExtensionPoint, serializeDirectoryContents };
604
+ export { addFiles, cloneRepo, commitAndPushBranch, commitAndPushRepo, createBranch, createTemplateAction, deserializeDirectoryContents, executeShellCommand, fetchContents, fetchFile, getRepoSourceDirectory, initRepoAndPush, isNotGitDirectoryOrContents, parseRepoUrl, removeFiles, scaffolderActionsExtensionPoint, serializeDirectoryContents };
591
605
  export type { ActionContext, ExecuteShellCommandOptions, ScaffolderActionsExtensionPoint, SerializedFile, SerializedTask, SerializedTaskEvent, TaskBroker, TaskBrokerDispatchOptions, TaskBrokerDispatchResult, TaskCompletionState, TaskContext, TaskEventType, TaskFilter, TaskFilters, TaskSecrets, TaskStatus, TemplateAction, TemplateActionOptions, TemplateExample };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-node",
3
- "version": "0.13.0-next.1",
3
+ "version": "0.13.0",
4
4
  "description": "The plugin-scaffolder-node module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "node-library",
@@ -70,13 +70,13 @@
70
70
  "test": "backstage-cli package test"
71
71
  },
72
72
  "dependencies": {
73
- "@backstage/backend-plugin-api": "1.7.1-next.0",
74
- "@backstage/catalog-model": "1.7.6",
75
- "@backstage/errors": "1.2.7",
76
- "@backstage/integration": "2.0.0-next.1",
77
- "@backstage/plugin-permission-common": "0.9.6",
78
- "@backstage/plugin-scaffolder-common": "2.0.0-next.1",
79
- "@backstage/types": "1.2.2",
73
+ "@backstage/backend-plugin-api": "^1.8.0",
74
+ "@backstage/catalog-model": "^1.7.7",
75
+ "@backstage/errors": "^1.2.7",
76
+ "@backstage/integration": "^2.0.0",
77
+ "@backstage/plugin-permission-common": "^0.9.7",
78
+ "@backstage/plugin-scaffolder-common": "^2.0.0",
79
+ "@backstage/types": "^1.2.2",
80
80
  "@isomorphic-git/pgp-plugin": "^0.0.7",
81
81
  "concat-stream": "^2.0.0",
82
82
  "fs-extra": "^11.2.0",
@@ -88,18 +88,18 @@
88
88
  "tar": "^7.5.6",
89
89
  "winston": "^3.2.1",
90
90
  "winston-transport": "^4.7.0",
91
- "zod": "^3.25.76",
91
+ "zod": "^3.25.76 || ^4.0.0",
92
92
  "zod-to-json-schema": "^3.25.1"
93
93
  },
94
94
  "devDependencies": {
95
- "@backstage/backend-test-utils": "1.11.1-next.1",
96
- "@backstage/cli": "0.36.0-next.1",
97
- "@backstage/config": "1.3.6",
95
+ "@backstage/backend-test-utils": "^1.11.1",
96
+ "@backstage/cli": "^0.36.0",
97
+ "@backstage/config": "^1.3.6",
98
98
  "@types/lodash": "^4.14.151",
99
99
  "msw": "^1.0.0"
100
100
  },
101
101
  "peerDependencies": {
102
- "@backstage/backend-test-utils": "1.11.1-next.1"
102
+ "@backstage/backend-test-utils": "^1.11.1"
103
103
  },
104
104
  "peerDependenciesMeta": {
105
105
  "@backstage/backend-test-utils": {