@foliwake/cli 0.0.0-stage → 0.7.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 (256) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/LICENSE +202 -0
  3. package/README.md +654 -2
  4. package/dist/bin.d.ts +2 -0
  5. package/dist/bin.js +9 -0
  6. package/dist/command-words.d.ts +13 -0
  7. package/dist/command-words.js +53 -0
  8. package/dist/commands/account/keys/create.d.ts +12 -0
  9. package/dist/commands/account/keys/create.js +36 -0
  10. package/dist/commands/account/keys/list.d.ts +9 -0
  11. package/dist/commands/account/keys/list.js +23 -0
  12. package/dist/commands/account/keys/revoke.d.ts +12 -0
  13. package/dist/commands/account/keys/revoke.js +15 -0
  14. package/dist/commands/branch/bootstrap.d.ts +11 -0
  15. package/dist/commands/branch/bootstrap.js +23 -0
  16. package/dist/commands/branch/delete.d.ts +17 -0
  17. package/dist/commands/branch/delete.js +38 -0
  18. package/dist/commands/branch/history.d.ts +14 -0
  19. package/dist/commands/branch/history.js +24 -0
  20. package/dist/commands/branch/list.d.ts +11 -0
  21. package/dist/commands/branch/list.js +15 -0
  22. package/dist/commands/branch/update.d.ts +19 -0
  23. package/dist/commands/branch/update.js +49 -0
  24. package/dist/commands/code/deploy.d.ts +15 -0
  25. package/dist/commands/code/deploy.js +78 -0
  26. package/dist/commands/code/prepare.d.ts +13 -0
  27. package/dist/commands/code/prepare.js +54 -0
  28. package/dist/commands/code/release.d.ts +19 -0
  29. package/dist/commands/code/release.js +51 -0
  30. package/dist/commands/code/rollback.d.ts +17 -0
  31. package/dist/commands/code/rollback.js +38 -0
  32. package/dist/commands/connect.d.ts +19 -0
  33. package/dist/commands/connect.js +100 -0
  34. package/dist/commands/create.d.ts +32 -0
  35. package/dist/commands/create.js +171 -0
  36. package/dist/commands/credential/list.d.ts +10 -0
  37. package/dist/commands/credential/list.js +21 -0
  38. package/dist/commands/credential/rm.d.ts +12 -0
  39. package/dist/commands/credential/rm.js +18 -0
  40. package/dist/commands/credential/set.d.ts +15 -0
  41. package/dist/commands/credential/set.js +58 -0
  42. package/dist/commands/dev.d.ts +30 -0
  43. package/dist/commands/dev.js +144 -0
  44. package/dist/commands/login.d.ts +20 -0
  45. package/dist/commands/login.js +94 -0
  46. package/dist/commands/logout.d.ts +14 -0
  47. package/dist/commands/logout.js +61 -0
  48. package/dist/commands/migration/commit.d.ts +13 -0
  49. package/dist/commands/migration/commit.js +42 -0
  50. package/dist/commands/migration/prepare.d.ts +18 -0
  51. package/dist/commands/migration/prepare.js +53 -0
  52. package/dist/commands/operation/cancel.d.ts +14 -0
  53. package/dist/commands/operation/cancel.js +21 -0
  54. package/dist/commands/operation/get.d.ts +14 -0
  55. package/dist/commands/operation/get.js +26 -0
  56. package/dist/commands/operation/list.d.ts +12 -0
  57. package/dist/commands/operation/list.js +25 -0
  58. package/dist/commands/operation/recover.d.ts +20 -0
  59. package/dist/commands/operation/recover.js +61 -0
  60. package/dist/commands/page/changes.d.ts +13 -0
  61. package/dist/commands/page/changes.js +26 -0
  62. package/dist/commands/page/check.d.ts +12 -0
  63. package/dist/commands/page/check.js +25 -0
  64. package/dist/commands/page/replace.d.ts +13 -0
  65. package/dist/commands/page/replace.js +59 -0
  66. package/dist/commands/page/unpreview.d.ts +17 -0
  67. package/dist/commands/page/unpreview.js +54 -0
  68. package/dist/commands/page/unpublish.d.ts +18 -0
  69. package/dist/commands/page/unpublish.js +36 -0
  70. package/dist/commands/project/preview.d.ts +8 -0
  71. package/dist/commands/project/preview.js +20 -0
  72. package/dist/commands/project/publish.d.ts +16 -0
  73. package/dist/commands/project/publish.js +40 -0
  74. package/dist/commands/project/unpublish.d.ts +16 -0
  75. package/dist/commands/project/unpublish.js +33 -0
  76. package/dist/commands/release/rollback.d.ts +17 -0
  77. package/dist/commands/release/rollback.js +38 -0
  78. package/dist/commands/servers/index.d.ts +20 -0
  79. package/dist/commands/servers/index.js +36 -0
  80. package/dist/commands/servers/use.d.ts +11 -0
  81. package/dist/commands/servers/use.js +30 -0
  82. package/dist/commands/site/adopt.d.ts +11 -0
  83. package/dist/commands/site/adopt.js +21 -0
  84. package/dist/commands/site/create.d.ts +18 -0
  85. package/dist/commands/site/create.js +61 -0
  86. package/dist/commands/site/edit.d.ts +11 -0
  87. package/dist/commands/site/edit.js +56 -0
  88. package/dist/commands/site/history.d.ts +11 -0
  89. package/dist/commands/site/history.js +25 -0
  90. package/dist/commands/site/link.d.ts +15 -0
  91. package/dist/commands/site/link.js +35 -0
  92. package/dist/commands/site/list.d.ts +9 -0
  93. package/dist/commands/site/list.js +29 -0
  94. package/dist/commands/site/reset-storage.d.ts +15 -0
  95. package/dist/commands/site/reset-storage.js +61 -0
  96. package/dist/commands/site/set.d.ts +16 -0
  97. package/dist/commands/site/set.js +45 -0
  98. package/dist/commands/site/show.d.ts +10 -0
  99. package/dist/commands/site/show.js +19 -0
  100. package/dist/commands/site/status.d.ts +11 -0
  101. package/dist/commands/site/status.js +15 -0
  102. package/dist/commands/site/unlink.d.ts +11 -0
  103. package/dist/commands/site/unlink.js +28 -0
  104. package/dist/commands/source/add.d.ts +32 -0
  105. package/dist/commands/source/add.js +103 -0
  106. package/dist/commands/source/adopt-pages.d.ts +14 -0
  107. package/dist/commands/source/adopt-pages.js +30 -0
  108. package/dist/commands/source/check.d.ts +17 -0
  109. package/dist/commands/source/check.js +52 -0
  110. package/dist/commands/source/list.d.ts +11 -0
  111. package/dist/commands/source/list.js +15 -0
  112. package/dist/commands/source/mappings/check.d.ts +13 -0
  113. package/dist/commands/source/mappings/check.js +69 -0
  114. package/dist/commands/source/pending.d.ts +12 -0
  115. package/dist/commands/source/pending.js +25 -0
  116. package/dist/commands/source/plugins.d.ts +6 -0
  117. package/dist/commands/source/plugins.js +17 -0
  118. package/dist/commands/source/sync.d.ts +16 -0
  119. package/dist/commands/source/sync.js +58 -0
  120. package/dist/commands/whoami.d.ts +6 -0
  121. package/dist/commands/whoami.js +22 -0
  122. package/dist/connect-prompts.d.ts +16 -0
  123. package/dist/connect-prompts.js +24 -0
  124. package/dist/connect.d.ts +133 -0
  125. package/dist/connect.js +416 -0
  126. package/dist/core-command.d.ts +99 -0
  127. package/dist/core-command.js +332 -0
  128. package/dist/core-types.d.ts +21 -0
  129. package/dist/core-types.js +1 -0
  130. package/dist/create-connect.d.ts +26 -0
  131. package/dist/create-connect.js +93 -0
  132. package/dist/dev/code-watcher.d.ts +66 -0
  133. package/dist/dev/code-watcher.js +254 -0
  134. package/dist/dev/dev-checks.d.ts +14 -0
  135. package/dist/dev/dev-checks.js +138 -0
  136. package/dist/dev/dev-reload.d.ts +51 -0
  137. package/dist/dev/dev-reload.js +345 -0
  138. package/dist/dev/flags.d.ts +19 -0
  139. package/dist/dev/flags.js +54 -0
  140. package/dist/dev/html.d.ts +30 -0
  141. package/dist/dev/html.js +106 -0
  142. package/dist/dev/kit-files.d.ts +7 -0
  143. package/dist/dev/kit-files.js +33 -0
  144. package/dist/dev/local-code.d.ts +22 -0
  145. package/dist/dev/local-code.js +101 -0
  146. package/dist/dev/remote-config.d.ts +57 -0
  147. package/dist/dev/remote-config.js +100 -0
  148. package/dist/dev/remote-dev.d.ts +41 -0
  149. package/dist/dev/remote-dev.js +527 -0
  150. package/dist/dev/remote-fetch.d.ts +5 -0
  151. package/dist/dev/remote-fetch.js +36 -0
  152. package/dist/dev/remote-html.d.ts +10 -0
  153. package/dist/dev/remote-html.js +60 -0
  154. package/dist/dev/remote-page.d.ts +34 -0
  155. package/dist/dev/remote-page.js +183 -0
  156. package/dist/dev/remote-routes.d.ts +63 -0
  157. package/dist/dev/remote-routes.js +114 -0
  158. package/dist/dev/signal-stop.d.ts +17 -0
  159. package/dist/dev/signal-stop.js +46 -0
  160. package/dist/dev/start.d.ts +18 -0
  161. package/dist/dev/start.js +80 -0
  162. package/dist/index.d.ts +6 -0
  163. package/dist/index.js +8 -0
  164. package/dist/lib/diagnostics.d.ts +15 -0
  165. package/dist/lib/diagnostics.js +12 -0
  166. package/dist/lib/front-matter.d.ts +6 -0
  167. package/dist/lib/front-matter.js +59 -0
  168. package/dist/lib/operation-result.d.ts +3 -0
  169. package/dist/lib/operation-result.js +16 -0
  170. package/dist/lib/problem-groups.d.ts +27 -0
  171. package/dist/lib/problem-groups.js +49 -0
  172. package/dist/lib/problems.d.ts +50 -0
  173. package/dist/lib/problems.js +94 -0
  174. package/dist/lib/prompts.d.ts +38 -0
  175. package/dist/lib/prompts.js +77 -0
  176. package/dist/lib/result-types.d.ts +198 -0
  177. package/dist/lib/result-types.js +3 -0
  178. package/dist/lib/rules.d.ts +15 -0
  179. package/dist/lib/rules.js +26 -0
  180. package/dist/lib/summaries.d.ts +19 -0
  181. package/dist/lib/summaries.js +22 -0
  182. package/dist/lib/sync-problems.d.ts +21 -0
  183. package/dist/lib/sync-problems.js +19 -0
  184. package/dist/local-runtime.d.ts +78 -0
  185. package/dist/local-runtime.js +11 -0
  186. package/dist/local-target.d.ts +6 -0
  187. package/dist/local-target.js +23 -0
  188. package/dist/main.d.ts +2 -0
  189. package/dist/main.js +40 -0
  190. package/dist/project-preview.d.ts +35 -0
  191. package/dist/project-preview.js +156 -0
  192. package/dist/project-publish.d.ts +28 -0
  193. package/dist/project-publish.js +173 -0
  194. package/dist/remote/connection.d.ts +8 -0
  195. package/dist/remote/connection.js +19 -0
  196. package/dist/remote/core-failure.d.ts +8 -0
  197. package/dist/remote/core-failure.js +15 -0
  198. package/dist/remote/credentials.d.ts +15 -0
  199. package/dist/remote/credentials.js +112 -0
  200. package/dist/remote/device-login.d.ts +33 -0
  201. package/dist/remote/device-login.js +161 -0
  202. package/dist/remote/remote-caller.d.ts +14 -0
  203. package/dist/remote/remote-caller.js +52 -0
  204. package/dist/remote/rpc-wire.d.ts +18 -0
  205. package/dist/remote/rpc-wire.js +57 -0
  206. package/dist/remote/servers.d.ts +80 -0
  207. package/dist/remote/servers.js +162 -0
  208. package/dist/remote/session.d.ts +53 -0
  209. package/dist/remote/session.js +132 -0
  210. package/dist/remote/sign-in-here.d.ts +5 -0
  211. package/dist/remote/sign-in-here.js +33 -0
  212. package/dist/remote/sign-in.d.ts +25 -0
  213. package/dist/remote/sign-in.js +55 -0
  214. package/dist/remote/wait-slices.d.ts +16 -0
  215. package/dist/remote/wait-slices.js +21 -0
  216. package/dist/render/add.d.ts +3 -0
  217. package/dist/render/add.js +9 -0
  218. package/dist/render/branch-write.d.ts +9 -0
  219. package/dist/render/branch-write.js +28 -0
  220. package/dist/render/branches.d.ts +5 -0
  221. package/dist/render/branches.js +28 -0
  222. package/dist/render/credentials.d.ts +5 -0
  223. package/dist/render/credentials.js +39 -0
  224. package/dist/render/operation-result.d.ts +16 -0
  225. package/dist/render/operation-result.js +65 -0
  226. package/dist/render/operation.d.ts +7 -0
  227. package/dist/render/operation.js +15 -0
  228. package/dist/render/page-changes.d.ts +3 -0
  229. package/dist/render/page-changes.js +36 -0
  230. package/dist/render/pending.d.ts +3 -0
  231. package/dist/render/pending.js +46 -0
  232. package/dist/render/plugin-list.d.ts +3 -0
  233. package/dist/render/plugin-list.js +30 -0
  234. package/dist/render/probe.d.ts +3 -0
  235. package/dist/render/probe.js +61 -0
  236. package/dist/render/problems.d.ts +35 -0
  237. package/dist/render/problems.js +64 -0
  238. package/dist/render/recovery.d.ts +2 -0
  239. package/dist/render/recovery.js +36 -0
  240. package/dist/render/reset-storage.d.ts +4 -0
  241. package/dist/render/reset-storage.js +70 -0
  242. package/dist/render/site-status.d.ts +2 -0
  243. package/dist/render/site-status.js +81 -0
  244. package/dist/render/source-list.d.ts +2 -0
  245. package/dist/render/source-list.js +37 -0
  246. package/dist/render/sync.d.ts +5 -0
  247. package/dist/render/sync.js +66 -0
  248. package/dist/settings.d.ts +10 -0
  249. package/dist/settings.js +45 -0
  250. package/dist/site-entry-edit.d.ts +5 -0
  251. package/dist/site-entry-edit.js +44 -0
  252. package/dist/source-entry.d.ts +32 -0
  253. package/dist/source-entry.js +89 -0
  254. package/dist/version.d.ts +3 -0
  255. package/dist/version.js +10 -0
  256. package/package.json +112 -3
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The arguments with the command words first, or null when no known command is named before `--`.
3
+ * `takesValue` says which `--name` consumes the next argument; `ids`: the commands, words joined by `:`.
4
+ */
5
+ export declare function commandWordsFirst(argv: readonly string[], takesValue: (name: string) => boolean, ids: ReadonlySet<string>): string[] | null;
6
+ /**
7
+ * `preview` and `publish` are always the project's (`project preview|publish`): without the engine there is
8
+ * no local configuration to preview. Null when the line names neither, or names a local configuration
9
+ * (`--config`, `--site`, `--content`: the engine's legacy commands), which `engineOnlyProject` refuses.
10
+ */
11
+ export declare function projectCommand(argv: readonly string[]): string[] | null;
12
+ /** The flag that makes `preview`/`publish` the engine's legacy command, or null. */
13
+ export declare function engineOnlyProject(argv: readonly string[]): string | null;
@@ -0,0 +1,53 @@
1
+ // oclif needs a command's words first; people also write flags before them (`foliwake --site a site status`,
2
+ // `foliwake --debug whoami`). This moves the words of a known command to the front and keeps every flag and
3
+ // value in its order. `--` ends the search: what follows is positional.
4
+ /** Positions of the first two words (non-flag arguments) before `--`, skipping the values of value flags. */
5
+ function wordPositions(argv, takesValue) {
6
+ const positions = [];
7
+ for (let i = 0; i < argv.length && positions.length < 2; i++) {
8
+ const arg = argv[i];
9
+ if (arg === '--')
10
+ break;
11
+ if (!arg.startsWith('-'))
12
+ positions.push(i);
13
+ else if (arg.startsWith('--') && !arg.includes('=') && takesValue(arg.slice(2)))
14
+ i++;
15
+ }
16
+ return positions;
17
+ }
18
+ /**
19
+ * The arguments with the command words first, or null when no known command is named before `--`.
20
+ * `takesValue` says which `--name` consumes the next argument; `ids`: the commands, words joined by `:`.
21
+ */
22
+ export function commandWordsFirst(argv, takesValue, ids) {
23
+ const rest = [...argv];
24
+ const positions = wordPositions(rest, takesValue);
25
+ const words = positions.map((position) => rest[position]);
26
+ const count = ids.has(words.join(':')) ? 2 : ids.has(words[0] ?? '') ? 1 : 0;
27
+ if (count === 0)
28
+ return null;
29
+ for (const position of positions.slice(0, count).reverse())
30
+ rest.splice(position, 1);
31
+ return [...words.slice(0, count), ...rest];
32
+ }
33
+ /** The words people type for the linked folder's preview and publication. */
34
+ const PROJECT_WORDS = new Set(['preview', 'publish']);
35
+ const ENGINE_FLAGS = /^--(config|site|content)(=|$)/;
36
+ /**
37
+ * `preview` and `publish` are always the project's (`project preview|publish`): without the engine there is
38
+ * no local configuration to preview. Null when the line names neither, or names a local configuration
39
+ * (`--config`, `--site`, `--content`: the engine's legacy commands), which `engineOnlyProject` refuses.
40
+ */
41
+ export function projectCommand(argv) {
42
+ if (!PROJECT_WORDS.has(argv[0] ?? ''))
43
+ return null;
44
+ if (argv.some((arg) => ENGINE_FLAGS.test(arg)))
45
+ return null;
46
+ return ['project', ...argv];
47
+ }
48
+ /** The flag that makes `preview`/`publish` the engine's legacy command, or null. */
49
+ export function engineOnlyProject(argv) {
50
+ if (!PROJECT_WORDS.has(argv[0] ?? ''))
51
+ return null;
52
+ return argv.find((arg) => ENGINE_FLAGS.test(arg))?.replace(/=.*$/, '') ?? null;
53
+ }
@@ -0,0 +1,12 @@
1
+ import { CoreCommand } from '../../../core-command.js';
2
+ export default class AccountKeysCreate extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ site: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
7
+ label: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ run(): Promise<unknown>;
12
+ }
@@ -0,0 +1,36 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { COMMAND } from '../../../settings.js';
3
+ import { CoreCommand } from '../../../core-command.js';
4
+ const C = COMMAND;
5
+ export default class AccountKeysCreate extends CoreCommand {
6
+ static description = 'Make a CI key: it may only deploy code and update branch previews of the named sites (role ci); ' +
7
+ 'shown once, kept as a hash (core account.keys.create)';
8
+ static examples = [
9
+ '<%= config.bin %> account keys create --site my-site --label "GitHub Actions" --server https://admin.example.com',
10
+ ];
11
+ static flags = {
12
+ ...CoreCommand.configFlag,
13
+ site: Flags.string({
14
+ description: 'a site the key may release code of (repeat for several)',
15
+ multiple: true,
16
+ required: true,
17
+ }),
18
+ label: Flags.string({
19
+ description: 'what the key is for, e.g. the pipeline (shown in `account keys list`)',
20
+ required: true,
21
+ }),
22
+ org: Flags.string({ description: 'the organisation of the sites (default: the only one you administer)' }),
23
+ };
24
+ async run() {
25
+ const { flags } = await this.parse(AccountKeysCreate);
26
+ const input = { sites: flags.site, label: flags.label, ...(flags.org === undefined ? {} : { org: flags.org }) };
27
+ const answer = await this.core.account.keys.create(input);
28
+ const { ciKey } = answer;
29
+ this.log(`CI key ${ciKey.id} for ${ciKey.sites.join(', ')} in ${ciKey.org} (${ciKey.label}).`);
30
+ this.log('Store it now as a secret of the pipeline; it is not shown again:');
31
+ this.log(` FOLIWAKE_TOKEN=${answer.key}`);
32
+ this.log('The pipeline also sets FOLIWAKE_SERVER to this server.');
33
+ this.log(`Revoke it with \`${C} account keys revoke ${ciKey.id}\`.`);
34
+ return answer;
35
+ }
36
+ }
@@ -0,0 +1,9 @@
1
+ import { CoreCommand } from '../../../core-command.js';
2
+ export default class AccountKeysList extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ };
8
+ run(): Promise<unknown>;
9
+ }
@@ -0,0 +1,23 @@
1
+ import { CoreCommand } from '../../../core-command.js';
2
+ const when = (ms) => (ms === null ? 'never' : new Date(ms).toISOString());
3
+ export default class AccountKeysList extends CoreCommand {
4
+ static description = 'Your signed-in computers and the CI keys of the organisations you administer; never a key itself ' +
5
+ '(core account.keys.list and account.keys.ci)';
6
+ static examples = ['<%= config.bin %> account keys list', '<%= config.bin %> account keys list --json'];
7
+ static flags = { ...CoreCommand.configFlag };
8
+ async run() {
9
+ await this.parse(AccountKeysList);
10
+ const ci = await this.core.account.keys.ci();
11
+ const computers = await this.core.account.keys.list().catch(() => []);
12
+ for (const key of computers) {
13
+ this.log(`${key.id} computer ${key.name} (${key.client}), last used ${when(key.lastUsedAt)}`);
14
+ }
15
+ for (const key of ci) {
16
+ const scope = `${key.sites.join(', ')} in ${key.org}`;
17
+ this.log(`${key.id} CI ${key.label}: ${scope}, made by ${key.createdBy}, last used ${when(key.lastUsedAt)}`);
18
+ }
19
+ if (computers.length === 0 && ci.length === 0)
20
+ this.log('No keys.');
21
+ return { computers, ci };
22
+ }
23
+ }
@@ -0,0 +1,12 @@
1
+ import { CoreCommand } from '../../../core-command.js';
2
+ export default class AccountKeysRevoke extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ run(): Promise<unknown>;
12
+ }
@@ -0,0 +1,15 @@
1
+ import { Args } from '@oclif/core';
2
+ import { CoreCommand } from '../../../core-command.js';
3
+ export default class AccountKeysRevoke extends CoreCommand {
4
+ static description = 'Revoke a key at once: a CI key of an organisation you administer (ci_…), or one of your signed-in ' +
5
+ 'computers (key_…) (core account.keys.revoke)';
6
+ static examples = ['<%= config.bin %> account keys revoke ci_0123456789abcdef'];
7
+ static args = { key: Args.string({ description: 'the key ID, as `account keys list` shows it', required: true }) };
8
+ static flags = { ...CoreCommand.configFlag };
9
+ async run() {
10
+ const { args } = await this.parse(AccountKeysRevoke);
11
+ await this.core.account.keys.revoke({ key: args.key });
12
+ this.log(`Revoked ${args.key}; it no longer works.`);
13
+ return { revoked: args.key };
14
+ }
15
+ }
@@ -0,0 +1,11 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class BranchBootstrap extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ };
10
+ run(): Promise<unknown>;
11
+ }
@@ -0,0 +1,23 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ import { branchUrls, branchWriteReport } from '../../render/branch-write.js';
3
+ export default class BranchBootstrap extends CoreCommand {
4
+ static description = 'Once: seed the default branch preview from live code; a no-op when it exists (core branches.bootstrap)';
5
+ static examples = ['<%= config.bin %> branch bootstrap', '<%= config.bin %> branch bootstrap --site a --json'];
6
+ static flags = { ...CoreCommand.siteFlags, ...CoreCommand.inputFlag };
7
+ async run() {
8
+ const { flags } = await this.parse(BranchBootstrap);
9
+ const input = await this.resolveInput(flags.input, () => this.siteInput(flags.site));
10
+ const operation = await this.follow(await this.core.branches.bootstrap(input), {
11
+ wait: false,
12
+ waitTimeout: undefined,
13
+ });
14
+ const report = branchWriteReport(operation, (result) => [
15
+ `Branch ${result.branch} now previews live code ${result.codeRelease}: ${branchUrls(result)}`,
16
+ ]);
17
+ if (!this.jsonEnabled())
18
+ for (const line of report.lines)
19
+ this.log(line);
20
+ process.exitCode = report.exitCode;
21
+ return operation;
22
+ }
23
+ }
@@ -0,0 +1,17 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class BranchDelete extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ branch: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ expect: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'latest-selection': import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ sequence: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ };
16
+ run(): Promise<unknown>;
17
+ }
@@ -0,0 +1,38 @@
1
+ import { Args } from '@oclif/core';
2
+ import { COMMAND } from '../../settings.js';
3
+ import { CoreCommand } from '../../core-command.js';
4
+ import { branchWriteReport } from '../../render/branch-write.js';
5
+ export default class BranchDelete extends CoreCommand {
6
+ static description = 'Stop serving a branch preview (its hosts answer 404); its code and selection history stay (core branches.remove)';
7
+ static examples = [
8
+ '<%= config.bin %> branch delete feature/hero --expect sel_…',
9
+ '<%= config.bin %> branch delete feature/hero --latest-selection',
10
+ '<%= config.bin %> branch delete feature/hero --sequence <ci run id> --json',
11
+ ];
12
+ static args = { branch: Args.string({ description: 'the Git branch whose preview stops' }) };
13
+ static flags = { ...CoreCommand.siteFlags, ...CoreCommand.expectBranchFlags, ...CoreCommand.inputFlag };
14
+ async run() {
15
+ const { args, flags } = await this.parse(BranchDelete);
16
+ const input = await this.resolveInput(flags.input, async () => {
17
+ if (args.branch == null)
18
+ this.error('Name the branch.', { exit: 2 });
19
+ const { site } = await this.siteInput(flags.site);
20
+ return { site, branch: args.branch, expect: await this.expectedBranch(site, args.branch, flags) };
21
+ });
22
+ const operation = await this.follow(await this.core.branches.remove(input), {
23
+ wait: false,
24
+ waitTimeout: undefined,
25
+ });
26
+ const report = branchWriteReport(operation, (result) => [
27
+ `Branch ${result.branch} is no longer previewed: its ` +
28
+ `hosts${result.releasedHost ? ` (and ${result.releasedHost})` : ''} now answer 404.`,
29
+ `Its code ${result.codeRelease ?? ''} and selection history stay in storage (immutable). \`${COMMAND} branch ` +
30
+ `update ${result.branch}\` revives it.`,
31
+ ]);
32
+ if (!this.jsonEnabled())
33
+ for (const line of report.lines)
34
+ this.log(line);
35
+ process.exitCode = report.exitCode;
36
+ return operation;
37
+ }
38
+ }
@@ -0,0 +1,14 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class BranchHistory extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ branch: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ };
13
+ run(): Promise<unknown>;
14
+ }
@@ -0,0 +1,24 @@
1
+ import { Args } from '@oclif/core';
2
+ import { CoreCommand } from '../../core-command.js';
3
+ import { branchHistoryLines } from '../../render/branches.js';
4
+ export default class BranchHistory extends CoreCommand {
5
+ static description = 'Selection history of one branch (core branches.history)';
6
+ static examples = [
7
+ '<%= config.bin %> branch history main',
8
+ '<%= config.bin %> branch history feature/hero --site a --json',
9
+ ];
10
+ static args = { branch: Args.string({ description: 'the branch' }) };
11
+ static flags = { ...CoreCommand.siteFlags, ...CoreCommand.inputFlag };
12
+ async run() {
13
+ const { args, flags } = await this.parse(BranchHistory);
14
+ const input = await this.resolveInput(flags.input, async () => {
15
+ if (args.branch == null)
16
+ this.error('Name the branch (or pass the full input as --input JSON).', { exit: 2 });
17
+ return { ...(await this.siteInput(flags.site)), branch: args.branch };
18
+ });
19
+ const history = await this.core.branches.history(input);
20
+ for (const line of branchHistoryLines(history))
21
+ this.log(line);
22
+ return history;
23
+ }
24
+ }
@@ -0,0 +1,11 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class BranchList extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ };
10
+ run(): Promise<unknown>;
11
+ }
@@ -0,0 +1,15 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ import { branchListLines } from '../../render/branches.js';
3
+ export default class BranchList extends CoreCommand {
4
+ static description = 'Branches, their code and preview URLs (core branches.list)';
5
+ static examples = ['<%= config.bin %> branch list', '<%= config.bin %> branch list --site a --json'];
6
+ static flags = { ...CoreCommand.siteFlags, ...CoreCommand.inputFlag };
7
+ async run() {
8
+ const { flags } = await this.parse(BranchList);
9
+ const input = await this.resolveInput(flags.input, () => this.siteInput(flags.site));
10
+ const rows = await this.core.branches.list(input);
11
+ for (const line of branchListLines(rows))
12
+ this.log(line);
13
+ return rows;
14
+ }
15
+ }
@@ -0,0 +1,19 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class BranchUpdate extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ branch: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ expect: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'latest-selection': import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ sequence: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ rev: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ code: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ };
18
+ run(): Promise<unknown>;
19
+ }
@@ -0,0 +1,49 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { CoreCommand } from '../../core-command.js';
3
+ import { branchUrls, branchWriteReport } from '../../render/branch-write.js';
4
+ export default class BranchUpdate extends CoreCommand {
5
+ static description = 'Prepare code from a commit (or use --code) and show it in that branch preview; live is unchanged (core ' +
6
+ 'branches.update)';
7
+ static examples = [
8
+ '<%= config.bin %> branch update feature/hero --rev feature/hero --latest-selection',
9
+ '<%= config.bin %> branch update feature/hero --code cd_… --expect sel_…',
10
+ '<%= config.bin %> branch update feature/hero --rev <sha> --sequence <ci run id> --json',
11
+ ];
12
+ static args = { branch: Args.string({ description: 'the Git branch whose preview this is' }) };
13
+ static flags = {
14
+ ...CoreCommand.siteFlags,
15
+ rev: Flags.string({
16
+ description: 'the commit to prepare the code from, a branch, tag or full SHA (default HEAD)',
17
+ exclusive: ['code'],
18
+ }),
19
+ code: Flags.string({
20
+ description: 'an already prepared code release (cd_…) instead of preparing one',
21
+ exclusive: ['rev'],
22
+ }),
23
+ ...CoreCommand.expectBranchFlags,
24
+ ...CoreCommand.inputFlag,
25
+ };
26
+ async run() {
27
+ const { args, flags } = await this.parse(BranchUpdate);
28
+ const input = await this.resolveInput(flags.input, async () => {
29
+ if (args.branch == null)
30
+ this.error('Name the branch.', { exit: 2 });
31
+ const { site } = await this.siteInput(flags.site);
32
+ const from = flags.code === undefined ? { rev: flags.rev ?? 'HEAD' } : { code: flags.code };
33
+ return { site, branch: args.branch, from, expect: await this.expectedBranch(site, args.branch, flags) };
34
+ });
35
+ const operation = await this.follow(await this.core.branches.update(input), {
36
+ wait: false,
37
+ waitTimeout: undefined,
38
+ });
39
+ const report = branchWriteReport(operation, (result) => [
40
+ `Branch ${result.branch} previews ${result.codeRelease}: ${branchUrls(result)}`,
41
+ 'Live is unchanged.',
42
+ ]);
43
+ if (!this.jsonEnabled())
44
+ for (const line of report.lines)
45
+ this.log(line);
46
+ process.exitCode = report.exitCode;
47
+ return operation;
48
+ }
49
+ }
@@ -0,0 +1,15 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class CodeDeploy extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ rev: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ sequence: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ run(): Promise<unknown>;
13
+ /** Where to look after a failed deploy: the trace its operation recorded (when traces were exported). */
14
+ private traceOf;
15
+ }
@@ -0,0 +1,78 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { COMMAND } from '../../settings.js';
3
+ import { CoreCommand } from '../../core-command.js';
4
+ import { traceLines } from '../../render/operation.js';
5
+ const C = COMMAND;
6
+ export default class CodeDeploy extends CoreCommand {
7
+ static description = "Deploy a commit of the site's frontend: prepare it, rebuild every page against it in preview and, with " +
8
+ 'codeRelease auto, release exactly that pair when its checks pass (core code.deploy). Its progress goes to ' +
9
+ 'stderr while it runs (one JSON event per line with --json); `operation list` shows it too';
10
+ static examples = ['<%= config.bin %> code deploy --rev <40-hex sha> --sequence <ci run id> --json'];
11
+ static flags = {
12
+ ...CoreCommand.siteFlags,
13
+ rev: Flags.string({ description: 'the full commit SHA to deploy' }),
14
+ sequence: Flags.integer({
15
+ description: 'deployment ordering, e.g. a CI run id; an older one than live code is not released',
16
+ min: 1,
17
+ }),
18
+ ...CoreCommand.inputFlag,
19
+ };
20
+ async run() {
21
+ const { flags } = await this.parse(CodeDeploy);
22
+ const input = await this.resolveInput(flags.input, async () => {
23
+ if (flags.rev === undefined)
24
+ this.error('Name the commit with --rev <40-hex sha>.', { exit: 2 });
25
+ return {
26
+ ...(await this.siteInput(flags.site)),
27
+ rev: flags.rev,
28
+ ...(flags.sequence === undefined ? {} : { sequence: flags.sequence }),
29
+ };
30
+ });
31
+ const answer = await this.core.code.deploy(input);
32
+ if (answer.result === 'released')
33
+ this.log(`Released ${answer.codeRelease} with every page (${answer.siteRelease}). To go back: \`${C} release ` +
34
+ `rollback ${answer.previousSiteRelease} --expect ${answer.siteRelease}\`.`);
35
+ else if (answer.result === 'prepared')
36
+ this.log(`Prepared ${answer.codeRelease}; every page rebuilt in preview (${answer.previewRelease}). Live is ` +
37
+ `unchanged.${answer.reason ? ` ${answer.reason}` : ''} Release by hand: \`${C} migration commit --expect ` +
38
+ `${answer.expect}\`.`);
39
+ else
40
+ this.log(`Failed${answer.code ? ` (${answer.code})` : ''}: ${answer.reason ?? 'no reason'}`);
41
+ for (const gate of answer.gates)
42
+ this.log(` ${gate.ok ? 'ok ' : 'FAIL'} ${gate.gate}: ${gate.detail}`);
43
+ for (const item of answer.rebuild?.diagnostics ?? [])
44
+ this.log(` ${item.severity} ${item.code} ${item.file}:${item.line}:${item.column} ${item.message}`);
45
+ const t = answer.timings;
46
+ if (t) {
47
+ const steps = Object.entries(t.steps)
48
+ .map(([step, ms]) => `${step} ${(ms / 1000).toFixed(1)} s${t.stepStore?.[step] ? `/${t.stepStore[step].requests} req` : ''}`)
49
+ .join(', ');
50
+ this.log(` took ${(t.totalMs / 1000).toFixed(1)} s (${steps}); ${t.pagesBuilt} pages built; ${t.store.requests} ` +
51
+ `store requests (${t.store.notModified} checked without bytes), ` +
52
+ `${(t.store.bytesDown / 1048576).toFixed(1)} MiB down, ${(t.store.bytesUp / 1048576).toFixed(1)} MiB up`);
53
+ }
54
+ if (answer.operation)
55
+ this.log(` operation ${answer.operation} (\`${C} operation get ${answer.operation}\`)`);
56
+ if (answer.release?.delivery?.state === 'pending')
57
+ this.log(`Cache refresh still pending; \`${C} operation recover --wait\` finishes it.`);
58
+ // 0: released and delivered, or prepared for a manual release; 3: released, refresh pending; 1: failed or held by a
59
+ // check.
60
+ const held = answer.result === 'prepared' && answer.mode === 'auto';
61
+ if ((answer.result === 'failed' || held) && answer.operation) {
62
+ for (const line of await this.traceOf(input.site, answer.operation)) {
63
+ this.log(line);
64
+ }
65
+ }
66
+ process.exitCode = answer.result === 'failed' || held ? 1 : answer.release?.delivery?.state === 'pending' ? 3 : 0;
67
+ return answer;
68
+ }
69
+ /** Where to look after a failed deploy: the trace its operation recorded (when traces were exported). */
70
+ async traceOf(site, id) {
71
+ try {
72
+ return traceLines((await this.core.operations.get({ site, id })).trace);
73
+ }
74
+ catch {
75
+ return []; // the answer and its exit status do not depend on this read
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,13 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class CodePrepare extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ 'wait-timeout': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ rev: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ run(): Promise<unknown>;
13
+ }
@@ -0,0 +1,54 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { COMMAND } from '../../settings.js';
3
+ import { finishedResult } from '../../lib/operation-result.js';
4
+ import { CoreCommand } from '../../core-command.js';
5
+ import { longWriteReport } from '../../render/operation-result.js';
6
+ const C = COMMAND;
7
+ export default class CodePrepare extends CoreCommand {
8
+ static description = 'Copy JS/CSS from a clean commit into an immutable code release; on a site with a live release, live and ' +
9
+ 'preview are unchanged. On a site without one it changes live: it makes release 1, this code and no pages, ' +
10
+ 'and waits for its cache refresh (core code.prepare)';
11
+ static examples = [
12
+ '<%= config.bin %> code prepare',
13
+ '<%= config.bin %> code prepare --rev feature/hero',
14
+ '<%= config.bin %> code prepare --rev <sha> --json',
15
+ ];
16
+ static flags = {
17
+ ...CoreCommand.siteFlags,
18
+ rev: Flags.string({
19
+ description: 'the Git revision to copy, a branch, tag or full SHA (default HEAD); the checkout must be clean',
20
+ }),
21
+ ...CoreCommand.refreshWaitFlag,
22
+ ...CoreCommand.inputFlag,
23
+ };
24
+ async run() {
25
+ const { flags } = await this.parse(CodePrepare);
26
+ const input = await this.resolveInput(flags.input, async () => ({
27
+ ...(await this.siteInput(flags.site)),
28
+ ...(flags.rev === undefined ? {} : { rev: flags.rev }),
29
+ }));
30
+ // Release 1 of a new site goes live: its cache refresh is awaited (bounded) like any live write's.
31
+ const operation = await this.follow(await this.core.code.prepare(input), {
32
+ wait: true,
33
+ waitTimeout: flags['wait-timeout'],
34
+ });
35
+ const releaseOne = operation.result?.siteRelease != null;
36
+ const report = longWriteReport(operation, 'Created the site: release 1 with this code and no pages');
37
+ if (!this.jsonEnabled()) {
38
+ if (report.exitCode !== 0 || releaseOne)
39
+ for (const line of report.lines)
40
+ this.log(line);
41
+ else {
42
+ const { codeRelease, sourceRevision, message, diagnostics } = finishedResult(operation);
43
+ this.log(`Prepared ${codeRelease} from ${sourceRevision}.${message ? ` ${message}` : ''}`);
44
+ for (const item of diagnostics)
45
+ this.log(` ${item.severity} ${item.code} ${item.file}:${item.line}:${item.column} ${item.message}`);
46
+ this.log(`Live is unchanged. Show it in a branch preview with \`${C} branch update <branch> --code ${codeRelease} ` +
47
+ `--latest-selection\`, rebuild every page against it with \`${C} migration prepare ${codeRelease}\`, or ` +
48
+ `make it live as it is with \`${C} code release ${codeRelease} --latest-live\`.`);
49
+ }
50
+ }
51
+ process.exitCode = report.exitCode;
52
+ return operation;
53
+ }
54
+ }
@@ -0,0 +1,19 @@
1
+ import { CoreCommand } from '../../core-command.js';
2
+ export default class CodeRelease extends CoreCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ code: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ input: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'wait-timeout': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ rev: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ sequence: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ expect: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'latest-live': import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ site: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ };
18
+ run(): Promise<unknown>;
19
+ }