@netlify/config 21.0.3 → 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,11 +35,15 @@ 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
42
42
  const useCachedSiteInfo = Boolean(featureFlags?.use_cached_site_info && siteInfo && accounts && addons && integrations);
43
+ // I'm adding some debug logging to see if the logic is working as expected
44
+ if (featureFlags?.use_cached_site_info_logging) {
45
+ console.log('Checking site information', { useCachedSiteInfo, siteInfo, accounts, addons, integrations });
46
+ }
43
47
  if (!useCachedSiteInfo) {
44
48
  const updatedSiteInfo = await getSiteInfo({
45
49
  api,
@@ -134,13 +138,7 @@ const addLegacyFunctionsDirectory = (config) => {
134
138
  if (!config.functionsDirectory) {
135
139
  return config;
136
140
  }
137
- return {
138
- ...config,
139
- build: {
140
- ...config.build,
141
- functions: config.functionsDirectory,
142
- },
143
- };
141
+ return { ...config, build: { ...config.build, functions: config.functionsDirectory } };
144
142
  };
145
143
  /**
146
144
  * Try to load the configuration file in two passes.
@@ -198,24 +196,10 @@ const loadConfig = async function ({ configOpt, cwd, context, repositoryRoot, pa
198
196
  * Load configuration file and normalize it, merge contexts, etc.
199
197
  */
200
198
  const getFullConfig = async function ({ configOpt, cwd, context, repositoryRoot, packagePath, branch, defaultConfig, inlineConfig, baseRelDir, configBase, base, logs, featureFlags, }) {
201
- const configPath = await getConfigPath({
202
- configOpt,
203
- cwd,
204
- repositoryRoot,
205
- packagePath,
206
- configBase,
207
- });
199
+ const configPath = await getConfigPath({ configOpt, cwd, repositoryRoot, packagePath, configBase });
208
200
  try {
209
201
  const config = await parseConfig(configPath);
210
- const configA = mergeAndNormalizeConfig({
211
- config,
212
- defaultConfig,
213
- inlineConfig,
214
- context,
215
- branch,
216
- logs,
217
- packagePath,
218
- });
202
+ const configA = mergeAndNormalizeConfig({ config, defaultConfig, inlineConfig, context, branch, logs, packagePath });
219
203
  const { config: configB, buildDir, base: baseA, } = await resolveFiles({ packagePath, config: configA, repositoryRoot, base, baseRelDir });
220
204
  const headersPath = getHeadersPath(configB);
221
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.3",
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": "180306dc6d37736969b5fa951f8588c2c85e6109"
98
+ "gitHead": "0e4628f57a0a7d02594b5070074445a4ff69b809"
99
99
  }