vovk-cli 0.0.1-draft.356 → 0.0.1-draft.359

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.
Files changed (2) hide show
  1. package/dist/init/index.mjs +30 -31
  2. package/package.json +4 -2
@@ -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 });
@@ -172,11 +172,8 @@ export class Init {
172
172
  lang: lang ?? [],
173
173
  });
174
174
  }
175
- if (!(await getFileSystemEntryType(path.join(root, 'package.json')))) {
176
- throw new Error(`package.json not found at ${root}. Run "npx create-next-app" to create a new Next.js project.`);
177
- }
178
- if (!(await getFileSystemEntryType(path.join(root, 'tsconfig.json')))) {
179
- throw new Error(`tsconfig.json not found at ${root}. Run "npx tsc --init" to create a new tsconfig.json file.`);
175
+ if (pkgJson && !(await getFileSystemEntryType(path.join(root, 'tsconfig.json')))) {
176
+ log.warn(`tsconfig.json not found at ${root}. Run "npx tsc --init" to create a new tsconfig.json file.`);
180
177
  }
181
178
  if (configPaths.length) {
182
179
  if (!(await confirm({
@@ -215,28 +212,30 @@ export class Init {
215
212
  { name: 'None', value: null, description: 'Install validation library later' },
216
213
  ],
217
214
  })));
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') {
215
+ updateScripts ??= !pkgJson
216
+ ? undefined
217
+ : await select({
218
+ message: 'Do you want to update "dev" and add "prebuild" NPM scripts at package.json?',
219
+ default: 'implicit',
220
+ choices: [
221
+ {
222
+ name: 'Yes, use "concurrently" implicitly',
223
+ value: 'implicit',
224
+ 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"`,
225
+ },
226
+ {
227
+ name: 'Yes, use "concurrently" explicitly',
228
+ value: 'explicit',
229
+ 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"`,
230
+ },
231
+ {
232
+ name: 'No',
233
+ value: undefined,
234
+ description: 'Add the NPM scripts manually',
235
+ },
236
+ ],
237
+ });
238
+ if (typeof updateTsConfig === 'undefined' && pkgJson) {
240
239
  let shouldAsk = false;
241
240
  try {
242
241
  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.356",
3
+ "version": "0.0.1-draft.359",
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.416"
38
+ "vovk": "^3.0.0-draft.419",
39
+ "vovk-ajv": "^0.0.0-draft.102",
40
+ "vovk-client": "^0.0.4-draft.130"
39
41
  },
40
42
  "optionalDependencies": {
41
43
  "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.36"