@daytonaio/sdk 0.9.2 → 0.10.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.
- package/dist/Daytona.d.ts +239 -47
- package/dist/Daytona.js +274 -63
- package/dist/FileSystem.d.ts +183 -32
- package/dist/FileSystem.js +168 -28
- package/dist/Git.d.ts +178 -30
- package/dist/Git.js +178 -30
- package/dist/LspServer.d.ts +170 -22
- package/dist/LspServer.js +162 -18
- package/dist/Process.d.ts +187 -37
- package/dist/Process.js +185 -44
- package/dist/Workspace.d.ts +252 -36
- package/dist/Workspace.js +239 -49
- package/dist/code-toolbox/WorkspacePythonCodeToolbox.d.ts +2 -1
- package/dist/code-toolbox/WorkspacePythonCodeToolbox.js +4 -2
- package/dist/code-toolbox/WorkspaceTsCodeToolbox.d.ts +2 -1
- package/dist/code-toolbox/WorkspaceTsCodeToolbox.js +4 -2
- package/dist/errors/DaytonaError.d.ts +8 -0
- package/dist/errors/DaytonaError.js +12 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -1
- package/dist/utils/Axios.d.ts +6 -0
- package/dist/utils/Axios.js +28 -0
- package/dist/utils/errors.d.ts +10 -0
- package/dist/utils/errors.js +36 -0
- package/dist/utils/timeout.d.ts +35 -0
- package/dist/utils/timeout.js +73 -0
- package/package.json +9 -8
- package/dist/client/apis/ApiKeyApi.d.ts +0 -54
- package/dist/client/apis/ApiKeyApi.js +0 -135
- package/dist/client/apis/BuildApi.d.ts +0 -95
- package/dist/client/apis/BuildApi.js +0 -228
- package/dist/client/apis/ContainerRegistryApi.d.ts +0 -68
- package/dist/client/apis/ContainerRegistryApi.js +0 -163
- package/dist/client/apis/DefaultApi.d.ts +0 -31
- package/dist/client/apis/DefaultApi.js +0 -72
- package/dist/client/apis/GitProviderApi.d.ts +0 -197
- package/dist/client/apis/GitProviderApi.js +0 -477
- package/dist/client/apis/PrebuildApi.d.ts +0 -97
- package/dist/client/apis/PrebuildApi.js +0 -241
- package/dist/client/apis/ProfileApi.d.ts +0 -51
- package/dist/client/apis/ProfileApi.js +0 -128
- package/dist/client/apis/ProjectConfigApi.d.ts +0 -94
- package/dist/client/apis/ProjectConfigApi.js +0 -220
- package/dist/client/apis/ProviderApi.d.ts +0 -71
- package/dist/client/apis/ProviderApi.js +0 -160
- package/dist/client/apis/SampleApi.d.ts +0 -28
- package/dist/client/apis/SampleApi.js +0 -73
- package/dist/client/apis/ServerApi.d.ts +0 -61
- package/dist/client/apis/ServerApi.js +0 -156
- package/dist/client/apis/TargetApi.d.ts +0 -67
- package/dist/client/apis/TargetApi.js +0 -159
- package/dist/client/apis/WorkspaceApi.d.ts +0 -141
- package/dist/client/apis/WorkspaceApi.js +0 -330
- package/dist/client/apis/WorkspaceToolboxApi.d.ts +0 -464
- package/dist/client/apis/WorkspaceToolboxApi.js +0 -1248
- package/dist/client/apis/index.d.ts +0 -14
- package/dist/client/apis/index.js +0 -32
- package/dist/client/index.d.ts +0 -3
- package/dist/client/index.js +0 -21
- package/dist/client/models/ApiKey.d.ts +0 -45
- package/dist/client/models/ApiKey.js +0 -60
- package/dist/client/models/ApikeyApiKeyType.d.ts +0 -26
- package/dist/client/models/ApikeyApiKeyType.js +0 -52
- package/dist/client/models/Build.d.ts +0 -98
- package/dist/client/models/Build.js +0 -91
- package/dist/client/models/BuildBuildState.d.ts +0 -31
- package/dist/client/models/BuildBuildState.js +0 -57
- package/dist/client/models/BuildConfig.d.ts +0 -40
- package/dist/client/models/BuildConfig.js +0 -57
- package/dist/client/models/CachedBuild.d.ts +0 -38
- package/dist/client/models/CachedBuild.js +0 -55
- package/dist/client/models/CloneTarget.d.ts +0 -25
- package/dist/client/models/CloneTarget.js +0 -51
- package/dist/client/models/CompletionContext.d.ts +0 -38
- package/dist/client/models/CompletionContext.js +0 -53
- package/dist/client/models/CompletionItem.d.ts +0 -68
- package/dist/client/models/CompletionItem.js +0 -63
- package/dist/client/models/CompletionList.d.ts +0 -39
- package/dist/client/models/CompletionList.js +0 -56
- package/dist/client/models/ContainerConfig.d.ts +0 -38
- package/dist/client/models/ContainerConfig.js +0 -55
- package/dist/client/models/ContainerRegistry.d.ts +0 -44
- package/dist/client/models/ContainerRegistry.js +0 -59
- package/dist/client/models/CreateBuildDTO.d.ts +0 -52
- package/dist/client/models/CreateBuildDTO.js +0 -62
- package/dist/client/models/CreatePrebuildDTO.d.ts +0 -56
- package/dist/client/models/CreatePrebuildDTO.js +0 -59
- package/dist/client/models/CreateProjectConfigDTO.d.ts +0 -71
- package/dist/client/models/CreateProjectConfigDTO.js +0 -72
- package/dist/client/models/CreateProjectDTO.d.ts +0 -72
- package/dist/client/models/CreateProjectDTO.js +0 -73
- package/dist/client/models/CreateProjectSourceDTO.d.ts +0 -33
- package/dist/client/models/CreateProjectSourceDTO.js +0 -52
- package/dist/client/models/CreateProviderTargetDTO.d.ts +0 -45
- package/dist/client/models/CreateProviderTargetDTO.js +0 -60
- package/dist/client/models/CreateWorkspaceDTO.d.ts +0 -51
- package/dist/client/models/CreateWorkspaceDTO.js +0 -64
- package/dist/client/models/DevcontainerConfig.d.ts +0 -32
- package/dist/client/models/DevcontainerConfig.js +0 -51
- package/dist/client/models/ExecuteRequest.d.ts +0 -38
- package/dist/client/models/ExecuteRequest.js +0 -53
- package/dist/client/models/ExecuteResponse.d.ts +0 -38
- package/dist/client/models/ExecuteResponse.js +0 -55
- package/dist/client/models/FRPSConfig.d.ts +0 -44
- package/dist/client/models/FRPSConfig.js +0 -59
- package/dist/client/models/FileInfo.d.ts +0 -74
- package/dist/client/models/FileInfo.js +0 -79
- package/dist/client/models/FileStatus.d.ts +0 -51
- package/dist/client/models/FileStatus.js +0 -64
- package/dist/client/models/GetRepositoryContext.d.ts +0 -80
- package/dist/client/models/GetRepositoryContext.js +0 -67
- package/dist/client/models/GitAddRequest.d.ts +0 -38
- package/dist/client/models/GitAddRequest.js +0 -55
- package/dist/client/models/GitBranch.d.ts +0 -38
- package/dist/client/models/GitBranch.js +0 -55
- package/dist/client/models/GitBranchRequest.d.ts +0 -38
- package/dist/client/models/GitBranchRequest.js +0 -55
- package/dist/client/models/GitCloneRequest.d.ts +0 -62
- package/dist/client/models/GitCloneRequest.js +0 -63
- package/dist/client/models/GitCommitInfo.d.ts +0 -56
- package/dist/client/models/GitCommitInfo.js +0 -67
- package/dist/client/models/GitCommitRequest.d.ts +0 -50
- package/dist/client/models/GitCommitRequest.js +0 -63
- package/dist/client/models/GitCommitResponse.d.ts +0 -32
- package/dist/client/models/GitCommitResponse.js +0 -51
- package/dist/client/models/GitNamespace.d.ts +0 -38
- package/dist/client/models/GitNamespace.js +0 -55
- package/dist/client/models/GitProvider.d.ts +0 -75
- package/dist/client/models/GitProvider.js +0 -76
- package/dist/client/models/GitPullRequest.d.ts +0 -68
- package/dist/client/models/GitPullRequest.js +0 -75
- package/dist/client/models/GitRepoRequest.d.ts +0 -44
- package/dist/client/models/GitRepoRequest.js +0 -55
- package/dist/client/models/GitRepository.d.ts +0 -87
- package/dist/client/models/GitRepository.js +0 -84
- package/dist/client/models/GitStatus.d.ts +0 -57
- package/dist/client/models/GitStatus.js +0 -62
- package/dist/client/models/GitUser.d.ts +0 -50
- package/dist/client/models/GitUser.js +0 -63
- package/dist/client/models/InstallProviderRequest.d.ts +0 -40
- package/dist/client/models/InstallProviderRequest.js +0 -55
- package/dist/client/models/ListBranchResponse.d.ts +0 -32
- package/dist/client/models/ListBranchResponse.js +0 -51
- package/dist/client/models/LogFileConfig.d.ts +0 -62
- package/dist/client/models/LogFileConfig.js +0 -67
- package/dist/client/models/LspCompletionParams.d.ts +0 -58
- package/dist/client/models/LspCompletionParams.js +0 -69
- package/dist/client/models/LspDocumentRequest.d.ts +0 -44
- package/dist/client/models/LspDocumentRequest.js +0 -59
- package/dist/client/models/LspLocation.d.ts +0 -39
- package/dist/client/models/LspLocation.js +0 -56
- package/dist/client/models/LspPosition.d.ts +0 -38
- package/dist/client/models/LspPosition.js +0 -55
- package/dist/client/models/LspRange.d.ts +0 -39
- package/dist/client/models/LspRange.js +0 -56
- package/dist/client/models/LspServerRequest.d.ts +0 -38
- package/dist/client/models/LspServerRequest.js +0 -55
- package/dist/client/models/LspSymbol.d.ts +0 -45
- package/dist/client/models/LspSymbol.js +0 -60
- package/dist/client/models/Match.d.ts +0 -44
- package/dist/client/models/Match.js +0 -59
- package/dist/client/models/NetworkKey.d.ts +0 -32
- package/dist/client/models/NetworkKey.js +0 -51
- package/dist/client/models/Position.d.ts +0 -38
- package/dist/client/models/Position.js +0 -55
- package/dist/client/models/PrebuildConfig.d.ts +0 -56
- package/dist/client/models/PrebuildConfig.js +0 -67
- package/dist/client/models/PrebuildDTO.d.ts +0 -62
- package/dist/client/models/PrebuildDTO.js +0 -68
- package/dist/client/models/ProfileData.d.ts +0 -34
- package/dist/client/models/ProfileData.js +0 -51
- package/dist/client/models/Project.d.ts +0 -91
- package/dist/client/models/Project.js +0 -88
- package/dist/client/models/ProjectConfig.d.ts +0 -84
- package/dist/client/models/ProjectConfig.js +0 -87
- package/dist/client/models/ProjectDirResponse.d.ts +0 -32
- package/dist/client/models/ProjectDirResponse.js +0 -49
- package/dist/client/models/ProjectInfo.d.ts +0 -56
- package/dist/client/models/ProjectInfo.js +0 -65
- package/dist/client/models/ProjectState.d.ts +0 -45
- package/dist/client/models/ProjectState.js +0 -60
- package/dist/client/models/Provider.d.ts +0 -44
- package/dist/client/models/Provider.js +0 -57
- package/dist/client/models/ProviderProviderInfo.d.ts +0 -44
- package/dist/client/models/ProviderProviderInfo.js +0 -57
- package/dist/client/models/ProviderProviderTargetProperty.d.ts +0 -72
- package/dist/client/models/ProviderProviderTargetProperty.js +0 -64
- package/dist/client/models/ProviderProviderTargetPropertyType.d.ts +0 -29
- package/dist/client/models/ProviderProviderTargetPropertyType.js +0 -55
- package/dist/client/models/ProviderTarget.d.ts +0 -51
- package/dist/client/models/ProviderTarget.js +0 -64
- package/dist/client/models/ReplaceRequest.d.ts +0 -44
- package/dist/client/models/ReplaceRequest.js +0 -59
- package/dist/client/models/ReplaceResult.d.ts +0 -44
- package/dist/client/models/ReplaceResult.js +0 -53
- package/dist/client/models/RepositoryUrl.d.ts +0 -32
- package/dist/client/models/RepositoryUrl.js +0 -51
- package/dist/client/models/Sample.d.ts +0 -44
- package/dist/client/models/Sample.js +0 -59
- package/dist/client/models/SearchFilesResponse.d.ts +0 -32
- package/dist/client/models/SearchFilesResponse.js +0 -51
- package/dist/client/models/ServerConfig.d.ts +0 -130
- package/dist/client/models/ServerConfig.js +0 -119
- package/dist/client/models/SetGitProviderConfig.d.ts +0 -75
- package/dist/client/models/SetGitProviderConfig.js +0 -70
- package/dist/client/models/SetProjectState.d.ts +0 -39
- package/dist/client/models/SetProjectState.js +0 -56
- package/dist/client/models/SigningMethod.d.ts +0 -25
- package/dist/client/models/SigningMethod.js +0 -51
- package/dist/client/models/Status.d.ts +0 -31
- package/dist/client/models/Status.js +0 -57
- package/dist/client/models/Workspace.d.ts +0 -51
- package/dist/client/models/Workspace.js +0 -64
- package/dist/client/models/WorkspaceDTO.d.ts +0 -58
- package/dist/client/models/WorkspaceDTO.js +0 -67
- package/dist/client/models/WorkspaceInfo.d.ts +0 -45
- package/dist/client/models/WorkspaceInfo.js +0 -58
- package/dist/client/models/index.d.ts +0 -79
- package/dist/client/models/index.js +0 -97
- package/dist/client/runtime.d.ts +0 -182
- package/dist/client/runtime.js +0 -340
package/dist/Git.d.ts
CHANGED
|
@@ -1,67 +1,215 @@
|
|
|
1
|
-
import { Workspace as WorkspaceInstance, ToolboxApi, ListBranchResponse, GitStatus } from '@daytonaio/api-client';
|
|
2
|
-
import { Workspace } from './Workspace';
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* The Daytona SDK provides built-in Git support. This guide covers all available Git
|
|
3
|
+
* operations and best practices. Daytona SDK provides an option to clone, check status,
|
|
4
|
+
* and manage Git repositories in Sandboxes. You can interact with Git repositories using
|
|
5
|
+
* the `git` module.
|
|
6
|
+
*
|
|
7
|
+
* @module Git
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Basic Git workflow
|
|
11
|
+
* // Create and initialize workspace
|
|
12
|
+
* const workspace = await daytona.create();
|
|
13
|
+
*
|
|
14
|
+
* // Clone a repository
|
|
15
|
+
* await workspace.git.clone(
|
|
16
|
+
* 'https://github.com/user/repo.git',
|
|
17
|
+
* '/workspace/repo'
|
|
18
|
+
* );
|
|
19
|
+
*
|
|
20
|
+
* // Make some changes
|
|
21
|
+
* await workspace.fs.uploadFile(
|
|
22
|
+
* '/workspace/repo/test.txt',
|
|
23
|
+
* new File([Buffer.from('Hello, World!')], 'test.txt')
|
|
24
|
+
* );
|
|
25
|
+
*
|
|
26
|
+
* // Stage and commit changes
|
|
27
|
+
* await workspace.git.add('/workspace/repo', ['test.txt']);
|
|
28
|
+
* await workspace.git.commit(
|
|
29
|
+
* '/workspace/repo',
|
|
30
|
+
* 'Add test file',
|
|
31
|
+
* 'John Doe',
|
|
32
|
+
* 'john@example.com'
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* // Push changes (with authentication)
|
|
36
|
+
* await workspace.git.push(
|
|
37
|
+
* '/workspace/repo',
|
|
38
|
+
* 'user',
|
|
39
|
+
* 'token'
|
|
40
|
+
* );
|
|
41
|
+
*
|
|
6
42
|
*/
|
|
43
|
+
import { ToolboxApi, ListBranchResponse, GitStatus } from '@daytonaio/api-client';
|
|
44
|
+
import { Workspace, WorkspaceInstance } from './Workspace';
|
|
7
45
|
export declare class Git {
|
|
8
46
|
private readonly workspace;
|
|
9
47
|
private readonly toolboxApi;
|
|
10
48
|
private readonly instance;
|
|
11
49
|
constructor(workspace: Workspace, toolboxApi: ToolboxApi, instance: WorkspaceInstance);
|
|
12
50
|
/**
|
|
13
|
-
* Stages files for commit
|
|
14
|
-
*
|
|
15
|
-
*
|
|
51
|
+
* Stages files for commit.
|
|
52
|
+
*
|
|
53
|
+
* This method stages the specified files for the next commit, similar to
|
|
54
|
+
* running 'git add' on the command line.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
57
|
+
* @param {string[]} files - List of file paths or directories to stage, relative to the repository root
|
|
16
58
|
* @returns {Promise<void>}
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Stage a single file
|
|
62
|
+
* await git.add('/workspace/repo', ['file.txt']);
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // Stage whole repository
|
|
66
|
+
* await git.add('/workspace/repo', ['.']);
|
|
17
67
|
*/
|
|
18
68
|
add(path: string, files: string[]): Promise<void>;
|
|
19
69
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
70
|
+
* List branches in the repository.
|
|
71
|
+
*
|
|
72
|
+
* This method returns information about all branches in the repository.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
75
|
+
* @returns {Promise<ListBranchResponse>} List of branches in the repository
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* const response = await git.branches('/workspace/repo');
|
|
79
|
+
* console.log(`Branches: ${response.branches}`);
|
|
23
80
|
*/
|
|
24
81
|
branches(path: string): Promise<ListBranchResponse>;
|
|
25
82
|
/**
|
|
26
|
-
* Clones a Git repository
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
83
|
+
* Clones a Git repository.
|
|
84
|
+
*
|
|
85
|
+
* This method clones a Git repository into the specified path. It supports
|
|
86
|
+
* cloning specific branches or commits, and can authenticate with the remote
|
|
87
|
+
* repository if credentials are provided.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} url - Repository URL to clone from
|
|
90
|
+
* @param {string} path - Absolute path where the repository should be cloned
|
|
91
|
+
* @param {string} [branch] - Specific branch to clone. If not specified, clones the default branch
|
|
92
|
+
* @param {string} [commitId] - Specific commit to clone. If specified, the repository will be left in a detached HEAD state at this commit
|
|
31
93
|
* @param {string} [username] - Git username for authentication
|
|
32
|
-
* @param {string} [password] - Git password
|
|
94
|
+
* @param {string} [password] - Git password or token for authentication
|
|
33
95
|
* @returns {Promise<void>}
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* // Clone the default branch
|
|
99
|
+
* await git.clone(
|
|
100
|
+
* 'https://github.com/user/repo.git',
|
|
101
|
+
* '/workspace/repo'
|
|
102
|
+
* );
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* // Clone a specific branch with authentication
|
|
106
|
+
* await git.clone(
|
|
107
|
+
* 'https://github.com/user/private-repo.git',
|
|
108
|
+
* '/workspace/private',
|
|
109
|
+
* branch='develop',
|
|
110
|
+
* username='user',
|
|
111
|
+
* password='token'
|
|
112
|
+
* );
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // Clone a specific commit
|
|
116
|
+
* await git.clone(
|
|
117
|
+
* 'https://github.com/user/repo.git',
|
|
118
|
+
* '/workspace/repo-old',
|
|
119
|
+
* commitId='abc123'
|
|
120
|
+
* );
|
|
34
121
|
*/
|
|
35
122
|
clone(url: string, path: string, branch?: string, commitId?: string, username?: string, password?: string): Promise<void>;
|
|
36
123
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
124
|
+
* Commits staged changes.
|
|
125
|
+
*
|
|
126
|
+
* This method creates a new commit with the staged changes. Make sure to stage
|
|
127
|
+
* changes using the add() method before committing.
|
|
128
|
+
*
|
|
129
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
130
|
+
* @param {string} message - Commit message describing the changes
|
|
131
|
+
* @param {string} author - Name of the commit author
|
|
132
|
+
* @param {string} email - Email address of the commit author
|
|
42
133
|
* @returns {Promise<void>}
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* // Stage and commit changes
|
|
137
|
+
* await git.add('/workspace/repo', ['README.md']);
|
|
138
|
+
* await git.commit(
|
|
139
|
+
* '/workspace/repo',
|
|
140
|
+
* 'Update documentation',
|
|
141
|
+
* 'John Doe',
|
|
142
|
+
* 'john@example.com'
|
|
143
|
+
* );
|
|
43
144
|
*/
|
|
44
145
|
commit(path: string, message: string, author: string, email: string): Promise<void>;
|
|
45
146
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
147
|
+
* Push local changes to the remote repository.
|
|
148
|
+
*
|
|
149
|
+
* This method pushes committed changes to the remote repository. If the remote
|
|
150
|
+
* requires authentication, username and password/token must be provided.
|
|
151
|
+
*
|
|
152
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
48
153
|
* @param {string} [username] - Git username for authentication
|
|
49
|
-
* @param {string} [password] - Git password
|
|
154
|
+
* @param {string} [password] - Git password or token for authentication
|
|
50
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
|
+
* );
|
|
51
168
|
*/
|
|
52
169
|
push(path: string, username?: string, password?: string): Promise<void>;
|
|
53
170
|
/**
|
|
54
|
-
* Pulls changes from remote repository
|
|
55
|
-
*
|
|
171
|
+
* Pulls changes from the remote repository.
|
|
172
|
+
*
|
|
173
|
+
* This method fetches and merges changes from the remote repository. If the remote
|
|
174
|
+
* requires authentication, username and password/token must be provided.
|
|
175
|
+
*
|
|
176
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
56
177
|
* @param {string} [username] - Git username for authentication
|
|
57
|
-
* @param {string} [password] - Git password
|
|
178
|
+
* @param {string} [password] - Git password or token for authentication
|
|
58
179
|
* @returns {Promise<void>}
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* // Pull from a public repository
|
|
183
|
+
* await git.pull('/workspace/repo');
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* // Pull from a private repository
|
|
187
|
+
* await git.pull(
|
|
188
|
+
* '/workspace/repo',
|
|
189
|
+
* 'user',
|
|
190
|
+
* 'token'
|
|
191
|
+
* );
|
|
59
192
|
*/
|
|
60
193
|
pull(path: string, username?: string, password?: string): Promise<void>;
|
|
61
194
|
/**
|
|
62
|
-
* Gets the current Git repository
|
|
63
|
-
*
|
|
64
|
-
*
|
|
195
|
+
* Gets the current status of the Git repository.
|
|
196
|
+
*
|
|
197
|
+
* This method returns information about the current state of the repository,
|
|
198
|
+
* including staged and unstaged changes, current branch, and untracked files.
|
|
199
|
+
*
|
|
200
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
201
|
+
* @returns {Promise<GitStatus>} Current repository status including:
|
|
202
|
+
* - currentBranch: Name of the current branch
|
|
203
|
+
* - ahead: Number of commits ahead of the remote branch
|
|
204
|
+
* - behind: Number of commits behind the remote branch
|
|
205
|
+
* - branchPublished: Whether the branch has been published to the remote repository
|
|
206
|
+
* - fileStatus: List of file statuses
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* const status = await workspace.git.status('/workspace/repo');
|
|
210
|
+
* console.log(`Current branch: ${status.currentBranch}`);
|
|
211
|
+
* console.log(`Commits ahead: ${status.ahead}`);
|
|
212
|
+
* console.log(`Commits behind: ${status.behind}`);
|
|
65
213
|
*/
|
|
66
214
|
status(path: string): Promise<GitStatus>;
|
|
67
215
|
}
|
package/dist/Git.js
CHANGED
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Git = void 0;
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* The Daytona SDK provides built-in Git support. This guide covers all available Git
|
|
4
|
+
* operations and best practices. Daytona SDK provides an option to clone, check status,
|
|
5
|
+
* and manage Git repositories in Sandboxes. You can interact with Git repositories using
|
|
6
|
+
* the `git` module.
|
|
7
|
+
*
|
|
8
|
+
* @module Git
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Basic Git workflow
|
|
12
|
+
* // Create and initialize workspace
|
|
13
|
+
* const workspace = await daytona.create();
|
|
14
|
+
*
|
|
15
|
+
* // Clone a repository
|
|
16
|
+
* await workspace.git.clone(
|
|
17
|
+
* 'https://github.com/user/repo.git',
|
|
18
|
+
* '/workspace/repo'
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* // Make some changes
|
|
22
|
+
* await workspace.fs.uploadFile(
|
|
23
|
+
* '/workspace/repo/test.txt',
|
|
24
|
+
* new File([Buffer.from('Hello, World!')], 'test.txt')
|
|
25
|
+
* );
|
|
26
|
+
*
|
|
27
|
+
* // Stage and commit changes
|
|
28
|
+
* await workspace.git.add('/workspace/repo', ['test.txt']);
|
|
29
|
+
* await workspace.git.commit(
|
|
30
|
+
* '/workspace/repo',
|
|
31
|
+
* 'Add test file',
|
|
32
|
+
* 'John Doe',
|
|
33
|
+
* 'john@example.com'
|
|
34
|
+
* );
|
|
35
|
+
*
|
|
36
|
+
* // Push changes (with authentication)
|
|
37
|
+
* await workspace.git.push(
|
|
38
|
+
* '/workspace/repo',
|
|
39
|
+
* 'user',
|
|
40
|
+
* 'token'
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
7
43
|
*/
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.Git = void 0;
|
|
8
46
|
class Git {
|
|
9
47
|
constructor(workspace, toolboxApi, instance) {
|
|
10
48
|
this.workspace = workspace;
|
|
@@ -12,10 +50,22 @@ class Git {
|
|
|
12
50
|
this.instance = instance;
|
|
13
51
|
}
|
|
14
52
|
/**
|
|
15
|
-
* Stages files for commit
|
|
16
|
-
*
|
|
17
|
-
*
|
|
53
|
+
* Stages files for commit.
|
|
54
|
+
*
|
|
55
|
+
* This method stages the specified files for the next commit, similar to
|
|
56
|
+
* running 'git add' on the command line.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
59
|
+
* @param {string[]} files - List of file paths or directories to stage, relative to the repository root
|
|
18
60
|
* @returns {Promise<void>}
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // Stage a single file
|
|
64
|
+
* await git.add('/workspace/repo', ['file.txt']);
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Stage whole repository
|
|
68
|
+
* await git.add('/workspace/repo', ['.']);
|
|
19
69
|
*/
|
|
20
70
|
async add(path, files) {
|
|
21
71
|
await this.toolboxApi.gitAddFiles(this.instance.id, {
|
|
@@ -24,23 +74,60 @@ class Git {
|
|
|
24
74
|
});
|
|
25
75
|
}
|
|
26
76
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
77
|
+
* List branches in the repository.
|
|
78
|
+
*
|
|
79
|
+
* This method returns information about all branches in the repository.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
82
|
+
* @returns {Promise<ListBranchResponse>} List of branches in the repository
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* const response = await git.branches('/workspace/repo');
|
|
86
|
+
* console.log(`Branches: ${response.branches}`);
|
|
30
87
|
*/
|
|
31
88
|
async branches(path) {
|
|
32
89
|
const response = await this.toolboxApi.gitListBranches(this.instance.id, path);
|
|
33
90
|
return response.data;
|
|
34
91
|
}
|
|
35
92
|
/**
|
|
36
|
-
* Clones a Git repository
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
93
|
+
* Clones a Git repository.
|
|
94
|
+
*
|
|
95
|
+
* This method clones a Git repository into the specified path. It supports
|
|
96
|
+
* cloning specific branches or commits, and can authenticate with the remote
|
|
97
|
+
* repository if credentials are provided.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} url - Repository URL to clone from
|
|
100
|
+
* @param {string} path - Absolute path where the repository should be cloned
|
|
101
|
+
* @param {string} [branch] - Specific branch to clone. If not specified, clones the default branch
|
|
102
|
+
* @param {string} [commitId] - Specific commit to clone. If specified, the repository will be left in a detached HEAD state at this commit
|
|
41
103
|
* @param {string} [username] - Git username for authentication
|
|
42
|
-
* @param {string} [password] - Git password
|
|
104
|
+
* @param {string} [password] - Git password or token for authentication
|
|
43
105
|
* @returns {Promise<void>}
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* // Clone the default branch
|
|
109
|
+
* await git.clone(
|
|
110
|
+
* 'https://github.com/user/repo.git',
|
|
111
|
+
* '/workspace/repo'
|
|
112
|
+
* );
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // Clone a specific branch with authentication
|
|
116
|
+
* await git.clone(
|
|
117
|
+
* 'https://github.com/user/private-repo.git',
|
|
118
|
+
* '/workspace/private',
|
|
119
|
+
* branch='develop',
|
|
120
|
+
* username='user',
|
|
121
|
+
* password='token'
|
|
122
|
+
* );
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* // Clone a specific commit
|
|
126
|
+
* await git.clone(
|
|
127
|
+
* 'https://github.com/user/repo.git',
|
|
128
|
+
* '/workspace/repo-old',
|
|
129
|
+
* commitId='abc123'
|
|
130
|
+
* );
|
|
44
131
|
*/
|
|
45
132
|
async clone(url, path, branch, commitId, username, password) {
|
|
46
133
|
await this.toolboxApi.gitCloneRepository(this.instance.id, {
|
|
@@ -53,12 +140,26 @@ class Git {
|
|
|
53
140
|
});
|
|
54
141
|
}
|
|
55
142
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
143
|
+
* Commits staged changes.
|
|
144
|
+
*
|
|
145
|
+
* This method creates a new commit with the staged changes. Make sure to stage
|
|
146
|
+
* changes using the add() method before committing.
|
|
147
|
+
*
|
|
148
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
149
|
+
* @param {string} message - Commit message describing the changes
|
|
150
|
+
* @param {string} author - Name of the commit author
|
|
151
|
+
* @param {string} email - Email address of the commit author
|
|
61
152
|
* @returns {Promise<void>}
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* // Stage and commit changes
|
|
156
|
+
* await git.add('/workspace/repo', ['README.md']);
|
|
157
|
+
* await git.commit(
|
|
158
|
+
* '/workspace/repo',
|
|
159
|
+
* 'Update documentation',
|
|
160
|
+
* 'John Doe',
|
|
161
|
+
* 'john@example.com'
|
|
162
|
+
* );
|
|
62
163
|
*/
|
|
63
164
|
async commit(path, message, author, email) {
|
|
64
165
|
await this.toolboxApi.gitCommitChanges(this.instance.id, {
|
|
@@ -69,11 +170,27 @@ class Git {
|
|
|
69
170
|
});
|
|
70
171
|
}
|
|
71
172
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
173
|
+
* Push local changes to the remote repository.
|
|
174
|
+
*
|
|
175
|
+
* This method pushes committed changes to the remote repository. If the remote
|
|
176
|
+
* requires authentication, username and password/token must be provided.
|
|
177
|
+
*
|
|
178
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
74
179
|
* @param {string} [username] - Git username for authentication
|
|
75
|
-
* @param {string} [password] - Git password
|
|
180
|
+
* @param {string} [password] - Git password or token for authentication
|
|
76
181
|
* @returns {Promise<void>}
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* // Push to a public repository
|
|
185
|
+
* await git.push('/workspace/repo');
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* // Push to a private repository
|
|
189
|
+
* await git.push(
|
|
190
|
+
* '/workspace/repo',
|
|
191
|
+
* 'user',
|
|
192
|
+
* 'token'
|
|
193
|
+
* );
|
|
77
194
|
*/
|
|
78
195
|
async push(path, username, password) {
|
|
79
196
|
await this.toolboxApi.gitPushChanges(this.instance.id, {
|
|
@@ -83,11 +200,27 @@ class Git {
|
|
|
83
200
|
});
|
|
84
201
|
}
|
|
85
202
|
/**
|
|
86
|
-
* Pulls changes from remote repository
|
|
87
|
-
*
|
|
203
|
+
* Pulls changes from the remote repository.
|
|
204
|
+
*
|
|
205
|
+
* This method fetches and merges changes from the remote repository. If the remote
|
|
206
|
+
* requires authentication, username and password/token must be provided.
|
|
207
|
+
*
|
|
208
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
88
209
|
* @param {string} [username] - Git username for authentication
|
|
89
|
-
* @param {string} [password] - Git password
|
|
210
|
+
* @param {string} [password] - Git password or token for authentication
|
|
90
211
|
* @returns {Promise<void>}
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* // Pull from a public repository
|
|
215
|
+
* await git.pull('/workspace/repo');
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* // Pull from a private repository
|
|
219
|
+
* await git.pull(
|
|
220
|
+
* '/workspace/repo',
|
|
221
|
+
* 'user',
|
|
222
|
+
* 'token'
|
|
223
|
+
* );
|
|
91
224
|
*/
|
|
92
225
|
async pull(path, username, password) {
|
|
93
226
|
await this.toolboxApi.gitPullChanges(this.instance.id, {
|
|
@@ -97,9 +230,24 @@ class Git {
|
|
|
97
230
|
});
|
|
98
231
|
}
|
|
99
232
|
/**
|
|
100
|
-
* Gets the current Git repository
|
|
101
|
-
*
|
|
102
|
-
*
|
|
233
|
+
* Gets the current status of the Git repository.
|
|
234
|
+
*
|
|
235
|
+
* This method returns information about the current state of the repository,
|
|
236
|
+
* including staged and unstaged changes, current branch, and untracked files.
|
|
237
|
+
*
|
|
238
|
+
* @param {string} path - Absolute path to the Git repository root
|
|
239
|
+
* @returns {Promise<GitStatus>} Current repository status including:
|
|
240
|
+
* - currentBranch: Name of the current branch
|
|
241
|
+
* - ahead: Number of commits ahead of the remote branch
|
|
242
|
+
* - behind: Number of commits behind the remote branch
|
|
243
|
+
* - branchPublished: Whether the branch has been published to the remote repository
|
|
244
|
+
* - fileStatus: List of file statuses
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* const status = await workspace.git.status('/workspace/repo');
|
|
248
|
+
* console.log(`Current branch: ${status.currentBranch}`);
|
|
249
|
+
* console.log(`Commits ahead: ${status.ahead}`);
|
|
250
|
+
* console.log(`Commits behind: ${status.behind}`);
|
|
103
251
|
*/
|
|
104
252
|
async status(path) {
|
|
105
253
|
const response = await this.toolboxApi.gitGetStatus(this.instance.id, path);
|