vona-cli-set-api 1.0.364 → 1.0.368

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.
@@ -19,9 +19,9 @@
19
19
  },
20
20
  "./package.json": "./package.json"
21
21
  },
22
- "description": "<%=argv.description%>",
22
+ "description": "",
23
23
  "keywords": ["Vona Module"],
24
- "author": "<%=argv.author%>",
24
+ "author": "",
25
25
  "files": [
26
26
  "assets",
27
27
  "dist"
@@ -46,7 +46,7 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "vona": "^5.0.209"
49
+ "vona": "^5.0.211"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@cabloy/lint": "^5.0.16",
@@ -94,7 +94,7 @@ export default function (appInfo: VonaAppInfo, env: VonaConfigEnv) {
94
94
  this.bean.logger.makeTransportFile(clientInfo, 'http', 'http'),
95
95
  this.bean.logger.makeTransportFile(clientInfo, 'combined'),
96
96
  this.bean.logger.makeTransportConsole(clientInfo),
97
- ].filter(item => !!item);
97
+ ];
98
98
  return { transports };
99
99
  },
100
100
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-home-index",
3
3
  "type": "module",
4
- "version": "5.0.10",
4
+ "version": "5.0.11",
5
5
  "title": "home-index",
6
6
  "vonaModule": {
7
7
  "dependencies": {
@@ -7,7 +7,7 @@ export class MetaPrintTip extends BeanBase implements IMetaPrintTipExecute {
7
7
  async execute(): Promise<TypeMetaPrintTipResult> {
8
8
  return {
9
9
  title: 'home',
10
- message: this.app.util.getAbsoluteUrl(),
10
+ message: this.bean.core.getAbsoluteUrl(),
11
11
  };
12
12
  }
13
13
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-suite-a-home",
3
3
  "type": "module",
4
- "version": "5.0.22",
4
+ "version": "5.0.23",
5
5
  "title": "a-home",
6
6
  "description": "",
7
7
  "author": "zhennann",
@@ -4,7 +4,7 @@
4
4
  "version": "5.0.0",
5
5
  "title": "<%=argv.suiteInfo.relativeName%>",
6
6
  "files": [],
7
- "description": "<%=argv.description%>",
8
- "author": "<%=argv.author%>",
7
+ "description": "",
8
+ "author": "",
9
9
  "dependencies": {}
10
10
  }
@@ -36,6 +36,7 @@ export class CliBinDev extends BeanCliBase {
36
36
  execArgs: [getImportEsm()],
37
37
  // execArgs: ['--experimental-transform-types', getImportEsm(), '--trace-deprecation'],
38
38
  // signal: 'SIGHUP',
39
+ ignore: ['test/**/*.test.ts', 'src/backend/play'],
39
40
  });
40
41
  nodemon.on('quit', () => {
41
42
  resolve(undefined);
@@ -5,10 +5,12 @@ declare module '@cabloy/cli' {
5
5
  mode?: VonaMetaMode;
6
6
  flavor?: VonaMetaFlavor;
7
7
  retainRuntime?: boolean;
8
+ attach?: boolean;
8
9
  }
9
10
  }
10
11
  export declare class CliBinPlay extends BeanCliBase {
11
12
  execute(): Promise<void>;
12
13
  _play(projectPath: string): Promise<void>;
13
- _run(projectPath: string): Promise<void>;
14
+ _runAttach(projectPath: string): Promise<void>;
15
+ _runIsolate(projectPath: string): Promise<void>;
14
16
  }
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { BeanCliBase } from '@cabloy/cli';
3
3
  import fse from 'fs-extra';
4
- import { getImportEsm } from "../utils.js";
4
+ import { getImportEsm, loadJSONFile } from "../utils.js";
5
5
  import { generateVonaMeta } from "./toolsBin/generateVonaMeta.js";
6
6
  export class CliBinPlay extends BeanCliBase {
7
7
  async execute() {
@@ -25,9 +25,49 @@ export class CliBinPlay extends BeanCliBase {
25
25
  };
26
26
  await generateVonaMeta(configMeta, configOptions);
27
27
  }
28
- await this._run(projectPath);
28
+ if (argv.attach) {
29
+ await this._runAttach(projectPath);
30
+ }
31
+ else {
32
+ await this._runIsolate(projectPath);
33
+ }
34
+ }
35
+ async _runAttach(projectPath) {
36
+ const runtimeFile = path.join(projectPath, '.app/runtime/-.json');
37
+ if (!fse.existsSync(runtimeFile))
38
+ throw new Error('dev server not running');
39
+ // args
40
+ let args = [];
41
+ const pos = process.argv.indexOf(':bin:play');
42
+ if (pos > -1) {
43
+ args = args.concat(process.argv.slice(pos + 1));
44
+ }
45
+ const body = { args, projectPath };
46
+ //
47
+ const runtime = await loadJSONFile(runtimeFile);
48
+ const runtimeCore = runtime['a-core'];
49
+ const runtimeUser = runtime['a-user'];
50
+ const result = await fetch(`${runtimeCore.protocol}://${runtimeCore.host}/api/play`, {
51
+ method: 'post',
52
+ headers: {
53
+ 'content-type': 'application/json',
54
+ 'authorization': `Bearer ${runtimeUser.accessToken}`,
55
+ },
56
+ body: JSON.stringify(body),
57
+ });
58
+ if (result.status !== 200) {
59
+ const message = `error: ${result.status}, ${result.statusText}`;
60
+ throw new Error(message);
61
+ }
62
+ const res = await result.json();
63
+ if (res.code !== 0)
64
+ throw new Error(res.message);
65
+ if (res.data !== undefined) {
66
+ // eslint-disable-next-line no-console
67
+ console.log(res.data);
68
+ }
29
69
  }
30
- async _run(projectPath) {
70
+ async _runIsolate(projectPath) {
31
71
  // testFile
32
72
  let testFile = path.join(import.meta.dirname, './toolsBin/play.ts');
33
73
  if (!fse.existsSync(testFile)) {
@@ -17,6 +17,7 @@ const __template = `import type { IArgv, VonaApplication } from 'vona';
17
17
  export async function main(app: VonaApplication, _argv: IArgv) {
18
18
  console.log(import.meta.filename);
19
19
  console.log(app.config.meta);
20
+ return 'Hello VonaJS';
20
21
  }
21
22
  `;
22
23
  const projectPath = process.argv[2];
@@ -40,7 +41,11 @@ async function playRun(projectPath) {
40
41
  }
41
42
  // run
42
43
  const playInstance = await import(__rewriteRelativeImportExtension(pathToHref(playFile)));
43
- await playInstance.main(app, argv);
44
+ const res = await playInstance.main(app, argv);
45
+ if (res !== undefined) {
46
+ // eslint-disable-next-line no-console
47
+ console.log(res);
48
+ }
44
49
  // close
45
50
  await app.close();
46
51
  // handles
@@ -18,6 +18,11 @@ declare const _default: {
18
18
  description: string;
19
19
  type: string;
20
20
  };
21
+ attach: {
22
+ alias: string;
23
+ description: string;
24
+ type: string;
25
+ };
21
26
  };
22
27
  };
23
28
  export default _default;
@@ -3,7 +3,7 @@ export default {
3
3
  info: {
4
4
  version: '5.0.0',
5
5
  title: 'Cli: Bin: Play',
6
- usage: 'vona :bin:play [index.ts] [--flavor=] [--retainRuntime=]',
6
+ usage: 'vona :bin:play [index.ts] [--flavor=] [--retainRuntime=] [--attach]',
7
7
  },
8
8
  options: {
9
9
  mode: {
@@ -18,5 +18,10 @@ export default {
18
18
  description: 'retainRuntime',
19
19
  type: 'boolean',
20
20
  },
21
+ attach: {
22
+ alias: 'a',
23
+ description: 'attach',
24
+ type: 'boolean',
25
+ },
21
26
  },
22
27
  };
@@ -7,6 +7,7 @@ declare const _default: {
7
7
  };
8
8
  options: {
9
9
  module: {
10
+ alias: string;
10
11
  description: string;
11
12
  type: string;
12
13
  };
@@ -7,6 +7,7 @@ export default {
7
7
  },
8
8
  options: {
9
9
  module: {
10
+ alias: 'm',
10
11
  description: 'module name',
11
12
  type: 'string',
12
13
  },
@@ -30,14 +30,6 @@ declare const _default: {
30
30
  type: string;
31
31
  message: string;
32
32
  };
33
- description: {
34
- type: string;
35
- message: string;
36
- };
37
- author: {
38
- type: string;
39
- message: string;
40
- };
41
33
  };
42
34
  };
43
35
  };
@@ -30,14 +30,6 @@ export default {
30
30
  type: 'input',
31
31
  message: 'suite name',
32
32
  },
33
- description: {
34
- type: 'input',
35
- message: 'module description',
36
- },
37
- author: {
38
- type: 'input',
39
- message: 'module author',
40
- },
41
33
  },
42
34
  },
43
35
  },
