@sfship/plugin-ship 1.0.0-beta.2

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 (229) hide show
  1. package/LICENSE.txt +206 -0
  2. package/README.md +164 -0
  3. package/lib/commands/ship/flow/eject.d.ts +15 -0
  4. package/lib/commands/ship/flow/eject.js +55 -0
  5. package/lib/commands/ship/flow/eject.js.map +1 -0
  6. package/lib/commands/ship/flow/info.d.ts +15 -0
  7. package/lib/commands/ship/flow/info.js +86 -0
  8. package/lib/commands/ship/flow/info.js.map +1 -0
  9. package/lib/commands/ship/flow/list.d.ts +12 -0
  10. package/lib/commands/ship/flow/list.js +51 -0
  11. package/lib/commands/ship/flow/list.js.map +1 -0
  12. package/lib/commands/ship/flow/run.d.ts +16 -0
  13. package/lib/commands/ship/flow/run.js +90 -0
  14. package/lib/commands/ship/flow/run.js.map +1 -0
  15. package/lib/commands/ship/project/init.d.ts +13 -0
  16. package/lib/commands/ship/project/init.js +81 -0
  17. package/lib/commands/ship/project/init.js.map +1 -0
  18. package/lib/commands/ship/service/connect/github.d.ts +12 -0
  19. package/lib/commands/ship/service/connect/github.js +47 -0
  20. package/lib/commands/ship/service/connect/github.js.map +1 -0
  21. package/lib/commands/ship/service/delete.d.ts +13 -0
  22. package/lib/commands/ship/service/delete.js +44 -0
  23. package/lib/commands/ship/service/delete.js.map +1 -0
  24. package/lib/commands/ship/service/info.d.ts +13 -0
  25. package/lib/commands/ship/service/info.js +51 -0
  26. package/lib/commands/ship/service/info.js.map +1 -0
  27. package/lib/commands/ship/service/list.d.ts +9 -0
  28. package/lib/commands/ship/service/list.js +55 -0
  29. package/lib/commands/ship/service/list.js.map +1 -0
  30. package/lib/commands/ship/task/info.d.ts +15 -0
  31. package/lib/commands/ship/task/info.js +75 -0
  32. package/lib/commands/ship/task/info.js.map +1 -0
  33. package/lib/commands/ship/task/list.d.ts +12 -0
  34. package/lib/commands/ship/task/list.js +45 -0
  35. package/lib/commands/ship/task/list.js.map +1 -0
  36. package/lib/commands/ship/task/run.d.ts +16 -0
  37. package/lib/commands/ship/task/run.js +72 -0
  38. package/lib/commands/ship/task/run.js.map +1 -0
  39. package/lib/core/config.dependency.schema.d.ts +24 -0
  40. package/lib/core/config.dependency.schema.js +34 -0
  41. package/lib/core/config.dependency.schema.js.map +1 -0
  42. package/lib/core/config.loader.d.ts +23 -0
  43. package/lib/core/config.loader.js +62 -0
  44. package/lib/core/config.loader.js.map +1 -0
  45. package/lib/core/config.ship.schema.d.ts +174 -0
  46. package/lib/core/config.ship.schema.js +67 -0
  47. package/lib/core/config.ship.schema.js.map +1 -0
  48. package/lib/core/error.d.ts +29 -0
  49. package/lib/core/error.js +59 -0
  50. package/lib/core/error.js.map +1 -0
  51. package/lib/core/file.d.ts +34 -0
  52. package/lib/core/file.js +123 -0
  53. package/lib/core/file.js.map +1 -0
  54. package/lib/core/flow.context.d.ts +22 -0
  55. package/lib/core/flow.context.js +4 -0
  56. package/lib/core/flow.context.js.map +1 -0
  57. package/lib/core/flow.definition.schema.d.ts +60 -0
  58. package/lib/core/flow.definition.schema.js +56 -0
  59. package/lib/core/flow.definition.schema.js.map +1 -0
  60. package/lib/core/flow.interpolate.d.ts +21 -0
  61. package/lib/core/flow.interpolate.js +64 -0
  62. package/lib/core/flow.interpolate.js.map +1 -0
  63. package/lib/core/flow.registry.d.ts +32 -0
  64. package/lib/core/flow.registry.js +99 -0
  65. package/lib/core/flow.registry.js.map +1 -0
  66. package/lib/core/flow.renderer.d.ts +51 -0
  67. package/lib/core/flow.renderer.js +137 -0
  68. package/lib/core/flow.renderer.js.map +1 -0
  69. package/lib/core/flow.runner.d.ts +13 -0
  70. package/lib/core/flow.runner.js +133 -0
  71. package/lib/core/flow.runner.js.map +1 -0
  72. package/lib/core/flow.store.d.ts +24 -0
  73. package/lib/core/flow.store.js +57 -0
  74. package/lib/core/flow.store.js.map +1 -0
  75. package/lib/core/flow.view.d.ts +20 -0
  76. package/lib/core/flow.view.js +77 -0
  77. package/lib/core/flow.view.js.map +1 -0
  78. package/lib/core/flows/create/package.yml +18 -0
  79. package/lib/core/flows/dependencies/lock.yml +4 -0
  80. package/lib/core/flows/deploy/beta.yml +38 -0
  81. package/lib/core/flows/deploy/dev.yml +26 -0
  82. package/lib/core/flows/deploy/feature.yml +56 -0
  83. package/lib/core/flows/deploy/qa.yml +51 -0
  84. package/lib/core/flows/deploy/regression.yml +60 -0
  85. package/lib/core/flows/deploy/release.yml +38 -0
  86. package/lib/core/flows/release/beta.yml +25 -0
  87. package/lib/core/flows/release/production.yml +16 -0
  88. package/lib/core/org.registry.d.ts +45 -0
  89. package/lib/core/org.registry.js +76 -0
  90. package/lib/core/org.registry.js.map +1 -0
  91. package/lib/core/org.scratch.schema.d.ts +44 -0
  92. package/lib/core/org.scratch.schema.js +62 -0
  93. package/lib/core/org.scratch.schema.js.map +1 -0
  94. package/lib/core/package.dependencies.d.ts +45 -0
  95. package/lib/core/package.dependencies.js +158 -0
  96. package/lib/core/package.dependencies.js.map +1 -0
  97. package/lib/core/package.installer.d.ts +13 -0
  98. package/lib/core/package.installer.js +60 -0
  99. package/lib/core/package.installer.js.map +1 -0
  100. package/lib/core/package.metadata.d.ts +6 -0
  101. package/lib/core/package.metadata.js +33 -0
  102. package/lib/core/package.metadata.js.map +1 -0
  103. package/lib/core/package.namespace.d.ts +10 -0
  104. package/lib/core/package.namespace.js +40 -0
  105. package/lib/core/package.namespace.js.map +1 -0
  106. package/lib/core/package.version.d.ts +42 -0
  107. package/lib/core/package.version.js +60 -0
  108. package/lib/core/package.version.js.map +1 -0
  109. package/lib/core/project.init.d.ts +11 -0
  110. package/lib/core/project.init.js +121 -0
  111. package/lib/core/project.init.js.map +1 -0
  112. package/lib/core/service.d.ts +45 -0
  113. package/lib/core/service.github.d.ts +98 -0
  114. package/lib/core/service.github.js +270 -0
  115. package/lib/core/service.github.js.map +1 -0
  116. package/lib/core/service.js +91 -0
  117. package/lib/core/service.js.map +1 -0
  118. package/lib/core/sfdx-project.d.ts +25 -0
  119. package/lib/core/sfdx-project.js +39 -0
  120. package/lib/core/sfdx-project.js.map +1 -0
  121. package/lib/core/stdout.d.ts +1 -0
  122. package/lib/core/stdout.js +27 -0
  123. package/lib/core/stdout.js.map +1 -0
  124. package/lib/core/task.definition.schema.d.ts +69 -0
  125. package/lib/core/task.definition.schema.js +33 -0
  126. package/lib/core/task.definition.schema.js.map +1 -0
  127. package/lib/core/task.output.d.ts +29 -0
  128. package/lib/core/task.output.js +39 -0
  129. package/lib/core/task.output.js.map +1 -0
  130. package/lib/core/task.param.d.ts +30 -0
  131. package/lib/core/task.param.js +141 -0
  132. package/lib/core/task.param.js.map +1 -0
  133. package/lib/core/task.param.schema.d.ts +22 -0
  134. package/lib/core/task.param.schema.js +26 -0
  135. package/lib/core/task.param.schema.js.map +1 -0
  136. package/lib/core/task.registry.d.ts +22 -0
  137. package/lib/core/task.registry.js +85 -0
  138. package/lib/core/task.registry.js.map +1 -0
  139. package/lib/core/task.view.d.ts +10 -0
  140. package/lib/core/task.view.js +25 -0
  141. package/lib/core/task.view.js.map +1 -0
  142. package/lib/core/tasks/apex/run/test.d.ts +25 -0
  143. package/lib/core/tasks/apex/run/test.js +85 -0
  144. package/lib/core/tasks/apex/run/test.js.map +1 -0
  145. package/lib/core/tasks/data/import/tree.d.ts +12 -0
  146. package/lib/core/tasks/data/import/tree.js +61 -0
  147. package/lib/core/tasks/data/import/tree.js.map +1 -0
  148. package/lib/core/tasks/git/release/create.d.ts +42 -0
  149. package/lib/core/tasks/git/release/create.js +197 -0
  150. package/lib/core/tasks/git/release/create.js.map +1 -0
  151. package/lib/core/tasks/git/release/fetch.d.ts +24 -0
  152. package/lib/core/tasks/git/release/fetch.js +93 -0
  153. package/lib/core/tasks/git/release/fetch.js.map +1 -0
  154. package/lib/core/tasks/git/repo/info.d.ts +12 -0
  155. package/lib/core/tasks/git/repo/info.js +47 -0
  156. package/lib/core/tasks/git/repo/info.js.map +1 -0
  157. package/lib/core/tasks/metadata/deploy.d.ts +12 -0
  158. package/lib/core/tasks/metadata/deploy.js +39 -0
  159. package/lib/core/tasks/metadata/deploy.js.map +1 -0
  160. package/lib/core/tasks/org/assign/permsets.d.ts +12 -0
  161. package/lib/core/tasks/org/assign/permsets.js +54 -0
  162. package/lib/core/tasks/org/assign/permsets.js.map +1 -0
  163. package/lib/core/tasks/org/create/scratch.d.ts +36 -0
  164. package/lib/core/tasks/org/create/scratch.js +127 -0
  165. package/lib/core/tasks/org/create/scratch.js.map +1 -0
  166. package/lib/core/tasks/org/delete/scratch.d.ts +12 -0
  167. package/lib/core/tasks/org/delete/scratch.js +10 -0
  168. package/lib/core/tasks/org/delete/scratch.js.map +1 -0
  169. package/lib/core/tasks/package/create.d.ts +36 -0
  170. package/lib/core/tasks/package/create.js +93 -0
  171. package/lib/core/tasks/package/create.js.map +1 -0
  172. package/lib/core/tasks/package/dependencies/lock.d.ts +6 -0
  173. package/lib/core/tasks/package/dependencies/lock.js +35 -0
  174. package/lib/core/tasks/package/dependencies/lock.js.map +1 -0
  175. package/lib/core/tasks/package/dependencies/verify.d.ts +6 -0
  176. package/lib/core/tasks/package/dependencies/verify.js +44 -0
  177. package/lib/core/tasks/package/dependencies/verify.js.map +1 -0
  178. package/lib/core/tasks/package/install/dependencies.d.ts +22 -0
  179. package/lib/core/tasks/package/install/dependencies.js +43 -0
  180. package/lib/core/tasks/package/install/dependencies.js.map +1 -0
  181. package/lib/core/tasks/package/install/index.d.ts +25 -0
  182. package/lib/core/tasks/package/install/index.js +37 -0
  183. package/lib/core/tasks/package/install/index.js.map +1 -0
  184. package/lib/core/tasks/package/version/create.d.ts +36 -0
  185. package/lib/core/tasks/package/version/create.js +133 -0
  186. package/lib/core/tasks/package/version/create.js.map +1 -0
  187. package/lib/core/tasks/package/version/promote.d.ts +30 -0
  188. package/lib/core/tasks/package/version/promote.js +79 -0
  189. package/lib/core/tasks/package/version/promote.js.map +1 -0
  190. package/lib/core/tasks/package/version/resolve-latest.d.ts +24 -0
  191. package/lib/core/tasks/package/version/resolve-latest.js +78 -0
  192. package/lib/core/tasks/package/version/resolve-latest.js.map +1 -0
  193. package/lib/core/tasks/package/version/resolve-next.d.ts +24 -0
  194. package/lib/core/tasks/package/version/resolve-next.js +49 -0
  195. package/lib/core/tasks/package/version/resolve-next.js.map +1 -0
  196. package/lib/core/tasks/project/deploy/start.d.ts +22 -0
  197. package/lib/core/tasks/project/deploy/start.js +117 -0
  198. package/lib/core/tasks/project/deploy/start.js.map +1 -0
  199. package/lib/core/tasks/project/reset/tracking.d.ts +25 -0
  200. package/lib/core/tasks/project/reset/tracking.js +32 -0
  201. package/lib/core/tasks/project/reset/tracking.js.map +1 -0
  202. package/lib/core/tasks/util/file/exists.d.ts +24 -0
  203. package/lib/core/tasks/util/file/exists.js +53 -0
  204. package/lib/core/tasks/util/file/exists.js.map +1 -0
  205. package/lib/core/tasks/util/file/find.d.ts +30 -0
  206. package/lib/core/tasks/util/file/find.js +70 -0
  207. package/lib/core/tasks/util/file/find.js.map +1 -0
  208. package/lib/core/tasks/util/log.d.ts +13 -0
  209. package/lib/core/tasks/util/log.js +10 -0
  210. package/lib/core/tasks/util/log.js.map +1 -0
  211. package/lib/core/templates/README.md +35 -0
  212. package/lib/core/tree.d.ts +7 -0
  213. package/lib/core/tree.js +42 -0
  214. package/lib/core/tree.js.map +1 -0
  215. package/messages/service.connect.github.md +16 -0
  216. package/messages/ship.flow.eject.md +21 -0
  217. package/messages/ship.flow.info.md +21 -0
  218. package/messages/ship.flow.list.md +15 -0
  219. package/messages/ship.flow.run.md +23 -0
  220. package/messages/ship.project.init.md +23 -0
  221. package/messages/ship.service.delete.md +19 -0
  222. package/messages/ship.service.info.md +19 -0
  223. package/messages/ship.service.list.md +11 -0
  224. package/messages/ship.task.info.md +25 -0
  225. package/messages/ship.task.list.md +15 -0
  226. package/messages/ship.task.run.md +29 -0
  227. package/oclif.lock +10313 -0
  228. package/oclif.manifest.json +707 -0
  229. package/package.json +254 -0
