Skip to content

Commit 7ab6d59

Browse files
log formatting (#483)
* log formatting * add figlet
1 parent 4c05627 commit 7ab6d59

File tree

11 files changed

+38
-6
lines changed

11 files changed

+38
-6
lines changed

lib/interface/cli/commands/agent/install.cmd.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const ProgressEvents = require('../../helpers/progressEvents');
88
const cliProgress = require('cli-progress');
99
const colors = require('colors');
1010
const { getNewAgentName } = require('./helper');
11+
const { DefaultLogFormatter } = require('./../hybrid/helper');
1112

1213
const defaultNamespace = 'codefresh';
1314

@@ -177,6 +178,7 @@ const installAgentCmd = new Command({
177178
agentId: name,
178179
terminateProcess,
179180
events,
181+
logFormatting: DefaultLogFormatter,
180182
});
181183
if (agentInstallStatusCode !== 0) {
182184
throw new Error(`\nRunner installation failed with code ${agentInstallStatusCode}`);

lib/interface/cli/commands/agent/uninstall.cmd.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const { sdk } = require('../../../../logic');
66
const { getKubeContext } = require('../../helpers/kubernetes');
77
const ProgressEvents = require('../../helpers/progressEvents');
88
const cliProgress = require('cli-progress');
9+
const { DefaultLogFormatter } = require('./../hybrid/helper');
910

1011

1112
const unInstallAgentCmd = new Command({
@@ -76,6 +77,7 @@ const unInstallAgentCmd = new Command({
7677
kubeConfigPath,
7778
terminateProcess: false,
7879
events,
80+
logFormatting: DefaultLogFormatter,
7981
});
8082
if (exitCode === 0) {
8183
console.log('Agent uninsalled successfully');

lib/interface/cli/commands/hybrid/helper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const INSTALLATION_DEFAULTS = {
1919
CF_CONTEXT_NAME: 'cf-runner',
2020
};
2121

22+
const DefaultLogFormatter = 'plain';
23+
2224
const defaultOpenIssueMessage = 'If you had any issues with this process please report them at: ' +
2325
`${colors.blue('https://github.com/codefresh-io/cli/issues/new')}`;
2426
const url = _.get(sdk, 'config.context.url', 'https://g.codefresh.io');
@@ -224,4 +226,5 @@ module.exports = {
224226
createProgressBar,
225227
getTestPipelineLink,
226228
INSTALLATION_DEFAULTS,
229+
DefaultLogFormatter,
227230
};

lib/interface/cli/commands/hybrid/init.cmd.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const {
2121
executeTestPipeline,
2222
INSTALLATION_DEFAULTS,
2323
} = require('./helper');
24-
24+
const figlet = require('figlet');
2525

2626
const handleError = createErrorHandler(`\nIf you had any issues with the installation please report them at: ${colors.blue('https://github.com/codefresh-io/cli/issues/new')}`);
2727

@@ -324,6 +324,15 @@ const initCmd = new Command({
324324
console.log(colors.green(`\nDocumenation link: ${colors.blue('https://codefresh.io/docs/docs/enterprise/codefresh-runner/#codefresh-runner-preview-release')}`));
325325
console.log(colors.green(`If you had any issues with the installation please report them at: ${colors.blue('https://github.com/codefresh-io/cli/issues/new')}`));
326326
await to(progressReporter.report(installationProgress.events.FINISHED, installationProgress.status.SUCCESS));
327+
await new Promise((resolve) => {
328+
figlet('CODEFRESH', (err, data) => {
329+
if (err) {
330+
return;
331+
}
332+
console.log(data);
333+
resolve();
334+
});
335+
});
327336
process.exit(); // TODO : This is not needed - needed to be fixed
328337
},
329338
});

lib/interface/cli/commands/monitor/install.cmd.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const installRoot = require('../root/install.cmd');
44
const { sdk } = require('../../../../logic');
55
const ProgressEvents = require('../../helpers/progressEvents');
66
const cliProgress = require('cli-progress');
7+
const { DefaultLogFormatter } = require('./../hybrid/helper');
78

89
const installMonitorCmd = new Command({
910
root: false,
@@ -72,6 +73,7 @@ const installMonitorCmd = new Command({
7273
verbose,
7374
events,
7475
codefreshHost: url,
76+
logFormatting: DefaultLogFormatter,
7577
});
7678
if (monitorInstallStatusCode !== 0) {
7779
throw new Error(`\nCodefresh Monitoring installation failed with code ${monitorInstallStatusCode}`);

lib/interface/cli/commands/monitor/uninstall.cmd.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const unInstallRoot = require('../root/uninstall.cmd');
44
const { sdk } = require('../../../../logic');
55
const ProgressEvents = require('../../helpers/progressEvents');
66
const cliProgress = require('cli-progress');
7+
const { DefaultLogFormatter } = require('./../hybrid/helper');
78

89

910
const unInstallAgentCmd = new Command({
@@ -60,6 +61,7 @@ const unInstallAgentCmd = new Command({
6061
kubeConfigPath,
6162
terminateProcess: false,
6263
events,
64+
logFormatting: DefaultLogFormatter,
6365
});
6466
if (exitCode === 0) {
6567
console.log('Monitor uninsalled successfully');

lib/interface/cli/commands/runtimeEnvironments/attach.cmd.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { sdk } = require('../../../../logic');
55
const ProgressEvents = require('../../helpers/progressEvents');
66
const cliProgress = require('cli-progress');
77
const { getKubeContext } = require('../../helpers/kubernetes');
8+
const { DefaultLogFormatter } = require('./../hybrid/helper');
89

910
const attachAgentToRuntime = async (agent, name) => {
1011
const rt = await sdk.runtimeEnvs.get({ name });
@@ -141,6 +142,7 @@ const attachRuntimeCmd = new Command({
141142
restartAgent,
142143
terminateProcess: false,
143144
events,
145+
logFormatting: DefaultLogFormatter,
144146
});
145147
if (!restartAgent) {
146148
console.log('Please restart agent\'s pod in order that changes will take effect');

lib/interface/cli/commands/runtimeEnvironments/install.cmd.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const cliProgress = require('cli-progress');
99
const createClusterCmd = require('../cluster/create.cmd');
1010
const colors = require('colors');
1111
const _ = require('lodash');
12+
const { DefaultLogFormatter } = require('./../hybrid/helper');
1213

1314
const defaultNamespace = 'codefresh';
1415
const maxRuntimeNameLength = 63;
@@ -259,6 +260,7 @@ const installRuntimeCmd = new Command({
259260
events: runtimeEvents,
260261
skipClusterTest,
261262
storageClassName,
263+
logFormatting: DefaultLogFormatter,
262264
});
263265
// attach RE to agent in codefresh
264266

lib/interface/cli/commands/runtimeEnvironments/uninstall.cmd.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const { getKubeContext } = require('../../helpers/kubernetes');
66
const _ = require('lodash');
77
const ProgressEvents = require('../../helpers/progressEvents');
88
const cliProgress = require('cli-progress');
9+
const { DefaultLogFormatter } = require('./../hybrid/helper');
910

1011

1112
const detachRuntimeFromAgent = async (agent, runtimeName) => {
@@ -140,6 +141,7 @@ const unInstallRuntimeCmd = new Command({
140141
verbose,
141142
terminateProcess: (terminateProcess !== false),
142143
events,
144+
logFormatting: DefaultLogFormatter,
143145
});
144146
},
145147
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"cf-errors": "^0.1.12",
3838
"chalk": "^1.1.3",
3939
"cli-progress": "3.6.0",
40-
"codefresh-sdk": "^1.8.6",
40+
"codefresh-sdk": "^1.9.1",
4141
"colors": "^1.1.2",
4242
"columnify": "^1.5.4",
4343
"compare-versions": "^3.4.0",
@@ -48,6 +48,7 @@
4848
"diff": "^3.5.0",
4949
"dockerode": "^2.5.7",
5050
"draftlog": "^1.0.12",
51+
"figlet": "^1.4.0",
5152
"filesize": "^3.5.11",
5253
"firebase": "git+https://github.com/codefresh-io/firebase.git#80b2ed883ff281cd67b53bd0f6a0bbd6f330fed5",
5354
"flat": "^4.1.0",

0 commit comments

Comments
 (0)