Browse Source

Merge branch 'master' into add/env-flags

master
Guillermo Rauch 9 years ago
parent
commit
4abbc8546d
  1. 3
      .travis.yml
  2. 2
      bin/now-alias
  3. 6
      bin/now-deploy
  4. 2
      bin/now-domains
  5. 30
      lib/get-files.js
  6. 6
      lib/index.js
  7. 49
      package.json
  8. 8
      test/_fixtures/negation/package.json

3
.travis.yml

@ -1,3 +1,2 @@
language: node_js
node_js:
- "6"
node_js: node

2
bin/now-alias

@ -223,7 +223,7 @@ async function readConfirmation (alias, _alias, list) {
{ align: ['l', 'r', 'l'], hsep: ' '.repeat(6) }
);
process.stdout.write('> The following deployment will be removed permanently\n');
process.stdout.write('> The following alias will be removed permanently\n');
process.stdout.write(' ' + tbl + '\n');
process.stdout.write(` ${chalk.bold.red('> Are you sure?')} ${chalk.gray('[yN] ')}`);

6
bin/now-deploy

@ -25,6 +25,7 @@ const argv = minimist(process.argv.slice(2), {
force: 'f',
forceSync: 'F',
login: 'L',
public: 'p',
'no-clipboard': 'C',
'forward-npm': 'N'
}
@ -51,6 +52,7 @@ const help = () => {
-d, --debug debug mode [off]
-f, --force force a new deployment even if nothing has changed
-L, --login configure login
-p, --public deployment is public (\`/_src\` is exposed) [on for oss, off for premium]
-C, --no-clipboard do not attempt to copy URL to clipboard
-N, --forward-npm Forward login information to install private NPM modules
@ -103,6 +105,7 @@ const forwardNpm = argv['forward-npm'];
const forceNew = argv.force;
const forceSync = argv.forceSync;
const shouldLogin = argv.login;
const wantsPublic = argv.public;
const apiUrl = argv.url || 'https://api.zeit.co';
const isTTY = process.stdout.isTTY;
const quiet = !isTTY;
@ -228,7 +231,8 @@ async function sync (token) {
forceNew,
forceSync,
forwardNpm: alwaysForwardNpm || forwardNpm,
quiet
quiet,
wantsPublic
});
} catch (err) {
if (debug) console.log(`> [debug] error: ${err.stack}`);

2
bin/now-domains

@ -215,7 +215,7 @@ async function readConfirmation (domain, _domain, list) {
{ align: ['l', 'r', 'l'], hsep: ' '.repeat(6) }
);
process.stdout.write('> The following deployment will be removed permanently\n');
process.stdout.write('> The following domain will be removed permanently\n');
process.stdout.write(' ' + tbl + '\n');
process.stdout.write(` ${chalk.bold.red('> Are you sure?')} ${chalk.gray('[yN] ')}`);

30
lib/get-files.js

@ -39,11 +39,6 @@ export async function npm (path, pkg, {
// convert all filenames into absolute paths
const search = search_.map((file) => asAbsolute(file, path));
// locate files
if (debug) console.time('> [debug] locating files');
const files_ = await explode(search, { limit, debug });
if (debug) console.timeEnd('> [debug] locating files');
// compile list of ignored patterns and files
const npmIgnore = await maybeRead(resolve(path, '.npmignore'), null);
const ignored = parser.compile(
@ -65,8 +60,10 @@ export async function npm (path, pkg, {
return accepted;
};
// filter files
const files = files_.filter(accepts);
// locate files
if (debug) console.time('> [debug] locating files');
const files = await explode(search, { accepts, limit, debug });
if (debug) console.timeEnd('> [debug] locating files');
// always include manifest as npm does not allow ignoring it
// source: https://docs.npmjs.com/files/package.json#files
@ -99,11 +96,6 @@ export async function docker (path, {
// convert all filenames into absolute paths
const search = search_.map((file) => asAbsolute(file, path));
// locate files
if (debug) console.time('> [debug] locating files');
const files_ = await explode(search, { limit, debug });
if (debug) console.timeEnd('> [debug] locating files');
// compile list of ignored patterns and files
const ignored = parser.compile(
IGNORED +
@ -122,8 +114,10 @@ export async function docker (path, {
return accepted;
};
// filter files
const files = files_.filter(accepts);
// locate files
if (debug) console.time('> [debug] locating files');
const files = await explode(search, { accepts, limit, debug });
if (debug) console.timeEnd('> [debug] locating files');
// always include manifest as npm does not allow ignoring it
// source: https://docs.npmjs.com/files/package.json#files
@ -160,7 +154,7 @@ const asAbsolute = function (path, parent) {
* @return {Array} of {String}s of full paths
*/
const explode = async function (paths, { limit, debug }) {
const explode = async function (paths, { accepts, limit, debug }) {
const many = async (all) => {
return await Promise.all(all.map(async (file) => {
return await list(file);
@ -171,6 +165,10 @@ const explode = async function (paths, { limit, debug }) {
let path = file;
let s;
if (!accepts(file)) {
return null;
}
try {
s = await stat(path);
} catch (e) {
@ -193,7 +191,7 @@ const explode = async function (paths, { limit, debug }) {
}
};
return flatten((await many(paths))).filter((v) => null != v);
return flatten((await many(paths))).filter((v) => null !== v);
};
/**

6
lib/index.js

@ -35,6 +35,7 @@ export default class Now extends EventEmitter {
}
async create (path, {
wantsPublic,
quiet = false,
forceNew = false,
forceSync = false,
@ -79,7 +80,7 @@ export default class Now extends EventEmitter {
let docker;
try {
const dockerfile = await readFile(resolvePath(path, 'Dockerfile'), 'utf8');
docker = parseDockerfile(dockerfile);
docker = parseDockerfile(dockerfile, { includeComments: true });
} catch (err) {
const e = Error(`Failed to parse "${path}/Dockerfile"`);
e.userError = true;
@ -176,10 +177,11 @@ export default class Now extends EventEmitter {
const res = await this._fetch('/now/create', {
method: 'POST',
body: {
public: wantsPublic,
forceNew,
forceSync,
name: name,
description: description,
description,
deploymentType,
registryAuthToken: authToken,
// Flatten the array to contain files to sync where each nested input

49
package.json

@ -7,6 +7,9 @@
"files": [
"build"
],
"greenkeeper": {
"emails": false
},
"babel": {
"presets": [
"es2015"
@ -50,12 +53,12 @@
"dependencies": {
"ansi-escapes": "1.4.0",
"arr-flatten": "1.0.1",
"array-unique": "0.2.1",
"array-unique": "0.3.2",
"async-retry": "0.2.1",
"babel-runtime": "6.5.0",
"bytes": "2.3.0",
"babel-runtime": "6.11.6",
"bytes": "2.4.0",
"chalk": "1.1.3",
"copy-paste": "1.2.0",
"copy-paste": "1.3.0",
"cross-spawn-async": "2.2.4",
"docker-file-parser": "0.1.0",
"domain-regex": "0.0.1",
@ -63,41 +66,41 @@
"email-validator": "1.0.4",
"fs-promise": "0.5.0",
"gitignore-parser": "0.0.2",
"graceful-fs": "4.1.4",
"graceful-fs": "4.1.5",
"ini": "1.3.4",
"minimatch": "3.0.0",
"minimatch": "3.0.3",
"minimist": "1.2.0",
"ms": "0.7.1",
"node-fetch": "1.5.3",
"node-fetch": "1.6.0",
"progress": "1.1.8",
"resumer": "0.0.0",
"semver-compare": "1.0.0",
"socket.io-client": "1.4.6",
"spdy": "3.3.3",
"socket.io-client": "1.4.8",
"spdy": "3.4.0",
"split-array": "1.0.1",
"text-table": "0.2.0"
},
"devDependencies": {
"alpha-sort": "1.0.2",
"ava": "0.15.2",
"babel-eslint": "6.0.4",
"babel-plugin-syntax-async-functions": "6.8.0",
"ava": "^0.16.0",
"babel-eslint": "6.1.2",
"babel-plugin-syntax-async-functions": "6.13.0",
"babel-plugin-transform-async-to-generator": "6.8.0",
"babel-plugin-transform-runtime": "6.9.0",
"babel-preset-es2015": "6.9.0",
"babel-register": "6.9.0",
"del": "2.2.0",
"enclose": "2.1.0",
"eslint": "2.12.0",
"eslint-config-standard": "5.3.1",
"eslint-plugin-promise": "1.3.2",
"eslint-plugin-standard": "1.3.2",
"babel-plugin-transform-runtime": "6.12.0",
"babel-preset-es2015": "6.13.2",
"babel-register": "6.11.6",
"del": "2.2.2",
"enclose": "2.2.0",
"eslint": "3.3.0",
"eslint-config-standard": "5.3.5",
"eslint-plugin-promise": "2.0.1",
"eslint-plugin-standard": "2.0.0",
"estraverse-fb": "1.3.1",
"gulp": "3.9.1",
"gulp-babel": "6.1.2",
"gulp-eslint": "2.0.0",
"gulp-eslint": "3.0.1",
"gulp-task-listing": "1.0.1",
"gulp-uglify": "1.5.3"
"gulp-uglify": "2.0.0"
},
"scripts": {
"start": "gulp",

8
test/_fixtures/negation/package.json

@ -0,0 +1,8 @@
{
"name": "negation",
"version": "0.0.1",
"description": "",
"dependencies": {
}
}
Loading…
Cancel
Save