New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →
Socket
Sign inDemoInstall
Socket

one

Package Overview
Dependencies
Maintainers
1
Versions
216
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

one - npm Package Compare versions

Comparing version 2.0.11 to 2.5.0

docs/man

31

lib/chaining.js

@@ -1,2 +0,3 @@

var modules = require('./modules'),
var debug = require('./debug')('chaining'),
modules = require('./modules'),
index = require('./index'),

@@ -10,3 +11,3 @@ main = index.main;

alias : alias,
debug : debug,
debug : enableDebug,
dependency : dependency,

@@ -29,3 +30,6 @@ devDependencies : devDependencies,

debug('Manifest: %s', manifest);
function alias(name, orig){
debug('Registering new alias for %s: %s', orig, name);
options.alias.push({ name: name, orig: orig });

@@ -35,3 +39,4 @@ return chain;

function debug(){
function enableDebug(){
debug('SourceUrls enabled');
options.debug = true;

@@ -42,2 +47,5 @@ return chain;

function dependency(name, version){
if(!name) return;
debug('Added new dependency %s v%s', name, version);
options.addDeps || (options.addDeps = {});

@@ -49,2 +57,3 @@ options.addDeps[name] = version;

function devDependencies(){
debug('Enabled devDependencies');
options.devDependencies = true;

@@ -55,2 +64,3 @@ return chain;

function exclude(pkg){
debug('%s will be excluded', Array.prototype.join.call(arguments, ','));
options.exclude.push.apply(options.exclude, arguments);

@@ -61,2 +71,4 @@ return chain;

function filter(regex){
debug('%s will be filtered', regex);
modules.filters.push(function(filename){

@@ -69,3 +81,5 @@ return !regex.test(filename);

function include(fiename){
function include(){
debug('%s will be included to the bundle', Array.prototype.join.call(arguments, ','));
modules.toInclude.push.apply(modules.toInclude, arguments);

@@ -76,2 +90,4 @@ return chain;

function name(bundleName){
debug('Bundle renamed to %s', bundleName);
options.bundleName = bundleName;

@@ -82,2 +98,4 @@ return chain;

function tie(module, to){
debug('%s tied to %s', module, to);
options.tie.push({ module: module, to: to });

@@ -88,2 +106,3 @@ return chain;

function save(/* [filename,] callback */){
var callback;

@@ -94,6 +113,8 @@

callback = arguments[1];
} else {
} else if(typeof arguments[0] == 'function') {
callback = options.callback = arguments[0];
}
options.target && debug('Saving to %s', options.target);
main(manifest, options, callback || function(error){

@@ -100,0 +121,0 @@ if(error) throw error;

14

lib/dependencies.js

@@ -1,6 +0,6 @@

var path = require('path'),
readdir = require('fs').readdir,
logging = require('./logging'),
manifest = require('./manifest'),
excludeds = require('./excludeds'),
var path = require('path'),
readdir = require('fs').readdir,
debug = require('./debug')('dependencies'),
manifest = require('./manifest'),
excludeds = require('./excludeds'),
pkg;

@@ -48,3 +48,3 @@

if(i>=declaredDepList.length){
logging.debug('Loaded %d dependencies under the package "%s"',deps.length, parent.manifest.name);
debug('Loaded %d dependencies under the package "%s"',deps.length, parent.manifest.name);
callback(undefined, deps);

@@ -65,3 +65,3 @@ return;

logging.debug('Loading the dependency "%s" for its parent package "%s"', name + ' ('+ manifestPath +')', parent.name);
debug('Loading the dependency "%s" for its parent package "%s"', name + ' ('+ manifestPath +')', parent.name);

@@ -68,0 +68,0 @@ if(parent.pkgdict[name]){

@@ -9,4 +9,3 @@ var path = require('path'),

logging = require('./logging'),
server = require('./server'),
debug = require('./debug')('index'),
targets = require('./targets'),

@@ -31,10 +30,5 @@

module.exports.modules = require('./modules');
module.exports.logging = logging;
module.exports.quiet = quiet;
module.exports.publish = publish;
module.exports.save = save;
module.exports.targets = targets;
module.exports.templating = templating;
module.exports.verbose = verbose;
module.exports.verbosity = verbosity;

@@ -64,3 +58,3 @@ function build(pkg, buildOptions, callback){

function iter(filename, callback){
logging.info('Saving %s', filename);
debug('Saving %s', filename);
save(filename, bundle[filename], callback);

@@ -109,3 +103,3 @@ }

if(error){
logging.warn('Failed to read .npmignore');
debug('Failed to read .npmignore');
callback();

@@ -121,12 +115,8 @@ return;

function quiet(y){
logging.setLevel('ERROR');
}
function save(target, content, callback){
logging.debug('Saving output into ' + target);
debug('Saving output into ' + target);
fs.writeFile(target, content, function(error) {
if(error) {
logging.error('Failed to write the target file "'+target+'"');
debug('Failed to write the target file "'+target+'"');
callback(error);

@@ -136,23 +126,5 @@ return;

logging.info('The target file "'+target+'" was saved!');
debug('The target file "'+target+'" was saved!');
callback();
});
}
function publish(options){
options.returnPackage = true;
build(options, function(error, built, pkg){
if(error) throw error;
options.content = built;
options.pkg = pkg;
server.start(options);
});
}
function verbose(){
logging.setLevel('TRACE');
}
function verbosity(level){
logging.setLevel(level);
}
var boxcars = require('boxcars'),
path = require('path'),
fs = require("fs"),
logging = require('./logging');
debug = require('./debug')('manifest');

@@ -29,3 +29,3 @@ function paths(pkg, dir){

logging.debug('Searching for the manifest file of package "%s" under "%s"', packageName, workingdir);
debug('Searching for the manifest file of package "%s" under "%s"', packageName, workingdir);

@@ -44,3 +44,3 @@ found = paths(packageName, workingdir).some(function(dir){

if(!found){
logging.error('Failed to find package "%s"', packageName);
debug('Failed to find package "%s"', packageName);
return callback(new Error('Failed to find package "' + packageName + '"'));

@@ -64,3 +64,3 @@ }

function read(filename, callback){
logging.debug('Reading the manifest @ "%s"', filename);
debug('Reading the manifest @ "%s"', filename);

@@ -72,3 +72,3 @@ var manifest;

if(error){
logging.error('Failed to read the file "%s"', filename);
debug('Failed to read the file "%s"', filename);
callback(error);

@@ -78,3 +78,3 @@ return;

logging.debug('Parsing the manifest @ "%s"', filename);
debug('Parsing the manifest @ "%s"', filename);

@@ -84,7 +84,7 @@ try {

manifest = JSON.parse(bf);
logging.trace('Manifest file "%s" loaded and parsed successfully.', filename);
debug('Manifest file "%s" loaded and parsed successfully.', filename);
} catch(exc) {
logging.error('Failed to parse the manifest @ "%s"', filename);
debug('Failed to parse the manifest @ "%s"', filename);
error = exc;

@@ -91,0 +91,0 @@

@@ -8,3 +8,3 @@ var functools = require('functools'),

logging = require('./logging');
debug = require('./debug')('modules');

@@ -63,3 +63,3 @@ var filters = [],

if( filename.substring( 0, ignore.length ) == ignore ){
logging.debug('Module "%s" is ignored by the line "%s" at .npmignore', filename, ignore);
debug('Module "%s" is ignored by the line "%s" at .npmignore', filename, ignore);
ignored = true;

@@ -88,3 +88,3 @@ break;

logging.trace('Loading module "'+filename+'"');
debug('Loading module "'+filename+'"');

@@ -118,3 +118,3 @@ readFile(filename, function(error, bf){

return function(filenames, callback){
logging.debug('Found '+filenames.length+' file(s) under the package "'+pkg.name+'"');
debug('Found '+filenames.length+' file(s) under the package "'+pkg.name+'"');
var modules = [];

@@ -124,3 +124,3 @@

if(i>=filenames.length){
logging.debug('Loaded %d module(s) under the package "%s"',filenames.length,pkg.name);
debug('Loaded %d module(s) under the package "%s"',filenames.length,pkg.name);
callback(undefined, modules);

@@ -132,3 +132,3 @@ return;

if(error){
logging.error('Failed to load the module "'+filenames[i]+'"');
debug('Failed to load the module "'+filenames[i]+'"');
callback(error);

@@ -162,3 +162,3 @@ return;

function modules(pkg, options, callback){
logging.debug('Collect modules for the package "'+pkg.name+'"');
debug('Collect modules for the package "'+pkg.name+'"');

@@ -186,3 +186,3 @@ var dirs = [],

logging.debug('The directories to search:', dirs);
debug('The directories to search:', dirs);

@@ -189,0 +189,0 @@ compose.async(combiner.findFiles,

var path = require('path'),
readFile = require('fs').readFile,
debug = require('./debug')('npmignore');
logging = require('./logging');
function filename(dir){

@@ -26,3 +25,3 @@ return path.join(dir, '.npmignore');

logging.debug('%s has been loaded and parsed.', filename(dir));
debug('%s has been loaded and parsed.', filename(dir));

@@ -29,0 +28,0 @@ callback(undefined, lines);

@@ -6,3 +6,3 @@ var path = require('path'),

logging = require('./logging'),
debug = require('./debug')('package'),
id = require('./id'),

@@ -45,3 +45,3 @@ manifest = require('./manifest'),

logging.debug('Loading dependencies of %s', pkg.name);
debug('Loading dependencies of %s', pkg.name);

@@ -51,4 +51,4 @@ dependencies(pkg, options, function(error, deps){

if(error){
logging.error('An unexpected error occurred during collecting dependencies of the package "%s".', pkg.name);
logging.error(error);
debug('An unexpected error occurred during collecting dependencies of the package "%s".', pkg.name);
debug(error);
callback(error);

@@ -58,3 +58,3 @@ return;

logging.debug('%d dependencies has been loaded for the package "%s"', deps.length, pkg.name);
debug('%d dependencies has been loaded for the package "%s"', deps.length, pkg.name);

@@ -73,4 +73,4 @@ pkg.dependencies = deps;

if(error){
logging.error('An unexpected error occurred during collecting modules of the package "%s".', pkg.name);
logging.error(error);
debug('An unexpected error occurred during collecting modules of the package "%s".', pkg.name);
debug(error);
callback(error);

@@ -80,3 +80,3 @@ return;

logging.debug('Collected %d modules for the package "%s"', modules.length, pkg.name);
debug('Collected %d modules for the package "%s"', modules.length, pkg.name);

@@ -103,3 +103,3 @@ pkg.modules = modules;

logging.debug('Setting main module of the package "%s" as %s', pkg.name, pkg.manifest.main);
debug('Setting main module of the package "%s" as %s', pkg.name, pkg.manifest.main);

@@ -124,3 +124,3 @@ var absolutePath = path.join(pkg.wd, pkg.manifest.main );

logging.fatal(errormsg);
debug(errormsg);
callback(new Error(errormsg));

@@ -133,3 +133,3 @@ }

function content(pkg, options, callback){
logging.debug('Loading the package "%s"', pkg.manifest.name);
debug('Loading the package "%s"', pkg.manifest.name);

@@ -142,3 +142,3 @@ compose.async(loadDependencies, loadModules, setMainModule)({ 'pkg': pkg, 'options': options }, function(error){

logging.info('%s loaded.', pkg.name);
debug('%s loaded.', pkg.name);
callback(undefined, pkg);

@@ -157,3 +157,3 @@

logging.trace('Building the package at "%s"', manifestPath);
debug('Building the package at "%s"', manifestPath);

@@ -160,0 +160,0 @@ manifest(manifestPath, function(error, manifestObj){

var readFile = require('fs').readFile,
map = require('functools').map.async,
logging = require('../../logging'),
debug = require('../../debug')('dynamic/index'),
flattenPkgTree = require('../flatten'),

@@ -15,3 +15,3 @@ objectName = require('../object_name'),

function dynamic(pkg, options, callback){
logging.info('Rendering %s', pkg.name);
debug('Rendering %s', pkg.name);

@@ -22,3 +22,3 @@ var bundleName = options.bundleName || (pkg.manifest.web && pkg.manifest.web.name) || objectName(pkg.name),

map(renderPackageTree.bind(undefined, options, bundleName), trees, function(error, output){
logging.info('All packages has been built. Rendering wrapper now...');
debug('All packages has been built. Rendering wrapper now...');

@@ -25,0 +25,0 @@ var mainTarget = options.save[pkg.name].to;

@@ -1,11 +0,11 @@

var juxt = require('functools').juxt.async,
logging = require('../../logging'),
env = require('../env'),
version = require('../version'),
templates = require('./templates'),
oneJSPath = require('./path');
var juxt = require('functools').juxt.async,
selfPath = require('./path'),
debug = require('../../debug')('library'),
env = require('../env'),
version = require('../version'),
templates = require('./templates');
function library(options, callback){
logging.trace('Rendering library...');
debug('Rendering library...');

@@ -19,3 +19,3 @@ var view = {

juxt({ 'path': oneJSPath })(options, function(error, partials){
juxt({ 'path': selfPath })(options, function(error, partials){

@@ -22,0 +22,0 @@ if(error){

@@ -1,6 +0,6 @@

var logging = require('../../logging'),
var debug = require('../../debug')('dynamic/module'),
templates = require('./templates');
module.exports = function oneJSModule(pkg, treeName, options, module, callback){
logging.debug('Building module "'+module.id+'"');
debug('Building module "'+module.id+'"');

@@ -7,0 +7,0 @@ var view = {

var map = require('functools').map.async,
logging = require('../../logging'),
debug = require('../../debug')('dynamic/package'),
templates = require('./templates'),

@@ -16,3 +16,3 @@ oneJSModule = require('./module');

logging.debug('Building package "'+pkg.name+'"');
debug('Building package "'+pkg.name+'"');

@@ -19,0 +19,0 @@ var modules = pkg.modules.sort(sort),

@@ -1,8 +0,8 @@

var logging = require('../../logging'),
var debug = require('../../debug')('dynamic/registry'),
templates = require('./templates');
module.exports = function registryTemplate(options, callback){
logging.debug('Rendering registry');
debug('Rendering registry');
templates.registry(options, callback);
};

@@ -1,8 +0,8 @@

var logging = require('../../logging'),
var debug = require('../../debug')('require'),
templates = require('./templates');
module.exports = function requireTemplate(options, callback){
logging.debug('Rendering require');
debug('Rendering require');
templates.require(options, callback);
};

@@ -1,2 +0,2 @@

var logging = require('../../logging'),
var debug = require('../../debug')('dynamic/wrapper'),
ownrequire = require('./require'),

@@ -27,3 +27,3 @@ registry = require('./registry'),

function wrapper(pkg, treeName, renderedPackages, options, callback){
logging.trace('Rendering wrapper template...');
debug('Rendering wrapper template...');

@@ -30,0 +30,0 @@ var partials = {},

@@ -1,7 +0,7 @@

var logging = require('../../logging'),
objectName = require('../object_name'),
templates = require('./templates');
var debug = require('../../debug')('plain'),
objectName = require('../object_name'),
templates = require('./templates');
function plain(pkg, options, callback){
logging.info('Rendering %s', pkg.name);
debug('Rendering %s', pkg.name);

@@ -8,0 +8,0 @@ templates.wrapper({ 'name': objectName(pkg.name), 'content': pkg.modules[0].content }, function(error, bf){

{
"name": "one",
"version": "2.0.11",
"version": "2.5.0",
"description": "Transform NodeJS packages into single stand-alone script files.",

@@ -24,3 +24,4 @@ "author": "Azer Koculu <azer@kodfabrik.com>",

"log4js": "0.6.x",
"boxcars": "0.x"
"boxcars": "0.x",
"debug": "*"
},

@@ -27,0 +28,0 @@ "devDependencies": {

OneJS is a command-line utility for converting CommonJS packages to single, stand-alone JavaScript
files that can be run on web browsers.
**Current Version:** 2.0.8
```bash
$ one > browser.js
```

@@ -271,2 +273,27 @@ # MOTIVATION

<a name="add-deps"></a>
### Additional Dependencies
You may add some dependencies not defined in your package.json;
```js
one('./package.json')
.dependency('request', '2.x')
.dependency('async', '2.x')
.save(function(error, bundle){
bundle
// => the source code
})
```
<a name="dev-deps"></a>
### Enabling Development Dependencies
```js
one('./package.json')
.devDependencies()
.save('bundle.js')
```
<a name="customize-name"></a>

@@ -353,6 +380,14 @@ ### Customizing Global Variable

.tie('json', 'JSON')
.include('optional-module.js')
.dependency('optional-dependency', '2.x')
.exclude('underscore')
.filter(/^build\.js$/)
.filter(/^bundle\.js$/)
.save('bundle.js');
.devDependencies()
.name('helloKitty')
.save('bundle.js'); // or .save(function(error, bundle){ })
```

@@ -364,2 +399,3 @@

* [Fox](https://github.com/azer/fox/blob/master/lib/browser.js#L19)
* See the example project included in this repository

@@ -366,0 +402,0 @@ * MultiplayerChess.com ([Source Code](https://github.com/azer/multiplayerchess.com/tree/master/frontend) - [Output](http://multiplayerchess.com/mpc.js) )

@@ -55,1 +55,5 @@ var {{ name }} = (function(){

}
if(typeof window != 'undefined' && typeof require == 'undefined'){
window.require = {{name}}.require;
}

@@ -1,14 +0,194 @@

var vegetables = (function(undefined){
var vegetables = (function(){
var exports = {}, module = { 'exports': exports };
var pkgmap = {},
global = {},
nativeRequire = typeof require != 'undefined' && require,
lib, ties, main, async;
function exports(){ return main(); };
exports.main = exports;
exports.module = module;
exports.packages = pkgmap;
exports.pkg = pkg;
exports.require = function require(uri){
return pkgmap.main.index.require(uri);
};
ties = {};
aliases = {};
return exports;
function join() {
return normalize(Array.prototype.join.call(arguments, "/"));
};
function normalize(path) {
var ret = [], parts = path.split('/'), cur, prev;
var i = 0, l = parts.length-1;
for (; i <= l; i++) {
cur = parts[i];
if (cur === "." && prev !== undefined) continue;
if (cur === ".." && ret.length && prev !== ".." && prev !== "." && prev !== undefined) {
ret.pop();
prev = ret.slice(-1)[0];
} else {
if (prev === ".") ret.pop();
ret.push(cur);
prev = cur;
}
}
return ret.join("/");
};
function dirname(path) {
return path && path.substr(0, path.lastIndexOf("/")) || ".";
};
function findModule(workingModule, uri){
var moduleId = join(dirname(workingModule.id), /\.\/$/.test(uri) ? (uri + 'index') : uri ).replace(/\.js$/, ''),
moduleIndexId = join(moduleId, 'index'),
pkg = workingModule.pkg,
module;
var i = pkg.modules.length,
id;
while(i-->0){
id = pkg.modules[i].id;
if(id==moduleId || id == moduleIndexId){
module = pkg.modules[i];
break;
}
}
return module;
}
function newRequire(callingModule){
function require(uri){
var module, pkg;
if(/^\./.test(uri)){
module = findModule(callingModule, uri);
} else if ( ties && ties.hasOwnProperty( uri ) ) {
return ties[uri];
} else if ( aliases && aliases.hasOwnProperty( uri ) ) {
return require(aliases[uri]);
} else {
pkg = pkgmap[uri];
if(!pkg && nativeRequire){
try {
pkg = nativeRequire(uri);
} catch (nativeRequireError) {}
if(pkg) return pkg;
}
if(!pkg){
throw new Error('Cannot find module "'+uri+'" @[module: '+callingModule.id+' package: '+callingModule.pkg.name+']');
}
module = pkg.index;
}
if(!module){
throw new Error('Cannot find module "'+uri+'" @[module: '+callingModule.id+' package: '+callingModule.pkg.name+']');
}
module.parent = callingModule;
return module.call();
};
return require;
}
function module(parent, id, wrapper){
var mod = { pkg: parent, id: id, wrapper: wrapper },
cached = false;
mod.exports = {};
mod.require = newRequire(mod);
mod.call = function(){
if(cached) {
return mod.exports;
}
cached = true;
global.require = mod.require;
mod.wrapper(mod, mod.exports, global, global.require);
return mod.exports;
};
if(parent.mainModuleId == mod.id){
parent.index = mod;
parent.parents.length === 0 && ( main = mod.call );
}
parent.modules.push(mod);
}
function pkg(/* [ parentId ...], wrapper */){
var wrapper = arguments[ arguments.length - 1 ],
parents = Array.prototype.slice.call(arguments, 0, arguments.length - 1),
ctx = wrapper(parents);
pkgmap[ctx.name] = ctx;
arguments.length == 1 && ( pkgmap.main = ctx );
return function(modules){
var id;
for(id in modules){
module(ctx, id, modules[id]);
}
};
}
}(this));
vegetables.pkg(function(parents){
return {
'name' : 'vegetables',
'mainModuleId' : 'lib/index',
'modules' : [],
'parents' : parents
};
})({ 'lib/index': function(module, exports, global, require, undefined){
module.exports = ['tomato', 'potato'];
},
return module.exports;
});
})();
if(typeof module != 'undefined' && module.exports){
if(typeof module != 'undefined' && module.exports ){
module.exports = vegetables;
};
if( !module.parent ){
vegetables();
}
}
if(typeof window != 'undefined' && typeof require == 'undefined'){
window.require = vegetables.require;
}

@@ -234,2 +234,19 @@ var exampleProject = (function(){

exampleProject.pkg("example-project", "subdependency", function(parents){
return {
'name' : 'exclude',
'mainModuleId' : 'index',
'modules' : [],
'parents' : parents
};
})({ 'index': function(module, exports, global, require, undefined){
exports.exclude = true;
},
});
exampleProject.pkg("dependency", function(parents){

@@ -369,1 +386,5 @@

}
if(typeof window != 'undefined' && typeof require == 'undefined'){
window.require = exampleProject.require;
}

@@ -234,1 +234,5 @@ var s_a_i = (function(){

}
if(typeof window != 'undefined' && typeof require == 'undefined'){
window.require = s_a_i.require;
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc