@backstage/plugin-scaffolder-node 0.6.2 → 0.6.3-next.1

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,31 @@
1
1
  # @backstage/plugin-scaffolder-node
2
2
 
3
+ ## 0.6.3-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/types@1.2.1-next.0
9
+ - @backstage/backend-plugin-api@1.1.1-next.1
10
+ - @backstage/catalog-model@1.7.3-next.0
11
+ - @backstage/errors@1.2.7-next.0
12
+ - @backstage/plugin-scaffolder-common@1.5.9-next.0
13
+ - @backstage/integration@1.16.1-next.0
14
+
15
+ ## 0.6.3-next.0
16
+
17
+ ### Patch Changes
18
+
19
+ - 5d9e5c8: Added the ability to use `${{ context.task.id }}` in nunjucks templating, as well as `ctx.task.id` in actions to get the current task ID.
20
+ - 7dd0013: Deprecate the `logStream` option in `executeShellCommand`, replacing it with a logger instance.
21
+ - Updated dependencies
22
+ - @backstage/backend-plugin-api@1.1.1-next.0
23
+ - @backstage/catalog-model@1.7.2
24
+ - @backstage/errors@1.2.6
25
+ - @backstage/integration@1.16.0
26
+ - @backstage/types@1.2.0
27
+ - @backstage/plugin-scaffolder-common@1.5.8
28
+
3
29
  ## 0.6.2
4
30
 
5
31
  ### Patch Changes
@@ -8,15 +8,22 @@ async function executeShellCommand(options) {
8
8
  command,
9
9
  args,
10
10
  options: spawnOptions,
11
+ logger,
11
12
  logStream = new stream.PassThrough()
12
13
  } = options;
