forest-cli 3.0.3 → 3.0.5
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/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/services/branch-manager.js +2 -2
- package/src/services/dumper/templates/app/models/mongo-model.hbs +2 -2
- package/src/services/dumper/templates/app/models/sequelize-model.hbs +3 -3
- package/src/services/dumper/templates/app/routes/route.hbs +11 -11
- package/src/services/init-manager.js +2 -2
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"3.0.3","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},"format":{"name":"format","type":"option","char":"format","description":"Output format.","options":["table","json"],"default":"table"},"origin":{"name":"origin","type":"option","char":"o","description":"Set the origin of the created branch."}},"args":[{"name":"BRANCH_NAME","description":"The name of the branch to create.","required":false}]},"deploy":{"id":"deploy","description":"Deploy layout changes of the current branch 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":[]},"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 the branch origin.","pluginName":"forest-cli","pluginType":"core","aliases":["branches:push"],"flags":{"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":[]},"set-origin":{"id":"set-origin","description":"Set an environment as your branch's origin. Your branch will build on top of that environment's layout.","pluginName":"forest-cli","pluginType":"core","aliases":["branches:origin"],"flags":{"help":{"name":"help","type":"boolean","description":"Display usage information.","allowNo":false}},"args":[{"name":"ENVIRONMENT_NAME","description":"The environment to set as origin.","required":false}]},"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":[{"name":"mongodb","value":"mongodb"},{"name":"mssql","value":"mssql"},{"name":"mysql / mariadb","value":"mysql"},{"name":"postgres","value":"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":"3.0.5","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},"format":{"name":"format","type":"option","char":"format","description":"Output format.","options":["table","json"],"default":"table"},"origin":{"name":"origin","type":"option","char":"o","description":"Set the origin of the created branch."}},"args":[{"name":"BRANCH_NAME","description":"The name of the branch to create.","required":false}]},"deploy":{"id":"deploy","description":"Deploy layout changes of the current branch 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":[]},"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 the branch origin.","pluginName":"forest-cli","pluginType":"core","aliases":["branches:push"],"flags":{"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":[]},"set-origin":{"id":"set-origin","description":"Set an environment as your branch's origin. Your branch will build on top of that environment's layout.","pluginName":"forest-cli","pluginType":"core","aliases":["branches:origin"],"flags":{"help":{"name":"help","type":"boolean","description":"Display usage information.","allowNo":false}},"args":[{"name":"ENVIRONMENT_NAME","description":"The environment to set as origin.","required":false}]},"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":[{"name":"mongodb","value":"mongodb"},{"name":"mssql","value":"mssql"},{"name":"mysql / mariadb","value":"mysql"},{"name":"postgres","value":"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": "3.0.
|
|
4
|
+
"version": "3.0.5",
|
|
5
5
|
"author": "Sandro Munda",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Arnaud Valensi <arnaud.valensi@gmail.com>",
|
|
@@ -12,7 +12,7 @@ const ERROR_MESSAGE_NO_PRODUCTION_OR_REMOTE_ENVIRONMENT = 'You cannot run branch
|
|
|
12
12
|
const ERROR_MESSAGE_NO_REMOTE_ENVIRONMENT = 'You cannot run this command until this project has a remote non-production environment.';
|
|
13
13
|
const ERROR_MESSAGE_BRANCH_DOES_NOT_EXIST = 'This branch doesn\'t exist.';
|
|
14
14
|
const ERROR_MESSAGE_REMOVE_BRANCH_FAILED = 'Failed to delete branch.';
|
|
15
|
-
const
|
|
15
|
+
const ERROR_MESSAGE_NOT_RIGHT_PERMISSION_LEVEL = 'You need the \'Admin\' or \'Developer\' permission level on this project to use branches.';
|
|
16
16
|
const ERROR_MESSAGE_ENVIRONMENT_NOT_FOUND = 'The environment provided doesn\'t exist.';
|
|
17
17
|
const ERROR_MESSAGE_NO_CURRENT_BRANCH = 'You don\'t have any branch to push. Use `forest branch` to create one or use `forest switch` to set your current branch.';
|
|
18
18
|
const ERROR_MESSAGE_WRONG_ENVIRONMENT_TYPE = 'The environment on which you are trying to push your modifications is not a remote environment.';
|
|
@@ -130,7 +130,7 @@ function handleBranchError(rawError) {
|
|
|
130
130
|
case 'Not Found':
|
|
131
131
|
return ERROR_MESSAGE_ENV_SECRET_ISSUE;
|
|
132
132
|
case 'Forbidden':
|
|
133
|
-
return
|
|
133
|
+
return ERROR_MESSAGE_NOT_RIGHT_PERMISSION_LEVEL;
|
|
134
134
|
case 'Environment is not in development.':
|
|
135
135
|
return ERROR_MESSAGE_ADDITIONAL_REMOTE_BRANCHES;
|
|
136
136
|
case 'Dev Workflow disabled.':
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This model was generated by Forest CLI. However, you remain in control of your models.
|
|
2
|
-
// Learn how here: https://docs.forestadmin.com/documentation/
|
|
2
|
+
// Learn how here: https://docs.forestadmin.com/documentation/reference-guide/models/enrich-your-models
|
|
3
3
|
|
|
4
4
|
module.exports = (mongoose, Mongoose) => {
|
|
5
5
|
// This section contains the properties of your model, mapped to your collection's properties.
|
|
6
|
-
// Learn more here: https://docs.forestadmin.com/documentation/
|
|
6
|
+
// Learn more here: https://docs.forestadmin.com/documentation/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
|
|
7
7
|
const schema = Mongoose.Schema({
|
|
8
8
|
{{#each fields as |field|}}
|
|
9
9
|
{{wq field.name}}: {{#if field.ref}}{ type: {{field.type}}, ref: '{{field.ref}}' }{{else if (isObject field.type)}}{{>renderNested type=field.type level=2}}{{else}}{{field.type}}{{/if}},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This model was generated by Forest CLI. However, you remain in control of your models.
|
|
2
|
-
// Learn how here: https://docs.forestadmin.com/documentation/
|
|
2
|
+
// Learn how here: https://docs.forestadmin.com/documentation/reference-guide/models/enrich-your-models
|
|
3
3
|
module.exports = (sequelize, DataTypes) => {
|
|
4
4
|
const { Sequelize } = sequelize;
|
|
5
5
|
// This section contains the fields of your model, mapped to your table's columns.
|
|
6
|
-
// Learn more here: https://docs.forestadmin.com/documentation/
|
|
6
|
+
// Learn more here: https://docs.forestadmin.com/documentation/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
|
|
7
7
|
const {{modelVariableName}} = sequelize.define('{{modelName}}', {
|
|
8
8
|
{{#each fields as |field|}}
|
|
9
9
|
{{#if field.hasParenthesis}}'{{/if}}{{field.name}}{{#if field.hasParenthesis}}'{{/if}}: {
|
|
@@ -21,7 +21,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
21
21
|
schema: process.env.DATABASE_SCHEMA,{{/if}}
|
|
22
22
|
});
|
|
23
23
|
{{#if noId}} {{modelVariableName}}.removeAttribute('id');{{/if}}
|
|
24
|
-
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/
|
|
24
|
+
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/reference-guide/relationships#adding-relationships.
|
|
25
25
|
{{modelVariableName}}.associate = (models) => {
|
|
26
26
|
{{#each references as |reference|}}
|
|
27
27
|
{{../modelVariableName}}.{{reference.association}}(models.{{reference.ref}}, {
|
|
@@ -6,55 +6,55 @@ const router = express.Router();
|
|
|
6
6
|
const permissionMiddlewareCreator = new PermissionMiddlewareCreator('{{ modelName }}');
|
|
7
7
|
|
|
8
8
|
// This file contains the logic of every route in Forest Admin for the collection {{ modelName }}:
|
|
9
|
-
// - Native routes are already generated but can be extended/overriden - Learn how to extend a route here: https://docs.forestadmin.com/documentation/
|
|
10
|
-
// - Smart action routes will need to be added as you create new Smart Actions - Learn how to create a Smart Action here: https://docs.forestadmin.com/documentation/
|
|
9
|
+
// - Native routes are already generated but can be extended/overriden - Learn how to extend a route here: https://docs.forestadmin.com/documentation/reference-guide/routes/extend-a-route
|
|
10
|
+
// - Smart action routes will need to be added as you create new Smart Actions - Learn how to create a Smart Action here: https://docs.forestadmin.com/documentation/reference-guide/actions/create-and-manage-smart-actions
|
|
11
11
|
|
|
12
12
|
// Create a {{ modelNameReadableSingular }}
|
|
13
13
|
router.post('/{{ modelName }}', permissionMiddlewareCreator.create(), (request, response, next) => {
|
|
14
|
-
// Learn what this route does here: https://docs.forestadmin.com/documentation/
|
|
14
|
+
// Learn what this route does here: https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#create-a-record
|
|
15
15
|
next();
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
// Update a {{ modelNameReadableSingular }}
|
|
19
19
|
router.put('/{{ modelName }}/:recordId', permissionMiddlewareCreator.update(), (request, response, next) => {
|
|
20
|
-
// Learn what this route does here: https://docs.forestadmin.com/documentation/
|
|
20
|
+
// Learn what this route does here: https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#update-a-record
|
|
21
21
|
next();
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
// Delete a {{ modelNameReadableSingular }}
|
|
25
25
|
router.delete('/{{ modelName }}/:recordId', permissionMiddlewareCreator.delete(), (request, response, next) => {
|
|
26
|
-
// Learn what this route does here: https://docs.forestadmin.com/documentation/
|
|
26
|
+
// Learn what this route does here: https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#delete-a-record
|
|
27
27
|
next();
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
// Get a list of {{ modelNameReadablePlural }}
|
|
31
31
|
router.get('/{{ modelName }}', permissionMiddlewareCreator.list(), (request, response, next) => {
|
|
32
|
-
// Learn what this route does here: https://docs.forestadmin.com/documentation/
|
|
32
|
+
// Learn what this route does here: https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#get-a-list-of-records
|
|
33
33
|
next();
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
// Get a number of {{ modelNameReadablePlural }}
|
|
37
37
|
router.get('/{{ modelName }}/count', permissionMiddlewareCreator.list(), (request, response, next) => {
|
|
38
|
-
// Learn what this route does here: https://docs.forestadmin.com/documentation/
|
|
39
|
-
// Improve
|
|
38
|
+
// Learn what this route does here: https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#get-a-number-of-records
|
|
39
|
+
// Improve performances disabling pagination: https://docs.forestadmin.com/documentation/reference-guide/performance#disable-pagination-count
|
|
40
40
|
next();
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
// Get a {{ modelNameReadableSingular }}
|
|
44
44
|
router.get('/{{ modelName }}/\\b(?!count\\b):recordId', permissionMiddlewareCreator.details(), (request, response, next) => {
|
|
45
|
-
// Learn what this route does here: https://docs.forestadmin.com/documentation/
|
|
45
|
+
// Learn what this route does here: https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#get-a-record
|
|
46
46
|
next();
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
// Export a list of {{ modelNameReadablePlural }}
|
|
50
50
|
router.get('/{{ modelName }}.csv', permissionMiddlewareCreator.export(), (request, response, next) => {
|
|
51
|
-
// Learn what this route does here: https://docs.forestadmin.com/documentation/
|
|
51
|
+
// Learn what this route does here: https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#export-a-list-of-records
|
|
52
52
|
next();
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
// Delete a list of {{ modelNameReadablePlural }}
|
|
56
56
|
router.delete('/{{ modelName }}', permissionMiddlewareCreator.delete(), (request, response, next) => {
|
|
57
|
-
// Learn what this route does here: https://docs.forestadmin.com/documentation/
|
|
57
|
+
// Learn what this route does here: https://docs.forestadmin.com/documentation/reference-guide/routes/default-routes#delete-a-list-of-records
|
|
58
58
|
next();
|
|
59
59
|
});
|
|
60
60
|
|
|
@@ -13,7 +13,7 @@ const SUCCESS_MESSAGE_DISPLAY_ENV_VARIABLES = 'Here are the environment variable
|
|
|
13
13
|
const SUCCESS_MESSAGE_ENV_VARIABLES_COPIED_TO_CLIPBOARD = 'Automatically copied to your clipboard!';
|
|
14
14
|
|
|
15
15
|
const ERROR_MESSAGE_PROJECT_IN_V1 = 'This project does not support branches yet. Please migrate your environments from your Project settings first.';
|
|
16
|
-
const
|
|
16
|
+
const ERROR_MESSAGE_NOT_RIGHT_PERMISSION_LEVEL = 'You need the \'Admin\' or \'Developer\' permission level on this project to use branches.';
|
|
17
17
|
const ERROR_MESSAGE_PROJECT_BY_ENV_NOT_FOUND = 'Your project was not found. Please check your environment secret.';
|
|
18
18
|
const ERROR_MESSAGE_PROJECT_BY_OPTION_NOT_FOUND = 'The project you specified does not exist.';
|
|
19
19
|
const ERROR_MESSAGE_NO_PRODUCTION_OR_REMOTE_ENVIRONMENT = 'You cannot create your development environment until this project has either a remote or a production environment.';
|
|
@@ -43,7 +43,7 @@ function handleInitError(rawError) {
|
|
|
43
43
|
case 'Dev Workflow disabled.':
|
|
44
44
|
return ERROR_MESSAGE_PROJECT_IN_V1;
|
|
45
45
|
case 'Forbidden':
|
|
46
|
-
return
|
|
46
|
+
return ERROR_MESSAGE_NOT_RIGHT_PERMISSION_LEVEL;
|
|
47
47
|
case 'Project by env secret not found':
|
|
48
48
|
return ERROR_MESSAGE_PROJECT_BY_ENV_NOT_FOUND;
|
|
49
49
|
case 'Project not found':
|