@ozyman42/ozy-cli 0.4.5 → 0.4.6-darwin-arm64.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 (202) hide show
  1. package/multi-call-binary +0 -0
  2. package/package.json +12 -55
  3. package/dist/commands/git/hosts.js +0 -18
  4. package/dist/commands/git/hosts.js.map +0 -1
  5. package/dist/commands/git/index.js +0 -8
  6. package/dist/commands/git/index.js.map +0 -1
  7. package/dist/commands/git/setup.js +0 -145
  8. package/dist/commands/git/setup.js.map +0 -1
  9. package/dist/commands/index.js +0 -13
  10. package/dist/commands/index.js.map +0 -1
  11. package/dist/commands/npm/index.js +0 -7
  12. package/dist/commands/npm/index.js.map +0 -1
  13. package/dist/commands/npm/setup/git-remote.js +0 -66
  14. package/dist/commands/npm/setup/git-remote.js.map +0 -1
  15. package/dist/commands/npm/setup/index.js +0 -168
  16. package/dist/commands/npm/setup/index.js.map +0 -1
  17. package/dist/commands/npm/setup/npm-auth.js +0 -62
  18. package/dist/commands/npm/setup/npm-auth.js.map +0 -1
  19. package/dist/commands/npm/setup/package-json-validate.js +0 -47
  20. package/dist/commands/npm/setup/package-json-validate.js.map +0 -1
  21. package/dist/commands/npm/setup/package-registry.js +0 -20
  22. package/dist/commands/npm/setup/package-registry.js.map +0 -1
  23. package/dist/commands/npm/setup/setup.test.js +0 -95
  24. package/dist/commands/npm/setup/setup.test.js.map +0 -1
  25. package/dist/commands/npm/setup/trusted-publishing.js +0 -84
  26. package/dist/commands/npm/setup/trusted-publishing.js.map +0 -1
  27. package/dist/commands/npm/setup/workflow.js +0 -19
  28. package/dist/commands/npm/setup/workflow.js.map +0 -1
  29. package/dist/commands/ssh/get-sk-credential.js +0 -104
  30. package/dist/commands/ssh/get-sk-credential.js.map +0 -1
  31. package/dist/commands/ssh/index.js +0 -7
  32. package/dist/commands/ssh/index.js.map +0 -1
  33. package/dist/commands/upgrade.js +0 -81
  34. package/dist/commands/upgrade.js.map +0 -1
  35. package/dist/common/command.js +0 -15
  36. package/dist/common/command.js.map +0 -1
  37. package/dist/common/constants.js +0 -24
  38. package/dist/common/constants.js.map +0 -1
  39. package/dist/common/effective-modules-extensions.js +0 -13
  40. package/dist/common/effective-modules-extensions.js.map +0 -1
  41. package/dist/common/log.js +0 -4
  42. package/dist/common/log.js.map +0 -1
  43. package/dist/common/render-caller-tree.js +0 -20
  44. package/dist/common/render-caller-tree.js.map +0 -1
  45. package/dist/entrypoints/ozy-signing-agent.js +0 -48
  46. package/dist/entrypoints/ozy-signing-agent.js.map +0 -1
  47. package/dist/entrypoints/ozy-ssh-keygen.js +0 -9
  48. package/dist/entrypoints/ozy-ssh-keygen.js.map +0 -1
  49. package/dist/entrypoints/ozy-virtual-security-key.js +0 -18
  50. package/dist/entrypoints/ozy-virtual-security-key.js.map +0 -1
  51. package/dist/entrypoints/ozy.js +0 -3
  52. package/dist/entrypoints/ozy.js.map +0 -1
  53. package/dist/index.js +0 -2
  54. package/dist/index.js.map +0 -1
  55. package/dist/internal/thing.js +0 -4
  56. package/dist/internal/thing.js.map +0 -1
  57. package/dist/modules/cli/agent-client/impl.js +0 -109
  58. package/dist/modules/cli/agent-client/impl.js.map +0 -1
  59. package/dist/modules/cli/agent-client/interface.js +0 -11
  60. package/dist/modules/cli/agent-client/interface.js.map +0 -1
  61. package/dist/modules/cli/git/impl.js +0 -124
  62. package/dist/modules/cli/git/impl.js.map +0 -1
  63. package/dist/modules/cli/git/interface.js +0 -3
  64. package/dist/modules/cli/git/interface.js.map +0 -1
  65. package/dist/modules/cli/git/submodule/fix.js +0 -257
  66. package/dist/modules/cli/git/submodule/fix.js.map +0 -1
  67. package/dist/modules/cli/git/submodule/git-state.js +0 -154
  68. package/dist/modules/cli/git/submodule/git-state.js.map +0 -1
  69. package/dist/modules/cli/git/submodule/gitmodules.js +0 -113
  70. package/dist/modules/cli/git/submodule/gitmodules.js.map +0 -1
  71. package/dist/modules/cli/git/submodule/printer.js +0 -232
  72. package/dist/modules/cli/git/submodule/printer.js.map +0 -1
  73. package/dist/modules/cli/git/submodule/resolve-git-dir.js +0 -16
  74. package/dist/modules/cli/git/submodule/resolve-git-dir.js.map +0 -1
  75. package/dist/modules/cli/github/impl.js +0 -137
  76. package/dist/modules/cli/github/impl.js.map +0 -1
  77. package/dist/modules/cli/github/interface.js +0 -2
  78. package/dist/modules/cli/github/interface.js.map +0 -1
  79. package/dist/modules/cli/index.js +0 -9
  80. package/dist/modules/cli/index.js.map +0 -1
  81. package/dist/modules/common/crypto/impl.js +0 -133
  82. package/dist/modules/common/crypto/impl.js.map +0 -1
  83. package/dist/modules/common/crypto/interface.js +0 -2
  84. package/dist/modules/common/crypto/interface.js.map +0 -1
  85. package/dist/modules/common/index.js +0 -10
  86. package/dist/modules/common/index.js.map +0 -1
  87. package/dist/modules/common/kep-map-store/impl.js +0 -42
  88. package/dist/modules/common/kep-map-store/impl.js.map +0 -1
  89. package/dist/modules/common/kep-map-store/interface.js +0 -2
  90. package/dist/modules/common/kep-map-store/interface.js.map +0 -1
  91. package/dist/modules/common/os-platform/caller-info.js +0 -132
  92. package/dist/modules/common/os-platform/caller-info.js.map +0 -1
  93. package/dist/modules/common/os-platform/impl.js +0 -87
  94. package/dist/modules/common/os-platform/impl.js.map +0 -1
  95. package/dist/modules/common/os-platform/interface.js +0 -2
  96. package/dist/modules/common/os-platform/interface.js.map +0 -1
  97. package/dist/modules/common/os-platform/virtual-hid/index.js +0 -12
  98. package/dist/modules/common/os-platform/virtual-hid/index.js.map +0 -1
  99. package/dist/modules/common/os-platform/virtual-hid/linux.js +0 -5
  100. package/dist/modules/common/os-platform/virtual-hid/linux.js.map +0 -1
  101. package/dist/modules/common/os-platform/virtual-hid/mac.js +0 -119
  102. package/dist/modules/common/os-platform/virtual-hid/mac.js.map +0 -1
  103. package/dist/modules/common/os-platform/virtual-hid/windows.js +0 -5
  104. package/dist/modules/common/os-platform/virtual-hid/windows.js.map +0 -1
  105. package/dist/modules/common/ssh-config/impl.js +0 -116
  106. package/dist/modules/common/ssh-config/impl.js.map +0 -1
  107. package/dist/modules/common/ssh-config/interface.js +0 -10
  108. package/dist/modules/common/ssh-config/interface.js.map +0 -1
  109. package/dist/modules/ssh-agent/index.js +0 -8
  110. package/dist/modules/ssh-agent/index.js.map +0 -1
  111. package/dist/modules/ssh-agent/session/impl.js +0 -265
  112. package/dist/modules/ssh-agent/session/impl.js.map +0 -1
  113. package/dist/modules/ssh-agent/session/interface-rpc.js +0 -20
  114. package/dist/modules/ssh-agent/session/interface-rpc.js.map +0 -1
  115. package/dist/modules/ssh-agent/session/interface.js +0 -32
  116. package/dist/modules/ssh-agent/session/interface.js.map +0 -1
  117. package/dist/modules/ssh-agent/session/passkey-prf-page.js +0 -204
  118. package/dist/modules/ssh-agent/session/passkey-prf-page.js.map +0 -1
  119. package/dist/modules/ssh-agent/session/prf-flow.js +0 -103
  120. package/dist/modules/ssh-agent/session/prf-flow.js.map +0 -1
  121. package/dist/modules/ssh-agent/ssh-agent/impl.js +0 -117
  122. package/dist/modules/ssh-agent/ssh-agent/impl.js.map +0 -1
  123. package/dist/modules/ssh-agent/ssh-agent/interface.js +0 -2
  124. package/dist/modules/ssh-agent/ssh-agent/interface.js.map +0 -1
  125. package/dist/scripts/build.js +0 -460
  126. package/dist/scripts/build.js.map +0 -1
  127. package/dist/scripts/check-npm-version.js +0 -8
  128. package/dist/scripts/check-npm-version.js.map +0 -1
  129. package/dist/scripts/kill-existing-agent.js +0 -21
  130. package/dist/scripts/kill-existing-agent.js.map +0 -1
  131. package/dist/scripts/publish.js +0 -46
  132. package/dist/scripts/publish.js.map +0 -1
  133. package/multi-call.js +0 -85
  134. package/src/commands/git/hosts.ts +0 -20
  135. package/src/commands/git/index.ts +0 -9
  136. package/src/commands/git/setup.ts +0 -182
  137. package/src/commands/index.ts +0 -15
  138. package/src/commands/npm/index.ts +0 -8
  139. package/src/commands/npm/setup/git-remote.ts +0 -78
  140. package/src/commands/npm/setup/index.ts +0 -189
  141. package/src/commands/npm/setup/npm-auth.ts +0 -58
  142. package/src/commands/npm/setup/package-json-validate.ts +0 -68
  143. package/src/commands/npm/setup/package-registry.ts +0 -24
  144. package/src/commands/npm/setup/publish-workflow.yml +0 -35
  145. package/src/commands/npm/setup/setup.test.ts +0 -117
  146. package/src/commands/npm/setup/trusted-publishing.ts +0 -106
  147. package/src/commands/npm/setup/workflow.ts +0 -20
  148. package/src/commands/ssh/get-sk-credential.ts +0 -110
  149. package/src/commands/ssh/index.ts +0 -8
  150. package/src/commands/upgrade.ts +0 -90
  151. package/src/common/command.ts +0 -16
  152. package/src/common/constants.ts +0 -24
  153. package/src/common/effective-modules-extensions.ts +0 -24
  154. package/src/common/log.ts +0 -3
  155. package/src/common/render-caller-tree.ts +0 -22
  156. package/src/entrypoints/ozy-signing-agent.ts +0 -48
  157. package/src/entrypoints/ozy-ssh-keygen.ts +0 -10
  158. package/src/entrypoints/ozy-virtual-security-key.ts +0 -21
  159. package/src/entrypoints/ozy.ts +0 -2
  160. package/src/index.ts +0 -1
  161. package/src/internal/thing.ts +0 -3
  162. package/src/modules/cli/agent-client/impl.ts +0 -152
  163. package/src/modules/cli/agent-client/interface.ts +0 -17
  164. package/src/modules/cli/git/impl.ts +0 -133
  165. package/src/modules/cli/git/interface.ts +0 -23
  166. package/src/modules/cli/git/submodule/fix.ts +0 -298
  167. package/src/modules/cli/git/submodule/git-state.ts +0 -217
  168. package/src/modules/cli/git/submodule/gitmodules.ts +0 -126
  169. package/src/modules/cli/git/submodule/printer.ts +0 -256
  170. package/src/modules/cli/git/submodule/resolve-git-dir.ts +0 -14
  171. package/src/modules/cli/github/impl.ts +0 -169
  172. package/src/modules/cli/github/interface.ts +0 -29
  173. package/src/modules/cli/index.ts +0 -16
  174. package/src/modules/common/crypto/impl.ts +0 -173
  175. package/src/modules/common/crypto/interface.ts +0 -20
  176. package/src/modules/common/index.ts +0 -19
  177. package/src/modules/common/kep-map-store/impl.ts +0 -47
  178. package/src/modules/common/kep-map-store/interface.ts +0 -9
  179. package/src/modules/common/os-platform/caller-info.ts +0 -152
  180. package/src/modules/common/os-platform/impl.ts +0 -86
  181. package/src/modules/common/os-platform/interface.ts +0 -16
  182. package/src/modules/common/os-platform/virtual-hid/index.ts +0 -12
  183. package/src/modules/common/os-platform/virtual-hid/linux.ts +0 -7
  184. package/src/modules/common/os-platform/virtual-hid/mac.ts +0 -150
  185. package/src/modules/common/os-platform/virtual-hid/windows.ts +0 -7
  186. package/src/modules/common/ssh-config/impl.ts +0 -130
  187. package/src/modules/common/ssh-config/interface.ts +0 -33
  188. package/src/modules/ssh-agent/index.ts +0 -13
  189. package/src/modules/ssh-agent/session/agent-notes.md +0 -210
  190. package/src/modules/ssh-agent/session/design.md +0 -2
  191. package/src/modules/ssh-agent/session/html-refactor.md +0 -23
  192. package/src/modules/ssh-agent/session/impl.ts +0 -328
  193. package/src/modules/ssh-agent/session/interface-rpc.ts +0 -24
  194. package/src/modules/ssh-agent/session/interface.ts +0 -62
  195. package/src/modules/ssh-agent/session/passkey-prf-page.ts +0 -224
  196. package/src/modules/ssh-agent/session/prf-flow.ts +0 -152
  197. package/src/modules/ssh-agent/ssh-agent/impl.ts +0 -136
  198. package/src/modules/ssh-agent/ssh-agent/interface.ts +0 -9
  199. package/src/scripts/build.ts +0 -543
  200. package/src/scripts/check-npm-version.ts +0 -7
  201. package/src/scripts/kill-existing-agent.ts +0 -22
  202. package/src/scripts/publish.ts +0 -47
