@burglekitt/worktree 0.1.0 → 0.1.2
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/commands/branch.d.ts +0 -1
- package/dist/commands/branch.js +2 -1
- package/dist/commands/config.d.ts +0 -1
- package/dist/commands/config.js +7 -2
- package/dist/lib/base-command.d.ts +4 -0
- package/dist/lib/base-command.js +29 -0
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/constants.js +1 -0
- package/package.json +13 -4
|
@@ -6,7 +6,6 @@ export default class Branch extends BaseCommand {
|
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
8
8
|
static flags: {
|
|
9
|
-
help: import("@oclif/core/interfaces").BooleanFlag<void>;
|
|
10
9
|
source: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
10
|
};
|
|
12
11
|
private confirmNonOriginSource;
|
package/dist/commands/branch.js
CHANGED
|
@@ -13,7 +13,6 @@ export default class Branch extends BaseCommand {
|
|
|
13
13
|
"<%= config.bin %> <%= command.id %> my-new-branch",
|
|
14
14
|
];
|
|
15
15
|
static flags = {
|
|
16
|
-
help: Flags.help({ char: "h", description: "Show branch help" }),
|
|
17
16
|
source: Flags.string({
|
|
18
17
|
char: "s",
|
|
19
18
|
description: "Source branch to create the worktree from",
|
|
@@ -66,6 +65,8 @@ export default class Branch extends BaseCommand {
|
|
|
66
65
|
}
|
|
67
66
|
async run() {
|
|
68
67
|
const { args, flags } = await this.parse(Branch);
|
|
68
|
+
// If there is no source flag provided, make sure defaultSourceBranch is configured
|
|
69
|
+
await this.verifyConfig(flags.source ? [] : ["defaultSourceBranch"]);
|
|
69
70
|
const branchName = await this.getBranchName(args.branchName);
|
|
70
71
|
const sourceBranch = await this.getSourceBranch(flags.source);
|
|
71
72
|
const projectPath = await gitCreateWorktree(branchName, sourceBranch);
|
|
@@ -8,7 +8,6 @@ export default class Config extends BaseCommand {
|
|
|
8
8
|
};
|
|
9
9
|
static flags: {
|
|
10
10
|
list: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
-
help: import("@oclif/core/interfaces").BooleanFlag<void>;
|
|
12
11
|
missing: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
12
|
};
|
|
14
13
|
private renderList;
|
package/dist/commands/config.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { EOL } from "node:os";
|
|
2
2
|
import { confirm, input } from "@inquirer/prompts";
|
|
3
3
|
import { Args, Flags } from "@oclif/core";
|
|
4
|
+
import chalk from "chalk";
|
|
4
5
|
import { BaseCommand } from "../lib/base-command.js";
|
|
5
6
|
import { CONFIG_NAMES } from "../lib/constants.js";
|
|
6
7
|
import { gitGetConfigValue, gitSetConfigValue } from "../lib/git.js";
|
|
7
8
|
import { conjoin } from "../lib/utils.js";
|
|
8
9
|
import { isValidBranch, isValidCommand, isValidEmail, validateConfigValue, } from "../lib/validators.js";
|
|
10
|
+
// TODO: Implement properly when Jira integration has been added
|
|
11
|
+
const JIRA_ENABLED = false;
|
|
9
12
|
export default class Config extends BaseCommand {
|
|
10
13
|
static description = "Configure worktree CLI settings";
|
|
11
14
|
static examples = ["<%= config.bin %> <%= command.id %>"];
|
|
@@ -18,7 +21,6 @@ export default class Config extends BaseCommand {
|
|
|
18
21
|
char: "l",
|
|
19
22
|
description: "List all available variables",
|
|
20
23
|
}),
|
|
21
|
-
help: Flags.help({ char: "h", description: "Show config help" }),
|
|
22
24
|
missing: Flags.boolean({
|
|
23
25
|
char: "m",
|
|
24
26
|
description: "Only prompt missing variables",
|
|
@@ -52,7 +54,7 @@ export default class Config extends BaseCommand {
|
|
|
52
54
|
}
|
|
53
55
|
async renderInput(missing) {
|
|
54
56
|
const configNames = await this.getPromptConfigNames(missing);
|
|
55
|
-
const hasJiraPrompt = !!configNames.find((name) => name.startsWith("jira"));
|
|
57
|
+
const hasJiraPrompt = JIRA_ENABLED && !!configNames.find((name) => name.startsWith("jira"));
|
|
56
58
|
// First check if there is anything to prompt
|
|
57
59
|
if (configNames.length === 0) {
|
|
58
60
|
this.log("No missing config found.");
|
|
@@ -96,12 +98,15 @@ export default class Config extends BaseCommand {
|
|
|
96
98
|
});
|
|
97
99
|
await gitSetConfigValue("codeEditor", codeEditor);
|
|
98
100
|
}
|
|
101
|
+
this.log(`${chalk.green("✔")} Configuration complete!${EOL}`);
|
|
99
102
|
}
|
|
100
103
|
isValidArgName(name) {
|
|
101
104
|
return CONFIG_NAMES.includes(name);
|
|
102
105
|
}
|
|
103
106
|
async run() {
|
|
104
107
|
const { args, flags } = await this.parse(Config);
|
|
108
|
+
// Mark that config has been called at least once
|
|
109
|
+
await gitSetConfigValue("has-called-config", "true");
|
|
105
110
|
if (args.name) {
|
|
106
111
|
if (!this.isValidArgName(args.name)) {
|
|
107
112
|
this.error([
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Command } from "@oclif/core";
|
|
2
2
|
import type { CommandError } from "@oclif/core/interfaces";
|
|
3
|
+
import type { ConfigName } from "./constants.js";
|
|
3
4
|
export declare abstract class BaseCommand extends Command {
|
|
5
|
+
private confirmFirstTimeConfig;
|
|
6
|
+
private confirmMissingConfig;
|
|
7
|
+
protected verifyConfig(configNames?: ConfigName[]): Promise<void>;
|
|
4
8
|
protected openWorktreePath(path: string): Promise<void>;
|
|
5
9
|
protected catch(error: CommandError): Promise<any>;
|
|
6
10
|
}
|
package/dist/lib/base-command.js
CHANGED
|
@@ -1,9 +1,38 @@
|
|
|
1
1
|
import { exec } from "node:child_process";
|
|
2
|
+
import { confirm } from "@inquirer/prompts";
|
|
2
3
|
import { Command } from "@oclif/core";
|
|
3
4
|
import chalk from "chalk";
|
|
4
5
|
import ora from "ora";
|
|
5
6
|
import { gitGetConfigValue } from "./git.js";
|
|
6
7
|
export class BaseCommand extends Command {
|
|
8
|
+
confirmFirstTimeConfig() {
|
|
9
|
+
const message = "Looks like this is your first time running the CLI. Do you want to run the config command now?";
|
|
10
|
+
return confirm({ message });
|
|
11
|
+
}
|
|
12
|
+
confirmMissingConfig() {
|
|
13
|
+
const message = "Some required configuration values are missing. Do you want to run the config command now?";
|
|
14
|
+
return confirm({ message });
|
|
15
|
+
}
|
|
16
|
+
async verifyConfig(configNames = []) {
|
|
17
|
+
if ((await gitGetConfigValue("has-called-config")) !== "true") {
|
|
18
|
+
if (await this.confirmFirstTimeConfig()) {
|
|
19
|
+
await this.config.runCommand("config");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
let isMissingConfig = false;
|
|
24
|
+
for (const name of configNames) {
|
|
25
|
+
if (!(await gitGetConfigValue(name))) {
|
|
26
|
+
isMissingConfig = true;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (isMissingConfig) {
|
|
31
|
+
if (await this.confirmMissingConfig()) {
|
|
32
|
+
await this.config.runCommand("config", ["--missing"]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
7
36
|
async openWorktreePath(path) {
|
|
8
37
|
const codeEditor = await gitGetConfigValue("codeEditor");
|
|
9
38
|
if (codeEditor) {
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const CONFIG_NAMES: readonly ["jira.domain", "jira.email", "jira.apiToken", "codeEditor", "defaultSourceBranch"];
|
|
1
|
+
export declare const CONFIG_NAMES: readonly ["has-called-config", "jira.domain", "jira.email", "jira.apiToken", "codeEditor", "defaultSourceBranch"];
|
|
2
2
|
export type ConfigName = (typeof CONFIG_NAMES)[number];
|
package/dist/lib/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burglekitt/worktree",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A CLI tool for managing git worktrees with enhanced workflow features",
|
|
5
5
|
"main": "./bin/run.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,11 +32,18 @@
|
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be",
|
|
34
34
|
"bin": {
|
|
35
|
-
"worktree": "./bin/run.js",
|
|
36
|
-
"
|
|
35
|
+
"@burglekitt/worktree": "./bin/run.js",
|
|
36
|
+
"worktree": "./bin/run.js"
|
|
37
37
|
},
|
|
38
38
|
"oclif": {
|
|
39
|
-
"bin": "worktree",
|
|
39
|
+
"bin": "@burglekitt/worktree",
|
|
40
|
+
"binAliases": [
|
|
41
|
+
"@burglekitt/worktree",
|
|
42
|
+
"worktree"
|
|
43
|
+
],
|
|
44
|
+
"plugins": [
|
|
45
|
+
"@oclif/plugin-*"
|
|
46
|
+
],
|
|
40
47
|
"commands": "./dist/commands",
|
|
41
48
|
"dirname": "worktree",
|
|
42
49
|
"topicSeparator": " "
|
|
@@ -44,6 +51,8 @@
|
|
|
44
51
|
"dependencies": {
|
|
45
52
|
"@inquirer/prompts": "^8.3.0",
|
|
46
53
|
"@oclif/core": "^4.8.3",
|
|
54
|
+
"@oclif/plugin-help": "^6.2.37",
|
|
55
|
+
"@oclif/plugin-not-found": "^3.2.74",
|
|
47
56
|
"chalk": "^5.6.2",
|
|
48
57
|
"glob": "^13.0.6",
|
|
49
58
|
"ora": "^9.3.0"
|