ticketlens 0.4.8 → 0.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ticketlens",
3
- "version": "0.4.8",
3
+ "version": "0.5.0",
4
4
  "description": "Jira CLI for developers — fetch ticket context, triage your queue, and stop tab-switching. Zero dependencies, all local.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -16,7 +16,8 @@
16
16
  ],
17
17
  "scripts": {
18
18
  "test": "node --test skills/jtb/scripts/test/*.test.mjs",
19
- "postinstall": "node scripts/postinstall.mjs"
19
+ "postinstall": "node scripts/postinstall.mjs",
20
+ "prepublishOnly": "node scripts/preflight.mjs"
20
21
  },
21
22
  "keywords": [
22
23
  "jira",
@@ -0,0 +1,46 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { dirname, join, resolve } from 'node:path';
4
+
5
+ const LOCAL_RE = /localhost|127\.0\.0\.1|\.test(:\d+)?(\/|$)/i;
6
+
7
+ /**
8
+ * @param {string} defaultApiBase
9
+ * @param {string|undefined} tag
10
+ * @returns {{ ok: boolean, reason: string }}
11
+ */
12
+ export function checkApiBase(defaultApiBase, tag = 'latest') {
13
+ const resolvedTag = tag || 'latest'; // treat undefined/empty as 'latest'
14
+ if (resolvedTag !== 'latest') {
15
+ return { ok: true, reason: `tag '${resolvedTag}' — skipping production URL check` };
16
+ }
17
+ if (LOCAL_RE.test(defaultApiBase)) {
18
+ return {
19
+ ok: false,
20
+ reason: `DEFAULT_API_BASE is still a local URL (${defaultApiBase}). ` +
21
+ `Update it to the production URL in api-utils.mjs before publishing to 'latest'.`,
22
+ };
23
+ }
24
+ return { ok: true, reason: `production URL looks good (${defaultApiBase})` };
25
+ }
26
+
27
+ // Only run when invoked directly (not when imported by tests)
28
+ const isMain = process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url));
29
+ if (isMain) {
30
+ const __dir = dirname(fileURLToPath(import.meta.url));
31
+ const apiUtilsPath = join(__dir, '../skills/jtb/scripts/lib/api-utils.mjs');
32
+ const source = readFileSync(apiUtilsPath, 'utf8');
33
+ const match = source.match(/export const DEFAULT_API_BASE\s*=\s*'([^']+)'/);
34
+ const defaultApiBase = match?.[1] ?? '';
35
+
36
+ const tag = process.env.npm_config_tag;
37
+ const { ok, reason } = checkApiBase(defaultApiBase, tag);
38
+
39
+ if (!ok) {
40
+ process.stderr.write(`\n[preflight] ERROR: ${reason}\n\n`);
41
+ process.exit(1);
42
+ }
43
+
44
+ process.stdout.write(`[preflight] ${reason}\n`);
45
+ process.exit(0);
46
+ }
@@ -105,7 +105,7 @@ export async function runScheduleWizard({
105
105
 
106
106
  writeLocalJob(content, platform);
107
107
 
108
- return data;
108
+ return { ok: true, ...data };
109
109
  } catch {
110
110
  print(` ${yellow('⚠')} Schedule API error (network error) — try again later\n`);
111
111
  return { ok: false };