packdog 0.1.3 → 0.1.4

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.
@@ -2,22 +2,18 @@ import { writeFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { getToken } from "../config.js";
4
4
  import { fetchJson } from "../api.js";
5
- export async function init(name) {
6
- if (!name) {
7
- console.error("Missing --name argument");
8
- console.error("Usage: packdog init --name=my-pack");
5
+ export async function init(id) {
6
+ if (!id) {
7
+ console.error("Missing --id argument");
8
+ console.error("Usage: packdog init --id=<packageId>");
9
+ console.error(" Run 'packdog list' to see packages you have access to.");
9
10
  process.exit(1);
10
11
  }
11
12
  const token = getToken();
12
- console.log(`Registering pack: ${name}`);
13
- const result = await fetchJson("/packages", token, {
14
- method: "POST",
15
- headers: { "Content-Type": "application/json" },
16
- body: JSON.stringify({ name })
17
- });
18
- const config = { packageId: result.packageId };
13
+ const pkg = await fetchJson(`/packages/${id}`, token);
14
+ const config = { packageId: pkg.id };
19
15
  const configPath = join(process.cwd(), "packdog.json");
20
16
  await writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
21
- console.log(`Pack registered: ${result.packageId}`);
17
+ console.log(`Package: ${pkg.name}`);
22
18
  console.log(`Created packdog.json`);
23
19
  }
@@ -4,11 +4,11 @@ export async function listCmd() {
4
4
  const token = getToken();
5
5
  const packages = await fetchJson("/packages", token);
6
6
  if (packages.length === 0) {
7
- console.log("No packages (or none you own when using a customer API key).");
7
+ console.log("No packages found.");
8
8
  return;
9
9
  }
10
10
  console.log("Packages:");
11
11
  for (const p of packages) {
12
- console.log(` ${p.name}\t${p.id}`);
12
+ console.log(` ${p.name.padEnd(30)} ${p.id}`);
13
13
  }
14
14
  }
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { init } from "./commands/init.js";
3
+ import { listCmd } from "./commands/list.js";
3
4
  import { upload } from "./commands/upload.js";
4
5
  import { publish } from "./commands/publish.js";
5
6
  import { rollback } from "./commands/rollback.js";
@@ -15,7 +16,8 @@ function getArg(name) {
15
16
  const HELP = `packdog — CLI for the Packdog package registry
16
17
 
17
18
  Commands:
18
- init Register a new pack and create packdog.json
19
+ list List packages you have access to (name + ID)
20
+ init Set up packdog.json for an existing package
19
21
  info Show pack name, versions and channels
20
22
  upload Upload dist/ as a new version (auto-publishes to stage)
21
23
  publish Publish latest version to a channel (default: stable)
@@ -24,18 +26,21 @@ Commands:
24
26
  channels List all channels
25
27
 
26
28
  Options:
29
+ --id=<packageId> Package ID (for init)
27
30
  --channel=<name> Channel name (default: stable for publish; required for rollback)
28
31
  --version=<id> Specific version ID (for publish)
29
- --name=<name> Pack name (for init)
30
32
 
31
33
  Environment (set in .env or .env.development):
32
- PACKDOG_TOKEN API token — admin token or developer token (dev_...)
34
+ PACKDOG_TOKEN Developer token (dev_...) get one from your admin
33
35
  PACKDOG_URL API URL (default: https://packdog.dev)
34
36
  `;
35
37
  async function main() {
36
38
  switch (command) {
39
+ case "list":
40
+ await listCmd();
41
+ break;
37
42
  case "init":
38
- await init(getArg("name"));
43
+ await init(getArg("id"));
39
44
  break;
40
45
  case "upload":
41
46
  await upload();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "packdog",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "CLI for the Packdog package registry",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,