@backstage/plugin-scaffolder-common 0.1.3 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # @backstage/plugin-scaffolder-common
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a4d53fe18e: **DEPRECATED** - The `TaskSpec.metadata` and `TaskSpec.baseUrl` has been deprecated in favour of the new `TaskSpec.templateInfo`.
8
+ The `baseUrl` is now found on the `templateInfo` object, and the name can be inferred from the `templateInfo.entityRef` property.
9
+
10
+ Usages of `TaskSpec.metadata.name` or `ctx.metadata.name` in Actions should migrate to using `parseEntityRef(taskSpec.templateInfo.entityRef)` to get the parsed entity triplet.
11
+
12
+ Usages of `ctx.baseUrl` in Actions should migrate to using `ctx.templateInfo.baseUrl` instead.
13
+
14
+ - Updated dependencies
15
+ - @backstage/catalog-model@0.11.0
16
+
17
+ ## 0.2.1
18
+
19
+ ### Patch Changes
20
+
21
+ - Fix for the previous release with missing type declarations.
22
+ - Updated dependencies
23
+ - @backstage/catalog-model@0.10.1
24
+ - @backstage/types@0.1.3
25
+
26
+ ## 0.2.0
27
+
28
+ ### Minor Changes
29
+
30
+ - 5e585bbc7f: **BREAKING**: Removed the `templateEntityV1beta3Schema` export
31
+
32
+ ### Patch Changes
33
+
34
+ - e72d371296: Added `TemplateEntityV1beta2` which was moved here from
35
+ `@backstage/plugin-scaffolder-common`. It has also been marked as deprecated in
36
+ the process - please consider [migrating to `v1beta3`
37
+ templates](https://backstage.io/docs/features/software-templates/migrating-from-v1beta2-to-v1beta3).
38
+ - c77c5c7eb6: Added `backstage.role` to `package.json`
39
+ - Updated dependencies
40
+ - @backstage/catalog-model@0.10.0
41
+ - @backstage/types@0.1.2
42
+
3
43
  ## 0.1.3
4
44
 
5
45
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -2,6 +2,236 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var catalogModel = require('@backstage/catalog-model');
6
+
7
+ var $schema$1 = "http://json-schema.org/draft-07/schema";
8
+ var $id$1 = "TemplateV1beta2";
9
+ var description$1 = "A Template describes a scaffolding task for use with the Scaffolder. It describes the required parameters as well as a series of steps that will be taken to execute the scaffolding task.";
10
+ var examples$1 = [
11
+ {
12
+ apiVersion: "backstage.io/v1beta2",
13
+ kind: "Template",
14
+ metadata: {
15
+ name: "react-ssr-template",
16
+ title: "React SSR Template",
17
+ description: "Next.js application skeleton for creating isomorphic web applications.",
18
+ tags: [
19
+ "recommended",
20
+ "react"
21
+ ]
22
+ },
23
+ spec: {
24
+ owner: "artist-relations-team",
25
+ type: "website",
26
+ parameters: {
27
+ required: [
28
+ "name",
29
+ "description"
30
+ ],
31
+ properties: {
32
+ name: {
33
+ title: "Name",
34
+ type: "string",
35
+ description: "Unique name of the component"
36
+ },
37
+ description: {
38
+ title: "Description",
39
+ type: "string",
40
+ description: "Description of the component"
41
+ }
42
+ }
43
+ },
44
+ steps: [
45
+ {
46
+ id: "fetch",
47
+ name: "Fetch",
48
+ action: "fetch:plain",
49
+ parameters: {
50
+ url: "./template"
51
+ }
52
+ },
53
+ {
54
+ id: "publish",
55
+ name: "Publish to GitHub",
56
+ action: "publish:github",
57
+ parameters: {
58
+ repoUrl: "{{ parameters.repoUrl }}"
59
+ },
60
+ "if": "{{ parameters.repoUrl }}"
61
+ }
62
+ ],
63
+ output: {
64
+ catalogInfoUrl: "{{ steps.publish.output.catalogInfoUrl }}"
65
+ }
66
+ }
67
+ }
68
+ ];
69
+ var allOf$1 = [
70
+ {
71
+ $ref: "Entity"
72
+ },
73
+ {
74
+ type: "object",
75
+ required: [
76
+ "spec"
77
+ ],
78
+ properties: {
79
+ apiVersion: {
80
+ "enum": [
81
+ "backstage.io/v1beta2"
82
+ ]
83
+ },
84
+ kind: {
85
+ "enum": [
86
+ "Template"
87
+ ]
88
+ },
89
+ spec: {
90
+ type: "object",
91
+ required: [
92
+ "type",
93
+ "steps"
94
+ ],
95
+ properties: {
96
+ type: {
97
+ type: "string",
98
+ description: "The type of component created by the template. The software catalog accepts any type value, but an organization should take great care to establish a proper taxonomy for these. Tools including Backstage itself may read this field and behave differently depending on its value. For example, a website type component may present tooling in the Backstage interface that is specific to just websites.",
99
+ examples: [
100
+ "service",
101
+ "website",
102
+ "library"
103
+ ],
104
+ minLength: 1
105
+ },
106
+ parameters: {
107
+ oneOf: [
108
+ {
109
+ type: "object",
110
+ description: "The JSONSchema describing the inputs for the template."
111
+ },
112
+ {
113
+ type: "array",
114
+ description: "A list of separate forms to collect parameters.",
115
+ items: {
116
+ type: "object",
117
+ description: "The JSONSchema describing the inputs for the template."
118
+ }
119
+ }
120
+ ]
121
+ },
122
+ steps: {
123
+ type: "array",
124
+ description: "A list of steps to execute.",
125
+ items: {
126
+ type: "object",
127
+ description: "A description of the step to execute.",
128
+ required: [
129
+ "action"
130
+ ],
131
+ properties: {
132
+ id: {
133
+ type: "string",
134
+ description: "The ID of the step, which can be used to refer to its outputs."
135
+ },
136
+ name: {
137
+ type: "string",
138
+ description: "The name of the step, which will be displayed in the UI during the scaffolding process."
139
+ },
140
+ action: {
141
+ type: "string",
142
+ description: "The name of the action to execute."
143
+ },
144
+ input: {
145
+ type: "object",
146
+ description: "A templated object describing the inputs to the action."
147
+ },
148
+ "if": {
149
+ type: [
150
+ "string",
151
+ "boolean"
152
+ ],
153
+ description: "A templated condition that skips the step when evaluated to false. If the condition is true or not defined, the step is executed. The condition is true, if the input is not `false`, `undefined`, `null`, `\"\"`, `0`, or `[]`."
154
+ }
155
+ }
156
+ }
157
+ },
158
+ output: {
159
+ type: "object",
160
+ description: "A templated object describing the outputs of the scaffolding task.",
161
+ properties: {
162
+ links: {
163
+ type: "array",
164
+ description: "A list of external hyperlinks, typically pointing to resources created or updated by the template",
165
+ items: {
166
+ type: "object",
167
+ required: [
168
+ ],
169
+ properties: {
170
+ url: {
171
+ type: "string",
172
+ description: "A url in a standard uri format.",
173
+ examples: [
174
+ "https://github.com/my-org/my-new-repo"
175
+ ],
176
+ minLength: 1
177
+ },
178
+ entityRef: {
179
+ type: "string",
180
+ description: "An entity reference to an entity in the catalog.",
181
+ examples: [
182
+ "Component:default/my-app"
183
+ ],
184
+ minLength: 1
185
+ },
186
+ title: {
187
+ type: "string",
188
+ description: "A user friendly display name for the link.",
189
+ examples: [
190
+ "View new repo"
191
+ ],
192
+ minLength: 1
193
+ },
194
+ icon: {
195
+ type: "string",
196
+ description: "A key representing a visual icon to be displayed in the UI.",
197
+ examples: [
198
+ "dashboard"
199
+ ],
200
+ minLength: 1
201
+ }
202
+ }
203
+ }
204
+ }
205
+ },
206
+ additionalProperties: {
207
+ type: "string"
208
+ }
209
+ },
210
+ owner: {
211
+ type: "string",
212
+ description: "The user (or group) owner of the template",
213
+ minLength: 1
214
+ }
215
+ }
216
+ }
217
+ }
218
+ }
219
+ ];
220
+ var schema$1 = {
221
+ $schema: $schema$1,
222
+ $id: $id$1,
223
+ description: description$1,
224
+ examples: examples$1,
225
+ allOf: allOf$1
226
+ };
227
+
228
+ const validator$1 = catalogModel.entityKindSchemaValidator(schema$1);
229
+ const templateEntityV1beta2Validator = {
230
+ async check(data) {
231
+ return validator$1(data) === data;
232
+ }
233
+ };
234
+
5
235
  var $schema = "http://json-schema.org/draft-07/schema";
6
236
  var $id = "TemplateV1beta3";
7
237
  var description = "A Template describes a scaffolding task for use with the Scaffolder. It describes the required parameters as well as a series of steps that will be taken to execute the scaffolding task.";
@@ -220,7 +450,7 @@ var allOf = [
220
450
  }
221
451
  }
