diff --git a/package.json b/package.json index d2597f5..24e64d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "type": "module", - "version": "1.1.11", + "version": "1.1.12", "name": "@mp281x/shared-config", "publishConfig": { "registry": "https://npm.pkg.github.com/@mp281x" }, diff --git a/src/lib/findProjects.ts b/src/lib/findProjects.ts index 5a1a19a..3d24400 100644 --- a/src/lib/findProjects.ts +++ b/src/lib/findProjects.ts @@ -15,7 +15,7 @@ const getWorkspaceProjects = (dir: string) => { return globs.flatMap((glob) => findGlob(glob, { cwd: dir })).filter((path) => fs.existsSync(`${dir}/${path}/package.json`)) } -export type Project = { name: string; scripts: string[]; lspPlugin: boolean; cwd: string } +export type Project = { name: string; scripts: string[]; lspPlugin: boolean; cwd: string; type: 'svelte' | 'node' } // find all the projects in a the monorepo/repo export const findProjects = (dir: string = process.cwd()): Project[] => { const projects = getWorkspaceProjects(dir).flatMap((project) => findProjects(project)) @@ -24,8 +24,8 @@ export const findProjects = (dir: string = process.cwd()): Project[] => { if (!fs.existsSync(`${dir}/package.json`)) return [] // load the package info - type PackageJSON = { scripts?: Record } - const { scripts } = parseConfig(`${dir}/package.json`) ?? {} + type PackageJSON = { scripts?: Record; devDependencies?: Record } + const { scripts, devDependencies } = parseConfig(`${dir}/package.json`) ?? {} // read the tsconfig and check if the project is using the custom lsp plugin type TSConfig = { compilerOptions?: { plugins?: { name: string }[] } } @@ -37,6 +37,7 @@ export const findProjects = (dir: string = process.cwd()): Project[] => { { scripts: Object.keys(scripts ?? {}), name: dir.split('/').pop() ?? '', + type: devDependencies?.['svelte'] ? 'svelte' : 'node', lspPlugin, cwd: dir } diff --git a/src/task-runner.ts b/src/task-runner.ts index fed1c83..c3a8dca 100644 --- a/src/task-runner.ts +++ b/src/task-runner.ts @@ -38,13 +38,31 @@ if (flags.length === 0 || flags.includes('--check')) { }) // type check - for (const { name, cwd } of projects) { - await execCmd({ - title: `${name}:tsc`, - cmd: ['tsc', '--noEmit'], - mode: 'sync', - cwd - }) + for (const { name, cwd, type } of projects) { + if (type === 'svelte') { + await execCmd({ + title: `svelte-sync:${name}`, + cmd: ['svelte-kit', 'sync'], + mode: 'sync', + cwd + }) + + await execCmd({ + title: `svelte-check:${name}`, + cmd: ['svelte-check', '--output=human', '--tsconfig=./tsconfig.json'], + mode: 'sync', + cwd + }) + } + + if (type === 'node') { + await execCmd({ + title: `${name}:tsc`, + cmd: ['tsc', '--noEmit'], + mode: 'sync', + cwd + }) + } } }