vovk-cli 0.0.1-draft.341 → 0.0.1-draft.345

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.
@@ -285,7 +285,6 @@ export class VovkDev {
285
285
  segments: this.#schemaSegments,
286
286
  meta: getMetaSchema({
287
287
  config: this.#projectInfo.config,
288
- package: this.#projectInfo.packageJson,
289
288
  }),
290
289
  };
291
290
  return generate({
@@ -7,7 +7,6 @@ export default async function writeMetaJson(schemaOutAbsolutePath, projectInfo)
7
7
  const metaJsonPath = path.join(schemaOutAbsolutePath, META_FILE_NAME + '.json');
8
8
  const metaStr = JSON.stringify(getMetaSchema({
9
9
  config: projectInfo.config,
10
- package: projectInfo.packageJson,
11
10
  }), null, 2);
12
11
  const existingStr = await fs.readFile(metaJsonPath, 'utf-8').catch(() => null);
13
12
  if (existingStr !== metaStr) {
@@ -21,7 +21,7 @@ export default async function ensureClient(projectInfo, locatedSegments) {
21
21
  fullSchema: {
22
22
  $schema: VovkSchemaIdEnum.SCHEMA,
23
23
  segments: getEmptySegmentRecordSchema(locatedSegments.map(({ segmentName }) => segmentName)),
24
- meta: getMetaSchema({ config: projectInfo.config, package: projectInfo.packageJson }),
24
+ meta: getMetaSchema({ config: projectInfo.config }),
25
25
  },
26
26
  locatedSegments,
27
27
  });
@@ -93,7 +93,7 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
93
93
  // preserve original object, so segments can be extended
94
94
  .map((segment) => ({ ...segment }))),
95
95
  };
96
- const { config, cwd, log, srcRoot, vovkCliPackage } = projectInfo;
96
+ const { config, cwd, log, srcRoot, vovkCliPackage, packageJson: projectPackageJson } = projectInfo;
97
97
  Object.entries(config.generatorConfig.segments ?? {})
98
98
  .filter(([, segmentConfig]) => segmentConfig.openAPIMixin)
