resulgit 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/resulgit.js +39 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resulgit",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A powerful CLI tool for version control system operations - clone, commit, push, pull, merge, branch management, and more",
5
5
  "main": "resulgit.js",
6
6
  "bin": {
package/resulgit.js CHANGED
@@ -35,7 +35,7 @@ function loadConfig() {
35
35
  const s = fs.readFileSync(file, 'utf8')
36
36
  return JSON.parse(s)
37
37
  } catch {
38
- return { server: 'https://delightful-dango-ee4842.netlify.app', token: '', workspaceRoot: path.join(os.homedir(), 'resulgit-workspace') }
38
+ return { server: 'http://10.205.11.8:7513', token: '', workspaceRoot: path.join(os.homedir(), 'resulgit-workspace') }
39
39
  }
40
40
  }
41
41
 
@@ -49,7 +49,7 @@ function saveConfig(update) {
49
49
  }
50
50
 
51
51
  function getServer(opts, cfg) {
52
- return opts.server || cfg.server || 'https://delightful-dango-ee4842.netlify.app'
52
+ return opts.server || cfg.server || 'http://10.205.11.8:7513'
53
53
  }
54
54
 
55
55
  function getToken(opts, cfg) {
@@ -106,6 +106,7 @@ async function cmdAuth(sub, opts) {
106
106
  const password = opts.password
107
107
  if (!email || !password) throw new Error('Missing --email and --password')
108
108
  const url = new URL('/api/auth/login', server).toString()
109
+ print({ server, email, password,url }, opts.json === 'true')
109
110
  const res = await request('POST', url, { email, password }, '')
110
111
  const token = res.token || ''
111
112
  if (token) saveConfig({ token })
@@ -188,6 +189,34 @@ async function cmdRepo(sub, opts, cfg) {
188
189
  throw new Error('Unknown repo subcommand')
189
190
  }
190
191
 
192
+ function parseCloneUrl(urlStr) {
193
+ try {
194
+ const u = new URL(String(urlStr))
195
+ const parts = u.pathname.split('/').filter(Boolean)
196
+ const idx = parts.findIndex((p) => p === 'repositories')
197
+ const repo = idx >= 0 ? (parts[idx + 1] || '') : ''
198
+ const branch = u.searchParams.get('branch') || ''
199
+ const server = u.origin
200
+ return { server, repo, branch }
201
+ } catch {
202
+ return { server: '', repo: '', branch: '' }
203
+ }
204
+ }
205
+
206
+ async function cmdCloneFromUrl(opts, cfg) {
207
+ const parsed = parseCloneUrl(opts.url || '')
208
+ if (!parsed.repo) throw new Error('Invalid clone URL')
209
+ const server = parsed.server || getServer(opts, cfg)
210
+ const token = getToken(opts, cfg)
211
+ let branch = parsed.branch
212
+ if (!branch) {
213
+ const info = await request('GET', new URL(`/api/repositories/${parsed.repo}/branches`, server).toString(), null, token)
214
+ branch = info.defaultBranch || 'main'
215
+ }
216
+ const nextOpts = { repo: parsed.repo, branch, dest: opts.dest, server }
217
+ await cmdClone(nextOpts, cfg)
218
+ }
219
+
191
220
  async function cmdClone(opts, cfg) {
192
221
  const server = getServer(opts, cfg)
193
222
  const token = getToken(opts, cfg)
@@ -2013,7 +2042,7 @@ function help() {
2013
2042
  ' >>>>>>> incoming (incoming changes)',
2014
2043
  ' Resolve conflicts manually, then commit and push. Push is blocked until conflicts are resolved.',
2015
2044
  ' pr list|create|merge [--dir <path>] [--title <t>] [--id <id>] [--source <branch>] [--target <branch>]',
2016
- ' clone --repo <id> --branch <name> [--dest <dir>] [--server <url>] [--token <token>]',
2045
+ ' clone <url> [--dest <dir>] | --repo <id> --branch <name> [--dest <dir>] [--server <url>] [--token <token>]',
2017
2046
  ' workspace set-root --path <dir>',
2018
2047
  ' cherry-pick --commit <id> [--branch <name>] [--no-push] [--dir <path>]',
2019
2048
  ' checkout <branch>|--branch <name> | --commit <id> [--dir <path>]',
@@ -2042,7 +2071,13 @@ async function main() {
2042
2071
  return
2043
2072
  }
2044
2073
  if (cmd[0] === 'clone') {
2045
- await cmdClone(opts, cfg)
2074
+ print({ url: 'Rajaram' }, opts.json === 'true')
2075
+ if (!opts.url && cmd[1] && !cmd[1].startsWith('--')) opts.url = cmd[1]
2076
+ if (opts.url) {
2077
+ await cmdCloneFromUrl(opts, cfg)
2078
+ } else {
2079
+ await cmdClone(opts, cfg)
2080
+ }
2046
2081
  return
2047
2082
  }
2048
2083
  if (cmd[0] === 'status') {