ya-git-jira 1.0.0 → 1.2.0
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/bin/git-bump.ts +33 -0
- package/bin/git-jira-issue.ts +35 -0
- package/bin/git-jira-issues.ts +25 -0
- package/bin/git-jira-start.ts +38 -0
- package/bin/git-jira.ts +27 -0
- package/bin/gitj.ts +24 -0
- package/bun.lockb +0 -0
- package/dist/bin/{bump.js → bundo.js} +16 -29
- package/dist/bin/git-bump.js +1903 -0
- package/dist/bin/git-jira-issue.js +1940 -0
- package/dist/bin/git-jira-issues.js +1933 -0
- package/dist/bin/git-jira-start.js +1940 -0
- package/dist/bin/git-jira.js +2035 -0
- package/dist/bin/gitj.js +1909 -0
- package/dist/index.js +49 -1
- package/index.ts +2 -0
- package/lib/git.ts +1 -10
- package/lib/is_main.ts +5 -0
- package/lib/jira.ts +20 -3
- package/lib/spawn.ts +10 -0
- package/package.json +9 -5
- package/bin/bump.ts +0 -18
- package/bin/start.ts +0 -24
- package/dist/bin/start.js +0 -308
package/bin/git-bump.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env bun run
|
|
2
|
+
|
|
3
|
+
import { createBranch, getCurrentBranch } from "../lib/git"
|
|
4
|
+
import { Command } from 'commander'
|
|
5
|
+
import { isMain } from '../lib/is_main'
|
|
6
|
+
|
|
7
|
+
export function create(): Command {
|
|
8
|
+
const program = new Command()
|
|
9
|
+
program
|
|
10
|
+
.name('bump')
|
|
11
|
+
.action(async () => {
|
|
12
|
+
const currentBranch = await getCurrentBranch()
|
|
13
|
+
|
|
14
|
+
let stem = currentBranch
|
|
15
|
+
let version = 1
|
|
16
|
+
|
|
17
|
+
const match = currentBranch.match(/^(.+)[-\.]v(\d+)$/)
|
|
18
|
+
if (match) {
|
|
19
|
+
stem = match[1]
|
|
20
|
+
version = parseInt(match[2]) + 1
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const nextBranch = `${stem}.v${version}`
|
|
24
|
+
await createBranch(nextBranch)
|
|
25
|
+
})
|
|
26
|
+
return program
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (isMain('git-bump')) {
|
|
30
|
+
create().parse(process.argv)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default create
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env bun run
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander'
|
|
4
|
+
import { getIssue } from "../lib/jira"
|
|
5
|
+
import { isMain } from '../lib/is_main'
|
|
6
|
+
|
|
7
|
+
export function create() {
|
|
8
|
+
const program = new Command()
|
|
9
|
+
program
|
|
10
|
+
.name('issue')
|
|
11
|
+
.argument('issue', 'Issue ID')
|
|
12
|
+
.option('-v, --verbose', 'Verbose output')
|
|
13
|
+
.option('-u, --url', 'Show the URL of the issue')
|
|
14
|
+
.action(async (issueId: string, options) => {
|
|
15
|
+
const issue = await getIssue(issueId)
|
|
16
|
+
if (!issue) {
|
|
17
|
+
console.error(`Issue ${issueId} not found`)
|
|
18
|
+
process.exit(1)
|
|
19
|
+
}
|
|
20
|
+
if (options.verbose) {
|
|
21
|
+
console.log(issue)
|
|
22
|
+
process.exit(0)
|
|
23
|
+
}
|
|
24
|
+
if (options.url) {
|
|
25
|
+
console.log(issue.self)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
return program
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isMain('git-jira-issue')) {
|
|
32
|
+
create().parse(process.argv)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default create
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env bun run
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander'
|
|
4
|
+
import { myUnresolvedIssues } from "../lib/jira"
|
|
5
|
+
import { isMain } from '../lib/is_main'
|
|
6
|
+
|
|
7
|
+
export function create(): Command {
|
|
8
|
+
const program = new Command()
|
|
9
|
+
program
|
|
10
|
+
.name('issues')
|
|
11
|
+
.action(async (options) => {
|
|
12
|
+
const issues = await myUnresolvedIssues()
|
|
13
|
+
console.log(`You have ${issues.length} unresolved issues`)
|
|
14
|
+
issues.forEach(issue => {
|
|
15
|
+
console.log(`${issue.key}: ${issue.fields.summary}`)
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
return program
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (isMain('git-jira-issues')) {
|
|
22
|
+
create().parse(process.argv)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default create
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env bun run
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander'
|
|
4
|
+
import { createBranch } from "../lib/git"
|
|
5
|
+
import { getIssue } from "../lib/jira"
|
|
6
|
+
import { isMain } from '../lib/is_main'
|
|
7
|
+
|
|
8
|
+
function toKebab(s: string): string {
|
|
9
|
+
return s.replace(/([a-z]+)([A-Z]+)/g, "$1_2").toLowerCase()
|
|
10
|
+
.replace(/(\W+)/g, "-")
|
|
11
|
+
.replace(/-$/, "")
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function create(): Command {
|
|
15
|
+
const program = new Command()
|
|
16
|
+
program
|
|
17
|
+
.name('start')
|
|
18
|
+
.argument('issue', 'Issue ID')
|
|
19
|
+
.action(async (issueId: string) => {
|
|
20
|
+
const issue = await getIssue(issueId)
|
|
21
|
+
if (!issue) {
|
|
22
|
+
console.error(`Issue ${issueId} not found`)
|
|
23
|
+
process.exit(1)
|
|
24
|
+
}
|
|
25
|
+
const summary = issue.fields.summary
|
|
26
|
+
|
|
27
|
+
const branchName = `${issueId}-${toKebab(summary)}`
|
|
28
|
+
await createBranch(branchName)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
return program
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (isMain('git-jira-issues')) {
|
|
35
|
+
create().parse(process.argv)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default create
|
package/bin/git-jira.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env bun run
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander'
|
|
4
|
+
import { isMain } from '../lib/is_main'
|
|
5
|
+
|
|
6
|
+
const start = (await import('./git-jira-start')).create()
|
|
7
|
+
const issue = (await import('./git-jira-issue')).create()
|
|
8
|
+
const issues = (await import('./git-jira-issues')).create()
|
|
9
|
+
|
|
10
|
+
export function create() {
|
|
11
|
+
const program = new Command()
|
|
12
|
+
program
|
|
13
|
+
.name('jira')
|
|
14
|
+
.addCommand(start)
|
|
15
|
+
.addCommand(issue)
|
|
16
|
+
.addCommand(issues)
|
|
17
|
+
.action(() => {
|
|
18
|
+
program.help()
|
|
19
|
+
})
|
|
20
|
+
return program
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (isMain('git-jira')) {
|
|
24
|
+
create().parse(process.argv)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default create
|
package/bin/gitj.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env bun run
|
|
2
|
+
|
|
3
|
+
// This is the root of the CLI. It's job is to parse the command
|
|
4
|
+
// from the command line and then call the appropriate subcommand.
|
|
5
|
+
|
|
6
|
+
import { Command } from 'commander'
|
|
7
|
+
import { isMain } from '../lib/is_main'
|
|
8
|
+
|
|
9
|
+
if (isMain('gitj')) {
|
|
10
|
+
|
|
11
|
+
const program = new Command()
|
|
12
|
+
const bump = (await import('./git-bump')).create()
|
|
13
|
+
|
|
14
|
+
program
|
|
15
|
+
.executableDir('./bin')
|
|
16
|
+
.addCommand(bump)
|
|
17
|
+
.command('jira', 'A collection of jira utility commands', { executableFile: 'git-jira' })
|
|
18
|
+
|
|
19
|
+
program
|
|
20
|
+
.action(() => {
|
|
21
|
+
program.help()
|
|
22
|
+
})
|
|
23
|
+
.parse(Bun.argv)
|
|
24
|
+
}
|
package/bun.lockb
CHANGED
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
1
|
+
#!/usr/bin/env bun run
|
|
2
2
|
// @bun
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -17,8 +17,18 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
20
|
+
var __require = (id) => {
|
|
21
|
+
return import.meta.require(id);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// lib/debug.ts
|
|
25
|
+
function dargv() {
|
|
26
|
+
if (Bun.env.DEBUG && Bun.env.DEBUG.toLowerCase().includes("gitjira")) {
|
|
27
|
+
console.log(Bun.argv);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
20
30
|
|
|
21
|
-
// lib/
|
|
31
|
+
// lib/spawn.ts
|
|
22
32
|
async function doCommand(args) {
|
|
23
33
|
const proc = Bun.spawn(args);
|
|
24
34
|
const stdout = new Response(proc.stdout);
|
|
@@ -28,31 +38,8 @@ async function doCommand(args) {
|
|
|
28
38
|
console.error(err);
|
|
29
39
|
return out.trim();
|
|
30
40
|
}
|
|
31
|
-
async function getConfig(key) {
|
|
32
|
-
return doCommand(["git", "config", "--get", key]);
|
|
33
|
-
}
|
|
34
|
-
async function getJiraConfig() {
|
|
35
|
-
const host = await getConfig("jira.host");
|
|
36
|
-
const user = await getConfig("jira.user") || await getConfig("user.email");
|
|
37
|
-
const pat = await getConfig("jira.pat");
|
|
38
|
-
const token = Buffer.from(`${user}:${pat}`).toString("base64");
|
|
39
|
-
return { host, token };
|
|
40
|
-
}
|
|
41
|
-
async function createBranch(name) {
|
|
42
|
-
return doCommand(["git", "checkout", "-b", name]);
|
|
43
|
-
}
|
|
44
|
-
async function getCurrentBranch() {
|
|
45
|
-
return doCommand(["git", "rev-parse", "--abbrev-ref", "HEAD"]);
|
|
46
|
-
}
|
|
47
41
|
|
|
48
|
-
// bin/
|
|
49
|
-
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
var match = currentBranch.match(/^(.+)[-\.]v(\d+)$/);
|
|
53
|
-
if (match) {
|
|
54
|
-
stem = match[1];
|
|
55
|
-
version = parseInt(match[2]) + 1;
|
|
56
|
-
}
|
|
57
|
-
var nextBranch = `${stem}.v${version}`;
|
|
58
|
-
await createBranch(nextBranch);
|
|
42
|
+
// bin/bundo.ts
|
|
43
|
+
dargv();
|
|
44
|
+
var args = ["sh", "-c", ...Bun.argv.slice(2)];
|
|
45
|
+
await doCommand(args);
|