@backstage-community/plugin-scaffolder-backend-module-annotator 2.8.0 → 2.9.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 +6 -0
- package/dist/actions/annotator/annotator.cjs.js +14 -42
- package/dist/actions/annotator/annotator.cjs.js.map +1 -1
- package/dist/actions/customActions/createScaffoldedFromAction.cjs.js.map +1 -1
- package/dist/actions/customActions/createTimestampAction.cjs.js.map +1 -1
- package/dist/actions/customActions/createVersionAction.cjs.js.map +1 -1
- package/dist/index.d.ts +43 -55
- package/dist/module.cjs.js.map +1 -1
- package/dist/utils/resolveAnnotation.cjs.js.map +1 -1
- package/dist/utils/resolveSpec.cjs.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## @janus-idp/backstage-scaffolder-backend-module-annotator [1.3.0](https://github.com/janus-idp/backstage-plugins/compare/@janus-idp/backstage-scaffolder-backend-module-annotator@1.2.1...@janus-idp/backstage-scaffolder-backend-module-annotator@1.3.0) (2024-07-25)
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4b2153a: Backstage version bump to v1.41.1
|
|
8
|
+
|
|
3
9
|
## 2.8.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -36,48 +36,20 @@ const createAnnotatorAction = (actionId = "catalog:annotate", actionDescription,
|
|
|
36
36
|
description: actionDescription || "Creates a new scaffolder action to annotate the entity object with specified label(s), annotation(s) and spec property(ies).",
|
|
37
37
|
schema: {
|
|
38
38
|
input: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
description: "Key-Value pair(s) that will be applied to the `spec` of the entity object",
|
|
54
|
-
type: "object"
|
|
55
|
-
},
|
|
56
|
-
entityFilePath: {
|
|
57
|
-
title: "Entity File Path",
|
|
58
|
-
description: "Path to the entity yaml you want to annotate",
|
|
59
|
-
type: "string"
|
|
60
|
-
},
|
|
61
|
-
objectYaml: {
|
|
62
|
-
title: "Object Yaml",
|
|
63
|
-
description: "Entity object yaml you want to annotate",
|
|
64
|
-
type: "object"
|
|
65
|
-
},
|
|
66
|
-
writeToFile: {
|
|
67
|
-
title: "Write To File",
|
|
68
|
-
description: "Path to the file you want to write. Default path `./catalog-info.yaml`",
|
|
69
|
-
type: "string"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
output: {
|
|
74
|
-
type: "object",
|
|
75
|
-
properties: {
|
|
76
|
-
annotatedObject: {
|
|
77
|
-
type: "object",
|
|
78
|
-
title: "The entity object annotated with your desired annotation(s), label(s) and spec property(ies)"
|
|
79
|
-
}
|
|
80
|
-
}
|
|
39
|
+
labels: (z) => z.record(z.string(), z.string()).optional().describe(
|
|
40
|
+
"Labels that will be applied to the `metadata.labels` of the entity object"
|
|
41
|
+
),
|
|
42
|
+
annotations: (z) => z.record(z.string(), z.string()).optional().describe(
|
|
43
|
+
"Annotations that will be applied to the `metadata.annotations` of the entity object"
|
|
44
|
+
),
|
|
45
|
+
spec: (z) => z.record(z.string(), z.any()).optional().describe(
|
|
46
|
+
"Key-Value pair(s) that will be applied to the `spec` of the entity object"
|
|
47
|
+
),
|
|
48
|
+
entityFilePath: (z) => z.string().optional().describe("Path to the entity yaml you want to annotate"),
|
|
49
|
+
objectYaml: (z) => z.record(z.string(), z.any()).optional().describe("Entity object yaml you want to annotate"),
|
|
50
|
+
writeToFile: (z) => z.string().optional().describe(
|
|
51
|
+
"Path to the file you want to write. Default path `./catalog-info.yaml`"
|
|
52
|
+
)
|
|
81
53
|
}
|
|
82
54
|
},
|
|
83
55
|
async handler(ctx) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotator.cjs.js","sources":["../../../src/actions/annotator/annotator.ts"],"sourcesContent":["/*\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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport {\n createTemplateAction,\n TemplateExample,\n} from '@backstage/plugin-scaffolder-node';\n\nimport * as fs from 'fs-extra';\nimport * as yaml from 'yaml';\n\nimport { getObjectToAnnotate } from '../../utils/getObjectToAnnotate';\nimport { resolveSpec
|
|
1
|
+
{"version":3,"file":"annotator.cjs.js","sources":["../../../src/actions/annotator/annotator.ts"],"sourcesContent":["/*\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 { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport {\n createTemplateAction,\n TemplateExample,\n} from '@backstage/plugin-scaffolder-node';\n\nimport * as fs from 'fs-extra';\nimport * as yaml from 'yaml';\n\nimport { getObjectToAnnotate } from '../../utils/getObjectToAnnotate';\nimport { resolveSpec } from '../../utils/resolveSpec';\nimport { resolveAnnotation } from '../../utils/resolveAnnotation';\nimport { Value } from '../../types';\n\n/**\n * @public\n * Creates a new Scaffolder action to annotate an entity object with specified label(s), annotation(s) and spec property(ies).\n *\n */\nexport const createAnnotatorAction = (\n actionId: string = 'catalog:annotate',\n actionDescription?: string,\n loggerInfoMsg?: string,\n annotateEntityObjectProvider?: () => {\n annotations?: { [key: string]: Value };\n labels?: { [key: string]: string };\n spec?: { [key: string]: Value };\n },\n examples?: TemplateExample[],\n) => {\n return createTemplateAction({\n id: actionId,\n examples,\n description:\n actionDescription ||\n 'Creates a new scaffolder action to annotate the entity object with specified label(s), annotation(s) and spec property(ies).',\n schema: {\n input: {\n labels: z =>\n z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Labels that will be applied to the `metadata.labels` of the entity object',\n ),\n annotations: z =>\n z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Annotations that will be applied to the `metadata.annotations` of the entity object',\n ),\n spec: z =>\n z\n .record(z.string(), z.any())\n .optional()\n .describe(\n 'Key-Value pair(s) that will be applied to the `spec` of the entity object',\n ),\n entityFilePath: z =>\n z\n .string()\n .optional()\n .describe('Path to the entity yaml you want to annotate'),\n objectYaml: z =>\n z\n .record(z.string(), z.any())\n .optional()\n .describe('Entity object yaml you want to annotate'),\n writeToFile: z =>\n z\n .string()\n .optional()\n .describe(\n 'Path to the file you want to write. Default path `./catalog-info.yaml`',\n ),\n },\n },\n async handler(ctx) {\n const annotateEntityObject = annotateEntityObjectProvider?.();\n let objToAnnotate: { [key: string]: any };\n\n if (ctx.input?.objectYaml) {\n objToAnnotate = { ...ctx.input?.objectYaml };\n } else {\n objToAnnotate = await getObjectToAnnotate(\n ctx.workspacePath,\n ctx.input?.entityFilePath,\n );\n }\n const annotatedObj = {\n ...objToAnnotate,\n metadata: {\n ...objToAnnotate.metadata,\n annotations: {\n ...(objToAnnotate.metadata.annotations || {}),\n ...(annotateEntityObject?.annotations || {}),\n ...resolveAnnotation(annotateEntityObject?.annotations, ctx),\n ...(ctx.input?.annotations || {}),\n },\n labels: {\n ...(objToAnnotate.metadata.labels || {}),\n ...(annotateEntityObject?.labels || {}),\n ...(ctx.input?.labels || {}),\n },\n },\n spec: {\n ...(objToAnnotate.spec || {}),\n ...resolveSpec(annotateEntityObject?.spec, ctx),\n ...(ctx.input?.spec || {}),\n },\n };\n\n const result = yaml.stringify(annotatedObj);\n if (\n Object.keys(\n annotateEntityObject?.labels ||\n annotateEntityObject?.annotations ||\n annotateEntityObject?.spec ||\n ctx.input?.labels ||\n ctx.input?.annotations ||\n ctx.input?.spec ||\n {},\n ).length > 0\n ) {\n ctx.logger.info(loggerInfoMsg || 'Annotating your object');\n\n await fs.writeFile(\n resolveSafeChildPath(\n ctx.workspacePath,\n ctx.input?.writeToFile || './catalog-info.yaml',\n ),\n result,\n 'utf8',\n );\n }\n\n ctx.output('annotatedObject', result);\n },\n });\n};\n"],"names":["createTemplateAction","getObjectToAnnotate","resolveAnnotation","resolveSpec","yaml","fs","resolveSafeChildPath"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createScaffoldedFromAction.cjs.js","sources":["../../../src/actions/customActions/createScaffoldedFromAction.ts"],"sourcesContent":["/*\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 { createAnnotatorAction } from '../annotator/annotator';\nimport { examples } from './createScaffoldedFromAction.examples';\n\nexport const createScaffoldedFromAction = () => {\n return createAnnotatorAction(\n 'catalog:scaffolded-from',\n 'Creates a new `catalog:scaffolded-from` scaffolder action to update a catalog-info.yaml with the entityRef of the template that created it.',\n 'Annotating catalog-info.yaml with template entityRef',\n () => {\n return {\n spec: {\n scaffoldedFrom: { readFromContext: 'templateInfo.entityRef' },\n },\n };\n },\n examples,\n );\n};\n"],"names":["createAnnotatorAction","examples"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"createScaffoldedFromAction.cjs.js","sources":["../../../src/actions/customActions/createScaffoldedFromAction.ts"],"sourcesContent":["/*\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 { createAnnotatorAction } from '../annotator/annotator';\nimport { examples } from './createScaffoldedFromAction.examples';\n\n/**\n * @public\n */\nexport const createScaffoldedFromAction = () => {\n return createAnnotatorAction(\n 'catalog:scaffolded-from',\n 'Creates a new `catalog:scaffolded-from` scaffolder action to update a catalog-info.yaml with the entityRef of the template that created it.',\n 'Annotating catalog-info.yaml with template entityRef',\n () => {\n return {\n spec: {\n scaffoldedFrom: { readFromContext: 'templateInfo.entityRef' },\n },\n };\n },\n examples,\n );\n};\n"],"names":["createAnnotatorAction","examples"],"mappings":";;;;;AAqBO,MAAM,6BAA6B,MAAM;AAC9C,EAAO,OAAAA,+BAAA;AAAA,IACL,yBAAA;AAAA,IACA,6IAAA;AAAA,IACA,sDAAA;AAAA,IACA,MAAM;AACJ,MAAO,OAAA;AAAA,QACL,IAAM,EAAA;AAAA,UACJ,cAAA,EAAgB,EAAE,eAAA,EAAiB,wBAAyB;AAAA;AAC9D,OACF;AAAA,KACF;AAAA,IACAC;AAAA,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTimestampAction.cjs.js","sources":["../../../src/actions/customActions/createTimestampAction.ts"],"sourcesContent":["/*\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 { getCurrentTimestamp } from '../../utils/getCurrentTimestamp';\nimport { createAnnotatorAction } from '../annotator/annotator';\nimport { examples } from './createTimestampAction.examples';\n\nexport const createTimestampAction = () => {\n return createAnnotatorAction(\n 'catalog:timestamping',\n 'Creates a new `catalog:timestamping` Scaffolder action to annotate scaffolded entities with creation timestamp.',\n 'Annotating catalog-info.yaml with current timestamp',\n () => {\n return {\n annotations: { 'backstage.io/createdAt': getCurrentTimestamp() },\n };\n },\n examples,\n );\n};\n"],"names":["createAnnotatorAction","getCurrentTimestamp","examples"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"createTimestampAction.cjs.js","sources":["../../../src/actions/customActions/createTimestampAction.ts"],"sourcesContent":["/*\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 { getCurrentTimestamp } from '../../utils/getCurrentTimestamp';\nimport { createAnnotatorAction } from '../annotator/annotator';\nimport { examples } from './createTimestampAction.examples';\n\n/**\n * @public\n */\nexport const createTimestampAction = () => {\n return createAnnotatorAction(\n 'catalog:timestamping',\n 'Creates a new `catalog:timestamping` Scaffolder action to annotate scaffolded entities with creation timestamp.',\n 'Annotating catalog-info.yaml with current timestamp',\n () => {\n return {\n annotations: { 'backstage.io/createdAt': getCurrentTimestamp() },\n };\n },\n examples,\n );\n};\n"],"names":["createAnnotatorAction","getCurrentTimestamp","examples"],"mappings":";;;;;;AAsBO,MAAM,wBAAwB,MAAM;AACzC,EAAO,OAAAA,+BAAA;AAAA,IACL,sBAAA;AAAA,IACA,iHAAA;AAAA,IACA,qDAAA;AAAA,IACA,MAAM;AACJ,MAAO,OAAA;AAAA,QACL,WAAa,EAAA,EAAE,wBAA0B,EAAAC,uCAAA,EAAsB;AAAA,OACjE;AAAA,KACF;AAAA,IACAC;AAAA,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createVersionAction.cjs.js","sources":["../../../src/actions/customActions/createVersionAction.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 */\nimport { createAnnotatorAction } from '../annotator/annotator';\nimport { examples } from './createVersionAction.examples';\n\nexport const createVersionAction = () => {\n return createAnnotatorAction(\n 'catalog:template:version',\n 'Creates a new `catalog:template:version` scaffolder action to update a catalog-info.yaml with the versioning information from the scaffolder template',\n 'Annotating catalog-info.yaml with the version of the scaffolder template',\n () => {\n return {\n annotations: {\n 'backstage.io/template-version': {\n readFromContext: 'templateInfo.entity.metadata.annotations',\n },\n },\n };\n },\n examples,\n );\n};\n"],"names":["createAnnotatorAction","examples"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"createVersionAction.cjs.js","sources":["../../../src/actions/customActions/createVersionAction.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 */\nimport { createAnnotatorAction } from '../annotator/annotator';\nimport { examples } from './createVersionAction.examples';\n\n/**\n * @public\n */\nexport const createVersionAction = () => {\n return createAnnotatorAction(\n 'catalog:template:version',\n 'Creates a new `catalog:template:version` scaffolder action to update a catalog-info.yaml with the versioning information from the scaffolder template',\n 'Annotating catalog-info.yaml with the version of the scaffolder template',\n () => {\n return {\n annotations: {\n 'backstage.io/template-version': {\n readFromContext: 'templateInfo.entity.metadata.annotations',\n },\n },\n };\n },\n examples,\n );\n};\n"],"names":["createAnnotatorAction","examples"],"mappings":";;;;;AAqBO,MAAM,sBAAsB,MAAM;AACvC,EAAO,OAAAA,+BAAA;AAAA,IACL,0BAAA;AAAA,IACA,uJAAA;AAAA,IACA,0EAAA;AAAA,IACA,MAAM;AACJ,MAAO,OAAA;AAAA,QACL,WAAa,EAAA;AAAA,UACX,+BAAiC,EAAA;AAAA,YAC/B,eAAiB,EAAA;AAAA;AACnB;AACF,OACF;AAAA,KACF;AAAA,IACAC;AAAA,GACF;AACF;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
|
|
2
2
|
import { TemplateExample } from '@backstage/plugin-scaffolder-node';
|
|
3
|
-
import * as _backstage_types_index from '@backstage/types/index';
|
|
4
3
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
6
8
|
type Value = string | {
|
|
7
9
|
readFromContext: string;
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
/**
|
|
13
|
+
* @public
|
|
11
14
|
* Creates a new Scaffolder action to annotate an entity object with specified label(s), annotation(s) and spec property(ies).
|
|
12
15
|
*
|
|
13
16
|
*/
|
|
@@ -22,79 +25,64 @@ declare const createAnnotatorAction: (actionId?: string, actionDescription?: str
|
|
|
22
25
|
[key: string]: Value;
|
|
23
26
|
} | undefined;
|
|
24
27
|
}) | undefined, examples?: TemplateExample[]) => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
25
|
-
labels?:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
annotations?: {
|
|
29
|
-
[key: string]: string;
|
|
30
|
-
} | undefined;
|
|
31
|
-
spec?: {
|
|
32
|
-
[key: string]: string;
|
|
33
|
-
} | undefined;
|
|
28
|
+
labels?: Record<string, string> | undefined;
|
|
29
|
+
annotations?: Record<string, string> | undefined;
|
|
30
|
+
spec?: Record<string, any> | undefined;
|
|
34
31
|
entityFilePath?: string | undefined;
|
|
35
|
-
objectYaml?:
|
|
36
|
-
[key: string]: string;
|
|
37
|
-
} | undefined;
|
|
32
|
+
objectYaml?: Record<string, any> | undefined;
|
|
38
33
|
writeToFile?: string | undefined;
|
|
39
|
-
},
|
|
34
|
+
}, {
|
|
35
|
+
[x: string]: any;
|
|
36
|
+
}, "v2">;
|
|
40
37
|
|
|
38
|
+
/**
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
41
|
declare const createTimestampAction: () => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
42
|
-
labels?:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
annotations?: {
|
|
46
|
-
[key: string]: string;
|
|
47
|
-
} | undefined;
|
|
48
|
-
spec?: {
|
|
49
|
-
[key: string]: string;
|
|
50
|
-
} | undefined;
|
|
42
|
+
labels?: Record<string, string> | undefined;
|
|
43
|
+
annotations?: Record<string, string> | undefined;
|
|
44
|
+
spec?: Record<string, any> | undefined;
|
|
51
45
|
entityFilePath?: string | undefined;
|
|
52
|
-
objectYaml?:
|
|
53
|
-
[key: string]: string;
|
|
54
|
-
} | undefined;
|
|
46
|
+
objectYaml?: Record<string, any> | undefined;
|
|
55
47
|
writeToFile?: string | undefined;
|
|
56
|
-
},
|
|
48
|
+
}, {
|
|
49
|
+
[x: string]: any;
|
|
50
|
+
}, "v2">;
|
|
57
51
|
|
|
52
|
+
/**
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
58
55
|
declare const createScaffoldedFromAction: () => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
59
|
-
labels?:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
annotations?: {
|
|
63
|
-
[key: string]: string;
|
|
64
|
-
} | undefined;
|
|
65
|
-
spec?: {
|
|
66
|
-
[key: string]: string;
|
|
67
|
-
} | undefined;
|
|
56
|
+
labels?: Record<string, string> | undefined;
|
|
57
|
+
annotations?: Record<string, string> | undefined;
|
|
58
|
+
spec?: Record<string, any> | undefined;
|
|
68
59
|
entityFilePath?: string | undefined;
|
|
69
|
-
objectYaml?:
|
|
70
|
-
[key: string]: string;
|
|
71
|
-
} | undefined;
|
|
60
|
+
objectYaml?: Record<string, any> | undefined;
|
|
72
61
|
writeToFile?: string | undefined;
|
|
73
|
-
},
|
|
62
|
+
}, {
|
|
63
|
+
[x: string]: any;
|
|
64
|
+
}, "v2">;
|
|
74
65
|
|
|
66
|
+
/**
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
75
69
|
declare const createVersionAction: () => _backstage_plugin_scaffolder_node.TemplateAction<{
|
|
76
|
-
labels?:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
annotations?: {
|
|
80
|
-
[key: string]: string;
|
|
81
|
-
} | undefined;
|
|
82
|
-
spec?: {
|
|
83
|
-
[key: string]: string;
|
|
84
|
-
} | undefined;
|
|
70
|
+
labels?: Record<string, string> | undefined;
|
|
71
|
+
annotations?: Record<string, string> | undefined;
|
|
72
|
+
spec?: Record<string, any> | undefined;
|
|
85
73
|
entityFilePath?: string | undefined;
|
|
86
|
-
objectYaml?:
|
|
87
|
-
[key: string]: string;
|
|
88
|
-
} | undefined;
|
|
74
|
+
objectYaml?: Record<string, any> | undefined;
|
|
89
75
|
writeToFile?: string | undefined;
|
|
90
|
-
},
|
|
76
|
+
}, {
|
|
77
|
+
[x: string]: any;
|
|
78
|
+
}, "v2">;
|
|
91
79
|
|
|
92
80
|
/***/
|
|
93
81
|
/**
|
|
94
|
-
* The annotator module for
|
|
82
|
+
* The annotator module for \@backstage/plugin-scaffolder-backend.
|
|
95
83
|
*
|
|
96
84
|
* @alpha
|
|
97
85
|
*/
|
|
98
86
|
declare const scaffolderCustomActionsScaffolderModule: _backstage_backend_plugin_api.BackendFeature;
|
|
99
87
|
|
|
100
|
-
export { createAnnotatorAction, createScaffoldedFromAction, createTimestampAction, createVersionAction, scaffolderCustomActionsScaffolderModule as default };
|
|
88
|
+
export { type Value, createAnnotatorAction, createScaffoldedFromAction, createTimestampAction, createVersionAction, scaffolderCustomActionsScaffolderModule as default };
|
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\n\nimport {\n createAnnotatorAction,\n createScaffoldedFromAction,\n createTimestampAction,\n createVersionAction,\n} from './actions';\n\n/***/\n/**\n * The annotator module for
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\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 { createBackendModule } from '@backstage/backend-plugin-api';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\n\nimport {\n createAnnotatorAction,\n createScaffoldedFromAction,\n createTimestampAction,\n createVersionAction,\n} from './actions';\n\n/***/\n/**\n * The annotator module for \\@backstage/plugin-scaffolder-backend.\n *\n * @alpha\n */\nexport const scaffolderCustomActionsScaffolderModule = createBackendModule({\n moduleId: 'scaffolder-backend-scaffolder-annotator',\n pluginId: 'scaffolder',\n register(env) {\n env.registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n },\n async init({ scaffolder }) {\n scaffolder.addActions(createScaffoldedFromAction());\n scaffolder.addActions(createTimestampAction());\n scaffolder.addActions(createAnnotatorAction());\n scaffolder.addActions(createVersionAction());\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","createScaffoldedFromAction","createTimestampAction","createAnnotatorAction","createVersionAction"],"mappings":";;;;;;;;;AA+BO,MAAM,0CAA0CA,oCAAoB,CAAA;AAAA,EACzE,QAAU,EAAA,yCAAA;AAAA,EACV,QAAU,EAAA,YAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,UAAY,EAAAC;AAAA,OACd;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAc,EAAA;AACzB,QAAW,UAAA,CAAA,UAAA,CAAWC,uDAA4B,CAAA;AAClD,QAAW,UAAA,CAAA,UAAA,CAAWC,6CAAuB,CAAA;AAC7C,QAAW,UAAA,CAAA,UAAA,CAAWC,iCAAuB,CAAA;AAC7C,QAAW,UAAA,CAAA,UAAA,CAAWC,yCAAqB,CAAA;AAAA;AAC7C,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAnnotation.cjs.js","sources":["../../src/utils/resolveAnnotation.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 */\nimport type { ActionContext } from '@backstage/plugin-scaffolder-node';\n\nimport { get } from 'lodash';\nimport { Value } from '
|
|
1
|
+
{"version":3,"file":"resolveAnnotation.cjs.js","sources":["../../src/utils/resolveAnnotation.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 */\nimport type { ActionContext } from '@backstage/plugin-scaffolder-node';\n\nimport { get } from 'lodash';\nimport { Value } from '../types';\n\nexport const resolveAnnotation = (\n annotation: { [key: string]: Value } | undefined,\n ctx: ActionContext<any>,\n) => {\n if (!annotation || Object.keys(annotation).length === 0) {\n return {};\n }\n return Object.keys(annotation).reduce((acc, s) => {\n const val = annotation[s];\n return {\n ...acc,\n ...{\n [`${s}`]:\n typeof val === 'string'\n ? annotation[s]\n : get(ctx, val.readFromContext)!['backstage.io/template-version'],\n },\n };\n }, {});\n};\n"],"names":["get"],"mappings":";;;;AAoBa,MAAA,iBAAA,GAAoB,CAC/B,UAAA,EACA,GACG,KAAA;AACH,EAAA,IAAI,CAAC,UAAc,IAAA,MAAA,CAAO,KAAK,UAAU,CAAA,CAAE,WAAW,CAAG,EAAA;AACvD,IAAA,OAAO,EAAC;AAAA;AAEV,EAAA,OAAO,OAAO,IAAK,CAAA,UAAU,EAAE,MAAO,CAAA,CAAC,KAAK,CAAM,KAAA;AAChD,IAAM,MAAA,GAAA,GAAM,WAAW,CAAC,CAAA;AACxB,IAAO,OAAA;AAAA,MACL,GAAG,GAAA;AAAA,MACH,GAAG;AAAA,QACD,CAAC,CAAG,EAAA,CAAC,CAAE,CAAA,GACL,OAAO,GAAQ,KAAA,QAAA,GACX,UAAW,CAAA,CAAC,IACZA,UAAI,CAAA,GAAA,EAAK,GAAI,CAAA,eAAe,EAAG,+BAA+B;AAAA;AACtE,KACF;AAAA,GACF,EAAG,EAAE,CAAA;AACP;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveSpec.cjs.js","sources":["../../src/utils/resolveSpec.ts"],"sourcesContent":["/*\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 type { ActionContext } from '@backstage/plugin-scaffolder-node';\n\nimport { get } from 'lodash';\
|
|
1
|
+
{"version":3,"file":"resolveSpec.cjs.js","sources":["../../src/utils/resolveSpec.ts"],"sourcesContent":["/*\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 type { ActionContext } from '@backstage/plugin-scaffolder-node';\n\nimport { get } from 'lodash';\nimport { Value } from '../types';\n\nexport const resolveSpec = (\n spec: { [key: string]: Value } | undefined,\n ctx: ActionContext<any>,\n) => {\n if (!spec || Object.keys(spec).length === 0) {\n return {};\n }\n return Object.keys(spec).reduce((acc, s) => {\n const val = spec[s];\n return {\n ...acc,\n ...{\n [`${s}`]:\n typeof val === 'string' ? spec[s] : get(ctx, val.readFromContext),\n },\n };\n }, {});\n};\n"],"names":["get"],"mappings":";;;;AAoBa,MAAA,WAAA,GAAc,CACzB,IAAA,EACA,GACG,KAAA;AACH,EAAA,IAAI,CAAC,IAAQ,IAAA,MAAA,CAAO,KAAK,IAAI,CAAA,CAAE,WAAW,CAAG,EAAA;AAC3C,IAAA,OAAO,EAAC;AAAA;AAEV,EAAA,OAAO,OAAO,IAAK,CAAA,IAAI,EAAE,MAAO,CAAA,CAAC,KAAK,CAAM,KAAA;AAC1C,IAAM,MAAA,GAAA,GAAM,KAAK,CAAC,CAAA;AAClB,IAAO,OAAA;AAAA,MACL,GAAG,GAAA;AAAA,MACH,GAAG;AAAA,QACD,CAAC,CAAA,EAAG,CAAC,CAAA,CAAE,GACL,OAAO,GAAA,KAAQ,QAAW,GAAA,IAAA,CAAK,CAAC,CAAA,GAAIA,UAAI,CAAA,GAAA,EAAK,IAAI,eAAe;AAAA;AACpE,KACF;AAAA,GACF,EAAG,EAAE,CAAA;AACP;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-scaffolder-backend-module-annotator",
|
|
3
3
|
"description": "The annotator module for @backstage/plugin-scaffolder-backend",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.9.0",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -47,16 +47,16 @@
|
|
|
47
47
|
"prettier:fix": "prettier --ignore-unknown --write ."
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@backstage/backend-plugin-api": "^1.
|
|
51
|
-
"@backstage/plugin-scaffolder-node": "^0.
|
|
50
|
+
"@backstage/backend-plugin-api": "^1.4.1",
|
|
51
|
+
"@backstage/plugin-scaffolder-node": "^0.10.0",
|
|
52
52
|
"fs-extra": "^11.2.0",
|
|
53
53
|
"lodash": "^4.17.21",
|
|
54
54
|
"yaml": "^2.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@backstage/backend-test-utils": "^1.
|
|
58
|
-
"@backstage/cli": "^0.
|
|
59
|
-
"@backstage/plugin-scaffolder-node-test-utils": "^0.
|
|
57
|
+
"@backstage/backend-test-utils": "^1.7.0",
|
|
58
|
+
"@backstage/cli": "^0.33.1",
|
|
59
|
+
"@backstage/plugin-scaffolder-node-test-utils": "^0.3.1",
|
|
60
60
|
"@types/fs-extra": "^11.0.4",
|
|
61
61
|
"@types/lodash": "^4.17.13"
|
|
62
62
|
},
|