@devdogsuga/devtools 0.1.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 +44 -0
- package/bin/devtools-ci-bare.mjs +48 -0
- package/bin/devtools-ci.mjs +17 -0
- package/bin/devtools.mjs +27 -0
- package/dist/args.d.ts +26 -0
- package/dist/args.js +78 -0
- package/dist/bws/bw.d.ts +9 -0
- package/dist/bws/bw.js +49 -0
- package/dist/bws/client.d.ts +43 -0
- package/dist/bws/client.js +363 -0
- package/dist/bws/environments.d.ts +96 -0
- package/dist/bws/environments.js +111 -0
- package/dist/bws/pace.d.ts +27 -0
- package/dist/bws/pace.js +43 -0
- package/dist/bws/retry.d.ts +12 -0
- package/dist/bws/retry.js +39 -0
- package/dist/bws/store.d.ts +1 -0
- package/dist/bws/store.js +32 -0
- package/dist/bws/token.d.ts +31 -0
- package/dist/bws/token.js +88 -0
- package/dist/bws/vault.d.ts +29 -0
- package/dist/bws/vault.js +200 -0
- package/dist/catalog.d.ts +55 -0
- package/dist/catalog.js +81 -0
- package/dist/cf/commands.d.ts +1 -0
- package/dist/cf/commands.js +182 -0
- package/dist/cf/local-env.d.ts +44 -0
- package/dist/cf/local-env.js +148 -0
- package/dist/ci.d.ts +1 -0
- package/dist/ci.js +319 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +1077 -0
- package/dist/commands.d.ts +255 -0
- package/dist/commands.js +1279 -0
- package/dist/completions.d.ts +4 -0
- package/dist/completions.js +110 -0
- package/dist/cron/commands.d.ts +47 -0
- package/dist/cron/commands.js +372 -0
- package/dist/cron/discovery.d.ts +55 -0
- package/dist/cron/discovery.js +85 -0
- package/dist/cron/schema.d.ts +45 -0
- package/dist/cron/schema.js +35 -0
- package/dist/db/config-push.d.ts +8 -0
- package/dist/db/config-push.js +11 -0
- package/dist/db/connection.d.ts +79 -0
- package/dist/db/connection.js +114 -0
- package/dist/db/exec.d.ts +1 -0
- package/dist/db/exec.js +11 -0
- package/dist/db/generate-migration.d.ts +1 -0
- package/dist/db/generate-migration.js +67 -0
- package/dist/db/generate-types.d.ts +1 -0
- package/dist/db/generate-types.js +4 -0
- package/dist/db/introspect.d.ts +1 -0
- package/dist/db/introspect.js +113 -0
- package/dist/db/local-env.d.ts +65 -0
- package/dist/db/local-env.js +23 -0
- package/dist/db/new-migration.d.ts +1 -0
- package/dist/db/new-migration.js +8 -0
- package/dist/db/run.d.ts +70 -0
- package/dist/db/run.js +158 -0
- package/dist/db/seed-buckets.d.ts +2 -0
- package/dist/db/seed-buckets.js +4 -0
- package/dist/db/seed-production.d.ts +8 -0
- package/dist/db/seed-production.js +73 -0
- package/dist/db/seed-roles.d.ts +7 -0
- package/dist/db/seed-roles.js +31 -0
- package/dist/db/session-refresh.d.ts +43 -0
- package/dist/db/session-refresh.js +40 -0
- package/dist/deploy/migrations.d.ts +20 -0
- package/dist/deploy/migrations.js +68 -0
- package/dist/deploy/orphans.d.ts +20 -0
- package/dist/deploy/orphans.js +177 -0
- package/dist/deploy/preflight.d.ts +53 -0
- package/dist/deploy/preflight.js +189 -0
- package/dist/deploy/report.d.ts +26 -0
- package/dist/deploy/report.js +70 -0
- package/dist/deploy/require-planner.d.ts +2 -0
- package/dist/deploy/require-planner.js +60 -0
- package/dist/deploy/require-token.d.ts +15 -0
- package/dist/deploy/require-token.js +78 -0
- package/dist/deploy/secrets-file.d.ts +17 -0
- package/dist/deploy/secrets-file.js +167 -0
- package/dist/deploy/write-env.d.ts +40 -0
- package/dist/deploy/write-env.js +393 -0
- package/dist/docs/index-pages.d.ts +36 -0
- package/dist/docs/index-pages.js +184 -0
- package/dist/doctor.d.ts +62 -0
- package/dist/doctor.js +225 -0
- package/dist/emails/commands.d.ts +15 -0
- package/dist/emails/commands.js +130 -0
- package/dist/emails/email-types.d.ts +13 -0
- package/dist/emails/email-types.js +1 -0
- package/dist/emails/fixtures.d.ts +20 -0
- package/dist/emails/fixtures.js +20 -0
- package/dist/env/audit.d.ts +206 -0
- package/dist/env/audit.js +436 -0
- package/dist/env/cloudflare.d.ts +21 -0
- package/dist/env/cloudflare.js +61 -0
- package/dist/env/commands.d.ts +99 -0
- package/dist/env/commands.js +612 -0
- package/dist/env/discovery.d.ts +15 -0
- package/dist/env/discovery.js +226 -0
- package/dist/env/document.d.ts +119 -0
- package/dist/env/document.js +323 -0
- package/dist/env/example.d.ts +68 -0
- package/dist/env/example.js +603 -0
- package/dist/env/selection.d.ts +105 -0
- package/dist/env/selection.js +226 -0
- package/dist/environment.d.ts +92 -0
- package/dist/environment.js +206 -0
- package/dist/fingerprint.d.ts +10 -0
- package/dist/fingerprint.js +18 -0
- package/dist/gen/campus-map.d.ts +1 -0
- package/dist/gen/campus-map.js +473 -0
- package/dist/gen/commands.d.ts +1 -0
- package/dist/gen/commands.js +25 -0
- package/dist/gen/hypno.d.ts +1 -0
- package/dist/gen/hypno.js +134 -0
- package/dist/gh/client.d.ts +80 -0
- package/dist/gh/client.js +258 -0
- package/dist/gh/environments.d.ts +83 -0
- package/dist/gh/environments.js +178 -0
- package/dist/gh/rulesets/actors.d.ts +14 -0
- package/dist/gh/rulesets/actors.js +68 -0
- package/dist/gh/rulesets/api.d.ts +15 -0
- package/dist/gh/rulesets/api.js +99 -0
- package/dist/gh/rulesets/commands.d.ts +3 -0
- package/dist/gh/rulesets/commands.js +203 -0
- package/dist/gh/rulesets/desired.d.ts +112 -0
- package/dist/gh/rulesets/desired.js +247 -0
- package/dist/gh/rulesets/diff.d.ts +65 -0
- package/dist/gh/rulesets/diff.js +134 -0
- package/dist/gh/rulesets/types.d.ts +76 -0
- package/dist/gh/rulesets/types.js +13 -0
- package/dist/gh/settings/api.d.ts +40 -0
- package/dist/gh/settings/api.js +172 -0
- package/dist/gh/settings/commands.d.ts +1 -0
- package/dist/gh/settings/commands.js +245 -0
- package/dist/gh/settings/desired.d.ts +53 -0
- package/dist/gh/settings/desired.js +39 -0
- package/dist/gh/settings/diff.d.ts +57 -0
- package/dist/gh/settings/diff.js +156 -0
- package/dist/gh/settings/types.d.ts +92 -0
- package/dist/gh/settings/types.js +11 -0
- package/dist/gh/settings/workflows.d.ts +41 -0
- package/dist/gh/settings/workflows.js +124 -0
- package/dist/grantRoot.d.ts +42 -0
- package/dist/grantRoot.js +89 -0
- package/dist/help.d.ts +18 -0
- package/dist/help.js +169 -0
- package/dist/images/commands.d.ts +35 -0
- package/dist/images/commands.js +233 -0
- package/dist/images/events.d.ts +36 -0
- package/dist/images/events.js +152 -0
- package/dist/images/graphics.d.ts +70 -0
- package/dist/images/graphics.js +233 -0
- package/dist/images/open-graph-types.d.ts +75 -0
- package/dist/images/open-graph-types.js +1 -0
- package/dist/images/prompts.d.ts +34 -0
- package/dist/images/prompts.js +100 -0
- package/dist/images/render.d.ts +21 -0
- package/dist/images/render.js +57 -0
- package/dist/images/select.d.ts +64 -0
- package/dist/images/select.js +96 -0
- package/dist/instance.d.ts +67 -0
- package/dist/instance.js +129 -0
- package/dist/invocation.d.ts +49 -0
- package/dist/invocation.js +78 -0
- package/dist/launch-ci.d.ts +1 -0
- package/dist/launch-ci.js +86 -0
- package/dist/launch.d.ts +29 -0
- package/dist/launch.js +371 -0
- package/dist/menu.d.ts +31 -0
- package/dist/menu.js +277 -0
- package/dist/newsletter/commands.d.ts +16 -0
- package/dist/newsletter/commands.js +311 -0
- package/dist/newsletter/imap.d.ts +17 -0
- package/dist/newsletter/imap.js +127 -0
- package/dist/newsletter/loopback.d.ts +24 -0
- package/dist/newsletter/loopback.js +100 -0
- package/dist/newsletter/oauth.d.ts +26 -0
- package/dist/newsletter/oauth.js +130 -0
- package/dist/newsletter/smtp.d.ts +23 -0
- package/dist/newsletter/smtp.js +133 -0
- package/dist/oauth/browser.d.ts +1 -0
- package/dist/oauth/browser.js +13 -0
- package/dist/oauth/config.d.ts +24 -0
- package/dist/oauth/config.js +24 -0
- package/dist/oauth/connect-url.d.ts +17 -0
- package/dist/oauth/connect-url.js +23 -0
- package/dist/oauth/db.d.ts +37 -0
- package/dist/oauth/db.js +108 -0
- package/dist/oauth/device.d.ts +93 -0
- package/dist/oauth/device.js +190 -0
- package/dist/oauth/discovery.d.ts +28 -0
- package/dist/oauth/discovery.js +54 -0
- package/dist/oauth/env-file.d.ts +6 -0
- package/dist/oauth/env-file.js +35 -0
- package/dist/oauth/exchange.d.ts +43 -0
- package/dist/oauth/exchange.js +87 -0
- package/dist/oauth/label.d.ts +1 -0
- package/dist/oauth/label.js +25 -0
- package/dist/oauth/loopback.d.ts +52 -0
- package/dist/oauth/loopback.js +162 -0
- package/dist/oauth/pkce.d.ts +6 -0
- package/dist/oauth/pkce.js +34 -0
- package/dist/oauth/target.d.ts +54 -0
- package/dist/oauth/target.js +102 -0
- package/dist/oauth/transport.d.ts +41 -0
- package/dist/oauth/transport.js +32 -0
- package/dist/oauth/wizard.d.ts +33 -0
- package/dist/oauth/wizard.js +571 -0
- package/dist/pick.d.ts +6 -0
- package/dist/pick.js +64 -0
- package/dist/planner/checks.d.ts +26 -0
- package/dist/planner/checks.js +104 -0
- package/dist/planner/commands.d.ts +10 -0
- package/dist/planner/commands.js +367 -0
- package/dist/planner/db.d.ts +15 -0
- package/dist/planner/db.js +33 -0
- package/dist/planner/role.d.ts +33 -0
- package/dist/planner/role.js +68 -0
- package/dist/repo/peers.d.ts +24 -0
- package/dist/repo/peers.js +114 -0
- package/dist/repo/preflight.d.ts +109 -0
- package/dist/repo/preflight.js +266 -0
- package/dist/repo/resolve.d.ts +41 -0
- package/dist/repo/resolve.js +152 -0
- package/dist/repo/root.d.ts +23 -0
- package/dist/repo/root.js +91 -0
- package/dist/repo/source.d.ts +14 -0
- package/dist/repo/source.js +54 -0
- package/dist/repo/tsx-loader.d.ts +6 -0
- package/dist/repo/tsx-loader.js +41 -0
- package/dist/run/pick.d.ts +60 -0
- package/dist/run/pick.js +559 -0
- package/dist/setup.d.ts +1 -0
- package/dist/setup.js +152 -0
- package/dist/stack.d.ts +48 -0
- package/dist/stack.js +290 -0
- package/dist/telemetry.d.ts +34 -0
- package/dist/telemetry.js +93 -0
- package/dist/tier.d.ts +40 -0
- package/dist/tier.js +93 -0
- package/dist/tsconfig.typecheck.tsbuildinfo +1 -0
- package/dist/ui.d.ts +25 -0
- package/dist/ui.js +51 -0
- package/dist/workers.d.ts +5 -0
- package/dist/workers.js +35 -0
- package/dist/workflows/commands.d.ts +44 -0
- package/dist/workflows/commands.js +668 -0
- package/env.ts +158 -0
- package/package.json +80 -0
package/dist/tier.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared `--tier` resolver for the handful of commands that pick a
|
|
3
|
+
* deploy tier of their OWN, separate from the session-wide tier
|
|
4
|
+
* `src/launch.ts` already resolved and entered before this CLI ever runs
|
|
5
|
+
* (see that file's header, and `@devdogsuga/env/session`, which is where
|
|
6
|
+
* `availableTiers` and the session-wide policy now live — this module used
|
|
7
|
+
* to carry its own copy of both, one of two the wizard's tier question also
|
|
8
|
+
* used to keep before it moved into `launch.ts`).
|
|
9
|
+
*
|
|
10
|
+
* `cf preview`, `cron run` and `workflows run` still need a resolver of their
|
|
11
|
+
* own: each names the tier something it is doing right now — running a
|
|
12
|
+
* workflow, previewing a build — SEPARATELY from the tier the session as a
|
|
13
|
+
* whole is running under (`process.env.DEPLOY_ENV`, honoured here as the
|
|
14
|
+
* fallback below), and a command flag can still name a different one. All
|
|
15
|
+
* three used to ask the same "which tier?" question with a subtly different
|
|
16
|
+
* answer, which is what this module unified. It asks only when the answer is
|
|
17
|
+
* not foregone: when more than one deploy tier's env file is actually
|
|
18
|
+
* present. That is the signature of someone working on the deploy workflow
|
|
19
|
+
* itself, who keeps `.env.staging` or `.env.production` around to test
|
|
20
|
+
* against. Everyone else falls straight through to development, exactly as
|
|
21
|
+
* if `--tier development` had been typed.
|
|
22
|
+
*/
|
|
23
|
+
import { select } from "@clack/prompts";
|
|
24
|
+
import { loadEnv, loadEnvSession } from "./repo/peers.js";
|
|
25
|
+
import { findRepoRoot } from "./repo/root.js";
|
|
26
|
+
import { unwrap } from "./ui.js";
|
|
27
|
+
/**
|
|
28
|
+
* The deploy tier a command runs under when `--tier` was not passed.
|
|
29
|
+
*
|
|
30
|
+
* Prompts ONLY when more than one deploy tier's file is present — the
|
|
31
|
+
* handful of contributors working on the deploy workflow — so that everyone
|
|
32
|
+
* else (just development, possibly with `.env.generated` from a running
|
|
33
|
+
* local stack) falls straight through to development with no prompt at all.
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` after reporting an error on stderr — an invalid `--tier`, or
|
|
36
|
+
* an interactive pick of a tier whose file is missing — so the caller can
|
|
37
|
+
* exit nonzero without printing a second message of its own.
|
|
38
|
+
*/
|
|
39
|
+
export async function resolveTier(given, message, opts = {}) {
|
|
40
|
+
const label = opts.label ?? "devtools";
|
|
41
|
+
const env = await loadEnv();
|
|
42
|
+
if (given !== undefined) {
|
|
43
|
+
if (env.isDeployEnvironment(given))
|
|
44
|
+
return given;
|
|
45
|
+
process.stderr.write(`${label}: unknown tier "${given}". Expected: ${env.DEPLOY_ENVIRONMENTS.join(", ")}.\n`);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
// Already inside a tier? Honour it instead of prompting. An entered tier is
|
|
49
|
+
// an answer, exactly like an explicit `--tier` above — including one whose
|
|
50
|
+
// file is missing, which `loadEnvironment` then reports — so it is validated
|
|
51
|
+
// for shape only, not existence, and does NOT fall through to the picker.
|
|
52
|
+
const entered = opts.deployEnv ?? process.env.DEPLOY_ENV;
|
|
53
|
+
if (entered !== undefined && entered !== "" && env.isDeployEnvironment(entered)) {
|
|
54
|
+
return entered;
|
|
55
|
+
}
|
|
56
|
+
const available = opts.available ?? (await (await loadEnvSession()).availableTiers(findRepoRoot()));
|
|
57
|
+
// Zero or one tier file present: there is nothing to choose between, so
|
|
58
|
+
// asking would be a question with one possible answer. Fall through to
|
|
59
|
+
// whichever tier is present, or development when nothing is (a machine
|
|
60
|
+
// that has never run `env pull` at all).
|
|
61
|
+
if (available.length <= 1)
|
|
62
|
+
return available[0] ?? "development";
|
|
63
|
+
const isTTY = opts.isTTY ?? process.stdin.isTTY;
|
|
64
|
+
if (!isTTY)
|
|
65
|
+
return "development";
|
|
66
|
+
const prompt = opts.prompt ??
|
|
67
|
+
(async (msg, choices) => unwrap(await select({
|
|
68
|
+
message: msg,
|
|
69
|
+
options: choices,
|
|
70
|
+
})));
|
|
71
|
+
// Show every deploy tier, not just the present ones: clack's `select` has
|
|
72
|
+
// no true "disabled" state, so a tier whose file is missing is shown with
|
|
73
|
+
// a hint that says so and how to fix it, rather than removed from the list
|
|
74
|
+
// where a contributor who expected to see "production" would wonder if
|
|
75
|
+
// they misconfigured something.
|
|
76
|
+
const choices = env.DEPLOY_ENVIRONMENTS.map((tier) => ({
|
|
77
|
+
value: tier,
|
|
78
|
+
label: tier,
|
|
79
|
+
hint: !available.includes(tier)
|
|
80
|
+
? `needs env pull --target ${tier}`
|
|
81
|
+
: tier === "development"
|
|
82
|
+
? "the default"
|
|
83
|
+
: tier === "production"
|
|
84
|
+
? "⚠️ live data"
|
|
85
|
+
: undefined,
|
|
86
|
+
}));
|
|
87
|
+
const choice = await prompt(message, choices);
|
|
88
|
+
if (!available.includes(choice)) {
|
|
89
|
+
process.stderr.write(`${label}: ${env.fileFor(choice)} is not present — run \`pnpm devtools env pull --target ${choice}\` first.\n`);
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return choice;
|
|
93
|
+
}
|