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

amdify

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amdify - npm Package Compare versions

Comparing version 0.0.1 to 0.0.5

lib/pathInfo.js

197

lib/analyzeDeps.js

@@ -7,12 +7,4 @@ var outcome = require("outcome"),

_ = require("underscore"),
utils = require('./utils'),
flatten = require("flatten"),
findPackagePath = utils.findPackagePath,
isMain = utils.isMain,
eachDir = utils.eachDir,
loadPackage = utils.loadPackage,
getPathInfo = utils.getPathInfo,
findFiles = utils.findFiles,
getPkgName = utils.getPackageName,
mainScriptPath = utils.mainScriptPath;
initPathInfo = require("./pathInfo");

@@ -27,3 +19,12 @@

//include these entry points - .JS files, directories, whatever.
var entries = ops.entries;
var entries = ops.entries,
pathInfo = initPathInfo(ops),
getPathInfo = pathInfo.getPathInfo,
findPackagePath = pathInfo.findPackagePath,
isMain = pathInfo.isMain,
eachDir = pathInfo.eachDir,
loadPackage = pathInfo.loadPackage,
findFiles = pathInfo.findFiles,
getPkgName = pathInfo.getPackageName,
mainScriptPath = pathInfo.mainScriptPath;

@@ -166,3 +167,3 @@

includeScript(getPathInfo(dirOrScript), this);
includeScript(pathInfo.getPathInfo(dirOrScript), this);

@@ -195,4 +196,2 @@ }

init(entries, callback);
}

@@ -202,116 +201,130 @@

