blytz 1.2.0 → 1.2.1
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 +2 -2
- package/src/readmeContext.js +5 -0
- package/src/index.js +0 -73
- package/src/projectReader.js +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blytz",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"bin": {
|
|
5
5
|
"blytz": "./bin/cli.js"
|
|
6
6
|
},
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"description": "An automated CLI tool to fix and maintain project READMEs",
|
|
14
14
|
"type": "module",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"start": "node
|
|
16
|
+
"start": "node server/server.js",
|
|
17
17
|
"prepublishOnly": "node scripts/sync-readme.js prepublish",
|
|
18
18
|
"postpublish": "node scripts/sync-readme.js postpublish"
|
|
19
19
|
},
|
package/src/readmeContext.js
CHANGED
|
@@ -60,6 +60,11 @@ export function collectScripts(packages = []) {
|
|
|
60
60
|
const packageDir = pkg.path === "package.json" ? "(root)" : pkg.path.replace("/package.json", "");
|
|
61
61
|
|
|
62
62
|
for (const [name, command] of Object.entries(pkg?.content?.scripts || {})) {
|
|
63
|
+
|
|
64
|
+
if(name !=="start"){
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
63
68
|
if (!scripts.has(name)) {
|
|
64
69
|
scripts.set(name, []);
|
|
65
70
|
}
|
package/src/index.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import getDefaultContent from "./template.js";
|
|
2
|
-
import { detectProjectType } from "./projectReader.js";
|
|
3
|
-
|
|
4
|
-
export function generateReadme(input = {}) {
|
|
5
|
-
const {
|
|
6
|
-
readmeContent = "",
|
|
7
|
-
packageJson = null,
|
|
8
|
-
fileTree = null,
|
|
9
|
-
username = "Unknown",
|
|
10
|
-
projectName = null,
|
|
11
|
-
hasPackageJson = false,
|
|
12
|
-
hasRequirementsTxt = false
|
|
13
|
-
} = input ?? {};
|
|
14
|
-
|
|
15
|
-
const resolvedProjectName = projectName || packageJson?.name || "this project";
|
|
16
|
-
|
|
17
|
-
const context = {
|
|
18
|
-
packageJson,
|
|
19
|
-
fileTree,
|
|
20
|
-
username,
|
|
21
|
-
projectName: resolvedProjectName,
|
|
22
|
-
hasPackageJson,
|
|
23
|
-
hasRequirementsTxt
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const projectType = detectProjectType(context);
|
|
27
|
-
|
|
28
|
-
// parse existing readme into sections
|
|
29
|
-
const sections = (readmeContent || "").split("## ");
|
|
30
|
-
const sectionMap = {};
|
|
31
|
-
const intro = sections[0].trim();
|
|
32
|
-
|
|
33
|
-
sections.slice(1).forEach(section => {
|
|
34
|
-
const lines = section.split("\n");
|
|
35
|
-
const title = lines[0].trim().toLowerCase();
|
|
36
|
-
const content = lines.slice(1).join("\n").trim();
|
|
37
|
-
sectionMap[title] = content;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const requiredSections = ["description", "installation", "usage", "dependencies", "folder structure", "built by"];
|
|
41
|
-
const autoManagedSections = ["installation", "usage", "dependencies", "folder structure"];
|
|
42
|
-
|
|
43
|
-
// fill in missing sections or update auto-managed ones
|
|
44
|
-
requiredSections.forEach(section => {
|
|
45
|
-
const newContent = getDefaultContent(section, projectType, context);
|
|
46
|
-
if (!(section in sectionMap)) {
|
|
47
|
-
sectionMap[section] = newContent;
|
|
48
|
-
} else if (autoManagedSections.includes(section) && sectionMap[section].trim() !== newContent.trim()) {
|
|
49
|
-
sectionMap[section] = newContent;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const formatTitle = title => title.split(" ").map(w => w[0].toUpperCase() + w.slice(1)).join(" ");
|
|
54
|
-
|
|
55
|
-
// build the final readme
|
|
56
|
-
let newReadme = intro ? intro + "\n\n" : "";
|
|
57
|
-
requiredSections.forEach(section => {
|
|
58
|
-
newReadme += `## ${formatTitle(section)}\n${sectionMap[section]}\n\n`;
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// append any extra sections the user had
|
|
62
|
-
Object.keys(sectionMap).forEach(section => {
|
|
63
|
-
if (!requiredSections.includes(section)) {
|
|
64
|
-
newReadme += `## ${formatTitle(section)}\n\n ${sectionMap[section]}\n\n`;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
return { content: newReadme, changed: readmeContent !== newReadme };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { detectProjectType } from "./projectReader.js";
|
|
72
|
-
export { default as getDefaultContent } from "./template.js";
|
|
73
|
-
export { default as getProjectStructure } from "./fileTree.js";
|