Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bundle-and-gitignore-deps.js « scripts - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 84a3ab3ad9ef04c5b6f50329d7a60a74eb61a060 (plain)
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
const Arborist = require('@npmcli/arborist')
const { resolve } = require('path')
const ignore = resolve(__dirname, '../node_modules/.gitignore')
const { writeFileSync } = require('fs')
const pj = resolve(__dirname, '../package.json')
const pkg = require(pj)
const bundle = []
const arb = new Arborist({ path: resolve(__dirname, '..') })
const shouldIgnore = []

arb.loadVirtual().then(tree => {
  for (const node of tree.children.values()) {
    if (node.dev || node.isLink) {
      console.error('ignore', node.name)
      shouldIgnore.push(node.name)
    } else if (tree.edgesOut.has(node.name)) {
      console.error('BUNDLE', node.name)
      bundle.push(node.name)
    }
  }
  pkg.bundleDependencies = bundle.sort((a, b) => a.localeCompare(b, 'en'))

  const ignores = shouldIgnore.sort((a, b) => a.localeCompare(b, 'en'))
    .map(i => `/${i}`)
    .join('\n')
  const ignoreData = `# Automatically generated to ignore dev deps
/.package-lock.json
package-lock.json
CHANGELOG*
README*
.editorconfig
.idea/
.npmignore
.eslintrc*
.travis*
.github
.jscsrc
.nycrc
.istanbul*
.eslintignore
.jshintrc*
.prettierrc*
.jscs.json
.dir-locals*
.coveralls*
.babelrc*
.nyc_output
.gitkeep

${ignores}
`
  writeFileSync(ignore, ignoreData)
  writeFileSync(pj, JSON.stringify(pkg, 0, 2) + '\n')
})