hyouji 0.0.11 → 0.0.13
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/dist/index.js +86 -57
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1278,9 +1278,15 @@ const getTargetLabel = async () => {
|
|
|
1278
1278
|
const response = await prompts(deleteLabel$1);
|
|
1279
1279
|
return [response.name];
|
|
1280
1280
|
};
|
|
1281
|
-
const execAsync = promisify(exec);
|
|
1282
1281
|
const GIT_COMMAND_TIMEOUT_MS = 5e3;
|
|
1283
|
-
class
|
|
1282
|
+
const _GitRepositoryDetector = class _GitRepositoryDetector {
|
|
1283
|
+
/**
|
|
1284
|
+
* Overrides the internal execAsync function for testing purposes.
|
|
1285
|
+
* @param mock - The mock function to use for execAsync.
|
|
1286
|
+
*/
|
|
1287
|
+
static overrideExecAsync(mock) {
|
|
1288
|
+
this.execAsyncInternal = mock;
|
|
1289
|
+
}
|
|
1284
1290
|
/**
|
|
1285
1291
|
* Detects Git repository information from the current working directory
|
|
1286
1292
|
* @param cwd - Current working directory (defaults to process.cwd())
|
|
@@ -1288,58 +1294,64 @@ class GitRepositoryDetector {
|
|
|
1288
1294
|
*/
|
|
1289
1295
|
static async detectRepository(cwd) {
|
|
1290
1296
|
const workingDir = cwd || process.cwd();
|
|
1297
|
+
let gitRoot;
|
|
1291
1298
|
try {
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
isGitRepository: false,
|
|
1296
|
-
error: "Not a Git repository"
|
|
1297
|
-
};
|
|
1298
|
-
}
|
|
1299
|
-
const remotes = await this.getAllRemotes(gitRoot);
|
|
1300
|
-
if (remotes.length === 0) {
|
|
1301
|
-
return {
|
|
1302
|
-
isGitRepository: true,
|
|
1303
|
-
error: "No remotes configured"
|
|
1304
|
-
};
|
|
1305
|
-
}
|
|
1306
|
-
let remoteUrl = null;
|
|
1307
|
-
let detectionMethod = "origin";
|
|
1308
|
-
if (remotes.includes("origin")) {
|
|
1309
|
-
remoteUrl = await this.getRemoteUrl(gitRoot, "origin");
|
|
1310
|
-
}
|
|
1311
|
-
if (!remoteUrl && remotes.length > 0) {
|
|
1312
|
-
remoteUrl = await this.getRemoteUrl(gitRoot, remotes[0]);
|
|
1313
|
-
detectionMethod = "first-remote";
|
|
1314
|
-
}
|
|
1315
|
-
if (!remoteUrl) {
|
|
1316
|
-
return {
|
|
1317
|
-
isGitRepository: true,
|
|
1318
|
-
error: "Could not retrieve remote URL"
|
|
1319
|
-
};
|
|
1320
|
-
}
|
|
1321
|
-
const parsedUrl = this.parseGitUrl(remoteUrl);
|
|
1322
|
-
if (!parsedUrl) {
|
|
1323
|
-
return {
|
|
1324
|
-
isGitRepository: true,
|
|
1325
|
-
error: "Could not parse remote URL"
|
|
1326
|
-
};
|
|
1327
|
-
}
|
|
1299
|
+
gitRoot = await this.findGitRoot(workingDir);
|
|
1300
|
+
} catch (err) {
|
|
1301
|
+
const error = err;
|
|
1328
1302
|
return {
|
|
1329
|
-
isGitRepository:
|
|
1330
|
-
|
|
1331
|
-
owner: parsedUrl.owner,
|
|
1332
|
-
repo: parsedUrl.repo,
|
|
1333
|
-
remoteUrl,
|
|
1334
|
-
detectionMethod
|
|
1335
|
-
}
|
|
1303
|
+
isGitRepository: false,
|
|
1304
|
+
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
1336
1305
|
};
|
|
1337
|
-
}
|
|
1306
|
+
}
|
|
1307
|
+
if (!gitRoot) {
|
|
1338
1308
|
return {
|
|
1339
1309
|
isGitRepository: false,
|
|
1340
|
-
error:
|
|
1310
|
+
error: "Not a Git repository"
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
const remotesResult = await this.getAllRemotes(gitRoot);
|
|
1314
|
+
if ("error" in remotesResult) {
|
|
1315
|
+
return { isGitRepository: false, error: remotesResult.error };
|
|
1316
|
+
}
|
|
1317
|
+
const remotes = remotesResult.remotes;
|
|
1318
|
+
if (remotes.length === 0) {
|
|
1319
|
+
return {
|
|
1320
|
+
isGitRepository: true,
|
|
1321
|
+
error: "No remotes configured"
|
|
1341
1322
|
};
|
|
1342
1323
|
}
|
|
1324
|
+
let remoteUrl = null;
|
|
1325
|
+
let detectionMethod = "origin";
|
|
1326
|
+
if (remotes.includes("origin")) {
|
|
1327
|
+
remoteUrl = await this.getRemoteUrl(gitRoot, "origin");
|
|
1328
|
+
}
|
|
1329
|
+
if (!remoteUrl && remotes.length > 0) {
|
|
1330
|
+
remoteUrl = await this.getRemoteUrl(gitRoot, remotes[0]);
|
|
1331
|
+
detectionMethod = "first-remote";
|
|
1332
|
+
}
|
|
1333
|
+
if (!remoteUrl) {
|
|
1334
|
+
return {
|
|
1335
|
+
isGitRepository: true,
|
|
1336
|
+
error: "Could not retrieve remote URL"
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
const parsedUrl = this.parseGitUrl(remoteUrl);
|
|
1340
|
+
if (!parsedUrl) {
|
|
1341
|
+
return {
|
|
1342
|
+
isGitRepository: true,
|
|
1343
|
+
error: "Could not parse remote URL"
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
return {
|
|
1347
|
+
isGitRepository: true,
|
|
1348
|
+
repositoryInfo: {
|
|
1349
|
+
owner: parsedUrl.owner,
|
|
1350
|
+
repo: parsedUrl.repo,
|
|
1351
|
+
remoteUrl,
|
|
1352
|
+
detectionMethod
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1343
1355
|
}
|
|
1344
1356
|
/**
|
|
1345
1357
|
* Finds the Git root directory by traversing up the directory tree
|
|
@@ -1355,6 +1367,9 @@ class GitRepositoryDetector {
|
|
|
1355
1367
|
}
|
|
1356
1368
|
currentPath = dirname(currentPath);
|
|
1357
1369
|
}
|
|
1370
|
+
if (existsSync(join(currentPath, ".git"))) {
|
|
1371
|
+
return currentPath;
|
|
1372
|
+
}
|
|
1358
1373
|
return null;
|
|
1359
1374
|
}
|
|
1360
1375
|
/**
|
|
@@ -1365,10 +1380,13 @@ class GitRepositoryDetector {
|
|
|
1365
1380
|
*/
|
|
1366
1381
|
static async getRemoteUrl(gitRoot, remoteName) {
|
|
1367
1382
|
try {
|
|
1368
|
-
const { stdout } = await
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1383
|
+
const { stdout } = await this.execAsyncInternal(
|
|
1384
|
+
`git remote get-url ${remoteName}`,
|
|
1385
|
+
{
|
|
1386
|
+
cwd: gitRoot,
|
|
1387
|
+
timeout: GIT_COMMAND_TIMEOUT_MS
|
|
1388
|
+
}
|
|
1389
|
+
);
|
|
1372
1390
|
return stdout.trim() || null;
|
|
1373
1391
|
} catch {
|
|
1374
1392
|
return null;
|
|
@@ -1435,20 +1453,31 @@ class GitRepositoryDetector {
|
|
|
1435
1453
|
/**
|
|
1436
1454
|
* Gets all configured Git remotes
|
|
1437
1455
|
* @param gitRoot - Git repository root directory
|
|
1438
|
-
* @returns Promise
|
|
1456
|
+
* @returns Promise with remotes array or error object
|
|
1439
1457
|
*/
|
|
1440
1458
|
static async getAllRemotes(gitRoot) {
|
|
1441
1459
|
try {
|
|
1442
|
-
const { stdout } = await
|
|
1460
|
+
const { stdout } = await this.execAsyncInternal("git remote", {
|
|
1443
1461
|
cwd: gitRoot,
|
|
1444
1462
|
timeout: GIT_COMMAND_TIMEOUT_MS
|
|
1445
1463
|
});
|
|
1446
|
-
return
|
|
1447
|
-
|
|
1448
|
-
|
|
1464
|
+
return {
|
|
1465
|
+
remotes: stdout.trim().split("\n").filter((remote) => remote.length > 0)
|
|
1466
|
+
};
|
|
1467
|
+
} catch (err) {
|
|
1468
|
+
const error = err;
|
|
1469
|
+
if (error.code === "ENOENT") {
|
|
1470
|
+
return { error: "Git command not available" };
|
|
1471
|
+
}
|
|
1472
|
+
if (error instanceof Error && (error.message.includes("not a git repository") || error.message.includes("Not a git repository"))) {
|
|
1473
|
+
return { error: "Not a Git repository" };
|
|
1474
|
+
}
|
|
1475
|
+
return { remotes: [] };
|
|
1449
1476
|
}
|
|
1450
1477
|
}
|
|
1451
|
-
}
|
|
1478
|
+
};
|
|
1479
|
+
_GitRepositoryDetector.execAsyncInternal = promisify(exec);
|
|
1480
|
+
let GitRepositoryDetector = _GitRepositoryDetector;
|
|
1452
1481
|
const getGitHubConfigs = async () => {
|
|
1453
1482
|
var _a, _b;
|
|
1454
1483
|
const configManager2 = new ConfigManager();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyouji",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Hyouji (表示) — A command-line tool for organizing and displaying GitHub labels with clarity and harmony.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "koji <baxin1919@gmail.com>",
|
|
@@ -56,22 +56,22 @@
|
|
|
56
56
|
"node": ">=10"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@octokit/core": "^7.0.
|
|
60
|
-
"chalk": "^5.
|
|
59
|
+
"@octokit/core": "^7.0.6",
|
|
60
|
+
"chalk": "^5.6.2",
|
|
61
61
|
"js-yaml": "^4.1.0",
|
|
62
|
-
"oh-my-logo": "^0.3.
|
|
62
|
+
"oh-my-logo": "^0.3.2",
|
|
63
63
|
"prompts": "^2.4.2"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@biomejs/biome": "2.
|
|
66
|
+
"@biomejs/biome": "2.3.4",
|
|
67
67
|
"@types/js-yaml": "^4.0.9",
|
|
68
|
-
"@types/node": "^24.0
|
|
69
|
-
"@vitest/coverage-v8": "^
|
|
70
|
-
"@vitest/ui": "^
|
|
68
|
+
"@types/node": "^24.10.0",
|
|
69
|
+
"@vitest/coverage-v8": "^4.0.8",
|
|
70
|
+
"@vitest/ui": "^4.0.8",
|
|
71
71
|
"standard-version": "^9.5.0",
|
|
72
|
-
"typescript": "^5.
|
|
73
|
-
"vite": "^7.
|
|
74
|
-
"vitest": "^
|
|
72
|
+
"typescript": "^5.9.3",
|
|
73
|
+
"vite": "^7.2.2",
|
|
74
|
+
"vitest": "^4.0.8"
|
|
75
75
|
},
|
|
76
76
|
"files": [
|
|
77
77
|
"dist/**/*",
|