Skip to content

Commit b801b68

Browse files
build: merge beta (#1841)
* refactor: simplify reading dashboard config from a json file (#1828) * refactor: simplify reading config from a json file * refactor: restore `data` nesting of config object Co-authored-by: Manuel <5673677+mtrezza@users.noreply.github.com> * docs: fix changelog branch names (#1837) * docs: reword changelog quote * docs: fix release changelog filename Co-authored-by: Damian Stasik <visualfanatic@users.noreply.github.com> Co-authored-by: Damian Stasik <visualfanatic@users.noreply.github.com>
1 parent 7846029 commit b801b68

File tree

5 files changed

+66
-107
lines changed

5 files changed

+66
-107
lines changed

CHANGELOG.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Changelogs are separated by release type for better overview.
44

5-
## [Master Releases][log_master]
5+
## [Stable Releases][log_release]
66

77
These are the official, stable releases that you can use in your production environments.
88

@@ -11,7 +11,7 @@ These are the official, stable releases that you can use in your production envi
1111
Details:
1212
- Stability: *stable*
1313
- NPM channel: `@latest`
14-
- Branch: [master][branch_master]
14+
- Branch: [release][branch_release]
1515
- Purpose: official release
1616
- Suitable environment: production
1717

@@ -30,7 +30,7 @@ Details:
3030

3131
## 🔥 [Alpha Releases][log_alpha]
3232

33-
> ### Use if you love sudden breaking changes!”
33+
> ### If you are curious to see what's next!”
3434
3535
These releases contain the latest development changes, but you should be prepared for anything, including sudden breaking changes or code refactoring. Use this branch to contribute to the project and open pull requests.
3636

@@ -42,9 +42,9 @@ Details:
4242
- Suitable environment: experimental
4343

4444

45-
[log_master]: https://github.com/parse-community/parse-dashboard/blob/master/changelogs/CHANGELOG_master.md
45+
[log_release]: https://github.com/parse-community/parse-dashboard/blob/release/changelogs/CHANGELOG_release.md
4646
[log_beta]: https://github.com/parse-community/parse-dashboard/blob/beta/changelogs/CHANGELOG_beta.md
4747
[log_alpha]: https://github.com/parse-community/parse-dashboard/blob/alpha/changelogs/CHANGELOG_alpha.md
48-
[branch_master]: https://github.com/parse-community/parse-dashboard/tree/master
48+
[branch_release]: https://github.com/parse-community/parse-dashboard/tree/release
4949
[branch_beta]: https://github.com/parse-community/parse-dashboard/tree/beta
5050
[branch_alpha]: https://github.com/parse-community/parse-dashboard/tree/alpha

Parse-Dashboard/index.js

+56-58
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Command line tool for npm start
99
'use strict'
1010
const path = require('path');
11-
const jsonFile = require('json-file-plus');
11+
const fs = require('fs');
1212
const express = require('express');
1313
const parseDashboard = require('./app');
1414
const CLIHelper = require('./CLIHelper.js');
@@ -126,74 +126,72 @@ if (!program.config && !process.env.PARSE_DASHBOARD_CONFIG) {
126126
}
127127
}
128128

129-
let p = null;
129+
let config = null;
130130
let configFilePath = null;
131131
if (configFile) {
132-
p = jsonFile(configFile);
133-
configFilePath = path.dirname(configFile);
132+
try {
133+
config = {
134+
data: JSON.parse(fs.readFileSync(configFile, 'utf8'))
135+
};
136+
configFilePath = path.dirname(configFile);
137+
} catch (error) {
138+
if (error instanceof SyntaxError) {
139+
console.log('Your config file contains invalid JSON. Exiting.');
140+
process.exit(1);
141+
} else if (error.code === 'ENOENT') {
142+
if (explicitConfigFileProvided) {
143+
console.log('Your config file is missing. Exiting.');
144+
process.exit(2);
145+
} else {
146+
console.log('You must provide either a config file or required CLI options (app ID, Master Key, and server URL); not both.');
147+
process.exit(3);
148+
}
149+
} else {
150+
console.log('There was a problem with your config. Exiting.');
151+
process.exit(-1);
152+
}
153+
}
134154
} else if (configFromCLI) {
135-
p = Promise.resolve(configFromCLI);
155+
config = configFromCLI;
136156
} else {
137157
//Failed to load default config file.
138158
console.log('You must provide either a config file or an app ID, Master Key, and server URL. See parse-dashboard --help for details.');
139159
process.exit(4);
140160
}
141-
p.then(config => {
142-
config.data.apps.forEach(app => {
143-
if (!app.appName) {
144-
app.appName = app.appId;
145-
}
146-
});
147161

148-
if (config.data.iconsFolder && configFilePath) {
149-
config.data.iconsFolder = path.join(configFilePath, config.data.iconsFolder);
162+
config.data.apps.forEach(app => {
163+
if (!app.appName) {
164+
app.appName = app.appId;
150165
}
166+
});
151167

152-
const app = express();
168+
if (config.data.iconsFolder && configFilePath) {
169+
config.data.iconsFolder = path.join(configFilePath, config.data.iconsFolder);
170+
}
153171

154-
if (allowInsecureHTTP || trustProxy || dev) app.enable('trust proxy');
172+
const app = express();
155173

156-
config.data.trustProxy = trustProxy;
157-
let dashboardOptions = { allowInsecureHTTP, cookieSessionSecret, dev };
158-
app.use(mountPath, parseDashboard(config.data, dashboardOptions));
159-
let server;
160-
if(!configSSLKey || !configSSLCert){
161-
// Start the server.
162-
server = app.listen(port, host, function () {
163-
console.log(`The dashboard is now available at http://${server.address().address}:${server.address().port}${mountPath}`);
164-
});
165-
} else {
166-
// Start the server using SSL.
167-
var fs = require('fs');
168-
var privateKey = fs.readFileSync(configSSLKey);
169-
var certificate = fs.readFileSync(configSSLCert);
174+
if (allowInsecureHTTP || trustProxy || dev) app.enable('trust proxy');
170175

171-
server = require('https').createServer({
172-
key: privateKey,
173-
cert: certificate
174-
}, app).listen(port, host, function () {
175-
console.log(`The dashboard is now available at https://${server.address().address}:${server.address().port}${mountPath}`);
176-
});
177-
}
178-
handleSIGs(server);
179-
}, error => {
180-
if (error instanceof SyntaxError) {
181-
console.log('Your config file contains invalid JSON. Exiting.');
182-
process.exit(1);
183-
} else if (error.code === 'ENOENT') {
184-
if (explicitConfigFileProvided) {
185-
console.log('Your config file is missing. Exiting.');
186-
process.exit(2);
187-
} else {
188-
console.log('You must provide either a config file or required CLI options (app ID, Master Key, and server URL); not both.');
189-
process.exit(3);
190-
}
191-
} else {
192-
console.log('There was a problem with your config. Exiting.');
193-
process.exit(-1);
194-
}
195-
})
196-
.catch(error => {
197-
console.log('There was a problem loading the dashboard. Exiting.', error);
198-
process.exit(-1);
199-
});
176+
config.data.trustProxy = trustProxy;
177+
let dashboardOptions = { allowInsecureHTTP, cookieSessionSecret, dev };
178+
app.use(mountPath, parseDashboard(config.data, dashboardOptions));
179+
let server;
180+
if(!configSSLKey || !configSSLCert){
181+
// Start the server.
182+
server = app.listen(port, host, function () {
183+
console.log(`The dashboard is now available at http://${server.address().address}:${server.address().port}${mountPath}`);
184+
});
185+
} else {
186+
// Start the server using SSL.
187+
var privateKey = fs.readFileSync(configSSLKey);
188+
var certificate = fs.readFileSync(configSSLCert);
189+
190+
server = require('https').createServer({
191+
key: privateKey,
192+
cert: certificate
193+
}, app).listen(port, host, function () {
194+
console.log(`The dashboard is now available at https://${server.address().address}:${server.address().port}${mountPath}`);
195+
});
196+
}
197+
handleSIGs(server);
File renamed without changes.

package-lock.json

+5-43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"immutable-devtools": "0.1.5",
5252
"inquirer": "8.1.3",
5353
"js-beautify": "1.14.0",
54-
"json-file-plus": "3.2.0",
5554
"otpauth": "7.0.6",
5655
"package-json": "6.5.0",
5756
"parse": "3.3.1",

0 commit comments

Comments
 (0)