@netlify/build-info 5.1.1-rc.2 → 5.1.1-rc.4
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/lib/bin.d.ts +0 -1
- package/lib/bin.js +3 -17
- package/lib/detect-package-manager.d.ts +1 -2
- package/lib/detect-package-manager.js +4 -2
- package/lib/get-build-info.d.ts +9 -0
- package/lib/get-build-info.js +18 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/workspaces.d.ts +12 -3
- package/lib/workspaces.js +17 -5
- package/package.json +6 -4
- package/lib/core.d.ts +0 -2
- package/lib/core.js +0 -12
- package/lib/main.d.ts +0 -2
- package/lib/main.js +0 -6
package/lib/bin.d.ts
CHANGED
package/lib/bin.js
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { relative } from 'path';
|
|
3
1
|
import { exit, argv } from 'process';
|
|
4
2
|
import yargs from 'yargs';
|
|
5
3
|
import { hideBin } from 'yargs/helpers';
|
|
6
|
-
import {
|
|
7
|
-
import { getBuildInfo } from './main.js';
|
|
8
|
-
import { getWorkspaceInfo } from './workspaces.js';
|
|
4
|
+
import { getBuildInfo } from './get-build-info.js';
|
|
9
5
|
yargs(hideBin(argv))
|
|
10
|
-
.command('
|
|
11
|
-
// no build options
|
|
12
|
-
}, async ({ projectDir }) => {
|
|
13
|
-
const context = await getContext({ projectDir });
|
|
14
|
-
const workspaces = await getWorkspaceInfo(context);
|
|
15
|
-
if (!workspaces) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
console.log(workspaces.packages.map((p) => relative(context.projectDir, p)).join(' '));
|
|
19
|
-
})
|
|
20
|
-
.command('* [projectDir]', '', (builder) => builder.options({
|
|
6
|
+
.command('* [projectDir]', 'Print relevant build information from a project.', (builder) => builder.options({
|
|
21
7
|
rootDir: {
|
|
22
8
|
string: true,
|
|
23
9
|
describe: `The root directory of the project if different from projectDir`,
|
|
24
10
|
},
|
|
25
|
-
}), async ({
|
|
11
|
+
}), async ({ projectDir, rootDir }) => {
|
|
26
12
|
try {
|
|
27
13
|
const buildInfo = await getBuildInfo({ projectDir, rootDir });
|
|
28
14
|
console.log(JSON.stringify(buildInfo, null, 2));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare type PkgManagerFields = {
|
|
1
|
+
export declare type PkgManagerFields = {
|
|
2
2
|
/** The package managers name that is used for logging */
|
|
3
3
|
name: string;
|
|
4
4
|
/** The package managers install command */
|
|
@@ -20,4 +20,3 @@ declare type PkgManagerFields = {
|
|
|
20
20
|
* @returns The package manager that was detected
|
|
21
21
|
*/
|
|
22
22
|
export declare const detectPackageManager: (cwd?: string) => Promise<PkgManagerFields>;
|
|
23
|
-
export {};
|
|
@@ -46,8 +46,10 @@ export const detectPackageManager = async (cwd) => {
|
|
|
46
46
|
// return the found package manager
|
|
47
47
|
if (lockFilePath) {
|
|
48
48
|
const lockFile = basename(lockFilePath);
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
const pkgM = lockFileMap[lockFile];
|
|
50
|
+
// check if it not got disabled
|
|
51
|
+
if (!(pkgM.forceEnvironment && process.env[pkgM.forceEnvironment] === 'false')) {
|
|
52
|
+
return pkgM;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
const pkgPaths = await findUpMultiple('package.json', { cwd });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContextOptions } from './context.js';
|
|
2
|
+
import { PkgManagerFields } from './detect-package-manager.js';
|
|
3
|
+
import { WorkspaceInfo } from './workspaces.js';
|
|
4
|
+
export declare type Info = {
|
|
5
|
+
jsWorkspaces?: WorkspaceInfo;
|
|
6
|
+
packageManager?: PkgManagerFields;
|
|
7
|
+
frameworks: unknown[];
|
|
8
|
+
};
|
|
9
|
+
export declare const getBuildInfo: (opts: ContextOptions) => Promise<Info>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { listFrameworks } from '@netlify/framework-info';
|
|
2
|
+
import { getContext } from './context.js';
|
|
3
|
+
import { detectPackageManager } from './detect-package-manager.js';
|
|
4
|
+
import { getWorkspaceInfo } from './workspaces.js';
|
|
5
|
+
export const getBuildInfo = async (opts) => {
|
|
6
|
+
const context = await getContext(opts);
|
|
7
|
+
const info = {
|
|
8
|
+
frameworks: await listFrameworks({ projectDir: context.projectDir }),
|
|
9
|
+
};
|
|
10
|
+
const workspaceInfo = await getWorkspaceInfo(context);
|
|
11
|
+
if (workspaceInfo) {
|
|
12
|
+
info.jsWorkspaces = workspaceInfo;
|
|
13
|
+
}
|
|
14
|
+
if (Object.keys(context.rootPackageJson).length > 0) {
|
|
15
|
+
info.packageManager = await detectPackageManager(context.projectDir);
|
|
16
|
+
}
|
|
17
|
+
return info;
|
|
18
|
+
};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getBuildInfo } from './get-build-info.js';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getBuildInfo } from './get-build-info.js';
|
package/lib/workspaces.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { Context } from './context.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare type WorkspaceInfo = {
|
|
3
|
+
/** if we are in the current workspace root or not */
|
|
3
4
|
isRoot: boolean;
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/** the workspace root directory */
|
|
6
|
+
rootDir: string;
|
|
7
|
+
/** list of relative package paths inside the workspace */
|
|
8
|
+
packages: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* If it's a javascript workspace (npm, pnpm, yarn) it will retrieve a list of all
|
|
12
|
+
* relative package paths and will indicate if it's the root of the workspace
|
|
13
|
+
*/
|
|
14
|
+
export declare const getWorkspaceInfo: (context: Context) => Promise<undefined | WorkspaceInfo>;
|
package/lib/workspaces.js
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
|
+
import { join, relative } from 'path';
|
|
1
2
|
import mapWorkspaces from '@npmcli/map-workspaces';
|
|
3
|
+
/**
|
|
4
|
+
* If it's a javascript workspace (npm, pnpm, yarn) it will retrieve a list of all
|
|
5
|
+
* relative package paths and will indicate if it's the root of the workspace
|
|
6
|
+
*/
|
|
2
7
|
export const getWorkspaceInfo = async (context) => {
|
|
3
8
|
if (!context.rootPackageJson.workspaces) {
|
|
4
9
|
return;
|
|
5
10
|
}
|
|
11
|
+
const rootDir = context.rootDir || context.projectDir;
|
|
6
12
|
const workspacesMap = await mapWorkspaces({
|
|
7
|
-
cwd:
|
|
13
|
+
cwd: rootDir,
|
|
8
14
|
pkg: context.rootPackageJson,
|
|
9
15
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
// make paths relative
|
|
17
|
+
const packages = [...workspacesMap.values()].map((p) => relative(rootDir, p));
|
|
18
|
+
// The provided project dir is a workspace package and not a different directory
|
|
19
|
+
// in a mono repository that is not part inside the npm workspaces
|
|
20
|
+
const isWorkspace = packages.find((path) => context.projectDir === join(rootDir, path));
|
|
13
21
|
// The project dir is a collection of workspaces itself
|
|
14
22
|
const isRoot = !context.rootDir;
|
|
15
23
|
if (isWorkspace || isRoot) {
|
|
16
|
-
return {
|
|
24
|
+
return {
|
|
25
|
+
isRoot,
|
|
26
|
+
packages,
|
|
27
|
+
rootDir,
|
|
28
|
+
};
|
|
17
29
|
}
|
|
18
30
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build-info",
|
|
3
|
-
"version": "5.1.1-rc.
|
|
3
|
+
"version": "5.1.1-rc.4",
|
|
4
4
|
"description": "Build info utility",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"exports":
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./lib/index.js",
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
9
11
|
"bin": {
|
|
10
12
|
"build-info": "./bin.js"
|
|
11
13
|
},
|
package/lib/core.d.ts
DELETED
package/lib/core.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { listFrameworks } from '@netlify/framework-info';
|
|
2
|
-
import { detectPackageManager } from './detect-package-manager.js';
|
|
3
|
-
import { getWorkspaceInfo } from './workspaces.js';
|
|
4
|
-
export const buildInfo = async function (context) {
|
|
5
|
-
const workspaceInfo = await getWorkspaceInfo(context);
|
|
6
|
-
const jsWorkspaces = workspaceInfo ? { jsWorkspaces: workspaceInfo } : {};
|
|
7
|
-
const frameworks = await listFrameworks({ projectDir: context.projectDir });
|
|
8
|
-
if (Object.keys(context.rootPackageJson).length > 0) {
|
|
9
|
-
jsWorkspaces.packageManager = detectPackageManager(context.projectDir);
|
|
10
|
-
}
|
|
11
|
-
return { ...jsWorkspaces, frameworks };
|
|
12
|
-
};
|
package/lib/main.d.ts
DELETED