Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

check-deps.js 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  1. #!/usr/bin/env node
  2. const dependencyCheck = require('dependency-check')
  3. const path = require('path')
  4. // [start-readme]
  5. //
  6. // This script checks which modules you have used in your code and then makes sure
  7. // they are listed as dependencies in your package.json, or vice-versa
  8. //
  9. // https://github.com/dependency-check-team/dependency-check
  10. //
  11. // The `ignore` array is for client-side or build-time stuff that doesn't get `require()d` in the normal way.
  12. //
  13. // [end-readme]
  14. const main = async () => {
  15. const data = await dependencyCheck({
  16. entries: [
  17. path.posix.join(__dirname, '..', '*.js'),
  18. path.posix.join(__dirname, '..', '*', '*.js'),
  19. path.posix.join('!', __dirname, '..', 'javascripts', '*.js'),
  20. path.posix.join(__dirname, '..', 'script', 'graphql', '*.js')
  21. ],
  22. path: path.join(__dirname, '..'),
  23. noDefaultEntries: true
  24. })
  25. const extra = dependencyCheck.extra(data.package, data.used, {
  26. excludeDev: true,
  27. ignore: [
  28. '@babel/*',
  29. 'babel-preset-env',
  30. '@primer/*',
  31. 'pa11y-ci',
  32. 'sass',
  33. 'babel-loader',
  34. 'cross-env',
  35. 'css-loader',
  36. 'resolve-url-loader',
  37. 'sass-loader',
  38. 'style-loader',
  39. 'webpack-cli',
  40. 'browser-date-formatter',
  41. 'search-with-your-keyboard',
  42. 'uuid',
  43. 'imurmurhash',
  44. 'js-cookie',
  45. 'mdast-util-from-markdown',
  46. 'unist-util-visit'
  47. ]
  48. })
  49. if (extra.length) {
  50. console.error(`Packages in package.json not used in your code: ${extra.join(', ')}`)
  51. }
  52. const missing = dependencyCheck.missing(data.package, data.used)
  53. if (missing.length) {
  54. console.error(`Dependencies not listed in package.json: ${missing.join(', ')}`)
  55. }
  56. if (extra.length || missing.length) process.exit(1)
  57. }
  58. main().catch(err => {
  59. console.error(err)
  60. process.exit(1)
  61. })
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...