99
99
  .forEach(([segmentName, segmentConfig]) => {
@@ -137,7 +137,8 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
137
137
  : { data: { imports: [] }, content: templateContent };
138
138
  const { package: packageJson, readme, origin, snippets, } = getGeneratorConfig({
139
139
  schema: fullSchema,
140
- config: templateDef.generatorConfig,
140
+ configs: [templateDef.generatorConfig ?? {}],
141
+ projectPackageJson,
141
142
  isBundle,
142
143
  segmentName: null,
143
144
  });
@@ -218,7 +219,8 @@ export async function generate({ isEnsuringClient = false, isBundle = false, pro
218
219
  const results = await Promise.all(segmentNames.map(async (segmentName) => {
219
220
  const { package: packageJson, readme, origin, snippets, } = getGeneratorConfig({
220
221
  schema: fullSchema,
221
- config: templateDef.generatorConfig,
222
+ configs: [templateDef.generatorConfig ?? {}],
223
+ projectPackageJson,
222
224
  segmentName,
223
225
  isBundle,
224
226
  });
@@ -1,10 +1,8 @@
1
1
  import { VovkStrictConfig, type VovkSchema } from 'vovk';
2
2
  import type { ProjectInfo } from '../getProjectInfo/index.mjs';
3
- import type { PackageJson } from 'type-fest';
4
- export declare function getProjectFullSchema({ schemaOutAbsolutePath, isNextInstalled, log, package: packageJson, config, }: {
3
+ export declare function getProjectFullSchema({ schemaOutAbsolutePath, isNextInstalled, log, config, }: {
5
4
  schemaOutAbsolutePath: string;
6
5
  isNextInstalled: boolean;
7
6
  log: ProjectInfo['log'];
8
- package: PackageJson;
9
7
  config: VovkStrictConfig;
10
8
  }): Promise<VovkSchema>;
@@ -4,13 +4,12 @@ import { glob } from 'glob';
4
4
  import { VovkSchemaIdEnum } from 'vovk';
5
5
  import { META_FILE_NAME, ROOT_SEGMENT_FILE_NAME } from '../dev/writeOneSegmentSchemaFile.mjs';
6
6
  import getMetaSchema from '../getProjectInfo/getMetaSchema.mjs';
7
- export async function getProjectFullSchema({ schemaOutAbsolutePath, isNextInstalled, log, package: packageJson, config, }) {
7
+ export async function getProjectFullSchema({ schemaOutAbsolutePath, isNextInstalled, log, config, }) {
8
8
  const result = {
9
9
  $schema: VovkSchemaIdEnum.SCHEMA,
10
10
  segments: {},
11
11
  meta: getMetaSchema({
12
12
  config,
13
- package: packageJson,
14
13
  }),
15
14
  };
16
15
  const isEmptyLogOrWarn = isNextInstalled ? log.warn : log.debug;
@@ -37,13 +37,12 @@ export class VovkGenerate {
37
37
  });
38
38
  }
39
39
  async getFullSchema() {
40
- const { log, config, cwd, isNextInstalled, packageJson } = this.#projectInfo;
40
+ const { log, config, cwd, isNextInstalled } = this.#projectInfo;
41
41
  const { schemaPath } = this.#cliGenerateOptions;
42
42
  const fullSchema = await getProjectFullSchema({
43
43
  schemaOutAbsolutePath: path.resolve(cwd, schemaPath ?? config.schemaOutDir),
44
44
  isNextInstalled,
45
45
  log,
46
- package: packageJson,
47
46
  config,
48
47
  });
49
48
  return fullSchema;
@@ -21,11 +21,11 @@ locatedSegments, isNodeNextResolution, hasMixins, isVovkProject, vovkCliPackage,
21
21
  const { templateFilePath, relativeDir } = clientTemplateFile;
22
22
  const locatedSegmentsByName = _.keyBy(locatedSegments, 'segmentName');
23
23
  const outPath = normalizeOutTemplatePath(path.resolve(cwd, outCwdRelativeDir, typeof segmentName === 'string' ? segmentName || ROOT_SEGMENT_FILE_NAME : '', relativeDir, path.basename(templateFilePath).replace('.ejs', '')), packageJson);
24
- let placeholder = !templateFilePath.endsWith('.json.ejs')
25
- ? `// This is a temporary placeholder to avoid compilation errors if client is imported before it's generated.
24
+ let placeholder = templateFilePath.endsWith('.json.ejs')
25
+ ? ''
26
+ : `// This is a temporary placeholder to avoid compilation errors if client is imported before it's generated.
26
27
  // If you still see this text, the client is not generated yet because of an unknown problem.
27
- // Feel free to report an issue at https://github.com/finom/vovk/issues`
28
- : '{}';
28
+ // Feel free to report an issue at https://github.com/finom/vovk/issues`;
29
29
  placeholder = outPath.endsWith('.py') ? placeholder.replace(/\/\//g, '#') : placeholder;
30
30
  const getFirstLineBanner = (type = 'c') => {
31
31
  const text = `auto-generated by vovk-cli v${vovkCliPackage.version} at ${new Date().toISOString()}`;
@@ -1,36 +1,7 @@
1
1
  import { VovkSchemaIdEnum, VovkStrictConfig } from 'vovk';
2
- import { PackageJson } from 'type-fest';
3
- export default function getMetaSchema({ config, package: packageJson, }: {
2
+ export default function getMetaSchema({ config }: {
4
3
  config: VovkStrictConfig;
5
- package: PackageJson;
6
4
  }): {
7
5
  config: VovkStrictConfig;
8
6
  $schema: VovkSchemaIdEnum;
9
- package: {
10
- main: string;
11
- module: string;
12
- types: string;
13
- exports: {
14
- '.': {
15
- import: string;
16
- require: string;
17
- types: string;
18
- };
19
- './schema': {
20
- import: string;
21
- require: string;
22
- types: string;
23
- };
24
- './openapi': {
25
- import: string;
26
- require: string;
27
- types: string;
28
- };
29
- };
30
- name?: string | undefined;
31
- version?: string | undefined;
32
- description?: string | undefined;
33
- author?: PackageJson.Person | undefined;
34
- license?: string | undefined;
35
- };
36
7
  };
@@ -1,31 +1,8 @@
1
1
  import { VovkSchemaIdEnum } from 'vovk';
2
2
  import pick from 'lodash/pick.js';
3
- export default function getMetaSchema({ config, package: packageJson, }) {
3
+ export default function getMetaSchema({ config }) {
4
4
  return {
5
5
  $schema: VovkSchemaIdEnum.META,
6
- package: {
7
- ...pick(packageJson, ['name', 'version', 'description', 'author', 'license']),
8
- main: './index.cjs',
9
- module: './index.mjs',
10
- types: './index.d.mts',
11
- exports: {
12
- '.': {
13
- import: './index.mjs',
14
- require: './index.cjs',
15
- types: './index.d.mts',
16
- },
17
- './schema': {
18
- import: './schema.cjs',
19
- require: './schema.cjs',
20
- types: './schema.d.cts',
21
- },
22
- './openapi': {
23
- import: './openapi.cjs',
24
- require: './openapi.cjs',
25
- types: './openapi.d.cts',
26
- },
27
- },
28
- },
29
6
  ...{
30
7
  config: (config
31
8
  ? pick(config, [...config.emitConfig, '$schema'])
package/dist/index.mjs CHANGED
@@ -138,12 +138,11 @@ program
138
138
  srcRootRequired: false,
139
139
  logLevel: cliBundleOptions.logLevel,
140
140
  });
141
- const { cwd, config, log, isNextInstalled, packageJson } = projectInfo;
141
+ const { cwd, config, log, isNextInstalled } = projectInfo;
142
142
  const fullSchema = await getProjectFullSchema({
143
143
  schemaOutAbsolutePath: path.resolve(cwd, cliBundleOptions?.schema ?? config.schemaOutDir),
144
144
  log,
145
145
  isNextInstalled,
146
- package: packageJson,
147
146
  config,
148
147
  });
149
148
  await bundle({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.341",
3
+ "version": "0.0.1-draft.345",
4
4
  "bin": {
5
5
  "vovk": "./dist/index.mjs"
6
6
  },