vovk-cli 0.0.1-draft.67 → 0.0.1-draft.69

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.
@@ -9,29 +9,39 @@ import formatLoggedSegmentName from '../utils/formatLoggedSegmentName.mjs';
9
9
  export default async function ensureSchemaFiles(projectInfo, schemaOutAbsolutePath, segmentNames) {
10
10
  const now = Date.now();
11
11
  let hasChanged = false;
12
- const indexContent = `// auto-generated
12
+ const jsContent = `// auto-generated
13
13
  ${segmentNames
14
14
  .map((segmentName) => {
15
15
  return `module.exports['${segmentName}'] = require('./${segmentName || ROOT_SEGMENT_SCHEMA_NAME}.json');`;
16
16
  })
17
17
  .join('\n')}`;
18
18
  const dTsContent = `// auto-generated
19
- import type { VovkSchema } from 'vovk';
20
19
  declare const fullSchema: {
21
- ${segmentNames.map((segmentName) => ` '${segmentName}': import('${segmentName}.json');`).join('\n')}
20
+ ${segmentNames.map((segmentName) => ` '${segmentName}': typeof import('./${segmentName || ROOT_SEGMENT_SCHEMA_NAME}.json');`).join('\n')}
22
21
  };
23
22
  export default fullSchema;`;
24
- const jsAbsolutePath = path.join(schemaOutAbsolutePath, 'index.cjs');
25
- const dTsAbsolutePath = path.join(schemaOutAbsolutePath, 'index.d.cts');
23
+ const tsContent = `// auto-generated
24
+ ${segmentNames.map((segmentName, i) => `import segment${i} from './${segmentName || ROOT_SEGMENT_SCHEMA_NAME}.json';`).join('\n')}
25
+ const fullSchema = {
26
+ ${segmentNames.map((segmentName, i) => ` '${segmentName}': segment${i},`).join('\n')}
27
+ };
28
+ export default fullSchema;`;
29
+ const jsAbsolutePath = path.join(schemaOutAbsolutePath, 'main.cjs');
30
+ const dTsAbsolutePath = path.join(schemaOutAbsolutePath, 'main.d.cts');
31
+ const tsAbsolutePath = path.join(schemaOutAbsolutePath, 'index.ts');
26
32
  const existingJs = await fs.readFile(jsAbsolutePath, 'utf-8').catch(() => null);
27
33
  const existingDTs = await fs.readFile(dTsAbsolutePath, 'utf-8').catch(() => null);
34
+ const existingTs = await fs.readFile(tsAbsolutePath, 'utf-8').catch(() => null);
28
35
  await fs.mkdir(schemaOutAbsolutePath, { recursive: true });
29
- if (existingJs !== indexContent) {
30
- await fs.writeFile(jsAbsolutePath, indexContent);
36
+ if (existingJs !== jsContent) {
37
+ await fs.writeFile(jsAbsolutePath, jsContent);
31
38
  }
32
39
  if (existingDTs !== dTsContent) {
33
40
  await fs.writeFile(dTsAbsolutePath, dTsContent);
34
41
  }
42
+ if (existingTs !== tsContent) {
43
+ await fs.writeFile(tsAbsolutePath, tsContent);
44
+ }
35
45
  // Create JSON files (if not exist) with name [segmentName].json (where segmentName can include /, which means the folder structure can be nested)
36
46
  await Promise.all(segmentNames.map(async (segmentName) => {
37
47
  const { isCreated } = await writeOneSchemaFile({
@@ -9,7 +9,7 @@ export default async function getProjectInfo({ port: givenPort, clientOutDir, cw
9
9
  const apiRoot = `${config.origin ?? ''}/${config.rootEntry}`;
10
10
  const apiDir = path.join(srcRoot, 'app', config.rootEntry);
11
11
  const schemaOutImportPath = path.relative(config.clientOutDir, config.schemaOutDir).replace(/\\/g, '/') + // windows fix
12
- '/index.cjs';
12
+ '/main.cjs';
13
13
  const log = getLogger(config.logLevel);
14
14
  if (configAbsolutePaths.length > 1) {
15
15
  log.warn(`Multiple config files found. Using the first one: ${configAbsolutePaths[0]}`);
package/dist/index.mjs CHANGED
@@ -83,7 +83,7 @@ program
83
83
  const { cwd, config, apiDir } = projectInfo;
84
84
  const segments = await locateSegments({ dir: apiDir, config });
85
85
  const schemaOutAbsolutePath = path.join(cwd, config.schemaOutDir);
86
- const schemaImportUrl = pathToFileURL(path.join(schemaOutAbsolutePath, 'index.cjs')).href;
86
+ const schemaImportUrl = pathToFileURL(path.join(schemaOutAbsolutePath, 'main.cjs')).href;
87
87
  const { default: segmentsSchema } = (await import(schemaImportUrl));
88
88
  await generate({
89
89
  projectInfo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk-cli",
3
- "version": "0.0.1-draft.67",
3
+ "version": "0.0.1-draft.69",
4
4
  "bin": {
5
5
  "vovk": "./dist/index.mjs"
6
6
  },
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "homepage": "https://vovk.dev",
38
38
  "peerDependencies": {
39
- "vovk": "^3.0.0-draft.66"
39
+ "vovk": "^3.0.0-draft.67"
40
40
  },
41
41
  "dependencies": {
42
42
  "@inquirer/prompts": "^7.3.1",