🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@backstage/cli-node

Package Overview
Dependencies
Maintainers
3
Versions
528
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backstage/cli-node - npm Package Compare versions

Comparing version
0.0.0-nightly-20260407031731
to
0.0.0-nightly-20260408031702
+13
-3
CHANGELOG.md
# @backstage/cli-node
## 0.0.0-nightly-20260407031731
## 0.0.0-nightly-20260408031702
### Patch Changes
- 482ceed: Migrated from `assertError` to `toError` for error handling.
- Updated dependencies
- @backstage/cli-common@0.0.0-nightly-20260407031731
- @backstage/errors@1.2.7
- @backstage/errors@0.0.0-nightly-20260408031702
- @backstage/cli-common@0.0.0-nightly-20260408031702
- @backstage/types@1.2.2
## 0.3.1-next.1
### Patch Changes
- 482ceed: Migrated from `assertError` to `toError` for error handling.
- Updated dependencies
- @backstage/errors@1.3.0-next.0
- @backstage/cli-common@0.2.1-next.1
## 0.3.1-next.0

@@ -13,0 +23,0 @@

+4
-4

@@ -13,6 +13,6 @@ 'use strict';

} catch (error) {
errors.assertError(error);
if ("code" in error && typeof error.code === "number") {
const code = error.code;
const stderr = error.stderr;
const err = errors.toError(error);
if ("code" in err && typeof err.code === "number") {
const code = err.code;
const stderr = err.stderr;
const msg = stderr?.trim() ?? `with exit code ${code}`;

@@ -19,0 +19,0 @@ throw new Error(`git ${args[0]} failed, ${msg}`);

@@ -1,1 +0,1 @@

{"version":3,"file":"GitUtils.cjs.js","sources":["../../src/git/GitUtils.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { assertError, ForwardedError } from '@backstage/errors';\nimport { targetPaths } from '@backstage/cli-common';\nimport { runOutput } from '@backstage/cli-common';\n\n/**\n * Run a git command, trimming the output splitting it into lines.\n */\nexport async function runGit(...args: string[]) {\n try {\n const stdout = await runOutput(['git', ...args], {\n cwd: targetPaths.rootDir,\n });\n return stdout.trim().split(/\\r\\n|\\r|\\n/);\n } catch (error) {\n assertError(error);\n if (\n 'code' in error &&\n typeof (error as { code?: number }).code === 'number'\n ) {\n const code = (error as { code?: number }).code;\n const stderr = (error as { stderr?: string }).stderr;\n const msg = stderr?.trim() ?? `with exit code ${code}`;\n throw new Error(`git ${args[0]} failed, ${msg}`);\n }\n throw new ForwardedError('Unknown execution error', error);\n }\n}\n\n/**\n * Utilities for working with git.\n *\n * @public\n */\nexport class GitUtils {\n /**\n * Returns a sorted list of all files that have changed since the merge base\n * of the provided `ref` and HEAD, as well as all files that are not tracked by git.\n */\n static async listChangedFiles(ref: string) {\n if (!ref) {\n throw new Error('ref is required');\n }\n\n let diffRef = ref;\n try {\n const [base] = await runGit('merge-base', 'HEAD', ref);\n diffRef = base;\n } catch {\n // silently fall back to using the ref directly if merge base is not available\n }\n\n const tracked = await runGit('diff', '--name-only', diffRef);\n const untracked = await runGit(\n 'ls-files',\n '--others',\n '--exclude-standard',\n );\n\n return Array.from(new Set([...tracked, ...untracked]));\n }\n\n /**\n * Returns the contents of a file at a specific ref.\n */\n static async readFileAtRef(path: string, ref: string) {\n let showRef = ref;\n try {\n const [base] = await runGit('merge-base', 'HEAD', ref);\n showRef = base;\n } catch {\n // silently fall back to using the ref directly if merge base is not available\n }\n\n const stdout = await runOutput(['git', 'show', `${showRef}:${path}`], {\n cwd: targetPaths.rootDir,\n });\n return stdout;\n }\n}\n"],"names":["runOutput","targetPaths","assertError","ForwardedError"],"mappings":";;;;;AAuBA,eAAsB,UAAU,IAAA,EAAgB;AAC9C,EAAA,IAAI;AACF,IAAA,MAAM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AA;AAAA,MACtB,UAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,OAAO,KAAA,CAAM,IAAA,iBAAK,IAAI,GAAA,CAAI,CAAC,GAAG,OAAA,EAAS,GAAG,SAAS,CAAC,CAAC,CAAA;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,aAAA,CAAc,IAAA,EAAc,GAAA,EAAa;AACpD,IAAA,IAAI,OAAA,GAAU,GAAA;AACd,IAAA,IAAI;AACF,MAAA,MAAM,CAAC,IAAI,CAAA,GAAI,MAAM,MAAA,CAAO,YAAA,EAAc,QAAQ,GAAG,CAAA;AACrD,MAAA,OAAA,GAAU,IAAA;AAAA,IACZ,CAAA,CAAA,MAAQ;AAAA,IAER;AAEA,IAAA,MAAM,MAAA,GAAS,MAAMH,mBAAA,CAAU,CAAC,KAAA,EAAO,MAAA,EAAQ,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,IAAI,CAAA,CAAE,CAAA,EAAG;AAAA,MACpE,KAAKC,qBAAA,CAAY;AAAA,KAClB,CAAA;AACD,IAAA,OAAO,MAAA;AAAA,EACT;AACF;;;;;"}
{"version":3,"file":"GitUtils.cjs.js","sources":["../../src/git/GitUtils.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { ForwardedError, toError } from '@backstage/errors';\nimport { targetPaths } from '@backstage/cli-common';\nimport { runOutput } from '@backstage/cli-common';\n\n/**\n * Run a git command, trimming the output splitting it into lines.\n */\nexport async function runGit(...args: string[]) {\n try {\n const stdout = await runOutput(['git', ...args], {\n cwd: targetPaths.rootDir,\n });\n return stdout.trim().split(/\\r\\n|\\r|\\n/);\n } catch (error) {\n const err = toError(error);\n if ('code' in err && typeof (err as { code?: number }).code === 'number') {\n const code = (err as { code?: number }).code;\n const stderr = (err as { stderr?: string }).stderr;\n const msg = stderr?.trim() ?? `with exit code ${code}`;\n throw new Error(`git ${args[0]} failed, ${msg}`);\n }\n throw new ForwardedError('Unknown execution error', error);\n }\n}\n\n/**\n * Utilities for working with git.\n *\n * @public\n */\nexport class GitUtils {\n /**\n * Returns a sorted list of all files that have changed since the merge base\n * of the provided `ref` and HEAD, as well as all files that are not tracked by git.\n */\n static async listChangedFiles(ref: string) {\n if (!ref) {\n throw new Error('ref is required');\n }\n\n let diffRef = ref;\n try {\n const [base] = await runGit('merge-base', 'HEAD', ref);\n diffRef = base;\n } catch {\n // silently fall back to using the ref directly if merge base is not available\n }\n\n const tracked = await runGit('diff', '--name-only', diffRef);\n const untracked = await runGit(\n 'ls-files',\n '--others',\n '--exclude-standard',\n );\n\n return Array.from(new Set([...tracked, ...untracked]));\n }\n\n /**\n * Returns the contents of a file at a specific ref.\n */\n static async readFileAtRef(path: string, ref: string) {\n let showRef = ref;\n try {\n const [base] = await runGit('merge-base', 'HEAD', ref);\n showRef = base;\n } catch {\n // silently fall back to using the ref directly if merge base is not available\n }\n\n const stdout = await runOutput(['git', 'show', `${showRef}:${path}`], {\n cwd: targetPaths.rootDir,\n });\n return stdout;\n }\n}\n"],"names":["runOutput","targetPaths","toError","ForwardedError"],"mappings":";;;;;AAuBA,eAAsB,UAAU,IAAA,EAAgB;AAC9C,EAAA,IAAI;AACF,IAAA,MAAM,SAAS,MAAMA,mBAAA,CAAU,CAAC,KAAA,EAAO,GAAG,IAAI,CAAA,EAAG;AAAA,MAC/C,KAAKC,qBAAA,CAAY;AAAA,KAClB,CAAA;AACD,IAAA,OAAO,MAAA,CAAO,IAAA,EAAK,CAAE,KAAA,CAAM,YAAY,CAAA;AAAA,EACzC,S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;AAAA;AAAA;AAAA,EAKA,aAAa,aAAA,CAAc,IAAA,EAAc,GAAA,EAAa;AACpD,IAAA,IAAI,OAAA,GAAU,GAAA;AACd,IAAA,IAAI;AACF,MAAA,MAAM,CAAC,IAAI,CAAA,GAAI,MAAM,MAAA,CAAO,YAAA,EAAc,QAAQ,GAAG,CAAA;AACrD,MAAA,OAAA,GAAU,IAAA;AAAA,IACZ,CAAA,CAAA,MAAQ;AAAA,IAER;AAEA,IAAA,MAAM,MAAA,GAAS,MAAMH,mBAAA,CAAU,CAAC,KAAA,EAAO,MAAA,EAAQ,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,IAAI,CAAA,CAAE,CAAA,EAAG;AAAA,MACpE,KAAKC,qBAAA,CAAY;AAAA,KAClB,CAAA;AACD,IAAA,OAAO,MAAA;AAAA,EACT;AACF;;;;;"}
{
"name": "@backstage/cli-node",
"version": "0.0.0-nightly-20260407031731",
"version": "0.0.0-nightly-20260408031702",
"description": "Node.js library for Backstage CLIs",

@@ -35,4 +35,4 @@ "backstage": {

"dependencies": {
"@backstage/cli-common": "0.0.0-nightly-20260407031731",
"@backstage/errors": "1.2.7",
"@backstage/cli-common": "0.0.0-nightly-20260408031702",
"@backstage/errors": "0.0.0-nightly-20260408031702",
"@backstage/types": "1.2.2",

@@ -52,5 +52,5 @@ "@manypkg/get-packages": "^1.1.3",

"devDependencies": {
"@backstage/backend-test-utils": "0.0.0-nightly-20260407031731",
"@backstage/cli": "0.0.0-nightly-20260407031731",
"@backstage/test-utils": "0.0.0-nightly-20260407031731",
"@backstage/backend-test-utils": "0.0.0-nightly-20260408031702",
"@backstage/cli": "0.0.0-nightly-20260408031702",
"@backstage/test-utils": "0.0.0-nightly-20260408031702",
"@types/proper-lockfile": "^4",

@@ -57,0 +57,0 @@ "@types/yarnpkg__lockfile": "^1.1.4"