Browse Source

Merge branch 'master' into add/http-2

master
Guillermo Rauch 9 years ago
parent
commit
f4c9ad240d
  1. 16
      History.md
  2. 2
      bin/now-deploy
  3. 2
      bin/now-list
  4. 2
      bin/now-remove
  5. 7
      lib/get-files.js
  6. 4
      lib/ignored.js
  7. 55
      lib/index.js
  8. 4
      lib/login.js
  9. 2
      package.json

16
History.md

@ -1,4 +1,20 @@
0.13.2 / 2016-05-14
===================
* remove `test` and `tests` from ignored files
0.13.1 / 2016-05-12
==================
* fix zeit endpoints [@rauchg]
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
===================

2
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();

2
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();

2
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();

7
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;
}
};

4
lib/ignored.js

@ -21,7 +21,5 @@ export default [
'History.md',
'LICENSE',
'Readme',
'Readme.*',
'test',
'tests'
'Readme.*'
];

55
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');
@ -73,9 +70,11 @@ 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] /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,
@ -92,10 +91,11 @@ export default class Now extends EventEmitter {
file: toRelative(name, this._path)
};
});
}))
})),
engines
}
});
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 +112,35 @@ 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((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,
bytes(limit)
);
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
);
}
});
if (sizeExceeded) {
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.`);
}
}
this._id = deployment.deploymentId;
this._host = deployment.url;
this._missing = deployment.missing || [];
@ -136,7 +165,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 +199,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 +225,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
});

4
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;
}

2
package.json

@ -1,6 +1,6 @@
{
"name": "now",
"version": "0.12.0",
"version": "0.13.2",
"description": "realtime instant node.js deployment with one command",
"readme": "",
"main": "./build/lib/index",

Loading…
Cancel
Save