@backstage/plugin-scaffolder-backend-module-sentry 0.1.17 → 0.1.18-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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-sentry
2
2
 
3
+ ## 0.1.18-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - e9a5228: Exporting a default module for the new Backend System
8
+ - Updated dependencies
9
+ - @backstage/plugin-scaffolder-node@0.3.0-next.0
10
+ - @backstage/backend-plugin-api@0.6.10-next.0
11
+ - @backstage/config@1.1.1
12
+ - @backstage/errors@1.2.3
13
+
3
14
  ## 0.1.17
4
15
 
5
16
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -4,6 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
6
6
  var errors = require('@backstage/errors');
7
+ var backendPluginApi = require('@backstage/backend-plugin-api');
8
+ var alpha = require('@backstage/plugin-scaffolder-node/alpha');
7
9
 
8
10
  function createSentryCreateProjectAction(options) {
9
11
  const { config } = options;
@@ -77,5 +79,23 @@ function createSentryCreateProjectAction(options) {
77
79
  });
78
80
  }
79
81
 
82
+ const sentryModule = backendPluginApi.createBackendModule({
83
+ pluginId: "scaffolder",
84
+ moduleId: "sentry",
85
+ register({ registerInit }) {
86
+ registerInit({
87
+ deps: {
88
+ scaffolder: alpha.scaffolderActionsExtensionPoint,
89
+ config: backendPluginApi.coreServices.rootConfig,
90
+ reade: backendPluginApi.coreServices.urlReader
91
+ },
92
+ async init({ scaffolder, config }) {
93
+ scaffolder.addActions(createSentryCreateProjectAction({ config }));
94
+ }
95
+ });
96
+ }
97
+ });
98
+
80
99
  exports.createSentryCreateProjectAction = createSentryCreateProjectAction;
