Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

one

Package Overview
Dependencies
Maintainers
1
Versions
207
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 1.7.12 to 1.8.1

lib/excludeds.js

35

lib/dependencies.js

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

manifest = require('./manifest'),
installDict = Object.keys(require('./install_dict')),
excludeds = require('./excludeds'),
pkg;

@@ -14,23 +13,6 @@

function nodeCorePackages(pkg, callback){
readdir( path.join(pkg.wd, 'node_modules'), function(error, files){
if(error){
callback([]);
return;
}
callback(files.filter(function(el){
return installDict.indexOf(el) > -1;
}));
});
}
function dependencies(parent, options, callback){
var deps = [],
declaredDepObj = parent.manifest.dependencies,
exclude = excludeds(parent, options),
declaredDepList,

@@ -41,13 +23,6 @@ next;

declaredDepList = Object.keys(declaredDepObj).filter(function(name){
return BLACK_LIST.indexOf(name) == -1 && ( !options.exclude || options.exclude.indexOf(name) == -1 );
return BLACK_LIST.indexOf(name) == -1 && ( exclude.indexOf(name) == -1 );
});
}
nodeCorePackages(parent, function(installedNodeCorePackages){
if(installedNodeCorePackages.length){
!declaredDepList && ( declaredDepList = [] );
declaredDepList = declaredDepList.concat(installedNodeCorePackages);
}
if(!declaredDepList || !declaredDepList.length){

@@ -97,8 +72,4 @@ callback(undefined, deps);

})(0);
});
};
module.exports = dependencies;

@@ -10,3 +10,2 @@ var genpkg = require('genpkg'),

server = require('./server'),
installDict = require('./install_dict'),

@@ -31,7 +30,5 @@ manifest = require('./manifest'),

toIgnore && ( pkgOptions.ignore = toIgnore );
templating(pkgOptions, buildOptions, callback);
});
}

@@ -65,3 +62,4 @@

