gitsu-cli 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/.github/workflows/ci.yml +45 -0
- package/CHANGELOG.md +14 -0
- package/README.md +2 -2
- package/biome.json +4 -6
- package/lib/package.json +22 -40
- package/lib/src/app.js +1 -1
- package/lib/src/commands/init.js +9 -18
- package/lib/src/commands/list.js +5 -14
- package/lib/src/functions/bootstrap-config.js +5 -14
- package/lib/src/functions/get-current-choice.js +4 -13
- package/lib/src/functions/save-git-config.js +3 -12
- package/lib/src/utils/get-config.js +4 -13
- package/package.json +22 -40
- package/src/app.ts +2 -4
- package/src/commands/init.ts +3 -3
- package/src/commands/list.ts +1 -1
- package/src/functions/bootstrap-config.ts +1 -1
- package/src/utils/get-config.ts +1 -2
- package/tsconfig.json +2 -2
- package/.github/workflows/build.yml +0 -39
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.husky/pre-push +0 -1
- package/.nvmrc +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v7
|
|
17
|
+
- uses: actions/setup-node@v7
|
|
18
|
+
with:
|
|
19
|
+
node-version: 24.x
|
|
20
|
+
- uses: pnpm/action-setup@v6
|
|
21
|
+
- run: pnpm install --frozen-lockfile
|
|
22
|
+
- run: pnpm check
|
|
23
|
+
- run: pnpm build
|
|
24
|
+
|
|
25
|
+
release:
|
|
26
|
+
needs: build
|
|
27
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
permissions:
|
|
30
|
+
contents: write # to be able to publish a GitHub release
|
|
31
|
+
issues: write # to be able to comment on released issues
|
|
32
|
+
pull-requests: write # to be able to comment on released pull requests
|
|
33
|
+
id-token: write # to enable use of OIDC for npm provenance
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v7
|
|
36
|
+
- uses: actions/setup-node@v7
|
|
37
|
+
with:
|
|
38
|
+
node-version: 24.x
|
|
39
|
+
- uses: pnpm/action-setup@v6
|
|
40
|
+
- run: pnpm install --frozen-lockfile
|
|
41
|
+
- run: pnpm build
|
|
42
|
+
- run: pnpm dlx semantic-release
|
|
43
|
+
env:
|
|
44
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
45
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.0.9](https://github.com/jamieweavis/gitsu/compare/v1.0.8...v1.0.9) (2026-10-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** upgrade dependencies and target node 24 ([53e0ddb](https://github.com/jamieweavis/gitsu/commit/53e0ddb702b50c6ef5600b359f85c3d70c6b0140))
|
|
7
|
+
|
|
8
|
+
## [1.0.8](https://github.com/jamieweavis/gitsu/compare/v1.0.7...v1.0.8) (2025-04-14)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update description ([867254a](https://github.com/jamieweavis/gitsu/commit/867254a9b1dbd270eb01580796e94cc67aee2037))
|
|
14
|
+
|
|
1
15
|
## [1.0.7](https://github.com/jamieweavis/gitsu/compare/v1.0.6...v1.0.7) (2025-04-05)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# gitsu
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Interactive command line util for quickly & easily switching git users
|
|
4
4
|
|
|
5
|
-
[](https://github.com/jamieweavis/gitsu/actions)
|
|
6
6
|
[](https://npmjs.com/package/gitsu-cli)
|
|
7
7
|
[](https://github.com/jamieweavis/gitsu/releases)
|
|
8
8
|
[](https://github.com/jamieweavis/gitsu/blob/main/LICENSE)
|
package/biome.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
|
|
3
3
|
"vcs": {
|
|
4
4
|
"enabled": false,
|
|
5
5
|
"clientKind": "git",
|
|
@@ -7,20 +7,18 @@
|
|
|
7
7
|
},
|
|
8
8
|
"files": {
|
|
9
9
|
"ignoreUnknown": false,
|
|
10
|
-
"
|
|
10
|
+
"includes": ["**"]
|
|
11
11
|
},
|
|
12
12
|
"formatter": {
|
|
13
13
|
"enabled": true,
|
|
14
14
|
"indentStyle": "space",
|
|
15
15
|
"indentWidth": 2
|
|
16
16
|
},
|
|
17
|
-
"organizeImports":
|
|
18
|
-
"enabled": true
|
|
19
|
-
},
|
|
17
|
+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
|
20
18
|
"linter": {
|
|
21
19
|
"enabled": true,
|
|
22
20
|
"rules": {
|
|
23
|
-
"
|
|
21
|
+
"preset": "recommended"
|
|
24
22
|
}
|
|
25
23
|
},
|
|
26
24
|
"javascript": {
|
package/lib/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitsu-cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "Interactive command line util for quickly & easily switching git users",
|
|
5
5
|
"author": "Jamie Weavis",
|
|
6
6
|
"homepage": "https://github.com/jamieweavis/gitsu#readme",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"packageManager": "pnpm@12.9.1",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=22.12"
|
|
11
|
+
},
|
|
8
12
|
"repository": {
|
|
9
13
|
"type": "git",
|
|
10
14
|
"url": "git+https://github.com/jamieweavis/gitsu.git"
|
|
@@ -29,39 +33,28 @@
|
|
|
29
33
|
"start": "node ./lib/src/app.js",
|
|
30
34
|
"dev": "ts-node-dev --respawn ./src/app.ts",
|
|
31
35
|
"build": "tsc",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"format": "biome format src",
|
|
35
|
-
"format:write": "npm run format -- --write",
|
|
36
|
-
"prepare": "husky"
|
|
36
|
+
"check": "biome check src",
|
|
37
|
+
"check:write": "pnpm check -- --write"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"cosmiconfig": "^8.3.6",
|
|
45
|
-
"inquirer": "^12.5.0",
|
|
46
|
-
"log-symbols": "^7.0.0",
|
|
47
|
-
"typescript": "^5.8.2"
|
|
40
|
+
"chalk": "^6.0.1",
|
|
41
|
+
"commander": "^15.0.0",
|
|
42
|
+
"cosmiconfig": "^10.0.1",
|
|
43
|
+
"inquirer": "^14.2.3",
|
|
44
|
+
"log-symbols": "^7.0.1"
|
|
48
45
|
},
|
|
49
46
|
"devDependencies": {
|
|
50
|
-
"@biomejs/biome": "^
|
|
51
|
-
"@
|
|
52
|
-
"@commitlint/config-conventional": "^19.8.0",
|
|
53
|
-
"@semantic-release/changelog": "^6.0.3",
|
|
47
|
+
"@biomejs/biome": "^2.5.15",
|
|
48
|
+
"@semantic-release/changelog": "^7.0.0",
|
|
54
49
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
55
|
-
"@semantic-release/git": "^
|
|
56
|
-
"@semantic-release/github": "^
|
|
57
|
-
"@semantic-release/npm": "^
|
|
58
|
-
"@semantic-release/release-notes-generator": "^14.
|
|
59
|
-
"
|
|
60
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
61
|
-
"husky": "^9.1.7",
|
|
62
|
-
"lint-staged": "^15.5.0",
|
|
50
|
+
"@semantic-release/git": "^11.0.1",
|
|
51
|
+
"@semantic-release/github": "^12.0.10",
|
|
52
|
+
"@semantic-release/npm": "^13.2.0",
|
|
53
|
+
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
54
|
+
"@types/node": "^24.19.2",
|
|
63
55
|
"ts-node": "^10.9.2",
|
|
64
|
-
"ts-node-dev": "^2.0.0"
|
|
56
|
+
"ts-node-dev": "^2.0.0",
|
|
57
|
+
"typescript": "^7.0.2"
|
|
65
58
|
},
|
|
66
59
|
"release": {
|
|
67
60
|
"branches": [
|
|
@@ -75,16 +68,5 @@
|
|
|
75
68
|
"@semantic-release/github",
|
|
76
69
|
"@semantic-release/release-notes-generator"
|
|
77
70
|
]
|
|
78
|
-
},
|
|
79
|
-
"lint-staged": {
|
|
80
|
-
"*.ts": [
|
|
81
|
-
"biome format --write",
|
|
82
|
-
"biome lint --write"
|
|
83
|
-
]
|
|
84
|
-
},
|
|
85
|
-
"commitlint": {
|
|
86
|
-
"extends": [
|
|
87
|
-
"@commitlint/config-conventional"
|
|
88
|
-
]
|
|
89
71
|
}
|
|
90
72
|
}
|
package/lib/src/app.js
CHANGED
|
@@ -10,7 +10,7 @@ const edit_1 = __importDefault(require("./commands/edit"));
|
|
|
10
10
|
const init_1 = __importDefault(require("./commands/init"));
|
|
11
11
|
const list_1 = __importDefault(require("./commands/list"));
|
|
12
12
|
const bootstrap = () => {
|
|
13
|
-
commander_1.program.description(
|
|
13
|
+
commander_1.program.description(package_json_1.description);
|
|
14
14
|
commander_1.program.version(package_json_1.version);
|
|
15
15
|
commander_1.program.option('-e, --edit', 'edit ~/.gitsurc with your EDITOR');
|
|
16
16
|
commander_1.program.option('-l, --list', 'list users stored in ~/.gitsurc');
|
package/lib/src/commands/init.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -20,19 +11,19 @@ const get_current_choice_1 = __importDefault(require("../functions/get-current-c
|
|
|
20
11
|
const save_git_config_1 = __importDefault(require("../functions/save-git-config"));
|
|
21
12
|
const choice_1 = require("../utils/choice");
|
|
22
13
|
const get_config_1 = __importDefault(require("../utils/get-config"));
|
|
23
|
-
exports.default = () =>
|
|
14
|
+
exports.default = async () => {
|
|
24
15
|
// Ensure ~/.gitsurc config exists
|
|
25
|
-
|
|
16
|
+
await (0, bootstrap_config_1.default)();
|
|
26
17
|
// Fetch configured gitsu users from config
|
|
27
|
-
const configResult =
|
|
18
|
+
const configResult = await (0, get_config_1.default)();
|
|
28
19
|
const users = configResult.config;
|
|
29
20
|
// Prompt for new user defaulting to the next choice in the list (maybe in the future we can sort by most recently used)
|
|
30
21
|
let answers;
|
|
31
22
|
try {
|
|
32
|
-
const currentChoice =
|
|
33
|
-
answers =
|
|
23
|
+
const currentChoice = await (0, get_current_choice_1.default)();
|
|
24
|
+
answers = await inquirer_1.default.prompt([
|
|
34
25
|
{
|
|
35
|
-
type: '
|
|
26
|
+
type: 'select',
|
|
36
27
|
name: 'user',
|
|
37
28
|
message: 'Which user would you like to use?',
|
|
38
29
|
choices: () => users.map((user) => (0, choice_1.formatChoice)(user)),
|
|
@@ -40,7 +31,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
40
31
|
},
|
|
41
32
|
]);
|
|
42
33
|
}
|
|
43
|
-
catch (
|
|
34
|
+
catch (_error) {
|
|
44
35
|
console.log(`\n${log_symbols_1.default.error} ${chalk_1.default.red('Switch aborted by user')}`);
|
|
45
36
|
}
|
|
46
37
|
// Save new user to git config
|
|
@@ -49,7 +40,7 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
49
40
|
return;
|
|
50
41
|
}
|
|
51
42
|
const user = (0, choice_1.parseChoice)(answers.user);
|
|
52
|
-
const saved =
|
|
43
|
+
const saved = await (0, save_git_config_1.default)(user);
|
|
53
44
|
if (!saved) {
|
|
54
45
|
throw new Error('Failed to save git config');
|
|
55
46
|
}
|
|
@@ -58,4 +49,4 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
58
49
|
catch (error) {
|
|
59
50
|
console.log(`${log_symbols_1.default.error} ${chalk_1.default.red('Failed to switch user')}`, error);
|
|
60
51
|
}
|
|
61
|
-
}
|
|
52
|
+
};
|
package/lib/src/commands/list.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -17,12 +8,12 @@ const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
|
17
8
|
const get_current_choice_1 = __importDefault(require("../functions/get-current-choice"));
|
|
18
9
|
const choice_1 = require("../utils/choice");
|
|
19
10
|
const get_config_1 = __importDefault(require("../utils/get-config"));
|
|
20
|
-
exports.default = () =>
|
|
11
|
+
exports.default = async () => {
|
|
21
12
|
try {
|
|
22
|
-
const configResult =
|
|
13
|
+
const configResult = await (0, get_config_1.default)();
|
|
23
14
|
const users = configResult.config;
|
|
24
|
-
const currentChoice =
|
|
25
|
-
users.
|
|
15
|
+
const currentChoice = await (0, get_current_choice_1.default)();
|
|
16
|
+
users.forEach((user) => {
|
|
26
17
|
if (currentChoice === (0, choice_1.formatChoice)(user)) {
|
|
27
18
|
console.log(`${log_symbols_1.default.success} ${(0, choice_1.formatChoice)(user)}`);
|
|
28
19
|
}
|
|
@@ -34,4 +25,4 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
34
25
|
catch (error) {
|
|
35
26
|
console.log(`${log_symbols_1.default.error} ${chalk_1.default.red('Failed to list configured gitsu users')}`, error);
|
|
36
27
|
}
|
|
37
|
-
}
|
|
28
|
+
};
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -20,14 +11,14 @@ const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
|
20
11
|
const choice_1 = require("../utils/choice");
|
|
21
12
|
const get_config_1 = __importDefault(require("../utils/get-config"));
|
|
22
13
|
const get_current_choice_1 = __importDefault(require("./get-current-choice"));
|
|
23
|
-
exports.default = () =>
|
|
14
|
+
exports.default = async () => {
|
|
24
15
|
try {
|
|
25
|
-
|
|
16
|
+
await (0, get_config_1.default)();
|
|
26
17
|
return true;
|
|
27
18
|
}
|
|
28
|
-
catch (
|
|
19
|
+
catch (_e) {
|
|
29
20
|
try {
|
|
30
|
-
const currentChoice =
|
|
21
|
+
const currentChoice = await (0, get_current_choice_1.default)();
|
|
31
22
|
const user = (0, choice_1.parseChoice)(currentChoice);
|
|
32
23
|
const configPath = node_path_1.default.join(node_os_1.default.homedir(), '/', '.gitsurc');
|
|
33
24
|
node_fs_1.default.writeFileSync(configPath, JSON.stringify([
|
|
@@ -44,4 +35,4 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
44
35
|
return false;
|
|
45
36
|
}
|
|
46
37
|
}
|
|
47
|
-
}
|
|
38
|
+
};
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -16,11 +7,11 @@ const node_child_process_1 = __importDefault(require("node:child_process"));
|
|
|
16
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
8
|
const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
18
9
|
const choice_1 = require("../utils/choice");
|
|
19
|
-
exports.default = () =>
|
|
10
|
+
exports.default = async () => {
|
|
20
11
|
try {
|
|
21
|
-
const gitUserEmail =
|
|
12
|
+
const gitUserEmail = await node_child_process_1.default.execSync('git config user.email');
|
|
22
13
|
const email = gitUserEmail.toString().trim();
|
|
23
|
-
const gitUserName =
|
|
14
|
+
const gitUserName = await node_child_process_1.default.execSync('git config user.name');
|
|
24
15
|
const name = gitUserName.toString().trim();
|
|
25
16
|
return (0, choice_1.formatChoice)({ name, email });
|
|
26
17
|
}
|
|
@@ -28,4 +19,4 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
28
19
|
console.error(`${log_symbols_1.default.error} ${chalk_1.default.red('Failed to fetch current git identity')}`, error);
|
|
29
20
|
return '';
|
|
30
21
|
}
|
|
31
|
-
}
|
|
22
|
+
};
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -16,13 +7,13 @@ const node_child_process_1 = require("node:child_process");
|
|
|
16
7
|
const node_util_1 = require("node:util");
|
|
17
8
|
const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
18
9
|
const execPromise = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
19
|
-
exports.default = (user) =>
|
|
10
|
+
exports.default = async (user) => {
|
|
20
11
|
try {
|
|
21
|
-
|
|
12
|
+
await execPromise(`git config --global user.name "${user.name}" && git config --global user.email "${user.email}"`);
|
|
22
13
|
return true;
|
|
23
14
|
}
|
|
24
15
|
catch (error) {
|
|
25
16
|
console.error(`${log_symbols_1.default.error} Failed to save git config`, error);
|
|
26
17
|
return false;
|
|
27
18
|
}
|
|
28
|
-
}
|
|
19
|
+
};
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
13
|
-
exports.default = () =>
|
|
14
|
-
const explorer = (0, cosmiconfig_1.cosmiconfig)('gitsu');
|
|
15
|
-
const result =
|
|
4
|
+
exports.default = async () => {
|
|
5
|
+
const explorer = (0, cosmiconfig_1.cosmiconfig)('gitsu', { searchStrategy: 'global' });
|
|
6
|
+
const result = await explorer.search();
|
|
16
7
|
if (!result)
|
|
17
8
|
throw new Error('Failed to find ~/.gitsurc configuration file');
|
|
18
9
|
return result;
|
|
19
|
-
}
|
|
10
|
+
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitsu-cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"description": "Interactive command line util for quickly & easily switching git users",
|
|
5
5
|
"author": "Jamie Weavis",
|
|
6
6
|
"homepage": "https://github.com/jamieweavis/gitsu#readme",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"packageManager": "pnpm@12.9.1",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=22.12"
|
|
11
|
+
},
|
|
8
12
|
"repository": {
|
|
9
13
|
"type": "git",
|
|
10
14
|
"url": "git+https://github.com/jamieweavis/gitsu.git"
|
|
@@ -29,39 +33,28 @@
|
|
|
29
33
|
"start": "node ./lib/src/app.js",
|
|
30
34
|
"dev": "ts-node-dev --respawn ./src/app.ts",
|
|
31
35
|
"build": "tsc",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"format": "biome format src",
|
|
35
|
-
"format:write": "npm run format -- --write",
|
|
36
|
-
"prepare": "husky"
|
|
36
|
+
"check": "biome check src",
|
|
37
|
+
"check:write": "pnpm check -- --write"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"cosmiconfig": "^8.3.6",
|
|
45
|
-
"inquirer": "^12.5.0",
|
|
46
|
-
"log-symbols": "^7.0.0",
|
|
47
|
-
"typescript": "^5.8.2"
|
|
40
|
+
"chalk": "^6.0.1",
|
|
41
|
+
"commander": "^15.0.0",
|
|
42
|
+
"cosmiconfig": "^10.0.1",
|
|
43
|
+
"inquirer": "^14.2.3",
|
|
44
|
+
"log-symbols": "^7.0.1"
|
|
48
45
|
},
|
|
49
46
|
"devDependencies": {
|
|
50
|
-
"@biomejs/biome": "^
|
|
51
|
-
"@
|
|
52
|
-
"@commitlint/config-conventional": "^19.8.0",
|
|
53
|
-
"@semantic-release/changelog": "^6.0.3",
|
|
47
|
+
"@biomejs/biome": "^2.5.15",
|
|
48
|
+
"@semantic-release/changelog": "^7.0.0",
|
|
54
49
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
55
|
-
"@semantic-release/git": "^
|
|
56
|
-
"@semantic-release/github": "^
|
|
57
|
-
"@semantic-release/npm": "^
|
|
58
|
-
"@semantic-release/release-notes-generator": "^14.
|
|
59
|
-
"
|
|
60
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
61
|
-
"husky": "^9.1.7",
|
|
62
|
-
"lint-staged": "^15.5.0",
|
|
50
|
+
"@semantic-release/git": "^11.0.1",
|
|
51
|
+
"@semantic-release/github": "^12.0.10",
|
|
52
|
+
"@semantic-release/npm": "^13.2.0",
|
|
53
|
+
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
54
|
+
"@types/node": "^24.19.2",
|
|
63
55
|
"ts-node": "^10.9.2",
|
|
64
|
-
"ts-node-dev": "^2.0.0"
|
|
56
|
+
"ts-node-dev": "^2.0.0",
|
|
57
|
+
"typescript": "^7.0.2"
|
|
65
58
|
},
|
|
66
59
|
"release": {
|
|
67
60
|
"branches": [
|
|
@@ -75,16 +68,5 @@
|
|
|
75
68
|
"@semantic-release/github",
|
|
76
69
|
"@semantic-release/release-notes-generator"
|
|
77
70
|
]
|
|
78
|
-
},
|
|
79
|
-
"lint-staged": {
|
|
80
|
-
"*.ts": [
|
|
81
|
-
"biome format --write",
|
|
82
|
-
"biome lint --write"
|
|
83
|
-
]
|
|
84
|
-
},
|
|
85
|
-
"commitlint": {
|
|
86
|
-
"extends": [
|
|
87
|
-
"@commitlint/config-conventional"
|
|
88
|
-
]
|
|
89
71
|
}
|
|
90
72
|
}
|
package/src/app.ts
CHANGED
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { program } from 'commander';
|
|
4
4
|
|
|
5
|
-
import { version } from '../package.json';
|
|
5
|
+
import { description, version } from '../package.json';
|
|
6
6
|
import edit from './commands/edit';
|
|
7
7
|
import init from './commands/init';
|
|
8
8
|
import list from './commands/list';
|
|
9
9
|
|
|
10
10
|
const bootstrap = () => {
|
|
11
|
-
program.description(
|
|
12
|
-
'Command line util for quickly & easily switching git identities',
|
|
13
|
-
);
|
|
11
|
+
program.description(description);
|
|
14
12
|
program.version(version);
|
|
15
13
|
program.option('-e, --edit', 'edit ~/.gitsurc with your EDITOR');
|
|
16
14
|
program.option('-l, --list', 'list users stored in ~/.gitsurc');
|
package/src/commands/init.ts
CHANGED
|
@@ -21,16 +21,16 @@ export default async () => {
|
|
|
21
21
|
let answers: { user: string } | undefined;
|
|
22
22
|
try {
|
|
23
23
|
const currentChoice = await getCurrentChoice();
|
|
24
|
-
answers = await inquirer.prompt([
|
|
24
|
+
answers = await inquirer.prompt<{ user: string }>([
|
|
25
25
|
{
|
|
26
|
-
type: '
|
|
26
|
+
type: 'select',
|
|
27
27
|
name: 'user',
|
|
28
28
|
message: 'Which user would you like to use?',
|
|
29
29
|
choices: () => users.map((user: IUser) => formatChoice(user)),
|
|
30
30
|
default: defaultChoice(users, currentChoice || users[0]),
|
|
31
31
|
},
|
|
32
32
|
]);
|
|
33
|
-
} catch (
|
|
33
|
+
} catch (_error) {
|
|
34
34
|
console.log(`\n${logSymbols.error} ${chalk.red('Switch aborted by user')}`);
|
|
35
35
|
}
|
|
36
36
|
|
package/src/commands/list.ts
CHANGED
|
@@ -12,7 +12,7 @@ export default async () => {
|
|
|
12
12
|
const users = configResult.config;
|
|
13
13
|
const currentChoice = await getCurrentChoice();
|
|
14
14
|
|
|
15
|
-
users.
|
|
15
|
+
users.forEach((user: IUser) => {
|
|
16
16
|
if (currentChoice === formatChoice(user)) {
|
|
17
17
|
console.log(`${logSymbols.success} ${formatChoice(user)}`);
|
|
18
18
|
} else {
|
package/src/utils/get-config.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { cosmiconfig } from 'cosmiconfig';
|
|
2
|
-
import { name } from '../../package.json';
|
|
3
2
|
|
|
4
3
|
export default async () => {
|
|
5
|
-
const explorer = cosmiconfig('gitsu');
|
|
4
|
+
const explorer = cosmiconfig('gitsu', { searchStrategy: 'global' });
|
|
6
5
|
const result = await explorer.search();
|
|
7
6
|
if (!result) throw new Error('Failed to find ~/.gitsurc configuration file');
|
|
8
7
|
return result;
|
package/tsconfig.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
12
|
|
|
13
13
|
/* Language and Environment */
|
|
14
|
-
"target": "
|
|
14
|
+
"target": "es2024" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
15
|
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
16
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
17
|
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
32
32
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
33
33
|
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
|
|
34
|
-
|
|
34
|
+
"types": ["node"] /* Specify type package names to be included without being referenced in a source file. */,
|
|
35
35
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
36
36
|
"resolveJsonModule": true /* Enable importing .json files */,
|
|
37
37
|
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
name: build
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [main]
|
|
8
|
-
|
|
9
|
-
permissions:
|
|
10
|
-
contents: write
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
build:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v4
|
|
17
|
-
- uses: actions/setup-node@v4
|
|
18
|
-
with:
|
|
19
|
-
node-version: 22
|
|
20
|
-
- run: npm ci
|
|
21
|
-
- run: npm run build
|
|
22
|
-
- run: npm run lint
|
|
23
|
-
|
|
24
|
-
release:
|
|
25
|
-
needs: [build]
|
|
26
|
-
runs-on: ubuntu-latest
|
|
27
|
-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
28
|
-
steps:
|
|
29
|
-
- uses: actions/checkout@v4
|
|
30
|
-
- uses: actions/setup-node@v4
|
|
31
|
-
with:
|
|
32
|
-
node-version: 22
|
|
33
|
-
- run: npm ci
|
|
34
|
-
- run: npm run build
|
|
35
|
-
- run: npx semantic-release
|
|
36
|
-
env:
|
|
37
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
38
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
39
|
-
HUSKY: 0
|
package/.husky/commit-msg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npx --no -- commitlint --edit "$1"
|
package/.husky/pre-commit
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npx --no -- lint-staged
|
package/.husky/pre-push
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm run lint && npm run build
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v22
|