periderm-cli 0.1.5 → 0.1.7

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/index.js CHANGED
@@ -14,6 +14,17 @@ import ora from "ora";
14
14
  import { PERIDERM_ASCII } from "./constants.js";
15
15
  import { PRE_SCAN_MESSAGES, UPLOAD_MESSAGES, startRotatingMessages, finishRotatingMessages } from "./loading-messages.js";
16
16
  import { formatScanPath } from "./scanner/progress.js";
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
+ }
17
28
  const program = new Command();
18
29
  program
19
30
  .name("periderm")
@@ -28,8 +39,7 @@ program
28
39
  const root = path.resolve(opts.cwd);
29
40
  const cfg = readConfig();
30
41
  if (!cfg.token) {
31
- console.error(chalk.red("Error: You must be logged in to scan. Run `periderm login` first."));
32
- process.exit(1);
42
+ requireAuth();
33
43
  }
34
44
  const verifySpinner = ora({ text: PRE_SCAN_MESSAGES[0], color: "cyan" }).start();
35
45
  const verifyStarted = Date.now();
@@ -144,8 +154,7 @@ program
144
154
  const root = path.resolve(opts.cwd);
145
155
  const cfg = readConfig();
146
156
  if (!cfg.token) {
147
- console.error(chalk.red("Error: You must be logged in. Run `periderm login` first."));
148
- process.exit(1);
157
+ requireAuth();
149
158
  }
150
159
  const reportPath = path.join(root, ".periderm", "last-report.json");
151
160
  let scanResult;
@@ -2,6 +2,7 @@ import chalk from "chalk";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
+ import { readConfig } from "./config.js";
5
6
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
7
  const pkgPath = path.join(__dirname, "..", "package.json");
7
8
  export async function checkUpdate() {
@@ -21,16 +22,17 @@ export async function checkUpdate() {
21
22
  const data = await res.json();
22
23
  const latestVersion = data.version;
23
24
  if (latestVersion && latestVersion !== currentVersion) {
24
- // Basic semver check (only notifies if latest > current simply by string comparison or simple parsing)
25
- // Since it's x.y.z, simple comparison works for basic stuff, but a strict semver check is better.
26
- // We will just check if they are not equal, since latest is usually higher.
25
+ const cfg = readConfig();
26
+ const apiUrl = cfg?.apiUrl || "https://periderm.dev";
27
+ const isWin = process.platform === "win32";
28
+ const updateCmd = isWin ? `npm install -g ${name}` : `curl -fsSL ${apiUrl}/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(`npm install -g ${name}`)} to update.
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,6 +1,6 @@
1
1
  {
2
2
  "name": "periderm-cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "A pre-launch checklist for your codebase.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,6 +12,7 @@
12
12
  ],
13
13
  "scripts": {
14
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
  },