@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.
Files changed (33) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +2 -2
  3. package/changelog.md +6 -0
  4. package/dist/src/generator.js +13 -13
  5. package/dist/src/generators/enums/react.generator.js +55 -55
  6. package/dist/src/generators/enums/types.generator.js +8 -8
  7. package/dist/src/generators/indices/datamockmodule.generator.js +46 -46
  8. package/dist/src/generators/indices/datamodule.generator.js +76 -76
  9. package/dist/src/generators/indices/dataservice.generator.js +26 -26
  10. package/dist/src/generators/indices/repositories.generator.js +3 -3
  11. package/dist/src/generators/indices/testdataservice.generator.js +22 -22
  12. package/dist/src/generators/models/react.generator/context.generator.js +47 -47
  13. package/dist/src/generators/models/react.generator/index.js +8 -8
  14. package/dist/src/generators/models/react.generator/library.generator.js +66 -66
  15. package/dist/src/generators/models/react.generator/lookup.generator.js +75 -75
  16. package/dist/src/generators/models/react.generator/modals.generator.js +261 -261
  17. package/dist/src/generators/models/repository.generator.js +239 -239
  18. package/dist/src/generators/models/route.generator.js +45 -45
  19. package/dist/src/generators/models/seed.generator.js +14 -14
  20. package/dist/src/generators/models/stub.generator.js +19 -19
  21. package/dist/src/generators/models/types.generator.js +39 -39
  22. package/dist/src/lib/meta.d.ts +7 -7
  23. package/dist/src/lib/meta.js +4 -4
  24. package/dist/src/lib/vfs.js +2 -2
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/jest.config.ts +18 -18
  27. package/package.json +1 -1
  28. package/tests/attributes.test.ts +91 -91
  29. package/tests/file.test.ts +32 -32
  30. package/tests/schemas/la/la.prisma +862 -862
  31. package/tests/schemas/mca/mca.prisma +528 -528
  32. package/tests/utils/random.ts +11 -11
  33. package/tests/vfs.test.ts +92 -92
@@ -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
+ })