@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 +13 -8
- package/src/commands/apply-templates/apply-templates.spec.ts +20 -11
- package/src/commands/msg-diff/msg-diff.spec.ts +6 -9
- package/src/commands/publish-schema-to-db/pg-models/columns/fk-column.spec.ts +18 -14
- package/src/commands/publish-schema-to-db/pg-models/columns/pk-column.spec.ts +11 -7
- package/src/commands/publish-schema-to-db/pg-models/columns/primitive-column.spec.ts +1 -0
- package/src/commands/publish-schema-to-db/pg-models/columns/virtual-fk-column.spec.ts +1 -0
- package/src/commands/publish-schema-to-db/pg-models/json-schema-parse-utils.spec.ts +2 -1
- package/src/commands/publish-schema-to-db/pg-models/pg-sql-gen-utils.spec.ts +1 -0
- package/src/commands/publish-schema-to-db/pg-models/pgl-utils.spec.ts +1 -0
- package/src/commands/publish-schema-to-db/jest.config.js +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-cli",
|
|
3
|
-
"version": "0.54.0-rc.
|
|
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": "
|
|
28
|
-
"test:
|
|
29
|
-
"test: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.
|
|
38
|
-
"@axinom/mosaic-service-common": "^0.67.0-rc.
|
|
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
|
-
"
|
|
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": "
|
|
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 '
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
|
|
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 '
|
|
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:
|
|
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(
|
|
56
|
-
consoleSpy =
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => undefined);
|
|
57
54
|
msgDiff = new MessageDiff(options);
|
|
58
55
|
});
|
|
59
56
|
|
|
60
|
-
afterEach(
|
|
61
|
-
|
|
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)(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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)(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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,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', (
|
|
119
|
+
test.each(testData)('%s', (_description: string, input: TestInput) => {
|
|
119
120
|
// Arrange
|
|
120
121
|
const schema = JSON.parse(input.schemaJson) as JSONSchema4;
|
|
121
122
|
|