jhipster-core
Advanced tools
Comparing version 1.1.9 to 1.2.0
@@ -28,3 +28,9 @@ 'use strict'; | ||
entityNames.slice(1, entityNames.length - 1); | ||
var firstPart = `${this.name === BINARY_OPTIONS.BINARY_OPTIONS.PAGINATION ? 'paginate' : this.name} ${entityNames} with ${this.value}`; | ||
var optionName = this.name; | ||
if (this.name === BINARY_OPTIONS.BINARY_OPTIONS.PAGINATION) { | ||
optionName = 'paginate'; | ||
} else if (this.name === BINARY_OPTIONS.BINARY_OPTIONS.SEARCH_ENGINE){ | ||
optionName = 'search'; | ||
} | ||
var firstPart = `${optionName} ${entityNames} with ${this.value}`; | ||
if (this.excludedNames.size() === 0) { | ||
@@ -31,0 +37,0 @@ return firstPart; |
@@ -25,3 +25,4 @@ 'use strict'; | ||
ANY_BLOB: 'AnyBlob', | ||
IMAGE_BLOB: 'ImageBlob' | ||
IMAGE_BLOB: 'ImageBlob', | ||
TEXT_BLOB: 'TextBlob' | ||
}; | ||
@@ -42,3 +43,4 @@ | ||
AnyBlob: new Set([VALIDATIONS.REQUIRED, VALIDATIONS.MINBYTES, VALIDATIONS.MAXBYTES]), | ||
ImageBlob: new Set([VALIDATIONS.REQUIRED, VALIDATIONS.MINBYTES, VALIDATIONS.MAXBYTES]) | ||
ImageBlob: new Set([VALIDATIONS.REQUIRED, VALIDATIONS.MINBYTES, VALIDATIONS.MAXBYTES]), | ||
TextBlob: new Set([VALIDATIONS.REQUIRED, VALIDATIONS.MINBYTES, VALIDATIONS.MAXBYTES]) | ||
}; | ||
@@ -59,3 +61,4 @@ | ||
ANY_BLOB: 'AnyBlob', | ||
IMAGE_BLOB: 'ImageBlob' | ||
IMAGE_BLOB: 'ImageBlob', | ||
TEXT_BLOB: 'TextBlob' | ||
}; | ||
@@ -76,3 +79,4 @@ | ||
AnyBlob: new Set([VALIDATIONS.REQUIRED, VALIDATIONS.MINBYTES, VALIDATIONS.MAXBYTES]), | ||
ImageBlob: new Set([VALIDATIONS.REQUIRED, VALIDATIONS.MINBYTES, VALIDATIONS.MAXBYTES]) | ||
ImageBlob: new Set([VALIDATIONS.REQUIRED, VALIDATIONS.MINBYTES, VALIDATIONS.MAXBYTES]), | ||
TextBlob: new Set([VALIDATIONS.REQUIRED, VALIDATIONS.MINBYTES, VALIDATIONS.MAXBYTES]) | ||
}; | ||
@@ -79,0 +83,0 @@ |
'use strict'; | ||
const MYSQL_RESERVED_WORDS = ['ACCESSIBLE', 'ADD', 'ALL', 'ALTER', 'ANALYZE', 'AND', 'AS', 'ASC', 'ASENSITIVE', 'BEFORE', 'BETWEEN', 'BIGINT', 'BINARY', 'BLOB', 'BOTH', 'BY', 'CALL', 'CASCADE', 'CASE', 'CHANGE', 'CHAR', 'CHARACTER', 'CHECK', 'COLLATE', 'COLUMN', 'CONDITION', 'CONSTRAINT', 'CONTINUE', 'CONVERT', 'CREATE', 'CROSS', 'CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'CURSOR', 'DATABASE', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DECLARE', 'DEFAULT', 'DELAYED', 'DELETE', 'DESC', 'DESCRIBE', 'DETERMINISTIC', 'DISTINCT', 'DISTINCTROW', 'DIV', 'DOUBLE', 'DROP', 'DUAL', 'EACH', 'ELSE', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXISTS', 'EXIT', 'EXPLAIN', 'FALSE', 'FETCH', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FOR', 'FORCE', 'FOREIGN', 'FROM', 'FULLTEXT', 'GRANT', 'GROUP', 'HAVING', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', 'HOUR_SECOND', 'IF', 'IGNORE', 'IN', 'INDEX', 'INFILE', 'INNER', 'INOUT', 'INSENSITIVE', 'INSERT', 'INT', 'INT1', 'INT2', 'INT3', 'INT4', 'INT8', 'INTEGER', 'INTERVAL', 'INTO', 'IS', 'ITERATE', 'JOIN', 'KEY', 'KEYS', 'KILL', 'LEADING', 'LEAVE', 'LEFT', 'LIKE', 'LIMIT', 'LINEAR', 'LINES', 'LOAD', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK', 'LONG', 'LONGBLOB', 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MASTER_SSL_VERIFY_SERVER_CERT', 'MATCH', 'MAXVALUE', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', 'MODIFIES', 'NATURAL', 'NOT', 'NO_WRITE_TO_BINLOG', 'NULL', 'NUMERIC', 'ON', 'OPTIMIZE', 'OPTION', 'OPTIONALLY', 'OR', 'ORDER', 'OUT', 'OUTER', 'OUTFILE', 'PRECISION', 'PRIMARY', 'PROCEDURE', 'PURGE', 'RANGE', 'READ', 'READS', 'READ_WRITE', 'REAL', 'REFERENCES', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REPLACE', 'REQUIRE', 'RESIGNAL', 'RESTRICT', 'RETURN', 'REVOKE', 'RIGHT', 'RLIKE', 'SCHEMA', 'SCHEMAS', 'SECOND_MICROSECOND', 'SELECT', 'SENSITIVE', 'SEPARATOR', 'SET', 'SHOW', 'SIGNAL', 'SMALLINT', 'SPATIAL', 'SPECIFIC', 'SQL', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', 'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN', 'TABLE', 'TERMINATED', 'THEN', 'TINYBLOB', 'TINYINT', 'TINYTEXT', 'TO', 'TRAILING', 'TRIGGER', 'TRUE', 'UNDO', 'UNION', 'UNIQUE', 'UNLOCK', 'UNSIGNED', 'UPDATE', 'USAGE', 'USE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', 'VALUES', 'VARBINARY', 'VARCHAR', 'VARCHARACTER', 'VARYING', 'WHEN', 'WHERE', 'WHILE', 'WITH', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'GENERAL', 'IGNORE_SERVER_IDS', 'MASTER_HEARTBEAT_PERIOD', 'MAXVALUE', 'RESIGNAL', 'SIGNAL', 'SLOW']; | ||
const RESERVED_WORDS = { | ||
JHIPSTER: ['ACCOUNT'], | ||
JAVA: ['ABSTRACT', 'CONTINUE', 'FOR', 'NEW', 'SWITCH', 'ASSERT', 'DEFAULT', 'GOTO', 'PACKAGE', 'SYNCHRONIZED', 'BOOLEAN', 'DO', 'IF', 'PRIVATE', 'THIS', 'BREAK', 'DOUBLE', 'IMPLEMENTS', 'PROTECTED', 'THROW', 'BYTE', 'ELSE', 'IMPORT', 'PUBLIC', 'THROWS', 'CASE', 'ENUM', 'INSTANCEOF', 'RETURN', 'TRANSIENT', 'CATCH', 'EXTENDS', 'INT', 'SHORT', 'TRY', 'CHAR', 'FINAL', 'INTERFACE', 'STATIC', 'VOID', 'CLASS', 'FINALLY', 'LONG', 'STRICTFP', 'VOLATILE', 'CONST', 'FLOAT', 'NATIVE', 'SUPER', 'WHILE'], | ||
MYSQL: ['ACCESSIBLE', 'ADD', 'ALL', 'ALTER', 'ANALYZE', 'AND', 'AS', 'ASC', 'ASENSITIVE', 'BEFORE', 'BETWEEN', 'BIGINT', 'BINARY', 'BLOB', 'BOTH', 'BY', 'CALL', 'CASCADE', 'CASE', 'CHANGE', 'CHAR', 'CHARACTER', 'CHECK', 'COLLATE', 'COLUMN', 'CONDITION', 'CONSTRAINT', 'CONTINUE', 'CONVERT', 'CREATE', 'CROSS', 'CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'CURSOR', 'DATABASE', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DECLARE', 'DEFAULT', 'DELAYED', 'DELETE', 'DESC', 'DESCRIBE', 'DETERMINISTIC', 'DISTINCT', 'DISTINCTROW', 'DIV', 'DOUBLE', 'DROP', 'DUAL', 'EACH', 'ELSE', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXISTS', 'EXIT', 'EXPLAIN', 'FALSE', 'FETCH', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FOR', 'FORCE', 'FOREIGN', 'FROM', 'FULLTEXT', 'GRANT', 'GROUP', 'HAVING', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', 'HOUR_SECOND', 'IF', 'IGNORE', 'IN', 'INDEX', 'INFILE', 'INNER', 'INOUT', 'INSENSITIVE', 'INSERT', 'INT', 'INT1', 'INT2', 'INT3', 'INT4', 'INT8', 'INTEGER', 'INTERVAL', 'INTO', 'IS', 'ITERATE', 'JOIN', 'KEY', 'KEYS', 'KILL', 'LEADING', 'LEAVE', 'LEFT', 'LIKE', 'LIMIT', 'LINEAR', 'LINES', 'LOAD', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK', 'LONG', 'LONGBLOB', 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MASTER_SSL_VERIFY_SERVER_CERT', 'MATCH', 'MAXVALUE', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', 'MODIFIES', 'NATURAL', 'NOT', 'NO_WRITE_TO_BINLOG', 'NULL', 'NUMERIC', 'ON', 'OPTIMIZE', 'OPTION', 'OPTIONALLY', 'OR', 'ORDER', 'OUT', 'OUTER', 'OUTFILE', 'PRECISION', 'PRIMARY', 'PROCEDURE', 'PURGE', 'RANGE', 'READ', 'READS', 'READ_WRITE', 'REAL', 'REFERENCES', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REPLACE', 'REQUIRE', 'RESIGNAL', 'RESTRICT', 'RETURN', 'REVOKE', 'RIGHT', 'RLIKE', 'SCHEMA', 'SCHEMAS', 'SECOND_MICROSECOND', 'SELECT', 'SENSITIVE', 'SEPARATOR', 'SET', 'SHOW', 'SIGNAL', 'SMALLINT', 'SPATIAL', 'SPECIFIC', 'SQL', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', 'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN', 'TABLE', 'TERMINATED', 'THEN', 'TINYBLOB', 'TINYINT', 'TINYTEXT', 'TO', 'TRAILING', 'TRIGGER', 'TRUE', 'UNDO', 'UNION', 'UNIQUE', 'UNLOCK', 'UNSIGNED', 'UPDATE', 'USAGE', 'USE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', 'VALUES', 'VARBINARY', 'VARCHAR', 'VARCHARACTER', 'VARYING', 'WHEN', 'WHERE', 'WHILE', 'WITH', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'GENERAL', 'IGNORE_SERVER_IDS', 'MASTER_HEARTBEAT_PERIOD', 'MAXVALUE', 'RESIGNAL', 'SIGNAL', 'SLOW'], | ||
MYSQL: MYSQL_RESERVED_WORDS, | ||
MARIADB: MYSQL_RESERVED_WORDS, | ||
POSTGRESQL: ['ALL', 'ANALYSE', 'ANALYZE', 'AND', 'ANY', 'ARRAY', 'AS', 'ASC', 'ASYMMETRIC', 'AUTHORIZATION', 'BINARY', 'BOTH', 'CASE', 'CAST', 'CHECK', 'COLLATE', 'COLLATION', 'COLUMN', 'CONCURRENTLY', 'CONSTRAINT', 'CREATE', 'CROSS', 'CURRENT_CATALOG', 'CURRENT_DATE', 'CURRENT_ROLE', 'CURRENT_SCHEMA', 'CURRENT_TIME', 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'DEFAULT', 'DEFERRABLE', 'DESC', 'DISTINCT', 'DO', 'ELSE', 'END', 'EXCEPT', 'FALSE', 'FETCH', 'FOR', 'FOREIGN', 'FROM', 'FULL', 'GRANT', 'GROUP', 'HAVING', 'ILIKE', 'IN', 'INITIALLY', 'INNER', 'INTERSECT', 'INTO', 'IS', 'ISNULL', 'JOIN', 'LATERAL', 'LEADING', 'LEFT', 'LIKE', 'LIMIT', 'LOCALTIME', 'LOCALTIMESTAMP', 'NATURAL', 'NOT', 'NOTNULL', 'NULL', 'OFFSET', 'ON', 'ONLY', 'OR', 'ORDER', 'OUTER', 'OVERLAPS', 'PLACING', 'PRIMARY', 'REFERENCES', 'RETURNING', 'RIGHT', 'SELECT', 'SESSION_USER', 'SIMILAR', 'SOME', 'SYMMETRIC', 'TABLE', 'THEN', 'TO', 'TRAILING', 'TRUE', 'UNION', 'UNIQUE', 'USER', 'USING', 'VARIADIC', 'VERBOSE', 'WHEN', 'WHERE', 'WINDOW', 'WITH'], | ||
@@ -16,3 +19,2 @@ CASSANDRA: ['ADD', 'ALL', 'ALTER', 'AND', 'ANY', 'APPLY', 'AS', 'ASC', 'ASCII', 'AUTHORIZE', 'BATCH', 'BEGIN', 'BIGINT', 'BLOB', 'BOOLEAN', 'BY', 'CLUSTERING', 'COLUMNFAMILY', 'COMPACT', 'CONSISTENCY', 'COUNT', 'COUNTER', 'CREATE', 'DECIMAL', 'DELETE', 'DESC', 'DOUBLE', 'DROP', 'EACH_QUORUM', 'FLOAT', 'FROM', 'GRANT', 'IN', 'INDEX', 'CUSTOM', 'INSERT', 'INT', 'INTO', 'KEY', 'KEYSPACE', 'LEVEL', 'LIMIT', 'LOCAL_ONE', 'LOCAL_QUORUM', 'MODIFY', 'NORECURSIVE', 'NOSUPERUSER', 'OF', 'ON', 'ONE', 'ORDER', 'PASSWORD', 'PERMISSION', 'PERMISSIONS', 'PRIMARY', 'QUORUM', 'REVOKE', 'SCHEMA', 'SELECT', 'SET', 'STORAGE', 'SUPERUSER', 'TABLE', 'TEXT', 'TIMESTAMP', 'TIMEUUID', 'THREE', 'TOKEN', 'TRUNCATE', 'TTL', 'TWO', 'TYPE', 'UPDATE', 'USE', 'USER', 'USERS', 'USING', 'UUID', 'VALUES', 'VARCHAR', 'VARINT', 'WHERE', 'WITH', 'WRITETIME', 'DISTINCT', 'BYTE', 'SMALLINT', 'COMPLEX', 'ENUM', 'DATE', 'INTERVAL', 'MACADDR', 'BITSTRING'], | ||
&& RESERVED_WORDS[type.toUpperCase()].indexOf(keyword.toUpperCase()) !== -1; | ||
} | ||
@@ -19,0 +21,0 @@ |
@@ -105,3 +105,3 @@ /* | ||
relationDecl | ||
= 'relationship' space rt:relationshipType space* "{" space* JDLComment? space* bodies:relationshipBodies space* "}" { | ||
= 'relationship' space rt:relationshipType space* "{" space* JDLComment? space* bodies:relationshipBodies space* JDLComment? space* "}" { | ||
addCardinalityToRelationships(rt, bodies); | ||
@@ -108,0 +108,0 @@ return concat([], bodies); |
@@ -22,2 +22,3 @@ 'use strict'; | ||
WrongFile: null, | ||
WrongDir: null, | ||
WrongType: null, | ||
@@ -24,0 +25,0 @@ WrongValidation: null |
@@ -6,2 +6,3 @@ 'use strict'; | ||
toFilePath = require('../reader/json_file_reader').toFilePath, | ||
doesfileExist = require('../reader/json_file_reader').doesfileExist, | ||
areJHipsterEntitiesEqual = require('../utils/object_utils').areEntitiesEqual, | ||
@@ -27,4 +28,5 @@ buildException = require('../exceptions/exception_factory').buildException, | ||
for (let i = 0, entityNames = Object.keys(entities); i < entityNames.length; i++) { | ||
let file = toFilePath(entityNames[i]); | ||
fs.writeFileSync(file, JSON.stringify(entities[entityNames[i]], null, 4)); | ||
let filePath = toFilePath(entityNames[i]); | ||
let entity = updateChangelogDate(filePath, entities[entityNames[i]]); | ||
fs.writeFileSync(filePath, JSON.stringify(entity, null, 4)); | ||
} | ||
@@ -43,17 +45,22 @@ } | ||
function updateChangelogDate(filePath, entity) { | ||
if (doesfileExist(filePath)) { | ||
let fileOnDisk = readEntityJSON(filePath); | ||
if (fileOnDisk && fileOnDisk.changelogDate) { | ||
entity.changelogDate = fileOnDisk.changelogDate; | ||
} | ||
} | ||
return entity; | ||
} | ||
function filterOutUnchangedEntities(entities) { | ||
var filtered = {}; | ||
for (let i = 0, entityNames = Object.keys(entities); i < entityNames.length; i++) { | ||
let filePath = toFilePath(entityNames[i]); | ||
let fileExists = true; | ||
try { | ||
fileExists = fs.statSync(filePath).isFile(); | ||
} catch (error) { | ||
fileExists = false; | ||
let entityName = entityNames[i]; | ||
let filePath = toFilePath(entityName); | ||
if (!(doesfileExist(filePath) && areJHipsterEntitiesEqual(readEntityJSON(filePath), entities[entityName]))) { | ||
filtered[entityName] = (entities[entityName]); | ||
} | ||
if (!(fileExists && areJHipsterEntitiesEqual(readEntityJSON(filePath), entities[entityNames[i]]))) { | ||
filtered[entityNames[i]] = (entities[entityNames[i]]); | ||
} | ||
} | ||
return filtered; | ||
} |
@@ -114,8 +114,10 @@ 'use strict'; | ||
if (option.name === BinaryOptions.MICROSERVICE) { | ||
option.name = 'microserviceName'; | ||
} | ||
if (option.name === UnaryOptions.NO_FLUENT_METHOD) { | ||
entities[entityName]['microserviceName'] = option.value; | ||
} else if (option.name === UnaryOptions.NO_FLUENT_METHOD) { | ||
entities[entityName]['fluentMethods'] = false; | ||
} else if (option.name === BinaryOptions.ANGULAR_SUFFIX) { | ||
entities[entityName]['angularJSSuffix'] = option.value; | ||
} else { | ||
entities[entityName][option.name] = option.value; | ||
} | ||
entities[entityName][option.name] = option.value; | ||
}); | ||
@@ -149,3 +151,3 @@ } | ||
if (comment) { | ||
fieldData.comment = comment; | ||
fieldData.javadoc = comment; | ||
} | ||
@@ -152,0 +154,0 @@ if (isType(jdlField.type)) { |
@@ -11,3 +11,4 @@ 'use strict'; | ||
readEntityJSON: readEntityJSON, | ||
toFilePath: toFilePath | ||
toFilePath: toFilePath, | ||
doesfileExist: doesfileExist | ||
}; | ||
@@ -20,3 +21,3 @@ | ||
try { | ||
if (!fs.statSync(filePath).isFile()) { | ||
if (!doesfileExist(filePath)) { | ||
throw new buildException(exceptions.FileNotFound, `The passed file '${filePath}' is a folder.`); | ||
@@ -38,2 +39,10 @@ } | ||
return `.jhipster/${_.upperFirst(entityName)}.json`; | ||
} | ||
} | ||
function doesfileExist(filePath) { | ||
try { | ||
return fs.statSync(filePath).isFile(); | ||
} catch (error) { | ||
return false; | ||
} | ||
} |
@@ -10,4 +10,6 @@ 'use strict'; | ||
JDLReader = require('../lib/reader/jdl_reader'), | ||
JsonReader = require('../lib/reader/json_reader'), | ||
convertToJDL = require('../lib/parser/jdl_parser').parse, | ||
convertToJHipsterJSON = require('../lib/parser/entity_parser').parse, | ||
JsonParser = require('../lib/parser/json_parser'), | ||
JDLObject = require('../lib/core/jdl_object'), | ||
@@ -24,2 +26,3 @@ JDLEntity = require('../lib/core/jdl_entity'), | ||
createJHipsterJSONFolder = require('../lib/export/json_exporter').createJHipsterJSONFolder, | ||
exportToJDL = require('../lib/export/jdl_exporter').exportToJDL, | ||
toFilePath = require('../lib/reader/json_file_reader').toFilePath, | ||
@@ -56,7 +59,14 @@ readEntityJSON = require('../lib/reader/json_file_reader').readEntityJSON, | ||
parseFromFiles: JDLReader.parseFromFiles, | ||
/* Json reading */ | ||
parseJsonFromDir: JsonReader.parseFromDir, | ||
/* JDL conversion */ | ||
convertToJDL: convertToJDL, | ||
convertToJHipsterJSON: convertToJHipsterJSON, | ||
/* Json conversion */ | ||
convertJsonEntitiesToJDL: JsonParser.parseEntities, | ||
convertJsonServerOptionsToJDL: JsonParser.parseServerOptions, | ||
/* JSON exporting */ | ||
exportToJSON: exportToJSON, | ||
/* JDL exporting */ | ||
exportToJDL: exportToJDL, | ||
/* JDL utils */ | ||
@@ -63,0 +73,0 @@ isJDLFile: JDLReader.checkFileIsJDLFile, |
{ | ||
"name": "jhipster-core", | ||
"version": "1.1.9", | ||
"version": "1.2.0", | ||
"description": "JHipster's own domain language and core objects", | ||
@@ -35,7 +35,7 @@ "main": "module/index.js", | ||
"dependencies": { | ||
"lodash": "4.15.0" | ||
"lodash": "4.16.4" | ||
}, | ||
"devDependencies": { | ||
"pegjs": "0.10.0", | ||
"mocha": "3.0.2", | ||
"mocha": "3.1.0", | ||
"chai": "3.5.0", | ||
@@ -42,0 +42,0 @@ "istanbul": "0.4.5" |
[![Build Status](https://travis-ci.org/jhipster/jhipster-core.svg?branch=master)](https://travis-ci.org/jhipster/jhipster-core) [![Dependency Status](https://david-dm.org/jhipster/jhipster-core.svg)](https://david-dm.org/jhipster/jhipster-core) [![devDependency Status](https://david-dm.org/jhipster/jhipster-core/dev-status.svg)](https://david-dm.org/jhipster/jhipster-core#info=devDependencies) [![peerDependency Status](https://david-dm.org/jhipster/jhipster-core/peer-status.svg)](https://david-dm.org/jhipster/jhipster-core#info=peerDependencies) | ||
Welcome to the official repository of everything common to JHipster and its projects, like the JDL (JHipster Domain Language). |
@@ -43,2 +43,10 @@ 'use strict'; | ||
}); | ||
}); | ||
describe('::isReservedClassName', function() { | ||
describe('when passing a valid entity name', function() { | ||
it('returns false', function() { | ||
expect(isReservedClassName('document')).to.be.false; | ||
expect(isReservedClassName('region')).to.be.false; | ||
}); | ||
}); | ||
describe('when passing an invalid entity name', function() { | ||
@@ -50,2 +58,28 @@ it('returns true', function() { | ||
}); | ||
}); | ||
describe('::isReservedFieldName', function() { | ||
describe('when passing a valid field name', function() { | ||
it('returns false', function() { | ||
expect(isReservedFieldName('item', 'sql')).to.be.false; | ||
expect(isReservedFieldName('mySuperField', 'cassandra')).to.be.false; | ||
}); | ||
}); | ||
describe('when passing an invalid field name', function() { | ||
it('returns true', function() { | ||
expect(isReservedFieldName('ANALYZE', 'sql')).to.be.true; | ||
expect(isReservedFieldName('CONTINUE', 'sql')).to.be.true; | ||
}); | ||
}); | ||
}); | ||
describe('::isReservedTableName', function() { | ||
describe('when passing a valid table name', function() { | ||
it('returns false', function() { | ||
expect(isReservedTableName('job_history', 'sql')).to.be.false; | ||
expect(isReservedTableName('job', 'mysql')).to.be.false; | ||
expect(isReservedTableName('document', 'postgresql')).to.be.false; | ||
expect(isReservedTableName('region', 'oracle')).to.be.false; | ||
expect(isReservedTableName('item', 'cassandra')).to.be.false; | ||
expect(isReservedTableName('person', 'mongodb')).to.be.false; | ||
}); | ||
}); | ||
describe('when passing an invalid table name', function() { | ||
@@ -61,9 +95,3 @@ it('returns true', function() { | ||
}); | ||
describe('when passing an invalid entity field name', function() { | ||
it('returns true', function() { | ||
expect(isReservedFieldName('ANALYZE', 'sql')).to.be.true; | ||
expect(isReservedFieldName('CONTINUE', 'sql')).to.be.true; | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -127,3 +127,29 @@ 'use strict'; | ||
}); | ||
describe('when exporting JDL to entity json for an existing entity', function () { | ||
it('exports it with same changeLogDate', function () { | ||
var input = parseFromFiles(['./test/test_files/valid_jdl.jdl']); | ||
var content = EntityParser.parse({jdlObject: JDLParser.parse(input, 'sql'), databaseType: 'sql'}); | ||
Exporter.exportToJSON(content); | ||
expect(fs.statSync('.jhipster/A.json').isFile()).to.be.true; | ||
var changeLogDate = JSON.parse(fs.readFileSync('.jhipster/A.json', {encoding: 'utf-8'})).changelogDate; | ||
this.timeout(3000); | ||
// hack to introduce a 1 second delay | ||
// http://stackoverflow.com/questions/14249506/how-can-i-wait-in-node-js-javascript-l-need-to-pause-for-a-period-of-time#answer-37575602 | ||
var waitTill = new Date(new Date().getTime() + 1 * 1000); | ||
while(waitTill > new Date()){} | ||
input = parseFromFiles(['./test/test_files/valid_jdl.jdl']); | ||
content = EntityParser.parse({jdlObject: JDLParser.parse(input, 'sql'), databaseType: 'sql'}); | ||
Exporter.exportToJSON(content, true); | ||
expect(fs.statSync('.jhipster/A.json').isFile()).to.be.true; | ||
var newChangeLogDate = JSON.parse(fs.readFileSync('.jhipster/A.json', {encoding: 'utf-8'})).changelogDate; | ||
expect(newChangeLogDate).to.eq(changeLogDate); | ||
// clean up the mess... | ||
fs.unlinkSync('.jhipster/A.json'); | ||
fs.unlinkSync('.jhipster/B.json'); | ||
fs.unlinkSync('.jhipster/C.json'); | ||
fs.unlinkSync('.jhipster/D.json'); | ||
fs.rmdirSync('.jhipster'); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -6,2 +6,3 @@ 'use strict'; | ||
toFilePath = require('../../../lib/reader/json_file_reader').toFilePath, | ||
doesfileExist = require('../../../lib/reader/json_file_reader').doesfileExist, | ||
readEntityJSON = require('../../../lib/reader/json_file_reader').readEntityJSON; | ||
@@ -111,2 +112,21 @@ | ||
}); | ||
describe('::doesfileExist', function () { | ||
describe('when checking a file path', function () { | ||
describe('with a nil file path', function () { | ||
it('return false', function () { | ||
expect(doesfileExist()).to.be.false; | ||
}); | ||
}); | ||
describe('with an invalid file path', function () { | ||
it('return false', function () { | ||
expect(doesfileExist('someInvalidPath')).to.be.false; | ||
}); | ||
}); | ||
describe('with a valid file path', function () { | ||
it('return true', function () { | ||
expect(doesfileExist(`./test/test_files/MyEntity.json`)).to.be.true; | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
462683
100
12253
4
11
+ Addedlodash@4.16.4(transitive)
- Removedlodash@4.15.0(transitive)
Updatedlodash@4.16.4