keypin 0.3.0 → 0.5.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/README.md +24 -21
- package/{chunk-p51dggc1.js → chunk-a9k9235c.js} +523 -333
- package/chunk-j6kpw8ge.js +65 -0
- package/main.js +6 -28
- package/package.json +1 -1
- package/chunk-8agfxsqt.js +0 -31
|
@@ -0,0 +1,65 @@
|
|
|
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 ENV_FILE = "--env-file";
|
|
35
|
+
function selfCommand(bun, script) {
|
|
36
|
+
return [bun, NO_ENV_FILE, script];
|
|
37
|
+
}
|
|
38
|
+
function runtimeProblem(bun, script, execArgv) {
|
|
39
|
+
if (bun === undefined)
|
|
40
|
+
return `keypin runs on Bun ${MIN_BUN} or newer, not Node.`;
|
|
41
|
+
if (olderThan(bun, MIN_BUN)) {
|
|
42
|
+
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}".`;
|
|
43
|
+
}
|
|
44
|
+
if (!execArgv.includes(NO_ENV_FILE)) {
|
|
45
|
+
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}".`;
|
|
46
|
+
}
|
|
47
|
+
if (execArgv.some((arg) => arg === ENV_FILE || arg.startsWith(`${ENV_FILE}=`))) {
|
|
48
|
+
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.`;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function olderThan(version, minimum) {
|
|
53
|
+
const parts = (v) => v.split(/[.+-]/).slice(0, 3).map(Number);
|
|
54
|
+
const a = parts(version);
|
|
55
|
+
const b = parts(minimum);
|
|
56
|
+
for (let i = 0;i < 3; i++) {
|
|
57
|
+
const left = a[i] ?? 0;
|
|
58
|
+
const right = b[i] ?? 0;
|
|
59
|
+
if (left !== right)
|
|
60
|
+
return left < right;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { messageOf, errorCode, installProblem, selfCommand, runtimeProblem };
|
package/main.js
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
1
|
+
#!/usr/bin/env -S bun --no-env-file
|
|
2
2
|
// @bun
|
|
3
3
|
import {
|
|
4
|
-
installProblem
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// src/runtime.ts
|
|
8
|
-
var MIN_BUN = "1.4.4";
|
|
9
|
-
function runtimeProblem(bun, script) {
|
|
10
|
-
if (bun === undefined)
|
|
11
|
-
return `keypin runs on Bun ${MIN_BUN} or newer, not Node.`;
|
|
12
|
-
if (olderThan(bun, MIN_BUN)) {
|
|
13
|
-
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} ${script}".`;
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
function olderThan(version, minimum) {
|
|
18
|
-
const parts = (v) => v.split(/[.+-]/).slice(0, 3).map(Number);
|
|
19
|
-
const a = parts(version);
|
|
20
|
-
const b = parts(minimum);
|
|
21
|
-
for (let i = 0;i < 3; i++) {
|
|
22
|
-
const left = a[i] ?? 0;
|
|
23
|
-
const right = b[i] ?? 0;
|
|
24
|
-
if (left !== right)
|
|
25
|
-
return left < right;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
4
|
+
installProblem,
|
|
5
|
+
runtimeProblem
|
|
6
|
+
} from "./chunk-j6kpw8ge.js";
|
|
29
7
|
|
|
30
8
|
// src/main.ts
|
|
31
|
-
var problem = runtimeProblem(typeof Bun === "undefined" ? undefined : Bun.version, process.argv[1] ?? "keypin");
|
|
9
|
+
var problem = runtimeProblem(typeof Bun === "undefined" ? undefined : Bun.version, process.argv[1] ?? "keypin", process.execArgv);
|
|
32
10
|
if (problem) {
|
|
33
11
|
process.stderr.write(`keypin: ${problem}
|
|
34
12
|
`);
|
|
@@ -36,7 +14,7 @@ if (problem) {
|
|
|
36
14
|
}
|
|
37
15
|
var start;
|
|
38
16
|
try {
|
|
39
|
-
start = await import("./chunk-
|
|
17
|
+
start = await import("./chunk-a9k9235c.js");
|
|
40
18
|
} catch (error) {
|
|
41
19
|
const hint = installProblem(error);
|
|
42
20
|
if (!hint)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keypin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A map of every app key across your projects, published to the account it's pinned to. Values stay in your vault.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/caiopizzol/keypin#readme",
|
package/chunk-8agfxsqt.js
DELETED
|
@@ -1,31 +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
|
-
export { messageOf, errorCode, installProblem };
|