-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
85 changed files
with
4,143 additions
and
4,681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import assert from 'node:assert'; | ||
import { existsSync } from 'node:fs'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { intersection } from 'lodash-es'; | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
export const prepareSampleEntry = sampleData => { | ||
const [sample, data = {}] = Array.isArray(sampleData) ? sampleData : [sampleData]; | ||
const clientFrameworks = ['angular', 'vue', 'react']; | ||
const authenticationTypes = ['jwt', 'oauth2']; | ||
const databaseTypes = ['mysql', 'mssql', 'postgresql', 'mongodb']; | ||
|
||
let split = sample.split('-'); | ||
if (!split.includes('jdl')) { | ||
assert(existsSync(path.join(__dirname, '../templates/samples', `${sample}`)), `The sample ${sample} does not exist.`); | ||
return [ | ||
sample, | ||
{ | ||
'sample-file': sample, | ||
'legacy-template-name': sample, | ||
'legacy-sample-file': sample, | ||
'sample-folder': 'samples/', | ||
'sample-type': 'yo-rc', | ||
...data, | ||
}, | ||
]; | ||
} | ||
|
||
intersection(clientFrameworks, split); | ||
const clientFramework = intersection(clientFrameworks, split)[0]; | ||
const authenticationType = intersection(authenticationTypes, split)[0]; | ||
const databaseType = intersection(databaseTypes, split)[0]; | ||
split = split | ||
.filter(s => s !== 'jdl') | ||
.map(s => (s === clientFramework ? 'client' : s === authenticationType ? 'auth' : s === databaseType ? 'database' : s)); | ||
|
||
const generatorOptions = {}; | ||
|
||
if (clientFramework) { | ||
generatorOptions.clientFramework = clientFramework; | ||
} | ||
if (authenticationType) { | ||
generatorOptions.authenticationType = authenticationType; | ||
} | ||
if (databaseType) { | ||
generatorOptions.prodDatabaseType = databaseType; | ||
} | ||
|
||
const sampleFile = [...split, 'template', 'jdl'].join('-'); | ||
const file = path.join(__dirname, '../templates/samples', `${sampleFile}.jdl`); | ||
assert(existsSync(file), `The sample ${file} does not exist.`); | ||
|
||
return [ | ||
sample, | ||
{ | ||
'sample-file': sampleFile, | ||
'legacy-template-name': sample, | ||
'legacy-sample-file': sampleFile, | ||
'sample-folder': 'samples/', | ||
'sample-type': 'jdl', | ||
generatorOptions, | ||
...data, | ||
}, | ||
]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { prepareSampleEntry } from '../support/prepare-sample.js'; | ||
|
||
const samples = [ | ||
'monolith-angular-jwt-jdl', | ||
'monolith-angular-jwt-i18n-jdl', | ||
'monolith-angular-oauth2-jdl', | ||
['monolith-angular-oauth2-mongodb-jdl', { 'legacy-sample-file': 'monolith-angular-auth-mongodb-template-jdl', e2e: 'false' }], | ||
'monolith-angular-oauth2-i18n-jdl', | ||
'monolith-angular-jwt-i18n-dev', | ||
['monolith-angular-jwt-mongodb-jdl', { 'legacy-sample-file': 'monolith-client-auth-database-template-jdl', e2e: 'false' }], | ||
'monolith-angular-mssql-prod-jdl', | ||
'monolith-angular-postgresql-prod-jdl', | ||
]; | ||
|
||
export default Object.fromEntries(samples.map(sample => prepareSampleEntry(sample))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
'microservice-oauth2-jdl': { | ||
'sample-folder': 'samples/', | ||
'sample-type': 'jdl', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { prepareSampleEntry } from '../support/prepare-sample.js'; | ||
|
||
const samples = [ | ||
'monolith-react-jwt-jdl', | ||
'monolith-react-jwt-i18n-jdl', | ||
'monolith-react-oauth2-jdl', | ||
'monolith-react-oauth2-i18n-jdl', | ||
'monolith-react-mysql-prod-jdl', | ||
['monolith-react-mongodb-prod-jdl', { 'legacy-sample-file': 'monolith-client-database-prod-template-jdl', e2e: 'false' }], | ||
'monolith-react-oauth2-dev', | ||
]; | ||
|
||
export default Object.fromEntries(samples.map(sample => prepareSampleEntry(sample))); |
Oops, something went wrong.