workspace-tools 0.41.5 → 0.41.7

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.
Files changed (60) hide show
  1. package/lib/git/branchRefs.d.ts +36 -0
  2. package/lib/git/branchRefs.js +84 -0
  3. package/lib/git/branchRefs.js.map +1 -0
  4. package/lib/git/config.d.ts +16 -0
  5. package/lib/git/config.js +39 -4
  6. package/lib/git/config.js.map +1 -1
  7. package/lib/git/fetchRemote.d.ts +13 -0
  8. package/lib/git/fetchRemote.js +56 -0
  9. package/lib/git/fetchRemote.js.map +1 -0
  10. package/lib/git/getChanges.d.ts +54 -0
  11. package/lib/git/getChanges.js +138 -0
  12. package/lib/git/getChanges.js.map +1 -0
  13. package/lib/git/getCurrentHash.d.ts +8 -0
  14. package/lib/git/getCurrentHash.js +24 -0
  15. package/lib/git/getCurrentHash.js.map +1 -0
  16. package/lib/git/getDefaultRemote.d.ts +14 -3
  17. package/lib/git/getDefaultRemote.js +92 -53
  18. package/lib/git/getDefaultRemote.js.map +1 -1
  19. package/lib/git/getDefaultRemoteBranch.d.ts +29 -2
  20. package/lib/git/getDefaultRemoteBranch.js +61 -21
  21. package/lib/git/getDefaultRemoteBranch.js.map +1 -1
  22. package/lib/git/getFileAddedHash.d.ts +10 -0
  23. package/lib/git/getFileAddedHash.js +24 -0
  24. package/lib/git/getFileAddedHash.js.map +1 -0
  25. package/lib/git/getFileFromRef.d.ts +11 -0
  26. package/lib/git/getFileFromRef.js +22 -0
  27. package/lib/git/getFileFromRef.js.map +1 -0
  28. package/lib/git/getRecentCommitMessages.d.ts +10 -0
  29. package/lib/git/getRecentCommitMessages.js +27 -0
  30. package/lib/git/getRecentCommitMessages.js.map +1 -0
  31. package/lib/git/getRemotes.d.ts +14 -0
  32. package/lib/git/getRemotes.js +53 -0
  33. package/lib/git/getRemotes.js.map +1 -0
  34. package/lib/git/gitUtilities.d.ts +12 -212
  35. package/lib/git/gitUtilities.js +38 -448
  36. package/lib/git/gitUtilities.js.map +1 -1
  37. package/lib/git/index.d.ts +17 -5
  38. package/lib/git/index.js +123 -17
  39. package/lib/git/index.js.map +1 -1
  40. package/lib/git/init.d.ts +11 -0
  41. package/lib/git/init.js +48 -0
  42. package/lib/git/init.js.map +1 -0
  43. package/lib/git/listAllTrackedFiles.d.ts +12 -0
  44. package/lib/git/listAllTrackedFiles.js +25 -0
  45. package/lib/git/listAllTrackedFiles.js.map +1 -0
  46. package/lib/git/parseRemoteBranch.d.ts +26 -0
  47. package/lib/git/parseRemoteBranch.js +77 -0
  48. package/lib/git/parseRemoteBranch.js.map +1 -0
  49. package/lib/git/revertLocalChanges.d.ts +9 -0
  50. package/lib/git/revertLocalChanges.js +42 -0
  51. package/lib/git/revertLocalChanges.js.map +1 -0
  52. package/lib/git/stageAndCommit.d.ts +21 -0
  53. package/lib/git/stageAndCommit.js +69 -0
  54. package/lib/git/stageAndCommit.js.map +1 -0
  55. package/lib/git/types.d.ts +5 -2
  56. package/lib/git/types.js.map +1 -1
  57. package/lib/workspaces/getCatalogVersion.d.ts +8 -3
  58. package/lib/workspaces/getCatalogVersion.js +9 -3
  59. package/lib/workspaces/getCatalogVersion.js.map +1 -1
  60. package/package.json +1 -1
