forest-cli 2.3.6 → 2.5.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 +33 -0
- package/oclif.manifest.json +1 -1
- package/package.json +8 -8
- package/src/commands/environments/reset.js +91 -0
- package/src/commands/user.js +1 -1
- package/src/services/branch-manager.js +3 -2
- package/src/services/dumper/templates/app/models/index.hbs +1 -1
- package/src/services/environment-manager.js +11 -1
- package/src/services/init-manager.js +1 -1
- package/src/services/project-manager.js +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## [2.5.1](https://github.com/ForestAdmin/toolbelt/compare/v2.5.0...v2.5.1) (2021-12-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* error message when the user wants to create a branch on a remote branch ([#285](https://github.com/ForestAdmin/toolbelt/issues/285)) ([2cbde60](https://github.com/ForestAdmin/toolbelt/commit/2cbde60e62f0172ea306e729d374a737db428cb6))
|
|
7
|
+
|
|
8
|
+
# [2.5.0](https://github.com/ForestAdmin/toolbelt/compare/v2.4.1...v2.5.0) (2021-11-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **reset:** allow users to reset layout changes on a remote environment ([#284](https://github.com/ForestAdmin/toolbelt/issues/284)) ([1c2ce0e](https://github.com/ForestAdmin/toolbelt/commit/1c2ce0e8aaccb05ca6747a40e0a24ca5aa759172))
|
|
14
|
+
|
|
15
|
+
## [2.4.1](https://github.com/ForestAdmin/toolbelt/compare/v2.4.0...v2.4.1) (2021-10-28)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* change the method to generate files to be compatible with sequelize@6 ([#267](https://github.com/ForestAdmin/toolbelt/issues/267)) ([4600ffe](https://github.com/ForestAdmin/toolbelt/commit/4600ffe94d8cb910ef29df5d6eade9bdfb99d8e8))
|
|
21
|
+
|
|
22
|
+
# [2.4.0](https://github.com/ForestAdmin/toolbelt/compare/v2.3.6...v2.4.0) (2021-10-26)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* display projects when connected with sso ([#265](https://github.com/ForestAdmin/toolbelt/issues/265)) ([83ec508](https://github.com/ForestAdmin/toolbelt/commit/83ec5082ac94b5610b5f1da712b200b521539d1d))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* show if the user is connected via sso or not ([#266](https://github.com/ForestAdmin/toolbelt/issues/266)) ([5a5a865](https://github.com/ForestAdmin/toolbelt/commit/5a5a865d2e5480130526beb14bcbb7055818ec84))
|
|
33
|
+
|
|
1
34
|
## [2.3.6](https://github.com/ForestAdmin/toolbelt/compare/v2.3.5...v2.3.6) (2021-10-22)
|
|
2
35
|
|
|
3
36
|
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.3.6","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: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.5.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.5.1",
|
|
5
5
|
"author": "Sandro Munda",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Arnaud Valensi <arnaud.valensi@gmail.com>",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"app-root-path": "3.0.0",
|
|
26
26
|
"atob": "2.1.2",
|
|
27
27
|
"bluebird": "3.5.2",
|
|
28
|
-
"chalk": "4.
|
|
28
|
+
"chalk": "4.1.2",
|
|
29
29
|
"cli-table": "0.3.6",
|
|
30
30
|
"clipboardy": "2.3.0",
|
|
31
31
|
"commander": "2.9.0",
|
|
@@ -56,22 +56,22 @@
|
|
|
56
56
|
"validate-npm-package-name": "3.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@commitlint/cli": "
|
|
59
|
+
"@commitlint/cli": "14.1.0",
|
|
60
60
|
"@commitlint/config-conventional": "13.2.0",
|
|
61
61
|
"@oclif/dev-cli": "1.22.2",
|
|
62
62
|
"@semantic-release/changelog": "5.0.1",
|
|
63
63
|
"@semantic-release/git": "9.0.0",
|
|
64
|
-
"@types/jest": "
|
|
65
|
-
"eslint": "6.
|
|
64
|
+
"@types/jest": "27.0.2",
|
|
65
|
+
"eslint": "6.8.0",
|
|
66
66
|
"eslint-config-airbnb-base": "14.0.0",
|
|
67
67
|
"eslint-config-oclif": "3.1.0",
|
|
68
|
-
"eslint-plugin-import": "2.
|
|
69
|
-
"eslint-plugin-jest": "
|
|
68
|
+
"eslint-plugin-import": "2.25.2",
|
|
69
|
+
"eslint-plugin-jest": "25.2.2",
|
|
70
70
|
"eslint-plugin-sonarjs": "0.5.0",
|
|
71
71
|
"fs-extra": "8.1.0",
|
|
72
72
|
"git-hooks": "1.1.10",
|
|
73
73
|
"husky": "7.0.2",
|
|
74
|
-
"jest": "
|
|
74
|
+
"jest": "27.3.1",
|
|
75
75
|
"mock-stdin": "1.0.0",
|
|
76
76
|
"nock": "13.0.4",
|
|
77
77
|
"rimraf": "3.0.2",
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const EnvironmentManager = require('../../services/environment-manager');
|
|
2
|
+
const ProjectManager = require('../../services/project-manager');
|
|
3
|
+
const AbstractAuthenticatedCommand = require('../../abstract-authenticated-command');
|
|
4
|
+
const withCurrentProject = require('../../services/with-current-project');
|
|
5
|
+
const { handleError } = require('../../utils/error');
|
|
6
|
+
|
|
7
|
+
class ResetCommand extends AbstractAuthenticatedCommand {
|
|
8
|
+
init(plan) {
|
|
9
|
+
super.init(plan);
|
|
10
|
+
const { assertPresent, env, inquirer } = this.context;
|
|
11
|
+
assertPresent({ env, inquirer });
|
|
12
|
+
this.env = env;
|
|
13
|
+
this.inquirer = inquirer;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async askForEnvironment(config) {
|
|
17
|
+
const environments = await new EnvironmentManager(config).listEnvironments();
|
|
18
|
+
const remoteEnvironments = environments.filter((environment) => environment.type === 'remote');
|
|
19
|
+
|
|
20
|
+
if (remoteEnvironments.length) {
|
|
21
|
+
const response = await this.inquirer.prompt([{
|
|
22
|
+
name: 'environment',
|
|
23
|
+
message: 'Select the remote environment you want to reset',
|
|
24
|
+
type: 'list',
|
|
25
|
+
choices: remoteEnvironments.map(({ name }) => name),
|
|
26
|
+
}]);
|
|
27
|
+
return response.environment;
|
|
28
|
+
}
|
|
29
|
+
throw new Error('No remote environment.');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async runIfAuthenticated() {
|
|
33
|
+
const parsed = this.parse(ResetCommand);
|
|
34
|
+
const envSecret = this.env.FOREST_ENV_SECRET;
|
|
35
|
+
const commandOptions = { ...parsed.flags, ...parsed.args, envSecret };
|
|
36
|
+
let config;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
config = await withCurrentProject({ ...this.env, ...commandOptions });
|
|
40
|
+
|
|
41
|
+
if (!config.envSecret) {
|
|
42
|
+
const environment = await new ProjectManager(config)
|
|
43
|
+
.getDevelopmentEnvironmentForUser(config.projectId);
|
|
44
|
+
config.envSecret = environment.secretKey;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!config.environment) {
|
|
48
|
+
config.environment = await this.askForEnvironment(config);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!config.force) {
|
|
52
|
+
const response = await this.inquirer
|
|
53
|
+
.prompt([{
|
|
54
|
+
type: 'confirm',
|
|
55
|
+
name: 'confirm',
|
|
56
|
+
message: `Reset changes on the environment ${config.environment}`,
|
|
57
|
+
}]);
|
|
58
|
+
if (!response.confirm) return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
await new EnvironmentManager(config).reset(config.environment, config.envSecret);
|
|
62
|
+
this.logger.success(`Environment ${config.environment} successfully reset. Please refresh your browser to see the new state.`);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (error.response && error.status === 403) {
|
|
65
|
+
this.logger.error(`You do not have the rights to reset the layout of the environment ${config.environment}`);
|
|
66
|
+
} else {
|
|
67
|
+
this.logger.error(handleError(error));
|
|
68
|
+
}
|
|
69
|
+
this.exit(2);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
ResetCommand.description = 'Reset a remote environment by removing all layout changes';
|
|
75
|
+
|
|
76
|
+
ResetCommand.flags = {
|
|
77
|
+
environment: AbstractAuthenticatedCommand.flags.string({
|
|
78
|
+
char: 'e',
|
|
79
|
+
description: 'The remote environment name to reset.',
|
|
80
|
+
}),
|
|
81
|
+
force: AbstractAuthenticatedCommand.flags.boolean({
|
|
82
|
+
description: 'Skip reset changes confirmation.',
|
|
83
|
+
}),
|
|
84
|
+
projectId: AbstractAuthenticatedCommand.flags.integer({
|
|
85
|
+
char: 'p',
|
|
86
|
+
description: 'The id of the project to work on.',
|
|
87
|
+
default: null,
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
module.exports = ResetCommand;
|
package/src/commands/user.js
CHANGED
|
@@ -31,7 +31,7 @@ class UserCommand extends AbstractCommand {
|
|
|
31
31
|
if (token) {
|
|
32
32
|
const decoded = this.jwtDecode(token);
|
|
33
33
|
const { email } = decoded.data.data.attributes;
|
|
34
|
-
this.logger.info(`${this.chalk.bold('Email:')} ${this.chalk.cyan(email)}`);
|
|
34
|
+
this.logger.info(`${this.chalk.bold('Email:')} ${this.chalk.cyan(email)} (connected with${decoded.organizationId ? '' : 'out'} SSO)`);
|
|
35
35
|
} else {
|
|
36
36
|
return this.terminator.terminate(1, { logs: ['You are not logged.'] });
|
|
37
37
|
}
|
|
@@ -7,6 +7,7 @@ const { handleError } = require('../utils/error');
|
|
|
7
7
|
const ERROR_MESSAGE_PROJECT_IN_V1 = 'This project does not support branches yet. Please migrate your environments from your Project settings first.';
|
|
8
8
|
const ERROR_MESSAGE_ENV_SECRET_ISSUE = 'Your development environment is not properly set up. Please run `forest init` first and retry.';
|
|
9
9
|
const ERROR_MESSAGE_BRANCH_ALREADY_EXISTS = 'This branch already exists.';
|
|
10
|
+
const ERROR_MESSAGE_ADDITIONAL_REMOTE_BRANCHES = 'The remote environments can\'t have additional branches.';
|
|
10
11
|
const ERROR_MESSAGE_NO_PRODUCTION_OR_REMOTE_ENVIRONMENT = 'You cannot run branch commands until this project has either a remote or a production environment.';
|
|
11
12
|
const ERROR_MESSAGE_NO_REMOTE_ENVIRONMENT = 'You cannot run this command until this project has a remote non-production environment.';
|
|
12
13
|
const ERROR_MESSAGE_BRANCH_DOES_NOT_EXIST = 'This branch doesn\'t exist.';
|
|
@@ -111,8 +112,8 @@ function handleBranchError(rawError) {
|
|
|
111
112
|
return ERROR_MESSAGE_ENV_SECRET_ISSUE;
|
|
112
113
|
case 'Forbidden':
|
|
113
114
|
return ERROR_MESSAGE_NOT_ADMIN_USER;
|
|
114
|
-
case '
|
|
115
|
-
return
|
|
115
|
+
case 'Environment is not in development.':
|
|
116
|
+
return ERROR_MESSAGE_ADDITIONAL_REMOTE_BRANCHES;
|
|
116
117
|
case 'Dev Workflow disabled.':
|
|
117
118
|
return ERROR_MESSAGE_PROJECT_IN_V1;
|
|
118
119
|
case 'Branch name already exists.':
|
|
@@ -29,7 +29,7 @@ databasesConfiguration.forEach((databaseInfo) => {
|
|
|
29
29
|
const model = require(path.join(modelsDir, file))(connection, Mongoose);
|
|
30
30
|
db[model.modelName] = model;
|
|
31
31
|
{{else}}
|
|
32
|
-
const model =
|
|
32
|
+
const model = require(path.join(modelsDir, file))(connection, Sequelize.DataTypes);
|
|
33
33
|
db[model.name] = model;
|
|
34
34
|
{{/if}}
|
|
35
35
|
} catch (error) {
|
|
@@ -5,7 +5,7 @@ const Context = require('@forestadmin/context');
|
|
|
5
5
|
const EnvironmentSerializer = require('../serializers/environment');
|
|
6
6
|
const environmentDeserializer = require('../deserializers/environment');
|
|
7
7
|
const DeploymentRequestSerializer = require('../serializers/deployment-request');
|
|
8
|
-
const JobStateChecker = require('
|
|
8
|
+
const JobStateChecker = require('./job-state-checker');
|
|
9
9
|
|
|
10
10
|
function EnvironmentManager(config) {
|
|
11
11
|
const {
|
|
@@ -112,6 +112,16 @@ function EnvironmentManager(config) {
|
|
|
112
112
|
return jobStateChecker.check(jobId, config.projectId);
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
+
this.reset = async (environmentName, environmentSecret) => {
|
|
116
|
+
const authToken = authenticator.getAuthToken();
|
|
117
|
+
|
|
118
|
+
return agent
|
|
119
|
+
.post(`${env.FOREST_URL}/api/environments/reset`)
|
|
120
|
+
.set('Authorization', `Bearer ${authToken}`)
|
|
121
|
+
.set('forest-secret-key', `${environmentSecret}`)
|
|
122
|
+
.send({ environmentName });
|
|
123
|
+
};
|
|
124
|
+
|
|
115
125
|
/**
|
|
116
126
|
* Deploy layout changes of an environment to production.
|
|
117
127
|
* @param {Number} environment.id - The environment id that contains the layout changes to deploy.
|
|
@@ -5,7 +5,7 @@ const { EOL } = require('os');
|
|
|
5
5
|
const Context = require('@forestadmin/context');
|
|
6
6
|
|
|
7
7
|
const { handleError } = require('../utils/error');
|
|
8
|
-
const { DatabasePrompts } = require('
|
|
8
|
+
const { DatabasePrompts } = require('./prompter/database-prompts');
|
|
9
9
|
|
|
10
10
|
const SUCCESS_MESSAGE_ENV_VARIABLES_COPIED_IN_ENV_FILE = 'Copying the environment variables in your `.env` file';
|
|
11
11
|
const SUCCESS_MESSAGE_ENV_FILE_CREATED_AND_FILLED = 'Creating a new `.env` file containing your environment variables';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
|
+
const querystring = require('querystring');
|
|
2
3
|
const P = require('bluebird');
|
|
3
4
|
const agent = require('superagent-promise')(require('superagent'), P);
|
|
4
5
|
const Context = require('@forestadmin/context');
|
|
@@ -8,8 +9,10 @@ const ProjectDeserializer = require('../deserializers/project');
|
|
|
8
9
|
const EnvironmentDeserializer = require('../deserializers/environment');
|
|
9
10
|
|
|
10
11
|
function ProjectManager(config) {
|
|
11
|
-
const {
|
|
12
|
-
|
|
12
|
+
const {
|
|
13
|
+
assertPresent, authenticator, env, jwtDecode,
|
|
14
|
+
} = Context.inject();
|
|
15
|
+
assertPresent({ authenticator, env, jwtDecode });
|
|
13
16
|
|
|
14
17
|
function deserialize(response) {
|
|
15
18
|
const attrs = _.clone(ProjectSerializer.opts.attributes);
|
|
@@ -28,9 +31,13 @@ function ProjectManager(config) {
|
|
|
28
31
|
|
|
29
32
|
this.listProjects = async () => {
|
|
30
33
|
const authToken = authenticator.getAuthToken();
|
|
34
|
+
const authTokenDecode = jwtDecode(authToken);
|
|
35
|
+
const queryParams = querystring.stringify({
|
|
36
|
+
...(authTokenDecode.organizationId ? { organizationId: authTokenDecode.organizationId } : {}),
|
|
37
|
+
});
|
|
31
38
|
|
|
32
39
|
return agent
|
|
33
|
-
.get(`${env.FOREST_URL}/api/projects`)
|
|
40
|
+
.get(`${env.FOREST_URL}/api/projects${queryParams ? (`?${queryParams}`) : ''}`)
|
|
34
41
|
.set('Authorization', `Bearer ${authToken}`)
|
|
35
42
|
.send()
|
|
36
43
|
.then((response) => deserialize(response));
|