abapgit-agent 1.8.8 → 1.8.9

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": "abapgit-agent",
3
- "version": "1.8.8",
3
+ "version": "1.8.9",
4
4
  "description": "ABAP Git Agent - Pull and activate ABAP code via abapGit from any git repository",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -77,7 +77,7 @@ module.exports = {
77
77
  await this.pull(gitUrl, branch, files, transportRequest, loadConfig, AbapHttp, jsonOutput);
78
78
  },
79
79
 
80
- async pull(gitUrl, branch = 'main', files = null, transportRequest = null, loadConfig, AbapHttp, jsonOutput = false) {
80
+ async pull(gitUrl, branch = 'main', files = null, transportRequest = null, loadConfig, AbapHttp, jsonOutput = false, gitCredentials = undefined) {
81
81
  const TERM_WIDTH = process.stdout.columns || 80;
82
82
 
83
83
  if (!jsonOutput) {
@@ -99,11 +99,15 @@ module.exports = {
99
99
  const csrfToken = await http.fetchCsrfToken();
100
100
 
101
101
  // Prepare request data with git credentials
102
+ // gitCredentials=null means no credentials (public repo); undefined means use config defaults
103
+ const resolvedCredentials = gitCredentials === undefined
104
+ ? { username: config.gitUsername, password: config.gitPassword }
105
+ : gitCredentials;
106
+
102
107
  const data = {
103
108
  url: gitUrl,
104
109
  branch: branch,
105
- username: config.gitUsername,
106
- password: config.gitPassword
110
+ ...(resolvedCredentials ? { username: resolvedCredentials.username, password: resolvedCredentials.password } : {})
107
111
  };
108
112
 
109
113
  // Add files array if specified
@@ -198,9 +202,9 @@ module.exports = {
198
202
  console.log(` Job ID: ${jobId || 'N/A'}`);
199
203
  console.log(` Message: ${message || 'N/A'}`);
200
204
  } else {
201
- console.log(`❌ Pull completed with errors!`);
202
- console.log(` Job ID: ${jobId || 'N/A'}`);
203
- console.log(` Message: ${message || 'N/A'}`);
205
+ console.error(`❌ Pull completed with errors!`);
206
+ console.error(` Job ID: ${jobId || 'N/A'}`);
207
+ console.error(` Message: ${message || 'N/A'}`);
204
208
  }
205
209
 
206
210
  // Display error detail if available
@@ -306,8 +310,18 @@ module.exports = {
306
310
  console.log(`\n❌ Failed Objects Log (${failedCount})`);
307
311
  }
308
312
 
313
+ // Throw if pull was not successful so callers (e.g. upgrade) can detect failure
314
+ if (success !== 'X' && success !== true) {
315
+ const err = new Error(message || 'Pull completed with errors');
316
+ err._isPullError = true;
317
+ throw err;
318
+ }
319
+
309
320
  return result;
310
321
  } catch (error) {
322
+ if (error._isPullError) {
323
+ throw error;
324
+ }
311
325
  console.error(`\n❌ Error: ${error.message}`);
312
326
  process.exit(1);
313
327
  }
@@ -46,10 +46,29 @@ module.exports = {
46
46
  const { apiVersion } = await versionCheck.checkCompatibility(config);
47
47
  abapVersion = apiVersion;
48
48
  } catch (e) {
49
- console.error(`⚠️ Could not fetch ABAP version: ${e.message}`);
49
+ console.error(`⚠️ Could not reach ABAP system: ${e.message}`);
50
50
  }
51
51
  }
52
52
 
53
+ // If ABAP is unreachable and we need to upgrade it, warn and ask whether to continue CLI-only
54
+ if (needsAbapConfig && abapVersion === null && !flags.cliOnly && !flags.abapOnly && !flags.match) {
55
+ console.error('');
56
+ console.error('⚠️ ABAP system is unreachable. Cannot upgrade ABAP backend.');
57
+ if (flags.yes) {
58
+ console.log(' --yes flag set: upgrading CLI only.');
59
+ flags.cliOnly = true;
60
+ } else {
61
+ const proceed = await this.confirmCliOnlyFallback();
62
+ if (!proceed) {
63
+ console.log('Upgrade cancelled.');
64
+ return;
65
+ }
66
+ flags.cliOnly = true;
67
+ }
68
+ console.log(' Run "abapgit-agent upgrade --abap-only" once the system is back.');
69
+ console.log('');
70
+ }
71
+
53
72
  // Get latest version from npm
54
73
  const latestVersion = await versionCheck.getLatestNpmVersion();
55
74
  if (!latestVersion && !flags.version && !flags.match) {
@@ -260,8 +279,8 @@ module.exports = {
260
279
  step++;
261
280
  }
262
281
  if (targets.abapTarget) {
263
- console.log(` ${step}. abapgit-agent pull --branch v${targets.abapTarget}`);
264
- console.log(' (via existing abapGit repository)');
282
+ console.log(` ${step}. abapgit-agent pull --url <agentRepoUrl> --branch v${targets.abapTarget}`);
283
+ console.log(' (agentRepoUrl from .abapGitAgent config or current git remote)');
265
284
  step++;
266
285
  }
267
286
  console.log(` ${step}. Verify versions match`);
@@ -379,7 +398,24 @@ module.exports = {
379
398
  },
380
399
 
381
400
  /**
382
- * Upgrade ABAP backend via pull command
401
+ * Confirm CLI-only fallback when ABAP system is unreachable
402
+ */
403
+ async confirmCliOnlyFallback() {
404
+ return new Promise((resolve) => {
405
+ const rl = readline.createInterface({
406
+ input: process.stdin,
407
+ output: process.stdout
408
+ });
409
+
410
+ rl.question(' Continue with CLI upgrade only? [Y/n] ', (answer) => {
411
+ rl.close();
412
+ const normalized = answer.trim().toLowerCase();
413
+ resolve(normalized === '' || normalized === 'y' || normalized === 'yes');
414
+ });
415
+ });
416
+ },
417
+
418
+ /**
383
419
  */
384
420
  async upgradeAbapBackend(version, transport, context) {
385
421
  console.log(`📦 Upgrading ABAP backend to v${version}...`);
@@ -387,15 +423,20 @@ module.exports = {
387
423
  console.log('');
388
424
 
389
425
  try {
390
- // Build pull command args
391
- const pullArgs = ['--branch', `v${version}`];
392
- if (transport) {
393
- pullArgs.push('--transport', transport);
394
- }
426
+ const { loadConfig } = context;
427
+
428
+ // Determine the abapgit-agent repository URL.
429
+ // Priority:
430
+ // 1. agentRepoUrl from .abapGitAgent config (for forks/mirrors)
431
+ // 2. Default canonical repository
432
+ const config = loadConfig();
433
+ const agentRepoUrl = config.agentRepoUrl || 'https://github.com/SylvosCai/abapgit-agent.git';
395
434
 
396
- // Execute pull command
435
+ // Execute pull command — pass null credentials so the canonical
436
+ // public GitHub repo is not sent the project's SAP internal git credentials.
397
437
  const pullCommand = require('./pull');
398
- await pullCommand.execute(pullArgs, context);
438
+ const { loadConfig: lc, AbapHttp } = context;
439
+ await pullCommand.pull(agentRepoUrl, `v${version}`, null, transport || null, lc, AbapHttp, false, null);
399
440
 
400
441
  console.log('');
401
442
  console.log(`✅ ABAP backend upgraded to v${version}`);
@@ -404,9 +445,13 @@ module.exports = {
404
445
  console.error(`❌ Failed to upgrade ABAP backend: ${error.message}`);
405
446
  console.error('');
406
447
  console.error('This may be due to:');
448
+ console.error(' - ABAP system is unavailable');
407
449
  console.error(' - Git tag not found in repository');
408
450
  console.error(' - ABAP activation errors');
409
451
  console.error(' - Connection issues with ABAP system');
452
+ console.error('');
453
+ console.error('To retry once the system is available:');
454
+ console.error(` abapgit-agent upgrade --abap-only --version ${version}`);
410
455
  process.exit(1);
411
456
  }
412
457
  },
@@ -75,9 +75,9 @@ async function checkCompatibility(config) {
75
75
  const apiVersion = result.version || '1.0.0';
76
76
 
77
77
  if (cliVersion !== apiVersion) {
78
- console.log(`\n⚠️ Version mismatch: CLI ${cliVersion}, ABAP API ${apiVersion}`);
79
- console.log(' Some commands may not work correctly.');
80
- console.log(' Update ABAP code: abapgit-agent pull\n');
78
+ console.error(`\n⚠️ Version mismatch: CLI ${cliVersion}, ABAP API ${apiVersion}`);
79
+ console.error(' Some commands may not work correctly.');
80
+ console.error(' Update ABAP code: abapgit-agent upgrade --match\n');
81
81
  }
82
82
  resolve({ cliVersion, apiVersion, compatible: cliVersion === apiVersion });
83
83
  } catch (e) {
@@ -242,9 +242,9 @@ async function showNewVersionReminder() {
242
242
  const { hasNewVersion, latestVersion, currentVersion } = await checkForNewVersion();
243
243
 
244
244
  if (hasNewVersion) {
245
- console.log('');
246
- console.log(`💡 New version available: ${latestVersion} (current: ${currentVersion})`);
247
- console.log(` Run: abapgit-agent upgrade`);
245
+ console.error('');
246
+ console.error(`💡 New version available: ${latestVersion} (current: ${currentVersion})`);
247
+ console.error(` Run: abapgit-agent upgrade`);
248
248
  }
249
249
  } catch (e) {
250
250
  // Silent - don't interrupt user's workflow