From 8712d7aa0df19429582e5c20ee750722154d3d82 Mon Sep 17 00:00:00 2001 From: aleidk Date: Thu, 19 Dec 2024 20:27:26 -0300 Subject: [PATCH] chore: fix sass dependencies management --- .gitignore | 2 ++ .justfile | 3 +++ _scripts/link-dependencies.ts | 47 ++++++++++++++++++++++++++++++++++ bun.lockb | Bin 3569 -> 3569 bytes package.json | 14 +++++----- sass/style.scss | 2 +- tsconfig.json | 35 +++++++++++++++---------- 7 files changed, 81 insertions(+), 22 deletions(-) create mode 100644 _scripts/link-dependencies.ts diff --git a/.gitignore b/.gitignore index 6d4c0aa..0945ee5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +sass/@** + # build output dist/ diff --git a/.justfile b/.justfile index ee0b6e0..a922584 100644 --- a/.justfile +++ b/.justfile @@ -6,3 +6,6 @@ dev: build: @zola build + +link-dependencies: + bun run _scripts/link-dependencies.ts diff --git a/_scripts/link-dependencies.ts b/_scripts/link-dependencies.ts new file mode 100644 index 0000000..f78417a --- /dev/null +++ b/_scripts/link-dependencies.ts @@ -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) { + 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!"); diff --git a/bun.lockb b/bun.lockb index 40627c88cbd0c53628622aeb6db0563212108040..fd62c1faa12c4ac0b0c5a2a8df6cccb2c077a55d 100755 GIT binary patch delta 89 zcmV-f0H*)(8}S>k?E^po$}ei;7=Rm#iw~RfY%aC@L5_#yfco~_<2p)otO8^*d?s;l v{>QA|o^HZVklwG1E>=1yQ8*H(&``E4X(r;cEd;3r23{~OF)lE(+zAx~wMQsi delta 89 zcmV-f0H*)(8}S>k?E^rI`4i}zU_!^w^$ToWIWc+7!lV}+)x>$NKl5Ab{n)RhrHtt^ vEz=M*kw!Qxv35Q!03DOOA!l=SmX7Fh+Zz(IEd;3r1~4u$E-(PI+zAx~*2pKa diff --git a/package.json b/package.json index a649e34..3497cc4 100644 --- a/package.json +++ b/package.json @@ -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" + } +} \ No newline at end of file diff --git a/sass/style.scss b/sass/style.scss index a6bf647..e903ac2 100644 --- a/sass/style.scss +++ b/sass/style.scss @@ -1,4 +1,4 @@ -@import "../node_modules/@mini-strap/core/src/style.scss"; +@import "@mini-strap/core/style.scss"; html { // background-color: red; diff --git a/tsconfig.json b/tsconfig.json index bab51e4..238655f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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 } }