Skip to content

Commit f1dca97

Browse files
authored
fix: improve T&C text RD-5839 (#123)
* fix: improve T&C text
1 parent aa2cb8c commit f1dca97

File tree

1 file changed

+60
-12
lines changed

1 file changed

+60
-12
lines changed

src/commands/scanner.js

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const _ = require("lodash");
2+
var fs = require("fs");
23
const { Command, flags } = require("@oclif/command");
34
const { checkVersion } = require("../lib/version-check");
45
const { track } = require("../lib/analytics");
@@ -14,6 +15,39 @@ const { getAWSSDK } = require("../lib/aws");
1415
const AWS = getAWSSDK();
1516
const STS = new AWS.STS();
1617

18+
const getConfigurationFileName = () => {
19+
const configurationFileName = ".lumigo-cli.json";
20+
try {
21+
const homedir = require("os").homedir();
22+
return `${homedir}/${configurationFileName}`;
23+
} catch (err) {
24+
return configurationFileName;
25+
}
26+
};
27+
const loadConf = () => {
28+
let approved = false;
29+
try {
30+
if (fs.existsSync(getConfigurationFileName())) {
31+
const data = fs.readFileSync(getConfigurationFileName());
32+
const lumigoConf = JSON.parse(data);
33+
approved = Boolean(lumigoConf.approved);
34+
}
35+
} catch (err) {
36+
// Ignore gracefully
37+
}
38+
return {
39+
approved
40+
};
41+
};
42+
43+
const saveConf = approved => {
44+
try {
45+
fs.writeFileSync(getConfigurationFileName(), JSON.stringify({ approved }));
46+
} catch (error) {
47+
// Ignore gracefully
48+
}
49+
};
50+
1751
class ScannerCommand extends Command {
1852
async run() {
1953
const { flags } = this.parse(ScannerCommand);
@@ -35,21 +69,35 @@ and recommends areas that can be improved.
3569
A customized report will be sent to your email.
3670
`);
3771

38-
this.log("We will send metadata about AWS resources to Lumigo.".yellow);
72+
let { approved } = loadConf();
3973

40-
const { toProceed } = await inquirer.prompt([
41-
{
42-
type: "confirm",
43-
name: "toProceed",
44-
message:
45-
"Do you give Lumigo permission to receive metadata about AWS resources?"
46-
}
47-
]);
74+
if (!approved) {
75+
let { toProceed } = await inquirer.prompt([
76+
{
77+
type: "confirm",
78+
name: "toProceed",
79+
message:
80+
"Do you agree to Lumigo Terms of Use and Privacy policy ?'\n\tTerm of Use: https://lumigo.io/terms/\n\tPrivacy Policy: https://lumigo.io/privacy-policy/\n"
81+
}
82+
]);
4883

49-
if (!toProceed) {
50-
return;
84+
if (!toProceed) {
85+
return;
86+
}
87+
toProceed = await inquirer.prompt([
88+
{
89+
type: "confirm",
90+
name: "toProceed",
91+
message:
92+
"Do you give Lumigo permission to receive metadata about AWS resources?"
93+
}
94+
]);
95+
96+
if (!toProceed) {
97+
return;
98+
}
5199
}
52-
100+
saveConf(true);
53101
const email = await this.signIn().catch(err => {
54102
throw err;
55103
});

0 commit comments

Comments
 (0)