vovk-cli 0.0.1-draft.355 → 0.0.1-draft.358

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.mjs CHANGED
@@ -94,7 +94,7 @@ program
94
94
  .option('--schema, --schema-path <path>', 'path to schema folder (default: ./.vovk-schema)')
95
95
  .option('--config, --config-path <config>', 'path to config file')
96
96
  .option('--origin <url>', 'set the origin URL for the generated client')
97
- .option('--watch <s>', 'watch for changes in schema or openapi spec and regenerate client; accepts a number in seconds to throttle the watcher or make an HTTP request to the OpenAPI spec URL', false)
97
+ .option('--watch [s]', 'watch for changes in schema or openapi spec and regenerate client; accepts a number in seconds to throttle the watcher or make an HTTP request to the OpenAPI spec URL')
98
98
  .option('--openapi, --openapi-spec <openapi_path_or_urls...>', 'use OpenAPI schema for client generation')
99
99
  .option('--openapi-module-name, --openapi-get-module-name <names...>', 'module names corresponding to the index of --openapi option')
100
100
  .option('--openapi-method-name, --openapi-get-method-name <names...>', 'method names corresponding to the index of --openapi option')
@@ -20,7 +20,7 @@ export class Init {
20
20
  log;
21
21
  async #init({ configPaths, pkgJson, }, { useNpm, useYarn, usePnpm, useBun, skipInstall, updateTsConfig, updateScripts, validationLibrary, lang, dryRun, channel, }) {
22
22
  const { log, root } = this;
23
- const dependencies = ['vovk', 'vovk-client', 'openapi3-ts', 'vovk-ajv', 'ajv'];
23
+ const dependencies = ['vovk', 'vovk-client', 'vovk-ajv'];
24
24
  const devDependencies = ['vovk-cli'];
25
25
  if (lang?.includes('py')) {
26
26
  devDependencies.push('vovk-python');
@@ -50,7 +50,7 @@ export class Init {
50
50
  }
51
51
  if (updateScripts) {
52
52
  try {
53
- if (!dryRun)
53
+ if (!dryRun && pkgJson)
54
54
  await updateNPMScripts(pkgJson, root, updateScripts);
55
55
  log.info('Updated scripts at package.json');
56
56
  }
@@ -79,7 +79,7 @@ export class Init {
79
79
  log.error(`Failed to update tsconfig.json: ${error.message}`);
80
80
  }
81
81
  }
82
- if (!dryRun) {
82
+ if (!dryRun && pkgJson) {
83
83
  let depsUpdated = false;
84
84
  try {
85
85
  await updateDependenciesWithoutInstalling({
@@ -152,7 +152,7 @@ export class Init {
152
152
  const cwd = process.cwd();
153
153
  const root = path.resolve(cwd, prefix ?? '.');
154
154
  const log = getLogger(logLevel ?? 'info');
155
- const pkgJson = await NPMCliPackageJson.load(root);
155
+ const pkgJson = await NPMCliPackageJson.load(root).catch(() => null);
156
156
  this.root = root;
157
157
  this.log = log;
158
158
  const configPaths = await getConfigPaths({ cwd, relativePath: prefix });
@@ -215,28 +215,30 @@ export class Init {
215
215
  { name: 'None', value: null, description: 'Install validation library later' },
216
216
  ],
217
217
  })));
218
- updateScripts ??= await select({
219
- message: 'Do you want to update "dev" and add "prebuild" NPM scripts at package.json?',
220
- default: 'implicit',
221
- choices: [
222
- {
223
- name: 'Yes, use "concurrently" implicitly',
224
- value: 'implicit',
225
- description: `The "dev" script will use "concurrently" API to run "next dev" and "vovk dev" commands together and automatically find an available port ${chalk.whiteBright.bold(`"${getDevScript(pkgJson, 'implicit')}"`)} and the "prebuild" script will run "vovk generate"`,
226
- },
227
- {
228
- name: 'Yes, use "concurrently" explicitly',
229
- value: 'explicit',
230
- description: `The "dev" script will use pre-defined PORT variable and run "next dev" and "vovk dev" as "concurrently" CLI arguments ${chalk.whiteBright.bold(`"${getDevScript(pkgJson, 'explicit')}"`)} and the "prebuild" script will run "vovk generate"`,
231
- },
232
- {
233
- name: 'No',
234
- value: undefined,
235
- description: 'Add the NPM scripts manually',
236
- },
237
- ],
238
- });
239
- if (typeof updateTsConfig === 'undefined') {
218
+ updateScripts ??= !pkgJson
219
+ ? undefined
220
+ : await select({
221
+ message: 'Do you want to update "dev" and add "prebuild" NPM scripts at package.json?',
222
+ default: 'implicit',
223
+ choices: [
224
+ {
225
+ name: 'Yes, use "concurrently" implicitly',
226
+ value: 'implicit',
227
+ description: `The "dev" script will use "concurrently" API to run "next dev" and "vovk dev" commands together and automatically find an available port ${chalk.whiteBright.bold(`"${getDevScript(pkgJson, 'implicit')}"`)} and the "prebuild" script will run "vovk generate"`,
228
+ },
229
+ {
230
+ name: 'Yes, use "concurrently" explicitly',
231
+ value: 'explicit',
232
+ description: `The "dev" script will use pre-defined PORT variable and run "next dev" and "vovk dev" as "concurrently" CLI arguments ${chalk.whiteBright.bold(`"${getDevScript(pkgJson, 'explicit')}"`)} and the "prebuild" script will run "vovk generate"`,
233
+ },
234
+ {
235
+ name: 'No',
236
+ value: undefined,
237
+ description: 'Add the NPM scripts manually',
238
+ },
239
+ ],
240
+ });
241
+ if (typeof updateTsConfig === 'undefined' && pkgJson) {
240
242
  let shouldAsk = false;
241
243
  try {
242
244
  shouldAsk = !(await checkTSConfigForExperimentalDecorators(root)); // TODO also check for emitDecoratorMetadata when vovk-dto is used
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.355",
3
+ "version": "0.0.1-draft.358",
4
4
  "bin": {
5
5
  "vovk": "./dist/index.mjs"
6
6
  },
@@ -35,7 +35,9 @@
35
35
  },
36
36
  "homepage": "https://vovk.dev",
37
37
  "peerDependencies": {
38
- "vovk": "^3.0.0-draft.415"
38
+ "vovk": "^3.0.0-draft.419",
39
+ "vovk-ajv": "^0.0.0-draft.101",
40
+ "vovk-client": "^0.0.4-draft.129"
39
41
  },
40
42
  "optionalDependencies": {
41
43
  "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.36"