package/lib/git/index.js CHANGED
@@ -5,11 +5,38 @@ Object.defineProperty(exports, "__esModule", {
5
5
  0 && (module.exports = {
6
6
  addGitObserver: null,
7
7
  clearGitObservers: null,
8
+ commit: null,
9
+ fetchRemote: null,
10
+ fetchRemoteBranch: null,
11
+ getBranchChanges: null,
12
+ getBranchName: null,
13
+ getChanges: null,
14
+ getChangesBetweenRefs: null,
8
15
  getConfigValue: null,
16
+ getCurrentHash: null,
17
+ getDefaultBranch: null,
9
18
  getDefaultRemote: null,
10
19
  getDefaultRemoteBranch: null,
20
+ getFileAddedHash: null,
21
+ getFileFromRef: null,
22
+ getFullBranchRef: null,
23
+ getParentBranch: null,
24
+ getRecentCommitMessages: null,
25
+ getRemoteBranch: null,
26
+ getShortBranchName: null,
27
+ getStagedChanges: null,
28
+ getUnstagedChanges: null,
29
+ getUntrackedChanges: null,
30
+ getUserEmail: null,
11
31
  git: null,
12
- gitFailFast: null
32
+ gitFailFast: null,
33
+ init: null,
34
+ listAllTrackedFiles: null,
35
+ parseRemoteBranch: null,
36
+ resolveRemoteBranch: null,
37
+ revertLocalChanges: null,
38
+ stage: null,
39
+ stageAndCommit: null
13
40
  });
14
41
  function _export(target, all) {
15
42
  for(var name in all)Object.defineProperty(target, name, {
@@ -24,39 +51,118 @@ _export(exports, {
24
51
  get clearGitObservers () {
25
52
  return _git.clearGitObservers;
26
53
  },
54
+ get commit () {
55
+ return _stageAndCommit.commit;
56
+ },
57
+ get fetchRemote () {
58
+ return _fetchRemote.fetchRemote;
59
+ },
60
+ get fetchRemoteBranch () {
61
+ return _fetchRemote.fetchRemoteBranch;
62
+ },
63
+ get getBranchChanges () {
64
+ return _getChanges.getBranchChanges;
65
+ },
66
+ get getBranchName () {
67
+ return _branchRefs.getBranchName;
68
+ },
69
+ get getChanges () {
70
+ return _getChanges.getChanges;
71
+ },
72
+ get getChangesBetweenRefs () {
73
+ return _getChanges.getChangesBetweenRefs;
74
+ },
27
75
  get getConfigValue () {
28
76
  return _config.getConfigValue;
29
77
  },
78
+ get getCurrentHash () {
79
+ return _getCurrentHash.getCurrentHash;
80
+ },
81
+ get getDefaultBranch () {
82
+ return _config.getDefaultBranch;
83
+ },
30
84
  get getDefaultRemote () {
31
85
  return _getDefaultRemote.getDefaultRemote;
32
86
  },
33
87
  get getDefaultRemoteBranch () {
34
88
  return _getDefaultRemoteBranch.getDefaultRemoteBranch;
35
89
  },
90
+ get getFileAddedHash () {
91
+ return _getFileAddedHash.getFileAddedHash;
92
+ },
93
+ get getFileFromRef () {
94
+ return _getFileFromRef.getFileFromRef;
95
+ },
96
+ get getFullBranchRef () {
97
+ return _branchRefs.getFullBranchRef;
98
+ },
99
+ get getParentBranch () {
100
+ return _gitUtilities.getParentBranch;
101
+ },
102
+ get getRecentCommitMessages () {
103
+ return _getRecentCommitMessages.getRecentCommitMessages;
104
+ },
105
+ get getRemoteBranch () {
106
+ return _branchRefs.getRemoteBranch;
107
+ },
108
+ get getShortBranchName () {
109
+ return _branchRefs.getShortBranchName;
110
+ },
111
+ get getStagedChanges () {
112
+ return _getChanges.getStagedChanges;
113
+ },
114
+ get getUnstagedChanges () {
115
+ return _getChanges.getUnstagedChanges;
116
+ },
117
+ get getUntrackedChanges () {
118
+ return _getChanges.getUntrackedChanges;
119
+ },
120
+ get getUserEmail () {
121
+ return _config.getUserEmail;
122
+ },
36
123
  get git () {
37
124
  return _git.git;
38
125
  },
39
126
  get gitFailFast () {
40
127
  return _git.gitFailFast;
128
+ },
129
+ get init () {
130
+ return _init.init;
131
+ },
132
+ get listAllTrackedFiles () {
133
+ return _listAllTrackedFiles.listAllTrackedFiles;
134
+ },
135
+ get parseRemoteBranch () {
136
+ return _parseRemoteBranch.parseRemoteBranch;
137
+ },
138
+ get resolveRemoteBranch () {
139
+ return _getDefaultRemoteBranch.resolveRemoteBranch;
140
+ },
141
+ get revertLocalChanges () {
142
+ return _revertLocalChanges.revertLocalChanges;
143
+ },
144
+ get stage () {
145
+ return _stageAndCommit.stage;
146
+ },
147
+ get stageAndCommit () {
148
+ return _stageAndCommit.stageAndCommit;
41
149
  }
42
150
  });
43
- 0 && __export(require("./gitUtilities.js"));
44
- const _git = require("./git.js");
151
+ const _branchRefs = require("./branchRefs.js");
45
152
  const _config = require("./config.js");
153
+ const _fetchRemote = require("./fetchRemote.js");
154
+ const _getChanges = require("./getChanges.js");
155
+ const _getCurrentHash = require("./getCurrentHash.js");
46
156
  const _getDefaultRemote = require("./getDefaultRemote.js");
47
157
  const _getDefaultRemoteBranch = require("./getDefaultRemoteBranch.js");
48
- _export_star(require("./gitUtilities.js"), exports);
49
- function _export_star(from, to) {
50
- Object.keys(from).forEach(function(k) {
51
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
52
- Object.defineProperty(to, k, {
53
- enumerable: true,
54
- get: function() {
55
- return from[k];
56
- }
57
- });
58
- }
59
- });
60
- return from;
61
- }
158
+ const _getFileAddedHash = require("./getFileAddedHash.js");
159
+ const _getFileFromRef = require("./getFileFromRef.js");
160
+ const _getRecentCommitMessages = require("./getRecentCommitMessages.js");
161
+ const _git = require("./git.js");
162
+ const _gitUtilities = require("./gitUtilities.js");
163
+ const _init = require("./init.js");
164
+ const _listAllTrackedFiles = require("./listAllTrackedFiles.js");
165
+ const _parseRemoteBranch = require("./parseRemoteBranch.js");
166
+ const _revertLocalChanges = require("./revertLocalChanges.js");
167
+ const _stageAndCommit = require("./stageAndCommit.js");
62
168
  // getRepositoryName is not currently exported; could be changed if it would be useful externally
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/git/index.ts"],"sourcesContent":["export {\n type GitError,\n type GitObserver,\n type GitOptions,\n type GitProcessOutput,\n addGitObserver,\n clearGitObservers,\n git,\n gitFailFast,\n} from \"./git.js\";\nexport { getConfigValue } from \"./config.js\";\nexport { type GetDefaultRemoteOptions, getDefaultRemote } from \"./getDefaultRemote.js\";\nexport { type GetDefaultRemoteBranchOptions, getDefaultRemoteBranch } from \"./getDefaultRemoteBranch.js\";\nexport * from \"./gitUtilities.js\";\n// getRepositoryName is not currently exported; could be changed if it would be useful externally\n"],"names":["addGitObserver","clearGitObservers","getConfigValue","getDefaultRemote","getDefaultRemoteBranch","git","gitFailFast"],"mappings":";;;;;;;;;;;;;;;;;;;;QAKEA;eAAAA,mBAAc;;QACdC;eAAAA,sBAAiB;;QAIVC;eAAAA,sBAAc;;QACgBC;eAAAA,kCAAgB;;QACVC;eAAAA,8CAAsB;;QALjEC;eAAAA,QAAG;;QACHC;eAAAA,gBAAW;;;;qBACN;wBACwB;kCACgC;wCACY;qBAC7D;;;;;;;;;;;;;;CACd,iGAAiG"}
1
+ {"version":3,"sources":["../../src/git/index.ts"],"sourcesContent":["export { getBranchName, getFullBranchRef, getRemoteBranch, getShortBranchName } from \"./branchRefs.js\";\nexport { getConfigValue, getDefaultBranch, getUserEmail } from \"./config.js\";\nexport { fetchRemote, fetchRemoteBranch } from \"./fetchRemote.js\";\nexport {\n getBranchChanges,\n getChanges,\n getChangesBetweenRefs,\n getStagedChanges,\n getUnstagedChanges,\n getUntrackedChanges,\n} from \"./getChanges.js\";\nexport { getCurrentHash } from \"./getCurrentHash.js\";\nexport { getDefaultRemote, type GetDefaultRemoteOptions } from \"./getDefaultRemote.js\";\nexport {\n getDefaultRemoteBranch,\n type GetDefaultRemoteBranchOptions,\n resolveRemoteBranch,\n} from \"./getDefaultRemoteBranch.js\";\nexport { getFileAddedHash } from \"./getFileAddedHash.js\";\nexport { getFileFromRef } from \"./getFileFromRef.js\";\nexport { getRecentCommitMessages } from \"./getRecentCommitMessages.js\";\nexport {\n addGitObserver,\n clearGitObservers,\n git,\n gitFailFast,\n type GitError,\n type GitObserver,\n type GitOptions,\n type GitProcessOutput,\n} from \"./git.js\";\nexport { getParentBranch } from \"./gitUtilities.js\";\nexport { init } from \"./init.js\";\nexport { listAllTrackedFiles } from \"./listAllTrackedFiles.js\";\nexport { parseRemoteBranch } from \"./parseRemoteBranch.js\";\nexport { revertLocalChanges } from \"./revertLocalChanges.js\";\nexport { commit, stage, stageAndCommit } from \"./stageAndCommit.js\";\n\n// getRepositoryName is not currently exported; could be changed if it would be useful externally\n"],"names":["addGitObserver","clearGitObservers","commit","fetchRemote","fetchRemoteBranch","getBranchChanges","getBranchName","getChanges","getChangesBetweenRefs","getConfigValue","getCurrentHash","getDefaultBranch","getDefaultRemote","getDefaultRemoteBranch","getFileAddedHash","getFileFromRef","getFullBranchRef","getParentBranch","getRecentCommitMessages","getRemoteBranch","getShortBranchName","getStagedChanges","getUnstagedChanges","getUntrackedChanges","getUserEmail","git","gitFailFast","init","listAllTrackedFiles","parseRemoteBranch","resolveRemoteBranch","revertLocalChanges","stage","stageAndCommit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsBEA;eAAAA,mBAAc;;QACdC;eAAAA,sBAAiB;;QAaVC;eAAAA,sBAAM;;QAlCNC;eAAAA,wBAAW;;QAAEC;eAAAA,8BAAiB;;QAErCC;eAAAA,4BAAgB;;QAJTC;eAAAA,yBAAa;;QAKpBC;eAAAA,sBAAU;;QACVC;eAAAA,iCAAqB;;QALdC;eAAAA,sBAAc;;QAUdC;eAAAA,8BAAc;;QAVEC;eAAAA,wBAAgB;;QAWhCC;eAAAA,kCAAgB;;QAEvBC;eAAAA,8CAAsB;;QAIfC;eAAAA,kCAAgB;;QAChBC;eAAAA,8BAAc;;QAnBCC;eAAAA,4BAAgB;;QA+B/BC;eAAAA,6BAAe;;QAXfC;eAAAA,gDAAuB;;QApBUC;eAAAA,2BAAe;;QAAEC;eAAAA,8BAAkB;;QAO3EC;eAAAA,4BAAgB;;QAChBC;eAAAA,8BAAkB;;QAClBC;eAAAA,+BAAmB;;QARsBC;eAAAA,oBAAY;;QAuBrDC;eAAAA,QAAG;;QACHC;eAAAA,gBAAW;;QAOJC;eAAAA,UAAI;;QACJC;eAAAA,wCAAmB;;QACnBC;eAAAA,oCAAiB;;QAlBxBC;eAAAA,2CAAmB;;QAmBZC;eAAAA,sCAAkB;;QACVC;eAAAA,qBAAK;;QAAEC;eAAAA,8BAAc;;;4BApC+C;wBACtB;6BAChB;4BAQxC;gCACwB;kCACgC;wCAKxD;kCAC0B;gCACF;yCACS;qBAUjC;8BACyB;sBACX;qCACe;mCACF;oCACC;gCACW;CAE9C,iGAAiG"}
@@ -0,0 +1,11 @@
1
+ import type { GitInitOptions } from "./types.js";
2
+ /**
3
+ * Run `git init` and verify that the `user.name` and `user.email` configs are set (at any level).
4
+ * Throws an error if `git init` fails.
5
+ *
6
+ * If `user.email` and `user.name` aren't already set globally, and the missing value is provided
7
+ * in params, set it at the repo level. Otherwise, throw an error.
8
+ */
9
+ export declare function init(options: GitInitOptions): void;
10
+ /** @deprecated Use object params version */
11
+ export declare function init(cwd: string, email?: string, username?: string): void;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "init", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return init;
9
+ }
10
+ });
11
+ const _config = require("./config.js");
12
+ const _git = require("./git.js");
13
+ function init(cwdOrOptions, _email, _username) {
14
+ const { email, username, ...options } = typeof cwdOrOptions === "string" ? {
15
+ cwd: cwdOrOptions,
16
+ email: _email,
17
+ username: _username
18
+ } : cwdOrOptions;
19
+ (0, _git.git)([
20
+ "init"
21
+ ], {
22
+ ...options,
23
+ throwOnError: true
24
+ });
25
+ if (!(0, _config.getConfigValue)({
26
+ key: "user.name",
27
+ ...options
28
+ })) {
29
+ if (!username) {
30
+ throw new Error("must include a username when initializing git repo");
31
+ }
32
+ (0, _git.git)([
33
+ "config",
34
+ "user.name",
35
+ username
36
+ ], options);
37
+ }
38
+ if (!(0, _config.getUserEmail)(options)) {
39
+ if (!email) {
40
+ throw new Error("must include a email when initializing git repo");
41
+ }
42
+ (0, _git.git)([
43
+ "config",
44
+ "user.email",
45
+ email
46
+ ], options);
47
+ }
48
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/git/init.ts"],"sourcesContent":["import { getConfigValue, getUserEmail } from \"./config.js\";\nimport { git } from \"./git.js\";\nimport type { GitInitOptions } from \"./types.js\";\n\n/**\n * Run `git init` and verify that the `user.name` and `user.email` configs are set (at any level).\n * Throws an error if `git init` fails.\n *\n * If `user.email` and `user.name` aren't already set globally, and the missing value is provided\n * in params, set it at the repo level. Otherwise, throw an error.\n */\nexport function init(options: GitInitOptions): void;\n/** @deprecated Use object params version */\nexport function init(cwd: string, email?: string, username?: string): void;\nexport function init(cwdOrOptions: string | GitInitOptions, _email?: string, _username?: string): void {\n const { email, username, ...options } =\n typeof cwdOrOptions === \"string\" ? { cwd: cwdOrOptions, email: _email, username: _username } : cwdOrOptions;\n\n git([\"init\"], { ...options, throwOnError: true });\n\n if (!getConfigValue({ key: \"user.name\", ...options })) {\n if (!username) {\n throw new Error(\"must include a username when initializing git repo\");\n }\n git([\"config\", \"user.name\", username], options);\n }\n\n if (!getUserEmail(options)) {\n if (!email) {\n throw new Error(\"must include a email when initializing git repo\");\n }\n git([\"config\", \"user.email\", email], options);\n }\n}\n"],"names":["init","cwdOrOptions","_email","_username","email","username","options","cwd","git","throwOnError","getConfigValue","key","Error","getUserEmail"],"mappings":";;;;+BAcgBA;;;eAAAA;;;wBAd6B;qBACzB;AAab,SAASA,KAAKC,YAAqC,EAAEC,MAAe,EAAEC,SAAkB;IAC7F,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGC,SAAS,GACnC,OAAOL,iBAAiB,WAAW;QAAEM,KAAKN;QAAcG,OAAOF;QAAQG,UAAUF;IAAU,IAAIF;IAEjGO,IAAAA,QAAG,EAAC;QAAC;KAAO,EAAE;QAAE,GAAGF,OAAO;QAAEG,cAAc;IAAK;IAE/C,IAAI,CAACC,IAAAA,sBAAc,EAAC;QAAEC,KAAK;QAAa,GAAGL,OAAO;IAAC,IAAI;QACrD,IAAI,CAACD,UAAU;YACb,MAAM,IAAIO,MAAM;QAClB;QACAJ,IAAAA,QAAG,EAAC;YAAC;YAAU;YAAaH;SAAS,EAAEC;IACzC;IAEA,IAAI,CAACO,IAAAA,oBAAY,EAACP,UAAU;QAC1B,IAAI,CAACF,OAAO;YACV,MAAM,IAAIQ,MAAM;QAClB;QACAJ,IAAAA,QAAG,EAAC;YAAC;YAAU;YAAcJ;SAAM,EAAEE;IACvC;AACF"}
@@ -0,0 +1,12 @@
1
+ import type { GitCommonOptions } from "./types.js";
2
+ /**
3
+ * Lists all tracked files matching the given patterns.
4
+ * Throws on error by default.
5
+ * @returns An array of file paths, or an empty array if no files are found
6
+ */
7
+ export declare function listAllTrackedFiles(options: {
8
+ /** File patterns to match (passed to git ls-files) */
9
+ patterns: string[];
10
+ } & GitCommonOptions): string[];
11
+ /** @deprecated Use object params version */
12
+ export declare function listAllTrackedFiles(patterns: string[], cwd: string): string[];
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "listAllTrackedFiles", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return listAllTrackedFiles;
9
+ }
10
+ });
11
+ const _git = require("./git.js");
12
+ function listAllTrackedFiles(patternsOrOptions, cwd) {
13
+ const { patterns, ...options } = Array.isArray(patternsOrOptions) ? {
14
+ patterns: patternsOrOptions,
15
+ cwd: cwd
16
+ } : patternsOrOptions;
17
+ const results = (0, _git.git)([
18
+ "ls-files",
19
+ ...patterns
20
+ ], {
21
+ throwOnError: true,
22
+ ...options
23
+ });
24
+ return (0, _git.processGitOutput)(results);
25
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/git/listAllTrackedFiles.ts"],"sourcesContent":["import { git, processGitOutput } from \"./git.js\";\nimport type { GitCommonOptions } from \"./types.js\";\n\n/**\n * Lists all tracked files matching the given patterns.\n * Throws on error by default.\n * @returns An array of file paths, or an empty array if no files are found\n */\nexport function listAllTrackedFiles(\n options: {\n /** File patterns to match (passed to git ls-files) */\n patterns: string[];\n } & GitCommonOptions\n): string[];\n/** @deprecated Use object params version */\nexport function listAllTrackedFiles(patterns: string[], cwd: string): string[];\nexport function listAllTrackedFiles(\n patternsOrOptions: string[] | ({ patterns: string[] } & GitCommonOptions),\n cwd?: string\n): string[] {\n const { patterns, ...options } = Array.isArray(patternsOrOptions)\n ? { patterns: patternsOrOptions, cwd: cwd! }\n : patternsOrOptions;\n\n const results = git([\"ls-files\", ...patterns], { throwOnError: true, ...options });\n\n return processGitOutput(results);\n}\n"],"names":["listAllTrackedFiles","patternsOrOptions","cwd","patterns","options","Array","isArray","results","git","throwOnError","processGitOutput"],"mappings":";;;;+BAgBgBA;;;eAAAA;;;qBAhBsB;AAgB/B,SAASA,oBACdC,iBAAyE,EACzEC,GAAY;IAEZ,MAAM,EAAEC,QAAQ,EAAE,GAAGC,SAAS,GAAGC,MAAMC,OAAO,CAACL,qBAC3C;QAAEE,UAAUF;QAAmBC,KAAKA;IAAK,IACzCD;IAEJ,MAAMM,UAAUC,IAAAA,QAAG,EAAC;QAAC;WAAeL;KAAS,EAAE;QAAEM,cAAc;QAAM,GAAGL,OAAO;IAAC;IAEhF,OAAOM,IAAAA,qBAAgB,EAACH;AAC1B"}
@@ -0,0 +1,26 @@
1
+ import type { ParsedRemoteBranch, ParseRemoteBranchOptions } from "./types.js";
2
+ /**
3
+ * Get the remote and branch name from a full branch name that may include a remote prefix.
4
+ * If the path doesn't start with one of `options.knownRemotes` (but has multiple segments),
5
+ * the actual list of remotes will be read via `git config` to see if one of those matches.
6
+ *
7
+ * With `throwOnError: true`, currently it will NOT throw if the branch prefix matches `knownRemotes`
8
+ * regardless of the actual state of remotes in the repo. If it has to get the actual list of
9
+ * remotes, it will throw in the same cases as {@link getRemotes}.
10
+ *
11
+ * NOTE: The additional verification is new in the object params version; the original version
12
+ * incorrectly assumes the first segment before a slash is always a remote.
13
+ */
14
+ export declare function parseRemoteBranch(options: ParseRemoteBranchOptions): ParsedRemoteBranch;
15
+ /**
16
+ * @deprecated Use object params version, which does more verification. This version inaccurately
17
+ * assumes the first segment before a slash is always a remote, which could lead to tricky bugs.
18
+ */
19
+ export declare function parseRemoteBranch(branch: string): ParsedRemoteBranch;
20
+ /**
21
+ * See {@link parseRemoteBranch}. This version also returns the remotes in the result if they were
22
+ * read from git, for reuse by other operations.
23
+ */
24
+ export declare function parseRemoteBranchPlusRemotes(options: ParseRemoteBranchOptions): ParsedRemoteBranch & {
25
+ remotes: Record<string, string> | undefined;
26
+ };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ 0 && (module.exports = {
6
+ parseRemoteBranch: null,
7
+ parseRemoteBranchPlusRemotes: null
8
+ });
9
+ function _export(target, all) {
10
+ for(var name in all)Object.defineProperty(target, name, {
11
+ enumerable: true,
12
+ get: Object.getOwnPropertyDescriptor(all, name).get
13
+ });
14
+ }
15
+ _export(exports, {
16
+ get parseRemoteBranch () {
17
+ return parseRemoteBranch;
18
+ },
19
+ get parseRemoteBranchPlusRemotes () {
20
+ return parseRemoteBranchPlusRemotes;
21
+ }
22
+ });
23
+ const _getRemotes = require("./getRemotes.js");
24
+ function parseRemoteBranch(branchOrOptions) {
25
+ if (typeof branchOrOptions === "string") {
26
+ const branch = branchOrOptions;
27
+ const firstSlashPos = branch.indexOf("/", 0);
28
+ return {
29
+ remote: branch.substring(0, firstSlashPos),
30
+ remoteBranch: branch.substring(firstSlashPos + 1)
31
+ };
32
+ }
33
+ // Remove the list of remotes from the result
34
+ const { remote, remoteBranch } = parseRemoteBranchPlusRemotes(branchOrOptions);
35
+ return {
36
+ remote,
37
+ remoteBranch
38
+ };
39
+ }
40
+ function parseRemoteBranchPlusRemotes(options) {
41
+ const { branch, knownRemotes = [
42
+ "origin",
43
+ "upstream"
44
+ ], ...otherOptions } = options;
45
+ if (!branch.includes("/")) {
46
+ return {
47
+ remote: "",
48
+ remoteBranch: branch,
49
+ remotes: undefined
50
+ };
51
+ }
52
+ // As a shortcut, check for the most common remote names before doing git operations
53
+ let remote = knownRemotes.find((r)=>branch.startsWith(`${r}/`));
54
+ let remotes;
55
+ if (!remote) {
56
+ // There's a slash in the branch name, but it doesn't start with one of the common remote names.
57
+ // Get the real list of remotes from git to see if it matches any of those, or is just a branch
58
+ // with a slash in the name (e.g. "feature/foo/bar"). This just reads the git config and isn't
59
+ // an expensive operation, but save the returned remotes for later anyway.
60
+ remotes = (0, _getRemotes.getRemotes)(otherOptions);
61
+ if (remotes) {
62
+ remote = Object.keys(remotes).find((r)=>branch.startsWith(`${r}/`));
63
+ }
64
+ }
65
+ if (remote) {
66
+ return {
67
+ remote,
68
+ remoteBranch: branch.slice(remote.length + 1),
69
+ remotes
70
+ };
71
+ }
72
+ return {
73
+ remote: "",
74
+ remoteBranch: branch,
75
+ remotes
76
+ };
77
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/git/parseRemoteBranch.ts"],"sourcesContent":["import { getRemotes } from \"./getRemotes.js\";\nimport type { ParsedRemoteBranch, ParseRemoteBranchOptions } from \"./types.js\";\n\n/**\n * Get the remote and branch name from a full branch name that may include a remote prefix.\n * If the path doesn't start with one of `options.knownRemotes` (but has multiple segments),\n * the actual list of remotes will be read via `git config` to see if one of those matches.\n *\n * With `throwOnError: true`, currently it will NOT throw if the branch prefix matches `knownRemotes`\n * regardless of the actual state of remotes in the repo. If it has to get the actual list of\n * remotes, it will throw in the same cases as {@link getRemotes}.\n *\n * NOTE: The additional verification is new in the object params version; the original version\n * incorrectly assumes the first segment before a slash is always a remote.\n */\nexport function parseRemoteBranch(options: ParseRemoteBranchOptions): ParsedRemoteBranch;\n/**\n * @deprecated Use object params version, which does more verification. This version inaccurately\n * assumes the first segment before a slash is always a remote, which could lead to tricky bugs.\n */\nexport function parseRemoteBranch(branch: string): ParsedRemoteBranch;\nexport function parseRemoteBranch(branchOrOptions: string | ParseRemoteBranchOptions): ParsedRemoteBranch {\n if (typeof branchOrOptions === \"string\") {\n const branch = branchOrOptions;\n const firstSlashPos = branch.indexOf(\"/\", 0);\n return {\n remote: branch.substring(0, firstSlashPos),\n remoteBranch: branch.substring(firstSlashPos + 1),\n };\n }\n\n // Remove the list of remotes from the result\n const { remote, remoteBranch } = parseRemoteBranchPlusRemotes(branchOrOptions);\n return { remote, remoteBranch };\n}\n\n/**\n * See {@link parseRemoteBranch}. This version also returns the remotes in the result if they were\n * read from git, for reuse by other operations.\n */\nexport function parseRemoteBranchPlusRemotes(\n options: ParseRemoteBranchOptions\n): ParsedRemoteBranch & { remotes: Record<string, string> | undefined } {\n const { branch, knownRemotes = [\"origin\", \"upstream\"], ...otherOptions } = options;\n\n if (!branch.includes(\"/\")) {\n return { remote: \"\", remoteBranch: branch, remotes: undefined };\n }\n\n // As a shortcut, check for the most common remote names before doing git operations\n let remote = knownRemotes.find((r) => branch.startsWith(`${r}/`));\n\n let remotes: Record<string, string> | undefined;\n if (!remote) {\n // There's a slash in the branch name, but it doesn't start with one of the common remote names.\n // Get the real list of remotes from git to see if it matches any of those, or is just a branch\n // with a slash in the name (e.g. \"feature/foo/bar\"). This just reads the git config and isn't\n // an expensive operation, but save the returned remotes for later anyway.\n remotes = getRemotes(otherOptions);\n if (remotes) {\n remote = Object.keys(remotes).find((r) => branch.startsWith(`${r}/`));\n }\n }\n\n if (remote) {\n return { remote, remoteBranch: branch.slice(remote.length + 1), remotes };\n }\n return { remote: \"\", remoteBranch: branch, remotes };\n}\n"],"names":["parseRemoteBranch","parseRemoteBranchPlusRemotes","branchOrOptions","branch","firstSlashPos","indexOf","remote","substring","remoteBranch","options","knownRemotes","otherOptions","includes","remotes","undefined","find","r","startsWith","getRemotes","Object","keys","slice","length"],"mappings":";;;;;;;;;;;;;;;QAqBgBA;eAAAA;;QAmBAC;eAAAA;;;4BAxCW;AAqBpB,SAASD,kBAAkBE,eAAkD;IAClF,IAAI,OAAOA,oBAAoB,UAAU;QACvC,MAAMC,SAASD;QACf,MAAME,gBAAgBD,OAAOE,OAAO,CAAC,KAAK;QAC1C,OAAO;YACLC,QAAQH,OAAOI,SAAS,CAAC,GAAGH;YAC5BI,cAAcL,OAAOI,SAAS,CAACH,gBAAgB;QACjD;IACF;IAEA,6CAA6C;IAC7C,MAAM,EAAEE,MAAM,EAAEE,YAAY,EAAE,GAAGP,6BAA6BC;IAC9D,OAAO;QAAEI;QAAQE;IAAa;AAChC;AAMO,SAASP,6BACdQ,OAAiC;IAEjC,MAAM,EAAEN,MAAM,EAAEO,eAAe;QAAC;QAAU;KAAW,EAAE,GAAGC,cAAc,GAAGF;IAE3E,IAAI,CAACN,OAAOS,QAAQ,CAAC,MAAM;QACzB,OAAO;YAAEN,QAAQ;YAAIE,cAAcL;YAAQU,SAASC;QAAU;IAChE;IAEA,oFAAoF;IACpF,IAAIR,SAASI,aAAaK,IAAI,CAAC,CAACC,IAAMb,OAAOc,UAAU,CAAC,GAAGD,EAAE,CAAC,CAAC;IAE/D,IAAIH;IACJ,IAAI,CAACP,QAAQ;QACX,gGAAgG;QAChG,+FAA+F;QAC/F,8FAA8F;QAC9F,0EAA0E;QAC1EO,UAAUK,IAAAA,sBAAU,EAACP;QACrB,IAAIE,SAAS;YACXP,SAASa,OAAOC,IAAI,CAACP,SAASE,IAAI,CAAC,CAACC,IAAMb,OAAOc,UAAU,CAAC,GAAGD,EAAE,CAAC,CAAC;QACrE;IACF;IAEA,IAAIV,QAAQ;QACV,OAAO;YAAEA;YAAQE,cAAcL,OAAOkB,KAAK,CAACf,OAAOgB,MAAM,GAAG;YAAIT;QAAQ;IAC1E;IACA,OAAO;QAAEP,QAAQ;QAAIE,cAAcL;QAAQU;IAAQ;AACrD"}
@@ -0,0 +1,9 @@
1
+ import type { GitCommonOptions } from "./types.js";
2
+ /**
3
+ * Reverts all local changes (both staged and unstaged) by stashing them and then dropping the stash.
4
+ * @returns True if the revert was successful, false otherwise. It will also be false if there were
5
+ * no changes to revert. (To distinguish between this case and errors, use the `throwOnError` option.)
6
+ */
7
+ export declare function revertLocalChanges(options: GitCommonOptions): boolean;
8
+ /** @deprecated Use object params version */
9
+ export declare function revertLocalChanges(cwd: string): boolean;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "revertLocalChanges", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return revertLocalChanges;
9
+ }
10
+ });
11
+ const _git = require("./git.js");
12
+ function revertLocalChanges(cwdOrOptions) {
13
+ const options = typeof cwdOrOptions === "string" ? {
14
+ cwd: cwdOrOptions
15
+ } : cwdOrOptions;
16
+ const stash = `workspace-tools_${new Date().getTime()}`;
17
+ if (!(0, _git.git)([
18
+ "stash",
19
+ "push",
20
+ "-u",
21
+ "-m",
22
+ stash
23
+ ], options).success) {
24
+ return false;
25
+ }
26
+ const results = (0, _git.git)([
27
+ "stash",
28
+ "list"
29
+ ], options);
30
+ if (results.success) {
31
+ const matched = results.stdout.split(/\n/).find((line)=>line.includes(stash))?.match(/^[^:]+/);
32
+ if (matched) {
33
+ (0, _git.git)([
34
+ "stash",
35
+ "drop",
36
+ matched[0]
37
+ ], options);
38
+ return true;
39
+ }
40
+ }
41
+ return false;
42
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/git/revertLocalChanges.ts"],"sourcesContent":["import { git } from \"./git.js\";\nimport type { GitCommonOptions } from \"./types.js\";\n\n/**\n * Reverts all local changes (both staged and unstaged) by stashing them and then dropping the stash.\n * @returns True if the revert was successful, false otherwise. It will also be false if there were\n * no changes to revert. (To distinguish between this case and errors, use the `throwOnError` option.)\n */\nexport function revertLocalChanges(options: GitCommonOptions): boolean;\n/** @deprecated Use object params version */\nexport function revertLocalChanges(cwd: string): boolean;\nexport function revertLocalChanges(cwdOrOptions: string | GitCommonOptions): boolean {\n const options: GitCommonOptions = typeof cwdOrOptions === \"string\" ? { cwd: cwdOrOptions } : cwdOrOptions;\n\n const stash = `workspace-tools_${new Date().getTime()}`;\n if (!git([\"stash\", \"push\", \"-u\", \"-m\", stash], options).success) {\n return false;\n }\n\n const results = git([\"stash\", \"list\"], options);\n if (results.success) {\n const matched = results.stdout\n .split(/\\n/)\n .find((line) => line.includes(stash))\n ?.match(/^[^:]+/);\n\n if (matched) {\n git([\"stash\", \"drop\", matched[0]], options);\n return true;\n }\n }\n\n return false;\n}\n"],"names":["revertLocalChanges","cwdOrOptions","options","cwd","stash","Date","getTime","git","success","results","matched","stdout","split","find","line","includes","match"],"mappings":";;;;+BAWgBA;;;eAAAA;;;qBAXI;AAWb,SAASA,mBAAmBC,YAAuC;IACxE,MAAMC,UAA4B,OAAOD,iBAAiB,WAAW;QAAEE,KAAKF;IAAa,IAAIA;IAE7F,MAAMG,QAAQ,CAAC,gBAAgB,EAAE,IAAIC,OAAOC,OAAO,IAAI;IACvD,IAAI,CAACC,IAAAA,QAAG,EAAC;QAAC;QAAS;QAAQ;QAAM;QAAMH;KAAM,EAAEF,SAASM,OAAO,EAAE;QAC/D,OAAO;IACT;IAEA,MAAMC,UAAUF,IAAAA,QAAG,EAAC;QAAC;QAAS;KAAO,EAAEL;IACvC,IAAIO,QAAQD,OAAO,EAAE;QACnB,MAAME,UAAUD,QAAQE,MAAM,CAC3BC,KAAK,CAAC,MACNC,IAAI,CAAC,CAACC,OAASA,KAAKC,QAAQ,CAACX,SAC5BY,MAAM;QAEV,IAAIN,SAAS;YACXH,IAAAA,QAAG,EAAC;gBAAC;gBAAS;gBAAQG,OAAO,CAAC,EAAE;aAAC,EAAER;YACnC,OAAO;QACT;IACF;IAEA,OAAO;AACT"}
@@ -0,0 +1,21 @@
1
+ import type { GitCommitOptions, GitStageOptions } from "./types.js";
2
+ /**
3
+ * Stages files matching the given patterns.
4
+ */
5
+ export declare function stage(options: GitStageOptions): void;
6
+ /** @deprecated Use object params version */
7
+ export declare function stage(patterns: string[], cwd: string): void;
8
+ /**
9
+ * Commit changes. Throws an error on failure by default.
10
+ */
11
+ export declare function commit(options: GitCommitOptions): void;
12
+ /** @deprecated Use object params version */
13
+ export declare function commit(message: string, cwd: string, options?: string[]): void;
14
+ /**
15
+ * Stages files matching the given patterns and creates a commit with the specified message.
16
+ * Convenience function that combines `stage()` and `commit()`.
17
+ * Throws an error on commit failure by default.
18
+ */
19
+ export declare function stageAndCommit(options: GitStageOptions & GitCommitOptions): void;
20
+ /** @deprecated Use object params version */
21
+ export declare function stageAndCommit(patterns: string[], message: string, cwd: string, commitOptions?: string[]): void;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ 0 && (module.exports = {
6
+ commit: null,
7
+ stage: null,
8
+ stageAndCommit: null
9
+ });
10
+ function _export(target, all) {
11
+ for(var name in all)Object.defineProperty(target, name, {
12
+ enumerable: true,
13
+ get: Object.getOwnPropertyDescriptor(all, name).get
14
+ });
15
+ }
16
+ _export(exports, {
17
+ get commit () {
18
+ return commit;
19
+ },
20
+ get stage () {
21
+ return stage;
22
+ },
23
+ get stageAndCommit () {
24
+ return stageAndCommit;
25
+ }
26
+ });
27
+ const _git = require("./git.js");
28
+ function stage(patternsOrOptions, cwd) {
29
+ const { patterns, ...options } = Array.isArray(patternsOrOptions) ? {
30
+ patterns: patternsOrOptions,
31
+ cwd: cwd
32
+ } : patternsOrOptions;
33
+ for (const pattern of patterns){
34
+ (0, _git.git)([
35
+ "add",
36
+ pattern
37
+ ], {
38
+ ...options,
39
+ description: `Staging changes (git add ${pattern})`
40
+ });
41
+ }
42
+ }
43
+ function commit(messageOrOptions, _cwd, _options) {
44
+ const { message, options, ...gitOptions } = typeof messageOrOptions === "string" ? {
45
+ message: messageOrOptions,
46
+ cwd: _cwd,
47
+ options: _options
48
+ } : messageOrOptions;
49
+ (0, _git.git)([
50
+ "commit",
51
+ "-m",
52
+ message,
53
+ ...options || []
54
+ ], {
55
+ throwOnError: true,
56
+ description: "Committing changes",
57
+ ...gitOptions
58
+ });
59
+ }
60
+ function stageAndCommit(patternsOrOptions, message, cwd, commitOptions) {
61
+ const options = Array.isArray(patternsOrOptions) ? {
62
+ patterns: patternsOrOptions,
63
+ message: message,
64
+ cwd: cwd,
65
+ options: commitOptions
66
+ } : patternsOrOptions;
67
+ stage(options);
68
+ commit(options);
69
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/git/stageAndCommit.ts"],"sourcesContent":["import { git } from \"./git.js\";\nimport type { GitCommitOptions, GitStageOptions } from \"./types.js\";\n\n/**\n * Stages files matching the given patterns.\n */\nexport function stage(options: GitStageOptions): void;\n/** @deprecated Use object params version */\nexport function stage(patterns: string[], cwd: string): void;\nexport function stage(patternsOrOptions: string[] | GitStageOptions, cwd?: string): void {\n const { patterns, ...options } = Array.isArray(patternsOrOptions)\n ? { patterns: patternsOrOptions, cwd: cwd! }\n : patternsOrOptions;\n\n for (const pattern of patterns) {\n git([\"add\", pattern], { ...options, description: `Staging changes (git add ${pattern})` });\n }\n}\n\n/**\n * Commit changes. Throws an error on failure by default.\n */\nexport function commit(options: GitCommitOptions): void;\n/** @deprecated Use object params version */\nexport function commit(message: string, cwd: string, options?: string[]): void;\nexport function commit(messageOrOptions: string | GitCommitOptions, _cwd?: string, _options?: string[]): void {\n const { message, options, ...gitOptions } =\n typeof messageOrOptions === \"string\"\n ? { message: messageOrOptions, cwd: _cwd!, options: _options }\n : messageOrOptions;\n\n git([\"commit\", \"-m\", message, ...(options || [])], {\n throwOnError: true,\n description: \"Committing changes\",\n ...gitOptions,\n });\n}\n\n/**\n * Stages files matching the given patterns and creates a commit with the specified message.\n * Convenience function that combines `stage()` and `commit()`.\n * Throws an error on commit failure by default.\n */\nexport function stageAndCommit(options: GitStageOptions & GitCommitOptions): void;\n/** @deprecated Use object params version */\nexport function stageAndCommit(patterns: string[], message: string, cwd: string, commitOptions?: string[]): void;\nexport function stageAndCommit(\n patternsOrOptions: string[] | (GitStageOptions & GitCommitOptions),\n message?: string,\n cwd?: string,\n commitOptions?: string[]\n): void {\n const options: GitStageOptions & GitCommitOptions = Array.isArray(patternsOrOptions)\n ? { patterns: patternsOrOptions, message: message!, cwd: cwd!, options: commitOptions }\n : patternsOrOptions;\n\n stage(options);\n commit(options);\n}\n"],"names":["commit","stage","stageAndCommit","patternsOrOptions","cwd","patterns","options","Array","isArray","pattern","git","description","messageOrOptions","_cwd","_options","message","gitOptions","throwOnError","commitOptions"],"mappings":";;;;;;;;;;;;;;;;QAyBgBA;eAAAA;;QAhBAC;eAAAA;;QAqCAC;eAAAA;;;qBA9CI;AASb,SAASD,MAAME,iBAA6C,EAAEC,GAAY;IAC/E,MAAM,EAAEC,QAAQ,EAAE,GAAGC,SAAS,GAAGC,MAAMC,OAAO,CAACL,qBAC3C;QAAEE,UAAUF;QAAmBC,KAAKA;IAAK,IACzCD;IAEJ,KAAK,MAAMM,WAAWJ,SAAU;QAC9BK,IAAAA,QAAG,EAAC;YAAC;YAAOD;SAAQ,EAAE;YAAE,GAAGH,OAAO;YAAEK,aAAa,CAAC,yBAAyB,EAAEF,QAAQ,CAAC,CAAC;QAAC;IAC1F;AACF;AAQO,SAAST,OAAOY,gBAA2C,EAAEC,IAAa,EAAEC,QAAmB;IACpG,MAAM,EAAEC,OAAO,EAAET,OAAO,EAAE,GAAGU,YAAY,GACvC,OAAOJ,qBAAqB,WACxB;QAAEG,SAASH;QAAkBR,KAAKS;QAAOP,SAASQ;IAAS,IAC3DF;IAENF,IAAAA,QAAG,EAAC;QAAC;QAAU;QAAMK;WAAaT,WAAW,EAAE;KAAE,EAAE;QACjDW,cAAc;QACdN,aAAa;QACb,GAAGK,UAAU;IACf;AACF;AAUO,SAASd,eACdC,iBAAkE,EAClEY,OAAgB,EAChBX,GAAY,EACZc,aAAwB;IAExB,MAAMZ,UAA8CC,MAAMC,OAAO,CAACL,qBAC9D;QAAEE,UAAUF;QAAmBY,SAASA;QAAUX,KAAKA;QAAME,SAASY;IAAc,IACpFf;IAEJF,MAAMK;IACNN,OAAOM;AACT"}
@@ -43,9 +43,12 @@ export type ParseRemoteBranchOptions = GitCommonOptions & {
43
43
  knownRemotes?: string[];
44
44
  };