@@ -17,14 +17,6 @@ declare const _default: {
17
17
  };
18
18
  required: boolean;
19
19
  };
20
- description: {
21
- type: string;
22
- message: string;
23
- };
24
- author: {
25
- type: string;
26
- message: string;
27
- };
28
20
  };
29
21
  };
30
22
  };
@@ -17,14 +17,6 @@ export default {
17
17
  },
18
18
  required: true,
19
19
  },
20
- description: {
21
- type: 'input',
22
- message: 'suite description',
23
- },
24
- author: {
25
- type: 'input',
26
- message: 'suite author',
27
- },
28
20
  },
29
21
  },
30
22
  },
@@ -108,6 +108,11 @@ export declare const commands: {
108
108
  description: string;
109
109
  type: string;
110
110
  };
111
+ attach: {
112
+ alias: string;
113
+ description: string;
114
+ type: string;
115
+ };
111
116
  };
112
117
  };
113
118
  test: {
@@ -163,14 +168,6 @@ export declare const commands: {
163
168
  };
164
169
  required: boolean;
165
170
  };
166
- description: {
167
- type: string;
168
- message: string;
169
- };
170
- author: {
171
- type: string;
172
- message: string;
173
- };
174
171
  };
175
172
  };
176
173
  };
@@ -207,14 +204,6 @@ export declare const commands: {
207
204
  type: string;
208
205
  message: string;
209
206
  };
