keypin 0.8.0 → 0.10.0

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/chunk-t31ce2x2.js DELETED
@@ -1,80 +0,0 @@
1
- // @bun
2
- // src/install.ts
3
- import { fileURLToPath } from "url";
4
-
5
- // src/errors.ts
6
- function messageOf(error) {
7
- return error instanceof Error ? error.message : String(error);
8
- }
9
- function errorCode(error) {
10
- if (error instanceof Error && "code" in error && typeof error.code === "string")
11
- return error.code;
12
- return;
13
- }
14
-
15
- // src/install.ts
16
- var INSTALL = "bunx --package vite-plus@1.5.1 vp install";
17
- var REINSTALL = "bun add -g keypin";
18
- function checkout() {
19
- if (!import.meta.url.endsWith("/apps/cli/src/install.ts"))
20
- return null;
21
- return fileURLToPath(new URL("../../..", import.meta.url)).replace(/\/$/, "");
22
- }
23
- function installProblem(error, repo = checkout()) {
24
- if (errorCode(error) !== "ERR_MODULE_NOT_FOUND")
25
- return null;
26
- const name = /'([^']+)'/.exec(messageOf(error))?.[1];
27
- const fix = repo === null ? `reinstall keypin with "${REINSTALL}"` : `run "${INSTALL}" in ${repo}`;
28
- return `${name ? `the package ${name}` : "a package"} isn't installed; ${fix}`;
29
- }
30
-
31
- // src/runtime.ts
32
- var MIN_BUN = "1.4.4";
33
- var NO_ENV_FILE = "--no-env-file";
34
- var COMPILED_AUTOLOAD_OFF = "dotenv and bunfig off";
35
- var COMPILED_REFUSED_ENV = ["BUN_OPTIONS", "BUN_INSPECT", "BUN_INSPECT_CONNECT_TO"];
36
- var ENV_FILE = "--env-file";
37
- function selfCommand(bun, script) {
38
- return [bun, NO_ENV_FILE, script];
39
- }
40
- function runtimeProblem(bun, script, execArgv, compiled) {
41
- if (bun === undefined)
42
- return `keypin runs on Bun ${MIN_BUN} or newer, not Node.`;
43
- if (olderThan(bun, MIN_BUN)) {
44
- return `keypin needs Bun ${MIN_BUN} or newer, because older Bun can read a keypin.toml wrong, and this is Bun ${bun}. Upgrade Bun, or run it with "bunx bun@${MIN_BUN} ${NO_ENV_FILE} ${script}".`;
45
- }
46
- if (compiled)
47
- return compiledProblem(compiled);
48
- if (!execArgv.includes(NO_ENV_FILE)) {
49
- return `keypin needs Bun started with ${NO_ENV_FILE}, or Bun adds this folder's .env values to every command keypin runs. Run it as "keypin", or as "bun ${NO_ENV_FILE} ${script}".`;
50
- }
51
- if (execArgv.some((arg) => arg === ENV_FILE || arg.startsWith(`${ENV_FILE}=`))) {
52
- return `keypin can't run with Bun's ${ENV_FILE}: Bun would add that file's values to every command keypin runs. Remove ${ENV_FILE} from the command and from BUN_OPTIONS.`;
53
- }
54
- return null;
55
- }
56
- function compiledProblem({ autoload, env }) {
57
- if (autoload !== COMPILED_AUTOLOAD_OFF) {
58
- return "this keypin binary wasn't built by apps/cli/compile.ts, so it may load this folder's .env and bunfig.toml. Build it with that script.";
59
- }
60
- const set = COMPILED_REFUSED_ENV.filter((name) => env[name] !== undefined);
61
- if (set.length) {
62
- const names = set.join(" and ");
63
- return `keypin can't run with ${names} set: Bun would let ${set.length === 1 ? "it" : "them"} load code or a debugger into keypin. Unset ${names}.`;
64
- }
65
- return null;
66
- }
67
- function olderThan(version, minimum) {
68
- const parts = (v) => v.split(/[.+-]/).slice(0, 3).map(Number);
69
- const a = parts(version);
70
- const b = parts(minimum);
71
- for (let i = 0;i < 3; i++) {
72
- const left = a[i] ?? 0;
73
- const right = b[i] ?? 0;
74
- if (left !== right)
75
- return left < right;
76
- }
77
- return false;
78
- }
79
-
80
- export { messageOf, errorCode, installProblem, selfCommand, runtimeProblem };
package/main.js DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env -S bun --no-env-file
2
- // @bun
3
- import {
4
- installProblem,
5
- runtimeProblem
6
- } from "./chunk-t31ce2x2.js";
7
-
8
- // src/main.ts
9
- var compiled = typeof Bun !== "undefined" && Bun.isStandaloneExecutable ? {
10
- autoload: typeof KEYPIN_COMPILED === "string" ? KEYPIN_COMPILED : undefined,
11
- env: process.env
12
- } : undefined;
13
- var problem = runtimeProblem(typeof Bun === "undefined" ? undefined : Bun.version, process.argv[1] ?? "keypin", process.execArgv, compiled);
14
- if (problem) {
15
- process.stderr.write(`keypin: ${problem}
16
- `);
17
- process.exit(1);
18
- }
19
- var start;
20
- try {
21
- start = await import("./chunk-m8824n5b.js");
22
- } catch (error) {
23
- const hint = installProblem(error);
24
- if (!hint)
25
- throw error;
26
- process.stderr.write(`keypin: ${hint}
27
- `);
28
- process.exit(1);
29
- }
30
- process.exitCode = await start.main();