@backstage/plugin-scaffolder-node 0.11.0-next.0 → 0.11.1-next.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 +22 -0
- package/dist/actions/createTemplateAction.cjs.js.map +1 -1
- package/dist/actions/executeShellCommand.cjs.js.map +1 -1
- package/dist/actions/fetch.cjs.js.map +1 -1
- package/dist/actions/gitHelpers.cjs.js.map +1 -1
- package/dist/actions/util.cjs.js.map +1 -1
- package/dist/alpha/filters/createTemplateFilter.cjs.js.map +1 -1
- package/dist/alpha/globals/createTemplateGlobal.cjs.js.map +1 -1
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/files/deserializeDirectoryContents.cjs.js.map +1 -1
- package/dist/files/serializeDirectoryContents.cjs.js.map +1 -1
- package/dist/scm/git.cjs.js.map +1 -1
- package/dist/tasks/serializer.cjs.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-node
|
|
2
2
|
|
|
3
|
+
## 0.11.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/integration@1.18.0-next.0
|
|
9
|
+
- @backstage/plugin-scaffolder-common@1.7.1-next.0
|
|
10
|
+
- @backstage/backend-plugin-api@1.4.3-next.0
|
|
11
|
+
|
|
12
|
+
## 0.11.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- c08cbc4: Move Scaffolder API to OpenAPI
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 812485c: Add step info to scaffolder action context to access the step id and name.
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @backstage/plugin-scaffolder-common@1.7.0
|
|
23
|
+
- @backstage/backend-plugin-api@1.4.2
|
|
24
|
+
|
|
3
25
|
## 0.11.0-next.0
|
|
4
26
|
|
|
5
27
|
### 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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeShellCommand.cjs.js","sources":["../../src/actions/executeShellCommand.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 { LoggerService } from '@backstage/backend-plugin-api';\nimport { spawn, SpawnOptionsWithoutStdio } from 'child_process';\nimport { PassThrough, Writable } from 'stream';\n\n/**\n * Options for {@link executeShellCommand}.\n *\n * @public\n */\nexport type ExecuteShellCommandOptions = {\n /** command to run */\n command: string;\n /** arguments to pass the command */\n args: string[];\n /** options to pass to spawn */\n options?: SpawnOptionsWithoutStdio;\n /** logger to capture stdout and stderr output */\n logger?: LoggerService;\n /**\n * stream to capture stdout and stderr output\n * @deprecated please provide a logger instead.\n */\n logStream?: Writable;\n};\n\n/**\n * Run a command in a sub-process, normally a shell command.\n *\n * @public\n */\nexport async function executeShellCommand(\n options: ExecuteShellCommandOptions,\n): Promise<void> {\n const {\n command,\n args,\n options: spawnOptions,\n logger,\n logStream = new PassThrough(),\n } = options;\n\n await new Promise<void>((resolve, reject) => {\n const process = spawn(command, args, spawnOptions);\n\n process.stdout.on('data', chunk => {\n logStream?.write(chunk);\n logger?.info(\n Buffer.isBuffer(chunk) ? chunk.toString('utf8').trim() : chunk.trim(),\n );\n });\n process.stderr.on('data', chunk => {\n logStream?.write(chunk);\n logger?.error(\n Buffer.isBuffer(chunk) ? chunk.toString('utf8').trim() : chunk.trim(),\n );\n });\n process.on('error', error => {\n return reject(error);\n });\n\n process.on('close', code => {\n if (code !== 0) {\n return reject(\n new Error(`Command ${command} failed, exit code: ${code}`),\n );\n }\n return resolve();\n });\n });\n}\n"],"names":["PassThrough","spawn"],"mappings":";;;;;AA8CA,eAAsB,oBACpB,
|
|
1
|
+
{"version":3,"file":"executeShellCommand.cjs.js","sources":["../../src/actions/executeShellCommand.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 { LoggerService } from '@backstage/backend-plugin-api';\nimport { spawn, SpawnOptionsWithoutStdio } from 'child_process';\nimport { PassThrough, Writable } from 'stream';\n\n/**\n * Options for {@link executeShellCommand}.\n *\n * @public\n */\nexport type ExecuteShellCommandOptions = {\n /** command to run */\n command: string;\n /** arguments to pass the command */\n args: string[];\n /** options to pass to spawn */\n options?: SpawnOptionsWithoutStdio;\n /** logger to capture stdout and stderr output */\n logger?: LoggerService;\n /**\n * stream to capture stdout and stderr output\n * @deprecated please provide a logger instead.\n */\n logStream?: Writable;\n};\n\n/**\n * Run a command in a sub-process, normally a shell command.\n *\n * @public\n */\nexport async function executeShellCommand(\n options: ExecuteShellCommandOptions,\n): Promise<void> {\n const {\n command,\n args,\n options: spawnOptions,\n logger,\n logStream = new PassThrough(),\n } = options;\n\n await new Promise<void>((resolve, reject) => {\n const process = spawn(command, args, spawnOptions);\n\n process.stdout.on('data', chunk => {\n logStream?.write(chunk);\n logger?.info(\n Buffer.isBuffer(chunk) ? chunk.toString('utf8').trim() : chunk.trim(),\n );\n });\n process.stderr.on('data', chunk => {\n logStream?.write(chunk);\n logger?.error(\n Buffer.isBuffer(chunk) ? chunk.toString('utf8').trim() : chunk.trim(),\n );\n });\n process.on('error', error => {\n return reject(error);\n });\n\n process.on('close', code => {\n if (code !== 0) {\n return reject(\n new Error(`Command ${command} failed, exit code: ${code}`),\n );\n }\n return resolve();\n });\n });\n}\n"],"names":["PassThrough","spawn"],"mappings":";;;;;AA8CA,eAAsB,oBACpB,OAAA,EACe;AACf,EAAA,MAAM;AAAA,IACJ,OAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAA,EAAS,YAAA;AAAA,IACT,MAAA;AAAA,IACA,SAAA,GAAY,IAAIA,kBAAA;AAAY,GAC9B,GAAI,OAAA;AAEJ,EAAA,MAAM,IAAI,OAAA,CAAc,CAAC,OAAA,EAAS,MAAA,KAAW;AAC3C,IAAA,MAAM,OAAA,GAAUC,mBAAA,CAAM,OAAA,EAAS,IAAA,EAAM,YAAY,CAAA;AAEjD,IAAA,OAAA,CAAQ,MAAA,CAAO,EAAA,CAAG,MAAA,EAAQ,CAAA,KAAA,KAAS;AACjC,MAAA,SAAA,EAAW,MAAM,KAAK,CAAA;AACtB,MAAA,MAAA,EAAQ,IAAA;AAAA,QACN,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,GAAI,KAAA,CAAM,QAAA,CAAS,MAAM,CAAA,CAAE,IAAA,EAAK,GAAI,KAAA,CAAM,IAAA;AAAK,OACtE;AAAA,IACF,CAAC,CAAA;AACD,IAAA,OAAA,CAAQ,MAAA,CAAO,EAAA,CAAG,MAAA,EAAQ,CAAA,KAAA,KAAS;AACjC,MAAA,SAAA,EAAW,MAAM,KAAK,CAAA;AACtB,MAAA,MAAA,EAAQ,KAAA;AAAA,QACN,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,GAAI,KAAA,CAAM,QAAA,CAAS,MAAM,CAAA,CAAE,IAAA,EAAK,GAAI,KAAA,CAAM,IAAA;AAAK,OACtE;AAAA,IACF,CAAC,CAAA;AACD,IAAA,OAAA,CAAQ,EAAA,CAAG,SAAS,CAAA,KAAA,KAAS;AAC3B,MAAA,OAAO,OAAO,KAAK,CAAA;AAAA,IACrB,CAAC,CAAA;AAED,IAAA,OAAA,CAAQ,EAAA,CAAG,SAAS,CAAA,IAAA,KAAQ;AAC1B,MAAA,IAAI,SAAS,CAAA,EAAG;AACd,QAAA,OAAO,MAAA;AAAA,UACL,IAAI,KAAA,CAAM,CAAA,QAAA,EAAW,OAAO,CAAA,oBAAA,EAAuB,IAAI,CAAA,CAAE;AAAA,SAC3D;AAAA,MACF;AACA,MAAA,OAAO,OAAA,EAAQ;AAAA,IACjB,CAAC,CAAA;AAAA,EACH,CAAC,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.cjs.js","sources":["../../src/actions/fetch.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 { UrlReaderService } from '@backstage/backend-plugin-api';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport fs from 'fs-extra';\nimport path from 'path';\n\n/**\n * A helper function that reads the contents of a directory from the given URL.\n * Can be used in your own actions, and also used behind fetch:template and fetch:plain\n *\n * @public\n */\nexport async function fetchContents(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n baseUrl?: string;\n fetchUrl?: string;\n outputPath: string;\n token?: string;\n}) {\n const {\n reader,\n integrations,\n baseUrl,\n fetchUrl = '.',\n outputPath,\n token,\n } = options;\n\n const fetchUrlIsAbsolute = isFetchUrlAbsolute(fetchUrl);\n\n // We handle both file locations and url ones\n if (!fetchUrlIsAbsolute && baseUrl?.startsWith('file://')) {\n const basePath = baseUrl.slice('file://'.length);\n const srcDir = resolveSafeChildPath(path.dirname(basePath), fetchUrl);\n await fs.copy(srcDir, outputPath);\n } else {\n const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);\n\n const res = await reader.readTree(readUrl, { token });\n await fs.ensureDir(outputPath);\n await res.dir({ targetDir: outputPath });\n }\n}\n\n/**\n * A helper function that reads the content of a single file from the given URL.\n * Can be used in your own actions, and also used behind `fetch:plain:file`\n *\n * @public\n */\nexport async function fetchFile(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n baseUrl?: string;\n fetchUrl?: string;\n outputPath: string;\n token?: string;\n}) {\n const {\n reader,\n integrations,\n baseUrl,\n fetchUrl = '.',\n outputPath,\n token,\n } = options;\n\n const fetchUrlIsAbsolute = isFetchUrlAbsolute(fetchUrl);\n\n // We handle both file locations and url ones\n if (!fetchUrlIsAbsolute && baseUrl?.startsWith('file://')) {\n const basePath = baseUrl.slice('file://'.length);\n const src = resolveSafeChildPath(path.dirname(basePath), fetchUrl);\n await fs.copyFile(src, outputPath);\n } else {\n const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);\n\n const res = await reader.readUrl(readUrl, { token });\n await fs.ensureDir(path.dirname(outputPath));\n const buffer = await res.buffer();\n await fs.outputFile(outputPath, buffer);\n }\n}\n\nfunction isFetchUrlAbsolute(fetchUrl: string) {\n let fetchUrlIsAbsolute = false;\n try {\n // eslint-disable-next-line no-new\n new URL(fetchUrl);\n fetchUrlIsAbsolute = true;\n } catch {\n /* ignored */\n }\n return fetchUrlIsAbsolute;\n}\n\nfunction getReadUrl(\n fetchUrl: string,\n baseUrl: string | undefined,\n integrations: ScmIntegrations,\n) {\n if (isFetchUrlAbsolute(fetchUrl)) {\n return fetchUrl;\n } else if (baseUrl) {\n const integration = integrations.byUrl(baseUrl);\n if (!integration) {\n throw new InputError(`No integration found for location ${baseUrl}`);\n }\n\n return integration.resolveUrl({\n url: fetchUrl,\n base: baseUrl,\n });\n }\n throw new InputError(\n `Failed to fetch, template location could not be determined and the fetch URL is relative, ${fetchUrl}`,\n );\n}\n"],"names":["resolveSafeChildPath","path","fs","InputError"],"mappings":";;;;;;;;;;;;AA6BA,eAAsB,cAAc,
|
|
1
|
+
{"version":3,"file":"fetch.cjs.js","sources":["../../src/actions/fetch.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 { UrlReaderService } from '@backstage/backend-plugin-api';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport fs from 'fs-extra';\nimport path from 'path';\n\n/**\n * A helper function that reads the contents of a directory from the given URL.\n * Can be used in your own actions, and also used behind fetch:template and fetch:plain\n *\n * @public\n */\nexport async function fetchContents(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n baseUrl?: string;\n fetchUrl?: string;\n outputPath: string;\n token?: string;\n}) {\n const {\n reader,\n integrations,\n baseUrl,\n fetchUrl = '.',\n outputPath,\n token,\n } = options;\n\n const fetchUrlIsAbsolute = isFetchUrlAbsolute(fetchUrl);\n\n // We handle both file locations and url ones\n if (!fetchUrlIsAbsolute && baseUrl?.startsWith('file://')) {\n const basePath = baseUrl.slice('file://'.length);\n const srcDir = resolveSafeChildPath(path.dirname(basePath), fetchUrl);\n await fs.copy(srcDir, outputPath);\n } else {\n const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);\n\n const res = await reader.readTree(readUrl, { token });\n await fs.ensureDir(outputPath);\n await res.dir({ targetDir: outputPath });\n }\n}\n\n/**\n * A helper function that reads the content of a single file from the given URL.\n * Can be used in your own actions, and also used behind `fetch:plain:file`\n *\n * @public\n */\nexport async function fetchFile(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n baseUrl?: string;\n fetchUrl?: string;\n outputPath: string;\n token?: string;\n}) {\n const {\n reader,\n integrations,\n baseUrl,\n fetchUrl = '.',\n outputPath,\n token,\n } = options;\n\n const fetchUrlIsAbsolute = isFetchUrlAbsolute(fetchUrl);\n\n // We handle both file locations and url ones\n if (!fetchUrlIsAbsolute && baseUrl?.startsWith('file://')) {\n const basePath = baseUrl.slice('file://'.length);\n const src = resolveSafeChildPath(path.dirname(basePath), fetchUrl);\n await fs.copyFile(src, outputPath);\n } else {\n const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);\n\n const res = await reader.readUrl(readUrl, { token });\n await fs.ensureDir(path.dirname(outputPath));\n const buffer = await res.buffer();\n await fs.outputFile(outputPath, buffer);\n }\n}\n\nfunction isFetchUrlAbsolute(fetchUrl: string) {\n let fetchUrlIsAbsolute = false;\n try {\n // eslint-disable-next-line no-new\n new URL(fetchUrl);\n fetchUrlIsAbsolute = true;\n } catch {\n /* ignored */\n }\n return fetchUrlIsAbsolute;\n}\n\nfunction getReadUrl(\n fetchUrl: string,\n baseUrl: string | undefined,\n integrations: ScmIntegrations,\n) {\n if (isFetchUrlAbsolute(fetchUrl)) {\n return fetchUrl;\n } else if (baseUrl) {\n const integration = integrations.byUrl(baseUrl);\n if (!integration) {\n throw new InputError(`No integration found for location ${baseUrl}`);\n }\n\n return integration.resolveUrl({\n url: fetchUrl,\n base: baseUrl,\n });\n }\n throw new InputError(\n `Failed to fetch, template location could not be determined and the fetch URL is relative, ${fetchUrl}`,\n );\n}\n"],"names":["resolveSafeChildPath","path","fs","InputError"],"mappings":";;;;;;;;;;;;AA6BA,eAAsB,cAAc,OAAA,EAOjC;AACD,EAAA,MAAM;AAAA,IACJ,MAAA;A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A,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACA,EAAA,MAAM,IAAIA,iBAAA;AAAA,IACR,6FAA6F,QAAQ,CAAA;AAAA,GACvG;AACF;;;;;"}
|
|
@@ -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,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;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{"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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,EAAA,MAAMA,KAAA,GAAMC,QAAI,QAAA,CAAS;AAAA,IACvB,GAAG,IAAA;AAAA,IACH;AAAA,GACD,CAAA;AAED,EAAA,MAAMD,KAAA,CAAI,GAAA,CAAI,EAAE,GAAA,EAAK,UAAU,CAAA;AACjC;AAKA,eAAsB,oBAAoB,OAAA,EAaN;AAClC,EAAA,MAAM;AAAA,IACJ,GAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA;AAAA,IACA,aAAA;AAAA,IACA,MAAA,GAAS,QAAA;AAAA,IACT,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;;;;;;;;;"}
|
|
@@ -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';\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 '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 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":";;;;;;;;;;;;;
|
|
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';\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 '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 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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AAA,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 +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":";;
|
|
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 +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":";;
|
|
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;;;;;"}
|
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';\nexport * from './types';\nexport * from './checkpoints';\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<any, any>[],\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":";;;;;;;AA8CO,MAAM,kCACXA,
|
|
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';\nexport * from './types';\nexport * from './checkpoints';\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<any, any>[],\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":";;;;;;;AA8CO,MAAM,kCACXA,qCAAA,CAAsD;AAAA,EACpD,EAAA,EAAI;AACN,CAAC;AAgBI,MAAM,qCACXA,qCAAA,CAAyD;AAAA,EACvD,EAAA,EAAI;AACN,CAAC;AAsBI,MAAM,qCACXA,qCAAA,CAAyD;AAAA,EACvD,EAAA,EAAI;AACN,CAAC;AAmCI,MAAM,uCACXA,qCAAA,CAA2D;AAAA,EACzD,EAAA,EAAI;AACN,CAAC;AAsCI,MAAM,4CACXA,qCAAA,CAAgE;AAAA,EAC9D,EAAA,EAAI;AACN,CAAC;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserializeDirectoryContents.cjs.js","sources":["../../src/files/deserializeDirectoryContents.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 fs from 'fs-extra';\nimport { dirname } from 'path';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { SerializedFile } from './types';\n\n/**\n * Deserializes a list of serialized files into the target directory.\n *\n * This method uses `resolveSafeChildPath` to make sure that files are\n * not written outside of the target directory.\n *\n * @public\n */\nexport async function deserializeDirectoryContents(\n targetPath: string,\n files: SerializedFile[],\n): Promise<void> {\n for (const file of files) {\n const filePath = resolveSafeChildPath(targetPath, file.path);\n await fs.ensureDir(dirname(filePath));\n await fs.writeFile(filePath, file.content); // Ignore file mode\n }\n}\n"],"names":["resolveSafeChildPath","fs","dirname"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"deserializeDirectoryContents.cjs.js","sources":["../../src/files/deserializeDirectoryContents.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 fs from 'fs-extra';\nimport { dirname } from 'path';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { SerializedFile } from './types';\n\n/**\n * Deserializes a list of serialized files into the target directory.\n *\n * This method uses `resolveSafeChildPath` to make sure that files are\n * not written outside of the target directory.\n *\n * @public\n */\nexport async function deserializeDirectoryContents(\n targetPath: string,\n files: SerializedFile[],\n): Promise<void> {\n for (const file of files) {\n const filePath = resolveSafeChildPath(targetPath, file.path);\n await fs.ensureDir(dirname(filePath));\n await fs.writeFile(filePath, file.content); // Ignore file mode\n }\n}\n"],"names":["resolveSafeChildPath","fs","dirname"],"mappings":";;;;;;;;;;AA6BA,eAAsB,4BAAA,CACpB,YACA,KAAA,EACe;AACf,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,MAAM,QAAA,GAAWA,qCAAA,CAAqB,UAAA,EAAY,IAAA,CAAK,IAAI,CAAA;AAC3D,IAAA,MAAMC,mBAAA,CAAG,SAAA,CAAUC,YAAA,CAAQ,QAAQ,CAAC,CAAA;AACpC,IAAA,MAAMD,mBAAA,CAAG,SAAA,CAAU,QAAA,EAAU,IAAA,CAAK,OAAO,CAAA;AAAA,EAC3C;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeDirectoryContents.cjs.js","sources":["../../src/files/serializeDirectoryContents.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 { promises as fs } from 'fs';\nimport globby from 'globby';\nimport limiterFactory from 'p-limit';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { SerializedFile } from './types';\nimport { isError } from '@backstage/errors';\n\nconst DEFAULT_GLOB_PATTERNS = ['./**', '!.git'];\n\nexport const isExecutable = (fileMode: number | undefined) => {\n if (!fileMode) {\n return false;\n }\n\n const executeBitMask = 0o000111;\n const res = fileMode & executeBitMask;\n return res > 0;\n};\n\nasync function asyncFilter<T>(\n array: T[],\n callback: (value: T, index: number, array: T[]) => Promise<boolean>,\n): Promise<T[]> {\n const filterMap = await Promise.all(array.map(callback));\n return array.filter((_value, index) => filterMap[index]);\n}\n\n/**\n * @public\n */\nexport async function serializeDirectoryContents(\n sourcePath: string,\n options?: {\n gitignore?: boolean;\n globPatterns?: string[];\n },\n): Promise<SerializedFile[]> {\n const paths = await globby(options?.globPatterns ?? DEFAULT_GLOB_PATTERNS, {\n cwd: sourcePath,\n dot: true,\n gitignore: options?.gitignore,\n followSymbolicLinks: false,\n // In order to pick up 'broken' symlinks, we oxymoronically request files AND folders yet we filter out folders\n // This is because broken symlinks aren't classed as files so we need to glob everything\n onlyFiles: false,\n objectMode: true,\n stats: true,\n });\n\n const limiter = limiterFactory(10);\n\n const valid = await asyncFilter(paths, async ({ dirent, path }) => {\n if (dirent.isDirectory()) return false;\n if (!dirent.isSymbolicLink()) return true;\n\n const safePath = resolveSafeChildPath(sourcePath, path);\n\n // we only want files that don't exist\n try {\n await fs.stat(safePath);\n return false;\n } catch (e) {\n return isError(e) && e.code === 'ENOENT';\n }\n });\n\n return Promise.all(\n valid.map(async ({ dirent, path, stats }) => ({\n path,\n content: await limiter(async () => {\n const absFilePath = resolveSafeChildPath(sourcePath, path);\n if (dirent.isSymbolicLink()) {\n return fs.readlink(absFilePath, 'buffer');\n }\n return fs.readFile(absFilePath);\n }),\n executable: isExecutable(stats?.mode),\n symlink: dirent.isSymbolicLink(),\n })),\n );\n}\n"],"names":["globby","limiterFactory","resolveSafeChildPath","fs","isError"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,qBAAA,GAAwB,CAAC,MAAA,EAAQ,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"serializeDirectoryContents.cjs.js","sources":["../../src/files/serializeDirectoryContents.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 { promises as fs } from 'fs';\nimport globby from 'globby';\nimport limiterFactory from 'p-limit';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { SerializedFile } from './types';\nimport { isError } from '@backstage/errors';\n\nconst DEFAULT_GLOB_PATTERNS = ['./**', '!.git'];\n\nexport const isExecutable = (fileMode: number | undefined) => {\n if (!fileMode) {\n return false;\n }\n\n const executeBitMask = 0o000111;\n const res = fileMode & executeBitMask;\n return res > 0;\n};\n\nasync function asyncFilter<T>(\n array: T[],\n callback: (value: T, index: number, array: T[]) => Promise<boolean>,\n): Promise<T[]> {\n const filterMap = await Promise.all(array.map(callback));\n return array.filter((_value, index) => filterMap[index]);\n}\n\n/**\n * @public\n */\nexport async function serializeDirectoryContents(\n sourcePath: string,\n options?: {\n gitignore?: boolean;\n globPatterns?: string[];\n },\n): Promise<SerializedFile[]> {\n const paths = await globby(options?.globPatterns ?? DEFAULT_GLOB_PATTERNS, {\n cwd: sourcePath,\n dot: true,\n gitignore: options?.gitignore,\n followSymbolicLinks: false,\n // In order to pick up 'broken' symlinks, we oxymoronically request files AND folders yet we filter out folders\n // This is because broken symlinks aren't classed as files so we need to glob everything\n onlyFiles: false,\n objectMode: true,\n stats: true,\n });\n\n const limiter = limiterFactory(10);\n\n const valid = await asyncFilter(paths, async ({ dirent, path }) => {\n if (dirent.isDirectory()) return false;\n if (!dirent.isSymbolicLink()) return true;\n\n const safePath = resolveSafeChildPath(sourcePath, path);\n\n // we only want files that don't exist\n try {\n await fs.stat(safePath);\n return false;\n } catch (e) {\n return isError(e) && e.code === 'ENOENT';\n }\n });\n\n return Promise.all(\n valid.map(async ({ dirent, path, stats }) => ({\n path,\n content: await limiter(async () => {\n const absFilePath = resolveSafeChildPath(sourcePath, path);\n if (dirent.isSymbolicLink()) {\n return fs.readlink(absFilePath, 'buffer');\n }\n return fs.readFile(absFilePath);\n }),\n executable: isExecutable(stats?.mode),\n symlink: dirent.isSymbolicLink(),\n })),\n );\n}\n"],"names":["globby","limiterFactory","resolveSafeChildPath","fs","isError"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,qBAAA,GAAwB,CAAC,MAAA,EAAQ,OAAO,CAAA;AAEvC,MAAM,YAAA,GAAe,CAAC,QAAA,KAAiC;AAC5D,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,cAAA,GAAiB,EAAA;AACvB,EAAA,MAAM,MAAM,QAAA,GAAW,cAAA;AACvB,EAAA,OAAO,GAAA,GAAM,CAAA;AACf;AAEA,eAAe,WAAA,CACb,OACA,QAAA,EACc;AACd,EAAA,MAAM,YAAY,MAAM,OAAA,CAAQ,IAAI,KAAA,CAAM,GAAA,CAAI,QAAQ,CAAC,CAAA;AACvD,EAAA,OAAO,MAAM,MAAA,CAAO,CAAC,QAAQ,KAAA,KAAU,SAAA,CAAU,KAAK,CAAC,CAAA;AACzD;AAKA,eAAsB,0BAAA,CACpB,YACA,OAAA,EAI2B;AAC3B,EAAA,MAAM,KAAA,GAAQ,MAAMA,uBAAA,CAAO,OAAA,EAAS,gBAAgB,qBAAA,EAAuB;AAAA,IACzE,GAAA,EAAK,UAAA;AAAA,IACL,GAAA,EAAK,IAAA;AAAA,IACL,WAAW,OAAA,EAAS,SAAA;AAAA,IACpB,mBAAA,EAAqB,KAAA;AAAA;AAAA;AAAA,IAGrB,SAAA,EAAW,KAAA;AAAA,IACX,UAAA,EAAY,IAAA;AAAA,IACZ,KAAA,EAAO;AAAA,GACR,CAAA;AAED,EAAA,MAAM,OAAA,GAAUC,gCAAe,EAAE,CAAA;AAEjC,EAAA,MAAM,KAAA,GAAQ,MAAM,WAAA,CAAY,KAAA,EAAO,OAAO,EAAE,MAAA,EAAQ,MAAK,KAAM;AACjE,IAAA,IAAI,MAAA,CAAO,WAAA,EAAY,EAAG,OAAO,KAAA;AACjC,IAAA,IAAI,CAAC,MAAA,CAAO,cAAA,EAAe,EAAG,OAAO,IAAA;AAErC,IAAA,MAAM,QAAA,GAAWC,qCAAA,CAAqB,UAAA,EAAY,IAAI,CAAA;AAGtD,IAAA,IAAI;AACF,MAAA,MAAMC,WAAA,CAAG,KAAK,QAAQ,CAAA;AACtB,MAAA,OAAO,KAAA;AAAA,IACT,SAAS,CAAA,EAAG;AACV,MAAA,OAAOC,cAAA,CAAQ,CAAC,CAAA,IAAK,CAAA,CAAE,IAAA,KAAS,QAAA;AAAA,IAClC;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,OAAA,CAAQ,GAAA;AAAA,IACb,MAAM,GAAA,CAAI,OAAO,EAAE,MAAA,EAAQ,IAAA,EAAM,OAAM,MAAO;AAAA,MAC5C,IAAA;AAAA,MACA,OAAA,EAAS,MAAM,OAAA,CAAQ,YAAY;AACjC,QAAA,MAAM,WAAA,GAAcF,qCAAA,CAAqB,UAAA,EAAY,IAAI,CAAA;AACzD,QAAA,IAAI,MAAA,CAAO,gBAAe,EAAG;AAC3B,UAAA,OAAOC,WAAA,CAAG,QAAA,CAAS,WAAA,EAAa,QAAQ,CAAA;AAAA,QAC1C;AACA,QAAA,OAAOA,WAAA,CAAG,SAAS,WAAW,CAAA;AAAA,MAChC,CAAC,CAAA;AAAA,MACD,UAAA,EAAY,YAAA,CAAa,KAAA,EAAO,IAAI,CAAA;AAAA,MACpC,OAAA,EAAS,OAAO,cAAA;AAAe,KACjC,CAAE;AAAA,GACJ;AACF;;;;;"}
|
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 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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A,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,OAAA,EACgC;AAChC,EAAA,OAAO,QAAA,IAAY,OAAA;AACrB;AA4CO,MAAM,GAAA,CAAI;AAAA,EAKP,YACW,MAAA,EAKjB;AALiB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAMjB,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AAErB,IAAA,IAAA,CAAK,OAAA,GAAU;AAAA,MACb,YAAA,EAAc,qBAAA;AAAA,MACd,GAAI,MAAA,CAAO,KAAA,GAAQ,EAAE,aAAA,EAAe,UAAU,MAAA,CAAO,KAAK,CAAA,CAAA,EAAG,GAAI;AAAC,KACpE;AAAA,EACF;AAAA,EAjBiB,OAAA;AAAA,EAmBjB,MAAM,IAAI,OAAA,EAA2D;AACnE,IAAA,MAAM,EAAE,GAAA,EAAK,QAAA,EAAS,GAAI,OAAA;AAC1B,IAAA,IAAA,CAAK,OAAO,MAAA,EAAQ,IAAA,CAAK,oBAAoB,GAAG,CAAA,UAAA,EAAa,QAAQ,CAAA,CAAA,CAAG,CAAA;AAExE,IAAA,OAAOA,qBAAI,GAAA,CAAI,MAAEC,mBAAA,EAAI,GAAA,EAAK,UAAU,CAAA;AAAA,EACtC;AAAA,EAEA,MAAM,UAAU,OAAA,EAKE;AAChB,IAAA,MAAM,EAAE,GAAA,EAAK,GAAA,EAAK,MAAA,EAAQ,OAAM,GAAI,OAAA;AACpC,IAAA,IAAA,CAAK,OAAO,MAAA,EAAQ,IAAA;AAAA,MAClB,CAAA,yBAAA,EAA4B,GAAG,CAAA,QAAA,EAAW,MAAM,QAAQ,GAAG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,MAAA,EAAQ,MAAA,EAAAG,OAAAA,EAAO,GAAI,OAAA;AAC3B,MAAA,OAAO,IAAI,GAAA,CAAI,EAAE,MAAA,EAAQ,MAAA,EAAAA,SAAQ,CAAA;AAAA,IACnC;AAEA,IAAA,MAAM,EAAE,QAAA,EAAU,QAAA,EAAU,KAAA,EAAO,QAAO,GAAI,OAAA;AAC9C,IAAA,OAAO,IAAI,GAAA,CAAI,EAAE,MAAA,EAAQ,OAAO,EAAE,QAAA,EAAU,QAAA,EAAS,CAAA,EAAI,KAAA,EAAO,MAAA,EAAQ,CAAA;AAAA,EAC1E,CAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.cjs.js","sources":["../../src/tasks/serializer.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 tar from 'tar';\nimport concatStream from 'concat-stream';\nimport { promisify } from 'util';\nimport { pipeline as pipelineCb, Readable } from 'stream';\n\nconst pipeline = promisify(pipelineCb);\n/**\n * Serializes provided path into tar archive\n *\n * @alpha\n */\nexport const serializeWorkspace = async (opts: {\n path: string;\n}): Promise<{ contents: Buffer }> => {\n return new Promise<{ contents: Buffer }>(async resolve => {\n await pipeline(\n tar.create({ cwd: opts.path }, ['']),\n concatStream(buffer => {\n return resolve({ contents: buffer });\n }),\n );\n });\n};\n\n/**\n * Rehydrates the provided buffer of tar archive into the provide destination path\n *\n * @alpha\n */\nexport const restoreWorkspace = async (opts: {\n path: string;\n buffer?: Buffer;\n}): Promise<void> => {\n const { buffer, path } = opts;\n if (buffer) {\n await pipeline(\n Readable.from(buffer),\n tar.extract({\n C: path,\n }),\n );\n }\n};\n"],"names":["promisify","pipelineCb","tar","concatStream","Readable"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,QAAA,GAAWA,eAAUC,eAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"serializer.cjs.js","sources":["../../src/tasks/serializer.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 tar from 'tar';\nimport concatStream from 'concat-stream';\nimport { promisify } from 'util';\nimport { pipeline as pipelineCb, Readable } from 'stream';\n\nconst pipeline = promisify(pipelineCb);\n/**\n * Serializes provided path into tar archive\n *\n * @alpha\n */\nexport const serializeWorkspace = async (opts: {\n path: string;\n}): Promise<{ contents: Buffer }> => {\n return new Promise<{ contents: Buffer }>(async resolve => {\n await pipeline(\n tar.create({ cwd: opts.path }, ['']),\n concatStream(buffer => {\n return resolve({ contents: buffer });\n }),\n );\n });\n};\n\n/**\n * Rehydrates the provided buffer of tar archive into the provide destination path\n *\n * @alpha\n */\nexport const restoreWorkspace = async (opts: {\n path: string;\n buffer?: Buffer;\n}): Promise<void> => {\n const { buffer, path } = opts;\n if (buffer) {\n await pipeline(\n Readable.from(buffer),\n tar.extract({\n C: path,\n }),\n );\n }\n};\n"],"names":["promisify","pipelineCb","tar","concatStream","Readable"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,QAAA,GAAWA,eAAUC,eAAU,CAAA;AAM9B,MAAM,kBAAA,GAAqB,OAAO,IAAA,KAEJ;AACnC,EAAA,OAAO,IAAI,OAAA,CAA8B,OAAM,OAAA,KAAW;AACxD,IAAA,MAAM,QAAA;AAAA,MACJC,oBAAA,CAAI,OAAO,EAAE,GAAA,EAAK,KAAK,IAAA,EAAK,EAAG,CAAC,EAAE,CAAC,CAAA;AAAA,MACnCC,8BAAa,CAAA,MAAA,KAAU;AACrB,QAAA,OAAO,OAAA,CAAQ,EAAE,QAAA,EAAU,MAAA,EAAQ,CAAA;AAAA,MACrC,CAAC;AAAA,KACH;AAAA,EACF,CAAC,CAAA;AACH;AAOO,MAAM,gBAAA,GAAmB,OAAO,IAAA,KAGlB;AACnB,EAAA,MAAM,EAAE,MAAA,EAAQ,IAAA,EAAK,GAAI,IAAA;AACzB,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,MAAM,QAAA;AAAA,MACJC,eAAA,CAAS,KAAK,MAAM,CAAA;AAAA,MACpBF,qBAAI,OAAA,CAAQ;AAAA,QACV,CAAA,EAAG;AAAA,OACJ;AAAA,KACH;AAAA,EACF;AACF;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-node",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1-next.0",
|
|
4
4
|
"description": "The plugin-scaffolder-node module for @backstage/plugin-scaffolder-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
"test": "backstage-cli package test"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@backstage/backend-plugin-api": "1.4.
|
|
65
|
+
"@backstage/backend-plugin-api": "1.4.3-next.0",
|
|
66
66
|
"@backstage/catalog-model": "1.7.5",
|
|
67
67
|
"@backstage/errors": "1.2.7",
|
|
68
|
-
"@backstage/integration": "1.
|
|
68
|
+
"@backstage/integration": "1.18.0-next.0",
|
|
69
69
|
"@backstage/plugin-permission-common": "0.9.1",
|
|
70
|
-
"@backstage/plugin-scaffolder-common": "1.7.
|
|
70
|
+
"@backstage/plugin-scaffolder-common": "1.7.1-next.0",
|
|
71
71
|
"@backstage/types": "1.2.1",
|
|
72
72
|
"@isomorphic-git/pgp-plugin": "^0.0.7",
|
|
73
73
|
"concat-stream": "^2.0.0",
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"zod-to-json-schema": "^3.20.4"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@backstage/backend-test-utils": "1.
|
|
88
|
-
"@backstage/cli": "0.
|
|
87
|
+
"@backstage/backend-test-utils": "1.9.0-next.1",
|
|
88
|
+
"@backstage/cli": "0.34.2-next.1",
|
|
89
89
|
"@backstage/config": "1.3.3",
|
|
90
90
|
"@types/lodash": "^4.14.151"
|
|
91
91
|
}
|