@picked/cli 0.0.111-next.2 → 0.0.111-next.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.
package/dist/cjs/cli.js CHANGED
@@ -1,5 +1,19 @@
1
1
  #!/usr/bin/env node
2
- const e=require("../workspace-use-CBVbT-DN.cjs");let t=require("@picked/config"),n=require("node:util"),r=require("@picked/telemetry");var i=2e3,a=null,o=0;function s(e){if((0,t.isTelemetryForcedOffByEnvironment)())return;o=Date.now();let n=(0,t.detectHostEnvironment)();a={name:`picked.cli.${e}`,traceId:(0,r.createTraceId)(),spanId:(0,r.createSpanId)(),startTimeUnixNano:(0,r.toUnixNano)(o),endTimeUnixNano:(0,r.toUnixNano)(o),attributes:{"picked.cli.command":e,"picked.env.provider":n.provider,"picked.env.ci":n.ci},status:`unset`}}function c(e){a&&(a.endTimeUnixNano=(0,r.toUnixNano)(Date.now()),a.status=e===0?`ok`:`error`)}async function l(){let e=a;if(a=null,e)try{let n=await(0,t.loadResolvedPickedConfig)();if(!n||!(0,t.isTelemetryEnabled)(n))return;let a=(0,r.createTelemetryEmitter)({resource:{"service.name":`picked-cli`},headers:{"Picked-Telemetry":`cli`}});a.record(e),await Promise.race([a.flush(),new Promise(e=>{setTimeout(e,i).unref()})])}catch{}}var u=`Usage:
2
+ const e=require("../workspace-use-zgrPXoil.cjs");let t=require("@picked/config"),n=require("@picked/admin-api-client"),r=require("node:util"),i=require("@picked/app-kit"),a=require("@picked/telemetry");async function o(){let{privateKey:e,publicKey:t,kid:n}=await(0,i.generateKeyPair)(),r=[`A new app key pair. Keep the private key secret; it is printed once:`,``,`PICKED_APP_PRIVATE_KEY=${e}`,``,`Public key: ${t}`,`Key id: ${n}`,``,"Set PICKED_APP_PRIVATE_KEY on the app server and where you run `picked app deploy`,",`which registers the public key with the app.`];for(let e of r)console.log(e);return 0}async function s(e){let t=e.PICKED_APP_PRIVATE_KEY?.trim()??``;if(t!==``)try{return(await(0,i.createSigner)(t)).publicKey}catch{throw Error(`PICKED_APP_PRIVATE_KEY is not an Ed25519 private key in PKCS#8`)}let n=e.PICKED_APP_PUBLIC_KEY?.trim()??``;return n===``?null:n}var c=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,l=(0,n.graphql)(`
3
+ mutation PickedAppDeploy($input: AppDeployInput!) {
4
+ appDeploy(input: $input) {
5
+ app {
6
+ id
7
+ name
8
+ handle
9
+ }
10
+ version {
11
+ version
12
+ }
13
+ unchanged
14
+ }
15
+ }
16
+ `);async function u(e){let n=await(0,t.loadPickedConfig)(e);if(n===null)throw Error(`No picked.config.ts, picked.config.js or picked.config.json in ${e}. Add one with an \`app\` section.`);if(!(0,t.hasApp)(n))throw Error(`picked.config in ${e} has no \`app\` section. \`picked app deploy\` and \`picked app dev\` need one.`);return n}async function d(t,n){if(n!==void 0&&c.test(n))return n;let r=await e.r(t);if(n!==void 0){let e=r.find(e=>e.slug===n||e.id===n);if(e===void 0)throw Error(`No organisation ${n} is visible to this account`);return e.id}let[i,...a]=r;if(i===void 0)throw Error(`This account belongs to no organisation`);if(a.length>0)throw Error(`Name the organisation with --org: ${r.map(e=>e.slug).join(`, `)}`);return i.id}function f(e,t,n){let r=(0,i.trimTrailing)(t,`/`),a=n===void 0?void 0:(0,i.trimTrailing)(n,`/`),o=e=>a!==void 0&&e.startsWith(a)?`${r}${e.slice(a.length)}`:e;return{...e,endpoint:r,...e.slots===void 0?{}:{slots:e.slots.map(e=>({...e,url:o(e.url)}))}}}function p({app:e,version:t,unchanged:n},r){let i=`${r?`dev `:``}version ${t.version} [${e.id}]`;return n?`${e.name} (${e.handle}) is unchanged: the manifest matches ${i}`:`Deployed ${e.name} (${e.handle}) ${i}`}async function m(t){let n=t.cwd??process.cwd();if(t.dev===!0&&(t.endpoint??``).trim()===``)return console.error(`picked app dev needs --endpoint <url>: the address your local app server is reachable at, such as a tunnel`),1;try{let{app:r}=await u(n),a=(0,i.parseManifest)(t.endpoint===void 0?r:{...r,endpoint:t.endpoint});if(!a.ok){console.error("picked.config `app` is not a valid app manifest:");for(let e of a.issues)console.error(` - ${e}`);return 1}let o=t.endpoint===void 0?a.manifest:f(a.manifest,t.endpoint,r.endpoint),c=await s(process.env),m=await e.f(await e.d(n)),h=await d(m,t.org),g=await m.request(l,{input:{organizationId:h,manifest:o,source:`CLI`,channel:t.dev===!0?`DEV`:`RELEASE`,publicKey:c}});return console.log(p(g.appDeploy,t.dev===!0)),c===null&&console.log("Set PICKED_APP_PRIVATE_KEY, from `picked app keys generate`, to register the key the app authenticates with."),0}catch(e){return console.error(e instanceof Error?e.message:String(e)),1}}var h=2e3,g=null,_=0;function v(e){if((0,t.isTelemetryForcedOffByEnvironment)())return;_=Date.now();let n=(0,t.detectHostEnvironment)();g={name:`picked.cli.${e}`,traceId:(0,a.createTraceId)(),spanId:(0,a.createSpanId)(),startTimeUnixNano:(0,a.toUnixNano)(_),endTimeUnixNano:(0,a.toUnixNano)(_),attributes:{"picked.cli.command":e,"picked.env.provider":n.provider,"picked.env.ci":n.ci},status:`unset`}}function y(e){g&&(g.endTimeUnixNano=(0,a.toUnixNano)(Date.now()),g.status=e===0?`ok`:`error`)}async function b(){let e=g;if(g=null,e)try{let n=await(0,t.loadResolvedPickedConfig)();if(!n||!(0,t.isTelemetryEnabled)(n))return;let r=(0,a.createTelemetryEmitter)({resource:{"service.name":`picked-cli`},headers:{"Picked-Telemetry":`cli`}});r.record(e),await Promise.race([r.flush(),new Promise(e=>{setTimeout(e,h).unref()})])}catch{}}var x=`Usage:
3
17
  picked login
4
18
  picked logout
5
19
  picked whoami
@@ -12,4 +26,7 @@ const e=require("../workspace-use-CBVbT-DN.cjs");let t=require("@picked/config")
12
26
  picked generate types [--check]
13
27
  picked pull [--check] [--allow-preview]
14
28
  picked docs list [words] [--type <type>] [--json]
15
- picked docs read <path>`,d=new Map([[`login`,()=>e.l({})],[`logout`,()=>e.c()],[`whoami`,()=>e.a()],[`status`,()=>e.o({})],[`pull`,t=>e.s({check:t.check,allowPreview:t[`allow-preview`]})]]);async function f(){let{positionals:t,values:r}=(0,n.parseArgs)({allowPositionals:!0,options:{check:{type:`boolean`,default:!1},project:{type:`string`},workspace:{type:`string`},json:{type:`boolean`,default:!1},generate:{type:`boolean`,default:!0},"no-generate":{type:`boolean`,default:!1},live:{type:`boolean`,default:!1},out:{type:`string`},in:{type:`string`},name:{type:`string`},publish:{type:`boolean`,default:!1},type:{type:`string`},"allow-preview":{type:`boolean`,default:!1}}}),[i,a]=t,o=r.generate&&!r[`no-generate`],c=i===void 0?void 0:d.get(i);i!==void 0&&c?(s(i),process.exitCode=await c(r)):i===`workspace`&&(a===`list`||a===`ls`)?(s(`workspace list`),process.exitCode=await e.n({json:r.json})):i===`workspace`&&a===`use`||i===`use`?(s(`workspace use`),process.exitCode=await e.t({project:r.project,workspace:r.workspace,generate:o})):i===`workspace`&&a===`export`?(s(`workspace export`),process.exitCode=await e.i({project:r.project,workspace:r.workspace,live:r.live,out:r.out})):i===`workspace`&&a===`import`?(s(`workspace import`),process.exitCode=await e.r({project:r.project,in:r.in,name:r.name,publish:r.publish})):i===`docs`?(s(e.d(a)),process.exitCode=await e.f({args:t.slice(1),type:r.type,json:r.json})):i===`generate`&&a===`types`?(s(`generate types`),process.exitCode=await e.u({check:r.check})):(s(`unknown`),console.error(u),process.exitCode=1)}function p(e){let t=2,n=()=>{--t,t<=0&&process.exit(e)};setTimeout(()=>{process.exit(e)},2e3).unref(),process.stdout.write(``,n),process.stderr.write(``,n)}f().then(async()=>{let e=typeof process.exitCode==`number`?process.exitCode:0;c(e),await l(),p(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);console.error(t),c(1),l().finally(()=>{p(1)})});
29
+ picked docs read <path>
30
+ picked app deploy [--org <slug>]
31
+ picked app dev --endpoint <url> [--org <slug>]
32
+ picked app keys generate`;async function S(e,t){let[n=``,r]=e,i=new Map([...r===`generate`?[[`keys`,o]]:[],[`deploy`,()=>m({org:t.org})],[`dev`,()=>m({org:t.org,dev:!0,endpoint:t.endpoint})]]).get(n);return i?(v(`app ${n}`),i()):(v(`unknown`),console.error(x),1)}var C=new Map([[`login`,()=>e.u({})],[`logout`,()=>e.l()],[`whoami`,()=>e.o()],[`status`,()=>e.s({})],[`pull`,t=>e.c({check:t.check,allowPreview:t[`allow-preview`]})],[`app`,(e,t)=>S(t,e)]]);async function w(){let{positionals:t,values:n}=(0,r.parseArgs)({allowPositionals:!0,options:{check:{type:`boolean`,default:!1},project:{type:`string`},workspace:{type:`string`},json:{type:`boolean`,default:!1},generate:{type:`boolean`,default:!0},"no-generate":{type:`boolean`,default:!1},live:{type:`boolean`,default:!1},out:{type:`string`},in:{type:`string`},name:{type:`string`},publish:{type:`boolean`,default:!1},type:{type:`string`},"allow-preview":{type:`boolean`,default:!1},org:{type:`string`},endpoint:{type:`string`}}}),[i,a]=t,o=n.generate&&!n[`no-generate`],s=i===void 0?void 0:C.get(i);i!==void 0&&s?(v(i),process.exitCode=await s(n,t.slice(1))):i===`workspace`&&(a===`list`||a===`ls`)?(v(`workspace list`),process.exitCode=await e.n({json:n.json})):i===`workspace`&&a===`use`||i===`use`?(v(`workspace use`),process.exitCode=await e.t({project:n.project,workspace:n.workspace,generate:o})):i===`workspace`&&a===`export`?(v(`workspace export`),process.exitCode=await e.a({project:n.project,workspace:n.workspace,live:n.live,out:n.out})):i===`workspace`&&a===`import`?(v(`workspace import`),process.exitCode=await e.i({project:n.project,in:n.in,name:n.name,publish:n.publish})):i===`docs`?(v(e.m(a)),process.exitCode=await e.h({args:t.slice(1),type:n.type,json:n.json})):i===`generate`&&a===`types`?(v(`generate types`),process.exitCode=await e.p({check:n.check})):(v(`unknown`),console.error(x),process.exitCode=1)}function T(e){let t=2,n=()=>{--t,t<=0&&process.exit(e)};setTimeout(()=>{process.exit(e)},2e3).unref(),process.stdout.write(``,n),process.stderr.write(``,n)}w().then(async()=>{let e=typeof process.exitCode==`number`?process.exitCode:0;y(e),await b(),T(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);console.error(t),y(1),b().finally(()=>{T(1)})});
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../workspace-use-CBVbT-DN.cjs");exports.runDocs=e.f,exports.runDocsList=e.p,exports.runDocsRead=e.m,exports.runGenerateTypes=e.u,exports.runLogin=e.l,exports.runLogout=e.c,exports.runPull=e.s,exports.runStatus=e.o,exports.runWhoami=e.a,exports.runWorkspaceExport=e.i,exports.runWorkspaceImport=e.r,exports.runWorkspaceList=e.n,exports.runWorkspaceUse=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../workspace-use-zgrPXoil.cjs");exports.runDocs=e.h,exports.runDocsList=e.g,exports.runDocsRead=e._,exports.runGenerateTypes=e.p,exports.runLogin=e.u,exports.runLogout=e.l,exports.runPull=e.c,exports.runStatus=e.s,exports.runWhoami=e.o,exports.runWorkspaceExport=e.a,exports.runWorkspaceImport=e.i,exports.runWorkspaceList=e.n,exports.runWorkspaceUse=e.t;
package/dist/esm/cli.js CHANGED
@@ -1,20 +1,111 @@
1
1
  #!/usr/bin/env node
2
- import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "../workspace-use-BlhQXU7t.js";
3
- import { detectHostEnvironment as f, isTelemetryEnabled as p, isTelemetryForcedOffByEnvironment as m, loadResolvedPickedConfig as h } from "@picked/config";
4
- import { parseArgs as g } from "node:util";
5
- import { createSpanId as _, createTelemetryEmitter as v, createTraceId as y, toUnixNano as b } from "@picked/telemetry";
2
+ import { a as e, c as t, d as n, f as r, h as i, i as a, l as o, m as s, n as c, o as l, p as u, r as d, s as f, t as p, u as m } from "../workspace-use-CQzmOQDR.js";
3
+ import { detectHostEnvironment as h, hasApp as g, isTelemetryEnabled as _, isTelemetryForcedOffByEnvironment as v, loadPickedConfig as y, loadResolvedPickedConfig as b } from "@picked/config";
4
+ import { graphql as x } from "@picked/admin-api-client";
5
+ import { parseArgs as S } from "node:util";
6
+ import { createSigner as C, generateKeyPair as w, parseManifest as T, trimTrailing as E } from "@picked/app-kit";
7
+ import { createSpanId as D, createTelemetryEmitter as O, createTraceId as k, toUnixNano as A } from "@picked/telemetry";
8
+ //#region src/commands/app-keys.ts
9
+ async function j() {
10
+ let { privateKey: e, publicKey: t, kid: n } = await w(), r = [
11
+ "A new app key pair. Keep the private key secret; it is printed once:",
12
+ "",
13
+ `PICKED_APP_PRIVATE_KEY=${e}`,
14
+ "",
15
+ `Public key: ${t}`,
16
+ `Key id: ${n}`,
17
+ "",
18
+ "Set PICKED_APP_PRIVATE_KEY on the app server and where you run `picked app deploy`,",
19
+ "which registers the public key with the app."
20
+ ];
21
+ for (let e of r) console.log(e);
22
+ return 0;
23
+ }
24
+ async function M(e) {
25
+ let t = e.PICKED_APP_PRIVATE_KEY?.trim() ?? "";
26
+ if (t !== "") try {
27
+ return (await C(t)).publicKey;
28
+ } catch {
29
+ throw Error("PICKED_APP_PRIVATE_KEY is not an Ed25519 private key in PKCS#8");
30
+ }
31
+ let n = e.PICKED_APP_PUBLIC_KEY?.trim() ?? "";
32
+ return n === "" ? null : n;
33
+ }
34
+ //#endregion
35
+ //#region src/commands/app-deploy.ts
36
+ var N = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, P = x("\n mutation PickedAppDeploy($input: AppDeployInput!) {\n appDeploy(input: $input) {\n app {\n id\n name\n handle\n }\n version {\n version\n }\n unchanged\n }\n }\n");
37
+ async function F(e) {
38
+ let t = await y(e);
39
+ if (t === null) throw Error(`No picked.config.ts, picked.config.js or picked.config.json in ${e}. Add one with an \`app\` section.`);
40
+ if (!g(t)) throw Error(`picked.config in ${e} has no \`app\` section. \`picked app deploy\` and \`picked app dev\` need one.`);
41
+ return t;
42
+ }
43
+ async function I(e, t) {
44
+ if (t !== void 0 && N.test(t)) return t;
45
+ let n = await d(e);
46
+ if (t !== void 0) {
47
+ let e = n.find((e) => e.slug === t || e.id === t);
48
+ if (e === void 0) throw Error(`No organisation ${t} is visible to this account`);
49
+ return e.id;
50
+ }
51
+ let [r, ...i] = n;
52
+ if (r === void 0) throw Error("This account belongs to no organisation");
53
+ if (i.length > 0) throw Error(`Name the organisation with --org: ${n.map((e) => e.slug).join(", ")}`);
54
+ return r.id;
55
+ }
56
+ function L(e, t, n) {
57
+ let r = E(t, "/"), i = n === void 0 ? void 0 : E(n, "/"), a = (e) => i !== void 0 && e.startsWith(i) ? `${r}${e.slice(i.length)}` : e;
58
+ return {
59
+ ...e,
60
+ endpoint: r,
61
+ ...e.slots === void 0 ? {} : { slots: e.slots.map((e) => ({
62
+ ...e,
63
+ url: a(e.url)
64
+ })) }
65
+ };
66
+ }
67
+ function R({ app: e, version: t, unchanged: n }, r) {
68
+ let i = `${r ? "dev " : ""}version ${t.version} [${e.id}]`;
69
+ return n ? `${e.name} (${e.handle}) is unchanged: the manifest matches ${i}` : `Deployed ${e.name} (${e.handle}) ${i}`;
70
+ }
71
+ async function z(e) {
72
+ let t = e.cwd ?? process.cwd();
73
+ if (e.dev === !0 && (e.endpoint ?? "").trim() === "") return console.error("picked app dev needs --endpoint <url>: the address your local app server is reachable at, such as a tunnel"), 1;
74
+ try {
75
+ let { app: i } = await F(t), a = T(e.endpoint === void 0 ? i : {
76
+ ...i,
77
+ endpoint: e.endpoint
78
+ });
79
+ if (!a.ok) {
80
+ console.error("picked.config `app` is not a valid app manifest:");
81
+ for (let e of a.issues) console.error(` - ${e}`);
82
+ return 1;
83
+ }
84
+ let o = e.endpoint === void 0 ? a.manifest : L(a.manifest, e.endpoint, i.endpoint), s = await M(process.env), c = await r(await n(t)), l = await I(c, e.org), u = await c.request(P, { input: {
85
+ organizationId: l,
86
+ manifest: o,
87
+ source: "CLI",
88
+ channel: e.dev === !0 ? "DEV" : "RELEASE",
89
+ publicKey: s
90
+ } });
91
+ return console.log(R(u.appDeploy, e.dev === !0)), s === null && console.log("Set PICKED_APP_PRIVATE_KEY, from `picked app keys generate`, to register the key the app authenticates with."), 0;
92
+ } catch (e) {
93
+ return console.error(e instanceof Error ? e.message : String(e)), 1;
94
+ }
95
+ }
96
+ //#endregion
6
97
  //#region src/telemetry.ts
