forked from CMU-313/cmu-313-f24-nodebb-f24-NodeBB
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added standardJS check log after autofixing
- Loading branch information
1 parent
09ae029
commit 73e9df4
Showing
800 changed files
with
114,692 additions
and
106,862 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,201 +1,201 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
const path = require('path'); | ||
const nconf = require('nconf'); | ||
const path = require('path') | ||
const nconf = require('nconf') | ||
|
||
nconf.argv().env({ | ||
separator: '__', | ||
}); | ||
const winston = require('winston'); | ||
const { fork } = require('child_process'); | ||
separator: '__' | ||
Check failure on line 7 in Gruntfile.js GitHub Actions / test
|
||
}) | ||
const winston = require('winston') | ||
const { fork } = require('child_process') | ||
|
||
const { env } = process; | ||
let worker; | ||
const { env } = process | ||
let worker | ||
|
||
env.NODE_ENV = env.NODE_ENV || 'development'; | ||
env.NODE_ENV = env.NODE_ENV || 'development' | ||
|
||
const configFile = path.resolve(__dirname, nconf.any(['config', 'CONFIG']) || 'config.json'); | ||
const prestart = require('./src/prestart'); | ||
const configFile = path.resolve(__dirname, nconf.any(['config', 'CONFIG']) || 'config.json') | ||
const prestart = require('./src/prestart') | ||
|
||
prestart.loadConfig(configFile); | ||
prestart.loadConfig(configFile) | ||
|
||
const db = require('./src/database'); | ||
const plugins = require('./src/plugins'); | ||
const db = require('./src/database') | ||
const plugins = require('./src/plugins') | ||
|
||
module.exports = function (grunt) { | ||
const args = []; | ||
|
||
if (!grunt.option('verbose')) { | ||
args.push('--log-level=info'); | ||
nconf.set('log-level', 'info'); | ||
} | ||
prestart.setupWinston(); | ||
|
||
grunt.initConfig({ | ||
watch: {}, | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
|
||
grunt.registerTask('default', ['watch']); | ||
|
||
grunt.registerTask('init', async function () { | ||
const done = this.async(); | ||
let pluginList = []; | ||
if (!process.argv.includes('--core')) { | ||
await db.init(); | ||
pluginList = await plugins.getActive(); | ||
addBaseThemes(pluginList); | ||
if (!pluginList.includes('nodebb-plugin-composer-default')) { | ||
pluginList.push('nodebb-plugin-composer-default'); | ||
} | ||
if (!pluginList.includes('nodebb-theme-harmony')) { | ||
pluginList.push('nodebb-theme-harmony'); | ||
} | ||
} | ||
|
||
const styleUpdated_Client = pluginList.map(p => `node_modules/${p}/*.scss`) | ||
.concat(pluginList.map(p => `node_modules/${p}/*.css`)) | ||
.concat(pluginList.map(p => `node_modules/${p}/+(public|static|scss)/**/*.scss`)) | ||
.concat(pluginList.map(p => `node_modules/${p}/+(public|static)/**/*.css`)); | ||
|
||
const clientUpdated = pluginList.map(p => `node_modules/${p}/+(public|static)/**/*.js`); | ||
const serverUpdated = pluginList.map(p => `node_modules/${p}/*.js`) | ||
.concat(pluginList.map(p => `node_modules/${p}/+(lib|src)/**/*.js`)); | ||
|
||
const templatesUpdated = pluginList.map(p => `node_modules/${p}/+(public|static|templates)/**/*.tpl`); | ||
const langUpdated = pluginList.map(p => `node_modules/${p}/+(public|static|languages)/**/*.json`); | ||
const interval = 100; | ||
grunt.config(['watch'], { | ||
styleUpdated: { | ||
files: [ | ||
'public/scss/**/*.scss', | ||
...styleUpdated_Client, | ||
], | ||
options: { | ||
interval: interval, | ||
}, | ||
}, | ||
clientUpdated: { | ||
files: [ | ||
'public/src/**/*.js', | ||
'public/vendor/**/*.js', | ||
...clientUpdated, | ||
'node_modules/benchpressjs/build/benchpress.js', | ||
], | ||
options: { | ||
interval: interval, | ||
}, | ||
}, | ||
serverUpdated: { | ||
files: [ | ||
'app.js', | ||
'install/*.js', | ||
'src/**/*.js', | ||
'public/src/modules/translator.common.js', | ||
'public/src/modules/helpers.common.js', | ||
'public/src/utils.common.js', | ||
serverUpdated, | ||
'!src/upgrades/**', | ||
], | ||
options: { | ||
interval: interval, | ||
}, | ||
}, | ||
templatesUpdated: { | ||
files: [ | ||
'src/views/**/*.tpl', | ||
...templatesUpdated, | ||
], | ||
options: { | ||
interval: interval, | ||
}, | ||
}, | ||
langUpdated: { | ||
files: [ | ||
'public/language/en-GB/*.json', | ||
'public/language/en-GB/**/*.json', | ||
...langUpdated, | ||
], | ||
options: { | ||
interval: interval, | ||
}, | ||
}, | ||
}); | ||
const build = require('./src/meta/build'); | ||
if (!grunt.option('skip')) { | ||
await build.build(true, { watch: true }); | ||
} | ||
run(); | ||
done(); | ||
}); | ||
|
||
function run() { | ||
if (worker) { | ||
worker.kill(); | ||
} | ||
|
||
const execArgv = []; | ||
const inspect = process.argv.find(a => a.startsWith('--inspect')); | ||
|
||
if (inspect) { | ||
execArgv.push(inspect); | ||
} | ||
|
||
worker = fork('app.js', args, { | ||
env, | ||
execArgv, | ||
}); | ||
} | ||
|
||
grunt.task.run('init'); | ||
|
||
grunt.event.removeAllListeners('watch'); | ||
grunt.event.on('watch', (action, filepath, target) => { | ||
let compiling; | ||
if (target === 'styleUpdated') { | ||
compiling = ['clientCSS', 'acpCSS']; | ||
} else if (target === 'clientUpdated') { | ||
compiling = ['js']; | ||
} else if (target === 'templatesUpdated') { | ||
compiling = ['tpl']; | ||
} else if (target === 'langUpdated') { | ||
compiling = ['lang']; | ||
} else if (target === 'serverUpdated') { | ||
// empty require cache | ||
const paths = ['./src/meta/build.js', './src/meta/index.js']; | ||
paths.forEach(p => delete require.cache[require.resolve(p)]); | ||
return run(); | ||
} | ||
|
||
require('./src/meta/build').build(compiling, { webpack: false }, (err) => { | ||
if (err) { | ||
winston.error(err.stack); | ||
} | ||
if (worker) { | ||
worker.send({ compiling: compiling }); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
function addBaseThemes(pluginList) { | ||
let themeId = pluginList.find(p => p.includes('nodebb-theme-')); | ||
if (!themeId) { | ||
return pluginList; | ||
} | ||
let baseTheme; | ||
do { | ||
try { | ||
baseTheme = require(`${themeId}/theme`).baseTheme; | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
|
||
if (baseTheme) { | ||
pluginList.push(baseTheme); | ||
themeId = baseTheme; | ||
} | ||
} while (baseTheme); | ||
return pluginList; | ||
const args = [] | ||
|
||
if (!grunt.option('verbose')) { | ||
args.push('--log-level=info') | ||
nconf.set('log-level', 'info') | ||
} | ||
prestart.setupWinston() | ||
|
||
grunt.initConfig({ | ||
watch: {} | ||
}) | ||
|
||
grunt.loadNpmTasks('grunt-contrib-watch') | ||
|
||
grunt.registerTask('default', ['watch']) | ||
|
||
grunt.registerTask('init', async function () { | ||
const done = this.async() | ||
let pluginList = [] | ||
if (!process.argv.includes('--core')) { | ||
await db.init() | ||
pluginList = await plugins.getActive() | ||
addBaseThemes(pluginList) | ||
if (!pluginList.includes('nodebb-plugin-composer-default')) { | ||
pluginList.push('nodebb-plugin-composer-default') | ||
} | ||
if (!pluginList.includes('nodebb-theme-harmony')) { | ||
pluginList.push('nodebb-theme-harmony') | ||
} | ||
} | ||
|
||
const styleUpdated_Client = pluginList.map(p => `node_modules/${p}/*.scss`) | ||
.concat(pluginList.map(p => `node_modules/${p}/*.css`)) | ||
.concat(pluginList.map(p => `node_modules/${p}/+(public|static|scss)/**/*.scss`)) | ||
.concat(pluginList.map(p => `node_modules/${p}/+(public|static)/**/*.css`)) | ||
|
||
const clientUpdated = pluginList.map(p => `node_modules/${p}/+(public|static)/**/*.js`) | ||
const serverUpdated = pluginList.map(p => `node_modules/${p}/*.js`) | ||
.concat(pluginList.map(p => `node_modules/${p}/+(lib|src)/**/*.js`)) | ||
|
||
const templatesUpdated = pluginList.map(p => `node_modules/${p}/+(public|static|templates)/**/*.tpl`) | ||
const langUpdated = pluginList.map(p => `node_modules/${p}/+(public|static|languages)/**/*.json`) | ||
const interval = 100 | ||
grunt.config(['watch'], { | ||
styleUpdated: { | ||
files: [ | ||
'public/scss/**/*.scss', | ||
...styleUpdated_Client | ||
], | ||
options: { | ||
interval | ||
} | ||
}, | ||
clientUpdated: { | ||
files: [ | ||
'public/src/**/*.js', | ||
'public/vendor/**/*.js', | ||
...clientUpdated, | ||
'node_modules/benchpressjs/build/benchpress.js' | ||
], | ||
options: { | ||
interval | ||
} | ||
}, | ||
serverUpdated: { | ||
files: [ | ||
'app.js', | ||
'install/*.js', | ||
'src/**/*.js', | ||
'public/src/modules/translator.common.js', | ||
'public/src/modules/helpers.common.js', | ||
'public/src/utils.common.js', | ||
serverUpdated, | ||
'!src/upgrades/**' | ||
], | ||
options: { | ||
interval | ||
} | ||
}, | ||
templatesUpdated: { | ||
files: [ | ||
'src/views/**/*.tpl', | ||
...templatesUpdated | ||
], | ||
options: { | ||
interval | ||
} | ||
}, | ||
langUpdated: { | ||
files: [ | ||
'public/language/en-GB/*.json', | ||
'public/language/en-GB/**/*.json', | ||
...langUpdated | ||
], | ||
options: { | ||
interval | ||
} | ||
} | ||
}) | ||
const build = require('./src/meta/build') | ||
if (!grunt.option('skip')) { | ||
await build.build(true, { watch: true }) | ||
} | ||
run() | ||
done() | ||
}) | ||
|
||
function run () { | ||
if (worker) { | ||
worker.kill() | ||
} | ||
|
||
const execArgv = [] | ||
const inspect = process.argv.find(a => a.startsWith('--inspect')) | ||
|
||
if (inspect) { | ||
execArgv.push(inspect) | ||
} | ||
|
||
worker = fork('app.js', args, { | ||
env, | ||
execArgv | ||
}) | ||
} | ||
|
||
grunt.task.run('init') | ||
|
||
grunt.event.removeAllListeners('watch') | ||
grunt.event.on('watch', (action, filepath, target) => { | ||
let compiling | ||
if (target === 'styleUpdated') { | ||
compiling = ['clientCSS', 'acpCSS'] | ||
} else if (target === 'clientUpdated') { | ||
compiling = ['js'] | ||
} else if (target === 'templatesUpdated') { | ||
compiling = ['tpl'] | ||
} else if (target === 'langUpdated') { | ||
compiling = ['lang'] | ||
} else if (target === 'serverUpdated') { | ||
// empty require cache | ||
const paths = ['./src/meta/build.js', './src/meta/index.js'] | ||
paths.forEach(p => delete require.cache[require.resolve(p)]) | ||
return run() | ||
} | ||
|
||
require('./src/meta/build').build(compiling, { webpack: false }, (err) => { | ||
if (err) { | ||
winston.error(err.stack) | ||
} | ||
if (worker) { | ||
worker.send({ compiling }) | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
function addBaseThemes (pluginList) { | ||
let themeId = pluginList.find(p => p.includes('nodebb-theme-')) | ||
if (!themeId) { | ||
return pluginList | ||
} | ||
let baseTheme | ||
do { | ||
try { | ||
baseTheme = require(`${themeId}/theme`).baseTheme | ||
} catch (err) { | ||
console.log(err) | ||
} | ||
|
||
if (baseTheme) { | ||
pluginList.push(baseTheme) | ||
themeId = baseTheme | ||
} | ||
} while (baseTheme) | ||
return pluginList | ||
} |
Oops, something went wrong.