@netlify/build 34.3.0 → 35.0.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.
@@ -1,4 +1,4 @@
1
- import stripAnsi from 'strip-ansi';
1
+ import { stripVTControlCharacters } from 'node:util';
2
2
  // Remove ANSI sequences from `error.message`
3
3
  export const removeErrorColors = function (error) {
4
4
  if (!(error instanceof Error)) {
@@ -6,8 +6,8 @@ export const removeErrorColors = function (error) {
6
6
  }
7
7
  // Setting error values might fail if they are getters or are non-writable.
8
8
  try {
9
- error.message = stripAnsi(error.message);
10
- error.stack = stripAnsi(error.stack);
9
+ error.message = stripVTControlCharacters(error.message);
10
+ error.stack = stripVTControlCharacters(error.stack);
11
11
  }
12
12
  catch {
13
13
  // continue
@@ -1,6 +1,6 @@
1
+ import { stripVTControlCharacters } from 'node:util';
1
2
  import { cwd } from 'process';
2
3
  import cleanStack from 'clean-stack';
3
- import stripAnsi from 'strip-ansi';
4
4
  // Clean stack traces:
5
5
  // - remove our internal code, e.g. the logic spawning plugins
6
6
  // - remove node modules and Node.js internals
@@ -22,7 +22,7 @@ export const cleanStacks = function ({ stack, rawStack, debug }) {
22
22
  };
23
23
  const cleanStackLine = function (lines, line) {
24
24
  const lineA = line.replace(getCwd(), '');
25
- const lineB = stripAnsi(lineA);
25
+ const lineB = stripVTControlCharacters(lineA);
26
26
  if (!STACK_LINE_REGEXP.test(lineB)) {
27
27
  return `${lines}\n${lineA}`;
28
28
  }
@@ -1,9 +1,7 @@
1
- import { promises as fs } from 'fs';
2
- import { normalize, resolve } from 'path';
3
- import { execa } from 'execa';
1
+ import { promises as fs } from 'node:fs';
2
+ import { normalize } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
4
  import { pathExists } from 'path-exists';
5
- import { isFile } from 'path-type';
6
- import { logArray, logSubHeader } from '../log/logger.js';
7
5
  import { logInstallMissingPlugins, logInstallIntegrations } from '../log/messages/install.js';
8
6
  import { addExactDependencies } from './main.js';
9
7
  // Automatically install plugins if not already installed.
@@ -21,40 +19,28 @@ export const installMissingPlugins = async function ({ missingPlugins, autoPlugi
21
19
  await addExactDependencies({ packageRoot: autoPluginsDir, isLocal: mode !== 'buildbot', packages });
22
20
  };
23
21
  export const installIntegrationPlugins = async function ({ integrations, autoPluginsDir, mode, logs, context, testOpts, pluginsEnv, buildDir, }) {
24
- const integrationsToBuild = integrations.filter((integration) => typeof integration.dev !== 'undefined' && context === 'dev');
25
- if (integrationsToBuild.length) {
26
- logSubHeader(logs, 'Building extensions');
27
- logArray(logs, integrationsToBuild.map(({ slug, dev: { path } }) => `${slug} from ${path}`));
28
- }
29
22
  const packages = (await Promise.all(integrations.map((integration) => getIntegrationPackage({ integration, context, testOpts, buildDir, pluginsEnv })))).filter(Boolean);
30
- logInstallIntegrations(logs, integrations.filter((integration) => integrationsToBuild.every((compiledIntegration) => integration.slug !== compiledIntegration.slug)));
23
+ logInstallIntegrations(logs, integrations);
31
24
  if (packages.length === 0) {
32
25
  return;
33
26
  }
34
27
  await createAutoPluginsDir(logs, autoPluginsDir);
35
28
  await addExactDependencies({ packageRoot: autoPluginsDir, isLocal: mode !== 'buildbot', packages });
36
29
  };
37
- const getIntegrationPackage = async function ({ integration: { version, dev }, context, testOpts = {}, buildDir, pluginsEnv, }) {
38
- if (typeof version !== 'undefined') {
39
- return `${version}/packages/buildhooks.tgz`;
40
- }
41
- if (typeof dev !== 'undefined' && context === 'dev') {
42
- const { path } = dev;
43
- const integrationDir = testOpts.cwd ? resolve(testOpts.cwd, path) : resolve(buildDir, path);
44
- try {
45
- const res = await execa('npm', ['run', 'build'], { cwd: integrationDir, env: pluginsEnv });
46
- // This is horrible and hacky, but `npm run build` will
47
- // return status code 0 even if it fails
48
- if (!res.stdout.includes('Build complete!')) {
49
- throw new Error(res.stdout);
50
- }
51
- }
52
- catch (e) {
53
- throw new Error(`Failed to build integration. Error:\n\n${e.stack}`);
54
- }
30
+ const getIntegrationPackage = async function ({ integration: { buildPlugin } }) {
31
+ if (buildPlugin === null) {
55
32
  return undefined;
56
33
  }
57
- return undefined;
34
+ switch (buildPlugin.packageURL.protocol) {
35
+ case 'http:':
36
+ // fallthrough
37
+ case 'https:':
38
+ return buildPlugin.packageURL.toString();
39
+ case 'file:':
40
+ return fileURLToPath(buildPlugin.packageURL);
41
+ default:
42
+ throw new Error(`unsupported build plugin package URL: ${buildPlugin.packageURL.toString()}`);
43
+ }
58
44
  };
59
45
  // We pin the version without using semver ranges ^ nor ~
60
46
  const getPackage = function ({ packageName, expectedVersion }) {
@@ -71,8 +57,14 @@ const ensureDir = async function (logs, autoPluginsDir) {
71
57
  }
72
58
  // If `.netlify` exists but is not a directory, we remove it first
73
59
  const autoPluginsParent = normalize(`${autoPluginsDir}/..`);
74
- if (await isFile(autoPluginsParent)) {
75
- await fs.unlink(autoPluginsParent);
60
+ try {
61
+ const stat = await fs.stat(autoPluginsParent);
62
+ if (stat.isFile()) {
63
+ await fs.unlink(autoPluginsParent);
64
+ }
65
+ }
66
+ catch {
67
+ // do nothing since it doesn't exist
76
68
  }
77
69
  await fs.mkdir(autoPluginsDir, { recursive: true });
78
70
  };
@@ -1,19 +1,20 @@
1
+ import * as colors from 'ansis';
1
2
  /**
2
- * Color theme. Please use this instead of requiring chalk directly,
3
+ * Color theme. Please use this instead of requiring ansis directly,
3
4
  * to ensure consistent colors.
4
5
  */
5
6
  export declare const THEME: {
6
- header: import("chalk").ChalkInstance;
7
- subHeader: import("chalk").ChalkInstance;
8
- highlightWords: import("chalk").ChalkInstance;
9
- errorHeader: import("chalk").ChalkInstance;
10
- errorSubHeader: import("chalk").ChalkInstance;
11
- errorLine: import("chalk").ChalkInstance;
12
- errorHighlightWords: import("chalk").ChalkInstance;
13
- warningHeader: import("chalk").ChalkInstance;
14
- warningSubHeader: import("chalk").ChalkInstance;
15
- warningLine: import("chalk").ChalkInstance;
16
- warningHighlightWords: import("chalk").ChalkInstance;
17
- dimWords: import("chalk").ChalkInstance;
7
+ header: colors.Ansis;
8
+ subHeader: colors.Ansis;
9
+ highlightWords: colors.Ansis;
10
+ errorHeader: colors.Ansis;
11
+ errorSubHeader: colors.Ansis;
12
+ errorLine: colors.Ansis;
13
+ errorHighlightWords: colors.Ansis;
14
+ warningHeader: colors.Ansis;
15
+ warningSubHeader: colors.Ansis;
16
+ warningLine: colors.Ansis;
17
+ warningHighlightWords: colors.Ansis;
18
+ dimWords: colors.Ansis;
18
19
  none: (string: any) => any;
19
20
  };
package/lib/log/theme.js CHANGED
@@ -1,27 +1,27 @@
1
- import chalk from 'chalk';
1
+ import * as colors from 'ansis';
2
2
  /**
3
- * Color theme. Please use this instead of requiring chalk directly,
3
+ * Color theme. Please use this instead of requiring ansis directly,
4
4
  * to ensure consistent colors.
5
5
  */
6
6
  export const THEME = {
7
7
  // Main headers
8
- header: chalk.cyanBright.bold,
8
+ header: colors.cyanBright.bold,
9
9
  // Single lines used as sub-headers
10
- subHeader: chalk.cyan.bold,
10
+ subHeader: colors.cyan.bold,
11
11
  // One of several words that should be highlighted inside a line
12
- highlightWords: chalk.cyan,
12
+ highlightWords: colors.cyan,
13
13
  // Same for errors
14
- errorHeader: chalk.redBright.bold,
15
- errorSubHeader: chalk.red.bold,
16
- errorLine: chalk.redBright,
17
- errorHighlightWords: chalk.redBright.bold,
14
+ errorHeader: colors.redBright.bold,
15
+ errorSubHeader: colors.red.bold,
16
+ errorLine: colors.redBright,
17
+ errorHighlightWords: colors.redBright.bold,
18
18
  // Same for warnings
19
- warningHeader: chalk.yellowBright.bold,
20
- warningSubHeader: chalk.yellow.bold,
21
- warningLine: chalk.yellowBright,
22
- warningHighlightWords: chalk.yellowBright.bold,
19
+ warningHeader: colors.yellowBright.bold,
20
+ warningSubHeader: colors.yellow.bold,
21
+ warningLine: colors.yellowBright,
22
+ warningHighlightWords: colors.yellowBright.bold,
23
23
  // One of several words that should be dimmed inside a line
24
- dimWords: chalk.gray,
24
+ dimWords: colors.gray,
25
25
  // No colors
26
26
  none: (string) => string,
27
27
  };
@@ -1,9 +1,6 @@
1
- import _pEvery from 'p-every';
2
1
  import pLocate from 'p-locate';
3
2
  import semver from 'semver';
4
3
  import { CONDITIONS } from './plugin_conditions.js';
5
- // the types of that package seem to be not correct and demand a `pEvery.default()` usage which is wrong
6
- const pEvery = _pEvery;
7
4
  /**
8
5
  * Retrieve the `expectedVersion` of a plugin:
9
6
  * - This is the version which should be run
@@ -66,7 +63,7 @@ const getCompatibleEntry = async function ({ versions, nodeVersion, packageJson,
66
63
  if (conditions.length === 0 && pinnedVersion === undefined) {
67
64
  return false;
68
65
  }
69
- return await pEvery(conditions, async ({ type, condition }) => CONDITIONS[type].test(condition, { nodeVersion, packageJson, packagePath, buildDir }));
66
+ return (await Promise.all(conditions.map(async ({ type, condition }) => CONDITIONS[type].test(condition, { nodeVersion, packageJson, packagePath, buildDir })))).every(Boolean);
70
67
  });
71
68
  if (compatibleEntry) {
72
69
  systemLog(`Used compatible version '${compatibleEntry.version}' for plugin '${packageName}' (pinned version is ${pinnedVersion})`);
@@ -98,7 +95,7 @@ const getFirstCompatibleEntry = async function ({ versions, nodeVersion, package
98
95
  if (conditions.length === 0) {
99
96
  return true;
100
97
  }
101
- return await pEvery(conditions, async ({ type, condition }) => CONDITIONS[type].test(condition, { nodeVersion, packageJson, packagePath, buildDir }));
98
+ return (await Promise.all(conditions.map(async ({ type, condition }) => CONDITIONS[type].test(condition, { nodeVersion, packageJson, packagePath, buildDir })))).every(Boolean);
102
99
  });
103
100
  if (compatibleEntry) {
104
101
  return compatibleEntry;
@@ -1,11 +1,11 @@
1
- import { locatePath } from 'locate-path';
1
+ import fsSync from 'node:fs';
2
2
  import { addErrorInfo } from '../../error/info.js';
3
3
  // Retrieve "manifest.yml" path for a specific plugin
4
4
  export const getManifestPath = async function ({ pluginDir, packageDir, packageName }) {
5
5
  const dirs = [pluginDir, packageDir]
6
6
  .filter(Boolean)
7
7
  .flatMap((dir) => MANIFEST_FILENAMES.map((filename) => `${dir}/${filename}`));
8
- const manifestPath = await locatePath(dirs);
8
+ const manifestPath = dirs.find((dir) => fsSync.existsSync(dir));
9
9
  validateManifestExists(manifestPath, packageName);
10
10
  return manifestPath;
11
11
  };
@@ -1,10 +1,7 @@
1
1
  import { join } from 'path';
2
- import _pEvery from 'p-every';
3
2
  import semver from 'semver';
4
3
  import { importJsonFile } from '../utils/json.js';
5
4
  import { resolvePath } from '../utils/resolve.js';
6
- // the types of that package seem to be not correct and demand a `pEvery.default()` usage which is wrong
7
- const pEvery = _pEvery;
8
5
  /**
9
6
  * Plugins can use `compatibility.{version}.nodeVersion: 'allowedNodeVersion'`
10
7
  * to deliver different plugin versions based on the Node.js version
@@ -25,7 +22,7 @@ const siteDependenciesTest = async function (allowedSiteDependencies, { packageJ
25
22
  // noop
26
23
  }
27
24
  }
28
- return await pEvery(Object.entries(allowedSiteDependencies), ([dependencyName, allowedVersion]) => siteDependencyTest({ dependencyName, allowedVersion, siteDependencies, buildDir }));
25
+ return (await Promise.all(Object.entries(allowedSiteDependencies).map(async ([dependencyName, allowedVersion]) => siteDependencyTest({ dependencyName, allowedVersion, siteDependencies, buildDir })))).every(Boolean);
29
26
  };
30
27
  const siteDependencyTest = async function ({ dependencyName, allowedVersion, siteDependencies, buildDir, }) {
31
28
  const siteDependency = siteDependencies[dependencyName];
@@ -1,4 +1,4 @@
1
- import { join, resolve } from 'path';
1
+ import { join } from 'node:path';
2
2
  import { addErrorInfo } from '../error/info.js';
3
3
  import { installMissingPlugins, installIntegrationPlugins } from '../install/missing.js';
4
4
  import { resolvePath, tryResolvePath } from '../utils/resolve.js';
@@ -39,8 +39,7 @@ export const resolvePluginsPath = async function ({ pluginsOptions, siteInfo, bu
39
39
  mode,
40
40
  logs,
41
41
  });
42
- let integrationPluginOptions = [];
43
- integrationPluginOptions = await handleIntegrations({
42
+ const integrationPluginOptions = await handleIntegrations({
44
43
  integrations,
45
44
  autoPluginsDir,
46
45
  mode,
@@ -118,9 +117,9 @@ const handleMissingPlugins = async function ({ pluginsOptions, autoPluginsDir, m
118
117
  return Promise.all(pluginsOptions.map((pluginOptions) => resolveMissingPluginPath({ pluginOptions, autoPluginsDir })));
119
118
  };
120
119
  const handleIntegrations = async function ({ integrations, autoPluginsDir, mode, logs, buildDir, context, testOpts, pluginsEnv, }) {
121
- const toInstall = integrations.filter((integration) => integration.has_build);
120
+ const integrationsWithBuildPlugins = integrations.filter((integration) => integration.has_build);
122
121
  await installIntegrationPlugins({
123
- integrations: toInstall,
122
+ integrations: integrationsWithBuildPlugins,
124
123
  autoPluginsDir,
125
124
  mode,
126
125
  logs,
@@ -129,26 +128,25 @@ const handleIntegrations = async function ({ integrations, autoPluginsDir, mode,
129
128
  buildDir,
130
129
  pluginsEnv,
131
130
  });
132
- if (toInstall.length === 0) {
133
- return [];
134
- }
135
- return Promise.all(toInstall.map((integration) => resolveIntegration({
136
- integration,
137
- autoPluginsDir,
138
- buildDir,
139
- context,
140
- testOpts,
141
- })));
142
- };
143
- const resolveIntegration = async function ({ integration, autoPluginsDir, buildDir, context, testOpts }) {
144
- if (typeof integration.dev !== 'undefined' && context === 'dev') {
145
- const { path } = integration.dev;
146
- const integrationDir = testOpts.cwd ? resolve(testOpts.cwd, path) : resolve(buildDir, path);
147
- const pluginPath = await resolvePath(`${integrationDir}/.ntli/build`, buildDir);
148
- return { pluginPath, packageName: `${integration.slug}`, isIntegration: true, integration, loadedFrom: 'local' };
149
- }
150
- const pluginPath = await resolvePath(`${integration.slug}-buildhooks`, autoPluginsDir);
151
- return { pluginPath, packageName: `${integration.slug}-buildhooks`, isIntegration: true, integration };
131
+ return Promise.all(integrationsWithBuildPlugins.map(async (integration) => {
132
+ // TODO(ndhoule): When developing locally, the user can accidentally set an extension name in
133
+ // their netlify.toml that points to a build plugin package that has a mismatched name. This
134
+ // will result in a failed install here. The solution is non-obvious: make sure your
135
+ // `netlify.toml#integrations[].name` matches the extension that `netlify.toml#integrations[].dev.path`
136
+ // points at.
137
+ //
138
+ // (We could, for example, detect a mismatch by untarring the local build plugin package in
139
+ // memory and comparing its `package.json#name` to `integration.slug`, and throw a descriptive
140
+ // error if they don't match.)
141
+ const packageName = `${integration.slug}-buildhooks`;
142
+ return {
143
+ integration,
144
+ isIntegration: true,
145
+ loadedFrom: integration.buildPlugin.origin === 'local' ? 'local' : undefined,
146
+ packageName,
147
+ pluginPath: await resolvePath(packageName, autoPluginsDir),
148
+ };
149
+ }));
152
150
  };
153
151
  // Resolve the plugins that just got automatically installed
154
152
  const resolveMissingPluginPath = async function ({ pluginOptions, pluginOptions: { packageName }, autoPluginsDir }) {
@@ -1,4 +1,4 @@
1
- import stripAnsi from 'strip-ansi';
1
+ import { stripVTControlCharacters } from 'node:util';
2
2
  // Remove colors from statuses
3
3
  export const removeStatusesColors = function (statuses) {
4
4
  return statuses.map(removeStatusColors);
@@ -13,6 +13,6 @@ const removeAttrColor = function (status, attribute) {
13
13
  if (value === undefined) {
14
14
  return {};
15
15
  }
16
- const valueA = stripAnsi(value);
16
+ const valueA = stripVTControlCharacters(value);
17
17
  return { [attribute]: valueA };
18
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "34.3.0",
3
+ "version": "35.0.1",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -67,10 +67,10 @@
67
67
  "license": "MIT",
68
68
  "dependencies": {
69
69
  "@bugsnag/js": "^8.0.0",
70
- "@netlify/blobs": "^10.0.6",
70
+ "@netlify/blobs": "^10.0.7",
71
71
  "@netlify/cache-utils": "^6.0.3",
72
- "@netlify/config": "^23.2.0",
73
- "@netlify/edge-bundler": "14.2.2",
72
+ "@netlify/config": "^24.0.1",
73
+ "@netlify/edge-bundler": "14.3.0",
74
74
  "@netlify/functions-utils": "^6.2.0",
75
75
  "@netlify/git-utils": "^6.0.2",
76
76
  "@netlify/opentelemetry-utils": "^2.0.1",
@@ -79,7 +79,7 @@
79
79
  "@netlify/zip-it-and-ship-it": "14.1.0",
80
80
  "@sindresorhus/slugify": "^2.0.0",
81
81
  "ansi-escapes": "^7.0.0",
82
- "chalk": "^5.0.0",
82
+ "ansis": "^4.1.0",
83
83
  "clean-stack": "^5.0.0",
84
84
  "execa": "^8.0.0",
85
85
  "fdir": "^6.0.1",
@@ -89,21 +89,18 @@
89
89
  "indent-string": "^5.0.0",
90
90
  "is-plain-obj": "^4.0.0",
91
91
  "keep-func-props": "^6.0.0",
92
- "locate-path": "^7.0.0",
93
92
  "log-process-errors": "^11.0.0",
94
93
  "map-obj": "^5.0.0",
95
94
  "memoize-one": "^6.0.0",
96
95
  "minimatch": "^9.0.4",
97
96
  "os-name": "^6.0.0",
98
97
  "p-event": "^6.0.0",
99
- "p-every": "^2.0.0",
100
98
  "p-filter": "^4.0.0",
101
99
  "p-locate": "^6.0.0",
102
100
  "p-map": "^7.0.0",
103
101
  "p-reduce": "^3.0.0",
104
102
  "package-directory": "^8.0.0",
105
103
  "path-exists": "^5.0.0",
106
- "path-type": "^6.0.0",
107
104
  "pretty-ms": "^9.0.0",
108
105
  "ps-list": "^8.0.0",
109
106
  "read-package-up": "^11.0.0",
@@ -113,7 +110,6 @@
113
110
  "safe-json-stringify": "^1.2.0",
114
111
  "semver": "^7.3.8",
115
112
  "string-width": "^7.0.0",
116
- "strip-ansi": "^7.0.0",
117
113
  "supports-color": "^10.0.0",
118
114
  "terminal-link": "^4.0.0",
119
115
  "ts-node": "^10.9.1",
@@ -138,7 +134,7 @@
138
134
  "moize": "^6.0.0",
139
135
  "npm-run-all2": "^6.0.0",
140
136
  "process-exists": "^5.0.0",
141
- "sinon": "^21.0.0",
137
+ "tinyspy": "^4.0.3",
142
138
  "tmp-promise": "^3.0.2",
143
139
  "tsd": "^0.32.0",
144
140
  "vitest": "^3.0.0",
@@ -156,5 +152,5 @@
156
152
  "engines": {
157
153
  "node": ">=18.14.0"
158
154
  },
159
- "gitHead": "2a186393af7f577cc6bafa5d3962ea0833cd084c"
155
+ "gitHead": "f65a08178a04db0ad274aa62f7d46319f2ef661a"
160
156
  }