7
- var x = 2e3, S = null, C = 0;
8
- function w(e) {
9
- if (m()) return;
10
- C = Date.now();
11
- let t = f();
12
- S = {
98
+ var B = 2e3, V = null, H = 0;
99
+ function U(e) {
100
+ if (v()) return;
101
+ H = Date.now();
102
+ let t = h();
103
+ V = {
13
104
  name: `picked.cli.${e}`,
14
- traceId: y(),
15
- spanId: _(),
16
- startTimeUnixNano: b(C),
17
- endTimeUnixNano: b(C),
105
+ traceId: k(),
106
+ spanId: D(),
107
+ startTimeUnixNano: A(H),
108
+ endTimeUnixNano: A(H),
18
109
  attributes: {
19
110
  "picked.cli.command": e,
20
111
  "picked.env.provider": t.provider,
@@ -23,37 +114,51 @@ function w(e) {
23
114
  status: "unset"
24
115
  };
25
116
  }
26
- function T(e) {
27
- S && (S.endTimeUnixNano = b(Date.now()), S.status = e === 0 ? "ok" : "error");
117
+ function W(e) {
118
+ V && (V.endTimeUnixNano = A(Date.now()), V.status = e === 0 ? "ok" : "error");
28
119
  }
29
- async function E() {
30
- let e = S;
31
- if (S = null, e) try {
32
- let t = await h();
33
- if (!t || !p(t)) return;
34
- let n = v({
120
+ async function G() {
121
+ let e = V;
122
+ if (V = null, e) try {
123
+ let t = await b();
124
+ if (!t || !_(t)) return;
125
+ let n = O({
35
126
  resource: { "service.name": "picked-cli" },
36
127
  headers: { "Picked-Telemetry": "cli" }
37
128
  });
38
129
  n.record(e), await Promise.race([n.flush(), new Promise((e) => {
39
- setTimeout(e, x).unref();
130
+ setTimeout(e, B).unref();
40
131
  })]);
41
132
  } catch {}
42
133
  }
43
134
  //#endregion
44
135
  //#region src/cli.ts
45
- var D = "Usage:\n picked login\n picked logout\n picked whoami\n picked status\n picked workspace list [--json]\n picked workspace use [--project <id>] [--workspace <id>] [--no-generate]\n picked use [--project <id>] [--workspace <id>] [--no-generate]\n picked workspace export --project <id> (--workspace <id> | --live) --out <dir>\n picked workspace import --project <id> --in <dir> [--name <name>] [--publish]\n picked generate types [--check]\n picked pull [--check] [--allow-preview]\n picked docs list [words] [--type <type>] [--json]\n picked docs read <path>", O = /* @__PURE__ */ new Map([
46
- ["login", () => a({})],
47
- ["logout", () => t()],
48
- ["whoami", () => e()],
49
- ["status", () => s({})],
50
- ["pull", (e) => l({
136
+ var K = "Usage:\n picked login\n picked logout\n picked whoami\n picked status\n picked workspace list [--json]\n picked workspace use [--project <id>] [--workspace <id>] [--no-generate]\n picked use [--project <id>] [--workspace <id>] [--no-generate]\n picked workspace export --project <id> (--workspace <id> | --live) --out <dir>\n picked workspace import --project <id> --in <dir> [--name <name>] [--publish]\n picked generate types [--check]\n picked pull [--check] [--allow-preview]\n picked docs list [words] [--type <type>] [--json]\n picked docs read <path>\n picked app deploy [--org <slug>]\n picked app dev --endpoint <url> [--org <slug>]\n picked app keys generate";
137
+ async function q(e, t) {
138
+ let [n = "", r] = e, i = new Map([
139
+ ...r === "generate" ? [["keys", j]] : [],
140
+ ["deploy", () => z({ org: t.org })],
141
+ ["dev", () => z({
142
+ org: t.org,
143
+ dev: !0,
144
+ endpoint: t.endpoint
145
+ })]
146
+ ]).get(n);
147
+ return i ? (U(`app ${n}`), i()) : (U("unknown"), console.error(K), 1);
148
+ }
149
+ var J = /* @__PURE__ */ new Map([
150
+ ["login", () => m({})],
151
+ ["logout", () => o()],
152
+ ["whoami", () => l()],
153
+ ["status", () => f({})],
154
+ ["pull", (e) => t({
51
155
  check: e.check,
52
156
  allowPreview: e["allow-preview"]
53
- })]
157
+ })],
158
+ ["app", (e, t) => q(t, e)]
54
159
  ]);
55
- async function k() {
56
- let { positionals: e, values: t } = g({
160
+ async function Y() {
161
+ let { positionals: t, values: n } = S({
57
162
  allowPositionals: !0,
58
163
  options: {
59
164
  check: {
@@ -89,30 +194,32 @@ async function k() {
89
194
  "allow-preview": {
90
195
  type: "boolean",
91
196
  default: !1
92
- }
197
+ },
198
+ org: { type: "string" },
199
+ endpoint: { type: "string" }
93
200
  }
94
- }), [a, s] = e, l = t.generate && !t["no-generate"], f = a === void 0 ? void 0 : O.get(a);
95
- a !== void 0 && f ? (w(a), process.exitCode = await f(t)) : a === "workspace" && (s === "list" || s === "ls") ? (w("workspace list"), process.exitCode = await o({ json: t.json })) : a === "workspace" && s === "use" || a === "use" ? (w("workspace use"), process.exitCode = await u({
96
- project: t.project,
97
- workspace: t.workspace,
201
+ }), [r, o] = t, l = n.generate && !n["no-generate"], d = r === void 0 ? void 0 : J.get(r);
202
+ r !== void 0 && d ? (U(r), process.exitCode = await d(n, t.slice(1))) : r === "workspace" && (o === "list" || o === "ls") ? (U("workspace list"), process.exitCode = await c({ json: n.json })) : r === "workspace" && o === "use" || r === "use" ? (U("workspace use"), process.exitCode = await p({
203
+ project: n.project,
204
+ workspace: n.workspace,
98
205
  generate: l
99
- })) : a === "workspace" && s === "export" ? (w("workspace export"), process.exitCode = await i({
100
- project: t.project,
101
- workspace: t.workspace,
102
- live: t.live,
103
- out: t.out
104
- })) : a === "workspace" && s === "import" ? (w("workspace import"), process.exitCode = await c({
105
- project: t.project,
106
- in: t.in,
107
- name: t.name,
108
- publish: t.publish
109
- })) : a === "docs" ? (w(n(s)), process.exitCode = await r({
110
- args: e.slice(1),
111
- type: t.type,
112
- json: t.json
113
- })) : a === "generate" && s === "types" ? (w("generate types"), process.exitCode = await d({ check: t.check })) : (w("unknown"), console.error(D), process.exitCode = 1);
206
+ })) : r === "workspace" && o === "export" ? (U("workspace export"), process.exitCode = await e({
207
+ project: n.project,
208
+ workspace: n.workspace,
209
+ live: n.live,
210
+ out: n.out
211
+ })) : r === "workspace" && o === "import" ? (U("workspace import"), process.exitCode = await a({
212
+ project: n.project,
213
+ in: n.in,
214
+ name: n.name,
215
+ publish: n.publish
216
+ })) : r === "docs" ? (U(s(o)), process.exitCode = await i({
217
+ args: t.slice(1),
218
+ type: n.type,
219
+ json: n.json
220
+ })) : r === "generate" && o === "types" ? (U("generate types"), process.exitCode = await u({ check: n.check })) : (U("unknown"), console.error(K), process.exitCode = 1);
114
221
  }
115
- function A(e) {
222
+ function X(e) {
116
223
  let t = 2, n = () => {
117
224
  --t, t <= 0 && process.exit(e);
118
225
  };
@@ -120,13 +227,13 @@ function A(e) {
120
227
  process.exit(e);
121
228
  }, 2e3).unref(), process.stdout.write("", n), process.stderr.write("", n);
122
229
  }
123
- k().then(async () => {
230
+ Y().then(async () => {
124
231
  let e = typeof process.exitCode == "number" ? process.exitCode : 0;
125
- T(e), await E(), A(e);
232
+ W(e), await G(), X(e);
126
233
  }).catch((e) => {
127
234
  let t = e instanceof Error ? e.message : String(e);
128
- console.error(t), T(1), E().finally(() => {
129
- A(1);
235
+ console.error(t), W(1), G().finally(() => {
236
+ X(1);
130
237
  });
131
238
  });
132
239
  //#endregion
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export { f as runDocs, p as runDocsList, m as runDocsRead, u as runGenerateTypes, l as runLogin, c as runLogout, s as runPull, o as runStatus, a as runWhoami, i as runWorkspaceExport, r as runWorkspaceImport, n as runWorkspaceList, t as runWorkspaceUse } from "../workspace-use-BlhQXU7t.js";
1
+ export { h as runDocs, g as runDocsList, _ as runDocsRead, p as runGenerateTypes, u as runLogin, l as runLogout, c as runPull, s as runStatus, o as runWhoami, a as runWorkspaceExport, i as runWorkspaceImport, n as runWorkspaceList, t as runWorkspaceUse } from "../workspace-use-CQzmOQDR.js";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Runs `picked app deploy`, or `picked app dev` with `dev` set: validates the `app` section of
3
+ * `picked.config`, then deploys it as the app's next version, creating the app on its first deploy. A dev
4
+ * deploy goes to the dev channel, which only the app's own organisation installs, and needs an
5
+ * endpoint. A manifest matching the channel's latest version is reported unchanged. The deploy
6
+ * registers the public key `PICKED_APP_PRIVATE_KEY` or `PICKED_APP_PUBLIC_KEY` names.
7
+ *
8
+ * @param {object} options - Command options.
9
+ * @param {string} [options.cwd] - The app's directory.
10
+ * @param {string} [options.org] - The organisation id or slug.
11
+ * @param {boolean} [options.dev] - Deploy to the dev channel.
12
+ * @param {string} [options.endpoint] - The endpoint the version points at, overriding the manifest's; required with `dev`.
13
+ * @returns {Promise<number>} The process exit code.
14
+ * @example await runAppDeploy({ org: 'acme' })
15
+ */
16
+ export declare function runAppDeploy(options: {
17
+ cwd?: string;
18
+ org: string | undefined;
19
+ dev?: boolean;
20
+ endpoint?: string;
21
+ }): Promise<number>;
22
+ //# sourceMappingURL=app-deploy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-deploy.d.ts","sourceRoot":"","sources":["../../../src/commands/app-deploy.ts"],"names":[],"mappings":"AA8IA;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IACvB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsDlB"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Runs `picked app keys generate`: prints a new Ed25519 private key, the one-line base64 of its
3
+ * PKCS#8 DER, as a `PICKED_APP_PRIVATE_KEY` assignment, with its public key and key id.
4
+ *
5
+ * @returns {Promise<number>} The process exit code.
6
+ * @example await runAppKeysGenerate()
7
+ */
8
+ export declare function runAppKeysGenerate(): Promise<number>;
9
+ /**
10
+ * Reads the public key a deploy registers: derived from `PICKED_APP_PRIVATE_KEY`, else
11
+ * `PICKED_APP_PUBLIC_KEY`.
12
+ *
13
+ * @param {Record<string, string | undefined>} env - The environment.
14
+ * @returns {Promise<string | null>} The base64url public key, or null when neither is set.
15
+ * @throws {Error} When `PICKED_APP_PRIVATE_KEY` is not an Ed25519 private key.
16
+ * @example await deployedPublicKey(process.env)
17
+ */
18
+ export declare function deployedPublicKey(env: Record<string, string | undefined>): Promise<string | null>;
19
+ //# sourceMappingURL=app-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-keys.d.ts","sourceRoot":"","sources":["../../../src/commands/app-keys.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAgB1D;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAYxB"}
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Runs `picked status`: prints the effective active workspace selection for the current
3
- * API origin alongside the committed `picked.config` default.
2
+ * Runs `picked status`: prints the app `picked.config` holds, with its endpoint, and the project it
3
+ * names, with the effective active workspace selection for the current API origin. A config
4
+ * that holds both prints both.
4
5
  *
5
6
  * @param {object} [options] - Command options.
6
7
  * @param {string} [options.cwd] - Working directory to inspect; defaults to `process.cwd()`.
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/status.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAsC3E"}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/status.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,wBAAsB,SAAS,CAAC,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAmD3E"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Resolves the canonical Picked API origin: the `PICKED_API_URL` env var, else `apiUrl`
3
- * from `picked.config`, else the production default. The result is normalised to its
3
+ * from `picked.config`, a project's or an app's, else the production default. The result is normalised to its
4
4
  * origin so it is identical whether it feeds a request or keys per-origin auth storage.
5
5
  *
6
6
  * @param {string} [cwd] - Directory to search for `picked.config`; defaults to `process.cwd()`.