forest-cli 2.5.3 → 2.5.4
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 +7 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/services/logger.js +53 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.5.4](https://github.com/ForestAdmin/toolbelt/compare/v2.5.3...v2.5.4) (2021-12-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **logger:** allow logger to display object ([#321](https://github.com/ForestAdmin/toolbelt/issues/321)) ([d81d5f1](https://github.com/ForestAdmin/toolbelt/commit/d81d5f17cab5980ee4009c6b8fe56a1ad06a743f))
|
|
7
|
+
|
|
1
8
|
## [2.5.3](https://github.com/ForestAdmin/toolbelt/compare/v2.5.2...v2.5.3) (2021-12-31)
|
|
2
9
|
|
|
3
10
|
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.5.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}},"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.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":[]}}}
|
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.5.
|
|
4
|
+
"version": "2.5.4",
|
|
5
5
|
"author": "Sandro Munda",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Arnaud Valensi <arnaud.valensi@gmail.com>",
|
package/src/services/logger.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
2
|
|
|
3
|
+
const ALLOWED_OPTION_KEYS = [
|
|
4
|
+
'color',
|
|
5
|
+
'prefix',
|
|
6
|
+
'std',
|
|
7
|
+
'lineColor',
|
|
8
|
+
];
|
|
9
|
+
const DEFAULT_OPTION_VALUES = ALLOWED_OPTION_KEYS.reduce((options, key) => {
|
|
10
|
+
options[key] = undefined;
|
|
11
|
+
return options;
|
|
12
|
+
}, {});
|
|
13
|
+
|
|
3
14
|
class Logger {
|
|
4
15
|
constructor({
|
|
5
16
|
assertPresent,
|
|
@@ -20,10 +31,7 @@ class Logger {
|
|
|
20
31
|
if (this.silent) return;
|
|
21
32
|
|
|
22
33
|
options = {
|
|
23
|
-
|
|
24
|
-
prefix: null,
|
|
25
|
-
std: null,
|
|
26
|
-
lineColor: null,
|
|
34
|
+
...DEFAULT_OPTION_VALUES,
|
|
27
35
|
...options,
|
|
28
36
|
};
|
|
29
37
|
|
|
@@ -33,11 +41,10 @@ class Logger {
|
|
|
33
41
|
actualPrefix = Logger._setBoldColor(options.color, actualPrefix);
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
let actualMessage = message;
|
|
44
|
+
let actualMessage = Logger._stringifyIfObject(message);
|
|
37
45
|
if (options.lineColor) {
|
|
38
46
|
actualMessage = `${Logger._setColor(options.lineColor, actualMessage)}`;
|
|
39
47
|
}
|
|
40
|
-
|
|
41
48
|
actualMessage = `${actualPrefix}${actualMessage}\n`;
|
|
42
49
|
|
|
43
50
|
if (options.std === 'err') {
|
|
@@ -54,6 +61,14 @@ class Logger {
|
|
|
54
61
|
messages.forEach((message) => this._logLine(message, { ...baseOptions, ...options }));
|
|
55
62
|
}
|
|
56
63
|
|
|
64
|
+
static _stringifyIfObject(message) {
|
|
65
|
+
if (typeof message === 'object') {
|
|
66
|
+
return JSON.stringify(message);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return message;
|
|
70
|
+
}
|
|
71
|
+
|
|
57
72
|
static _setColor(color, message) {
|
|
58
73
|
return chalk[color](message);
|
|
59
74
|
}
|
|
@@ -62,27 +77,49 @@ class Logger {
|
|
|
62
77
|
return chalk.bold[color](message);
|
|
63
78
|
}
|
|
64
79
|
|
|
65
|
-
|
|
80
|
+
static _isObjectKeysMatchAlwaysTheGivenKeys(object) {
|
|
81
|
+
if (typeof object !== 'object') {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return Object.keys(object).every((key) => ALLOWED_OPTION_KEYS.includes(key));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// This is a hack to keep the current signature of Logger methods.
|
|
89
|
+
// Last `message` is considered an option object if its keys are in `ALLOWED_OPTION_KEYS`.
|
|
66
90
|
static _extractGivenOptionsFromMessages(messages) {
|
|
67
91
|
let options = {};
|
|
68
|
-
const potentialGivenOption = messages[messages.length - 1];
|
|
69
92
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
93
|
+
const potentialGivenOptions = messages[messages.length - 1];
|
|
94
|
+
const hasOptions = Logger._isObjectKeysMatchAlwaysTheGivenKeys(potentialGivenOptions);
|
|
95
|
+
|
|
96
|
+
if (hasOptions) {
|
|
97
|
+
messages = messages.slice(0, -1);
|
|
98
|
+
options = { ...options, ...potentialGivenOptions };
|
|
73
99
|
}
|
|
100
|
+
|
|
74
101
|
return { messages, options };
|
|
75
102
|
}
|
|
76
103
|
|
|
77
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Allows to log one ore more messages, with option object as last optional parameter.
|
|
106
|
+
* @example logger.log('message')
|
|
107
|
+
* @example logger.log('message', { color: 'blue', colorLine: 'green' })
|
|
108
|
+
* @example logger.log('message 1', 'message 2')
|
|
109
|
+
* @example logger.log('message 1', 'message 2', { color: 'blue', colorLine: 'green' })
|
|
110
|
+
*/
|
|
111
|
+
log(...messagesAndOptions) { this._logLines(messagesAndOptions); }
|
|
78
112
|
|
|
79
|
-
|
|
113
|
+
error(...messagesAndOptions) { this._logLines(messagesAndOptions, { color: 'red', prefix: '×', std: 'err' }); }
|
|
80
114
|
|
|
81
|
-
|
|
115
|
+
info(...messagesAndOptions) { this._logLines(messagesAndOptions, { color: 'blue', prefix: '>' }); }
|
|
82
116
|
|
|
83
|
-
success(...
|
|
117
|
+
success(...messagesAndOptions) { this._logLines(messagesAndOptions, { color: 'green', prefix: '√' }); }
|
|
84
118
|
|
|
85
|
-
warn(...
|
|
119
|
+
warn(...messagesAndOptions) { this._logLines(messagesAndOptions, { color: 'yellow', prefix: 'Δ' }); }
|
|
86
120
|
}
|
|
87
121
|
|
|
122
|
+
if (process.env.NODE_ENV === 'test') {
|
|
123
|
+
Logger.DEFAULT_OPTION_VALUES = DEFAULT_OPTION_VALUES;
|
|
124
|
+
}
|
|
88
125
|
module.exports = Logger;
|