plugin-git-manager 1.0.3

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 (156) hide show
  1. package/client.d.ts +3 -0
  2. package/client.js +1 -0
  3. package/dist/client/100.e08d760e0b01997c.js +10 -0
  4. package/dist/client/components/CommitHistory.d.ts +2 -0
  5. package/dist/client/components/FileExplorer.d.ts +2 -0
  6. package/dist/client/components/GitManagerSettings.d.ts +2 -0
  7. package/dist/client/components/GitOperations.d.ts +2 -0
  8. package/dist/client/components/RepositoryConfig.d.ts +2 -0
  9. package/dist/client/context/GitManagerContext.d.ts +24 -0
  10. package/dist/client/index.d.ts +5 -0
  11. package/dist/client/index.js +10 -0
  12. package/dist/client/locale.d.ts +2 -0
  13. package/dist/externalVersion.js +18 -0
  14. package/dist/index.d.ts +2 -0
  15. package/dist/index.js +48 -0
  16. package/dist/locale/en-US.json +45 -0
  17. package/dist/locale/vi-VN.json +45 -0
  18. package/dist/node_modules/simple-git/dist/cjs/index.js +7399 -0
  19. package/dist/node_modules/simple-git/dist/esm/index.js +4745 -0
  20. package/dist/node_modules/simple-git/dist/esm/package.json +3 -0
  21. package/dist/node_modules/simple-git/dist/src/lib/api.d.ts +13 -0
  22. package/dist/node_modules/simple-git/dist/src/lib/args/log-format.d.ts +9 -0
  23. package/dist/node_modules/simple-git/dist/src/lib/errors/git-construct-error.d.ts +15 -0
  24. package/dist/node_modules/simple-git/dist/src/lib/errors/git-error.d.ts +30 -0
  25. package/dist/node_modules/simple-git/dist/src/lib/errors/git-plugin-error.d.ts +7 -0
  26. package/dist/node_modules/simple-git/dist/src/lib/errors/git-response-error.d.ts +32 -0
  27. package/dist/node_modules/simple-git/dist/src/lib/errors/task-configuration-error.d.ts +12 -0
  28. package/dist/node_modules/simple-git/dist/src/lib/git-factory.d.ts +15 -0
  29. package/dist/node_modules/simple-git/dist/src/lib/git-logger.d.ts +21 -0
  30. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch-delete.d.ts +5 -0
  31. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch.d.ts +2 -0
  32. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-commit.d.ts +2 -0
  33. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-diff-summary.d.ts +3 -0
  34. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-fetch.d.ts +2 -0
  35. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-list-log-summary.d.ts +6 -0
  36. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-merge.d.ts +11 -0
  37. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-move.d.ts +2 -0
  38. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-pull.d.ts +6 -0
  39. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-push.d.ts +4 -0
  40. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-messages.d.ts +5 -0
  41. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-objects.d.ts +3 -0
  42. package/dist/node_modules/simple-git/dist/src/lib/plugins/abort-plugin.d.ts +3 -0
  43. package/dist/node_modules/simple-git/dist/src/lib/plugins/block-unsafe-operations-plugin.d.ts +3 -0
  44. package/dist/node_modules/simple-git/dist/src/lib/plugins/command-config-prefixing-plugin.d.ts +2 -0
  45. package/dist/node_modules/simple-git/dist/src/lib/plugins/completion-detection.plugin.d.ts +3 -0
  46. package/dist/node_modules/simple-git/dist/src/lib/plugins/custom-binary.plugin.d.ts +3 -0
  47. package/dist/node_modules/simple-git/dist/src/lib/plugins/error-detection.plugin.d.ts +7 -0
  48. package/dist/node_modules/simple-git/dist/src/lib/plugins/index.d.ts +11 -0
  49. package/dist/node_modules/simple-git/dist/src/lib/plugins/plugin-store.d.ts +11 -0
  50. package/dist/node_modules/simple-git/dist/src/lib/plugins/progress-monitor-plugin.d.ts +3 -0
  51. package/dist/node_modules/simple-git/dist/src/lib/plugins/simple-git-plugin.d.ts +48 -0
  52. package/dist/node_modules/simple-git/dist/src/lib/plugins/spawn-options-plugin.d.ts +3 -0
  53. package/dist/node_modules/simple-git/dist/src/lib/plugins/suffix-paths.plugin.d.ts +2 -0
  54. package/dist/node_modules/simple-git/dist/src/lib/plugins/timout-plugin.d.ts +3 -0
  55. package/dist/node_modules/simple-git/dist/src/lib/responses/BranchDeleteSummary.d.ts +12 -0
  56. package/dist/node_modules/simple-git/dist/src/lib/responses/BranchSummary.d.ts +14 -0
  57. package/dist/node_modules/simple-git/dist/src/lib/responses/CheckIgnore.d.ts +4 -0
  58. package/dist/node_modules/simple-git/dist/src/lib/responses/CleanSummary.d.ts +9 -0
  59. package/dist/node_modules/simple-git/dist/src/lib/responses/ConfigList.d.ts +13 -0
  60. package/dist/node_modules/simple-git/dist/src/lib/responses/DiffSummary.d.ts +10 -0
  61. package/dist/node_modules/simple-git/dist/src/lib/responses/FileStatusSummary.d.ts +9 -0
  62. package/dist/node_modules/simple-git/dist/src/lib/responses/GetRemoteSummary.d.ts +11 -0
  63. package/dist/node_modules/simple-git/dist/src/lib/responses/InitSummary.d.ts +9 -0
  64. package/dist/node_modules/simple-git/dist/src/lib/responses/MergeSummary.d.ts +16 -0
  65. package/dist/node_modules/simple-git/dist/src/lib/responses/PullSummary.d.ts +25 -0
  66. package/dist/node_modules/simple-git/dist/src/lib/responses/StatusSummary.d.ts +19 -0
  67. package/dist/node_modules/simple-git/dist/src/lib/responses/TagList.d.ts +7 -0
  68. package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor-chain.d.ts +25 -0
  69. package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor.d.ts +14 -0
  70. package/dist/node_modules/simple-git/dist/src/lib/runners/promise-wrapped.d.ts +2 -0
  71. package/dist/node_modules/simple-git/dist/src/lib/runners/scheduler.d.ts +11 -0
  72. package/dist/node_modules/simple-git/dist/src/lib/runners/tasks-pending-queue.d.ts +23 -0
  73. package/dist/node_modules/simple-git/dist/src/lib/simple-git-api.d.ts +20 -0
  74. package/dist/node_modules/simple-git/dist/src/lib/task-callback.d.ts +2 -0
  75. package/dist/node_modules/simple-git/dist/src/lib/tasks/apply-patch.d.ts +3 -0
  76. package/dist/node_modules/simple-git/dist/src/lib/tasks/branch.d.ts +7 -0
  77. package/dist/node_modules/simple-git/dist/src/lib/tasks/change-working-directory.d.ts +2 -0
  78. package/dist/node_modules/simple-git/dist/src/lib/tasks/check-ignore.d.ts +2 -0
  79. package/dist/node_modules/simple-git/dist/src/lib/tasks/check-is-repo.d.ts +9 -0
  80. package/dist/node_modules/simple-git/dist/src/lib/tasks/checkout.d.ts +2 -0
  81. package/dist/node_modules/simple-git/dist/src/lib/tasks/clean.d.ts +25 -0
  82. package/dist/node_modules/simple-git/dist/src/lib/tasks/clone.d.ts +9 -0
  83. package/dist/node_modules/simple-git/dist/src/lib/tasks/commit.d.ts +4 -0
  84. package/dist/node_modules/simple-git/dist/src/lib/tasks/config.d.ts +8 -0
  85. package/dist/node_modules/simple-git/dist/src/lib/tasks/count-objects.d.ts +12 -0
  86. package/dist/node_modules/simple-git/dist/src/lib/tasks/diff-name-status.d.ts +12 -0
  87. package/dist/node_modules/simple-git/dist/src/lib/tasks/diff.d.ts +5 -0
  88. package/dist/node_modules/simple-git/dist/src/lib/tasks/fetch.d.ts +4 -0
  89. package/dist/node_modules/simple-git/dist/src/lib/tasks/first-commit.d.ts +2 -0
  90. package/dist/node_modules/simple-git/dist/src/lib/tasks/grep.d.ts +12 -0
  91. package/dist/node_modules/simple-git/dist/src/lib/tasks/hash-object.d.ts +5 -0
  92. package/dist/node_modules/simple-git/dist/src/lib/tasks/init.d.ts +3 -0
  93. package/dist/node_modules/simple-git/dist/src/lib/tasks/log.d.ts +32 -0
  94. package/dist/node_modules/simple-git/dist/src/lib/tasks/merge.d.ts +4 -0
  95. package/dist/node_modules/simple-git/dist/src/lib/tasks/move.d.ts +3 -0
  96. package/dist/node_modules/simple-git/dist/src/lib/tasks/pull.d.ts +3 -0
  97. package/dist/node_modules/simple-git/dist/src/lib/tasks/push.d.ts +9 -0
  98. package/dist/node_modules/simple-git/dist/src/lib/tasks/remote.d.ts +8 -0
  99. package/dist/node_modules/simple-git/dist/src/lib/tasks/reset.d.ts +11 -0
  100. package/dist/node_modules/simple-git/dist/src/lib/tasks/show.d.ts +2 -0
  101. package/dist/node_modules/simple-git/dist/src/lib/tasks/stash-list.d.ts +4 -0
  102. package/dist/node_modules/simple-git/dist/src/lib/tasks/status.d.ts +3 -0
  103. package/dist/node_modules/simple-git/dist/src/lib/tasks/sub-module.d.ts +5 -0
  104. package/dist/node_modules/simple-git/dist/src/lib/tasks/tag.d.ts +18 -0
  105. package/dist/node_modules/simple-git/dist/src/lib/tasks/task.d.ts +14 -0
  106. package/dist/node_modules/simple-git/dist/src/lib/tasks/version.d.ts +9 -0
  107. package/dist/node_modules/simple-git/dist/src/lib/types/handlers.d.ts +21 -0
  108. package/dist/node_modules/simple-git/dist/src/lib/types/index.d.ts +136 -0
  109. package/dist/node_modules/simple-git/dist/src/lib/types/tasks.d.ts +19 -0
  110. package/dist/node_modules/simple-git/dist/src/lib/utils/argument-filters.d.ts +14 -0
  111. package/dist/node_modules/simple-git/dist/src/lib/utils/exit-codes.d.ts +10 -0
  112. package/dist/node_modules/simple-git/dist/src/lib/utils/git-output-streams.d.ts +7 -0
  113. package/dist/node_modules/simple-git/dist/src/lib/utils/index.d.ts +8 -0
  114. package/dist/node_modules/simple-git/dist/src/lib/utils/line-parser.d.ts +15 -0
  115. package/dist/node_modules/simple-git/dist/src/lib/utils/simple-git-options.d.ts +2 -0
  116. package/dist/node_modules/simple-git/dist/src/lib/utils/task-options.d.ts +13 -0
  117. package/dist/node_modules/simple-git/dist/src/lib/utils/task-parser.d.ts +5 -0
  118. package/dist/node_modules/simple-git/dist/src/lib/utils/util.d.ts +47 -0
  119. package/dist/node_modules/simple-git/dist/typings/errors.d.ts +5 -0
  120. package/dist/node_modules/simple-git/dist/typings/index.d.ts +14 -0
  121. package/dist/node_modules/simple-git/dist/typings/response.d.ts +556 -0
  122. package/dist/node_modules/simple-git/dist/typings/simple-git.d.ts +1033 -0
  123. package/dist/node_modules/simple-git/dist/typings/types.d.ts +22 -0
  124. package/dist/node_modules/simple-git/node_modules/debug/package.json +64 -0
  125. package/dist/node_modules/simple-git/node_modules/debug/src/browser.js +272 -0
  126. package/dist/node_modules/simple-git/node_modules/debug/src/common.js +292 -0
  127. package/dist/node_modules/simple-git/node_modules/debug/src/index.js +10 -0
  128. package/dist/node_modules/simple-git/node_modules/debug/src/node.js +263 -0
  129. package/dist/node_modules/simple-git/package.json +1 -0
  130. package/dist/node_modules/simple-git/promise.js +17 -0
  131. package/dist/server/actions/git-actions.d.ts +13 -0
  132. package/dist/server/actions/git-actions.js +354 -0
  133. package/dist/server/collections/gitRepositories.d.ts +2 -0
  134. package/dist/server/collections/gitRepositories.js +75 -0
  135. package/dist/server/index.d.ts +2 -0
  136. package/dist/server/index.js +48 -0
  137. package/dist/server/plugin.d.ts +6 -0
  138. package/dist/server/plugin.js +120 -0
  139. package/package.json +32 -0
  140. package/server.d.ts +2 -0
  141. package/server.js +1 -0
  142. package/src/client/components/CommitHistory.tsx +326 -0
  143. package/src/client/components/FileExplorer.tsx +329 -0
  144. package/src/client/components/GitManagerSettings.tsx +123 -0
  145. package/src/client/components/GitOperations.tsx +195 -0
  146. package/src/client/components/RepositoryConfig.tsx +188 -0
  147. package/src/client/context/GitManagerContext.tsx +84 -0
  148. package/src/client/index.tsx +19 -0
  149. package/src/client/locale.ts +9 -0
  150. package/src/index.ts +2 -0
  151. package/src/locale/en-US.json +45 -0
  152. package/src/locale/vi-VN.json +45 -0
  153. package/src/server/actions/git-actions.ts +346 -0
  154. package/src/server/collections/gitRepositories.ts +45 -0
  155. package/src/server/index.ts +2 -0
  156. package/src/server/plugin.ts +81 -0
