@netlify/build-info 3.0.0 → 4.0.2
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/README.md +42 -43
- package/package.json +10 -8
- package/src/bin.js +5 -4
- package/src/context.js +4 -6
- package/src/core.js +3 -5
- package/src/frameworks.js +2 -4
- package/src/main.js +3 -5
- package/src/workspaces.js +2 -4
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ Build information detection utility.
|
|
|
7
7
|
|
|
8
8
|
The purpose of this lib is to, given a project and a configuration, return a set of useful data for our build system.
|
|
9
9
|
Currently it's used to detect:
|
|
10
|
+
|
|
10
11
|
- [`jsWorkspaces`](https://docs.npmjs.com/cli/v7/using-npm/workspaces)
|
|
11
12
|
- [`frameworks`](https://github.com/netlify/framework-info)
|
|
12
13
|
|
|
@@ -14,51 +15,50 @@ But it's possible to extend it in the future to extract other bits of informatio
|
|
|
14
15
|
[`build-image`](https://github.com/netlify/build-image/blob/xenial/run-build-functions.sh#L214).
|
|
15
16
|
|
|
16
17
|
# Example (Node.js)
|
|
18
|
+
|
|
17
19
|
```js
|
|
18
|
-
|
|
20
|
+
import { getBuildInfo } from '@netlify/build-info'
|
|
19
21
|
|
|
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
|
-
// }
|
|
22
|
+
console.log(await getBuildInfo({ projectDir: 'path/to/site', rootDir: '/project/root/dir' }))
|
|
23
|
+
// {
|
|
24
|
+
// jsWorkspaces: {
|
|
25
|
+
// isRoot: false,
|
|
26
|
+
// packages: [
|
|
27
|
+
// 'path/to/site',
|
|
28
|
+
// 'path/to/component/library'
|
|
29
|
+
// 'path/to/utility/library'
|
|
30
|
+
// ]
|
|
31
|
+
// },
|
|
32
|
+
// frameworks: [
|
|
33
|
+
// {
|
|
34
|
+
// name: 'gatsby',
|
|
35
|
+
// category: 'static_site_generator',
|
|
36
|
+
// dev: {
|
|
37
|
+
// commands: ['gatsby develop'],
|
|
38
|
+
// port: 8000
|
|
39
|
+
// },
|
|
40
|
+
// build: {
|
|
41
|
+
// commands: ['gatsby build'],
|
|
42
|
+
// directory: 'public'
|
|
43
|
+
// },
|
|
44
|
+
// env: { GATSBY_LOGGER: 'yurnalist' },
|
|
45
|
+
// plugins: []
|
|
46
|
+
// }
|
|
47
|
+
// ]
|
|
48
|
+
// }
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})();
|
|
50
|
+
console.log(await getBuildInfo({ projectDir: '/project/root/dir' }))
|
|
51
|
+
// {
|
|
52
|
+
// jsWorkspaces: {
|
|
53
|
+
// isRoot: true,
|
|
54
|
+
// packages: [
|
|
55
|
+
// 'path/to/site',
|
|
56
|
+
// 'path/to/component/library'
|
|
57
|
+
// 'path/to/utility/library'
|
|
58
|
+
// ]
|
|
59
|
+
// },
|
|
60
|
+
// frameworks: []
|
|
61
|
+
// }
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
# Example (CLI)
|
|
@@ -106,7 +106,6 @@ $ build-info path/to/site --rootDir /project/root/dir
|
|
|
106
106
|
}
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
|
|
110
109
|
## Contributors
|
|
111
110
|
|
|
112
111
|
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for instructions on how to set up and work on this repository. Thanks
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build-info",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Build info utility",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": "./src/main.js",
|
|
5
7
|
"main": "./src/main.js",
|
|
6
8
|
"bin": {
|
|
7
9
|
"build-info": "./src/bin.js"
|
|
@@ -27,8 +29,8 @@
|
|
|
27
29
|
"test:ci:ava": "nyc -r lcovonly -r text -r json ava"
|
|
28
30
|
},
|
|
29
31
|
"config": {
|
|
30
|
-
"eslint": "--ignore-path .gitignore --cache --format=codeframe --max-warnings=0 \"{src,scripts,.github}/**/*.{js,md,html}\" \"*.{js,md,html}\" \".*.{js,md,html}\"",
|
|
31
|
-
"prettier": "--ignore-path .gitignore --loglevel=warn \"{src,scripts,.github}/**/*.{js,md,yml,json,html}\" \"*.{js,yml,json,html}\" \".*.{js,yml,json,html}\" \"!**/package-lock.json\" \"!package-lock.json\""
|
|
32
|
+
"eslint": "--ignore-path .gitignore --cache --format=codeframe --max-warnings=0 \"{src,scripts,.github}/**/*.{cjs,mjs,js,md,html}\" \"*.{cjs,mjs,js,md,html}\" \".*.{cjs,mjs,js,md,html}\"",
|
|
33
|
+
"prettier": "--ignore-path .gitignore --loglevel=warn \"{src,scripts,.github}/**/*.{cjs,mjs,js,md,yml,json,html}\" \"*.{cjs,mjs,js,yml,json,html}\" \".*.{cjs,mjs,js,yml,json,html}\" \"!**/package-lock.json\" \"!package-lock.json\""
|
|
32
34
|
},
|
|
33
35
|
"ava": {
|
|
34
36
|
"verbose": true,
|
|
@@ -53,9 +55,9 @@
|
|
|
53
55
|
"test": "test"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
|
-
"@commitlint/cli": "^
|
|
57
|
-
"@commitlint/config-conventional": "^
|
|
58
|
-
"@netlify/eslint-config-node": "^
|
|
58
|
+
"@commitlint/cli": "^15.0.0",
|
|
59
|
+
"@commitlint/config-conventional": "^15.0.0",
|
|
60
|
+
"@netlify/eslint-config-node": "^4.0.0",
|
|
59
61
|
"ava": "^3.0.0",
|
|
60
62
|
"execa": "^5.0.0",
|
|
61
63
|
"get-bin-path": "^5.0.0",
|
|
@@ -66,9 +68,9 @@
|
|
|
66
68
|
"node": "^12.20.0 || ^14.14.0 || >=16.0.0"
|
|
67
69
|
},
|
|
68
70
|
"dependencies": {
|
|
69
|
-
"@netlify/framework-info": "^
|
|
71
|
+
"@netlify/framework-info": "^7.0.0",
|
|
70
72
|
"@npmcli/map-workspaces": "^1.0.3",
|
|
71
73
|
"read-pkg": "^5.2.0",
|
|
72
|
-
"yargs": "^
|
|
74
|
+
"yargs": "^17.0.0"
|
|
73
75
|
}
|
|
74
76
|
}
|
package/src/bin.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import { exit, argv } from 'process'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import yargs from 'yargs'
|
|
5
|
+
import { hideBin } from 'yargs/helpers'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
import { getBuildInfo } from './main.js'
|
|
7
8
|
|
|
8
9
|
// CLI entry point
|
|
9
10
|
const runCli = async function () {
|
|
@@ -19,7 +20,7 @@ const runCli = async function () {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const parseArgs = function () {
|
|
22
|
-
return yargs.command('* [projectDir]').options(OPTIONS).usage(USAGE).strict().parse()
|
|
23
|
+
return yargs(hideBin(argv)).command('* [projectDir]').options(OPTIONS).usage(USAGE).strict().parse()
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
const OPTIONS = {
|
package/src/context.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { resolve } from 'path'
|
|
2
|
+
import { cwd } from 'process'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import readPkg from 'read-pkg'
|
|
5
5
|
|
|
6
6
|
const getPackageJson = async function (dir) {
|
|
7
7
|
try {
|
|
@@ -16,7 +16,7 @@ const getPackageJson = async function (dir) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const getContext = async function ({ projectDir = cwd(), rootDir = '' } = {}) {
|
|
19
|
+
export const getContext = async function ({ projectDir = cwd(), rootDir = '' } = {}) {
|
|
20
20
|
// Get the absolute dirs for both project and root
|
|
21
21
|
// We resolve the projectDir from the rootDir
|
|
22
22
|
const absoluteProjectDir = resolve(rootDir, projectDir)
|
|
@@ -37,5 +37,3 @@ const getContext = async function ({ projectDir = cwd(), rootDir = '' } = {}) {
|
|
|
37
37
|
rootPackageJson,
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
module.exports = { getContext }
|
package/src/core.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { getFrameworks } from './frameworks.js'
|
|
4
|
+
import { getWorkspaceInfo } from './workspaces.js'
|
|
5
5
|
|
|
6
|
-
const buildInfo = async function (context) {
|
|
6
|
+
export const buildInfo = async function (context) {
|
|
7
7
|
const workspaceInfo = await getWorkspaceInfo(context)
|
|
8
8
|
const jsWorkspaces = workspaceInfo ? { jsWorkspaces: workspaceInfo } : {}
|
|
9
9
|
const frameworks = await getFrameworks(context)
|
|
10
10
|
return { ...jsWorkspaces, frameworks }
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
module.exports = { buildInfo }
|
package/src/frameworks.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { listFrameworks } from '@netlify/framework-info'
|
|
4
4
|
|
|
5
|
-
const getFrameworks = async function ({ projectDir }) {
|
|
5
|
+
export const getFrameworks = async function ({ projectDir }) {
|
|
6
6
|
return await listFrameworks({ projectDir })
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
module.exports = { getFrameworks }
|
package/src/main.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { getContext } from './context.js'
|
|
4
|
+
import { buildInfo } from './core.js'
|
|
5
5
|
|
|
6
|
-
const getBuildInfo = async function (opts) {
|
|
6
|
+
export const getBuildInfo = async function (opts) {
|
|
7
7
|
const context = await getContext(opts)
|
|
8
8
|
return await buildInfo(context)
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
module.exports = { getBuildInfo }
|
package/src/workspaces.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import mapWorkspaces from '@npmcli/map-workspaces'
|
|
4
4
|
|
|
5
|
-
const getWorkspaceInfo = async function ({ rootPackageJson, projectDir, rootDir }) {
|
|
5
|
+
export const getWorkspaceInfo = async function ({ rootPackageJson, projectDir, rootDir }) {
|
|
6
6
|
if (!rootPackageJson.workspaces) {
|
|
7
7
|
return
|
|
8
8
|
}
|
|
@@ -23,5 +23,3 @@ const getWorkspaceInfo = async function ({ rootPackageJson, projectDir, rootDir
|
|
|
23
23
|
return { isRoot, packages }
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = { getWorkspaceInfo }
|