@backstage/plugin-scaffolder-backend-module-azure 0.2.7-next.1 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-azure
2
2
 
3
+ ## 0.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 4f8b5b6: Allow signing git commits using configured private PGP key in scaffolder
8
+ - Updated dependencies
9
+ - @backstage/integration@1.16.2
10
+ - @backstage/plugin-scaffolder-node@0.8.0
11
+ - @backstage/backend-plugin-api@1.2.1
12
+ - @backstage/config@1.3.2
13
+ - @backstage/errors@1.2.7
14
+
15
+ ## 0.2.7-next.2
16
+
17
+ ### Patch Changes
18
+
19
+ - 4f8b5b6: Allow signing git commits using configured private PGP key in scaffolder
20
+ - Updated dependencies
21
+ - @backstage/plugin-scaffolder-node@0.8.0-next.2
22
+ - @backstage/integration@1.16.2-next.0
23
+ - @backstage/backend-plugin-api@1.2.1-next.1
24
+ - @backstage/config@1.3.2
25
+ - @backstage/errors@1.2.7
26
+
3
27
  ## 0.2.7-next.1
4
28
 
5
29
  ### Patch Changes
@@ -54,6 +54,11 @@ function createPublishAzureAction(options) {
54
54
  title: "Authentication Token",
55
55
  type: "string",
56
56
  description: "The token to use for authorization to Azure"
57
+ },
58
+ signCommit: {
59
+ title: "Sign commit",
60
+ type: "boolean",
61
+ description: "Sign commit with configured PGP private key"
57
62
  }
58
63
  }
59
64
  },
@@ -85,7 +90,8 @@ function createPublishAzureAction(options) {
85
90
  defaultBranch = "master",
86
91
  gitCommitMessage = "initial commit",
87
92
  gitAuthorName,
88
- gitAuthorEmail
93
+ gitAuthorEmail,
94
+ signCommit
89
95
  } = ctx.input;
