@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.
Files changed (78) hide show
  1. package/README.md +33 -4
  2. package/dist/createCli.d.ts.map +1 -1
  3. package/dist/createCli.js +12 -5
  4. package/dist/createCli.js.map +1 -1
  5. package/dist/secrets/assertNewSource.d.ts +3 -0
  6. package/dist/secrets/assertNewSource.d.ts.map +1 -0
  7. package/dist/secrets/assertNewSource.js +32 -0
  8. package/dist/secrets/assertNewSource.js.map +1 -0
  9. package/dist/secrets/config.d.ts +37 -0
  10. package/dist/secrets/config.d.ts.map +1 -0
  11. package/dist/secrets/config.js +67 -0
  12. package/dist/secrets/config.js.map +1 -0
  13. package/dist/secrets/createSecretsCommands.d.ts +3 -0
  14. package/dist/secrets/createSecretsCommands.d.ts.map +1 -0
  15. package/dist/secrets/createSecretsCommands.js +93 -0
  16. package/dist/secrets/createSecretsCommands.js.map +1 -0
  17. package/dist/secrets/loadSecrets.d.ts +3 -0
  18. package/dist/secrets/loadSecrets.d.ts.map +1 -0
  19. package/dist/secrets/loadSecrets.js +35 -0
  20. package/dist/secrets/loadSecrets.js.map +1 -0
  21. package/dist/secrets/promptPassword.d.ts +2 -0
  22. package/dist/secrets/promptPassword.d.ts.map +1 -0
  23. package/dist/secrets/promptPassword.js +42 -0
  24. package/dist/secrets/promptPassword.js.map +1 -0
  25. package/dist/secrets/provisionSource.d.ts +25 -0
  26. package/dist/secrets/provisionSource.d.ts.map +1 -0
  27. package/dist/secrets/provisionSource.js +141 -0
  28. package/dist/secrets/provisionSource.js.map +1 -0
  29. package/dist/secrets/readRemoteSource.d.ts +7 -0
  30. package/dist/secrets/readRemoteSource.d.ts.map +1 -0
  31. package/dist/secrets/readRemoteSource.js +32 -0
  32. package/dist/secrets/readRemoteSource.js.map +1 -0
  33. package/dist/secrets/runWithSecrets.d.ts +6 -0
  34. package/dist/secrets/runWithSecrets.d.ts.map +1 -0
  35. package/dist/secrets/runWithSecrets.js +59 -0
  36. package/dist/secrets/runWithSecrets.js.map +1 -0
  37. package/dist/secrets/secretCommand.d.ts +2 -0
  38. package/dist/secrets/secretCommand.d.ts.map +1 -0
  39. package/dist/secrets/secretCommand.js +17 -0
  40. package/dist/secrets/secretCommand.js.map +1 -0
  41. package/dist/secrets/selectSecrets.d.ts +3 -0
  42. package/dist/secrets/selectSecrets.d.ts.map +1 -0
  43. package/dist/secrets/selectSecrets.js +18 -0
  44. package/dist/secrets/selectSecrets.js.map +1 -0
  45. package/dist/secrets/syncSecrets.d.ts +10 -0
  46. package/dist/secrets/syncSecrets.d.ts.map +1 -0
  47. package/dist/secrets/syncSecrets.js +43 -0
  48. package/dist/secrets/syncSecrets.js.map +1 -0
  49. package/dist/secrets/wireSecretsWorkflows.d.ts +2 -0
  50. package/dist/secrets/wireSecretsWorkflows.d.ts.map +1 -0
  51. package/dist/secrets/wireSecretsWorkflows.js +48 -0
  52. package/dist/secrets/wireSecretsWorkflows.js.map +1 -0
  53. package/dist/secrets/withDeploymentSecrets.d.ts +2 -0
  54. package/dist/secrets/withDeploymentSecrets.d.ts.map +1 -0
  55. package/dist/secrets/withDeploymentSecrets.js +58 -0
  56. package/dist/secrets/withDeploymentSecrets.js.map +1 -0
  57. package/dist/secrets/writeSecretsWorkflow.d.ts +3 -0
  58. package/dist/secrets/writeSecretsWorkflow.d.ts.map +1 -0
  59. package/dist/secrets/writeSecretsWorkflow.js +60 -0
  60. package/dist/secrets/writeSecretsWorkflow.js.map +1 -0
  61. package/docs/public/commands.md +74 -0
  62. package/docs/public/llms-full.txt +107 -4
  63. package/package.json +2 -1
  64. package/src/createCli.ts +18 -8
  65. package/src/secrets/assertNewSource.ts +40 -0
  66. package/src/secrets/config.ts +91 -0
  67. package/src/secrets/createSecretsCommands.ts +189 -0
  68. package/src/secrets/loadSecrets.ts +53 -0
  69. package/src/secrets/promptPassword.ts +46 -0
  70. package/src/secrets/provisionSource.ts +238 -0
  71. package/src/secrets/readRemoteSource.ts +73 -0
  72. package/src/secrets/runWithSecrets.ts +71 -0
  73. package/src/secrets/secretCommand.ts +26 -0
  74. package/src/secrets/selectSecrets.ts +33 -0
  75. package/src/secrets/syncSecrets.ts +60 -0
  76. package/src/secrets/wireSecretsWorkflows.ts +57 -0
  77. package/src/secrets/withDeploymentSecrets.ts +77 -0
  78. 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
+ };