safelaunch 1.0.26 → 1.0.28
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/package.json +1 -1
- package/src/setup.js +52 -31
package/package.json
CHANGED
package/src/setup.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { runScan }
|
|
4
|
-
const { installHook }
|
|
5
|
-
const init
|
|
3
|
+
const { runScan } = require("./scan");
|
|
4
|
+
const { installHook } = require("./hook");
|
|
5
|
+
const init = require("./init");
|
|
6
6
|
|
|
7
7
|
const c = {
|
|
8
8
|
reset: "\x1b[0m", bold: "\x1b[1m", dim: "\x1b[2m",
|
|
@@ -15,40 +15,74 @@ const yellow = (s) => `${c.yellow}${c.bold}${s}${c.reset}`;
|
|
|
15
15
|
const gray = (s) => `${c.gray}${s}${c.reset}`;
|
|
16
16
|
const dim = (s) => `${c.dim}${s}${c.reset}`;
|
|
17
17
|
const bold = (s) => `${c.bold}${s}${c.reset}`;
|
|
18
|
+
const cyan = (s) => `${c.cyan}${s}${c.reset}`;
|
|
18
19
|
|
|
19
20
|
const HR = gray("─".repeat(49));
|
|
20
21
|
|
|
21
|
-
let version = "1.0.
|
|
22
|
+
let version = "1.0.27";
|
|
22
23
|
try { version = require("../package.json").version; } catch {}
|
|
23
24
|
|
|
24
25
|
async function run(options = {}) {
|
|
25
26
|
const { cwd = process.cwd() } = options;
|
|
26
27
|
|
|
27
|
-
console.log(`\n${bold("safelaunch")} ${gray(`v${version}`)}
|
|
28
|
-
console.log(
|
|
28
|
+
console.log(`\n${bold("safelaunch")} ${gray(`v${version}`)}`);
|
|
29
|
+
console.log("");
|
|
30
|
+
console.log(gray("Scanning your project..."));
|
|
31
|
+
console.log("");
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
const { blockers, warnings, infos, elapsed } = await runScan({ hookMode: true, cwd });
|
|
33
|
+
const { blockers, warnings, infos, elapsed } = await runScan({ hookMode: true, quiet: true, cwd });
|
|
32
34
|
|
|
33
35
|
const totalChecks = 16;
|
|
34
36
|
const issueCount = blockers.length + warnings.length;
|
|
35
37
|
const passed = totalChecks - issueCount;
|
|
36
38
|
|
|
39
|
+
console.log(HR);
|
|
40
|
+
console.log("");
|
|
41
|
+
|
|
37
42
|
if (issueCount === 0) {
|
|
38
|
-
console.log(
|
|
43
|
+
console.log(gray(` ${totalChecks} checks passed`));
|
|
44
|
+
console.log("");
|
|
45
|
+
console.log(green(" ✓ Safe to deploy"));
|
|
46
|
+
console.log(gray(" Hook active — your next push is protected."));
|
|
39
47
|
} else {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(
|
|
44
|
-
"
|
|
45
|
-
|
|
48
|
+
for (const issue of blockers) {
|
|
49
|
+
console.log(red(` ${issue.title}`));
|
|
50
|
+
console.log("");
|
|
51
|
+
console.log(` ${issue.impact}`);
|
|
52
|
+
console.log("");
|
|
53
|
+
console.log(cyan(` Fix: ${issue.fix}`));
|
|
54
|
+
console.log("");
|
|
55
|
+
console.log(HR);
|
|
56
|
+
console.log("");
|
|
57
|
+
}
|
|
58
|
+
for (const issue of warnings) {
|
|
59
|
+
console.log(yellow(` ${issue.title}`));
|
|
60
|
+
console.log("");
|
|
61
|
+
console.log(` ${issue.impact}`);
|
|
62
|
+
console.log("");
|
|
63
|
+
console.log(dim(` Fix: ${issue.fix}`));
|
|
64
|
+
console.log("");
|
|
65
|
+
console.log(HR);
|
|
66
|
+
console.log("");
|
|
67
|
+
}
|
|
68
|
+
const issueWord = issueCount === 1 ? "issue" : "issues";
|
|
69
|
+
console.log(gray(` ${issueCount} ${issueWord} found · ${passed} checks passed`));
|
|
70
|
+
console.log("");
|
|
71
|
+
console.log(red(" ✗ Not safe to deploy"));
|
|
72
|
+
console.log(gray(" Hook active — this push would have been blocked."));
|
|
46
73
|
}
|
|
47
74
|
|
|
75
|
+
console.log("");
|
|
76
|
+
console.log(HR);
|
|
77
|
+
console.log("");
|
|
78
|
+
|
|
48
79
|
console.log(gray("Generating env.manifest.json..."));
|
|
49
80
|
const manifestResult = await init.run({ cwd, silent: true });
|
|
50
81
|
if (manifestResult && manifestResult.count > 0) {
|
|
51
|
-
console.log(
|
|
82
|
+
console.log(
|
|
83
|
+
`${green("✓")} ${bold("env.manifest.json created")} ` +
|
|
84
|
+
gray(`(${manifestResult.count} variable${manifestResult.count !== 1 ? "s" : ""} registered)`)
|
|
85
|
+
);
|
|
52
86
|
} else {
|
|
53
87
|
console.log(`${green("✓")} ${bold("env.manifest.json updated")}`);
|
|
54
88
|
}
|
|
@@ -63,20 +97,7 @@ async function run(options = {}) {
|
|
|
63
97
|
console.log(dim(" Run: safelaunch hook install --force to replace it."));
|
|
64
98
|
}
|
|
65
99
|
|
|
66
|
-
console.log("
|
|
67
|
-
|
|
68
|
-
if (blockers.length === 0) {
|
|
69
|
-
console.log(`${green("You're protected.")}\n`);
|
|
70
|
-
console.log(gray("From now on, safelaunch runs before every push."));
|
|
71
|
-
console.log(gray("Broken deploys get stopped here — not in production.\n"));
|
|
72
|
-
if (warnings.length > 0) {
|
|
73
|
-
console.log(yellow(`Fix the ${warnings.length} warning${warnings.length > 1 ? "s" : ""} above when you can, then push.`));
|
|
74
|
-
console.log("");
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
console.log(`${red(`Fix the ${blockers.length} blocker${blockers.length > 1 ? "s" : ""} above, then push.`)}\n`);
|
|
78
|
-
console.log(gray("Your hook is installed. It will block pushes until these are resolved.\n"));
|
|
79
|
-
}
|
|
100
|
+
console.log("");
|
|
80
101
|
}
|
|
81
102
|
|
|
82
|
-
module.exports = { run };
|
|
103
|
+
module.exports = { run };
|