@delegance/claude-autopilot 1.2.0 → 1.2.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/bin/autopilot.js +11 -6
- package/package.json +1 -1
- package/src/cli/detector.ts +5 -1
- package/src/cli/hook.ts +2 -2
- package/src/cli/setup.ts +1 -1
package/bin/autopilot.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Thin launcher that uses tsx to run the TypeScript CLI entry point.
|
|
3
|
-
// This is what `npx autopilot` resolves to — it hands off to tsx so TypeScript
|
|
4
|
-
// source can execute without a separate build step during alpha.
|
|
5
|
-
import { createRequire } from 'node:module';
|
|
6
2
|
import { fileURLToPath } from 'node:url';
|
|
7
3
|
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
8
5
|
import * as path from 'node:path';
|
|
9
6
|
|
|
10
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
const tsxBin = path.resolve(__dirname, '..', 'node_modules', '.bin', 'tsx');
|
|
12
8
|
const entrypoint = path.resolve(__dirname, '..', 'src', 'cli', 'index.ts');
|
|
13
9
|
|
|
14
|
-
|
|
10
|
+
// Locate tsx: own node_modules (dev) → consumer's node_modules/.bin → PATH
|
|
11
|
+
function findTsx() {
|
|
12
|
+
const own = path.resolve(__dirname, '..', 'node_modules', '.bin', 'tsx');
|
|
13
|
+
if (fs.existsSync(own)) return own;
|
|
14
|
+
const consumer = path.resolve(__dirname, '..', '..', '..', '.bin', 'tsx');
|
|
15
|
+
if (fs.existsSync(consumer)) return consumer;
|
|
16
|
+
return 'tsx';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const result = spawnSync(findTsx(), [entrypoint, ...process.argv.slice(2)], { stdio: 'inherit' });
|
|
15
20
|
process.exit(result.status ?? 1);
|
package/package.json
CHANGED
package/src/cli/detector.ts
CHANGED
|
@@ -24,10 +24,14 @@ function fileContains(filePath: string, needle: string): boolean {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const DEFAULT_TEST_PLACEHOLDER = /^echo .error: no test specified/i;
|
|
28
|
+
|
|
27
29
|
function nodeTestCommand(cwd: string): string {
|
|
28
30
|
const pkg = readJson(path.join(cwd, 'package.json'));
|
|
29
31
|
const scripts = pkg?.['scripts'] as Record<string, string> | undefined;
|
|
30
|
-
|
|
32
|
+
const cmd = scripts?.['test'];
|
|
33
|
+
if (!cmd || DEFAULT_TEST_PLACEHOLDER.test(cmd)) return 'npm test';
|
|
34
|
+
return cmd;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
export function detectProject(cwd: string): DetectionResult {
|
package/src/cli/hook.ts
CHANGED
|
@@ -28,13 +28,13 @@ function findGitDir(cwd: string): string | null {
|
|
|
28
28
|
|
|
29
29
|
export async function runHook(
|
|
30
30
|
sub: string,
|
|
31
|
-
options: { cwd?: string; force?: boolean } = {},
|
|
31
|
+
options: { cwd?: string; force?: boolean; silent?: boolean } = {},
|
|
32
32
|
): Promise<number> {
|
|
33
33
|
const cwd = options.cwd ?? process.cwd();
|
|
34
34
|
const gitDir = findGitDir(cwd);
|
|
35
35
|
|
|
36
36
|
if (!gitDir) {
|
|
37
|
-
console.error('[hook] not inside a git repository');
|
|
37
|
+
if (!options.silent) console.error('[hook] not inside a git repository');
|
|
38
38
|
return 1;
|
|
39
39
|
}
|
|
40
40
|
|
package/src/cli/setup.ts
CHANGED
|
@@ -70,7 +70,7 @@ export async function runSetup(options: SetupOptions = {}): Promise<void> {
|
|
|
70
70
|
console.log(` ${PASS} Created autopilot.config.yaml`);
|
|
71
71
|
|
|
72
72
|
if (!options.skipHook) {
|
|
73
|
-
const hookCode = await runHook('install', { cwd });
|
|
73
|
+
const hookCode = await runHook('install', { cwd, silent: true });
|
|
74
74
|
if (hookCode === 0) {
|
|
75
75
|
console.log(` ${PASS} Installed pre-push git hook`);
|
|
76
76
|
} else {
|