@netlify/config 21.0.4 → 21.0.5

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.
@@ -75,7 +75,11 @@ const getIntegrations = async function ({ siteId, accountId, testOpts, offline,
75
75
  return [];
76
76
  }
77
77
  const sendBuildBotTokenToJigsaw = featureFlags?.send_build_bot_token_to_jigsaw;
78
- const { host } = testOpts;
78
+ const { host, setBaseUrl } = testOpts;
79
+ // We only use this for testing
80
+ if (host && setBaseUrl) {
81
+ setBaseUrl(extensionApiBaseUrl);
82
+ }
79
83
  const baseUrl = new URL(host ? `http://${host}` : extensionApiBaseUrl);
80
84
  // if accountId isn't present, use safe v1 endpoint
81
85
  const url = accountId
@@ -1,6 +1,9 @@
1
1
  import { IntegrationResponse } from './types/api.js';
2
2
  import { Integration } from './types/integrations.js';
3
3
  import { TestOptions } from './types/options.js';
4
+ export declare const NETLIFY_API_STAGING_BASE_URL = "api-staging.netlify.com";
5
+ export declare const EXTENSION_API_BASE_URL = "https://api.netlifysdk.com";
6
+ export declare const EXTENSION_API_STAGING_BASE_URL = "https://api-staging.netlifysdk.com";
4
7
  type MergeIntegrationsOpts = {
5
8
  configIntegrations?: {
6
9
  name: string;
@@ -1,4 +1,7 @@
1
1
  import { getAvailableIntegrations } from './api/integrations.js';
2
+ export const NETLIFY_API_STAGING_BASE_URL = 'api-staging.netlify.com';
3
+ export const EXTENSION_API_BASE_URL = 'https://api.netlifysdk.com';
4
+ export const EXTENSION_API_STAGING_BASE_URL = 'https://api-staging.netlifysdk.com';
2
5
  export const mergeIntegrations = async function ({ configIntegrations = [], apiIntegrations, context, testOpts = {}, offline, extensionApiBaseUrl, }) {
3
6
  const availableIntegrations = await getAvailableIntegrations({ testOpts, offline, extensionApiBaseUrl });
4
7
  // Include all API integrations, unless they have a `dev` property and we are in the `dev` context
@@ -23,11 +26,7 @@ export const mergeIntegrations = async function ({ configIntegrations = [], apiI
23
26
  if (!integration) {
24
27
  return undefined;
25
28
  }
26
- return {
27
- slug: integration.slug,
28
- version: integration.hostSiteUrl,
29
- has_build: !!integration.hasBuild,
30
- };
29
+ return { slug: integration.slug, version: integration.hostSiteUrl, has_build: !!integration.hasBuild };
31
30
  })
32
31
  .filter((i) => typeof i !== 'undefined');
33
32
  return [...resolvedApiIntegrations, ...resolvedConfigIntegrations];
package/lib/main.js CHANGED
@@ -9,7 +9,7 @@ import { getEnv } from './env/main.js';
9
9
  import { resolveConfigPaths } from './files.js';
10
10
  import { getHeadersPath, addHeaders } from './headers.js';
11
11
  import { getInlineConfig } from './inline_config.js';
12
- import { mergeIntegrations } from './integrations.js';
12
+ import { EXTENSION_API_BASE_URL, EXTENSION_API_STAGING_BASE_URL, mergeIntegrations, NETLIFY_API_STAGING_BASE_URL, } from './integrations.js';
13
13
  import { logResult } from './log/main.js';
14
14
  import { mergeConfigs } from './merge.js';
15
15
  import { normalizeBeforeConfigMerge, normalizeAfterConfigMerge } from './merge_normalize.js';
@@ -35,7 +35,7 @@ export const resolveConfig = async function (opts) {
35
35
  return parsedCachedConfig;
36
36
  }
37
37
  // TODO(kh): remove this mapping and get the extensionApiHost from the opts
38
- const extensionApiBaseUrl = host === 'api-staging.netlify.com' ? 'https://api-staging.netlifysdk.com' : 'https://api.netlifysdk.com';
38
+ const extensionApiBaseUrl = host === NETLIFY_API_STAGING_BASE_URL ? EXTENSION_API_STAGING_BASE_URL : EXTENSION_API_BASE_URL;
39
39
  const { config: configOpt, defaultConfig, inlineConfig, configMutations, cwd, context, repositoryRoot, base, branch, siteId, accountId, deployId, buildId, baseRelDir, mode, debug, logs, featureFlags, } = await normalizeOpts(optsA);
40
40
  let { siteInfo, accounts, addons, integrations } = parsedCachedConfig || {};
41
41
  // If we have cached site info, we don't need to fetch it again
@@ -138,13 +138,7 @@ const addLegacyFunctionsDirectory = (config) => {
138
138
  if (!config.functionsDirectory) {
139
139
  return config;
140
140
  }
141
- return {
142
- ...config,
143
- build: {
144
- ...config.build,
145
- functions: config.functionsDirectory,
146
- },
147
- };
141
+ return { ...config, build: { ...config.build, functions: config.functionsDirectory } };
148
142
  };
149
143
  /**
150
144
  * Try to load the configuration file in two passes.
@@ -202,24 +196,10 @@ const loadConfig = async function ({ configOpt, cwd, context, repositoryRoot, pa
202
196
  * Load configuration file and normalize it, merge contexts, etc.
203
197
  */
204
198
  const getFullConfig = async function ({ configOpt, cwd, context, repositoryRoot, packagePath, branch, defaultConfig, inlineConfig, baseRelDir, configBase, base, logs, featureFlags, }) {
205
- const configPath = await getConfigPath({
206
- configOpt,
207
- cwd,
208
- repositoryRoot,
209
- packagePath,
210
- configBase,
211
- });
199
+ const configPath = await getConfigPath({ configOpt, cwd, repositoryRoot, packagePath, configBase });
212
200
  try {
213
201
  const config = await parseConfig(configPath);
214
- const configA = mergeAndNormalizeConfig({
215
- config,
216
- defaultConfig,
217
- inlineConfig,
218
- context,
219
- branch,
220
- logs,
221
- packagePath,
222
- });
202
+ const configA = mergeAndNormalizeConfig({ config, defaultConfig, inlineConfig, context, branch, logs, packagePath });
223
203
  const { config: configB, buildDir, base: baseA, } = await resolveFiles({ packagePath, config: configA, repositoryRoot, base, baseRelDir });
224
204
  const headersPath = getHeadersPath(configB);
225
205
  const configC = await addHeaders({ config: configB, headersPath, logs });
@@ -2,4 +2,5 @@ export type ModeOption = 'buildbot' | 'cli' | 'require';
2
2
  export type TestOptions = {
3
3
  env?: boolean;
4
4
  host?: string;
5
+ setBaseUrl?: (url: string) => void;
5
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "21.0.4",
3
+ "version": "21.0.5",
4
4
  "description": "Netlify config module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -74,7 +74,7 @@
74
74
  "is-plain-obj": "^4.0.0",
75
75
  "js-yaml": "^4.0.0",
76
76
  "map-obj": "^5.0.0",
77
- "netlify": "^13.3.3",
77
+ "netlify": "^13.3.4",
78
78
  "node-fetch": "^3.3.1",
79
79
  "omit.js": "^2.0.2",
80
80
  "p-locate": "^6.0.0",
@@ -95,5 +95,5 @@
95
95
  "engines": {
96
96
  "node": "^14.16.0 || >=16.0.0"
97
97
  },
98
- "gitHead": "61c3b009c7b1e16b32e06e1f783a5717106bae10"
98
+ "gitHead": "0e4628f57a0a7d02594b5070074445a4ff69b809"
99
99
  }