gent-cli 1.9.0 → 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gent-cli",
3
- "version": "1.9.0",
3
+ "version": "2.1.0",
4
4
  "description": "A modern, Git-like version control CLI with built-in cloud authentication and global user identity management.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -76,14 +76,17 @@ async function create(repoName, options) {
76
76
  'main'
77
77
  );
78
78
 
79
- spinner.succeed(chalk.green(`Repository created: ${repository.name}`));
79
+ const ownerId = repository.owner_id || repository.owner?.id || repository.owner;
80
+ const name = repository.name || repository.project_name || repoName;
81
+
82
+ spinner.succeed(chalk.green(`Repository created: ${name}`));
80
83
 
81
84
  console.log(chalk.cyan('\nRepository Details:'));
82
- console.log(chalk.gray(' Name:'), repository.name);
83
- console.log(chalk.gray(' Owner:'), repository.owner_email);
85
+ console.log(chalk.gray(' Name:'), name);
86
+ console.log(chalk.gray(' Owner:'), ownerId);
84
87
  console.log(chalk.gray(' Private:'), repository.is_private ? 'Yes' : 'No');
85
88
  console.log(chalk.gray(' Description:'), repository.description || '(none)');
86
- console.log(chalk.gray(' Created:'), new Date(repository.created_at).toLocaleString());
89
+ console.log(chalk.gray(' Created:'), new Date(repository.created_at || repository.created || new Date()).toLocaleString());
87
90
 
88
91
  // Initialize local repository if requested
