@drops-it/dpm 1.0.6 → 1.1.5
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 -17
- package/dist/config.js +17 -4
- package/dist/index.js +239 -55
- package/dist/install.d.ts +18 -9
- package/dist/install.js +332 -249
- package/dist/runtime.d.ts +39 -0
- package/dist/runtime.js +279 -0
- package/dist/updateCheck.d.ts +2 -2
- package/dist/updateCheck.js +67 -32
- package/dist/windowsInstall.d.ts +16 -0
- package/dist/windowsInstall.js +175 -0
- package/package.json +12 -14
package/README.md
CHANGED
|
@@ -1,43 +1,42 @@
|
|
|
1
1
|
# dpm
|
|
2
2
|
|
|
3
|
-
**Drops Package Manager** — a fast, privacy-minded CLI for installing, publishing, and auditing
|
|
3
|
+
**Drops Package Manager** — a fast, privacy-minded CLI for installing, publishing, running, and auditing packages on [dpm.drops-it.com](https://dpm.drops-it.com), with automatic npm fallback for anything not on the registry.
|
|
4
4
|
|
|
5
5
|
```text
|
|
6
6
|
┌─────────────────────────────────────────┐
|
|
7
7
|
│ dpm i lodash │
|
|
8
|
-
│ →
|
|
8
|
+
│ → installing dependencies… │
|
|
9
9
|
│ ✔ added 1 package in 0.4s │
|
|
10
10
|
│ found 0 vulnerabilities │
|
|
11
11
|
└─────────────────────────────────────────┘
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
The Windows installer ships a managed DPM runtime (used for install + `dpm run`). You never need to invoke another runtime by name.
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
20
|
-
**
|
|
20
|
+
**Windows**
|
|
21
|
+
|
|
22
|
+
Download [`dpm.exe`](https://dpm.drops-it.com/download/dpm.exe) and run it once (double-click). It installs into your user profile, adds `dpm` to PATH, installs the DPM runtime, and creates a Start Menu shortcut.
|
|
21
23
|
|
|
22
24
|
```bash
|
|
23
|
-
# after
|
|
24
|
-
dpm
|
|
25
|
+
# after install, open a NEW terminal:
|
|
26
|
+
dpm --help
|
|
27
|
+
dpm login
|
|
25
28
|
```
|
|
26
29
|
|
|
27
30
|
**From npm**
|
|
28
31
|
|
|
29
32
|
```bash
|
|
30
|
-
npm
|
|
33
|
+
npm install -g @drops-it/dpm
|
|
31
34
|
```
|
|
32
35
|
|
|
33
|
-
**
|
|
34
|
-
|
|
35
|
-
Download [`dpm.exe`](https://dpm.drops-it.com/download/dpm.exe) — it boots the CLI if Node is installed.
|
|
36
|
-
|
|
37
|
-
Verify:
|
|
36
|
+
**How To Update DPM** (once you already have any `dpm`)
|
|
38
37
|
|
|
39
38
|
```bash
|
|
40
|
-
dpm
|
|
39
|
+
dpm i -g dpm
|
|
41
40
|
```
|
|
42
41
|
|
|
43
42
|
---
|
|
@@ -49,6 +48,7 @@ dpm login # browser device flow (Drops-IT)
|
|
|
49
48
|
dpm init # create package.json
|
|
50
49
|
dpm i lodash # add + install
|
|
51
50
|
dpm i # install from package.json
|
|
51
|
+
dpm run starter # run a package.json script
|
|
52
52
|
dpm publish --access public
|
|
53
53
|
```
|
|
54
54
|
|
|
@@ -74,6 +74,13 @@ dpm whoami
|
|
|
74
74
|
| `dpm rm -g` | Remove the global **dpm** CLI + bin shims |
|
|
75
75
|
| `dpm rm -g <pkg>` | Uninstall a global package |
|
|
76
76
|
| `dpm update` | Re-resolve and reinstall |
|
|
77
|
+
| `dpm run <script>` | Run a `package.json` script |
|
|
78
|
+
| `dpm test` | Run tests |
|
|
79
|
+
| `dpm x` / `exec` | Execute a package binary |
|
|
80
|
+
| `dpm build` | Bundle with the DPM runtime |
|
|
81
|
+
| `dpm --watch <file>` | Run a file with reload (e.g. API server) |
|
|
82
|
+
| `dpm <file>` | Run a JS/TS file |
|
|
83
|
+
| `dpm create` / `repl` / `pm` / `link` / `unlink` / `outdated` / `patch` / `why` / `info` / `upgrade` | Toolkit commands (managed runtime) |
|
|
77
84
|
| `dpm search <q>` | Search the registry |
|
|
78
85
|
| `dpm view <name>` | Show package metadata |
|
|
79
86
|
| `dpm publish [--access public\|private]` | Publish the current package |
|
|
@@ -86,9 +93,9 @@ dpm whoami
|
|
|
86
93
|
|
|
87
94
|
## Install experience
|
|
88
95
|
|
|
89
|
-
-
|
|
96
|
+
- Fast parallel installs via the managed DPM runtime against the DPM registry (`/npm` facade)
|
|
90
97
|
- Colorized success, warnings, and severity
|
|
91
|
-
- Post-install **advisory report**
|
|
98
|
+
- Post-install **advisory report**
|
|
92
99
|
- Fix hints: `dpm audit fix` / `dpm audit fix --force`
|
|
93
100
|
- Transitive fixes can land in `package.json` `overrides` so they stick
|
|
94
101
|
|
|
@@ -105,11 +112,11 @@ dpm audit fix
|
|
|
105
112
|
On the **first `dpm` command in a new terminal**, dpm checks the DPM registry for a newer CLI.
|
|
106
113
|
|
|
107
114
|
```text
|
|
108
|
-
▲ dpm update available: 1.0
|
|
115
|
+
▲ dpm update available: 1.1.0 → 1.1.1
|
|
109
116
|
Update with: dpm i -g dpm
|
|
110
117
|
```
|
|
111
118
|
|
|
112
|
-
No daily nag.
|
|
119
|
+
No daily nag. Updates are driven by the DPM package `dpm`.
|
|
113
120
|
|
|
114
121
|
---
|
|
115
122
|
|
package/dist/config.js
CHANGED
|
@@ -4,16 +4,29 @@ import path from "node:path";
|
|
|
4
4
|
import YAML from "yaml";
|
|
5
5
|
const CONFIG_PATH = path.join(homedir(), ".dpmrc");
|
|
6
6
|
export async function loadConfig() {
|
|
7
|
+
let config;
|
|
7
8
|
try {
|
|
8
9
|
const raw = await readFile(CONFIG_PATH, "utf8");
|
|
9
|
-
|
|
10
|
+
config = JSON.parse(raw);
|
|
10
11
|
}
|
|
11
12
|
catch {
|
|
12
|
-
|
|
13
|
-
registry:
|
|
14
|
-
token: process.env.DPM_TOKEN,
|
|
13
|
+
config = {
|
|
14
|
+
registry: "https://dpm.drops-it.com",
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
// Env can override the API host — but public npm is an install fallback only,
|
|
18
|
+
// never a DPM registry API (publish/login/search would 404 there).
|
|
19
|
+
if (process.env.DPM_REGISTRY) {
|
|
20
|
+
const raw = process.env.DPM_REGISTRY.trim();
|
|
21
|
+
const isPublicNpm = raw === "npmjs" ||
|
|
22
|
+
/registry\.npmjs\.org/i.test(raw) ||
|
|
23
|
+
/^https?:\/\/npmjs\.org\/?$/i.test(raw);
|
|
24
|
+
if (!isPublicNpm)
|
|
25
|
+
config.registry = raw;
|
|
26
|
+
}
|
|
27
|
+
if (process.env.DPM_TOKEN)
|
|
28
|
+
config.token = process.env.DPM_TOKEN;
|
|
29
|
+
return config;
|
|
17
30
|
}
|
|
18
31
|
export async function saveConfig(config) {
|
|
19
32
|
await writeFile(CONFIG_PATH, JSON.stringify(config, null, 2), { mode: 0o600 });
|
package/dist/index.js
CHANGED
|
@@ -3,11 +3,99 @@ import { exec } from "node:child_process";
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { DpmApi } from "./api.js";
|
|
5
5
|
import { loadConfig, saveConfig, writePackageJson } from "./config.js";
|
|
6
|
-
import { addPackages, auditFix,
|
|
6
|
+
import { addPackages, auditFix, installGlobalPackages, packTarball, removeGlobalPackages, removePackage, runAudit, syncLockFromNodeModules, } from "./install.js";
|
|
7
|
+
import { ensureInstallConfig, runtimeInstallEnv, spawnRuntime } from "./runtime.js";
|
|
7
8
|
import { createUi } from "./ui.js";
|
|
8
9
|
import { CLI_VERSION, maybeNotifyUpdate } from "./updateCheck.js";
|
|
10
|
+
/**
|
|
11
|
+
* Commands handled by DPM itself (registry / auth / branded PM wrappers).
|
|
12
|
+
* Everything else — including all other runtime CLI commands — is forwarded.
|
|
13
|
+
*/
|
|
14
|
+
const NATIVE_COMMANDS = new Set([
|
|
15
|
+
"config",
|
|
16
|
+
"login",
|
|
17
|
+
"logout",
|
|
18
|
+
"whoami",
|
|
19
|
+
"init",
|
|
20
|
+
"search",
|
|
21
|
+
"view",
|
|
22
|
+
"install",
|
|
23
|
+
"i",
|
|
24
|
+
"add",
|
|
25
|
+
"a",
|
|
26
|
+
"update",
|
|
27
|
+
"remove",
|
|
28
|
+
"rm",
|
|
29
|
+
"uninstall",
|
|
30
|
+
"audit",
|
|
31
|
+
"publish",
|
|
32
|
+
"run",
|
|
33
|
+
"test",
|
|
34
|
+
"x",
|
|
35
|
+
"exec",
|
|
36
|
+
"build",
|
|
37
|
+
"help",
|
|
38
|
+
]);
|
|
39
|
+
function argvAfterCommand(names) {
|
|
40
|
+
const idx = process.argv.findIndex((a, i) => i >= 2 && names.includes(a));
|
|
41
|
+
if (idx < 0)
|
|
42
|
+
return process.argv.slice(2);
|
|
43
|
+
return process.argv.slice(idx + 1);
|
|
44
|
+
}
|
|
45
|
+
function shouldForwardToRuntime(argv) {
|
|
46
|
+
const args = argv.slice(2);
|
|
47
|
+
if (args.length === 0)
|
|
48
|
+
return false;
|
|
49
|
+
const first = args[0];
|
|
50
|
+
// `-v` must stay on the CLI (Commander); do not forward to the runtime (Bun).
|
|
51
|
+
if (first === "-h" ||
|
|
52
|
+
first === "--help" ||
|
|
53
|
+
first === "-v" ||
|
|
54
|
+
first === "-V" ||
|
|
55
|
+
first === "--version") {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
if (first.startsWith("-"))
|
|
59
|
+
return true;
|
|
60
|
+
return !NATIVE_COMMANDS.has(first);
|
|
61
|
+
}
|
|
62
|
+
/** Spawns the managed runtime with registry env for package-manager ops. */
|
|
63
|
+
async function runtimePm(args) {
|
|
64
|
+
const config = await loadConfig();
|
|
65
|
+
await ensureInstallConfig(config, process.cwd());
|
|
66
|
+
return spawnRuntime({
|
|
67
|
+
args,
|
|
68
|
+
env: runtimeInstallEnv(config),
|
|
69
|
+
brandOutput: true,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** Spawns the managed runtime for non-PM commands (run, test, build, …). */
|
|
73
|
+
async function runtimeRaw(args) {
|
|
74
|
+
return spawnRuntime({
|
|
75
|
+
args,
|
|
76
|
+
brandOutput: true,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
9
79
|
const program = new Command();
|
|
10
|
-
program
|
|
80
|
+
program
|
|
81
|
+
.name("dpm")
|
|
82
|
+
.description("Drops Package Manager — same commands as a full JS toolkit, plus DPM registry auth/publish")
|
|
83
|
+
.version(CLI_VERSION, "-v, --version", "output the DPM CLI version")
|
|
84
|
+
.addHelpText("after", `
|
|
85
|
+
Runtime (same surface as a modern JS toolkit; binary is managed by DPM):
|
|
86
|
+
dpm --watch <file> Run a file with reload
|
|
87
|
+
dpm <file> Run a JS/TS file
|
|
88
|
+
dpm create <template> Scaffold from a template
|
|
89
|
+
dpm repl Interactive REPL
|
|
90
|
+
dpm pm <subcommand> Package utilities (ls, cache, …)
|
|
91
|
+
dpm outdated List outdated deps
|
|
92
|
+
dpm link / unlink Link local packages
|
|
93
|
+
dpm patch / why / info Extra package tools
|
|
94
|
+
dpm upgrade Upgrade the managed DPM runtime
|
|
95
|
+
|
|
96
|
+
DPM registry:
|
|
97
|
+
dpm login | publish | search | view | config
|
|
98
|
+
`);
|
|
11
99
|
program.hook("preAction", async () => {
|
|
12
100
|
await maybeNotifyUpdate();
|
|
13
101
|
});
|
|
@@ -81,17 +169,25 @@ program
|
|
|
81
169
|
});
|
|
82
170
|
program
|
|
83
171
|
.command("init")
|
|
84
|
-
.description("Create a package.json")
|
|
172
|
+
.description("Create a package.json (or pass flags through to the runtime init)")
|
|
173
|
+
.allowUnknownOption(true)
|
|
174
|
+
.argument("[args...]")
|
|
85
175
|
.action(async () => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
176
|
+
const rest = argvAfterCommand(["init"]);
|
|
177
|
+
// No args → simple DPM scaffold; any flags/args → full runtime init
|
|
178
|
+
if (rest.length === 0) {
|
|
179
|
+
await writePackageJson({
|
|
180
|
+
name: "my-package",
|
|
181
|
+
version: "1.0.0",
|
|
182
|
+
description: "",
|
|
183
|
+
main: "index.js",
|
|
184
|
+
license: "MIT",
|
|
185
|
+
dependencies: {},
|
|
186
|
+
});
|
|
187
|
+
console.log("Created package.json");
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
process.exit(await runtimeRaw(["init", ...rest]));
|
|
95
191
|
});
|
|
96
192
|
program
|
|
97
193
|
.command("search")
|
|
@@ -118,53 +214,81 @@ program
|
|
|
118
214
|
program
|
|
119
215
|
.command("install")
|
|
120
216
|
.alias("i")
|
|
121
|
-
.
|
|
122
|
-
.
|
|
123
|
-
.
|
|
124
|
-
.action(async (
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
217
|
+
.description("Install deps via DPM registry (all runtime install flags supported)")
|
|
218
|
+
.allowUnknownOption(true)
|
|
219
|
+
.argument("[args...]")
|
|
220
|
+
.action(async () => {
|
|
221
|
+
const rest = argvAfterCommand(["install", "i"]);
|
|
222
|
+
const global = rest.includes("-g") || rest.includes("--global");
|
|
223
|
+
const packages = rest.filter((a) => !a.startsWith("-"));
|
|
224
|
+
if (global && packages.length > 0) {
|
|
225
|
+
const api = new DpmApi(await loadConfig());
|
|
226
|
+
await installGlobalPackages(api, packages, createUi());
|
|
129
227
|
return;
|
|
130
228
|
}
|
|
131
|
-
if (packages.length > 0) {
|
|
132
|
-
|
|
133
|
-
|
|
229
|
+
if (!global && packages.length > 0 && rest.every((a) => !a.startsWith("-") || a === packages[0])) {
|
|
230
|
+
// Plain `dpm i lodash` / `dpm install lodash@1` without flags → add flow
|
|
231
|
+
if (rest.every((a) => !a.startsWith("-"))) {
|
|
232
|
+
const api = new DpmApi(await loadConfig());
|
|
233
|
+
await addPackages(api, packages, process.cwd(), createUi());
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
134
236
|
}
|
|
135
|
-
await
|
|
237
|
+
const code = await runtimePm(["install", ...rest]);
|
|
238
|
+
if (code !== 0)
|
|
239
|
+
process.exit(code);
|
|
240
|
+
await syncLockFromNodeModules(process.cwd());
|
|
136
241
|
});
|
|
137
242
|
program
|
|
138
243
|
.command("add")
|
|
139
|
-
.
|
|
140
|
-
.
|
|
141
|
-
.
|
|
142
|
-
.
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
244
|
+
.alias("a")
|
|
245
|
+
.description("Add dependencies (runtime add flags supported)")
|
|
246
|
+
.allowUnknownOption(true)
|
|
247
|
+
.argument("[args...]")
|
|
248
|
+
.action(async () => {
|
|
249
|
+
const rest = argvAfterCommand(["add", "a"]);
|
|
250
|
+
const global = rest.includes("-g") || rest.includes("--global");
|
|
251
|
+
const packages = rest.filter((a) => !a.startsWith("-"));
|
|
252
|
+
if (global) {
|
|
253
|
+
const api = new DpmApi(await loadConfig());
|
|
254
|
+
await installGlobalPackages(api, packages, createUi());
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (packages.length > 0 && rest.every((a) => !a.startsWith("-"))) {
|
|
258
|
+
const api = new DpmApi(await loadConfig());
|
|
259
|
+
await addPackages(api, packages, process.cwd(), createUi());
|
|
147
260
|
return;
|
|
148
261
|
}
|
|
149
|
-
|
|
262
|
+
const code = await runtimePm(["add", ...rest]);
|
|
263
|
+
if (code !== 0)
|
|
264
|
+
process.exit(code);
|
|
265
|
+
await syncLockFromNodeModules(process.cwd());
|
|
150
266
|
});
|
|
151
267
|
program
|
|
152
268
|
.command("update")
|
|
153
|
-
.description("
|
|
269
|
+
.description("Update dependencies (runtime update flags supported)")
|
|
270
|
+
.allowUnknownOption(true)
|
|
271
|
+
.argument("[args...]")
|
|
154
272
|
.action(async () => {
|
|
155
|
-
const
|
|
156
|
-
await
|
|
273
|
+
const rest = argvAfterCommand(["update"]);
|
|
274
|
+
const code = await runtimePm(["update", ...rest]);
|
|
275
|
+
if (code !== 0)
|
|
276
|
+
process.exit(code);
|
|
277
|
+
await syncLockFromNodeModules(process.cwd());
|
|
157
278
|
});
|
|
158
279
|
program
|
|
159
280
|
.command("remove")
|
|
160
281
|
.alias("rm")
|
|
161
282
|
.alias("uninstall")
|
|
162
|
-
.
|
|
163
|
-
.
|
|
164
|
-
.
|
|
165
|
-
.action(async (
|
|
283
|
+
.description("Remove a dependency (or dpm rm -g for the global CLI)")
|
|
284
|
+
.allowUnknownOption(true)
|
|
285
|
+
.argument("[args...]")
|
|
286
|
+
.action(async () => {
|
|
287
|
+
const rest = argvAfterCommand(["remove", "rm", "uninstall"]);
|
|
288
|
+
const global = rest.includes("-g") || rest.includes("--global");
|
|
289
|
+
const packages = rest.filter((a) => !a.startsWith("-"));
|
|
166
290
|
const ui = createUi();
|
|
167
|
-
if (
|
|
291
|
+
if (global) {
|
|
168
292
|
await removeGlobalPackages(packages, ui);
|
|
169
293
|
return;
|
|
170
294
|
}
|
|
@@ -172,13 +296,20 @@ program
|
|
|
172
296
|
console.error("Usage: dpm rm <name> or dpm rm -g");
|
|
173
297
|
process.exit(1);
|
|
174
298
|
}
|
|
175
|
-
|
|
176
|
-
|
|
299
|
+
if (rest.every((a) => !a.startsWith("-"))) {
|
|
300
|
+
for (const name of packages) {
|
|
301
|
+
await removePackage(name, process.cwd(), ui);
|
|
302
|
+
}
|
|
303
|
+
return;
|
|
177
304
|
}
|
|
305
|
+
const code = await runtimePm(["remove", ...rest]);
|
|
306
|
+
if (code !== 0)
|
|
307
|
+
process.exit(code);
|
|
308
|
+
await syncLockFromNodeModules(process.cwd());
|
|
178
309
|
});
|
|
179
310
|
const auditCmd = program
|
|
180
311
|
.command("audit")
|
|
181
|
-
.description("Report known vulnerabilities
|
|
312
|
+
.description("Report known vulnerabilities")
|
|
182
313
|
.action(async () => {
|
|
183
314
|
const api = new DpmApi(await loadConfig());
|
|
184
315
|
await runAudit(api, process.cwd(), createUi());
|
|
@@ -194,29 +325,82 @@ auditCmd
|
|
|
194
325
|
program
|
|
195
326
|
.command("publish")
|
|
196
327
|
.option("--access <access>", "public or private")
|
|
328
|
+
.description("Publish the current package to the DPM registry")
|
|
197
329
|
.action(async (opts) => {
|
|
198
330
|
const api = new DpmApi(await loadConfig());
|
|
199
331
|
const packed = await packTarball();
|
|
332
|
+
const manifest = { ...packed.manifest };
|
|
333
|
+
// CLI npm name maps to the DPM registry package `dpm`.
|
|
334
|
+
if (manifest.name === "@drops-it/dpm")
|
|
335
|
+
manifest.name = "dpm";
|
|
200
336
|
const result = await api.publish({
|
|
201
|
-
manifest
|
|
337
|
+
manifest,
|
|
202
338
|
tarballBase64: packed.tarballBase64,
|
|
203
|
-
access: opts.access,
|
|
339
|
+
access: opts.access ?? "public",
|
|
204
340
|
});
|
|
205
341
|
console.log(`Published ${result.name}@${result.version} (${result.access})`);
|
|
206
342
|
});
|
|
207
343
|
program
|
|
208
|
-
.command("
|
|
209
|
-
.description("
|
|
210
|
-
.
|
|
211
|
-
|
|
344
|
+
.command("run")
|
|
345
|
+
.description("Run a package.json script or file")
|
|
346
|
+
.allowUnknownOption(true)
|
|
347
|
+
.argument("[args...]")
|
|
348
|
+
.action(async () => {
|
|
349
|
+
process.exit(await runtimeRaw(["run", ...argvAfterCommand(["run"])]));
|
|
350
|
+
});
|
|
351
|
+
program
|
|
352
|
+
.command("test")
|
|
353
|
+
.description("Run tests")
|
|
354
|
+
.allowUnknownOption(true)
|
|
355
|
+
.argument("[args...]")
|
|
356
|
+
.action(async () => {
|
|
357
|
+
process.exit(await runtimeRaw(["test", ...argvAfterCommand(["test"])]));
|
|
358
|
+
});
|
|
359
|
+
program
|
|
360
|
+
.command("x")
|
|
361
|
+
.alias("exec")
|
|
362
|
+
.description("Execute a package binary (installing if needed)")
|
|
363
|
+
.allowUnknownOption(true)
|
|
364
|
+
.argument("[args...]")
|
|
365
|
+
.action(async () => {
|
|
366
|
+
const name = process.argv.includes("exec") ? "exec" : "x";
|
|
367
|
+
// Prefer `x` for package bins; `exec` stays exec for shell-style
|
|
368
|
+
const cmd = name === "exec" ? "exec" : "x";
|
|
369
|
+
process.exit(await runtimeRaw([cmd, ...argvAfterCommand(["x", "exec"])]));
|
|
212
370
|
});
|
|
213
371
|
program
|
|
214
|
-
.command("
|
|
215
|
-
.description("
|
|
216
|
-
.
|
|
217
|
-
|
|
372
|
+
.command("build")
|
|
373
|
+
.description("Bundle with the DPM runtime")
|
|
374
|
+
.allowUnknownOption(true)
|
|
375
|
+
.argument("[args...]")
|
|
376
|
+
.action(async () => {
|
|
377
|
+
process.exit(await runtimeRaw(["build", ...argvAfterCommand(["build"])]));
|
|
218
378
|
});
|
|
219
|
-
|
|
379
|
+
async function main() {
|
|
380
|
+
if (shouldForwardToRuntime(process.argv)) {
|
|
381
|
+
await maybeNotifyUpdate();
|
|
382
|
+
const args = process.argv.slice(2);
|
|
383
|
+
// Package-manager-ish forwards still get DPM registry config
|
|
384
|
+
const pmFirst = new Set([
|
|
385
|
+
"link",
|
|
386
|
+
"unlink",
|
|
387
|
+
"outdated",
|
|
388
|
+
"pm",
|
|
389
|
+
"patch",
|
|
390
|
+
"why",
|
|
391
|
+
"info",
|
|
392
|
+
"list",
|
|
393
|
+
"create",
|
|
394
|
+
]);
|
|
395
|
+
const first = args[0] ?? "";
|
|
396
|
+
const code = pmFirst.has(first)
|
|
397
|
+
? await runtimePm(args)
|
|
398
|
+
: await runtimeRaw(args);
|
|
399
|
+
process.exit(code);
|
|
400
|
+
}
|
|
401
|
+
await program.parseAsync(process.argv);
|
|
402
|
+
}
|
|
403
|
+
main().catch((err) => {
|
|
220
404
|
console.error(err instanceof Error ? err.message : err);
|
|
221
405
|
process.exit(1);
|
|
222
406
|
});
|
package/dist/install.d.ts
CHANGED
|
@@ -9,9 +9,7 @@ export type InstallLog = {
|
|
|
9
9
|
clearStatus?: () => void;
|
|
10
10
|
};
|
|
11
11
|
export type InstallOptions = {
|
|
12
|
-
/** Prefer these exact versions when they satisfy the requested range. */
|
|
13
12
|
preferredVersions?: Record<string, string>;
|
|
14
|
-
/** Skip the post-install vulnerability check (used by nested audit-fix reinstall). */
|
|
15
13
|
skipAudit?: boolean;
|
|
16
14
|
};
|
|
17
15
|
/** Parse `name`, `name@1.2.3`, `name@^1`, `@scope/name`, `@scope/name@1.0.0`. */
|
|
@@ -19,20 +17,30 @@ export declare function parsePackageSpec(spec: string): {
|
|
|
19
17
|
name: string;
|
|
20
18
|
range: string;
|
|
21
19
|
};
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Builds a DPM lock snapshot from installed node_modules for audit tooling.
|
|
22
|
+
*/
|
|
23
|
+
export declare function syncLockFromNodeModules(cwd: string): Promise<Lockfile>;
|
|
24
|
+
/** Installs package.json dependencies via the managed DPM runtime. */
|
|
25
|
+
export declare function installAll(_api: DpmApi, cwd?: string, log?: InstallLog, options?: InstallOptions): Promise<Lockfile>;
|
|
26
|
+
/** Adds packages then installs via the managed DPM runtime. */
|
|
23
27
|
export declare function addPackages(api: DpmApi, specs: string[], cwd?: string, log?: InstallLog): Promise<Lockfile>;
|
|
24
28
|
/**
|
|
25
|
-
* Installs packages into the
|
|
26
|
-
*
|
|
27
|
-
* Used for CLI self-updates: `dpm i -g dpm` / `dpm i -g @drops-it/dpm`.
|
|
29
|
+
* Installs packages into the global prefix via the managed DPM runtime.
|
|
30
|
+
* Self-update of the Windows exe uses `/download/dpm.exe` instead of bun -g.
|
|
28
31
|
*/
|
|
29
|
-
export declare function installGlobalPackages(
|
|
32
|
+
export declare function installGlobalPackages(_api: DpmApi, specs: string[], log?: InstallLog): Promise<void>;
|
|
30
33
|
/**
|
|
31
34
|
* Uninstalls global packages (and cleans dpm bin shims when removing the CLI).
|
|
32
|
-
* `dpm rm -g` with no names removes the dpm CLI itself.
|
|
35
|
+
* `dpm rm -g` with no names removes the dpm CLI itself (Windows exe + bun/npm globals).
|
|
33
36
|
*/
|
|
34
37
|
export declare function removeGlobalPackages(specs: string[], log?: InstallLog): Promise<void>;
|
|
35
38
|
export declare function addPackage(api: DpmApi, name: string, range?: string, cwd?: string, log?: InstallLog): Promise<Lockfile>;
|
|
39
|
+
/**
|
|
40
|
+
* Removes a local dependency via the managed runtime.
|
|
41
|
+
* If Bun fails (e.g. ENOENT on an unrelated cached tarball), falls back to
|
|
42
|
+
* editing package.json + reinstall.
|
|
43
|
+
*/
|
|
36
44
|
export declare function removePackage(name: string, cwd?: string, log?: InstallLog): Promise<void>;
|
|
37
45
|
/**
|
|
38
46
|
* Runs a vulnerability audit against the current lockfile (or installs first).
|
|
@@ -42,12 +50,13 @@ export declare function runAudit(api: DpmApi, cwd?: string, log?: InstallLog): P
|
|
|
42
50
|
fixes: ProposedFix[];
|
|
43
51
|
}>;
|
|
44
52
|
/**
|
|
45
|
-
* Applies available advisory fixes
|
|
53
|
+
* Applies available advisory fixes, then reinstalls via the DPM runtime.
|
|
46
54
|
*/
|
|
47
55
|
export declare function auditFix(api: DpmApi, cwd?: string, log?: InstallLog, force?: boolean): Promise<{
|
|
48
56
|
fixed: ProposedFix[];
|
|
49
57
|
lock: Lockfile;
|
|
50
58
|
}>;
|
|
59
|
+
/** Packs the current package into a gzipped tarball for publish. */
|
|
51
60
|
export declare function packTarball(cwd?: string): Promise<{
|
|
52
61
|
manifest: Record<string, unknown>;
|
|
53
62
|
tarballBase64: string;
|