@netlify/config 23.0.11 → 23.1.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.
@@ -65,6 +65,7 @@ export async function handleAutoInstallExtensions({ featureFlags, siteId, accoun
65
65
  netlifyToken: token,
66
66
  slug: ext.slug,
67
67
  hostSiteUrl: ext.hostSiteUrl,
68
+ extensionInstallationSource: mode,
68
69
  });
69
70
  }));
70
71
  if (results.length > 0 && results.some((result) => !result.error)) {
@@ -1,3 +1,4 @@
1
+ import { ModeOption } from '../../types/options.js';
1
2
  export type InstallExtensionResult = {
2
3
  slug: string;
3
4
  error: null;
@@ -8,11 +9,12 @@ export type InstallExtensionResult = {
8
9
  message: string;
9
10
  };
10
11
  };
11
- export declare const installExtension: ({ netlifyToken, accountId, slug, hostSiteUrl, }: {
12
+ export declare const installExtension: ({ netlifyToken, accountId, slug, hostSiteUrl, extensionInstallationSource, }: {
12
13
  netlifyToken: string;
13
14
  accountId: string;
14
15
  slug: string;
15
16
  hostSiteUrl: string;
17
+ extensionInstallationSource: ModeOption;
16
18
  }) => Promise<InstallExtensionResult>;
17
19
  type AutoInstallableExtensionMeta = {
18
20
  slug: string;
@@ -1,5 +1,7 @@
1
1
  import { EXTENSION_API_BASE_URL } from '../../integrations.js';
2
- export const installExtension = async ({ netlifyToken, accountId, slug, hostSiteUrl, }) => {
2
+ import { ROOT_PACKAGE_JSON } from '../json.js';
3
+ export const installExtension = async ({ netlifyToken, accountId, slug, hostSiteUrl, extensionInstallationSource, }) => {
4
+ const userAgent = `Netlify Config (mode:${extensionInstallationSource}) / ${ROOT_PACKAGE_JSON.version}`;
3
5
  const extensionOnInstallUrl = new URL('/.netlify/functions/handler/on-install', hostSiteUrl);
4
6
  const installedResponse = await fetch(extensionOnInstallUrl, {
5
7
  method: 'POST',
@@ -8,6 +10,7 @@ export const installExtension = async ({ netlifyToken, accountId, slug, hostSite
8
10
  }),
9
11
  headers: {
10
12
  'netlify-token': netlifyToken,
13
+ 'User-Agent': userAgent,
11
14
  },
12
15
  });
13
16
  if (!installedResponse.ok && installedResponse.status !== 409) {
@@ -0,0 +1,7 @@
1
+ import type { PackageJson } from 'read-package-up';
2
+ export type RootPackageJson = {
3
+ name: string;
4
+ version: string;
5
+ };
6
+ export declare const importJsonFile: (filePath: string) => Promise<PackageJson>;
7
+ export declare const ROOT_PACKAGE_JSON: RootPackageJson;
@@ -0,0 +1,10 @@
1
+ import { readFile } from 'fs/promises';
2
+ import { fileURLToPath } from 'url';
3
+ const ROOT_PACKAGE_JSON_PATH = fileURLToPath(new URL('../../package.json', import.meta.url));
4
+ // TODO: Replace with dynamic `import()` once it is supported without
5
+ // experimental flags
6
+ export const importJsonFile = async function (filePath) {
7
+ const fileContents = await readFile(filePath, 'utf-8');
8
+ return JSON.parse(fileContents);
9
+ };
10
+ export const ROOT_PACKAGE_JSON = (await importJsonFile(ROOT_PACKAGE_JSON_PATH));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "23.0.11",
3
+ "version": "23.1.0",
4
4
  "description": "Netlify config module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -77,6 +77,7 @@
77
77
  "omit.js": "^2.0.2",
78
78
  "p-locate": "^6.0.0",
79
79
  "path-type": "^6.0.0",
80
+ "read-package-up": "^11.0.0",
80
81
  "tomlify-j0.4": "^3.0.0",
81
82
  "validate-npm-package-name": "^5.0.0",
82
83
  "yaml": "^2.8.0",
@@ -94,5 +95,5 @@
94
95
  "engines": {
95
96
  "node": ">=18.14.0"
96
97
  },
97
- "gitHead": "e663c8f1a5667e6737c689c33f7cabd6b2a98774"
98
+ "gitHead": "cc8bccf13040e0e43282845c5a3a6d17db659ce8"
98
99
  }