Comparing version 0.1.7 to 0.1.11
@@ -35,3 +35,3 @@ 'use strict'; | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } step("next"); }); }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
@@ -45,2 +45,5 @@ function printUsage() { | ||
console.log(); | ||
console.log(" neon build [--rust|-r nightly|stable|default] [--debug|-d]"); | ||
console.log(" rebuild the project"); | ||
console.log(); | ||
console.log(" neon version"); | ||
@@ -79,3 +82,3 @@ console.log(" print neon-cli version"); | ||
} | ||
return (0, _neon_build2.default)(this.cwd, this.args.rust || this.args.r || 'default', this.args.debug || this.args.d ? 'debug' : 'release'); | ||
return (0, _neon_build2.default)(this.cwd, this.args.rust || this.args.r || 'default', this.args.debug || this.args.d ? 'debug' : 'release', this.args.node_module_version); | ||
} | ||
@@ -82,0 +85,0 @@ }; |
'use strict'; | ||
var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,2 +7,22 @@ value: true | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
let main = (() => { | ||
var _ref3 = _asyncToGenerator(function* (name, configuration, target) { | ||
let pp = process.platform; | ||
let output_directory = target ? _path2.default.resolve('native', 'target', target, configuration) : _path2.default.resolve('native', 'target', configuration); | ||
let dylib = _path2.default.resolve(output_directory, LIB_PREFIX[pp] + name + LIB_SUFFIX[pp]); | ||
let index = _path2.default.resolve('native', 'index.node'); | ||
console.log(style.info("generating native" + _path2.default.sep + "index.node")); | ||
yield (0, _fs.remove)(index); | ||
yield (0, _fs.copy)(dylib, index); | ||
}); | ||
return function main(_x, _x2, _x3) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
})(); | ||
var _fs = require('../async/fs'); | ||
@@ -40,3 +58,3 @@ | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } step("next"); }); }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
@@ -61,18 +79,33 @@ const TEMPLATES_DIR = _path2.default.resolve(__dirname, '..', 'templates'); | ||
function cargo(toolchain, configuration) { | ||
function explicit_cargo_target() { | ||
if (process.platform === 'win32') { | ||
let arch = process.env.npm_config_arch || process.arch; | ||
if (arch === 'ia32') { | ||
return 'i686-pc-windows-msvc'; | ||
} else { | ||
return 'x86_64-pc-windows-msvc'; | ||
} | ||
} | ||
} | ||
function cargo(toolchain, configuration, nodeModuleVersion, target) { | ||
let macos = process.platform === 'darwin'; | ||
var _ref = toolchain === 'default' ? ["cargo", []] : ["multirust", ["run", toolchain]]; | ||
var _ref = toolchain === 'default' ? ["cargo", []] : ["multirust", ["run", toolchain]], | ||
_ref2 = _slicedToArray(_ref, 2); | ||
var _ref2 = _slicedToArray(_ref, 2); | ||
let command = _ref2[0], | ||
prefix = _ref2[1]; | ||
let command = _ref2[0]; | ||
let prefix = _ref2[1]; | ||
let args = prefix.concat(macos ? 'rustc' : 'build', configuration === 'release' ? ["--release"] : [], macos ? ["--", "-C", "link-args=-Wl,-undefined,dynamic_lookup"] : []); | ||
// Save the current Node ABI version as an environment variable. | ||
// Pass the Node modules ABI version to the build as an environment variable. | ||
let env = (0, _shallowCopy2.default)(process.env); | ||
env.NEON_NODE_ABI = process.versions.modules; | ||
env.NEON_NODE_ABI = nodeModuleVersion || process.versions.modules; | ||
if (target) { | ||
args.push("--target=" + target); | ||
} | ||
console.log(style.info([command].concat(args).join(" "))); | ||
@@ -83,21 +116,4 @@ | ||
let main = (function () { | ||
var ref = _asyncToGenerator(function* (name, configuration) { | ||
let pp = process.platform; | ||
let dylib = _path2.default.resolve('native', 'target', configuration, LIB_PREFIX[pp] + name + LIB_SUFFIX[pp]); | ||
let index = _path2.default.resolve('native', 'index.node'); | ||
console.log(style.info("generating native" + _path2.default.sep + "index.node")); | ||
yield (0, _fs.remove)(index); | ||
yield (0, _fs.copy)(dylib, index); | ||
}); | ||
return function main(_x, _x2) { | ||
return ref.apply(this, arguments); | ||
}; | ||
})(); | ||
exports.default = (function () { | ||
var ref = _asyncToGenerator(function* (pwd, toolchain, configuration) { | ||
exports.default = (() => { | ||
var _ref4 = _asyncToGenerator(function* (pwd, toolchain, configuration, nodeModuleVersion) { | ||
// 1. Read the Cargo metadata. | ||
@@ -110,6 +126,8 @@ let metadata = _toml2.default.parse((yield (0, _fs.readFile)(_path2.default.resolve('native', 'Cargo.toml'), 'utf8'))); | ||
let target = explicit_cargo_target(); | ||
console.log(style.info("running cargo")); | ||
// 2. Build the binary. | ||
if ((yield cargo(toolchain, configuration)) !== 0) { | ||
if ((yield cargo(toolchain, configuration, nodeModuleVersion, target)) !== 0) { | ||
throw new Error("cargo build failed"); | ||
@@ -119,8 +137,10 @@ } | ||
// 3. Copy the dylib into the main index.node file. | ||
yield main(metadata.lib.name, configuration); | ||
yield main(metadata.lib.name, configuration, target); | ||
}); | ||
return function neon_build(_x3, _x4, _x5) { | ||
return ref.apply(this, arguments); | ||
}; | ||
function neon_build(_x4, _x5, _x6, _x7) { | ||
return _ref4.apply(this, arguments); | ||
} | ||
return neon_build; | ||
})(); |
'use strict'; | ||
var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })(); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,2 +7,39 @@ value: true | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
let compile = (() => { | ||
var _ref2 = _asyncToGenerator(function* (filename) { | ||
return _handlebars2.default.compile((yield (0, _fs.readFile)(_path2.default.resolve(TEMPLATES_DIR, filename), 'utf8')), { noEscape: true }); | ||
}); | ||
return function compile(_x) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
})(); | ||
let guessAuthor = (() => { | ||
var _ref3 = _asyncToGenerator(function* () { | ||
let author = { | ||
name: process.env.USER || process.env.USERNAME, | ||
email: undefined | ||
}; | ||
try { | ||
let config = yield (0, _gitConfig2.default)(); | ||
if (config.user.name) { | ||
author.name = config.user.name; | ||
} | ||
if (config.user.email) { | ||
author.email = config.user.email; | ||
} | ||
return author; | ||
} catch (e) { | ||
return author; | ||
} | ||
}); | ||
return function guessAuthor() { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
})(); | ||
var _fs = require('../async/fs'); | ||
@@ -46,3 +81,3 @@ | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } step("next"); }); }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
@@ -56,12 +91,2 @@ const ROOT_DIR = _path2.default.resolve(__dirname, '..', '..'); | ||
let compile = (function () { | ||
var ref = _asyncToGenerator(function* (filename) { | ||
return _handlebars2.default.compile((yield (0, _fs.readFile)(_path2.default.resolve(TEMPLATES_DIR, filename), 'utf8')), { noEscape: true }); | ||
}); | ||
return function compile(_x) { | ||
return ref.apply(this, arguments); | ||
}; | ||
})(); | ||
const GITIGNORE_TEMPLATE = compile('.gitignore.hbs'); | ||
@@ -73,28 +98,6 @@ const CARGO_TEMPLATE = compile('Cargo.toml.hbs'); | ||
const README_TEMPLATE = compile('README.md.hbs'); | ||
const BUILDRS_TEMPLATE = compile('build.rs.hbs'); | ||
let guessAuthor = (function () { | ||
var ref = _asyncToGenerator(function* () { | ||
try { | ||
let config = yield (0, _gitConfig2.default)(); | ||
if (config.user.name) { | ||
return { | ||
author: config.user.name, | ||
email: config.user.email | ||
}; | ||
} | ||
} catch (e) { | ||
return { | ||
author: process.env.USER || process.env.USERNAME, | ||
email: undefined | ||
}; | ||
} | ||
}); | ||
return function guessAuthor() { | ||
return ref.apply(this, arguments); | ||
}; | ||
})(); | ||
exports.default = (function () { | ||
var ref = _asyncToGenerator(function* (pwd, name, toolchain) { | ||
exports.default = (() => { | ||
var _ref4 = _asyncToGenerator(function* (pwd, name, toolchain) { | ||
let its = (0, _validateNpmPackageName2.default)(name); | ||
@@ -109,8 +112,8 @@ if (!its.validForNewPackages) { | ||
var _ref = scoped || [, null, name]; | ||
var _ref5 = scoped || [, null, name], | ||
_ref6 = _slicedToArray(_ref5, 3); | ||
var _ref2 = _slicedToArray(_ref, 3); | ||
let scope = _ref6[1], | ||
local = _ref6[2]; | ||
let scope = _ref2[1]; | ||
let local = _ref2[2]; | ||
@@ -136,3 +139,3 @@ console.log("This utility will walk you through creating the " + style.project(name) + " Neon project."); | ||
} | ||
}, { type: 'input', name: 'description', message: "description" }, { type: 'input', name: 'node', message: "node entry point", default: "lib" + _path2.default.sep + "index.js" }, { type: 'input', name: 'git', message: "git repository" }, { type: 'input', name: 'author', message: "author", default: guess.author }, { type: 'input', name: 'email', message: "email", default: guess.email }, { | ||
}, { type: 'input', name: 'description', message: "description" }, { type: 'input', name: 'node', message: "node entry point", default: "lib" + _path2.default.sep + "index.js" }, { type: 'input', name: 'git', message: "git repository" }, { type: 'input', name: 'author', message: "author", default: guess.name }, { type: 'input', name: 'email', message: "email", default: guess.email }, { | ||
type: 'input', | ||
@@ -191,2 +194,3 @@ name: 'license', | ||
yield (0, _fs.writeFile)(_path2.default.resolve(src, 'lib.rs'), (yield LIBRS_TEMPLATE)(ctx), { flag: 'wx' }); | ||
yield (0, _fs.writeFile)(_path2.default.resolve(native_, 'build.rs'), (yield BUILDRS_TEMPLATE)(ctx), { flag: 'wx' }); | ||
@@ -209,5 +213,7 @@ let relativeRoot = _path2.default.relative(pwd, root); | ||
return function wizard(_x2, _x3, _x4) { | ||
return ref.apply(this, arguments); | ||
}; | ||
function wizard(_x2, _x3, _x4) { | ||
return _ref4.apply(this, arguments); | ||
} | ||
return wizard; | ||
})(); |
{ | ||
"name": "neon-cli", | ||
"version": "0.1.7", | ||
"version": "0.1.11", | ||
"description": "Build and load native Rust/Neon modules.", | ||
@@ -8,3 +8,3 @@ "author": "Dave Herman <dherman@mozilla.com>", | ||
"type": "git", | ||
"url": "https://github.com/rustbridge/neon-cli.git" | ||
"url": "https://github.com/neon-bindings/neon-cli.git" | ||
}, | ||
@@ -47,5 +47,5 @@ "main": "lib/index.js", | ||
"bugs": { | ||
"url": "https://github.com/rustbridge/neon-cli/issues" | ||
"url": "https://github.com/neon-bindings/neon-cli/issues" | ||
}, | ||
"homepage": "https://github.com/rustbridge/neon-cli" | ||
"homepage": "https://github.com/neon-bindings/neon-cli" | ||
} |
@@ -1,7 +0,7 @@ | ||
# Neon-cli | ||
# The Neon Command-Line Tool | ||
[![Build Status](https://travis-ci.org/rustbridge/neon-cli.svg?branch=master)](https://travis-ci.org/rustbridge/neon-cli) | ||
[![Build Status](https://travis-ci.org/neon-bindings/neon-cli.svg?branch=master)](https://travis-ci.org/neon-bindings/neon-cli) | ||
[![npm](https://img.shields.io/npm/v/neon-cli.svg)](https://www.npmjs.com/package/neon-cli) | ||
Automatically create and build [Neon](https://github.com/rustbridge/neon) modules. | ||
Automatically create and build [Neon](https://github.com/neon-bindings/neon) modules. | ||
@@ -28,13 +28,4 @@ ![Screencast](screencast.gif) | ||
You'll need the following on all OSes: | ||
See the [Neon README](https://github.com/neon-bindings/neon/#requirements). | ||
* [Node](http://nodejs.org) v4 or later; | ||
* [Rust](http://rust-lang.org) v1.5 or later; | ||
* [multirust](https://github.com/brson/multirust) (only required for Neon projects that override the system default Rust). | ||
For Mac OS X, you'll need: | ||
* OS X 10.7 or later; | ||
* [XCode](https://developer.apple.com/xcode/download/). | ||
# Commands | ||
@@ -59,8 +50,6 @@ | ||
The [Rust Bridge community Slack](http://rustbridge.slack.com) is open to all; use [the Slackin app](http://rustbridge-community-slackin.herokuapp.com) to receive an invitation. | ||
The [Rust Bindings community Slack](https://rust-bindings.slack.com/) is open to all; use [the Slackin app](https://rust-bindings-slackin.herokuapp.com/) to receive an invitation. | ||
There's also an IRC channel at `#neon` on [Mozilla IRC](https://wiki.mozilla.org/IRC) (`irc.mozilla.org`). | ||
# License | ||
MIT |
@@ -15,2 +15,5 @@ import path from 'path'; | ||
console.log(); | ||
console.log(" neon build [--rust|-r nightly|stable|default] [--debug|-d]"); | ||
console.log(" rebuild the project"); | ||
console.log(); | ||
console.log(" neon version"); | ||
@@ -51,3 +54,4 @@ console.log(" print neon-cli version"); | ||
this.args.rust || this.args.r || 'default', | ||
this.args.debug || this.args.d ? 'debug' : 'release'); | ||
this.args.debug || this.args.d ? 'debug' : 'release', | ||
this.args.node_module_version); | ||
} | ||
@@ -54,0 +58,0 @@ }; |
@@ -28,3 +28,14 @@ import { remove, copy, readFile } from '../async/fs'; | ||
function cargo(toolchain, configuration) { | ||
function explicit_cargo_target() { | ||
if (process.platform === 'win32') { | ||
let arch = process.env.npm_config_arch || process.arch; | ||
if (arch === 'ia32') { | ||
return 'i686-pc-windows-msvc'; | ||
} else { | ||
return 'x86_64-pc-windows-msvc'; | ||
} | ||
} | ||
} | ||
function cargo(toolchain, configuration, nodeModuleVersion, target) { | ||
let macos = process.platform === 'darwin'; | ||
@@ -40,6 +51,10 @@ | ||
// Save the current Node ABI version as an environment variable. | ||
// Pass the Node modules ABI version to the build as an environment variable. | ||
let env = clone(process.env); | ||
env.NEON_NODE_ABI = process.versions.modules; | ||
env.NEON_NODE_ABI = nodeModuleVersion || process.versions.modules; | ||
if (target) { | ||
args.push("--target=" + target); | ||
} | ||
console.log(style.info([command].concat(args).join(" "))); | ||
@@ -50,5 +65,8 @@ | ||
async function main(name, configuration) { | ||
async function main(name, configuration, target) { | ||
let pp = process.platform; | ||
let dylib = path.resolve('native', 'target', configuration, LIB_PREFIX[pp] + name + LIB_SUFFIX[pp]); | ||
let output_directory = target ? | ||
path.resolve('native', 'target', target, configuration) : | ||
path.resolve('native', 'target', configuration); | ||
let dylib = path.resolve(output_directory, LIB_PREFIX[pp] + name + LIB_SUFFIX[pp]); | ||
let index = path.resolve('native', 'index.node'); | ||
@@ -62,3 +80,3 @@ | ||
export default async function neon_build(pwd, toolchain, configuration) { | ||
export default async function neon_build(pwd, toolchain, configuration, nodeModuleVersion) { | ||
// 1. Read the Cargo metadata. | ||
@@ -71,6 +89,8 @@ let metadata = TOML.parse(await readFile(path.resolve('native', 'Cargo.toml'), 'utf8')); | ||
let target = explicit_cargo_target(); | ||
console.log(style.info("running cargo")); | ||
// 2. Build the binary. | ||
if ((await cargo(toolchain, configuration)) !== 0) { | ||
if ((await cargo(toolchain, configuration, nodeModuleVersion, target)) !== 0) { | ||
throw new Error("cargo build failed"); | ||
@@ -80,3 +100,3 @@ } | ||
// 3. Copy the dylib into the main index.node file. | ||
await main(metadata.lib.name, configuration); | ||
await main(metadata.lib.name, configuration, target); | ||
} |
@@ -28,17 +28,20 @@ import { readFile, writeFile, mkdirs } from '../async/fs'; | ||
const README_TEMPLATE = compile('README.md.hbs'); | ||
const BUILDRS_TEMPLATE = compile('build.rs.hbs'); | ||
async function guessAuthor() { | ||
let author = { | ||
name: process.env.USER || process.env.USERNAME, | ||
email: undefined | ||
}; | ||
try { | ||
let config = await gitconfig(); | ||
if (config.user.name) { | ||
return { | ||
author: config.user.name, | ||
email: config.user.email | ||
}; | ||
author.name = config.user.name; | ||
} | ||
if (config.user.email) { | ||
author.email = config.user.email; | ||
} | ||
return author; | ||
} catch (e) { | ||
return { | ||
author: process.env.USER || process.env.USERNAME, | ||
email: undefined | ||
}; | ||
return author; | ||
} | ||
@@ -82,3 +85,3 @@ } | ||
{ type: 'input', name: 'git', message: "git repository" }, | ||
{ type: 'input', name: 'author', message: "author", default: guess.author }, | ||
{ type: 'input', name: 'author', message: "author", default: guess.name }, | ||
{ type: 'input', name: 'email', message: "email", default: guess.email }, | ||
@@ -142,2 +145,3 @@ { | ||
await writeFile(path.resolve(src, 'lib.rs'), (await LIBRS_TEMPLATE)(ctx), { flag: 'wx' }); | ||
await writeFile(path.resolve(native_, 'build.rs'), (await BUILDRS_TEMPLATE)(ctx), { flag: 'wx' }); | ||
@@ -144,0 +148,0 @@ let relativeRoot = path.relative(pwd, root); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
899
43629
38
54
15