@@ -0,0 +1,60 @@
1
+ import { resolveDependencies } from './package.dependencies.js';
2
+ import { deployMetadataStep } from './package.metadata.js';
3
+ import { withSuppressedStdout } from './stdout.js';
4
+ export function describeStep(step) {
5
+ if (step.kind === 'package-id')
6
+ return `package-id ${step.versionId}${step.name ? ` (${step.name})` : ''}`;
7
+ return `metadata ${step.repoUrl}/${step.subfolder}`;
8
+ }
9
+ export async function installDependencies(deps, options) {
10
+ const { alias, wait, dryRun, force, shipDir, log, runCommand } = options;
11
+ if (deps.length === 0) {
12
+ log('No dependencies declared in ship.yml.');
13
+ return;
14
+ }
15
+ log('Resolving dependencies...');
16
+ const steps = await resolveDependencies(deps);
17
+ if (steps.length === 0) {
18
+ log('Dependency tree resolved to zero steps.');
19
+ return;
20
+ }
21
+ log(`Resolved ${steps.length} step(s):`);
22
+ for (const step of steps) {
23
+ log(` ${describeStep(step)}`);
24
+ }
25
+ if (dryRun) {
26
+ log('dry-run — skipping install.');
27
+ return;
28
+ }
29
+ let installed = new Set();
30
+ if (!force) {
31
+ const listArgs = ['--json', ...(alias !== undefined ? ['--target-org', alias] : [])];
32
+ const result = (await withSuppressedStdout(() => runCommand('package:installed:list', listArgs)));
33
+ installed = new Set(result.map((p) => p.SubscriberPackageVersionId));
34
+ log(`${installed.size} package version(s) already installed in ${alias ?? 'default org'}.`);
35
+ }
36
+ for (const step of steps) {
37
+ if (step.kind === 'package-id') {
38
+ if (installed.has(step.versionId)) {
39
+ log(`Already installed: ${step.versionId}${step.name ? ` (${step.name})` : ''} — skipping.`);
40
+ continue;
41
+ }
42
+ log(`Installing ${step.versionId}${step.name ? ` (${step.name})` : ''}...`);
43
+ const installArgs = ['--package', step.versionId, '--wait', String(wait), '--no-prompt'];
44
+ if (alias !== undefined)
45
+ installArgs.push('--target-org', alias);
46
+ // eslint-disable-next-line no-await-in-loop
47
+ await runCommand('package:install', installArgs);
48
+ log(`Installed ${step.versionId}.`);
49
+ }
50
+ else {
51
+ if (installed.has(step.versionId)) {
52
+ log(`Already installed (${step.versionId}): ${step.repoUrl}/${step.subfolder} — skipping.`);
53
+ continue;
54
+ }
55
+ // eslint-disable-next-line no-await-in-loop
56
+ await deployMetadataStep(step, alias ?? '', shipDir, log, runCommand);
57
+ }
58
+ }
59
+ }
60
+ //# sourceMappingURL=package.installer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.installer.js","sourceRoot":"","sources":["../../src/core/package.installer.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAuB,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,UAAU,YAAY,CAAC,IAAoB;IAC/C,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,eAAe,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC5G,OAAO,eAAe,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;AACzD,CAAC;AAYD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAsB,EAAE,OAAmC;IACnG,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAEzE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,GAAG,CAAC,uCAAuC,CAAC,CAAC;QAC7C,OAAO;IACT,CAAC;IAED,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAE9C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,GAAG,CAA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,EAAE,cAAc,CAAC,CAAC;gBAC7F,SAAS;YACX,CAAC;YACD,GAAG,CAAC,cAAc,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAC5E,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC;YACzF,IAAI,KAAK,KAAK,SAAS;gBAAE,WAAW,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YACjE,4CAA4C;YAC5C,MAAM,UAAU,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;YACjD,GAAG,CAAC,aAAa,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;gBAClC,GAAG,CAAC,sBAAsB,IAAI,CAAC,SAAS,MAAM,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,cAAc,CAAC,CAAC;gBAC5F,SAAS;YACX,CAAC;YACD,4CAA4C;YAC5C,MAAM,kBAAkB,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { MetadataStep } from './package.dependencies.js';
2
+ /**
3
+ * Downloads a CCI `unpackaged/pre` or `unpackaged/post` subfolder from GitHub,
4
+ * injects namespace tokens, and deploys it to the target org via `project:deploy:start`.
5
+ */
6
+ export declare function deployMetadataStep(step: MetadataStep, targetOrg: string, shipDir: string, log: (msg: string) => void, runCommand: (id: string, argv: string[]) => Promise<unknown>): Promise<void>;
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * You may obtain a copy of the License at
5
+ *
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ *
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ */
14
+ import { join } from 'node:path';
15
+ import { walkFiles } from './file.js';
16
+ import { replaceTokens, buildTokenMap } from './package.namespace.js';
17
+ import { normalizeRepo, downloadDir } from './service.github.js';
18
+ /**
19
+ * Downloads a CCI `unpackaged/pre` or `unpackaged/post` subfolder from GitHub,
20
+ * injects namespace tokens, and deploys it to the target org via `project:deploy:start`.
21
+ */
22
+ export async function deployMetadataStep(step, targetOrg, shipDir, log, runCommand) {
23
+ const repo = normalizeRepo(step.repoUrl);
24
+ const slug = repo.replace('/', '_');
25
+ const localDir = join(shipDir, 'tmp', 'deps', slug, step.subfolder);
26
+ log(`Downloading ${step.repoUrl}/${step.subfolder}@${step.tag}...`);
27
+ await downloadDir(repo, step.tag, step.subfolder, localDir);
28
+ const files = await walkFiles(localDir);
29
+ await Promise.all(files.map((f) => replaceTokens(f, buildTokenMap(step.namespace))));
30
+ log(`Deploying ${step.subfolder}...`);
31
+ await runCommand('project:deploy:start', ['--metadata-dir', localDir, '--target-org', targetOrg]);
32
+ }
33
+ //# sourceMappingURL=package.metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.metadata.js","sourceRoot":"","sources":["../../src/core/package.metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGjE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAkB,EAClB,SAAiB,EACjB,OAAe,EACf,GAA0B,EAC1B,UAA4D;IAE5D,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAEpE,GAAG,CAAC,eAAe,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IACpE,MAAM,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAE5D,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAErF,GAAG,CAAC,aAAa,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC;IACtC,MAAM,UAAU,CAAC,sBAAsB,EAAE,CAAC,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;AACpG,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Replaces `%%%TOKEN%%%` placeholders in a file in-place.
3
+ * Binary files (containing null bytes) are skipped.
4
+ */
5
+ export declare function replaceTokens(filePath: string, tokens: Record<string, string>): Promise<void>;
6
+ /**
7
+ * Builds the CCI namespace token map for use with {@link replaceTokens}.
8
+ * Pass an empty string for unmanaged packages.
9
+ */
10
+ export declare function buildTokenMap(namespace: string): Record<string, string>;
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * You may obtain a copy of the License at
5
+ *
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ *
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ */
14
+ import { readFile, writeFile } from 'node:fs/promises';
15
+ /**
16
+ * Replaces `%%%TOKEN%%%` placeholders in a file in-place.
17
+ * Binary files (containing null bytes) are skipped.
18
+ */
19
+ export async function replaceTokens(filePath, tokens) {
20
+ const buf = await readFile(filePath);
21
+ if (buf.includes(0))
22
+ return; // skip binary files
23
+ let content = buf.toString('utf8');
24
+ for (const [token, replacement] of Object.entries(tokens)) {
25
+ content = content.replaceAll(`%%%${token}%%%`, replacement);
26
+ }
27
+ await writeFile(filePath, content, 'utf8');
28
+ }
29
+ /**
30
+ * Builds the CCI namespace token map for use with {@link replaceTokens}.
31
+ * Pass an empty string for unmanaged packages.
32
+ */
33
+ export function buildTokenMap(namespace) {
34
+ return {
35
+ NAMESPACE: namespace ? `${namespace}__` : '',
36
+ NAMESPACE_DOT: namespace ? `${namespace}.` : '',
37
+ NAMESPACE_OR_C: namespace || 'c',
38
+ };
39
+ }
40
+ //# sourceMappingURL=package.namespace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.namespace.js","sourceRoot":"","sources":["../../src/core/package.namespace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAgB,EAAE,MAA8B;IAClF,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,oBAAoB;IACjD,IAAI,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,KAAK,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1D,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,KAAK,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiB;IAC7C,OAAO;QACL,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC,CAAC,EAAE;QAC5C,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE;QAC/C,cAAc,EAAE,SAAS,IAAI,GAAG;KACjC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ export type PackageVersion = {
2
+ SubscriberPackageVersionId: string;
3
+ Version?: string;
4
+ IsReleased: boolean;
5
+ Branch?: string | null;
6
+ Name?: string;
7
+ CreatedDate: string;
8
+ };
9
+ export declare function selectLatest(versions: PackageVersion[], wantReleased: boolean): PackageVersion | null;
10
+ export declare function extractVersionBase(version: string): string | undefined;
11
+ export type PackageVersionCreateResult = {
12
+ Id?: string;
13
+ Status?: string;
14
+ Package2Id?: string;
15
+ Package2VersionId?: string;
16
+ SubscriberPackageVersionId?: string;
17
+ Branch?: string | null;
18
+ Tag?: string | null;
19
+ VersionNumber?: string;
20
+ MajorVersion?: number;
21
+ MinorVersion?: number;
22
+ PatchVersion?: number;
23
+ BuildNumber?: number;
24
+ };
25
+ export declare function formatVersionNumber(result: PackageVersionCreateResult): string | undefined;
26
+ export declare const VERSION_TYPES: readonly ["build", "patch", "minor", "major"];
27
+ export type VersionType = (typeof VERSION_TYPES)[number];
28
+ type Semver = {
29
+ major: number;
30
+ minor: number;
31
+ patch: number;
32
+ };
33
+ export declare function parseSemver(s: string): Semver | null;
34
+ export declare function bump(base: Semver, type: VersionType): Semver;
35
+ /**
36
+ * Computes the next `.NEXT` version string from the latest release tag and the requested bump type.
37
+ *
38
+ * A 'build' bump on an existing release secretly bumps minor instead — sf won't allow a new
39
+ * build version in a series that already has a promoted production release.
40
+ */
41
+ export declare function resolveNextVersion(tagName: string | null, versionType: VersionType): string;
42
+ export {};
@@ -0,0 +1,60 @@
1
+ export function selectLatest(versions, wantReleased) {
2
+ const matching = versions.filter((v) => v.IsReleased === wantReleased);
3
+ if (matching.length === 0)
4
+ return null;
5
+ matching.sort((a, b) => (a.CreatedDate < b.CreatedDate ? 1 : -1));
6
+ return matching[0];
7
+ }
8
+ export function extractVersionBase(version) {
9
+ const parts = version.split('.');
10
+ return parts.length >= 3 ? `${parts[0]}.${parts[1]}.${parts[2]}` : undefined;
11
+ }
12
+ export function formatVersionNumber(result) {
13
+ if (result.VersionNumber)
14
+ return result.VersionNumber;
15
+ if (result.MajorVersion !== undefined) {
16
+ return `${result.MajorVersion}.${result.MinorVersion ?? 0}.${result.PatchVersion ?? 0}.${result.BuildNumber ?? 0}`;
17
+ }
18
+ return undefined;
19
+ }
20
+ export const VERSION_TYPES = ['build', 'patch', 'minor', 'major'];
21
+ export function parseSemver(s) {
22
+ const match = s.match(/(\d+)\.(\d+)\.(\d+)/);
23
+ if (!match)
24
+ return null;
25
+ return {
26
+ major: parseInt(match[1], 10),
27
+ minor: parseInt(match[2], 10),
28
+ patch: parseInt(match[3], 10),
29
+ };
30
+ }
31
+ export function bump(base, type) {
32
+ switch (type) {
33
+ case 'major':
34
+ return { major: base.major + 1, minor: 0, patch: 0 };
35
+ case 'minor':
36
+ return { major: base.major, minor: base.minor + 1, patch: 0 };
37
+ case 'patch':
38
+ return { major: base.major, minor: base.minor, patch: base.patch + 1 };
39
+ case 'build':
40
+ return { ...base };
41
+ }
42
+ }
43
+ /**
44
+ * Computes the next `.NEXT` version string from the latest release tag and the requested bump type.
45
+ *
46
+ * A 'build' bump on an existing release secretly bumps minor instead — sf won't allow a new
47
+ * build version in a series that already has a promoted production release.
48
+ */
49
+ export function resolveNextVersion(tagName, versionType) {
50
+ let base = { major: 0, minor: 0, patch: 0 };
51
+ if (tagName) {
52
+ const parsed = parseSemver(tagName);
53
+ if (parsed)
54
+ base = parsed;
55
+ }
56
+ const effectiveType = versionType === 'build' && tagName !== null ? 'minor' : versionType;
57
+ const next = bump(base, effectiveType);
58
+ return `${next.major}.${next.minor}.${next.patch}.NEXT`;
59
+ }
60
+ //# sourceMappingURL=package.version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.version.js","sourceRoot":"","sources":["../../src/core/package.version.ts"],"names":[],"mappings":"AAsBA,MAAM,UAAU,YAAY,CAAC,QAA0B,EAAE,YAAqB;IAC5E,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,YAAY,CAAC,CAAC;IACvE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,O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5
+ repoUrl?: string;
6
+ };
7
+ export type InitResult = {
8
+ created: string[];
9
+ skipped: string[];
10
+ };
11
+ export declare function initProject(options: InitOptions, projectDir: string): InitResult;
@@ -0,0 +1,121 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * You may obtain a copy of the License at
5
+ *
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ *
8
+ * Unless required by applicable law or agreed to in writing, software
9
+ * distributed under the License is distributed on an "AS IS" BASIS,
10
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and
12
+ * limitations under the License.
13
+ */
14
+ import { join } from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
16
+ import { fileExists, ensureDir, readText, writeText, writeJson, appendText, removeFile } from './file.js';
17
+ const templateDir = join(fileURLToPath(import.meta.url), '..', 'templates');
18
+ function writeIfAbsent(absPath, relPath, content, result) {
19
+ if (fileExists(absPath)) {
20
+ result.skipped.push(relPath);
21
+ return;
22
+ }
23
+ writeText(absPath, content);
24
+ result.created.push(relPath);
25
+ }
26
+ function buildShipYml({ packageName, namespace, packageType, repoUrl }) {
27
+ const lines = ['project:', ' package:', ` name: ${packageName}`];
28
+ if (namespace)
29
+ lines.push(` namespace: ${namespace}`);
30
+ lines.push(` type: ${packageType}`);
31
+ lines.push(' git:', ' defaultBranch: main');
32
+ if (repoUrl)
33
+ lines.push(` repoUrl: ${repoUrl}`);
34
+ return lines.join('\n') + '\n';
35
+ }
36
+ function patchSfdxProjectJson(projectDir, { packageName, namespace, packageType }) {
37
+ const filePath = join(projectDir, 'sfdx-project.json');
38
+ if (!fileExists(filePath))
39
+ return;
40
+ const raw = JSON.parse(readText(filePath));
41
+ const defaultDir = raw.packageDirectories.find((d) => d.default) ?? raw.packageDirectories[0];
42
+ if (defaultDir) {
43
+ defaultDir.package = packageName;
44
+ defaultDir.versionName = 'ver 0.1';
45
+ defaultDir.versionNumber = '0.0.0.NEXT';
46
+ if (packageType === 'Managed') {
47
+ defaultDir.ancestorVersion = 'HIGHEST';
48
+ }
49
+ }
50
+ if (namespace) {
51
+ raw.namespace = namespace;
52
+ }
53
+ writeJson(filePath, raw);
54
+ }
55
+ function appendToGitignore(projectDir) {
56
+ const filePath = join(projectDir, '.gitignore');
57
+ const entry = '\n# sf-ship\n.ship/tmp/\n';
58
+ const existing = fileExists(filePath) ? readText(filePath) : '';
59
+ if (!existing.includes('.ship/tmp/')) {
60
+ appendText(filePath, entry);
61
+ }
62
+ }
63
+ function appendToForceignore(projectDir) {
64
+ const filePath = join(projectDir, '.forceignore');
65
+ const entry = [
66
+ '',
67
+ '# sf-ship',
68
+ '**/*.profile-meta.xml',
69
+ '**/*.appMenu-meta.xml',
70
+ '**/sfdcInternalInt__*.permissionset-meta.xml',
71
+ '',
72
+ ].join('\n');
73
+ const existing = fileExists(filePath) ? readText(filePath) : '';
74
+ if (!existing.includes('# sf-ship')) {
75
+ appendText(filePath, entry);
76
+ }
77
+ }
78
+ const commonSettings = {
79
+ lightningExperienceSettings: { enableS1DesktopEnabled: true },
80
+ securitySettings: {
81
+ enableAdminLoginAsAnyUser: true,
82
+ sessionSettings: { forceRelogin: false },
83
+ },
84
+ };
85
+ function buildOrgDefs(packageName) {
86
+ const label = (env) => `${packageName}:${env}`;
87
+ return {
88
+ dev: {
89
+ orgName: label('dev'),
90
+ edition: 'Developer',
91
+ hasSampleData: true,
92
+ settings: {
93
+ ...commonSettings,
94
+ userManagementSettings: { permsetsInFieldCreation: true, enableEnhancedPermsetMgmt: true },
95
+ },
96
+ },
97
+ feature: { orgName: label('feature'), edition: 'Developer', settings: commonSettings },
98
+ beta: { orgName: label('beta'), edition: 'Developer', settings: commonSettings },
99
+ qa: { orgName: label('qa'), edition: 'Enterprise', hasSampleData: true, settings: commonSettings },
100
+ regression: { orgName: label('regression'), edition: 'Enterprise', settings: commonSettings },
101
+ release: { orgName: label('release'), edition: 'Enterprise', settings: commonSettings },
102
+ };
103
+ }
104
+ export function initProject(options, projectDir) {
105
+ const result = { created: [], skipped: [] };
106
+ const orgsDir = join(projectDir, '.ship', 'orgs');
107
+ ensureDir(orgsDir);
108
+ patchSfdxProjectJson(projectDir, options);
109
+ appendToGitignore(projectDir);
110
+ appendToForceignore(projectDir);
111
+ writeIfAbsent(join(projectDir, 'README.md'), 'README.md', readText(join(templateDir, 'README.md')), result);
112
+ const legacyConfigDir = join(projectDir, 'config');
113
+ if (fileExists(legacyConfigDir))
114
+ removeFile(legacyConfigDir);
115
+ writeIfAbsent(join(projectDir, 'ship.yml'), 'ship.yml', buildShipYml(options), result);
116
+ for (const [name, def] of Object.entries(buildOrgDefs(options.packageName))) {
117
+ writeIfAbsent(join(orgsDir, `${name}.json`), `.ship/orgs/${name}.json`, JSON.stringify(def, null, 4) + '\n', result);
118
+ }
119
+ return result;
120
+ }
121
+ //# sourceMappingURL=project.init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.init.js","sourceRoot":"","sources":["../../src/core/project.init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1G,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAc5E,SAAS,aAAa,CAAC,OAAe,EAAE,OAAe,EAAE,OAAe,EAAE,MAAkB;IAC1F,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,OAAO;IACT,CAA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EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAExD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAClD,SAAS,CAAC,OAAO,CAAC,CAAC;IAEnB,oBAAoB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC1C,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC9B,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAChC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC5G,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACnD,IAAI,UAAU,CAAC,eAAe,CAAC;QAAE,UAAU,CAAC,eAAe,CAAC,CAAC;IAC7D,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;IAEvF,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;QAC5E,aAAa,CACX,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,OAAO,CAAC,EAC7B,cAAc,IAAI,OAAO,EACzB,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EACnC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,45 @@
1
+ /** Metadata stored alongside a credential, describing the account and granted scopes. */
2
+ export type ServiceMeta = {
3
+ service: string;
4
+ account: string;
5
+ alias: string;
6
+ scopes: string[];
7
+ };
8
+ /**
9
+ * Retrieves the stored token for a service alias from the OS keychain.
10
+ *
11
+ * @param service - The external service name (e.g. `'github.com'`).
12
+ * @param alias - The account alias (e.g. `'default'`).
13
+ * @returns The stored token, or `null` if not found.
14
+ */
15
+ export declare function getToken(service: string, alias: string): string | null;
16
+ /**
17
+ * Stores a token in the OS keychain and writes a metadata file alongside it.
18
+ *
19
+ * @param service - The external service name (e.g. `'github.com'`).
20
+ * @param account - The account identifier (e.g. GitHub username).
21
+ * @param alias - The account alias (e.g. `'default'`).
22
+ * @param token - The credential to store.
23
+ * @param scopes - The scopes or permissions granted to this credential.
24
+ */
25
+ export declare function setToken(service: string, account: string, alias: string, token: string, scopes?: string[]): void;
26
+ /**
27
+ * Reads the metadata for a stored credential by alias.
28
+ *
29
+ * @param service - The external service name.
30
+ * @param alias - The account alias to look up.
31
+ * @returns The metadata, or `undefined` if no credential is stored for this alias.
32
+ */
33
+ export declare function getMeta(service: string, alias: string): ServiceMeta | undefined;
34
+ /**
35
+ * Returns metadata for all stored credentials.
36
+ */
37
+ export declare function listMetas(): ServiceMeta[];
38
+ /**
39
+ * Removes a stored credential from the OS keychain and deletes its metadata file.
40
+ *
41
+ * @param service - The external service name.
42
+ * @param account - The account identifier.
43
+ * @param alias - The account alias.
44
+ */
45
+ export declare function deleteToken(service: string, account: string, alias: string): void;
@@ -0,0 +1,98 @@
1
+ import type { ServiceMeta } from './service.js';
2
+ declare const SERVICE = "github";
3
+ /** Metadata for a stored GitHub credential. */
4
+ export type GithubMeta = ServiceMeta & {
5
+ service: typeof SERVICE;
6
+ };
7
+ /** Returns the stored GitHub access token for the given alias, or `undefined` if not connected. */
8
+ export declare function getGithubToken(alias?: string): string | undefined;
9
+ /**
10
+ * Persists a GitHub access token securely for the given alias.
11
+ * The token is stored in the OS keychain; metadata is written alongside it.
12
+ */
13
+ export declare function setGithubToken(token: string, username: string, alias?: string, scopes?: string[]): void;
14
+ /** Normalises a GitHub reference to an `owner/repo` slug, accepting full URLs or slugs. */
15
+ export declare function normalizeRepo(github: string): string;
16
+ /** A GitHub release with its associated tag name. */
17
+ export type ReleaseRef = {
18
+ tagName: string;
19
+ };
20
+ export type GitTagObject = {
21
+ sha: string;
22
+ };
23
+ export type Release = {
24
+ html_url: string;
25
+ };
26
+ export type ReleaseListItem = {
27
+ tag_name: string;
28
+ prerelease: boolean;
29
+ };
30
+ /** Response from the GitHub device code endpoint. */
31
+ export type DeviceCodeResponse = {
32
+ device_code: string;
33
+ user_code: string;
34
+ verification_uri: string;
35
+ expires_in: number;
36
+ interval: number;
37
+ };
38
+ /** A GitHub user object. */
39
+ export type GithubUser = {
40
+ login: string;
41
+ };
42
+ /** Fetches the authenticated user and their granted OAuth scopes. */
43
+ export declare function fetchGithubUser(token: string): Promise<{
44
+ user: GithubUser;
45
+ scopes: string[];
46
+ }>;
47
+ /**
48
+ * Fetches a GitHub release for `repo`. Returns `null` if no release exists.
49
+ * When `tag` is provided, fetches that specific release.
50
+ * When `prerelease` is true, fetches the latest pre-release; otherwise fetches the latest production release.
51
+ */
52
+ export declare function fetchRelease(repo: string, tag?: string, prerelease?: boolean): Promise<ReleaseRef | null>;
53
+ /** Fetches raw file content from a GitHub repository at a specific ref. Returns `null` if the file does not exist. */
54
+ export declare function fetchRaw(repo: string, ref: string, filename: string): Promise<string | null>;
55
+ /**
56
+ * Fetches the annotated git tag object for `tagName` in `repo`.
57
+ * Returns `null` for lightweight tags (no message) or if the tag does not exist.
58
+ */
59
+ export declare function fetchGitTag(repo: string, tagName: string): Promise<{
60
+ message: string;
61
+ } | null>;
62
+ /** Basic metadata for a GitHub repository. */
63
+ export type GithubRepo = {
64
+ full_name: string;
65
+ description: string | null;
66
+ default_branch: string;
67
+ stargazers_count: number;
68
+ open_issues_count: number;
69
+ visibility: string;
70
+ };
71
+ /** Fetches basic repository metadata from the GitHub API using an explicit token. */
72
+ export declare function fetchRepoInfo(repo: string, token: string): Promise<GithubRepo>;
73
+ /**
74
+ * Returns the package namespace declared in a CCI repo's `cumulusci.yml` at `ref`.
75
+ * Returns an empty string if the file is missing or declares no namespace.
76
+ */
77
+ export declare function fetchCciNamespace(repo: string, ref: string): Promise<string>;
78
+ /**
79
+ * Lists the immediate subdirectories of `path` in a GitHub repo at `ref`.
80
+ * Returns an empty array if the path does not exist.
81
+ */
82
+ export declare function fetchSubdirs(repo: string, ref: string, path: string): Promise<string[]>;
83
+ /** Downloads a GitHub repository directory at `ref` into `localDir`, recursing into subdirectories. */
84
+ export declare function downloadDir(repo: string, ref: string, remotePath: string, localDir: string): Promise<void>;
85
+ /** Authenticated GitHub API call. Throws ExpectedError on non-2xx. */
86
+ export declare function gh<T>(token: string, path: string, init?: {
87
+ method?: string;
88
+ body?: unknown;
89
+ }): Promise<T>;
90
+ /** Returns the SHA of the first commit on the repo's default branch, or null. */
91
+ export declare function fetchFirstCommitSha(repo: string, token: string): Promise<string | null>;
92
+ /** Resolves a commit SHA from a full 40-char SHA, branch name, or the repo's default branch. */
93
+ export declare function resolveCommitSha(target: string | undefined, token: string, repo: string): Promise<string>;
94
+ /** Initiates the GitHub OAuth device flow and returns the device code response. */
95
+ export declare function requestDeviceCode(): Promise<DeviceCodeResponse>;
96
+ /** Polls the GitHub token endpoint until the user authorizes the device or an error occurs. */
97
+ export declare function pollForToken(deviceCode: string, interval: number): Promise<string>;
98
+ export {};