vovk-cli 0.0.1-draft.329 → 0.0.1-draft.330

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.
@@ -10,10 +10,10 @@ export async function bundle({ projectInfo, fullSchema, cliBundleOptions, }) {
10
10
  const { config, log, cwd, apiDirAbsolutePath } = projectInfo;
11
11
  const locatedSegments = await locateSegments({ dir: apiDirAbsolutePath, config, log });
12
12
  const { bundle: bundleConfig } = config;
13
- const tsFullClientOutAbsoluteDirInput = path.join(cwd, bundleConfig.tsClientOutDir);
14
- const tsClientOutDir = cliBundleOptions?.tsClientOutDir ?? bundleConfig.tsClientOutDir;
15
- const dontDeleteTsClientOutDirAfter = cliBundleOptions?.dontDeleteTsClientOutDirAfter ?? bundleConfig?.dontDeleteTsClientOutDirAfter ?? false;
16
- if (!tsClientOutDir) {
13
+ const tsFullClientOutAbsoluteDirInput = path.join(cwd, bundleConfig.prebundleOutDir);
14
+ const prebundleOutDir = cliBundleOptions?.prebundleOutDir ?? bundleConfig.prebundleOutDir;
15
+ const keepPrebundleDir = cliBundleOptions?.keepPrebundleDir ?? bundleConfig?.keepPrebundleDir ?? false;
16
+ if (!prebundleOutDir) {
17
17
  throw new Error('No output directory specified for composed client');
18
18
  }
19
19
  const outDir = cliBundleOptions?.outDir ?? bundleConfig.tsdownBuildOptions.outDir;
@@ -36,7 +36,7 @@ export async function bundle({ projectInfo, fullSchema, cliBundleOptions, }) {
36
36
  openapiGetMethodName: cliBundleOptions?.openapiGetMethodName,
37
37
  openapiRootUrl: cliBundleOptions?.openapiRootUrl,
38
38
  composedFrom: [BuiltInTemplateName.ts],
39
- composedOut: tsClientOutDir,
39
+ composedOut: prebundleOutDir,
40
40
  composedOnly: true,
41
41
  composedIncludeSegments: cliBundleOptions.includeSegments ?? bundleConfig.includeSegments,
42
42
  composedExcludeSegments: cliBundleOptions.excludeSegments ?? bundleConfig.excludeSegments,
@@ -79,7 +79,7 @@ export async function bundle({ projectInfo, fullSchema, cliBundleOptions, }) {
79
79
  },
80
80
  });
81
81
  }
82
- if (!dontDeleteTsClientOutDirAfter) {
82
+ if (!keepPrebundleDir) {
83
83
  await fs.rm(tsFullClientOutAbsoluteDirInput, { recursive: true, force: true });
84
84
  log.debug(`Deleted temporary TypeScript client output directory: ${chalkHighlightThing(tsFullClientOutAbsoluteDirInput)}`);
85
85
  }
@@ -369,7 +369,7 @@ export class VovkDev {
369
369
  void this.#requestSchema(segmentName).then(({ isError: isError2 }) => {
370
370
  if (!isError2) {
371
371
  clearInterval(interval);
372
- log.info(`Requested schema for ${formatLoggedSegmentName(segmentName)} after ${attempts} attempts`);
372
+ log.info(`Requested schema for ${formatLoggedSegmentName(segmentName)} after ${attempts} attempt${attempts === 1 ? '' : 's'}`);
373
373
  }
374
374
  });
375
375
  }, DELAY);
@@ -157,7 +157,7 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
157
157
  projectInfo,
158
158
  clientTemplateFile,
159
159
  fullSchema: composedFullSchema,
160
- prettifyClient: config.prettifyClient,
160
+ prettifyClient: config.composedClient.prettifyClient,
161
161
  segmentName: null,
162
162
  imports: clientImports.composedClient,
163
163
  templateContent,
@@ -243,7 +243,7 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
243
243
  projectInfo,
244
244
  clientTemplateFile,
245
245
  fullSchema: segmentedFullSchema,
246
- prettifyClient: config.prettifyClient,
246
+ prettifyClient: config.segmentedClient.prettifyClient,
247
247
  segmentName,
