vona-cli 1.0.376 → 1.0.377
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/bin/vona.js +4 -5
- package/dist/play.d.ts +1 -0
- package/dist/play.js +33 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +5 -0
- package/package.json +1 -1
package/dist/bin/vona.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { ProcessHelper } from '@cabloy/process-helper';
|
|
4
4
|
import fse from 'fs-extra';
|
|
5
5
|
import semver from 'semver';
|
|
6
|
-
import {
|
|
6
|
+
import { playAttach } from "../play.js";
|
|
7
7
|
const pnpm_version = '10.19.0';
|
|
8
8
|
const processHelper = new ProcessHelper(process.cwd());
|
|
9
9
|
main();
|
|
@@ -36,9 +36,9 @@ async function main() {
|
|
|
36
36
|
const isPlayAttach = isPlay && (rawArgv.includes('-a') || rawArgv.includes('--attach'));
|
|
37
37
|
if (isPlay) {
|
|
38
38
|
if (!isPlayAttach) {
|
|
39
|
-
args.
|
|
39
|
+
args = args.concat([bootstrapFile, ':bin:play']);
|
|
40
40
|
}
|
|
41
|
-
args = args.concat(
|
|
41
|
+
args = args.concat(rawArgv.slice(1)).concat(['--dummy']);
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
44
44
|
args.push(bootstrapFile);
|
|
@@ -46,8 +46,7 @@ async function main() {
|
|
|
46
46
|
}
|
|
47
47
|
// run
|
|
48
48
|
if (isPlayAttach) {
|
|
49
|
-
|
|
50
|
-
await command.start();
|
|
49
|
+
await playAttach(process.cwd(), args);
|
|
51
50
|
}
|
|
52
51
|
else {
|
|
53
52
|
if (!isPlay) {
|
package/dist/play.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function playAttach(projectPath: string, args: string[]): Promise<void>;
|
package/dist/play.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import { loadJSONFile } from "./utils.js";
|
|
4
|
+
export async function playAttach(projectPath, args) {
|
|
5
|
+
const runtimeFile = path.join(projectPath, '.app/runtime/-.json');
|
|
6
|
+
if (!fse.existsSync(runtimeFile))
|
|
7
|
+
throw new Error('dev server not running');
|
|
8
|
+
// body
|
|
9
|
+
const body = { args, projectPath };
|
|
10
|
+
//
|
|
11
|
+
const runtime = await loadJSONFile(runtimeFile);
|
|
12
|
+
const runtimeCore = runtime['a-core'];
|
|
13
|
+
const runtimeUser = runtime['a-user'];
|
|
14
|
+
const result = await fetch(`${runtimeCore?.protocol}://${runtimeCore?.host}/api/play`, {
|
|
15
|
+
method: 'post',
|
|
16
|
+
headers: {
|
|
17
|
+
'content-type': 'application/json',
|
|
18
|
+
'authorization': `Bearer ${runtimeUser?.accessToken}`,
|
|
19
|
+
},
|
|
20
|
+
body: JSON.stringify(body),
|
|
21
|
+
});
|
|
22
|
+
if (result.status !== 200) {
|
|
23
|
+
const message = `error: ${result.status}, ${result.statusText}`;
|
|
24
|
+
throw new Error(message);
|
|
25
|
+
}
|
|
26
|
+
const res = await result.json();
|
|
27
|
+
if (res.code !== 0)
|
|
28
|
+
throw new Error(res.message);
|
|
29
|
+
if (res.data !== undefined) {
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
31
|
+
console.log(res.data);
|
|
32
|
+
}
|
|
33
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadJSONFile(fileName: string): Promise<any>;
|
package/dist/utils.js
ADDED