@axinom/mosaic-cli 0.54.0-rc.13 → 0.54.0-rc.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-cli",
3
- "version": "0.54.0-rc.13",
3
+ "version": "0.54.0-rc.16",
4
4
  "description": "The Axinom Mosaic CLI",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -24,9 +24,12 @@
24
24
  "ts:validate": "tsc",
25
25
  "build:ci": "yarn workspaces focus && yarn build",
26
26
  "dev": "tsc --watch",
27
- "test": "jest --silent",
28
- "test:ci": "jest --reporters=default --reporters=jest-junit --coverage --coverageReporters=cobertura --coverageReporters=html",
29
- "test:cov": "jest --coverage --silent && yarn posttest:cov",
27
+ "test": "vitest run --silent",
28
+ "test:watch": "vitest watch",
29
+ "test:cov": "vitest run --coverage --silent && yarn posttest:cov",
30
+ "test:debug": "vitest run --inspect-brk --no-file-parallelism",
31
+ "test:ci": "vitest run --reporter=default --reporter=junit --coverage --coverage.reporter=cobertura --coverage.reporter=html",
32
+ "test:ui": "vitest --ui",
30
33
  "posttest:cov": "ts-node ../../scripts/open-test-coverage.ts -- libs/cli",
31
34
  "lint": "eslint . --ext .ts,.tsx,.js --color --cache"
32
35
  },
@@ -34,8 +37,8 @@
34
37
  "@asyncapi/diff": "^0.4.1",
35
38
  "@asyncapi/modelina": "^1.8.4",
36
39
  "@asyncapi/parser": "^2.0.2",
37
- "@axinom/mosaic-id-link-be": "^0.37.0-rc.13",
38
- "@axinom/mosaic-service-common": "^0.67.0-rc.13",
40
+ "@axinom/mosaic-id-link-be": "^0.37.0-rc.16",
41
+ "@axinom/mosaic-service-common": "^0.67.0-rc.16",
39
42
  "@graphql-inspector/core": "^3.1.2",
40
43
  "@inquirer/confirm": "^3.1.0",
41
44
  "@inquirer/core": "^9.1.0",
@@ -71,14 +74,16 @@
71
74
  "@types/diff": "^5.0.0",
72
75
  "@types/node": "^22.0.0",
73
76
  "@types/yargs": "^16",
74
- "jest": "^29",
77
+ "@vitest/ui": "^4.0.18",
78
+ "jest-extended": "^7.0.0",
75
79
  "rimraf": "^3.0.2",
76
80
  "ts-node": "^10.9.1",
77
81
  "typescript": "^5.9.3",
82
+ "vitest": "^4.0.18",
78
83
  "yargs": "^16.2.0"
79
84
  },
80
85
  "publishConfig": {
81
86
  "access": "public"
82
87
  },
83
- "gitHead": "40779318c9b091b23a3aa559734727df3e903741"
88
+ "gitHead": "61cc0e626bb816beee81d16b31c46f1d2a13844d"
84
89
  }
@@ -1,6 +1,6 @@
1
1
  import * as envfile from 'envfile';
2
2
  import { existsSync, readFileSync, writeFileSync } from 'fs';
