stackscan 0.1.16 → 0.1.18
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-OX7SYHLD.mjs +235 -0
- package/dist/cli.js +95 -61
- package/dist/cli.mjs +5 -3
- package/dist/index.js +91 -59
- package/dist/index.mjs +4 -4
- package/dist/scan.d.mts +2 -1
- package/dist/scan.d.ts +2 -1
- package/dist/scan.js +91 -59
- package/dist/scan.mjs +1 -1
- package/dist/scan.old.d.mts +8 -0
- package/dist/scan.old.d.ts +8 -0
- package/dist/scan.old.js +5770 -0
- package/dist/scan.old.mjs +205 -0
- package/package.json +3 -3
package/dist/scan.js
CHANGED
|
@@ -5618,12 +5618,99 @@ var getCategoryPriority = (cat) => {
|
|
|
5618
5618
|
const idx = CATEGORY_PRIORITY.indexOf(cat ? cat.toLowerCase() : "");
|
|
5619
5619
|
return idx === -1 ? 999 : idx;
|
|
5620
5620
|
};
|
|
5621
|
-
async function
|
|
5621
|
+
async function analyzeProject(projectPath, options) {
|
|
5622
|
+
const packageJsonPath = import_path2.default.join(projectPath, "package.json");
|
|
5623
|
+
if (!import_fs.default.existsSync(packageJsonPath)) {
|
|
5624
|
+
throw new Error(`No package.json found at ${packageJsonPath}`);
|
|
5625
|
+
}
|
|
5626
|
+
const content = import_fs.default.readFileSync(packageJsonPath, "utf-8");
|
|
5627
|
+
const pkg = JSON.parse(content);
|
|
5628
|
+
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
5629
|
+
const detectedTechs = [];
|
|
5630
|
+
Object.keys(allDeps).forEach((dep) => {
|
|
5631
|
+
if (SKIPPED_TECHS.includes(dep)) return;
|
|
5632
|
+
if (techMap[dep]) {
|
|
5633
|
+
const tech = techMap[dep];
|
|
5634
|
+
let color = null;
|
|
5635
|
+
if (options.color === "white") color = "#FFFFFF";
|
|
5636
|
+
else if (options.color === "black") color = "#000000";
|
|
5637
|
+
else if (options.color && options.color.startsWith("#")) color = options.color;
|
|
5638
|
+
else {
|
|
5639
|
+
const depSlug = dep.toLowerCase();
|
|
5640
|
+
const nameSlug = tech.name.toLowerCase();
|
|
5641
|
+
const nameSlugNoSpaces = tech.name.toLowerCase().replace(/\s+/g, "");
|
|
5642
|
+
const hex = simple_icons_hex_default[depSlug] || simple_icons_hex_default[nameSlug] || simple_icons_hex_default[nameSlugNoSpaces];
|
|
5643
|
+
if (hex) color = `#${hex}`;
|
|
5644
|
+
}
|
|
5645
|
+
detectedTechs.push({
|
|
5646
|
+
name: tech.name,
|
|
5647
|
+
slug: dep,
|
|
5648
|
+
logo: tech.logo,
|
|
5649
|
+
type: tech.type,
|
|
5650
|
+
color
|
|
5651
|
+
});
|
|
5652
|
+
}
|
|
5653
|
+
});
|
|
5654
|
+
const uniqueSlugs = Array.from(new Set(detectedTechs.map((t) => t.slug)));
|
|
5655
|
+
let uniqueTechs = uniqueSlugs.map((slug) => detectedTechs.find((t) => t.slug === slug));
|
|
5656
|
+
const seenLogos = /* @__PURE__ */ new Set();
|
|
5657
|
+
uniqueTechs = uniqueTechs.filter((t) => {
|
|
5658
|
+
if (seenLogos.has(t.logo)) {
|
|
5659
|
+
return false;
|
|
5660
|
+
}
|
|
5661
|
+
seenLogos.add(t.logo);
|
|
5662
|
+
return true;
|
|
5663
|
+
});
|
|
5664
|
+
uniqueTechs.sort((a, b) => {
|
|
5665
|
+
const pA = getCategoryPriority(a.type);
|
|
5666
|
+
const pB = getCategoryPriority(b.type);
|
|
5667
|
+
if (pA !== pB) return pA - pB;
|
|
5668
|
+
return a.name.localeCompare(b.name);
|
|
5669
|
+
});
|
|
5670
|
+
const assetsDir = import_path2.default.join(process.cwd(), "public", "assets", "logos");
|
|
5671
|
+
if (options.copyAssets !== false) {
|
|
5672
|
+
await copyAssets(uniqueTechs, assetsDir, { colorMode: options.color });
|
|
5673
|
+
}
|
|
5674
|
+
return uniqueTechs.map((t) => ({
|
|
5675
|
+
...t,
|
|
5676
|
+
logo: `https://raw.githubusercontent.com/benjamindotdev/stackscan/main/public/assets/logos/${t.logo}`,
|
|
5677
|
+
relativePath: `./public/assets/logos/${t.logo}`
|
|
5678
|
+
}));
|
|
5679
|
+
}
|
|
5680
|
+
async function scan(targetPath, optionsOrUndefined) {
|
|
5681
|
+
let options = {};
|
|
5682
|
+
let pathArg = void 0;
|
|
5683
|
+
if (typeof targetPath === "string") {
|
|
5684
|
+
pathArg = targetPath;
|
|
5685
|
+
options = optionsOrUndefined || {};
|
|
5686
|
+
} else if (typeof targetPath === "object") {
|
|
5687
|
+
options = targetPath;
|
|
5688
|
+
}
|
|
5622
5689
|
if (options.readme === void 0) options.readme = true;
|
|
5623
5690
|
console.log("\u{1F680} Starting Scan...");
|
|
5624
5691
|
if (options.color) {
|
|
5625
5692
|
console.log(`\u{1F3A8} Color mode: ${options.color}`);
|
|
5626
5693
|
}
|
|
5694
|
+
if (pathArg) {
|
|
5695
|
+
const absPath = import_path2.default.resolve(pathArg);
|
|
5696
|
+
console.log(`Scanning single project at: ${absPath}`);
|
|
5697
|
+
try {
|
|
5698
|
+
const techsWithUrls = await analyzeProject(absPath, options);
|
|
5699
|
+
if (options.out) {
|
|
5700
|
+
const outPath = import_path2.default.resolve(options.out);
|
|
5701
|
+
import_fs.default.writeFileSync(outPath, JSON.stringify(techsWithUrls, null, 2));
|
|
5702
|
+
console.log(`\u2705 Generated stack output to: ${options.out}`);
|
|
5703
|
+
} else {
|
|
5704
|
+
const outPath = import_path2.default.join(absPath, "stack.json");
|
|
5705
|
+
import_fs.default.writeFileSync(outPath, JSON.stringify(techsWithUrls, null, 2));
|
|
5706
|
+
console.log(`\u2705 Generated stack.json at: ${outPath}`);
|
|
5707
|
+
}
|
|
5708
|
+
} catch (err) {
|
|
5709
|
+
console.error(`\u274C Error scanning project:`, err.message);
|
|
5710
|
+
process.exit(1);
|
|
5711
|
+
}
|
|
5712
|
+
return;
|
|
5713
|
+
}
|
|
5627
5714
|
if (!import_fs.default.existsSync(BASE_DIR)) {
|
|
5628
5715
|
console.log(`Creating stackscan directory at: ${BASE_DIR}`);
|
|
5629
5716
|
import_fs.default.mkdirSync(BASE_DIR, { recursive: true });
|
|
@@ -5639,66 +5726,11 @@ async function scan(options = {}) {
|
|
|
5639
5726
|
console.log(`Found ${projectDirs.length} projects to process.
|
|
5640
5727
|
`);
|
|
5641
5728
|
const allProjects = [];
|
|
5642
|
-
const allTechs = [];
|
|
5643
5729
|
for (const dir of projectDirs) {
|
|
5644
5730
|
const projectPath = import_path2.default.join(BASE_DIR, dir.name);
|
|
5645
|
-
|
|
5646
|
-
if (import_fs.default.existsSync(packageJsonPath)) {
|
|
5731
|
+
if (import_fs.default.existsSync(import_path2.default.join(projectPath, "package.json"))) {
|
|
5647
5732
|
try {
|
|
5648
|
-
const
|
|
5649
|
-
const pkg = JSON.parse(content);
|
|
5650
|
-
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
5651
|
-
const detectedTechs = [];
|
|
5652
|
-
Object.keys(allDeps).forEach((dep) => {
|
|
5653
|
-
if (SKIPPED_TECHS.includes(dep)) return;
|
|
5654
|
-
if (techMap[dep]) {
|
|
5655
|
-
const tech = techMap[dep];
|
|
5656
|
-
let color = null;
|
|
5657
|
-
if (options.color === "white") color = "#FFFFFF";
|
|
5658
|
-
else if (options.color === "black") color = "#000000";
|
|
5659
|
-
else if (options.color && options.color.startsWith("#")) color = options.color;
|
|
5660
|
-
else {
|
|
5661
|
-
const depSlug = dep.toLowerCase();
|
|
5662
|
-
const nameSlug = tech.name.toLowerCase();
|
|
5663
|
-
const nameSlugNoSpaces = tech.name.toLowerCase().replace(/\s+/g, "");
|
|
5664
|
-
const hex = simple_icons_hex_default[depSlug] || simple_icons_hex_default[nameSlug] || simple_icons_hex_default[nameSlugNoSpaces];
|
|
5665
|
-
if (hex) color = `#${hex}`;
|
|
5666
|
-
}
|
|
5667
|
-
detectedTechs.push({
|
|
5668
|
-
name: tech.name,
|
|
5669
|
-
slug: dep,
|
|
5670
|
-
logo: tech.logo,
|
|
5671
|
-
// Raw path for resolution
|
|
5672
|
-
type: tech.type,
|
|
5673
|
-
color
|
|
5674
|
-
});
|
|
5675
|
-
}
|
|
5676
|
-
});
|
|
5677
|
-
let uniqueTechs = Array.from(new Set(detectedTechs.map((t) => t.slug))).map((slug) => detectedTechs.find((t) => t.slug === slug));
|
|
5678
|
-
const seenLogos = /* @__PURE__ */ new Set();
|
|
5679
|
-
uniqueTechs = uniqueTechs.filter((t) => {
|
|
5680
|
-
if (seenLogos.has(t.logo)) {
|
|
5681
|
-
return false;
|
|
5682
|
-
}
|
|
5683
|
-
seenLogos.add(t.logo);
|
|
5684
|
-
return true;
|
|
5685
|
-
});
|
|
5686
|
-
uniqueTechs.sort((a, b) => {
|
|
5687
|
-
const pA = getCategoryPriority(a.type);
|
|
5688
|
-
const pB = getCategoryPriority(b.type);
|
|
5689
|
-
if (pA !== pB) return pA - pB;
|
|
5690
|
-
return a.name.localeCompare(b.name);
|
|
5691
|
-
});
|
|
5692
|
-
const assetsDir = import_path2.default.join(process.cwd(), "public", "assets", "logos");
|
|
5693
|
-
if (options.copyAssets !== false) {
|
|
5694
|
-
await copyAssets(uniqueTechs, assetsDir, { colorMode: options.color });
|
|
5695
|
-
}
|
|
5696
|
-
const techsWithUrls = uniqueTechs.map((t) => ({
|
|
5697
|
-
...t,
|
|
5698
|
-
logo: `https://raw.githubusercontent.com/benjamindotdev/stackscan/main/public/assets/logos/${t.logo}`,
|
|
5699
|
-
relativePath: `./public/assets/logos/${t.logo}`
|
|
5700
|
-
}));
|
|
5701
|
-
allTechs.push(...techsWithUrls);
|
|
5733
|
+
const techsWithUrls = await analyzeProject(projectPath, options);
|
|
5702
5734
|
import_fs.default.writeFileSync(
|
|
5703
5735
|
import_path2.default.join(projectPath, "stack.json"),
|
|
5704
5736
|
JSON.stringify(techsWithUrls, null, 2)
|
|
@@ -5709,7 +5741,7 @@ async function scan(options = {}) {
|
|
|
5709
5741
|
name: dir.name,
|
|
5710
5742
|
techs: techsWithUrls
|
|
5711
5743
|
});
|
|
5712
|
-
console.log(`\u2705 ${dir.name.padEnd(20)} -> stack.json (${
|
|
5744
|
+
console.log(`\u2705 ${dir.name.padEnd(20)} -> stack.json (${techsWithUrls.length} techs)`);
|
|
5713
5745
|
} catch (err) {
|
|
5714
5746
|
console.error(`\u274C Error processing ${dir.name}:`, err.message);
|
|
5715
5747
|
}
|
package/dist/scan.mjs
CHANGED