hale-commenting-system 3.1.1 → 3.3.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 +1 -1
- package/scripts/integrate.js +179 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hale-commenting-system",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "A commenting system for PatternFly React applications that allows designers and developers to add comments directly on design pages, sync with GitHub Issues, and link Jira tickets.",
|
|
5
5
|
"homepage": "https://www.npmjs.com/package/hale-commenting-system",
|
|
6
6
|
"license": "MIT",
|
package/scripts/integrate.js
CHANGED
|
@@ -1363,31 +1363,188 @@ async function main() {
|
|
|
1363
1363
|
console.log('\nWhere do you want to store comments as GitHub Issues?');
|
|
1364
1364
|
console.log('This should be a repository you have write access to.\n');
|
|
1365
1365
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1366
|
+
let targetOwner, targetRepo;
|
|
1367
|
+
|
|
1368
|
+
// Try to use gh CLI if available
|
|
1369
|
+
let ghAvailable = false;
|
|
1370
|
+
try {
|
|
1371
|
+
execSync('gh auth status', {
|
|
1372
|
+
stdio: 'ignore',
|
|
1373
|
+
timeout: 2000
|
|
1374
|
+
});
|
|
1375
|
+
ghAvailable = true;
|
|
1376
|
+
} catch {
|
|
1377
|
+
// gh CLI not available or not authenticated, will use manual entry
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
if (ghAvailable) {
|
|
1381
|
+
let ghLoopComplete = false;
|
|
1382
|
+
|
|
1383
|
+
while (!ghLoopComplete) {
|
|
1384
|
+
const useGh = await prompt([
|
|
1385
|
+
{
|
|
1386
|
+
type: 'confirm',
|
|
1387
|
+
name: 'use',
|
|
1388
|
+
message: 'GitHub CLI (gh) detected. Would you like to select from your repositories?',
|
|
1389
|
+
default: true
|
|
1390
|
+
}
|
|
1391
|
+
]);
|
|
1392
|
+
|
|
1393
|
+
if (useGh.use) {
|
|
1394
|
+
try {
|
|
1395
|
+
console.log(' Fetching your repositories...');
|
|
1396
|
+
const reposJson = execSync('gh repo list --json name,owner --limit 100', {
|
|
1397
|
+
encoding: 'utf-8',
|
|
1398
|
+
timeout: 10000,
|
|
1399
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
1400
|
+
});
|
|
1401
|
+
|
|
1402
|
+
const repos = JSON.parse(reposJson);
|
|
1403
|
+
|
|
1404
|
+
if (repos && repos.length > 0) {
|
|
1405
|
+
const repoChoices = repos.map(r => ({
|
|
1406
|
+
name: `${r.owner.login}/${r.name}`,
|
|
1407
|
+
value: { owner: r.owner.login, repo: r.name, action: 'select' }
|
|
1408
|
+
}));
|
|
1409
|
+
|
|
1410
|
+
// Add option to create new repo
|
|
1411
|
+
repoChoices.push({
|
|
1412
|
+
name: '→ Create a new repository',
|
|
1413
|
+
value: { action: 'create' }
|
|
1414
|
+
});
|
|
1415
|
+
|
|
1416
|
+
// Add option to enter manually
|
|
1417
|
+
repoChoices.push({
|
|
1418
|
+
name: '→ Enter repository manually',
|
|
1419
|
+
value: { action: 'manual' }
|
|
1420
|
+
});
|
|
1421
|
+
|
|
1422
|
+
// Add option to go back
|
|
1423
|
+
repoChoices.push({
|
|
1424
|
+
name: '← Go back',
|
|
1425
|
+
value: { action: 'back' }
|
|
1426
|
+
});
|
|
1427
|
+
|
|
1428
|
+
const selected = await prompt([
|
|
1429
|
+
{
|
|
1430
|
+
type: 'list',
|
|
1431
|
+
name: 'repo',
|
|
1432
|
+
message: 'Select a repository:',
|
|
1433
|
+
choices: repoChoices
|
|
1434
|
+
}
|
|
1435
|
+
]);
|
|
1436
|
+
|
|
1437
|
+
if (selected.repo.action === 'select') {
|
|
1438
|
+
targetOwner = selected.repo.owner;
|
|
1439
|
+
targetRepo = selected.repo.repo;
|
|
1440
|
+
console.log(` ✓ Selected: ${targetOwner}/${targetRepo}\n`);
|
|
1441
|
+
ghLoopComplete = true;
|
|
1442
|
+
} else if (selected.repo.action === 'create') {
|
|
1443
|
+
// Create new repository
|
|
1444
|
+
console.log('\n📦 Creating a new GitHub repository...\n');
|
|
1445
|
+
|
|
1446
|
+
const newRepoDetails = await prompt([
|
|
1447
|
+
{
|
|
1448
|
+
type: 'input',
|
|
1449
|
+
name: 'name',
|
|
1450
|
+
message: 'Repository name:',
|
|
1451
|
+
validate: (input) => {
|
|
1452
|
+
if (!input.trim()) return 'Repository name is required';
|
|
1453
|
+
if (!/^[a-zA-Z0-9_.-]+$/.test(input)) return 'Invalid repository name (use letters, numbers, dashes, underscores, or periods)';
|
|
1454
|
+
return true;
|
|
1455
|
+
}
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
type: 'list',
|
|
1459
|
+
name: 'visibility',
|
|
1460
|
+
message: 'Repository visibility:',
|
|
1461
|
+
choices: [
|
|
1462
|
+
{ name: 'Public', value: 'public' },
|
|
1463
|
+
{ name: 'Private', value: 'private' }
|
|
1464
|
+
],
|
|
1465
|
+
default: 'private'
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
type: 'input',
|
|
1469
|
+
name: 'description',
|
|
1470
|
+
message: 'Repository description (optional):',
|
|
1471
|
+
default: 'Comments and issues for design collaboration'
|
|
1472
|
+
}
|
|
1473
|
+
]);
|
|
1474
|
+
|
|
1475
|
+
try {
|
|
1476
|
+
console.log(` Creating repository: ${newRepoDetails.name}...`);
|
|
1477
|
+
const createCmd = `gh repo create ${newRepoDetails.name} --${newRepoDetails.visibility}${newRepoDetails.description ? ` --description "${newRepoDetails.description}"` : ''}`;
|
|
1478
|
+
const createResult = execSync(createCmd, {
|
|
1479
|
+
encoding: 'utf-8',
|
|
1480
|
+
stdio: ['ignore', 'pipe', 'pipe']
|
|
1481
|
+
});
|
|
1482
|
+
|
|
1483
|
+
// Get the authenticated user to determine owner
|
|
1484
|
+
const userJson = execSync('gh api user --jq ".login"', {
|
|
1485
|
+
encoding: 'utf-8',
|
|
1486
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
1487
|
+
}).trim();
|
|
1488
|
+
|
|
1489
|
+
targetOwner = userJson;
|
|
1490
|
+
targetRepo = newRepoDetails.name;
|
|
1491
|
+
console.log(` ✅ Repository created: ${targetOwner}/${targetRepo}\n`);
|
|
1492
|
+
ghLoopComplete = true;
|
|
1493
|
+
} catch (error) {
|
|
1494
|
+
console.error(` ❌ Failed to create repository: ${error.message}`);
|
|
1495
|
+
console.log(' Please create the repository manually and run the setup again.\n');
|
|
1496
|
+
rl.close();
|
|
1497
|
+
process.exit(1);
|
|
1498
|
+
}
|
|
1499
|
+
} else if (selected.repo.action === 'back') {
|
|
1500
|
+
// Go back to previous question - loop will restart
|
|
1501
|
+
console.log('');
|
|
1502
|
+
continue;
|
|
1503
|
+
} else if (selected.repo.action === 'manual') {
|
|
1504
|
+
// Exit loop to use manual entry
|
|
1505
|
+
ghLoopComplete = true;
|
|
1506
|
+
}
|
|
1507
|
+
} else {
|
|
1508
|
+
console.log(' No repositories found. Using manual entry.\n');
|
|
1509
|
+
ghLoopComplete = true;
|
|
1510
|
+
}
|
|
1511
|
+
} catch (error) {
|
|
1512
|
+
console.log(' ⚠️ Error fetching repositories. Using manual entry.\n');
|
|
1513
|
+
ghLoopComplete = true;
|
|
1514
|
+
}
|
|
1515
|
+
} else {
|
|
1516
|
+
// User chose not to use gh CLI
|
|
1517
|
+
ghLoopComplete = true;
|
|
1385
1518
|
}
|
|
1386
1519
|
}
|
|
1387
|
-
|
|
1520
|
+
}
|
|
1388
1521
|
|
|
1389
|
-
|
|
1390
|
-
|
|
1522
|
+
// Manual entry if gh CLI not used or failed
|
|
1523
|
+
if (!targetOwner || !targetRepo) {
|
|
1524
|
+
const repoAnswers = await prompt([
|
|
1525
|
+
{
|
|
1526
|
+
type: 'input',
|
|
1527
|
+
name: 'owner',
|
|
1528
|
+
message: 'GitHub repository owner (username or organization):',
|
|
1529
|
+
validate: (input) => {
|
|
1530
|
+
if (!input.trim()) return 'Owner is required';
|
|
1531
|
+
return true;
|
|
1532
|
+
}
|
|
1533
|
+
},
|
|
1534
|
+
{
|
|
1535
|
+
type: 'input',
|
|
1536
|
+
name: 'repo',
|
|
1537
|
+
message: 'GitHub repository name:',
|
|
1538
|
+
validate: (input) => {
|
|
1539
|
+
if (!input.trim()) return 'Repository name is required';
|
|
1540
|
+
return true;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
]);
|
|
1544
|
+
|
|
1545
|
+
targetOwner = repoAnswers.owner;
|
|
1546
|
+
targetRepo = repoAnswers.repo;
|
|
1547
|
+
}
|
|
1391
1548
|
|
|
1392
1549
|
// Validate GitHub credentials
|
|
1393
1550
|
console.log('\n🔍 Validating GitHub credentials...');
|