stackscan 0.1.22 → 0.1.24
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/README.md +6 -8
- package/dist/chunk-24PM76MV.mjs +235 -0
- package/dist/chunk-E75XPZ2U.mjs +2237 -0
- package/dist/chunk-HKCVFKM4.mjs +19 -0
- package/dist/chunk-XNTLNSF6.mjs +158 -0
- package/dist/cli.js +14 -8
- package/dist/cli.mjs +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -10
- package/dist/index.mjs +4 -4
- package/dist/output.d.mts +3 -3
- package/dist/output.d.ts +3 -3
- package/dist/scan.js +14 -8
- package/dist/scan.mjs +3 -3
- package/dist/sync.js +14 -8
- package/dist/sync.mjs +3 -3
- package/dist/techDefinitions.js +12 -6
- package/dist/techDefinitions.mjs +1 -1
- package/dist/techMap.js +12 -6
- package/dist/techMap.mjs +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
- package/public/assets/logos/cli/chalk.svg +1 -1
- package/public/assets/logos/cli/ora.svg +1 -1
- package/public/assets/logos/cloud/googlecloud.svg +1 -1
- package/public/assets/logos/css/fallback/mantine-logo.svg +0 -1
- package/public/assets/logos/css/fallback/shadcnui.svg +0 -1
package/README.md
CHANGED
|
@@ -38,10 +38,8 @@ stackscan
|
|
|
38
38
|
## Usage
|
|
39
39
|
|
|
40
40
|
1. **Prepare Input**:
|
|
41
|
-
* Place
|
|
42
|
-
*
|
|
43
|
-
* If you have multiple, you can name them `package (1).json`, `package (2).json`, etc.
|
|
44
|
-
* StackScan will automatically create folders based on the project name defined in each file.
|
|
41
|
+
* Place a folder for each desired project inside `public/stackscan/`.
|
|
42
|
+
* Each folder should contain a `package.json` file.
|
|
45
43
|
2. **Run Scan**:
|
|
46
44
|
|
|
47
45
|
```bash
|
|
@@ -60,10 +58,10 @@ npx stackscan add ./path/to/package.json
|
|
|
60
58
|
npx stackscan add ../my-project
|
|
61
59
|
```
|
|
62
60
|
|
|
63
|
-
This will copy the `package.json` into a new folder inside `stackscan/` (e.g., `stackscan/my-project/`), handling name collisions automatically.
|
|
61
|
+
This will copy the `package.json` into a new folder inside `public/stackscan/` (e.g., `public/stackscan/my-project/`), handling name collisions automatically.
|
|
64
62
|
|
|
65
63
|
This will:
|
|
66
|
-
* Scan all projects in `stackscan/`.
|
|
64
|
+
* Scan all projects in `public/stackscan/`.
|
|
67
65
|
* Generate `stack.json` and `stack.md` inside each project folder.
|
|
68
66
|
* Copy logo assets to `public/assets/logos/`.
|
|
69
67
|
* Update your root `README.md` with a "My Projects" section.
|
|
@@ -85,7 +83,7 @@ npx stackscan scan --color brand
|
|
|
85
83
|
|
|
86
84
|
## Output
|
|
87
85
|
|
|
88
|
-
For each project in `stackscan/`, a `stack.json` is generated in the same folder.
|
|
86
|
+
For each project in `public/stackscan/`, a `stack.json` is generated in the same folder.
|
|
89
87
|
|
|
90
88
|
Example `stack.json`:
|
|
91
89
|
|
|
@@ -149,7 +147,7 @@ jobs:
|
|
|
149
147
|
|
|
150
148
|
---
|
|
151
149
|
|
|
152
|
-
## What
|
|
150
|
+
## What StackScan does *not* do
|
|
153
151
|
|
|
154
152
|
* ❌ It does not execute or analyze runtime code
|
|
155
153
|
* ❌ It does not attempt to infer architectural quality
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import {
|
|
2
|
+
techMap
|
|
3
|
+
} from "./chunk-HKCVFKM4.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 = "<!-- STACKSCAN_START -->";
|
|
200
|
+
const endMarker = "<!-- STACKSCAN_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
|
+
};
|