90
96
  const { project, repo, host, organization } = pluginScaffolderNode.parseRepoUrl(
91
97
  repoUrl,
@@ -99,6 +105,7 @@ function createPublishAzureAction(options) {
99
105
  const url = `https://${host}/${organization}`;
100
106
  const credentialProvider = integration.DefaultAzureDevOpsCredentialsProvider.fromIntegrations(integrations);
101
107
  const credentials = await credentialProvider.getCredentials({ url });
108
+ const integrationConfig = integrations.azure.byHost(host);
102
109
  if (credentials === void 0 && ctx.input.token === void 0) {
103
110
  throw new errors.InputError(
104
111
  `No credentials provided ${url}, please check your integrations config`
@@ -142,6 +149,12 @@ function createPublishAzureAction(options) {
142
149
  username: "notempty",
143
150
  password: ctx.input.token ?? credentials.token
144
151
  };
152
+ const signingKey = integrationConfig?.config.commitSigningKey ?? config.getOptionalString("scaffolder.defaultCommitSigningKey");
153
+ if (signCommit && !signingKey) {
154
+ throw new Error(
155
+ "Signing commits is enabled but no signing key is provided in the configuration"
156
+ );
157
+ }
145
158
  const commitResult = await pluginScaffolderNode.initRepoAndPush({
146
159
  dir: pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
147
160
  remoteUrl,
@@ -149,7 +162,8 @@ function createPublishAzureAction(options) {
149
162
  auth,
150
163
  logger: ctx.logger,
151
164
  commitMessage: gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage"),
152
- gitAuthorInfo
165
+ gitAuthorInfo,
166
+ signingKey: signCommit ? signingKey : void 0
153
167
  });
154
168
  ctx.output("commitHash", commitResult?.commitHash);
155
169
  ctx.output("remoteUrl", remoteUrl);
@@ -1 +1 @@
1
- {"version":3,"file":"azure.cjs.js","sources":["../../src/actions/azure.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 {\n DefaultAzureDevOpsCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n initRepoAndPush,\n getRepoSourceDirectory,\n parseRepoUrl,\n createTemplateAction,\n} from '@backstage/plugin-scaffolder-node';\nimport { GitRepositoryCreateOptions } from 'azure-devops-node-api/interfaces/GitInterfaces';\nimport {\n getBearerHandler,\n getPersonalAccessTokenHandler,\n WebApi,\n} from 'azure-devops-node-api';\nimport { Config } from '@backstage/config';\nimport { examples } from './azure.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to Azure.\n * @public\n */\nexport function createPublishAzureAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description?: string;\n defaultBranch?: string;\n sourcePath?: string;\n token?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n }>({\n id: 'publish:azure',\n examples,\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Azure.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n description: {\n title: 'Repository Description',\n type: 'string',\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'master'`,\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n sourcePath: {\n title: 'Source Path',\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',\n type: 'string',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to Azure',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n repositoryId: {\n title: 'The Id of the created repository',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n defaultBranch = 'master',\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n } = ctx.input;\n\n const { project, repo, host, organization } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n if (!organization) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing organization`,\n );\n }\n\n const url = `https://${host}/${organization}`;\n const credentialProvider =\n DefaultAzureDevOpsCredentialsProvider.fromIntegrations(integrations);\n const credentials = await credentialProvider.getCredentials({ url: url });\n\n if (credentials === undefined && ctx.input.token === undefined) {\n throw new InputError(\n `No credentials provided ${url}, please check your integrations config`,\n );\n }\n\n const authHandler =\n ctx.input.token || credentials?.type === 'pat'\n ? getPersonalAccessTokenHandler(ctx.input.token ?? credentials!.token)\n : getBearerHandler(credentials!.token);\n\n const webApi = new WebApi(url, authHandler);\n const client = await webApi.getGitApi();\n const createOptions: GitRepositoryCreateOptions = { name: repo };\n const returnedRepo = await client.createRepository(\n createOptions,\n project,\n );\n\n if (!returnedRepo) {\n throw new InputError(\n `Unable to create the repository with Organization ${organization}, Project ${project} and Repo ${repo}.\n Please make sure that both the Org and Project are typed corrected and exist.`,\n );\n }\n const remoteUrl = returnedRepo.remoteUrl;\n\n if (!remoteUrl) {\n throw new InputError(\n 'No remote URL returned from create repository for Azure',\n );\n }\n const repositoryId = returnedRepo.id;\n\n if (!repositoryId) {\n throw new InputError('No Id returned from create repository for Azure');\n }\n\n const repoContentsUrl = returnedRepo.webUrl;\n\n if (!repoContentsUrl) {\n throw new InputError(\n 'No web URL returned from create repository for Azure',\n );\n }\n\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n const auth = {\n username: 'notempty',\n password: ctx.input.token ?? credentials!.token,\n };\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),\n remoteUrl,\n defaultBranch,\n auth: auth,\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n });\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('repositoryId', repositoryId);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","DefaultAzureDevOpsCredentialsProvider","getPersonalAccessTokenHandler","getBearerHandler","WebApi","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;;AAyCO,SAAS,yBAAyB,OAGtC,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,MAAA,EAAW,GAAA,OAAA;AAEjC,EAAA,OAAOA,yCASJ,CAAA;AAAA,IACD,EAAI,EAAA,eAAA;AAAA,cACJC,uBAAA;AAAA,IACA,WACE,EAAA,0FAAA;AAAA,IACF,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,QACpB,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,IAAM,EAAA;AAAA,WACR;AAAA,UACA,WAAa,EAAA;AAAA,YACX,KAAO,EAAA,wBAAA;AAAA,YACP,IAAM,EAAA;AAAA,WACR;AAAA,UACA,aAAe,EAAA;AAAA,YACb,KAAO,EAAA,gBAAA;AA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,MAAA;AAAA,QACZ,aAAe,EAAA,gBAAA,GACX,gBACA,GAAA,MAAA,CAAO,kBAAkB,iCAAiC,CAAA;AAAA,QAC9D;AAAA,OACD,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,EAAc,UAAU,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAC7C,MAAI,GAAA,CAAA,MAAA,CAAO,gBAAgB,YAAY,CAAA;AAAA;AACzC,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"azure.cjs.js","sources":["../../src/actions/azure.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 {\n DefaultAzureDevOpsCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { GitRepositoryCreateOptions } from 'azure-devops-node-api/interfaces/GitInterfaces';\nimport {\n getBearerHandler,\n getPersonalAccessTokenHandler,\n WebApi,\n} from 'azure-devops-node-api';\nimport { Config } from '@backstage/config';\nimport { examples } from './azure.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to Azure.\n * @public\n */\nexport function createPublishAzureAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description?: string;\n defaultBranch?: string;\n sourcePath?: string;\n token?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n signCommit?: boolean;\n }>({\n id: 'publish:azure',\n examples,\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Azure.',\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n description: {\n title: 'Repository Description',\n type: 'string',\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'master'`,\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n sourcePath: {\n title: 'Source Path',\n description:\n 'Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.',\n type: 'string',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to Azure',\n },\n signCommit: {\n title: 'Sign commit',\n type: 'boolean',\n description: 'Sign commit with configured PGP private key',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n repositoryId: {\n title: 'The Id of the created repository',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n defaultBranch = 'master',\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n signCommit,\n } = ctx.input;\n\n const { project, repo, host, organization } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n if (!organization) {\n throw new InputError(\n `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing organization`,\n );\n }\n\n const url = `https://${host}/${organization}`;\n const credentialProvider =\n DefaultAzureDevOpsCredentialsProvider.fromIntegrations(integrations);\n const credentials = await credentialProvider.getCredentials({ url: url });\n const integrationConfig = integrations.azure.byHost(host);\n\n if (credentials === undefined && ctx.input.token === undefined) {\n throw new InputError(\n `No credentials provided ${url}, please check your integrations config`,\n );\n }\n\n const authHandler =\n ctx.input.token || credentials?.type === 'pat'\n ? getPersonalAccessTokenHandler(ctx.input.token ?? credentials!.token)\n : getBearerHandler(credentials!.token);\n\n const webApi = new WebApi(url, authHandler);\n const client = await webApi.getGitApi();\n const createOptions: GitRepositoryCreateOptions = { name: repo };\n const returnedRepo = await client.createRepository(\n createOptions,\n project,\n );\n\n if (!returnedRepo) {\n throw new InputError(\n `Unable to create the repository with Organization ${organization}, Project ${project} and Repo ${repo}.\n Please make sure that both the Org and Project are typed corrected and exist.`,\n );\n }\n const remoteUrl = returnedRepo.remoteUrl;\n\n if (!remoteUrl) {\n throw new InputError(\n 'No remote URL returned from create repository for Azure',\n );\n }\n const repositoryId = returnedRepo.id;\n\n if (!repositoryId) {\n throw new InputError('No Id returned from create repository for Azure');\n }\n\n const repoContentsUrl = returnedRepo.webUrl;\n\n if (!repoContentsUrl) {\n throw new InputError(\n 'No web URL returned from create repository for Azure',\n );\n }\n\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n\n const auth = {\n username: 'notempty',\n password: ctx.input.token ?? credentials!.token,\n };\n\n const signingKey =\n integrationConfig?.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),\n remoteUrl,\n defaultBranch,\n auth: auth,\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('repositoryId', repositoryId);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","DefaultAzureDevOpsCredentialsProvider","getPersonalAccessTokenHandler","getBearerHandler","WebApi","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;;AAyCO,SAAS,yBAAyB,OAGtC,EAAA;AACD,EAAM,MAAA,EAAE,YAAc,EAAA,MAAA,EAAW,GAAA,OAAA;AAEjC,EAAA,OAAOA,yCAUJ,CAAA;AAAA,IACD,EAAI,EAAA,eAAA;AAAA,cACJC,uBAAA;AAAA,IACA,WACE,EAAA,0FAAA;AAAA,IACF,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,CAAC,SAAS,CAAA;AAAA,QACpB,UAAY,EAAA;AAAA,UACV,OAAS,EAAA;AAAA,YACP,KAAO,EAAA,qBAAA;AAAA,YACP,IAAM,EAAA;AAAA,WACR;AAAA,UACA,WAAa,EAAA;AAAA,YACX,KAAO,EAAA,wBAAA;AAAA,YACP,IAAM,EAAA;AAAA,WACR;AAAA,UACA,aAAe,EAAA;AAAA,YACb,KAAO,EAAA,gBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WAAa,EAAA,CAAA,wEAAA;AAAA,WACf;AAAA,UACA,gBAAkB,EAAA;AAAA,YAChB,KAAO,EAAA,oBAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,YACN,WAAa,EAAA,CAAA,gF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ACF;AAAA;AAGF,MAAM,MAAA,YAAA,GAAe,MAAMK,oCAAgB,CAAA;AAAA,QACzC,KAAKC,2CAAuB,CAAA,GAAA,CAAI,aAAe,EAAA,GAAA,CAAI,MAAM,UAAU,CAAA;AAAA,QACnE,SAAA;AAAA,QACA,aAAA;AAAA,QACA,IAAA;AAAA,QACA,QAAQ,GAAI,CAAA,MAAA;AAAA,QACZ,aAAe,EAAA,gBAAA,GACX,gBACA,GAAA,MAAA,CAAO,kBAAkB,iCAAiC,CAAA;AAAA,QAC9D,aAAA;AAAA,QACA,UAAA,EAAY,aAAa,UAAa,GAAA,KAAA;AAAA,OACvC,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,EAAc,UAAU,CAAA;AACjD,MAAI,GAAA,CAAA,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,MAAI,GAAA,CAAA,MAAA,CAAO,mBAAmB,eAAe,CAAA;AAC7C,MAAI,GAAA,CAAA,MAAA,CAAO,gBAAgB,YAAY,CAAA;AAAA;AACzC,GACD,CAAA;AACH;;;;"}
package/dist/index.d.ts CHANGED
@@ -14,14 +14,15 @@ declare function createPublishAzureAction(options: {
14
14
  config: Config;
15
15
  }): _backstage_plugin_scaffolder_node.TemplateAction<{
16
16
  repoUrl: string;
17
- description?: string | undefined;
18
- defaultBranch?: string | undefined;
19
- sourcePath?: string | undefined;
20
- token?: string | undefined;
21
- gitCommitMessage?: string | undefined;
22
- gitAuthorName?: string | undefined;
23
- gitAuthorEmail?: string | undefined;
24
- }, _backstage_types.JsonObject>;
17
+ description?: string;
18
+ defaultBranch?: string;
19
+ sourcePath?: string;
20
+ token?: string;
21
+ gitCommitMessage?: string;
22
+ gitAuthorName?: string;
23
+ gitAuthorEmail?: string;
24
+ signCommit?: boolean;
25
+ }, _backstage_types.JsonObject, "v1">;
25
26
 
26
27
  /**
27
28
  * @public
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-azure",
3
- "version": "0.2.7-next.1",
3
+ "version": "0.2.7",
4
4
  "description": "The azure module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -30,13 +30,6 @@
30
30
  },
31
31
  "main": "./dist/index.cjs.js",
32
32
  "types": "./dist/index.d.ts",
33
- "typesVersions": {
34
- "*": {
35
- "index": [
36
- "dist/index.d.ts"
37
- ]
38
- }
39
- },
40
33
  "files": [
41
34
  "dist"
42
35
  ],
@@ -50,16 +43,16 @@
50
43
  "test": "backstage-cli package test"
51
44
  },
52
45
  "dependencies": {
53
- "@backstage/backend-plugin-api": "1.2.1-next.1",
54
- "@backstage/config": "1.3.2",
55
- "@backstage/errors": "1.2.7",
56
- "@backstage/integration": "1.16.1",
57
- "@backstage/plugin-scaffolder-node": "0.7.1-next.1",
46
+ "@backstage/backend-plugin-api": "^1.2.1",
47
+ "@backstage/config": "^1.3.2",
48
+ "@backstage/errors": "^1.2.7",
49
+ "@backstage/integration": "^1.16.2",
50
+ "@backstage/plugin-scaffolder-node": "^0.8.0",
58
51
  "azure-devops-node-api": "^14.0.0",
59
52
  "yaml": "^2.0.0"
60
53
  },
61
54
  "devDependencies": {
62
- "@backstage/cli": "0.30.1-next.0",
63
- "@backstage/plugin-scaffolder-node-test-utils": "0.1.20-next.1"
55
+ "@backstage/cli": "^0.31.0",
56
+ "@backstage/plugin-scaffolder-node-test-utils": "^0.2.0"
64
57
  }
65
58
  }