vovk-cli 0.0.5 → 0.1.1

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/README.md CHANGED
@@ -9,6 +9,8 @@
9
9
  <br>
10
10
  <strong>Back-end Framework for Next.js App Router</strong>
11
11
  <br />
12
+ <em>One codebase → type-safe clients, OpenAPI, and AI tools</em>
13
+ <br />
12
14
  <a href="https://vovk.dev/">Documentation</a>
13
15
  &nbsp;&nbsp;
14
16
  <a href="https://vovk.dev/quick-install">Quick Start</a>
@@ -28,8 +30,8 @@ npm install -D vovk-cli
28
30
 
29
31
  - [vovk dev](https://vovk.dev/dev) - starts the development script that watches the changes in [controllers](https://vovk.dev/controller) and regenerates the [schema](https://vovk.dev/schema) and [client](https://vovk.dev/typescript)
30
32
  - [vovk generate](https://vovk.dev/generate) - generates the client based on the schema
31
- - [vovk bundle](https://vovk.dev/bundle) - bundles the client with [tsdown](https://tsdown.dev/)
32
- - [vovk init](https://vovk.dev/init) - initializes a new Vovk.ts project
33
+ - [vovk bundle](https://vovk.dev/bundle) - bundles the client (requires `bundle.build` config to be set)
34
+ - [vovk init](https://vovk.dev/init) - initializes a new Vovk.ts project in an existing Next.js app
33
35
  - [vovk new](https://vovk.dev/new) - generates a new controller, service or a custom module
34
36
 
35
37
  ```sh
@@ -19,7 +19,7 @@ export class Init {
19
19
  log;
20
20
  async #init({ configPaths, pkgJson, }, { useNpm, useYarn, usePnpm, useBun, skipInstall, updateTsConfig, updateScripts, validationLibrary, bundle, lang, dryRun, channel, }) {
21
21
  const { log, root } = this;
22
- const dependencies = ['vovk', 'vovk-client', 'vovk-ajv', 'openapi3-ts'];
22
+ const dependencies = ['vovk', 'vovk-client', 'vovk-ajv'];
23
23
  const devDependencies = ['vovk-cli'];
24
24
  if (lang?.includes('py')) {
25
25
  devDependencies.push('vovk-python');
@@ -170,7 +170,7 @@ export class Init {
170
170
  ? null
171
171
  : (validationLibrary ??
172
172
  (await select({
173
- message: 'Choose validation library',
173
+ message: 'Which validation library would you like to use?',
174
174
  default: 'zod',
175
175
  choices: [
176
176
  {
@@ -207,7 +207,7 @@ export class Init {
207
207
  }
208
208
  }
209
209
  bundle ??= await confirm({
210
- message: 'Do you want to set up "tsdown" to bundle TypeScript client?',
210
+ message: 'Do you want to set up "tsdown" to bundle TypeScript client (experimental)?',
211
211
  default: true,
212
212
  });
213
213
  updateScripts ??= !pkgJson
@@ -2,12 +2,23 @@ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import chalk from 'chalk';
4
4
  import { getNPMPackageMetadata } from '../utils/getNPMPackageMetadata.mjs';
5
- async function updateDeps({ packageJson, packageNames, channel, key, log, }) {
5
+ /** Root of the monorepo packages directory (…/packages) resolved from the compiled CLI location (dist/init/). */
6
+ const packagesRoot = path.resolve(import.meta.dirname, '../../..');
7
+ /** Vovk package names that have a matching local directory under packages/. */
8
+ const localPackageDirs = {
9
+ vovk: 'vovk',
10
+ 'vovk-cli': 'vovk-cli',
11
+ 'vovk-client': 'vovk-client',
12
+ 'vovk-ajv': 'vovk-ajv',
13
+ 'vovk-python': 'vovk-python',
14
+ 'vovk-rust': 'vovk-rust',
15
+ };
16
+ async function updateDeps({ packageJson, packageNames, channel, key, log, dir, }) {
17
+ const useLocal = process.env.NODE_ENV === 'test';
6
18
  return Promise.all(packageNames.map(async (packageName) => {
7
19
  let name;
8
20
  let version;
9
21
  if (packageName.startsWith('@')) {
10
- // Handle scoped packages (@org/name@version)
11
22
  const lastAtIndex = packageName.lastIndexOf('@');
12
23
  if (lastAtIndex > 0) {
13
24
  name = packageName.substring(0, lastAtIndex);
@@ -19,11 +30,17 @@ async function updateDeps({ packageJson, packageNames, channel, key, log, }) {
19
30
  }
20
31
  }
21
32
  else {
22
- // Handle regular packages (name@version)
23
33
  const parts = packageName.split('@');
24
34
  name = parts[0];
25
35
  version = parts[1];
26
36
  }
37
+ // In test mode, use file: paths for local vovk packages
38
+ if (useLocal && name in localPackageDirs) {
39
+ const rel = path.relative(dir, path.join(packagesRoot, localPackageDirs[name]));
40
+ packageJson[key] ??= {};
41
+ packageJson[key][name] = `file:${rel}`;
42
+ return;
43
+ }
27
44
  if (version) {
28
45
  packageJson[key] ??= {};
29
46
  packageJson[key][name] = version;
@@ -46,8 +63,8 @@ async function updateDeps({ packageJson, packageNames, channel, key, log, }) {
46
63
  export async function updateDependenciesWithoutInstalling({ log, dir, dependencyNames, devDependencyNames, channel, }) {
47
64
  const packageJsonPath = path.join(dir, 'package.json');
48
65
  const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
49
- await updateDeps({ packageJson, packageNames: dependencyNames, channel, log, key: 'dependencies' });
50
- await updateDeps({ packageJson, packageNames: devDependencyNames, channel, log, key: 'devDependencies' });
66
+ await updateDeps({ packageJson, packageNames: dependencyNames, channel, log, key: 'dependencies', dir });
67
+ await updateDeps({ packageJson, packageNames: devDependencyNames, channel, log, key: 'devDependencies', dir });
51
68
  await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
52
69
  log.info('Added dependencies to package.json:');
53
70
  for (const dependency of dependencyNames) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.5",
3
+ "version": "0.1.1",
4
4
  "description": "CLI tool for managing Vovk.ts projects",
5
5
  "files": [
6
6
  "dist",
@@ -18,8 +18,8 @@
18
18
  "build": "rm -rf dist tsconfig.build.tsbuildinfo && tsc -P tsconfig.build.json",
19
19
  "postbuild": "chmod +x ./dist/index.mjs",
20
20
  "pre-test": "npm run build && npm run clear-test-cache",
21
- "test-only": "npm run pre-test && node --experimental-transform-types --experimental-strip-types --experimental-vm-modules --test --test-only test/spec/**/*.mts",
22
- "test": "npm run pre-test && node --experimental-transform-types --experimental-strip-types --experimental-vm-modules --test --test-concurrency=1 test/spec/**/*.mts",
21
+ "test-only": "npm run pre-test && NODE_ENV=test node --experimental-transform-types --experimental-strip-types --experimental-vm-modules --test --test-only test/spec/**/*.mts",
22
+ "test": "npm run pre-test && NODE_ENV=test node --experimental-transform-types --experimental-strip-types --experimental-vm-modules --test --test-concurrency=1 test/spec/**/*.mts",
23
23
  "tsc": "tsc --noEmit",
24
24
  "ncu": "npm-check-updates -u -x commander,node-pty",
25
25
  "npm-publish": "npm publish",
@@ -42,11 +42,7 @@
42
42
  },
43
43
  "homepage": "https://vovk.dev",
44
44
  "peerDependencies": {
45
- "vovk": ">=3.0.0-beta.1",
46
- "vovk-ajv": ">=0.0.0-beta.1",
47
- "vovk-client": ">=0.0.4-beta.25",
48
- "vovk-python": ">=0.0.1-beta.14",
49
- "vovk-rust": ">=0.0.1-beta.16"
45
+ "vovk": ">=3.0.0-beta.1"
50
46
  },
51
47
  "optionalDependencies": {
52
48
  "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.7"
@@ -71,7 +67,6 @@
71
67
  "jsonc-parser": "^3.3.1",
72
68
  "lodash": "^4.17.23",
73
69
  "loglevel": "^1.9.2",
74
- "openapi3-ts": "^4.5.0",
75
70
  "pluralize": "^8.0.0",
76
71
  "prettier": "^3.8.1",
77
72
  "tar-stream": "^3.1.8",
@@ -91,6 +86,7 @@
91
86
  "create-next-app": "^16.1.6",
92
87
  "http-server": "^14.1.1",
93
88
  "node-pty": "0.10.1",
89
+ "openapi3-ts": "^4.5.0",
94
90
  "tsdown": "^0.19.0",
95
91
  "zod": "^4.3.6"
96
92
  }