UNPKG

@modyqyw/fabric

Version:

Opinionated shareable specifications for git-based JavaScript/TypeScript projects.

108 lines (105 loc) 5.25 kB
import { existsSync } from 'node:fs'; import { resolve } from 'node:path'; import process from 'node:process'; import { isPackageExists, getPackageInfoSync } from 'local-pkg'; const hasTypeScript = isPackageExists("typescript"); const hasNuxt = isPackageExists("nuxt"); const getNuxtVersion = () => { const pkg = getPackageInfoSync("nuxt", { paths: [process.cwd()] }); if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) { return +pkg.version[0]; } return 3; }; const hasNuxt3 = getNuxtVersion() === 3; const hasVuePress = isPackageExists("vuepress"); const hasVitePress = isPackageExists("vitepress"); const hasSlidev = isPackageExists("@slidev/cli"); const hasUniApp = isPackageExists("@dcloudio/vite-plugin-uni") || isPackageExists("@dcloudio/vue-cli-plugin-uni"); const hasTaroVue = [ "@tarojs/taro", "@tarojs/plugin-framework-vue" ].every((p) => isPackageExists(p)); const hasIonicVue = isPackageExists("@ionic/vue"); const hasVue = isPackageExists("vue") || hasNuxt || hasVuePress || hasVitePress || hasSlidev || hasUniApp || hasTaroVue || hasIonicVue; const getVueVersion = () => { const pkg = getPackageInfoSync("vue", { paths: [process.cwd()] }); if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) { return +pkg.version[0]; } return 3; }; const hasVue3 = getVueVersion() === 3; const hasNext = ["next"].some((p) => isPackageExists(p)); const hasRemix = [ "@remix-run/node", "@remix-run/react", "@remix-run/serve", "@remix-run/dev", "remix" ].some((p) => isPackageExists(p)); const hasReactRouter = [ "@react-router/node", "@react-router/react", "@react-router/serve", "@react-router/dev" ].some((p) => isPackageExists(p)); const hasReactNative = ["react-native", "@expo/cli"].some( (p) => isPackageExists(p) ); const hasIonicReact = isPackageExists("@ionic/react"); const hasDocusaurus = isPackageExists("docusaurus"); const hasTaroReact = [ "@tarojs/taro", "@tarojs/plugin-framework-react" ].every((p) => isPackageExists(p)); const hasReact = isPackageExists("react") || hasNext || hasRemix || hasReactNative || hasIonicReact || hasDocusaurus || hasTaroReact; const hasSvelteKit = isPackageExists("@sveltejs/kit"); const hasTaroSvelte = [ "@tarojs/taro", "@tarojs/plugin-framework-svelte" ].every((p) => isPackageExists(p)); const hasSvelte = hasSvelteKit || hasTaroSvelte || isPackageExists("svelte"); const hasSolidStart = isPackageExists("solid-start"); const hasTaroSolid = [ "@tarojs/taro", "@tarojs/plugin-framework-solid" ].every((p) => isPackageExists(p)); const hasSolid = hasSolidStart || hasTaroSolid || isPackageExists("solid-js"); const hasAstro = isPackageExists("astro"); const hasTaro = isPackageExists("@tarojs/taro"); const hasMiniProgram = hasUniApp || hasTaro; const hasScss = isPackageExists("sass"); const hasLess = isPackageExists("less"); const hasUnoCss = isPackageExists("unocss"); const hasWindiCss = isPackageExists("windicss"); const hasTailwindCss = isPackageExists("tailwindcss"); const hasVite = isPackageExists("vite"); const hasLerna = isPackageExists("lerna") || isPackageExists("@lerna-lite/cli"); const hasNx = isPackageExists("nx"); const hasRush = isPackageExists("@microsoft/rush"); const hasPnpmWorkspace = existsSync( resolve(process.cwd(), "pnpm-workspace.yaml") ); const hasMonoRepo = hasLerna || hasNx || hasRush || hasPnpmWorkspace; const hasVitest = isPackageExists("vitest"); const hasTsconfigVitestJson = existsSync( resolve(process.cwd(), "tsconfig.vitest.json") ); const hasTsconfigTestJson = existsSync( resolve(process.cwd(), "tsconfig.test.json") ); const hasTsconfigAppJson = existsSync( resolve(process.cwd(), "tsconfig.app.json") ); const hasBiome = isPackageExists("biome"); const hasESLint = isPackageExists("eslint"); const hasOxlint = isPackageExists("oxlint"); const hasStylelint = isPackageExists("stylelint"); const hasPrettier = isPackageExists("prettier"); const hasTsc = isPackageExists("typescript"); const hasVueTsc = isPackageExists("vue-tsc"); const hasMarkdownlintCli = isPackageExists("markdownlint-cli"); const hasLintStaged = isPackageExists("lint-staged"); const hasCommitlint = isPackageExists("@commitlint/cli") || isPackageExists("commitlint-cli"); export { hasLintStaged as $, hasSolid as A, hasAstro as B, hasTaro as C, hasMiniProgram as D, hasScss as E, hasLess as F, hasUnoCss as G, hasWindiCss as H, hasTailwindCss as I, hasVite as J, hasLerna as K, hasNx as L, hasRush as M, hasPnpmWorkspace as N, hasMonoRepo as O, hasVitest as P, hasTsconfigVitestJson as Q, hasTsconfigTestJson as R, hasTsconfigAppJson as S, hasBiome as T, hasESLint as U, hasOxlint as V, hasStylelint as W, hasPrettier as X, hasTsc as Y, hasVueTsc as Z, hasMarkdownlintCli as _, hasNuxt as a, hasCommitlint as a0, hasNuxt3 as b, hasVuePress as c, hasVitePress as d, hasSlidev as e, hasUniApp as f, getNuxtVersion as g, hasTypeScript as h, hasTaroVue as i, hasIonicVue as j, hasVue as k, getVueVersion as l, hasVue3 as m, hasNext as n, hasRemix as o, hasReactRouter as p, hasReactNative as q, hasIonicReact as r, hasDocusaurus as s, hasTaroReact as t, hasReact as u, hasSvelteKit as v, hasTaroSvelte as w, hasSvelte as x, hasSolidStart as y, hasTaroSolid as z };