-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
78ccc92
commit 14299ff
Showing
3 changed files
with
59 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"commonjs": true, | ||
"es2021": true | ||
}, | ||
|
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 |
---|---|---|
@@ -1,66 +1,66 @@ | ||
exports.newAppSchemas = function () { | ||
|
||
let thisObject = { | ||
initialize: initialize | ||
} | ||
let thisObject = { | ||
initialize: initialize | ||
} | ||
|
||
return thisObject | ||
return thisObject | ||
|
||
async function initialize() { | ||
/* | ||
Here we will load into memory all the APP_SCHEMA files of every project. | ||
*/ | ||
async function initialize() { | ||
/* | ||
Here we will load into memory all the APP_SCHEMA files of every project. | ||
*/ | ||
|
||
await loadAppSchemas() | ||
await loadAppSchemas() | ||
|
||
async function loadAppSchemas() { | ||
async function loadAppSchemas() { | ||
|
||
return new Promise(loadAppSchemasForAllProjects) | ||
return new Promise(loadAppSchemasForAllProjects) | ||
|
||
function loadAppSchemasForAllProjects(resolve, reject) { | ||
function loadAppSchemasForAllProjects(resolve, reject) { | ||
|
||
let projectsLoaded = 0 | ||
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) { | ||
let projectDefinition = PROJECTS_SCHEMA[i] | ||
loadAppSchemasForProject(projectDefinition.name) | ||
} | ||
let projectsLoaded = 0 | ||
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) { | ||
let projectDefinition = PROJECTS_SCHEMA[i] | ||
loadAppSchemasForProject(projectDefinition.name) | ||
} | ||
|
||
function loadAppSchemasForProject(project) { | ||
function loadAppSchemasForProject(project) { | ||
|
||
let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/' | ||
let folder = 'App-Schema' | ||
let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/' | ||
let folder = 'App-Schema' | ||
|
||
SA.projects.foundations.utilities.filesAndDirectories.getAllFilesInDirectoryAndSubdirectories(filePath + folder, onFilesReady) | ||
SA.projects.foundations.utilities.filesAndDirectories.getAllFilesInDirectoryAndSubdirectories(filePath + folder, onFilesReady) | ||
|
||
function onFilesReady(files) { | ||
function onFilesReady(files) { | ||
|
||
for (let k = 0; k < files.length; k++) { | ||
let name = files[k] | ||
let nameSplitted = name.split(folder) | ||
let fileName = nameSplitted[1] | ||
for (let i = 0; i < 10; i++) { | ||
fileName = fileName.replace('\\', '/') | ||
} | ||
let fileToRead = filePath + folder + fileName | ||
for (let k = 0; k < files.length; k++) { | ||
let name = files[k] | ||
let nameSplitted = name.split(folder) | ||
let fileName = nameSplitted[1] | ||
for (let i = 0; i < 10; i++) { | ||
fileName = fileName.replace('\\', '/') | ||
} | ||
let fileToRead = filePath + folder + fileName | ||
|
||
let fileContent = SA.nodeModules.fs.readFileSync(fileToRead) | ||
let schemaDocument | ||
try { | ||
schemaDocument = JSON.parse(fileContent) | ||
SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.set(project + '-' + schemaDocument.type, schemaDocument) | ||
} catch (err) { | ||
console.log('[WARN] loadAppSchemasForProject -> Error Parsing JSON File: ' + fileToRead + '. Error = ' + err.stack) | ||
return | ||
} | ||
} | ||
projectsLoaded++ | ||
let fileContent = SA.nodeModules.fs.readFileSync(fileToRead) | ||
let schemaDocument | ||
try { | ||
schemaDocument = JSON.parse(fileContent) | ||
SA.projects.foundations.globals.schemas.APP_SCHEMA_MAP.set(project + '-' + schemaDocument.type, schemaDocument) | ||
} catch (err) { | ||
console.log('[WARN] loadAppSchemasForProject -> Error Parsing JSON File: ' + fileToRead + '. Error = ' + err.stack) | ||
return | ||
} | ||
} | ||
projectsLoaded++ | ||
|
||
if (projectsLoaded === PROJECTS_SCHEMA.length) { | ||
resolve() | ||
} | ||
} | ||
} | ||
if (projectsLoaded === PROJECTS_SCHEMA.length) { | ||
resolve() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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