create-heresay 0.2.8 → 0.2.9

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": "create-heresay",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
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.8
1
+ 0.2.9
@@ -1,3 +1,3 @@
1
1
  /** The Heresay release. Bumped by the release script; the CLI and /v1/health report it. */
2
- export const VERSION = '0.2.8';
2
+ export const VERSION = '0.2.9';
3
3
  //# sourceMappingURL=version.js.map
@@ -46,6 +46,7 @@
46
46
  <span id="who" class="who"></span>
47
47
  <button id="signout" class="btn ghost">Sign out</button>
48
48
  </header>
49
+ <div id="update" class="update" role="status" hidden></div>
49
50
  <main id="view"></main>
50
51
  </div>
51
52
 
@@ -226,3 +226,9 @@ a.platform:hover { border-color:var(--acc); box-shadow:0 0 0 3px var(--mist); }
226
226
  .alt summary:hover { color:var(--fg); }
227
227
  .alt[open] summary { margin-bottom:10px; }
228
228
  .alt[open] { font-size:15px; }
229
+
230
+ .update { background:var(--mist); border-bottom:1px solid var(--line); }
231
+ .update-in { max-width:880px; margin:0 auto; padding:10px 24px; display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
232
+ .update-in p { margin:0; flex:1 1 360px; font-size:14px; color:var(--deep); }
233
+ .update-in b { margin-right:4px; }
234
+ .update-in code { white-space:nowrap; }
@@ -127,6 +127,7 @@
127
127
  $('who').textContent = b.email;
128
128
  show('app');
129
129
  route();
130
+ checkForUpdate(b);
130
131
  }).catch(function (x) {
131
132
  show('blocked');
132
133
  if (x.code === 'not_member') {
@@ -142,6 +143,48 @@
142
143
  });
143
144
  });
144
145
 
146
+ // ---- a newer Heresay -------------------------------------------------------------------
147
+
148
+ /** a.b.c > x.y.z, numerically. Anything unparseable is never newer. */
149
+ function newer(a, b) {
150
+ var p = function (v) { return String(v).split('-')[0].split('.').map(Number); };
151
+ var x = p(a), y = p(b);
152
+ if (x.length !== 3 || x.some(isNaN)) return false;
153
+ for (var i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] > (y[i] || 0);
154
+ return false;
155
+ }
156
+
157
+ /**
158
+ * Each team runs its own Heresay, so nothing updates it but them. Owners (who can run the
159
+ * update) see a quiet banner when npm has a newer release; it goes away per version once
160
+ * dismissed. A slow or blocked registry just means no banner.
161
+ */
162
+ function checkForUpdate(who) {
163
+ if (who.role !== 'owner' || !who.version) return;
164
+ fetch('https://registry.npmjs.org/create-heresay/latest').then(function (r) { return r.ok ? r.json() : null; }).then(function (pkg) {
165
+ if (!pkg || !newer(pkg.version, who.version)) return;
166
+ var key = 'heresay.update-dismissed';
167
+ try { if (localStorage.getItem(key) === pkg.version) return; } catch (e) { /* private mode */ }
168
+ var box = $('update');
169
+ box.textContent = '';
170
+ var cmd = 'npx create-heresay update';
171
+ var copy = el('button', { class: 'btn', type: 'button', text: 'Copy command', onclick: function () {
172
+ navigator.clipboard.writeText(cmd).then(function () { copy.textContent = 'Copied'; });
173
+ } });
174
+ box.appendChild(el('div', { class: 'update-in' }, [
175
+ el('p', {}, [el('b', { text: 'Heresay ' + pkg.version + ' is out.' }),
176
+ document.createTextNode(' This one runs ' + who.version + '. On the computer that set it up, run '),
177
+ el('code', { text: cmd }), document.createTextNode('. It takes a few minutes, and nothing is lost.')]),
178
+ copy,
179
+ el('button', { class: 'btn ghost', type: 'button', text: 'Not now', 'aria-label': 'Dismiss until the next version', onclick: function () {
180
+ try { localStorage.setItem(key, pkg.version); } catch (e) { /* private mode */ }
181
+ box.hidden = true;
182
+ } }),
183
+ ]));
184
+ box.hidden = false;
185
+ }).catch(function () { /* offline or blocked: no banner */ });
186
+ }
187
+
145
188
  // ---- routes ----------------------------------------------------------------------------
146
189
 
147
190
  window.addEventListener('hashchange', function () { if (me) route(); });