45
45
  export type ParsedRemoteBranch = {
46
- /** Remote name, e.g. `origin` */
46
+ /**
47
+ * Remote name, e.g. `origin`.
48
+ * May be an empty string if the original branch reference didn't include a remote.
49
+ */
47
50
  remote: string;
48
- /** Branch name without remote, e.g. `main` */
51
+ /** Branch name without remote, e.g. `main`. This is always set. */
49
52
  remoteBranch: string;
50
53
  };
51
54
  export type GitStageOptions = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/git/types.ts"],"sourcesContent":["/** Options used for all git operations and wrappers */\nexport type GitCommonOptions = {\n cwd: string;\n /** If true, throw if the command fails */\n throwOnError?: boolean;\n};\n\n/** Options for git operations related to a branch */\nexport type GitBranchOptions = { branch: string } & GitCommonOptions;\n\nexport type GitFetchOptions = GitCommonOptions & {\n /** Remote name to fetch, e.g. \"origin\" (if not provided, fetches all remotes) */\n remote?: string;\n /** Branch name to fetch, e.g. \"main\". To use this, `remote` must also be set. */\n remoteBranch?: string;\n /** Extra command line options */\n options?: string[];\n};\n\nexport type GetChangesBetweenRefsOptions = GitCommonOptions & {\n /** The starting reference */\n fromRef: string;\n /** The ending reference */\n toRef?: string;\n /** Extra command line options */\n options?: string[];\n /** Optional file pattern to filter results */\n pattern?: string;\n};\n\nexport type GitInitOptions = Omit<GitCommonOptions, \"throwOnError\"> & {\n /** Email to set in the git config, if not already set */\n email?: string;\n /** Username to set in the git config, if not already set */\n username?: string;\n};\n\nexport type ParseRemoteBranchOptions = GitCommonOptions & {\n /** Branch name with possible remote prefix */\n branch: string;\n /**\n * Well-known remote names. If these appear at the beginning of a branch name, they'll always\n * be returned as `ParsedRemoteBranch.remote` regardless of whether they exist locally.\n * @default [\"origin\", \"upstream\"]\n */\n knownRemotes?: string[];\n};\n\nexport type ParsedRemoteBranch = {\n /** Remote name, e.g. `origin` */\n remote: string;\n /** Branch name without remote, e.g. `main` */\n remoteBranch: string;\n};\n\nexport type GitStageOptions = {\n /** File patterns to stage */\n patterns: string[];\n} & GitCommonOptions;\n\nexport type GitCommitOptions = GitCommonOptions & {\n /** Commit message */\n message: string;\n /** Additional git commit options */\n options?: string[];\n};\n"],"names":[],"mappings":"AAAA,qDAAqD"}
