@mitsein-ai/cli 0.1.0 → 0.1.1
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/dist/index.js +142 -130
- package/package.json +4 -4
- package/src/commands/version.ts +4 -2
- package/src/core/credentials.ts +12 -8
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"consola": "^3.4.2",
|
|
8
8
|
"ofetch": "^1.4.1"
|
|
9
9
|
},
|
|
10
|
-
"description": "Mitsein CLI
|
|
10
|
+
"description": "Mitsein CLI — dev tooling, API helpers, and workflow automation",
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@types/bun": "latest",
|
|
13
13
|
"typescript": "^5.3.3"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
|
-
"
|
|
16
|
+
"node": ">=20.0.0"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"src",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"url": "https://gitee.com/mitsein/mitsein.git"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
-
"build": "bun build ./src/index.ts --outdir=dist --target=
|
|
42
|
+
"build": "bun build ./src/index.ts --outdir=dist --target=node --minify",
|
|
43
43
|
"prepublishOnly": "bun run typecheck && bun test && bun run build",
|
|
44
44
|
"test": "bun test",
|
|
45
45
|
"typecheck": "tsc --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"type": "module",
|
|
48
|
-
"version": "0.1.
|
|
48
|
+
"version": "0.1.1"
|
|
49
49
|
}
|
package/src/commands/version.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
3
4
|
import { emit } from '../core/output.js';
|
|
4
5
|
|
|
5
6
|
export function getPackageVersion(): string {
|
|
6
|
-
const
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const pkgPath = join(__dirname, '..', '..', 'package.json');
|
|
7
9
|
try {
|
|
8
10
|
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version?: string };
|
|
9
11
|
return pkg.version ?? '0.1.0-dev';
|
package/src/core/credentials.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface ResolveCredentialsOptions {
|
|
|
14
14
|
profile?: string | undefined;
|
|
15
15
|
real?: boolean | undefined;
|
|
16
16
|
projectRoot?: string | undefined;
|
|
17
|
-
/** Injected for tests
|
|
17
|
+
/** Injected for tests. */
|
|
18
18
|
spawnDevToken?: typeof runDevTokenScript;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -56,17 +56,21 @@ function findDevTokenScript(projectRoot: string | undefined): string | null {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function runDevTokenScript(scriptPath: string, real: boolean): { ok: boolean; stdout: string } {
|
|
59
|
+
const { execFileSync } = require('node:child_process') as typeof import('node:child_process');
|
|
59
60
|
const args = [scriptPath, '--raw'];
|
|
60
61
|
if (real) {
|
|
61
62
|
args.push('--real');
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
try {
|
|
65
|
+
const stdout = execFileSync('bash', args, {
|
|
66
|
+
timeout: 10_000,
|
|
67
|
+
encoding: 'utf8',
|
|
68
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
69
|
+
}).trim();
|
|
70
|
+
return { ok: stdout.length > 0, stdout };
|
|
71
|
+
} catch {
|
|
72
|
+
return { ok: false, stdout: '' };
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
function loadExplicit(token: string | undefined, endpoint: string | undefined): Credentials | null {
|
package/src/index.ts
CHANGED