| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  | #!/usr/bin/env node
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Copyright 2019 Google Inc. All rights reserved. | 
					
						
							|  |  |  |  * Modifications copyright (c) Microsoft Corporation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *     http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  | // @ts-check
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-01 15:17:27 -08:00
										 |  |  | const fs = require('fs'); | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  | const ts = require('typescript'); | 
					
						
							| 
									
										
										
										
											2023-06-05 20:33:54 +01:00
										 |  |  | const path = require('path').posix; | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  | const Module = require('module'); | 
					
						
							|  |  |  | const builtins = new Set(Module.builtinModules); | 
					
						
							| 
									
										
										
										
											2023-06-06 14:50:44 -07:00
										 |  |  | const packagesDir = path.resolve(path.join(__dirname, '..', 'packages')); | 
					
						
							| 
									
										
										
										
											2022-10-18 19:39:58 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | const packages = new Map(); | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  | packages.set('web', packagesDir + '/web/src/'); | 
					
						
							| 
									
										
										
										
											2023-02-17 11:19:53 -08:00
										 |  |  | packages.set('injected', packagesDir + '/playwright-core/src/server/injected/'); | 
					
						
							| 
									
										
										
										
											2023-03-06 18:49:14 -08:00
										 |  |  | packages.set('isomorphic', packagesDir + '/playwright-core/src/utils/isomorphic/'); | 
					
						
							| 
									
										
										
										
											2023-09-08 14:23:35 -07:00
										 |  |  | packages.set('testIsomorphic', packagesDir + '/playwright/src/isomorphic/'); | 
					
						
							| 
									
										
										
										
											2022-10-18 19:39:58 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-25 13:12:00 -08:00
										 |  |  | const peerDependencies = ['electron', 'react', 'react-dom', '@zip.js/zip.js']; | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-06 13:40:19 -08:00
										 |  |  | const depsCache = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  | async function checkDeps() { | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  |   await innerCheckDeps(path.join(packagesDir, 'html-reporter')); | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  |   await innerCheckDeps(path.join(packagesDir, 'playwright-ct-core')); | 
					
						
							|  |  |  |   await innerCheckDeps(path.join(packagesDir, 'protocol')); | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  |   await innerCheckDeps(path.join(packagesDir, 'recorder')); | 
					
						
							|  |  |  |   await innerCheckDeps(path.join(packagesDir, 'trace-viewer')); | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  |   await innerCheckDeps(path.join(packagesDir, 'trace')); | 
					
						
							|  |  |  |   await innerCheckDeps(path.join(packagesDir, 'web')); | 
					
						
							| 
									
										
										
										
											2022-03-25 13:12:00 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  |   const corePackageJson = await innerCheckDeps(path.join(packagesDir, 'playwright-core')); | 
					
						
							| 
									
										
										
										
											2023-09-08 14:23:35 -07:00
										 |  |  |   const playwrightPackageJson = await innerCheckDeps(path.join(packagesDir, 'playwright')); | 
					
						
							| 
									
										
										
										
											2021-12-01 18:14:13 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   let hasVersionMismatch = false; | 
					
						
							| 
									
										
										
										
											2022-04-18 19:20:49 -08:00
										 |  |  |   for (const [key, value] of Object.entries(corePackageJson.dependencies || {})) { | 
					
						
							| 
									
										
										
										
											2023-09-08 14:23:35 -07:00
										 |  |  |     const value2 = playwrightPackageJson.dependencies[key]; | 
					
						
							| 
									
										
										
										
											2021-12-01 18:14:13 -08:00
										 |  |  |     if (value2 && value2 !== value) { | 
					
						
							|  |  |  |       hasVersionMismatch = true; | 
					
						
							|  |  |  |       console.log(`Dependency version mismatch ${key}: ${value} != ${value2}`); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   process.exit(hasVersionMismatch ? 1 : 0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  | async function innerCheckDeps(root) { | 
					
						
							|  |  |  |   console.log('Checking DEPS for ' + path.relative(packagesDir, root)); | 
					
						
							| 
									
										
										
										
											2021-12-01 18:14:13 -08:00
										 |  |  |   const deps = new Set(); | 
					
						
							|  |  |  |   const src = path.join(root, 'src'); | 
					
						
							| 
									
										
										
										
											2022-04-06 13:40:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  |   let packageJSON; | 
					
						
							|  |  |  |   try { | 
					
						
							| 
									
										
										
										
											2023-06-06 14:50:44 -07:00
										 |  |  |     packageJSON = require(path.resolve(path.join(root, 'package.json'))); | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  |   } catch { | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  |   const program = ts.createProgram({ | 
					
						
							|  |  |  |     options: { | 
					
						
							|  |  |  |       allowJs: true, | 
					
						
							|  |  |  |       target: ts.ScriptTarget.ESNext, | 
					
						
							|  |  |  |       strict: true, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-01-01 15:17:27 -08:00
										 |  |  |     rootNames: listAllFiles(src), | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  |   }); | 
					
						
							|  |  |  |   const sourceFiles = program.getSourceFiles(); | 
					
						
							|  |  |  |   const errors = []; | 
					
						
							| 
									
										
										
										
											2023-11-10 22:00:28 -08:00
										 |  |  |   sourceFiles.filter(x => !x.fileName.includes('node_modules')).map(x => visit(x, x.fileName, x.getFullText())); | 
					
						
							| 
									
										
										
										
											2022-04-06 13:40:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  |   if (errors.length) { | 
					
						
							| 
									
										
										
										
											2021-12-01 18:14:13 -08:00
										 |  |  |     for (const error of errors) | 
					
						
							|  |  |  |       console.log(error); | 
					
						
							| 
									
										
										
										
											2020-08-24 14:48:03 -07:00
										 |  |  |     console.log(`--------------------------------------------------------`); | 
					
						
							|  |  |  |     console.log(`Changing the project structure or adding new components?`); | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |     console.log(`Update DEPS in ${root}`); | 
					
						
							| 
									
										
										
										
											2020-08-24 14:48:03 -07:00
										 |  |  |     console.log(`--------------------------------------------------------`); | 
					
						
							| 
									
										
										
										
											2021-12-01 18:14:13 -08:00
										 |  |  |     process.exit(1); | 
					
						
							| 
									
										
										
										
											2020-08-24 14:48:03 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-12-01 18:14:13 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  |   if (packageJSON) { | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |     for (const dep of peerDependencies) | 
					
						
							| 
									
										
										
										
											2021-12-01 18:14:13 -08:00
										 |  |  |       deps.delete(dep); | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |     for (const dep of deps) { | 
					
						
							|  |  |  |       const resolved = require.resolve(dep, { paths: [root] }); | 
					
						
							|  |  |  |       if (dep === resolved || !resolved.includes('node_modules')) | 
					
						
							|  |  |  |         deps.delete(dep); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     for (const dep of Object.keys(packageJSON.dependencies || {})) | 
					
						
							|  |  |  |       deps.delete(dep); | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |     if (deps.size) { | 
					
						
							|  |  |  |       console.log('Dependencies are not declared in package.json:'); | 
					
						
							|  |  |  |       for (const dep of deps) | 
					
						
							|  |  |  |         console.log(`  ${dep}`); | 
					
						
							|  |  |  |       process.exit(1); | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-12-01 18:14:13 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return packageJSON; | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-10 22:00:28 -08:00
										 |  |  |   function visit(node, fileName, text) { | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  |     if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) { | 
					
						
							| 
									
										
										
										
											2023-05-31 14:08:59 -07:00
										 |  |  |       if (node.importClause) { | 
					
						
							|  |  |  |         if (node.importClause.isTypeOnly) | 
					
						
							|  |  |  |           return; | 
					
						
							|  |  |  |         if (node.importClause.namedBindings && ts.isNamedImports(node.importClause.namedBindings)) { | 
					
						
							|  |  |  |           if (node.importClause.namedBindings.elements.every(e => e.isTypeOnly)) | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  |       const importName = node.moduleSpecifier.text; | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |       let importPath; | 
					
						
							|  |  |  |       if (importName.startsWith('.')) { | 
					
						
							|  |  |  |         importPath = path.resolve(path.dirname(fileName), importName); | 
					
						
							|  |  |  |       } else if (importName.startsWith('@')) { | 
					
						
							|  |  |  |         const tokens = importName.substring(1).split('/'); | 
					
						
							|  |  |  |         const package = tokens[0]; | 
					
						
							| 
									
										
										
										
											2022-10-18 19:39:58 -04:00
										 |  |  |         if (packages.has(package)) | 
					
						
							|  |  |  |           importPath = packages.get(package) + tokens.slice(1).join('/'); | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  |       const mergedDeps = calculateDeps(fileName); | 
					
						
							|  |  |  |       if (mergedDeps.includes('***')) | 
					
						
							| 
									
										
										
										
											2023-09-08 14:23:35 -07:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |       if (importPath) { | 
					
						
							|  |  |  |         if (!fs.existsSync(importPath)) { | 
					
						
							|  |  |  |           if (fs.existsSync(importPath + '.ts')) | 
					
						
							|  |  |  |             importPath = importPath + '.ts'; | 
					
						
							|  |  |  |           else if (fs.existsSync(importPath + '.tsx')) | 
					
						
							|  |  |  |             importPath = importPath + '.tsx'; | 
					
						
							| 
									
										
										
										
											2022-03-25 13:12:00 -08:00
										 |  |  |           else if (fs.existsSync(importPath + '.d.ts')) | 
					
						
							|  |  |  |             importPath = importPath + '.d.ts'; | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  |         if (!allowImport(fileName, importPath, mergedDeps)) | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |           errors.push(`Disallowed import ${path.relative(root, importPath)} in ${path.relative(root, fileName)}`); | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2021-12-01 18:14:13 -08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-10 22:00:28 -08:00
										 |  |  |       const fullStart = node.getFullStart(); | 
					
						
							|  |  |  |       const commentRanges = ts.getLeadingCommentRanges(text, fullStart); | 
					
						
							|  |  |  |       for (const range of commentRanges || []) { | 
					
						
							|  |  |  |           const comment = text.substring(range.pos, range.end); | 
					
						
							|  |  |  |           if (comment.includes('@no-check-deps')) | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |       if (importName.startsWith('@')) | 
					
						
							|  |  |  |         deps.add(importName.split('/').slice(0, 2).join('/')); | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         deps.add(importName.split('/')[0]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  |       if (!allowExternalImport(importName, packageJSON)) | 
					
						
							| 
									
										
										
										
											2021-09-02 19:56:30 +02:00
										 |  |  |         errors.push(`Disallowed external dependency ${importName} from ${path.relative(root, fileName)}`); | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-11-10 22:00:28 -08:00
										 |  |  |     ts.forEachChild(node, x => visit(x, fileName, text)); | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  |   function calculateDeps(from) { | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |     const fromDirectory = path.dirname(from); | 
					
						
							| 
									
										
										
										
											2022-04-06 13:40:19 -08:00
										 |  |  |     let depsDirectory = fromDirectory; | 
					
						
							|  |  |  |     while (depsDirectory.startsWith(packagesDir) && !depsCache[depsDirectory] && !fs.existsSync(path.join(depsDirectory, 'DEPS.list'))) | 
					
						
							|  |  |  |       depsDirectory = path.dirname(depsDirectory); | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  |     if (!depsDirectory.startsWith(packagesDir)) | 
					
						
							|  |  |  |       return []; | 
					
						
							| 
									
										
										
										
											2022-04-06 13:40:19 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     let deps = depsCache[depsDirectory]; | 
					
						
							|  |  |  |     if (!deps) { | 
					
						
							|  |  |  |       const depsListFile = path.join(depsDirectory, 'DEPS.list'); | 
					
						
							|  |  |  |       deps = {}; | 
					
						
							| 
									
										
										
										
											2023-03-06 20:39:52 -08:00
										 |  |  |       let group = []; | 
					
						
							| 
									
										
										
										
											2022-04-06 13:40:19 -08:00
										 |  |  |       for (const line of fs.readFileSync(depsListFile, 'utf-8').split('\n').filter(Boolean).filter(l => !l.startsWith('#'))) { | 
					
						
							|  |  |  |         const groupMatch = line.match(/\[(.*)\]/); | 
					
						
							|  |  |  |         if (groupMatch) { | 
					
						
							|  |  |  |           group = []; | 
					
						
							|  |  |  |           deps[groupMatch[1]] = group; | 
					
						
							|  |  |  |           continue; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-03-06 20:39:52 -08:00
										 |  |  |         if (line === '***') | 
					
						
							|  |  |  |           group.push('***'); | 
					
						
							|  |  |  |         else if (line.startsWith('@')) | 
					
						
							| 
									
										
										
										
											2022-10-18 19:39:58 -04:00
										 |  |  |           group.push(line.replace(/@([\w-]+)\/(.*)/, (_, arg1, arg2) => packages.get(arg1) + arg2)); | 
					
						
							| 
									
										
										
										
											2022-04-06 13:40:19 -08:00
										 |  |  |         else | 
					
						
							|  |  |  |           group.push(path.resolve(depsDirectory, line)); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       depsCache[depsDirectory] = deps; | 
					
						
							| 
									
										
										
										
											2020-08-23 21:24:16 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  |     return [...(deps['*'] || []), ...(deps[path.relative(depsDirectory, from)] || [])] | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   function allowImport(from, to, mergedDeps) { | 
					
						
							|  |  |  |     const fromDirectory = path.dirname(from); | 
					
						
							|  |  |  |     const toDirectory = isDirectory(to) ? to : path.dirname(to); | 
					
						
							|  |  |  |     if (to === toDirectory) | 
					
						
							|  |  |  |       to = path.join(to, 'index.ts'); | 
					
						
							|  |  |  |     if (fromDirectory === toDirectory) | 
					
						
							|  |  |  |       return true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-06 13:40:19 -08:00
										 |  |  |     for (const dep of mergedDeps) { | 
					
						
							| 
									
										
										
										
											2023-03-06 20:39:52 -08:00
										 |  |  |       if (dep === '***') | 
					
						
							|  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2020-08-23 21:24:16 -07:00
										 |  |  |       if (to === dep || toDirectory === dep) | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |       if (dep.endsWith('**')) { | 
					
						
							|  |  |  |         const parent = dep.substring(0, dep.length - 2); | 
					
						
							|  |  |  |         if (to.startsWith(parent)) | 
					
						
							| 
									
										
										
										
											2020-08-22 07:07:13 -07:00
										 |  |  |           return true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-08-23 21:24:16 -07:00
										 |  |  |     return false; | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-09-02 19:56:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |   function allowExternalImport(importName, packageJSON) { | 
					
						
							| 
									
										
										
										
											2021-09-02 19:56:30 +02:00
										 |  |  |     // Only external imports are relevant. Files in src/web are bundled via webpack.
 | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  |     if (importName.startsWith('.') || (importName.startsWith('@') && !importName.startsWith('@playwright/'))) | 
					
						
							| 
									
										
										
										
											2021-09-02 19:56:30 +02:00
										 |  |  |       return true; | 
					
						
							| 
									
										
										
										
											2022-03-25 07:43:29 -08:00
										 |  |  |     if (peerDependencies.includes(importName)) | 
					
						
							| 
									
										
										
										
											2021-09-02 19:56:30 +02:00
										 |  |  |       return true; | 
					
						
							| 
									
										
										
										
											2023-03-03 14:50:43 -08:00
										 |  |  |     if (!packageJSON) | 
					
						
							|  |  |  |       return false; | 
					
						
							| 
									
										
										
										
											2022-04-06 13:40:19 -08:00
										 |  |  |     const match = importName.match(/(@[\w-]+\/)?([^/]+)/); | 
					
						
							| 
									
										
										
										
											2023-07-06 12:01:45 -07:00
										 |  |  |     const dependency = match[1] ? match[1] + match[2] : match[2]; | 
					
						
							|  |  |  |     if (builtins.has(dependency)) | 
					
						
							|  |  |  |       return true; | 
					
						
							| 
									
										
										
										
											2022-04-06 13:40:19 -08:00
										 |  |  |     return !!(packageJSON.dependencies || {})[dependency]; | 
					
						
							| 
									
										
										
										
											2021-09-02 19:56:30 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-07-27 13:02:28 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-01 15:17:27 -08:00
										 |  |  | function listAllFiles(dir) { | 
					
						
							|  |  |  |   const dirs = fs.readdirSync(dir, { withFileTypes: true }); | 
					
						
							| 
									
										
										
										
											2021-09-02 19:56:30 +02:00
										 |  |  |   const result = []; | 
					
						
							| 
									
										
										
										
											2021-01-01 15:17:27 -08:00
										 |  |  |   dirs.map(d => { | 
					
						
							|  |  |  |     const res = path.resolve(dir, d.name); | 
					
						
							|  |  |  |     if (d.isDirectory()) | 
					
						
							|  |  |  |       result.push(...listAllFiles(res)); | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       result.push(res); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   return result; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-30 14:57:17 -08:00
										 |  |  | checkDeps().catch(e => { | 
					
						
							|  |  |  |   console.error(e && e.stack ? e.stack : e); | 
					
						
							|  |  |  |   process.exit(1); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2022-04-07 20:48:41 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | function isDirectory(dir) { | 
					
						
							|  |  |  |   return fs.existsSync(dir) && fs.statSync(dir).isDirectory(); | 
					
						
							| 
									
										
										
										
											2023-06-05 20:33:54 +01:00
										 |  |  | } |