89
92
  if (options.initLocal) {
@@ -96,7 +99,7 @@ async function create(repoName, options) {
96
99
  await ensureDir(path.join(gentPath, 'refs', 'heads'));
97
100
 
98
101
  // Add remote
99
- await addRemote('origin', repository.owner_id, repository.name, cwd);
102
+ await addRemote('origin', ownerId, name, cwd);
100
103
 
101
104
  console.log(chalk.green('\n✓ Local repository initialized and remote added'));
102
105
  console.log(chalk.yellow('\nNext steps:'));
@@ -127,8 +127,11 @@ node_modules/
127
127
  'main'
128
128
  );
129
129
 
130
- await addRemote('origin', repository.owner_id, repository.name, cwd);
131
- spinner.succeed(chalk.green(`Created cloud repository: ${repository.owner_id}/${repository.name}`));
130
+ const ownerId = repository.owner_id || repository.owner?.id || repository.owner;
131
+ const name = repository.name || repository.project_name || repoName;
132
+
133
+ await addRemote('origin', ownerId, name, cwd);
134
+ spinner.succeed(chalk.green(`Created cloud repository: ${ownerId}/${name}`));
132
135
  console.log(chalk.gray(`Remote 'origin' added`));
133
136
  } catch (error) {
134
137
  console.log(chalk.red(`\nFailed to create cloud repository: ${error.message}`));
@@ -20,6 +20,14 @@ function buildUrl(template, params = {}) {
20
20
  return url;
21
21
  }
22
22
 
23
+ /**
24
+ * Create a new repository
25
+ * @param {string} name - Repository name
26
+ * @param {string} description - Repository description
27
+ * @param {boolean} isPrivate - Whether the repository is private
28
+ * @param {string} defaultBranch - Default branch name
29
+ * @returns {Promise<Object>} Created repository data
30
+ */
23
31
  /**
24
32
  * Create a new repository
25
33
  * @param {string} name - Repository name
@@ -58,12 +66,12 @@ async function listRepositories() {
58
66
  /**
59
67
  * Get repository details
60
68
  * @param {number} ownerId - Owner user ID
61
- * @param {string} projectName - Project name
69
+ * @param {string} name - Repository name
62
70
  * @returns {Promise<Object>} Repository data
63
71
  */
64
- async function getRepository(ownerId, projectName) {
72
+ async function getRepository(ownerId, name) {
65
73
  try {
66
- const url = buildUrl(API_ENDPOINTS.REPOS_GET, { owner_id: ownerId, project_name: projectName });
74
+ const url = buildUrl(API_ENDPOINTS.REPOS_GET, { owner_id: ownerId, name: name });
67
75
  const response = await apiClient.get(url);
68
76
  return response;
69
77
  } catch (error) {
@@ -74,12 +82,12 @@ async function getRepository(ownerId, projectName) {
74
82
  /**
75
83
  * Delete a repository
76
84
  * @param {number} ownerId - Owner user ID
77
- * @param {string} projectName - Project name
85
+ * @param {string} name - Repository name
78
86
  * @returns {Promise<Object>} Delete response
79
87
  */
80
- async function deleteRepository(ownerId, projectName) {
88
+ async function deleteRepository(ownerId, name) {
81
89
  try {
82
- const url = buildUrl(API_ENDPOINTS.REPOS_DELETE, { owner_id: ownerId, project_name: projectName });
90
+ const url = buildUrl(API_ENDPOINTS.REPOS_DELETE, { owner_id: ownerId, name: name });
83
91
  const response = await apiClient.delete(url);
84
92
  return response;
85
93
  } catch (error) {
@@ -90,14 +98,14 @@ async function deleteRepository(ownerId, projectName) {
90
98
  /**
91
99
  * Create a blob (file content) in the repository
92
100
  * @param {number} ownerId - Owner user ID
93
- * @param {string} projectName - Project name
101
+ * @param {string} name - Repository name
94
102
  * @param {string} content - File content
95
103
  * @param {string} encoding - Encoding type (utf-8 or base64)
96
104
  * @returns {Promise<Object>} Created blob data
97
105
  */
98
- async function createBlob(ownerId, projectName, content, encoding = 'utf-8') {
106
+ async function createBlob(ownerId, name, content, encoding = 'utf-8') {
99
107
  try {
100
- const url = buildUrl(API_ENDPOINTS.BLOB_CREATE, { owner_id: ownerId, project_name: projectName });
108
+ const url = buildUrl(API_ENDPOINTS.BLOB_CREATE, { owner_id: ownerId, name: name });
101
109
  const response = await apiClient.post(url, {
102
110
  content,
103
111
  encoding
@@ -111,13 +119,13 @@ async function createBlob(ownerId, projectName, content, encoding = 'utf-8') {
111
119
  /**
112
120
  * Get a blob by SHA
113
121
  * @param {number} ownerId - Owner user ID
114
- * @param {string} projectName - Project name
122
+ * @param {string} name - Repository name
115
123
  * @param {string} sha - Blob SHA
116
124
  * @returns {Promise<Object>} Blob data
117
125
  */
118
- async function getBlob(ownerId, projectName, sha) {
126
+ async function getBlob(ownerId, name, sha) {
119
127
  try {
120
- const url = buildUrl(API_ENDPOINTS.BLOB_GET, { owner_id: ownerId, project_name: projectName, sha });
128
+ const url = buildUrl(API_ENDPOINTS.BLOB_GET, { owner_id: ownerId, name: name, sha });
121
129
  const response = await apiClient.get(url);
122
130
  return response;
123
131
  } catch (error) {
@@ -128,13 +136,13 @@ async function getBlob(ownerId, projectName, sha) {
128
136
  /**
129
137
  * Create a tree (directory structure) in the repository
130
138
  * @param {number} ownerId - Owner user ID
131
- * @param {string} projectName - Project name
139
+ * @param {string} name - Repository name
132
140
  * @param {Array} entries - Tree entries
133
141
  * @returns {Promise<Object>} Created tree data
134
142
  */
135
- async function createTree(ownerId, projectName, entries) {
143
+ async function createTree(ownerId, name, entries) {
136
144
  try {
137
- const url = buildUrl(API_ENDPOINTS.TREE_CREATE, { owner_id: ownerId, project_name: projectName });
145
+ const url = buildUrl(API_ENDPOINTS.TREE_CREATE, { owner_id: ownerId, name: name });
138
146
  const response = await apiClient.post(url, {
139
147
  entries
140
148
  });
@@ -147,13 +155,13 @@ async function createTree(ownerId, projectName, entries) {
147
155
  /**
148
156
  * Get a tree by SHA
149
157
  * @param {number} ownerId - Owner user ID
150
- * @param {string} projectName - Project name
158
+ * @param {string} name - Repository name
151
159
  * @param {string} sha - Tree SHA
152
160
  * @returns {Promise<Object>} Tree data
153
161
  */
154
- async function getTree(ownerId, projectName, sha) {
162
+ async function getTree(ownerId, name, sha) {
155
163
  try {
156
- const url = buildUrl(API_ENDPOINTS.TREE_GET, { owner_id: ownerId, project_name: projectName, sha });
164
+ const url = buildUrl(API_ENDPOINTS.TREE_GET, { owner_id: ownerId, name: name, sha });
157
165
  const response = await apiClient.get(url);
158
166
  return response;
159
167
  } catch (error) {
@@ -164,13 +172,13 @@ async function getTree(ownerId, projectName, sha) {
164
172
  /**
165
173
  * Create a commit in the repository
166
174
  * @param {number} ownerId - Owner user ID
167
- * @param {string} projectName - Project name
175
+ * @param {string} name - Repository name
168
176
  * @param {Object} commitData - Commit data (message, tree_sha, parent_shas, author_name, author_email, branch)
169
177
  * @returns {Promise<Object>} Created commit data
170
178
  */
171
- async function createCommit(ownerId, projectName, commitData) {
179
+ async function createCommit(ownerId, name, commitData) {
172
180
  try {
173
- const url = buildUrl(API_ENDPOINTS.COMMITS_CREATE, { owner_id: ownerId, project_name: projectName });
181
+ const url = buildUrl(API_ENDPOINTS.COMMITS_CREATE, { owner_id: ownerId, name: name });
174
182
  const response = await apiClient.post(url, commitData);
175
183
  return response;
176
184
  } catch (error) {
@@ -181,12 +189,12 @@ async function createCommit(ownerId, projectName, commitData) {
181
189
  /**
182
190
  * List all commits in a repository
183
191
  * @param {number} ownerId - Owner user ID
184
- * @param {string} projectName - Project name
192
+ * @param {string} name - Repository name
185
193
  * @returns {Promise<Array>} List of commits
186
194
  */
187
- async function listCommits(ownerId, projectName) {
195
+ async function listCommits(ownerId, name) {
188
196
  try {
189
- const url = buildUrl(API_ENDPOINTS.COMMITS_LIST, { owner_id: ownerId, project_name: projectName });
197
+ const url = buildUrl(API_ENDPOINTS.COMMITS_LIST, { owner_id: ownerId, name: name });
190
198
  const response = await apiClient.get(url);
191
199
  return response;
192
200
  } catch (error) {
@@ -197,13 +205,13 @@ async function listCommits(ownerId, projectName) {
197
205
  /**
198
206
  * Get a commit by SHA
199
207
  * @param {number} ownerId - Owner user ID
200
- * @param {string} projectName - Project name
208
+ * @param {string} name - Repository name
201
209
  * @param {string} sha - Commit SHA
202
210
  * @returns {Promise<Object>} Commit data
203
211
  */
204
- async function getCommit(ownerId, projectName, sha) {
212
+ async function getCommit(ownerId, name, sha) {
205
213
  try {
206
- const url = buildUrl(API_ENDPOINTS.COMMITS_GET, { owner_id: ownerId, project_name: projectName, sha });
214
+ const url = buildUrl(API_ENDPOINTS.COMMITS_GET, { owner_id: ownerId, name: name, sha });
207
215
  const response = await apiClient.get(url);
208
216
  return response;
209
217
  } catch (error) {
@@ -214,14 +222,14 @@ async function getCommit(ownerId, projectName, sha) {
214
222
  /**
215
223
  * Create a branch in the repository
216
224
  * @param {number} ownerId - Owner user ID
217
- * @param {string} projectName - Project name
225
+ * @param {string} name - Repository name
218
226
  * @param {string} branchName - Branch name
219
227
  * @param {string} commitSha - Commit SHA to point the branch to
220
228
  * @returns {Promise<Object>} Created branch data
221
229
  */
222
- async function createBranch(ownerId, projectName, branchName, commitSha) {
230
+ async function createBranch(ownerId, name, branchName, commitSha) {
223
231
  try {
224
- const url = buildUrl(API_ENDPOINTS.BRANCHES_CREATE, { owner_id: ownerId, project_name: projectName });
232
+ const url = buildUrl(API_ENDPOINTS.BRANCHES_CREATE, { owner_id: ownerId, name: name });
225
233
  const response = await apiClient.post(url, {
226
234
  name: branchName,
227
235
  commit_sha: commitSha
@@ -235,12 +243,12 @@ async function createBranch(ownerId, projectName, branchName, commitSha) {
235
243
  /**
236
244
  * List all branches in a repository
237
245
  * @param {number} ownerId - Owner user ID
238
- * @param {string} projectName - Project name
246
+ * @param {string} name - Repository name
239
247
  * @returns {Promise<Array>} List of branches
240
248
  */
241
- async function listBranches(ownerId, projectName) {
249
+ async function listBranches(ownerId, name) {
242
250
  try {
243
- const url = buildUrl(API_ENDPOINTS.BRANCHES_LIST, { owner_id: ownerId, project_name: projectName });
251
+ const url = buildUrl(API_ENDPOINTS.BRANCHES_LIST, { owner_id: ownerId, name: name });
244
252
  const response = await apiClient.get(url);
245
253
  return response;
246
254
  } catch (error) {
@@ -251,13 +259,13 @@ async function listBranches(ownerId, projectName) {
251
259
  /**
252
260
  * Get a branch by name
253
261
  * @param {number} ownerId - Owner user ID
254
- * @param {string} projectName - Project name
262
+ * @param {string} name - Repository name
255
263
  * @param {string} branchName - Branch name
256
264
  * @returns {Promise<Object>} Branch data
257
265
  */
258
- async function getBranch(ownerId, projectName, branchName) {
266
+ async function getBranch(ownerId, name, branchName) {
259
267
  try {
260
- const url = buildUrl(API_ENDPOINTS.BRANCHES_GET, { owner_id: ownerId, project_name: projectName, branch_name: branchName });
268
+ const url = buildUrl(API_ENDPOINTS.BRANCHES_GET, { owner_id: ownerId, name: name, branch_name: branchName });
261
269
  const response = await apiClient.get(url);
262
270
  return response;
263
271
  } catch (error) {
@@ -27,26 +27,26 @@ module.exports = {
27
27
  // Repository endpoints
28
28
  REPOS_LIST: '/api/repos/',
29
29
  REPOS_CREATE: '/api/repos/create/',
30
- REPOS_GET: '/api/repos/{owner_id}/{project_name}/',
31
- REPOS_DELETE: '/api/repos/{owner_id}/{project_name}/delete/',
30
+ REPOS_GET: '/api/repos/{owner_id}/{name}/',
31
+ REPOS_DELETE: '/api/repos/{owner_id}/{name}/delete/',
32
32
 
33
33
  // Blob endpoints
34
- BLOB_GET: '/api/repos/{owner_id}/{project_name}/blob/{sha}/',
35
- BLOB_CREATE: '/api/repos/{owner_id}/{project_name}/blob/create/',
34
+ BLOB_GET: '/api/repos/{owner_id}/{name}/blob/{sha}/',
35
+ BLOB_CREATE: '/api/repos/{owner_id}/{name}/blob/create/',
36
36
 
37
37
  // Tree endpoints
38
- TREE_GET: '/api/repos/{owner_id}/{project_name}/tree/{sha}/',
39
- TREE_CREATE: '/api/repos/{owner_id}/{project_name}/tree/create/',
38
+ TREE_GET: '/api/repos/{owner_id}/{name}/tree/{sha}/',
39
+ TREE_CREATE: '/api/repos/{owner_id}/{name}/tree/create/',
40
40
 
41
41
  // Commit endpoints
42
- COMMITS_LIST: '/api/repos/{owner_id}/{project_name}/commits/',
43
- COMMITS_GET: '/api/repos/{owner_id}/{project_name}/commits/{sha}/',
44
- COMMITS_CREATE: '/api/repos/{owner_id}/{project_name}/commits/create/',
42
+ COMMITS_LIST: '/api/repos/{owner_id}/{name}/commits/',
43
+ COMMITS_GET: '/api/repos/{owner_id}/{name}/commits/{sha}/',
44
+ COMMITS_CREATE: '/api/repos/{owner_id}/{name}/commits/create/',
45
45
 
46
46
  // Branch endpoints
47
- BRANCHES_LIST: '/api/repos/{owner_id}/{project_name}/branches/',
48
- BRANCHES_GET: '/api/repos/{owner_id}/{project_name}/branches/{branch_name}/',
49
- BRANCHES_CREATE: '/api/repos/{owner_id}/{project_name}/branches/create/'
47
+ BRANCHES_LIST: '/api/repos/{owner_id}/{name}/branches/',
48
+ BRANCHES_GET: '/api/repos/{owner_id}/{name}/branches/{branch_name}/',
49
+ BRANCHES_CREATE: '/api/repos/{owner_id}/{name}/branches/create/'
50
50
  },
51
51
 
52
52
  // Default ignore patterns
@@ -113,23 +113,31 @@ async function getAllFiles(dir, ignorePatterns = []) {
113
113
  */
114
114
  function shouldIgnore(filePath, patterns) {
115
115
  const normalizedPath = filePath.replace(/\\/g, '/');
116
+ const segments = normalizedPath.split('/');
116
117
 
117
118
  for (const pattern of patterns) {
118
- // Exact match
119
- if (normalizedPath === pattern || normalizedPath.startsWith(pattern + '/')) {
119
+ const normalizedPattern = pattern.replace(/\/$/, '');
120
+
121
+ // Check if any segment matches the pattern (for directory-level ignores like node_modules)
122
+ if (segments.some(segment => segment === normalizedPattern)) {
123
+ return true;
124
+ }
125
+
126
+ // Exact match or starts with pattern
127
+ if (normalizedPath === normalizedPattern || normalizedPath.startsWith(normalizedPattern + '/')) {
120
128
  return true;
121
129
  }
122
130
 
123
131
  // Wildcard match
124
- if (pattern.includes('*')) {
125
- const regex = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$');
132
+ if (normalizedPattern.includes('*')) {
133
+ const regex = new RegExp('^' + normalizedPattern.replace(/\*/g, '.*') + '$');
126
134
  if (regex.test(normalizedPath)) {
127
135
  return true;
128
136
  }
129
137
  }
130
138
 
131
139
  // Extension match
132
- if (pattern.startsWith('*.') && normalizedPath.endsWith(pattern.substring(1))) {
140
+ if (normalizedPattern.startsWith('*.') && normalizedPath.endsWith(normalizedPattern.substring(1))) {
133
141
  return true;
134
142
  }
135
143
  }