From 19a2e55a9087f30c202e72925752a8c088f0990d Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Thu, 12 May 2016 12:41:18 -0700 Subject: [PATCH 01/11] migrate to api.zeit.co and add warnings support --- bin/now-deploy | 2 +- lib/get-files.js | 7 ------- lib/index.js | 41 +++++++++++++++++++++++++++++------------ 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/bin/now-deploy b/bin/now-deploy index 9a6d7aa..89c7487 100755 --- a/bin/now-deploy +++ b/bin/now-deploy @@ -51,7 +51,7 @@ const clipboard = !(argv.noClipboard || argv.C); const force = argv.f || argv.force; const forceSync = argv.F || argv.forceSync; const shouldLogin = argv.L || argv.login; -const apiUrl = argv.url || 'https://api.now.sh'; +const apiUrl = argv.url || 'https://api.zeit.co'; const config = cfg.read(); diff --git a/lib/get-files.js b/lib/get-files.js index cf54b64..9408cc8 100644 --- a/lib/get-files.js +++ b/lib/get-files.js @@ -1,4 +1,3 @@ -import bytes from 'bytes'; import flatten from 'arr-flatten'; import unique from 'array-unique'; import minimatch from 'minimatch'; @@ -143,12 +142,6 @@ const explode = async function (paths, ignored, { limit, debug }) { const all = await readdir(file); return many(all.map(subdir => asAbsolute(subdir, file))); } else { - if (null != limit && s.size > limit) { - console.error('> \u001b[31mWarning!\u001b[39m Skipping file ' + - `over ${bytes(limit)}: ${path}`); - return null; - } - return path; } }; diff --git a/lib/index.js b/lib/index.js index 75d0ac3..dc6a427 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,7 +1,8 @@ +import bytes from 'bytes'; +import chalk from 'chalk'; import getFiles from './get-files'; import hash from './hash'; import retry from './retry'; -import bytes from 'bytes'; import Agent from './agent'; import EventEmitter from 'events'; import { basename, resolve } from 'path'; @@ -9,9 +10,6 @@ import { stat, readFile } from 'fs-promise'; import resumer from 'resumer'; import splitArray from 'split-array'; -// limit of size of files to find -const ONEMB = bytes('1mb'); - // how many concurrent HTTP/2 stream uploads const MAX_CONCURRENT = 10; @@ -39,7 +37,6 @@ export default class Now extends EventEmitter { e.userError = true; throw e; } - let pkg; try { pkg = await readFile(resolve(path, 'package.json')); @@ -64,7 +61,7 @@ export default class Now extends EventEmitter { } if (this._debug) console.time('> [debug] Getting files'); - const files = await getFiles(path, pkg, { limit: ONEMB, debug: this._debug }); + const files = await getFiles(path, pkg, { debug: this._debug }); if (this._debug) console.timeEnd('> [debug] Getting files'); if (this._debug) console.time('> [debug] Computing hashes'); @@ -74,8 +71,8 @@ export default class Now extends EventEmitter { this._files = hashes; const deployment = await retry(async (bail) => { - if (this._debug) console.time('> [debug] /create'); - const res = await this._fetch('/create', { + if (this._debug) console.time('> [debug] /now/create'); + const res = await this._fetch('/now/create', { method: 'POST', body: { forceNew, @@ -95,7 +92,7 @@ export default class Now extends EventEmitter { })) } }); - if (this._debug) console.timeEnd('> [debug] /create'); + if (this._debug) console.timeEnd('> [debug] /now/create'); // no retry on 4xx if (200 !== res.status && (400 <= res.status && 500 > res.status)) { @@ -112,6 +109,26 @@ export default class Now extends EventEmitter { return res.json(); }, { retries: 3, minTimeout: 2500, onRetry: this._onRetry }); + // we report about files whose sizes are too big + if (deployment.warnings) { + let sizeExceeded = 0; + deployment.warnings.forEach(({ reason, sha, limit }) => { + if ('size_exceeded' === reason) { + console.error('> \u001b[31mWarning!\u001b[39m Skipping file %s (size exceeded %s)', + hashes.get(sha), + bytes(limit) + ); + sizeExceeded++; + } + }); + + if (sizeExceeded) { + console.log('> \u001b[31mWarning!\u001b[39m %d of the files ' + + 'exceeded the limit for your plan.\n' + + `> See ${chalk.underline('https://zeit.co/account')} to upgrade.`); + } + } + this._id = deployment.deploymentId; this._host = deployment.url; this._missing = deployment.missing || []; @@ -136,7 +153,7 @@ export default class Now extends EventEmitter { if (this._debug) console.time(`> [debug] /sync ${names.join(' ')}`); const stream = resumer().queue(data).end(); - const res = await this._fetch('/sync', { + const res = await this._fetch('/now/sync', { method: 'POST', headers: { 'Content-Type': 'application/octet-stream', @@ -170,7 +187,7 @@ export default class Now extends EventEmitter { const { deployments } = await retry(async (bail) => { if (this._debug) console.time('> [debug] /list'); - const res = await this._fetch('/list' + query); + const res = await this._fetch('/now/list' + query); if (this._debug) console.timeEnd('> [debug] /list'); // no retry on 4xx @@ -196,7 +213,7 @@ export default class Now extends EventEmitter { await retry(async (bail) => { if (this._debug) console.time('> [debug] /remove'); - const res = await this._fetch('/remove', { + const res = await this._fetch('/now/remove', { method: 'DELETE', body: data }); From 5caa1dc8f45d07eac7bced04ed951e13356b3422 Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Thu, 12 May 2016 23:00:24 +0300 Subject: [PATCH 02/11] Fix `.reason` match for file size warnings --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index dc6a427..2d9a175 100644 --- a/lib/index.js +++ b/lib/index.js @@ -113,7 +113,7 @@ export default class Now extends EventEmitter { if (deployment.warnings) { let sizeExceeded = 0; deployment.warnings.forEach(({ reason, sha, limit }) => { - if ('size_exceeded' === reason) { + if ('size_limit_exceeded' === reason) { console.error('> \u001b[31mWarning!\u001b[39m Skipping file %s (size exceeded %s)', hashes.get(sha), bytes(limit) From 7608bf6fd6ff159a9d7935c4cfe624d13bd5cfce Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Thu, 12 May 2016 23:09:25 +0300 Subject: [PATCH 03/11] Fix file size warning reporting --- lib/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2d9a175..fdf815c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -114,16 +114,18 @@ export default class Now extends EventEmitter { let sizeExceeded = 0; deployment.warnings.forEach(({ reason, sha, limit }) => { if ('size_limit_exceeded' === reason) { + const name = hashes.get(sha).names.pop(); console.error('> \u001b[31mWarning!\u001b[39m Skipping file %s (size exceeded %s)', - hashes.get(sha), + name, bytes(limit) ); + hashes.get(sha).names.unshift(name); // move name (hack, if duplicate matches we report them in order) sizeExceeded++; } }); if (sizeExceeded) { - console.log('> \u001b[31mWarning!\u001b[39m %d of the files ' + + console.log(`> \u001b[31mWarning!\u001b[39m ${sizeExceeded} of the files ` + 'exceeded the limit for your plan.\n' + `> See ${chalk.underline('https://zeit.co/account')} to upgrade.`); } From f41397651f2a63182a9e0dd008d9c1601e61e00e Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Thu, 12 May 2016 16:25:15 -0700 Subject: [PATCH 04/11] login: adapt code for api.zeit.co --- lib/login.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/login.js b/lib/login.js index 337661a..c324d2d 100644 --- a/lib/login.js +++ b/lib/login.js @@ -15,7 +15,7 @@ function readEmail () { async function getVerificationToken (url, email) { const data = JSON.stringify({ email }); - const res = await fetch(url + '/registration', { + const res = await fetch(`${url}/now/registration`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -38,7 +38,7 @@ async function verify (url, email, verificationToken) { token: verificationToken }; - const res = await fetch(`${url}/registration/verify?${stringifyQuery(query)}`); + const res = await fetch(`${url}/now/registration/verify?${stringifyQuery(query)}`); const body = await res.json(); return body.token; } From e712759b5014ef00c3b049345d8bfb453a7438ca Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Thu, 12 May 2016 16:25:37 -0700 Subject: [PATCH 05/11] Release 0.13.0 --- History.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 7a7bac3..9b56aac 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,10 @@ +0.13.0 / 2016-05-12 +=================== + + * add warning reports for `/create` [@rauchg, @rase-] + * migrate to `api.zeit.co` [@rauchg] + 0.12.0 / 2016-04-29 =================== diff --git a/package.json b/package.json index c3b4ab5..66f827f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "now", - "version": "0.12.0", + "version": "0.13.0", "description": "realtime instant node.js deployment with one command", "readme": "", "main": "./build/lib/index", From b44140e262c1f368bfde2696032076e627aa0417 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Thu, 12 May 2016 16:46:36 -0700 Subject: [PATCH 06/11] fix zeit endpoints --- bin/now-list | 2 +- bin/now-remove | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/now-list b/bin/now-list index 8a6fb42..10bbfc1 100755 --- a/bin/now-list +++ b/bin/now-list @@ -33,7 +33,7 @@ const app = argv._[0]; // options const debug = argv.debug || argv.d; -const apiUrl = argv.url || 'https://api.now.sh'; +const apiUrl = argv.url || 'https://api.zeit.co'; const config = cfg.read(); diff --git a/bin/now-remove b/bin/now-remove index c59daa5..afa6c4f 100755 --- a/bin/now-remove +++ b/bin/now-remove @@ -39,7 +39,7 @@ if (!deploymentId) { // options const debug = argv.debug || argv.d; -const apiUrl = argv.url || 'https://api.now.sh'; +const apiUrl = argv.url || 'https://api.zeit.co'; const hard = argv.hard || false; const config = cfg.read(); From 93151601118a5262fb767bd3a28b4019b6fcf2ee Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Thu, 12 May 2016 16:47:35 -0700 Subject: [PATCH 07/11] Release 0.13.1 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 9b56aac..6325b30 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,9 @@ +0.13.1 / 2016-05-12 +================== + + * fix zeit endpoints [@rauchg] + 0.13.0 / 2016-05-12 =================== diff --git a/package.json b/package.json index 66f827f..a1f9a94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "now", - "version": "0.13.0", + "version": "0.13.1", "description": "realtime instant node.js deployment with one command", "readme": "", "main": "./build/lib/index", From dd5516e1ed909896c47050d6e40c6083cd1db3a6 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Sat, 14 May 2016 09:39:46 -0700 Subject: [PATCH 08/11] remove `test` and `tests` from ignored files --- lib/ignored.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/ignored.js b/lib/ignored.js index ed47eab..59588a1 100644 --- a/lib/ignored.js +++ b/lib/ignored.js @@ -21,7 +21,5 @@ export default [ 'History.md', 'LICENSE', 'Readme', - 'Readme.*', - 'test', - 'tests' + 'Readme.*' ]; From 194330216aba4977811ce0476a08a2d199ebd7bc Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Sun, 15 May 2016 18:32:44 +0300 Subject: [PATCH 09/11] Read and send `now-engines` --- lib/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index fdf815c..94838e9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -70,6 +70,8 @@ export default class Now extends EventEmitter { this._files = hashes; + const engines = pkg['now-engines']; + const deployment = await retry(async (bail) => { if (this._debug) console.time('> [debug] /now/create'); const res = await this._fetch('/now/create', { @@ -89,7 +91,8 @@ export default class Now extends EventEmitter { file: toRelative(name, this._path) }; }); - })) + })), + engines } }); if (this._debug) console.timeEnd('> [debug] /now/create'); From 18ce4229629e69a8efe375bd3cd4d7c2c463000c Mon Sep 17 00:00:00 2001 From: Tony Kovanen Date: Mon, 16 May 2016 00:00:53 +0300 Subject: [PATCH 10/11] Add warnings for unfound node version match --- lib/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 94838e9..c6c92bd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -115,8 +115,9 @@ export default class Now extends EventEmitter { // we report about files whose sizes are too big if (deployment.warnings) { let sizeExceeded = 0; - deployment.warnings.forEach(({ reason, sha, limit }) => { - if ('size_limit_exceeded' === reason) { + deployment.warnings.forEach((warning) => { + if ('size_limit_exceeded' === warning.reason) { + const { sha, limit } = warning; const name = hashes.get(sha).names.pop(); console.error('> \u001b[31mWarning!\u001b[39m Skipping file %s (size exceeded %s)', name, @@ -124,6 +125,12 @@ export default class Now extends EventEmitter { ); hashes.get(sha).names.unshift(name); // move name (hack, if duplicate matches we report them in order) sizeExceeded++; + } else if ('node_version_not_found' === warning.reason) { + const { wanted, used } = warning; + console.error('> \u001b[31mWarning!\u001b[39m Requested node version %s is not available, using default version %s', + wanted, + used + ); } }); From be5cd55a81cf2d5d8ba3acc35d9c8e3315bf6625 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Tue, 17 May 2016 10:07:38 -0700 Subject: [PATCH 11/11] Release 0.13.2 --- History.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 6325b30..b4632e7 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,9 @@ +0.13.2 / 2016-05-14 +=================== + + * remove `test` and `tests` from ignored files + 0.13.1 / 2016-05-12 ================== diff --git a/package.json b/package.json index a1f9a94..beaf7e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "now", - "version": "0.13.1", + "version": "0.13.2", "description": "realtime instant node.js deployment with one command", "readme": "", "main": "./build/lib/index",