@xylabs/ts-scripts-yarn3 6.4.5 → 6.4.6
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/actions/deplint.mjs +2 -1
- package/dist/actions/deplint.mjs.map +1 -1
- package/dist/actions/index.mjs +2 -1
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +2 -1
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +2 -1
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +2 -1
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +2 -1
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +2 -2
package/dist/actions/deplint.mjs
CHANGED
|
@@ -55,13 +55,14 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
|
55
55
|
);
|
|
56
56
|
const imports = [];
|
|
57
57
|
const typeImports = [];
|
|
58
|
+
const isDeclarationFile = filePath.endsWith(".d.ts");
|
|
58
59
|
function visit(node) {
|
|
59
60
|
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
60
61
|
const moduleSpecifier = node.moduleSpecifier?.getFullText();
|
|
61
62
|
const isTypeImport = ts.isImportDeclaration(node) ? node.importClause?.isTypeOnly ?? false : false;
|
|
62
63
|
if (moduleSpecifier) {
|
|
63
64
|
const trimmed = moduleSpecifier.split("'").at(1) ?? moduleSpecifier;
|
|
64
|
-
if (isTypeImport) {
|
|
65
|
+
if (isTypeImport && !isDeclarationFile) {
|
|
65
66
|
typeImports.push(trimmed);
|
|
66
67
|
} else {
|
|
67
68
|
imports.push(trimmed);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/deplint.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/yarn/workspace/yarnWorkspace.ts"],"sourcesContent":["/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport chalk from 'chalk'\nimport { globSync } from 'glob'\nimport ts from 'typescript'\n\nimport { yarnWorkspace, yarnWorkspaces } from '../lib/index.ts'\n\nfunction getDependenciesFromPackageJson(packageJsonPath: string) {\n const packageJsonFullPath = path.resolve(packageJsonPath)\n const rawContent = fs.readFileSync(packageJsonFullPath, 'utf8')\n const packageJson = JSON.parse(rawContent)\n\n const dependencies = packageJson.dependencies\n ? Object.keys(packageJson.dependencies)\n : []\n\n const devDependencies = packageJson.devDependencies\n ? Object.keys(packageJson.devDependencies)\n : []\n\n const peerDependencies = packageJson.peerDependencies\n ? Object.keys(packageJson.peerDependencies)\n : []\n\n return {\n dependencies, devDependencies, peerDependencies,\n }\n}\n\nfunction getBasePackageName(importName: string) {\n if (importName.startsWith('@')) {\n const parts = importName.split('/')\n return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : importName\n }\n return importName.split('/')[0]\n}\n\nfunction getImportsFromFile(filePath: string, importPaths: Record<string, string[]>, typeImportPaths: Record<string, string[]>) {\n const sourceCode = fs.readFileSync(filePath, 'utf8')\n\n const sourceFile = ts.createSourceFile(\n path.basename(filePath),\n sourceCode,\n ts.ScriptTarget.Latest,\n true,\n )\n\n const imports: string[] = []\n const typeImports: string[] = []\n\n function visit(node: ts.Node) {\n if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {\n const moduleSpecifier = (node.moduleSpecifier)?.getFullText()\n const isTypeImport = ts.isImportDeclaration(node) ? (node.importClause?.isTypeOnly ?? false) : false\n if (moduleSpecifier) {\n const trimmed = moduleSpecifier.split(\"'\").at(1) ?? moduleSpecifier\n if (isTypeImport) {\n typeImports.push(trimmed)\n } else {\n imports.push(trimmed)\n }\n }\n } else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {\n const [arg] = node.arguments\n if (ts.isStringLiteral(arg)) {\n const trimmed = arg.text\n imports.push(trimmed)\n }\n }\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n\n const importsStartsWithExcludes = ['.', '#', 'node:']\n\n const cleanedImports = imports.filter(imp => !importsStartsWithExcludes.some(exc => imp.startsWith(exc))).map(getBasePackageName)\n const cleanedTypeImports = typeImports.filter(imp => !importsStartsWithExcludes.some(exc => imp.startsWith(exc))).map(getBasePackageName)\n\n for (const imp of cleanedImports) {\n importPaths[imp] = importPaths[imp] || []\n importPaths[imp].push(filePath)\n }\n\n for (const imp of cleanedTypeImports) {\n typeImportPaths[imp] = typeImportPaths[imp] || []\n typeImportPaths[imp].push(filePath)\n }\n\n return [cleanedImports, cleanedTypeImports]\n}\n\nfunction findFilesByGlob(cwd: string, pattern: string) {\n return globSync(pattern, { cwd, absolute: true })\n}\n\nfunction findFiles(path: string) {\n const allSourceInclude = ['./src/**/*.{ts,tsx}', './dist/**/*.d.ts']\n const prodExcludeEndswith = ['.spec.ts', '.stories.tsx']\n const prodExcludeIncludes = ['/spec/', '/stories/', '/scripts/']\n const allSourceFiles = allSourceInclude.flatMap(pattern => findFilesByGlob(path, pattern))\n\n const prodSourceFiles = allSourceFiles.filter(file => !prodExcludeEndswith.some(ext => file.endsWith(ext))\n && !prodExcludeIncludes.some(excl => file.includes(excl)))\n\n const devSourceFiles = allSourceFiles.filter(file => !prodSourceFiles.includes(file))\n return {\n allSourceFiles, prodSourceFiles, devSourceFiles,\n }\n}\n\nfunction getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles }: { devSourceFiles: string[]; prodSourceFiles: string[] }) {\n const prodImportPaths: Record<string, string[]> = {}\n const prodTypeImportPaths: Record<string, string[]> = {}\n const prodImportPairs = prodSourceFiles.map(path => getImportsFromFile(path, prodImportPaths, prodTypeImportPaths))\n const prodImports = prodImportPairs.flatMap(pair => pair[0])\n const prodTypeImports = prodImportPairs.flatMap(pair => pair[1])\n\n const devImportPaths: Record<string, string[]> = {}\n const devTypeImportPaths: Record<string, string[]> = {}\n const devImportPairs = devSourceFiles.map(path => getImportsFromFile(path, devImportPaths, devTypeImportPaths))\n const devImports = devImportPairs.flatMap(pair => pair[0])\n const devTypeImports = devImportPairs.flatMap(pair => pair[1])\n\n const externalProdImports = prodImports.filter(imp => !imp.startsWith('.') && !imp.startsWith('#') && !imp.startsWith('node:'))\n const externalProdTypeImports = prodTypeImports.filter(imp => !imp.startsWith('.') && !imp.startsWith('#') && !imp.startsWith('node:'))\n const externalDevImports = devImports.filter(imp => !imp.startsWith('.') && !imp.startsWith('#') && !imp.startsWith('node:'))\n return {\n prodImports,\n devImports,\n prodImportPaths,\n prodTypeImportPaths,\n devImportPaths,\n externalProdImports,\n externalDevImports,\n prodTypeImports,\n devTypeImports,\n externalProdTypeImports,\n }\n}\n\nfunction check({\n name, location, devDeps = false, peerDeps = false,\n}: { devDeps?: boolean; location: string; name: string; peerDeps?: boolean }) {\n const { prodSourceFiles, devSourceFiles } = findFiles(location)\n const {\n prodTypeImportPaths, prodImportPaths, externalProdTypeImports, devImportPaths, externalProdImports, externalDevImports,\n } = getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles })\n\n const {\n dependencies, devDependencies, peerDependencies,\n } = getDependenciesFromPackageJson(`${location}/package.json`)\n\n let unlistedDependencies = 0\n let unlistedDevDependencies = 0\n let unusedDependencies = 0\n let typesInDependencies = 0\n\n for (const imp of externalProdTypeImports) {\n if (!dependencies.includes(imp) && !peerDependencies.includes(imp) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`)) {\n unlistedDependencies++\n console.log(`[${chalk.blue(name)}] Missing dependency in package.json: ${chalk.red(imp)}`)\n console.log(` ${prodTypeImportPaths[imp].join('\\n')}`)\n console.log('')\n }\n }\n\n for (const imp of externalProdImports) {\n if (!dependencies.includes(imp) && !peerDependencies.includes(imp)) {\n unlistedDependencies++\n console.log(`[${chalk.blue(name)}] Missing dependency in package.json: ${chalk.red(imp)}`)\n console.log(` ${prodImportPaths[imp].join('\\n')}`)\n console.log('')\n }\n }\n\n for (const dep of dependencies) {\n if (dep.startsWith('@types/')) {\n typesInDependencies++\n console.log(`[${chalk.blue(name)}] @types in dependencies in package.json: ${chalk.red(dep)}`)\n console.log(` ${location}/package.json\\n`)\n console.log('')\n }\n if (!externalProdImports.includes(dep)) {\n unusedDependencies++\n console.log(`[${chalk.blue(name)}] Unused dependency in package.json: ${chalk.red(dep)}`)\n console.log(` ${location}/package.json\\n`)\n console.log('')\n }\n }\n\n if (peerDeps) {\n for (const dep of peerDependencies) {\n if (!externalProdImports.includes(dep)) {\n unusedDependencies++\n console.log(`[${chalk.blue(name)}] Unused peerDependency in package.json: ${chalk.red(dep)}`)\n console.log(` ${location}/package.json\\n`)\n console.log('')\n }\n }\n }\n\n if (devDeps) {\n for (const imp of externalDevImports) {\n if (!devDependencies.includes(imp)) {\n unlistedDevDependencies++\n console.log(`[${chalk.blue(name)}] Missing devDependency in package.json: ${chalk.red(imp)}`)\n console.log(` Found in: ${devImportPaths[imp].join(', ')}`)\n }\n }\n }\n\n const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + typesInDependencies\n\n return totalErrors\n}\n\nexport const deplint = ({ pkg }: { pkg: string }) => {\n if (pkg) {\n const { location, name } = yarnWorkspace(pkg)\n\n console.log(`Running Deplint for ${name}`)\n check({\n name, location, devDeps: true,\n })\n } else {\n const workspaces = yarnWorkspaces()\n\n console.log('Deplint Started...')\n\n let totalErrors = 0\n\n for (const workspace of workspaces) {\n totalErrors += check(workspace)\n }\n\n if (totalErrors > 0) {\n console.log(`Found ${chalk.red(totalErrors)} unlisted imports.`)\n } else {\n console.log(`No unlisted imports found. ${chalk.green('✔')}`)\n }\n }\n return 0\n}\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { Workspace } from './Workspace.ts'\nimport { yarnWorkspaces } from './yarnWorkspaces.ts'\n\nexport const yarnWorkspace = (pkg: string): Workspace => {\n const workspace = yarnWorkspaces().find(({ name }) => name === pkg)\n if (!workspace) throw new Error(`Workspace ${pkg} not found`)\n return workspace\n}\n"],"mappings":";AAEA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,OAAO,WAAW;AAClB,SAAS,gBAAgB;AACzB,OAAO,QAAQ;;;ACPf,SAAS,iBAAiB;AAInB,IAAM,iBAAiB,MAAmB;AAC/C,QAAM,SAAS,UAAU,QAAQ,CAAC,cAAc,QAAQ,UAAU,aAAa,GAAG,EAAE,UAAU,QAAQ,OAAO,KAAK,CAAC;AACnH,MAAI,OAAO,OAAO;AAChB,UAAM,OAAO;AAAA,EACf;AACA,SACE,OAAO,OACJ,SAAS,EAGT,MAAM,IAAI,EACV,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,CAAC;AAEP;;;ACjBO,IAAM,gBAAgB,CAAC,QAA2B;AACvD,QAAM,YAAY,eAAe,EAAE,KAAK,CAAC,EAAE,KAAK,MAAM,SAAS,GAAG;AAClE,MAAI,CAAC,UAAW,OAAM,IAAI,MAAM,aAAa,GAAG,YAAY;AAC5D,SAAO;AACT;;;AFIA,SAAS,+BAA+B,iBAAyB;AAC/D,QAAM,sBAAsB,KAAK,QAAQ,eAAe;AACxD,QAAM,aAAa,GAAG,aAAa,qBAAqB,MAAM;AAC9D,QAAM,cAAc,KAAK,MAAM,UAAU;AAEzC,QAAM,eAAe,YAAY,eAC7B,OAAO,KAAK,YAAY,YAAY,IACpC,CAAC;AAEL,QAAM,kBAAkB,YAAY,kBAChC,OAAO,KAAK,YAAY,eAAe,IACvC,CAAC;AAEL,Q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,IAAI,oBAAoB;AAEhC,QAAI,cAAc;AAElB,eAAW,aAAa,YAAY;AAClC,qBAAe,MAAM,SAAS;AAAA,IAChC;AAEA,QAAI,cAAc,GAAG;AACnB,cAAQ,IAAI,SAAS,MAAM,IAAI,WAAW,CAAC,oBAAoB;AAAA,IACjE,OAAO;AACL,cAAQ,IAAI,8BAA8B,MAAM,MAAM,QAAG,CAAC,EAAE;AAAA,IAC9D;AAAA,EACF;AACA,SAAO;AACT;","names":["path"]}
|
|
1
|
+
{"version":3,"sources":["../../src/actions/deplint.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/yarn/workspace/yarnWorkspace.ts"],"sourcesContent":["/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport chalk from 'chalk'\nimport { globSync } from 'glob'\nimport ts from 'typescript'\n\nimport { yarnWorkspace, yarnWorkspaces } from '../lib/index.ts'\n\nfunction getDependenciesFromPackageJson(packageJsonPath: string) {\n const packageJsonFullPath = path.resolve(packageJsonPath)\n const rawContent = fs.readFileSync(packageJsonFullPath, 'utf8')\n const packageJson = JSON.parse(rawContent)\n\n const dependencies = packageJson.dependencies\n ? Object.keys(packageJson.dependencies)\n : []\n\n const devDependencies = packageJson.devDependencies\n ? Object.keys(packageJson.devDependencies)\n : []\n\n const peerDependencies = packageJson.peerDependencies\n ? Object.keys(packageJson.peerDependencies)\n : []\n\n return {\n dependencies, devDependencies, peerDependencies,\n }\n}\n\nfunction getBasePackageName(importName: string) {\n if (importName.startsWith('@')) {\n const parts = importName.split('/')\n return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : importName\n }\n return importName.split('/')[0]\n}\n\nfunction getImportsFromFile(filePath: string, importPaths: Record<string, string[]>, typeImportPaths: Record<string, string[]>) {\n const sourceCode = fs.readFileSync(filePath, 'utf8')\n\n const sourceFile = ts.createSourceFile(\n path.basename(filePath),\n sourceCode,\n ts.ScriptTarget.Latest,\n true,\n )\n\n const imports: string[] = []\n const typeImports: string[] = []\n\n const isDeclarationFile = filePath.endsWith('.d.ts')\n\n function visit(node: ts.Node) {\n if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {\n const moduleSpecifier = (node.moduleSpecifier)?.getFullText()\n const isTypeImport = ts.isImportDeclaration(node) ? (node.importClause?.isTypeOnly ?? false) : false\n if (moduleSpecifier) {\n const trimmed = moduleSpecifier.split(\"'\").at(1) ?? moduleSpecifier\n // we are determining if the type import is being imported in an exported d.ts file\n if (isTypeImport && !isDeclarationFile) {\n typeImports.push(trimmed)\n } else {\n imports.push(trimmed)\n }\n }\n } else if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {\n const [arg] = node.arguments\n if (ts.isStringLiteral(arg)) {\n const trimmed = arg.text\n imports.push(trimmed)\n }\n }\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n\n const importsStartsWithExcludes = ['.', '#', 'node:']\n\n const cleanedImports = imports.filter(imp => !importsStartsWithExcludes.some(exc => imp.startsWith(exc))).map(getBasePackageName)\n const cleanedTypeImports = typeImports.filter(imp => !importsStartsWithExcludes.some(exc => imp.startsWith(exc))).map(getBasePackageName)\n\n for (const imp of cleanedImports) {\n importPaths[imp] = importPaths[imp] || []\n importPaths[imp].push(filePath)\n }\n\n for (const imp of cleanedTypeImports) {\n typeImportPaths[imp] = typeImportPaths[imp] || []\n typeImportPaths[imp].push(filePath)\n }\n\n return [cleanedImports, cleanedTypeImports]\n}\n\nfunction findFilesByGlob(cwd: string, pattern: string) {\n return globSync(pattern, { cwd, absolute: true })\n}\n\nfunction findFiles(path: string) {\n const allSourceInclude = ['./src/**/*.{ts,tsx}', './dist/**/*.d.ts']\n const prodExcludeEndswith = ['.spec.ts', '.stories.tsx']\n const prodExcludeIncludes = ['/spec/', '/stories/', '/scripts/']\n const allSourceFiles = allSourceInclude.flatMap(pattern => findFilesByGlob(path, pattern))\n\n const prodSourceFiles = allSourceFiles.filter(file => !prodExcludeEndswith.some(ext => file.endsWith(ext))\n && !prodExcludeIncludes.some(excl => file.includes(excl)))\n\n const devSourceFiles = allSourceFiles.filter(file => !prodSourceFiles.includes(file))\n return {\n allSourceFiles, prodSourceFiles, devSourceFiles,\n }\n}\n\nfunction getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles }: { devSourceFiles: string[]; prodSourceFiles: string[] }) {\n const prodImportPaths: Record<string, string[]> = {}\n const prodTypeImportPaths: Record<string, string[]> = {}\n const prodImportPairs = prodSourceFiles.map(path => getImportsFromFile(path, prodImportPaths, prodTypeImportPaths))\n const prodImports = prodImportPairs.flatMap(pair => pair[0])\n const prodTypeImports = prodImportPairs.flatMap(pair => pair[1])\n\n const devImportPaths: Record<string, string[]> = {}\n const devTypeImportPaths: Record<string, string[]> = {}\n const devImportPairs = devSourceFiles.map(path => getImportsFromFile(path, devImportPaths, devTypeImportPaths))\n const devImports = devImportPairs.flatMap(pair => pair[0])\n const devTypeImports = devImportPairs.flatMap(pair => pair[1])\n\n const externalProdImports = prodImports.filter(imp => !imp.startsWith('.') && !imp.startsWith('#') && !imp.startsWith('node:'))\n const externalProdTypeImports = prodTypeImports.filter(imp => !imp.startsWith('.') && !imp.startsWith('#') && !imp.startsWith('node:'))\n const externalDevImports = devImports.filter(imp => !imp.startsWith('.') && !imp.startsWith('#') && !imp.startsWith('node:'))\n return {\n prodImports,\n devImports,\n prodImportPaths,\n prodTypeImportPaths,\n devImportPaths,\n externalProdImports,\n externalDevImports,\n prodTypeImports,\n devTypeImports,\n externalProdTypeImports,\n }\n}\n\nfunction check({\n name, location, devDeps = false, peerDeps = false,\n}: { devDeps?: boolean; location: string; name: string; peerDeps?: boolean }) {\n const { prodSourceFiles, devSourceFiles } = findFiles(location)\n const {\n prodTypeImportPaths, prodImportPaths, externalProdTypeImports, devImportPaths, externalProdImports, externalDevImports,\n } = getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles })\n\n const {\n dependencies, devDependencies, peerDependencies,\n } = getDependenciesFromPackageJson(`${location}/package.json`)\n\n let unlistedDependencies = 0\n let unlistedDevDependencies = 0\n let unusedDependencies = 0\n let typesInDependencies = 0\n\n for (const imp of externalProdTypeImports) {\n if (!dependencies.includes(imp) && !peerDependencies.includes(imp) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`)) {\n unlistedDependencies++\n console.log(`[${chalk.blue(name)}] Missing dependency in package.json: ${chalk.red(imp)}`)\n console.log(` ${prodTypeImportPaths[imp].join('\\n')}`)\n console.log('')\n }\n }\n\n for (const imp of externalProdImports) {\n if (!dependencies.includes(imp) && !peerDependencies.includes(imp)) {\n unlistedDependencies++\n console.log(`[${chalk.blue(name)}] Missing dependency in package.json: ${chalk.red(imp)}`)\n console.log(` ${prodImportPaths[imp].join('\\n')}`)\n console.log('')\n }\n }\n\n for (const dep of dependencies) {\n if (dep.startsWith('@types/')) {\n typesInDependencies++\n console.log(`[${chalk.blue(name)}] @types in dependencies in package.json: ${chalk.red(dep)}`)\n console.log(` ${location}/package.json\\n`)\n console.log('')\n }\n if (!externalProdImports.includes(dep)) {\n unusedDependencies++\n console.log(`[${chalk.blue(name)}] Unused dependency in package.json: ${chalk.red(dep)}`)\n console.log(` ${location}/package.json\\n`)\n console.log('')\n }\n }\n\n if (peerDeps) {\n for (const dep of peerDependencies) {\n if (!externalProdImports.includes(dep)) {\n unusedDependencies++\n console.log(`[${chalk.blue(name)}] Unused peerDependency in package.json: ${chalk.red(dep)}`)\n console.log(` ${location}/package.json\\n`)\n console.log('')\n }\n }\n }\n\n if (devDeps) {\n for (const imp of externalDevImports) {\n if (!devDependencies.includes(imp)) {\n unlistedDevDependencies++\n console.log(`[${chalk.blue(name)}] Missing devDependency in package.json: ${chalk.red(imp)}`)\n console.log(` Found in: ${devImportPaths[imp].join(', ')}`)\n }\n }\n }\n\n const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + typesInDependencies\n\n return totalErrors\n}\n\nexport const deplint = ({ pkg }: { pkg: string }) => {\n if (pkg) {\n const { location, name } = yarnWorkspace(pkg)\n\n console.log(`Running Deplint for ${name}`)\n check({\n name, location, devDeps: true,\n })\n } else {\n const workspaces = yarnWorkspaces()\n\n console.log('Deplint Started...')\n\n let totalErrors = 0\n\n for (const workspace of workspaces) {\n totalErrors += check(workspace)\n }\n\n if (totalErrors > 0) {\n console.log(`Found ${chalk.red(totalErrors)} unlisted imports.`)\n } else {\n console.log(`No unlisted imports found. ${chalk.green('✔')}`)\n }\n }\n return 0\n}\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { Workspace } from './Workspace.ts'\nimport { yarnWorkspaces } from './yarnWorkspaces.ts'\n\nexport const yarnWorkspace = (pkg: string): Workspace => {\n const workspace = yarnWorkspaces().find(({ name }) => name === pkg)\n if (!workspace) throw new Error(`Workspace ${pkg} not found`)\n return workspace\n}\n"],"mappings":";AAEA,OAAO,QAAQ;AACf,OAAO,UAAU;AAEjB,OAAO,WAAW;AAClB,SAAS,gBAAgB;AACzB,OAAO,QAAQ;;;ACPf,SAAS,iBAAiB;AAInB,IAAM,iBAAiB,MAAmB;AAC/C,QAAM,SAAS,UAAU,QAAQ,CAAC,cAAc,QAAQ,UAAU,aAAa,GAAG,EAAE,UAAU,QAAQ,OAAO,KAAK,CAAC;AACnH,MAAI,OAAO,OAAO;AAChB,UAAM,OAAO;AAAA,EACf;AACA,SACE,OAAO,OACJ,SAAS,EAGT,MAAM,IAAI,EACV,MAAM,GAAG,EAAE,EACX,IAAI,CAAC,SAAS;AACb,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,CAAC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,SAAS,GAAG,GAAG;AAClC;AACA,gBAAQ,IAAI,IAAI,MAAM,KAAK,IAAI,CAAC,4CAA4C,MAAM,IAAI,GAAG,CAAC,EAAE;AAC5F,gBAAQ,IAAI,eAAe,eAAe,GAAG,EAAE,KAAK,IAAI,CAAC,EAAE;AAAA,MAC7D;AAAA,IACF;AAAA,EACF;AAEA,QAAM,cAAc,uBAAuB,0BAA0B,qBAAqB;AAE1F,SAAO;AACT;AAEO,IAAM,UAAU,CAAC,EAAE,IAAI,MAAuB;AACnD,MAAI,KAAK;AACP,UAAM,EAAE,UAAU,KAAK,IAAI,cAAc,GAAG;AAE5C,YAAQ,IAAI,uBAAuB,IAAI,EAAE;AACzC,UAAM;AAAA,MACJ;AAAA,MAAM;AAAA,MAAU,SAAS;AAAA,IAC3B,CAAC;AAAA,EACH,OAAO;AACL,UAAM,aAAa,eAAe;AAElC,YAAQ,IAAI,oBAAoB;AAEhC,QAAI,cAAc;AAElB,eAAW,aAAa,YAAY;AAClC,qBAAe,MAAM,SAAS;AAAA,IAChC;AAEA,QAAI,cAAc,GAAG;AACnB,cAAQ,IAAI,SAAS,MAAM,IAAI,WAAW,CAAC,oBAAoB;AAAA,IACjE,OAAO;AACL,cAAQ,IAAI,8BAA8B,MAAM,MAAM,QAAG,CAAC,EAAE;AAAA,IAC9D;AAAA,EACF;AACA,SAAO;AACT;","names":["path"]}
|
package/dist/actions/index.mjs
CHANGED
|
@@ -707,13 +707,14 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
|
707
707
|
);
|
|
708
708
|
const imports = [];
|
|
709
709
|
const typeImports = [];
|
|
710
|
+
const isDeclarationFile = filePath.endsWith(".d.ts");
|
|
710
711
|
function visit(node) {
|
|
711
712
|
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
712
713
|
const moduleSpecifier = node.moduleSpecifier?.getFullText();
|
|
713
714
|
const isTypeImport = ts.isImportDeclaration(node) ? node.importClause?.isTypeOnly ?? false : false;
|
|
714
715
|
if (moduleSpecifier) {
|
|
715
716
|
const trimmed = moduleSpecifier.split("'").at(1) ?? moduleSpecifier;
|
|
716
|
-
if (isTypeImport) {
|
|
717
|
+
if (isTypeImport && !isDeclarationFile) {
|
|
717
718
|
typeImports.push(trimmed);
|
|
718
719
|
} else {
|
|
719
720
|
imports.push(trimmed);
|