@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/CHANGELOG.md +110 -0
- package/bin/hcc.mjs +865 -2430
- package/docs/commands.md +21 -9
- package/docs/commands.zh-CN.md +19 -9
- package/lib/cli-args.mjs +89 -0
- package/lib/db-schema.mjs +324 -0
- package/lib/errors.mjs +7 -0
- package/lib/format.mjs +39 -0
- package/lib/guidance.mjs +123 -0
- package/lib/json-file.mjs +14 -0
- package/lib/package-meta.mjs +24 -0
- package/lib/release-notes.mjs +40 -0
- package/lib/runtime-paths.mjs +45 -0
- package/lib/setup.mjs +3 -474
- package/lib/shell-path.mjs +69 -0
- package/lib/shim-script.mjs +384 -0
- package/lib/web-http.mjs +55 -0
- package/lib/web-runtime.mjs +108 -0
- package/lib/web-ui-template.mjs +1909 -0
- package/package.json +1 -1
- package/scripts/github-release.mjs +11 -49
- package/scripts/regression.mjs +443 -18
- package/scripts/release-notes.mjs +6 -38
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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 =
|
|
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 =
|
|
97
|
+
const problems = validateReleaseSection(body, version);
|
|
136
98
|
if (problems.length) {
|
|
137
99
|
console.error(problems.join('\n'));
|
|
138
100
|
process.exitCode = 1;
|