Skip to content

Commit a60cacd

Browse files
authored
chore: update dependencies and optimize storage migration (#3)
1 parent 5228f8a commit a60cacd

File tree

8 files changed

+81
-69
lines changed

8 files changed

+81
-69
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
"dependencies": {
4747
"chalk": "^4.1.2",
48-
"commander": "^11.1.0",
48+
"commander": "^13.1.0",
4949
"execa": "^5.1.1",
5050
"external-editor": "^3.1.0",
5151
"fs-extra": "^11.3.0",
@@ -55,12 +55,13 @@
5555
"simple-git": "^3.27.0"
5656
},
5757
"devDependencies": {
58-
"@biomejs/biome": "1.5.3",
58+
"@biomejs/biome": "^1.9.4",
5959
"@types/fs-extra": "^11.0.4",
6060
"@types/node": "^20.11.24",
6161
"@types/prompts": "^2.4.9",
6262
"pkg": "^5.8.1",
6363
"tsup": "^8.0.2",
64+
"type-fest": "^4.39.1",
6465
"typescript": "^5.3.3",
6566
"vitest": "^1.3.1"
6667
},

pnpm-lock.yaml

Lines changed: 61 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/tests/test-utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { join } from 'node:path';
2-
import execa, { Options } from 'execa';
2+
import execa, { type Options } from 'execa';
33
import { testEnvironment } from './test-environment';
44

55
export const CLI_PATH = join(__dirname, '../../../dist/index.js');
66

77
export async function runCLI(command: string, options?: Options): Promise<execa.ExecaChildProcess>;
88
export async function runCLI(command: string, args: string[], options?: Options): Promise<execa.ExecaChildProcess>;
9-
export async function runCLI(command: string, argsOrOptions?: string[] | Options, options?: Options): Promise<execa.ExecaChildProcess> {
9+
export async function runCLI(
10+
command: string,
11+
argsOrOptions?: string[] | Options,
12+
options?: Options
13+
): Promise<execa.ExecaChildProcess> {
1014
const isArrayArgs = Array.isArray(argsOrOptions);
1115
const execaOptions = isArrayArgs ? options : argsOrOptions;
1216
const args = isArrayArgs ? argsOrOptions : [];

src/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
#!/usr/bin/env node
2-
import { Command } from 'commander';
2+
import { program } from 'commander';
33
import * as command from './commands/index.js';
4-
import { getPackageInfo } from './utils/get-package-info.js';
54
import { storage } from './utils/storage.js';
65

76
(async () => {
8-
const program = new Command();
9-
107
await storage.initializeRefs();
118

12-
const packageInfo = getPackageInfo();
13-
14-
program.name('git-intent').description(packageInfo.description).version(packageInfo.version);
15-
169
program
1710
.addCommand(command.add)
1811
.addCommand(command.list)

src/utils/get-package-info.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
23
import fs from 'fs-extra';
34
import type { PackageJson } from 'type-fest';
45

56
export function getPackageInfo(): PackageJson & { version: string; description: string } {
6-
const packageJsonPath = path.join('package.json');
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
10+
const packageJsonPath = path.join(__dirname, '..', 'package.json');
711

812
return fs.readJSONSync(packageJsonPath);
913
}

src/utils/storage.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@ export class GitIntentionalCommitStorage {
9090
try {
9191
const result = await git.cwd(root).show(`${this.REFS_PREFIX}/commits:${this.storageFilename}`);
9292
const data = this.migrateData(JSON.parse(result));
93+
94+
console.log(data);
9395
return data.commits;
9496
} catch {
9597
const commitsFile = await this.getCommitsFile();
9698
const data = this.migrateData(await fs.readJSON(commitsFile));
99+
console.log(data);
97100
return data.commits;
98101
}
99102
}

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"$schema": "https://json.schemastore.org/tsconfig",
33
"compilerOptions": {
4-
"moduleResolution": "node",
54
"resolveJsonModule": true,
65
"strict": true,
76
"strictNullChecks": true,
87
"noEmit": true,
98
"esModuleInterop": true,
109
"skipDefaultLibCheck": true,
1110
"skipLibCheck": true,
11+
"module": "node16",
12+
"moduleResolution": "node16",
1213
"paths": {
1314
"@/*": ["./src/*"]
1415
}

tsup.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@ import { defineConfig } from 'tsup';
33
export default defineConfig({
44
entry: ['src/index.ts'],
55
format: ['esm'],
6-
clean: true,
7-
minify: true,
8-
shims: true,
96
});

0 commit comments

Comments
 (0)