210
- description: {
211
- type: string;
212
- message: string;
213
- };
214
- author: {
215
- type: string;
216
- message: string;
217
- };
218
207
  };
219
208
  };
220
209
  };
@@ -272,6 +261,7 @@ export declare const commands: {
272
261
  };
273
262
  options: {
274
263
  module: {
264
+ alias: string;
275
265
  description: string;
276
266
  type: string;
277
267
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-cli-set-api",
3
3
  "type": "module",
4
- "version": "1.0.364",
4
+ "version": "1.0.368",
5
5
  "description": "vona cli-set-api",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -31,7 +31,7 @@
31
31
  "@babel/plugin-proposal-decorators": "^7.25.9",
32
32
  "@babel/plugin-transform-class-properties": "^7.25.9",
33
33
  "@babel/plugin-transform-typescript": "^7.26.8",
34
- "@cabloy/cli": "^3.0.58",
34
+ "@cabloy/cli": "^3.0.60",
35
35
  "@cabloy/dotenv": "^1.1.10",
36
36
  "@cabloy/extend": "^3.1.10",
37
37
  "@cabloy/module-glob": "^5.2.32",
@@ -61,9 +61,9 @@
61
61
  "ts-node-maintained": "^10.9.6",
62
62
  "urllib": "^4.6.11",
63
63
  "uuid": "^11.1.0",
64
- "vona-core": "^5.0.97",
64
+ "vona-core": "^5.0.98",
65
65
  "why-is-node-running": "^3.2.2",
66
- "yargs-parser": "^21.1.1"
66
+ "yargs-parser": "^22.0.0"
67
67
  },
68
68
  "gitHead": "0eab9dc4a5622caffe89e7b1b3f02c08ccbc4c4b",
69
69
  "scripts": {