Skip to content

Commit 617e840

Browse files
authored
Updates definition build script for babel 7.0 (#5024)
* Updates definition build script for babel 7.0 * run eslint on staged files
1 parent fefecfe commit 617e840

File tree

4 files changed

+102
-67
lines changed

4 files changed

+102
-67
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@
107107
"lint-staged": {
108108
"{src,spec}/**/*.js": [
109109
"prettier --write",
110-
"flow",
111-
"eslint --cache ./",
110+
"eslint --cache",
112111
"git add"
113112
]
114113
}

resources/buildConfigDefinitions.js

+22-11
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,35 @@ function getENVPrefix(iface) {
5656

5757
function processProperty(property, iface) {
5858
const firstComment = getCommentValue(last(property.leadingComments || []));
59-
const lastComment = getCommentValue((property.trailingComments || [])[0]);
6059
const name = property.key.name;
6160
const prefix = getENVPrefix(iface);
6261

6362
if (!firstComment) {
6463
return;
6564
}
66-
const components = firstComment.split(':ENV:').map((elt) => {
67-
return elt.trim();
65+
const lines = firstComment.split('\n').map((line) => line.trim());
66+
let help = '';
67+
let envLine;
68+
let defaultLine;
69+
lines.forEach((line) => {
70+
if (line.indexOf(':ENV:') === 0) {
71+
envLine = line;
72+
} else if (line.indexOf(':DEFAULT:') === 0) {
73+
defaultLine = line;
74+
} else {
75+
help += line;
76+
}
6877
});
78+
let env;
79+
if (envLine) {
80+
env = envLine.split(' ')[1];
81+
} else {
82+
env = (prefix + toENV(name));
83+
}
6984
let defaultValue;
70-
if (lastComment && lastComment.indexOf('=') >= 0) {
71-
const slice = lastComment.slice(lastComment.indexOf('=') + 1, lastComment.length).trim();
72-
defaultValue = slice;
85+
if (defaultLine) {
86+
defaultValue = defaultLine.split(' ')[1];
7387
}
74-
const help = components[0];
75-
const env = components[1] || (prefix + toENV(name));
7688
let type = property.value.type;
7789
let isRequired = true;
7890
if (type == 'NullableTypeAnnotation') {
@@ -249,8 +261,7 @@ This code has been generated by resources/buildConfigDefinitions.js
249261
Do not edit manually, but update Options/index.js
250262
`
251263

252-
const babel = require("babel-core");
253-
const res = babel.transformFileSync('./src/Options/index.js', { plugins: [ plugin ], auxiliaryCommentBefore, sourceMaps: false });
264+
const babel = require("@babel/core");
265+
const res = babel.transformFileSync('./src/Options/index.js', { plugins: [ plugin, '@babel/transform-flow-strip-types' ], babelrc: false, auxiliaryCommentBefore, sourceMaps: false });
254266
require('fs').writeFileSync('./src/Options/Definitions.js', res.code + '\n');
255267
require('fs').writeFileSync('./src/Options/docs.js', docs);
256-

src/Options/Definitions.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
**** GENERATED CODE ****
33
This code has been generated by resources/buildConfigDefinitions.js
44
Do not edit manually, but update Options/index.js
5-
*/ 'use strict';
6-
5+
*/
76
var parsers = require('./parsers');
87

98
module.exports.ParseServerOptions = {

src/Options/index.js

+78-52
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ export interface ParseServerOptions {
1919
/* URL to your parse server with http:// or https://.
2020
:ENV: PARSE_SERVER_URL */
2121
serverURL: string;
22-
/* Restrict masterKey to be used by only these ips, defaults to [] (allow all ips) */
23-
masterKeyIps: ?(string[]); // = []
22+
/* Restrict masterKey to be used by only these ips, defaults to [] (allow all ips)
23+
:DEFAULT: [] */
24+
masterKeyIps: ?(string[]);
2425
/* Sets the app name */
2526
appName: ?string;
2627
/* Adapter module for the analytics */
@@ -29,16 +30,18 @@ export interface ParseServerOptions {
2930
filesAdapter: ?Adapter<FilesAdapter>;
3031
/* Configuration for push, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#push-notifications */
3132
push: ?any;
32-
/* Configuration for push scheduling, defaults to false. */
33-
scheduledPush: ?boolean; // = false
33+
/* Configuration for push scheduling, defaults to false.
34+
:DEFAULT: false */
35+
scheduledPush: ?boolean;
3436
/* Adapter module for the logging sub-system */
3537
loggerAdapter: ?Adapter<LoggerAdapter>;
3638
/* Log as structured JSON objects
3739
:ENV: JSON_LOGS */
3840
jsonLogs: ?boolean;
3941
/* Folder for the logs (defaults to './logs'); set to null to disable file based logging
40-
:ENV: PARSE_SERVER_LOGS_FOLDER */
41-
logsFolder: ?string; // = ./logs
42+
:ENV: PARSE_SERVER_LOGS_FOLDER
43+
:DEFAULT: ./logs */
44+
logsFolder: ?string;
4245
/* Set the logging to verbose
4346
:ENV: VERBOSE */
4447
verbose: ?boolean;
@@ -47,16 +50,18 @@ export interface ParseServerOptions {
4750
/* Disables console output
4851
:ENV: SILENT */
4952
silent: ?boolean;
50-
/* The full URI to your database. Supported databases are mongodb or postgres. */
51-
databaseURI: string; // = mongodb://localhost:27017/parse
53+
/* The full URI to your database. Supported databases are mongodb or postgres.
54+
:DEFAULT: mongodb://localhost:27017/parse */
55+
databaseURI: string;
5256
/* Options to pass to the mongodb client */
5357
databaseOptions: ?any;
5458
/* Adapter module for the database */
5559
databaseAdapter: ?Adapter<StorageAdapter>;
5660
/* Full path to your cloud code main.js */
5761
cloud: ?string;
58-
/* A collection prefix for the classes */
59-
collectionPrefix: ?string; // = ''
62+
/* A collection prefix for the classes
63+
:DEFAULT: '' */
64+
collectionPrefix: ?string;
6065
/* Key for iOS, MacOS, tvOS clients */
6166
clientKey: ?string;
6267
/* Key for the Javascript SDK */
@@ -73,25 +78,32 @@ export interface ParseServerOptions {
7378
/* Key for your files */
7479
fileKey: ?string;
7580
/* Enable (or disable) the addition of a unique hash to the file names
76-
:ENV: PARSE_SERVER_PRESERVE_FILE_NAME */
77-
preserveFileName: ?boolean; // = false
78-
/* Personally identifiable information fields in the user table the should be removed for non-authorized users. */
79-
userSensitiveFields: ?(string[]); // = ["email"]
81+
:ENV: PARSE_SERVER_PRESERVE_FILE_NAME
82+
:DEFAULT: false */
83+
preserveFileName: ?boolean;
84+
/* Personally identifiable information fields in the user table the should be removed for non-authorized users.
85+
:DEFAULT: ["email"] */
86+
userSensitiveFields: ?(string[]);
8087
/* Enable (or disable) anon users, defaults to true
81-
:ENV: PARSE_SERVER_ENABLE_ANON_USERS */
82-
enableAnonymousUsers: ?boolean; // = true
88+
:ENV: PARSE_SERVER_ENABLE_ANON_USERS
89+
:DEFAULT: true */
90+
enableAnonymousUsers: ?boolean;
8391
/* Enable (or disable) client class creation, defaults to true
84-
:ENV: PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION */
85-
allowClientClassCreation: ?boolean; // = true
92+
:ENV: PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION
93+
:DEFAULT: true */
94+
allowClientClassCreation: ?boolean;
8695
/* Configuration for your authentication providers, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication
8796
:ENV: PARSE_SERVER_AUTH_PROVIDERS */
8897
auth: ?any;
89-
/* Max file size for uploads, defaults to 20mb */
90-
maxUploadSize: ?string; // = 20mb
91-
/* Enable (or disable) user email validation, defaults to false */
92-
verifyUserEmails: ?boolean; // = false
93-
/* Prevent user from login if email is not verified and PARSE_SERVER_VERIFY_USER_EMAILS is true, defaults to false */
94-
preventLoginWithUnverifiedEmail: ?boolean; // = false
98+
/* Max file size for uploads, defaults to 20mb
99+
:DEFAULT: 20mb */
100+
maxUploadSize: ?string;
101+
/* Enable (or disable) user email validation, defaults to false
102+
:DEFAULT: false */
103+
verifyUserEmails: ?boolean;
104+
/* Prevent user from login if email is not verified and PARSE_SERVER_VERIFY_USER_EMAILS is true, defaults to false
105+
:DEFAULT: false */
106+
preventLoginWithUnverifiedEmail: ?boolean;
95107
/* Email verification token validity duration, in seconds */
96108
emailVerifyTokenValidityDuration: ?number;
97109
/* account lockout policy for failed login attempts */
@@ -105,37 +117,50 @@ export interface ParseServerOptions {
105117
/* Public URL to your parse server with http:// or https://.
106118
:ENV: PARSE_PUBLIC_SERVER_URL */
107119
publicServerURL: ?string;
108-
/* custom pages for password validation and reset */
109-
customPages: ?CustomPagesOptions; // = {}
120+
/* custom pages for password validation and reset
121+
:DEFAULT: {} */
122+
customPages: ?CustomPagesOptions;
110123
/* parse-server's LiveQuery configuration object */
111124
liveQuery: ?LiveQueryOptions;
112-
/* Session duration, in seconds, defaults to 1 year */
113-
sessionLength: ?number; // = 31536000
125+
/* Session duration, in seconds, defaults to 1 year
126+
:DEFAULT: 31536000 */
127+
sessionLength: ?number;
114128
/* Max value for limit option on queries, defaults to unlimited */
115129
maxLimit: ?number;
116-
/* Sets wether we should expire the inactive sessions, defaults to true */
117-
expireInactiveSessions: ?boolean; // = true
118-
/* When a user changes their password, either through the reset password email or while logged in, all sessions are revoked if this is true. Set to false if you don't want to revoke sessions. */
119-
revokeSessionOnPasswordReset: ?boolean; // = true
120-
/* The TTL for caching the schema for optimizing read/write operations. You should put a long TTL when your DB is in production. default to 5000; set 0 to disable. */
121-
schemaCacheTTL: ?number; // = 5000
122-
/* Sets the TTL for the in memory cache (in ms), defaults to 5000 (5 seconds) */
123-
cacheTTL: ?number; // = 5000
124-
/* Sets the maximum size for the in memory cache, defaults to 10000 */
125-
cacheMaxSize: ?number; // = 10000
126-
/* Use a single schema cache shared across requests. Reduces number of queries made to _SCHEMA, defaults to false, i.e. unique schema cache per request. */
127-
enableSingleSchemaCache: ?boolean; // = false
128-
/* Enables the default express error handler for all errors */
129-
enableExpressErrorHandler: ?boolean; // = false
130-
/* Sets the number of characters in generated object id's, default 10 */
131-
objectIdSize: ?number; // = 10
130+
/* Sets wether we should expire the inactive sessions, defaults to true
131+
:DEFAULT: true */
132+
expireInactiveSessions: ?boolean;
133+
/* When a user changes their password, either through the reset password email or while logged in, all sessions are revoked if this is true. Set to false if you don't want to revoke sessions.
134+
:DEFAULT: true */
135+
revokeSessionOnPasswordReset: ?boolean;
136+
/* The TTL for caching the schema for optimizing read/write operations. You should put a long TTL when your DB is in production. default to 5000; set 0 to disable.
137+
:DEFAULT: 5000 */
138+
schemaCacheTTL: ?number;
139+
/* Sets the TTL for the in memory cache (in ms), defaults to 5000 (5 seconds)
140+
:DEFAULT: 5000 */
141+
cacheTTL: ?number;
142+
/* Sets the maximum size for the in memory cache, defaults to 10000
143+
:DEFAULT: 10000 */
144+
cacheMaxSize: ?number;
145+
/* Use a single schema cache shared across requests. Reduces number of queries made to _SCHEMA, defaults to false, i.e. unique schema cache per request.
146+
:DEFAULT: false */
147+
enableSingleSchemaCache: ?boolean;
148+
/* Enables the default express error handler for all errors
149+
:DEFAULT: false */
150+
enableExpressErrorHandler: ?boolean;
151+
/* Sets the number of characters in generated object id's, default 10
152+
:DEFAULT: 10 */
153+
objectIdSize: ?number;
132154
/* The port to run the ParseServer, defaults to 1337.
133-
:ENV: PORT */
134-
port: ?number; // = 1337
135-
/* The host to serve ParseServer on, defaults to 0.0.0.0 */
136-
host: ?string; // = 0.0.0.0
137-
/* Mount path for the server, defaults to /parse */
138-
mountPath: ?string; // = /parse
155+
:ENV: PORT
156+
:DEFAULT: 1337 */
157+
port: ?number;
158+
/* The host to serve ParseServer on, defaults to 0.0.0.0
159+
:DEFAULT: 0.0.0.0 */
160+
host: ?string;
161+
/* Mount path for the server, defaults to /parse
162+
:DEFAULT: /parse */
163+
mountPath: ?string;
139164
/* Run with cluster, optionally set the number of processes default to os.cpus().length */
140165
cluster: ?NumberOrBoolean;
141166
/* middleware for express server, can be string or function */
@@ -184,8 +209,9 @@ export interface LiveQueryServerOptions {
184209
cacheTimeout: ?number;
185210
/* This string defines the log level of the LiveQuery server. We support VERBOSE, INFO, ERROR, NONE, defaults to INFO.*/
186211
logLevel: ?string;
187-
/* The port to run the LiveQuery server, defaults to 1337.*/
188-
port: ?number; // = 1337
212+
/* The port to run the LiveQuery server, defaults to 1337.
213+
:DEFAULT: 1337 */
214+
port: ?number;
189215
/* parse-server's LiveQuery redisURL */
190216
redisURL: ?string;
191217
/* LiveQuery pubsub adapter */

0 commit comments

Comments
 (0)