13
14
  await new Promise((resolve, reject) => {
14
15
  const process = child_process.spawn(command, args, spawnOptions);
15
- process.stdout.on("data", (stream) => {
16
- logStream.write(stream);
16
+ process.stdout.on("data", (chunk) => {
17
+ logStream?.write(chunk);
18
+ logger?.info(
19
+ Buffer.isBuffer(chunk) ? chunk.toString("utf8").trim() : chunk.trim()
20
+ );
17
21
  });
18
- process.stderr.on("data", (stream) => {
19
- logStream.write(stream);
22
+ process.stderr.on("data", (chunk) => {
23
+ logStream?.write(chunk);
24
+ logger?.error(
25
+ Buffer.isBuffer(chunk) ? chunk.toString("utf8").trim() : chunk.trim()
26
+ );
20
27
  });
21
28
  process.on("error", (error) => {
22
29
  return reject(error);
@@ -1 +1 @@
1
- {"version":3,"file":"executeShellCommand.cjs.js","sources":["../../src/actions/executeShellCommand.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { spawn, SpawnOptionsWithoutStdio } from 'child_process';\nimport { PassThrough, Writable } from 'stream';\n\n/**\n * Options for {@link executeShellCommand}.\n *\n * @public\n */\nexport type ExecuteShellCommandOptions = {\n /** command to run */\n command: string;\n /** arguments to pass the command */\n args: string[];\n /** options to pass to spawn */\n options?: SpawnOptionsWithoutStdio;\n /** stream to capture stdout and stderr output */\n logStream?: Writable;\n};\n\n/**\n * Run a command in a sub-process, normally a shell command.\n *\n * @public\n */\nexport async function executeShellCommand(\n options: ExecuteShellCommandOptions,\n): Promise<void> {\n const {\n command,\n args,\n options: spawnOptions,\n logStream = new PassThrough(),\n } = options;\n\n await new Promise<void>((resolve, reject) => {\n const process = spawn(command, args, spawnOptions);\n\n process.stdout.on('data', stream => {\n logStream.write(stream);\n });\n\n process.stderr.on('data', stream => {\n logStream.write(stream);\n });\n\n process.on('error', error => {\n return reject(error);\n });\n\n process.on('close', code => {\n if (code !== 0) {\n return reject(\n new Error(`Command ${command} failed, exit code: ${code}`),\n );\n }\n return resolve();\n });\n });\n}\n"],"names":["PassThrough","spawn"],"mappings":";;;;;AAwCA,eAAsB,oBACpB,OACe,EAAA;AACf,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAS,EAAA,YAAA;AAAA,IACT,SAAA,GAAY,IAAIA,kBAAY;AAAA,GAC1B,GAAA,OAAA;AAEJ,EAAA,MAAM,IAAI,OAAA,CAAc,CAAC,OAAA,EAAS,MAAW,KAAA;AAC3C,IAAA,MAAM,OAAU,GAAAC,mBAAA,CAAM,OAAS,EAAA,IAAA,EAAM,YAAY,CAAA;AAEjD,IAAQ,OAAA,CAAA,MAAA,CAAO,EAAG,CAAA,MAAA,EAAQ,CAAU,MAAA,KAAA;AAClC,MAAA,SAAA,CAAU,MAAM,MAAM,CAAA;AAAA,KACvB,CAAA;AAED,IAAQ,OAAA,CAAA,MAAA,CAAO,EAAG,CAAA,MAAA,EAAQ,CAAU,MAAA,KAAA;AAClC,MAAA,SAAA,CAAU,MAAM,MAAM,CAAA;AAAA,KACvB,CAAA;AAED,IAAQ,OAAA,CAAA,EAAA,CAAG,SAAS,CAAS,KAAA,KAAA;AAC3B,MAAA,OAAO,OAAO,KAAK,CAAA;AAAA,KACpB,CAAA;AAED,IAAQ,OAAA,CAAA,EAAA,CAAG,SAAS,CAAQ,IAAA,KAAA;AAC1B,MAAA,IAAI,SAAS,CAAG,EAAA;AACd,QAAO,OAAA,MAAA;AAAA,UACL,IAAI,KAAM,CAAA,CAAA,QAAA,EAAW,OAAO,CAAA,oBAAA,EAAuB,IAAI,CAAE,CAAA;AAAA,SAC3D;AAAA;AAEF,MAAA,OAAO,OAAQ,EAAA;AAAA,KAChB,CAAA;AAAA,GACF,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"executeShellCommand.cjs.js","sources":["../../src/actions/executeShellCommand.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { spawn, SpawnOptionsWithoutStdio } from 'child_process';\nimport { PassThrough, Writable } from 'stream';\n\n/**\n * Options for {@link executeShellCommand}.\n *\n * @public\n */\nexport type ExecuteShellCommandOptions = {\n /** command to run */\n command: string;\n /** arguments to pass the command */\n args: string[];\n /** options to pass to spawn */\n options?: SpawnOptionsWithoutStdio;\n /** logger to capture stdout and stderr output */\n logger?: LoggerService;\n /**\n * stream to capture stdout and stderr output\n * @deprecated please provide a logger instead.\n */\n logStream?: Writable;\n};\n\n/**\n * Run a command in a sub-process, normally a shell command.\n *\n * @public\n */\nexport async function executeShellCommand(\n options: ExecuteShellCommandOptions,\n): Promise<void> {\n const {\n command,\n args,\n options: spawnOptions,\n logger,\n logStream = new PassThrough(),\n } = options;\n\n await new Promise<void>((resolve, reject) => {\n const process = spawn(command, args, spawnOptions);\n\n process.stdout.on('data', chunk => {\n logStream?.write(chunk);\n logger?.info(\n Buffer.isBuffer(chunk) ? chunk.toString('utf8').trim() : chunk.trim(),\n );\n });\n process.stderr.on('data', chunk => {\n logStream?.write(chunk);\n logger?.error(\n Buffer.isBuffer(chunk) ? chunk.toString('utf8').trim() : chunk.trim(),\n );\n });\n process.on('error', error => {\n return reject(error);\n });\n\n process.on('close', code => {\n if (code !== 0) {\n return reject(\n new Error(`Command ${command} failed, exit code: ${code}`),\n );\n }\n return resolve();\n });\n });\n}\n"],"names":["PassThrough","spawn"],"mappings":";;;;;AA8CA,eAAsB,oBACpB,OACe,EAAA;AACf,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAS,EAAA,YAAA;AAAA,IACT,MAAA;AAAA,IACA,SAAA,GAAY,IAAIA,kB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
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Logger } from 'winston';
3
3
  import { Writable } from 'stream';
4
4
  import { JsonObject, JsonValue, Observable } from '@backstage/types';
5
- import { BackstageCredentials, UrlReaderService } from '@backstage/backend-plugin-api';
5
+ import { BackstageCredentials, LoggerService, UrlReaderService } from '@backstage/backend-plugin-api';
6
6
  import { TaskSpec, TemplateInfo } from '@backstage/plugin-scaffolder-common';
7
7
  import { UserEntity } from '@backstage/catalog-model';
8
8
  import { Schema } from 'jsonschema';
@@ -194,6 +194,12 @@ type ActionContext<TActionInput extends JsonObject, TActionOutput extends JsonOb
194
194
  * Get the credentials for the current request
195
195
  */
196
196
  getInitiatorCredentials(): Promise<BackstageCredentials>;
197
+ /**
198
+ * Task information
199
+ */
200
+ task: {
201
+ id: string;
202
+ };
197
203
  templateInfo?: TemplateInfo;
198
204
  /**
199
205
  * Whether this action invocation is a dry-run or not.
@@ -274,7 +280,12 @@ type ExecuteShellCommandOptions = {
274
280
  args: string[];
275
281
  /** options to pass to spawn */
276
282
  options?: SpawnOptionsWithoutStdio;
277
- /** stream to capture stdout and stderr output */
283
+ /** logger to capture stdout and stderr output */
284
+ logger?: LoggerService;
285
+ /**
286
+ * stream to capture stdout and stderr output
287
+ * @deprecated please provide a logger instead.
288
+ */
278
289
  logStream?: Writable;
279
290
  };
280
291
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-node",
3
- "version": "0.6.2",
3
+ "version": "0.6.3-next.1",
4
4
  "description": "The plugin-scaffolder-node module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "node-library",
@@ -63,12 +63,12 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@backstage/backend-common": "^0.25.0",
66
- "@backstage/backend-plugin-api": "^1.1.0",
67
- "@backstage/catalog-model": "^1.7.2",
68
- "@backstage/errors": "^1.2.6",
69
- "@backstage/integration": "^1.16.0",
70
- "@backstage/plugin-scaffolder-common": "^1.5.8",
71
- "@backstage/types": "^1.2.0",
66
+ "@backstage/backend-plugin-api": "1.1.1-next.1",
67
+ "@backstage/catalog-model": "1.7.3-next.0",
68
+ "@backstage/errors": "1.2.7-next.0",
69
+ "@backstage/integration": "1.16.1-next.0",
70
+ "@backstage/plugin-scaffolder-common": "1.5.9-next.0",
71
+ "@backstage/types": "1.2.1-next.0",
72
72
  "concat-stream": "^2.0.0",
73
73
  "fs-extra": "^11.2.0",
74
74
  "globby": "^11.0.0",
@@ -81,8 +81,8 @@
81
81
  "zod-to-json-schema": "^3.20.4"
82
82
  },
83
83
  "devDependencies": {
84
- "@backstage/backend-test-utils": "^1.2.0",
85
- "@backstage/cli": "^0.29.4",
86
- "@backstage/config": "^1.3.1"
84
+ "@backstage/backend-test-utils": "1.2.1-next.1",
85
+ "@backstage/cli": "0.29.5-next.1",
86
+ "@backstage/config": "1.3.2-next.0"
87
87
  }
88
88
  }