vovk-cli 0.0.1-draft.306 → 0.0.1-draft.308

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.
@@ -259,11 +259,13 @@ export class VovkDev {
259
259
  log.debug(`Requesting schema for ${formatLoggedSegmentName(segmentName)} at ${endpoint}`);
260
260
  try {
261
261
  const resp = await fetch(endpoint);
262
+ const text = await resp.text();
262
263
  if (resp.status !== 200) {
263
264
  const probableCause = {
264
265
  404: 'The segment did not compile or config.origin is wrong.',
265
266
  }[resp.status];
266
- log.warn(`Schema request to ${formatLoggedSegmentName(segmentName)} failed with status code ${resp.status} but expected 200.${probableCause ? ` Probable cause: ${probableCause}` : ''}`);
267
+ const MAX_RESP_CHARS = 200;
268
+ log.warn(`Schema request to ${endpoint} for ${formatLoggedSegmentName(segmentName)} failed with status code ${resp.status} but expected 200.${probableCause ? ` Probable cause: ${probableCause}` : ''}. Response: ${text.length > MAX_RESP_CHARS ? text.slice(0, MAX_RESP_CHARS) + `... and ${text.length - MAX_RESP_CHARS} more characters` : text}`);
267
269
  return { isError: true };
268
270
  }
269
271
  let segmentSchema = null;
@@ -1,9 +1,9 @@
1
1
  import type getLogger from '../utils/getLogger.mjs';
2
2
  import type { InitOptions } from '../types.mjs';
3
- export default function createConfig({ root, log, options: { validationLibrary, reactQuery, lang, channel, dryRun }, }: {
3
+ export default function createConfig({ root, log, options: { validationLibrary, lang, channel, dryRun }, }: {
4
4
  root: string;
5
5
  log: ReturnType<typeof getLogger>;
6
- options: Pick<InitOptions, 'validationLibrary' | 'reactQuery' | 'lang' | 'channel' | 'dryRun'>;
6
+ options: Pick<InitOptions, 'validationLibrary' | 'lang' | 'channel' | 'dryRun'>;
7
7
  }): Promise<{
8
8
  configAbsolutePath: string;
9
9
  }>;
@@ -3,7 +3,7 @@ import fs from 'node:fs/promises';
3
3
  import getTemplateFilesFromPackage from './getTemplateFilesFromPackage.mjs';
4
4
  import prettify from '../utils/prettify.mjs';
5
5
  import getFileSystemEntryType, { FileSystemEntryType } from '../utils/getFileSystemEntryType.mjs';
6
- export default async function createConfig({ root, log, options: { validationLibrary, reactQuery, lang, channel, dryRun }, }) {
6
+ export default async function createConfig({ root, log, options: { validationLibrary, lang, channel, dryRun }, }) {
7
7
  const config = {};
8
8
  const dotConfigPath = path.join(root, '.config');
9
9
  const dir = (await getFileSystemEntryType(dotConfigPath)) === FileSystemEntryType.DIRECTORY ? dotConfigPath : root;
@@ -30,10 +30,6 @@ export default async function createConfig({ root, log, options: { validationLib
30
30
  config.composedClient ??= {};
31
31
  config.composedClient.fromTemplates = ['mjs', 'cjs', ...lang];
32
32
  }
33
- if (reactQuery) {
34
- config.imports ??= {};
35
- config.imports.createRPC = 'vovk-react-query';
36
- }
37
33
  config.moduleTemplates = moduleTemplates;
38
34
  const configStr = await prettify(`// @ts-check
39
35
  /** @type {import('vovk').VovkConfig} */
@@ -4,5 +4,5 @@ export declare class Init {
4
4
  #private;
5
5
  root: string;
6
6
  log: ReturnType<typeof getLogger>;
7
- main(prefix: string, { yes, logLevel, useNpm, useYarn, usePnpm, useBun, skipInstall, updateTsConfig, updateScripts, validationLibrary, reactQuery, lang, dryRun, channel, }: InitOptions): Promise<void>;
7
+ main(prefix: string, { yes, logLevel, useNpm, useYarn, usePnpm, useBun, skipInstall, updateTsConfig, updateScripts, validationLibrary, lang, dryRun, channel, }: InitOptions): Promise<void>;
8
8
  }
@@ -17,7 +17,7 @@ import chalkHighlightThing from '../utils/chalkHighlightThing.mjs';
17
17
  export class Init {
18
18
  root;
19
19
  log;
20
- async #init({ configPaths, pkgJson, }, { useNpm, useYarn, usePnpm, useBun, skipInstall, updateTsConfig, updateScripts, validationLibrary, reactQuery, lang, dryRun, channel, }) {
20
+ async #init({ configPaths, pkgJson, }, { useNpm, useYarn, usePnpm, useBun, skipInstall, updateTsConfig, updateScripts, validationLibrary, lang, dryRun, channel, }) {
21
21
  const { log, root } = this;
22
22
  const dependencies = ['vovk', 'vovk-client', 'vovk-ajv', 'openapi3-ts'];
23
23
  const devDependencies = ['vovk-cli'];
@@ -38,9 +38,6 @@ export class Init {
38
38
  'vovk-dto': ['class-validator', 'class-transformer', 'dto-mapped-types', 'reflect-metadata'],
39
39
  }[validationLibrary] ?? []));
40
40
  }
41
- if (reactQuery) {
42
- dependencies.push('vovk-react-query', '@tanstack/react-query');
43
- }
44
41
  if (updateScripts) {
45
42
  try {
46
43
  if (!dryRun)
@@ -127,7 +124,7 @@ export class Init {
127
124
  const { configAbsolutePath } = await createConfig({
128
125
  root,
129
126
  log,
130
- options: { validationLibrary, reactQuery, channel, lang, dryRun },
127
+ options: { validationLibrary, channel, lang, dryRun },
131
128
  });
132
129
  log.info('Config created successfully at ' + chalkHighlightThing(configAbsolutePath));
133
130
  }
@@ -135,7 +132,7 @@ export class Init {
135
132
  log.error(`Failed to create config: ${error.message}`);
136
133
  }
137
134
  }
138
- async main(prefix, { yes, logLevel, useNpm, useYarn, usePnpm, useBun, skipInstall, updateTsConfig, updateScripts, validationLibrary, reactQuery, lang, dryRun, channel, }) {
135
+ async main(prefix, { yes, logLevel, useNpm, useYarn, usePnpm, useBun, skipInstall, updateTsConfig, updateScripts, validationLibrary, lang, dryRun, channel, }) {
139
136
  const cwd = process.cwd();
140
137
  const root = path.resolve(cwd, prefix);
141
138
  const log = getLogger(logLevel);
@@ -153,7 +150,6 @@ export class Init {
153
150
  updateTsConfig: updateTsConfig ?? true,
154
151
  updateScripts: updateScripts ?? 'implicit',
155
152
  validationLibrary: validationLibrary?.toLocaleLowerCase() === 'none' ? null : (validationLibrary ?? 'vovk-zod'),
156
- reactQuery: reactQuery ?? true,
157
153
  dryRun: dryRun ?? false,
158
154
  channel: channel ?? 'latest',
159
155
  lang: lang ?? [],
@@ -213,10 +209,6 @@ export class Init {
213
209
  },
214
210
  ],
215
211
  });
216
- reactQuery ??= await confirm({
217
- default: false,
218
- message: 'Do you want to use @tanstack/react-query for data fetching at React components?',
219
- });
220
212
  if (typeof updateTsConfig === 'undefined') {
221
213
  let shouldAsk = false;
222
214
  try {
@@ -236,7 +228,7 @@ export class Init {
236
228
  }
237
229
  }
238
230
  lang ??= await checkbox({
239
- message: 'Do you want to generate RPC client for other languages besides TypeScript?',
231
+ message: 'Do you want to generate RPC client for other languages besides TypeScript (beta)?',
240
232
  choices: [
241
233
  { name: 'Python', value: 'py' },
242
234
  { name: 'Rust', value: 'rs' },
@@ -251,7 +243,6 @@ export class Init {
251
243
  updateTsConfig,
252
244
  updateScripts,
253
245
  validationLibrary,
254
- reactQuery,
255
246
  lang,
256
247
  dryRun,
257
248
  channel,
@@ -15,7 +15,6 @@ export function initProgram(program) {
15
15
  .option('--update-scripts <mode>', 'update package.json scripts ("implicit" or "explicit")')
16
16
  .option('--lang <languages...>', 'generate client for other programming languages by default ("py" for Python and "rs" for Rust are supported)')
17
17
  .option('--validation-library <library>', 'validation library to use ("vovk-zod", "vovk-dto" or another); set to "none" to skip')
18
- .option('--react-query', 'use @tanstack/react-query for data fetching inside components')
19
18
  .option('--channel <channel>', 'channel to use for fetching packages', 'latest')
20
19
  .option('--dry-run', 'do not write files to disk')
21
20
  .action((prefix = '.', options) => new Init().main(prefix, options));
package/dist/types.d.mts CHANGED
@@ -56,7 +56,6 @@ export interface InitOptions {
56
56
  updateTsConfig?: boolean;
57
57
  updateScripts?: 'implicit' | 'explicit';
58
58
  validationLibrary?: string | null;
59
- reactQuery?: boolean;
60
59
  dryRun?: boolean;
61
60
  lang?: string[];
62
61
  channel?: 'latest' | 'beta' | 'draft';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.306",
3
+ "version": "0.0.1-draft.308",
4
4
  "bin": {
5
5
  "vovk": "./dist/index.mjs"
6
6
  },
@@ -35,10 +35,10 @@
35
35
  },
36
36
  "homepage": "https://vovk.dev",
37
37
  "peerDependencies": {
38
- "vovk": "^3.0.0-draft.351"
38
+ "vovk": "^3.0.0-draft.352"
39
39
  },
40
40
  "optionalDependencies": {
41
- "vovk-python": "^0.0.1-draft.56"
41
+ "vovk-python": "^0.0.1-draft.58"
42
42
  },
43
43
  "dependencies": {
44
44
  "@iarna/toml": "^2.2.5",