248
248
  imports: clientImports.segmentedClient[segmentName],
249
249
  templateContent,
@@ -101,7 +101,7 @@ export default async function writeOneClientFile({ cwd, projectInfo, clientTempl
101
101
  })
102
102
  : templateContent;
103
103
  // Optionally prettify
104
- if (prettifyClient || config.prettifyClient) {
104
+ if (prettifyClient) {
105
105
  rendered = await prettify(rendered, outPath);
106
106
  }
107
107
  if (isEnsuringClient) {
@@ -14,7 +14,6 @@ export default function getConfig({ configPath, cwd }: {
14
14
  rootEntry?: string;
15
15
  origin?: string;
16
16
  logLevel?: "error" | "trace" | "debug" | "info" | "warn" | (string & {});
17
- prettifyClient?: boolean;
18
17
  libs?: {
19
18
  ajv: import("vovk").KnownAny;
20
19
  [key: string]: import("vovk").KnownAny;
@@ -24,6 +23,7 @@ export default function getConfig({ configPath, cwd }: {
24
23
  enabled?: boolean;
25
24
  outDir?: string;
26
25
  fromTemplates?: string[];
26
+ prettifyClient?: boolean;
27
27
  } & ({
28
28
  excludeSegments?: never;
29
29
  includeSegments?: string[];
@@ -40,6 +40,7 @@ export default function getConfig({ configPath, cwd }: {
40
40
  enabled?: boolean;
41
41
  outDir?: string;
42
42
  fromTemplates?: string[];
43
+ prettifyClient?: boolean;
43
44
  } & ({
44
45
  excludeSegments?: never;
45
46
  includeSegments?: string[];
@@ -54,8 +55,8 @@ export default function getConfig({ configPath, cwd }: {
54
55
  };
55
56
  bundle?: {
56
57
  requires?: Record<string, string>;
57
- tsClientOutDir?: string;
58
- dontDeleteTsClientOutDirAfter?: boolean;
58
+ prebundleOutDir?: string;
59
+ keepPrebundleDir?: boolean;
59
60
  origin?: string;
60
61
  package?: import("type-fest").PackageJson;
61
62
  readme?: {
@@ -35,16 +35,18 @@ export default async function getConfig({ configPath, cwd }) {
35
35
  enabled: conf.composedClient?.enabled ?? true,
36
36
  fromTemplates: conf.composedClient?.fromTemplates ?? ['mjs', 'cjs'],
37
37
  outDir: conf.composedClient?.outDir ?? './node_modules/.vovk-client',
38
+ prettifyClient: conf.composedClient?.prettifyClient ?? false,
38
39
  },
39
40
  segmentedClient: {
40
41
  ...conf.segmentedClient,
41
42
  enabled: conf.segmentedClient?.enabled ?? false,
42
43
  fromTemplates: conf.segmentedClient?.fromTemplates ?? ['ts'],
43
44
  outDir: conf.segmentedClient?.outDir ?? path.join(srcRoot ?? '.', 'client'),
45
+ prettifyClient: conf.segmentedClient?.prettifyClient ?? true,
44
46
  },
45
47
  bundle: {
46
- tsClientOutDir: conf.bundle?.tsClientOutDir ?? 'tmp_prebundle',
47
- dontDeleteTsClientOutDirAfter: conf.bundle?.dontDeleteTsClientOutDirAfter ?? false,
48
+ prebundleOutDir: conf.bundle?.prebundleOutDir ?? 'tmp_prebundle',
49
+ keepPrebundleDir: conf.bundle?.keepPrebundleDir ?? false,
48
50
  requires: {
49
51
  [BuiltInTemplateName.readme]: '.',
50
52
  [BuiltInTemplateName.packageJson]: '.',
@@ -64,8 +66,7 @@ export default async function getConfig({ configPath, cwd }) {
64
66
  rootEntry: env.VOVK_ROOT_ENTRY ?? conf.rootEntry ?? 'api',
65
67
  rootSegmentModulesDirName: conf.rootSegmentModulesDirName ?? '',
66
68
  logLevel: env.VOVK_LOG_LEVEL ?? conf.logLevel ?? 'info',
67
- prettifyClient: (env.VOVK_PRETTIFY_CLIENT ? !!env.VOVK_PRETTIFY_CLIENT : null) ?? conf.prettifyClient ?? false,
68
- devHttps: (env.VOVK_DEV_HTTPS ? !!env.VOVK_DEV_HTTPS : null) ?? conf.devHttps ?? false,
69
+ devHttps: conf.devHttps ?? false,
69
70
  moduleTemplates: {
70
71
  service: 'vovk-cli/module-templates/service.ts.ejs',
71
72
  controller: 'vovk-cli/module-templates/controller.ts.ejs',
package/dist/index.mjs CHANGED
@@ -90,7 +90,7 @@ program
90
90
  .option('--prettify', 'prettify output files')
91
91
  .option('--schema, --schema-path <path>', 'path to schema folder (default: ./.vovk-schema)')
92
92
  .option('--config, --config-path <config>', 'path to config file')
93
- .option('--force-ts-standalone', 'force TypeScript standalone mode (Next.js environment will be ignored, by default it\'s "true" for non-Next.js directories)')
93
+ .option('--origin <url>', 'set the origin URL for the generated client')
94
94
  .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')
95
95
  .option('--openapi, --openapi-spec <openapi_path_or_urls...>', 'use OpenAPI schema for client generation')
96
96
  .option('--openapi-get-module-name <names...>', 'module names corresponding to the index of --openapi option')
@@ -113,10 +113,11 @@ program
113
113
  .option('--out, --out-dir <path>', 'path to output directory for bundle')
114
114
  .option('--include, --include-segments <segments...>', 'include segments')
115
115
  .option('--exclude, --exclude-segments <segments...>', 'exclude segments')
116
- .option('--ts-client-out-dir <path>', 'path to output directory for TypeScript client')
117
- .option('--dont-delete-ts-client-out-dir-after', 'do not delete TypeScript client output directory after bundling')
116
+ .option('--prebundle-out-dir, --prebundle-out <path>', 'path to output directory for prebundle')
117
+ .option('--keep-prebundle-dir', 'do not delete prebundle directory after bundling')
118
118
  .option('--config <config>', 'path to config file')
119
119
  .option('--schema <path>', 'path to schema folder (default: .vovk-schema)')
120
+ .option('--origin <url>', 'set the origin URL for the generated client')
120
121
  .option('--openapi, --openapi-spec <openapi_path_or_urls...>', 'use OpenAPI schema instead of Vovk schema')
121
122
  .option('--openapi-get-module-name <names...>', 'module names corresponding to the index of --openapi option')
122
123
  .option('--openapi-get-method-name <names...>', 'method names corresponding to the index of --openapi option')
@@ -8,7 +8,7 @@ import getFileSystemEntryType from '../utils/getFileSystemEntryType.mjs';
8
8
  import installDependencies, { getPackageManager } from './installDependencies.mjs';
9
9
  import getLogger from '../utils/getLogger.mjs';
10
10
  import createConfig from './createConfig.mjs';
11
- import updateNPMScripts, { getDevScript } from './updateNPMScripts.mjs';
11
+ import updateNPMScripts, { getBuildScript, getDevScript } from './updateNPMScripts.mjs';
12
12
  import checkTSConfigForExperimentalDecorators from './checkTSConfigForExperimentalDecorators.mjs';
13
13
  import updateTypeScriptConfig from './updateTypeScriptConfig.mjs';
14
14
  import updateDependenciesWithoutInstalling from './updateDependenciesWithoutInstalling.mjs';
@@ -189,18 +189,18 @@ export class Init {
189
189
  ],
190
190
  })));
191
191
  updateScripts ??= await select({
192
- message: 'Do you want to update "dev" NPM script at package.json?',
192
+ message: 'Do you want to update "dev" and "build" NPM scripts at package.json?',
193
193
  default: 'implicit',
194
194
  choices: [
195
195
  {
196
196
  name: 'Yes, use "concurrently" implicitly',
197
197
  value: 'implicit',
198
- description: `The 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')}"`)}`,
198
+ 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 "build" scrilt will run "vovk generate" before "next build" ${chalk.whiteBright.bold(`"${getBuildScript(pkgJson)}"`)}`,
199
199
  },
200
200
  {
201
201
  name: 'Yes, use "concurrently" explicitly',
202
202
  value: 'explicit',
203
- description: `The script will use pre-defined PORT variable and run "next dev" and "vovk dev" as "concurrently" CLI arguments ${chalk.whiteBright.bold(`"${getDevScript(pkgJson, 'explicit')}"`)}`,
203
+ 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 "build" scrilt will run "vovk generate" before "next build" ${chalk.whiteBright.bold(`"${getBuildScript(pkgJson)}"`)}`,
204
204
  },
205
205
  {
206
206
  name: 'No',
@@ -1,3 +1,4 @@
1
1
  import NPMCliPackageJson from '@npmcli/package-json';
2
2
  export declare function getDevScript(pkgJson: NPMCliPackageJson, updateScriptsMode: 'implicit' | 'explicit'): string;
3
+ export declare function getBuildScript(pkgJson: NPMCliPackageJson): string;
3
4
  export default function updateNPMScripts(pkgJson: NPMCliPackageJson, root: string, updateScriptsMode: 'implicit' | 'explicit'): Promise<void>;
@@ -5,11 +5,16 @@ export function getDevScript(pkgJson, updateScriptsMode) {
5
5
  ? `PORT=3000 concurrently '${nextDev}' 'vovk dev' --kill-others`
6
6
  : `vovk dev --next-dev${nextDevFlags ? ` -- ${nextDevFlags}` : ''}`;
7
7
  }
8
+ export function getBuildScript(pkgJson) {
9
+ const nextBuild = pkgJson.content.scripts?.build ?? 'next build';
10
+ return `vovk generate && ${nextBuild}`;
11
+ }
8
12
  export default async function updateNPMScripts(pkgJson, root, updateScriptsMode) {
9
13
  pkgJson.update({
10
14
  scripts: {
11
15
  ...pkgJson.content.scripts,
12
16
  dev: getDevScript(pkgJson, updateScriptsMode),
17
+ build: getBuildScript(pkgJson),
13
18
  },
14
19
  });
15
20
  await pkgJson.save();
package/dist/types.d.mts CHANGED
@@ -36,7 +36,7 @@ export interface GenerateOptions {
36
36
  segmentedIncludeSegments?: string[];
37
37
  segmentedExcludeSegments?: string[];
38
38
  }
39
- export interface BundleOptions extends Partial<Pick<VovkStrictConfig['bundle'], 'tsClientOutDir' | 'dontDeleteTsClientOutDirAfter' | 'includeSegments' | 'excludeSegments'>> {
39
+ export interface BundleOptions extends Partial<Pick<VovkStrictConfig['bundle'], 'prebundleOutDir' | 'keepPrebundleDir' | 'includeSegments' | 'excludeSegments'>> {
40
40
  config?: string;
41
41
  schema?: string;
42
42
  outDir?: string;
@@ -78,8 +78,6 @@ export type VovkEnv = {
78
78
  VOVK_ROOT_ENTRY?: string;
79
79
  VOVK_API_ENTRY_POINT?: string;
80
80
  VOVK_LOG_LEVEL?: LogLevelNames;
81
- VOVK_PRETTIFY_CLIENT?: string;
82
- VOVK_DEV_HTTPS?: string;
83
81
  __VOVK_START_WATCHER_IN_STANDALONE_MODE__?: 'true';
84
82
  __VOVK_SCHEMA_OUT_FLAG__?: string;
85
83
  __VOVK_DEV_HTTPS_FLAG__?: 'true' | 'false';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.329",
3
+ "version": "0.0.1-draft.330",
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.358"
38
+ "vovk": "^3.0.0-draft.362"
39
39
  },
40
40
  "optionalDependencies": {
41
- "vovk-python": "^0.0.1-draft.59"
41
+ "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.31"
42
42
  },
43
43
  "dependencies": {
44
44
  "@iarna/toml": "^2.2.5",