1
+ {"version":3,"sources":["../../src/git/types.ts"],"sourcesContent":["/** Options used for all git operations and wrappers */\nexport type GitCommonOptions = {\n cwd: string;\n /** If true, throw if the command fails */\n throwOnError?: boolean;\n};\n\n/** Options for git operations related to a branch */\nexport type GitBranchOptions = { branch: string } & GitCommonOptions;\n\nexport type GitFetchOptions = GitCommonOptions & {\n /** Remote name to fetch, e.g. \"origin\" (if not provided, fetches all remotes) */\n remote?: string;\n /** Branch name to fetch, e.g. \"main\". To use this, `remote` must also be set. */\n remoteBranch?: string;\n /** Extra command line options */\n options?: string[];\n};\n\nexport type GetChangesBetweenRefsOptions = GitCommonOptions & {\n /** The starting reference */\n fromRef: string;\n /** The ending reference */\n toRef?: string;\n /** Extra command line options */\n options?: string[];\n /** Optional file pattern to filter results */\n pattern?: string;\n};\n\nexport type GitInitOptions = Omit<GitCommonOptions, \"throwOnError\"> & {\n /** Email to set in the git config, if not already set */\n email?: string;\n /** Username to set in the git config, if not already set */\n username?: string;\n};\n\nexport type ParseRemoteBranchOptions = GitCommonOptions & {\n /** Branch name with possible remote prefix */\n branch: string;\n /**\n * Well-known remote names. If these appear at the beginning of a branch name, they'll always\n * be returned as `ParsedRemoteBranch.remote` regardless of whether they exist locally.\n * @default [\"origin\", \"upstream\"]\n */\n knownRemotes?: string[];\n};\n\nexport type ParsedRemoteBranch = {\n /**\n * Remote name, e.g. `origin`.\n * May be an empty string if the original branch reference didn't include a remote.\n */\n remote: string;\n /** Branch name without remote, e.g. `main`. This is always set. */\n remoteBranch: string;\n};\n\nexport type GitStageOptions = {\n /** File patterns to stage */\n patterns: string[];\n} & GitCommonOptions;\n\nexport type GitCommitOptions = GitCommonOptions & {\n /** Commit message */\n message: string;\n /** Additional git commit options */\n options?: string[];\n};\n"],"names":[],"mappings":"AAAA,qDAAqD"}
@@ -9,18 +9,23 @@ export declare function isCatalogVersion(version: string): boolean;
9
9
  *
