@mp-lb/arcnet 0.1.0 → 0.2.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 +33 -4
- package/dist/createCli.d.ts.map +1 -1
- package/dist/createCli.js +12 -5
- package/dist/createCli.js.map +1 -1
- package/dist/secrets/assertNewSource.d.ts +3 -0
- package/dist/secrets/assertNewSource.d.ts.map +1 -0
- package/dist/secrets/assertNewSource.js +32 -0
- package/dist/secrets/assertNewSource.js.map +1 -0
- package/dist/secrets/config.d.ts +37 -0
- package/dist/secrets/config.d.ts.map +1 -0
- package/dist/secrets/config.js +67 -0
- package/dist/secrets/config.js.map +1 -0
- package/dist/secrets/createSecretsCommands.d.ts +3 -0
- package/dist/secrets/createSecretsCommands.d.ts.map +1 -0
- package/dist/secrets/createSecretsCommands.js +93 -0
- package/dist/secrets/createSecretsCommands.js.map +1 -0
- package/dist/secrets/loadSecrets.d.ts +3 -0
- package/dist/secrets/loadSecrets.d.ts.map +1 -0
- package/dist/secrets/loadSecrets.js +35 -0
- package/dist/secrets/loadSecrets.js.map +1 -0
- package/dist/secrets/promptPassword.d.ts +2 -0
- package/dist/secrets/promptPassword.d.ts.map +1 -0
- package/dist/secrets/promptPassword.js +42 -0
- package/dist/secrets/promptPassword.js.map +1 -0
- package/dist/secrets/provisionSource.d.ts +25 -0
- package/dist/secrets/provisionSource.d.ts.map +1 -0
- package/dist/secrets/provisionSource.js +141 -0
- package/dist/secrets/provisionSource.js.map +1 -0
- package/dist/secrets/readRemoteSource.d.ts +7 -0
- package/dist/secrets/readRemoteSource.d.ts.map +1 -0
- package/dist/secrets/readRemoteSource.js +32 -0
- package/dist/secrets/readRemoteSource.js.map +1 -0
- package/dist/secrets/runWithSecrets.d.ts +6 -0
- package/dist/secrets/runWithSecrets.d.ts.map +1 -0
- package/dist/secrets/runWithSecrets.js +59 -0
- package/dist/secrets/runWithSecrets.js.map +1 -0
- package/dist/secrets/secretCommand.d.ts +2 -0
- package/dist/secrets/secretCommand.d.ts.map +1 -0
- package/dist/secrets/secretCommand.js +17 -0
- package/dist/secrets/secretCommand.js.map +1 -0
- package/dist/secrets/selectSecrets.d.ts +3 -0
- package/dist/secrets/selectSecrets.d.ts.map +1 -0
- package/dist/secrets/selectSecrets.js +18 -0
- package/dist/secrets/selectSecrets.js.map +1 -0
- package/dist/secrets/syncSecrets.d.ts +10 -0
- package/dist/secrets/syncSecrets.d.ts.map +1 -0
- package/dist/secrets/syncSecrets.js +43 -0
- package/dist/secrets/syncSecrets.js.map +1 -0
- package/dist/secrets/wireSecretsWorkflows.d.ts +2 -0
- package/dist/secrets/wireSecretsWorkflows.d.ts.map +1 -0
- package/dist/secrets/wireSecretsWorkflows.js +48 -0
- package/dist/secrets/wireSecretsWorkflows.js.map +1 -0
- package/dist/secrets/withDeploymentSecrets.d.ts +2 -0
- package/dist/secrets/withDeploymentSecrets.d.ts.map +1 -0
- package/dist/secrets/withDeploymentSecrets.js +58 -0
- package/dist/secrets/withDeploymentSecrets.js.map +1 -0
- package/dist/secrets/writeSecretsWorkflow.d.ts +3 -0
- package/dist/secrets/writeSecretsWorkflow.d.ts.map +1 -0
- package/dist/secrets/writeSecretsWorkflow.js +60 -0
- package/dist/secrets/writeSecretsWorkflow.js.map +1 -0
- package/docs/public/commands.md +74 -0
- package/docs/public/llms-full.txt +107 -4
- package/package.json +2 -1
- package/src/createCli.ts +18 -8
- package/src/secrets/assertNewSource.ts +40 -0
- package/src/secrets/config.ts +91 -0
- package/src/secrets/createSecretsCommands.ts +189 -0
- package/src/secrets/loadSecrets.ts +53 -0
- package/src/secrets/promptPassword.ts +46 -0
- package/src/secrets/provisionSource.ts +238 -0
- package/src/secrets/readRemoteSource.ts +73 -0
- package/src/secrets/runWithSecrets.ts +71 -0
- package/src/secrets/secretCommand.ts +26 -0
- package/src/secrets/selectSecrets.ts +33 -0
- package/src/secrets/syncSecrets.ts +60 -0
- package/src/secrets/wireSecretsWorkflows.ts +57 -0
- package/src/secrets/withDeploymentSecrets.ts +77 -0
- package/src/secrets/writeSecretsWorkflow.ts +83 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { mkdirSync, existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { stringify } from "yaml";
|
|
4
|
+
import { safeTargetPath } from "../safeTargetPath.js";
|
|
5
|
+
import type { SecretsConfig } from "./config.js";
|
|
6
|
+
import { wireSecretsWorkflows } from "./wireSecretsWorkflows.js";
|
|
7
|
+
|
|
8
|
+
export const writeSecretsWorkflow = (
|
|
9
|
+
config: SecretsConfig,
|
|
10
|
+
root: string,
|
|
11
|
+
configFile: string,
|
|
12
|
+
) => {
|
|
13
|
+
const path = safeTargetPath(
|
|
14
|
+
root,
|
|
15
|
+
".github/workflows/validate-arcnet-secrets.yaml",
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const marker =
|
|
19
|
+
"# Generated by arcnet secrets; configure sources in .arcnet/secrets.json.\n";
|
|
20
|
+
|
|
21
|
+
if (existsSync(path) && !readFileSync(path, "utf8").startsWith(marker))
|
|
22
|
+
throw new Error(
|
|
23
|
+
"Existing validate-arcnet-secrets.yaml is not ArcNet-managed; move it before continuing.",
|
|
24
|
+
);
|
|
25
|
+
if (configFile !== ".arcnet/secrets.json")
|
|
26
|
+
throw new Error(
|
|
27
|
+
"Generated CI requires the standard .arcnet/secrets.json location.",
|
|
28
|
+
);
|
|
29
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
30
|
+
|
|
31
|
+
const env = Object.fromEntries(
|
|
32
|
+
config.sources
|
|
33
|
+
.flatMap((source) => [
|
|
34
|
+
source.keyEnv,
|
|
35
|
+
...(!source.snapshot && source.tokenEnv ? [source.tokenEnv] : []),
|
|
36
|
+
])
|
|
37
|
+
.map((key) => [key, `\u0024{{ secrets.${key} }}`]),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
writeFileSync(
|
|
41
|
+
path,
|
|
42
|
+
marker +
|
|
43
|
+
stringify({
|
|
44
|
+
name: "Validate ArcNet secrets",
|
|
45
|
+
on: {
|
|
46
|
+
workflow_dispatch: {},
|
|
47
|
+
push: {
|
|
48
|
+
branches: ["main"],
|
|
49
|
+
paths: [
|
|
50
|
+
".arcnet/**",
|
|
51
|
+
".github/workflows/validate-arcnet-secrets.yaml",
|
|
52
|
+
"package.json",
|
|
53
|
+
"pnpm-lock.yaml",
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
permissions: { contents: "read" },
|
|
58
|
+
jobs: {
|
|
59
|
+
validate: {
|
|
60
|
+
if: `github.repository == '${config.repository}' && github.ref == 'refs/heads/main'`,
|
|
61
|
+
"runs-on": "ubuntu-latest",
|
|
62
|
+
"timeout-minutes": 10,
|
|
63
|
+
steps: [
|
|
64
|
+
{
|
|
65
|
+
uses: "actions/checkout@v4",
|
|
66
|
+
with: { "persist-credentials": false },
|
|
67
|
+
},
|
|
68
|
+
{ uses: "pnpm/action-setup@v4" },
|
|
69
|
+
{ uses: "actions/setup-node@v4", with: { "node-version": 22 } },
|
|
70
|
+
{ run: "pnpm install --frozen-lockfile --ignore-scripts" },
|
|
71
|
+
{
|
|
72
|
+
name: "Decrypt, merge and validate selected keys",
|
|
73
|
+
run: "pnpm exec arcnet env check",
|
|
74
|
+
env,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
wireSecretsWorkflows(dirname(path), env);
|
|
83
|
+
};
|