@logicseek/hello-cc 0.1.3 → 0.1.5

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": "@logicseek/hello-cc",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Local control plane for coordinating Claude Code, Codex, and other coding CLI sessions.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,8 +3,15 @@
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import process from 'node:process';
6
-
7
- const repoRoot = path.resolve(import.meta.dirname, '..');
6
+ import { packageRoot, readPackageJson } from '../lib/package-meta.mjs';
7
+ import {
8
+ normalizeVersion,
9
+ releaseSection,
10
+ repoFromPackage,
11
+ validateReleaseSection
12
+ } from '../lib/release-notes.mjs';
13
+
14
+ const repoRoot = packageRoot(import.meta.url);
8
15
  const githubApi = 'https://api.github.com';
9
16
 
10
17
  function usage() {
@@ -21,10 +28,6 @@ Authentication:
21
28
  `);
22
29
  }
23
30
 
24
- function readJson(file) {
25
- return JSON.parse(fs.readFileSync(file, 'utf8'));
26
- }
27
-
28
31
  function parseArgs(argv) {
29
32
  const opts = { dryRun: false, help: false, repo: null, version: null };
30
33
  for (let i = 0; i < argv.length; i += 1) {
@@ -50,47 +53,6 @@ function parseArgs(argv) {
50
53
  return opts;
51
54
  }
52
55
 
53
- function normalizeVersion(version) {
54
- return String(version || '').replace(/^v/, '');
55
- }
56
-
57
- function releaseSection(markdown, version) {
58
- const lines = markdown.split(/\r?\n/);
59
- const heading = `## ${version}`;
60
- const start = lines.findIndex((line) => line.trim() === heading);
61
- if (start < 0) return null;
62
-
63
- let end = lines.length;
64
- for (let i = start + 1; i < lines.length; i += 1) {
65
- if (/^##\s+/.test(lines[i])) {
66
- end = i;
67
- break;
68
- }
69
- }
70
- return lines.slice(start, end).join('\n').trimEnd();
71
- }
72
-
73
- function validateSection(section, version) {
74
- const problems = [];
75
- if (!section) {
76
- problems.push(`CHANGELOG.md is missing section ## ${version}`);
77
- return problems;
78
- }
79
- if (!section.includes('### Summary')) problems.push(`## ${version} is missing ### Summary`);
80
- if (!section.includes('### Highlights')) problems.push(`## ${version} is missing ### Highlights`);
81
- if (section.includes('TODO') || section.includes('TBD')) problems.push(`## ${version} still contains TODO/TBD text`);
82
- const bulletCount = (section.match(/^- /gm) || []).length;
83
- if (bulletCount < 2) problems.push(`## ${version} should include at least two release-note bullets`);
84
- return problems;
85
- }
86
-
87
- function repoFromPackage(pkg) {
88
- const repo = typeof pkg.repository === 'string' ? pkg.repository : pkg.repository?.url;
89
- if (!repo) return null;
90
- const match = repo.match(/github\.com[:/](.+?\/.+?)(?:\.git)?$/);
91
- return match ? match[1] : null;
92
- }
93
-
94
56
  function envToken() {
95
57
  return process.env.GH_TOKEN || process.env.GITHUB_TOKEN || '';
96
58
  }
@@ -124,7 +86,7 @@ async function main() {
124
86
  return;
125
87
  }
126
88
 
127
- const pkg = readJson(path.join(repoRoot, 'package.json'));
89
+ const pkg = readPackageJson(repoRoot);
128
90
  const version = normalizeVersion(opts.version || pkg.version);
129
91
  const tag = `v${version}`;
130
92
  const repo = opts.repo || process.env.GITHUB_REPOSITORY || repoFromPackage(pkg);
@@ -132,7 +94,7 @@ async function main() {
132
94
 
133
95
  const changelog = fs.readFileSync(path.join(repoRoot, 'CHANGELOG.md'), 'utf8');
134
96
  const body = releaseSection(changelog, version);
135
- const problems = validateSection(body, version);
97
+ const problems = validateReleaseSection(body, version);
136
98
  if (problems.length) {
137
99
  console.error(problems.join('\n'));
138
100
  process.exitCode = 1;