diff --git a/package-lock.json b/package-lock.json index a2141f8b18b..3619f704994 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11111,12 +11111,12 @@ "integrity": "sha512-AO81vsIO1k1sM4Zrd6Hu7regmJN1NSiAja10gc4bX3F0wd+9rQmcuHQaHVQCYIEC8iFXnE+mavh23GOt7wBgug==" }, "netlify": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/netlify/-/netlify-4.1.8.tgz", - "integrity": "sha512-3m5RDs3PrYFSuuZR9eZ8cNGy597rMUvkrT8phWmo1uiguL4rxSeOoIeqsI5UZwG6KNY2b/4GuDSSw34znWn4eg==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/netlify/-/netlify-4.3.0.tgz", + "integrity": "sha512-4tDEc8CtRbM/Lbvooyn9pAIsfpyiW5euqxViFM1SWOjFeH96P2eh0RfMj03+NVaZ3O7d92JqNAKZliPHf+ulNA==", "requires": { "@netlify/open-api": "^0.15.0", - "@netlify/zip-it-and-ship-it": "^1.0.0", + "@netlify/zip-it-and-ship-it": "^1.1.0", "backoff": "^2.5.0", "clean-deep": "^3.3.0", "filter-obj": "^2.0.1", @@ -11141,6 +11141,41 @@ "through2-map": "^3.0.0" }, "dependencies": { + "@netlify/zip-it-and-ship-it": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@netlify/zip-it-and-ship-it/-/zip-it-and-ship-it-1.1.0.tgz", + "integrity": "sha512-/MkvRL1eRPZ43U/dT2MsRsGSi1U6gFJobfuwz/3SFSNu+HdzsX/QgTs1VsHlKQejMYOtOyIAzgswFkV/UHs7qg==", + "requires": { + "archiver": "^3.0.0", + "common-path-prefix": "^2.0.0", + "cp-file": "^7.0.0", + "elf-tools": "^1.1.1", + "end-of-stream": "^1.4.4", + "find-up": "^4.1.0", + "glob": "^7.1.6", + "junk": "^3.1.0", + "make-dir": "^3.0.2", + "p-map": "^3.0.0", + "path-exists": "^4.0.0", + "pkg-dir": "^4.2.0", + "precinct": "^6.2.0", + "require-package-name": "^2.0.1", + "resolve": "^2.0.0-next.1", + "semver": "^7.3.2", + "unixify": "^1.0.0", + "util.promisify": "^1.0.1", + "yargs": "^15.3.1" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, "p-timeout": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz", @@ -11156,6 +11191,14 @@ "requires": { "p-timeout": "^3.0.0" } + }, + "resolve": { + "version": "2.0.0-next.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.1.tgz", + "integrity": "sha512-ZGTmuLZAW++TDjgslfUMRZcv7kXHv8z0zwxvuRWOPjnqc56HVsn1lVaqsWOZeQ8MwiilPVJLrcPVKG909QsAfA==", + "requires": { + "path-parse": "^1.0.6" + } } } }, diff --git a/package.json b/package.json index 03d050c17ee..7559edca9f5 100644 --- a/package.json +++ b/package.json @@ -119,7 +119,7 @@ "log-symbols": "^2.2.0", "make-dir": "^3.0.0", "minimist": "^1.2.5", - "netlify": "^4.1.8", + "netlify": "^4.3.0", "netlify-redirect-parser": "^2.5.0", "netlify-redirector": "^0.2.0", "node-fetch": "^2.6.0", diff --git a/src/commands/deploy.js b/src/commands/deploy.js index b864933cd77..5a4cb948cc5 100644 --- a/src/commands/deploy.js +++ b/src/commands/deploy.js @@ -22,6 +22,9 @@ class DeployCommand extends Command { const { api, site, config } = this.netlify const deployToProduction = flags.prod + if (deployToProduction && flags.branch) { + this.error(`--prod and --branch flags cannot be used at the same time`) + } await this.authenticate(flags.auth) await this.config.runHook('analytics', { @@ -31,6 +34,7 @@ class DeployCommand extends Command { open: flags.open, prod: flags.prod, json: flags.json, + branch: Boolean(flags.branch), }, }) @@ -142,7 +146,7 @@ class DeployCommand extends Command { } this.log(prettyjson.render(pathInfo)) - ensureDirectory(deployFolder, this.exit) + ensureDirectory(deployFolder, this.error) if (functionsFolder) { // we used to hard error if functions folder is specified but doesnt exist @@ -195,9 +199,10 @@ class DeployCommand extends Command { configPath: configPath, fnDir: functionsFolder, statusCb: flags.json || flags.silent ? () => {} : deployProgressCb(), - draft: !deployToProduction, + draft: !deployToProduction && !flags.branch, message: flags.message, deployTimeout: flags.timeout * 1000 || 1.2e6, + branch: flags.branch, }) } catch (e) { switch (true) { @@ -375,6 +380,10 @@ DeployCommand.flags = { description: 'Deploy to production', default: false, }), + branch: flags.string({ + char: 'b', + description: "Specifies the branch for deployment. Useful for creating specific deployment URL's", + }), open: flags.boolean({ char: 'o', description: 'Open site after deploy', @@ -441,28 +450,25 @@ function deployProgressCb() { } } -function ensureDirectory(resolvedDeployPath, exit) { +function ensureDirectory(resolvedDeployPath, error) { let stat try { stat = fs.statSync(resolvedDeployPath) } catch (e) { if (e.status === 'ENOENT') { - console.log( + return error( `No such directory ${resolvedDeployPath}! Did you forget to create a functions folder or run a build?` ) - exit(1) } // Improve the message of permission errors if (e.status === 'EACCES') { - console.log('Permission error when trying to access deploy folder') - exit(1) + return error('Permission error when trying to access deploy folder') } throw e } if (!stat.isDirectory) { - console.log('Deploy target must be a directory') - exit(1) + return error('Deploy target must be a directory') } return stat }