create-heresay 0.2.37 → 0.2.38
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 +1 -1
- package/release/VERSION +1 -1
- package/release/functions/lib/core/agent.js +6 -0
- package/release/functions/lib/core/duplicates.js +3 -2
- package/release/functions/lib/core/handler.js +24 -4
- package/release/functions/lib/core/store.js +3 -0
- package/release/functions/lib/core/version.js +1 -1
- package/release/functions/lib/core/withdraw.js +2 -2
- package/release/functions/lib/providers/firebase/firestore-store.js +4 -0
- package/release/public/dashboard.js +92 -21
- package/src/steps.mjs +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-heresay",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.38",
|
|
4
4
|
"description": "Set up your own Heresay: in-app feedback that every report gets a hearing. Creates a Firebase project in your Google account and deploys the dashboard, API and SDK to it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/release/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.38
|
|
@@ -257,6 +257,8 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
257
257
|
return json(409, { error: `this brief is already ${report?.status}`, status: report?.status });
|
|
258
258
|
const takenByOther = (t) => claimLive(t, now) && t.claim.repo !== repoName;
|
|
259
259
|
const addNote = (t, text, kind) => ({ ...t, notes: [...(t.notes ?? []), { by: me, at, text, kind }] });
|
|
260
|
+
// The dashboard polls reports by updated_at, and shows claims and notes beside them.
|
|
261
|
+
const touch = () => deps.store.updateReport(app.id, found.task.report_id, { updated_at: at });
|
|
260
262
|
if (p[2] === 'claim') {
|
|
261
263
|
let refused = '';
|
|
262
264
|
const t = await deps.store.updateTask(app.id, found.task.id, (cur) => {
|
|
@@ -268,6 +270,7 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
268
270
|
});
|
|
269
271
|
if (refused)
|
|
270
272
|
return json(409, { error: `already in progress in ${refused}`, claimed_by: refused });
|
|
273
|
+
await touch();
|
|
271
274
|
deps.log('api.brief_claimed', { repo: repoName, report_id: t.id });
|
|
272
275
|
return json(200, { brief: summary(t, app, now) });
|
|
273
276
|
}
|
|
@@ -280,6 +283,7 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
280
283
|
// Working on it keeps the claim fresh.
|
|
281
284
|
return cur.claim?.repo === repoName ? { ...next, claim: { repo: repoName, at } } : next;
|
|
282
285
|
});
|
|
286
|
+
await touch();
|
|
283
287
|
return json(200, { brief: summary(t, app, now) });
|
|
284
288
|
}
|
|
285
289
|
if (p[2] === 'handoff') {
|
|
@@ -303,6 +307,7 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
303
307
|
});
|
|
304
308
|
if (refused)
|
|
305
309
|
return json(409, { error: `in progress in ${refused}`, claimed_by: refused });
|
|
310
|
+
await touch();
|
|
306
311
|
deps.log('api.brief_handed_off', { from: repoName, to, report_id: t.id });
|
|
307
312
|
await notify('handoff', app, t.id, deps);
|
|
308
313
|
return json(200, { brief: summary(t, app, now) });
|
|
@@ -320,6 +325,7 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
|
|
|
320
325
|
const res = await toReporter(app, found.task.id, note, me, fx.ref);
|
|
321
326
|
if (res.status === 200) {
|
|
322
327
|
await deps.store.updateTask(app.id, found.task.id, (cur) => ({ ...addNote(cur, `Fixed: ${note}`, 'note'), claim: null }));
|
|
328
|
+
await touch();
|
|
323
329
|
}
|
|
324
330
|
return res;
|
|
325
331
|
}
|
|
@@ -60,7 +60,7 @@ export async function merge(project, id, body, me, deps) {
|
|
|
60
60
|
const dup = { project_id: targetApp.id, report_id: target.id, by: me.email, at };
|
|
61
61
|
const moving = [report, ...await duplicatesOf(project, id, deps)];
|
|
62
62
|
for (const r of moving) {
|
|
63
|
-
await deps.store.updateReport(r.project_id, r.id, { duplicate_of: dup });
|
|
63
|
+
await deps.store.updateReport(r.project_id, r.id, { duplicate_of: dup, updated_at: at });
|
|
64
64
|
// Into an accepted report: these are accepted too, and their words join the brief.
|
|
65
65
|
if (target.status === 'accepted' && r.status === 'open') {
|
|
66
66
|
await deps.store.move(r.project_id, r.id, 'open', 'accepted', { triaged_by: me.email, updated_at: at });
|
|
@@ -71,6 +71,7 @@ export async function merge(project, id, body, me, deps) {
|
|
|
71
71
|
await deps.store.updateTask(targetApp.id, target.id, (t) => ({
|
|
72
72
|
...t, also_reported: [...(t.also_reported ?? []).filter((a) => !add.some((x) => x.report_id === a.report_id)), ...add],
|
|
73
73
|
}));
|
|
74
|
+
await deps.store.updateReport(targetApp.id, target.id, { updated_at: at });
|
|
74
75
|
}
|
|
75
76
|
deps.log('api.report_merged', { project_id: project.id, report_id: id, into: target.id, by: me.email, moved: moving.length });
|
|
76
77
|
return json(200, { merged: moving.map((r) => r.id), into: { project_id: targetApp.id, report_id: target.id, status: target.status } });
|
|
@@ -84,7 +85,7 @@ export async function unmerge(project, id, me, deps) {
|
|
|
84
85
|
return json(409, { error: 'this report isn\'t merged into another' });
|
|
85
86
|
if (report.status !== 'open')
|
|
86
87
|
return json(409, { error: `it has already followed that report to ${report.status}; it can't be separated now` });
|
|
87
|
-
await deps.store.updateReport(project.id, id, { duplicate_of: null });
|
|
88
|
+
await deps.store.updateReport(project.id, id, { duplicate_of: null, updated_at: new Date(deps.now()).toISOString() });
|
|
88
89
|
deps.log('api.report_unmerged', { project_id: project.id, report_id: id, by: me.email });
|
|
89
90
|
return json(200, { report_id: id });
|
|
90
91
|
}
|
|
@@ -7,6 +7,7 @@ import { withdraw } from './withdraw.js';
|
|
|
7
7
|
import { alsoReported, duplicatesOf, follow, merge, parseFixRef, stampFix, unmerge } from './duplicates.js';
|
|
8
8
|
import { notificationSettings, notify } from './notifications.js';
|
|
9
9
|
import { LIMITS, PLATFORMS, REPORT_ORDER, REPORT_TYPES, isFramework, isPlatform, isReportType, isSignIn, toReporterView, } from './types.js';
|
|
10
|
+
const ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
|
|
10
11
|
/**
|
|
11
12
|
* Fixed windows. The public endpoint has no login, so each of these is a separate line of
|
|
12
13
|
* defence: the device id is chosen by the client and can be rotated, the IP limit catches that,
|
|
@@ -266,12 +267,31 @@ async function route(req, deps) {
|
|
|
266
267
|
if (p[2] === 'reports' && p.length === 3 && req.method === 'GET') {
|
|
267
268
|
// Alongside each accepted report: where its fix is going, and whether an agent has it.
|
|
268
269
|
const now = deps.now();
|
|
269
|
-
const
|
|
270
|
-
|
|
270
|
+
const since = req.query?.since;
|
|
271
|
+
if (since !== undefined && !(typeof since === 'string' && ISO.test(since) && !Number.isNaN(Date.parse(since)))) {
|
|
272
|
+
return json(400, { error: 'since must be an ISO timestamp' });
|
|
273
|
+
}
|
|
274
|
+
const brief = (t) => {
|
|
271
275
|
const live = t.claim && now - Date.parse(t.claim.at) < 24 * 3600_000;
|
|
272
|
-
|
|
276
|
+
return { repo: t.repo ?? null, claimed_by: live ? t.claim.repo : null, notes: t.notes ?? [] };
|
|
277
|
+
};
|
|
278
|
+
const briefs = {};
|
|
279
|
+
const nowIso = new Date(now).toISOString();
|
|
280
|
+
if (since !== undefined) {
|
|
281
|
+
// A delta: only what changed, and tasks only for those, so a poll costs a few reads.
|
|
282
|
+
const reports = await deps.store.listReportsSince(project.id, since);
|
|
283
|
+
for (const r of reports) {
|
|
284
|
+
if (r.status !== 'open' && r.status !== 'declined' && r.status !== 'withdrawn') {
|
|
285
|
+
const t = await deps.store.getTask(project.id, r.id);
|
|
286
|
+
if (t)
|
|
287
|
+
briefs[t.id] = brief(t);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return json(200, { reports, briefs, now: nowIso });
|
|
273
291
|
}
|
|
274
|
-
|
|
292
|
+
for (const t of await deps.store.listTasks(project.id))
|
|
293
|
+
briefs[t.id] = brief(t);
|
|
294
|
+
return json(200, { reports: sortForTriage(await deps.store.listReports(project.id)), briefs, now: nowIso });
|
|
275
295
|
}
|
|
276
296
|
if (p[2] === 'repos' && p.length === 3 && req.method === 'GET') {
|
|
277
297
|
return json(200, { repos: await reposFor(project.id, deps) });
|
|
@@ -41,6 +41,9 @@ export class MemoryStore {
|
|
|
41
41
|
async listReports(project_id) {
|
|
42
42
|
return [...this.reports.values()].filter((r) => r.project_id === project_id);
|
|
43
43
|
}
|
|
44
|
+
async listReportsSince(project_id, since) {
|
|
45
|
+
return (await this.listReports(project_id)).filter((r) => r.updated_at > since).slice(0, 500);
|
|
46
|
+
}
|
|
44
47
|
async listReportsForDevice(project_id, device_id) {
|
|
45
48
|
return (await this.listReports(project_id)).filter((r) => r.device_id === device_id);
|
|
46
49
|
}
|
|
@@ -19,10 +19,10 @@ export async function withdraw(project, id, by, reason, owns, deps) {
|
|
|
19
19
|
if (!t.ok)
|
|
20
20
|
return json(409, { error: 'it changed just now; look again' });
|
|
21
21
|
const withdrawal = { ...by, at, reason: why };
|
|
22
|
-
await deps.store.updateReport(project.id, id, { withdrawal });
|
|
22
|
+
await deps.store.updateReport(project.id, id, { withdrawal, updated_at: at });
|
|
23
23
|
// Reports merged into it stand on their own again: their reporters still want an answer.
|
|
24
24
|
for (const d of await duplicatesOf(project, id, deps))
|
|
25
|
-
await deps.store.updateReport(d.project_id, d.id, { duplicate_of: null });
|
|
25
|
+
await deps.store.updateReport(d.project_id, d.id, { duplicate_of: null, updated_at: at });
|
|
26
26
|
deps.log('api.report_withdrawn', { project_id: project.id, report_id: id, kind: by.kind });
|
|
27
27
|
return json(200, { report: { ...t.report, withdrawal } });
|
|
28
28
|
}
|
|
@@ -62,6 +62,10 @@ export class FirestoreStore {
|
|
|
62
62
|
const q = await this.reports(project_id).orderBy('created_at', 'desc').limit(500).get();
|
|
63
63
|
return q.docs.map((d) => d.data());
|
|
64
64
|
}
|
|
65
|
+
async listReportsSince(project_id, since) {
|
|
66
|
+
const q = await this.reports(project_id).where('updated_at', '>', since).orderBy('updated_at').limit(500).get();
|
|
67
|
+
return q.docs.map((d) => d.data());
|
|
68
|
+
}
|
|
65
69
|
async listReportsForDevice(project_id, device_id) {
|
|
66
70
|
const q = await this.reports(project_id).where('device_id', '==', device_id).limit(50).get();
|
|
67
71
|
return q.docs.map((d) => d.data());
|
|
@@ -1429,7 +1429,10 @@
|
|
|
1429
1429
|
function drawDetail(shown, preserve) {
|
|
1430
1430
|
var chosen = shown.filter(function (x) { return key(x) === selected; })[0];
|
|
1431
1431
|
var signature = chosen ? JSON.stringify([chosen, ctxs[chosen.project_id].briefs[chosen.id], ctxs[chosen.project_id].dups[chosen.id], ctxs[chosen.project_id].repos]) : null;
|
|
1432
|
-
|
|
1432
|
+
var drawn = detail.querySelector('.detail-card, .detail-placeholder');
|
|
1433
|
+
// 'hold': a person is mid-reply, so the open report stays as it is until they ask for the refresh.
|
|
1434
|
+
if (preserve === 'hold' && drawn) return;
|
|
1435
|
+
if (preserve && signature === detailSignature && drawn) return;
|
|
1433
1436
|
detailSignature = signature;
|
|
1434
1437
|
detail.textContent = '';
|
|
1435
1438
|
detail.appendChild(el('button', { class: 'btn ghost detail-back', type: 'button', text: '← Back to reports', onclick: function () { view.classList.remove('detail-open'); var active = list.querySelector('[aria-current=true]'); if (active) active.focus(); } }));
|
|
@@ -1460,31 +1463,38 @@
|
|
|
1460
1463
|
return (detail.contains(document.activeElement) && /^(INPUT|TEXTAREA|SELECT)$/.test(document.activeElement.tagName)) || detail.querySelector('.busy, .settled')
|
|
1461
1464
|
|| Array.prototype.some.call(detail.querySelectorAll('textarea, input'), function (n) { return n.value.trim(); });
|
|
1462
1465
|
}
|
|
1463
|
-
|
|
1464
|
-
|
|
1466
|
+
/** Everything derived from the per-project reports: duplicate groups, counts, the sorted inbox. */
|
|
1467
|
+
function derive() {
|
|
1468
|
+
var everything = [].concat.apply([], projects.map(function (x) { return ctxs[x.id].reports; }));
|
|
1469
|
+
var dups = {}, counts = {};
|
|
1470
|
+
everything.forEach(function (r) { if (r.duplicate_of) (dups[r.duplicate_of.report_id] = dups[r.duplicate_of.report_id] || []).push(r); });
|
|
1471
|
+
Object.keys(dups).forEach(function (id) { counts[id] = dups[id].length; });
|
|
1472
|
+
projects.forEach(function (x) { var c = ctxs[x.id]; c.dups = dups; c.all = everything.filter(function (r) { return productOf(ctxs[r.project_id].project) === productOf(x); }); c.siblings = ctxs; c.reload = load; });
|
|
1473
|
+
reports = triageSort(everything.filter(function (r) { return !r.duplicate_of; }), counts);
|
|
1474
|
+
}
|
|
1475
|
+
function fetchAll() {
|
|
1476
|
+
var nextProjects, nextContexts = {};
|
|
1465
1477
|
return api('GET', '/projects').then(function (b) {
|
|
1466
|
-
if (!shell.isConnected) return;
|
|
1467
1478
|
nextProjects = b.projects;
|
|
1468
1479
|
return Promise.all(nextProjects.map(function (x) {
|
|
1469
1480
|
return Promise.all([api('GET', '/projects/' + x.id + '/reports'), api('GET', '/projects/' + x.id + '/repos')]).then(function (r) {
|
|
1470
|
-
nextContexts[x.id] = { project: x, reports: r[0].reports, briefs: r[0].briefs || {}, repos: r[1].repos || [] };
|
|
1481
|
+
nextContexts[x.id] = { project: x, reports: r[0].reports, briefs: r[0].briefs || {}, repos: r[1].repos || [], now: r[0].now || null };
|
|
1471
1482
|
});
|
|
1472
1483
|
}));
|
|
1473
|
-
}).then(function () {
|
|
1484
|
+
}).then(function () { return { projects: nextProjects, contexts: nextContexts }; });
|
|
1485
|
+
}
|
|
1486
|
+
function load(background) {
|
|
1487
|
+
var serial = ++loadSerial;
|
|
1488
|
+
return fetchAll().then(function (next) {
|
|
1474
1489
|
if (!shell.isConnected || serial !== loadSerial || (background && readingReport())) return;
|
|
1475
1490
|
// Commit a complete snapshot together; failed refreshes leave the old one intact.
|
|
1476
1491
|
// Retained details close over their context; update it in place after success.
|
|
1477
|
-
Object.keys(
|
|
1478
|
-
if (ctxs[id])
|
|
1492
|
+
Object.keys(next.contexts).forEach(function (id) {
|
|
1493
|
+
if (ctxs[id]) next.contexts[id] = Object.assign(ctxs[id], next.contexts[id]);
|
|
1479
1494
|
});
|
|
1480
|
-
projects =
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
everything.forEach(function (r) { if (r.duplicate_of) (dups[r.duplicate_of.report_id] = dups[r.duplicate_of.report_id] || []).push(r); });
|
|
1484
|
-
Object.keys(dups).forEach(function (id) { counts[id] = dups[id].length; });
|
|
1485
|
-
projects.forEach(function (x) { var c = ctxs[x.id]; c.dups = dups; c.all = everything.filter(function (r) { return productOf(ctxs[r.project_id].project) === productOf(x); }); c.siblings = ctxs; c.reload = load; });
|
|
1486
|
-
reports = triageSort(everything.filter(function (r) { return !r.duplicate_of; }), counts);
|
|
1487
|
-
loaded = true; drawProducts(); render(background === true);
|
|
1495
|
+
projects = next.projects; ctxs = next.contexts;
|
|
1496
|
+
derive();
|
|
1497
|
+
loaded = true; hideCue(); noteChange(); drawProducts(); render(background === true);
|
|
1488
1498
|
}).catch(function (x) {
|
|
1489
1499
|
if (!shell.isConnected) return;
|
|
1490
1500
|
if (loaded) { toast('Could not refresh reports. ' + x.message, null, true); return; }
|
|
@@ -1492,12 +1502,73 @@
|
|
|
1492
1502
|
list.appendChild(el('div', { class: 'inbox-empty' }, [el('h2', { text: 'Could not load reports' }), el('p', { class: 'err', role: 'alert', text: x.message }), el('button', { class: 'btn', text: 'Retry', onclick: load })]));
|
|
1493
1503
|
});
|
|
1494
1504
|
}
|
|
1505
|
+
|
|
1506
|
+
// Background polls fetch only what changed since the server's last `now`, so keeping the
|
|
1507
|
+
// inbox live costs a few reads. A person mid-reply keeps their detail pane; a cue offers the refresh.
|
|
1508
|
+
var FAST = 8000, SLOW = 30000, QUIET = 5 * 60000;
|
|
1509
|
+
var polling = false, lastChange = Date.now(), lastPoll = 0, pending = {}, failing = false;
|
|
1510
|
+
var cue = el('button', { class: 'btn ghost new-cue', type: 'button', hidden: true, onclick: function () { hideCue(); render(); } });
|
|
1511
|
+
listHead.after(cue);
|
|
1512
|
+
function noteChange() { lastChange = Date.now(); }
|
|
1513
|
+
function hideCue() { pending = {}; cue.hidden = true; }
|
|
1514
|
+
function showCue() {
|
|
1515
|
+
var n = Object.keys(pending).length;
|
|
1516
|
+
cue.hidden = !n;
|
|
1517
|
+
cue.textContent = n === 1 ? '1 new update. Show' : n + ' new updates. Show';
|
|
1518
|
+
}
|
|
1519
|
+
/** `since` is the server's clock, minus a short overlap so a write in the same instant is never missed. */
|
|
1520
|
+
function sinceOf(c) { return new Date(Date.parse(c.now) - 2000).toISOString(); }
|
|
1521
|
+
function poll(force) {
|
|
1522
|
+
if (!loaded || polling || !shell.isConnected) return;
|
|
1523
|
+
var quiet = Date.now() - lastChange > QUIET;
|
|
1524
|
+
if (!force && quiet && Date.now() - lastPoll < SLOW - 1000) return;
|
|
1525
|
+
polling = true; lastPoll = Date.now();
|
|
1526
|
+
var serial = loadSerial;
|
|
1527
|
+
Promise.all(projects.map(function (x) {
|
|
1528
|
+
var c = ctxs[x.id];
|
|
1529
|
+
if (!c || !c.now) return null;
|
|
1530
|
+
return api('GET', '/projects/' + x.id + '/reports?since=' + encodeURIComponent(sinceOf(c))).then(function (b) { return { id: x.id, body: b }; });
|
|
1531
|
+
})).then(function (deltas) {
|
|
1532
|
+
failing = false;
|
|
1533
|
+
if (!shell.isConnected || serial !== loadSerial) return;
|
|
1534
|
+
var changed = [];
|
|
1535
|
+
deltas.forEach(function (d) {
|
|
1536
|
+
if (!d) return;
|
|
1537
|
+
var c = ctxs[d.id], have = {};
|
|
1538
|
+
c.reports.forEach(function (r) { have[r.id] = r; });
|
|
1539
|
+
(d.body.reports || []).forEach(function (r) {
|
|
1540
|
+
var cur = have[r.id], brief = (d.body.briefs || {})[r.id];
|
|
1541
|
+
if (cur && JSON.stringify(cur) === JSON.stringify(r) && (brief === undefined || JSON.stringify(c.briefs[r.id]) === JSON.stringify(brief))) return;
|
|
1542
|
+
if (cur) Object.assign(cur, r); else c.reports.push(r);
|
|
1543
|
+
if (brief !== undefined) c.briefs[r.id] = brief;
|
|
1544
|
+
changed.push(d.id + '/' + r.id);
|
|
1545
|
+
});
|
|
1546
|
+
c.now = d.body.now || c.now;
|
|
1547
|
+
});
|
|
1548
|
+
if (!changed.length) return;
|
|
1549
|
+
noteChange();
|
|
1550
|
+
derive(); drawProducts();
|
|
1551
|
+
if (readingReport()) {
|
|
1552
|
+
changed.forEach(function (k) { pending[k] = true; });
|
|
1553
|
+
render('hold'); showCue();
|
|
1554
|
+
} else { hideCue(); render(true); }
|
|
1555
|
+
}).catch(function (x) {
|
|
1556
|
+
if (!shell.isConnected) return;
|
|
1557
|
+
if (x.status === 404) { load(true); return; }
|
|
1558
|
+
if (!failing) toast('Could not refresh reports. ' + x.message, null, true);
|
|
1559
|
+
failing = true;
|
|
1560
|
+
}).then(function () { polling = false; });
|
|
1561
|
+
}
|
|
1562
|
+
function resume() {
|
|
1563
|
+
if (!shell.isConnected) { document.removeEventListener('visibilitychange', onVisible); window.removeEventListener('focus', resume); return; }
|
|
1564
|
+
if (document.hidden) return;
|
|
1565
|
+
noteChange(); poll(true);
|
|
1566
|
+
}
|
|
1567
|
+
function onVisible() { resume(); }
|
|
1568
|
+
document.addEventListener('visibilitychange', onVisible);
|
|
1569
|
+
window.addEventListener('focus', resume);
|
|
1495
1570
|
load();
|
|
1496
|
-
every(
|
|
1497
|
-
// Keep a person's form, selection and reading position steady while they work.
|
|
1498
|
-
if (readingReport()) return;
|
|
1499
|
-
load(true);
|
|
1500
|
-
});
|
|
1571
|
+
every(FAST, function () { poll(false); });
|
|
1501
1572
|
}
|
|
1502
1573
|
|
|
1503
1574
|
// Where a report came from, worded and coloured the same in the list and on the report.
|
package/src/steps.mjs
CHANGED
|
@@ -148,8 +148,13 @@ export function prepareRelease(ctx) {
|
|
|
148
148
|
for (const fn of cfg.functions) delete fn.predeploy;
|
|
149
149
|
for (const r of cfg.hosting.rewrites) if (r.function) r.function.region = ctx.region;
|
|
150
150
|
// On a named site, keep serving the project's default site too: apps already shipped with its
|
|
151
|
-
// address, and repos already connected to it, must keep working.
|
|
152
|
-
|
|
151
|
+
// address, and repos already connected to it, must keep working. HERESAY_ONLY_SITE=1 opts out
|
|
152
|
+
// for an instance that has retired the default address.
|
|
153
|
+
if (siteOf(ctx) !== ctx.id) {
|
|
154
|
+
cfg.hosting = process.env.HERESAY_ONLY_SITE === '1'
|
|
155
|
+
? { ...cfg.hosting, site: siteOf(ctx) }
|
|
156
|
+
: [{ ...cfg.hosting, site: siteOf(ctx) }, { ...cfg.hosting, site: ctx.id }];
|
|
157
|
+
}
|
|
153
158
|
writeFileSync(join(dir, 'firebase.json'), JSON.stringify(cfg, null, 2) + '\n');
|
|
154
159
|
writeFileSync(join(dir, '.firebaserc'), JSON.stringify({ projects: { default: ctx.id } }, null, 2) + '\n');
|
|
155
160
|
writeFileSync(join(dir, 'functions', '.env'), `HERESAY_REGION=${ctx.region}\n`);
|