10
10
  * Throws an error if there's anything invalid about the catalog spec (no catalogs defined,
11
11
  * no matching catalog, catalog doesn't contain `name`, recursive catalog version).
12
+ * If `allowNotFound` is true, it will return undefined if no match instead.
12
13
  *
13
14
  * Returns undefined if the version doesn't start with `catalog:`.
14
15
  * @see https://pnpm.io/catalogs
15
16
  * @see https://yarnpkg.com/features/catalogs
16
17
  *
17
- * @param name - Dependency package name
18
- * @param version - Dependency version spec, e.g. `catalog:my-catalog` or `catalog:`,
19
- * or some non-catalog spec like `^1.2.3`
20
18
  * @returns Actual version spec from the catalog, or undefined if not a catalog version
19
+ * (or undefined if `allowNotFound` is true and the package isn't in the catalog)
21
20
  */
22
21
  export declare function getCatalogVersion(params: {
22
+ /** Dependency package name */
23
23
  name: string;
24
+ /**
25
+ * Dependency version spec, e.g. `catalog:my-catalog` or `catalog:`, or some non-catalog
26
+ * spec like `^1.2.3`
27
+ */
24
28
  version: string;
25
29
  catalogs: Catalogs | undefined;
30
+ allowNotFound?: boolean;
26
31
  }): string | undefined;