netlify 27.19.0 → 27.20.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.
@@ -25,6 +25,7 @@ For more information about getting started with Netlify CLI, see ${terminalLink(
25
25
  .action(async (options, command) => {
26
26
  const { init } = await import('./init.js');
27
27
  await init(options, command, {
28
+ skipPromptsWithoutTerminal: true,
28
29
  setupAgentSkills: !options.skipAgentSetup,
29
30
  setupAgentMcp: !options.skipAgentSetup && !options.skipMcpSetup,
30
31
  resetMcpSetup: Boolean(options.resetMcpSetup),
@@ -7,12 +7,13 @@ type InitExitMessageCustomizer = (code: InitExitCode, defaultMessage: string) =>
7
7
  type InitExtraOptions = {
8
8
  customizeExitMessage?: InitExitMessageCustomizer | undefined;
9
9
  exitAfterConfiguringRepo?: boolean | undefined;
10
+ skipPromptsWithoutTerminal?: boolean | undefined;
10
11
  setupAgentSkills?: boolean | undefined;
11
12
  setupAgentMcp?: boolean | undefined;
12
13
  resetContext?: boolean | undefined;
13
14
  resetMcpSetup?: boolean | undefined;
14
15
  mcpScope?: McpScope | undefined;
15
16
  };
16
- export declare const init: (options: OptionValues, command: BaseCommand, { customizeExitMessage, exitAfterConfiguringRepo, setupAgentSkills: shouldSetupAgentSkills, setupAgentMcp: shouldSetupAgentMcp, resetContext, resetMcpSetup, mcpScope, }?: InitExtraOptions) => Promise<SiteInfo>;
17
+ export declare const init: (options: OptionValues, command: BaseCommand, { customizeExitMessage, exitAfterConfiguringRepo, skipPromptsWithoutTerminal, setupAgentSkills: shouldSetupAgentSkills, setupAgentMcp: shouldSetupAgentMcp, resetContext, resetMcpSetup, mcpScope, }?: InitExtraOptions) => Promise<SiteInfo>;
17
18
  export {};
18
19
  //# sourceMappingURL=init.d.ts.map
@@ -4,6 +4,7 @@ import { chalk, exit, log, logAndThrowError, netlifyCommand, warn } from '../../
4
4
  import getRepoData from '../../utils/get-repo-data.js';
5
5
  import { ensureNetlifyIgnore } from '../../utils/gitignore.js';
6
6
  import { configureRepo } from '../../utils/init/config.js';
7
+ import { isInteractive } from '../../utils/scripted-commands.js';
7
8
  import { track } from '../../utils/telemetry/index.js';
8
9
  import { link } from '../link/link.js';
9
10
  import { sitesCreate } from '../sites/sites-create.js';
@@ -46,6 +47,49 @@ const logLinkedWithoutGitAndExit = ({ siteInfo, repoError, }) => {
46
47
  log(`To link this folder to a different project, run ${chalk.cyanBright.bold(`${netlifyCommand()} unlink`)}, then ${chalk.cyanBright.bold(`${netlifyCommand()} init`)}.`);
47
48
  return exit();
48
49
  };
50
+ const canAnswerPrompts = () => isInteractive() || process.env.TESTING_PROMPTS === 'true';
51
+ const SHELL_SAFE_URL = /^https:\/\/[\w.-]+(:\d+)?\/[\w./-]+$/;
52
+ const logNextStepsAndExit = ({ command, linkedSiteInfo, repoData, }) => {
53
+ const run = (args) => chalk.cyanBright.bold(`${netlifyCommand()} ${args}`);
54
+ const teams = command.netlify.accounts;
55
+ const teamSlug = teams.length === 1 ? teams[0].slug : '<team-slug>';
56
+ log();
57
+ log('Project setup asks questions and there is no terminal to answer them in, so it was skipped.');
58
+ log();
59
+ if (linkedSiteInfo) {
60
+ log(`This folder is linked to the Netlify project ${chalk.cyan(linkedSiteInfo.name)}.`);
61
+ log();
62
+ log(`To deploy to it, run ${run('deploy')}.`);
63
+ }
64
+ else {
65
+ if (process.env.NETLIFY_SITE_ID) {
66
+ log('NETLIFY_SITE_ID names a Netlify project that could not be used. See the warning above.');
67
+ log('Set it to a project this account can access, or unset it. Then run one of:');
68
+ }
69
+ else if (command.netlify.state.get('siteId') === undefined) {
70
+ log('This folder is not linked to a Netlify project yet. To continue without a terminal, run one of:');
71
+ }
72
+ else {
73
+ log('The Netlify project saved as the link for this folder could not be used. See the warning above.');
74
+ log(`If you are logged in to the right account, run ${run('unlink')} to remove the saved link. Then run one of:`);
75
+ }
76
+ log();
77
+ if (!('error' in repoData) && SHELL_SAFE_URL.test(repoData.httpsUrl)) {
78
+ log(` ${run(`link --git-remote-url ${repoData.httpsUrl}`)} links the project connected to this repository`);
79
+ }
80
+ log(` ${run('link --id <project-id>')} links an existing project`);
81
+ log(` ${run(`sites:create --name <name> --account-slug ${teamSlug}`)} creates a project and links it`);
82
+ if (teams.length > 1) {
83
+ log();
84
+ log(`Teams: ${teams.map(({ slug }) => slug).join(', ')}`);
85
+ log('Ask the user which team a new project belongs in.');
86
+ }
87
+ log();
88
+ log(`Then run ${run('deploy')} to deploy.`);
89
+ }
90
+ log(`To deploy on every push, run ${run('init')} in a terminal. It asks for access to the Git provider.`);
91
+ return exit();
92
+ };
49
93
  const ignoreLinkedSiteForThisRun = (command) => {
50
94
  const { site } = command.netlify;
51
95
  command.siteId = undefined;
@@ -259,7 +303,7 @@ const setUpAgents = async (command, { skills, mcp, reset, resetMcp, mcpScope, })
259
303
  await addAgentMcp(command, resetMcp, mcpScope);
260
304
  }
261
305
  };
262
- export const init = async (options, command, { customizeExitMessage, exitAfterConfiguringRepo = false, setupAgentSkills: shouldSetupAgentSkills = false, setupAgentMcp: shouldSetupAgentMcp = false, resetContext = false, resetMcpSetup = false, mcpScope = 'project', } = {}) => {
306
+ export const init = async (options, command, { customizeExitMessage, exitAfterConfiguringRepo = false, skipPromptsWithoutTerminal = false, setupAgentSkills: shouldSetupAgentSkills = false, setupAgentMcp: shouldSetupAgentMcp = false, resetContext = false, resetMcpSetup = false, mcpScope = 'project', } = {}) => {
263
307
  command.setAnalyticsPayload({
264
308
  manual: options.manual,
265
309
  force: options.force,
@@ -281,16 +325,20 @@ export const init = async (options, command, { customizeExitMessage, exitAfterCo
281
325
  resetMcp: resetMcpSetup,
282
326
  mcpScope,
283
327
  });
328
+ const promptsSkipped = skipPromptsWithoutTerminal && !canAnswerPrompts();
284
329
  const linkedSiteInfo = await getLinkedSiteInfo(command);
285
- if (linkedSiteInfo && getRepoUrl(linkedSiteInfo) && !options.force) {
330
+ if (linkedSiteInfo && getRepoUrl(linkedSiteInfo) && (!options.force || promptsSkipped)) {
286
331
  logExistingAndExit({ siteInfo: linkedSiteInfo });
287
332
  }
288
333
  // Look for local repo
289
334
  const repoData = await getRepoData({ workingDir: command.workingDir, remoteName: options.gitRemoteName });
335
+ if ('error' in repoData && linkedSiteInfo) {
336
+ return logLinkedWithoutGitAndExit({ siteInfo: linkedSiteInfo, repoError: repoData });
337
+ }
338
+ if (promptsSkipped) {
339
+ return logNextStepsAndExit({ command, linkedSiteInfo, repoData });
340
+ }
290
341
  if ('error' in repoData) {
291
- if (linkedSiteInfo) {
292
- return logLinkedWithoutGitAndExit({ siteInfo: linkedSiteInfo, repoError: repoData });
293
- }
294
342
  // TODO(ndhoule): Custom error messaage here
295
343
  return await handleNoGitRemoteAndExit({
296
344
  command,
@@ -43,6 +43,13 @@ To search for projects:
43
43
  return firstSite;
44
44
  }
45
45
  spinner.warn({ text: `Found ${matchingSites.length} projects connected to ${repoUrl}` });
46
+ if (!isInteractive() && process.env.TESTING_PROMPTS !== 'true') {
47
+ return logAndThrowError(`More than one project is connected to ${repoUrl}. Link the one you want by ID:
48
+
49
+ ${matchingSites
50
+ .map(({ id, name }) => ` ${chalk.cyanBright(`${netlifyCommand()} link --id ${id}`)} ${name}`)
51
+ .join('\n')}`);
52
+ }
46
53
  const selectedSite = await select({
47
54
  message: 'Which project do you want to link?',
48
55
  choices: matchingSites.map((matchingSite) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netlify",
3
- "version": "27.19.0",
3
+ "version": "27.20.0",
4
4
  "description": "Netlify command line tool",
5
5
  "keywords": [
6
6
  "api",