chore: fix sass dependencies management

This commit is contained in:
Alexander Navarro 2024-12-19 20:27:26 -03:00
parent d24fa9dc45
commit 8712d7aa0d
7 changed files with 81 additions and 22 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
sass/@**
# build output
dist/

View file

@ -6,3 +6,6 @@ dev:
build:
@zola build
link-dependencies:
bun run _scripts/link-dependencies.ts

View file

@ -0,0 +1,47 @@
#!/usr/bin/env bun
import { fileURLToPath } from 'url';
import fs from "node:fs/promises";
import { basename, normalize } from "node:path";
function ignore_exist_error(fn: (...args: any[]) => Promise<void>) {
return async (...args: any[]) => {
try {
await fn(...args);
} catch (error: any) {
if (error.code !== 'EEXIST') {
throw error; // Re-throw the error if it's not "file exists"
}
}
}
}
const mkdir = ignore_exist_error(fs.mkdir);
const symlink = ignore_exist_error(fs.symlink);
const def = await Bun.file("package.json").json();
const dependencies = Object.keys(def.dependencies);
for (const pkg of dependencies) {
const path = normalize(fileURLToPath(import.meta.resolve(pkg)));
const file = Bun.file(import.meta.resolve(pkg));
const type = file.type.split(";").at(0);
const filename = basename(path);
switch (type) {
case "text/x-scss":
await mkdir(`sass/${pkg}`)
await symlink(path, `sass/${pkg}/${filename}`);
console.log(`${path} -> sass/${pkg}/${filename}`)
break;
case "text/javascript":
// console.log("es JS")
break;
}
}
console.log();
console.log("Dependencies linked!");

BIN
bun.lockb

Binary file not shown.

View file

@ -1,14 +1,14 @@
{
"name": "personal-page",
"type": "module",
"version": "0.3.0",
"scripts": {},
"dependencies": {
"@mini-strap/core": "0.1.0"
},
"module": "index.ts",
"devDependencies": {
"typescript": "^5.2.2",
"@types/bun": "latest"
},
"module": "index.ts"
"scripts": {},
"type": "module",
"dependencies": {
"@mini-strap/core": "^0.1.0"
}
}

View file

@ -1,4 +1,4 @@
@import "../node_modules/@mini-strap/core/src/style.scss";
@import "@mini-strap/core/style.scss";
html {
// background-color: red;

View file

@ -1,20 +1,27 @@
{
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"jsxImportSource": "react",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"],
"@layouts/*": ["src/layouts/*"],
"@assets/*": ["src/assets/*"],
"@locales/*": ["public/locales/*"]
},
"plugins": [
{
"name": "@astrojs/ts-plugin"
}
]
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}