222
452
  ];
223
- var v1beta3Schema = {
453
+ var schema = {
224
454
  $schema: $schema,
225
455
  $id: $id,
226
456
  description: description,
@@ -228,7 +458,13 @@ var v1beta3Schema = {
228
458
  allOf: allOf
229
459
  };
230
460
 
231
- const templateEntityV1beta3Schema = v1beta3Schema;
461
+ const validator = catalogModel.entityKindSchemaValidator(schema);
462
+ const templateEntityV1beta3Validator = {
463
+ async check(data) {
464
+ return validator(data) === data;
465
+ }
466
+ };
232
467
 
233
- exports.templateEntityV1beta3Schema = templateEntityV1beta3Schema;
468
+ exports.templateEntityV1beta2Validator = templateEntityV1beta2Validator;
469
+ exports.templateEntityV1beta3Validator = templateEntityV1beta3Validator;
234
470
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/index.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\n/**\n * Common functionalities for the scaffolder, to be shared between scaffolder and scaffolder-backend plugin\n *\n * @packageDocumentation\n */\n\nimport { JSONSchema } from '@backstage/catalog-model';\nimport v1beta3Schema from './Template.v1beta3.schema.json';\n\nexport type { TemplateEntityV1beta3 } from './TemplateEntityV1beta3';\n\n/** @public */\nexport const templateEntityV1beta3Schema: JSONSchema = v1beta3Schema as Omit<\n JSONSchema,\n 'examples'\n>;\n\nexport * from './TaskSpec';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4Ba,8BAA0C;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/TemplateEntityV1beta2.ts","../src/TemplateEntityV1beta3.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 {\n Entity,\n entityKindSchemaValidator,\n KindValidator,\n} from '@backstage/catalog-model';\nimport { JsonObject } from '@backstage/types';\nimport schema from './Template.v1beta2.schema.json';\n\n/**\n * Backstage catalog Template kind Entity. Templates are used by the Scaffolder\n * plugin to create new entities, such as Components.\n *\n * @public\n * @deprecated Please convert your templates to TemplateEntityV1beta3 on\n * apiVersion scaffolder.backstage.io/v1beta3\n */\nexport interface TemplateEntityV1beta2 extends Entity {\n apiVersion: 'backstage.io/v1beta2';\n kind: 'Template';\n spec: {\n type: string;\n parameters?: JsonObject | JsonObject[];\n steps: Array<{\n id?: string;\n name?: string;\n action: string;\n input?: JsonObject;\n if?: string | boolean;\n }>;\n output?: { [name: string]: string };\n owner?: string;\n };\n}\n\nconst validator = entityKindSchemaValidator(schema);\n\n/**\n * Entity data validator for {@link TemplateEntityV1beta2}.\n *\n * @public\n * @deprecated Please convert your templates to TemplateEntityV1beta3 on\n * apiVersion scaffolder.backstage.io/v1beta3\n */\nexport const templateEntityV1beta2Validator: KindValidator = {\n // TODO(freben): Emulate the old KindValidator until we fix that type\n async check(data: Entity) {\n return validator(data) === data;\n },\n};\n","/*\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 {\n Entity,\n entityKindSchemaValidator,\n KindValidator,\n} from '@backstage/catalog-model';\nimport { JsonObject } from '@backstage/types';\nimport schema from './Template.v1beta3.schema.json';\n\n/**\n * Backstage catalog Template kind Entity. Templates are used by the Scaffolder\n * plugin to create new entities, such as Components.\n *\n * @public\n */\nexport interface TemplateEntityV1beta3 extends Entity {\n apiVersion: 'scaffolder.backstage.io/v1beta3';\n kind: 'Template';\n spec: {\n type: string;\n parameters?: JsonObject | JsonObject[];\n steps: Array<{\n id?: string;\n name?: string;\n action: string;\n input?: JsonObject;\n if?: string | boolean;\n }>;\n output?: { [name: string]: string };\n owner?: string;\n };\n}\n\nconst validator = entityKindSchemaValidator(schema);\n\n/**\n * Entity data validator for {@link TemplateEntityV1beta3}.\n *\n * @public\n */\nexport const templateEntityV1beta3Validator: KindValidator = {\n // TODO(freben): Emulate the old KindValidator until we fix that type\n async check(data: Entity) {\n return validator(data) === data;\n },\n};\n"],"names":["validator","entityKindSchemaValidator","schema"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAMA,cAAYC,uCAA0BC;MAS/B,iCAAgD;AAAA,QAErD,MAAM,MAAc;AACxB,WAAOF,YAAU,UAAU;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACd/B,MAAM,YAAYC,uCAA0B;MAO/B,iCAAgD;AAAA,QAErD,MAAM,MAAc;AACxB,WAAO,UAAU,UAAU;AAAA;AAAA;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,37 +1,28 @@
1
- import { Entity, JSONSchema } from '@backstage/catalog-model';
2
1
  import { JsonObject, JsonValue } from '@backstage/types';
3
-
4
- /** @public */
5
- interface TemplateEntityV1beta3 extends Entity {
6
- apiVersion: 'scaffolder.backstage.io/v1beta3';
7
- kind: 'Template';
8
- spec: {
9
- type: string;
10
- parameters?: JsonObject | JsonObject[];
11
- steps: Array<{
12
- id?: string;
13
- name?: string;
14
- action: string;
15
- input?: JsonObject;
16
- if?: string | boolean;
17
- }>;
18
- output?: {
19
- [name: string]: string;
20
- };
21
- owner?: string;
22
- };
23
- }
2
+ import { Entity, KindValidator } from '@backstage/catalog-model';
24
3
 
25
4
  /**
26
- * TemplateMetadata
5
+ * Metadata about the Template that was the originator of a scaffolder task, as
6
+ * stored in the database.
27
7
  *
28
8
  * @public
9
+ * @deprecated use templateInfo on the spec instead
29
10
  */
30
11
  declare type TemplateMetadata = {
31
12
  name: string;
32
13
  };
33
14
  /**
34
- * TaskStep
15
+ * Information about a template that is stored on a task specification.
16
+ * Includes a stringified entityRef, and the baseUrl which is usually the relative path of the template definition
17
+ *
18
+ * @public
19
+ */
20
+ declare type TemplateInfo = {
21
+ entityRef: string;
22
+ baseUrl?: string;
23
+ };
24
+ /**
25
+ * An individual step of a scaffolder task, as stored in the database.
35
26
  *
36
27
  * @public
37
28
  */
@@ -43,49 +34,118 @@ interface TaskStep {
43
34
  if?: string | boolean;
44
35
  }
45
36
  /**
46
- * TaskSpecV1beta2
37
+ * A scaffolder task as stored in the database, generated from a v1beta2
38
+ * apiVersion Template.
47
39
  *
48
40
  * @public
41
+ * @deprecated Please convert your templates to TaskSpecV1beta3 on apiVersion
42
+ * scaffolder.backstage.io/v1beta3
49
43
  */
50
44
  interface TaskSpecV1beta2 {
51
45
  apiVersion: 'backstage.io/v1beta2';
46
+ /** @deprecated use templateInfo.baseUrl instead */
52
47
  baseUrl?: string;
53
48
  values: JsonObject;
54
49
  steps: TaskStep[];
55
50
  output: {
56
51
  [name: string]: string;
57
52
  };
53
+ /** @deprecated use templateInfo instead */
58
54
  metadata?: TemplateMetadata;
55
+ templateInfo?: TemplateInfo;
59
56
  }
60
57
  /**
61
- * TaskSpecV1beta3
58
+ * A scaffolder task as stored in the database, generated from a v1beta3
59
+ * apiVersion Template.
62
60
  *
63
61
  * @public
64
62
  */
65
63
  interface TaskSpecV1beta3 {
66
64
  apiVersion: 'scaffolder.backstage.io/v1beta3';
65
+ /** @deprecated use templateInfo.baseUrl instead */
67
66
  baseUrl?: string;
68
67
  parameters: JsonObject;
69
68
  steps: TaskStep[];
70
69
  output: {
71
70
  [name: string]: JsonValue;
72
71
  };
72
+ /** @deprecated use templateInfo instead */
73
73
  metadata?: TemplateMetadata;
74
+ templateInfo?: TemplateInfo;
74
75
  }
75
76
  /**
76
- * TaskSpec
77
+ * A scaffolder task as stored in the database, generated from a Template.
77
78
  *
78
79
  * @public
79
80
  */
80
81
  declare type TaskSpec = TaskSpecV1beta2 | TaskSpecV1beta3;
81
82
 
82
83
  /**
83
- * Common functionalities for the scaffolder, to be shared between scaffolder and scaffolder-backend plugin
84
+ * Backstage catalog Template kind Entity. Templates are used by the Scaffolder
85
+ * plugin to create new entities, such as Components.
86
+ *
87
+ * @public
88
+ * @deprecated Please convert your templates to TemplateEntityV1beta3 on
89
+ * apiVersion scaffolder.backstage.io/v1beta3
90
+ */
91
+ interface TemplateEntityV1beta2 extends Entity {
92
+ apiVersion: 'backstage.io/v1beta2';
93
+ kind: 'Template';
94
+ spec: {
95
+ type: string;
96
+ parameters?: JsonObject | JsonObject[];
97
+ steps: Array<{
98
+ id?: string;
99
+ name?: string;
100
+ action: string;
101
+ input?: JsonObject;
102
+ if?: string | boolean;
103
+ }>;
104
+ output?: {
105
+ [name: string]: string;
106
+ };
107
+ owner?: string;
108
+ };
109
+ }
110
+ /**
111
+ * Entity data validator for {@link TemplateEntityV1beta2}.
84
112
  *
85
- * @packageDocumentation
113
+ * @public
114
+ * @deprecated Please convert your templates to TemplateEntityV1beta3 on
115
+ * apiVersion scaffolder.backstage.io/v1beta3
86
116
  */
117
+ declare const templateEntityV1beta2Validator: KindValidator;
87
118
 
88
- /** @public */
89
- declare const templateEntityV1beta3Schema: JSONSchema;
119
+ /**
120
+ * Backstage catalog Template kind Entity. Templates are used by the Scaffolder
121
+ * plugin to create new entities, such as Components.
122
+ *
123
+ * @public
124
+ */
125
+ interface TemplateEntityV1beta3 extends Entity {
126
+ apiVersion: 'scaffolder.backstage.io/v1beta3';
127
+ kind: 'Template';
128
+ spec: {
129
+ type: string;
130
+ parameters?: JsonObject | JsonObject[];
131
+ steps: Array<{
132
+ id?: string;
133
+ name?: string;
134
+ action: string;
135
+ input?: JsonObject;
136
+ if?: string | boolean;
137
+ }>;
138
+ output?: {
139
+ [name: string]: string;
140
+ };
141
+ owner?: string;
142
+ };
143
+ }
144
+ /**
145
+ * Entity data validator for {@link TemplateEntityV1beta3}.
146
+ *
147
+ * @public
148
+ */
149
+ declare const templateEntityV1beta3Validator: KindValidator;
90
150
 
91
- export { TaskSpec, TaskSpecV1beta2, TaskSpecV1beta3, TaskStep, TemplateEntityV1beta3, TemplateMetadata, templateEntityV1beta3Schema };
151
+ export { TaskSpec, TaskSpecV1beta2, TaskSpecV1beta3, TaskStep, TemplateEntityV1beta2, TemplateEntityV1beta3, TemplateInfo, TemplateMetadata, templateEntityV1beta2Validator, templateEntityV1beta3Validator };
package/dist/index.esm.js CHANGED
@@ -1,3 +1,233 @@
1
+ import { entityKindSchemaValidator } from '@backstage/catalog-model';
2
+
3
+ var $schema$1 = "http://json-schema.org/draft-07/schema";
4
+ var $id$1 = "TemplateV1beta2";
5
+ var description$1 = "A Template describes a scaffolding task for use with the Scaffolder. It describes the required parameters as well as a series of steps that will be taken to execute the scaffolding task.";
6
+ var examples$1 = [
7
+ {
8
+ apiVersion: "backstage.io/v1beta2",
9
+ kind: "Template",
10
+ metadata: {
11
+ name: "react-ssr-template",
12
+ title: "React SSR Template",
13
+ description: "Next.js application skeleton for creating isomorphic web applications.",
14
+ tags: [
15
+ "recommended",
16
+ "react"
17
+ ]
18
+ },
19
+ spec: {
20
+ owner: "artist-relations-team",
21
+ type: "website",
22
+ parameters: {
23
+ required: [
24
+ "name",
25
+ "description"
26
+ ],
27
+ properties: {
28
+ name: {
29
+ title: "Name",
30
+ type: "string",
31
+ description: "Unique name of the component"
32
+ },
33
+ description: {
34
+ title: "Description",
35
+ type: "string",
36
+ description: "Description of the component"
37
+ }
38
+ }
39
+ },
40
+ steps: [
41
+ {
42
+ id: "fetch",
43
+ name: "Fetch",
44
+ action: "fetch:plain",
45
+ parameters: {
46
+ url: "./template"
47
+ }
48
+ },
49
+ {
50
+ id: "publish",
51
+ name: "Publish to GitHub",
52
+ action: "publish:github",
53
+ parameters: {
54
+ repoUrl: "{{ parameters.repoUrl }}"
55
+ },
56
+ "if": "{{ parameters.repoUrl }}"
57
+ }
58
+ ],
59
+ output: {
60
+ catalogInfoUrl: "{{ steps.publish.output.catalogInfoUrl }}"
61
+ }
62
+ }
63
+ }
64
+ ];
65
+ var allOf$1 = [
66
+ {
67
+ $ref: "Entity"
68
+ },
69
+ {
70
+ type: "object",
71
+ required: [
72
+ "spec"
73
+ ],
74
+ properties: {
75
+ apiVersion: {
76
+ "enum": [
77
+ "backstage.io/v1beta2"
78
+ ]
79
+ },
80
+ kind: {
81
+ "enum": [
82
+ "Template"
83
+ ]
84
+ },
85
+ spec: {
86
+ type: "object",
87
+ required: [
88
+ "type",
89
+ "steps"
90
+ ],
91
+ properties: {
92
+ type: {
93
+ type: "string",
94
+ description: "The type of component created by the template. The software catalog accepts any type value, but an organization should take great care to establish a proper taxonomy for these. Tools including Backstage itself may read this field and behave differently depending on its value. For example, a website type component may present tooling in the Backstage interface that is specific to just websites.",
95
+ examples: [
96
+ "service",
97
+ "website",
98
+ "library"
99
+ ],
100
+ minLength: 1
101
+ },
102
+ parameters: {
103
+ oneOf: [
104
+ {
105
+ type: "object",
106
+ description: "The JSONSchema describing the inputs for the template."
107
+ },
108
+ {
109
+ type: "array",
110
+ description: "A list of separate forms to collect parameters.",
111
+ items: {
112
+ type: "object",
113
+ description: "The JSONSchema describing the inputs for the template."
114
+ }
115
+ }
116
+ ]
117
+ },
118
+ steps: {
119
+ type: "array",
120
+ description: "A list of steps to execute.",
121
+ items: {
122
+ type: "object",
123
+ description: "A description of the step to execute.",
124
+ required: [
125
+ "action"
126
+ ],
127
+ properties: {
128
+ id: {
129
+ type: "string",
130
+ description: "The ID of the step, which can be used to refer to its outputs."
131
+ },
132
+ name: {
133
+ type: "string",
134
+ description: "The name of the step, which will be displayed in the UI during the scaffolding process."
135
+ },
136
+ action: {
137
+ type: "string",
138
+ description: "The name of the action to execute."
139
+ },
140
+ input: {
141
+ type: "object",
142
+ description: "A templated object describing the inputs to the action."
143
+ },
144
+ "if": {
145
+ type: [
146
+ "string",
147
+ "boolean"
148
+ ],
149
+ description: "A templated condition that skips the step when evaluated to false. If the condition is true or not defined, the step is executed. The condition is true, if the input is not `false`, `undefined`, `null`, `\"\"`, `0`, or `[]`."
150
+ }
151
+ }
152
+ }
153
+ },
154
+ output: {
155
+ type: "object",
156
+ description: "A templated object describing the outputs of the scaffolding task.",
157
+ properties: {
158
+ links: {
159
+ type: "array",
160
+ description: "A list of external hyperlinks, typically pointing to resources created or updated by the template",
161
+ items: {
162
+ type: "object",
163
+ required: [
164
+ ],
165
+ properties: {
166
+ url: {
167
+ type: "string",
168
+ description: "A url in a standard uri format.",
169
+ examples: [
170
+ "https://github.com/my-org/my-new-repo"
171
+ ],
172
+ minLength: 1
173
+ },
174
+ entityRef: {
175
+ type: "string",
176
+ description: "An entity reference to an entity in the catalog.",
177
+ examples: [
178
+ "Component:default/my-app"
179
+ ],
180
+ minLength: 1
181
+ },
182
+ title: {
183
+ type: "string",
184
+ description: "A user friendly display name for the link.",
185
+ examples: [
186
+ "View new repo"
187
+ ],
188
+ minLength: 1
189
+ },
190
+ icon: {
191
+ type: "string",
192
+ description: "A key representing a visual icon to be displayed in the UI.",
193
+ examples: [
194
+ "dashboard"
195
+ ],
196
+ minLength: 1
197
+ }
198
+ }
199
+ }
200
+ }
201
+ },
202
+ additionalProperties: {
203
+ type: "string"
204
+ }
205
+ },
206
+ owner: {
207
+ type: "string",
208
+ description: "The user (or group) owner of the template",
209
+ minLength: 1
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ ];
216
+ var schema$1 = {
217
+ $schema: $schema$1,
218
+ $id: $id$1,
219
+ description: description$1,
220
+ examples: examples$1,
221
+ allOf: allOf$1
222
+ };
223
+
224
+ const validator$1 = entityKindSchemaValidator(schema$1);
225
+ const templateEntityV1beta2Validator = {
226
+ async check(data) {
227
+ return validator$1(data) === data;
228
+ }
229
+ };
230
+
1
231
  var $schema = "http://json-schema.org/draft-07/schema";
2
232
  var $id = "TemplateV1beta3";
3
233
  var description = "A Template describes a scaffolding task for use with the Scaffolder. It describes the required parameters as well as a series of steps that will be taken to execute the scaffolding task.";
@@ -216,7 +446,7 @@ var allOf = [
216
446
  }
217
447
  }
218
448
  ];
219
- var v1beta3Schema = {
449
+ var schema = {
220
450
  $schema: $schema,
221
451
  $id: $id,
222
452
  description: description,
@@ -224,7 +454,12 @@ var v1beta3Schema = {
224
454
  allOf: allOf
225
455
  };
226
456
 
227
- const templateEntityV1beta3Schema = v1beta3Schema;
457
+ const validator = entityKindSchemaValidator(schema);
458
+ const templateEntityV1beta3Validator = {
459
+ async check(data) {
460
+ return validator(data) === data;
461
+ }
462
+ };
228
463
 
229
- export { templateEntityV1beta3Schema };
464
+ export { templateEntityV1beta2Validator, templateEntityV1beta3Validator };
230
465
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/index.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\n/**\n * Common functionalities for the scaffolder, to be shared between scaffolder and scaffolder-backend plugin\n *\n * @packageDocumentation\n */\n\nimport { JSONSchema } from '@backstage/catalog-model';\nimport v1beta3Schema from './Template.v1beta3.schema.json';\n\nexport type { TemplateEntityV1beta3 } from './TemplateEntityV1beta3';\n\n/** @public */\nexport const templateEntityV1beta3Schema: JSONSchema = v1beta3Schema as Omit<\n JSONSchema,\n 'examples'\n>;\n\nexport * from './TaskSpec';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4Ba,8BAA0C;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/TemplateEntityV1beta2.ts","../src/TemplateEntityV1beta3.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 {\n Entity,\n entityKindSchemaValidator,\n KindValidator,\n} from '@backstage/catalog-model';\nimport { JsonObject } from '@backstage/types';\nimport schema from './Template.v1beta2.schema.json';\n\n/**\n * Backstage catalog Template kind Entity. Templates are used by the Scaffolder\n * plugin to create new entities, such as Components.\n *\n * @public\n * @deprecated Please convert your templates to TemplateEntityV1beta3 on\n * apiVersion scaffolder.backstage.io/v1beta3\n */\nexport interface TemplateEntityV1beta2 extends Entity {\n apiVersion: 'backstage.io/v1beta2';\n kind: 'Template';\n spec: {\n type: string;\n parameters?: JsonObject | JsonObject[];\n steps: Array<{\n id?: string;\n name?: string;\n action: string;\n input?: JsonObject;\n if?: string | boolean;\n }>;\n output?: { [name: string]: string };\n owner?: string;\n };\n}\n\nconst validator = entityKindSchemaValidator(schema);\n\n/**\n * Entity data validator for {@link TemplateEntityV1beta2}.\n *\n * @public\n * @deprecated Please convert your templates to TemplateEntityV1beta3 on\n * apiVersion scaffolder.backstage.io/v1beta3\n */\nexport const templateEntityV1beta2Validator: KindValidator = {\n // TODO(freben): Emulate the old KindValidator until we fix that type\n async check(data: Entity) {\n return validator(data) === data;\n },\n};\n","/*\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 {\n Entity,\n entityKindSchemaValidator,\n KindValidator,\n} from '@backstage/catalog-model';\nimport { JsonObject } from '@backstage/types';\nimport schema from './Template.v1beta3.schema.json';\n\n/**\n * Backstage catalog Template kind Entity. Templates are used by the Scaffolder\n * plugin to create new entities, such as Components.\n *\n * @public\n */\nexport interface TemplateEntityV1beta3 extends Entity {\n apiVersion: 'scaffolder.backstage.io/v1beta3';\n kind: 'Template';\n spec: {\n type: string;\n parameters?: JsonObject | JsonObject[];\n steps: Array<{\n id?: string;\n name?: string;\n action: string;\n input?: JsonObject;\n if?: string | boolean;\n }>;\n output?: { [name: string]: string };\n owner?: string;\n };\n}\n\nconst validator = entityKindSchemaValidator(schema);\n\n/**\n * Entity data validator for {@link TemplateEntityV1beta3}.\n *\n * @public\n */\nexport const templateEntityV1beta3Validator: KindValidator = {\n // TODO(freben): Emulate the old KindValidator until we fix that type\n async check(data: Entity) {\n return validator(data) === data;\n },\n};\n"],"names":["validator","schema"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAMA,cAAY,0BAA0BC;MAS/B,iCAAgD;AAAA,QAErD,MAAM,MAAc;AACxB,WAAOD,YAAU,UAAU;AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACd/B,MAAM,YAAY,0BAA0B;MAO/B,iCAAgD;AAAA,QAErD,MAAM,MAAc;AACxB,WAAO,UAAU,UAAU;AAAA;AAAA;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-common",
3
3
  "description": "Common functionalities for the scaffolder, to be shared between scaffolder and scaffolder-backend plugin",
4
- "version": "0.1.3",
4
+ "version": "0.2.2",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -12,6 +12,9 @@
12
12
  "module": "dist/index.esm.js",
13
13
  "types": "dist/index.d.ts"
14
14
  },
15
+ "backstage": {
16
+ "role": "common-library"
17
+ },
15
18
  "homepage": "https://backstage.io",
16
19
  "repository": {
17
20
  "type": "git",
@@ -25,23 +28,23 @@
25
28
  "dist"
26
29
  ],
27
30
  "scripts": {
28
- "build": "backstage-cli build",
29
- "lint": "backstage-cli lint",
30
- "test": "backstage-cli test",
31
- "prepack": "backstage-cli prepack",
32
- "postpack": "backstage-cli postpack",
33
- "clean": "backstage-cli clean"
31
+ "build": "backstage-cli package build",
32
+ "lint": "backstage-cli package lint",
33
+ "test": "backstage-cli package test",
34
+ "prepack": "backstage-cli package prepack",
35
+ "postpack": "backstage-cli package postpack",
36
+ "clean": "backstage-cli package clean"
34
37
  },
35
38
  "bugs": {
36
39
  "url": "https://github.com/backstage/backstage/issues"
37
40
  },
38
41
  "dependencies": {
39
- "@backstage/catalog-model": "^0.9.10",
40
- "@backstage/types": "^0.1.1"
42
+ "@backstage/catalog-model": "^0.11.0",
43
+ "@backstage/types": "^0.1.3"
41
44
  },
42
45
  "devDependencies": {
43
- "@backstage/cli": "^0.12.0"
46
+ "@backstage/cli": "^0.14.1"
44
47
  },
45
- "gitHead": "600d6e3c854bbfb12a0078ca6f726d1c0d1fea0b",
48
+ "gitHead": "a15da6ea1e3e8adc37be98be064071c8b5279b4a",
46
49
  "module": "dist/index.esm.js"
47
50
  }