Binary file
package/package.json CHANGED
@@ -1,8 +1,18 @@
1
1
  {
2
2
  "name": "@ozyman42/ozy-cli",
3
- "version": "0.4.5",
4
- "description": "Ozymandias' personal tools",
3
+ "version": "0.4.6-darwin-arm64.0",
5
4
  "type": "module",
5
+ "os": [
6
+ "darwin"
7
+ ],
8
+ "cpu": [
9
+ "arm64"
10
+ ],
11
+ "files": [
12
+ "multi-call-binary"
13
+ ],
14
+ "description": "Tools for setting up new packages, configuring with git & npm",
15
+ "license": "MIT",
6
16
  "repository": {
7
17
  "type": "git",
8
18
  "url": "git+https://github.com/ozyman42/ozy-cli.git"
@@ -10,58 +20,5 @@
10
20
  "publishConfig": {
11
21
  "access": "public",
12
22
  "provenance": true
13
- },
14
- "main": "./dist/index.js",
15
- "module": "./dist/index.js",
16
- "types": "./src/index.ts",
17
- "exports": {
18
- ".": {
19
- "types": "./src/index.ts",
20
- "import": "./dist/index.js"
21
- },
22
- "./entrypoints": null,
23
- "./entrypoints/*": null,
24
- "./agents": null,
25
- "./agents/*": null,
26
- "./internal": null,
27
- "./internal/*": null,
28
- "./*": {
29
- "types": "./src/*.ts",
30
- "import": "./dist/*.js"
31
- }
32
- },
33
- "files": [
34
- "dist",
35
- "src",
36
- "multi-call.js"
37
- ],
38
- "bin": {
39
- "ozy": "./multi-call.js",
40
- "ozy-signing-agent": "./multi-call.js",
41
- "ozy-ssh-keygen": "./multi-call.js",
42
- "ozy-virtual-security-key": "./multi-call.js"
43
- },
44
- "scripts": {
45
- "postinstall": "node ./multi-call.js"
46
- },
47
- "dependencies": {
48
- "@effect/platform-bun": "^4.0.0-beta.70",
49
- "@ozyman42/interactive-cli-select": "^0.2.0",
50
- "bip39": "^3.1.0",
51
- "bs58": "^6.0.0",
52
- "commander": "^13.1.0",
53
- "effect": "4.0.0-beta.70",
54
- "effective-modules": "0.3.1-effect4",
55
- "expand-tilde": "^2.0.2",
56
- "friendly-words": "^1.3.1",
57
- "ssh-config": "^5.0.3",
58
- "zod": "^3.24.2"
59
- },
60
- "optionalDependencies": {
61
- "@ozyman42/ozy-cli-darwin-arm64": "npm:@ozyman42/ozy-cli@0.4.5-darwin-arm64.0",
62
- "@ozyman42/ozy-cli-darwin-x64": "npm:@ozyman42/ozy-cli@0.4.5-darwin-x64.0",
63
- "@ozyman42/ozy-cli-linux-arm64": "npm:@ozyman42/ozy-cli@0.4.5-linux-arm64.0",
64
- "@ozyman42/ozy-cli-linux-x64": "npm:@ozyman42/ozy-cli@0.4.5-linux-x64.0",
65
- "@ozyman42/ozy-cli-windows-x64": "npm:@ozyman42/ozy-cli@0.4.5-windows-x64.0"
66
23
  }
67
24
  }
@@ -1,18 +0,0 @@
1
- import { Effect } from "effect";
2
- import { makeCommand } from "@/common/command";
3
- import { log } from "@/common/log";
4
- import { commonModules } from "@/modules/common";
5
- import { SSHConfigImpl } from "@/modules/common/ssh-config/impl";
6
- export const hosts = makeCommand('hosts', 'show all configured github.com SSH hosts', () => Effect.gen(function* () {
7
- const sshConfig = yield* commonModules.SSHConfig;
8
- const config = yield* sshConfig.getSSHConfig();
9
- const gitHosts = [];
10
- for (const host in config) {
11
- if (config[host].HostName === 'github.com') {
12
- gitHosts.push(host);
13
- }
14
- }
15
- log('Available hosts:');
16
- gitHosts.forEach(host => { log(` - ${host}`); });
17
- }).pipe(Effect.provide(SSHConfigImpl.Layer)));
18
- //# sourceMappingURL=hosts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hosts.js","sourceRoot":"","sources":["../../../../../../src/commands/git/hosts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,MAAM,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE,0CAA0C,EAAE,GAAG,EAAE,CACzF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC;IACjD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;IAC/C,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,IAAI,MAAM,CAAC,IAAI,CAAE,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YAC5C,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IACD,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAC7C,CAAC"}
@@ -1,8 +0,0 @@
1
- import { Command } from 'commander';
2
- import { setup } from './setup';
3
- import { hosts } from './hosts';
4
- export const git = new Command('git')
5
- .summary('setup git in repo for verified commits');
6
- [setup, hosts]
7
- .forEach(cmd => { git.addCommand(cmd); });
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/commands/git/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC;KAClC,OAAO,CAAC,wCAAwC,CAAC,CAAC;AAErD,CAAC,KAAK,EAAE,KAAK,CAAC;KACX,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC"}
@@ -1,145 +0,0 @@
1
- import { Command } from 'commander';
2
- import { Effect, Layer, Option, pipe } from 'effect';
3
- import { log } from '@/common/log';
4
- import { cliModules } from '@/modules/cli';
5
- import { commonModules, CommonModules } from '@/modules/common';
6
- import { effunct } from 'effective-modules';
7
- import { GitImpl } from '@/modules/cli/git/impl';
8
- import { GitHubImpl } from '@/modules/cli/github/impl';
9
- import { AgentClientImpl } from '@/modules/cli/agent-client/impl';
10
- import { OSPlatformImpl } from '@/modules/common/os-platform/impl';
11
- import { SSHConfigImpl } from '@/modules/common/ssh-config/impl';
12
- import { AGENT_SOCK_FILE_PATH, FUTURE_TOOL_NAME, STANDARD_REMOTE_PREFIX } from '../../common/constants';
13
- import { CredentialId } from '@/modules/common/crypto/impl';
14
- import { BunFileSystem } from "@effect/platform-bun";
15
- const GITHUB_CLIENT_ID = 'Ov23liKYxk1Ag7SsNhbP';
16
- const GITHUB_CLIENT_SECRET = 'e2901fbe93c591e7a53a903e70490ff87e998159';
17
- const OAUTH_SCOPES = 'read:user user:email write:ssh_signing_key write:public_key';
18
- const KEY_PREFIX = `${FUTURE_TOOL_NAME}-`;
19
- function parseCredentialIdFromTitle(title) {
20
- const match = title.match(/\(([^)]+)\)$/);
21
- if (!match)
22
- return Option.none();
23
- return Option.some(match[1]);
24
- }
25
- function baseKey(pubkey) {
26
- return pubkey.split(' ').slice(0, 2).join(' ');
27
- }
28
- export var GitSetupError;
29
- (function (GitSetupError) {
30
- GitSetupError["NotInGitRepositoryError"] = "NotInGitRepositoryError";
31
- GitSetupError["NoRemoteOriginError"] = "NoRemoteOriginError";
32
- GitSetupError["OAuthFailedError"] = "OAuthFailedError";
33
- GitSetupError["GitHubUserFetchFailedError"] = "GitHubUserFetchFailedError";
34
- GitSetupError["RepoAccessDeniedError"] = "RepoAccessDeniedError";
35
- GitSetupError["MultipleJiveSigningKeysError"] = "MultipleJiveSigningKeysError";
36
- GitSetupError["MultipleJiveAuthnKeysError"] = "MultipleJiveAuthnKeysError";
37
- GitSetupError["MissingCredentialIdError"] = "MissingCredentialIdError";
38
- GitSetupError["SigningAuthnKeyMismatchError"] = "SigningAuthnKeyMismatchError";
39
- GitSetupError["AgentStartFailedError"] = "AgentStartFailedError";
40
- GitSetupError["AgentProcedureFailedError"] = "AgentProcedureFailedError";
41
- GitSetupError["GitCloneFailedError"] = "GitCloneFailedError";
42
- GitSetupError["GitConfigFailedError"] = "GitConfigFailedError";
43
- })(GitSetupError || (GitSetupError = {}));
44
- function* gitSetup(ownerRepoArg) {
45
- const git = yield* cliModules.Git;
46
- const github = yield* cliModules.GitHub;
47
- const agentClient = yield* cliModules.AgentClient;
48
- const sshConfig = yield* commonModules.SSHConfig;
49
- const isCloneMode = ownerRepoArg !== undefined;
50
- // 1. Parse owner/repo
51
- const { owner, repo } = yield* git.resolveOwnerAndRepo(Option.fromNullishOr(ownerRepoArg));
52
- log(`Setting up ${owner}/${repo}`);
53
- // 2. GitHub OAuth
54
- const token = yield* github.authorize(GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, OAUTH_SCOPES);
55
- log('✓ Authorized with GitHub');
56
- // 3. Fetch user info
57
- const { login, email } = yield* github.getUser(token);
58
- const gitUser = { name: login, email: email };
59
- log(` Logged in as: ${gitUser.name} <${gitUser.email}>`);
60
- // 4. Check GitHub signing keys for <tool name>: prefix
61
- const signingKeys = yield* github.getSigningKeys(token);
62
- const toolKeys = signingKeys.filter(k => k.title.startsWith(KEY_PREFIX));
63
- if (toolKeys.length > 1)
64
- return yield* Effect.fail(`${GitSetupError.MultipleJiveSigningKeysError}: Found ${toolKeys.length} signing keys with "${KEY_PREFIX}" prefix — expected at most 1`);
65
- let maybeKey = Option.none();
66
- if (toolKeys[0]) {
67
- const credentialId = parseCredentialIdFromTitle(toolKeys[0].title);
68
- if (Option.isNone(credentialId))
69
- return yield* Effect.fail(`${GitSetupError.MissingCredentialIdError}: signing key title "${toolKeys[0].title}" has no credentialId`);
70
- maybeKey = Option.some({ credentialId: credentialId.value, pubkey: baseKey(toolKeys[0].key) });
71
- }
72
- // 5. Check authn keys too — must match signing key if both present.
73
- const authnKeys = yield* github.getAuthnKeys(token);
74
- const toolAuthnKeys = authnKeys.filter(k => k.title.startsWith(KEY_PREFIX));
75
- if (toolAuthnKeys.length > 1)
76
- return yield* Effect.fail(`${GitSetupError.MultipleJiveAuthnKeysError}: Found ${toolAuthnKeys.length} authn keys with "${KEY_PREFIX}" prefix — expected at most 1`);
77
- let maybeAuthnKey = Option.none();
78
- if (toolAuthnKeys[0]) {
79
- const credentialId = parseCredentialIdFromTitle(toolAuthnKeys[0].title);
80
- if (Option.isNone(credentialId))
81
- return yield* Effect.fail(`${GitSetupError.MissingCredentialIdError}: authn key title "${toolAuthnKeys[0].title}" has no credentialId`);
82
- maybeAuthnKey = Option.some({ credentialId: credentialId.value, pubkey: baseKey(toolAuthnKeys[0].key) });
83
- }
84
- if (Option.isSome(maybeKey) && Option.isSome(maybeAuthnKey) && maybeKey.value.pubkey !== maybeAuthnKey.value.pubkey)
85
- return yield* Effect.fail(`${GitSetupError.SigningAuthnKeyMismatchError}: signing key and authn key pubkeys don't match — GitHub account is in an inconsistent state`);
86
- // 6. Call agent to get/create/verify key (starts agent if not running)
87
- const { credentialId, pubkey } = yield* pipe(Effect.gen(() => agentClient.usingClient(function* (client) {
88
- return yield* pipe(client.Setup({
89
- pubkey: Option.map(maybeKey, k => k.pubkey),
90
- credentialId: Option.map(maybeKey, k => k.credentialId),
91
- username: login,
92
- }), Effect.mapError(e => `${GitSetupError.AgentProcedureFailedError}: ${String(e)}`));
93
- })), Effect.catchTag("AgentClientError", err => Effect.fail(err.reason)), Effect.catchTag("AgentClientUsageError", err => Effect.fail(err.cause)));
94
- const credentialFriendlyName = new CredentialId(credentialId).humanReadableName;
95
- const keyTitle = `${credentialFriendlyName} (${credentialId})`;
96
- // 8. Register signing key on GitHub if not already present
97
- if (Option.isNone(maybeKey)) {
98
- yield* github.addSigningKey(token, keyTitle, pubkey);
99
- log(`✓ Registered GitHub signing key: ${keyTitle}`);
100
- }
101
- // 9. Register key as authn key on GitHub account if not already present
102
- if (Option.isNone(maybeAuthnKey)) {
103
- yield* github.addAuthnKey(token, keyTitle, pubkey);
104
- log(`✓ Registered authn key on GitHub account`);
105
- }
106
- // 10. Write ssh config (pubkey file written by agent via KeyMapStore.addKey)
107
- const pubkeyPath = sshConfig.getPubkeyPath(credentialFriendlyName);
108
- yield* sshConfig.writeHost({
109
- section: {
110
- HostName: "github.com",
111
- User: "git",
112
- IdentityFile: pubkeyPath,
113
- IdentitiesOnly: "yes",
114
- IdentityAgent: AGENT_SOCK_FILE_PATH,
115
- },
116
- });
117
- // 11. Clone if in clone mode
118
- if (isCloneMode) {
119
- yield* git.clone(owner, repo);
120
- log(`✓ Cloned into ${repo}/`);
121
- }
122
- // 12. Set repo config plus any submodules' config
123
- log('\nSetting git config:');
124
- yield* git.setupRepo({
125
- dir: process.cwd(),
126
- remoteURL: `${STANDARD_REMOTE_PREFIX}${owner}/${repo}.git`,
127
- user: gitUser,
128
- pubkeyPath,
129
- });
130
- log(`\n✓ Setup complete for ${owner}/${repo}`);
131
- }
132
- const layerLive = pipe(GitImpl.Layer, Layer.provideMerge(GitHubImpl.Layer), Layer.provideMerge(AgentClientImpl.Layer), Layer.provideMerge(OSPlatformImpl.Layer), Layer.provideMerge(SSHConfigImpl.Layer), Layer.provideMerge(BunFileSystem.layer));
133
- export const setup = new Command('setup')
134
- .description('setup verified git commits for current repo')
135
- .argument('[owner/repo]', 'GitHub repo to clone and set up (omit if already in a repo with a remote)')
136
- .action(async (ownerRepo) => {
137
- function* program() {
138
- yield* pipe(effunct(gitSetup)(ownerRepo), Effect.provide(layerLive), Effect.catch(err => Effect.gen(function* () {
139
- log(`✗ ${err}`);
140
- })));
141
- }
142
- await Effect.runPromise(Effect.gen(program));
143
- process.exit();
144
- });
145
- //# sourceMappingURL=setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../../../../src/commands/git/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC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AAc,CAAC,KAAK,CAAC,EACxC,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,EACvC,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CACxC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KACtC,WAAW,CAAC,6CAA6C,CAAC;KAC1D,QAAQ,CAAC,cAAc,EAAE,2EAA2E,CAAC;KACrG,MAAM,CAAC,KAAK,EAAE,SAAkB,EAAE,EAAE;IACnC,QAAQ,CAAC,CAAC,OAAO;QACf,KAAK,CAAC,CAAC,IAAI,CACT,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,EAC5B,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EACzB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;YACtC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- import { program } from 'commander';
2
- import { git } from './git';
3
- import { npm } from './npm';
4
- import { upgrade } from './upgrade';
5
- import { ssh } from "./ssh";
6
- import { CLI_CMD_NAME, CURRENT_VERSION } from '@/common/constants';
7
- program.name(CLI_CMD_NAME).version(CURRENT_VERSION);
8
- [git, npm, ssh, upgrade]
9
- .forEach(cmd => { program.addCommand(cmd); });
10
- program.parse();
11
- if (process.argv.length <= 2)
12
- program.help();
13
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;AAEpD,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC;KACrB,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;AAE/C,OAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC;IAAE,OAAO,CAAC,IAAI,EAAE,CAAC"}
@@ -1,7 +0,0 @@
1
- import { Command } from 'commander';
2
- import { setup } from './setup';
3
- export const npm = new Command('npm')
4
- .summary('npm package management utilities');
5
- [setup]
6
- .forEach(cmd => { npm.addCommand(cmd); });
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/commands/npm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC;KAClC,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAE/C,CAAC,KAAK,CAAC;KACJ,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC"}
@@ -1,66 +0,0 @@
1
- import { $ } from 'bun';
2
- import { Effect, Option } from 'effect';
3
- // Handles https://github.com/owner/repo.git, git@github.com:owner/repo.git,
4
- // and SSH aliases like github-ozyman42:owner/repo.git
5
- export function parseGithubOwnerRepo(url) {
6
- const https = url.match(/github\.com[/:]([^/]+)\/([^/]+?)(?:\.git)?$/);
7
- if (https)
8
- return Option.some({ owner: https[1], repo: https[2] });
9
- const alias = url.match(/^[^:]+:([^/]+)\/([^/]+?)(?:\.git)?$/);
10
- if (alias)
11
- return Option.some({ owner: alias[1], repo: alias[2] });
12
- return Option.none();
13
- }
14
- async function viewRepo(nameWithOwner) {
15
- const view = await $ `gh repo view ${nameWithOwner} --json name,owner,url,sshUrl`.quiet().nothrow();
16
- if (view.exitCode !== 0)
17
- return Option.none();
18
- try {
19
- const data = JSON.parse(view.stdout.toString());
20
- return Option.some({ owner: data.owner.login, repo: data.name, url: data.url, sshUrl: data.sshUrl });
21
- }
22
- catch {
23
- return Option.none();
24
- }
25
- }
26
- export function ensureGitHubRepo(name, isPrivate = false) {
27
- return Effect.tryPromise({
28
- try: async () => {
29
- const whoami = await $ `gh api user --jq .login`.quiet().nothrow();
30
- const owner = whoami.exitCode === 0 ? whoami.stdout.toString().trim() : null;
31
- if (owner) {
32
- const existingOption = await viewRepo(`${owner}/${name}`);
33
- if (Option.isSome(existingOption))
34
- return { repo: existingOption.value, created: false };
35
- }
36
- const visibility = isPrivate ? '--private' : '--public';
37
- const create = await $ `gh repo create ${name} ${visibility}`.quiet().nothrow();
38
- if (create.exitCode !== 0) {
39
- throw new Error(`gh repo create failed: ${create.stderr.toString().trim()}`);
40
- }
41
- const createdOption = await viewRepo(name);
42
- if (Option.isNone(createdOption))
43
- throw new Error(`repo created but could not retrieve details for "${name}"`);
44
- return { repo: createdOption.value, created: true };
45
- },
46
- catch: (e) => e instanceof Error ? e.message : String(e),
47
- });
48
- }
49
- export async function checkGitHubAccess(remoteUrl) {
50
- const parsedOption = parseGithubOwnerRepo(remoteUrl);
51
- if (Option.isNone(parsedOption))
52
- return Option.none();
53
- const { owner, repo } = parsedOption.value;
54
- const result = await $ `gh api repos/${owner}/${repo}`.quiet().nothrow();
55
- if (result.exitCode !== 0)
56
- return Option.none();
57
- let data;
58
- try {
59
- data = JSON.parse(result.stdout.toString());
60
- }
61
- catch {
62
- return Option.none();
63
- }
64
- return Option.some({ owner, repo, canPush: data?.permissions?.push === true });
65
- }
66
- //# sourceMappingURL=git-remote.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-remote.js","sourceRoot":"","sources":["../../../../../../../src/commands/npm/setup/git-remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAexC,4EAA4E;AAC5E,sDAAsD;AACtD,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACvE,IAAI,KAAK;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC;IACrE,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC/D,IAAI,KAAK;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC;IACrE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,aAAqB;IAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,CAAA,gBAAgB,aAAa,+BAA+B,CAAC,KAAK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AAC,IAAI,EAAE,CAAC;IAEhD,IAAI,IAAS,CAAC;IACd,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC;AACjF,CAAC"}
@@ -1,168 +0,0 @@
1
- import { $ } from 'bun';
2
- import { existsSync } from 'node:fs';
3
- import { Effect, Option } from 'effect';
4
- import { makeCommand } from '@/common/command';
5
- import { log } from '@/common/log';
6
- import { acquireToken } from './npm-auth';
7
- import { fetchPackageInfo } from './package-registry';
8
- import { addTrustedPublisher, setPackageAccessPolicy } from './trusted-publishing';
9
- import { checkGitHubAccess } from './git-remote';
10
- import { workflowExists, createWorkflow } from './workflow';
11
- import { validatePackageJson } from './package-json-validate';
12
- var SetupError;
13
- (function (SetupError) {
14
- SetupError["NoGitRepo"] = "NoGitRepo";
15
- SetupError["NoPackageJson"] = "NoPackageJson";
16
- SetupError["InvalidPackageJson"] = "InvalidPackageJson";
17
- SetupError["NpmNotFound"] = "NpmNotFound";
18
- SetupError["GhNotFound"] = "GhNotFound";
19
- SetupError["NotLoggedIn"] = "NotLoggedIn";
20
- SetupError["NoGitRemote"] = "NoGitRemote";
21
- SetupError["RepoNotFound"] = "RepoNotFound";
22
- SetupError["NoWriteAccess"] = "NoWriteAccess";
23
- SetupError["BuildFailed"] = "BuildFailed";
24
- SetupError["PublishFailed"] = "PublishFailed";
25
- SetupError["TrustedPublishingFailed"] = "TrustedPublishingFailed";
26
- SetupError["AccessPolicyFailed"] = "AccessPolicyFailed";
27
- })(SetupError || (SetupError = {}));
28
- export const setup = makeCommand('setup', 'configure a new npm package for publishing', () => Effect.gen(function* () {
29
- const cwd = process.cwd();
30
- // 1. npm
31
- log('checking npm...');
32
- const npmCheck = yield* Effect.promise(() => $ `which npm`.quiet().nothrow());
33
- if (npmCheck.exitCode !== 0)
34
- yield* Effect.fail(`${SetupError.NpmNotFound}: "npm" not found in PATH — install Node.js from nodejs.org`);
35
- const npmVersion = (yield* Effect.promise(() => $ `npm --version`.quiet().nothrow())).stdout.toString().trim();
36
- const [major, minor] = npmVersion.split('.').map(Number);
37
- if (major < 11 || (major === 11 && minor < 10))
38
- yield* Effect.fail(`${SetupError.NpmNotFound}: npm ${npmVersion} is too old — "npm trust" requires 11.10.0+ (run "npm install -g npm")`);
39
- const { token: npmToken, user: npmUser } = yield* acquireToken().pipe(Effect.mapError(e => `${SetupError.NotLoggedIn}: npm authentication failed: ${e}`));
40
- log(` ✓ logged into npm as ${npmUser}`);
41
- // 2. GitHub CLI
42
- log('checking GitHub...');
43
- const ghCheck = yield* Effect.promise(() => $ `which gh`.quiet().nothrow());
44
- if (ghCheck.exitCode !== 0)
45
- yield* Effect.fail(`${SetupError.GhNotFound}: "gh" not found in PATH — install GitHub CLI from cli.github.com`);
46
- let ghUser = yield* Effect.promise(() => $ `gh api user --jq .login`.quiet().nothrow());
47
- if (ghUser.exitCode !== 0) {
48
- log(' not logged in — opening gh auth login...');
49
- yield* Effect.promise(() => $ `gh auth login`.nothrow());
50
- ghUser = yield* Effect.promise(() => $ `gh api user --jq .login`.quiet().nothrow());
51
- }
52
- if (ghUser.exitCode !== 0)
53
- yield* Effect.fail(`${SetupError.NotLoggedIn}: not logged into GitHub — run "gh auth login"`);
54
- log(` ✓ logged into github as ${ghUser.stdout.toString().trim()}`);
55
- // 3. git repo root
56
- if (!existsSync(`${cwd}/.git`))
57
- yield* Effect.fail(`${SetupError.NoGitRepo}: current directory is not a git repository — run "git init" first`);
58
- // 4. package.json — read and fatal-check
59
- log('checking package.json...');
60
- const pkgFile = Bun.file(`${cwd}/package.json`);
61
- if (!(yield* Effect.promise(() => pkgFile.exists())))
62
- yield* Effect.fail(`${SetupError.NoPackageJson}: no package.json found — run this command from a package directory`);
63
- let pkg = yield* Effect.tryPromise({
64
- try: () => pkgFile.json(),
65
- catch: () => `${SetupError.InvalidPackageJson}: package.json contains invalid JSON — fix it and retry`,
66
- });
67
- const { name } = pkg;
68
- if (!name)
69
- yield* Effect.fail(`${SetupError.InvalidPackageJson}: package.json is missing a "name" field`);
70
- log(` name: ${name}`);
71
- const fatal = validatePackageJson(pkg).find(i => i.fatal);
72
- if (fatal)
73
- yield* Effect.fail(`${SetupError.InvalidPackageJson}: ${fatal.field}: ${fatal.issue}`);
74
- // 5. git remote
75
- log('checking git remote...');
76
- const remoteOption = yield* Effect.promise(() => getRemoteUrl(cwd));
77
- if (Option.isNone(remoteOption))
78
- yield* Effect.fail(`${SetupError.NoGitRemote}: no git remote configured — run "git remote add origin <url>" first`);
79
- const remote = remoteOption.value;
80
- log(` remote: ${remote}`);
81
- const accessOption = yield* Effect.promise(() => checkGitHubAccess(remote));
82
- if (Option.isNone(accessOption))
83
- yield* Effect.fail(`${SetupError.RepoNotFound}: could not reach GitHub repo at ${remote} — check "gh auth status"`);
84
- const access = accessOption.value;
85
- if (!access.canPush)
86
- yield* Effect.fail(`${SetupError.NoWriteAccess}: no push access to ${access.owner}/${access.repo} — you need write permissions`);
87
- const repoHttpsUrl = `https://github.com/${access.owner}/${access.repo}`;
88
- log(` ✓ ${access.owner}/${access.repo} (write access confirmed)`);
89
- // 6. Sync package.json repository URL from git remote; report other non-fatal issues
90
- const expectedRepoUrl = `git+${repoHttpsUrl}.git`;
91
- const currentRepoUrl = typeof pkg.repository === 'object' ? pkg.repository?.url : pkg.repository;
92
- if (currentRepoUrl !== expectedRepoUrl) {
93
- log('syncing package.json repository URL...');
94
- log(` was: ${currentRepoUrl ?? '(missing)'}`);
95
- pkg = { ...pkg, repository: { type: 'git', url: expectedRepoUrl } };
96
- yield* Effect.promise(() => Bun.write(`${cwd}/package.json`, JSON.stringify(pkg, null, 2) + '\n'));
97
- log(` ✓ set to ${expectedRepoUrl}`);
98
- }
99
- const nonFatal = validatePackageJson(pkg).filter(i => !i.fatal);
100
- if (nonFatal.length > 0) {
101
- log('package.json issues (fix manually):');
102
- for (const { field, issue } of nonFatal)
103
- log(` ${field}: ${issue}`);
104
- }
105
- // 7. Publish workflow
106
- log('checking publish workflow...');
107
- if (!(yield* Effect.promise(() => workflowExists(cwd)))) {
108
- yield* Effect.promise(() => createWorkflow(cwd));
109
- log(' ✓ created .github/workflows/publish.yml');
110
- }
111
- else {
112
- log(' ✓ already exists');
113
- }
114
- // 8. npm package — initial publish if not yet on registry
115
- log('checking npm registry...');
116
- const infoOption = yield* fetchPackageInfo(name).pipe(Effect.mapError(e => `${SetupError.NpmNotFound}: npm registry lookup failed: ${e}`));
117
- if (Option.isNone(infoOption)) {
118
- log(' package not yet published — building and creating initial release...');
119
- const buildResult = yield* Effect.promise(() => $ `bun run build`.nothrow());
120
- if (buildResult.exitCode !== 0)
121
- yield* Effect.fail(`${SetupError.BuildFailed}: build failed: ${buildResult.stderr.toString().trim()}`);
122
- const distPkgFile = Bun.file(`${cwd}/dist/package.json`);
123
- if (!(yield* Effect.promise(() => distPkgFile.exists())))
124
- yield* Effect.fail(`${SetupError.BuildFailed}: build succeeded but dist/package.json is missing — build script must produce it`);
125
- yield* Effect.tryPromise({
126
- try: () => distPkgFile.json(),
127
- catch: () => `${SetupError.BuildFailed}: dist/package.json exists but contains invalid JSON — check your build script`,
128
- });
129
- yield* npmPublish(npmToken).pipe(Effect.mapError(e => `${SetupError.PublishFailed}: ${e}`));
130
- log(` ✓ published ${name}`);
131
- }
132
- else {
133
- const version = infoOption.value.latestVersion ?? '(unknown)';
134
- log(` ✓ exists (latest v${version})`);
135
- }
136
- // 9. Trusted publishing
137
- log('checking trusted publishing...');
138
- const ownerRepo = `${access.owner}/${access.repo}`;
139
- const trust = yield* addTrustedPublisher(name, ownerRepo, npmToken).pipe(Effect.mapError(e => `${SetupError.TrustedPublishingFailed}: ${e}`));
140
- log(trust.alreadyConfigured ? ' ✓ already configured' : ' ✓ configured');
141
- // 10. Package access policy — require 2FA, disallow automation tokens
142
- log('setting package access policy...');
143
- yield* setPackageAccessPolicy(name, npmToken, trust.otp).pipe(Effect.mapError(e => `${SetupError.AccessPolicyFailed}: ${e}`));
144
- log(' ✓ configured');
145
- }));
146
- async function getRemoteUrl(cwd) {
147
- const result = await $ `git -C ${cwd} remote get-url origin`.quiet().nothrow();
148
- if (result.exitCode !== 0)
149
- return Option.none();
150
- return Option.some(result.stdout.toString().trim());
151
- }
152
- function npmPublish(token) {
153
- return Effect.tryPromise({
154
- try: async () => {
155
- const proc = Bun.spawn(['npm', 'publish', 'dist/', '--access', 'public', '--no-provenance'], {
156
- stdin: 'inherit',
157
- stdout: 'inherit',
158
- stderr: 'inherit',
159
- env: { ...process.env, NODE_AUTH_TOKEN: token },
160
- });
161
- const exitCode = await proc.exited;
162
- if (exitCode !== 0)
163
- throw new Error('npm publish failed — see output above');
164
- },
165
- catch: (e) => e instanceof Error ? e.message : String(e),
166
- });
167
- }
168
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/commands/npm/setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,sBA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G,EAAE,eAAe,EAAE,KAAK,EAAE;aAChD,CAAC,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC;YACnC,IAAI,QAAQ,KAAK,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC/E,CAAC;QACD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;KACzD,CAAC,CAAC;AACL,CAAC"}
@@ -1,62 +0,0 @@
1
- import { $ } from 'bun';
2
- import { readFileSync, writeFileSync, unlinkSync } from 'node:fs';
3
- import { homedir } from 'node:os';
4
- import { Effect, Option } from 'effect';
5
- import { log } from '@/common/log';
6
- const npmrcPath = `${homedir()}/.npmrc`;
7
- const TOKEN_RE = /^\/\/registry\.npmjs\.org\/:_authToken=(\S+)$/m;
8
- function readNpmrc() {
9
- try {
10
- return readFileSync(npmrcPath, 'utf8');
11
- }
12
- catch {
13
- return '';
14
- }
15
- }
16
- function stripTokenFromDisk() {
17
- const content = readNpmrc();
18
- const stripped = content.replace(TOKEN_RE, '').replace(/\n{3,}/g, '\n\n').trim();
19
- if (!stripped) {
20
- try {
21
- unlinkSync(npmrcPath);
22
- }
23
- catch { }
24
- }
25
- else {
26
- writeFileSync(npmrcPath, stripped + '\n');
27
- }
28
- }
29
- async function whoamiWithToken(token) {
30
- const result = await $ `npm whoami`
31
- .env({ ...process.env, NODE_AUTH_TOKEN: token })
32
- .quiet().nothrow();
33
- if (result.exitCode !== 0)
34
- return Option.none();
35
- return Option.some(result.stdout.toString().trim());
36
- }
37
- export function acquireToken() {
38
- return Effect.tryPromise({
39
- try: async () => {
40
- const existing = readNpmrc().match(TOKEN_RE)?.[1];
41
- if (existing) {
42
- const userOption = await whoamiWithToken(existing);
43
- if (Option.isSome(userOption)) {
44
- stripTokenFromDisk();
45
- return { token: existing, user: userOption.value };
46
- }
47
- }
48
- log(' not logged in — opening npm login...');
49
- await $ `npm login`.nothrow();
50
- const token = readNpmrc().match(TOKEN_RE)?.[1];
51
- if (!token)
52
- throw new Error('npm login did not produce a token — try running "npm login" manually');
53
- const userOption = await whoamiWithToken(token);
54
- if (Option.isNone(userOption))
55
- throw new Error('npm login succeeded but token verification failed');
56
- stripTokenFromDisk();
57
- return { token, user: userOption.value };
58
- },
59
- catch: (e) => e instanceof Error ? e.message : String(e),
60
- });
61
- }
62
- //# sourceMappingURL=npm-auth.js.map