@netlify/build-info 5.0.0 → 5.1.1
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 +0 -3
- package/lib/bin.js +17 -21
- package/lib/context.d.ts +7 -4
- package/lib/context.js +9 -7
- package/lib/core.d.ts +2 -1
- package/lib/core.js +2 -2
- package/lib/main.d.ts +2 -1
- package/lib/main.js +1 -1
- package/lib/workspaces.d.ts +2 -5
- package/lib/workspaces.js +6 -6
- package/package.json +10 -10
- package/lib/frameworks.d.ts +0 -3
- package/lib/frameworks.js +0 -4
package/README.md
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
[](https://github.com/netlify/build-info/actions)
|
|
2
|
-
[](https://www.npmjs.com/package/@netlify/build-info)
|
|
3
|
-
|
|
4
1
|
# Build Info
|
|
5
2
|
|
|
6
3
|
Build information detection utility.
|
package/lib/bin.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { exit, argv } from 'process';
|
|
3
|
-
import yargs from 'yargs';
|
|
4
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
|
+
import yargs from 'yargs/yargs';
|
|
5
5
|
import { getBuildInfo } from './main.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 = {
|
|
6
|
+
const { projectDir, rootDir } = yargs(hideBin(argv))
|
|
7
|
+
.command('* [projectDir]')
|
|
8
|
+
.options({
|
|
22
9
|
rootDir: {
|
|
23
10
|
string: true,
|
|
24
11
|
describe: `The root directory of the project if different from projectDir`,
|
|
25
12
|
},
|
|
26
|
-
}
|
|
27
|
-
|
|
13
|
+
})
|
|
14
|
+
.usage(`$0 [OPTIONS...] [PROJECT_DIRECTORY]
|
|
28
15
|
|
|
29
|
-
Print relevant build information from a project
|
|
30
|
-
|
|
16
|
+
Print relevant build information from a project.`)
|
|
17
|
+
.strict()
|
|
18
|
+
.parse();
|
|
19
|
+
try {
|
|
20
|
+
const buildInfo = await getBuildInfo({ projectDir, rootDir });
|
|
21
|
+
console.log(JSON.stringify(buildInfo, null, 2));
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error(error);
|
|
25
|
+
exit(1);
|
|
26
|
+
}
|
package/lib/context.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { PackageJson } from 'read-pkg';
|
|
2
|
+
export declare type ContextOptions = {
|
|
2
3
|
projectDir?: string;
|
|
3
4
|
rootDir?: string;
|
|
4
|
-
}
|
|
5
|
+
};
|
|
6
|
+
export declare type Context = {
|
|
5
7
|
projectDir: string;
|
|
6
8
|
rootDir: string;
|
|
7
|
-
rootPackageJson:
|
|
8
|
-
}
|
|
9
|
+
rootPackageJson: PackageJson;
|
|
10
|
+
};
|
|
11
|
+
export declare const getContext: (config?: ContextOptions) => Promise<Context>;
|
package/lib/context.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { cwd } from 'process';
|
|
3
3
|
import { readPackage } from 'read-pkg';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Reads a package.json up the tree starting at the provided directory
|
|
6
|
+
* @param cwd The current working directory where it tries to find the package.json
|
|
7
|
+
* @returns A parsed object of the package.json
|
|
8
|
+
*/
|
|
9
|
+
const getPackageJson = async (cwd) => {
|
|
5
10
|
try {
|
|
6
|
-
|
|
7
|
-
if (packageJson === undefined) {
|
|
8
|
-
return {};
|
|
9
|
-
}
|
|
10
|
-
return packageJson;
|
|
11
|
+
return await readPackage({ cwd, normalize: false });
|
|
11
12
|
}
|
|
12
13
|
catch {
|
|
13
14
|
return {};
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
|
-
export const getContext = async
|
|
17
|
+
export const getContext = async (config = {}) => {
|
|
18
|
+
const { projectDir = cwd(), rootDir = '' } = config;
|
|
17
19
|
// Get the absolute dirs for both project and root
|
|
18
20
|
// We resolve the projectDir from the rootDir
|
|
19
21
|
const absoluteProjectDir = resolve(rootDir, projectDir);
|
package/lib/core.d.ts
CHANGED
package/lib/core.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { listFrameworks } from '@netlify/framework-info';
|
|
2
2
|
import { getWorkspaceInfo } from './workspaces.js';
|
|
3
3
|
export const buildInfo = async function (context) {
|
|
4
4
|
const workspaceInfo = await getWorkspaceInfo(context);
|
|
5
5
|
const jsWorkspaces = workspaceInfo ? { jsWorkspaces: workspaceInfo } : {};
|
|
6
|
-
const frameworks = await
|
|
6
|
+
const frameworks = await listFrameworks({ projectDir: context.projectDir });
|
|
7
7
|
return { ...jsWorkspaces, frameworks };
|
|
8
8
|
};
|
package/lib/main.d.ts
CHANGED
package/lib/main.js
CHANGED
package/lib/workspaces.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
projectDir: any;
|
|
4
|
-
rootDir: any;
|
|
5
|
-
}): Promise<{
|
|
1
|
+
import type { Context } from './context.js';
|
|
2
|
+
export declare const getWorkspaceInfo: (context: Context) => Promise<{
|
|
6
3
|
isRoot: boolean;
|
|
7
4
|
packages: any[];
|
|
8
5
|
}>;
|
package/lib/workspaces.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import mapWorkspaces from '@npmcli/map-workspaces';
|
|
2
|
-
export const getWorkspaceInfo = async
|
|
3
|
-
if (!rootPackageJson.workspaces) {
|
|
2
|
+
export const getWorkspaceInfo = async (context) => {
|
|
3
|
+
if (!context.rootPackageJson.workspaces) {
|
|
4
4
|
return;
|
|
5
5
|
}
|
|
6
6
|
const workspacesMap = await mapWorkspaces({
|
|
7
|
-
cwd: rootDir || projectDir,
|
|
8
|
-
pkg: rootPackageJson,
|
|
7
|
+
cwd: context.rootDir || context.projectDir,
|
|
8
|
+
pkg: context.rootPackageJson,
|
|
9
9
|
});
|
|
10
10
|
const packages = [...workspacesMap.values()];
|
|
11
11
|
// The provided project dir is a workspace package
|
|
12
|
-
const isWorkspace = packages.find((path) => projectDir === path);
|
|
12
|
+
const isWorkspace = packages.find((path) => context.projectDir === path);
|
|
13
13
|
// The project dir is a collection of workspaces itself
|
|
14
|
-
const isRoot = !rootDir;
|
|
14
|
+
const isRoot = !context.rootDir;
|
|
15
15
|
if (isWorkspace || isRoot) {
|
|
16
16
|
return { isRoot, packages };
|
|
17
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build-info",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "Build info utility",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/main.js",
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"prebuild": "rm -rf lib",
|
|
18
18
|
"build": "tsc",
|
|
19
|
-
"test": "
|
|
20
|
-
"test:
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:dev": "vitest",
|
|
21
|
+
"test:ci": "vitest run --reporter=default"
|
|
21
22
|
},
|
|
22
23
|
"keywords": [],
|
|
23
24
|
"license": "MIT",
|
|
@@ -29,19 +30,18 @@
|
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"@netlify/framework-info": "^9.3.0",
|
|
31
32
|
"@npmcli/map-workspaces": "^2.0.0",
|
|
32
|
-
"read-pkg": "^7.
|
|
33
|
-
"yargs": "^17.
|
|
33
|
+
"read-pkg": "^7.1.0",
|
|
34
|
+
"yargs": "^17.6.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@types/node": "^14.18.31",
|
|
37
|
-
"
|
|
38
|
-
"c8": "^7.11.0",
|
|
38
|
+
"@vitest/coverage-c8": "^0.24.1",
|
|
39
39
|
"execa": "^6.0.0",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
40
|
+
"typescript": "^4.8.4",
|
|
41
|
+
"vitest": "^0.24.1"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": "^14.16.0 || >=16.0.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "20503830a8814af5d5f8bfabaac38be846e131f4"
|
|
47
47
|
}
|
package/lib/frameworks.d.ts
DELETED
package/lib/frameworks.js
DELETED