@netlify/build-info 4.0.9 → 4.0.11
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/bin.js +5 -0
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +30 -0
- package/lib/context.d.ts +8 -0
- package/lib/context.js +34 -0
- package/lib/core.d.ts +10 -0
- package/lib/core.js +8 -0
- package/lib/frameworks.d.ts +3 -0
- package/lib/frameworks.js +4 -0
- package/lib/main.d.ts +10 -0
- package/lib/main.js +6 -0
- package/lib/workspaces.d.ts +8 -0
- package/lib/workspaces.js +18 -0
- package/package.json +16 -40
- package/src/bin.js +0 -37
- package/src/context.js +0 -39
- package/src/core.js +0 -11
- package/src/frameworks.js +0 -7
- package/src/main.js +0 -9
- package/src/workspaces.js +0 -25
package/bin.js
ADDED
package/lib/bin.d.ts
ADDED
package/lib/bin.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { exit, argv } from 'process';
|
|
3
|
+
import yargs from 'yargs';
|
|
4
|
+
import { hideBin } from 'yargs/helpers';
|
|
5
|
+
import { getBuildInfo } from './main.js';
|
|
6
|
+
// CLI entry point
|
|
7
|
+
const runCli = async function () {
|
|
8
|
+
const { projectDir, rootDir } = parseArgs();
|
|
9
|
+
try {
|
|
10
|
+
const buildInfo = await getBuildInfo({ projectDir, rootDir });
|
|
11
|
+
console.log(JSON.stringify(buildInfo, null, 2));
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.error(error);
|
|
15
|
+
exit(1);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const parseArgs = function () {
|
|
19
|
+
return yargs(hideBin(argv)).command('* [projectDir]').options(OPTIONS).usage(USAGE).strict().parse();
|
|
20
|
+
};
|
|
21
|
+
const OPTIONS = {
|
|
22
|
+
rootDir: {
|
|
23
|
+
string: true,
|
|
24
|
+
describe: `The root directory of the project if different from projectDir`,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const USAGE = `$0 [OPTIONS...] [PROJECT_DIRECTORY]
|
|
28
|
+
|
|
29
|
+
Print relevant build information from a project.`;
|
|
30
|
+
runCli();
|
package/lib/context.d.ts
ADDED
package/lib/context.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { cwd } from 'process';
|
|
3
|
+
import { readPackage } from 'read-pkg';
|
|
4
|
+
const getPackageJson = async function (dir) {
|
|
5
|
+
try {
|
|
6
|
+
const packageJson = await readPackage({ cwd: dir, normalize: false });
|
|
7
|
+
if (packageJson === undefined) {
|
|
8
|
+
return {};
|
|
9
|
+
}
|
|
10
|
+
return packageJson;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const getContext = async function ({ projectDir = cwd(), rootDir = '' } = {}) {
|
|
17
|
+
// Get the absolute dirs for both project and root
|
|
18
|
+
// We resolve the projectDir from the rootDir
|
|
19
|
+
const absoluteProjectDir = resolve(rootDir, projectDir);
|
|
20
|
+
// If a relative absolute path is given we rely on cwd
|
|
21
|
+
const absoluteRootDir = rootDir ? resolve(cwd(), rootDir) : undefined;
|
|
22
|
+
// We only pass through the root dir if it was provided and is actually different
|
|
23
|
+
// from the project dir
|
|
24
|
+
const validRootDir = absoluteRootDir && absoluteRootDir !== absoluteProjectDir ? absoluteRootDir : undefined;
|
|
25
|
+
// If rootDir equals projectDir we'll be getting the projectDir package.json
|
|
26
|
+
// Later on if we also need the projectDir package.json we can check for it
|
|
27
|
+
// and only perform one resolution
|
|
28
|
+
const rootPackageJson = await getPackageJson(rootDir || projectDir);
|
|
29
|
+
return {
|
|
30
|
+
projectDir: absoluteProjectDir,
|
|
31
|
+
rootDir: validRootDir,
|
|
32
|
+
rootPackageJson,
|
|
33
|
+
};
|
|
34
|
+
};
|
package/lib/core.d.ts
ADDED
package/lib/core.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getFrameworks } from './frameworks.js';
|
|
2
|
+
import { getWorkspaceInfo } from './workspaces.js';
|
|
3
|
+
export const buildInfo = async function (context) {
|
|
4
|
+
const workspaceInfo = await getWorkspaceInfo(context);
|
|
5
|
+
const jsWorkspaces = workspaceInfo ? { jsWorkspaces: workspaceInfo } : {};
|
|
6
|
+
const frameworks = await getFrameworks(context);
|
|
7
|
+
return { ...jsWorkspaces, frameworks };
|
|
8
|
+
};
|
package/lib/main.d.ts
ADDED
package/lib/main.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import mapWorkspaces from '@npmcli/map-workspaces';
|
|
2
|
+
export const getWorkspaceInfo = async function ({ rootPackageJson, projectDir, rootDir }) {
|
|
3
|
+
if (!rootPackageJson.workspaces) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const workspacesMap = await mapWorkspaces({
|
|
7
|
+
cwd: rootDir || projectDir,
|
|
8
|
+
pkg: rootPackageJson,
|
|
9
|
+
});
|
|
10
|
+
const packages = [...workspacesMap.values()];
|
|
11
|
+
// The provided project dir is a workspace package
|
|
12
|
+
const isWorkspace = packages.find((path) => projectDir === path);
|
|
13
|
+
// The project dir is a collection of workspaces itself
|
|
14
|
+
const isRoot = !rootDir;
|
|
15
|
+
if (isWorkspace || isRoot) {
|
|
16
|
+
return { isRoot, packages };
|
|
17
|
+
}
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,69 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build-info",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.11",
|
|
4
4
|
"description": "Build info utility",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"exports": "./
|
|
7
|
-
"main": "./
|
|
6
|
+
"exports": "./lib/main.js",
|
|
7
|
+
"main": "./lib/main.js",
|
|
8
|
+
"types": "./lib/main.d.ts",
|
|
8
9
|
"bin": {
|
|
9
|
-
"build-info": "./
|
|
10
|
+
"build-info": "./bin.js"
|
|
10
11
|
},
|
|
11
12
|
"files": [
|
|
12
|
-
"
|
|
13
|
-
"
|
|
13
|
+
"bin.js",
|
|
14
|
+
"lib/**/*"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"test": "
|
|
19
|
-
"
|
|
20
|
-
"format:ci": "run-s format:check:*",
|
|
21
|
-
"format:check-fix:lint": "run-e format:check:lint format:fix:lint",
|
|
22
|
-
"format:check:lint": "cross-env-shell eslint $npm_package_config_eslint",
|
|
23
|
-
"format:fix:lint": "cross-env-shell eslint --fix $npm_package_config_eslint",
|
|
24
|
-
"format:check-fix:prettier": "run-e format:check:prettier format:fix:prettier",
|
|
25
|
-
"format:check:prettier": "cross-env-shell prettier --check $npm_package_config_prettier",
|
|
26
|
-
"format:fix:prettier": "cross-env-shell prettier --write $npm_package_config_prettier",
|
|
27
|
-
"test:dev": "run-s test:dev:*",
|
|
28
|
-
"test:ci": "run-s test:ci:*",
|
|
29
|
-
"test:dev:ava": "ava",
|
|
30
|
-
"test:ci:ava": "c8 -r lcovonly -r text -r json ava"
|
|
31
|
-
},
|
|
32
|
-
"config": {
|
|
33
|
-
"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}\"",
|
|
34
|
-
"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\""
|
|
35
|
-
},
|
|
36
|
-
"ava": {
|
|
37
|
-
"verbose": true,
|
|
38
|
-
"files": [
|
|
39
|
-
"!test/fixtures/**/*"
|
|
40
|
-
]
|
|
17
|
+
"prebuild": "rm -rf lib",
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"test": "ava",
|
|
20
|
+
"test:ci": "c8 -r lcovonly -r text -r json ava"
|
|
41
21
|
},
|
|
42
22
|
"keywords": [],
|
|
43
23
|
"license": "MIT",
|
|
44
24
|
"repository": "netlify/build-info",
|
|
45
25
|
"bugs": {
|
|
46
|
-
"url": "https://github.com/netlify/build
|
|
26
|
+
"url": "https://github.com/netlify/build/issues"
|
|
47
27
|
},
|
|
48
28
|
"author": "Netlify Inc.",
|
|
49
|
-
"directories": {
|
|
50
|
-
"test": "test"
|
|
51
|
-
},
|
|
52
29
|
"dependencies": {
|
|
53
|
-
"@netlify/framework-info": "^9.
|
|
30
|
+
"@netlify/framework-info": "^9.3.0",
|
|
54
31
|
"@npmcli/map-workspaces": "^2.0.0",
|
|
55
32
|
"read-pkg": "^7.0.0",
|
|
56
33
|
"yargs": "^17.0.0"
|
|
57
34
|
},
|
|
58
35
|
"devDependencies": {
|
|
59
|
-
"@netlify/eslint-config-node": "^5.1.4",
|
|
60
36
|
"ava": "^4.0.0",
|
|
61
37
|
"c8": "^7.11.0",
|
|
62
38
|
"execa": "^6.0.0",
|
|
63
|
-
"get-bin-path": "^6.0.0"
|
|
64
|
-
"husky": "^7.0.4"
|
|
39
|
+
"get-bin-path": "^6.0.0"
|
|
65
40
|
},
|
|
66
41
|
"engines": {
|
|
67
42
|
"node": "^12.20.0 || ^14.14.0 || >=16.0.0"
|
|
68
|
-
}
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "4a38bc66bc9897e37beaab9e51a48516b0d02b40"
|
|
69
45
|
}
|
package/src/bin.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { exit, argv } from 'process'
|
|
3
|
-
|
|
4
|
-
import yargs from 'yargs'
|
|
5
|
-
import { hideBin } from 'yargs/helpers'
|
|
6
|
-
|
|
7
|
-
import { getBuildInfo } from './main.js'
|
|
8
|
-
|
|
9
|
-
// CLI entry point
|
|
10
|
-
const runCli = async function () {
|
|
11
|
-
const { projectDir, rootDir } = parseArgs()
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const buildInfo = await getBuildInfo({ projectDir, rootDir })
|
|
15
|
-
console.log(JSON.stringify(buildInfo, null, 2))
|
|
16
|
-
} catch (error) {
|
|
17
|
-
console.error(error)
|
|
18
|
-
exit(1)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const parseArgs = function () {
|
|
23
|
-
return yargs(hideBin(argv)).command('* [projectDir]').options(OPTIONS).usage(USAGE).strict().parse()
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const OPTIONS = {
|
|
27
|
-
rootDir: {
|
|
28
|
-
string: true,
|
|
29
|
-
describe: `The root directory of the project if different from projectDir`,
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const USAGE = `$0 [OPTIONS...] [PROJECT_DIRECTORY]
|
|
34
|
-
|
|
35
|
-
Print relevant build information from a project.`
|
|
36
|
-
|
|
37
|
-
runCli()
|
package/src/context.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path'
|
|
2
|
-
import { cwd } from 'process'
|
|
3
|
-
|
|
4
|
-
import { readPackage } from 'read-pkg'
|
|
5
|
-
|
|
6
|
-
const getPackageJson = async function (dir) {
|
|
7
|
-
try {
|
|
8
|
-
const packageJson = await readPackage({ cwd: dir, normalize: false })
|
|
9
|
-
if (packageJson === undefined) {
|
|
10
|
-
return {}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return packageJson
|
|
14
|
-
} catch {
|
|
15
|
-
return {}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const getContext = async function ({ projectDir = cwd(), rootDir = '' } = {}) {
|
|
20
|
-
// Get the absolute dirs for both project and root
|
|
21
|
-
// We resolve the projectDir from the rootDir
|
|
22
|
-
const absoluteProjectDir = resolve(rootDir, projectDir)
|
|
23
|
-
// If a relative absolute path is given we rely on cwd
|
|
24
|
-
const absoluteRootDir = rootDir ? resolve(cwd(), rootDir) : undefined
|
|
25
|
-
|
|
26
|
-
// We only pass through the root dir if it was provided and is actually different
|
|
27
|
-
// from the project dir
|
|
28
|
-
const validRootDir = absoluteRootDir && absoluteRootDir !== absoluteProjectDir ? absoluteRootDir : undefined
|
|
29
|
-
|
|
30
|
-
// If rootDir equals projectDir we'll be getting the projectDir package.json
|
|
31
|
-
// Later on if we also need the projectDir package.json we can check for it
|
|
32
|
-
// and only perform one resolution
|
|
33
|
-
const rootPackageJson = await getPackageJson(rootDir || projectDir)
|
|
34
|
-
return {
|
|
35
|
-
projectDir: absoluteProjectDir,
|
|
36
|
-
rootDir: validRootDir,
|
|
37
|
-
rootPackageJson,
|
|
38
|
-
}
|
|
39
|
-
}
|
package/src/core.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { getFrameworks } from './frameworks.js'
|
|
4
|
-
import { getWorkspaceInfo } from './workspaces.js'
|
|
5
|
-
|
|
6
|
-
export const buildInfo = async function (context) {
|
|
7
|
-
const workspaceInfo = await getWorkspaceInfo(context)
|
|
8
|
-
const jsWorkspaces = workspaceInfo ? { jsWorkspaces: workspaceInfo } : {}
|
|
9
|
-
const frameworks = await getFrameworks(context)
|
|
10
|
-
return { ...jsWorkspaces, frameworks }
|
|
11
|
-
}
|
package/src/frameworks.js
DELETED
package/src/main.js
DELETED
package/src/workspaces.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import mapWorkspaces from '@npmcli/map-workspaces'
|
|
4
|
-
|
|
5
|
-
export const getWorkspaceInfo = async function ({ rootPackageJson, projectDir, rootDir }) {
|
|
6
|
-
if (!rootPackageJson.workspaces) {
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const workspacesMap = await mapWorkspaces({
|
|
11
|
-
cwd: rootDir || projectDir,
|
|
12
|
-
pkg: rootPackageJson,
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
const packages = [...workspacesMap.values()]
|
|
16
|
-
// The provided project dir is a workspace package
|
|
17
|
-
const isWorkspace = packages.find((path) => projectDir === path)
|
|
18
|
-
|
|
19
|
-
// The project dir is a collection of workspaces itself
|
|
20
|
-
const isRoot = !rootDir
|
|
21
|
-
|
|
22
|
-
if (isWorkspace || isRoot) {
|
|
23
|
-
return { isRoot, packages }
|
|
24
|
-
}
|
|
25
|
-
}
|