resulgit 1.0.7 → 1.0.8
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 +1 -1
- package/resulgit.js +32 -11
package/package.json
CHANGED
package/resulgit.js
CHANGED
|
@@ -2332,8 +2332,13 @@ async function cmdInit(opts) {
|
|
|
2332
2332
|
const spinner = createSpinner(`Initializing repository${repo ? ` '${repo}'` : ''}...`, opts.json)
|
|
2333
2333
|
|
|
2334
2334
|
let repoId = repo
|
|
2335
|
-
|
|
2336
|
-
|
|
2335
|
+
let remoteCreated = false
|
|
2336
|
+
|
|
2337
|
+
// If a repo name is provided and we have server, try to create remote repo
|
|
2338
|
+
if (repo && server) {
|
|
2339
|
+
if (!token) {
|
|
2340
|
+
spinnerUpdate(spinner, 'No auth token set. Run "resulgit auth login" first for remote repo creation.')
|
|
2341
|
+
}
|
|
2337
2342
|
try {
|
|
2338
2343
|
spinnerUpdate(spinner, 'Creating remote repository...')
|
|
2339
2344
|
const createUrl = new URL('/api/repositories', server).toString()
|
|
@@ -2345,20 +2350,26 @@ async function cmdInit(opts) {
|
|
|
2345
2350
|
}, token)
|
|
2346
2351
|
// Use the ID returned by the server (could be numeric or string)
|
|
2347
2352
|
repoId = String(createRes.id || repo)
|
|
2348
|
-
|
|
2353
|
+
remoteCreated = true
|
|
2354
|
+
spinnerUpdate(spinner, `Remote repository '${repo}' created (ID: ${repoId})`)
|
|
2349
2355
|
} catch (err) {
|
|
2350
|
-
// If repo already exists, try to fetch its ID
|
|
2351
|
-
if (err.message && err.message.includes('409')) {
|
|
2356
|
+
// If repo already exists (409), try to fetch its ID
|
|
2357
|
+
if (err.message && (err.message.includes('409') || err.message.includes('already exists'))) {
|
|
2352
2358
|
spinnerUpdate(spinner, `Remote repository '${repo}' already exists, linking...`)
|
|
2353
2359
|
try {
|
|
2354
2360
|
const listUrl = new URL('/api/repositories', server).toString()
|
|
2355
2361
|
const repos = await request('GET', listUrl, null, token)
|
|
2356
2362
|
const found = (repos || []).find(r => r.name === repo)
|
|
2357
|
-
if (found)
|
|
2363
|
+
if (found) {
|
|
2364
|
+
repoId = String(found.id)
|
|
2365
|
+
remoteCreated = true
|
|
2366
|
+
}
|
|
2358
2367
|
} catch { /* ignore */ }
|
|
2368
|
+
} else if (err.message && err.message.includes('401')) {
|
|
2369
|
+
spinnerUpdate(spinner, 'Authentication required. Run "resulgit auth login" to set up credentials.')
|
|
2359
2370
|
} else {
|
|
2360
2371
|
// Other error - continue with local init only
|
|
2361
|
-
spinnerUpdate(spinner, `Could not create remote repo: ${err.message}
|
|
2372
|
+
spinnerUpdate(spinner, `Could not create remote repo: ${err.message}`)
|
|
2362
2373
|
}
|
|
2363
2374
|
}
|
|
2364
2375
|
}
|
|
@@ -2389,8 +2400,14 @@ async function cmdInit(opts) {
|
|
|
2389
2400
|
const localMeta = { baseCommitId: '', baseFiles: {}, pendingCommit: null }
|
|
2390
2401
|
await fs.promises.writeFile(path.join(metaDir, 'local.json'), JSON.stringify(localMeta, null, 2))
|
|
2391
2402
|
|
|
2392
|
-
|
|
2393
|
-
|
|
2403
|
+
if (remoteCreated) {
|
|
2404
|
+
spinnerSuccess(spinner, `Initialized repository '${repo}' in ${targetDir} (remote linked)`)
|
|
2405
|
+
} else if (repo) {
|
|
2406
|
+
spinnerSuccess(spinner, `Initialized local repository in ${targetDir} (remote not created - check auth)`)
|
|
2407
|
+
} else {
|
|
2408
|
+
spinnerSuccess(spinner, `Initialized repository in ${targetDir}`)
|
|
2409
|
+
}
|
|
2410
|
+
print({ initialized: targetDir, branch, repoId: repoId, remoteCreated }, opts.json === 'true')
|
|
2394
2411
|
}
|
|
2395
2412
|
|
|
2396
2413
|
async function cmdMv(opts) {
|
|
@@ -3229,8 +3246,12 @@ async function main() {
|
|
|
3229
3246
|
return
|
|
3230
3247
|
}
|
|
3231
3248
|
if (cmd[0] === 'init') {
|
|
3232
|
-
|
|
3233
|
-
|
|
3249
|
+
// Allow positional repo name: resulgit init MyRepo
|
|
3250
|
+
if (cmd[1] && !cmd[1].startsWith('-') && !opts.repo) {
|
|
3251
|
+
opts.repo = cmd[1];
|
|
3252
|
+
}
|
|
3253
|
+
await cmdInit(opts);
|
|
3254
|
+
return;
|
|
3234
3255
|
}
|
|
3235
3256
|
if (cmd[0] === 'remote') {
|
|
3236
3257
|
await cmdRemote(cmd[1], opts)
|