netlify-cli 27.14.2 → 27.14.3

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.
@@ -5,19 +5,9 @@ import { normalizeRepoUrl } from '../../utils/normalize-repo-url.js';
5
5
  import { chalk, logAndThrowError, log, getToken, netlifyCommand } from '../../utils/command-helpers.js';
6
6
  import { runGit } from '../../utils/run-git.js';
7
7
  import execa from '../../utils/execa.js';
8
- import { NETLIFY_GIT_HOST } from '../git-credential/git-credential.js';
8
+ import { isNetlifyGitUrl, NETLIFY_GIT_HOST } from '../../utils/netlify-git.js';
9
9
  import { link } from '../link/link.js';
10
10
  import { startSpinner } from '../../lib/spinner.js';
11
- const NETLIFY_GIT_SERVICE_HOST = 'hgit.services-prod.nsvcs.net';
12
- const isNetlifyGitServiceUrl = (repoUrl) => {
13
- try {
14
- const host = new URL(repoUrl).host;
15
- return host === NETLIFY_GIT_HOST || host === NETLIFY_GIT_SERVICE_HOST;
16
- }
17
- catch {
18
- return false;
19
- }
20
- };
21
11
  const getTargetDir = async (defaultDir) => {
22
12
  return await input({
23
13
  message: 'Where should we clone the repository?',
@@ -192,7 +182,7 @@ export const clone = async (options, command, args) => {
192
182
  }
193
183
  siteSpinner.success(`Found site ${chalk.cyan(siteInfo.name)}`);
194
184
  const connectedRepoUrl = siteInfo.build_settings?.repo_url;
195
- if (connectedRepoUrl && isNetlifyGitServiceUrl(connectedRepoUrl)) {
185
+ if (connectedRepoUrl && isNetlifyGitUrl(connectedRepoUrl)) {
196
186
  log(`Site is connected to Netlify's managed git service.`);
197
187
  log(`Cloning from Netlify's managed git service...`);
198
188
  log();
@@ -19,6 +19,7 @@ import { NETLIFY_CYAN_HEX, NETLIFYDEVERR, NETLIFYDEVLOG, chalk, logAndThrowError
19
19
  import { DEFAULT_CONCURRENT_HASH, DEFAULT_DEPLOY_TIMEOUT } from '../../utils/deploy/constants.js';
20
20
  import { deploySite } from '../../utils/deploy/deploy-site.js';
21
21
  import { getDeploySourceFields } from '../../utils/deploy/deploy-source.js';
22
+ import { getDeployUrls } from '../../utils/deploy/deploy-urls.js';
22
23
  import { uploadSourceZip } from '../../utils/deploy/upload-source-zip.js';
23
24
  import { getEnvelopeEnv } from '../../utils/env/index.js';
24
25
  import { mergeDeployEnvVars } from '../../utils/env/deploy-env-vars.js';
@@ -472,24 +473,11 @@ const runDeploy = async ({ alias, api, command, config, deployFolder, deployTime
472
473
  }
473
474
  return reportDeployError({ error: error, failAndExit: logAndThrowError });
474
475
  }
475
- const siteUrl = results.deploy.ssl_url || results.deploy.url;
476
- const deployUrl = results.deploy.deploy_ssl_url || results.deploy.deploy_url;
477
- const logsUrl = `${results.deploy.admin_url}/deploys/${results.deploy.id}`;
478
- let functionLogsUrl = `${results.deploy.admin_url}/logs/functions`;
479
- let edgeFunctionLogsUrl = `${results.deploy.admin_url}/logs/edge-functions`;
480
- if (!deployToProduction) {
481
- functionLogsUrl += `?scope=deploy:${deployId}`;
482
- edgeFunctionLogsUrl += `?scope=deployid:${deployId}`;
483
- }
484
476
  return {
485
477
  siteId: results.deploy.site_id,
486
478
  siteName: results.deploy.name,
487
479
  deployId: results.deployId,
488
- siteUrl,
489
- deployUrl,
490
- logsUrl,
491
- functionLogsUrl,
492
- edgeFunctionLogsUrl,
480
+ ...getDeployUrls(results.deploy, { deployToProduction }),
493
481
  sourceZipFileName: uploadSourceZipResult?.sourceZipFileName,
494
482
  };
495
483
  };
@@ -1,6 +1,5 @@
1
1
  import type { Readable, Writable } from 'stream';
2
2
  import type { GitCredentialOptionValues } from './option_values.js';
3
- export declare const NETLIFY_GIT_HOST = "git.netlify.com";
4
3
  export declare const parseGitCredentialInput: (input: Readable) => Promise<Partial<Record<string, string>>>;
5
4
  export declare const writeCredentials: (output: Writable, token: string) => void;
6
5
  export declare const gitCredential: (operation: string, _options: GitCredentialOptionValues) => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import process from 'process';
2
2
  import readline from 'readline';
3
3
  import { getToken } from '../../utils/command-helpers.js';
4
- export const NETLIFY_GIT_HOST = 'git.netlify.com';
4
+ import { NETLIFY_GIT_HOST } from '../../utils/netlify-git.js';
5
5
  export const parseGitCredentialInput = async (input) => {
6
6
  const rl = readline.createInterface({
7
7
  input,
@@ -1,6 +1,7 @@
1
1
  import { select } from '@inquirer/prompts';
2
2
  import { log, chalk } from '../../utils/command-helpers.js';
3
3
  import { getWebSocket } from '../../utils/websockets/index.js';
4
+ import { SOCKETEER_URL } from '../../utils/socketeer.js';
4
5
  export function getName({ deploy, userId }) {
5
6
  let normalisedName = '';
6
7
  const isUserDeploy = deploy.user_id === userId;
@@ -51,7 +52,7 @@ export const logsBuild = async (_options, command) => {
51
52
  deploy = deploys.find((dep) => dep.id === result) || deploy;
52
53
  }
53
54
  const { id } = deploy;
54
- const ws = getWebSocket(`wss://socketeer.services.netlify.com/build/logs`);
55
+ const ws = getWebSocket(`${SOCKETEER_URL}/build/logs`);
55
56
  ws.on('open', function open() {
56
57
  ws.send(JSON.stringify({ deploy_id: id, site_id: siteId, access_token: client.accessToken }));
57
58
  });
@@ -1,4 +1,5 @@
1
1
  import { getWebSocket } from '../../../utils/websockets/index.js';
2
+ import { SOCKETEER_URL } from '../../../utils/socketeer.js';
2
3
  const DEPLOY_LOG_REPLAY_TIMEOUT_MS = 30_000;
3
4
  const DEPLOY_STREAM_START_TIMEOUT_MS = 20_000;
4
5
  const parseDeployLogTimestamp = (message) => {
@@ -29,7 +30,7 @@ const parseDeployLogMessage = (data) => {
29
30
  };
30
31
  export const fetchDeployHistoricalLogs = async ({ siteId, accessToken, deployId, from, to, }) => {
31
32
  const collected = [];
32
- const ws = getWebSocket('wss://socketeer.services.netlify.com/build/logs');
33
+ const ws = getWebSocket(`${SOCKETEER_URL}/build/logs`);
33
34
  await new Promise((resolve, reject) => {
34
35
  let settled = false;
35
36
  const finish = (error) => {
@@ -84,7 +85,7 @@ export const fetchDeployHistoricalLogs = async ({ siteId, accessToken, deployId,
84
85
  .sort((a, b) => a.ts - b.ts);
85
86
  };
86
87
  export const streamDeploy = (siteId, deployId, accessToken, onEntry, onClose, { closeWhenIdleMs } = {}) => {
87
- const ws = getWebSocket('wss://socketeer.services.netlify.com/build/logs');
88
+ const ws = getWebSocket(`${SOCKETEER_URL}/build/logs`);
88
89
  let closeTimer;
89
90
  const scheduleClose = (ms) => {
90
91
  clearTimeout(closeTimer);
@@ -1,4 +1,5 @@
1
1
  import { getWebSocket } from '../../../utils/websockets/index.js';
2
+ import { SOCKETEER_URL } from '../../../utils/socketeer.js';
2
3
  import { buildEdgeFunctionLogsUrl, debugFetch, fetchHistoricalLogs } from '../log-api.js';
3
4
  export const listEdgeFunctions = async (apiBase, accessToken, deployId) => {
4
5
  const response = await debugFetch(`${apiBase}/api/v1/deploys/${encodeURIComponent(deployId)}/edge_functions`, {
@@ -41,7 +42,7 @@ export const fetchEdgeFunctionHistoricalLogs = async ({ siteId, accessToken, fro
41
42
  }));
42
43
  };
43
44
  export const streamEdgeFunctions = (siteId, deployId, accessToken, filterNames, onEntry) => {
44
- const ws = getWebSocket('wss://socketeer.services.netlify.com/edge-function/logs');
45
+ const ws = getWebSocket(`${SOCKETEER_URL}/edge-function/logs`);
45
46
  ws.on('open', () => {
46
47
  ws.send(JSON.stringify({
47
48
  deploy_id: deployId,
@@ -1,4 +1,5 @@
1
1
  import { getWebSocket } from '../../../utils/websockets/index.js';
2
+ import { SOCKETEER_URL } from '../../../utils/socketeer.js';
2
3
  import { buildFunctionLogsUrl, fetchHistoricalLogs } from '../log-api.js';
3
4
  const MAX_CONCURRENT_FUNCTIONS = 10;
4
5
  export const listFunctions = async (client, siteId, deployId) => {
@@ -45,7 +46,7 @@ export const fetchFunctionHistoricalLogs = async ({ functions, siteId, accessTok
45
46
  export const streamFunctions = (functions, siteId, accessToken, onEntry) => {
46
47
  const sockets = [];
47
48
  for (const fn of functions) {
48
- const ws = getWebSocket('wss://socketeer.services.netlify.com/function/logs');
49
+ const ws = getWebSocket(`${SOCKETEER_URL}/function/logs`);
49
50
  sockets.push(ws);
50
51
  ws.on('open', () => {
51
52
  ws.send(JSON.stringify({
@@ -0,0 +1,20 @@
1
+ export interface DeployUrls {
2
+ siteUrl: string;
3
+ deployUrl: string;
4
+ logsUrl: string;
5
+ functionLogsUrl: string;
6
+ edgeFunctionLogsUrl: string;
7
+ }
8
+ interface DeployUrlFields {
9
+ id?: string;
10
+ ssl_url?: string;
11
+ url?: string;
12
+ deploy_ssl_url?: string;
13
+ deploy_url?: string;
14
+ admin_url?: string;
15
+ }
16
+ export declare const getDeployUrls: (deploy: DeployUrlFields, { deployToProduction }: {
17
+ deployToProduction: boolean;
18
+ }) => DeployUrls;
19
+ export {};
20
+ //# sourceMappingURL=deploy-urls.d.ts.map
@@ -0,0 +1,14 @@
1
+ export const getDeployUrls = (deploy, { deployToProduction }) => {
2
+ const functionLogsUrl = `${deploy.admin_url ?? ''}/logs/functions`;
3
+ const edgeFunctionLogsUrl = `${deploy.admin_url ?? ''}/logs/edge-functions`;
4
+ return {
5
+ siteUrl: deploy.ssl_url ?? deploy.url ?? '',
6
+ deployUrl: deploy.deploy_ssl_url ?? deploy.deploy_url ?? '',
7
+ logsUrl: `${deploy.admin_url ?? ''}/deploys/${deploy.id ?? ''}`,
8
+ functionLogsUrl: deployToProduction ? functionLogsUrl : `${functionLogsUrl}?scope=deploy:${deploy.id ?? ''}`,
9
+ edgeFunctionLogsUrl: deployToProduction
10
+ ? edgeFunctionLogsUrl
11
+ : `${edgeFunctionLogsUrl}?scope=deployid:${deploy.id ?? ''}`,
12
+ };
13
+ };
14
+ //# sourceMappingURL=deploy-urls.js.map
@@ -0,0 +1,3 @@
1
+ export declare const NETLIFY_GIT_HOST = "git.netlify.com";
2
+ export declare const isNetlifyGitUrl: (repoUrl: string) => boolean;
3
+ //# sourceMappingURL=netlify-git.d.ts.map
@@ -0,0 +1,12 @@
1
+ export const NETLIFY_GIT_HOST = 'git.netlify.com';
2
+ const NETLIFY_GIT_SERVICE_HOST = 'hgit.services-prod.nsvcs.net';
3
+ export const isNetlifyGitUrl = (repoUrl) => {
4
+ try {
5
+ const { host } = new URL(repoUrl);
6
+ return host === NETLIFY_GIT_HOST || host === NETLIFY_GIT_SERVICE_HOST;
7
+ }
8
+ catch {
9
+ return false;
10
+ }
11
+ };
12
+ //# sourceMappingURL=netlify-git.js.map
@@ -582,6 +582,9 @@ const onRequest = async ({ api, edgeFunctionsProxy, env, functionsRegistry, func
582
582
  for (let index = 0; index < req.rawHeaders.length; index += 2) {
583
583
  headers.append(req.rawHeaders[index], req.rawHeaders[index + 1]);
584
584
  }
585
+ // The server handler gets a `Request` with no socket, so it reads the
586
+ // client's address from this header to set `context.ip`.
587
+ headers.set('x-forwarded-for', req.socket.remoteAddress ?? '');
585
588
  const response = await serverMatch.handle(new Request(requestURL, {
586
589
  body: req.originalBody,
587
590
  headers,
@@ -0,0 +1,2 @@
1
+ export declare const SOCKETEER_URL: string;
2
+ //# sourceMappingURL=socketeer.d.ts.map
@@ -0,0 +1,2 @@
1
+ export const SOCKETEER_URL = process.env.NETLIFY_SOCKETEER_URL ?? 'wss://socketeer.services.netlify.com';
2
+ //# sourceMappingURL=socketeer.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netlify-cli",
3
- "version": "27.14.2",
3
+ "version": "27.14.3",
4
4
  "description": "Netlify command line tool",
5
5
  "keywords": [
6
6
  "api",
@@ -139,7 +139,7 @@
139
139
  "semver": "^7.7.2",
140
140
  "source-map-support": "^0.5.21",
141
141
  "terminal-link": "^5.0.0",
142
- "toml": "^4.0.0",
142
+ "toml": "^5.0.0",
143
143
  "tomlify-j0.4": "^3.0.0",
144
144
  "ulid": "^3.0.1",
145
145
  "update-notifier": "^7.3.1",