@proteinjs/reflection-build 1.2.0 → 1.3.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/src/build.js +30 -15
  3. package/dist/src/build.js.map +1 -1
  4. package/dist/src/codegen/writeGeneratedIndex.d.ts +7 -1
  5. package/dist/src/codegen/writeGeneratedIndex.js +13 -5
  6. package/dist/src/codegen/writeGeneratedIndex.js.map +1 -1
  7. package/dist/src/parser/createSourceGraph.d.ts +1 -1
  8. package/dist/src/parser/createSourceGraph.js +36 -22
  9. package/dist/src/parser/createSourceGraph.js.map +1 -1
  10. package/package.json +4 -4
  11. package/src/build.ts +45 -14
  12. package/src/codegen/writeGeneratedIndex.ts +23 -4
  13. package/src/parser/createSourceGraph.ts +21 -12
  14. package/test/examples/source-repository/a/dist/build.js +30 -15
  15. package/test/examples/source-repository/a/dist/build.js.map +1 -1
  16. package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.d.ts +7 -1
  17. package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.js +13 -5
  18. package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.js.map +1 -1
  19. package/test/examples/source-repository/a/dist/parser/createSourceGraph.d.ts +1 -1
  20. package/test/examples/source-repository/a/dist/parser/createSourceGraph.js +36 -22
  21. package/test/examples/source-repository/a/dist/parser/createSourceGraph.js.map +1 -1
  22. package/test/examples/source-repository/a/node_modules/.package-lock.json +6 -6
  23. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/CHANGELOG.md +13 -0
  24. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/Fs.d.ts +23 -0
  25. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/Fs.js +67 -0
  26. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/Fs.js.map +1 -1
  27. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/GitUtil.d.ts +297 -10
  28. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/GitUtil.js +349 -112
  29. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/GitUtil.js.map +1 -1
  30. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/cmd.d.ts +10 -1
  31. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/cmd.js +91 -48
  32. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/cmd.js.map +1 -1
  33. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/package.json +2 -2
  34. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/src/Fs.ts +75 -0
  35. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/src/GitUtil.ts +248 -110
  36. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/src/cmd.ts +84 -59
  37. package/test/examples/source-repository/a/package-lock.json +8 -8
  38. package/test/examples/source-repository/a/package.json +2 -2
  39. package/test/examples/source-repository/b/dist/build.js +30 -15
  40. package/test/examples/source-repository/b/dist/build.js.map +1 -1
  41. package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.d.ts +7 -1
  42. package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.js +13 -5
  43. package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.js.map +1 -1
  44. package/test/examples/source-repository/b/dist/parser/createSourceGraph.d.ts +1 -1
  45. package/test/examples/source-repository/b/dist/parser/createSourceGraph.js +36 -22
  46. package/test/examples/source-repository/b/dist/parser/createSourceGraph.js.map +1 -1
  47. package/test/examples/source-repository/b/node_modules/.package-lock.json +4 -4
  48. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/CHANGELOG.md +13 -0
  49. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/Fs.d.ts +23 -0
  50. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/Fs.js +67 -0
  51. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/Fs.js.map +1 -1
  52. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/GitUtil.d.ts +297 -10
  53. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/GitUtil.js +349 -112
  54. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/GitUtil.js.map +1 -1
  55. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/cmd.d.ts +10 -1
  56. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/cmd.js +91 -48
  57. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/cmd.js.map +1 -1
  58. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/package.json +2 -2
  59. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/src/Fs.ts +75 -0
  60. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/src/GitUtil.ts +248 -110
  61. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/src/cmd.ts +84 -59
  62. package/test/examples/source-repository/b/package-lock.json +6 -6
  63. package/test/examples/source-repository/b/package.json +2 -2
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -36,22 +47,26 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
47
  }
37
48
  };
