contribute-now 0.4.0-dev.ba6545c → 0.4.0-dev.d24b735
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 +100 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2018,7 +2018,7 @@ import pc7 from "picocolors";
|
|
|
2018
2018
|
// package.json
|
|
2019
2019
|
var package_default = {
|
|
2020
2020
|
name: "contribute-now",
|
|
2021
|
-
version: "0.4.0-dev.
|
|
2021
|
+
version: "0.4.0-dev.d24b735",
|
|
2022
2022
|
description: "Git workflow CLI for squash-merge two-branch models. Keeps dev in sync with main after squash merges.",
|
|
2023
2023
|
type: "module",
|
|
2024
2024
|
bin: {
|
|
@@ -2677,6 +2677,40 @@ function colorizeSubject(subject) {
|
|
|
2677
2677
|
// src/commands/setup.ts
|
|
2678
2678
|
import { defineCommand as defineCommand7 } from "citty";
|
|
2679
2679
|
import pc10 from "picocolors";
|
|
2680
|
+
async function shouldContinueSetupWithExistingConfig(options) {
|
|
2681
|
+
const {
|
|
2682
|
+
existingConfig,
|
|
2683
|
+
hasConfigFile,
|
|
2684
|
+
confirm: confirm2,
|
|
2685
|
+
ensureIgnored,
|
|
2686
|
+
onInfo,
|
|
2687
|
+
onWarn,
|
|
2688
|
+
onSuccess,
|
|
2689
|
+
summary
|
|
2690
|
+
} = options;
|
|
2691
|
+
if (existingConfig) {
|
|
2692
|
+
onInfo("Existing .contributerc.json detected:");
|
|
2693
|
+
summary(existingConfig);
|
|
2694
|
+
const shouldContinue = await confirm2("Continue setup and overwrite existing config?");
|
|
2695
|
+
if (!shouldContinue) {
|
|
2696
|
+
if (ensureIgnored()) {
|
|
2697
|
+
onInfo("Added .contributerc.json to .gitignore to avoid committing personal config.");
|
|
2698
|
+
}
|
|
2699
|
+
onSuccess("Keeping existing setup.");
|
|
2700
|
+
return false;
|
|
2701
|
+
}
|
|
2702
|
+
return true;
|
|
2703
|
+
}
|
|
2704
|
+
if (hasConfigFile) {
|
|
2705
|
+
onWarn("Found .contributerc.json but it appears invalid.");
|
|
2706
|
+
const shouldContinue = await confirm2("Continue setup and overwrite invalid config?");
|
|
2707
|
+
if (!shouldContinue) {
|
|
2708
|
+
onInfo("Keeping existing file. Run setup again when ready to repair it.");
|
|
2709
|
+
return false;
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
return true;
|
|
2713
|
+
}
|
|
2680
2714
|
var setup_default = defineCommand7({
|
|
2681
2715
|
meta: {
|
|
2682
2716
|
name: "setup",
|
|
@@ -2688,6 +2722,20 @@ var setup_default = defineCommand7({
|
|
|
2688
2722
|
process.exit(1);
|
|
2689
2723
|
}
|
|
2690
2724
|
heading("\uD83D\uDD27 contribute-now setup");
|
|
2725
|
+
const existingConfig = readConfig();
|
|
2726
|
+
const shouldContinue = await shouldContinueSetupWithExistingConfig({
|
|
2727
|
+
existingConfig,
|
|
2728
|
+
hasConfigFile: configExists(),
|
|
2729
|
+
confirm: confirmPrompt,
|
|
2730
|
+
ensureIgnored: ensureGitignored,
|
|
2731
|
+
onInfo: info,
|
|
2732
|
+
onWarn: warn,
|
|
2733
|
+
onSuccess: success,
|
|
2734
|
+
summary: logConfigSummary
|
|
2735
|
+
});
|
|
2736
|
+
if (!shouldContinue) {
|
|
2737
|
+
return;
|
|
2738
|
+
}
|
|
2691
2739
|
const workflowChoice = await selectPrompt("Which git workflow does this project use?", [
|
|
2692
2740
|
"Clean Flow — main + dev, squash features into dev, merge dev into main (recommended)",
|
|
2693
2741
|
"GitHub Flow — main + feature branches, squash/merge into main",
|
|
@@ -2717,31 +2765,42 @@ var setup_default = defineCommand7({
|
|
|
2717
2765
|
info(`Found remotes: ${remotes.join(", ")}`);
|
|
2718
2766
|
let detectedRole = null;
|
|
2719
2767
|
let detectionSource = "";
|
|
2720
|
-
const
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2768
|
+
const roleSpinner = createSpinner("Detecting your role...");
|
|
2769
|
+
try {
|
|
2770
|
+
roleSpinner.update("Checking GitHub CLI and auth...");
|
|
2771
|
+
const ghInstalled = await checkGhInstalled();
|
|
2772
|
+
if (ghInstalled && await checkGhAuth()) {
|
|
2773
|
+
roleSpinner.update("Inspecting repository relationship (fork/permissions)...");
|
|
2774
|
+
const isFork = await isRepoFork();
|
|
2775
|
+
if (isFork === true) {
|
|
2776
|
+
detectedRole = "contributor";
|
|
2777
|
+
detectionSource = "gh CLI (fork detected)";
|
|
2778
|
+
} else if (isFork === false) {
|
|
2779
|
+
const repoInfo = await getCurrentRepoInfo();
|
|
2780
|
+
if (repoInfo) {
|
|
2781
|
+
const perms = await checkRepoPermissions(repoInfo.owner, repoInfo.repo);
|
|
2782
|
+
if (perms?.admin || perms?.push) {
|
|
2783
|
+
detectedRole = "maintainer";
|
|
2784
|
+
detectionSource = "gh CLI (admin/push permissions)";
|
|
2785
|
+
}
|
|
2733
2786
|
}
|
|
2734
2787
|
}
|
|
2735
2788
|
}
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2789
|
+
if (detectedRole === null) {
|
|
2790
|
+
roleSpinner.update("Analyzing git remotes...");
|
|
2791
|
+
if (remotes.includes("upstream")) {
|
|
2792
|
+
detectedRole = "contributor";
|
|
2793
|
+
detectionSource = "heuristic (upstream remote exists)";
|
|
2794
|
+
} else if (remotes.includes("origin") && remotes.length === 1) {
|
|
2795
|
+
detectedRole = "maintainer";
|
|
2796
|
+
detectionSource = "heuristic (only origin remote)";
|
|
2797
|
+
}
|
|
2744
2798
|
}
|
|
2799
|
+
roleSpinner.success("Role detection complete.");
|
|
2800
|
+
} catch {
|
|
2801
|
+
roleSpinner.fail("Role detection failed; falling back to manual selection.");
|
|
2802
|
+
detectedRole = null;
|
|
2803
|
+
detectionSource = "";
|
|
2745
2804
|
}
|
|
2746
2805
|
if (detectedRole === null) {
|
|
2747
2806
|
const roleChoice = await selectPrompt("What is your role in this project?", [
|
|
@@ -2759,16 +2818,20 @@ var setup_default = defineCommand7({
|
|
|
2759
2818
|
}
|
|
2760
2819
|
}
|
|
2761
2820
|
const defaultConfig = getDefaultConfig();
|
|
2762
|
-
|
|
2821
|
+
info(pc10.dim("Tip: press Enter to keep the default branch name shown in each prompt."));
|
|
2822
|
+
const mainBranchDefault = defaultConfig.mainBranch;
|
|
2823
|
+
const mainBranch = await inputPrompt(`Main branch name (default: ${mainBranchDefault} — press Enter to keep)`, mainBranchDefault);
|
|
2763
2824
|
let devBranch;
|
|
2764
2825
|
if (hasDevBranch(workflow)) {
|
|
2765
2826
|
const defaultDev = workflow === "git-flow" ? "develop" : "dev";
|
|
2766
|
-
devBranch = await inputPrompt(
|
|
2827
|
+
devBranch = await inputPrompt(`Dev/develop branch name (default: ${defaultDev} — press Enter to keep)`, defaultDev);
|
|
2767
2828
|
}
|
|
2768
|
-
const
|
|
2829
|
+
const originRemoteDefault = defaultConfig.origin;
|
|
2830
|
+
const originRemote = await inputPrompt(`Origin remote name (default: ${originRemoteDefault} — press Enter to keep)`, originRemoteDefault);
|
|
2769
2831
|
let upstreamRemote = defaultConfig.upstream;
|
|
2770
2832
|
if (detectedRole === "contributor") {
|
|
2771
|
-
|
|
2833
|
+
const upstreamRemoteDefault = defaultConfig.upstream;
|
|
2834
|
+
upstreamRemote = await inputPrompt(`Upstream remote name (default: ${upstreamRemoteDefault} — press Enter to keep)`, upstreamRemoteDefault);
|
|
2772
2835
|
if (!remotes.includes(upstreamRemote)) {
|
|
2773
2836
|
warn(`Remote "${upstreamRemote}" not found.`);
|
|
2774
2837
|
const originUrl = await getRemoteUrl(originRemote);
|
|
@@ -2831,6 +2894,17 @@ var setup_default = defineCommand7({
|
|
|
2831
2894
|
info(`Origin: ${pc10.bold(config.origin)}${config.role === "contributor" ? ` | Upstream: ${pc10.bold(config.upstream)}` : ""}`);
|
|
2832
2895
|
}
|
|
2833
2896
|
});
|
|
2897
|
+
function logConfigSummary(config) {
|
|
2898
|
+
info(`Workflow: ${pc10.bold(WORKFLOW_DESCRIPTIONS[config.workflow])}`);
|
|
2899
|
+
info(`Convention: ${pc10.bold(CONVENTION_DESCRIPTIONS[config.commitConvention])}`);
|
|
2900
|
+
info(`Role: ${pc10.bold(config.role)}`);
|
|
2901
|
+
if (config.devBranch) {
|
|
2902
|
+
info(`Main: ${pc10.bold(config.mainBranch)} | Dev: ${pc10.bold(config.devBranch)}`);
|
|
2903
|
+
} else {
|
|
2904
|
+
info(`Main: ${pc10.bold(config.mainBranch)}`);
|
|
2905
|
+
}
|
|
2906
|
+
info(`Origin: ${pc10.bold(config.origin)}${config.role === "contributor" ? ` | Upstream: ${pc10.bold(config.upstream)}` : ""}`);
|
|
2907
|
+
}
|
|
2834
2908
|
|
|
2835
2909
|
// src/commands/start.ts
|
|
2836
2910
|
import { defineCommand as defineCommand8 } from "citty";
|
package/package.json
CHANGED