vona-cli-set-api 1.1.100 → 1.1.101

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 CHANGED
@@ -25,10 +25,6 @@ import { catchError, combineApiPathControllerAndActionRaw, replaceTemplate } fro
25
25
  import { getOnionScenesMeta, getOnionMetasMeta, relativeNameToCapitalize } from '@cabloy/module-info';
26
26
  import { toUpperCaseFirstChar, stringToCapitalize, replaceTemplate as replaceTemplate$1 } from '@cabloy/word-utils';
27
27
  import fs from 'node:fs';
28
- import compressing from 'compressing';
29
- import randomize from 'randomatic';
30
- import urllib from 'urllib';
31
- import * as uuid from 'uuid';
32
28
  import { beanFullNameFromOnionName } from 'vona-core';
33
29
 
34
30
  function getEnvMeta(configMeta) {
@@ -1214,128 +1210,6 @@ class CliCreateModule extends BeanCliBase {
1214
1210
  }
1215
1211
  }
1216
1212
 
1217
- class CliCreateProject extends BeanCliBase {
1218
- constructor(options) {
1219
- super(options);
1220
- this.httpClient = void 0;
1221
- this.httpClient = urllib;
1222
- }
1223
- async execute() {
1224
- const {
1225
- argv
1226
- } = this.context;
1227
- // super
1228
- await super.execute();
1229
- // noformat
1230
- // argv.noformat = true;
1231
- // project name
1232
- const projectName = argv.name;
1233
- // target dir
1234
- const targetDir = path.join(argv.projectPath, projectName);
1235
- if (!argv.force && fs.existsSync(targetDir)) {
1236
- throw new Error(`project exists: ${projectName}`);
1237
- }
1238
- fse.ensureDirSync(targetDir);
1239
- // vars
1240
- argv.SERVER_KEYS = `vona_${uuid.v4()}_${Date.now()}_${random(100, 10000)}`;
1241
- argv.SERVER_KEYS_PROD = `vona_${uuid.v4()}_${Date.now()}_${random(100, 10000)}`;
1242
- argv.DATABASE_CLIENT_MYSQL_USER = 'web_user';
1243
- argv.DATABASE_CLIENT_MYSQL_PASSWORD = randomize('*', 16, {
1244
- exclude: '\\\'"$'
1245
- });
1246
- argv.DATABASE_CLIENT_MYSQL_PASSWORD_ROOT = randomize('*', 16, {
1247
- exclude: '\\\'"$'
1248
- });
1249
- argv.DATABASE_CLIENT_PG_USER = 'postgres';
1250
- argv.DATABASE_CLIENT_PG_PASSWORD = randomize('*', 16, {
1251
- exclude: '\\\'"$'
1252
- });
1253
- argv.DATABASE_CLIENT_PG_PASSWORD_ROOT = randomize('*', 16, {
1254
- exclude: '\\\'"$'
1255
- });
1256
- // template
1257
- const template = argv.template;
1258
- // render project boilerplate
1259
- await this.template.renderBoilerplateAndSnippets({
1260
- targetDir,
1261
- setName: __ThisSetName__,
1262
- snippetsPath: null,
1263
- boilerplatePath: `create/project/${template}/boilerplate`
1264
- });
1265
- // create docker-compose/data/pg
1266
- fse.ensureDirSync(path.join(targetDir, 'docker-compose/data/pg'));
1267
- // copy package.json
1268
- fse.copyFileSync(path.join(targetDir, 'package.original.json'), path.join(targetDir, 'package.json'));
1269
- // npm run init
1270
- await this.helper.spawnCmd({
1271
- cmd: 'npm',
1272
- args: ['run', 'init'],
1273
- options: {
1274
- cwd: targetDir
1275
- }
1276
- });
1277
- // done
1278
- await this.printUsage(targetDir);
1279
- }
1280
- async printUsage(targetDir) {
1281
- await this.console.log(`usage:
1282
- - cd ${targetDir}
1283
- - pnpm install
1284
- - npm run dev
1285
- - npm run test
1286
- - npm run build
1287
- - npm run start
1288
- `);
1289
- }
1290
- async downloadBoilerplate(packageName) {
1291
- const result = await this.getPackageInfo(packageName, false);
1292
- const tgzUrl = result.dist.tarball;
1293
- await this.console.log(`downloading ${tgzUrl}`);
1294
- const saveDir = path.join(os.tmpdir(), 'zova-project-boilerplate');
1295
- await rimraf(saveDir);
1296
- const response = await this.curl(tgzUrl, {
1297
- streaming: true,
1298
- followRedirect: true
1299
- });
1300
- await compressing.tgz.uncompress(response.res, saveDir);
1301
- await this.console.log(`extract to ${saveDir}`);
1302
- return path.join(saveDir, '/package');
1303
- }
1304
- async getPackageInfo(packageName, withFallback) {
1305
- await this.console.log(`fetching npm info of ${packageName}`);
1306
- try {
1307
- const registry = await this.helper.getRegistry();
1308
- const result = await this.curl(`${registry}${packageName}/latest`, {
1309
- dataType: 'json',
1310
- followRedirect: true,
1311
- maxRedirects: 5
1312
- });
1313
- if (result.status !== 200) {
1314
- const message = `npm info ${packageName} got error: ${result.status}, ${result.data.reason}`;
1315
- throw new Error(message);
1316
- }
1317
- return result.data;
1318
- } catch (err) {
1319
- if (withFallback) {
1320
- await this.console.log(`use fallback from ${packageName}`);
1321
- const require = createRequire(import.meta.url);
1322
- return require(`${packageName}/package.json`);
1323
- }
1324
- throw err;
1325
- }
1326
- }
1327
- async curl(url, options) {
1328
- options = options || {};
1329
- if (!options.timeout) {
1330
- options.timeout = 30000;
1331
- }
1332
- return await this.httpClient.request(url, options);
1333
- }
1334
- }
1335
- function random(start, end) {
1336
- return Math.floor(Math.random() * (end - start) + start);
1337
- }
1338
-
1339
1213
  class CliCreateSuite extends BeanCliBase {
1340
1214
  async execute() {
1341
1215
  const {
@@ -2907,7 +2781,6 @@ const beans = {
2907
2781
  'create.suite': CliCreateSuite,
2908
2782
  'create.bean': CliCreateBean,
2909
2783
  'create.module': CliCreateModule,
2910
- 'create.project': CliCreateProject,
2911
2784
  'create.test': CliCreateTest,
2912
2785
  'init.config': CliInitConfig,
2913
2786
  'init.constant': CliInitConstant,
@@ -3164,54 +3037,6 @@ var createModule = {
3164
3037
  }
3165
3038
  };
3166
3039
 
3167
- var createProject = {
3168
- bean: 'create.project',
3169
- info: {
3170
- version: '5.0.0',
3171
- title: 'Cli: Create Project',
3172
- usage: 'vona :create:project projectName [--template=] [--force]'
3173
- },
3174
- options: {
3175
- template: {
3176
- description: 'template',
3177
- type: 'string'
3178
- },
3179
- force: {
3180
- description: 'force',
3181
- type: 'boolean'
3182
- }
3183
- },
3184
- groups: {
3185
- default: {
3186
- questions: {
3187
- template: {
3188
- type: 'select',
3189
- message: 'Specify the project template',
3190
- choices: [{
3191
- name: 'cabloy-basic',
3192
- message: 'Cabloy Basic'
3193
- }, {
3194
- name: 'cabloy-start',
3195
- message: 'Cabloy Start'
3196
- }]
3197
- }
3198
- }
3199
- },
3200
- moduleInfo: {
3201
- questions: {
3202
- name: {
3203
- type: 'input',
3204
- message: 'project name',
3205
- initial: {
3206
- expression: 'arg0'
3207
- },
3208
- required: true
3209
- }
3210
- }
3211
- }
3212
- }
3213
- };
3214
-
3215
3040
  var createSuite = {
3216
3041
  bean: 'create.suite',
3217
3042
  info: {
@@ -3577,7 +3402,6 @@ const commands = {
3577
3402
  create: {
3578
3403
  suite: createSuite,
3579
3404
  module: createModule,
3580
- project: createProject,
3581
3405
  bean: createBean,
3582
3406
  test: createTest
3583
3407
  },
@@ -8,7 +8,6 @@ import { CliBinTest } from './bean/cli.bin.test.ts';
8
8
  import { CliBinTsc } from './bean/cli.bin.tsc.ts';
9
9
  import { CliCreateBean } from './bean/cli.create.bean.ts';
10
10
  import { CliCreateModule } from './bean/cli.create.module.ts';
11
- import { CliCreateProject } from './bean/cli.create.project.ts';
12
11
  import { CliCreateSuite } from './bean/cli.create.suite.ts';
13
12
  import { CliCreateTest } from './bean/cli.create.test.ts';
14
13
  import { CliDefaultList } from './bean/cli.default.list.ts';
@@ -41,7 +40,6 @@ export declare const beans: {
41
40
  'create.suite': typeof CliCreateSuite;
42
41
  'create.bean': typeof CliCreateBean;
43
42
  'create.module': typeof CliCreateModule;
44
- 'create.project': typeof CliCreateProject;
45
43
  'create.test': typeof CliCreateTest;
46
44
  'init.config': typeof CliInitConfig;
47
45
  'init.constant': typeof CliInitConstant;
@@ -226,50 +226,6 @@ export declare const commands: {
226
226
  };
227
227
  };
228
228
  };
229
- project: {
230
- bean: string;
231
- info: {
232
- version: string;
233
- title: string;
234
- usage: string;
235
- };
236
- options: {
237
- template: {
238
- description: string;
239
- type: string;
240
- };
241
- force: {
242
- description: string;
243
- type: string;
244
- };
245
- };
246
- groups: {
247
- default: {
248
- questions: {
249
- template: {
250
- type: string;
251
- message: string;
252
- choices: {
253
- name: string;
254
- message: string;
255
- }[];
256
- };
257
- };
258
- };
259
- moduleInfo: {
260
- questions: {
261
- name: {
262
- type: string;
263
- message: string;
264
- initial: {
265
- expression: string;
266
- };
267
- required: boolean;
268
- };
269
- };
270
- };
271
- };
272
- };
273
229
  bean: {
274
230
  bean: string;
275
231
  info: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-cli-set-api",
3
- "version": "1.1.100",
4
- "gitHead": "c4ed219c0de3e0163a406268597dda062275e551",
3
+ "version": "1.1.101",
4
+ "gitHead": "77e7d321e21482a08f743d441a017f3fb7be43cc",
5
5
  "description": "vona cli-set-api",
6
6
  "keywords": [
7
7
  "framework",
@@ -41,7 +41,7 @@
41
41
  "@babel/plugin-proposal-decorators": "^7.29.0",
42
42
  "@babel/plugin-transform-class-properties": "^7.28.6",
43
43
  "@babel/plugin-transform-typescript": "^7.28.6",
44
- "@cabloy/cli": "^3.1.13",
44
+ "@cabloy/cli": "^3.1.14",
45
45
  "@cabloy/dotenv": "^1.2.5",
46
46
  "@cabloy/extend": "^3.2.5",
47
47
  "@cabloy/module-glob": "^5.3.10",
@@ -1,26 +0,0 @@
1
- import type { CmdOptions } from '@cabloy/cli';
2
- import { BeanCliBase } from '@cabloy/cli';
3
- import urllib from 'urllib';
4
- declare module '@cabloy/cli' {
5
- interface ICommandArgv {
6
- force: boolean;
7
- template: string;
8
- SERVER_KEYS: string;
9
- SERVER_KEYS_PROD: string;
10
- DATABASE_CLIENT_MYSQL_USER: string;
11
- DATABASE_CLIENT_MYSQL_PASSWORD: string;
12
- DATABASE_CLIENT_MYSQL_PASSWORD_ROOT: string;
13
- DATABASE_CLIENT_PG_USER: string;
14
- DATABASE_CLIENT_PG_PASSWORD: string;
15
- DATABASE_CLIENT_PG_PASSWORD_ROOT: string;
16
- }
17
- }
18
- export declare class CliCreateProject extends BeanCliBase {
19
- httpClient: typeof urllib;
20
- constructor(options: CmdOptions);
21
- execute(): Promise<void>;
22
- printUsage(targetDir: string): Promise<void>;
23
- downloadBoilerplate(packageName: string): Promise<string>;
24
- getPackageInfo(packageName: string, withFallback: boolean): Promise<any>;
25
- curl(url: string, options: any): Promise<import("urllib").HttpClientResponse<any>>;
26
- }
@@ -1,45 +0,0 @@
1
- declare const _default: {
2
- bean: string;
3
- info: {
4
- version: string;
5
- title: string;
6
- usage: string;
7
- };
8
- options: {
9
- template: {
10
- description: string;
11
- type: string;
12
- };
13
- force: {
14
- description: string;
15
- type: string;
16
- };
17
- };
18
- groups: {
19
- default: {
20
- questions: {
21
- template: {
22
- type: string;
23
- message: string;
24
- choices: {
25
- name: string;
26
- message: string;
27
- }[];
28
- };
29
- };
30
- };
31
- moduleInfo: {
32
- questions: {
33
- name: {
34
- type: string;
35
- message: string;
36
- initial: {
37
- expression: string;
38
- };
39
- required: boolean;
40
- };
41
- };
42
- };
43
- };
44
- };
45
- export default _default;