38
49
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.gitFunctions = exports.syncFunction = exports.syncFunctionName = exports.addAllFunction = exports.addAllFunctionName = exports.statusFunction = exports.statusFunctionName = exports.pushFunction = exports.pushFunctionName = exports.pullFunction = exports.pullFunctionName = exports.commitFunction = exports.commitFunctionName = exports.addRemoteFunction = exports.addRemoteFunctionName = exports.setRemoteFunction = exports.setRemoteFunctionName = exports.initFunction = exports.initFunctionName = exports.cloneAppTemplatePackagesFunction = exports.cloneAppTemplatePackagesFunctionName = exports.GitUtil = void 0;
50
+ exports.gitFunctions = exports.applyPatchFunction = exports.applyPatchFunctionName = exports.diffPatchFunction = exports.diffPatchFunctionName = exports.checkoutFunction = exports.checkoutFunctionName = exports.createBranchFunction = exports.createBranchFunctionName = exports.headShaFunction = exports.headShaFunctionName = exports.currentBranchFunction = exports.currentBranchFunctionName = exports.syncFunction = exports.syncFunctionName = exports.addAllFunction = exports.addAllFunctionName = exports.statusFunction = exports.statusFunctionName = exports.pushFunction = exports.pushFunctionName = exports.pullFunction = exports.pullFunctionName = exports.commitFunction = exports.commitFunctionName = exports.addRemoteFunction = exports.addRemoteFunctionName = exports.setRemoteFunction = exports.setRemoteFunctionName = exports.initFunction = exports.initFunctionName = exports.cloneAppTemplatePackagesFunction = exports.cloneAppTemplatePackagesFunctionName = exports.GitUtil = void 0;
40
51
  var cmd_1 = require("./cmd");
