netlify-cli 17.27.0 → 17.29.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.
- package/dist/commands/base-command.d.ts +3 -1
- package/dist/commands/base-command.d.ts.map +1 -1
- package/dist/commands/base-command.js +25 -9
- package/dist/commands/dev/dev.d.ts.map +1 -1
- package/dist/commands/dev/dev.js +0 -1
- package/dist/commands/serve/serve.js +1 -1
- package/dist/lib/functions/netlify-function.d.ts.map +1 -1
- package/dist/lib/functions/netlify-function.js +23 -11
- package/dist/lib/functions/runtimes/js/builders/zisi.d.ts +1 -0
- package/dist/lib/functions/runtimes/js/builders/zisi.d.ts.map +1 -1
- package/dist/lib/functions/runtimes/js/builders/zisi.js +12 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/deploy/hash-fns.d.ts +2 -1
- package/dist/utils/deploy/hash-fns.d.ts.map +1 -1
- package/dist/utils/deploy/hash-fns.js +1 -0
- package/dist/utils/proxy.js +3 -3
- package/npm-shrinkwrap.json +1123 -861
- package/package.json +6 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Project } from '@netlify/build-info';
|
|
2
2
|
import { resolveConfig } from '@netlify/config';
|
|
3
3
|
import { Command, Help } from 'commander';
|
|
4
|
+
import { FeatureFlags } from '../utils/feature-flags.js';
|
|
4
5
|
import { type NetlifyOptions } from './types.js';
|
|
5
6
|
type Analytics = {
|
|
6
7
|
startTime: bigint;
|
|
@@ -26,6 +27,8 @@ export default class BaseCommand extends Command {
|
|
|
26
27
|
jsWorkspaceRoot?: string;
|
|
27
28
|
/** The current workspace package we should execute the commands in */
|
|
28
29
|
workspacePackage?: string;
|
|
30
|
+
featureFlags: FeatureFlags;
|
|
31
|
+
siteId?: string;
|
|
29
32
|
/**
|
|
30
33
|
* IMPORTANT this function will be called for each command!
|
|
31
34
|
* Don't do anything expensive in there.
|
|
@@ -53,7 +56,6 @@ export default class BaseCommand extends Command {
|
|
|
53
56
|
getConfig(config: {
|
|
54
57
|
cwd: string;
|
|
55
58
|
token?: string | null;
|
|
56
|
-
state?: any;
|
|
57
59
|
offline?: boolean;
|
|
58
60
|
/** An optional path to the netlify configuration file e.g. netlify.toml */
|
|
59
61
|
configFilePath?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-command.d.ts","sourceRoot":"","sources":["../../src/commands/base-command.ts"],"names":[],"mappings":"AAOA,OAAO,EAAiB,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAU,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"base-command.d.ts","sourceRoot":"","sources":["../../src/commands/base-command.ts"],"names":[],"mappings":"AAOA,OAAO,EAAiB,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAU,MAAM,WAAW,CAAA;AA0BjD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAOxD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,KAAK,SAAS,GAAG;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC,CAAA;AAuGD,0EAA0E;AAC1E,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAAO;;IAC9C,4DAA4D;IAE5D,OAAO,EAAE,cAAc,CAAA;IACvB,SAAS,EAAE,SAAS,CAAyC;IAE7D,OAAO,EAAE,OAAO,CAAA;IAEhB;;;;OAIG;IAGH,UAAU,SAAgB;IAE1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,MAAM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
|
|
@@ -53,6 +53,10 @@ const HELP_SEPARATOR_WIDTH = 5;
|
|
|
53
53
|
* workspace aware.
|
|
54
54
|
*/
|
|
55
55
|
const COMMANDS_WITHOUT_WORKSPACE_OPTIONS = new Set(['api', 'recipes', 'completion', 'status', 'switch', 'login', 'lm']);
|
|
56
|
+
/**
|
|
57
|
+
* A list of commands where we need to fetch featureflags for config resolution
|
|
58
|
+
*/
|
|
59
|
+
const COMMANDS_WITH_FEATURE_FLAGS = new Set(['build', 'dev', 'deploy']);
|
|
56
60
|
/** Formats a help list correctly with the correct indent */
|
|
57
61
|
const formatHelpList = (textArray) => textArray.join('\n').replace(/^/gm, ' '.repeat(HELP_INDENT_WIDTH));
|
|
58
62
|
/** Get the duration between a start time and the current time */
|
|
@@ -121,6 +125,7 @@ class BaseCommand extends Command {
|
|
|
121
125
|
// here we actually want to disable the lint rule as its value is set
|
|
122
126
|
// eslint-disable-next-line workspace/no-process-cwd
|
|
123
127
|
this.workingDir = process.cwd();
|
|
128
|
+
this.featureFlags = {};
|
|
124
129
|
_BaseCommand_noBaseOptions.set(this, false
|
|
125
130
|
/** don't show help options on command overview (mostly used on top commands like `addons` where options only apply on children) */
|
|
126
131
|
);
|
|
@@ -431,6 +436,24 @@ class BaseCommand extends Command {
|
|
|
431
436
|
apiUrlOpts.pathPrefix =
|
|
432
437
|
process.env.NETLIFY_API_URL === `${apiUrl.protocol}//${apiUrl.host}` ? '/api/v1' : apiUrl.pathname;
|
|
433
438
|
}
|
|
439
|
+
const agent = await getAgent({
|
|
440
|
+
httpProxy: flags.httpProxy,
|
|
441
|
+
certificateFile: flags.httpProxyCertificateFilename,
|
|
442
|
+
});
|
|
443
|
+
const apiOpts = { ...apiUrlOpts, agent };
|
|
444
|
+
// TODO: remove typecast once we have proper types for the API
|
|
445
|
+
const api = new NetlifyAPI(token || '', apiOpts);
|
|
446
|
+
actionCommand.siteId = flags.siteId || (typeof flags.site === 'string' && flags.site) || state.get('siteId');
|
|
447
|
+
const needsFeatureFlagsToResolveConfig = COMMANDS_WITH_FEATURE_FLAGS.has(actionCommand.name());
|
|
448
|
+
if (api.accessToken && !flags.offline && needsFeatureFlagsToResolveConfig && actionCommand.siteId) {
|
|
449
|
+
try {
|
|
450
|
+
const site = await api.getSite({ siteId: actionCommand.siteId, feature_flags: 'cli' });
|
|
451
|
+
actionCommand.featureFlags = site.feature_flags;
|
|
452
|
+
}
|
|
453
|
+
catch {
|
|
454
|
+
// if the site is not found, that could mean that the user passed a site name, not an ID
|
|
455
|
+
}
|
|
456
|
+
}
|
|
434
457
|
// ==================================================
|
|
435
458
|
// Start retrieving the configuration through the
|
|
436
459
|
// configuration file and the API
|
|
@@ -441,20 +464,12 @@ class BaseCommand extends Command {
|
|
|
441
464
|
packagePath: this.workspacePackage,
|
|
442
465
|
// The config flag needs to be resolved from the actual process working directory
|
|
443
466
|
configFilePath: packageConfig,
|
|
444
|
-
state,
|
|
445
467
|
token,
|
|
446
468
|
...apiUrlOpts,
|
|
447
469
|
});
|
|
448
470
|
const { buildDir, config, configPath, env, repositoryRoot, siteInfo } = cachedConfig;
|
|
449
471
|
env.NETLIFY_CLI_VERSION = { sources: ['internal'], value: version };
|
|
450
472
|
const normalizedConfig = normalizeConfig(config);
|
|
451
|
-
const agent = await getAgent({
|
|
452
|
-
httpProxy: flags.httpProxy,
|
|
453
|
-
certificateFile: flags.httpProxyCertificateFilename,
|
|
454
|
-
});
|
|
455
|
-
const apiOpts = { ...apiUrlOpts, agent };
|
|
456
|
-
// TODO: remove typecast once we have proper types for the API
|
|
457
|
-
const api = new NetlifyAPI(token || '', apiOpts);
|
|
458
473
|
// If a user passes a site name as an option instead of a site ID to options.site, the siteInfo object
|
|
459
474
|
// will only have the property siteInfo.id. Checking for one of the other properties ensures that we can do
|
|
460
475
|
// a re-call of the api.getSite() that is done in @netlify/config so we have the proper site object in all
|
|
@@ -531,7 +546,7 @@ class BaseCommand extends Command {
|
|
|
531
546
|
cwd: config.cwd,
|
|
532
547
|
context: flags.context || process.env.CONTEXT || this.getDefaultContext(),
|
|
533
548
|
debug: flags.debug,
|
|
534
|
-
siteId:
|
|
549
|
+
siteId: this.siteId,
|
|
535
550
|
token: config.token,
|
|
536
551
|
mode: 'cli',
|
|
537
552
|
host: config.host,
|
|
@@ -539,6 +554,7 @@ class BaseCommand extends Command {
|
|
|
539
554
|
scheme: config.scheme,
|
|
540
555
|
offline: config.offline ?? flags.offline,
|
|
541
556
|
siteFeatureFlagPrefix: 'cli',
|
|
557
|
+
featureFlags: this.featureFlags,
|
|
542
558
|
});
|
|
543
559
|
}
|
|
544
560
|
catch (error_) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/dev.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,YAAY,EAAE,MAAM,WAAW,CAAA;AA0BhD,OAAO,WAAW,MAAM,oBAAoB,CAAA;AA4D5C,eAAO,MAAM,GAAG,YAAmB,YAAY,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/dev.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,YAAY,EAAE,MAAM,WAAW,CAAA;AA0BhD,OAAO,WAAW,MAAM,oBAAoB,CAAA;AA4D5C,eAAO,MAAM,GAAG,YAAmB,YAAY,WAAW,WAAW,kBA8JpE,CAAA;AAED,eAAO,MAAM,gBAAgB,YAAa,WAAW,gBA8GpD,CAAA"}
|
package/dist/commands/dev/dev.js
CHANGED
|
@@ -164,7 +164,6 @@ export const dev = async (options, command) => {
|
|
|
164
164
|
const { config: newConfig } = await command.getConfig({
|
|
165
165
|
cwd: command.workingDir,
|
|
166
166
|
offline: true,
|
|
167
|
-
state,
|
|
168
167
|
});
|
|
169
168
|
const normalizedNewConfig = normalizeConfig(newConfig);
|
|
170
169
|
return normalizedNewConfig;
|
|
@@ -109,7 +109,7 @@ export const serve = async (options, command) => {
|
|
|
109
109
|
}
|
|
110
110
|
// TODO: We should consolidate this with the existing config watcher.
|
|
111
111
|
const getUpdatedConfig = async () => {
|
|
112
|
-
const { config: newConfig } = await command.getConfig({ cwd: command.workingDir, offline: true
|
|
112
|
+
const { config: newConfig } = await command.getConfig({ cwd: command.workingDir, offline: true });
|
|
113
113
|
const normalizedNewConfig = normalizeConfig(newConfig);
|
|
114
114
|
return normalizedNewConfig;
|
|
115
115
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netlify-function.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/netlify-function.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"netlify-function.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/netlify-function.ts"],"names":[],"mappings":"AA4BA,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B,SAAgB,QAAQ,EAAE,MAAM,CAAA;IAChC,SAAgB,WAAW,EAAE,MAAM,CAAA;IACnC,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjC,SAAgB,OAAO,EAAE,MAAM,CAAA;IAE/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IACpC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;IACzD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAQ;IAI3C,SAAgB,YAAY,EAAE,OAAO,CAAA;IAErC,OAAO,CAAC,UAAU,CAAC,CAAiB;IACpC,OAAO,CAAC,SAAS,CAAC,CAAQ;IACnB,UAAU,EAAE,KAAK,GAAG,IAAI,CAAO;IAItC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;gBAEjC,EAEV,YAAY,EAEZ,MAAM,EAEN,SAAS,EAET,WAAW,EAEX,QAAQ,EAER,IAAI,EAEJ,WAAW,EAEX,OAAO,EAEP,QAAQ,EAER,iBAAiB,EAEjB,kBAAkB,GACnB;;;;;;;;;;;;KAAA;IAuBD,IAAI,QAAQ,kBAMX;IAED,uBAAuB;IAqBvB,YAAY;IAMN,WAAW;IAMjB,WAAW;IAIX,YAAY;IAQN,UAAU;IAeV,KAAK,CAAC,EAAE,KAAK,EAAE;;KAAA;;;;;;;;;;;;IA2Cf,YAAY;IAQlB,eAAe,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC;;;;IAWlC,MAAM,CAAC,KAAK,KAAK,EAAE,OAAO,KAAK;;;;;;;IAgCrC;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC;IAqDzF,IAAI,iBAAiB,QAEpB;IAED,IAAI,GAAG,WAWN;CACF"}
|
|
@@ -198,28 +198,40 @@ export default class NetlifyFunction {
|
|
|
198
198
|
await this.buildQueue;
|
|
199
199
|
let path = rawPath !== '/' && rawPath.endsWith('/') ? rawPath.slice(0, -1) : rawPath;
|
|
200
200
|
path = path.toLowerCase();
|
|
201
|
-
const { routes = [] } = this.buildData ?? {};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (methods.length !== 0 && !methods.includes(method)) {
|
|
201
|
+
const { excludedRoutes = [], routes = [] } = this.buildData ?? {};
|
|
202
|
+
const matchingRoute = routes.find((route) => {
|
|
203
|
+
if (route.methods && route.methods.length !== 0 && !route.methods.includes(method)) {
|
|
205
204
|
return false;
|
|
206
205
|
}
|
|
207
|
-
if (literal !== undefined) {
|
|
208
|
-
return path === literal;
|
|
206
|
+
if ('literal' in route && route.literal !== undefined) {
|
|
207
|
+
return path === route.literal;
|
|
209
208
|
}
|
|
210
|
-
if (expression !== undefined) {
|
|
211
|
-
const regex = new RegExp(expression);
|
|
209
|
+
if ('expression' in route && route.expression !== undefined) {
|
|
210
|
+
const regex = new RegExp(route.expression);
|
|
212
211
|
return regex.test(path);
|
|
213
212
|
}
|
|
214
213
|
return false;
|
|
215
214
|
});
|
|
216
|
-
if (!
|
|
215
|
+
if (!matchingRoute) {
|
|
217
216
|
return;
|
|
218
217
|
}
|
|
219
|
-
|
|
218
|
+
const isExcluded = excludedRoutes.some((excludedRoute) => {
|
|
219
|
+
if ('literal' in excludedRoute && excludedRoute.literal !== undefined) {
|
|
220
|
+
return path === excludedRoute.literal;
|
|
221
|
+
}
|
|
222
|
+
if ('expression' in excludedRoute && excludedRoute.expression !== undefined) {
|
|
223
|
+
const regex = new RegExp(excludedRoute.expression);
|
|
224
|
+
return regex.test(path);
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
});
|
|
228
|
+
if (isExcluded) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (matchingRoute.prefer_static && (await hasStaticFile())) {
|
|
220
232
|
return;
|
|
221
233
|
}
|
|
222
|
-
return
|
|
234
|
+
return matchingRoute;
|
|
223
235
|
}
|
|
224
236
|
get runtimeAPIVersion() {
|
|
225
237
|
return this.buildData?.runtimeAPIVersion ?? 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zisi.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/functions/runtimes/js/builders/zisi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zisi.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/functions/runtimes/js/builders/zisi.ts"],"names":[],"mappings":"AAgHA;;;;;GAKG;AAEH,eAAO,MAAM,wBAAwB;;;;+EAMjC,CAAA;AAoCJ;;;;;;;;;GASG;AAEH,wBAA8B,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE;;;;;;;CAAA;;;;;;;;;;;;;;;;GAoDlG"}
|
|
@@ -56,7 +56,7 @@ targetDirectory, }) => {
|
|
|
56
56
|
// root of the functions directory (e.g. `functions/my-func.js`). In
|
|
57
57
|
// this case, we use `mainFile` as the function path of `zipFunction`.
|
|
58
58
|
const entryPath = functionDirectory === directory ? func.mainFile : functionDirectory;
|
|
59
|
-
const { entryFilename, includedFiles, inputs, mainFile, outputModuleFormat, path: functionPath, routes, runtimeAPIVersion, schedule, } = await memoizedBuild({
|
|
59
|
+
const { entryFilename, excludedRoutes, includedFiles, inputs, mainFile, outputModuleFormat, path: functionPath, routes, runtimeAPIVersion, schedule, } = await memoizedBuild({
|
|
60
60
|
cache,
|
|
61
61
|
cacheKey: `zisi-${entryPath}`,
|
|
62
62
|
// @ts-expect-error TS(2345) FIXME: Argument of type '{ archiveFormat: string; basePat... Remove this comment to see the full error message
|
|
@@ -73,7 +73,17 @@ targetDirectory, }) => {
|
|
|
73
73
|
}));
|
|
74
74
|
}
|
|
75
75
|
clearFunctionsCache(targetDirectory);
|
|
76
|
-
return {
|
|
76
|
+
return {
|
|
77
|
+
buildPath,
|
|
78
|
+
excludedRoutes,
|
|
79
|
+
includedFiles,
|
|
80
|
+
outputModuleFormat,
|
|
81
|
+
mainFile,
|
|
82
|
+
routes,
|
|
83
|
+
runtimeAPIVersion,
|
|
84
|
+
srcFiles,
|
|
85
|
+
schedule,
|
|
86
|
+
};
|
|
77
87
|
};
|
|
78
88
|
/**
|
|
79
89
|
* @param {object} params
|