diff --git a/.eslintrc.json b/.eslintrc.json index 8cce18c3b6..2316bbdd25 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,6 @@ { "env": { - "browser": true, + "node": true, "commonjs": true, "es2021": true }, diff --git a/AppSchemas.js b/AppSchemas.js index b00b557375..2e9b43ddef 100644 --- a/AppSchemas.js +++ b/AppSchemas.js @@ -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() } + } } + } } + } } \ No newline at end of file diff --git a/Launch-Scripts/runSetup.js b/Launch-Scripts/runSetup.js index f63924a3a6..6ad00772a9 100644 --- a/Launch-Scripts/runSetup.js +++ b/Launch-Scripts/runSetup.js @@ -19,10 +19,10 @@ const installExternalScripts = () => { const url = externalScriptsURLs[i] const filename = url.split('/').pop() const dest = path.join(externalScriptsDir, filename) - const res = https.get(url, resp => { + https.get(url, resp => { if (resp.statusCode !== 200) { console.error( - `Error downloading ${url}: HTTP response code ${response.statusCode}.` + `Error downloading ${url}: HTTP response code ${resp.statusCode}.` ) return false } else { @@ -78,7 +78,7 @@ const setUpstreamAndOrigin = async (dir, repo='Superalgos') => { if (repo === 'Superalgos' && origin) { if (origin.indexOf('@') === -1) { gitUser = origin.split('/')[3] - useSSH = false + usesSSH = false } else { gitUser = origin.split(':')[1].split('/')[0] usesSSH = true @@ -130,20 +130,19 @@ const runSetup = (tfjs=false) => { // install tensorflow if user ran tensorflow setup file if (tfjs !== false) { console.log('Including tensorflow.js in your setup...') - nodeModulesDirs = [ - path.join(process.cwd(), - "Projects", - "TensorFlow", - "TS", - "Bot-Modules", - "Learning-Bot", - "Low-Frequency-Learning") - ] + + path.join(process.cwd(), + "Projects", + "TensorFlow", + "TS", + "Bot-Modules", + "Learning-Bot", + "Low-Frequency-Learning") } let dir = process.cwd() let command = 'echo Results of install at ' + dir + ' & npm ci' - let nodeInstPromise = new Promise(resolve => { + let nodeInstPromise = new Promise(() => { exec(command, { cwd: dir @@ -179,7 +178,6 @@ const runSetup = (tfjs=false) => { // Initialize and update git repositories // Ensure upstream and origin are set for this repo and submodules - let gitUser setUpstreamAndOrigin().then(async () => { Object.values(projectPluginMap).forEach(plugin => { setUpstreamAndOrigin(plugin.dir, plugin.repo)