@netlify/build-info 7.4.1 → 7.4.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 +36 -93
- package/lib/node/get-build-info.js +2 -15
- package/lib/node/get-build-info.js.map +1 -1
- package/package.json +8 -9
package/README.md
CHANGED
|
@@ -1,106 +1,49 @@
|
|
|
1
1
|
# Build Info
|
|
2
2
|
|
|
3
|
-
Build
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
// packages: [
|
|
24
|
-
// 'path/to/site',
|
|
25
|
-
// 'path/to/component/library'
|
|
26
|
-
// 'path/to/utility/library'
|
|
27
|
-
// ]
|
|
28
|
-
// },
|
|
29
|
-
// frameworks: [
|
|
30
|
-
// {
|
|
31
|
-
// name: 'gatsby',
|
|
32
|
-
// category: 'static_site_generator',
|
|
33
|
-
// dev: {
|
|
34
|
-
// commands: ['gatsby develop'],
|
|
35
|
-
// port: 8000
|
|
36
|
-
// },
|
|
37
|
-
// build: {
|
|
38
|
-
// commands: ['gatsby build'],
|
|
39
|
-
// directory: 'public'
|
|
40
|
-
// },
|
|
41
|
-
// env: { GATSBY_LOGGER: 'yurnalist' },
|
|
42
|
-
// plugins: []
|
|
43
|
-
// }
|
|
44
|
-
// ]
|
|
45
|
-
// }
|
|
46
|
-
|
|
47
|
-
console.log(await getBuildInfo({ projectDir: '/project/root/dir' }))
|
|
48
|
-
// {
|
|
49
|
-
// jsWorkspaces: {
|
|
50
|
-
// isRoot: true,
|
|
51
|
-
// packages: [
|
|
52
|
-
// 'path/to/site',
|
|
53
|
-
// 'path/to/component/library'
|
|
54
|
-
// 'path/to/utility/library'
|
|
55
|
-
// ]
|
|
56
|
-
// },
|
|
57
|
-
// frameworks: []
|
|
58
|
-
// }
|
|
3
|
+
Build info is the core part of detecting settings and heuristics about the users code. The library is platform agnostic
|
|
4
|
+
to be used in our React UI, Node.js CLI and build system.
|
|
5
|
+
|
|
6
|
+
It provides a layered approach to detecting the following information:
|
|
7
|
+
|
|
8
|
+
1. Package Manager
|
|
9
|
+
2. Workspaces (pnpm, yarn, npm)
|
|
10
|
+
3. Build Systems
|
|
11
|
+
4. Frameworks
|
|
12
|
+
5. Build Settings
|
|
13
|
+
|
|
14
|
+
How to use it: First of all, you need to create a `FileSystem` that works for your platform. For Node.js we ship already
|
|
15
|
+
one that can be used: For other platforms, a file system needs to implement the `FileSystem` interface:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { FileSystem } from '@netlify/build-info'
|
|
19
|
+
|
|
20
|
+
export class WebFS extends FileSystem {
|
|
21
|
+
// ...
|
|
22
|
+
}
|
|
59
23
|
```
|
|
60
24
|
|
|
25
|
+
After that the core piece is the Project that needs to be initialized with a file system, the base directory and an
|
|
26
|
+
optional repository root.
|
|
27
|
+
|
|
28
|
+
It is important to note that setting a node version is important for some frameworks to load the correct plugins.
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
const project = new Project(fs, baseDir, root).setEnvironment(process.env).setNodeVersion(process.version)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
after that on the project, we can call multiple methods like `getBuildSettings` which is running all the other steps as
|
|
35
|
+
well.
|
|
36
|
+
|
|
61
37
|
# Example (CLI)
|
|
62
38
|
|
|
63
39
|
```bash
|
|
40
|
+
# will use the current working directory as base directory
|
|
41
|
+
$ build-info
|
|
42
|
+
|
|
64
43
|
$ build-info /project/root/dir
|
|
65
|
-
{
|
|
66
|
-
jsWorkspaces: {
|
|
67
|
-
isRoot: true,
|
|
68
|
-
packages: [
|
|
69
|
-
'path/to/site',
|
|
70
|
-
'path/to/component/library'
|
|
71
|
-
'path/to/utility/library'
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
frameworks: []
|
|
75
|
-
}
|
|
76
44
|
|
|
77
45
|
$ build-info path/to/site --rootDir /project/root/dir
|
|
78
|
-
|
|
79
|
-
jsWorkspaces: {
|
|
80
|
-
isRoot: false,
|
|
81
|
-
packages: [
|
|
82
|
-
'path/to/site',
|
|
83
|
-
'path/to/component/library'
|
|
84
|
-
'path/to/utility/library'
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
frameworks: [
|
|
88
|
-
{
|
|
89
|
-
name: 'gatsby',
|
|
90
|
-
category: 'static_site_generator',
|
|
91
|
-
dev: {
|
|
92
|
-
commands: ['gatsby develop'],
|
|
93
|
-
port: 8000
|
|
94
|
-
},
|
|
95
|
-
build: {
|
|
96
|
-
commands: ['gatsby build'],
|
|
97
|
-
directory: 'public'
|
|
98
|
-
},
|
|
99
|
-
env: { GATSBY_LOGGER: 'yurnalist' },
|
|
100
|
-
plugins: []
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
}
|
|
46
|
+
|
|
104
47
|
```
|
|
105
48
|
|
|
106
49
|
## Contributors
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { listFrameworks } from '@netlify/framework-info';
|
|
2
|
-
import { report } from '../metrics.js';
|
|
3
1
|
import { Project } from '../project.js';
|
|
4
2
|
import { NodeFS } from './file-system.js';
|
|
5
3
|
/** A noop logger that is used to not log anything (we use the stdout for parsing the json output) */
|
|
@@ -30,19 +28,8 @@ export async function getBuildInfo(config = { featureFlags: {} }) {
|
|
|
30
28
|
.setEnvironment(process.env)
|
|
31
29
|
.setNodeVersion(process.version);
|
|
32
30
|
const info = {};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
try {
|
|
38
|
-
// if the framework detection is crashing we should not crash the build info and package-manager detection
|
|
39
|
-
info.frameworks = (await listFrameworks({ projectDir: project.baseDirectory }));
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
report(error, { client: config.bugsnagClient });
|
|
43
|
-
info.frameworks = [];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
31
|
+
// we are only interested in the frameworks of the base directory here (as they are for this site)
|
|
32
|
+
info.frameworks = (await project.detectFrameworksInPath(project.baseDirectory)) || [];
|
|
46
33
|
info.settings = await project.getBuildSettings();
|
|
47
34
|
info.langRuntimes = await project.detectRuntime();
|
|
48
35
|
// some framework detection like NX can update the workspace in the project so assign it later on
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-build-info.js","sourceRoot":"","sources":["../../src/node/get-build-info.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-build-info.js","sourceRoot":"","sources":["../../src/node/get-build-info.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAczC,qGAAqG;AACrG,MAAM,OAAO,UAAU;IACrB,KAAK;QACH,WAAW;IACb,CAAC;IACD,GAAG;QACD,WAAW;IACb,CAAC;IACD,KAAK;QACH,WAAW;IACb,CAAC;IACD,IAAI;QACF,WAAW;IACb,CAAC;IACD,IAAI;QACF,WAAW;IACb,CAAC;CACF;AAED,6DAA6D;AAC7D,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,SAKI,EAAE,YAAY,EAAE,EAAE,EAAE;IAExB,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,CAAA;IACvB,qEAAqE;IACrE,EAAE,CAAC,MAAM,GAAG,IAAI,UAAU,EAAE,CAAA;IAC5B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC;SAC/D,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC;SAChC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC;SAC3B,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAElC,MAAM,IAAI,GAAG,EAAU,CAAA;IAEvB,kGAAkG;IAClG,IAAI,CAAC,UAAU,GAAG,CAAC,MAAM,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAA;IACrF,IAAI,CAAC,QAAQ,GAAG,MAAM,OAAO,CAAC,gBAAgB,EAAE,CAAA;IAChD,IAAI,CAAC,YAAY,GAAG,MAAM,OAAO,CAAC,aAAa,EAAE,CAAA;IAEjD,iGAAiG;IACjG,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,SAAS,CAAA;IACrC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;IACxC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;IAE5C,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build-info",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.2",
|
|
4
4
|
"description": "Build info utility",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
+
"types": "./lib/index.d.ts",
|
|
8
9
|
"import": "./lib/index.js",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
10
|
+
"browser": "./lib/index.js",
|
|
11
|
+
"default": "./lib/index.js"
|
|
11
12
|
},
|
|
12
13
|
"./node": {
|
|
14
|
+
"types": "./lib/node/index.d.ts",
|
|
13
15
|
"import": "./lib/node/index.js",
|
|
14
|
-
"default": "./lib/node/index.js"
|
|
15
|
-
"types": "./lib/node/index.d.ts"
|
|
16
|
+
"default": "./lib/node/index.js"
|
|
16
17
|
}
|
|
17
18
|
},
|
|
18
|
-
"browser": "./lib/index.js",
|
|
19
19
|
"main": "./lib/index.js",
|
|
20
20
|
"types": "./lib/index.d.ts",
|
|
21
21
|
"bin": {
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"author": "Netlify Inc.",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@bugsnag/js": "^7.20.0",
|
|
49
|
-
"@netlify/framework-info": "^9.8.10",
|
|
50
49
|
"dot-prop": "^7.2.0",
|
|
51
50
|
"find-up": "^6.3.0",
|
|
52
51
|
"minimatch": "^9.0.0",
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
"devDependencies": {
|
|
60
59
|
"@bugsnag/source-maps": "^2.3.1",
|
|
61
60
|
"@playwright/test": "^1.30.0",
|
|
62
|
-
"@types/node": "^18.
|
|
61
|
+
"@types/node": "^14.18.53",
|
|
63
62
|
"@types/semver": "^7.3.13",
|
|
64
63
|
"@vitest/coverage-c8": "^0.30.1",
|
|
65
64
|
"@vitest/ui": "^0.30.1",
|
|
@@ -74,5 +73,5 @@
|
|
|
74
73
|
"engines": {
|
|
75
74
|
"node": "^14.16.0 || >=16.0.0"
|
|
76
75
|
},
|
|
77
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "487f1b282fed53beeb3ea17db151a741535ba8fc"
|
|
78
77
|
}
|