@@ -0,0 +1,263 @@
1
+ /**
2
+ * Module dependencies.
3
+ */
4
+
5
+ const tty = require('tty');
6
+ const util = require('util');
7
+
8
+ /**
9
+ * This is the Node.js implementation of `debug()`.
10
+ */
11
+
12
+ exports.init = init;
13
+ exports.log = log;
14
+ exports.formatArgs = formatArgs;
15
+ exports.save = save;
16
+ exports.load = load;
17
+ exports.useColors = useColors;
18
+ exports.destroy = util.deprecate(
19
+ () => {},
20
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
21
+ );
22
+
23
+ /**
24
+ * Colors.
25
+ */
26
+
27
+ exports.colors = [6, 2, 3, 4, 5, 1];
28
+
29
+ try {
30
+ // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
31
+ // eslint-disable-next-line import/no-extraneous-dependencies
32
+ const supportsColor = require('supports-color');
33
+
34
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
35
+ exports.colors = [
36
+ 20,
37
+ 21,
38
+ 26,
39
+ 27,
40
+ 32,
41
+ 33,
42
+ 38,
43
+ 39,
44
+ 40,
45
+ 41,
46
+ 42,
47
+ 43,
48
+ 44,
49
+ 45,
50
+ 56,
51
+ 57,
52
+ 62,
53
+ 63,
54
+ 68,
55
+ 69,
56
+ 74,
57
+ 75,
58
+ 76,
59
+ 77,
60
+ 78,
61
+ 79,
62
+ 80,
63
+ 81,
64
+ 92,
65
+ 93,
66
+ 98,
67
+ 99,
68
+ 112,
69
+ 113,
70
+ 128,
71
+ 129,
72
+ 134,
73
+ 135,
74
+ 148,
75
+ 149,
76
+ 160,
77
+ 161,
78
+ 162,
79
+ 163,
80
+ 164,
81
+ 165,
82
+ 166,
83
+ 167,
84
+ 168,
85
+ 169,
86
+ 170,
87
+ 171,
88
+ 172,
89
+ 173,
90
+ 178,
91
+ 179,
92
+ 184,
93
+ 185,
94
+ 196,
95
+ 197,
96
+ 198,
97
+ 199,
98
+ 200,
99
+ 201,
100
+ 202,
101
+ 203,
102
+ 204,
103
+ 205,
104
+ 206,
105
+ 207,
106
+ 208,
107
+ 209,
108
+ 214,
109
+ 215,
110
+ 220,
111
+ 221
112
+ ];
113
+ }
114
+ } catch (error) {
115
+ // Swallow - we only care if `supports-color` is available; it doesn't have to be.
116
+ }
117
+
118
+ /**
119
+ * Build up the default `inspectOpts` object from the environment variables.
120
+ *
121
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
122
+ */
123
+
124
+ exports.inspectOpts = Object.keys(process.env).filter(key => {
125
+ return /^debug_/i.test(key);
126
+ }).reduce((obj, key) => {
127
+ // Camel-case
128
+ const prop = key
129
+ .substring(6)
130
+ .toLowerCase()
131
+ .replace(/_([a-z])/g, (_, k) => {
132
+ return k.toUpperCase();
133
+ });
134
+
135
+ // Coerce string value into JS value
136
+ let val = process.env[key];
137
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
138
+ val = true;
139
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
140
+ val = false;
141
+ } else if (val === 'null') {
142
+ val = null;
143
+ } else {
144
+ val = Number(val);
145
+ }
146
+
147
+ obj[prop] = val;
148
+ return obj;
149
+ }, {});
150
+
151
+ /**
152
+ * Is stdout a TTY? Colored output is enabled when `true`.
153
+ */
154
+
155
+ function useColors() {
156
+ return 'colors' in exports.inspectOpts ?
157
+ Boolean(exports.inspectOpts.colors) :
158
+ tty.isatty(process.stderr.fd);
159
+ }
160
+
161
+ /**
162
+ * Adds ANSI color escape codes if enabled.
163
+ *
164
+ * @api public
165
+ */
166
+
167
+ function formatArgs(args) {
168
+ const {namespace: name, useColors} = this;
169
+
170
+ if (useColors) {
171
+ const c = this.color;
172
+ const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
173
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
174
+
175
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
176
+ args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
177
+ } else {
178
+ args[0] = getDate() + name + ' ' + args[0];
179
+ }
180
+ }
181
+
182
+ function getDate() {
183
+ if (exports.inspectOpts.hideDate) {
184
+ return '';
185
+ }
186
+ return new Date().toISOString() + ' ';
187
+ }
188
+
189
+ /**
190
+ * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
191
+ */
192
+
193
+ function log(...args) {
194
+ return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
195
+ }
196
+
197
+ /**
198
+ * Save `namespaces`.
199
+ *
200
+ * @param {String} namespaces
201
+ * @api private
202
+ */
203
+ function save(namespaces) {
204
+ if (namespaces) {
205
+ process.env.DEBUG = namespaces;
206
+ } else {
207
+ // If you set a process.env field to null or undefined, it gets cast to the
208
+ // string 'null' or 'undefined'. Just delete instead.
209
+ delete process.env.DEBUG;
210
+ }
211
+ }
212
+
213
+ /**
214
+ * Load `namespaces`.
215
+ *
216
+ * @return {String} returns the previously persisted debug modes
217
+ * @api private
218
+ */
219
+
220
+ function load() {
221
+ return process.env.DEBUG;
222
+ }
223
+
224
+ /**
225
+ * Init logic for `debug` instances.
226
+ *
227
+ * Create a new `inspectOpts` object in case `useColors` is set
228
+ * differently for a particular `debug` instance.
229
+ */
230
+
231
+ function init(debug) {
232
+ debug.inspectOpts = {};
233
+
234
+ const keys = Object.keys(exports.inspectOpts);
235
+ for (let i = 0; i < keys.length; i++) {
236
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
237
+ }
238
+ }
239
+
240
+ module.exports = require('./common')(exports);
241
+
242
+ const {formatters} = module.exports;
243
+
244
+ /**
245
+ * Map %o to `util.inspect()`, all on a single line.
246
+ */
247
+
248
+ formatters.o = function (v) {
249
+ this.inspectOpts.colors = this.useColors;
250
+ return util.inspect(v, this.inspectOpts)
251
+ .split('\n')
252
+ .map(str => str.trim())
253
+ .join(' ');
254
+ };
255
+
256
+ /**
257
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
258
+ */
259
+
260
+ formatters.O = function (v) {
261
+ this.inspectOpts.colors = this.useColors;
262
+ return util.inspect(v, this.inspectOpts);
263
+ };
@@ -0,0 +1 @@
1
+ {"name":"simple-git","description":"Simple GIT interface for node.js","version":"3.36.0","author":"Steve King <steve@mydev.co>","contributors":[{"name":"Steve King","email":"steve@mydev.co"}],"funding":{"type":"github","url":"https://github.com/steveukx/git-js?sponsor=1"},"keywords":["git","source control","vcs"],"license":"MIT","repository":{"type":"git","url":"https://github.com/steveukx/git-js.git","directory":"simple-git"},"main":"dist/cjs/index.js","module":"dist/esm/index.js","exports":{".":{"types":"./dist/typings/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"./promise":{"require":"./promise.js"}},"types":"./dist/typings/index.d.ts","files":["promise.*","dist"],"dependencies":{"@kwsites/file-exists":"^1.1.1","@kwsites/promise-deferred":"^1.1.1","@simple-git/args-pathspec":"^1.0.3","@simple-git/argv-parser":"^1.1.0","debug":"^4.4.0"},"_lastModified":"2026-04-25T07:57:51.194Z"}
@@ -0,0 +1,17 @@
1
+ console.error(`=============================================
2
+ simple-git has supported promises / async await since version 2.6.0.
3
+ Importing from 'simple-git/promise' has been deprecated and will
4
+ report this error until the next major release of version 4.
5
+
6
+ To upgrade, change all 'simple-git/promise' imports to just 'simple-git'
7
+ =============================================`);
8
+
9
+ const simpleGit = require('.');
10
+
11
+ module.exports = Object.assign(
12
+ function () {
13
+ return simpleGit.gitP.apply(null, arguments);
14
+ },
15
+ simpleGit,
16
+ { default: simpleGit.gitP }
17
+ );
@@ -0,0 +1,13 @@
1
+ import { Context } from '@nocobase/actions';
2
+ export declare function clone(ctx: Context, next: () => Promise<void>): Promise<void>;
3
+ export declare function pull(ctx: Context, next: () => Promise<void>): Promise<void>;
4
+ export declare function push(ctx: Context, next: () => Promise<void>): Promise<void>;
5
+ export declare function fetch(ctx: Context, next: () => Promise<void>): Promise<void>;
6
+ export declare function diff(ctx: Context, next: () => Promise<void>): Promise<void>;
7
+ export declare function status(ctx: Context, next: () => Promise<void>): Promise<void>;
8
+ export declare function log(ctx: Context, next: () => Promise<void>): Promise<void>;
9
+ export declare function branches(ctx: Context, next: () => Promise<void>): Promise<void>;
10
+ export declare function checkout(ctx: Context, next: () => Promise<void>): Promise<void>;
11
+ export declare function fileTree(ctx: Context, next: () => Promise<void>): Promise<void>;
12
+ export declare function fileContent(ctx: Context, next: () => Promise<void>): Promise<void>;
13
+ export declare function commitDetail(ctx: Context, next: () => Promise<void>): Promise<void>;
@@ -0,0 +1,354 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var git_actions_exports = {};
38
+ __export(git_actions_exports, {
39
+ branches: () => branches,
40
+ checkout: () => checkout,
41
+ clone: () => clone,
42
+ commitDetail: () => commitDetail,
43
+ diff: () => diff,
44
+ fetch: () => fetch,
45
+ fileContent: () => fileContent,
46
+ fileTree: () => fileTree,
47
+ log: () => log,
48
+ pull: () => pull,
49
+ push: () => push,
50
+ status: () => status
51
+ });
52
+ module.exports = __toCommonJS(git_actions_exports);
53
+ var import_simple_git = __toESM(require("simple-git"));
54
+ var path = __toESM(require("path"));
55
+ var fs = __toESM(require("fs"));
56
+ const REF_PATTERN = /^[a-zA-Z0-9._\-\/]+$/;
57
+ const repoLocks = /* @__PURE__ */ new Map();
58
+ function acquireLock(key) {
59
+ const prev = repoLocks.get(key) || Promise.resolve();
60
+ let release;
61
+ const next = new Promise((resolve) => {
62
+ release = resolve;
63
+ });
64
+ const promise = prev.then(() => {
65
+ });
66
+ repoLocks.set(key, next);
67
+ return { promise, release };
68
+ }
69
+ function validateRef(ref) {
70
+ if (!REF_PATTERN.test(ref)) {
71
+ throw new Error(`Invalid ref: ${ref}`);
72
+ }
73
+ return ref;
74
+ }
75
+ function validateBranch(branch) {
76
+ if (!branch || !REF_PATTERN.test(branch)) {
77
+ throw new Error(`Invalid branch name: ${branch}`);
78
+ }
79
+ return branch;
80
+ }
81
+ function validateRepoUrl(repoUrl) {
82
+ let parsed;
83
+ try {
84
+ parsed = new URL(repoUrl);
85
+ } catch {
86
+ throw new Error("Invalid repository URL");
87
+ }
88
+ if (parsed.protocol !== "https:") {
89
+ throw new Error("Only HTTPS repository URLs are allowed");
90
+ }
91
+ }
92
+ async function withAuth(git, repoUrl, pat, fn) {
93
+ const lockKey = repoUrl;
94
+ const lock = acquireLock(lockKey);
95
+ await lock.promise;
96
+ const authUrl = getAuthUrl(repoUrl, pat);
97
+ await git.remote(["set-url", "origin", authUrl]);
98
+ try {
99
+ return await fn();
100
+ } finally {
101
+ await git.remote(["set-url", "origin", repoUrl]);
102
+ lock.release();
103
+ }
104
+ }
105
+ function getAuthUrl(repoUrl, pat) {
106
+ const url = new URL(repoUrl);
107
+ url.username = "oauth2";
108
+ url.password = pat;
109
+ return url.toString();
110
+ }
111
+ function getGit(localPath) {
112
+ return (0, import_simple_git.default)(localPath);
113
+ }
114
+ async function getRepo(ctx) {
115
+ const { repositoryId } = ctx.action.params;
116
+ const repo = await ctx.db.getRepository("gitRepositories").findOne({
117
+ filterByTk: repositoryId
118
+ });
119
+ if (!repo) {
120
+ ctx.throw(404, "Repository not found");
121
+ }
122
+ return repo;
123
+ }
124
+ function validateLocalPath(localPath) {
125
+ const basePath = process.env.GIT_REPOS_BASE_PATH || path.join(process.cwd(), "storage", "git-repos");
126
+ const resolved = path.resolve(basePath, localPath);
127
+ const strictBasePath = path.resolve(basePath) + path.sep;
128
+ if (!resolved.startsWith(strictBasePath) && resolved !== path.resolve(basePath)) {
129
+ throw new Error("Invalid local path: path traversal detected or path is outside the allowed base directory");
130
+ }
131
+ return resolved;
132
+ }
133
+ async function clone(ctx, next) {
134
+ const repo = await getRepo(ctx);
135
+ const localPath = validateLocalPath(repo.get("localPath"));
136
+ const repoUrl = repo.get("repoUrl");
137
+ const pat = repo.get("pat");
138
+ validateRepoUrl(repoUrl);
139
+ if (fs.existsSync(localPath)) {
140
+ ctx.throw(400, "Directory already exists. Remove it before cloning again.");
141
+ }
142
+ if (!fs.existsSync(path.dirname(localPath))) {
143
+ fs.mkdirSync(path.dirname(localPath), { recursive: true });
144
+ }
145
+ const authUrl = getAuthUrl(repoUrl, pat);
146
+ try {
147
+ await (0, import_simple_git.default)().clone(authUrl, localPath, ["--branch", repo.get("defaultBranch") || "main"]);
148
+ await (0, import_simple_git.default)(localPath).remote(["set-url", "origin", repoUrl]);
149
+ await ctx.db.getRepository("gitRepositories").update({
150
+ filterByTk: repo.get("id"),
151
+ values: { status: "connected" }
152
+ });
153
+ ctx.body = { success: true, message: "Repository cloned successfully" };
154
+ } catch (err) {
155
+ await ctx.db.getRepository("gitRepositories").update({
156
+ filterByTk: repo.get("id"),
157
+ values: { status: "error" }
158
+ });
159
+ throw err;
160
+ }
161
+ await next();
162
+ }
163
+ async function pull(ctx, next) {
164
+ const repo = await getRepo(ctx);
165
+ const localPath = validateLocalPath(repo.get("localPath"));
166
+ const pat = repo.get("pat");
167
+ const repoUrl = repo.get("repoUrl");
168
+ const git = getGit(localPath);
169
+ const result = await withAuth(git, repoUrl, pat, () => git.pull());
170
+ ctx.body = { success: true, data: result };
171
+ await next();
172
+ }
173
+ async function push(ctx, next) {
174
+ const repo = await getRepo(ctx);
175
+ const localPath = validateLocalPath(repo.get("localPath"));
176
+ const pat = repo.get("pat");
177
+ const repoUrl = repo.get("repoUrl");
178
+ const git = getGit(localPath);
179
+ const result = await withAuth(git, repoUrl, pat, () => git.push());
180
+ ctx.body = { success: true, data: result };
181
+ await next();
182
+ }
183
+ async function fetch(ctx, next) {
184
+ const repo = await getRepo(ctx);
185
+ const localPath = validateLocalPath(repo.get("localPath"));
186
+ const pat = repo.get("pat");
187
+ const repoUrl = repo.get("repoUrl");
188
+ const git = getGit(localPath);
189
+ const result = await withAuth(git, repoUrl, pat, () => git.fetch());
190
+ ctx.body = { success: true, data: result };
191
+ await next();
192
+ }
193
+ async function diff(ctx, next) {
194
+ const repo = await getRepo(ctx);
195
+ const localPath = validateLocalPath(repo.get("localPath"));
196
+ const { file, commitHash, compareHash } = ctx.action.params;
197
+ const git = getGit(localPath);
198
+ const args = [];
199
+ if (commitHash && compareHash) {
200
+ args.push(validateRef(commitHash), validateRef(compareHash));
201
+ } else if (commitHash) {
202
+ args.push(validateRef(commitHash) + "^", validateRef(commitHash));
203
+ }
204
+ if (file) {
205
+ if (file.includes("..")) ctx.throw(400, "Invalid file path");
206
+ args.push("--", file);
207
+ }
208
+ const result = await git.diff(args);
209
+ ctx.body = { success: true, data: result };
210
+ await next();
211
+ }
212
+ async function status(ctx, next) {
213
+ const repo = await getRepo(ctx);
214
+ const localPath = validateLocalPath(repo.get("localPath"));
215
+ const result = await getGit(localPath).status();
216
+ ctx.body = { success: true, data: result };
217
+ await next();
218
+ }
219
+ async function log(ctx, next) {
220
+ const repo = await getRepo(ctx);
221
+ const localPath = validateLocalPath(repo.get("localPath"));
222
+ const { maxCount = 50, file } = ctx.action.params;
223
+ const parsed = parseInt(maxCount, 10);
224
+ const options = { maxCount: Math.min(Math.max(parsed || 50, 1), 500) };
225
+ if (file) {
226
+ if (file.includes("..")) ctx.throw(400, "Invalid file path");
227
+ options.file = file;
228
+ }
229
+ const result = await getGit(localPath).log(options);
230
+ ctx.body = { success: true, data: result };
231
+ await next();
232
+ }
233
+ async function branches(ctx, next) {
234
+ const repo = await getRepo(ctx);
235
+ const localPath = validateLocalPath(repo.get("localPath"));
236
+ const result = await getGit(localPath).branch();
237
+ ctx.body = { success: true, data: result };
238
+ await next();
239
+ }
240
+ async function checkout(ctx, next) {
241
+ const repo = await getRepo(ctx);
242
+ const localPath = validateLocalPath(repo.get("localPath"));
243
+ const { branch } = ctx.action.params;
244
+ validateBranch(branch);
245
+ await getGit(localPath).checkout(branch);
246
+ ctx.body = { success: true, message: `Switched to branch ${branch}` };
247
+ await next();
248
+ }
249
+ async function fileTree(ctx, next) {
250
+ const repo = await getRepo(ctx);
251
+ const localPath = validateLocalPath(repo.get("localPath"));
252
+ const { ref = "HEAD", treePath = "" } = ctx.action.params;
253
+ const git = getGit(localPath);
254
+ validateRef(ref);
255
+ if (treePath && treePath.includes("..")) {
256
+ ctx.throw(400, "Invalid tree path");
257
+ }
258
+ const detailArgs = ["ls-tree", "-l", ref];
259
+ if (treePath) detailArgs.push(treePath + "/");
260
+ const detailedResult = await git.raw(detailArgs);
261
+ const items = detailedResult.trim().split("\n").filter(Boolean).map((line) => {
262
+ const match = line.match(/^(\d+)\s+(blob|tree)\s+([a-f0-9]+)\s+(-|\d+)\t(.+)$/);
263
+ if (!match) return null;
264
+ const fullPath = match[5];
265
+ const name = fullPath.includes("/") ? fullPath.split("/").pop() : fullPath;
266
+ return {
267
+ mode: match[1],
268
+ type: match[2],
269
+ hash: match[3],
270
+ size: match[4] === "-" ? 0 : parseInt(match[4], 10),
271
+ name,
272
+ path: treePath ? `${treePath}/${name}` : name
273
+ };
274
+ }).filter(Boolean);
275
+ items.sort((a, b) => {
276
+ if (a.type !== b.type) return a.type === "tree" ? -1 : 1;
277
+ return a.name.localeCompare(b.name);
278
+ });
279
+ ctx.body = { success: true, data: items };
280
+ await next();
281
+ }
282
+ async function fileContent(ctx, next) {
283
+ const repo = await getRepo(ctx);
284
+ const localPath = validateLocalPath(repo.get("localPath"));
285
+ const { ref = "HEAD", filePath } = ctx.action.params;
286
+ if (!filePath) {
287
+ ctx.throw(400, "filePath is required");
288
+ }
289
+ if (filePath.includes("..")) {
290
+ ctx.throw(400, "Invalid file path");
291
+ }
292
+ validateRef(ref);
293
+ const git = getGit(localPath);
294
+ const content = await git.show([`${ref}:${filePath}`]);
295
+ ctx.body = { success: true, data: { content, filePath, ref } };
296
+ await next();
297
+ }
298
+ async function commitDetail(ctx, next) {
299
+ const repo = await getRepo(ctx);
300
+ const localPath = validateLocalPath(repo.get("localPath"));
301
+ const { commitHash } = ctx.action.params;
302
+ if (!commitHash) {
303
+ ctx.throw(400, "commitHash is required");
304
+ }
305
+ const git = getGit(localPath);
306
+ validateRef(commitHash);
307
+ const DELIM_ARG = "%x00";
308
+ const DELIM_OUT = "\0";
309
+ const format = `%H${DELIM_ARG}%an${DELIM_ARG}%ae${DELIM_ARG}%aI${DELIM_ARG}%s${DELIM_ARG}%b`;
310
+ const [show, diffResult] = await Promise.all([
311
+ git.show([commitHash, "--stat", `--format=${format}`]),
312
+ git.diff([`${commitHash}^`, commitHash, "--name-status"]).catch(
313
+ () => (
314
+ // Root commit has no parent — use diff-tree --root instead
315
+ git.raw(["diff-tree", "--root", "--name-status", "-r", commitHash])
316
+ )
317
+ )
318
+ ]);
319
+ const parts = show.split(DELIM_OUT);
320
+ const files = diffResult.trim().split("\n").filter(Boolean).map((line) => {
321
+ const [statusCode, ...fileParts] = line.split(" ");
322
+ return { status: statusCode, file: fileParts.join(" ") };
323
+ });
324
+ ctx.body = {
325
+ success: true,
326
+ data: {
327
+ hash: parts[0] || "",
328
+ author: parts[1] || "",
329
+ email: parts[2] || "",
330
+ date: parts[3] || "",
331
+ subject: parts[4] || "",
332
+ body: (parts[5] || "").split("\n\n")[0].trim(),
333
+ // body before --stat output
334
+ files,
335
+ raw: show
336
+ }
337
+ };
338
+ await next();
339
+ }
340
+ // Annotate the CommonJS export names for ESM import in node:
341
+ 0 && (module.exports = {
342
+ branches,
343
+ checkout,
344
+ clone,
345
+ commitDetail,
346
+ diff,
347
+ fetch,
348
+ fileContent,
349
+ fileTree,
350
+ log,
351
+ pull,
352
+ push,
353
+ status
354
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@nocobase/database").CollectionOptions;
2
+ export default _default;