breakaway 1.0.2-main.24 → 1.0.2-main.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "breakaway",
3
- "version": "1.0.2-main.24",
3
+ "version": "1.0.2-main.25",
4
4
  "description": "The task board for you and your coding agents: a Cloudflare Worker, its web app, Taskwarrior sync, and the CLI (npx breakaway).",
5
5
  "license": "FSL-1.1-Apache-2.0",
6
6
  "type": "module",
@@ -92,8 +92,10 @@ export function writeInstall({ dir, templateDir, config, state }) {
92
92
  writeFileSync(target, text);
93
93
  written.push(path);
94
94
  };
95
- // The Worker reads the channel from its config (BRK-10), so it starts the same as breakaway.json's.
96
- put('breakaway.config.json', json({ ...config, channel: state.channel }));
95
+ // The Worker reads the channel from its config (BRK-10), so it starts the same as breakaway.json's. No aliases yet: an
96
+ // empty list is left out, so a release from before them (BRK-78) still reads the file.
97
+ const { aliases, ...named } = config;
98
+ put('breakaway.config.json', json({ ...named, ...(aliases?.length ? { aliases } : {}), channel: state.channel }));
97
99
  put('breakaway.json', json(state));
98
100
  for (const file of TEMPLATE_FILES) put(file, readFileSync(join(templateDir, file), 'utf8'));
99
101
  put('README.md', readmeFor(readFileSync(join(templateDir, 'README.md'), 'utf8'), config));
@@ -4,5 +4,5 @@
4
4
  * and how to update it. scripts/tasks/version.test.js fails when the copied files change and this doesn't:
5
5
  * so it lives in the board's package (CLD-135) and the CLI imports it from here.
6
6
  */
7
- export const CLI_VERSION = 45;
8
- export const CLI_FINGERPRINT = '947c6296a0dd677e';
7
+ export const CLI_VERSION = 46;
8
+ export const CLI_FINGERPRINT = '0eaad403bcd23b2e';
package/src/install.js CHANGED
@@ -13,6 +13,7 @@ export const DEFAULTS = Object.freeze({
13
13
  name: 'breakaway',
14
14
  worker: 'breakaway',
15
15
  url: null,
16
+ aliases: [],
16
17
  secretsPrefix: 'BREAKAWAY_',
17
18
  secretsStore: null,
18
19
  store: 'breakaway',
@@ -72,6 +73,26 @@ function origin(url) {
72
73
  }
73
74
  }
74
75
 
76
+ /**
77
+ * The other addresses a board answers on beside its url, as https origins (BRK-78): while it moves to a new address,
78
+ * the old one stays an alias until nothing uses it. Each is a custom domain of the Worker, like the url.
79
+ */
80
+ function aliasesOf(aliases, url) {
81
+ if (!Array.isArray(aliases))
82
+ throw new ConfigError('aliases is a list of https origins, like ["https://old.example.com"]');
83
+ if (aliases.length && url === null)
84
+ throw new ConfigError('aliases need a url: they are the other addresses the board answers on beside it');
85
+ const out = aliases.map((a) => {
86
+ const o = origin(a);
87
+ if (!o) throw new ConfigError(`aliases: ${a} isn't an https origin, like https://old.example.com`);
88
+ if (o === url) throw new ConfigError(`aliases: ${o} is already the url`);
89
+ return o;
90
+ });
91
+ const twice = out.find((o, i) => out.indexOf(o) !== i);
92
+ if (twice) throw new ConfigError(`aliases: ${twice} is there twice`);
93
+ return out;
94
+ }
95
+
75
96
  /** A breakaway.config.json's contents, checked and with its defaults filled in. Throws ConfigError naming what's wrong. */
76
97
  export function parseInstall(raw) {
77
98
  if (!raw || typeof raw !== 'object' || Array.isArray(raw)) throw new ConfigError('the config is a JSON object');
@@ -88,6 +109,7 @@ export function parseInstall(raw) {
88
109
  'url is where the board answers, an https origin like https://tasks.example.com, or null for workers.dev',
89
110
  );
90
111
  c.url = c.url === null ? null : origin(c.url);
112
+ c.aliases = aliasesOf(c.aliases, c.url);
91
113
  if (!PREFIX.test(c.secretsPrefix))
92
114
  throw new ConfigError('secretsPrefix is uppercase and ends with _, like BREAKAWAY_');
93
115
  if (c.secretsStore !== null && !STORE_ID.test(c.secretsStore))
@@ -179,7 +201,9 @@ export function wranglerConfig(config, { local = false, root = '.' } = {}) {
179
201
  name: c.worker,
180
202
  main: at('src/worker.js'),
181
203
  compatibility_date: COMPATIBILITY_DATE,
182
- ...(local || !c.url ? {} : { routes: [{ pattern: new URL(c.url).host, custom_domain: true }] }),
204
+ ...(local || !c.url
205
+ ? {}
206
+ : { routes: [c.url, ...c.aliases].map((u) => ({ pattern: new URL(u).host, custom_domain: true })) }),
183
207
  workers_dev: !local && !c.url,
184
208
  preview_urls: false,
185
209
  ...(local
@@ -55,3 +55,5 @@ With `wrangler deploy`:
55
55
  ## Change the install
56
56
 
57
57
  Edit `breakaway.config.json` and merge it: Deploy runs on every push to `main`.
58
+
59
+ To move the board to a new address without a gap, add the new one under `aliases` first, so both answer; then swap `url` and the alias; and remove the alias once nothing uses the old address. breakaway's [docs/tasks.md](https://github.com/TheAnarchoX/breakaway/blob/main/docs/tasks.md#moving-to-a-new-address) has the whole list of what names the address.