@scriptdb/storage 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +201 -0
- package/dist/index.d.ts +201 -0
- package/dist/index.js +119 -18
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +655 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +2 -5
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { SimpleGit } from 'simple-git';
|
|
2
|
+
|
|
3
|
+
interface GitConfig {
|
|
4
|
+
userName?: string;
|
|
5
|
+
userEmail?: string;
|
|
6
|
+
options?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
interface RepoStatus {
|
|
9
|
+
staged: string[];
|
|
10
|
+
unstaged: string[];
|
|
11
|
+
untracked: string[];
|
|
12
|
+
clean: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
interface RemoteInfo {
|
|
16
|
+
name: string;
|
|
17
|
+
refs: string;
|
|
18
|
+
pushUrl: string;
|
|
19
|
+
}
|
|
20
|
+
interface CommitHistory {
|
|
21
|
+
hash: string;
|
|
22
|
+
message: string;
|
|
23
|
+
date: string;
|
|
24
|
+
author: string;
|
|
25
|
+
}
|
|
26
|
+
declare class Storage {
|
|
27
|
+
private repoPath;
|
|
28
|
+
private gitRoot;
|
|
29
|
+
private repo;
|
|
30
|
+
constructor(repoPath: string, gitRoot?: string);
|
|
31
|
+
initialize(repoPath?: string | null): Promise<SimpleGit>;
|
|
32
|
+
addFile(filePath: string, content: string): Promise<{
|
|
33
|
+
success: boolean;
|
|
34
|
+
message: string;
|
|
35
|
+
path?: string;
|
|
36
|
+
}>;
|
|
37
|
+
updateFile(filePath: string, content: string): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
message: string;
|
|
40
|
+
path?: string;
|
|
41
|
+
}>;
|
|
42
|
+
getFile(filePath: string): Promise<{
|
|
43
|
+
success: boolean;
|
|
44
|
+
content?: string;
|
|
45
|
+
path?: string;
|
|
46
|
+
message?: string;
|
|
47
|
+
}>;
|
|
48
|
+
deleteFile(filePath: string): Promise<{
|
|
49
|
+
success: boolean;
|
|
50
|
+
message: string;
|
|
51
|
+
}>;
|
|
52
|
+
commit(message: string): Promise<{
|
|
53
|
+
success: boolean;
|
|
54
|
+
message: string;
|
|
55
|
+
}>;
|
|
56
|
+
getStatus(): Promise<RepoStatus>;
|
|
57
|
+
getHistory(filePath: string): Promise<CommitHistory[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Set Git configuration values
|
|
60
|
+
* @param config - Configuration object
|
|
61
|
+
* @param scope - Configuration scope ('local', 'global', 'system')
|
|
62
|
+
* @returns Result of the operation
|
|
63
|
+
*/
|
|
64
|
+
setConfig(config: GitConfig, scope?: 'local' | 'global' | 'system'): Promise<{
|
|
65
|
+
success: boolean;
|
|
66
|
+
message: string;
|
|
67
|
+
changes?: any[];
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Get Git configuration value
|
|
71
|
+
* @param key - Configuration key (e.g., 'user.name')
|
|
72
|
+
* @param scope - Configuration scope ('local', 'global', 'system')
|
|
73
|
+
* @returns Result containing the configuration value
|
|
74
|
+
*/
|
|
75
|
+
getConfig(key: string, scope?: 'local' | 'global' | 'system'): Promise<{
|
|
76
|
+
success: boolean;
|
|
77
|
+
key?: string;
|
|
78
|
+
value?: string;
|
|
79
|
+
scope?: string;
|
|
80
|
+
message?: string;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Get all Git configuration values
|
|
84
|
+
* @param scope - Configuration scope ('local', 'global', 'system')
|
|
85
|
+
* @returns Result containing all configuration values
|
|
86
|
+
*/
|
|
87
|
+
listConfig(scope?: 'local' | 'global' | 'system'): Promise<{
|
|
88
|
+
success: boolean;
|
|
89
|
+
scope: string;
|
|
90
|
+
config?: any;
|
|
91
|
+
message?: string;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Set up a basic configuration for the repository
|
|
95
|
+
* @param userName - User name (optional, defaults to 'Sandbox Storage')
|
|
96
|
+
* @param userEmail - User email (optional, defaults to 'sandbox@example.com')
|
|
97
|
+
* @param additionalConfig - Additional configuration options (optional)
|
|
98
|
+
* @returns Result of the operation
|
|
99
|
+
*/
|
|
100
|
+
setupBasicConfig(userName?: string, userEmail?: string, additionalConfig?: Record<string, string>): Promise<{
|
|
101
|
+
success: boolean;
|
|
102
|
+
message: string;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Add a remote repository
|
|
106
|
+
* @param name - Remote name (e.g., 'origin')
|
|
107
|
+
* @param url - Remote repository URL
|
|
108
|
+
* @returns Result of the operation
|
|
109
|
+
*/
|
|
110
|
+
addRemote(name: string, url: string): Promise<{
|
|
111
|
+
success: boolean;
|
|
112
|
+
message: string;
|
|
113
|
+
name?: string;
|
|
114
|
+
url?: string;
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Remove a remote repository
|
|
118
|
+
* @param name - Remote name to remove
|
|
119
|
+
* @returns Result of the operation
|
|
120
|
+
*/
|
|
121
|
+
removeRemote(name: string): Promise<{
|
|
122
|
+
success: boolean;
|
|
123
|
+
message: string;
|
|
124
|
+
name?: string;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* List all remote repositories
|
|
128
|
+
* @returns Result containing the list of remotes
|
|
129
|
+
*/
|
|
130
|
+
listRemotes(): Promise<{
|
|
131
|
+
success: boolean;
|
|
132
|
+
remotes: RemoteInfo[];
|
|
133
|
+
message?: string;
|
|
134
|
+
}>;
|
|
135
|
+
/**
|
|
136
|
+
* Push changes to a remote repository
|
|
137
|
+
* @param remote - Remote name (defaults to 'origin')
|
|
138
|
+
* @param branch - Branch to push (defaults to current branch)
|
|
139
|
+
* @param options - Additional options
|
|
140
|
+
* @returns Result of the operation
|
|
141
|
+
*/
|
|
142
|
+
push(remote?: string, branch?: string, options?: {
|
|
143
|
+
force?: boolean;
|
|
144
|
+
setUpstream?: boolean;
|
|
145
|
+
}): Promise<{
|
|
146
|
+
success: boolean;
|
|
147
|
+
message: string;
|
|
148
|
+
remote?: string;
|
|
149
|
+
branch?: string;
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Pull changes from a remote repository
|
|
153
|
+
* @param remote - Remote name (defaults to 'origin')
|
|
154
|
+
* @param branch - Branch to pull from (defaults to current branch)
|
|
155
|
+
* @param options - Additional options
|
|
156
|
+
* @returns Result of the operation
|
|
157
|
+
*/
|
|
158
|
+
pull(remote?: string, branch?: string, options?: {
|
|
159
|
+
allowUnrelatedHistories?: boolean;
|
|
160
|
+
}): Promise<{
|
|
161
|
+
success: boolean;
|
|
162
|
+
message: string;
|
|
163
|
+
remote?: string;
|
|
164
|
+
branch?: string;
|
|
165
|
+
}>;
|
|
166
|
+
/**
|
|
167
|
+
* Fetch changes from a remote repository without merging
|
|
168
|
+
* @param remote - Remote name (defaults to 'origin')
|
|
169
|
+
* @param branch - Branch to fetch (defaults to 'main')
|
|
170
|
+
* @param options - Additional options
|
|
171
|
+
* @returns Result of the operation
|
|
172
|
+
*/
|
|
173
|
+
fetch(remote?: string, branch?: string, options?: {
|
|
174
|
+
prune?: boolean;
|
|
175
|
+
}): Promise<{
|
|
176
|
+
success: boolean;
|
|
177
|
+
message: string;
|
|
178
|
+
remote?: string;
|
|
179
|
+
branch?: string;
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Clone a remote repository
|
|
183
|
+
* @param url - Repository URL to clone
|
|
184
|
+
* @param targetPath - Directory to clone into (optional)
|
|
185
|
+
* @param options - Additional options
|
|
186
|
+
* @returns Result of the operation
|
|
187
|
+
*/
|
|
188
|
+
clone(url: string, targetPath?: string | null, options?: {
|
|
189
|
+
bare?: boolean;
|
|
190
|
+
branch?: string;
|
|
191
|
+
depth?: number;
|
|
192
|
+
}): Promise<{
|
|
193
|
+
success: boolean;
|
|
194
|
+
message: string;
|
|
195
|
+
url?: string;
|
|
196
|
+
path?: string;
|
|
197
|
+
}>;
|
|
198
|
+
listFiles(): Promise<string[]>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { type CommitHistory, type GitConfig, type RemoteInfo, type RepoStatus, Storage, Storage as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { SimpleGit } from 'simple-git';
|
|
2
|
+
|
|
3
|
+
interface GitConfig {
|
|
4
|
+
userName?: string;
|
|
5
|
+
userEmail?: string;
|
|
6
|
+
options?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
interface RepoStatus {
|
|
9
|
+
staged: string[];
|
|
10
|
+
unstaged: string[];
|
|
11
|
+
untracked: string[];
|
|
12
|
+
clean: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
interface RemoteInfo {
|
|
16
|
+
name: string;
|
|
17
|
+
refs: string;
|
|
18
|
+
pushUrl: string;
|
|
19
|
+
}
|
|
20
|
+
interface CommitHistory {
|
|
21
|
+
hash: string;
|
|
22
|
+
message: string;
|
|
23
|
+
date: string;
|
|
24
|
+
author: string;
|
|
25
|
+
}
|
|
26
|
+
declare class Storage {
|
|
27
|
+
private repoPath;
|
|
28
|
+
private gitRoot;
|
|
29
|
+
private repo;
|
|
30
|
+
constructor(repoPath: string, gitRoot?: string);
|
|
31
|
+
initialize(repoPath?: string | null): Promise<SimpleGit>;
|
|
32
|
+
addFile(filePath: string, content: string): Promise<{
|
|
33
|
+
success: boolean;
|
|
34
|
+
message: string;
|
|
35
|
+
path?: string;
|
|
36
|
+
}>;
|
|
37
|
+
updateFile(filePath: string, content: string): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
message: string;
|
|
40
|
+
path?: string;
|
|
41
|
+
}>;
|
|
42
|
+
getFile(filePath: string): Promise<{
|
|
43
|
+
success: boolean;
|
|
44
|
+
content?: string;
|
|
45
|
+
path?: string;
|
|
46
|
+
message?: string;
|
|
47
|
+
}>;
|
|
48
|
+
deleteFile(filePath: string): Promise<{
|
|
49
|
+
success: boolean;
|
|
50
|
+
message: string;
|
|
51
|
+
}>;
|
|
52
|
+
commit(message: string): Promise<{
|
|
53
|
+
success: boolean;
|
|
54
|
+
message: string;
|
|
55
|
+
}>;
|
|
56
|
+
getStatus(): Promise<RepoStatus>;
|
|
57
|
+
getHistory(filePath: string): Promise<CommitHistory[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Set Git configuration values
|
|
60
|
+
* @param config - Configuration object
|
|
61
|
+
* @param scope - Configuration scope ('local', 'global', 'system')
|
|
62
|
+
* @returns Result of the operation
|
|
63
|
+
*/
|
|
64
|
+
setConfig(config: GitConfig, scope?: 'local' | 'global' | 'system'): Promise<{
|
|
65
|
+
success: boolean;
|
|
66
|
+
message: string;
|
|
67
|
+
changes?: any[];
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Get Git configuration value
|
|
71
|
+
* @param key - Configuration key (e.g., 'user.name')
|
|
72
|
+
* @param scope - Configuration scope ('local', 'global', 'system')
|
|
73
|
+
* @returns Result containing the configuration value
|
|
74
|
+
*/
|
|
75
|
+
getConfig(key: string, scope?: 'local' | 'global' | 'system'): Promise<{
|
|
76
|
+
success: boolean;
|
|
77
|
+
key?: string;
|
|
78
|
+
value?: string;
|
|
79
|
+
scope?: string;
|
|
80
|
+
message?: string;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Get all Git configuration values
|
|
84
|
+
* @param scope - Configuration scope ('local', 'global', 'system')
|
|
85
|
+
* @returns Result containing all configuration values
|
|
86
|
+
*/
|
|
87
|
+
listConfig(scope?: 'local' | 'global' | 'system'): Promise<{
|
|
88
|
+
success: boolean;
|
|
89
|
+
scope: string;
|
|
90
|
+
config?: any;
|
|
91
|
+
message?: string;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Set up a basic configuration for the repository
|
|
95
|
+
* @param userName - User name (optional, defaults to 'Sandbox Storage')
|
|
96
|
+
* @param userEmail - User email (optional, defaults to 'sandbox@example.com')
|
|
97
|
+
* @param additionalConfig - Additional configuration options (optional)
|
|
98
|
+
* @returns Result of the operation
|
|
99
|
+
*/
|
|
100
|
+
setupBasicConfig(userName?: string, userEmail?: string, additionalConfig?: Record<string, string>): Promise<{
|
|
101
|
+
success: boolean;
|
|
102
|
+
message: string;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Add a remote repository
|
|
106
|
+
* @param name - Remote name (e.g., 'origin')
|
|
107
|
+
* @param url - Remote repository URL
|
|
108
|
+
* @returns Result of the operation
|
|
109
|
+
*/
|
|
110
|
+
addRemote(name: string, url: string): Promise<{
|
|
111
|
+
success: boolean;
|
|
112
|
+
message: string;
|
|
113
|
+
name?: string;
|
|
114
|
+
url?: string;
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Remove a remote repository
|
|
118
|
+
* @param name - Remote name to remove
|
|
119
|
+
* @returns Result of the operation
|
|
120
|
+
*/
|
|
121
|
+
removeRemote(name: string): Promise<{
|
|
122
|
+
success: boolean;
|
|
123
|
+
message: string;
|
|
124
|
+
name?: string;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* List all remote repositories
|
|
128
|
+
* @returns Result containing the list of remotes
|
|
129
|
+
*/
|
|
130
|
+
listRemotes(): Promise<{
|
|
131
|
+
success: boolean;
|
|
132
|
+
remotes: RemoteInfo[];
|
|
133
|
+
message?: string;
|
|
134
|
+
}>;
|
|
135
|
+
/**
|
|
136
|
+
* Push changes to a remote repository
|
|
137
|
+
* @param remote - Remote name (defaults to 'origin')
|
|
138
|
+
* @param branch - Branch to push (defaults to current branch)
|
|
139
|
+
* @param options - Additional options
|
|
140
|
+
* @returns Result of the operation
|
|
141
|
+
*/
|
|
142
|
+
push(remote?: string, branch?: string, options?: {
|
|
143
|
+
force?: boolean;
|
|
144
|
+
setUpstream?: boolean;
|
|
145
|
+
}): Promise<{
|
|
146
|
+
success: boolean;
|
|
147
|
+
message: string;
|
|
148
|
+
remote?: string;
|
|
149
|
+
branch?: string;
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Pull changes from a remote repository
|
|
153
|
+
* @param remote - Remote name (defaults to 'origin')
|
|
154
|
+
* @param branch - Branch to pull from (defaults to current branch)
|
|
155
|
+
* @param options - Additional options
|
|
156
|
+
* @returns Result of the operation
|
|
157
|
+
*/
|
|
158
|
+
pull(remote?: string, branch?: string, options?: {
|
|
159
|
+
allowUnrelatedHistories?: boolean;
|
|
160
|
+
}): Promise<{
|
|
161
|
+
success: boolean;
|
|
162
|
+
message: string;
|
|
163
|
+
remote?: string;
|
|
164
|
+
branch?: string;
|
|
165
|
+
}>;
|
|
166
|
+
/**
|
|
167
|
+
* Fetch changes from a remote repository without merging
|
|
168
|
+
* @param remote - Remote name (defaults to 'origin')
|
|
169
|
+
* @param branch - Branch to fetch (defaults to 'main')
|
|
170
|
+
* @param options - Additional options
|
|
171
|
+
* @returns Result of the operation
|
|
172
|
+
*/
|
|
173
|
+
fetch(remote?: string, branch?: string, options?: {
|
|
174
|
+
prune?: boolean;
|
|
175
|
+
}): Promise<{
|
|
176
|
+
success: boolean;
|
|
177
|
+
message: string;
|
|
178
|
+
remote?: string;
|
|
179
|
+
branch?: string;
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Clone a remote repository
|
|
183
|
+
* @param url - Repository URL to clone
|
|
184
|
+
* @param targetPath - Directory to clone into (optional)
|
|
185
|
+
* @param options - Additional options
|
|
186
|
+
* @returns Result of the operation
|
|
187
|
+
*/
|
|
188
|
+
clone(url: string, targetPath?: string | null, options?: {
|
|
189
|
+
bare?: boolean;
|
|
190
|
+
branch?: string;
|
|
191
|
+
depth?: number;
|
|
192
|
+
}): Promise<{
|
|
193
|
+
success: boolean;
|
|
194
|
+
message: string;
|
|
195
|
+
url?: string;
|
|
196
|
+
path?: string;
|
|
197
|
+
}>;
|
|
198
|
+
listFiles(): Promise<string[]>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { type CommitHistory, type GitConfig, type RemoteInfo, type RepoStatus, Storage, Storage as default };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
5
29
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
Storage: () => Storage,
|
|
34
|
+
default: () => index_default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
var fs = __toESM(require("fs"));
|
|
38
|
+
var path = __toESM(require("path"));
|
|
39
|
+
var import_simple_git = require("simple-git");
|
|
40
|
+
var Storage = class {
|
|
10
41
|
constructor(repoPath, gitRoot) {
|
|
42
|
+
this.repo = null;
|
|
11
43
|
this.repoPath = repoPath;
|
|
12
44
|
this.gitRoot = gitRoot || repoPath;
|
|
13
45
|
}
|
|
@@ -19,7 +51,7 @@ class Storage {
|
|
|
19
51
|
if (!fs.existsSync(this.repoPath)) {
|
|
20
52
|
fs.mkdirSync(this.repoPath, { recursive: true });
|
|
21
53
|
}
|
|
22
|
-
this.repo = simpleGit(this.gitRoot);
|
|
54
|
+
this.repo = (0, import_simple_git.simpleGit)(this.gitRoot);
|
|
23
55
|
if (!fs.existsSync(path.join(this.gitRoot, ".git"))) {
|
|
24
56
|
try {
|
|
25
57
|
await this.repo.init();
|
|
@@ -216,6 +248,12 @@ class Storage {
|
|
|
216
248
|
return [];
|
|
217
249
|
}
|
|
218
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Set Git configuration values
|
|
253
|
+
* @param config - Configuration object
|
|
254
|
+
* @param scope - Configuration scope ('local', 'global', 'system')
|
|
255
|
+
* @returns Result of the operation
|
|
256
|
+
*/
|
|
219
257
|
async setConfig(config, scope = "local") {
|
|
220
258
|
try {
|
|
221
259
|
if (!this.repo) {
|
|
@@ -248,6 +286,12 @@ class Storage {
|
|
|
248
286
|
};
|
|
249
287
|
}
|
|
250
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Get Git configuration value
|
|
291
|
+
* @param key - Configuration key (e.g., 'user.name')
|
|
292
|
+
* @param scope - Configuration scope ('local', 'global', 'system')
|
|
293
|
+
* @returns Result containing the configuration value
|
|
294
|
+
*/
|
|
251
295
|
async getConfig(key, scope = "local") {
|
|
252
296
|
try {
|
|
253
297
|
if (!this.repo) {
|
|
@@ -273,14 +317,18 @@ class Storage {
|
|
|
273
317
|
};
|
|
274
318
|
}
|
|
275
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Get all Git configuration values
|
|
322
|
+
* @param scope - Configuration scope ('local', 'global', 'system')
|
|
323
|
+
* @returns Result containing all configuration values
|
|
324
|
+
*/
|
|
276
325
|
async listConfig(scope = "local") {
|
|
277
326
|
try {
|
|
278
327
|
if (!this.repo) {
|
|
279
328
|
throw new Error("Repository not initialized. Call initialize() first.");
|
|
280
329
|
}
|
|
281
330
|
const result = await this.repo.raw(["config", `--${scope}`, "--list"]);
|
|
282
|
-
const lines = result.trim().split(
|
|
283
|
-
`);
|
|
331
|
+
const lines = result.trim().split("\n");
|
|
284
332
|
const config = {};
|
|
285
333
|
lines.forEach((line) => {
|
|
286
334
|
const [key, value] = line.split("=");
|
|
@@ -301,18 +349,33 @@ class Storage {
|
|
|
301
349
|
};
|
|
302
350
|
}
|
|
303
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Set up a basic configuration for the repository
|
|
354
|
+
* @param userName - User name (optional, defaults to 'Sandbox Storage')
|
|
355
|
+
* @param userEmail - User email (optional, defaults to 'sandbox@example.com')
|
|
356
|
+
* @param additionalConfig - Additional configuration options (optional)
|
|
357
|
+
* @returns Result of the operation
|
|
358
|
+
*/
|
|
304
359
|
async setupBasicConfig(userName = "Sandbox Storage", userEmail = "sandbox@example.com", additionalConfig = {}) {
|
|
305
360
|
const config = {
|
|
306
361
|
userName,
|
|
307
362
|
userEmail,
|
|
308
363
|
options: {
|
|
309
364
|
"core.autocrlf": "false",
|
|
365
|
+
// Important for cross-platform compatibility
|
|
310
366
|
"core.filemode": "false",
|
|
367
|
+
// Important for cross-platform compatibility
|
|
311
368
|
...additionalConfig
|
|
312
369
|
}
|
|
313
370
|
};
|
|
314
371
|
return this.setConfig(config, "local");
|
|
315
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Add a remote repository
|
|
375
|
+
* @param name - Remote name (e.g., 'origin')
|
|
376
|
+
* @param url - Remote repository URL
|
|
377
|
+
* @returns Result of the operation
|
|
378
|
+
*/
|
|
316
379
|
async addRemote(name, url) {
|
|
317
380
|
try {
|
|
318
381
|
if (!this.repo) {
|
|
@@ -332,6 +395,11 @@ class Storage {
|
|
|
332
395
|
};
|
|
333
396
|
}
|
|
334
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* Remove a remote repository
|
|
400
|
+
* @param name - Remote name to remove
|
|
401
|
+
* @returns Result of the operation
|
|
402
|
+
*/
|
|
335
403
|
async removeRemote(name) {
|
|
336
404
|
try {
|
|
337
405
|
if (!this.repo) {
|
|
@@ -350,6 +418,10 @@ class Storage {
|
|
|
350
418
|
};
|
|
351
419
|
}
|
|
352
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* List all remote repositories
|
|
423
|
+
* @returns Result containing the list of remotes
|
|
424
|
+
*/
|
|
353
425
|
async listRemotes() {
|
|
354
426
|
try {
|
|
355
427
|
if (!this.repo) {
|
|
@@ -372,6 +444,13 @@ class Storage {
|
|
|
372
444
|
};
|
|
373
445
|
}
|
|
374
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Push changes to a remote repository
|
|
449
|
+
* @param remote - Remote name (defaults to 'origin')
|
|
450
|
+
* @param branch - Branch to push (defaults to current branch)
|
|
451
|
+
* @param options - Additional options
|
|
452
|
+
* @returns Result of the operation
|
|
453
|
+
*/
|
|
375
454
|
async push(remote = "origin", branch = "main", options = {}) {
|
|
376
455
|
try {
|
|
377
456
|
if (!this.repo) {
|
|
@@ -426,6 +505,13 @@ class Storage {
|
|
|
426
505
|
};
|
|
427
506
|
}
|
|
428
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* Pull changes from a remote repository
|
|
510
|
+
* @param remote - Remote name (defaults to 'origin')
|
|
511
|
+
* @param branch - Branch to pull from (defaults to current branch)
|
|
512
|
+
* @param options - Additional options
|
|
513
|
+
* @returns Result of the operation
|
|
514
|
+
*/
|
|
429
515
|
async pull(remote = "origin", branch = "main", options = {}) {
|
|
430
516
|
try {
|
|
431
517
|
if (!this.repo) {
|
|
@@ -483,6 +569,13 @@ class Storage {
|
|
|
483
569
|
};
|
|
484
570
|
}
|
|
485
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* Fetch changes from a remote repository without merging
|
|
574
|
+
* @param remote - Remote name (defaults to 'origin')
|
|
575
|
+
* @param branch - Branch to fetch (defaults to 'main')
|
|
576
|
+
* @param options - Additional options
|
|
577
|
+
* @returns Result of the operation
|
|
578
|
+
*/
|
|
486
579
|
async fetch(remote = "origin", branch = "main", options = {}) {
|
|
487
580
|
try {
|
|
488
581
|
if (!this.repo) {
|
|
@@ -526,6 +619,13 @@ class Storage {
|
|
|
526
619
|
};
|
|
527
620
|
}
|
|
528
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* Clone a remote repository
|
|
624
|
+
* @param url - Repository URL to clone
|
|
625
|
+
* @param targetPath - Directory to clone into (optional)
|
|
626
|
+
* @param options - Additional options
|
|
627
|
+
* @returns Result of the operation
|
|
628
|
+
*/
|
|
529
629
|
async clone(url, targetPath = null, options = {}) {
|
|
530
630
|
try {
|
|
531
631
|
const clonePath = targetPath || this.repoPath;
|
|
@@ -539,11 +639,11 @@ class Storage {
|
|
|
539
639
|
if (options.depth) {
|
|
540
640
|
cloneOptions["--depth"] = options.depth.toString();
|
|
541
641
|
}
|
|
542
|
-
const git = simpleGit();
|
|
642
|
+
const git = (0, import_simple_git.simpleGit)();
|
|
543
643
|
await git.clone(url, clonePath, cloneOptions);
|
|
544
644
|
if (!targetPath) {
|
|
545
645
|
this.repoPath = clonePath;
|
|
546
|
-
this.repo = simpleGit(clonePath);
|
|
646
|
+
this.repo = (0, import_simple_git.simpleGit)(clonePath);
|
|
547
647
|
}
|
|
548
648
|
return {
|
|
549
649
|
success: true,
|
|
@@ -581,9 +681,10 @@ class Storage {
|
|
|
581
681
|
}
|
|
582
682
|
});
|
|
583
683
|
}
|
|
584
|
-
}
|
|
585
|
-
var src_default = Storage;
|
|
586
|
-
export {
|
|
587
|
-
src_default as default,
|
|
588
|
-
Storage
|
|
589
684
|
};
|
|
685
|
+
var index_default = Storage;
|
|
686
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
687
|
+
0 && (module.exports = {
|
|
688
|
+
Storage
|
|
689
|
+
});
|
|
690
|
+
//# sourceMappingURL=index.js.map
|