@postxl/generator 0.0.19 → 0.0.21
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/CHANGELOG.md +7 -0
- package/README.md +2 -2
- package/changelog.md +6 -0
- package/dist/src/generator.js +13 -13
- package/dist/src/generators/enums/react.generator.js +55 -55
- package/dist/src/generators/enums/types.generator.js +8 -8
- package/dist/src/generators/indices/datamockmodule.generator.js +46 -46
- package/dist/src/generators/indices/datamodule.generator.js +76 -76
- package/dist/src/generators/indices/dataservice.generator.js +26 -26
- package/dist/src/generators/indices/repositories.generator.js +3 -3
- package/dist/src/generators/indices/testdataservice.generator.js +22 -22
- package/dist/src/generators/models/react.generator/context.generator.js +47 -47
- package/dist/src/generators/models/react.generator/index.js +8 -8
- package/dist/src/generators/models/react.generator/library.generator.js +66 -66
- package/dist/src/generators/models/react.generator/lookup.generator.js +75 -75
- package/dist/src/generators/models/react.generator/modals.generator.js +261 -261
- package/dist/src/generators/models/repository.generator.js +239 -239
- package/dist/src/generators/models/route.generator.js +45 -45
- package/dist/src/generators/models/seed.generator.js +14 -14
- package/dist/src/generators/models/stub.generator.js +19 -19
- package/dist/src/generators/models/types.generator.js +39 -39
- package/dist/src/lib/meta.d.ts +7 -7
- package/dist/src/lib/meta.js +4 -4
- package/dist/src/lib/vfs.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jest.config.ts +18 -18
- package/package.json +1 -1
- package/tests/attributes.test.ts +91 -91
- package/tests/file.test.ts +32 -32
- package/tests/schemas/la/la.prisma +862 -862
- package/tests/schemas/mca/mca.prisma +528 -528
- package/tests/utils/random.ts +11 -11
- package/tests/vfs.test.ts +92 -92
package/tests/utils/random.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const ALPHANUMERIC_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
2
|
-
|
|
3
|
-
export namespace RandomUtils {
|
|
4
|
-
export function generateRandomAlphaNumericString(len: number): string {
|
|
5
|
-
let text = ''
|
|
6
|
-
for (let i = 0; i < len; i++) {
|
|
7
|
-
text += ALPHANUMERIC_CHARS.charAt(Math.floor(Math.random() * ALPHANUMERIC_CHARS.length))
|
|
8
|
-
}
|
|
9
|
-
return text
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
const ALPHANUMERIC_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
2
|
+
|
|
3
|
+
export namespace RandomUtils {
|
|
4
|
+
export function generateRandomAlphaNumericString(len: number): string {
|
|
5
|
+
let text = ''
|
|
6
|
+
for (let i = 0; i < len; i++) {
|
|
7
|
+
text += ALPHANUMERIC_CHARS.charAt(Math.floor(Math.random() * ALPHANUMERIC_CHARS.length))
|
|
8
|
+
}
|
|
9
|
+
return text
|
|
10
|
+
}
|
|
11
|
+
}
|
package/tests/vfs.test.ts
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
import { VirtualFS } from '../src/lib/vfs'
|
|
2
|
-
import { RandomUtils } from './utils/random'
|
|
3
|
-
|
|
4
|
-
function adjustPathToOS(path: string) {
|
|
5
|
-
return path.replace(/\//g, process.platform === 'win32' ? '\\' : '/')
|
|
6
|
-
}
|
|
7
|
-
describe('virtual file system', () => {
|
|
8
|
-
test('IO works', () => {
|
|
9
|
-
const vfs = new VirtualFS()
|
|
10
|
-
|
|
11
|
-
const files = []
|
|
12
|
-
|
|
13
|
-
for (let depth = 0; depth < 100; depth++) {
|
|
14
|
-
const path = '/folder'.repeat(depth) + '/file.txt'
|
|
15
|
-
const content = RandomUtils.generateRandomAlphaNumericString(160)
|
|
16
|
-
const status = vfs.write(path, content)
|
|
17
|
-
|
|
18
|
-
expect(status.ok).toBeTruthy()
|
|
19
|
-
|
|
20
|
-
files.push({ path, content })
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
for (const { path, content } of files) {
|
|
24
|
-
const file = vfs.read(path)
|
|
25
|
-
expect(file).toEqual({ ok: true, content })
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
test('lists files correctly', () => {
|
|
30
|
-
const vfs = new VirtualFS()
|
|
31
|
-
|
|
32
|
-
vfs.write('/a.txt', 'a')
|
|
33
|
-
vfs.write('/b.txt', 'b')
|
|
34
|
-
vfs.write('/c.txt', 'c')
|
|
35
|
-
|
|
36
|
-
vfs.write('/sub/a.txt', 'a')
|
|
37
|
-
vfs.write('/sub/b.txt', 'b')
|
|
38
|
-
vfs.write('/sub/c.txt', 'c')
|
|
39
|
-
|
|
40
|
-
const files = vfs.list('/')
|
|
41
|
-
const subFiles = vfs.list('/sub')
|
|
42
|
-
|
|
43
|
-
expect(files).toHaveLength(4)
|
|
44
|
-
expect(files).toContainEqual({ kind: 'FILE', name: 'a.txt' })
|
|
45
|
-
expect(files).toContainEqual({ kind: 'FILE', name: 'b.txt' })
|
|
46
|
-
expect(files).toContainEqual({ kind: 'FILE', name: 'c.txt' })
|
|
47
|
-
expect(files).toContainEqual({ kind: 'FOLDER', name: 'sub' })
|
|
48
|
-
|
|
49
|
-
expect(subFiles).toHaveLength(3)
|
|
50
|
-
expect(subFiles).toContainEqual({ kind: 'FILE', name: 'a.txt' })
|
|
51
|
-
expect(subFiles).toContainEqual({ kind: 'FILE', name: 'b.txt' })
|
|
52
|
-
expect(subFiles).toContainEqual({ kind: 'FILE', name: 'c.txt' })
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
test('lists folders correctly', () => {
|
|
56
|
-
const vfs = new VirtualFS()
|
|
57
|
-
|
|
58
|
-
vfs.write('/a/b/a/file.txt', 'a')
|
|
59
|
-
vfs.write('/a/b/b/file.txt', 'b')
|
|
60
|
-
vfs.write('/a/b/c/file.txt', 'c')
|
|
61
|
-
vfs.write('/a/b/d/file.txt', 'd')
|
|
62
|
-
|
|
63
|
-
const folders = vfs.list('/a/b')
|
|
64
|
-
|
|
65
|
-
expect(folders).toHaveLength(4)
|
|
66
|
-
expect(folders).toContainEqual({ kind: 'FOLDER', name: 'a' })
|
|
67
|
-
expect(folders).toContainEqual({ kind: 'FOLDER', name: 'b' })
|
|
68
|
-
expect(folders).toContainEqual({ kind: 'FOLDER', name: 'c' })
|
|
69
|
-
expect(folders).toContainEqual({ kind: 'FOLDER', name: 'd' })
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('copies files correctly', () => {
|
|
73
|
-
const vfs = new VirtualFS()
|
|
74
|
-
|
|
75
|
-
const src = new VirtualFS()
|
|
76
|
-
src.write('/a.txt', 'a')
|
|
77
|
-
src.write('/b.txt', 'b')
|
|
78
|
-
src.write('/c.txt', 'c')
|
|
79
|
-
|
|
80
|
-
vfs.copy(src, '/')
|
|
81
|
-
vfs.copy(src, '/sub')
|
|
82
|
-
|
|
83
|
-
expect(vfs.files()).toEqual({
|
|
84
|
-
[adjustPathToOS('/a.txt')]: 'a',
|
|
85
|
-
[adjustPathToOS('/b.txt')]: 'b',
|
|
86
|
-
[adjustPathToOS('/c.txt')]: 'c',
|
|
87
|
-
[adjustPathToOS('/sub/a.txt')]: 'a',
|
|
88
|
-
[adjustPathToOS('/sub/b.txt')]: 'b',
|
|
89
|
-
[adjustPathToOS('/sub/c.txt')]: 'c',
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
})
|
|
1
|
+
import { VirtualFS } from '../src/lib/vfs'
|
|
2
|
+
import { RandomUtils } from './utils/random'
|
|
3
|
+
|
|
4
|
+
function adjustPathToOS(path: string) {
|
|
5
|
+
return path.replace(/\//g, process.platform === 'win32' ? '\\' : '/')
|
|
6
|
+
}
|
|
7
|
+
describe('virtual file system', () => {
|
|
8
|
+
test('IO works', () => {
|
|
9
|
+
const vfs = new VirtualFS()
|
|
10
|
+
|
|
11
|
+
const files = []
|
|
12
|
+
|
|
13
|
+
for (let depth = 0; depth < 100; depth++) {
|
|
14
|
+
const path = '/folder'.repeat(depth) + '/file.txt'
|
|
15
|
+
const content = RandomUtils.generateRandomAlphaNumericString(160)
|
|
16
|
+
const status = vfs.write(path, content)
|
|
17
|
+
|
|
18
|
+
expect(status.ok).toBeTruthy()
|
|
19
|
+
|
|
20
|
+
files.push({ path, content })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
for (const { path, content } of files) {
|
|
24
|
+
const file = vfs.read(path)
|
|
25
|
+
expect(file).toEqual({ ok: true, content })
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('lists files correctly', () => {
|
|
30
|
+
const vfs = new VirtualFS()
|
|
31
|
+
|
|
32
|
+
vfs.write('/a.txt', 'a')
|
|
33
|
+
vfs.write('/b.txt', 'b')
|
|
34
|
+
vfs.write('/c.txt', 'c')
|
|
35
|
+
|
|
36
|
+
vfs.write('/sub/a.txt', 'a')
|
|
37
|
+
vfs.write('/sub/b.txt', 'b')
|
|
38
|
+
vfs.write('/sub/c.txt', 'c')
|
|
39
|
+
|
|
40
|
+
const files = vfs.list('/')
|
|
41
|
+
const subFiles = vfs.list('/sub')
|
|
42
|
+
|
|
43
|
+
expect(files).toHaveLength(4)
|
|
44
|
+
expect(files).toContainEqual({ kind: 'FILE', name: 'a.txt' })
|
|
45
|
+
expect(files).toContainEqual({ kind: 'FILE', name: 'b.txt' })
|
|
46
|
+
expect(files).toContainEqual({ kind: 'FILE', name: 'c.txt' })
|
|
47
|
+
expect(files).toContainEqual({ kind: 'FOLDER', name: 'sub' })
|
|
48
|
+
|
|
49
|
+
expect(subFiles).toHaveLength(3)
|
|
50
|
+
expect(subFiles).toContainEqual({ kind: 'FILE', name: 'a.txt' })
|
|
51
|
+
expect(subFiles).toContainEqual({ kind: 'FILE', name: 'b.txt' })
|
|
52
|
+
expect(subFiles).toContainEqual({ kind: 'FILE', name: 'c.txt' })
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('lists folders correctly', () => {
|
|
56
|
+
const vfs = new VirtualFS()
|
|
57
|
+
|
|
58
|
+
vfs.write('/a/b/a/file.txt', 'a')
|
|
59
|
+
vfs.write('/a/b/b/file.txt', 'b')
|
|
60
|
+
vfs.write('/a/b/c/file.txt', 'c')
|
|
61
|
+
vfs.write('/a/b/d/file.txt', 'd')
|
|
62
|
+
|
|
63
|
+
const folders = vfs.list('/a/b')
|
|
64
|
+
|
|
65
|
+
expect(folders).toHaveLength(4)
|
|
66
|
+
expect(folders).toContainEqual({ kind: 'FOLDER', name: 'a' })
|
|
67
|
+
expect(folders).toContainEqual({ kind: 'FOLDER', name: 'b' })
|
|
68
|
+
expect(folders).toContainEqual({ kind: 'FOLDER', name: 'c' })
|
|
69
|
+
expect(folders).toContainEqual({ kind: 'FOLDER', name: 'd' })
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test('copies files correctly', () => {
|
|
73
|
+
const vfs = new VirtualFS()
|
|
74
|
+
|
|
75
|
+
const src = new VirtualFS()
|
|
76
|
+
src.write('/a.txt', 'a')
|
|
77
|
+
src.write('/b.txt', 'b')
|
|
78
|
+
src.write('/c.txt', 'c')
|
|
79
|
+
|
|
80
|
+
vfs.copy(src, '/')
|
|
81
|
+
vfs.copy(src, '/sub')
|
|
82
|
+
|
|
83
|
+
expect(vfs.files()).toEqual({
|
|
84
|
+
[adjustPathToOS('/a.txt')]: 'a',
|
|
85
|
+
[adjustPathToOS('/b.txt')]: 'b',
|
|
86
|
+
[adjustPathToOS('/c.txt')]: 'c',
|
|
87
|
+
[adjustPathToOS('/sub/a.txt')]: 'a',
|
|
88
|
+
[adjustPathToOS('/sub/b.txt')]: 'b',
|
|
89
|
+
[adjustPathToOS('/sub/c.txt')]: 'c',
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
})
|