@netlify/build 29.42.5 → 29.43.0

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.
@@ -38,4 +38,4 @@ export declare const reduceLogLines: (lines: any) => any;
38
38
  * the user-facing build logs)
39
39
  */
40
40
  export declare const getSystemLogger: (logs: BufferedLogs | undefined, debug: boolean, systemLogFile?: number) => (...args: any[]) => void;
41
- export declare const addOutputGate: (logs: Logs, outputFlusher: OutputFlusher) => Logs;
41
+ export declare const addOutputFlusher: (logs: Logs, outputFlusher: OutputFlusher) => Logs;
package/lib/log/logger.js CHANGED
@@ -144,7 +144,7 @@ systemLogFile) {
144
144
  });
145
145
  return (...args) => fileDescriptor.write(`${reduceLogLines(args)}\n`);
146
146
  };
147
- export const addOutputGate = (logs, outputFlusher) => {
147
+ export const addOutputFlusher = (logs, outputFlusher) => {
148
148
  if (logsAreBuffered(logs)) {
149
149
  return {
150
150
  ...logs,
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  import { Transform } from 'stream';
3
+ import type { StandardStreams } from './stream.js';
3
4
  declare const flusherSymbol: unique symbol;
4
5
  /**
5
6
  * Utility class for conditionally rendering certain output only if additional
@@ -21,4 +22,5 @@ export declare class OutputFlusherTransform extends Transform {
21
22
  constructor(flusher: OutputFlusher);
22
23
  _transform(chunk: any, _: string, callback: () => void): void;
23
24
  }
25
+ export declare const getStandardStreams: (outputFlusher?: OutputFlusher) => StandardStreams;
24
26
  export {};
@@ -1,3 +1,4 @@
1
+ import { stdout, stderr } from 'process';
1
2
  import { Transform } from 'stream';
2
3
  const flusherSymbol = Symbol.for('@netlify/output-gate');
3
4
  /**
@@ -35,3 +36,16 @@ export class OutputFlusherTransform extends Transform {
35
36
  callback();
36
37
  }
37
38
  }
39
+ export const getStandardStreams = (outputFlusher) => {
40
+ if (!outputFlusher) {
41
+ return {
42
+ stdout,
43
+ stderr,
44
+ };
45
+ }
46
+ return {
47
+ outputFlusher,
48
+ stdout: new OutputFlusherTransform(outputFlusher).pipe(stdout),
49
+ stderr: new OutputFlusherTransform(outputFlusher).pipe(stderr),
50
+ };
51
+ };
@@ -1,10 +1,23 @@
1
- export function getBuildCommandStdio(logs: any): "pipe" | "inherit";
2
- export function handleBuildCommandOutput({ stdout: commandStdout, stderr: commandStderr }: {
3
- stdout: any;
4
- stderr: any;
5
- }, logs: any): void;
6
- export function pipePluginOutput(childProcess: any, logs: any, outputFlusher: any): void | {
7
- stdoutListener: any;
8
- stderrListener: any;
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import type { ChildProcess } from '../plugins/spawn.js';
4
+ import { Logs } from './logger.js';
5
+ import type { OutputFlusher } from './output_flusher.js';
6
+ export type StandardStreams = {
7
+ stderr: NodeJS.WriteStream;
8
+ stdout: NodeJS.WriteStream;
9
+ outputFlusher?: OutputFlusher;
9
10
  };
10
- export function unpipePluginOutput(childProcess: any, logs: any, listeners: any): Promise<void>;
11
+ type LogsListener = (logs: string[], outputFlusher: OutputFlusher | undefined, chunk: Buffer) => void;
12
+ type LogsListeners = {
13
+ stderrListener: LogsListener;
14
+ stdoutListener: LogsListener;
15
+ };
16
+ export declare const getBuildCommandStdio: (logs: Logs) => "pipe" | "inherit";
17
+ export declare const handleBuildCommandOutput: ({ stdout: commandStdout, stderr: commandStderr }: {
18
+ stdout: string;
19
+ stderr: string;
20
+ }, logs: Logs) => void;
21
+ export declare const pipePluginOutput: (childProcess: ChildProcess, logs: Logs, standardStreams: StandardStreams) => void | LogsListeners;
22
+ export declare const unpipePluginOutput: (childProcess: ChildProcess, logs: Logs, listeners: LogsListeners, standardStreams: StandardStreams) => Promise<void>;
23
+ export {};
package/lib/log/stream.js CHANGED
@@ -1,7 +1,5 @@
1
- import { stdout, stderr } from 'process';
2
1
  import { promisify } from 'util';
3
2
  import { logsAreBuffered } from './logger.js';
4
- import { OutputFlusherTransform } from './output_flusher.js';
5
3
  // TODO: replace with `timers/promises` after dropping Node < 15.0.0
6
4
  const pSetTimeout = promisify(setTimeout);
7
5
  // We try to use `stdio: inherit` because it keeps `stdout/stderr` as `TTY`,
@@ -29,41 +27,36 @@ const pushBuildCommandOutput = function (output, logsArray) {
29
27
  logsArray.push(output);
30
28
  };
31
29
  // Start plugin step output
32
- export const pipePluginOutput = function (childProcess, logs, outputFlusher) {
30
+ export const pipePluginOutput = function (childProcess, logs, standardStreams) {
33
31
  if (!logsAreBuffered(logs)) {
34
- return streamOutput(childProcess, outputFlusher);
32
+ return streamOutput(childProcess, standardStreams);
35
33
  }
36
- return pushOutputToLogs(childProcess, logs, outputFlusher);
34
+ return pushOutputToLogs(childProcess, logs, standardStreams.outputFlusher);
37
35
  };
38
36
  // Stop streaming/buffering plugin step output
39
- export const unpipePluginOutput = async function (childProcess, logs, listeners) {
37
+ export const unpipePluginOutput = async function (childProcess, logs, listeners, standardStreams) {
40
38
  // Let `childProcess` `stdout` and `stderr` flush before stopping redirecting
41
39
  await pSetTimeout(0);
42
40
  if (!logsAreBuffered(logs)) {
43
- return unstreamOutput(childProcess);
41
+ return unstreamOutput(childProcess, standardStreams);
44
42
  }
45
- unpushOutputToLogs(childProcess, logs, listeners);
43
+ unpushOutputToLogs(childProcess, listeners.stdoutListener, listeners.stderrListener);
46
44
  };
47
45
  // Usually, we stream stdout/stderr because it is more efficient
48
- const streamOutput = function (childProcess, outputFlusher) {
49
- if (outputFlusher) {
50
- childProcess.stdout.pipe(new OutputFlusherTransform(outputFlusher)).pipe(stdout);
51
- childProcess.stderr.pipe(new OutputFlusherTransform(outputFlusher)).pipe(stderr);
52
- return;
53
- }
54
- childProcess.stdout.pipe(stdout);
55
- childProcess.stderr.pipe(stderr);
46
+ const streamOutput = function (childProcess, standardStreams) {
47
+ childProcess.stdout?.pipe(standardStreams.stdout);
48
+ childProcess.stderr?.pipe(standardStreams.stderr);
56
49
  };
57
- const unstreamOutput = function (childProcess) {
58
- childProcess.stdout.unpipe(stdout);
59
- childProcess.stderr.unpipe(stderr);
50
+ const unstreamOutput = function (childProcess, standardStreams) {
51
+ childProcess.stdout?.unpipe(standardStreams.stdout);
52
+ childProcess.stderr?.unpipe(standardStreams.stderr);
60
53
  };
61
54
  // In tests, we push to the `logs` array instead
62
55
  const pushOutputToLogs = function (childProcess, logs, outputFlusher) {
63
56
  const stdoutListener = logsListener.bind(null, logs.stdout, outputFlusher);
64
57
  const stderrListener = logsListener.bind(null, logs.stderr, outputFlusher);
65
- childProcess.stdout.on('data', stdoutListener);
66
- childProcess.stderr.on('data', stderrListener);
58
+ childProcess.stdout?.on('data', stdoutListener);
59
+ childProcess.stderr?.on('data', stderrListener);
67
60
  return { stdoutListener, stderrListener };
68
61
  };
69
62
  const logsListener = function (logs, outputFlusher, chunk) {
@@ -72,7 +65,7 @@ const logsListener = function (logs, outputFlusher, chunk) {
72
65
  }
73
66
  logs.push(chunk.toString().trimEnd());
74
67
  };
75
- const unpushOutputToLogs = function (childProcess, logs, { stdoutListener, stderrListener }) {
76
- childProcess.stdout.removeListener('data', stdoutListener);
77
- childProcess.stderr.removeListener('data', stderrListener);
68
+ const unpushOutputToLogs = function (childProcess, stdoutListener, stderrListener) {
69
+ childProcess.stdout?.removeListener('data', stdoutListener);
70
+ childProcess.stderr?.removeListener('data', stderrListener);
78
71
  };
@@ -1,4 +1,4 @@
1
- import { PackageJson } from 'read-pkg-up';
1
+ import { PackageJson } from 'read-package-up';
2
2
  import { FeatureFlags } from '../core/feature_flags.js';
3
3
  import { SystemLogger } from '../plugins_core/types.js';
4
4
  import { PluginVersion } from './list.js';
@@ -1,4 +1,4 @@
1
- import { PackageJson } from 'read-pkg-up';
1
+ import { PackageJson } from 'read-package-up';
2
2
  /**
3
3
  * Load plugin's `manifest.yml`
4
4
  */
@@ -1,4 +1,4 @@
1
- import { PackageJson } from 'read-pkg-up';
1
+ import { PackageJson } from 'read-package-up';
2
2
  export declare const getPluginsOptions: any;
3
3
  /**
4
4
  * Retrieve information about @netlify/build when an error happens there and not
@@ -1,4 +1,4 @@
1
- import { PackageJson } from 'read-pkg-up';
1
+ import { PackageJson } from 'read-package-up';
2
2
  import { type PluginVersion } from './list.js';
3
3
  type ConditionContext = {
4
4
  nodeVersion: string;
@@ -2,6 +2,7 @@ import { ExecaChildProcess } from 'execa';
2
2
  import { NetlifyConfig } from '../index.js';
3
3
  import { BufferedLogs } from '../log/logger.js';
4
4
  import { PluginsOptions } from './node_version.js';
5
+ export type ChildProcess = ExecaChildProcess<string>;
5
6
  export declare const startPlugins: any;
6
7
  export declare const stopPlugins: ({ childProcesses, logs, verbose, pluginOptions, netlifyConfig, }: {
7
8
  logs: BufferedLogs;
@@ -1,10 +1,10 @@
1
1
  import { setEnvChanges } from '../env/changes.js';
2
2
  import { addErrorInfo, isBuildError } from '../error/info.js';
3
- import { addOutputGate } from '../log/logger.js';
3
+ import { addOutputFlusher } from '../log/logger.js';
4
4
  import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js';
5
5
  // Fire a core step
6
6
  export const fireCoreStep = async function ({ coreStep, coreStepId, coreStepName, configPath, outputConfigPath, buildDir, repositoryRoot, packagePath, constants, buildbotServerSocket, events, logs, quiet, nodePath, childEnv, context, branch, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, featureFlags, debug, systemLog, saveConfig, userNodeVersion, explicitSecretKeys, edgeFunctionsBootstrapURL, deployId, outputFlusher, }) {
7
- const logsA = addOutputGate(logs, outputFlusher);
7
+ const logsA = outputFlusher ? addOutputFlusher(logs, outputFlusher) : logs;
8
8
  try {
9
9
  const configSideFiles = await listConfigSideFiles([headersPath, redirectsPath]);
10
10
  const childEnvA = setEnvChanges(envChanges, { ...childEnv });
@@ -1,7 +1,8 @@
1
1
  import { context, propagation } from '@opentelemetry/api';
2
2
  import { addErrorInfo } from '../error/info.js';
3
- import { addOutputGate } from '../log/logger.js';
3
+ import { addOutputFlusher } from '../log/logger.js';
4
4
  import { logStepCompleted } from '../log/messages/ipc.js';
5
+ import { getStandardStreams } from '../log/output_flusher.js';
5
6
  import { pipePluginOutput, unpipePluginOutput } from '../log/stream.js';
6
7
  import { callChild } from '../plugins/ipc.js';
7
8
  import { getSuccessStatus } from '../status/success.js';
@@ -10,10 +11,11 @@ import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js';
10
11
  export const isTrustedPlugin = (packageName) => packageName?.startsWith('@netlify/');
11
12
  // Fire a plugin step
12
13
  export const firePluginStep = async function ({ event, childProcess, packageName, packagePath, pluginPackageJson, loadedFrom, origin, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, constants, steps, error, logs, outputFlusher, systemLog, featureFlags, debug, verbose, }) {
13
- const listeners = pipePluginOutput(childProcess, logs, outputFlusher);
14
+ const standardStreams = getStandardStreams(outputFlusher);
15
+ const listeners = pipePluginOutput(childProcess, logs, standardStreams);
14
16
  const otelCarrier = {};
15
17
  propagation.inject(context.active(), otelCarrier);
16
- const logsA = addOutputGate(logs, outputFlusher);
18
+ const logsA = outputFlusher ? addOutputFlusher(logs, outputFlusher) : logs;
17
19
  try {
18
20
  const configSideFiles = await listConfigSideFiles([headersPath, redirectsPath]);
19
21
  const { newEnvChanges, configMutations: newConfigMutations, status, } = await callChild({
@@ -28,7 +30,7 @@ export const firePluginStep = async function ({ event, childProcess, packageName
28
30
  constants,
29
31
  otelCarrier,
30
32
  },
31
- logs,
33
+ logs: logsA,
32
34
  verbose,
33
35
  });
34
36
  const { netlifyConfig: netlifyConfigA, configMutations: configMutationsA, headersPath: headersPathA, redirectsPath: redirectsPathA, } = await updateNetlifyConfig({
@@ -66,7 +68,7 @@ export const firePluginStep = async function ({ event, childProcess, packageName
66
68
  return { newError };
67
69
  }
68
70
  finally {
69
- await unpipePluginOutput(childProcess, logs, listeners);
71
+ await unpipePluginOutput(childProcess, logs, listeners, standardStreams);
70
72
  logStepCompleted(logs, verbose);
71
73
  }
72
74
  };
@@ -1,4 +1,4 @@
1
- import type { PackageJson } from 'read-pkg-up';
1
+ import type { PackageJson } from 'read-package-up';
2
2
  export type RootPackageJson = {
3
3
  name: string;
4
4
  version: string;
@@ -1,4 +1,4 @@
1
- import { Options, PackageJson } from 'read-pkg-up';
1
+ import { Options, PackageJson } from 'read-package-up';
2
2
  type PackageResult = {
3
3
  packageJson: PackageJson;
4
4
  packageDir?: string;
@@ -1,5 +1,5 @@
1
1
  import { dirname } from 'path';
2
- import { readPackageUp } from 'read-pkg-up';
2
+ import { readPackageUp } from 'read-package-up';
3
3
  /**
4
4
  * Retrieve `package.json` from a specific directory
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "29.42.5",
3
+ "version": "29.43.0",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -111,7 +111,7 @@
111
111
  "pkg-dir": "^7.0.0",
112
112
  "pretty-ms": "^8.0.0",
113
113
  "ps-list": "^8.0.0",
114
- "read-pkg-up": "^9.1.0",
114
+ "read-package-up": "^11.0.0",
115
115
  "readdirp": "^3.4.0",
116
116
  "resolve": "^2.0.0-next.1",
117
117
  "rfdc": "^1.3.0",
@@ -165,5 +165,5 @@
165
165
  "engines": {
166
166
  "node": "^14.16.0 || >=16.0.0"
167
167
  },
168
- "gitHead": "9260347bbb405cdb44a5e52c3e619ab43f1354ac"
168
+ "gitHead": "5c7e4326ca1e4f0134506295281f76ed842d31f5"
169
169
  }