hyouji 0.0.7 → 0.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/dist/index.js +101 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -64,8 +64,9 @@ const actionSelector = {
|
|
|
64
64
|
{ title: "delete a label", value: 2 },
|
|
65
65
|
{ title: "delete all labels", value: 3 },
|
|
66
66
|
{ title: "import JSON", value: 4 },
|
|
67
|
-
{ title: "
|
|
68
|
-
{ title: "
|
|
67
|
+
{ title: "Generate sample JSON", value: 5 },
|
|
68
|
+
{ title: "Display your settings", value: 6 },
|
|
69
|
+
{ title: "exit", value: 7 }
|
|
69
70
|
]
|
|
70
71
|
};
|
|
71
72
|
const holdToken = {
|
|
@@ -74,6 +75,23 @@ const holdToken = {
|
|
|
74
75
|
message: "Do you have a personal token?",
|
|
75
76
|
initial: true
|
|
76
77
|
};
|
|
78
|
+
const sampleData = [
|
|
79
|
+
{
|
|
80
|
+
name: "Type: Bug Fix",
|
|
81
|
+
color: "FF8A65",
|
|
82
|
+
description: "Fix features that are not working"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "Type: Enhancement",
|
|
86
|
+
color: "64B5F7",
|
|
87
|
+
description: "Add new features"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "Type: Improvement",
|
|
91
|
+
color: "4DB6AC",
|
|
92
|
+
description: "Improve existing functionality"
|
|
93
|
+
}
|
|
94
|
+
];
|
|
77
95
|
const labels = (
|
|
78
96
|
// the following labels are based on this post
|
|
79
97
|
// https://qiita.com/willow-micro/items/51eeb3efe5b4192a4abd
|
|
@@ -247,7 +265,7 @@ Thank you!
|
|
|
247
265
|
};
|
|
248
266
|
const extraGuideText = `If you don't see action selector, please hit space key.`;
|
|
249
267
|
const linkToPersonalToken = "https://github.com/settings/tokens";
|
|
250
|
-
const log$
|
|
268
|
+
const log$3 = console.log;
|
|
251
269
|
const createLabel = async (configs2, label) => {
|
|
252
270
|
const resp = await configs2.octokit.request(
|
|
253
271
|
"POST /repos/{owner}/{repo}/labels",
|
|
@@ -262,16 +280,16 @@ const createLabel = async (configs2, label) => {
|
|
|
262
280
|
const status = resp.status;
|
|
263
281
|
switch (status) {
|
|
264
282
|
case 201:
|
|
265
|
-
log$
|
|
283
|
+
log$3(chalk.green(`${resp.status}: Created ${label.name}`));
|
|
266
284
|
break;
|
|
267
285
|
case 404:
|
|
268
|
-
log$
|
|
286
|
+
log$3(chalk.red(`${resp.status}: Resource not found`));
|
|
269
287
|
break;
|
|
270
288
|
case 422:
|
|
271
|
-
log$
|
|
289
|
+
log$3(chalk.red(`${resp.status}: Validation failed`));
|
|
272
290
|
break;
|
|
273
291
|
default:
|
|
274
|
-
log$
|
|
292
|
+
log$3(chalk.yellow(`${resp.status}: Something wrong`));
|
|
275
293
|
break;
|
|
276
294
|
}
|
|
277
295
|
};
|
|
@@ -279,8 +297,8 @@ const createLabels = async (configs2) => {
|
|
|
279
297
|
labels.forEach(async (label) => {
|
|
280
298
|
createLabel(configs2, label);
|
|
281
299
|
});
|
|
282
|
-
log$
|
|
283
|
-
log$
|
|
300
|
+
log$3("Created all labels");
|
|
301
|
+
log$3(chalk.bgBlueBright(extraGuideText));
|
|
284
302
|
};
|
|
285
303
|
const deleteLabel = async (configs2, labelNames) => {
|
|
286
304
|
for (const labelName of labelNames) {
|
|
@@ -294,15 +312,15 @@ const deleteLabel = async (configs2, labelNames) => {
|
|
|
294
312
|
}
|
|
295
313
|
);
|
|
296
314
|
if (resp.status === 204) {
|
|
297
|
-
log$
|
|
315
|
+
log$3(chalk.green(`${resp.status}: Deleted ${labelName}`));
|
|
298
316
|
} else {
|
|
299
|
-
log$
|
|
317
|
+
log$3(chalk.yellow(`${resp.status}: Something wrong with ${labelName}`));
|
|
300
318
|
}
|
|
301
319
|
} catch (error) {
|
|
302
320
|
if (error && typeof error === "object" && "status" in error && error.status === 404) {
|
|
303
|
-
log$
|
|
321
|
+
log$3(chalk.red(`404: Label "${labelName}" not found`));
|
|
304
322
|
} else {
|
|
305
|
-
log$
|
|
323
|
+
log$3(
|
|
306
324
|
chalk.red(
|
|
307
325
|
`Error deleting label "${labelName}": ${error instanceof Error ? error.message : "Unknown error"}`
|
|
308
326
|
)
|
|
@@ -323,17 +341,17 @@ const getLabels = async (configs2) => {
|
|
|
323
341
|
const names = await resp.data.map((label) => label.name);
|
|
324
342
|
return names;
|
|
325
343
|
} else {
|
|
326
|
-
log$
|
|
344
|
+
log$3(chalk.red("something wrong"));
|
|
327
345
|
return [];
|
|
328
346
|
}
|
|
329
347
|
};
|
|
330
348
|
const deleteLabels = async (configs2) => {
|
|
331
349
|
const names = await getLabels(configs2);
|
|
332
350
|
if (names.length === 0) {
|
|
333
|
-
log$
|
|
351
|
+
log$3(chalk.yellow("No labels found to delete"));
|
|
334
352
|
return;
|
|
335
353
|
}
|
|
336
|
-
log$
|
|
354
|
+
log$3(chalk.blue(`Deleting ${names.length} labels...`));
|
|
337
355
|
for (const name of names) {
|
|
338
356
|
try {
|
|
339
357
|
const resp = await configs2.octokit.request(
|
|
@@ -345,15 +363,15 @@ const deleteLabels = async (configs2) => {
|
|
|
345
363
|
}
|
|
346
364
|
);
|
|
347
365
|
if (resp.status === 204) {
|
|
348
|
-
log$
|
|
366
|
+
log$3(chalk.green(`${resp.status}: Deleted ${name}`));
|
|
349
367
|
} else {
|
|
350
|
-
log$
|
|
368
|
+
log$3(chalk.yellow(`${resp.status}: Something wrong with ${name}`));
|
|
351
369
|
}
|
|
352
370
|
} catch (error) {
|
|
353
371
|
if (error && typeof error === "object" && "status" in error && error.status === 404) {
|
|
354
|
-
log$
|
|
372
|
+
log$3(chalk.red(`404: Label "${name}" not found`));
|
|
355
373
|
} else {
|
|
356
|
-
log$
|
|
374
|
+
log$3(
|
|
357
375
|
chalk.red(
|
|
358
376
|
`Error deleting label "${name}": ${error instanceof Error ? error.message : "Unknown error"}`
|
|
359
377
|
)
|
|
@@ -361,8 +379,8 @@ const deleteLabels = async (configs2) => {
|
|
|
361
379
|
}
|
|
362
380
|
}
|
|
363
381
|
}
|
|
364
|
-
log$
|
|
365
|
-
log$
|
|
382
|
+
log$3(chalk.blue("Finished deleting labels"));
|
|
383
|
+
log$3(chalk.bgBlueBright(extraGuideText));
|
|
366
384
|
};
|
|
367
385
|
const _CryptoUtils = class _CryptoUtils {
|
|
368
386
|
/**
|
|
@@ -956,6 +974,53 @@ const getConfirmation = async () => {
|
|
|
956
974
|
const response = await prompts(holdToken);
|
|
957
975
|
return response.value;
|
|
958
976
|
};
|
|
977
|
+
const log$2 = console.log;
|
|
978
|
+
const generateSampleJson = async () => {
|
|
979
|
+
try {
|
|
980
|
+
const outputPath = "./hyouji.json";
|
|
981
|
+
const jsonContent = JSON.stringify(sampleData, null, 2);
|
|
982
|
+
log$2(chalk.blue("Generating sample JSON file..."));
|
|
983
|
+
fs.writeFileSync(outputPath, jsonContent, "utf8");
|
|
984
|
+
log$2(
|
|
985
|
+
chalk.green(
|
|
986
|
+
"✅ Sample JSON file generated successfully at ./hyouji.json"
|
|
987
|
+
)
|
|
988
|
+
);
|
|
989
|
+
} catch (error) {
|
|
990
|
+
if (error instanceof Error) {
|
|
991
|
+
const nodeError = error;
|
|
992
|
+
if (nodeError.code === "EACCES") {
|
|
993
|
+
log$2(
|
|
994
|
+
chalk.red(
|
|
995
|
+
"❌ Error generating sample JSON file: Permission denied. Please check write permissions for the current directory."
|
|
996
|
+
)
|
|
997
|
+
);
|
|
998
|
+
} else if (nodeError.code === "ENOSPC") {
|
|
999
|
+
log$2(
|
|
1000
|
+
chalk.red(
|
|
1001
|
+
"❌ Error generating sample JSON file: Insufficient disk space."
|
|
1002
|
+
)
|
|
1003
|
+
);
|
|
1004
|
+
} else if (nodeError.code === "EROFS") {
|
|
1005
|
+
log$2(
|
|
1006
|
+
chalk.red(
|
|
1007
|
+
"❌ Error generating sample JSON file: Read-only file system."
|
|
1008
|
+
)
|
|
1009
|
+
);
|
|
1010
|
+
} else {
|
|
1011
|
+
log$2(
|
|
1012
|
+
chalk.red(`❌ Error generating sample JSON file: ${error.message}`)
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
} else {
|
|
1016
|
+
log$2(
|
|
1017
|
+
chalk.red(
|
|
1018
|
+
"❌ An unexpected error occurred while generating the sample JSON file"
|
|
1019
|
+
)
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
959
1024
|
const log$1 = console.log;
|
|
960
1025
|
const importLabelsFromJson = async (configs2, filePath) => {
|
|
961
1026
|
try {
|
|
@@ -1617,11 +1682,24 @@ const main = async () => {
|
|
|
1617
1682
|
break;
|
|
1618
1683
|
}
|
|
1619
1684
|
case 5: {
|
|
1620
|
-
|
|
1685
|
+
try {
|
|
1686
|
+
await generateSampleJson();
|
|
1687
|
+
} catch (error) {
|
|
1688
|
+
log(
|
|
1689
|
+
chalk.red(
|
|
1690
|
+
`Error generating sample JSON: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1691
|
+
)
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1621
1694
|
firstStart = firstStart && false;
|
|
1622
1695
|
break;
|
|
1623
1696
|
}
|
|
1624
1697
|
case 6: {
|
|
1698
|
+
await displaySettings();
|
|
1699
|
+
firstStart = firstStart && false;
|
|
1700
|
+
break;
|
|
1701
|
+
}
|
|
1702
|
+
case 7: {
|
|
1625
1703
|
console.log("exit");
|
|
1626
1704
|
process.exit(0);
|
|
1627
1705
|
}
|