ticketlens 0.9.2 → 0.9.3

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.9.2",
3
+ "version": "0.9.3",
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": {
@@ -17,7 +17,9 @@
17
17
  "scripts": {
18
18
  "test": "node --test skills/jtb/scripts/test/*.test.mjs",
19
19
  "postinstall": "node scripts/postinstall.mjs",
20
- "prepublishOnly": "node scripts/preflight.mjs"
20
+ "prepublishOnly": "node scripts/preflight.mjs",
21
+ "publish:beta": "node scripts/publish.mjs --tag=beta",
22
+ "publish:latest": "node scripts/publish.mjs --tag=latest"
21
23
  },
22
24
  "keywords": [
23
25
  "jira",
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Pack and publish ticketlens to npm.
4
+ *
5
+ * Swaps DEFAULT_API_BASE to the production URL, runs npm pack, reverts the
6
+ * source file (always — even on failure), then publishes the tarball.
7
+ * Source code always stays at the local dev URL; only the tarball gets prod.
8
+ *
9
+ * Usage:
10
+ * node scripts/publish.mjs # --tag beta, prod URL default
11
+ * node scripts/publish.mjs --tag=latest # only when hosting is live
12
+ * node scripts/publish.mjs --prod-url=https://... # override prod URL
13
+ */
14
+
15
+ import { readFileSync, writeFileSync, rmSync } from 'node:fs';
16
+ import { execSync } from 'node:child_process';
17
+ import { dirname, join, resolve } from 'node:path';
18
+ import { fileURLToPath } from 'node:url';
19
+
20
+ const __dir = dirname(fileURLToPath(import.meta.url));
21
+ const ROOT = resolve(__dir, '..');
22
+ const API_UTILS = join(ROOT, 'skills/jtb/scripts/lib/api-utils.mjs');
23
+ const PROD_URL = 'https://api.ticketlens.app';
24
+
25
+ const args = process.argv.slice(2);
26
+ const tag = args.find(a => a.startsWith('--tag='))?.split('=')[1] ?? 'beta';
27
+ const prodUrl = args.find(a => a.startsWith('--prod-url='))?.split('=')[1] ?? PROD_URL;
28
+
29
+ const original = readFileSync(API_UTILS, 'utf8');
30
+ const swapped = original.replace(
31
+ /export const DEFAULT_API_BASE\s*=\s*'[^']+'/,
32
+ `export const DEFAULT_API_BASE = '${prodUrl}'`,
33
+ );
34
+
35
+ if (original === swapped) {
36
+ process.stderr.write('Error: DEFAULT_API_BASE not found in api-utils.mjs\n');
37
+ process.exit(1);
38
+ }
39
+
40
+ let tarball = null;
41
+
42
+ try {
43
+ log(`Swapping DEFAULT_API_BASE → ${prodUrl}`);
44
+ writeFileSync(API_UTILS, swapped, 'utf8');
45
+
46
+ log('Running npm pack...');
47
+ const raw = execSync('npm pack --json', { cwd: ROOT }).toString().trim();
48
+ const info = JSON.parse(raw);
49
+ tarball = Array.isArray(info) ? info[0]?.filename : info?.filename;
50
+
51
+ if (!tarball) throw new Error('npm pack did not return a filename');
52
+ log(`Packed: ${tarball}`);
53
+
54
+ } finally {
55
+ log('Reverting DEFAULT_API_BASE → local dev URL');
56
+ writeFileSync(API_UTILS, original, 'utf8');
57
+ }
58
+
59
+ try {
60
+ log(`Publishing ${tarball} --tag ${tag}...`);
61
+ execSync(`npm publish "${tarball}" --tag ${tag}`, { cwd: ROOT, stdio: 'inherit' });
62
+ log(`Done — ticketlens published with tag: ${tag}`);
63
+ } finally {
64
+ rmSync(join(ROOT, tarball), { force: true });
65
+ }
66
+
67
+ function log(msg) {
68
+ process.stdout.write(`[publish] ${msg}\n`);
69
+ }