stackscan 0.1.18 → 0.1.19
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/dist/chunk-2R4IRVBW.mjs +19 -0
- package/dist/chunk-3JWM3QKI.mjs +2013 -0
- package/dist/chunk-5XOMETBV.mjs +158 -0
- package/dist/chunk-75Z7C4SW.mjs +19 -0
- package/dist/chunk-AU42WGBI.mjs +158 -0
- package/dist/chunk-BPDLELPJ.mjs +235 -0
- package/dist/chunk-JFE6WNCW.mjs +235 -0
- package/dist/chunk-MEH6MW3S.mjs +235 -0
- package/dist/chunk-NWUJIUCE.mjs +2028 -0
- package/dist/chunk-QNTMPVPN.mjs +19 -0
- package/dist/chunk-RRAAD3VC.mjs +2075 -0
- package/dist/chunk-TEUMOU3M.mjs +158 -0
- package/dist/cli.js +129 -34
- package/dist/cli.mjs +3 -3
- package/dist/index.js +129 -34
- package/dist/index.mjs +6 -6
- package/dist/scan.js +129 -34
- package/dist/scan.mjs +3 -3
- package/dist/sync.js +129 -34
- package/dist/sync.mjs +3 -3
- package/dist/techDefinitions.js +129 -34
- package/dist/techDefinitions.mjs +1 -1
- package/dist/techMap.js +129 -34
- package/dist/techMap.mjs +2 -2
- package/package.json +1 -1
- package/public/assets/logos/backend/convex.svg +5 -0
- package/public/assets/logos/backend/springboot.svg +1 -0
- package/public/assets/logos/css/shadcn.svg +6 -0
- package/public/assets/logos/defaults/package.svg +18 -0
- package/public/assets/logos/language/css3.svg +6 -0
- package/public/assets/logos/language/html5.svg +6 -0
- package/public/assets/logos/language/typescript.svg +1 -1
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import {
|
|
2
|
+
techMap
|
|
3
|
+
} from "./chunk-2R4IRVBW.mjs";
|
|
4
|
+
import {
|
|
5
|
+
copyAssets,
|
|
6
|
+
generateMarkdown
|
|
7
|
+
} from "./chunk-UJM3S22V.mjs";
|
|
8
|
+
import {
|
|
9
|
+
simple_icons_hex_default
|
|
10
|
+
} from "./chunk-EH2SEQZP.mjs";
|
|
11
|
+
|
|
12
|
+
// src/scan.ts
|
|
13
|
+
import fs from "fs";
|
|
14
|
+
import path from "path";
|
|
15
|
+
var BASE_DIR = path.join(process.cwd(), "public", "stackscan");
|
|
16
|
+
var SKIPPED_TECHS = [
|
|
17
|
+
"react-dom"
|
|
18
|
+
];
|
|
19
|
+
var CATEGORY_PRIORITY = [
|
|
20
|
+
"language",
|
|
21
|
+
"framework",
|
|
22
|
+
"mobile",
|
|
23
|
+
"frontend",
|
|
24
|
+
"backend",
|
|
25
|
+
"runtime",
|
|
26
|
+
"database",
|
|
27
|
+
"orm",
|
|
28
|
+
"auth",
|
|
29
|
+
"api",
|
|
30
|
+
"state",
|
|
31
|
+
"css",
|
|
32
|
+
"cloud",
|
|
33
|
+
"hosting",
|
|
34
|
+
"devops",
|
|
35
|
+
"container",
|
|
36
|
+
"ci",
|
|
37
|
+
"testing",
|
|
38
|
+
"build",
|
|
39
|
+
"lint",
|
|
40
|
+
"format",
|
|
41
|
+
"automation",
|
|
42
|
+
"package",
|
|
43
|
+
"ai",
|
|
44
|
+
"network",
|
|
45
|
+
"utility",
|
|
46
|
+
"cms",
|
|
47
|
+
"ssg",
|
|
48
|
+
"payment"
|
|
49
|
+
];
|
|
50
|
+
var getCategoryPriority = (cat) => {
|
|
51
|
+
const idx = CATEGORY_PRIORITY.indexOf(cat ? cat.toLowerCase() : "");
|
|
52
|
+
return idx === -1 ? 999 : idx;
|
|
53
|
+
};
|
|
54
|
+
async function analyzeProject(projectPath, options) {
|
|
55
|
+
const packageJsonPath = path.join(projectPath, "package.json");
|
|
56
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
57
|
+
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
58
|
+
}
|
|
59
|
+
const content = fs.readFileSync(packageJsonPath, "utf-8");
|
|
60
|
+
const pkg = JSON.parse(content);
|
|
61
|
+
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
62
|
+
const detectedTechs = [];
|
|
63
|
+
Object.keys(allDeps).forEach((dep) => {
|
|
64
|
+
if (SKIPPED_TECHS.includes(dep)) return;
|
|
65
|
+
if (techMap[dep]) {
|
|
66
|
+
const tech = techMap[dep];
|
|
67
|
+
let color = null;
|
|
68
|
+
if (options.color === "white") color = "#FFFFFF";
|
|
69
|
+
else if (options.color === "black") color = "#000000";
|
|
70
|
+
else if (options.color && options.color.startsWith("#")) color = options.color;
|
|
71
|
+
else {
|
|
72
|
+
const depSlug = dep.toLowerCase();
|
|
73
|
+
const nameSlug = tech.name.toLowerCase();
|
|
74
|
+
const nameSlugNoSpaces = tech.name.toLowerCase().replace(/\s+/g, "");
|
|
75
|
+
const hex = simple_icons_hex_default[depSlug] || simple_icons_hex_default[nameSlug] || simple_icons_hex_default[nameSlugNoSpaces];
|
|
76
|
+
if (hex) color = `#${hex}`;
|
|
77
|
+
}
|
|
78
|
+
detectedTechs.push({
|
|
79
|
+
name: tech.name,
|
|
80
|
+
slug: dep,
|
|
81
|
+
logo: tech.logo,
|
|
82
|
+
type: tech.type,
|
|
83
|
+
color
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const uniqueSlugs = Array.from(new Set(detectedTechs.map((t) => t.slug)));
|
|
88
|
+
let uniqueTechs = uniqueSlugs.map((slug) => detectedTechs.find((t) => t.slug === slug));
|
|
89
|
+
const seenLogos = /* @__PURE__ */ new Set();
|
|
90
|
+
uniqueTechs = uniqueTechs.filter((t) => {
|
|
91
|
+
if (seenLogos.has(t.logo)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
seenLogos.add(t.logo);
|
|
95
|
+
return true;
|
|
96
|
+
});
|
|
97
|
+
uniqueTechs.sort((a, b) => {
|
|
98
|
+
const pA = getCategoryPriority(a.type);
|
|
99
|
+
const pB = getCategoryPriority(b.type);
|
|
100
|
+
if (pA !== pB) return pA - pB;
|
|
101
|
+
return a.name.localeCompare(b.name);
|
|
102
|
+
});
|
|
103
|
+
const assetsDir = path.join(process.cwd(), "public", "assets", "logos");
|
|
104
|
+
if (options.copyAssets !== false) {
|
|
105
|
+
await copyAssets(uniqueTechs, assetsDir, { colorMode: options.color });
|
|
106
|
+
}
|
|
107
|
+
return uniqueTechs.map((t) => ({
|
|
108
|
+
...t,
|
|
109
|
+
logo: `https://raw.githubusercontent.com/benjamindotdev/stackscan/main/public/assets/logos/${t.logo}`,
|
|
110
|
+
relativePath: `./public/assets/logos/${t.logo}`
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
async function scan(targetPath, optionsOrUndefined) {
|
|
114
|
+
let options = {};
|
|
115
|
+
let pathArg = void 0;
|
|
116
|
+
if (typeof targetPath === "string") {
|
|
117
|
+
pathArg = targetPath;
|
|
118
|
+
options = optionsOrUndefined || {};
|
|
119
|
+
} else if (typeof targetPath === "object") {
|
|
120
|
+
options = targetPath;
|
|
121
|
+
}
|
|
122
|
+
if (options.readme === void 0) options.readme = true;
|
|
123
|
+
console.log("\u{1F680} Starting Scan...");
|
|
124
|
+
if (options.color) {
|
|
125
|
+
console.log(`\u{1F3A8} Color mode: ${options.color}`);
|
|
126
|
+
}
|
|
127
|
+
if (pathArg) {
|
|
128
|
+
const absPath = path.resolve(pathArg);
|
|
129
|
+
console.log(`Scanning single project at: ${absPath}`);
|
|
130
|
+
try {
|
|
131
|
+
const techsWithUrls = await analyzeProject(absPath, options);
|
|
132
|
+
if (options.out) {
|
|
133
|
+
const outPath = path.resolve(options.out);
|
|
134
|
+
fs.writeFileSync(outPath, JSON.stringify(techsWithUrls, null, 2));
|
|
135
|
+
console.log(`\u2705 Generated stack output to: ${options.out}`);
|
|
136
|
+
} else {
|
|
137
|
+
const outPath = path.join(absPath, "stack.json");
|
|
138
|
+
fs.writeFileSync(outPath, JSON.stringify(techsWithUrls, null, 2));
|
|
139
|
+
console.log(`\u2705 Generated stack.json at: ${outPath}`);
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
console.error(`\u274C Error scanning project:`, err.message);
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!fs.existsSync(BASE_DIR)) {
|
|
148
|
+
console.log(`Creating stackscan directory at: ${BASE_DIR}`);
|
|
149
|
+
fs.mkdirSync(BASE_DIR, { recursive: true });
|
|
150
|
+
console.log('Please place your project folders inside "public/stackscan/" and run this command again.');
|
|
151
|
+
process.exit(0);
|
|
152
|
+
}
|
|
153
|
+
const entries = fs.readdirSync(BASE_DIR, { withFileTypes: true });
|
|
154
|
+
const projectDirs = entries.filter((dirent) => dirent.isDirectory() && dirent.name !== "input" && dirent.name !== "output");
|
|
155
|
+
if (projectDirs.length === 0) {
|
|
156
|
+
console.log('\u26A0\uFE0F No project directories found in "public/stackscan/".');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
console.log(`Found ${projectDirs.length} projects to process.
|
|
160
|
+
`);
|
|
161
|
+
const allProjects = [];
|
|
162
|
+
for (const dir of projectDirs) {
|
|
163
|
+
const projectPath = path.join(BASE_DIR, dir.name);
|
|
164
|
+
if (fs.existsSync(path.join(projectPath, "package.json"))) {
|
|
165
|
+
try {
|
|
166
|
+
const techsWithUrls = await analyzeProject(projectPath, options);
|
|
167
|
+
fs.writeFileSync(
|
|
168
|
+
path.join(projectPath, "stack.json"),
|
|
169
|
+
JSON.stringify(techsWithUrls, null, 2)
|
|
170
|
+
);
|
|
171
|
+
const mdContent = generateMarkdown(techsWithUrls);
|
|
172
|
+
fs.writeFileSync(path.join(projectPath, "stack.md"), mdContent);
|
|
173
|
+
allProjects.push({
|
|
174
|
+
name: dir.name,
|
|
175
|
+
techs: techsWithUrls
|
|
176
|
+
});
|
|
177
|
+
console.log(`\u2705 ${dir.name.padEnd(20)} -> stack.json (${techsWithUrls.length} techs)`);
|
|
178
|
+
} catch (err) {
|
|
179
|
+
console.error(`\u274C Error processing ${dir.name}:`, err.message);
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
console.warn(`\u26A0\uFE0F Skipping "${dir.name}": No package.json found.`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (options.readme && allProjects.length > 0) {
|
|
186
|
+
updateRootReadme(allProjects);
|
|
187
|
+
} else if (!options.readme) {
|
|
188
|
+
console.log("Skipping README update (--no-readme passed).");
|
|
189
|
+
}
|
|
190
|
+
console.log("\n\u2728 Sync complete.");
|
|
191
|
+
}
|
|
192
|
+
function updateRootReadme(projects) {
|
|
193
|
+
const readmePath = path.join(process.cwd(), "README.md");
|
|
194
|
+
if (!fs.existsSync(readmePath)) {
|
|
195
|
+
console.log("\u26A0\uFE0F No root README.md found to update.");
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
let readmeContent = fs.readFileSync(readmePath, "utf-8");
|
|
199
|
+
const startMarker = "<!-- STACKSYNC_START -->";
|
|
200
|
+
const endMarker = "<!-- STACKSYNC_END -->";
|
|
201
|
+
let newSection = `${startMarker}
|
|
202
|
+
## My Projects
|
|
203
|
+
|
|
204
|
+
`;
|
|
205
|
+
for (const p of projects) {
|
|
206
|
+
newSection += `### ${p.name}
|
|
207
|
+
`;
|
|
208
|
+
newSection += `<p>
|
|
209
|
+
`;
|
|
210
|
+
for (const t of p.techs) {
|
|
211
|
+
const src = t.relativePath || t.logo;
|
|
212
|
+
newSection += ` <img src="${src}" alt="${t.name}" height="25" style="margin-right: 10px;" />
|
|
213
|
+
`;
|
|
214
|
+
}
|
|
215
|
+
newSection += `</p>
|
|
216
|
+
|
|
217
|
+
`;
|
|
218
|
+
}
|
|
219
|
+
newSection += `${endMarker}`;
|
|
220
|
+
if (readmeContent.includes(startMarker) && readmeContent.includes(endMarker)) {
|
|
221
|
+
const regex = new RegExp(`${startMarker}[\\s\\S]*?${endMarker}`);
|
|
222
|
+
readmeContent = readmeContent.replace(regex, newSection);
|
|
223
|
+
console.log(`\u{1F4DD} Updated root README.md with ${projects.length} projects.`);
|
|
224
|
+
} else {
|
|
225
|
+
readmeContent += `
|
|
226
|
+
|
|
227
|
+
${newSection}`;
|
|
228
|
+
console.log(`\u{1F4DD} Appended projects to root README.md.`);
|
|
229
|
+
}
|
|
230
|
+
fs.writeFileSync(readmePath, readmeContent);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
scan
|
|
235
|
+
};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import {
|
|
2
|
+
techMap
|
|
3
|
+
} from "./chunk-QNTMPVPN.mjs";
|
|
4
|
+
import {
|
|
5
|
+
copyAssets,
|
|
6
|
+
generateMarkdown
|
|
7
|
+
} from "./chunk-UJM3S22V.mjs";
|
|
8
|
+
import {
|
|
9
|
+
simple_icons_hex_default
|
|
10
|
+
} from "./chunk-EH2SEQZP.mjs";
|
|
11
|
+
|
|
12
|
+
// src/scan.ts
|
|
13
|
+
import fs from "fs";
|
|
14
|
+
import path from "path";
|
|
15
|
+
var BASE_DIR = path.join(process.cwd(), "public", "stackscan");
|
|
16
|
+
var SKIPPED_TECHS = [
|
|
17
|
+
"react-dom"
|
|
18
|
+
];
|
|
19
|
+
var CATEGORY_PRIORITY = [
|
|
20
|
+
"language",
|
|
21
|
+
"framework",
|
|
22
|
+
"mobile",
|
|
23
|
+
"frontend",
|
|
24
|
+
"backend",
|
|
25
|
+
"runtime",
|
|
26
|
+
"database",
|
|
27
|
+
"orm",
|
|
28
|
+
"auth",
|
|
29
|
+
"api",
|
|
30
|
+
"state",
|
|
31
|
+
"css",
|
|
32
|
+
"cloud",
|
|
33
|
+
"hosting",
|
|
34
|
+
"devops",
|
|
35
|
+
"container",
|
|
36
|
+
"ci",
|
|
37
|
+
"testing",
|
|
38
|
+
"build",
|
|
39
|
+
"lint",
|
|
40
|
+
"format",
|
|
41
|
+
"automation",
|
|
42
|
+
"package",
|
|
43
|
+
"ai",
|
|
44
|
+
"network",
|
|
45
|
+
"utility",
|
|
46
|
+
"cms",
|
|
47
|
+
"ssg",
|
|
48
|
+
"payment"
|
|
49
|
+
];
|
|
50
|
+
var getCategoryPriority = (cat) => {
|
|
51
|
+
const idx = CATEGORY_PRIORITY.indexOf(cat ? cat.toLowerCase() : "");
|
|
52
|
+
return idx === -1 ? 999 : idx;
|
|
53
|
+
};
|
|
54
|
+
async function analyzeProject(projectPath, options) {
|
|
55
|
+
const packageJsonPath = path.join(projectPath, "package.json");
|
|
56
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
57
|
+
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
58
|
+
}
|
|
59
|
+
const content = fs.readFileSync(packageJsonPath, "utf-8");
|
|
60
|
+
const pkg = JSON.parse(content);
|
|
61
|
+
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
62
|
+
const detectedTechs = [];
|
|
63
|
+
Object.keys(allDeps).forEach((dep) => {
|
|
64
|
+
if (SKIPPED_TECHS.includes(dep)) return;
|
|
65
|
+
if (techMap[dep]) {
|
|
66
|
+
const tech = techMap[dep];
|
|
67
|
+
let color = null;
|
|
68
|
+
if (options.color === "white") color = "#FFFFFF";
|
|
69
|
+
else if (options.color === "black") color = "#000000";
|
|
70
|
+
else if (options.color && options.color.startsWith("#")) color = options.color;
|
|
71
|
+
else {
|
|
72
|
+
const depSlug = dep.toLowerCase();
|
|
73
|
+
const nameSlug = tech.name.toLowerCase();
|
|
74
|
+
const nameSlugNoSpaces = tech.name.toLowerCase().replace(/\s+/g, "");
|
|
75
|
+
const hex = simple_icons_hex_default[depSlug] || simple_icons_hex_default[nameSlug] || simple_icons_hex_default[nameSlugNoSpaces];
|
|
76
|
+
if (hex) color = `#${hex}`;
|
|
77
|
+
}
|
|
78
|
+
detectedTechs.push({
|
|
79
|
+
name: tech.name,
|
|
80
|
+
slug: dep,
|
|
81
|
+
logo: tech.logo,
|
|
82
|
+
type: tech.type,
|
|
83
|
+
color
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const uniqueSlugs = Array.from(new Set(detectedTechs.map((t) => t.slug)));
|
|
88
|
+
let uniqueTechs = uniqueSlugs.map((slug) => detectedTechs.find((t) => t.slug === slug));
|
|
89
|
+
const seenLogos = /* @__PURE__ */ new Set();
|
|
90
|
+
uniqueTechs = uniqueTechs.filter((t) => {
|
|
91
|
+
if (seenLogos.has(t.logo)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
seenLogos.add(t.logo);
|
|
95
|
+
return true;
|
|
96
|
+
});
|
|
97
|
+
uniqueTechs.sort((a, b) => {
|
|
98
|
+
const pA = getCategoryPriority(a.type);
|
|
99
|
+
const pB = getCategoryPriority(b.type);
|
|
100
|
+
if (pA !== pB) return pA - pB;
|
|
101
|
+
return a.name.localeCompare(b.name);
|
|
102
|
+
});
|
|
103
|
+
const assetsDir = path.join(process.cwd(), "public", "assets", "logos");
|
|
104
|
+
if (options.copyAssets !== false) {
|
|
105
|
+
await copyAssets(uniqueTechs, assetsDir, { colorMode: options.color });
|
|
106
|
+
}
|
|
107
|
+
return uniqueTechs.map((t) => ({
|
|
108
|
+
...t,
|
|
109
|
+
logo: `https://raw.githubusercontent.com/benjamindotdev/stackscan/main/public/assets/logos/${t.logo}`,
|
|
110
|
+
relativePath: `./public/assets/logos/${t.logo}`
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
async function scan(targetPath, optionsOrUndefined) {
|
|
114
|
+
let options = {};
|
|
115
|
+
let pathArg = void 0;
|
|
116
|
+
if (typeof targetPath === "string") {
|
|
117
|
+
pathArg = targetPath;
|
|
118
|
+
options = optionsOrUndefined || {};
|
|
119
|
+
} else if (typeof targetPath === "object") {
|
|
120
|
+
options = targetPath;
|
|
121
|
+
}
|
|
122
|
+
if (options.readme === void 0) options.readme = true;
|
|
123
|
+
console.log("\u{1F680} Starting Scan...");
|
|
124
|
+
if (options.color) {
|
|
125
|
+
console.log(`\u{1F3A8} Color mode: ${options.color}`);
|
|
126
|
+
}
|
|
127
|
+
if (pathArg) {
|
|
128
|
+
const absPath = path.resolve(pathArg);
|
|
129
|
+
console.log(`Scanning single project at: ${absPath}`);
|
|
130
|
+
try {
|
|
131
|
+
const techsWithUrls = await analyzeProject(absPath, options);
|
|
132
|
+
if (options.out) {
|
|
133
|
+
const outPath = path.resolve(options.out);
|
|
134
|
+
fs.writeFileSync(outPath, JSON.stringify(techsWithUrls, null, 2));
|
|
135
|
+
console.log(`\u2705 Generated stack output to: ${options.out}`);
|
|
136
|
+
} else {
|
|
137
|
+
const outPath = path.join(absPath, "stack.json");
|
|
138
|
+
fs.writeFileSync(outPath, JSON.stringify(techsWithUrls, null, 2));
|
|
139
|
+
console.log(`\u2705 Generated stack.json at: ${outPath}`);
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
console.error(`\u274C Error scanning project:`, err.message);
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!fs.existsSync(BASE_DIR)) {
|
|
148
|
+
console.log(`Creating stackscan directory at: ${BASE_DIR}`);
|
|
149
|
+
fs.mkdirSync(BASE_DIR, { recursive: true });
|
|
150
|
+
console.log('Please place your project folders inside "public/stackscan/" and run this command again.');
|
|
151
|
+
process.exit(0);
|
|
152
|
+
}
|
|
153
|
+
const entries = fs.readdirSync(BASE_DIR, { withFileTypes: true });
|
|
154
|
+
const projectDirs = entries.filter((dirent) => dirent.isDirectory() && dirent.name !== "input" && dirent.name !== "output");
|
|
155
|
+
if (projectDirs.length === 0) {
|
|
156
|
+
console.log('\u26A0\uFE0F No project directories found in "public/stackscan/".');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
console.log(`Found ${projectDirs.length} projects to process.
|
|
160
|
+
`);
|
|
161
|
+
const allProjects = [];
|
|
162
|
+
for (const dir of projectDirs) {
|
|
163
|
+
const projectPath = path.join(BASE_DIR, dir.name);
|
|
164
|
+
if (fs.existsSync(path.join(projectPath, "package.json"))) {
|
|
165
|
+
try {
|
|
166
|
+
const techsWithUrls = await analyzeProject(projectPath, options);
|
|
167
|
+
fs.writeFileSync(
|
|
168
|
+
path.join(projectPath, "stack.json"),
|
|
169
|
+
JSON.stringify(techsWithUrls, null, 2)
|
|
170
|
+
);
|
|
171
|
+
const mdContent = generateMarkdown(techsWithUrls);
|
|
172
|
+
fs.writeFileSync(path.join(projectPath, "stack.md"), mdContent);
|
|
173
|
+
allProjects.push({
|
|
174
|
+
name: dir.name,
|
|
175
|
+
techs: techsWithUrls
|
|
176
|
+
});
|
|
177
|
+
console.log(`\u2705 ${dir.name.padEnd(20)} -> stack.json (${techsWithUrls.length} techs)`);
|
|
178
|
+
} catch (err) {
|
|
179
|
+
console.error(`\u274C Error processing ${dir.name}:`, err.message);
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
console.warn(`\u26A0\uFE0F Skipping "${dir.name}": No package.json found.`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (options.readme && allProjects.length > 0) {
|
|
186
|
+
updateRootReadme(allProjects);
|
|
187
|
+
} else if (!options.readme) {
|
|
188
|
+
console.log("Skipping README update (--no-readme passed).");
|
|
189
|
+
}
|
|
190
|
+
console.log("\n\u2728 Sync complete.");
|
|
191
|
+
}
|
|
192
|
+
function updateRootReadme(projects) {
|
|
193
|
+
const readmePath = path.join(process.cwd(), "README.md");
|
|
194
|
+
if (!fs.existsSync(readmePath)) {
|
|
195
|
+
console.log("\u26A0\uFE0F No root README.md found to update.");
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
let readmeContent = fs.readFileSync(readmePath, "utf-8");
|
|
199
|
+
const startMarker = "<!-- STACKSYNC_START -->";
|
|
200
|
+
const endMarker = "<!-- STACKSYNC_END -->";
|
|
201
|
+
let newSection = `${startMarker}
|
|
202
|
+
## My Projects
|
|
203
|
+
|
|
204
|
+
`;
|
|
205
|
+
for (const p of projects) {
|
|
206
|
+
newSection += `### ${p.name}
|
|
207
|
+
`;
|
|
208
|
+
newSection += `<p>
|
|
209
|
+
`;
|
|
210
|
+
for (const t of p.techs) {
|
|
211
|
+
const src = t.relativePath || t.logo;
|
|
212
|
+
newSection += ` <img src="${src}" alt="${t.name}" height="25" style="margin-right: 10px;" />
|
|
213
|
+
`;
|
|
214
|
+
}
|
|
215
|
+
newSection += `</p>
|
|
216
|
+
|
|
217
|
+
`;
|
|
218
|
+
}
|
|
219
|
+
newSection += `${endMarker}`;
|
|
220
|
+
if (readmeContent.includes(startMarker) && readmeContent.includes(endMarker)) {
|
|
221
|
+
const regex = new RegExp(`${startMarker}[\\s\\S]*?${endMarker}`);
|
|
222
|
+
readmeContent = readmeContent.replace(regex, newSection);
|
|
223
|
+
console.log(`\u{1F4DD} Updated root README.md with ${projects.length} projects.`);
|
|
224
|
+
} else {
|
|
225
|
+
readmeContent += `
|
|
226
|
+
|
|
227
|
+
${newSection}`;
|
|
228
|
+
console.log(`\u{1F4DD} Appended projects to root README.md.`);
|
|
229
|
+
}
|
|
230
|
+
fs.writeFileSync(readmePath, readmeContent);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
scan
|
|
235
|
+
};
|