hsh19900502 1.0.7 → 1.0.9
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/.vscode/settings.json +5 -0
- package/README.md +0 -0
- package/dist/commands/git.d.ts +2 -0
- package/dist/commands/git.js +18 -0
- package/dist/hsh.js +13 -1
- package/package.json +1 -1
- package/src/commands/git.ts +20 -0
- package/src/hsh.ts +15 -1
package/README.md
ADDED
|
File without changes
|
package/dist/commands/git.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import 'zx/globals';
|
|
2
2
|
export declare const gcm: (message: string, isPush?: boolean) => Promise<void>;
|
|
3
|
+
export declare const merge: (branch: string) => Promise<void>;
|
|
4
|
+
export declare const branchout: (branch: string) => Promise<void>;
|
|
3
5
|
export declare const push: () => Promise<void>;
|
package/dist/commands/git.js
CHANGED
|
@@ -9,6 +9,24 @@ export const gcm = async function (message, isPush) {
|
|
|
9
9
|
await push();
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
+
export const merge = async (branch) => {
|
|
13
|
+
const currentBranch = (await $ `git branch --show-current`).stdout.trim();
|
|
14
|
+
if (currentBranch === branch) {
|
|
15
|
+
console.warn(chalk.yellow('Current branch is the same as the branch to be merged'));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
await $ `git checkout ${branch}`;
|
|
19
|
+
await $ `git pull origin ${branch}`;
|
|
20
|
+
await $ `git checkout ${currentBranch}`;
|
|
21
|
+
await $ `git merge ${branch}`;
|
|
22
|
+
console.log(chalk.green('Merged branch into current branch successfully!\n'));
|
|
23
|
+
};
|
|
24
|
+
export const branchout = async (branch) => {
|
|
25
|
+
await $ `git checkout master`;
|
|
26
|
+
await $ `git pull origin master`;
|
|
27
|
+
await $ `git checkout -b ${branch}`;
|
|
28
|
+
console.log(chalk.green(`Created and checked out branch ${branch} successfully from master!\n`));
|
|
29
|
+
};
|
|
12
30
|
export const push = async function () {
|
|
13
31
|
const question = [
|
|
14
32
|
{
|
package/dist/hsh.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { gcm, push } from './commands/git.js';
|
|
2
|
+
import { branchout, gcm, merge, push } from './commands/git.js';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import packageJson from '../package.json' assert { type: "json" };
|
|
5
5
|
import { initMonoRepo, monoCd } from './commands/mono.js';
|
|
@@ -21,6 +21,18 @@ program
|
|
|
21
21
|
.action(() => {
|
|
22
22
|
push();
|
|
23
23
|
});
|
|
24
|
+
program.command('merge')
|
|
25
|
+
.description('merge branch into current branch')
|
|
26
|
+
.argument('<branch>')
|
|
27
|
+
.action((branch) => {
|
|
28
|
+
merge(branch);
|
|
29
|
+
});
|
|
30
|
+
program.command('branchout')
|
|
31
|
+
.description('create a new branch')
|
|
32
|
+
.argument('<branch>')
|
|
33
|
+
.action((branch) => {
|
|
34
|
+
branchout(branch);
|
|
35
|
+
});
|
|
24
36
|
const mono = program.command('mono').description('multi repo management');
|
|
25
37
|
mono.command('init').description('init mono repo').action(() => {
|
|
26
38
|
initMonoRepo();
|
package/package.json
CHANGED
package/src/commands/git.ts
CHANGED
|
@@ -12,6 +12,26 @@ export const gcm = async function (message: string, isPush?: boolean): Promise<v
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
export const merge = async (branch: string) => {
|
|
16
|
+
const currentBranch = (await $`git branch --show-current`).stdout.trim()
|
|
17
|
+
if(currentBranch === branch) {
|
|
18
|
+
console.warn(chalk.yellow('Current branch is the same as the branch to be merged'));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
await $`git checkout ${branch}`;
|
|
22
|
+
await $`git pull origin ${branch}`;
|
|
23
|
+
await $`git checkout ${currentBranch}`;
|
|
24
|
+
await $`git merge ${branch}`;
|
|
25
|
+
console.log(chalk.green('Merged branch into current branch successfully!\n'));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const branchout = async (branch: string) => {
|
|
29
|
+
await $`git checkout master`;
|
|
30
|
+
await $`git pull origin master`;
|
|
31
|
+
await $`git checkout -b ${branch}`;
|
|
32
|
+
console.log(chalk.green(`Created and checked out branch ${branch} successfully from master!\n`));
|
|
33
|
+
}
|
|
34
|
+
|
|
15
35
|
interface BranchQuestion {
|
|
16
36
|
type: 'input';
|
|
17
37
|
name: 'branch';
|
package/src/hsh.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { gcm, push } from './commands/git.js';
|
|
2
|
+
import { branchout, gcm, merge, push } from './commands/git.js';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import packageJson from '../package.json' assert { type: "json" };
|
|
5
5
|
import { initMonoRepo, monoCd } from './commands/mono.js';
|
|
@@ -27,6 +27,20 @@ program
|
|
|
27
27
|
push();
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
+
program.command('merge')
|
|
31
|
+
.description('merge branch into current branch')
|
|
32
|
+
.argument('<branch>')
|
|
33
|
+
.action((branch: string) => {
|
|
34
|
+
merge(branch);
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
program.command('branchout')
|
|
38
|
+
.description('create a new branch')
|
|
39
|
+
.argument('<branch>')
|
|
40
|
+
.action((branch: string) => {
|
|
41
|
+
branchout(branch);
|
|
42
|
+
})
|
|
43
|
+
|
|
30
44
|
const mono = program.command('mono').description('multi repo management')
|
|
31
45
|
mono.command('init').description('init mono repo').action(() => {
|
|
32
46
|
initMonoRepo();
|