function save(target, content, callback){
logging.debug('Saving output into '+target);
logging.debug('Saving output into ' + target);
fs.writeFile(target, content, function(error) {

@@ -89,41 +87,2 @@ if(error) {

function setupNodeModules(/* modules */){
var pkgs = slice.call(arguments, 0, arguments.length-1),
callback = arguments[arguments.length - 1],
len = pkgs.length;
var pkgName, pkgURI, next;
(function iter(i, error){
if(i>=len || error){
callback(error);
return;
}
pkgName = pkgs[i];
pkgURI = installDict[pkgName];
if(!pkgURI){
logging.error('Unknown package "%s" ', pkgName);
callback(new Error('Unknown package "%s"', pkgName));
return;
}
next = iter.bind(undefined, i+1);
genpkg.pkg({ 'uri':pkgURI }, function(error, pkg){
if(error){
throw error;
}
pkg.target = path.join('node_modules', pkg.manifest.name);
genpkg.save(pkg, next);
});
})(0);
}
function verbose(){

@@ -149,3 +108,2 @@ logging.setLevel('TRACE');

'save': save,
'setupNodeModules': setupNodeModules,
'templating': templating,

@@ -152,0 +110,0 @@ 'verbose': verbose,

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

if( ! pkg.manifest.main ){
callback(undefined, pkg, options);
return callback(undefined, pkg, options);
}

@@ -98,0 +98,0 @@

@@ -14,3 +14,2 @@ var readFile = require('fs').readFile,

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

@@ -21,6 +20,5 @@

options.includeProcess = !options.noprocess;
// FIXME split packages here!
map( npmpackage.bind(undefined, treeName, options), tree, function(error, packages){
map(npmpackage.bind(undefined, treeName, options), tree, function(error, packages){
if(error){

@@ -33,6 +31,4 @@ callback(error);

wrapper(treeName, packages.join('\n\n\n\n'), options, callback);
wrapper(pkg, treeName, packages.join('\n\n\n\n'), options, callback);
});
}

@@ -39,0 +35,0 @@

@@ -10,5 +10,3 @@ var juxt = require('functools').juxt.async,

oneJSPath = require('./path'),
oneJSConsole = require('./console'),
oneJSProcess = require('./process');
oneJSPath = require('./path');

@@ -23,8 +21,6 @@ function library(options, callback){

versions : '{}',
env : env(options),
sandbox_console : options.sandboxConsole,
include_process : options.includeProcess
env : env(options)
};
juxt({ 'path': oneJSPath, 'process': oneJSProcess, 'console': oneJSConsole })(options, function(error, partials){
juxt({ 'path': oneJSPath })(options, function(error, partials){

@@ -31,0 +27,0 @@ if(error){

@@ -12,4 +12,2 @@ var logging = require('../../logging'),

'id' : module.id,
'sandbox_console' : options.sandboxConsole,
'include_process' : options.includeProcess,
'content' : module.content

@@ -16,0 +14,0 @@ };

var map = require('functools').map.async,
logging = require('../../logging'),
templates = require('./templates'),
oneJSModule = require('./module');

@@ -8,0 +5,0 @@

@@ -7,6 +7,4 @@ var coll = require('../coll');

'dynamic/module.js',
'dynamic/console.js',
'dynamic/library.js',
'dynamic/path.js',
'dynamic/process.js'
'dynamic/path.js'
);
var logging = require('../../logging'),
library = require('./library'),
templates = require('./templates');
templates = require('./templates'),
ties = require('../../ties');
function ties(options){
function renderTies(ties){
var output = '{',
key, comma = '';
if(!options.tie){
return undefined;
}
var output = '{', key,
i = options.tie.length,
comma = '',
tie;
while( i -- ){
tie = options.tie[i];
output += comma + '"'+ ( tie.pkg || tie.module ) + '": ' + ( tie.obj || tie.to );
for(key in ties){
output += comma + '"' + key + '": ' + ties[key];
comma = ', ';

@@ -27,3 +20,3 @@ }

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

@@ -35,5 +28,3 @@

'debug' : options.debug,
'ties' : ties(options),
'sandbox_console' : options.sandboxConsole,
'include_process' : options.includeProcess
'ties' : renderTies(ties(pkg, options))
};

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

views.packages = packages;
views.packages = renderedPackages;
views.library = renderedLibrary;

@@ -51,0 +42,0 @@

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

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

"log4js":"0.4.1",
"genpkg":"0.x",
"boxcars":"0.x"

@@ -22,0 +21,0 @@ },

@@ -26,6 +26,4 @@ OneJS is a command-line utility for converting CommonJS packages to single, stand-alone JavaScript

# MANUAL
# First Steps
## First Steps
OneJS walks the modules and dependencies defined by package.json files. To create your bundle, just go a project directory and type `onejs build` command:

@@ -37,3 +35,3 @@

### Experimenting the Bundle Script
**Experimenting the Bundle Script**

@@ -54,40 +52,4 @@ The output OneJS generates can be used by NodeJS, too. It's the easiest way of making sure if the output works or not.

### Using the NodeJS Core Library
**Requiring Global Variables**
Many modules of the core NodeJS library is able to be used by web projects, as well. OneJS has an 'install' command that converts demanded remote NodeJS module to a package on the fly:
```javascript
> onejs install assert path url
```
The reference of available modules that you can install: https://github.com/azer/onejs/blob/master/lib/install_dict.js
## Process
OneJS includes a simple emulation of [NodeJS' process](http://nodejs.org/api/process.html). (Pass --noprocess if you don't need it)
```javascript
> exampleProject.require('dependency'), exampleProject.require('./b');
> exampleProject.lib.process.stdout.write("Hello World");
> exampleProject.stdout();
"Hello World"
```
## Debug Mode
Pass `--debug` parameter disabling cache and passing ENV variables to the built file. If we assume that we have a module that depends on ENV;
```javascript
if( process.env.VERBOSE ){
console.log( "fabula de narratur" );
}
```
Above module becomes available to access ENV on debug-mode;
```bash
$ VERBOSE=1 onejs build package.json --debug
```
## Requiring Global Variables
OneJS doesn't change the way we access global variables. However, we may want to use require statements to access global variables (such as document, jQuery etc..) for purposes like dependency injection or documentation. Following example demonstrates the usage of `--tie` option that lets us require global variables;

@@ -109,3 +71,3 @@

## Excluding Specific Dependencies
**Excluding Specific Dependencies**

@@ -124,24 +86,26 @@ There are some cases we prefer to not have some dependency packages in the build. The `--exclude` option leads OneJS ignore the specified packages;

## Sandboxing Console Object
## Command-Line API
```
usage: onejs [action] [manifest] [options]
OneJS provides an embed, encapsulated console object (disabled by default). Pass `--sandbox-console` if needed, output is available by `projectName.stdout()` and `project.stderr()`.
Transforms NodeJS packages into single, stand-alone JavaScript files that can be run at other platforms. See the documentation at http://github.com/azer/onejs for more information.
```bash
$ onejs build package.json foobar.js --sandbox-console
```
actions:
build <manifest> <target> Generate a stand-alone JavaScript file from specified package. Write output to <target> if given any.
server <manifest> <port> <host> Publish generated JavaScript file on web. Uses 127.0.0.1:1338 by default.
```javascript
> var foobar = require('./foobar');
> foobar.stdout();
'Trying out the embed console'
'Hello world!'
> foobar.stderr()
'warning! something may be going wrong!'
'error! something went wrong!'
options:
--debug Disable module caching.
--tie <package name>=<global object> Create package links to specified global variables. e.g; --tie dom=window.document,jquery=jQuery
--exclude <package name> Do not contain specified dependencies. e.g: --exclude underscore,request
--plain Builds the package within a minimalistic template for the packages with single module and no dependencies.
--quiet Make console output less verbose.
--verbose Tell what's going on by being verbose.
--version Show version and exit.
--help Show help.
```
## NodeJS API
You can also use OneJS from inside your own NodeJS code.
```javascript

@@ -154,42 +118,25 @@ var one = require('one');

debug: true // see available options section below
};
};
one.build(manifest, options, function(error, bundle){
if(error) throw error;
one.save(target, bundle, function(error){
if(error) throw error;
console.log('path/to/package.json built and saved to path/to/bundle.js successfully!');
});
});
```
#### Available Options
**Applying Filters**
* **noprocess:** do not include process module.
* **tie:** Registers given object path as a package. Usage: `tie: [{ 'module': 'pi', 'to': 'Math.PI' }, { 'module': 'json', 'to': 'JSON' }]`
* **exclude:** Exclude specified packages from build. Usage: `exclude: ['underscore', 'request']`
* **ignore:** Modules to ignore. .npmignore will not be read if this option is provided. Usage: `ignore: ['lib/foo.js', 'lib/path/to/a/directory']`
* **sandboxConsole:** Sandboxes console object. Disabled by default.
* **debug:** Enables debug mode. See the Debug Mode section above for information on the affects of this option.
#### Applying Filters
Filtering filenames might be a useful option for specific cases such as splitting build to different pieces. Here is an example usage;
```javascript
var one = require('one');
one.modules.filters.push(function(filename){
return filename.substring(0, 7) != 'lib/foo';
});
```

@@ -199,3 +146,3 @@

* The most common issue of a OneJS output is to lack some dependencies. In that case, make sure that the library is located under `node_modules/` properly.
* The most common issue is to lack some dependencies. In that case, make sure that the missing dependency is located under `node_modules/` properly.
* Enabling verbose mode might be helpful: `onejs build package.json --verbose`

@@ -202,0 +149,0 @@ * See the content of `projectName.map` object if it contains the missing dependency

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

lib = (function(exports){

@@ -10,21 +9,4 @@

{{#include_process}}
global.process = exports.process = (function(exports){
{{>process}}
return exports;
}({}));
{{/include_process}}
{{#sandbox_console}}
global.console = exports.console = (function(exports){
{{>console}}
return exports;
}({}));
{{/sandbox_console}}
return exports;
}({}));

@@ -6,3 +6,3 @@ {{ treeName }}.module({{ parentId }}, function(/* parent */){

'pkg': arguments[0],
'wrapper': function(module, exports, global, Buffer,{{#sandbox_console}} console, {{/sandbox_console}} {{#include_process}}process,{{/include_process}} require, undefined){
'wrapper': function(module, exports, global, require, undefined){
{{{content}}}

@@ -9,0 +9,0 @@ }

// Copyright Joyent, Inc. and other Node contributors.
// Minimized fork of NodeJS' path module, based on its an early version.
// Minimized fork of NodeJS' path module, based on an earliest version.

@@ -45,3 +45,1 @@ exports.join = function () {

};

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

/*global require:false, Buffer:false, process:false, module:false */
/*global require:false, module:false */
var {{ name }} = (function(unused, undefined){

@@ -11,3 +11,2 @@

nativeRequire = typeof require != 'undefined' && require,
nativeBuffer = typeof Buffer != 'undefined' && Buffer,
ties, locals;

@@ -45,3 +44,3 @@

function genRequire(callingModule){
function newRequire(callingModule){
return function require(uri){

@@ -88,3 +87,3 @@ var module,

mod.exports = {};
mod.require = genRequire(mod);
mod.require = newRequire(mod);

@@ -100,3 +99,3 @@ mod.call = function(){

mod.wrapper(mod, mod.exports, global, nativeBuffer || global.Buffer, {{#sandbox_console}} global.console,{{/sandbox_console}} {{#include_process}}global.process,{{/include_process}} global.require);
mod.wrapper(mod, mod.exports, global, global.require);
return mod.exports;

@@ -120,3 +119,3 @@ };

if(pkgdefs.hasOwnProperty(ctx.id)){
throw new Error('Package#'+ctx.id+' "' + ctx.name + '" has duplication of itself.');
throw new Error('Package#'+ctx.id+' "' + ctx.name + '" has a duplication of itself.');
}

@@ -134,16 +133,3 @@

function stderr(){
return lib.process.stderr.content;
}
function stdin(){
return lib.process.stdin.content;
}
function stdout(){
return lib.process.stdout.content;
}
return (locals = {
'lib' : lib,
'findPkg' : findPkg,

@@ -155,5 +141,2 @@ 'findModule' : findModule,

'packages' : pkgmap,
'stderr' : stderr,
'stdin' : stdin,
'stdout' : stdout,
'require' : mainRequire

@@ -160,0 +143,0 @@ {{#debug}}

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