3
- import 'jest-extended';
3
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
4
4
  import {
5
5
  ConfigTransform,
6
6
  EnvConfigTransform,
@@ -10,19 +10,28 @@ import {
10
10
  import { Vault } from './bitwarden-vault';
11
11
 
12
12
  // mock file system functions
13
- let mockFiles: Record<string, string> = {};
14
- jest.mock('fs', () => ({
15
- existsSync: jest.fn((f) => f.toString() in mockFiles),
16
- readFileSync: jest.fn((f, _) => mockFiles[f.toString()]),
17
- copyFileSync: jest.fn((f1, f2) => (mockFiles[f2] = mockFiles[f1])),
18
- writeFileSync: jest.fn((f, c) => (mockFiles[f.toString()] = c)),
19
- readdirSync: jest.fn((_) => Object.keys(mockFiles)),
13
+ const mockState = vi.hoisted(() => ({
14
+ files: {} as Record<string, string>,
20
15
  }));
21
16
 
22
- jest.mock('../../common/utils', () => ({
23
- getTimestamp: jest.fn(() => '[2023-03-14 10:33:52.223]'),
17
+ vi.mock('fs', () => ({
18
+ existsSync: vi.fn((f) => f.toString() in mockState.files),
19
+ readFileSync: vi.fn((f, _) => mockState.files[f.toString()]),
20
+ copyFileSync: vi.fn((f1, f2) => (mockState.files[f2] = mockState.files[f1])),
21
+ writeFileSync: vi.fn((f, c) => (mockState.files[f.toString()] = c)),
22
+ readdirSync: vi.fn((_) => Object.keys(mockState.files)),
24
23
  }));
25
24
 
25
+ vi.mock('../../common', async () => {
26
+ const actual = await vi.importActual<typeof import('../../common')>(
27
+ '../../common',
28
+ );
29
+ return {
30
+ ...actual,
31
+ getTimestamp: vi.fn(() => '[2023-03-14 10:33:52.223]'),
32
+ };
33
+ });
34
+
26
35
  class MockVault implements Vault {
27
36
  constructor(
28
37
  private values: Record<string, string> = {
@@ -48,7 +57,7 @@ const saveEnv = (
48
57
 
49
58
  describe('applyTemplates', () => {
50
59
  beforeEach(() => {
51
- mockFiles = {};
60
+ mockState.files = {};
52
61
  });
53
62
 
54
63
  describe('sanity', () => {
@@ -5,7 +5,7 @@ import {
5
5
  Parser,
6
6
  } from '@asyncapi/parser';
7
7
  import * as fs from 'fs';
8
- import 'jest-extended';
8
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
9
9
  import { MessageDiffOptions } from './message-diff-options';
10
10
  import { MessageDiff } from './msg-diff';
11
11
 
@@ -20,10 +20,7 @@ describe('sanity', () => {
20
20
  verbose: false,
21
21
  };
22
22
  let msgDiff: MessageDiff;
23
- let consoleSpy: jest.SpyInstance<
24
- void,
25
- [message?: any, ...optionalParams: any[]]
26
- >;
23
+ let consoleSpy: ReturnType<typeof vi.spyOn>;
27
24
 
28
25
  const loadDocument = async (
29
26
  file: string,
@@ -52,13 +49,13 @@ describe('sanity', () => {
52
49
  return document;
53
50
  };
54
51
 
55
- beforeEach(async () => {
56
- consoleSpy = jest.spyOn(console, 'log');
52
+ beforeEach(() => {
53
+ consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => undefined);
57
54
  msgDiff = new MessageDiff(options);
58
55
  });
59
56
 
60
- afterEach(async () => {
61
- jest.restoreAllMocks();
57
+ afterEach(() => {
58
+ vi.restoreAllMocks();
62
59
  });
63
60
 
64
61
  describe('walk', () => {
@@ -1,3 +1,4 @@
1
+ import { describe, expect, test } from 'vitest';
1
2
  import { PgColumn, PgTable, PgType } from '../../abstractions';
2
3
  import { FkColumn } from './fk-column';
3
4
 
@@ -24,19 +25,22 @@ const testData: [string, FkColumnTestInput][] = [
24
25
  ],
25
26
  ];
26
27
  describe('FkColumn', () => {
27
- test.each(testData)('%s', (description: string, input: FkColumnTestInput) => {
28
- // Arrange
29
- const entityTablePk: PgColumn = {
30
- name: 'id',
31
- type: input.pkType,
32
- table: { name: 'entity' } as PgTable,
33
- } as PgColumn;
34
- const propertyTable: PgTable = { name: 'object' } as PgTable;
35
- const fk = new FkColumn(entityTablePk, propertyTable);
36
- const expectedFkName = `${fk.table.name}_${fk.name}_fkey`;
28
+ test.each(testData)(
29
+ '%s',
30
+ (_description: string, input: FkColumnTestInput) => {
31
+ // Arrange
32
+ const entityTablePk: PgColumn = {
33
+ name: 'id',
34
+ type: input.pkType,
35
+ table: { name: 'entity' } as PgTable,
36
+ } as PgColumn;
37
+ const propertyTable: PgTable = { name: 'object' } as PgTable;
38
+ const fk = new FkColumn(entityTablePk, propertyTable);
39
+ const expectedFkName = `${fk.table.name}_${fk.name}_fkey`;
37
40
 
38
- // Act & Assert
39
- expect(fk.buildExpression()).toBe(input.expectedExpression);
40
- expect(fk.fkName).toBe(expectedFkName);
41
- });
41
+ // Act & Assert
42
+ expect(fk.buildExpression()).toBe(input.expectedExpression);
43
+ expect(fk.fkName).toBe(expectedFkName);
44
+ },
45
+ );
42
46
  });
@@ -1,3 +1,4 @@
1
+ import { describe, expect, test } from 'vitest';
1
2
  import { PgTable, PgType } from '../../abstractions';
2
3
  import { PkColumn } from './pk-column';
3
4
 
@@ -24,13 +25,16 @@ const testData: [string, PkColumnTestInput][] = [
24
25
  ];
25
26
 
26
27
  describe('PkColumn', () => {
27
- test.each(testData)('%s', (description: string, input: PkColumnTestInput) => {
28
- // Arrange
29
- const pkColumn = new PkColumn(dummyTable, input.type);
30
-
31
- // Act & Assert
32
- expect(pkColumn.buildExpression()).toBe(input.expectedExpression);
33
- });
28
+ test.each(testData)(
29
+ '%s',
30
+ (_description: string, input: PkColumnTestInput) => {
31
+ // Arrange
32
+ const pkColumn = new PkColumn(dummyTable, input.type);
33
+
34
+ // Act & Assert
35
+ expect(pkColumn.buildExpression()).toBe(input.expectedExpression);
36
+ },
37
+ );
34
38
 
35
39
  test('PK column with unsupported type throws', () => {
36
40
  // Arrange
@@ -1,3 +1,4 @@
1
+ import { describe, expect, test } from 'vitest';
1
2
  import { PgTable } from '../../abstractions';
2
3
  import { PrimitiveColumn } from './primitive-column';
3
4
 
@@ -1,3 +1,4 @@
1
+ import { describe, expect, test } from 'vitest';
1
2
  import { PgColumn, PgTable } from '../../abstractions';
2
3
  import { VirtualFkColumn } from './virtual-fk-column';
3
4
 
@@ -1,4 +1,5 @@
1
1
  import { JSONSchema4 } from 'json-schema';
2
+ import { describe, expect, test } from 'vitest';
2
3
  import { PgType } from '../abstractions';
3
4
  import { getPropertySchema, mapToPgType } from './json-schema-parse-utils';
4
5
 
@@ -115,7 +116,7 @@ describe('mapToPgType', () => {
115
116
  ],
116
117
  ];
117
118
 
118
- test.each(testData)('%s', (description: string, input: TestInput) => {
119
+ test.each(testData)('%s', (_description: string, input: TestInput) => {
119
120
  // Arrange
120
121
  const schema = JSON.parse(input.schemaJson) as JSONSchema4;
121
122
 
@@ -1,3 +1,4 @@
1
+ import { describe, expect, test } from 'vitest';
1
2
  import { buildName } from './pg-sql-gen-utils';
2
3
 
3
4
  describe('buildName', () => {
@@ -1,3 +1,4 @@
1
+ import { describe, expect, test } from 'vitest';
1
2
  import { snakeCaseToCamelCase } from './pgl-utils';
2
3
 
3
4
  describe('snakeCaseToCamelCase', () => {
@@ -1,9 +0,0 @@
1
- const base = require('../../../../../jest.config.base.js');
2
-
3
- /** @type {import('jest').Config} */
4
- module.exports = {
5
- ...base,
6
- displayName: 'publish-schema-to-db',
7
- testEnvironment: 'node',
8
- transformIgnorePatterns: ['^.+\\.js$'],
9
- };