100
+ exports["default"] = sentryModule;
81
101
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/actions/createProject.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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\n\n/**\n * Creates the `sentry:project:create` Scaffolder action.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/features/software-templates/writing-custom-actions}.\n *\n * @param options - Configuration of the Sentry API.\n * @public\n */\nexport function createSentryCreateProjectAction(options: { config: Config }) {\n const { config } = options;\n\n return createTemplateAction<{\n organizationSlug: string;\n teamSlug: string;\n name: string;\n slug?: string;\n authToken?: string;\n }>({\n id: 'sentry:project:create',\n schema: {\n input: {\n required: ['organizationSlug', 'teamSlug', 'name'],\n type: 'object',\n properties: {\n organizationSlug: {\n title: 'The slug of the organization the team belongs to',\n type: 'string',\n },\n teamSlug: {\n title: 'The slug of the team to create a new project for',\n type: 'string',\n },\n name: {\n title: 'The name for the new project',\n type: 'string',\n },\n slug: {\n title:\n 'Optional slug for the new project. If not provided a slug is generated from the name',\n type: 'string',\n },\n authToken: {\n title:\n 'authenticate via bearer auth token. Requires scope: project:write',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const { organizationSlug, teamSlug, name, slug, authToken } = ctx.input;\n\n const body: any = {\n name: name,\n };\n\n if (slug) {\n body.slug = slug;\n }\n\n const token = authToken\n ? authToken\n : config.getOptionalString('scaffolder.sentry.token');\n\n if (!token) {\n throw new InputError(`No valid sentry token given`);\n }\n\n const response = await fetch(\n `https://sentry.io/api/0/teams/${organizationSlug}/${teamSlug}/projects/`,\n {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n },\n );\n\n const contentType = response.headers.get('content-type');\n\n if (contentType !== 'application/json') {\n throw new InputError(\n `Unexpected Sentry Response Type: ${await response.text()}`,\n );\n }\n\n const code = response.status;\n const result = await response.json();\n\n if (code !== 201) {\n throw new InputError(`Sentry Response was: ${await result.detail}`);\n }\n\n ctx.output('id', result.id);\n ctx.output('result', result);\n },\n });\n}\n"],"names":["createTemplateAction","InputError"],"mappings":";;;;;;;AA8BO,SAAS,gCAAgC,OAA6B,EAAA;AAC3E,EAAM,MAAA,EAAE,QAAW,GAAA,OAAA,CAAA;AAEnB,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,uBAAA;AAAA,IACJ,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,QAAU,EAAA,CAAC,kBAAoB,EAAA,UAAA,EAAY,MAAM,CAAA;AAAA,QACjD,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,gBAAkB,EAAA;AAAA,YAChB,KAAO,EAAA,kDAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,QAAU,EAAA;AAAA,YACR,KAAO,EAAA,kDAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,8BAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,IAAM,EAAA;AAAA,YACJ,KACE,EAAA,sFAAA;AAAA,YACF,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,SAAW,EAAA;AAAA,YACT,KACE,EAAA,mEAAA;AAAA,YACF,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,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AI,SAAS,GAAK,EAAA;AAChB,QAAA,MAAM,IAAIA,iBAAW,CAAA,CAAA,qBAAA,EAAwB,MAAM,MAAA,CAAO,MAAM,CAAE,CAAA,CAAA,CAAA;AAAA,OACpE;AAEA,MAAI,GAAA,CAAA,MAAA,CAAO,IAAM,EAAA,MAAA,CAAO,EAAE,CAAA,CAAA;AAC1B,MAAI,GAAA,CAAA,MAAA,CAAO,UAAU,MAAM,CAAA,CAAA;AAAA,KAC7B;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/actions/createProject.ts","../src/module.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 { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { InputError } from '@backstage/errors';\nimport { Config } from '@backstage/config';\n\n/**\n * Creates the `sentry:project:create` Scaffolder action.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/features/software-templates/writing-custom-actions}.\n *\n * @param options - Configuration of the Sentry API.\n * @public\n */\nexport function createSentryCreateProjectAction(options: { config: Config }) {\n const { config } = options;\n\n return createTemplateAction<{\n organizationSlug: string;\n teamSlug: string;\n name: string;\n slug?: string;\n authToken?: string;\n }>({\n id: 'sentry:project:create',\n schema: {\n input: {\n required: ['organizationSlug', 'teamSlug', 'name'],\n type: 'object',\n properties: {\n organizationSlug: {\n title: 'The slug of the organization the team belongs to',\n type: 'string',\n },\n teamSlug: {\n title: 'The slug of the team to create a new project for',\n type: 'string',\n },\n name: {\n title: 'The name for the new project',\n type: 'string',\n },\n slug: {\n title:\n 'Optional slug for the new project. If not provided a slug is generated from the name',\n type: 'string',\n },\n authToken: {\n title:\n 'authenticate via bearer auth token. Requires scope: project:write',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const { organizationSlug, teamSlug, name, slug, authToken } = ctx.input;\n\n const body: any = {\n name: name,\n };\n\n if (slug) {\n body.slug = slug;\n }\n\n const token = authToken\n ? authToken\n : config.getOptionalString('scaffolder.sentry.token');\n\n if (!token) {\n throw new InputError(`No valid sentry token given`);\n }\n\n const response = await fetch(\n `https://sentry.io/api/0/teams/${organizationSlug}/${teamSlug}/projects/`,\n {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n },\n );\n\n const contentType = response.headers.get('content-type');\n\n if (contentType !== 'application/json') {\n throw new InputError(\n `Unexpected Sentry Response Type: ${await response.text()}`,\n );\n }\n\n const code = response.status;\n const result = await response.json();\n\n if (code !== 201) {\n throw new InputError(`Sentry Response was: ${await result.detail}`);\n }\n\n ctx.output('id', result.id);\n ctx.output('result', result);\n },\n });\n}\n","/*\n * Copyright 2024 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 */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport { createSentryCreateProjectAction } from './actions/createProject';\n\n/**\n * @public\n * The Sentry Module for the Scaffolder Backend\n */\nexport const sentryModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'sentry',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n config: coreServices.rootConfig,\n reade: coreServices.urlReader,\n },\n async init({ scaffolder, config }) {\n scaffolder.addActions(createSentryCreateProjectAction({ config }));\n },\n });\n },\n});\n"],"names":["createTemplateAction","InputError","createBackendModule","scaffolderActionsExtensionPoint","coreServices"],"mappings":";;;;;;;;;AA8BO,SAAS,gCAAgC,OAA6B,EAAA;AAC3E,EAAM,MAAA,EAAE,QAAW,GAAA,OAAA,CAAA;AAEnB,EAAA,OAAOA,yCAMJ,CAAA;AAAA,IACD,EAAI,EAAA,uBAAA;AAAA,IACJ,MAAQ,EAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,QAAU,EAAA,CAAC,kBAAoB,EAAA,UAAA,EAAY,MAAM,CAAA;AAAA,QACjD,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,gBAAkB,EAAA;AAAA,YAChB,KAAO,EAAA,kDAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,QAAU,EAAA;AAAA,YACR,KAAO,EAAA,kDAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,IAAM,EAAA;AAAA,YACJ,KAAO,EAAA,8BAAA;AAAA,YACP,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,IAAM,EAAA;AAAA,YACJ,KACE,EAAA,sFAAA;AAAA,YACF,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,UACA,SAAW,EAAA;AAAA,YACT,KACE,EAAA,mEAAA;AAAA,YACF,IAAM,EAAA,QAAA;AAAA,WACR;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,MAAM,EAAE,gBAAkB,EAAA,QAAA,EAAU,MAAM,IAAM,EAAA,SAAA,KAAc,GAAI,CAAA,KAAA,CAAA;AAElE,MAAA,MAAM,IAAY,GAAA;AAAA,QAChB,IAAA;AAAA,OACF,C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CAAO,IAAM,EAAA,MAAA,CAAO,EAAE,CAAA,CAAA;AAC1B,MAAI,GAAA,CAAA,MAAA,CAAO,UAAU,MAAM,CAAA,CAAA;AAAA,KAC7B;AAAA,GACD,CAAA,CAAA;AACH;;AC/FO,MAAM,eAAeC,oCAAoB,CAAA;AAAA,EAC9C,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,QAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAgB,EAAA;AACzB,IAAa,YAAA,CAAA;AAAA,MACX,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC,qCAAA;AAAA,QACZ,QAAQC,6BAAa,CAAA,UAAA;AAAA,QACrB,OAAOA,6BAAa,CAAA,SAAA;AAAA,OACtB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAY,QAAU,EAAA;AACjC,QAAA,UAAA,CAAW,UAAW,CAAA,+BAAA,CAAgC,EAAE,MAAA,EAAQ,CAAC,CAAA,CAAA;AAAA,OACnE;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
2
2
  import * as _backstage_types from '@backstage/types';
3
3
  import { Config } from '@backstage/config';
4
+ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
4
5
 
5
6
  /**
6
7
  * Creates the `sentry:project:create` Scaffolder action.
@@ -22,4 +23,10 @@ declare function createSentryCreateProjectAction(options: {
22
23
  authToken?: string | undefined;
23
24
  }, _backstage_types.JsonObject>;
24
25
 
25
- export { createSentryCreateProjectAction };
26
+ /**
27
+ * @public
28
+ * The Sentry Module for the Scaffolder Backend
29
+ */
30
+ declare const sentryModule: () => _backstage_backend_plugin_api.BackendFeature;
31
+
32
+ export { createSentryCreateProjectAction, sentryModule as default };
package/package.json CHANGED
@@ -1,17 +1,23 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-sentry",
3
- "version": "0.1.17",
4
- "main": "dist/index.cjs.js",
5
- "types": "dist/index.d.ts",
3
+ "version": "0.1.18-next.0",
4
+ "main": "./dist/index.cjs.js",
5
+ "types": "./dist/index.d.ts",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
8
- "access": "public",
9
- "main": "dist/index.cjs.js",
10
- "types": "dist/index.d.ts"
8
+ "access": "public"
11
9
  },
