chiefwiggum 1.3.18 → 1.3.20
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/cli.cjs +148 -25
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -794,8 +794,41 @@ async function setupTemplates() {
|
|
|
794
794
|
console.log(import_picocolors7.default.dim(" You can customize these templates to change how specs are generated."));
|
|
795
795
|
console.log();
|
|
796
796
|
}
|
|
797
|
+
function checkGitHubCLI() {
|
|
798
|
+
try {
|
|
799
|
+
(0, import_node_child_process6.execSync)("which gh", { stdio: ["pipe", "pipe", "pipe"] });
|
|
800
|
+
} catch {
|
|
801
|
+
return { ok: false, reason: "not_installed" };
|
|
802
|
+
}
|
|
803
|
+
try {
|
|
804
|
+
(0, import_node_child_process6.execSync)("gh auth status", { stdio: ["pipe", "pipe", "pipe"] });
|
|
805
|
+
} catch {
|
|
806
|
+
return { ok: false, reason: "not_authenticated" };
|
|
807
|
+
}
|
|
808
|
+
try {
|
|
809
|
+
const repo = (0, import_node_child_process6.execSync)("gh repo view --json nameWithOwner -q .nameWithOwner", {
|
|
810
|
+
encoding: "utf-8",
|
|
811
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
812
|
+
}).trim();
|
|
813
|
+
return { ok: true, repo };
|
|
814
|
+
} catch {
|
|
815
|
+
return { ok: false, reason: "not_github_repo" };
|
|
816
|
+
}
|
|
817
|
+
}
|
|
797
818
|
async function setupProjectConfig() {
|
|
819
|
+
const existingConfig = getConfig();
|
|
798
820
|
if ((0, import_node_fs3.existsSync)(CONFIG_FILE)) {
|
|
821
|
+
if (existingConfig.projectTracker === "github" && existingConfig.githubProject === void 0) {
|
|
822
|
+
const ghCheck = checkGitHubCLI();
|
|
823
|
+
if (ghCheck.ok) {
|
|
824
|
+
const projectName = await selectOrCreateProjectBoard(ghCheck.repo);
|
|
825
|
+
const config3 = { ...existingConfig, githubProject: projectName };
|
|
826
|
+
saveConfig(config3);
|
|
827
|
+
if (projectName) {
|
|
828
|
+
console.log(import_picocolors7.default.green(`\u2713 Project board saved: ${projectName}`));
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
799
832
|
return;
|
|
800
833
|
}
|
|
801
834
|
console.log();
|
|
@@ -807,12 +840,48 @@ async function setupProjectConfig() {
|
|
|
807
840
|
projectTracker: useGitHub ? "github" : "todo"
|
|
808
841
|
};
|
|
809
842
|
if (useGitHub) {
|
|
810
|
-
const
|
|
811
|
-
|
|
843
|
+
const ghCheck = checkGitHubCLI();
|
|
844
|
+
if (!ghCheck.ok) {
|
|
845
|
+
console.log();
|
|
846
|
+
if (ghCheck.reason === "not_installed") {
|
|
847
|
+
console.log(import_picocolors7.default.yellow("GitHub CLI (gh) is not installed."));
|
|
848
|
+
console.log();
|
|
849
|
+
console.log("To use GitHub Issues, install it first:");
|
|
850
|
+
console.log(import_picocolors7.default.cyan(" brew install gh # macOS"));
|
|
851
|
+
console.log(import_picocolors7.default.cyan(" sudo apt install gh # Ubuntu/Debian"));
|
|
852
|
+
console.log(import_picocolors7.default.dim(" https://cli.github.com for other platforms"));
|
|
853
|
+
} else if (ghCheck.reason === "not_authenticated") {
|
|
854
|
+
console.log(import_picocolors7.default.yellow("GitHub CLI is not authenticated."));
|
|
855
|
+
console.log();
|
|
856
|
+
console.log("Run this command to log in:");
|
|
857
|
+
console.log(import_picocolors7.default.cyan(" gh auth login"));
|
|
858
|
+
} else if (ghCheck.reason === "not_github_repo") {
|
|
859
|
+
console.log(import_picocolors7.default.yellow("This doesn't appear to be a GitHub repository."));
|
|
860
|
+
console.log();
|
|
861
|
+
console.log("Make sure you're in a git repo with a GitHub remote.");
|
|
862
|
+
}
|
|
863
|
+
console.log();
|
|
864
|
+
const fallback = await select2({
|
|
865
|
+
message: "What would you like to do?",
|
|
866
|
+
options: [
|
|
867
|
+
{ value: "todo", label: "Use TODO.md instead", hint: "Track tasks locally" },
|
|
868
|
+
{ value: "exit", label: "Exit and set up gh first", hint: "Then run chiefwiggum new again" }
|
|
869
|
+
]
|
|
870
|
+
});
|
|
871
|
+
if (fallback === "exit") {
|
|
872
|
+
console.log();
|
|
873
|
+
console.log(import_picocolors7.default.dim("Run 'chiefwiggum new' again after setting up gh."));
|
|
874
|
+
process.exit(0);
|
|
875
|
+
}
|
|
876
|
+
config2.projectTracker = "todo";
|
|
877
|
+
} else {
|
|
878
|
+
const projectName = await selectOrCreateProjectBoard(ghCheck.repo);
|
|
879
|
+
config2.githubProject = projectName;
|
|
880
|
+
}
|
|
812
881
|
}
|
|
813
882
|
saveConfig(config2);
|
|
814
883
|
console.log(import_picocolors7.default.green(`\u2713 Config saved to ${CONFIG_FILE}`));
|
|
815
|
-
if (
|
|
884
|
+
if (config2.projectTracker === "github") {
|
|
816
885
|
console.log(import_picocolors7.default.dim(" Tasks will be created as GitHub Issues."));
|
|
817
886
|
if (config2.githubProject) {
|
|
818
887
|
console.log(import_picocolors7.default.dim(` Issues will be added to board: ${config2.githubProject}`));
|
|
@@ -820,16 +889,18 @@ async function setupProjectConfig() {
|
|
|
820
889
|
}
|
|
821
890
|
console.log();
|
|
822
891
|
}
|
|
823
|
-
async function selectOrCreateProjectBoard() {
|
|
824
|
-
let repoName = "";
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
892
|
+
async function selectOrCreateProjectBoard(knownRepo) {
|
|
893
|
+
let repoName = knownRepo || "";
|
|
894
|
+
if (!repoName) {
|
|
895
|
+
try {
|
|
896
|
+
repoName = (0, import_node_child_process6.execSync)("gh repo view --json nameWithOwner -q .nameWithOwner", {
|
|
897
|
+
encoding: "utf-8",
|
|
898
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
899
|
+
}).trim();
|
|
900
|
+
} catch {
|
|
901
|
+
console.log(import_picocolors7.default.yellow("Could not detect GitHub repo. Skipping project board setup."));
|
|
902
|
+
return null;
|
|
903
|
+
}
|
|
833
904
|
}
|
|
834
905
|
let existingProjects = [];
|
|
835
906
|
try {
|
|
@@ -1176,6 +1247,27 @@ function saveConfig2(config2) {
|
|
|
1176
1247
|
(0, import_node_fs5.mkdirSync)(".chiefwiggum", { recursive: true });
|
|
1177
1248
|
(0, import_node_fs5.writeFileSync)(CONFIG_FILE2, JSON.stringify(config2, null, 2) + "\n");
|
|
1178
1249
|
}
|
|
1250
|
+
function checkGitHubCLI2() {
|
|
1251
|
+
try {
|
|
1252
|
+
(0, import_node_child_process7.execSync)("which gh", { stdio: ["pipe", "pipe", "pipe"] });
|
|
1253
|
+
} catch {
|
|
1254
|
+
return { ok: false, reason: "not_installed" };
|
|
1255
|
+
}
|
|
1256
|
+
try {
|
|
1257
|
+
(0, import_node_child_process7.execSync)("gh auth status", { stdio: ["pipe", "pipe", "pipe"] });
|
|
1258
|
+
} catch {
|
|
1259
|
+
return { ok: false, reason: "not_authenticated" };
|
|
1260
|
+
}
|
|
1261
|
+
try {
|
|
1262
|
+
const repo = (0, import_node_child_process7.execSync)("gh repo view --json nameWithOwner -q .nameWithOwner", {
|
|
1263
|
+
encoding: "utf-8",
|
|
1264
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
1265
|
+
}).trim();
|
|
1266
|
+
return { ok: true, repo };
|
|
1267
|
+
} catch {
|
|
1268
|
+
return { ok: false, reason: "not_github_repo" };
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1179
1271
|
async function cmdConfig() {
|
|
1180
1272
|
console.log(import_picocolors9.default.bold("Configuration"));
|
|
1181
1273
|
console.log();
|
|
@@ -1194,11 +1286,40 @@ async function cmdConfig() {
|
|
|
1194
1286
|
initialValue: config2.projectTracker
|
|
1195
1287
|
});
|
|
1196
1288
|
let changed = false;
|
|
1197
|
-
if (newTracker
|
|
1289
|
+
if (newTracker === "github" && config2.projectTracker !== "github") {
|
|
1290
|
+
const ghCheck = checkGitHubCLI2();
|
|
1291
|
+
if (!ghCheck.ok) {
|
|
1292
|
+
console.log();
|
|
1293
|
+
if (ghCheck.reason === "not_installed") {
|
|
1294
|
+
console.log(import_picocolors9.default.yellow("GitHub CLI (gh) is not installed."));
|
|
1295
|
+
console.log();
|
|
1296
|
+
console.log("To use GitHub Issues, install it first:");
|
|
1297
|
+
console.log(import_picocolors9.default.cyan(" brew install gh # macOS"));
|
|
1298
|
+
console.log(import_picocolors9.default.cyan(" sudo apt install gh # Ubuntu/Debian"));
|
|
1299
|
+
console.log(import_picocolors9.default.dim(" https://cli.github.com for other platforms"));
|
|
1300
|
+
} else if (ghCheck.reason === "not_authenticated") {
|
|
1301
|
+
console.log(import_picocolors9.default.yellow("GitHub CLI is not authenticated."));
|
|
1302
|
+
console.log();
|
|
1303
|
+
console.log("Run this command to log in:");
|
|
1304
|
+
console.log(import_picocolors9.default.cyan(" gh auth login"));
|
|
1305
|
+
} else if (ghCheck.reason === "not_github_repo") {
|
|
1306
|
+
console.log(import_picocolors9.default.yellow("This doesn't appear to be a GitHub repository."));
|
|
1307
|
+
console.log();
|
|
1308
|
+
console.log("Make sure you're in a git repo with a GitHub remote.");
|
|
1309
|
+
}
|
|
1310
|
+
console.log();
|
|
1311
|
+
console.log(import_picocolors9.default.dim("Cannot switch to GitHub Issues. Keeping current tracker."));
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
config2.projectTracker = "github";
|
|
1315
|
+
changed = true;
|
|
1316
|
+
const projectName = await selectOrCreateProjectBoard2(ghCheck.repo);
|
|
1317
|
+
config2.githubProject = projectName;
|
|
1318
|
+
} else if (newTracker !== config2.projectTracker) {
|
|
1198
1319
|
config2.projectTracker = newTracker;
|
|
1199
1320
|
changed = true;
|
|
1200
1321
|
}
|
|
1201
|
-
if (newTracker === "github") {
|
|
1322
|
+
if (newTracker === "github" && config2.projectTracker === "github" && !changed) {
|
|
1202
1323
|
const changeBoard = await confirm2({
|
|
1203
1324
|
message: config2.githubProject ? `Change project board? (current: ${config2.githubProject})` : "Set up a project board?",
|
|
1204
1325
|
initialValue: !config2.githubProject
|
|
@@ -1224,16 +1345,18 @@ async function cmdConfig() {
|
|
|
1224
1345
|
console.log(import_picocolors9.default.dim("No changes made."));
|
|
1225
1346
|
}
|
|
1226
1347
|
}
|
|
1227
|
-
async function selectOrCreateProjectBoard2() {
|
|
1228
|
-
let repoName = "";
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1348
|
+
async function selectOrCreateProjectBoard2(knownRepo) {
|
|
1349
|
+
let repoName = knownRepo || "";
|
|
1350
|
+
if (!repoName) {
|
|
1351
|
+
try {
|
|
1352
|
+
repoName = (0, import_node_child_process7.execSync)("gh repo view --json nameWithOwner -q .nameWithOwner", {
|
|
1353
|
+
encoding: "utf-8",
|
|
1354
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
1355
|
+
}).trim();
|
|
1356
|
+
} catch {
|
|
1357
|
+
console.log(import_picocolors9.default.yellow("Could not detect GitHub repo. Skipping project board setup."));
|
|
1358
|
+
return null;
|
|
1359
|
+
}
|
|
1237
1360
|
}
|
|
1238
1361
|
let existingProjects = [];
|
|
1239
1362
|
try {
|