@backstage/cli-node 0.3.0 → 0.3.1-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 +18 -0
- package/dist/git/GitUtils.cjs.js +4 -4
- package/dist/git/GitUtils.cjs.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @backstage/cli-node
|
|
2
2
|
|
|
3
|
+
## 0.3.1-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 482ceed: Migrated from `assertError` to `toError` for error handling.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/errors@1.3.0-next.0
|
|
10
|
+
- @backstage/cli-common@0.2.1-next.1
|
|
11
|
+
|
|
12
|
+
## 0.3.1-next.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @backstage/cli-common@0.2.1-next.0
|
|
18
|
+
- @backstage/errors@1.2.7
|
|
19
|
+
- @backstage/types@1.2.2
|
|
20
|
+
|
|
3
21
|
## 0.3.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/git/GitUtils.cjs.js
CHANGED
|
@@ -10,10 +10,10 @@ async function runGit(...args) {
|
|
|
10
10
|
});
|
|
11
11
|
return stdout.trim().split(/\r\n|\r|\n/);
|
|
12
12
|
} catch (error) {
|
|
13
|
-
errors.
|
|
14
|
-
if ("code" in
|
|
15
|
-
const code =
|
|
16
|
-
const stderr =
|
|
13
|
+
const err = errors.toError(error);
|
|
14
|
+
if ("code" in err && typeof err.code === "number") {
|
|
15
|
+
const code = err.code;
|
|
16
|
+
const stderr = err.stderr;
|
|
17
17
|
const msg = stderr?.trim() ?? `with exit code ${code}`;
|
|
18
18
|
throw new Error(`git ${args[0]} failed, ${msg}`);
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
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 {
|
|
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 { 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,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,GAAA,GAAMC,eAAQ,KAAK,CAAA;AACzB,IAAA,IAAI,MAAA,IAAU,GAAA,IAAO,OAAQ,GAAA,CAA0B,SAAS,QAAA,EAAU;AACxE,MAAA,MAAM,OAAQ,GAAA,CAA0B,IAAA;AACxC,MAAA,MAAM,SAAU,GAAA,CAA4B,MAAA;AAC5C,MAAA,MAAM,GAAA,GAAM,MAAA,EAAQ,IAAA,EAAK,IAAK,kBAAkB,IAAI,CAAA,CAAA;AACpD,MAAA,M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C,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;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/cli-node",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1-next.1",
|
|
4
4
|
"description": "Node.js library for Backstage CLIs",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library"
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"test": "backstage-cli package test"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@backstage/cli-common": "
|
|
36
|
-
"@backstage/errors": "
|
|
37
|
-
"@backstage/types": "
|
|
35
|
+
"@backstage/cli-common": "0.2.1-next.1",
|
|
36
|
+
"@backstage/errors": "1.3.0-next.0",
|
|
37
|
+
"@backstage/types": "1.2.2",
|
|
38
38
|
"@manypkg/get-packages": "^1.1.3",
|
|
39
39
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
40
40
|
"@yarnpkg/parsers": "^3.0.0",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"zod": "^3.25.76 || ^4.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@backstage/backend-test-utils": "
|
|
52
|
-
"@backstage/cli": "
|
|
53
|
-
"@backstage/test-utils": "
|
|
51
|
+
"@backstage/backend-test-utils": "1.11.2-next.2",
|
|
52
|
+
"@backstage/cli": "0.36.1-next.2",
|
|
53
|
+
"@backstage/test-utils": "1.7.17-next.2",
|
|
54
54
|
"@types/proper-lockfile": "^4",
|
|
55
55
|
"@types/yarnpkg__lockfile": "^1.1.4"
|
|
56
56
|
},
|