From 9f6cf1d66bc49d026ead6ec1e326ca2838733ba7 Mon Sep 17 00:00:00 2001 From: Florent Vilmart <364568+flovilmart@users.noreply.github.com> Date: Sat, 1 Sep 2018 15:32:53 -0400 Subject: [PATCH 1/2] Updates definition build script for babel 7.0 --- package.json | 1 - resources/buildConfigDefinitions.js | 33 ++++--- src/Options/Definitions.js | 3 +- src/Options/index.js | 130 +++++++++++++++++----------- 4 files changed, 101 insertions(+), 66 deletions(-) diff --git a/package.json b/package.json index 2f26db886d..e9abf80214 100644 --- a/package.json +++ b/package.json @@ -107,7 +107,6 @@ "lint-staged": { "{src,spec}/**/*.js": [ "prettier --write", - "flow", "eslint --cache ./", "git add" ] diff --git a/resources/buildConfigDefinitions.js b/resources/buildConfigDefinitions.js index 8d3771091b..11431fdba1 100644 --- a/resources/buildConfigDefinitions.js +++ b/resources/buildConfigDefinitions.js @@ -56,23 +56,35 @@ function getENVPrefix(iface) { function processProperty(property, iface) { const firstComment = getCommentValue(last(property.leadingComments || [])); - const lastComment = getCommentValue((property.trailingComments || [])[0]); const name = property.key.name; const prefix = getENVPrefix(iface); if (!firstComment) { return; } - const components = firstComment.split(':ENV:').map((elt) => { - return elt.trim(); + const lines = firstComment.split('\n').map((line) => line.trim()); + let help = ''; + let envLine; + let defaultLine; + lines.forEach((line) => { + if (line.indexOf(':ENV:') === 0) { + envLine = line; + } else if (line.indexOf(':DEFAULT:') === 0) { + defaultLine = line; + } else { + help += line; + } }); + let env; + if (envLine) { + env = envLine.split(' ')[1]; + } else { + env = (prefix + toENV(name)); + } let defaultValue; - if (lastComment && lastComment.indexOf('=') >= 0) { - const slice = lastComment.slice(lastComment.indexOf('=') + 1, lastComment.length).trim(); - defaultValue = slice; + if (defaultLine) { + defaultValue = defaultLine.split(' ')[1]; } - const help = components[0]; - const env = components[1] || (prefix + toENV(name)); let type = property.value.type; let isRequired = true; if (type == 'NullableTypeAnnotation') { @@ -249,8 +261,7 @@ This code has been generated by resources/buildConfigDefinitions.js Do not edit manually, but update Options/index.js ` -const babel = require("babel-core"); -const res = babel.transformFileSync('./src/Options/index.js', { plugins: [ plugin ], auxiliaryCommentBefore, sourceMaps: false }); +const babel = require("@babel/core"); +const res = babel.transformFileSync('./src/Options/index.js', { plugins: [ plugin, '@babel/transform-flow-strip-types' ], babelrc: false, auxiliaryCommentBefore, sourceMaps: false }); require('fs').writeFileSync('./src/Options/Definitions.js', res.code + '\n'); require('fs').writeFileSync('./src/Options/docs.js', docs); - diff --git a/src/Options/Definitions.js b/src/Options/Definitions.js index e484eba583..0d0b715400 100644 --- a/src/Options/Definitions.js +++ b/src/Options/Definitions.js @@ -2,8 +2,7 @@ **** GENERATED CODE **** This code has been generated by resources/buildConfigDefinitions.js Do not edit manually, but update Options/index.js -*/ 'use strict'; - +*/ var parsers = require('./parsers'); module.exports.ParseServerOptions = { diff --git a/src/Options/index.js b/src/Options/index.js index fb816293e2..8ff3d371cd 100644 --- a/src/Options/index.js +++ b/src/Options/index.js @@ -19,8 +19,9 @@ export interface ParseServerOptions { /* URL to your parse server with http:// or https://. :ENV: PARSE_SERVER_URL */ serverURL: string; - /* Restrict masterKey to be used by only these ips, defaults to [] (allow all ips) */ - masterKeyIps: ?(string[]); // = [] + /* Restrict masterKey to be used by only these ips, defaults to [] (allow all ips) + :DEFAULT: [] */ + masterKeyIps: ?(string[]); /* Sets the app name */ appName: ?string; /* Adapter module for the analytics */ @@ -29,16 +30,18 @@ export interface ParseServerOptions { filesAdapter: ?Adapter; /* Configuration for push, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#push-notifications */ push: ?any; - /* Configuration for push scheduling, defaults to false. */ - scheduledPush: ?boolean; // = false + /* Configuration for push scheduling, defaults to false. + :DEFAULT: false */ + scheduledPush: ?boolean; /* Adapter module for the logging sub-system */ loggerAdapter: ?Adapter; /* Log as structured JSON objects :ENV: JSON_LOGS */ jsonLogs: ?boolean; /* Folder for the logs (defaults to './logs'); set to null to disable file based logging - :ENV: PARSE_SERVER_LOGS_FOLDER */ - logsFolder: ?string; // = ./logs + :ENV: PARSE_SERVER_LOGS_FOLDER + :DEFAULT: ./logs */ + logsFolder: ?string; /* Set the logging to verbose :ENV: VERBOSE */ verbose: ?boolean; @@ -47,16 +50,18 @@ export interface ParseServerOptions { /* Disables console output :ENV: SILENT */ silent: ?boolean; - /* The full URI to your database. Supported databases are mongodb or postgres. */ - databaseURI: string; // = mongodb://localhost:27017/parse + /* The full URI to your database. Supported databases are mongodb or postgres. + :DEFAULT: mongodb://localhost:27017/parse */ + databaseURI: string; /* Options to pass to the mongodb client */ databaseOptions: ?any; /* Adapter module for the database */ databaseAdapter: ?Adapter; /* Full path to your cloud code main.js */ cloud: ?string; - /* A collection prefix for the classes */ - collectionPrefix: ?string; // = '' + /* A collection prefix for the classes + :DEFAULT: '' */ + collectionPrefix: ?string; /* Key for iOS, MacOS, tvOS clients */ clientKey: ?string; /* Key for the Javascript SDK */ @@ -73,25 +78,32 @@ export interface ParseServerOptions { /* Key for your files */ fileKey: ?string; /* Enable (or disable) the addition of a unique hash to the file names - :ENV: PARSE_SERVER_PRESERVE_FILE_NAME */ - preserveFileName: ?boolean; // = false - /* Personally identifiable information fields in the user table the should be removed for non-authorized users. */ - userSensitiveFields: ?(string[]); // = ["email"] + :ENV: PARSE_SERVER_PRESERVE_FILE_NAME + :DEFAULT: false */ + preserveFileName: ?boolean; + /* Personally identifiable information fields in the user table the should be removed for non-authorized users. + :DEFAULT: ["email"] */ + userSensitiveFields: ?(string[]); /* Enable (or disable) anon users, defaults to true - :ENV: PARSE_SERVER_ENABLE_ANON_USERS */ - enableAnonymousUsers: ?boolean; // = true + :ENV: PARSE_SERVER_ENABLE_ANON_USERS + :DEFAULT: true */ + enableAnonymousUsers: ?boolean; /* Enable (or disable) client class creation, defaults to true - :ENV: PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION */ - allowClientClassCreation: ?boolean; // = true + :ENV: PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION + :DEFAULT: true */ + allowClientClassCreation: ?boolean; /* Configuration for your authentication providers, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication :ENV: PARSE_SERVER_AUTH_PROVIDERS */ auth: ?any; - /* Max file size for uploads, defaults to 20mb */ - maxUploadSize: ?string; // = 20mb - /* Enable (or disable) user email validation, defaults to false */ - verifyUserEmails: ?boolean; // = false - /* Prevent user from login if email is not verified and PARSE_SERVER_VERIFY_USER_EMAILS is true, defaults to false */ - preventLoginWithUnverifiedEmail: ?boolean; // = false + /* Max file size for uploads, defaults to 20mb + :DEFAULT: 20mb */ + maxUploadSize: ?string; + /* Enable (or disable) user email validation, defaults to false + :DEFAULT: false */ + verifyUserEmails: ?boolean; + /* Prevent user from login if email is not verified and PARSE_SERVER_VERIFY_USER_EMAILS is true, defaults to false + :DEFAULT: false */ + preventLoginWithUnverifiedEmail: ?boolean; /* Email verification token validity duration, in seconds */ emailVerifyTokenValidityDuration: ?number; /* account lockout policy for failed login attempts */ @@ -105,37 +117,50 @@ export interface ParseServerOptions { /* Public URL to your parse server with http:// or https://. :ENV: PARSE_PUBLIC_SERVER_URL */ publicServerURL: ?string; - /* custom pages for password validation and reset */ - customPages: ?CustomPagesOptions; // = {} + /* custom pages for password validation and reset + :DEFAULT: {} */ + customPages: ?CustomPagesOptions; /* parse-server's LiveQuery configuration object */ liveQuery: ?LiveQueryOptions; - /* Session duration, in seconds, defaults to 1 year */ - sessionLength: ?number; // = 31536000 + /* Session duration, in seconds, defaults to 1 year + :DEFAULT: 31536000 */ + sessionLength: ?number; /* Max value for limit option on queries, defaults to unlimited */ maxLimit: ?number; - /* Sets wether we should expire the inactive sessions, defaults to true */ - expireInactiveSessions: ?boolean; // = true - /* 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. */ - revokeSessionOnPasswordReset: ?boolean; // = true - /* 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. */ - schemaCacheTTL: ?number; // = 5000 - /* Sets the TTL for the in memory cache (in ms), defaults to 5000 (5 seconds) */ - cacheTTL: ?number; // = 5000 - /* Sets the maximum size for the in memory cache, defaults to 10000 */ - cacheMaxSize: ?number; // = 10000 - /* 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. */ - enableSingleSchemaCache: ?boolean; // = false - /* Enables the default express error handler for all errors */ - enableExpressErrorHandler: ?boolean; // = false - /* Sets the number of characters in generated object id's, default 10 */ - objectIdSize: ?number; // = 10 + /* Sets wether we should expire the inactive sessions, defaults to true + :DEFAULT: true */ + expireInactiveSessions: ?boolean; + /* 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. + :DEFAULT: true */ + revokeSessionOnPasswordReset: ?boolean; + /* 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. + :DEFAULT: 5000 */ + schemaCacheTTL: ?number; + /* Sets the TTL for the in memory cache (in ms), defaults to 5000 (5 seconds) + :DEFAULT: 5000 */ + cacheTTL: ?number; + /* Sets the maximum size for the in memory cache, defaults to 10000 + :DEFAULT: 10000 */ + cacheMaxSize: ?number; + /* 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. + :DEFAULT: false */ + enableSingleSchemaCache: ?boolean; + /* Enables the default express error handler for all errors + :DEFAULT: false */ + enableExpressErrorHandler: ?boolean; + /* Sets the number of characters in generated object id's, default 10 + :DEFAULT: 10 */ + objectIdSize: ?number; /* The port to run the ParseServer, defaults to 1337. - :ENV: PORT */ - port: ?number; // = 1337 - /* The host to serve ParseServer on, defaults to 0.0.0.0 */ - host: ?string; // = 0.0.0.0 - /* Mount path for the server, defaults to /parse */ - mountPath: ?string; // = /parse + :ENV: PORT + :DEFAULT: 1337 */ + port: ?number; + /* The host to serve ParseServer on, defaults to 0.0.0.0 + :DEFAULT: 0.0.0.0 */ + host: ?string; + /* Mount path for the server, defaults to /parse + :DEFAULT: /parse */ + mountPath: ?string; /* Run with cluster, optionally set the number of processes default to os.cpus().length */ cluster: ?NumberOrBoolean; /* middleware for express server, can be string or function */ @@ -184,8 +209,9 @@ export interface LiveQueryServerOptions { cacheTimeout: ?number; /* This string defines the log level of the LiveQuery server. We support VERBOSE, INFO, ERROR, NONE, defaults to INFO.*/ logLevel: ?string; - /* The port to run the LiveQuery server, defaults to 1337.*/ - port: ?number; // = 1337 + /* The port to run the LiveQuery server, defaults to 1337. + :DEFAULT: 1337 */ + port: ?number; /* parse-server's LiveQuery redisURL */ redisURL: ?string; /* LiveQuery pubsub adapter */ From 2d575c147fabb71a27a9a30f85ebb1fe11d6e385 Mon Sep 17 00:00:00 2001 From: Florent Vilmart <364568+flovilmart@users.noreply.github.com> Date: Sat, 1 Sep 2018 16:10:36 -0400 Subject: [PATCH 2/2] run eslint on staged files --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e9abf80214..6a3624423f 100644 --- a/package.json +++ b/package.json @@ -107,7 +107,7 @@ "lint-staged": { "{src,spec}/**/*.js": [ "prettier --write", - "eslint --cache ./", + "eslint --cache", "git add" ] }