@netlify/build 29.30.0 → 29.31.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/lib/core/constants.d.ts +93 -4
- package/lib/core/constants.js +5 -4
- package/lib/core/types.d.ts +1 -1
- package/lib/index.d.ts +7 -1
- package/lib/plugins/child/systemLog.d.ts +1 -1
- package/lib/plugins/child/systemLog.js +4 -2
- package/lib/plugins_core/blobs_upload/index.d.ts +2 -26
- package/lib/plugins_core/blobs_upload/index.js +10 -6
- package/lib/plugins_core/pre_cleanup/index.d.ts +2 -18
- package/lib/plugins_core/pre_cleanup/index.js +3 -5
- package/lib/plugins_core/pre_dev_cleanup/index.d.ts +2 -14
- package/lib/plugins_core/pre_dev_cleanup/index.js +5 -5
- package/lib/plugins_core/secrets_scanning/index.d.ts +2 -16
- package/lib/plugins_core/secrets_scanning/index.js +2 -2
- package/lib/plugins_core/types.d.ts +40 -0
- package/lib/plugins_core/types.js +1 -0
- package/lib/steps/get.d.ts +4 -4
- package/lib/types/config/build.d.ts +45 -0
- package/lib/types/config/build.js +1 -0
- package/lib/types/config/functions.d.ts +30 -0
- package/lib/types/config/functions.js +1 -0
- package/lib/types/config/inputs.d.ts +3 -0
- package/lib/types/config/inputs.js +1 -0
- package/lib/types/config/netlify_config.d.ts +55 -0
- package/lib/types/config/netlify_config.js +1 -0
- package/lib/types/netlify_event_handler.d.ts +16 -0
- package/lib/types/netlify_event_handler.js +1 -0
- package/lib/types/netlify_plugin.d.ts +28 -0
- package/lib/types/netlify_plugin.js +1 -0
- package/lib/types/netlify_plugin_options.d.ts +24 -0
- package/lib/types/netlify_plugin_options.js +1 -0
- package/lib/types/options/netlify_plugin_build_util.d.ts +6 -0
- package/lib/types/options/netlify_plugin_build_util.js +1 -0
- package/lib/types/options/netlify_plugin_cache_util.d.ts +29 -0
- package/lib/types/options/netlify_plugin_cache_util.js +1 -0
- package/lib/types/options/netlify_plugin_functions_util.d.ts +28 -0
- package/lib/types/options/netlify_plugin_functions_util.js +1 -0
- package/lib/types/options/netlify_plugin_git_util.d.ts +41 -0
- package/lib/types/options/netlify_plugin_git_util.js +1 -0
- package/lib/types/options/netlify_plugin_run_util.d.ts +17 -0
- package/lib/types/options/netlify_plugin_run_util.js +1 -0
- package/lib/types/options/netlify_plugin_status_util.d.ts +24 -0
- package/lib/types/options/netlify_plugin_status_util.js +1 -0
- package/{types → lib/types}/options/netlify_plugin_utils.d.ts +12 -13
- package/lib/types/options/netlify_plugin_utils.js +1 -0
- package/lib/types/utils/json_value.d.ts +3 -0
- package/lib/types/utils/json_value.js +1 -0
- package/{types → lib/types}/utils/many.d.ts +5 -5
- package/lib/types/utils/many.js +1 -0
- package/lib/utils/blobs.d.ts +9 -8
- package/lib/utils/blobs.js +11 -6
- package/package.json +5 -5
- package/types/config/build.d.ts +0 -52
- package/types/config/functions.d.ts +0 -36
- package/types/config/inputs.d.ts +0 -7
- package/types/config/netlify_config.d.ts +0 -66
- package/types/index.d.ts +0 -7
- package/types/netlify_event_handler.d.ts +0 -29
- package/types/netlify_plugin.d.ts +0 -29
- package/types/netlify_plugin_constants.d.ts +0 -66
- package/types/netlify_plugin_options.d.ts +0 -25
- package/types/options/netlify_plugin_build_util.d.ts +0 -7
- package/types/options/netlify_plugin_cache_util.d.ts +0 -39
- package/types/options/netlify_plugin_functions_util.d.ts +0 -32
- package/types/options/netlify_plugin_git_util.d.ts +0 -41
- package/types/options/netlify_plugin_run_util.d.ts +0 -24
- package/types/options/netlify_plugin_status_util.d.ts +0 -24
- package/types/utils/json_value.d.ts +0 -1
package/lib/core/constants.d.ts
CHANGED
|
@@ -1,4 +1,77 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface NetlifyPluginConstants {
|
|
2
|
+
/**
|
|
3
|
+
* path to the Netlify configuration file.
|
|
4
|
+
* `undefined` if none was used.
|
|
5
|
+
*/
|
|
6
|
+
CONFIG_PATH?: string;
|
|
7
|
+
/**
|
|
8
|
+
* directory that contains the deploy-ready HTML files and assets generated by the build. Its value is always defined, but the target might not have been created yet.
|
|
9
|
+
*/
|
|
10
|
+
PUBLISH_DIR: string;
|
|
11
|
+
/**
|
|
12
|
+
* the directory where function source code lives.
|
|
13
|
+
* `undefined` if no `netlify/functions` directory exists in the base directory and if not specified by the user.
|
|
14
|
+
*/
|
|
15
|
+
FUNCTIONS_SRC?: string;
|
|
16
|
+
/**
|
|
17
|
+
* the directory inside a mono repository where it collects the settings from.
|
|
18
|
+
* This is the value of the package directory field of the build settings
|
|
19
|
+
* `undefined` if none is set.
|
|
20
|
+
*/
|
|
21
|
+
PACKAGE_PATH?: string;
|
|
22
|
+
/**
|
|
23
|
+
* the directory where internal Edge Functions source code lives. This is where build plugins should place auto-generated functions.
|
|
24
|
+
* `undefined` if the version of @netlify/build does not support internal Edge Functions
|
|
25
|
+
*/
|
|
26
|
+
INTERNAL_EDGE_FUNCTIONS_SRC?: string;
|
|
27
|
+
/**
|
|
28
|
+
* the directory where internal function source code lives. This is where build plugins should place auto-generated functions.
|
|
29
|
+
* `undefined` if the version of @netlify/build does not support internal functions
|
|
30
|
+
*/
|
|
31
|
+
INTERNAL_FUNCTIONS_SRC?: string;
|
|
32
|
+
/**
|
|
33
|
+
* the directory where built serverless functions are placed before deployment. Its value is always defined, but the target might not have been created yet.
|
|
34
|
+
*/
|
|
35
|
+
FUNCTIONS_DIST: string;
|
|
36
|
+
/**
|
|
37
|
+
* the directory where built Edge Functions are placed before deployment. Its value is always defined, but the target might not have been created yet.
|
|
38
|
+
*/
|
|
39
|
+
EDGE_FUNCTIONS_DIST: string;
|
|
40
|
+
/**
|
|
41
|
+
* the directory where Edge Functions source code lives.
|
|
42
|
+
* `undefined` if no `netlify/edge-functions` directory exists.
|
|
43
|
+
*/
|
|
44
|
+
EDGE_FUNCTIONS_SRC?: string;
|
|
45
|
+
/**
|
|
46
|
+
* boolean indicating whether the build was [run locally](https://docs.netlify.com/cli/get-started/#run-builds-locally) or on Netlify
|
|
47
|
+
*/
|
|
48
|
+
IS_LOCAL: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* version of Netlify Build as a `major.minor.patch` string
|
|
51
|
+
*/
|
|
52
|
+
NETLIFY_BUILD_VERSION: string;
|
|
53
|
+
/**
|
|
54
|
+
* the Netlify site ID
|
|
55
|
+
*/
|
|
56
|
+
SITE_ID: string;
|
|
57
|
+
/**
|
|
58
|
+
* the Netlify API access token
|
|
59
|
+
*/
|
|
60
|
+
NETLIFY_API_TOKEN?: string;
|
|
61
|
+
/**
|
|
62
|
+
* the Netlify API host
|
|
63
|
+
*/
|
|
64
|
+
NETLIFY_API_HOST?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The directory that is used for caching
|
|
67
|
+
* @default '.netlify/cache'
|
|
68
|
+
*/
|
|
69
|
+
CACHE_DIR: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Retrieve constants passed to plugins
|
|
73
|
+
*/
|
|
74
|
+
export declare const getConstants: ({ configPath, buildDir, packagePath, functionsDistDir, edgeFunctionsDistDir, cacheDir, netlifyConfig, siteInfo: { id: siteId }, apiHost, token, mode, }: {
|
|
2
75
|
configPath: any;
|
|
3
76
|
buildDir: any;
|
|
4
77
|
packagePath: any;
|
|
@@ -12,8 +85,8 @@ export function getConstants({ configPath, buildDir, packagePath, functionsDistD
|
|
|
12
85
|
apiHost: any;
|
|
13
86
|
token: any;
|
|
14
87
|
mode: any;
|
|
15
|
-
})
|
|
16
|
-
export
|
|
88
|
+
}) => Promise<NetlifyPluginConstants>;
|
|
89
|
+
export declare const addMutableConstants: ({ constants, buildDir, netlifyConfig: { build: { publish, edge_functions: edgeFunctions }, functionsDirectory, }, }: {
|
|
17
90
|
constants: any;
|
|
18
91
|
buildDir: any;
|
|
19
92
|
netlifyConfig: {
|
|
@@ -23,4 +96,20 @@ export function addMutableConstants({ constants, buildDir, netlifyConfig: { buil
|
|
|
23
96
|
};
|
|
24
97
|
functionsDirectory: any;
|
|
25
98
|
};
|
|
26
|
-
})
|
|
99
|
+
}) => Promise<{
|
|
100
|
+
FUNCTIONS_SRC: string | undefined;
|
|
101
|
+
EDGE_FUNCTIONS_SRC: string | undefined;
|
|
102
|
+
CONFIG_PATH: string | undefined;
|
|
103
|
+
PUBLISH_DIR: string | undefined;
|
|
104
|
+
FUNCTIONS_DIST: string | undefined;
|
|
105
|
+
INTERNAL_EDGE_FUNCTIONS_SRC: string | undefined;
|
|
106
|
+
INTERNAL_FUNCTIONS_SRC: string | undefined;
|
|
107
|
+
EDGE_FUNCTIONS_DIST: string | undefined;
|
|
108
|
+
CACHE_DIR: string | undefined;
|
|
109
|
+
PACKAGE_PATH: string | undefined;
|
|
110
|
+
IS_LOCAL: string | undefined;
|
|
111
|
+
NETLIFY_BUILD_VERSION: string | undefined;
|
|
112
|
+
SITE_ID: string | undefined;
|
|
113
|
+
NETLIFY_API_TOKEN: string | undefined;
|
|
114
|
+
NETLIFY_API_HOST: string | undefined;
|
|
115
|
+
}>;
|
package/lib/core/constants.js
CHANGED
|
@@ -3,7 +3,9 @@ import { getCacheDir } from '@netlify/cache-utils';
|
|
|
3
3
|
import mapObj from 'map-obj';
|
|
4
4
|
import { pathExists } from 'path-exists';
|
|
5
5
|
import { ROOT_PACKAGE_JSON } from '../utils/json.js';
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Retrieve constants passed to plugins
|
|
8
|
+
*/
|
|
7
9
|
export const getConstants = async function ({ configPath, buildDir, packagePath, functionsDistDir, edgeFunctionsDistDir, cacheDir, netlifyConfig, siteInfo: { id: siteId }, apiHost, token, mode, }) {
|
|
8
10
|
const isLocal = mode !== 'buildbot';
|
|
9
11
|
const normalizedCacheDir = getCacheDir({ cacheDir, cwd: buildDir });
|
|
@@ -39,8 +41,7 @@ export const getConstants = async function ({ configPath, buildDir, packagePath,
|
|
|
39
41
|
// via plugins or others) live
|
|
40
42
|
INTERNAL_EDGE_FUNCTIONS_SRC: join(buildDir, packagePath || '', INTERNAL_EDGE_FUNCTIONS_SRC),
|
|
41
43
|
};
|
|
42
|
-
|
|
43
|
-
return constantsA;
|
|
44
|
+
return (await addMutableConstants({ constants, buildDir, netlifyConfig }));
|
|
44
45
|
};
|
|
45
46
|
const INTERNAL_EDGE_FUNCTIONS_SRC = '.netlify/edge-functions';
|
|
46
47
|
const INTERNAL_FUNCTIONS_SRC = '.netlify/functions-internal';
|
|
@@ -94,7 +95,7 @@ const normalizeConstantsPaths = function (constants, buildDir) {
|
|
|
94
95
|
// Instead of passing absolute paths, we pass paths relative to `buildDir`, so
|
|
95
96
|
// that logs are less verbose.
|
|
96
97
|
const normalizePath = function (path, buildDir, key) {
|
|
97
|
-
if (
|
|
98
|
+
if (path === undefined || path === '' || !CONSTANT_PATHS.has(key)) {
|
|
98
99
|
return path;
|
|
99
100
|
}
|
|
100
101
|
const pathA = normalize(path);
|
package/lib/core/types.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { buildSite } from './core/main.js';
|
|
2
|
-
export
|
|
2
|
+
export { NetlifyPluginConstants } from './core/constants.js';
|
|
3
|
+
export type { NetlifyPlugin } from './types/netlify_plugin.js';
|
|
4
|
+
export type { NetlifyPluginOptions } from './types/netlify_plugin_options.js';
|
|
5
|
+
export type { OnBuild, OnEnd, OnError, OnPostBuild, OnPreBuild, OnSuccess } from './types/netlify_event_handler.js';
|
|
6
|
+
export type { NetlifyConfig } from './types/config/netlify_config.js';
|
|
7
|
+
export type { NetlifyPluginUtils } from './types/options/netlify_plugin_utils.js';
|
|
8
|
+
export type { ListedFunction, ListedFunctionFile } from './types/options/netlify_plugin_functions_util.js';
|
|
3
9
|
export { startDev } from './core/dev.js';
|
|
4
10
|
export { runCoreSteps } from './steps/run_core_steps.js';
|
|
5
11
|
export default buildSite;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const getSystemLog: () => ((message: unknown) => void) | undefined;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { appendFileSync, openSync } from 'fs';
|
|
2
|
+
import { inspect } from 'util';
|
|
2
3
|
const systemLogLocation = '/dev/fd/4';
|
|
3
4
|
export const getSystemLog = () => {
|
|
4
5
|
try {
|
|
5
6
|
// throws if system log wasn't hooked up
|
|
6
7
|
const fd = openSync(systemLogLocation, 'a');
|
|
7
8
|
return (message) => {
|
|
8
|
-
|
|
9
|
+
const stringifiedMessage = typeof message === 'string' ? message : inspect(message);
|
|
10
|
+
appendFileSync(fd, `${stringifiedMessage}\n`);
|
|
9
11
|
};
|
|
10
12
|
}
|
|
11
13
|
catch {
|
|
12
|
-
|
|
14
|
+
// not accessible
|
|
13
15
|
}
|
|
14
16
|
};
|
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
coreStep: ({ debug, logs, deployId, buildDir, quiet, constants: { PUBLISH_DIR, SITE_ID, NETLIFY_API_TOKEN, API_URL }, }: {
|
|
4
|
-
debug: any;
|
|
5
|
-
logs: any;
|
|
6
|
-
deployId: any;
|
|
7
|
-
buildDir: any;
|
|
8
|
-
quiet: any;
|
|
9
|
-
constants: {
|
|
10
|
-
PUBLISH_DIR: any;
|
|
11
|
-
SITE_ID: any;
|
|
12
|
-
NETLIFY_API_TOKEN: any;
|
|
13
|
-
API_URL: any;
|
|
14
|
-
};
|
|
15
|
-
}) => Promise<{}>;
|
|
16
|
-
coreStepId: string;
|
|
17
|
-
coreStepName: string;
|
|
18
|
-
coreStepDescription: () => string;
|
|
19
|
-
condition: ({ deployId, buildDir, constants: { PUBLISH_DIR } }: {
|
|
20
|
-
deployId: any;
|
|
21
|
-
buildDir: any;
|
|
22
|
-
constants: {
|
|
23
|
-
PUBLISH_DIR: any;
|
|
24
|
-
};
|
|
25
|
-
}) => Promise<boolean>;
|
|
26
|
-
};
|
|
1
|
+
import { CoreStep } from '../types.js';
|
|
2
|
+
export declare const uploadBlobs: CoreStep;
|
|
@@ -5,19 +5,25 @@ import semver from 'semver';
|
|
|
5
5
|
import { log, logError } from '../../log/logger.js';
|
|
6
6
|
import { anyBlobsToUpload, getBlobsDir } from '../../utils/blobs.js';
|
|
7
7
|
import { getKeysToUpload, getFileWithMetadata } from './utils.js';
|
|
8
|
-
const coreStep = async function ({ debug, logs, deployId, buildDir, quiet, constants: {
|
|
8
|
+
const coreStep = async function ({ debug, logs, deployId, buildDir, quiet, packagePath, constants: { SITE_ID, NETLIFY_API_TOKEN, NETLIFY_API_HOST }, }) {
|
|
9
|
+
// This should never happen due to the condition check
|
|
10
|
+
if (!deployId || !NETLIFY_API_TOKEN) {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
// for cli deploys with `netlify deploy --build` the `NETLIFY_API_HOST` is undefined
|
|
14
|
+
const apiHost = NETLIFY_API_HOST || 'api.netlify.com';
|
|
9
15
|
const storeOpts = {
|
|
10
16
|
siteID: SITE_ID,
|
|
11
17
|
deployID: deployId,
|
|
12
18
|
token: NETLIFY_API_TOKEN,
|
|
13
|
-
apiURL:
|
|
19
|
+
apiURL: `https://${apiHost}`,
|
|
14
20
|
};
|
|
15
21
|
if (semver.lt(nodeVersion, '18.0.0')) {
|
|
16
22
|
const nodeFetch = await import('node-fetch');
|
|
17
23
|
storeOpts.fetch = nodeFetch.default;
|
|
18
24
|
}
|
|
19
25
|
const blobStore = getDeployStore(storeOpts);
|
|
20
|
-
const blobsDir = getBlobsDir(
|
|
26
|
+
const blobsDir = getBlobsDir(buildDir, packagePath);
|
|
21
27
|
const keys = await getKeysToUpload(blobsDir);
|
|
22
28
|
// We checked earlier, but let's be extra safe
|
|
23
29
|
if (keys.length === 0) {
|
|
@@ -48,9 +54,7 @@ const coreStep = async function ({ debug, logs, deployId, buildDir, quiet, const
|
|
|
48
54
|
}
|
|
49
55
|
return {};
|
|
50
56
|
};
|
|
51
|
-
const deployAndBlobsPresent = async
|
|
52
|
-
return deployId && (await anyBlobsToUpload({ buildDir, publishDir: PUBLISH_DIR }));
|
|
53
|
-
};
|
|
57
|
+
const deployAndBlobsPresent = async ({ deployId, buildDir, packagePath, constants: { NETLIFY_API_TOKEN }, }) => Boolean(NETLIFY_API_TOKEN && deployId && (await anyBlobsToUpload(buildDir, packagePath)));
|
|
54
58
|
export const uploadBlobs = {
|
|
55
59
|
event: 'onPostBuild',
|
|
56
60
|
coreStep,
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
coreStep: ({ buildDir, constants: { PUBLISH_DIR } }: {
|
|
4
|
-
buildDir: any;
|
|
5
|
-
constants: {
|
|
6
|
-
PUBLISH_DIR: any;
|
|
7
|
-
};
|
|
8
|
-
}) => Promise<{}>;
|
|
9
|
-
coreStepId: string;
|
|
10
|
-
coreStepName: string;
|
|
11
|
-
coreStepDescription: () => string;
|
|
12
|
-
condition: ({ buildDir, constants: { PUBLISH_DIR } }: {
|
|
13
|
-
buildDir: any;
|
|
14
|
-
constants: {
|
|
15
|
-
PUBLISH_DIR: any;
|
|
16
|
-
};
|
|
17
|
-
}) => Promise<boolean>;
|
|
18
|
-
};
|
|
1
|
+
import { CoreStep } from '../types.js';
|
|
2
|
+
export declare const preCleanup: CoreStep;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rm } from 'node:fs/promises';
|
|
2
2
|
import { anyBlobsToUpload, getBlobsDir } from '../../utils/blobs.js';
|
|
3
|
-
const coreStep = async
|
|
4
|
-
const blobsDir = getBlobsDir(
|
|
3
|
+
const coreStep = async ({ buildDir, packagePath }) => {
|
|
4
|
+
const blobsDir = getBlobsDir(buildDir, packagePath);
|
|
5
5
|
try {
|
|
6
6
|
await rm(blobsDir, { recursive: true, force: true });
|
|
7
7
|
}
|
|
@@ -10,9 +10,7 @@ const coreStep = async function ({ buildDir, constants: { PUBLISH_DIR } }) {
|
|
|
10
10
|
}
|
|
11
11
|
return {};
|
|
12
12
|
};
|
|
13
|
-
const blobsPresent =
|
|
14
|
-
return await anyBlobsToUpload({ buildDir, publishDir: PUBLISH_DIR });
|
|
15
|
-
};
|
|
13
|
+
const blobsPresent = ({ buildDir, packagePath }) => anyBlobsToUpload(buildDir, packagePath);
|
|
16
14
|
export const preCleanup = {
|
|
17
15
|
event: 'onPreBuild',
|
|
18
16
|
coreStep,
|
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
buildDir: string;
|
|
4
|
-
logs: any;
|
|
5
|
-
};
|
|
6
|
-
export declare const preDevCleanup: {
|
|
7
|
-
event: string;
|
|
8
|
-
coreStep: (input: Input) => Promise<{}>;
|
|
9
|
-
coreStepId: string;
|
|
10
|
-
coreStepName: string;
|
|
11
|
-
coreStepDescription: () => string;
|
|
12
|
-
condition: (input: Input) => Promise<boolean>;
|
|
13
|
-
};
|
|
14
|
-
export {};
|
|
1
|
+
import { CoreStep } from '../types.js';
|
|
2
|
+
export declare const preDevCleanup: CoreStep;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rm, stat } from 'node:fs/promises';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { log } from '../../log/logger.js';
|
|
4
|
-
const dirExists = async
|
|
4
|
+
const dirExists = async (path) => {
|
|
5
5
|
try {
|
|
6
6
|
await stat(path);
|
|
7
7
|
return true;
|
|
@@ -20,10 +20,6 @@ const getDirtyDirs = async function ({ buildDir, constants: { INTERNAL_EDGE_FUNC
|
|
|
20
20
|
}
|
|
21
21
|
return dirs;
|
|
22
22
|
};
|
|
23
|
-
const condition = async (input) => {
|
|
24
|
-
const dirs = await getDirtyDirs(input);
|
|
25
|
-
return dirs.length > 0;
|
|
26
|
-
};
|
|
27
23
|
const coreStep = async (input) => {
|
|
28
24
|
const dirs = await getDirtyDirs(input);
|
|
29
25
|
for (const dir of dirs) {
|
|
@@ -32,6 +28,10 @@ const coreStep = async (input) => {
|
|
|
32
28
|
log(input.logs, `Cleaned up ${dirs.join(', ')}.`);
|
|
33
29
|
return {};
|
|
34
30
|
};
|
|
31
|
+
const condition = async (input) => {
|
|
32
|
+
const dirs = await getDirtyDirs(input);
|
|
33
|
+
return dirs.length > 0;
|
|
34
|
+
};
|
|
35
35
|
export const preDevCleanup = {
|
|
36
36
|
event: 'onPreDev',
|
|
37
37
|
coreStep,
|
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
coreStep: ({ buildDir, logs, netlifyConfig, explicitSecretKeys, systemLog }: {
|
|
4
|
-
buildDir: any;
|
|
5
|
-
logs: any;
|
|
6
|
-
netlifyConfig: any;
|
|
7
|
-
explicitSecretKeys: any;
|
|
8
|
-
systemLog: any;
|
|
9
|
-
}) => Promise<{}>;
|
|
10
|
-
coreStepId: string;
|
|
11
|
-
coreStepName: string;
|
|
12
|
-
coreStepDescription: () => string;
|
|
13
|
-
condition: ({ explicitSecretKeys }: {
|
|
14
|
-
explicitSecretKeys: any;
|
|
15
|
-
}) => boolean;
|
|
16
|
-
};
|
|
1
|
+
import { CoreStep } from '../types.js';
|
|
2
|
+
export declare const scanForSecrets: CoreStep;
|
|
@@ -8,7 +8,7 @@ const coreStep = async function ({ buildDir, logs, netlifyConfig, explicitSecret
|
|
|
8
8
|
const stepResults = {};
|
|
9
9
|
const passedSecretKeys = (explicitSecretKeys || '').split(',');
|
|
10
10
|
const envVars = netlifyConfig.build.environment;
|
|
11
|
-
systemLog({ passedSecretKeys, buildDir });
|
|
11
|
+
systemLog?.({ passedSecretKeys, buildDir });
|
|
12
12
|
if (!isSecretsScanningEnabled(envVars)) {
|
|
13
13
|
logSecretsScanSkipMessage(logs, 'Secrets scanning disabled via SECRETS_SCAN_ENABLED flag set to false.');
|
|
14
14
|
return stepResults;
|
|
@@ -47,7 +47,7 @@ const coreStep = async function ({ buildDir, logs, netlifyConfig, explicitSecret
|
|
|
47
47
|
secretsFilesCount: scanResults.scannedFilesCount,
|
|
48
48
|
keysToSearchFor,
|
|
49
49
|
};
|
|
50
|
-
systemLog(attributesForLogsAndSpan);
|
|
50
|
+
systemLog?.(attributesForLogsAndSpan);
|
|
51
51
|
span.setAttributes(attributesForLogsAndSpan);
|
|
52
52
|
span.end();
|
|
53
53
|
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NetlifyPluginConstants } from '../core/constants.js';
|
|
2
|
+
import { BufferedLogs } from '../log/logger.js';
|
|
3
|
+
import { NetlifyConfig } from '../types/config/netlify_config.js';
|
|
4
|
+
type $TSFixme = any;
|
|
5
|
+
export type CoreStepFunctionArgs = {
|
|
6
|
+
/**
|
|
7
|
+
* The absolute process working directory of a build
|
|
8
|
+
*/
|
|
9
|
+
buildDir: string;
|
|
10
|
+
/**
|
|
11
|
+
* the directory inside a mono repository where it collects the settings from.
|
|
12
|
+
* This is the value of the package directory field of the build settings
|
|
13
|
+
* `undefined` if none is set.
|
|
14
|
+
*/
|
|
15
|
+
packagePath?: string;
|
|
16
|
+
deployId?: string;
|
|
17
|
+
saveConfig: boolean;
|
|
18
|
+
constants: NetlifyPluginConstants;
|
|
19
|
+
quiet?: boolean;
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
logs?: BufferedLogs;
|
|
22
|
+
systemLog?: (message: unknown) => void;
|
|
23
|
+
edgeFunctionsBootstrapURL?: string;
|
|
24
|
+
featureFlags?: Record<string, any>;
|
|
25
|
+
netlifyConfig: NetlifyConfig;
|
|
26
|
+
explicitSecretKeys: $TSFixme;
|
|
27
|
+
buildbotServerSocket: $TSFixme;
|
|
28
|
+
};
|
|
29
|
+
export type CoreStepFunction = (args: CoreStepFunctionArgs) => Promise<object>;
|
|
30
|
+
export type CoreStepCondition = (args: CoreStepFunctionArgs) => Promise<boolean> | boolean;
|
|
31
|
+
type Event = 'onPreBuild' | 'onBuild' | 'onPostBuild' | 'onPreDev' | 'onDev' | 'onPostDev';
|
|
32
|
+
export type CoreStep = {
|
|
33
|
+
event: Event;
|
|
34
|
+
coreStep: CoreStepFunction;
|
|
35
|
+
coreStepId: string;
|
|
36
|
+
coreStepName: string;
|
|
37
|
+
coreStepDescription: () => string;
|
|
38
|
+
condition: CoreStepCondition;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/steps/get.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const getSteps: (steps: any, eventHandlers?: any[]) => {
|
|
2
2
|
steps: any;
|
|
3
|
-
events:
|
|
3
|
+
events: unknown[];
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export declare const getDevSteps: (command: any, steps: any, eventHandlers?: any[]) => {
|
|
6
6
|
steps: any;
|
|
7
|
-
events:
|
|
7
|
+
events: unknown[];
|
|
8
8
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface Build {
|
|
2
|
+
/**
|
|
3
|
+
* Includes a site's [build command](https://docs.netlify.com/configure-builds/get-started/#definitions)
|
|
4
|
+
*/
|
|
5
|
+
command?: string;
|
|
6
|
+
/**
|
|
7
|
+
* the path to your static content folder
|
|
8
|
+
*/
|
|
9
|
+
publish: string;
|
|
10
|
+
base: string;
|
|
11
|
+
services: Record<string, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Allows specifying a Bash command that will be run from the base directory to determine whether the site needs rebuilding or not.
|
|
14
|
+
* Check out our [ignore builds](https://docs.netlify.com/configure-builds/common-configurations/ignore-builds/) doc for more information on the default ignore behavior and details about constructing a custom ignore command.
|
|
15
|
+
*/
|
|
16
|
+
ignore?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Includes the path to a site's [Edge Handlers directory](https://docs.netlify.com/edge-handlers/configure-and-build/#choose-an-edge-handlers-directory)
|
|
19
|
+
*/
|
|
20
|
+
edge_handlers?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Contains a site's [environment variables](https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables)
|
|
23
|
+
*/
|
|
24
|
+
environment: Partial<Record<string, string>>;
|
|
25
|
+
/**
|
|
26
|
+
* Includes options for [post processing](https://docs.netlify.com/configure-builds/file-based-configuration/#post-processing) HTML, CSS, JavaScript, and images
|
|
27
|
+
*/
|
|
28
|
+
processing: {
|
|
29
|
+
skip_processing?: boolean;
|
|
30
|
+
css: {
|
|
31
|
+
bundle?: boolean;
|
|
32
|
+
minify?: boolean;
|
|
33
|
+
};
|
|
34
|
+
js: {
|
|
35
|
+
bundle?: boolean;
|
|
36
|
+
minify?: boolean;
|
|
37
|
+
};
|
|
38
|
+
html: {
|
|
39
|
+
pretty_url?: boolean;
|
|
40
|
+
};
|
|
41
|
+
images: {
|
|
42
|
+
compress?: boolean;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type GlobPattern = string;
|
|
2
|
+
type FunctionsObject = {
|
|
3
|
+
/**
|
|
4
|
+
* a list of additional paths to include in the function bundle. Although our build system includes statically referenced files (like `import * from "./some-file.js"`) by default, `included_files` lets you specify additional files or directories and reference them dynamically in function code. You can use `*` to match any character or prefix an entry with `!` to exclude files. Paths are relative to the [base directory](https://docs.netlify.com/configure-builds/get-started/#definitions-1).
|
|
5
|
+
*/
|
|
6
|
+
included_files?: string[];
|
|
7
|
+
} & ({
|
|
8
|
+
/**
|
|
9
|
+
* the function bundling method used in [`@netlify/zip-it-and-ship-it`](https://github.com/netlify/zip-it-and-ship-it).
|
|
10
|
+
*/
|
|
11
|
+
node_bundler?: 'zisi' | 'nft';
|
|
12
|
+
} | {
|
|
13
|
+
/**
|
|
14
|
+
* the function bundling method used in [`@netlify/zip-it-and-ship-it`](https://github.com/netlify/zip-it-and-ship-it).
|
|
15
|
+
*/
|
|
16
|
+
node_bundler?: 'esbuild' | 'none';
|
|
17
|
+
/**
|
|
18
|
+
* a list of Node.js modules that are copied to the bundled artifact without adjusting their source or references during the bundling process.
|
|
19
|
+
* This property helps handle dependencies that can’t be inlined, such as modules with native add-ons.
|
|
20
|
+
*/
|
|
21
|
+
external_node_modules?: string[];
|
|
22
|
+
ignored_node_modules?: string[];
|
|
23
|
+
});
|
|
24
|
+
export type Functions = {
|
|
25
|
+
'*': FunctionsObject & {
|
|
26
|
+
deno_import_map?: string;
|
|
27
|
+
};
|
|
28
|
+
[pattern: GlobPattern]: FunctionsObject;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Many } from '../utils/many.js';
|
|
2
|
+
import type { Build } from './build.js';
|
|
3
|
+
import type { Functions } from './functions.js';
|
|
4
|
+
import type { PluginInputs } from './inputs.js';
|
|
5
|
+
type HttpStatusCode = number;
|
|
6
|
+
interface Redirect {
|
|
7
|
+
from: string;
|
|
8
|
+
to?: string;
|
|
9
|
+
status?: HttpStatusCode;
|
|
10
|
+
force?: boolean;
|
|
11
|
+
signed?: string;
|
|
12
|
+
query?: Partial<Record<string, string>>;
|
|
13
|
+
headers?: Partial<Record<string, string>>;
|
|
14
|
+
conditions?: Partial<Record<'Language' | 'Role' | 'Country' | 'Cookie', readonly string[]>>;
|
|
15
|
+
}
|
|
16
|
+
interface Header {
|
|
17
|
+
for: string;
|
|
18
|
+
values: Partial<Record<string, Many<string, 'mutable'>>>;
|
|
19
|
+
}
|
|
20
|
+
interface EdgeFunction {
|
|
21
|
+
path?: `/${string}`;
|
|
22
|
+
function: string;
|
|
23
|
+
}
|
|
24
|
+
interface NetlifyPlugin {
|
|
25
|
+
package: string;
|
|
26
|
+
inputs: PluginInputs;
|
|
27
|
+
}
|
|
28
|
+
interface ImagesConfig {
|
|
29
|
+
remote_images: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface NetlifyConfig {
|
|
32
|
+
/**
|
|
33
|
+
* array of redirects with their modifiable options
|
|
34
|
+
*/
|
|
35
|
+
redirects: Redirect[];
|
|
36
|
+
/**
|
|
37
|
+
* array of headers with their modifiable options
|
|
38
|
+
*/
|
|
39
|
+
headers: Header[];
|
|
40
|
+
/**
|
|
41
|
+
* array of Edge Functions with their modifiable options
|
|
42
|
+
*/
|
|
43
|
+
edge_functions: EdgeFunction[];
|
|
44
|
+
/**
|
|
45
|
+
* object with options for modifying [functions](https://docs.netlify.com/configure-builds/file-based-configuration/#functions)
|
|
46
|
+
*/
|
|
47
|
+
functions: Functions;
|
|
48
|
+
build: Build;
|
|
49
|
+
plugins: readonly NetlifyPlugin[];
|
|
50
|
+
/**
|
|
51
|
+
* object with options for image transforms
|
|
52
|
+
*/
|
|
53
|
+
images: ImagesConfig;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PluginInputs, StringKeys } from './config/inputs.js';
|
|
2
|
+
import type { NetlifyPluginOptions } from './netlify_plugin_options.js';
|
|
3
|
+
interface NetlifyEventHandler<PluginOptions extends NetlifyPluginOptions = NetlifyPluginOptions> {
|
|
4
|
+
(options: PluginOptions): void | Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export type OnPreBuild<TInputs extends PluginInputs<StringKeys<TInputs>> = PluginInputs> = NetlifyEventHandler<NetlifyPluginOptions<TInputs>>;
|
|
7
|
+
export type OnBuild<TInputs extends PluginInputs<StringKeys<TInputs>> = PluginInputs> = NetlifyEventHandler<NetlifyPluginOptions<TInputs>>;
|
|
8
|
+
export type OnPostBuild<TInputs extends PluginInputs<StringKeys<TInputs>> = PluginInputs> = NetlifyEventHandler<NetlifyPluginOptions<TInputs>>;
|
|
9
|
+
export type OnError<TInputs extends PluginInputs<StringKeys<TInputs>> = PluginInputs> = NetlifyEventHandler<NetlifyPluginOptions<TInputs> & {
|
|
10
|
+
error: Error;
|
|
11
|
+
}>;
|
|
12
|
+
export type OnSuccess<TInputs extends PluginInputs<StringKeys<TInputs>> = PluginInputs> = NetlifyEventHandler<NetlifyPluginOptions<TInputs>>;
|
|
13
|
+
export type OnEnd<TInputs extends PluginInputs<StringKeys<TInputs>> = PluginInputs> = NetlifyEventHandler<NetlifyPluginOptions<TInputs> & {
|
|
14
|
+
error?: Error;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PluginInputs } from './config/inputs.js';
|
|
2
|
+
import type { OnBuild, OnEnd, OnError, OnPostBuild, OnPreBuild, OnSuccess } from './netlify_event_handler.js';
|
|
3
|
+
export interface NetlifyPlugin<TInputs extends PluginInputs = PluginInputs> {
|
|
4
|
+
/**
|
|
5
|
+
* Runs before the build command is executed.
|
|
6
|
+
*/
|
|
7
|
+
onPreBuild?: OnPreBuild<TInputs>;
|
|
8
|
+
/**
|
|
9
|
+
* runs directly after the build command is executed and before Functions? bundling and Edge Handlers bundling.
|
|
10
|
+
*/
|
|
11
|
+
onBuild?: OnBuild<TInputs>;
|
|
12
|
+
/**
|
|
13
|
+
* runs after the build command completes; after onBuild? tasks, Functions? bundling, and Edge Handlers bundling are executed; and before the deploy stage. Can be used to prevent a build from being deployed.
|
|
14
|
+
*/
|
|
15
|
+
onPostBuild?: OnPostBuild<TInputs>;
|
|
16
|
+
/**
|
|
17
|
+
* runs when an error occurs in the build or deploy stage, failing the build. Can’t be used to prevent a build from being deployed.
|
|
18
|
+
*/
|
|
19
|
+
onError?: OnError<TInputs>;
|
|
20
|
+
/**
|
|
21
|
+
* runs when the deploy succeeds. Can’t be used to prevent a build from being deployed.
|
|
22
|
+
*/
|
|
23
|
+
onSuccess?: OnSuccess<TInputs>;
|
|
24
|
+
/**
|
|
25
|
+
* runs after completion of the deploy stage, regardless of build error or success; is useful for resources cleanup. Can’t be used to prevent a build from being deployed.
|
|
26
|
+
*/
|
|
27
|
+
onEnd?: OnEnd<TInputs>;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|