mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
1
.gitignore
vendored
1
.gitignore
vendored
@@ -40,6 +40,7 @@ pidfile
|
|||||||
/public/acp.min.js.map
|
/public/acp.min.js.map
|
||||||
/public/installer.css
|
/public/installer.css
|
||||||
/public/installer.min.js
|
/public/installer.min.js
|
||||||
|
/public/bootstrap.min.css
|
||||||
/public/logo.png
|
/public/logo.png
|
||||||
|
|
||||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const uglify = require('uglify-es');
|
|||||||
const nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
|
|
||||||
const Benchpress = require('benchpressjs');
|
const Benchpress = require('benchpressjs');
|
||||||
|
const mkdirp = require('mkdirp');
|
||||||
const { paths } = require('../src/constants');
|
const { paths } = require('../src/constants');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
@@ -63,6 +64,8 @@ let success = false;
|
|||||||
let error = false;
|
let error = false;
|
||||||
let launchUrl;
|
let launchUrl;
|
||||||
|
|
||||||
|
const viewsDir = path.join(paths.baseDir, 'build/public/templates');
|
||||||
|
|
||||||
web.install = async function (port) {
|
web.install = async function (port) {
|
||||||
port = port || 4567;
|
port = port || 4567;
|
||||||
winston.info('Launching web installer on port ' + port);
|
winston.info('Launching web installer on port ' + port);
|
||||||
@@ -74,13 +77,13 @@ web.install = async function (port) {
|
|||||||
Benchpress.__express(filepath, options, callback);
|
Benchpress.__express(filepath, options, callback);
|
||||||
});
|
});
|
||||||
app.set('view engine', 'tpl');
|
app.set('view engine', 'tpl');
|
||||||
const viewsDir = path.join(paths.baseDir, 'build/public/templates');
|
|
||||||
app.set('views', viewsDir);
|
app.set('views', viewsDir);
|
||||||
app.use(bodyParser.urlencoded({
|
app.use(bodyParser.urlencoded({
|
||||||
extended: true,
|
extended: true,
|
||||||
}));
|
}));
|
||||||
try {
|
try {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
compileTemplate(),
|
||||||
compileLess(),
|
compileLess(),
|
||||||
compileJS(),
|
compileJS(),
|
||||||
copyCSS(),
|
copyCSS(),
|
||||||
@@ -228,6 +231,25 @@ async function launch(req, res) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this is necessary because otherwise the compiled templates won't be available on a clean install
|
||||||
|
async function compileTemplate() {
|
||||||
|
const sourceFile = path.join(__dirname, '../src/views/install/index.tpl');
|
||||||
|
const destTpl = path.join(viewsDir, 'install/index.tpl');
|
||||||
|
const destJs = path.join(viewsDir, 'install/index.js');
|
||||||
|
|
||||||
|
const source = await fs.promises.readFile(sourceFile, 'utf8');
|
||||||
|
|
||||||
|
const [compiled] = await Promise.all([
|
||||||
|
Benchpress.precompile(source),
|
||||||
|
mkdirp(path.dirname(destJs)),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
fs.promises.writeFile(destJs, compiled),
|
||||||
|
fs.promises.writeFile(destTpl, source),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
async function compileLess() {
|
async function compileLess() {
|
||||||
try {
|
try {
|
||||||
const installSrc = path.join(__dirname, '../public/less/install.less');
|
const installSrc = path.join(__dirname, '../public/less/install.less');
|
||||||
|
|||||||
Reference in New Issue
Block a user