Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
chore: merge master into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffladiray authored Jan 5, 2021
2 parents 99cc33b + ad80921 commit b1f78bc
Show file tree
Hide file tree
Showing 28 changed files with 1,116 additions and 255 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
# NOTICE: Handles code coverage reporting to Code Climate
before_install:
- docker-compose up -d
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- curl -L $CC_TEST_REPORTER_URL > ./cc-test-reporter
- chmod +x ./cc-test-reporter
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [3.10.5](https://github.com/ForestAdmin/lumber/compare/v3.10.4...v3.10.5) (2020-12-21)


### Bug Fixes

* **sequelize:** fix error when working with column table including parenthesis ([#520](https://github.com/ForestAdmin/lumber/issues/520)) ([79c041b](https://github.com/ForestAdmin/lumber/commit/79c041b8ca6a78db198e71a4b0ec1dbba224acbd))

# [4.0.0-beta.1](https://github.com/ForestAdmin/lumber/compare/v3.10.4...v4.0.0-beta.1) (2020-12-21)


Expand Down
11 changes: 10 additions & 1 deletion context/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ const open = require('open');
const openIdClient = require('openid-client');
const superagent = require('superagent');
const { promisify } = require('util');
const Database = require('../services/database');
const pkg = require('../package.json');
const applicationTokenDeserializer = require('../deserializers/application-token');
const applicationTokenSerializer = require('../serializers/application-token');
const Api = require('../services/api');
const ApplicationTokenService = require('../services/application-token');
const mkdirp = require('mkdirp');
const Handlebars = require('handlebars');
const Database = require('../services/database');
const Dumper = require('../services/dumper');
const logger = require('../services/logger');
const terminator = require('../utils/terminator');
const Authenticator = require('../services/authenticator');
Expand Down Expand Up @@ -46,10 +49,12 @@ const fsAsync = {
* fs: import('fs');
* os: import('os');
* inquirer: import('inquirer');
* mkdirp: import('mkdirp');
* mongodb: import('mongodb');
* Sequelize: import('sequelize');
* superagent: import('superagent');
* fsAsync: fsAsync;
* Handlebars: import('handlebars');
* }} Dependencies
*
* @typedef {{
Expand All @@ -66,6 +71,7 @@ const fsAsync = {
* @typedef {{
* logger: import('../services/logger');
* database: import('../services/database');
* dumper: import('../services/dumper');
* api: import('../services/api');
* authenticator: import('../services/authenticator');
* oidcAuthenticator: import('../services/oidc/authenticator');
Expand Down Expand Up @@ -98,10 +104,12 @@ function initDependencies(context) {
context.addInstance('fs', fs);
context.addInstance('os', os);
context.addInstance('inquirer', inquirer);
context.addInstance('mkdirp', mkdirp);
context.addInstance('Sequelize', Sequelize);
context.addInstance('mongodb', mongodb);
context.addInstance('superagent', superagent);
context.addInstance('fsAsync', fsAsync);
context.addInstance('Handlebars', Handlebars);
}

/**
Expand All @@ -127,6 +135,7 @@ function initSerializers(context) {
function initServices(context) {
context.addInstance('logger', logger);
context.addClass(Database);
context.addClass(Dumper);
context.addClass(Api);
context.addClass(ApplicationTokenService);
context.addClass(Authenticator);
Expand Down
7 changes: 3 additions & 4 deletions lumber-generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ initContext(context);

const spinners = require('./services/spinners');
const DatabaseAnalyzer = require('./services/analyzer/database-analyzer');
const Dumper = require('./services/dumper');
const CommandGenerateConfigGetter = require('./services/command-generate-config-getter');
const eventSender = require('./services/event-sender');
const ProjectCreator = require('./services/project-creator');
const { terminate } = require('./utils/terminator');
const { ERROR_UNEXPECTED } = require('./utils/messages');

const { logger, authenticator } = context.inject();
const { logger, authenticator, dumper } = context.inject();

if (!authenticator) throw new Error('Missing dependency authenticator');
if (!logger) throw new Error('Missing dependency logger');
if (!dumper) throw new Error('Missing dependency dumper');

program
.description('Generate a backend application with an ORM/ODM configured')
Expand Down Expand Up @@ -62,8 +62,7 @@ program

const spinner = spinners.add('dumper', { text: 'Creating your project files' });
logger.spinner = spinner;
const dumper = new Dumper(config);
await dumper.dump(schema);
await dumper.dump(schema, config);
spinner.succeed();

logger.success(`Hooray, ${chalk.green('installation success')}!`);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"inquirer": "^6.2.0",
"jsonapi-serializer": "^3.4.1",
"lodash": "4.17.19",
"mkdirp": "^0.5.1",
"mongodb": "3.3.0",
"mysql2": "2.1.0",
"mkdirp": "^1.0.4",
"mongodb": "3.6.3",
"mysql2": "2.2.5",
"open": "^7.3.0",
"openid-client": "^4.2.1",
"pg": "8.2.1",
Expand Down
5 changes: 4 additions & 1 deletion services/analyzer/sequelize-tables-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,10 @@ async function createTableSchema(columnTypeGetter, {
defaultValue = Sequelize.literal(defaultValue);
}

const name = _.camelCase(columnName);
// NOTICE: sequelize considers column name with parenthesis as raw Attributes
// do not try to camelCase the name for avoiding sequelize issues
const hasParenthesis = columnName.includes('(') || columnName.includes(')');
const name = hasParenthesis ? columnName : _.camelCase(columnName);
let isRequired = !columnInfo.allowNull;
if (isTechnicalTimestamp({ name, type })) {
isRequired = false;
Expand Down
Loading

0 comments on commit b1f78bc

Please sign in to comment.