@genesislcap/blank-app-seed 3.14.1 → 3.16.0
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/.genx/configure.js +4 -7
- package/.genx/package.json +2 -1
- package/.genx/templates/csv.hbs +6 -1
- package/.genx/utils.js +72 -3
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/server/build.gradle.kts +9 -1
- package/server/{{appName}}-app/build.gradle.kts +3 -0
- package/server/{{appName}}-app/src/test/kotlin/global/genesis/EventHandlerTest.kt +27 -0
- package/server/{{appName}}-app/src/test/resources/genesisHome/.gitkeep +0 -0
package/.genx/configure.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const versions = require('./versions.json');
|
|
2
|
-
const { registerPartials, generateRoute,
|
|
2
|
+
const { registerPartials, generateRoute, generateCsv, getCombinedCsvData, formatRouteData, validateRoute } = require('./utils');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Signature is `async (data: inquirer.Answers, utils: SeedConfigurationUtils)`
|
|
@@ -30,11 +30,8 @@ module.exports = async (data, utils) => {
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
data.csv
|
|
33
|
-
.map(entity => (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}))
|
|
37
|
-
.forEach(entity => {
|
|
38
|
-
generateEmptyCsv(entity, data.appName, utils);
|
|
33
|
+
.map((entity) => getCombinedCsvData(entity))
|
|
34
|
+
.forEach((entity) => {
|
|
35
|
+
generateCsv(entity, utils);
|
|
39
36
|
});
|
|
40
37
|
};
|
package/.genx/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/blank-app-seed-config",
|
|
3
3
|
"description": "Genesis Blank App Seed Configuration",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.16.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"genxSeedConfig": {
|
|
7
7
|
"exclude": [
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
".sh",
|
|
36
36
|
".json",
|
|
37
37
|
".js",
|
|
38
|
+
".kt",
|
|
38
39
|
".kts",
|
|
39
40
|
".ts",
|
|
40
41
|
".md",
|
package/.genx/templates/csv.hbs
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
{{#each entity.fields}}{{this.name}}{{#unless this.isLast }},{{/unless}}{{/each}}
|
|
1
|
+
{{#each entity.fields}}{{this.name}}{{#unless this.isLast }},{{/unless}}{{/each}}
|
|
2
|
+
{{#if entity.data}}
|
|
3
|
+
{{#each entity.data}}
|
|
4
|
+
{{#each this.rows}}{{this.name}}{{#unless this.isLast }},{{/unless}}{{/each}}
|
|
5
|
+
{{/each}}
|
|
6
|
+
{{/if}}
|
package/.genx/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {existsSync, mkdirSync} = require('node:fs');
|
|
1
|
+
const {existsSync, mkdirSync, readFileSync} = require('node:fs');
|
|
2
2
|
const { resolve } = require('node:path');
|
|
3
3
|
|
|
4
4
|
const makeDirectory = (directory) => {
|
|
@@ -25,10 +25,78 @@ const generateRoute = (route, { writeFileWithData, changeCase }) => {
|
|
|
25
25
|
writeFileWithData(resolve(__dirname, `../client/src/routes/${routeName}/${routeName}.styles.ts`), {route}, resolve(__dirname, 'templates/route.styles.hbs'));
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const generateCsv = (entity, { writeFileWithData }) => {
|
|
29
29
|
writeFileWithData(resolve(__dirname, `../server/{{appName}}-app/src/main/genesis/data/${entity.name}.csv`), {entity}, resolve(__dirname, 'templates/csv.hbs'));
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const prepareCsvData = (entity) => {
|
|
33
|
+
if (!entity.data?.length) return null;
|
|
34
|
+
|
|
35
|
+
const data = entity.data.map((rows) => ({
|
|
36
|
+
rows: rows?.map((x, index) => ({
|
|
37
|
+
name: x,
|
|
38
|
+
isLast: index === rows.length - 1,
|
|
39
|
+
})),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
function csvToObject(csv) {
|
|
46
|
+
const lines = csv
|
|
47
|
+
.split('\n')
|
|
48
|
+
.map((x) => x.replaceAll('"', ''))
|
|
49
|
+
.filter((line) => line.trim() !== '');
|
|
50
|
+
const fieldsRow = lines[0].split(',').map((field) => field.trim());
|
|
51
|
+
const fields = fieldsRow.map((field, index) => ({
|
|
52
|
+
name: field.toUpperCase(),
|
|
53
|
+
isLast: index === fieldsRow.length - 1,
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
const data = lines.slice(1).map((line) => {
|
|
57
|
+
const rows = line.split(',').map((value, index) => ({
|
|
58
|
+
name: value.trim(),
|
|
59
|
+
isLast: index === fieldsRow.length - 1,
|
|
60
|
+
}));
|
|
61
|
+
return { rows };
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return { fields, data };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const getCombinedCsvData = (entity) => {
|
|
68
|
+
let csvFile;
|
|
69
|
+
const combinedCsv = {
|
|
70
|
+
name: entity.name.toUpperCase(),
|
|
71
|
+
fields: entity.fields?.map((field, index) => ({
|
|
72
|
+
name: field.toUpperCase(),
|
|
73
|
+
isLast: index === entity.fields.length - 1,
|
|
74
|
+
})),
|
|
75
|
+
data: prepareCsvData(entity),
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
if (entity.mode?.toLowerCase() === 'append') {
|
|
79
|
+
const path = resolve(
|
|
80
|
+
__dirname,
|
|
81
|
+
`../server/{{appName}}-app/src/main/genesis/data/${entity.name}.csv`
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
csvFile = readFileSync(path, 'utf8');
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.log('File to append not found - creating a new CSV file');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (csvFile) {
|
|
91
|
+
const existingCsv = csvToObject(csvFile);
|
|
92
|
+
combinedCsv.fields = existingCsv.fields;
|
|
93
|
+
combinedCsv.data = [...existingCsv.data, ...prepareCsvData(entity)];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return combinedCsv;
|
|
98
|
+
};
|
|
99
|
+
|
|
32
100
|
const formatJSONValue = (value) => {
|
|
33
101
|
try {
|
|
34
102
|
return value ? JSON.stringify(value, null, 2) : undefined;
|
|
@@ -137,7 +205,8 @@ module.exports = {
|
|
|
137
205
|
registerPartials,
|
|
138
206
|
generateRoute,
|
|
139
207
|
validateRoute,
|
|
140
|
-
|
|
208
|
+
generateCsv,
|
|
209
|
+
getCombinedCsvData,
|
|
141
210
|
formatRouteData,
|
|
142
211
|
parseJSONArgument,
|
|
143
212
|
};
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.16.0](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.15.0...v3.16.0) (2024-06-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* Add test dependencies to server in blank-app-seed GENC-543 (#259) d87c4f9
|
|
9
|
+
|
|
10
|
+
## [3.15.0](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.14.1...v3.15.0) (2024-06-20)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* ability to add/append data to csv files GENC-473 (#260) 7b337ff
|
|
16
|
+
|
|
3
17
|
## [3.14.1](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.14.0...v3.14.1) (2024-06-18)
|
|
4
18
|
|
|
5
19
|
|
package/package.json
CHANGED
package/server/build.gradle.kts
CHANGED
|
@@ -9,6 +9,7 @@ subprojects {
|
|
|
9
9
|
|
|
10
10
|
dependencies {
|
|
11
11
|
implementation("com.h2database:h2:2.2.224")
|
|
12
|
+
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5:1.9.0")
|
|
12
13
|
}
|
|
13
14
|
tasks {
|
|
14
15
|
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
|
@@ -86,5 +87,12 @@ allprojects {
|
|
|
86
87
|
from(components["java"])
|
|
87
88
|
}
|
|
88
89
|
}
|
|
90
|
+
tasks{
|
|
91
|
+
test {
|
|
92
|
+
systemProperty("DbLayer", "SQL")
|
|
93
|
+
systemProperty("DbHost", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1")
|
|
94
|
+
systemProperty("DbQuotedIdentifiers", "true")
|
|
95
|
+
useJUnitPlatform()
|
|
96
|
+
}
|
|
97
|
+
}
|
|
89
98
|
}
|
|
90
|
-
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
dependencies {
|
|
2
2
|
compileOnly(genesis("script-dependencies"))
|
|
3
3
|
genesisGeneratedCode(withTestDependency = true)
|
|
4
|
+
testImplementation(genesis("dbtest"))
|
|
5
|
+
testImplementation(genesis("testsupport"))
|
|
6
|
+
testImplementation(genesis("pal-eventhandler"))
|
|
4
7
|
}
|
|
5
8
|
|
|
6
9
|
description = "{{appName}}-app"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full documentation on event handler tests may be found here >> https://learn.genesis.global/docs/server/event-handler/testing/#simple-test
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import global.genesis.db.rx.entity.multi.AsyncEntityDb
|
|
6
|
+
import global.genesis.testsupport.client.eventhandler.EventClientSync
|
|
7
|
+
import global.genesis.testsupport.jupiter.GenesisJunit
|
|
8
|
+
import global.genesis.testsupport.jupiter.ScriptFile
|
|
9
|
+
import javax.inject.Inject
|
|
10
|
+
import org.junit.jupiter.api.Test
|
|
11
|
+
import org.junit.jupiter.api.extension.ExtendWith
|
|
12
|
+
|
|
13
|
+
@ExtendWith(GenesisJunit::class)
|
|
14
|
+
@ScriptFile("{{appName}}-eventhandler.kts")
|
|
15
|
+
class EventHandlerTest {
|
|
16
|
+
@Inject
|
|
17
|
+
lateinit var client: EventClientSync
|
|
18
|
+
|
|
19
|
+
@Inject
|
|
20
|
+
lateinit var entityDb: AsyncEntityDb
|
|
21
|
+
|
|
22
|
+
@Test
|
|
23
|
+
fun `test EventHandler`(){
|
|
24
|
+
//TODO Write Test
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
File without changes
|