/**
* scans content for required dependencies
*/
/**
* scans content for required dependencies
*/
var findDeps = module.exports.findDeps = function(entry, callback) {
var findDeps = module.exports.findDeps = function(entry, callback) {
//incase getPathInfo stuff is passed...
if(entry.path) entry = entry.path;
var cwd = path.dirname(entry),
on = outcome.e(callback),
content = null;
//incase getPathInfo stuff is passed...
if(entry.path) entry = entry.path;
step(
var cwd = path.dirname(entry),
on = outcome.e(callback),
content = null;
step(
/**
*/
/**
*/
function() {
fs.readFile(entry, "utf8", this);
},
function() {
fs.readFile(entry, "utf8", this);
},
/**
*/
/**
*/
on.s(function(cn) {
on.s(function(cn) {
content = cn;
content = cn;
var next = this, d;
var next = this, d;
scanRequired(content, cwd, on.s(function(deps) {
scanInclude(content, cwd, on.s(function(incDeps) {
next(null, deps.concat(incDeps));
scanRequired(content, cwd, on.s(function(deps) {
scanInclude(content, cwd, on.s(function(incDeps) {
next(null, deps.concat(incDeps));
}));
}));
}));
}),
}),
/**
*/
/**
*/
on.success(function(deps) {
callback(null, deps);
})
);
}
on.success(function(deps) {
callback(null, deps);
})
);
}
function findJsFiles(entry, callback) {
function findJsFiles(entry, callback) {
var inc = [];
var inc = [];
findFiles(entry, /\.js$/, function(file) {
findFiles(entry, /\.js$/, function(file) {
//the included dir MIGHT be a module, so make sure that's the starting point
if(file.substr(file.indexOf(entry) + entry.length).indexOf('node_modules/') > -1) return;
//the included dir MIGHT be a module, so make sure that's the starting point
if(file.substr(file.indexOf(entry) + entry.length).indexOf('node_modules/') > -1) return;
var script = getPathInfo(file);
var script = getPathInfo(file);
inc.push(script);
inc.push(script);
}, function(err, success) {
callback(null, inc);
});
}
}, function(err, success) {
callback(null, inc);
});
}
//scans for #include file.js or/path
function scanInclude(content, cwd, callback) {
var include = String(content).match(/\/\/#include\s([^\n]+)/g) || [];
//scans for #include file.js or/path
function scanInclude(content, cwd, callback) {
var include = String(content).match(/\/\/#include\s([^\n]+)/g) || [];
step(
function() {
step(
function() {
var next = this;
var next = this;
async.map(include, function(fn, next) {
inc = fn.split(/\s+/g);
inc.shift();
async.map(inc, function(path, next) {
findJsFiles(cwd+"/"+path, next);
}, next);
async.map(include, function(fn, next) {
inc = fn.split(/\s+/g);
inc.shift();
async.map(inc, function(path, next) {
findJsFiles(cwd+"/"+path, next);
}, next);
}, function(err, inc) {
next(null, flatten(inc));
});
}, function(err, inc) {
next(null, flatten(inc));
});
},
callback
)
}
},
callback
)
}
function scanRequired(content, cwd, callback) {
function scanRequired(content, cwd, callback) {
//for speed.
var required = String(content).match(/require\(["'].*?["']\)/g) || [],
pathInfo = [];
//for speed.
var required = getRequired(content, cwd);//String(content).match(/require\(["'].*?["']\)/g) || [],
pathInfo = [];
async.forEach(required, function(fn, next) {
relPath = fn.match(/["'](.*?)["']/)[1]
async.forEach(required, function(relPath, next) {
var pi = getPathInfo(relPath, cwd);
pathInfo.push(pi);
var pi = getPathInfo(relPath, cwd);
next();
pathInfo.push(pi);
}, function() {
callback(null, pathInfo);
})
next();
}, function() {
callback(null, pathInfo);
})
}
function getRequired(content, cwd) {
//for speed.
var required = String(content).match(/require\(["'].*?["']\)/g) || [],
pathInfo = [];
return required.map(function(fn) {
return fn.match(/["'](.*?)["']/)[1];
});
}
}

@@ -13,3 +13,2 @@ var allFiles = _sardines.allFiles;

console.log(cp)
var parts = path.split('/'),

@@ -29,4 +28,3 @@ cp = allFiles;

exports.realpathSync = function(path) {
console.log("RPS");
}

@@ -24,4 +24,7 @@ require("structr").mixin(require("asyngleton"));

analyzeDeps({ entries: include }, outcome.e(next).s(function(deps) {
analyzeDeps({
entries : include,
platform : ops.platform || "browser",
prefix : ops.prefix
}, outcome.e(next).s(function(deps) {
next(null, new Bundle(dependencies(deps)));

@@ -28,0 +31,0 @@ }));

@@ -27,3 +27,2 @@

/**

@@ -30,0 +29,0 @@ */

@@ -26,3 +26,2 @@ var fs = require("fs");

/**

@@ -29,0 +28,0 @@ */

mkdirp = require("mkdirp"),
fs = require("fs"),
path = require("path")
path = require("path"),
step = require("stepc"),
outcome = require("outcome");

@@ -24,8 +26,53 @@ /**

var self = this, fp = path.join(self.output, dep.alias), dir = path.dirname(fp);
mkdirp(dir, function() {
fs.writeFile(fp, dep.content(), next);
});
var self = this,
fp = path.join(self.output, dep.alias),
dir = path.dirname(fp),
o = outcome.e(next);
step(
/**
*/
function() {
mkdirp(dir, this);
},
/**
*/
function() {
if(!dep.isMain) return this();
var pkg = path.join(self.output, dep.baseDir, "package.json"),
oldPkg = dep.pkgPath ? JSON.parse(fs.readFileSync(dep.pkgPath, "utf8")) : {
name: dep.moduleName,
version: "0.0.0"
};
oldPkg.main = dep.pathFromPkg;
oldPkg.description = oldPkg.description || oldPkg.name;
fs.writeFile(pkg, JSON.stringify(oldPkg, null, 2), this);
},
/**
*/
function() {
fs.writeFile(fp, dep.content(), this);
},
/**
*/
next
);
}
});

@@ -22,13 +22,12 @@ templates = require("../templates"),

var options = {
__dirname: path.dirname(dep.alias),
__filename: dep.alias,
dependencies: dep.dependencies.map(function(dep) {
return dep.alias;
}).filter(function(dep) {
return !!dep;
}),
name: dep.isMain ? dep.moduleName : dep.alias,
dependencies: dep.dependencies,
content: dep.content()
};
dep.content(this.render(options));

@@ -35,0 +34,0 @@ callback();

{
"name": "amdify",
"version": "0.0.1",
"version": "0.0.5",
"description": "Amdify converts your node.js code into browser-compatible code. For example",

@@ -26,3 +26,5 @@ "main": "./lib/index.js",

"structr": "0.2.x",
"asyngleton": "0.0.x"
"asyngleton": "0.0.x",
"ejs": "0.8.x",
"mkdirp": "0.3.x"
},

@@ -29,0 +31,0 @@ "bin": {

@@ -1,45 +0,12 @@

Amdify converts your node.js code into browser-compatible code. For example
```javascript
var events = require("events"),
EventEmitter = require("events").EventEmitter;
var em = new EventEmitter();
em.emit("hello", "world!");
```
Amdify converts your commonJS code (node.js) into browser-compatible code. Just point amdify to a node.js entry point:
Would be converted to:
```bash
```javascript
define(["events"], function() {
var events = require("events"),
EventEmitter = require("events").EventEmitter;
# combine in a single file
amdify -i ./application/entry.js -o ./amd/output.js
var em = new EventEmitter();
em.emit("hello", "world!");
});
# wrap the files, and copy them to their own directory
amdify -i ./application/entry.js -o ./amd
```
You can also include files:
```javascript
var amdify = require("amdify"),
template = amdify.require("template.mu");
console.log(template); //<h1>hello world!</h1>
```
Would be converted to:
```javascript
define(["amdify", "template.mu"], function() {
var amdify = require("amdify"),
template = amdify.require("template.mu");
console.log(template); //<h1>hello world!</h1>
});
```

Sorry, the diff of this file is not supported yet

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