periderm-cli 0.1.4 → 0.1.6
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/dist/bin.js +21 -0
- package/dist/index.js +13 -11
- package/dist/update-notifier.js +7 -5
- package/package.json +4 -3
package/dist/bin.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { checkUpdate } from "./update-notifier.js";
|
|
3
|
+
const updatePromise = checkUpdate();
|
|
4
|
+
process.on("uncaughtException", async (err) => {
|
|
5
|
+
console.error(err);
|
|
6
|
+
await updatePromise;
|
|
7
|
+
process.exit(1);
|
|
8
|
+
});
|
|
9
|
+
process.on("unhandledRejection", async (err) => {
|
|
10
|
+
console.error(err);
|
|
11
|
+
await updatePromise;
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|
|
14
|
+
try {
|
|
15
|
+
await import("./index.js");
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
console.error(err);
|
|
19
|
+
await updatePromise;
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import { Command } from "commander";
|
|
3
2
|
import chalk from "chalk";
|
|
4
3
|
import fs from "node:fs/promises";
|
|
@@ -15,8 +14,17 @@ import ora from "ora";
|
|
|
15
14
|
import { PERIDERM_ASCII } from "./constants.js";
|
|
16
15
|
import { PRE_SCAN_MESSAGES, UPLOAD_MESSAGES, startRotatingMessages, finishRotatingMessages } from "./loading-messages.js";
|
|
17
16
|
import { formatScanPath } from "./scanner/progress.js";
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
function requireAuth() {
|
|
18
|
+
console.info("");
|
|
19
|
+
console.info(chalk.bold.hex("#FF4D00")("▸_ Periderm CLI"));
|
|
20
|
+
console.info(chalk.white("──────────────────────────────────────────"));
|
|
21
|
+
console.info(chalk.bold.red("✖ Authentication Required"));
|
|
22
|
+
console.info("");
|
|
23
|
+
console.info(chalk.white("You must be logged in to run this command."));
|
|
24
|
+
console.info(chalk.white("Run ") + chalk.bold.cyan("$ periderm login") + chalk.white(" to securely authenticate."));
|
|
25
|
+
console.info("");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
20
28
|
const program = new Command();
|
|
21
29
|
program
|
|
22
30
|
.name("periderm")
|
|
@@ -31,8 +39,7 @@ program
|
|
|
31
39
|
const root = path.resolve(opts.cwd);
|
|
32
40
|
const cfg = readConfig();
|
|
33
41
|
if (!cfg.token) {
|
|
34
|
-
|
|
35
|
-
process.exit(1);
|
|
42
|
+
requireAuth();
|
|
36
43
|
}
|
|
37
44
|
const verifySpinner = ora({ text: PRE_SCAN_MESSAGES[0], color: "cyan" }).start();
|
|
38
45
|
const verifyStarted = Date.now();
|
|
@@ -133,7 +140,6 @@ program
|
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
|
-
await updatePromise;
|
|
137
143
|
});
|
|
138
144
|
program
|
|
139
145
|
.command("review")
|
|
@@ -148,8 +154,7 @@ program
|
|
|
148
154
|
const root = path.resolve(opts.cwd);
|
|
149
155
|
const cfg = readConfig();
|
|
150
156
|
if (!cfg.token) {
|
|
151
|
-
|
|
152
|
-
process.exit(1);
|
|
157
|
+
requireAuth();
|
|
153
158
|
}
|
|
154
159
|
const reportPath = path.join(root, ".periderm", "last-report.json");
|
|
155
160
|
let scanResult;
|
|
@@ -188,7 +193,6 @@ program
|
|
|
188
193
|
await fs.writeFile(reportPath, JSON.stringify(scanResult, null, 2), "utf8");
|
|
189
194
|
reviewSpinner.succeed(`Deep review complete · ${findings.length} additional finding${findings.length === 1 ? "" : "s"}`);
|
|
190
195
|
console.info(chalk.white(`\nAppended to ${mdPath}\n`));
|
|
191
|
-
await updatePromise;
|
|
192
196
|
});
|
|
193
197
|
program
|
|
194
198
|
.command("watch")
|
|
@@ -352,7 +356,6 @@ program
|
|
|
352
356
|
console.info(`user: ${r.user_id}`);
|
|
353
357
|
console.info(`plan: ${r.plan}`);
|
|
354
358
|
console.info(`quota: ${r.scans_remaining} scans remaining`);
|
|
355
|
-
await updatePromise;
|
|
356
359
|
});
|
|
357
360
|
program
|
|
358
361
|
.command("logout")
|
|
@@ -367,7 +370,6 @@ program
|
|
|
367
370
|
console.info("");
|
|
368
371
|
console.info(chalk.white("Run ") + chalk.white("$ periderm login") + chalk.white(" to re-authenticate."));
|
|
369
372
|
console.info("");
|
|
370
|
-
await updatePromise;
|
|
371
373
|
});
|
|
372
374
|
if (process.argv.length === 2) {
|
|
373
375
|
console.info("");
|
package/dist/update-notifier.js
CHANGED
|
@@ -24,13 +24,15 @@ export async function checkUpdate() {
|
|
|
24
24
|
// Basic semver check (only notifies if latest > current simply by string comparison or simple parsing)
|
|
25
25
|
// Since it's x.y.z, simple comparison works for basic stuff, but a strict semver check is better.
|
|
26
26
|
// We will just check if they are not equal, since latest is usually higher.
|
|
27
|
+
const isWin = process.platform === "win32";
|
|
28
|
+
const updateCmd = isWin ? `npm install -g ${name}` : `curl -fsSL https://periderm.dev/install.sh | bash`;
|
|
27
29
|
const box = `
|
|
28
|
-
|
|
29
|
-
│
|
|
30
|
+
╭──────────────────────────────────────────────────────────────╮
|
|
31
|
+
│ │
|
|
30
32
|
│ A new version of Periderm CLI is available: ${chalk.dim(currentVersion)} → ${chalk.green(latestVersion)} │
|
|
31
|
-
│ Run ${chalk.cyan(
|
|
32
|
-
│
|
|
33
|
-
|
|
33
|
+
│ Run ${chalk.cyan(updateCmd)} to update.
|
|
34
|
+
│ │
|
|
35
|
+
╰──────────────────────────────────────────────────────────────╯
|
|
34
36
|
`;
|
|
35
37
|
console.log(box);
|
|
36
38
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "periderm-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "A pre-launch checklist for your codebase.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"periderm": "./dist/
|
|
7
|
+
"periderm": "./dist/bin.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"README.md"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build": "tsc -p tsconfig.json && chmod +x dist/
|
|
14
|
+
"build": "tsc -p tsconfig.json && chmod +x dist/bin.js",
|
|
15
|
+
"postpublish": "cd ../../ && tsx scripts/broadcast-update.ts",
|
|
15
16
|
"dev": "tsx src/index.ts",
|
|
16
17
|
"start": "node dist/index.js"
|
|
17
18
|
},
|