12
10
  "backstage": {
13
11
  "role": "backend-plugin-module"
14
12
  },
13
+ "exports": {
14
+ ".": {
15
+ "require": "./dist/index.cjs.js",
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.cjs.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
15
21
  "homepage": "https://backstage.io",
16
22
  "repository": {
17
23
  "type": "git",
@@ -28,14 +34,15 @@
28
34
  "postpack": "backstage-cli package postpack"
29
35
  },
30
36
  "dependencies": {
37
+ "@backstage/backend-plugin-api": "^0.6.10-next.0",
31
38
  "@backstage/config": "^1.1.1",
32
39
  "@backstage/errors": "^1.2.3",
33
- "@backstage/plugin-scaffolder-node": "^0.2.10",
40
+ "@backstage/plugin-scaffolder-node": "^0.3.0-next.0",
34
41
  "yaml": "^2.3.3"
35
42
  },
36
43
  "devDependencies": {
37
- "@backstage/backend-test-utils": "^0.2.10",
38
- "@backstage/cli": "^0.25.1",
44
+ "@backstage/backend-test-utils": "^0.3.0-next.0",
45
+ "@backstage/cli": "^0.25.2-next.0",
39
46
  "@backstage/types": "^1.1.1",
40
47
  "msw": "^2.0.0"
41
48
  },