forest-cli 2.5.4 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/projects/create.js +25 -10
- package/src/serializers/project.js +1 -0
- package/src/services/dumper/templates/app/routes/route.hbs +1 -0
- package/src/services/projects/create/project-creator.js +3 -2
- package/src/services/schema/update/analyzer/mongo-collections-analyzer.js +1 -1
- package/src/utils/event-sender.js +44 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [2.6.1](https://github.com/ForestAdmin/toolbelt/compare/v2.6.0...v2.6.1) (2022-03-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **templates:** add link to performance doc in count route ([#355](https://github.com/ForestAdmin/toolbelt/issues/355)) ([f7ebd92](https://github.com/ForestAdmin/toolbelt/commit/f7ebd928121757a3c5f7ffa92327288b789a71ff))
|
|
7
|
+
|
|
8
|
+
# [2.6.0](https://github.com/ForestAdmin/toolbelt/compare/v2.5.5...v2.6.0) (2022-02-21)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* send better events during project generation ([#348](https://github.com/ForestAdmin/toolbelt/issues/348)) ([60a2800](https://github.com/ForestAdmin/toolbelt/commit/60a2800a5e4e9029d50fe9f7cbe28f53f915b5c1))
|
|
14
|
+
|
|
15
|
+
## [2.5.5](https://github.com/ForestAdmin/toolbelt/compare/v2.5.4...v2.5.5) (2022-01-03)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **mongodb:** fix typos on the "analysis" word ([#324](https://github.com/ForestAdmin/toolbelt/issues/324)) ([47670a9](https://github.com/ForestAdmin/toolbelt/commit/47670a9d5f12e3574e62d6368d17a420014af6c1))
|
|
21
|
+
|
|
1
22
|
## [2.5.4](https://github.com/ForestAdmin/toolbelt/compare/v2.5.3...v2.5.4) (2021-12-31)
|
|
2
23
|
|
|
3
24
|
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.5.4","commands":{"branch":{"id":"branch","description":"Create a new branch or list your existing branches.","pluginName":"forest-cli","pluginType":"core","aliases":["branches"],"flags":{"projectId":{"name":"projectId","type":"option","description":"The id of the project to create a branch in."},"delete":{"name":"delete","type":"boolean","char":"d","description":"Delete the branch.","allowNo":false},"force":{"name":"force","type":"boolean","description":"When deleting a branch, skip confirmation.","allowNo":false},"help":{"name":"help","type":"boolean","description":"Display usage information.","allowNo":false}},"args":[{"name":"BRANCH_NAME","description":"The name of the branch to create.","required":false}]},"deploy":{"id":"deploy","description":"Deploy layout changes of an environment to the reference one.","pluginName":"forest-cli","pluginType":"core","aliases":["environments:deploy"],"flags":{"help":{"name":"help","type":"boolean","description":"Display usage information.","allowNo":false},"force":{"name":"force","type":"boolean","char":"f","description":"Skip deploy confirmation.","allowNo":false},"projectId":{"name":"projectId","type":"option","char":"p","description":"The id of the project you want to deploy.","default":null}},"args":[{"name":"ENVIRONMENT_NAME","description":"The name of the environment containing the layout changes to deploy to the reference one.","required":false}]},"environments":{"id":"environments","description":"Manage environments.","pluginName":"forest-cli","pluginType":"core","aliases":["environments:list"],"flags":{"projectId":{"name":"projectId","type":"option","char":"p","description":"Forest project ID.","default":null},"format":{"name":"format","type":"option","char":"format","description":"Ouput format.","options":["table","json"],"default":"table"}},"args":[]},"init":{"id":"init","description":"Set up your development environment in your current folder.","pluginName":"forest-cli","pluginType":"core","aliases":["environments:init"],"flags":{"projectId":{"name":"projectId","type":"option","char":"p","description":"The id of the project you want to init."}},"args":[]},"login":{"id":"login","description":"Sign in with an existing account.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"email":{"name":"email","type":"option","char":"e","description":"Your Forest Admin account email."},"password":{"name":"password","type":"option","char":"P","description":"Your Forest Admin account password (ignored if token is set)."},"token":{"name":"token","type":"option","char":"t","description":"Your Forest Admin account token (replaces password)."}},"args":[]},"logout":{"id":"logout","description":"Sign out of your account.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"build":{"name":"build"},"option":{"name":"option"},"enum":{"name":"enum"},"string":{"name":"string"},"boolean":{"name":"boolean"},"integer":{"name":"integer"},"version":{"name":"version"},"help":{"name":"help"}},"args":[]},"projects":{"id":"projects","description":"Manage projects.","pluginName":"forest-cli","pluginType":"core","aliases":["projects:list"],"flags":{"format":{"name":"format","type":"option","char":"format","description":"Ouput format.","options":["table","json"],"default":"table"}},"args":[]},"push":{"id":"push","description":"Push layout changes of your current branch to a remote environment.","pluginName":"forest-cli","pluginType":"core","aliases":["branches:push"],"flags":{"environment":{"name":"environment","type":"option","char":"e","description":"The remote environment name to push onto."},"force":{"name":"force","type":"boolean","description":"Skip push changes confirmation.","allowNo":false},"help":{"name":"help","type":"boolean","description":"Display usage information.","allowNo":false},"projectId":{"name":"projectId","type":"option","char":"p","description":"The id of the project to work on.","default":null}},"args":[]},"switch":{"id":"switch","description":"Switch to another branch in your local development environment.","pluginName":"forest-cli","pluginType":"core","aliases":["branch:switch"],"flags":{"help":{"name":"help","type":"boolean","description":"Display usage information.","allowNo":false}},"args":[{"name":"BRANCH_NAME","description":"The name of the local branch to set as current.","required":false}]},"user":{"id":"user","description":"Display the current logged in user.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"build":{"name":"build"},"option":{"name":"option"},"enum":{"name":"enum"},"string":{"name":"string"},"boolean":{"name":"boolean"},"integer":{"name":"integer"},"version":{"name":"version"},"help":{"name":"help"}},"args":[]},"environments:copy-layout":{"id":"environments:copy-layout","description":"Copy the layout from one environment to another.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"projectId":{"name":"projectId","type":"option","char":"p","description":"Forest project ID.","default":null},"force":{"name":"force","type":"boolean","char":"force","description":"Force copy.","allowNo":false}},"args":[{"name":"fromEnvironment","description":"Source environment ID.","required":true},{"name":"toEnvironment","description":"Target environment ID.","required":true}]},"environments:create":{"id":"environments:create","description":"Create a new environment.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"projectId":{"name":"projectId","type":"option","char":"p","description":"Forest project ID.","default":null},"name":{"name":"name","type":"option","char":"n","description":"Environment name.","required":true},"url":{"name":"url","type":"option","char":"u","description":"Application URL.","required":true},"format":{"name":"format","type":"option","char":"format","description":"Ouput format.","options":["table","json"],"default":"table"}},"args":[]},"environments:delete":{"id":"environments:delete","description":"Delete an environment.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"force","description":"Force delete.","allowNo":false}},"args":[{"name":"environmentId","description":"ID of an environment.","required":true}]},"environments:get":{"id":"environments:get","description":"Get the configuration of an environment.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"format":{"name":"format","type":"option","char":"format","description":"Output format.","options":["table","json"],"default":"table"}},"args":[{"name":"environmentId","description":"ID of an environment.","required":true}]},"environments:reset":{"id":"environments:reset","description":"Reset a remote environment by removing all layout changes","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"environment":{"name":"environment","type":"option","char":"e","description":"The remote environment name to reset."},"force":{"name":"force","type":"boolean","description":"Skip reset changes confirmation.","allowNo":false},"projectId":{"name":"projectId","type":"option","char":"p","description":"The id of the project to work on.","default":null}},"args":[]},"environments:update":{"id":"environments:update","description":"Update an environment.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"environmentId":{"name":"environmentId","type":"option","char":"e","description":"The forest environment ID to update.","required":true},"name":{"name":"name","type":"option","char":"n","description":"To update the environment name.","required":false},"url":{"name":"url","type":"option","char":"u","description":"To update the application URL.","required":false}},"args":[]},"projects:create":{"id":"projects:create","description":"Create a Forest API.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"applicationHost":{"name":"applicationHost","type":"option","char":"H","description":"Hostname of your admin backend application.","required":false},"applicationPort":{"name":"applicationPort","type":"option","char":"P","description":"Port of your admin backend application.","required":false},"databaseConnectionURL":{"name":"databaseConnectionURL","type":"option","char":"c","description":"Enter the database credentials with a connection URL.","required":false},"databaseDialect":{"name":"databaseDialect","type":"option","char":"d","description":"Enter your database dialect.","required":false,"options":["mongodb","mssql","mysql","postgres"]},"databaseName":{"name":"databaseName","type":"option","char":"n","description":"Enter your database name.","required":false},"databaseHost":{"name":"databaseHost","type":"option","char":"h","description":"Enter your database host.","required":false},"databasePort":{"name":"databasePort","type":"option","char":"p","description":"Enter your database port.","required":false},"databaseUser":{"name":"databaseUser","type":"option","char":"u","description":"Enter your database user.","required":false},"databasePassword":{"name":"databasePassword","type":"option","description":"Enter your database password.","required":false},"databaseSchema":{"name":"databaseSchema","type":"option","char":"s","description":"Enter your database schema.","required":false},"databaseSSL":{"name":"databaseSSL","type":"boolean","description":"Use SSL for database connection.","required":false,"allowNo":false},"mongoDBSRV":{"name":"mongoDBSRV","type":"boolean","description":"Use SRV DNS record for mongoDB connection.","required":false,"allowNo":false}},"args":[{"name":"applicationName","description":"Name of the project to create.","required":true}]},"projects:get":{"id":"projects:get","description":"Get the configuration of a project.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"format":{"name":"format","type":"option","char":"format","description":"Ouput format.","options":["table","json"],"default":"table"}},"args":[{"name":"projectId","description":"ID of a project.","required":true}]},"schema:apply":{"id":"schema:apply","description":"Apply the current schema of your repository to the specified environment (using your \".forestadmin-schema.json\" file).","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"secret":{"name":"secret","type":"option","char":"s","description":"Environment secret of the project (FOREST_ENV_SECRET).","required":false}},"args":[]},"schema:update":{"id":"schema:update","description":"Refresh your schema by generating files that do not currently exist.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"config":{"name":"config","type":"option","char":"c","description":"Database configuration file to use.","required":false,"default":"config/databases.js"},"outputDirectory":{"name":"outputDirectory","type":"option","char":"o","description":"Output directory where to generate new files.","required":false}},"args":[]}}}
|
|
1
|
+
{"version":"2.6.1","commands":{"branch":{"id":"branch","description":"Create a new branch or list your existing branches.","pluginName":"forest-cli","pluginType":"core","aliases":["branches"],"flags":{"projectId":{"name":"projectId","type":"option","description":"The id of the project to create a branch in."},"delete":{"name":"delete","type":"boolean","char":"d","description":"Delete the branch.","allowNo":false},"force":{"name":"force","type":"boolean","description":"When deleting a branch, skip confirmation.","allowNo":false},"help":{"name":"help","type":"boolean","description":"Display usage information.","allowNo":false}},"args":[{"name":"BRANCH_NAME","description":"The name of the branch to create.","required":false}]},"deploy":{"id":"deploy","description":"Deploy layout changes of an environment to the reference one.","pluginName":"forest-cli","pluginType":"core","aliases":["environments:deploy"],"flags":{"help":{"name":"help","type":"boolean","description":"Display usage information.","allowNo":false},"force":{"name":"force","type":"boolean","char":"f","description":"Skip deploy confirmation.","allowNo":false},"projectId":{"name":"projectId","type":"option","char":"p","description":"The id of the project you want to deploy.","default":null}},"args":[{"name":"ENVIRONMENT_NAME","description":"The name of the environment containing the layout changes to deploy to the reference one.","required":false}]},"environments":{"id":"environments","description":"Manage environments.","pluginName":"forest-cli","pluginType":"core","aliases":["environments:list"],"flags":{"projectId":{"name":"projectId","type":"option","char":"p","description":"Forest project ID.","default":null},"format":{"name":"format","type":"option","char":"format","description":"Ouput format.","options":["table","json"],"default":"table"}},"args":[]},"init":{"id":"init","description":"Set up your development environment in your current folder.","pluginName":"forest-cli","pluginType":"core","aliases":["environments:init"],"flags":{"projectId":{"name":"projectId","type":"option","char":"p","description":"The id of the project you want to init."}},"args":[]},"login":{"id":"login","description":"Sign in with an existing account.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"email":{"name":"email","type":"option","char":"e","description":"Your Forest Admin account email."},"password":{"name":"password","type":"option","char":"P","description":"Your Forest Admin account password (ignored if token is set)."},"token":{"name":"token","type":"option","char":"t","description":"Your Forest Admin account token (replaces password)."}},"args":[]},"logout":{"id":"logout","description":"Sign out of your account.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"build":{"name":"build"},"option":{"name":"option"},"enum":{"name":"enum"},"string":{"name":"string"},"boolean":{"name":"boolean"},"integer":{"name":"integer"},"version":{"name":"version"},"help":{"name":"help"}},"args":[]},"projects":{"id":"projects","description":"Manage projects.","pluginName":"forest-cli","pluginType":"core","aliases":["projects:list"],"flags":{"format":{"name":"format","type":"option","char":"format","description":"Ouput format.","options":["table","json"],"default":"table"}},"args":[]},"push":{"id":"push","description":"Push layout changes of your current branch to a remote environment.","pluginName":"forest-cli","pluginType":"core","aliases":["branches:push"],"flags":{"environment":{"name":"environment","type":"option","char":"e","description":"The remote environment name to push onto."},"force":{"name":"force","type":"boolean","description":"Skip push changes confirmation.","allowNo":false},"help":{"name":"help","type":"boolean","description":"Display usage information.","allowNo":false},"projectId":{"name":"projectId","type":"option","char":"p","description":"The id of the project to work on.","default":null}},"args":[]},"switch":{"id":"switch","description":"Switch to another branch in your local development environment.","pluginName":"forest-cli","pluginType":"core","aliases":["branch:switch"],"flags":{"help":{"name":"help","type":"boolean","description":"Display usage information.","allowNo":false}},"args":[{"name":"BRANCH_NAME","description":"The name of the local branch to set as current.","required":false}]},"user":{"id":"user","description":"Display the current logged in user.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"build":{"name":"build"},"option":{"name":"option"},"enum":{"name":"enum"},"string":{"name":"string"},"boolean":{"name":"boolean"},"integer":{"name":"integer"},"version":{"name":"version"},"help":{"name":"help"}},"args":[]},"environments:copy-layout":{"id":"environments:copy-layout","description":"Copy the layout from one environment to another.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"projectId":{"name":"projectId","type":"option","char":"p","description":"Forest project ID.","default":null},"force":{"name":"force","type":"boolean","char":"force","description":"Force copy.","allowNo":false}},"args":[{"name":"fromEnvironment","description":"Source environment ID.","required":true},{"name":"toEnvironment","description":"Target environment ID.","required":true}]},"environments:create":{"id":"environments:create","description":"Create a new environment.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"projectId":{"name":"projectId","type":"option","char":"p","description":"Forest project ID.","default":null},"name":{"name":"name","type":"option","char":"n","description":"Environment name.","required":true},"url":{"name":"url","type":"option","char":"u","description":"Application URL.","required":true},"format":{"name":"format","type":"option","char":"format","description":"Ouput format.","options":["table","json"],"default":"table"}},"args":[]},"environments:delete":{"id":"environments:delete","description":"Delete an environment.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"force","description":"Force delete.","allowNo":false}},"args":[{"name":"environmentId","description":"ID of an environment.","required":true}]},"environments:get":{"id":"environments:get","description":"Get the configuration of an environment.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"format":{"name":"format","type":"option","char":"format","description":"Output format.","options":["table","json"],"default":"table"}},"args":[{"name":"environmentId","description":"ID of an environment.","required":true}]},"environments:reset":{"id":"environments:reset","description":"Reset a remote environment by removing all layout changes","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"environment":{"name":"environment","type":"option","char":"e","description":"The remote environment name to reset."},"force":{"name":"force","type":"boolean","description":"Skip reset changes confirmation.","allowNo":false},"projectId":{"name":"projectId","type":"option","char":"p","description":"The id of the project to work on.","default":null}},"args":[]},"environments:update":{"id":"environments:update","description":"Update an environment.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"environmentId":{"name":"environmentId","type":"option","char":"e","description":"The forest environment ID to update.","required":true},"name":{"name":"name","type":"option","char":"n","description":"To update the environment name.","required":false},"url":{"name":"url","type":"option","char":"u","description":"To update the application URL.","required":false}},"args":[]},"projects:create":{"id":"projects:create","description":"Create a Forest API.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"applicationHost":{"name":"applicationHost","type":"option","char":"H","description":"Hostname of your admin backend application.","required":false},"applicationPort":{"name":"applicationPort","type":"option","char":"P","description":"Port of your admin backend application.","required":false},"databaseConnectionURL":{"name":"databaseConnectionURL","type":"option","char":"c","description":"Enter the database credentials with a connection URL.","required":false},"databaseDialect":{"name":"databaseDialect","type":"option","char":"d","description":"Enter your database dialect.","required":false,"options":["mongodb","mssql","mysql","postgres"]},"databaseName":{"name":"databaseName","type":"option","char":"n","description":"Enter your database name.","required":false},"databaseHost":{"name":"databaseHost","type":"option","char":"h","description":"Enter your database host.","required":false},"databasePort":{"name":"databasePort","type":"option","char":"p","description":"Enter your database port.","required":false},"databaseUser":{"name":"databaseUser","type":"option","char":"u","description":"Enter your database user.","required":false},"databasePassword":{"name":"databasePassword","type":"option","description":"Enter your database password.","required":false},"databaseSchema":{"name":"databaseSchema","type":"option","char":"s","description":"Enter your database schema.","required":false},"databaseSSL":{"name":"databaseSSL","type":"boolean","description":"Use SSL for database connection.","required":false,"allowNo":false},"mongoDBSRV":{"name":"mongoDBSRV","type":"boolean","description":"Use SRV DNS record for mongoDB connection.","required":false,"allowNo":false}},"args":[{"name":"applicationName","description":"Name of the project to create.","required":true}]},"projects:get":{"id":"projects:get","description":"Get the configuration of a project.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"format":{"name":"format","type":"option","char":"format","description":"Ouput format.","options":["table","json"],"default":"table"}},"args":[{"name":"projectId","description":"ID of a project.","required":true}]},"schema:apply":{"id":"schema:apply","description":"Apply the current schema of your repository to the specified environment (using your \".forestadmin-schema.json\" file).","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"secret":{"name":"secret","type":"option","char":"s","description":"Environment secret of the project (FOREST_ENV_SECRET).","required":false}},"args":[]},"schema:update":{"id":"schema:update","description":"Refresh your schema by generating files that do not currently exist.","pluginName":"forest-cli","pluginType":"core","aliases":[],"flags":{"config":{"name":"config","type":"option","char":"c","description":"Database configuration file to use.","required":false,"default":"config/databases.js"},"outputDirectory":{"name":"outputDirectory","type":"option","char":"o","description":"Output directory where to generate new files.","required":false}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "forest-cli",
|
|
3
3
|
"description": "The Lumberjacks' toolbelt is the Forest CLI which makes easy to manage your back office application directly from the terminal.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.6.1",
|
|
5
5
|
"author": "Sandro Munda",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Arnaud Valensi <arnaud.valensi@gmail.com>",
|
|
@@ -82,6 +82,30 @@ class CreateCommand extends AbstractAuthenticatedCommand {
|
|
|
82
82
|
this.exit(1);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
this.eventSender.sessionToken = authenticationToken;
|
|
86
|
+
this.eventSender.meta = {
|
|
87
|
+
dbDialect: dbConfig.dbDialect,
|
|
88
|
+
agent: dbConfig.dbDialect === 'mongodb' ? 'express-mongoose' : 'express-sequelize',
|
|
89
|
+
isLocal: ['localhost', '127.0.0.1', '::1'].some((keyword) => (
|
|
90
|
+
dbConfig.dbHostname
|
|
91
|
+
? dbConfig.dbHostname.includes(keyword)
|
|
92
|
+
: dbConfig.dbConnectionUrl.includes(keyword)
|
|
93
|
+
)),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
this.spinner.start({ text: 'Creating your project on Forest Admin' });
|
|
97
|
+
const projectCreationPromise = this.projectCreator.create(
|
|
98
|
+
authenticationToken, appConfig, this.eventSender.meta.agent,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const {
|
|
102
|
+
id, envSecret, authSecret,
|
|
103
|
+
} = await this.spinner.attachToPromise(projectCreationPromise);
|
|
104
|
+
|
|
105
|
+
this.eventSender.meta.projectId = id;
|
|
106
|
+
config.forestAuthSecret = authSecret;
|
|
107
|
+
config.forestEnvSecret = envSecret;
|
|
108
|
+
|
|
85
109
|
let schema = {};
|
|
86
110
|
|
|
87
111
|
this.spinner.start({ text: 'Connecting to your database' });
|
|
@@ -94,15 +118,6 @@ class CreateCommand extends AbstractAuthenticatedCommand {
|
|
|
94
118
|
const disconnectPromise = this.database.disconnect(connection);
|
|
95
119
|
await this.spinner.attachToPromise(disconnectPromise);
|
|
96
120
|
|
|
97
|
-
this.spinner.start({ text: 'Creating your project on Forest Admin' });
|
|
98
|
-
const projectCreationPromise = this.projectCreator.create(
|
|
99
|
-
authenticationToken, appConfig,
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const { envSecret, authSecret } = await this.spinner.attachToPromise(projectCreationPromise);
|
|
103
|
-
config.forestAuthSecret = authSecret;
|
|
104
|
-
config.forestEnvSecret = envSecret;
|
|
105
|
-
|
|
106
121
|
this.spinner.start({ text: 'Creating your project files' });
|
|
107
122
|
const dumperConfig = {
|
|
108
123
|
...dbConfig,
|
|
@@ -119,7 +134,7 @@ class CreateCommand extends AbstractAuthenticatedCommand {
|
|
|
119
134
|
|
|
120
135
|
async analyzeDatabase(dbConfig, connection) {
|
|
121
136
|
if (dbConfig.dbDialect === 'mongodb') {
|
|
122
|
-
// the mongodb analyzer display a progress bar during the
|
|
137
|
+
// the mongodb analyzer display a progress bar during the analysis
|
|
123
138
|
this.logger.info('Analyzing the database...');
|
|
124
139
|
const analysis = await this.databaseAnalyzer.analyzeMongoDb(connection, dbConfig, true);
|
|
125
140
|
this.logger.success('Database is analyzed', { lineColor: 'green' });
|
|
@@ -36,6 +36,7 @@ router.get('/{{ modelName }}', permissionMiddlewareCreator.list(), (request, res
|
|
|
36
36
|
// Get a number of {{ modelNameReadablePlural }}
|
|
37
37
|
router.get('/{{ modelName }}/count', permissionMiddlewareCreator.list(), (request, response, next) => {
|
|
38
38
|
// Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#get-a-number-of-records
|
|
39
|
+
// Improve peformances disabling pagination: https://docs.forestadmin.com/documentation/reference-guide/performance#disable-pagination-count
|
|
39
40
|
next();
|
|
40
41
|
});
|
|
41
42
|
|
|
@@ -21,12 +21,13 @@ class ProjectCreator {
|
|
|
21
21
|
this.terminator = terminator;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
async create(sessionToken, config) {
|
|
24
|
+
async create(sessionToken, config, agent) {
|
|
25
25
|
try {
|
|
26
|
-
const newProjectPayload = { name: config.applicationName };
|
|
26
|
+
const newProjectPayload = { name: config.applicationName, agent };
|
|
27
27
|
const newProject = await this.api.createProject(config, sessionToken, newProjectPayload);
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
|
+
id: newProject.id,
|
|
30
31
|
envSecret: newProject.defaultEnvironment.secretKey,
|
|
31
32
|
authSecret: this.keyGenerator.generate(),
|
|
32
33
|
};
|
|
@@ -322,7 +322,7 @@ class MongoCollectionsAnalyzer {
|
|
|
322
322
|
analysis = await this.analyzeMongoCollectionRemotely(databaseConnection, collectionName);
|
|
323
323
|
if (analysis === MAP_REDUCE_ERROR_STRING) {
|
|
324
324
|
isMongodbInstanceSupportJs = false;
|
|
325
|
-
this.logger.warn('The
|
|
325
|
+
this.logger.warn('The analysis is running locally instead of in the db instance because your instance does not support javascript.'
|
|
326
326
|
+ ' This action can takes a bit of time because it fetches all the collections.');
|
|
327
327
|
}
|
|
328
328
|
}
|
|
@@ -1,30 +1,49 @@
|
|
|
1
|
-
const superagent = require('superagent');
|
|
2
|
-
|
|
3
1
|
class EventSender {
|
|
4
|
-
constructor({ assertPresent, env }) {
|
|
5
|
-
assertPresent({ env });
|
|
2
|
+
constructor({ assertPresent, env, superagent }) {
|
|
3
|
+
assertPresent({ env, superagent });
|
|
6
4
|
this.env = env;
|
|
5
|
+
this.superagent = superagent;
|
|
7
6
|
|
|
8
7
|
this.applicationName = null;
|
|
9
8
|
this.command = null;
|
|
9
|
+
this.meta = null;
|
|
10
|
+
this.sessionToken = null;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
async notifyError(code = 'unknown_error', message = null, context = undefined) {
|
|
13
14
|
if (!this.applicationName || !this.command) { return; }
|
|
14
15
|
|
|
16
|
+
const attributes = {
|
|
17
|
+
code,
|
|
18
|
+
message,
|
|
19
|
+
project_name: this.applicationName,
|
|
20
|
+
command: this.command,
|
|
21
|
+
context,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
if (this.command !== 'schema:update') {
|
|
25
|
+
attributes.project_id = this.meta.projectId || null;
|
|
26
|
+
attributes.db_dialect = this.meta.dbDialect;
|
|
27
|
+
attributes.agent = this.meta.agent;
|
|
28
|
+
attributes.is_local = this.meta.isLocal;
|
|
29
|
+
}
|
|
30
|
+
|
|
15
31
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
message,
|
|
22
|
-
project_name: this.applicationName,
|
|
23
|
-
command: this.command,
|
|
24
|
-
context,
|
|
32
|
+
if (this.sessionToken) {
|
|
33
|
+
await this.superagent.post(`${this.env.FOREST_URL}/api/lumber/error`, {
|
|
34
|
+
data: {
|
|
35
|
+
type: 'events',
|
|
36
|
+
attributes,
|
|
25
37
|
},
|
|
26
|
-
},
|
|
27
|
-
}
|
|
38
|
+
}).set('Authorization', `Bearer ${this.sessionToken}`);
|
|
39
|
+
} else {
|
|
40
|
+
await this.superagent.post(`${this.env.FOREST_URL}/api/lumber/error`, {
|
|
41
|
+
data: {
|
|
42
|
+
type: 'events',
|
|
43
|
+
attributes,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
28
47
|
} catch (e) {
|
|
29
48
|
// NOTICE: We want silent error because this is just for reporting error
|
|
30
49
|
// and not not blocking if that does not work.
|
|
@@ -32,18 +51,25 @@ class EventSender {
|
|
|
32
51
|
}
|
|
33
52
|
|
|
34
53
|
async notifySuccess() {
|
|
35
|
-
if (
|
|
54
|
+
if (
|
|
55
|
+
!this.applicationName || !this.command || !this.sessionToken || !Object.keys(this.meta).length
|
|
56
|
+
) { return; }
|
|
36
57
|
|
|
37
58
|
try {
|
|
38
|
-
await superagent.post(`${this.env.FOREST_URL}/api/lumber/success`, {
|
|
59
|
+
await this.superagent.post(`${this.env.FOREST_URL}/api/lumber/success`, {
|
|
39
60
|
data: {
|
|
40
61
|
type: 'events',
|
|
41
62
|
attributes: {
|
|
42
63
|
command: this.command,
|
|
64
|
+
project_id: this.meta.projectId,
|
|
43
65
|
project_name: this.applicationName,
|
|
66
|
+
db_dialect: this.meta.dbDialect,
|
|
67
|
+
agent: this.meta.agent,
|
|
68
|
+
is_local: this.meta.isLocal,
|
|
44
69
|
},
|
|
45
70
|
},
|
|
46
|
-
})
|
|
71
|
+
})
|
|
72
|
+
.set('Authorization', `Bearer ${this.sessionToken}`);
|
|
47
73
|
} catch (e) {
|
|
48
74
|
// NOTICE: We want silent error because this is just for reporting error
|
|
49
75
|
// and not not blocking if that does not work.
|