Updates definition build script for babel 7.0 (#5024)

* Updates definition build script for babel 7.0

* run eslint on staged files
This commit is contained in:
Florent Vilmart
2018-09-08 14:12:23 -04:00
committed by GitHub
parent fefecfeb9a
commit 617e8405ff
4 changed files with 103 additions and 68 deletions

View File

@@ -107,8 +107,7 @@
"lint-staged": { "lint-staged": {
"{src,spec}/**/*.js": [ "{src,spec}/**/*.js": [
"prettier --write", "prettier --write",
"flow", "eslint --cache",
"eslint --cache ./",
"git add" "git add"
] ]
} }

View File

@@ -56,23 +56,35 @@ function getENVPrefix(iface) {
function processProperty(property, iface) { function processProperty(property, iface) {
const firstComment = getCommentValue(last(property.leadingComments || [])); const firstComment = getCommentValue(last(property.leadingComments || []));
const lastComment = getCommentValue((property.trailingComments || [])[0]);
const name = property.key.name; const name = property.key.name;
const prefix = getENVPrefix(iface); const prefix = getENVPrefix(iface);
if (!firstComment) { if (!firstComment) {
return; return;
} }
const components = firstComment.split(':ENV:').map((elt) => { const lines = firstComment.split('\n').map((line) => line.trim());
return elt.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 defaultValue; let env;
if (lastComment && lastComment.indexOf('=') >= 0) { if (envLine) {
const slice = lastComment.slice(lastComment.indexOf('=') + 1, lastComment.length).trim(); env = envLine.split(' ')[1];
defaultValue = slice; } else {
env = (prefix + toENV(name));
}
let defaultValue;
if (defaultLine) {
defaultValue = defaultLine.split(' ')[1];
} }
const help = components[0];
const env = components[1] || (prefix + toENV(name));
let type = property.value.type; let type = property.value.type;
let isRequired = true; let isRequired = true;
if (type == 'NullableTypeAnnotation') { 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 Do not edit manually, but update Options/index.js
` `
const babel = require("babel-core"); const babel = require("@babel/core");
const res = babel.transformFileSync('./src/Options/index.js', { plugins: [ plugin ], auxiliaryCommentBefore, sourceMaps: false }); 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/Definitions.js', res.code + '\n');
require('fs').writeFileSync('./src/Options/docs.js', docs); require('fs').writeFileSync('./src/Options/docs.js', docs);

View File

@@ -2,8 +2,7 @@
**** GENERATED CODE **** **** GENERATED CODE ****
This code has been generated by resources/buildConfigDefinitions.js This code has been generated by resources/buildConfigDefinitions.js
Do not edit manually, but update Options/index.js Do not edit manually, but update Options/index.js
*/ 'use strict'; */
var parsers = require('./parsers'); var parsers = require('./parsers');
module.exports.ParseServerOptions = { module.exports.ParseServerOptions = {

View File

@@ -19,8 +19,9 @@ export interface ParseServerOptions {
/* URL to your parse server with http:// or https://. /* URL to your parse server with http:// or https://.
:ENV: PARSE_SERVER_URL */ :ENV: PARSE_SERVER_URL */
serverURL: string; serverURL: string;
/* Restrict masterKey to be used by only these ips, defaults to [] (allow all ips) */ /* Restrict masterKey to be used by only these ips, defaults to [] (allow all ips)
masterKeyIps: ?(string[]); // = [] :DEFAULT: [] */
masterKeyIps: ?(string[]);
/* Sets the app name */ /* Sets the app name */
appName: ?string; appName: ?string;
/* Adapter module for the analytics */ /* Adapter module for the analytics */
@@ -29,16 +30,18 @@ export interface ParseServerOptions {
filesAdapter: ?Adapter<FilesAdapter>; filesAdapter: ?Adapter<FilesAdapter>;
/* Configuration for push, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#push-notifications */ /* Configuration for push, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#push-notifications */
push: ?any; push: ?any;
/* Configuration for push scheduling, defaults to false. */ /* Configuration for push scheduling, defaults to false.
scheduledPush: ?boolean; // = false :DEFAULT: false */
scheduledPush: ?boolean;
/* Adapter module for the logging sub-system */ /* Adapter module for the logging sub-system */
loggerAdapter: ?Adapter<LoggerAdapter>; loggerAdapter: ?Adapter<LoggerAdapter>;
/* Log as structured JSON objects /* Log as structured JSON objects
:ENV: JSON_LOGS */ :ENV: JSON_LOGS */
jsonLogs: ?boolean; jsonLogs: ?boolean;
/* Folder for the logs (defaults to './logs'); set to null to disable file based logging /* Folder for the logs (defaults to './logs'); set to null to disable file based logging
:ENV: PARSE_SERVER_LOGS_FOLDER */ :ENV: PARSE_SERVER_LOGS_FOLDER
logsFolder: ?string; // = ./logs :DEFAULT: ./logs */
logsFolder: ?string;
/* Set the logging to verbose /* Set the logging to verbose
:ENV: VERBOSE */ :ENV: VERBOSE */
verbose: ?boolean; verbose: ?boolean;
@@ -47,16 +50,18 @@ export interface ParseServerOptions {
/* Disables console output /* Disables console output
:ENV: SILENT */ :ENV: SILENT */
silent: ?boolean; silent: ?boolean;
/* The full URI to your database. Supported databases are mongodb or postgres. */ /* The full URI to your database. Supported databases are mongodb or postgres.
databaseURI: string; // = mongodb://localhost:27017/parse :DEFAULT: mongodb://localhost:27017/parse */
databaseURI: string;
/* Options to pass to the mongodb client */ /* Options to pass to the mongodb client */
databaseOptions: ?any; databaseOptions: ?any;
/* Adapter module for the database */ /* Adapter module for the database */
databaseAdapter: ?Adapter<StorageAdapter>; databaseAdapter: ?Adapter<StorageAdapter>;
/* Full path to your cloud code main.js */ /* Full path to your cloud code main.js */
cloud: ?string; cloud: ?string;
/* A collection prefix for the classes */ /* A collection prefix for the classes
collectionPrefix: ?string; // = '' :DEFAULT: '' */
collectionPrefix: ?string;
/* Key for iOS, MacOS, tvOS clients */ /* Key for iOS, MacOS, tvOS clients */
clientKey: ?string; clientKey: ?string;
/* Key for the Javascript SDK */ /* Key for the Javascript SDK */
@@ -73,25 +78,32 @@ export interface ParseServerOptions {
/* Key for your files */ /* Key for your files */
fileKey: ?string; fileKey: ?string;
/* Enable (or disable) the addition of a unique hash to the file names /* Enable (or disable) the addition of a unique hash to the file names
:ENV: PARSE_SERVER_PRESERVE_FILE_NAME */ :ENV: PARSE_SERVER_PRESERVE_FILE_NAME
preserveFileName: ?boolean; // = false :DEFAULT: false */
/* Personally identifiable information fields in the user table the should be removed for non-authorized users. */ preserveFileName: ?boolean;
userSensitiveFields: ?(string[]); // = ["email"] /* 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 /* Enable (or disable) anon users, defaults to true
:ENV: PARSE_SERVER_ENABLE_ANON_USERS */ :ENV: PARSE_SERVER_ENABLE_ANON_USERS
enableAnonymousUsers: ?boolean; // = true :DEFAULT: true */
enableAnonymousUsers: ?boolean;
/* Enable (or disable) client class creation, defaults to true /* Enable (or disable) client class creation, defaults to true
:ENV: PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION */ :ENV: PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION
allowClientClassCreation: ?boolean; // = true :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 /* 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 */ :ENV: PARSE_SERVER_AUTH_PROVIDERS */
auth: ?any; auth: ?any;
/* Max file size for uploads, defaults to 20mb */ /* Max file size for uploads, defaults to 20mb
maxUploadSize: ?string; // = 20mb :DEFAULT: 20mb */
/* Enable (or disable) user email validation, defaults to false */ maxUploadSize: ?string;
verifyUserEmails: ?boolean; // = false /* Enable (or disable) user email validation, defaults to false
/* Prevent user from login if email is not verified and PARSE_SERVER_VERIFY_USER_EMAILS is true, defaults to false */ :DEFAULT: false */
preventLoginWithUnverifiedEmail: ?boolean; // = 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 */ /* Email verification token validity duration, in seconds */
emailVerifyTokenValidityDuration: ?number; emailVerifyTokenValidityDuration: ?number;
/* account lockout policy for failed login attempts */ /* account lockout policy for failed login attempts */
@@ -105,37 +117,50 @@ export interface ParseServerOptions {
/* Public URL to your parse server with http:// or https://. /* Public URL to your parse server with http:// or https://.
:ENV: PARSE_PUBLIC_SERVER_URL */ :ENV: PARSE_PUBLIC_SERVER_URL */
publicServerURL: ?string; publicServerURL: ?string;
/* custom pages for password validation and reset */ /* custom pages for password validation and reset
customPages: ?CustomPagesOptions; // = {} :DEFAULT: {} */
customPages: ?CustomPagesOptions;
/* parse-server's LiveQuery configuration object */ /* parse-server's LiveQuery configuration object */
liveQuery: ?LiveQueryOptions; liveQuery: ?LiveQueryOptions;
/* Session duration, in seconds, defaults to 1 year */ /* Session duration, in seconds, defaults to 1 year
sessionLength: ?number; // = 31536000 :DEFAULT: 31536000 */
sessionLength: ?number;
/* Max value for limit option on queries, defaults to unlimited */ /* Max value for limit option on queries, defaults to unlimited */
maxLimit: ?number; maxLimit: ?number;
/* Sets wether we should expire the inactive sessions, defaults to true */ /* Sets wether we should expire the inactive sessions, defaults to true
expireInactiveSessions: ?boolean; // = true :DEFAULT: 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. */ expireInactiveSessions: ?boolean;
revokeSessionOnPasswordReset: ?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.
/* 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: true */
schemaCacheTTL: ?number; // = 5000 revokeSessionOnPasswordReset: ?boolean;
/* Sets the TTL for the in memory cache (in ms), defaults to 5000 (5 seconds) */ /* 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.
cacheTTL: ?number; // = 5000 :DEFAULT: 5000 */
/* Sets the maximum size for the in memory cache, defaults to 10000 */ schemaCacheTTL: ?number;
cacheMaxSize: ?number; // = 10000 /* Sets the TTL for the in memory cache (in ms), defaults to 5000 (5 seconds)
/* 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: 5000 */
enableSingleSchemaCache: ?boolean; // = false cacheTTL: ?number;
/* Enables the default express error handler for all errors */ /* Sets the maximum size for the in memory cache, defaults to 10000
enableExpressErrorHandler: ?boolean; // = false :DEFAULT: 10000 */
/* Sets the number of characters in generated object id's, default 10 */ cacheMaxSize: ?number;
objectIdSize: ?number; // = 10 /* 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. /* The port to run the ParseServer, defaults to 1337.
:ENV: PORT */ :ENV: PORT
port: ?number; // = 1337 :DEFAULT: 1337 */
/* The host to serve ParseServer on, defaults to 0.0.0.0 */ port: ?number;
host: ?string; // = 0.0.0.0 /* The host to serve ParseServer on, defaults to 0.0.0.0
/* Mount path for the server, defaults to /parse */ :DEFAULT: 0.0.0.0 */
mountPath: ?string; // = /parse 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 */ /* Run with cluster, optionally set the number of processes default to os.cpus().length */
cluster: ?NumberOrBoolean; cluster: ?NumberOrBoolean;
/* middleware for express server, can be string or function */ /* middleware for express server, can be string or function */
@@ -184,8 +209,9 @@ export interface LiveQueryServerOptions {
cacheTimeout: ?number; cacheTimeout: ?number;
/* This string defines the log level of the LiveQuery server. We support VERBOSE, INFO, ERROR, NONE, defaults to INFO.*/ /* This string defines the log level of the LiveQuery server. We support VERBOSE, INFO, ERROR, NONE, defaults to INFO.*/
logLevel: ?string; logLevel: ?string;
/* The port to run the LiveQuery server, defaults to 1337.*/ /* The port to run the LiveQuery server, defaults to 1337.
port: ?number; // = 1337 :DEFAULT: 1337 */
port: ?number;
/* parse-server's LiveQuery redisURL */ /* parse-server's LiveQuery redisURL */
redisURL: ?string; redisURL: ?string;
/* LiveQuery pubsub adapter */ /* LiveQuery pubsub adapter */