@daytonaio/sdk 0.0.0-dev
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/README.md +146 -0
- package/package.json +39 -0
- package/src/Daytona.d.ts +331 -0
- package/src/Daytona.js +400 -0
- package/src/Daytona.js.map +1 -0
- package/src/FileSystem.d.ts +270 -0
- package/src/FileSystem.js +302 -0
- package/src/FileSystem.js.map +1 -0
- package/src/Git.d.ts +211 -0
- package/src/Git.js +275 -0
- package/src/Git.js.map +1 -0
- package/src/Image.d.ts +264 -0
- package/src/Image.js +565 -0
- package/src/Image.js.map +1 -0
- package/src/LspServer.d.ts +173 -0
- package/src/LspServer.js +209 -0
- package/src/LspServer.js.map +1 -0
- package/src/ObjectStorage.d.ts +85 -0
- package/src/ObjectStorage.js +231 -0
- package/src/ObjectStorage.js.map +1 -0
- package/src/Process.d.ts +246 -0
- package/src/Process.js +290 -0
- package/src/Process.js.map +1 -0
- package/src/Sandbox.d.ts +266 -0
- package/src/Sandbox.js +389 -0
- package/src/Sandbox.js.map +1 -0
- package/src/Snapshot.d.ts +116 -0
- package/src/Snapshot.js +187 -0
- package/src/Snapshot.js.map +1 -0
- package/src/Volume.d.ts +79 -0
- package/src/Volume.js +97 -0
- package/src/Volume.js.map +1 -0
- package/src/code-toolbox/SandboxPythonCodeToolbox.d.ts +11 -0
- package/src/code-toolbox/SandboxPythonCodeToolbox.js +358 -0
- package/src/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
- package/src/code-toolbox/SandboxTsCodeToolbox.d.ts +5 -0
- package/src/code-toolbox/SandboxTsCodeToolbox.js +17 -0
- package/src/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
- package/src/errors/DaytonaError.d.ts +10 -0
- package/src/errors/DaytonaError.js +20 -0
- package/src/errors/DaytonaError.js.map +1 -0
- package/src/index.d.ts +15 -0
- package/src/index.js +32 -0
- package/src/index.js.map +1 -0
- package/src/types/Charts.d.ts +151 -0
- package/src/types/Charts.js +46 -0
- package/src/types/Charts.js.map +1 -0
- package/src/types/ExecuteResponse.d.ts +26 -0
- package/src/types/ExecuteResponse.js +7 -0
- package/src/types/ExecuteResponse.js.map +1 -0
- package/src/utils/ArtifactParser.d.ts +13 -0
- package/src/utils/ArtifactParser.js +55 -0
- package/src/utils/ArtifactParser.js.map +1 -0
- package/src/utils/Path.d.ts +1 -0
- package/src/utils/Path.js +61 -0
- package/src/utils/Path.js.map +1 -0
- package/src/utils/Stream.d.ts +13 -0
- package/src/utils/Stream.js +82 -0
- package/src/utils/Stream.js.map +1 -0
package/src/Git.d.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { ToolboxApi, ListBranchResponse, GitStatus } from '@daytonaio/api-client';
|
|
2
|
+
/**
|
|
3
|
+
* Response from the git commit.
|
|
4
|
+
*
|
|
5
|
+
* @interface
|
|
6
|
+
* @property {string} sha - The SHA of the commit
|
|
7
|
+
*/
|
|
8
|
+
export interface GitCommitResponse {
|
|
9
|
+
sha: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Provides Git operations within a Sandbox.
|
|
13
|
+
*
|
|
14
|
+
* @class
|
|
15
|
+
*/
|
|
16
|
+
export declare class Git {
|
|
17
|
+
private readonly sandboxId;
|
|
18
|
+
private readonly toolboxApi;
|
|
19
|
+
private readonly getRootDir;
|
|
20
|
+
constructor(sandboxId: string, toolboxApi: ToolboxApi, getRootDir: () => Promise<string>);
|
|
21
|
+
/**
|
|
22
|
+
* Stages the specified files for the next commit, similar to
|
|
23
|
+
* running 'git add' on the command line.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
26
|
+
* root directory.
|
|
27
|
+
* @param {string[]} files - List of file paths or directories to stage, relative to the repository root
|
|
28
|
+
* @returns {Promise<void>}
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Stage a single file
|
|
32
|
+
* await git.add('workspace/repo', ['file.txt']);
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Stage whole repository
|
|
36
|
+
* await git.add('workspace/repo', ['.']);
|
|
37
|
+
*/
|
|
38
|
+
add(path: string, files: string[]): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* List branches in the repository.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
43
|
+
* root directory.
|
|
44
|
+
* @returns {Promise<ListBranchResponse>} List of branches in the repository
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const response = await git.branches('workspace/repo');
|
|
48
|
+
* console.log(`Branches: ${response.branches}`);
|
|
49
|
+
*/
|
|
50
|
+
branches(path: string): Promise<ListBranchResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Create branche in the repository.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
55
|
+
* root directory.
|
|
56
|
+
* @param {string} name - Name of the new branch to create
|
|
57
|
+
* @returns {Promise<void>}
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* await git.createBranch('workspace/repo', 'new-feature');
|
|
61
|
+
*/
|
|
62
|
+
createBranch(path: string, name: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Delete branche in the repository.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
67
|
+
* root directory.
|
|
68
|
+
* @param {string} name - Name of the branch to delete
|
|
69
|
+
* @returns {Promise<void>}
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* await git.deleteBranch('workspace/repo', 'new-feature');
|
|
73
|
+
*/
|
|
74
|
+
deleteBranch(path: string, name: string): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Checkout branche in the repository.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
79
|
+
* root directory.
|
|
80
|
+
* @param {string} branch - Name of the branch to checkout
|
|
81
|
+
* @returns {Promise<void>}
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* await git.checkoutBranch('workspace/repo', 'new-feature');
|
|
85
|
+
*/
|
|
86
|
+
checkoutBranch(path: string, branch: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Clones a Git repository into the specified path. It supports
|
|
89
|
+
* cloning specific branches or commits, and can authenticate with the remote
|
|
90
|
+
* repository if credentials are provided.
|
|
91
|
+
*
|
|
92
|
+
* @param {string} url - Repository URL to clone from
|
|
93
|
+
* @param {string} path - Path where the repository should be cloned. Relative paths are resolved based on the user's
|
|
94
|
+
* root directory.
|
|
95
|
+
* @param {string} [branch] - Specific branch to clone. If not specified, clones the default branch
|
|
96
|
+
* @param {string} [commitId] - Specific commit to clone. If specified, the repository will be left in a detached HEAD state at this commit
|
|
97
|
+
* @param {string} [username] - Git username for authentication
|
|
98
|
+
* @param {string} [password] - Git password or token for authentication
|
|
99
|
+
* @returns {Promise<void>}
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* // Clone the default branch
|
|
103
|
+
* await git.clone(
|
|
104
|
+
* 'https://github.com/user/repo.git',
|
|
105
|
+
* 'workspace/repo'
|
|
106
|
+
* );
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* // Clone a specific branch with authentication
|
|
110
|
+
* await git.clone(
|
|
111
|
+
* 'https://github.com/user/private-repo.git',
|
|
112
|
+
* 'workspace/private',
|
|
113
|
+
* branch='develop',
|
|
114
|
+
* username='user',
|
|
115
|
+
* password='token'
|
|
116
|
+
* );
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* // Clone a specific commit
|
|
120
|
+
* await git.clone(
|
|
121
|
+
* 'https://github.com/user/repo.git',
|
|
122
|
+
* 'workspace/repo-old',
|
|
123
|
+
* commitId='abc123'
|
|
124
|
+
* );
|
|
125
|
+
*/
|
|
126
|
+
clone(url: string, path: string, branch?: string, commitId?: string, username?: string, password?: string): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Commits staged changes.
|
|
129
|
+
*
|
|
130
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
131
|
+
* root directory.
|
|
132
|
+
* @param {string} message - Commit message describing the changes
|
|
133
|
+
* @param {string} author - Name of the commit author
|
|
134
|
+
* @param {string} email - Email address of the commit author
|
|
135
|
+
* @returns {Promise<void>}
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* // Stage and commit changes
|
|
139
|
+
* await git.add('workspace/repo', ['README.md']);
|
|
140
|
+
* await git.commit(
|
|
141
|
+
* 'workspace/repo',
|
|
142
|
+
* 'Update documentation',
|
|
143
|
+
* 'John Doe',
|
|
144
|
+
* 'john@example.com'
|
|
145
|
+
* );
|
|
146
|
+
*/
|
|
147
|
+
commit(path: string, message: string, author: string, email: string): Promise<GitCommitResponse>;
|
|
148
|
+
/**
|
|
149
|
+
* Push local changes to the remote repository.
|
|
150
|
+
*
|
|
151
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
152
|
+
* root directory.
|
|
153
|
+
* @param {string} [username] - Git username for authentication
|
|
154
|
+
* @param {string} [password] - Git password or token for authentication
|
|
155
|
+
* @returns {Promise<void>}
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* // Push to a public repository
|
|
159
|
+
* await git.push('workspace/repo');
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* // Push to a private repository
|
|
163
|
+
* await git.push(
|
|
164
|
+
* 'workspace/repo',
|
|
165
|
+
* 'user',
|
|
166
|
+
* 'token'
|
|
167
|
+
* );
|
|
168
|
+
*/
|
|
169
|
+
push(path: string, username?: string, password?: string): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Pulls changes from the remote repository.
|
|
172
|
+
*
|
|
173
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
174
|
+
* root directory.
|
|
175
|
+
* @param {string} [username] - Git username for authentication
|
|
176
|
+
* @param {string} [password] - Git password or token for authentication
|
|
177
|
+
* @returns {Promise<void>}
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* // Pull from a public repository
|
|
181
|
+
* await git.pull('workspace/repo');
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* // Pull from a private repository
|
|
185
|
+
* await git.pull(
|
|
186
|
+
* 'workspace/repo',
|
|
187
|
+
* 'user',
|
|
188
|
+
* 'token'
|
|
189
|
+
* );
|
|
190
|
+
*/
|
|
191
|
+
pull(path: string, username?: string, password?: string): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Gets the current status of the Git repository.
|
|
194
|
+
*
|
|
195
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
196
|
+
* root directory.
|
|
197
|
+
* @returns {Promise<GitStatus>} Current repository status including:
|
|
198
|
+
* - currentBranch: Name of the current branch
|
|
199
|
+
* - ahead: Number of commits ahead of the remote branch
|
|
200
|
+
* - behind: Number of commits behind the remote branch
|
|
201
|
+
* - branchPublished: Whether the branch has been published to the remote repository
|
|
202
|
+
* - fileStatus: List of file statuses
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* const status = await sandbox.git.status('workspace/repo');
|
|
206
|
+
* console.log(`Current branch: ${status.currentBranch}`);
|
|
207
|
+
* console.log(`Commits ahead: ${status.ahead}`);
|
|
208
|
+
* console.log(`Commits behind: ${status.behind}`);
|
|
209
|
+
*/
|
|
210
|
+
status(path: string): Promise<GitStatus>;
|
|
211
|
+
}
|
package/src/Git.js
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Git = void 0;
|
|
8
|
+
const Path_1 = require("./utils/Path");
|
|
9
|
+
/**
|
|
10
|
+
* Provides Git operations within a Sandbox.
|
|
11
|
+
*
|
|
12
|
+
* @class
|
|
13
|
+
*/
|
|
14
|
+
class Git {
|
|
15
|
+
sandboxId;
|
|
16
|
+
toolboxApi;
|
|
17
|
+
getRootDir;
|
|
18
|
+
constructor(sandboxId, toolboxApi, getRootDir) {
|
|
19
|
+
this.sandboxId = sandboxId;
|
|
20
|
+
this.toolboxApi = toolboxApi;
|
|
21
|
+
this.getRootDir = getRootDir;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Stages the specified files for the next commit, similar to
|
|
25
|
+
* running 'git add' on the command line.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
28
|
+
* root directory.
|
|
29
|
+
* @param {string[]} files - List of file paths or directories to stage, relative to the repository root
|
|
30
|
+
* @returns {Promise<void>}
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Stage a single file
|
|
34
|
+
* await git.add('workspace/repo', ['file.txt']);
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Stage whole repository
|
|
38
|
+
* await git.add('workspace/repo', ['.']);
|
|
39
|
+
*/
|
|
40
|
+
async add(path, files) {
|
|
41
|
+
await this.toolboxApi.gitAddFiles(this.sandboxId, {
|
|
42
|
+
path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
|
|
43
|
+
files,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* List branches in the repository.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
50
|
+
* root directory.
|
|
51
|
+
* @returns {Promise<ListBranchResponse>} List of branches in the repository
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* const response = await git.branches('workspace/repo');
|
|
55
|
+
* console.log(`Branches: ${response.branches}`);
|
|
56
|
+
*/
|
|
57
|
+
async branches(path) {
|
|
58
|
+
const response = await this.toolboxApi.gitListBranches(this.sandboxId, (0, Path_1.prefixRelativePath)(await this.getRootDir(), path));
|
|
59
|
+
return response.data;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create branche in the repository.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
65
|
+
* root directory.
|
|
66
|
+
* @param {string} name - Name of the new branch to create
|
|
67
|
+
* @returns {Promise<void>}
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* await git.createBranch('workspace/repo', 'new-feature');
|
|
71
|
+
*/
|
|
72
|
+
async createBranch(path, name) {
|
|
73
|
+
await this.toolboxApi.gitCreateBranch(this.sandboxId, {
|
|
74
|
+
path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
|
|
75
|
+
name,
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Delete branche in the repository.
|
|
81
|
+
*
|
|
82
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
83
|
+
* root directory.
|
|
84
|
+
* @param {string} name - Name of the branch to delete
|
|
85
|
+
* @returns {Promise<void>}
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* await git.deleteBranch('workspace/repo', 'new-feature');
|
|
89
|
+
*/
|
|
90
|
+
async deleteBranch(path, name) {
|
|
91
|
+
await this.toolboxApi.gitDeleteBranch(this.sandboxId, {
|
|
92
|
+
path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
|
|
93
|
+
name,
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Checkout branche in the repository.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
101
|
+
* root directory.
|
|
102
|
+
* @param {string} branch - Name of the branch to checkout
|
|
103
|
+
* @returns {Promise<void>}
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* await git.checkoutBranch('workspace/repo', 'new-feature');
|
|
107
|
+
*/
|
|
108
|
+
async checkoutBranch(path, branch) {
|
|
109
|
+
await this.toolboxApi.gitCheckoutBranch(this.sandboxId, {
|
|
110
|
+
path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
|
|
111
|
+
branch,
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Clones a Git repository into the specified path. It supports
|
|
117
|
+
* cloning specific branches or commits, and can authenticate with the remote
|
|
118
|
+
* repository if credentials are provided.
|
|
119
|
+
*
|
|
120
|
+
* @param {string} url - Repository URL to clone from
|
|
121
|
+
* @param {string} path - Path where the repository should be cloned. Relative paths are resolved based on the user's
|
|
122
|
+
* root directory.
|
|
123
|
+
* @param {string} [branch] - Specific branch to clone. If not specified, clones the default branch
|
|
124
|
+
* @param {string} [commitId] - Specific commit to clone. If specified, the repository will be left in a detached HEAD state at this commit
|
|
125
|
+
* @param {string} [username] - Git username for authentication
|
|
126
|
+
* @param {string} [password] - Git password or token for authentication
|
|
127
|
+
* @returns {Promise<void>}
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* // Clone the default branch
|
|
131
|
+
* await git.clone(
|
|
132
|
+
* 'https://github.com/user/repo.git',
|
|
133
|
+
* 'workspace/repo'
|
|
134
|
+
* );
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* // Clone a specific branch with authentication
|
|
138
|
+
* await git.clone(
|
|
139
|
+
* 'https://github.com/user/private-repo.git',
|
|
140
|
+
* 'workspace/private',
|
|
141
|
+
* branch='develop',
|
|
142
|
+
* username='user',
|
|
143
|
+
* password='token'
|
|
144
|
+
* );
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* // Clone a specific commit
|
|
148
|
+
* await git.clone(
|
|
149
|
+
* 'https://github.com/user/repo.git',
|
|
150
|
+
* 'workspace/repo-old',
|
|
151
|
+
* commitId='abc123'
|
|
152
|
+
* );
|
|
153
|
+
*/
|
|
154
|
+
async clone(url, path, branch, commitId, username, password) {
|
|
155
|
+
await this.toolboxApi.gitCloneRepository(this.sandboxId, {
|
|
156
|
+
url: url,
|
|
157
|
+
branch: branch,
|
|
158
|
+
path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
|
|
159
|
+
username,
|
|
160
|
+
password,
|
|
161
|
+
commit_id: commitId,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Commits staged changes.
|
|
166
|
+
*
|
|
167
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
168
|
+
* root directory.
|
|
169
|
+
* @param {string} message - Commit message describing the changes
|
|
170
|
+
* @param {string} author - Name of the commit author
|
|
171
|
+
* @param {string} email - Email address of the commit author
|
|
172
|
+
* @returns {Promise<void>}
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* // Stage and commit changes
|
|
176
|
+
* await git.add('workspace/repo', ['README.md']);
|
|
177
|
+
* await git.commit(
|
|
178
|
+
* 'workspace/repo',
|
|
179
|
+
* 'Update documentation',
|
|
180
|
+
* 'John Doe',
|
|
181
|
+
* 'john@example.com'
|
|
182
|
+
* );
|
|
183
|
+
*/
|
|
184
|
+
async commit(path, message, author, email) {
|
|
185
|
+
const response = await this.toolboxApi.gitCommitChanges(this.sandboxId, {
|
|
186
|
+
path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
|
|
187
|
+
message,
|
|
188
|
+
author,
|
|
189
|
+
email,
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
sha: response.data.hash,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Push local changes to the remote repository.
|
|
197
|
+
*
|
|
198
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
199
|
+
* root directory.
|
|
200
|
+
* @param {string} [username] - Git username for authentication
|
|
201
|
+
* @param {string} [password] - Git password or token for authentication
|
|
202
|
+
* @returns {Promise<void>}
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* // Push to a public repository
|
|
206
|
+
* await git.push('workspace/repo');
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* // Push to a private repository
|
|
210
|
+
* await git.push(
|
|
211
|
+
* 'workspace/repo',
|
|
212
|
+
* 'user',
|
|
213
|
+
* 'token'
|
|
214
|
+
* );
|
|
215
|
+
*/
|
|
216
|
+
async push(path, username, password) {
|
|
217
|
+
await this.toolboxApi.gitPushChanges(this.sandboxId, {
|
|
218
|
+
path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
|
|
219
|
+
username,
|
|
220
|
+
password,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Pulls changes from the remote repository.
|
|
225
|
+
*
|
|
226
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
227
|
+
* root directory.
|
|
228
|
+
* @param {string} [username] - Git username for authentication
|
|
229
|
+
* @param {string} [password] - Git password or token for authentication
|
|
230
|
+
* @returns {Promise<void>}
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* // Pull from a public repository
|
|
234
|
+
* await git.pull('workspace/repo');
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* // Pull from a private repository
|
|
238
|
+
* await git.pull(
|
|
239
|
+
* 'workspace/repo',
|
|
240
|
+
* 'user',
|
|
241
|
+
* 'token'
|
|
242
|
+
* );
|
|
243
|
+
*/
|
|
244
|
+
async pull(path, username, password) {
|
|
245
|
+
await this.toolboxApi.gitPullChanges(this.sandboxId, {
|
|
246
|
+
path: (0, Path_1.prefixRelativePath)(await this.getRootDir(), path),
|
|
247
|
+
username,
|
|
248
|
+
password,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Gets the current status of the Git repository.
|
|
253
|
+
*
|
|
254
|
+
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the user's
|
|
255
|
+
* root directory.
|
|
256
|
+
* @returns {Promise<GitStatus>} Current repository status including:
|
|
257
|
+
* - currentBranch: Name of the current branch
|
|
258
|
+
* - ahead: Number of commits ahead of the remote branch
|
|
259
|
+
* - behind: Number of commits behind the remote branch
|
|
260
|
+
* - branchPublished: Whether the branch has been published to the remote repository
|
|
261
|
+
* - fileStatus: List of file statuses
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* const status = await sandbox.git.status('workspace/repo');
|
|
265
|
+
* console.log(`Current branch: ${status.currentBranch}`);
|
|
266
|
+
* console.log(`Commits ahead: ${status.ahead}`);
|
|
267
|
+
* console.log(`Commits behind: ${status.behind}`);
|
|
268
|
+
*/
|
|
269
|
+
async status(path) {
|
|
270
|
+
const response = await this.toolboxApi.gitGetStatus(this.sandboxId, (0, Path_1.prefixRelativePath)(await this.getRootDir(), path));
|
|
271
|
+
return response.data;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
exports.Git = Git;
|
|
275
|
+
//# sourceMappingURL=Git.js.map
|
package/src/Git.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Git.js","sourceRoot":"","sources":["../../../../libs/sdk-typescript/src/Git.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,uCAAiD;AAYjD;;;;GAIG;AACH,MAAa,GAAG;IAEK;IACA;IACA;IAHnB,YACmB,SAAiB,EACjB,UAAsB,EACtB,UAAiC;QAFjC,cAAS,GAAT,SAAS,CAAQ;QACjB,eAAU,GAAV,UAAU,CAAY;QACtB,eAAU,GAAV,UAAU,CAAuB;IACjD,CAAC;IAEJ;;;;;;;;;;;;;;;;OAgBG;IACI,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,KAAe;QAC5C,MAAM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