52
+ var DEFAULT_SILENT_LOG = {
53
+ omitLogs: {
54
+ stdout: { omit: true },
55
+ stderr: { omit: true },
56
+ },
57
+ };
41
58
  var GitUtil = /** @class */ (function () {
42
59
  function GitUtil() {
43
60
  }
44
- GitUtil.cloneAppTemplatePackages = function (directory) {
61
+ GitUtil.cloneAppTemplatePackages = function (directory, opts) {
45
62
  return __awaiter(this, void 0, void 0, function () {
46
- var args, envVars;
63
+ var args, env;
47
64
  return __generator(this, function (_a) {
48
65
  switch (_a.label) {
49
66
  case 0:
50
- args = ['clone', 'https://github.com/brentbahry/app-template.git', directory];
51
- if (directory) {
52
- envVars = { cwd: directory };
53
- }
54
- return [4 /*yield*/, (0, cmd_1.cmd)('git', args, envVars)];
67
+ args = ['clone', 'https://github.com/proteinjs/app-template.git', directory];
68
+ env = directory ? { cwd: directory } : undefined;
69
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
55
70
  case 1:
56
71
  _a.sent();
57
72
  return [2 /*return*/];
@@ -59,17 +74,15 @@ var GitUtil = /** @class */ (function () {
59
74
  });
60
75
  });
61
76
  };
62
- GitUtil.init = function (directory) {
77
+ GitUtil.init = function (directory, opts) {
63
78
  return __awaiter(this, void 0, void 0, function () {
64
- var args, envVars;
79
+ var args, env;
65
80
  return __generator(this, function (_a) {
66
81
  switch (_a.label) {
67
82
  case 0:
68
83
  args = ['init'];
69
- if (directory) {
70
- envVars = { cwd: directory };
71
- }
72
- return [4 /*yield*/, (0, cmd_1.cmd)('git', args, envVars)];
84
+ env = directory ? { cwd: directory } : undefined;
85
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
73
86
  case 1:
74
87
  _a.sent();
75
88
  return [2 /*return*/];
@@ -77,17 +90,15 @@ var GitUtil = /** @class */ (function () {
77
90
  });
78
91
  });
79
92
  };
80
- GitUtil.setRemote = function (directory, remote) {
93
+ GitUtil.setRemote = function (directory, remote, opts) {
81
94
  return __awaiter(this, void 0, void 0, function () {
82
- var args, envVars;
95
+ var args, env;
83
96
  return __generator(this, function (_a) {
84
97
  switch (_a.label) {
85
98
  case 0:
86
99
  args = ['remote', 'set-url', 'origin', remote];
87
- if (directory) {
88
- envVars = { cwd: directory };
89
- }
90
- return [4 /*yield*/, (0, cmd_1.cmd)('git', args, envVars)];
100
+ env = directory ? { cwd: directory } : undefined;
101
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
91
102
  case 1:
92
103
  _a.sent();
93
104
  return [2 /*return*/];
@@ -95,17 +106,15 @@ var GitUtil = /** @class */ (function () {
95
106
  });
96
107
  });
97
108
  };
98
- GitUtil.addRemote = function (directory, remote) {
109
+ GitUtil.addRemote = function (directory, remote, opts) {
99
110
  return __awaiter(this, void 0, void 0, function () {
100
- var args, envVars;
111
+ var args, env;
101
112
  return __generator(this, function (_a) {
102
113
  switch (_a.label) {
103
114
  case 0:
104
115
  args = ['remote', 'add', 'origin', remote];
105
- if (directory) {
106
- envVars = { cwd: directory };
107
- }
108
- return [4 /*yield*/, (0, cmd_1.cmd)('git', args, envVars)];
116
+ env = directory ? { cwd: directory } : undefined;
117
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
109
118
  case 1:
110
119
  _a.sent();
111
120
  return [2 /*return*/];
@@ -113,17 +122,15 @@ var GitUtil = /** @class */ (function () {
113
122
  });
114
123
  });
115
124
  };
116
- GitUtil.commit = function (directory, message) {
125
+ GitUtil.commit = function (directory, message, opts) {
117
126
  return __awaiter(this, void 0, void 0, function () {
118
- var args, envVars;
127
+ var args, env;
119
128
  return __generator(this, function (_a) {
120
129
  switch (_a.label) {
121
130
  case 0:
122
131
  args = ['commit', '-m', message];
123
- if (directory) {
124
- envVars = { cwd: directory };
125
- }
126
- return [4 /*yield*/, (0, cmd_1.cmd)('git', args, envVars)];
132
+ env = directory ? { cwd: directory } : undefined;
133
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
127
134
  case 1:
128
135
  _a.sent();
129
136
  return [2 /*return*/];
@@ -131,17 +138,15 @@ var GitUtil = /** @class */ (function () {
131
138
  });
132
139
  });
133
140
  };
134
- GitUtil.pull = function (directory) {
141
+ GitUtil.pull = function (directory, opts) {
135
142
  return __awaiter(this, void 0, void 0, function () {
136
- var args, envVars;
143
+ var args, env;
137
144
  return __generator(this, function (_a) {
138
145
  switch (_a.label) {
139
146
  case 0:
140
147
  args = ['pull'];
141
- if (directory) {
142
- envVars = { cwd: directory };
143
- }
144
- return [4 /*yield*/, (0, cmd_1.cmd)('git', args, envVars)];
148
+ env = directory ? { cwd: directory } : undefined;
149
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
145
150
  case 1:
146
151
  _a.sent();
147
152
  return [2 /*return*/];
@@ -149,17 +154,15 @@ var GitUtil = /** @class */ (function () {
149
154
  });
150
155
  });
151
156
  };
152
- GitUtil.push = function (directory) {
157
+ GitUtil.push = function (directory, opts) {
153
158
  return __awaiter(this, void 0, void 0, function () {
154
- var args, envVars;
159
+ var args, env;
155
160
  return __generator(this, function (_a) {
156
161
  switch (_a.label) {
157
162
  case 0:
158
163
  args = ['push'];
159
- if (directory) {
160
- envVars = { cwd: directory };
161
- }
162
- return [4 /*yield*/, (0, cmd_1.cmd)('git', args, envVars)];
164
+ env = directory ? { cwd: directory } : undefined;
165
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
163
166
  case 1:
164
167
  _a.sent();
165
168
  return [2 /*return*/];
@@ -167,17 +170,15 @@ var GitUtil = /** @class */ (function () {
167
170
  });
168
171
  });
169
172
  };
170
- GitUtil.status = function (directory) {
173
+ GitUtil.status = function (directory, opts) {
171
174
  return __awaiter(this, void 0, void 0, function () {
172
- var args, envVars;
175
+ var args, env;
173
176
  return __generator(this, function (_a) {
174
177
  switch (_a.label) {
175
178
  case 0:
176
179
  args = ['status'];
177
- if (directory) {
178
- envVars = { cwd: directory };
179
- }
180
- return [4 /*yield*/, (0, cmd_1.cmd)('git', args, envVars)];
180
+ env = directory ? { cwd: directory } : undefined;
181
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
181
182
  case 1:
182
183
  _a.sent();
183
184
  return [2 /*return*/];
@@ -185,17 +186,15 @@ var GitUtil = /** @class */ (function () {
185
186
  });
186
187
  });
187
188
  };
188
- GitUtil.addAll = function (directory) {
189
+ GitUtil.addAll = function (directory, opts) {
189
190
  return __awaiter(this, void 0, void 0, function () {
190
- var args, envVars;
191
+ var args, env;
191
192
  return __generator(this, function (_a) {
192
193
  switch (_a.label) {
193
194
  case 0:
194
- args = ['add', '.'];
195
- if (directory) {
196
- envVars = { cwd: directory };
197
- }
198
- return [4 /*yield*/, (0, cmd_1.cmd)('git', args, envVars)];
195
+ args = ['add', '-A'];
196
+ env = directory ? { cwd: directory } : undefined;
197
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
199
198
  case 1:
200
199
  _a.sent();
201
200
  return [2 /*return*/];
@@ -203,14 +202,14 @@ var GitUtil = /** @class */ (function () {
203
202
  });
204
203
  });
205
204
  };
206
- GitUtil.sync = function (directory) {
205
+ GitUtil.sync = function (directory, opts) {
207
206
  return __awaiter(this, void 0, void 0, function () {
208
207
  return __generator(this, function (_a) {
209
208
  switch (_a.label) {
210
- case 0: return [4 /*yield*/, GitUtil.pull(directory)];
209
+ case 0: return [4 /*yield*/, GitUtil.pull(directory, opts)];
211
210
  case 1:
212
211
  _a.sent();
213
- return [4 /*yield*/, GitUtil.push(directory)];
212
+ return [4 /*yield*/, GitUtil.push(directory, opts)];
214
213
  case 2:
215
214
  _a.sent();
216
215
  return [2 /*return*/];
@@ -218,9 +217,148 @@ var GitUtil = /** @class */ (function () {
218
217
  });
219
218
  });
220
219
  };
220
+ /** Return the current branch name. */
221
+ GitUtil.currentBranch = function (directory, opts) {
222
+ return __awaiter(this, void 0, void 0, function () {
223
+ var args, env, stdout;
224
+ return __generator(this, function (_a) {
225
+ switch (_a.label) {
226
+ case 0:
227
+ args = ['rev-parse', '--abbrev-ref', 'HEAD'];
228
+ env = directory ? { cwd: directory } : undefined;
229
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
230
+ case 1:
231
+ stdout = (_a.sent()).stdout;
232
+ return [2 /*return*/, String(stdout !== null && stdout !== void 0 ? stdout : '').trim()];
233
+ }
234
+ });
235
+ });
236
+ };
237
+ /** Return the current HEAD SHA. */
238
+ GitUtil.headSha = function (directory, opts) {
239
+ return __awaiter(this, void 0, void 0, function () {
240
+ var args, env, stdout;
241
+ return __generator(this, function (_a) {
242
+ switch (_a.label) {
243
+ case 0:
244
+ args = ['rev-parse', 'HEAD'];
245
+ env = directory ? { cwd: directory } : undefined;
246
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
247
+ case 1:
248
+ stdout = (_a.sent()).stdout;
249
+ return [2 /*return*/, String(stdout !== null && stdout !== void 0 ? stdout : '').trim()];
250
+ }
251
+ });
252
+ });
253
+ };
254
+ /** Create and switch to a new branch. */
255
+ GitUtil.createBranch = function (directory, name, opts) {
256
+ return __awaiter(this, void 0, void 0, function () {
257
+ var args, env;
258
+ return __generator(this, function (_a) {
259
+ switch (_a.label) {
260
+ case 0:
261
+ args = ['checkout', '-b', name];
262
+ env = directory ? { cwd: directory } : undefined;
263
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
264
+ case 1:
265
+ _a.sent();
266
+ return [2 /*return*/];
267
+ }
268
+ });
269
+ });
270
+ };
271
+ /** Checkout an existing branch. */
272
+ GitUtil.checkout = function (directory, name, opts) {
273
+ return __awaiter(this, void 0, void 0, function () {
274
+ var args, env;
275
+ return __generator(this, function (_a) {
276
+ switch (_a.label) {
277
+ case 0:
278
+ args = ['checkout', name];
279
+ env = directory ? { cwd: directory } : undefined;
280
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, opts === null || opts === void 0 ? void 0 : opts.log)];
281
+ case 1:
282
+ _a.sent();
283
+ return [2 /*return*/];
284
+ }
285
+ });
286
+ });
287
+ };
288
+ /** Return a binary-safe patch between two refs (from..to). Defaults to no logging. */
289
+ GitUtil.diffPatch = function (directory, fromRef, toRef, opts) {
290
+ var _a;
291
+ return __awaiter(this, void 0, void 0, function () {
292
+ var args, env, log, stdout;
293
+ return __generator(this, function (_b) {
294
+ switch (_b.label) {
295
+ case 0:
296
+ args = ['diff', '--binary', "".concat(fromRef, "..").concat(toRef)];
297
+ env = directory ? { cwd: directory } : undefined;
298
+ log = (_a = opts === null || opts === void 0 ? void 0 : opts.log) !== null && _a !== void 0 ? _a : DEFAULT_SILENT_LOG;
299
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, log)];
300
+ case 1:
301
+ stdout = (_b.sent()).stdout;
302
+ return [2 /*return*/, String(stdout !== null && stdout !== void 0 ? stdout : '')];
303
+ }
304
+ });
305
+ });
306
+ };
307
+ /**
308
+ * Apply a patch to the working tree (stdin piped). Defaults to no logging.
309
+ * When `staged` is true, applies to the index only; otherwise as unstaged changes.
310
+ * When `reverse` is true, applies the patch in reverse.
311
+ */
312
+ GitUtil.applyPatch = function (directory, patch, opts) {
313
+ var _a;
314
+ if (opts === void 0) { opts = {}; }
315
+ return __awaiter(this, void 0, void 0, function () {
316
+ var args, env, baseLog;
317
+ return __generator(this, function (_b) {
318
+ switch (_b.label) {
319
+ case 0:
320
+ args = ['apply', '--whitespace=nowarn'];
321
+ if (opts.reverse) {
322
+ args.push('--reverse');
323
+ }
324
+ if (opts.staged) {
325
+ args.push('--cached');
326
+ }
327
+ args.push('-'); // read patch from stdin
328
+ env = directory ? { cwd: directory } : undefined;
329
+ baseLog = (_a = opts.log) !== null && _a !== void 0 ? _a : DEFAULT_SILENT_LOG;
330
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', args, env, __assign(__assign({}, baseLog), { stdin: patch }))];
331
+ case 1:
332
+ _b.sent();
333
+ return [2 /*return*/];
334
+ }
335
+ });
336
+ });
337
+ };
338
+ GitUtil.hasStagedChanges = function (directory, opts) {
339
+ var _a;
340
+ return __awaiter(this, void 0, void 0, function () {
341
+ var _b;
342
+ return __generator(this, function (_c) {
343
+ switch (_c.label) {
344
+ case 0:
345
+ _c.trys.push([0, 2, , 3]);
346
+ return [4 /*yield*/, (0, cmd_1.cmd)('git', ['diff', '--cached', '--quiet'], directory ? { cwd: directory } : {}, (_a = opts === null || opts === void 0 ? void 0 : opts.log) !== null && _a !== void 0 ? _a : DEFAULT_SILENT_LOG)];
347
+ case 1:
348
+ _c.sent();
349
+ return [2 /*return*/, false];
350
+ case 2:
351
+ _b = _c.sent();
352
+ return [2 /*return*/, true];
353
+ case 3: return [2 /*return*/];
354
+ }
355
+ });
356
+ });
357
+ };
221
358
  return GitUtil;
222
359
  }());
223
360
  exports.GitUtil = GitUtil;
361
+ /* ---------- exported function wrappers (unchanged public API) ---------- */
224
362
  exports.cloneAppTemplatePackagesFunctionName = 'cloneAppTemplatePackages';
225
363
  exports.cloneAppTemplatePackagesFunction = {
226
364
  definition: {
@@ -229,10 +367,7 @@ exports.cloneAppTemplatePackagesFunction = {
229
367
  parameters: {
230
368
  type: 'object',
231
369
  properties: {
232
- directory: {
233
- type: 'string',
234
- description: 'The directory to clone the packages to',
235
- },
370
+ directory: { type: 'string', description: 'The directory to clone the packages to' },
236
371
  },
237
372
  required: ['directory'],
238
373
  },
@@ -252,10 +387,7 @@ exports.initFunction = {
252
387
  parameters: {
253
388
  type: 'object',
254
389
  properties: {
255
- directory: {
256
- type: 'string',
257
- description: 'The directory to initialize the git repository in',
258
- },
390
+ directory: { type: 'string', description: 'The directory to initialize the git repository in' },
259
391
  },
260
392
  required: ['directory'],
261
393
  },
@@ -275,14 +407,8 @@ exports.setRemoteFunction = {
275
407
  parameters: {
276
408
  type: 'object',
277
409
  properties: {
278
- directory: {
279
- type: 'string',
280
- description: 'The directory of the git repository',
281
- },
282
- remote: {
283
- type: 'string',
284
- description: 'The remote to set',
285
- },
410
+ directory: { type: 'string', description: 'The directory of the git repository' },
411
+ remote: { type: 'string', description: 'The remote to set' },
286
412
  },
287
413
  required: ['directory', 'remote'],
288
414
  },
@@ -302,14 +428,8 @@ exports.addRemoteFunction = {
302
428
  parameters: {
303
429
  type: 'object',
304
430
  properties: {
305
- directory: {
306
- type: 'string',
307
- description: 'The directory of the git repository',
308
- },
309
- remote: {
310
- type: 'string',
311
- description: 'The remote to add',
312
- },
431
+ directory: { type: 'string', description: 'The directory of the git repository' },
432
+ remote: { type: 'string', description: 'The remote to add' },
313
433
  },
314
434
  required: ['directory', 'remote'],
315
435
  },
@@ -329,14 +449,8 @@ exports.commitFunction = {
329
449
  parameters: {
330
450
  type: 'object',
331
451
  properties: {
332
- directory: {
333
- type: 'string',
334
- description: 'The directory of the git repository',
335
- },
336
- message: {
337
- type: 'string',
338
- description: 'The commit message',
339
- },
452
+ directory: { type: 'string', description: 'The directory of the git repository' },
453
+ message: { type: 'string', description: 'The commit message' },
340
454
  },
341
455
  required: ['directory', 'message'],
342
456
  },
@@ -356,10 +470,7 @@ exports.pullFunction = {
356
470
  parameters: {
357
471
  type: 'object',
358
472
  properties: {
359
- directory: {
360
- type: 'string',
361
- description: 'The directory of the git repository',
362
- },
473
+ directory: { type: 'string', description: 'The directory of the git repository' },
363
474
  },
364
475
  required: ['directory'],
365
476
  },
@@ -379,10 +490,7 @@ exports.pushFunction = {
379
490
  parameters: {
380
491
  type: 'object',
381
492
  properties: {
382
- directory: {
383
- type: 'string',
384
- description: 'The directory of the git repository',
385
- },
493
+ directory: { type: 'string', description: 'The directory of the git repository' },
386
494
  },
387
495
  required: ['directory'],
388
496
  },
@@ -402,10 +510,7 @@ exports.statusFunction = {
402
510
  parameters: {
403
511
  type: 'object',
404
512
  properties: {
405
- directory: {
406
- type: 'string',
407
- description: 'The directory of the git repository',
408
- },
513
+ directory: { type: 'string', description: 'The directory of the git repository' },
409
514
  },
410
515
  required: ['directory'],
411
516
  },
@@ -425,10 +530,7 @@ exports.addAllFunction = {
425
530
  parameters: {
426
531
  type: 'object',
427
532
  properties: {
428
- directory: {
429
- type: 'string',
430
- description: 'The directory of the git repository',
431
- },
533
+ directory: { type: 'string', description: 'The directory of the git repository' },
432
534
  },
433
535
  required: ['directory'],
434
536
  },
@@ -448,10 +550,7 @@ exports.syncFunction = {
448
550
  parameters: {
449
551
  type: 'object',
450
552
  properties: {
451
- directory: {
452
- type: 'string',
453
- description: 'The directory of the git repository',
454
- },
553
+ directory: { type: 'string', description: 'The directory of the git repository' },
455
554
  },
456
555
  required: ['directory'],
457
556
  },
@@ -463,6 +562,138 @@ exports.syncFunction = {
463
562
  }
464
563
  }); }); },
465
564
  };
565
+ exports.currentBranchFunctionName = 'gitCurrentBranch';
566
+ exports.currentBranchFunction = {
567
+ definition: {
568
+ name: exports.currentBranchFunctionName,
569
+ description: 'Get the current branch name',
570
+ parameters: {
571
+ type: 'object',
572
+ properties: {
573
+ directory: { type: 'string', description: 'Repository directory' },
574
+ },
575
+ required: ['directory'],
576
+ },
577
+ },
578
+ call: function (params) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
579
+ switch (_a.label) {
580
+ case 0: return [4 /*yield*/, GitUtil.currentBranch(params.directory)];
581
+ case 1: return [2 /*return*/, _a.sent()];
582
+ }
583
+ }); }); },
584
+ };
585
+ exports.headShaFunctionName = 'gitHeadSha';
586
+ exports.headShaFunction = {
587
+ definition: {
588
+ name: exports.headShaFunctionName,
589
+ description: 'Get the SHA of HEAD',
590
+ parameters: {
591
+ type: 'object',
592
+ properties: {
593
+ directory: { type: 'string', description: 'Repository directory' },
594
+ },
595
+ required: ['directory'],
596
+ },
597
+ },
598
+ call: function (params) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
599
+ switch (_a.label) {
600
+ case 0: return [4 /*yield*/, GitUtil.headSha(params.directory)];
601
+ case 1: return [2 /*return*/, _a.sent()];
602
+ }
603
+ }); }); },
604
+ };
605
+ exports.createBranchFunctionName = 'gitCreateBranch';
606
+ exports.createBranchFunction = {
607
+ definition: {
608
+ name: exports.createBranchFunctionName,
609
+ description: 'Create and switch to a new branch',
610
+ parameters: {
611
+ type: 'object',
612
+ properties: {
613
+ directory: { type: 'string', description: 'Repository directory' },
614
+ name: { type: 'string', description: 'Branch name' },
615
+ },
616
+ required: ['directory', 'name'],
617
+ },
618
+ },
619
+ call: function (params) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
620
+ switch (_a.label) {
621
+ case 0: return [4 /*yield*/, GitUtil.createBranch(params.directory, params.name)];
622
+ case 1: return [2 /*return*/, _a.sent()];
623
+ }
624
+ }); }); },
625
+ };
626
+ exports.checkoutFunctionName = 'gitCheckout';
627
+ exports.checkoutFunction = {
628
+ definition: {
629
+ name: exports.checkoutFunctionName,
630
+ description: 'Checkout an existing branch',
631
+ parameters: {
632
+ type: 'object',
633
+ properties: {
634
+ directory: { type: 'string', description: 'Repository directory' },
635
+ name: { type: 'string', description: 'Branch name' },
636
+ },
637
+ required: ['directory', 'name'],
638
+ },
639
+ },
640
+ call: function (params) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
641
+ switch (_a.label) {
642
+ case 0: return [4 /*yield*/, GitUtil.checkout(params.directory, params.name)];
643
+ case 1: return [2 /*return*/, _a.sent()];
644
+ }
645
+ }); }); },
646
+ };
647
+ exports.diffPatchFunctionName = 'gitDiffPatch';
648
+ exports.diffPatchFunction = {
649
+ definition: {
650
+ name: exports.diffPatchFunctionName,
651
+ description: 'Return a binary-safe patch between two refs (from..to)',
652
+ parameters: {
653
+ type: 'object',
654
+ properties: {
655
+ directory: { type: 'string', description: 'Repository directory' },
656
+ from: { type: 'string', description: 'From ref' },
657
+ to: { type: 'string', description: 'To ref' },
658
+ },
659
+ required: ['directory', 'from', 'to'],
660
+ },
661
+ },
662
+ call: function (params) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
663
+ switch (_a.label) {
664
+ case 0: return [4 /*yield*/, GitUtil.diffPatch(params.directory, params.from, params.to)];
665
+ case 1: return [2 /*return*/, _a.sent()];
666
+ }
667
+ }); }); },
668
+ };
669
+ exports.applyPatchFunctionName = 'gitApplyPatch';
670
+ exports.applyPatchFunction = {
671
+ definition: {
672
+ name: exports.applyPatchFunctionName,
673
+ description: 'Apply a patch to the working tree',
674
+ parameters: {
675
+ type: 'object',
676
+ properties: {
677
+ directory: { type: 'string', description: 'Repository directory' },
678
+ patch: { type: 'string', description: 'Patch content' },
679
+ reverse: { type: 'boolean', description: 'Apply in reverse', default: false },
680
+ staged: { type: 'boolean', description: 'Apply to index/staged only', default: false },
681
+ },
682
+ required: ['directory', 'patch'],
683
+ },
684
+ },
685
+ call: function (params) { return __awaiter(void 0, void 0, void 0, function () {
686
+ return __generator(this, function (_a) {
687
+ switch (_a.label) {
688
+ case 0: return [4 /*yield*/, GitUtil.applyPatch(params.directory, params.patch, {
689
+ reverse: !!params.reverse,
690
+ staged: !!params.staged,
691
+ })];
692
+ case 1: return [2 /*return*/, _a.sent()];
693
+ }
694
+ });
695
+ }); },
696
+ };
466
697
  exports.gitFunctions = [
467
698
  exports.cloneAppTemplatePackagesFunction,
468
699
  exports.initFunction,
@@ -474,5 +705,11 @@ exports.gitFunctions = [
474
705
  exports.statusFunction,
475
706
  exports.addAllFunction,
476
707
  exports.syncFunction,
708
+ exports.currentBranchFunction,
709
+ exports.headShaFunction,
710
+ exports.createBranchFunction,
711
+ exports.checkoutFunction,
712
+ exports.diffPatchFunction,
713
+ exports.applyPatchFunction,
477
714
  ];
478
715
  //# sourceMappingURL=GitUtil.js.map