@jordond/kit 0.0.0-stage → 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/bin/kit +39 -0
- package/dist/_verb-espppzez.js +115 -0
- package/dist/android-g73naxgg.js +31 -0
- package/dist/build-88hxf0kc.js +42 -0
- package/dist/check-7mndz8g8.js +54 -0
- package/dist/check-ngc4kzmj.js +33 -0
- package/dist/cleanup-hrcvxmh2.js +18 -0
- package/dist/cli/builtins.d.ts +13 -0
- package/dist/cli/command.d.ts +86 -0
- package/dist/cli/discover.d.ts +10 -0
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/plugin.d.ts +7 -0
- package/dist/cli/usage.d.ts +3 -0
- package/dist/cli-07t28k94.js +30 -0
- package/dist/cli-12dww95e.js +195 -0
- package/dist/cli-5d61x8vg.js +675 -0
- package/dist/cli-5wasc5mr.js +76 -0
- package/dist/cli-6dxp4v3m.js +73 -0
- package/dist/cli-7wvrehng.js +23 -0
- package/dist/cli-bam7dqfd.js +33 -0
- package/dist/cli-fqfan92n.js +135 -0
- package/dist/cli-fqxtcj42.js +75 -0
- package/dist/cli-h974q2wr.js +2019 -0
- package/dist/cli-m53122z6.js +221 -0
- package/dist/cli-qhs8ww91.js +51 -0
- package/dist/cli-qq1ktr8q.js +234 -0
- package/dist/cli-rds33bnp.js +101 -0
- package/dist/cli-re3ntm60.js +48 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +35 -0
- package/dist/cloudflare-n5c46k6x.js +43 -0
- package/dist/command-gazq4bmt.js +19 -0
- package/dist/commands/_verb.d.ts +15 -0
- package/dist/commands/build.d.ts +11 -0
- package/dist/commands/check.d.ts +8 -0
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/db/create.d.ts +7 -0
- package/dist/commands/db/exec.d.ts +16 -0
- package/dist/commands/db/list.d.ts +11 -0
- package/dist/commands/db/migrate.d.ts +11 -0
- package/dist/commands/deploy.d.ts +13 -0
- package/dist/commands/deps.d.ts +72 -0
- package/dist/commands/dev.d.ts +8 -0
- package/dist/commands/doctor.d.ts +56 -0
- package/dist/commands/env/check.d.ts +7 -0
- package/dist/commands/env/init.d.ts +2 -0
- package/dist/commands/env/push.d.ts +12 -0
- package/dist/commands/env/sync.d.ts +2 -0
- package/dist/commands/format.d.ts +11 -0
- package/dist/commands/gradle.d.ts +2 -0
- package/dist/commands/init.d.ts +53 -0
- package/dist/commands/lint.d.ts +12 -0
- package/dist/commands/release/android.d.ts +13 -0
- package/dist/commands/release/ios.d.ts +13 -0
- package/dist/commands/test.d.ts +2 -0
- package/dist/commands/typecheck.d.ts +2 -0
- package/dist/commands/wrangler.d.ts +4 -0
- package/dist/commands/xcode.d.ts +8 -0
- package/dist/config/load.d.ts +6 -0
- package/dist/config/schema.d.ts +135 -0
- package/dist/config-ey5yrrfn.js +22 -0
- package/dist/create-7s8h3dja.js +38 -0
- package/dist/deploy-8mg1zhpb.js +102 -0
- package/dist/deps-97dq4mg8.js +334 -0
- package/dist/dev-yc9xmntj.js +62 -0
- package/dist/doctor-0wzmfyyh.js +324 -0
- package/dist/errors-1fjbr7ee.js +10 -0
- package/dist/exec-1k3sqwxz.js +53 -0
- package/dist/format-mnqfak22.js +39 -0
- package/dist/git-52v5rk51.js +80 -0
- package/dist/gradle-gtkf3geq.js +39 -0
- package/dist/index-cx34x4np.js +874 -0
- package/dist/index-erv82p4z.js +1528 -0
- package/dist/index-jqfz6hfy.js +2659 -0
- package/dist/index-mm4ht8yh.js +9 -0
- package/dist/index-s3ehw02w.js +1610 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +50 -0
- package/dist/init-0402av4m.js +78 -0
- package/dist/init-dk5sym9w.js +76 -0
- package/dist/init-qr7y55ea.js +185 -0
- package/dist/ios-msg4bk15.js +31 -0
- package/dist/lib/cleanup.d.ts +21 -0
- package/dist/lib/cloudflare.d.ts +96 -0
- package/dist/lib/env/init.d.ts +22 -0
- package/dist/lib/env/load.d.ts +12 -0
- package/dist/lib/env/push.d.ts +54 -0
- package/dist/lib/env/render.d.ts +49 -0
- package/dist/lib/env/schema.d.ts +49 -0
- package/dist/lib/errors.d.ts +14 -0
- package/dist/lib/git.d.ts +36 -0
- package/dist/lib/log.d.ts +11 -0
- package/dist/lib/pm.d.ts +8 -0
- package/dist/lib/proc.d.ts +73 -0
- package/dist/lib/prompt.d.ts +32 -0
- package/dist/lib/secrets.d.ts +32 -0
- package/dist/lib/steps.d.ts +38 -0
- package/dist/lib/targets.d.ts +46 -0
- package/dist/lib/toml.d.ts +15 -0
- package/dist/lint-280dpn4y.js +39 -0
- package/dist/list-jdc3dqk0.js +34 -0
- package/dist/load-5qzs1c6b.js +137 -0
- package/dist/log-hhspqwjw.js +11 -0
- package/dist/main-ywtsjxev.js +2052 -0
- package/dist/migrate-emk758k1.js +35 -0
- package/dist/picocolors-0dxagz5d.js +6 -0
- package/dist/pm-5q5vz6w3.js +14 -0
- package/dist/proc-jv4bcyyx.js +33 -0
- package/dist/prompt-v510j04z.js +93 -0
- package/dist/push-4z70h3d8.js +117 -0
- package/dist/push-xzqw218t.js +117 -0
- package/dist/render-488tjnsq.js +22 -0
- package/dist/sync-wc4jpmkj.js +53 -0
- package/dist/targets-hbwxv97d.js +22 -0
- package/dist/test-198w46m4.js +26 -0
- package/dist/toml-zbhtxjh1.js +1062 -0
- package/dist/typecheck-e86e6yg1.js +24 -0
- package/dist/wrangler-0ctx1p3w.js +66 -0
- package/dist/xcode-g44qh2rc.js +60 -0
- package/fastlane/Fastfile +413 -0
- package/fastlane/Gemfile +21 -0
- package/fastlane/Gemfile.lock +275 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.jar +0 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.jar.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.jar.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.jar.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.jar.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.module +64 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.module.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.module.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.module.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.module.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.pom +12 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.pom.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.pom.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.pom.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/0.1.0/kit-plugins-0.1.0.pom.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/maven-metadata.xml +13 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/maven-metadata.xml.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/maven-metadata.xml.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/maven-metadata.xml.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-plugins/maven-metadata.xml.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.jar +0 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.jar.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.jar.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.jar.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.jar.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.module +64 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.module.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.module.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.module.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.module.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.pom +12 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.pom.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.pom.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.pom.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/0.1.0/kit-settings-0.1.0.pom.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/maven-metadata.xml +13 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/maven-metadata.xml.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/maven-metadata.xml.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/maven-metadata.xml.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/kit-settings/maven-metadata.xml.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/0.1.0/io.github.jordond.kit.release.gradle.plugin-0.1.0.pom +15 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/0.1.0/io.github.jordond.kit.release.gradle.plugin-0.1.0.pom.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/0.1.0/io.github.jordond.kit.release.gradle.plugin-0.1.0.pom.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/0.1.0/io.github.jordond.kit.release.gradle.plugin-0.1.0.pom.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/0.1.0/io.github.jordond.kit.release.gradle.plugin-0.1.0.pom.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/maven-metadata.xml +13 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/maven-metadata.xml.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/maven-metadata.xml.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/maven-metadata.xml.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/release/io.github.jordond.kit.release.gradle.plugin/maven-metadata.xml.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/0.1.0/io.github.jordond.kit.settings.gradle.plugin-0.1.0.pom +15 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/0.1.0/io.github.jordond.kit.settings.gradle.plugin-0.1.0.pom.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/0.1.0/io.github.jordond.kit.settings.gradle.plugin-0.1.0.pom.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/0.1.0/io.github.jordond.kit.settings.gradle.plugin-0.1.0.pom.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/0.1.0/io.github.jordond.kit.settings.gradle.plugin-0.1.0.pom.sha512 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/maven-metadata.xml +13 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/maven-metadata.xml.md5 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/maven-metadata.xml.sha1 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/maven-metadata.xml.sha256 +1 -0
- package/gradle/maven/io/github/jordond/kit/settings/io.github.jordond.kit.settings.gradle.plugin/maven-metadata.xml.sha512 +1 -0
- package/package.json +58 -4
- package/templates/lefthook.yml +6 -0
- package/templates/mise.toml +6 -0
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { KitConfigInput } from './config/schema';
|
|
2
|
+
export type { Group, KitCommand, KitContext } from './cli/command';
|
|
3
|
+
export { defineCommand } from './cli/command';
|
|
4
|
+
export type { KitConfig, KitConfigInput } from './config/schema';
|
|
5
|
+
export { onCleanup } from './lib/cleanup';
|
|
6
|
+
export { ExitCode, KitError } from './lib/errors';
|
|
7
|
+
export { addChildEnv, ProcError, run, runCapture, runInteractive, runLines, runOrThrow, runQuiet, } from './lib/proc';
|
|
8
|
+
export { commandStep, runSteps, type Step, type StepGroup, type StepResult } from './lib/steps';
|
|
9
|
+
/** Typed identity helper for `kit.config.ts`. Validation happens when kit loads the file. */
|
|
10
|
+
export declare function defineConfig(config: KitConfigInput): KitConfigInput;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
commandStep,
|
|
4
|
+
runSteps
|
|
5
|
+
} from "./cli-h974q2wr.js";
|
|
6
|
+
import {
|
|
7
|
+
ProcError,
|
|
8
|
+
addChildEnv,
|
|
9
|
+
run,
|
|
10
|
+
runCapture,
|
|
11
|
+
runInteractive,
|
|
12
|
+
runLines,
|
|
13
|
+
runOrThrow,
|
|
14
|
+
runQuiet
|
|
15
|
+
} from "./cli-fqfan92n.js";
|
|
16
|
+
import {
|
|
17
|
+
onCleanup
|
|
18
|
+
} from "./cli-fqxtcj42.js";
|
|
19
|
+
import {
|
|
20
|
+
defineCommand
|
|
21
|
+
} from "./cli-6dxp4v3m.js";
|
|
22
|
+
import"./cli-07t28k94.js";
|
|
23
|
+
import"./cli-5wasc5mr.js";
|
|
24
|
+
import {
|
|
25
|
+
ExitCode,
|
|
26
|
+
KitError
|
|
27
|
+
} from "./cli-7wvrehng.js";
|
|
28
|
+
import"./cli-re3ntm60.js";
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
function defineConfig(config) {
|
|
32
|
+
return config;
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
runSteps,
|
|
36
|
+
runQuiet,
|
|
37
|
+
runOrThrow,
|
|
38
|
+
runLines,
|
|
39
|
+
runInteractive,
|
|
40
|
+
runCapture,
|
|
41
|
+
run,
|
|
42
|
+
onCleanup,
|
|
43
|
+
defineConfig,
|
|
44
|
+
defineCommand,
|
|
45
|
+
commandStep,
|
|
46
|
+
addChildEnv,
|
|
47
|
+
ProcError,
|
|
48
|
+
KitError,
|
|
49
|
+
ExitCode
|
|
50
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
defineCommand
|
|
4
|
+
} from "./cli-6dxp4v3m.js";
|
|
5
|
+
import"./cli-07t28k94.js";
|
|
6
|
+
import"./cli-5wasc5mr.js";
|
|
7
|
+
import"./cli-7wvrehng.js";
|
|
8
|
+
import {
|
|
9
|
+
__require
|
|
10
|
+
} from "./cli-re3ntm60.js";
|
|
11
|
+
|
|
12
|
+
// src/commands/env/init.ts
|
|
13
|
+
var init_default = defineCommand({
|
|
14
|
+
description: "Create .env from .env.example and ask for missing required keys",
|
|
15
|
+
group: "Infra",
|
|
16
|
+
examples: `kit env init
|
|
17
|
+
kit env init --dry-run`,
|
|
18
|
+
async run(ctx) {
|
|
19
|
+
const { requireProject } = await import("./command-gazq4bmt.js");
|
|
20
|
+
const { loadEnv, assertValid } = await import("./load-5qzs1c6b.js");
|
|
21
|
+
const { planInit, applyInit } = await import("./init-dk5sym9w.js");
|
|
22
|
+
const { outputs, writeOutputs } = await import("./render-488tjnsq.js");
|
|
23
|
+
const { password, text } = await import("./prompt-v510j04z.js");
|
|
24
|
+
const { emitJson } = await import("./log-hhspqwjw.js");
|
|
25
|
+
const { root, config } = requireProject(ctx);
|
|
26
|
+
const { schema } = await loadEnv(root, config);
|
|
27
|
+
const plan = planInit(root, schema);
|
|
28
|
+
if (ctx.flags.dryRun) {
|
|
29
|
+
const summary = { created: plan.created, backfilled: plan.backfilled, ask: plan.ask.map((k) => k.name) };
|
|
30
|
+
if (ctx.flags.json)
|
|
31
|
+
emitJson({ dryRun: true, ...summary });
|
|
32
|
+
else {
|
|
33
|
+
if (plan.created)
|
|
34
|
+
ctx.log.step("would create .env");
|
|
35
|
+
if (plan.backfilled.length)
|
|
36
|
+
ctx.log.step(`would backfill: ${plan.backfilled.join(", ")}`);
|
|
37
|
+
if (plan.ask.length)
|
|
38
|
+
ctx.log.step(`would ask for: ${summary.ask.join(", ")}`);
|
|
39
|
+
if (!plan.created && !plan.backfilled.length && !plan.ask.length)
|
|
40
|
+
ctx.log.success(".env complete");
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const answers = {};
|
|
45
|
+
const required = (v) => v.trim() ? undefined : "Required";
|
|
46
|
+
for (const key of plan.ask) {
|
|
47
|
+
const message = key.description ? `${key.name} (${key.description})` : key.name;
|
|
48
|
+
const hint = `Set ${key.name} in .env`;
|
|
49
|
+
answers[key.name] = key.secret ? await password(ctx.flags, message, { hint, validate: required }) : await text(ctx.flags, message, { hint, validate: required });
|
|
50
|
+
}
|
|
51
|
+
const parsed = applyInit(root, plan, answers);
|
|
52
|
+
if (!ctx.flags.json) {
|
|
53
|
+
if (plan.created)
|
|
54
|
+
ctx.log.success("created .env");
|
|
55
|
+
if (plan.backfilled.length)
|
|
56
|
+
ctx.log.success(`backfilled ${plan.backfilled.join(", ")}`);
|
|
57
|
+
if (plan.ask.length)
|
|
58
|
+
ctx.log.success(`set ${plan.ask.map((k) => k.name).join(", ")}`);
|
|
59
|
+
}
|
|
60
|
+
const state = await loadEnv(root, config, { ...process.env, ...parsed });
|
|
61
|
+
assertValid(state);
|
|
62
|
+
const written = writeOutputs(root, outputs(config, state.schema), state.values).filter((r) => r.changed);
|
|
63
|
+
if (ctx.flags.json) {
|
|
64
|
+
emitJson({
|
|
65
|
+
created: plan.created,
|
|
66
|
+
backfilled: plan.backfilled,
|
|
67
|
+
set: plan.ask.map((k) => k.name),
|
|
68
|
+
outputs: written.map((r) => r.path)
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
for (const r of written)
|
|
73
|
+
ctx.log.success(`wrote ${r.path}`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
export {
|
|
77
|
+
init_default as default
|
|
78
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
parseDotenv,
|
|
4
|
+
writeAtomic
|
|
5
|
+
} from "./cli-rds33bnp.js";
|
|
6
|
+
import"./cli-re3ntm60.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/env/init.ts
|
|
9
|
+
import { existsSync, readFileSync } from "fs";
|
|
10
|
+
import { join } from "path";
|
|
11
|
+
var PLACEHOLDER_RE = /^replace-me/;
|
|
12
|
+
function setKey(text, key, value) {
|
|
13
|
+
const lines = text.split(`
|
|
14
|
+
`);
|
|
15
|
+
let replaced = false;
|
|
16
|
+
const next = lines.map((line) => {
|
|
17
|
+
const trimmed = line.trim();
|
|
18
|
+
if (trimmed.startsWith("#") || !trimmed.includes("="))
|
|
19
|
+
return line;
|
|
20
|
+
const k = trimmed.slice(0, trimmed.indexOf("=")).replace(/^export\s+/, "").trim();
|
|
21
|
+
if (k !== key)
|
|
22
|
+
return line;
|
|
23
|
+
replaced = true;
|
|
24
|
+
return `${key}=${value}`;
|
|
25
|
+
});
|
|
26
|
+
if (!replaced) {
|
|
27
|
+
if (next.length && next[next.length - 1] === "")
|
|
28
|
+
next.splice(next.length - 1, 0, `${key}=${value}`);
|
|
29
|
+
else
|
|
30
|
+
next.push(`${key}=${value}`);
|
|
31
|
+
}
|
|
32
|
+
return next.join(`
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
function planInit(root, schema) {
|
|
36
|
+
const envPath = join(root, ".env");
|
|
37
|
+
const examplePath = join(root, ".env.example");
|
|
38
|
+
const example = existsSync(examplePath) ? readFileSync(examplePath, "utf8") : null;
|
|
39
|
+
const created = !existsSync(envPath);
|
|
40
|
+
let text = created ? example ?? "" : readFileSync(envPath, "utf8");
|
|
41
|
+
const parsed = parseDotenv(text);
|
|
42
|
+
const backfilled = [];
|
|
43
|
+
if (example !== null && !created) {
|
|
44
|
+
for (const [k, v] of Object.entries(parseDotenv(example))) {
|
|
45
|
+
if (k in parsed)
|
|
46
|
+
continue;
|
|
47
|
+
text = setKey(text, k, v);
|
|
48
|
+
parsed[k] = v;
|
|
49
|
+
backfilled.push(k);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const ask = schema.keys.filter((k) => {
|
|
53
|
+
if (!k.required)
|
|
54
|
+
return false;
|
|
55
|
+
const current = parsed[k.name] ?? "";
|
|
56
|
+
return current === "" || PLACEHOLDER_RE.test(current);
|
|
57
|
+
});
|
|
58
|
+
return { created, backfilled, ask, text };
|
|
59
|
+
}
|
|
60
|
+
function applyInit(root, plan, answers) {
|
|
61
|
+
let text = plan.text;
|
|
62
|
+
for (const [k, v] of Object.entries(answers))
|
|
63
|
+
text = setKey(text, k, v);
|
|
64
|
+
if (text && !text.endsWith(`
|
|
65
|
+
`))
|
|
66
|
+
text += `
|
|
67
|
+
`;
|
|
68
|
+
writeAtomic(join(root, ".env"), text);
|
|
69
|
+
return parseDotenv(text);
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
setKey,
|
|
73
|
+
planInit,
|
|
74
|
+
applyInit,
|
|
75
|
+
PLACEHOLDER_RE
|
|
76
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
defineCommand
|
|
4
|
+
} from "./cli-6dxp4v3m.js";
|
|
5
|
+
import"./cli-07t28k94.js";
|
|
6
|
+
import"./cli-5wasc5mr.js";
|
|
7
|
+
import"./cli-7wvrehng.js";
|
|
8
|
+
import {
|
|
9
|
+
__require,
|
|
10
|
+
__toESM
|
|
11
|
+
} from "./cli-re3ntm60.js";
|
|
12
|
+
|
|
13
|
+
// src/commands/init.ts
|
|
14
|
+
import { existsSync, readFileSync } from "fs";
|
|
15
|
+
import { dirname, join } from "path";
|
|
16
|
+
var SCAFFOLDS = {
|
|
17
|
+
mise: { file: "mise.toml", alt: [".mise.toml"], template: "mise.toml" },
|
|
18
|
+
lefthook: { file: "lefthook.yml", alt: ["lefthook.yaml", ".lefthook.yml"], template: "lefthook.yml" }
|
|
19
|
+
};
|
|
20
|
+
var WRANGLER_CONFIGS = ["wrangler.jsonc", "wrangler.json", "wrangler.toml"];
|
|
21
|
+
function planInit(s) {
|
|
22
|
+
const plan = [];
|
|
23
|
+
if (!s.exists(".env.example"))
|
|
24
|
+
plan.push({ kind: "skip", title: ".env", reason: "no .env.example" });
|
|
25
|
+
else if (s.exists(".env"))
|
|
26
|
+
plan.push({ kind: "skip", title: ".env", reason: "already exists" });
|
|
27
|
+
else
|
|
28
|
+
plan.push({ kind: "env-file", title: ".env from .env.example" });
|
|
29
|
+
if (s.exists("package.json")) {
|
|
30
|
+
plan.push({ kind: "cmd", title: `${s.pm} install`, cmd: [s.pm, "install"], cwd: s.root });
|
|
31
|
+
} else
|
|
32
|
+
plan.push({ kind: "skip", title: "install", reason: "no package.json" });
|
|
33
|
+
for (const name of Object.keys(SCAFFOLDS)) {
|
|
34
|
+
const { file, alt } = SCAFFOLDS[name];
|
|
35
|
+
const title = file;
|
|
36
|
+
const present = [file, ...alt].find((f) => s.exists(f));
|
|
37
|
+
if (present)
|
|
38
|
+
plan.push({ kind: "skip", title, reason: `${present} exists` });
|
|
39
|
+
else if (s.accepted.includes(name))
|
|
40
|
+
plan.push({ kind: "scaffold", title, scaffold: name });
|
|
41
|
+
else
|
|
42
|
+
plan.push({ kind: "skip", title, reason: s.declinedReason ?? "declined" });
|
|
43
|
+
}
|
|
44
|
+
if (s.config?.env) {
|
|
45
|
+
plan.push({
|
|
46
|
+
kind: "cmd",
|
|
47
|
+
title: "kit env sync",
|
|
48
|
+
cmd: [...s.self, "env", "sync"],
|
|
49
|
+
cwd: s.root,
|
|
50
|
+
env: { KIT_ROOT: s.root }
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
for (const [name, t] of Object.entries(s.config?.targets ?? {})) {
|
|
54
|
+
if (t.kind !== "worker")
|
|
55
|
+
continue;
|
|
56
|
+
if (!WRANGLER_CONFIGS.some((f) => s.exists(join(t.dir, f))))
|
|
57
|
+
continue;
|
|
58
|
+
const cwd = join(s.root, t.dir);
|
|
59
|
+
plan.push({ kind: "cmd", title: `wrangler types (${name})`, cmd: s.exec(cwd, "wrangler", "types"), cwd });
|
|
60
|
+
}
|
|
61
|
+
return plan;
|
|
62
|
+
}
|
|
63
|
+
function kitPackageRoot(from = import.meta.dir) {
|
|
64
|
+
let dir = from;
|
|
65
|
+
while (true) {
|
|
66
|
+
const pkg = join(dir, "package.json");
|
|
67
|
+
if (existsSync(pkg) && JSON.parse(readFileSync(pkg, "utf8")).name === "@jordond/kit")
|
|
68
|
+
return dir;
|
|
69
|
+
const parent = dirname(dir);
|
|
70
|
+
if (parent === dir)
|
|
71
|
+
throw new Error("kit package root not found");
|
|
72
|
+
dir = parent;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function renderTemplate(text, vars) {
|
|
76
|
+
return text.replace(/\{\{(\w+)\}\}/g, (m, k) => vars[k] ?? m);
|
|
77
|
+
}
|
|
78
|
+
var init_default = defineCommand({
|
|
79
|
+
description: "Set up a fresh clone: .env, install, optional mise/lefthook, env sync, wrangler types",
|
|
80
|
+
group: "Setup",
|
|
81
|
+
examples: `kit init
|
|
82
|
+
kit init --dry-run
|
|
83
|
+
kit init --yes # also scaffold mise.toml and lefthook.yml`,
|
|
84
|
+
async run(ctx) {
|
|
85
|
+
const { chmodSync, writeFileSync } = await import("fs");
|
|
86
|
+
const { relative } = await import("path");
|
|
87
|
+
const pc = (await import("./picocolors-0dxagz5d.js").then((m)=>__toESM(m.default,1))).default;
|
|
88
|
+
const { emitJson } = await import("./log-hhspqwjw.js");
|
|
89
|
+
const { detectPackageManager, pmExec } = await import("./pm-5q5vz6w3.js");
|
|
90
|
+
const { run, runQuiet } = await import("./proc-jv4bcyyx.js");
|
|
91
|
+
const { confirm } = await import("./prompt-v510j04z.js");
|
|
92
|
+
const root = ctx.root ?? process.cwd();
|
|
93
|
+
const exists = (p) => existsSync(join(root, p));
|
|
94
|
+
const pm = detectPackageManager(root, root);
|
|
95
|
+
const missing = Object.keys(SCAFFOLDS).filter((n) => [SCAFFOLDS[n].file, ...SCAFFOLDS[n].alt].every((f) => !exists(f)));
|
|
96
|
+
const accepted = [];
|
|
97
|
+
let declinedReason;
|
|
98
|
+
if (ctx.flags.yes)
|
|
99
|
+
accepted.push(...missing);
|
|
100
|
+
else if (!ctx.flags.interactive)
|
|
101
|
+
declinedReason = "no terminal; re-run with --yes to add it";
|
|
102
|
+
else if (ctx.flags.dryRun)
|
|
103
|
+
declinedReason = "would ask";
|
|
104
|
+
else {
|
|
105
|
+
for (const n of missing) {
|
|
106
|
+
if (await confirm(ctx.flags, `Add ${SCAFFOLDS[n].file}?`, { initial: true }))
|
|
107
|
+
accepted.push(n);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const plan = planInit({
|
|
111
|
+
root,
|
|
112
|
+
config: ctx.config,
|
|
113
|
+
exists,
|
|
114
|
+
pm,
|
|
115
|
+
accepted,
|
|
116
|
+
declinedReason,
|
|
117
|
+
self: [process.execPath, "--no-env-file", process.argv[1]],
|
|
118
|
+
exec: (cwd, bin, ...args) => pmExec(detectPackageManager(cwd, root), bin, ...args)
|
|
119
|
+
});
|
|
120
|
+
const where = (cwd) => relative(root, cwd) || ".";
|
|
121
|
+
if (ctx.flags.dryRun) {
|
|
122
|
+
if (ctx.flags.json) {
|
|
123
|
+
emitJson({
|
|
124
|
+
plan: plan.map((a) => a.kind === "cmd" ? { kind: a.kind, title: a.title, cmd: a.cmd, cwd: where(a.cwd) } : a)
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
for (const a of plan) {
|
|
129
|
+
if (a.kind === "skip")
|
|
130
|
+
ctx.log.dim(`- ${a.title} ${a.reason}`);
|
|
131
|
+
else if (a.kind === "cmd")
|
|
132
|
+
ctx.log.step(`${a.title} ${pc.dim(`${where(a.cwd)} $ ${a.cmd.join(" ")}`)}`);
|
|
133
|
+
else
|
|
134
|
+
ctx.log.step(a.kind === "scaffold" ? `write ${a.title}` : `create ${a.title}`);
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const results = [];
|
|
139
|
+
const kitRoot = ctx.flags.json ? undefined : kitPackageRoot();
|
|
140
|
+
for (const a of plan) {
|
|
141
|
+
if (a.kind === "skip") {
|
|
142
|
+
if (!ctx.flags.json)
|
|
143
|
+
ctx.log.dim(`- ${a.title} ${a.reason}`);
|
|
144
|
+
results.push({ title: a.title, ok: true, skipped: a.reason });
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (!ctx.flags.json)
|
|
148
|
+
ctx.log.step(a.title);
|
|
149
|
+
let ok = true;
|
|
150
|
+
if (a.kind === "env-file") {
|
|
151
|
+
const dotenv = join(root, ".env");
|
|
152
|
+
writeFileSync(dotenv, readFileSync(join(root, ".env.example")), { mode: 384 });
|
|
153
|
+
chmodSync(dotenv, 384);
|
|
154
|
+
if (!ctx.flags.json)
|
|
155
|
+
ctx.log.dim(" fill in the values, then run `kit doctor`");
|
|
156
|
+
} else if (a.kind === "scaffold") {
|
|
157
|
+
const { file, template } = SCAFFOLDS[a.scaffold];
|
|
158
|
+
const text = readFileSync(join(kitRoot ?? kitPackageRoot(), "templates", template), "utf8");
|
|
159
|
+
writeFileSync(join(root, file), renderTemplate(text, { bun: Bun.version }));
|
|
160
|
+
} else {
|
|
161
|
+
const code = ctx.flags.json ? (await runQuiet(a.cmd, { cwd: a.cwd, env: a.env })).code : await run(a.cmd, { cwd: a.cwd, env: a.env });
|
|
162
|
+
ok = code === 0;
|
|
163
|
+
if (!ok && !ctx.flags.json)
|
|
164
|
+
ctx.log.error(`${a.title} failed (exit ${code})`);
|
|
165
|
+
}
|
|
166
|
+
results.push({ title: a.title, ok });
|
|
167
|
+
}
|
|
168
|
+
const failed = results.filter((r) => !r.ok).map((r) => r.title);
|
|
169
|
+
if (ctx.flags.json)
|
|
170
|
+
emitJson({ ok: !failed.length, steps: results });
|
|
171
|
+
else if (failed.length)
|
|
172
|
+
ctx.log.error(`init failed: ${failed.join(", ")}`);
|
|
173
|
+
else
|
|
174
|
+
ctx.log.success("init complete");
|
|
175
|
+
if (failed.length)
|
|
176
|
+
process.exitCode = 1;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
export {
|
|
180
|
+
renderTemplate,
|
|
181
|
+
planInit,
|
|
182
|
+
kitPackageRoot,
|
|
183
|
+
init_default as default,
|
|
184
|
+
SCAFFOLDS
|
|
185
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
defineCommand
|
|
4
|
+
} from "./cli-6dxp4v3m.js";
|
|
5
|
+
import"./cli-07t28k94.js";
|
|
6
|
+
import"./cli-5wasc5mr.js";
|
|
7
|
+
import"./cli-7wvrehng.js";
|
|
8
|
+
import"./cli-re3ntm60.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/release/ios.ts
|
|
11
|
+
var ios_default = defineCommand({
|
|
12
|
+
description: "Build and upload iOS to a track",
|
|
13
|
+
group: "Release",
|
|
14
|
+
args: {
|
|
15
|
+
track: {
|
|
16
|
+
type: "enum",
|
|
17
|
+
choices: ["internal", "alpha", "beta", "prod"],
|
|
18
|
+
required: true,
|
|
19
|
+
description: "Store track"
|
|
20
|
+
},
|
|
21
|
+
build: { type: "number", description: "Override the store build number" }
|
|
22
|
+
},
|
|
23
|
+
examples: `kit release ios --track beta
|
|
24
|
+
kit release ios --track internal --dry-run`,
|
|
25
|
+
run(ctx) {
|
|
26
|
+
ctx.log.step(`release ios \u2192 ${ctx.args.track}${ctx.flags.dryRun ? " (dry run)" : ""}`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
ios_default as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Subprocess } from 'bun';
|
|
2
|
+
/**
|
|
3
|
+
* Process-wide cleanup and interrupt handling.
|
|
4
|
+
*
|
|
5
|
+
* - `onCleanup(fn)` registers work that must run however kit exits (temp secrets, restoring the tty).
|
|
6
|
+
* - Running children are tracked so an interrupt can reach them.
|
|
7
|
+
* - First Ctrl-C: SIGINT reaches every child's process tree, kit waits for them and exits 130.
|
|
8
|
+
* With no child running it exits at once.
|
|
9
|
+
* - Second Ctrl-C: SIGKILL every child, run cleanup, exit 130.
|
|
10
|
+
* - SIGTERM and SIGHUP are forwarded to children (detached ones are in their own session).
|
|
11
|
+
*/
|
|
12
|
+
type Fn = () => void | Promise<void>;
|
|
13
|
+
export declare function onCleanup(fn: Fn): () => void;
|
|
14
|
+
export declare function runCleanup(): Promise<void>;
|
|
15
|
+
/** True once the user pressed Ctrl-C. Commands that loop should stop. */
|
|
16
|
+
export declare const interrupted: () => boolean;
|
|
17
|
+
export declare function trackChild(proc: Subprocess, group?: boolean): void;
|
|
18
|
+
export declare function installSignalHandlers(): void;
|
|
19
|
+
/** Test seam. */
|
|
20
|
+
export declare function resetInterrupts(): void;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { KitContext } from '../cli/command';
|
|
2
|
+
import type { KitConfig } from '../config/schema';
|
|
3
|
+
import { type PipeResult } from './secrets';
|
|
4
|
+
/**
|
|
5
|
+
* Cloudflare helpers (ported from brewd `lib/cloudflare-account.ts`, `lib/d1.ts`, `commands/db.ts`).
|
|
6
|
+
*
|
|
7
|
+
* Account pinning: wrangler reads the ambient CLOUDFLARE_ACCOUNT_ID for d1, r2 and secret, and only
|
|
8
|
+
* falls back to wrangler.jsonc for deploy and dev. kit's `.env` loading does not override a variable
|
|
9
|
+
* the shell already exports, so an id left over from another project would silently retarget those
|
|
10
|
+
* commands at the wrong account (a d1 execute against someone else's database). The pin rides on
|
|
11
|
+
* every spawn via `addChildEnv`: Bun.spawn snapshots the env kit started with, so mutating
|
|
12
|
+
* `process.env` would reach no child.
|
|
13
|
+
*/
|
|
14
|
+
export declare const WRANGLER_FILES: readonly ['wrangler.jsonc', 'wrangler.json', 'wrangler.toml'];
|
|
15
|
+
/** JSONC → JSON text: drops `//` and block comments outside strings, then trailing commas. */
|
|
16
|
+
export declare function stripJsonc(text: string): string;
|
|
17
|
+
/** Top-level `account_id` from the wrangler config in `dir`, or undefined when there is none. */
|
|
18
|
+
export declare function readAccountId(dir: string): {
|
|
19
|
+
id?: string;
|
|
20
|
+
file?: string;
|
|
21
|
+
};
|
|
22
|
+
/** The target whose wrangler config holds the account: any `cloudflare.d1` entry's, else the first worker. */
|
|
23
|
+
export declare function accountTarget(config: KitConfig): string | undefined;
|
|
24
|
+
/** `cloudflare.accountId` resolved: a literal id, or read from wrangler config. Undefined when unset. */
|
|
25
|
+
export declare function resolveAccountId(root: string, config: KitConfig): string | undefined;
|
|
26
|
+
/** Resolve the account and pin it for every later child. Commands that run wrangler call this first. */
|
|
27
|
+
export declare function pinCloudflareAccount(root: string, config: KitConfig): string | undefined;
|
|
28
|
+
export interface WranglerCommand {
|
|
29
|
+
cmd: string[];
|
|
30
|
+
cwd: string;
|
|
31
|
+
}
|
|
32
|
+
/** `wrangler …` from a target's dir, through its package manager (`bun x wrangler`). */
|
|
33
|
+
export declare function wrangler(root: string, config: KitConfig, target: string, ...args: string[]): WranglerCommand;
|
|
34
|
+
/** `wrangler secret put <key>` with the value on stdin. */
|
|
35
|
+
export declare function wranglerSecretPut(w: WranglerCommand, value: string): Promise<PipeResult>;
|
|
36
|
+
/** Names from `wrangler secret list --format json` (`[{ name, type }]`); unparseable output → []. */
|
|
37
|
+
export declare function parseSecretNames(stdout: string): string[];
|
|
38
|
+
export interface D1Database {
|
|
39
|
+
/** Key in `cloudflare.d1`. */
|
|
40
|
+
key: string;
|
|
41
|
+
/** Database name wrangler knows. */
|
|
42
|
+
name: string;
|
|
43
|
+
target: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The database for `--db`: a `cloudflare.d1` key or database name. Without `--db` the only one;
|
|
47
|
+
* with several, a usage error listing them.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveD1(config: KitConfig, db: string | undefined): D1Database;
|
|
50
|
+
export declare const locality: (remote: boolean) => string;
|
|
51
|
+
export type D1Action = {
|
|
52
|
+
kind: 'migrate';
|
|
53
|
+
remote: boolean;
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'list';
|
|
56
|
+
remote: boolean;
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'create';
|
|
59
|
+
migration: string;
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'exec';
|
|
62
|
+
remote: boolean;
|
|
63
|
+
sql?: string;
|
|
64
|
+
file?: string;
|
|
65
|
+
json?: boolean;
|
|
66
|
+
};
|
|
67
|
+
/** `wrangler d1 …` args for an action. Wrangler finds `migrations_dir` from its d1_databases entry. */
|
|
68
|
+
export declare function d1Args(db: D1Database, action: D1Action): string[];
|
|
69
|
+
/** Flags every `kit db` command takes. */
|
|
70
|
+
export declare const dbArgs: {
|
|
71
|
+
readonly db: {
|
|
72
|
+
readonly type: 'string';
|
|
73
|
+
readonly description: 'cloudflare.d1 key or database name (default: the only one)';
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export declare const remoteArg: {
|
|
77
|
+
readonly remote: {
|
|
78
|
+
readonly type: 'boolean';
|
|
79
|
+
readonly description: 'Deployed D1 (default: local)';
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Body of `kit db …`: resolve the database, pin the account, print the plan on --dry-run, confirm
|
|
84
|
+
* remote mutations, run wrangler from the database's target dir with inherited stdio (wrangler's own
|
|
85
|
+
* "apply N migrations?" prompt works). `--json` captures wrangler's output into one document, except
|
|
86
|
+
* `exec`, where wrangler's `--json` result is the document.
|
|
87
|
+
*/
|
|
88
|
+
export declare function runD1(ctx: Pick<KitContext, 'root' | 'config' | 'flags' | 'log'> & {
|
|
89
|
+
args: {
|
|
90
|
+
db?: string;
|
|
91
|
+
};
|
|
92
|
+
}, action: D1Action, opts: {
|
|
93
|
+
mutates: boolean;
|
|
94
|
+
}): Promise<void>;
|
|
95
|
+
/** SQLite string literal (doubles embedded `'`). Values go to wrangler as one argv element, never a shell. */
|
|
96
|
+
export declare function sqlString(value: string): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EnvKey, EnvSchema } from './schema';
|
|
2
|
+
/**
|
|
3
|
+
* `kit env init` (ported from WhaleSay `env/init.ts`): create `.env` from `.env.example`, backfill
|
|
4
|
+
* keys the example gained since, then ask for required keys that are empty or still a
|
|
5
|
+
* `replace-me…` placeholder. Optional keys are never asked. Values are only ever written to `.env`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PLACEHOLDER_RE: RegExp;
|
|
8
|
+
/** Replace `KEY=…` in place, or append it. Comments and other lines are kept. */
|
|
9
|
+
export declare function setKey(text: string, key: string, value: string): string;
|
|
10
|
+
export interface InitPlan {
|
|
11
|
+
/** `.env` did not exist; it starts as a copy of `.env.example` (or empty). */
|
|
12
|
+
created: boolean;
|
|
13
|
+
/** Keys copied from `.env.example` that `.env` lacked. */
|
|
14
|
+
backfilled: string[];
|
|
15
|
+
/** Required keys that are empty or placeholders. */
|
|
16
|
+
ask: EnvKey[];
|
|
17
|
+
/** `.env` text after copy and backfill, before answers. */
|
|
18
|
+
text: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function planInit(root: string, schema: EnvSchema): InitPlan;
|
|
21
|
+
/** Apply answers and write `.env` (0600). Returns the parsed result. */
|
|
22
|
+
export declare function applyInit(root: string, plan: InitPlan, answers: Record<string, string>): Record<string, string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { KitConfig } from '../../config/schema';
|
|
2
|
+
import { type EnvIssue, type EnvSchema, type EnvValues } from './schema';
|
|
3
|
+
/** What every `kit env` command starts from: the schema and `.env` validated against it. */
|
|
4
|
+
export interface EnvState {
|
|
5
|
+
schema: EnvSchema;
|
|
6
|
+
/** `.env` values (kit loaded it into the process env) with schema defaults applied. */
|
|
7
|
+
values: Record<string, string>;
|
|
8
|
+
issues: EnvIssue[];
|
|
9
|
+
}
|
|
10
|
+
export declare function loadEnv(root: string, config: KitConfig, raw?: EnvValues): Promise<EnvState>;
|
|
11
|
+
/** Throw exit 3 listing invalid keys (names and redacted messages only). */
|
|
12
|
+
export declare function assertValid(state: EnvState): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { KitConfig } from '../../config/schema';
|
|
2
|
+
import { type PipeResult } from '../secrets';
|
|
3
|
+
import type { EnvValues } from './schema';
|
|
4
|
+
/**
|
|
5
|
+
* Push secrets to their remotes (ported from brewd `lib/env.ts` pushSecrets/pushGithubSecrets and
|
|
6
|
+
* WhaleSay `_lib/wrangler-push.ts`): `wrangler secret put` per `env.workerSecrets[target]`, and
|
|
7
|
+
* `gh secret set` for `env.githubSecrets`. Values go on stdin, never argv.
|
|
8
|
+
*
|
|
9
|
+
* Split in two so the command can show a summary and confirm once between them:
|
|
10
|
+
* - `planPush` lists what is already set remotely (read-only) and classifies each key.
|
|
11
|
+
* - `executePush` pushes the planned keys and stops at the first failure, so a bad credential
|
|
12
|
+
* doesn't fan out into N identical errors.
|
|
13
|
+
* A remote whose list fails is skipped unless `proceedOnListFailure` (`--yes`): kit can't tell
|
|
14
|
+
* what it would overwrite.
|
|
15
|
+
*/
|
|
16
|
+
export declare const GITHUB = "github";
|
|
17
|
+
export interface ListResult {
|
|
18
|
+
ok: boolean;
|
|
19
|
+
names: string[];
|
|
20
|
+
/** First line of the failure, redacted. */
|
|
21
|
+
error?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Destination {
|
|
24
|
+
/** Target name, or `github`. */
|
|
25
|
+
name: string;
|
|
26
|
+
keys: string[];
|
|
27
|
+
list(): Promise<ListResult>;
|
|
28
|
+
put(key: string, value: string): Promise<PipeResult>;
|
|
29
|
+
}
|
|
30
|
+
export type PlanStatus = 'new' | 'overwrite' | 'unknown' | 'skipped-empty' | 'list-failed';
|
|
31
|
+
export interface PlannedDestination {
|
|
32
|
+
destination: Destination;
|
|
33
|
+
listError?: string;
|
|
34
|
+
items: {
|
|
35
|
+
key: string;
|
|
36
|
+
status: PlanStatus;
|
|
37
|
+
}[];
|
|
38
|
+
}
|
|
39
|
+
export type PushStatus = 'pushed' | 'skipped-empty' | 'list-failed' | 'failed' | 'not-run';
|
|
40
|
+
export interface PushOutcome {
|
|
41
|
+
destination: string;
|
|
42
|
+
key: string;
|
|
43
|
+
status: PushStatus;
|
|
44
|
+
/** Redacted child output on failure. */
|
|
45
|
+
output?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function planPush(dest: Destination, values: EnvValues, opts?: {
|
|
48
|
+
proceedOnListFailure?: boolean;
|
|
49
|
+
}): Promise<PlannedDestination>;
|
|
50
|
+
export declare function executePush(plans: PlannedDestination[], values: EnvValues, onPush?: (dest: string, key: string) => void): Promise<PushOutcome[]>;
|
|
51
|
+
/** A worker target's secrets via wrangler, run from the target's dir. */
|
|
52
|
+
export declare function workerDestination(root: string, config: KitConfig, target: string): Destination;
|
|
53
|
+
/** GitHub Actions secrets via `gh`, run from the repo root (gh infers the repo from its remote). */
|
|
54
|
+
export declare function githubDestination(root: string, keys: string[]): Destination;
|