Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

assembot

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assembot - npm Package Compare versions

Comparing version
0.2.4
to
0.2.5
+43
lib/plugins/increment-version.js
// Generated by CoffeeScript 1.6.1
/*
assembot:
options:
autoincrement:
enabled: yes
target: './package.json'
segment: 'build' # or major, minor, patch
when: 'after:write'
*/
(function() {
var path, semver;
semver = require('semver');
path = require('path');
console.log("Increment Version Plugin...");
module.exports = function(assembot) {
var log;
log = assembot.log;
return assembot.on('done', function(options) {
var filepath, output, pinfo;
if (options.autoincrement == null) {
return;
}
if (options.autoincrement.enabled === false) {
return;
}
filepath = path.resolve(path.join(process.cwd(), options.autoincrement.target));
pinfo = require(filepath);
pinfo.version = semver.inc(pinfo.version, options.autoincrement.segment);
log.info("Incrementing build version to", pinfo.version);
output = JSON.stringify(pinfo, null, 2);
return output.to(filepath);
});
};
}).call(this);
// Generated by CoffeeScript 1.6.1
/*
Usage:
In your assembot conf (coffeescript example):
options:
http:
log: no
latency:
enabled: yes
max: 1000
rules:
".(jpg|png|jpeg)": 100
*/
(function() {
module.exports = function(assembot) {
var log;
log = assembot.log;
log.info("Server Latency Plugin...");
return assembot.on('create:server', function(server, opts) {
var maxAge, test, tests, time, _ref, _ref1, _ref2;
if (opts == null) {
opts = {};
}
if ((_ref = opts.http) == null) {
opts.http = {};
}
if ((opts.http.latency != null) && opts.http.latency.enabled) {
log.info("Activating latency simulator");
maxAge = (_ref1 = opts.http.latency.max) != null ? _ref1 : 3000;
tests = [];
_ref2 = opts.http.latency.rules;
for (test in _ref2) {
time = _ref2[test];
log.info(" - compiling latency test", test);
tests.push({
matcher: new RegExp(test),
time: time,
prev: 0
});
}
return server.use(function(req, res, next) {
var waitFor, _i, _len;
for (_i = 0, _len = tests.length; _i < _len; _i++) {
test = tests[_i];
if (test.matcher.test(req.url)) {
waitFor = test.time < 0 ? test.prev + (-test.time) : test.time;
test.prev = waitFor;
if (waitFor >= maxAge) {
waitFor = maxAge;
test.prev = 0;
}
log.info("Waiting....", waitFor, req.url);
setTimeout(next, waitFor);
return;
}
}
return next();
});
}
});
};
}).call(this);
###
assembot:
options:
autoincrement:
enabled: yes
target: './package.json'
segment: 'build' # or major, minor, patch
when: 'after:write'
###
semver= require 'semver'
path= require 'path'
console.log "Increment Version Plugin..."
module.exports= (assembot)->
{log}= assembot
assembot.on 'done', (options)->
return unless options.autoincrement?
return if options.autoincrement.enabled is false
filepath= path.resolve path.join(process.cwd(), options.autoincrement.target)
pinfo= require filepath
pinfo.version= semver.inc(pinfo.version, options.autoincrement.segment)
# major, minor, patch, or build
log.info "Incrementing build version to", pinfo.version
output= JSON.stringify pinfo, null, 2
# outpath= path.resolve __dirname, '..', "package.json"
output.to filepath
###
Usage:
In your assembot conf (coffeescript example):
options:
http:
log: no
latency:
enabled: yes
max: 1000
rules:
".(jpg|png|jpeg)": 100
###
module.exports= (assembot)->
{log}= assembot
log.info "Server Latency Plugin..."
assembot.on 'create:server', (server, opts={})->
opts.http ?= {}
if opts.http.latency? and opts.http.latency.enabled
log.info "Activating latency simulator"
maxAge= opts.http.latency.max ? 3000
tests= []
for test, time of opts.http.latency.rules
log.info " - compiling latency test", test
tests.push matcher:(new RegExp test), time:time, prev:0
server.use (req, res, next)->
for test in tests
if test.matcher.test(req.url)
waitFor= if test.time < 0
test.prev + (- test.time)
else
test.time
test.prev= waitFor
if waitFor >= maxAge
waitFor= maxAge
test.prev= 0
log.info "Waiting....", waitFor, req.url
setTimeout next, waitFor
return
next()

Sorry, the diff of this file is not supported yet

console.log "{{ name }}"
isDebug= String(process.argv[2]) is 'serve'
onLoad= (assembot)->
console.log "Startup! (debug:#{isDebug})"
module.exports=
assembot:
options:
callback: onLoad
header: "/* {{ name }} v{%- package.version -%} */"
plugins: [
"assembot/lib/plugins/increment-version"
"assembot/lib/plugins/server-latency"
]
autoincrement:
enabled: yes
target: 'package.json'
segment: 'build' # or major, minor, patch
when: 'after:write'
http:
log: no
latency:
enabled: no
max: 1000
rules:
".(jpg|png|jpeg)": 100
targets:
"public/app.js":
source: "./source"
ident: "require"
main: "main"
autoload: true
debug: isDebug
prune: true
minify: (if isDebug then 0 else 2)
"public/app.css":
source: "./source"
debug: isDebug
build:
./node_modules/.bin/assembot build
gzip:
gzip --stdout --best public/app.js > public/app.js.gz
clean:
rm public/app.*
test:
@NODE_ENV=test
@clear
@./node_modules/.bin/mocha
.PHONY: build clean gzip test
# {{name}} Notes / Ideas
{
"name": "{{ name }}",
"version": "1.0.0",
"license": "",
"description": "",
"author": "",
"devDependencies": {
"assembot": "~0.2.5",
"coffee-script": "~1.6.1",
"mocha": "*",
"chai": "*"
}
}
<!DOCTYPE html>
<html lang="en" class="nojs">
<head>
<meta charset="utf-8" />
<title>{{ name }}</title>
<link rel="stylesheet" type="text/css" href="app.css">
</head>
<body>
Loading...
</body>
<script src="app.js"></script>
</html>
# {{ name }}
**Remember**
If you're having problems compiling or testing, you might need to run:
npm install
And yeah, you should probably delete all this and say a few words about {{ name }} here.
# {{ name }} main
@onload= ->
console.log "Ready."
document.body.innerHTML= "Ready."
// {{name}}
@import 'nib'
global-reset()
body
font-family "Helvetica Neue", Helvetica, Sans-Serif
# Insert your test helpers here...

Sorry, the diff of this file is not supported yet

should= require('chai').should()
# this is the compiled output from assembot,
# use it like you would the 'window' object:
buildenv= require('../public/app')
describe '{{name}}', ->
#beforeEach ->
#afterEach ->
it 'should exist', ->
should.exist buildenv
it 'should contain the module loader', ->
buildenv.require.should.exist
buildenv.require.should.be.a.function
describe 'main', ->
it 'should exist', ->
main= buildenv.require('main')
should.exist main
+7
-0

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

# Version 0.2.5
- New server-latency plugin, to simulate server latency in dev server
- Updated prune plugin to build dependency list (parses coffeescript now)
and whitelists pre-render. So files that are referenced won't be transpiled
- Moved project creation to fgen
# Version 0.2.4

@@ -2,0 +9,0 @@ - Added target source path to stylus load_paths

+24
-73
// Generated by CoffeeScript 1.6.1
(function() {
var build_project, cat, cd, content, defaults, exec, loadOptions, log, mkdir, path, spawn, test, _, _ref;
var build_project, cat, cd, defaults, exec, fgen, loadOptions, log, mkdir, path, spawn, test, _, _ref;

@@ -15,2 +15,4 @@ require('coffee-script');

fgen = require('fgen');
spawn = require('child_process').spawn;

@@ -23,81 +25,30 @@

build_project = function(name) {
var create_dir, create_file, projectpath, settings, t, v, _ref1;
var projectpath, templatepath;
projectpath = path.resolve("./" + name);
if (test('-e', projectpath)) {
return log.say("" + name + " already exists at this location!");
} else {
log.say("create: " + name);
mkdir(projectpath);
cd(projectpath);
create_dir = function(filepath) {
log.say("create: " + name + "/" + filepath);
return mkdir(filepath);
};
create_file = function(filepath, contentName) {
log.say("create: " + name + "/" + filepath);
return String(content[contentName]).replace(/APPNAME/g, name).to(filepath);
};
create_dir("source");
create_file("source/main.coffee", 'mainCoffee');
create_file("source/main.styl", 'mainStylus');
create_dir("public");
create_file("public/index.html", 'indexHtml');
create_dir("docs");
create_file("docs/ideas.md", 'ideas');
create_file("docs/todos.md", 'todos');
create_dir("test");
create_dir("test/fixtures");
create_file("test/mocha.opts", 'mochaOpts');
create_file("test/helpers.coffee", 'testHelpers');
create_file("test/test_app.coffee", 'projectTest');
create_file(".gitignore", 'gitIgnore');
create_file("Makefile", 'makefile');
create_file("readme.md", 'readme');
settings = {
log.say("" + name + " already exists at this location!");
return;
}
console.log("Creating new project:", name);
templatepath = path.resolve(path.join(__dirname, '../../', 'template'));
return fgen.createGenerator(templatepath, function(err, generator) {
if (err != null) {
throw err;
}
generator.context = {
name: name,
version: "1.0.0",
license: "",
description: "",
author: "",
assembot: defaults,
devDependencies: {
assembot: "*",
"coffee-script": "*",
mocha: "*",
chai: "*"
}
version: '1.0.0'
};
_ref1 = settings.assembot.targets;
for (t in _ref1) {
v = _ref1[t];
if (t.indexOf('.js') > 0) {
v.autoLoad = "main";
return generator.generateAll(projectpath, function(err) {
if (err != null) {
return log.error(err);
} else {
cd(projectpath);
exec("npm install");
return log.say("Done.");
}
}
content.packageJSON = JSON.stringify(settings, null, 2);
create_file("package.json", 'packageJSON');
exec("npm install");
log.say("");
log.say("OK, you can have fun!");
log.say("");
log.say(" cd " + name);
log.say("");
return log.say("Done!");
}
});
});
};
content = {
readme: "# APPNAME\n\n## Remember\n\nIf you're having problems compiling or testing, you might need to run:\n\n npm install\n\nAnd yeah, you should probably delete all this and say a few words about APPNAME here.",
mainCoffee: "# APPNAME main\n\nthis.onload= ->\n console.log \"Ready.\"\n document.body.innerHTML= \"Ready.\"\n",
mainStylus: "// APPNAME\n@import 'nib'\n\nglobal-reset()\n\nbody\n font-family \"Helvetica Neue\", Helvetica, Sans-Serif",
ideas: "# APPNAME Ideas\n\n- Do cool stuff!",
todos: "# APPNAME Todos\n\n- Write docs\n- Flesh out readme.md\n- Release APPNAME!",
indexHtml: "<!DOCTYPE html>\n<html lang=\"en\" class=\"nojs\">\n <head>\n <meta charset=\"utf-8\" />\n <title>APPNAME</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"app.css\">\n </head>\n <body>\n Loading...\n </body>\n <script src=\"app.js\"></script>\n</html>",
mochaOpts: "--ignore-leaks\n--compilers coffee:coffee-script\n--reporter spec\n--require coffee-script\n--require test/helpers.coffee\n--colors",
testHelpers: "# Insert your test helpers here...",
projectTest: "should= require('chai').should()\n# this is the compiled output from assembot, \n# use it like you would the 'window' object:\nbuildenv= require('../public/app')\n\ndescribe 'APPNAME', ->\n #beforeEach ->\n #afterEach ->\n\n it 'should exist', ->\n should.exist buildenv\n\n it 'should contain the module loader', ->\n buildenv.require.should.exist\n buildenv.require.should.be.a.function\n\n describe 'main', ->\n\n it 'should exist', ->\n main= buildenv.require('main')\n should.exist main",
gitIgnore: "node_modules",
makefile: "build:\n\t./node_modules/.bin/assembot build\n\ntest:\n\t@NODE_ENV=test\n\t@clear\n\t@./node_modules/.bin/mocha\n\n.PHONY: build test\n"
};
module.exports = function(cli, pkg) {

@@ -104,0 +55,0 @@ return cli.command('new').description("project directory name").action(function(name) {

@@ -56,3 +56,3 @@ // Generated by CoffeeScript 1.6.1

if (autoStart) {
result += "" + identifier + "('" + autoStart + "');\n";
result += "this." + identifier + "('" + autoStart + "');\n";
}

@@ -59,0 +59,0 @@ return callback(null, result);

// Generated by CoffeeScript 1.6.1
(function() {
var modParser, path, reqParser, resolve_path,
var modParser, path, reqParser, requireParser, resolve_path,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

@@ -26,3 +26,3 @@

log = assembot.log;
assembot.after('render', function(bot) {
assembot.after('scan', function(bot) {
if (bot.target !== 'js') {

@@ -34,7 +34,7 @@ return;

}
log.info("Scanning resources for internal dependencies...");
log.info("Building dependency list...");
return bot.resources.each(function(res) {
var lib, libs, req, reqs, src, _i, _len, _ref, _results;
res.dependencies = [];
if (reqs = res.content.match(reqParser)) {
if (reqs = res.content.match(requireParser)) {
log.debug(res.path);

@@ -58,3 +58,3 @@ libs = [];

});
return assembot.before('assemble', function(bot) {
return assembot.before('render', function(bot) {
var add_libs, lib, libs, missing, _i, _j, _len, _len1;

@@ -113,2 +113,4 @@ if (bot.target !== 'js') {

requireParser = /(require[\s\(]+['"]?[\.a-zA-Z0-9_\-\/]*['"]?[\s\)]+)/g;
}).call(this);

@@ -157,1 +157,42 @@ # AssemBot Notes/Todos

Especially the ones that require a runtime?!
### Empirical vs Scanning
Instead of scanning and loading every file in the source directory, why not take
the prune plugin and build around it?
You'd specify the source paths (an array), and a main entry point. It would then
scan that file, search for `require`d files, then scan for those files -- repeating
the dendency search for each child file until there are no more files required.
Then you only have to load the content and transpile those files. Everything else
in the source folder(s) would never be opened (or even touched at all).
Would make supporting components even easier,
```coffeescript
assembot:
targets:
"public/app.js":
source: ['./source', './components']
main: "main"
```
```coffeescript
assembot:
targets:
"public/app.js":
source: ['./source', './components']
main: ["main", "test"]
```
```coffeescript
assembot:
targets:
"public/app.js":
paths: ['./source', './components']
source: ["main", "test", "never/required/directly/but/needed/*"]
autoload: "main" # or true to require first 'source'
```
{
"name": "assembot",
"version": "0.2.4",
"version": "0.2.5",
"license": "MIT",

@@ -11,3 +11,3 @@ "description": "Simple asset assembly bot for compiling/combining client-side js and css files.",

},
"keywords": [
"keywords": [
"cli",

@@ -44,3 +44,5 @@ "http",

"minimatch": "~0.2.11",
"async": "~0.2.6"
"async": "~0.2.6",
"fgen": "~0.3.1",
"semver": "~1.1.4"
},

@@ -47,0 +49,0 @@ "devDependencies": {

@@ -6,2 +6,3 @@ require 'coffee-script'

path= require 'path'
fgen= require 'fgen'
{spawn}= require('child_process')

@@ -15,165 +16,23 @@ {test, cat, cd, mkdir, exec}= require 'shelljs'

log.say "#{ name} already exists at this location!"
else
return
log.say "create: #{ name }"
mkdir projectpath
cd projectpath
console.log "Creating new project:", name
create_dir= (filepath)->
log.say "create: #{ name }/#{ filepath }"
mkdir filepath
templatepath= path.resolve path.join(__dirname, '../../', 'template')
fgen.createGenerator templatepath, (err, generator)->
throw err if err?
create_file= (filepath, contentName)->
log.say "create: #{ name }/#{ filepath }"
String(content[contentName]).replace(/APPNAME/g, name).to filepath
create_dir "source"
create_file "source/main.coffee", 'mainCoffee'
create_file "source/main.styl", 'mainStylus'
create_dir "public"
create_file "public/index.html", 'indexHtml'
create_dir "docs"
create_file "docs/ideas.md", 'ideas'
create_file "docs/todos.md", 'todos'
create_dir "test"
create_dir "test/fixtures"
create_file "test/mocha.opts", 'mochaOpts'
create_file "test/helpers.coffee", 'testHelpers'
create_file "test/test_app.coffee", 'projectTest'
create_file ".gitignore", 'gitIgnore'
create_file "Makefile", 'makefile'
create_file "readme.md", 'readme'
settings=
generator.context=
name: name
version: "1.0.0"
license: ""
description: ""
author: ""
assembot: defaults
devDependencies:
assembot: "*"
"coffee-script": "*"
mocha: "*"
chai: "*"
for t,v of settings.assembot.targets
if t.indexOf('.js') > 0
v.autoLoad= "main"
content.packageJSON= JSON.stringify settings, null, 2
create_file "package.json", 'packageJSON'
exec "npm install"
log.say ""
log.say "OK, you can have fun!"
log.say ""
log.say " cd #{name}"
log.say ""
log.say "Done!"
version: '1.0.0'
content=
readme: """
# APPNAME
generator.generateAll projectpath, (err)->
if err?
log.error err
else
cd projectpath
exec "npm install"
log.say "Done."
## Remember
If you're having problems compiling or testing, you might need to run:
npm install
And yeah, you should probably delete all this and say a few words about APPNAME here.
"""
mainCoffee: """
# APPNAME main
this.onload= ->
console.log "Ready."
document.body.innerHTML= "Ready."
"""
mainStylus: """
// APPNAME
@import 'nib'
global-reset()
body
font-family "Helvetica Neue", Helvetica, Sans-Serif
"""
ideas: """
# APPNAME Ideas
- Do cool stuff!
"""
todos: """
# APPNAME Todos
- Write docs
- Flesh out readme.md
- Release APPNAME!
"""
indexHtml: """<!DOCTYPE html>
<html lang="en" class="nojs">
<head>
<meta charset="utf-8" />
<title>APPNAME</title>
<link rel="stylesheet" type="text/css" href="app.css">
</head>
<body>
Loading...
</body>
<script src="app.js"></script>
</html>"""
mochaOpts: """
--ignore-leaks
--compilers coffee:coffee-script
--reporter spec
--require coffee-script
--require test/helpers.coffee
--colors
"""
testHelpers: """
# Insert your test helpers here...
"""
projectTest: """
should= require('chai').should()
# this is the compiled output from assembot,
# use it like you would the 'window' object:
buildenv= require('../public/app')
describe 'APPNAME', ->
#beforeEach ->
#afterEach ->
it 'should exist', ->
should.exist buildenv
it 'should contain the module loader', ->
buildenv.require.should.exist
buildenv.require.should.be.a.function
describe 'main', ->
it 'should exist', ->
main= buildenv.require('main')
should.exist main
"""
gitIgnore: "node_modules"
# The hard way, cause Makefile's have to have tabs, not spaces!
makefile: "build:\n\t./node_modules/.bin/assembot build\n\ntest:\n\t@NODE_ENV=test\n\t@clear\n\t@./node_modules/.bin/mocha\n\n.PHONY: build test\n"
# cli
# .parse(process.argv);
# log.level 0 if cli.quiet
# log.level 2 if cli.verbose
module.exports= (cli, pkg)->

@@ -188,4 +47,3 @@ cli

return
build_project name
build_project name
)

@@ -131,4 +131,4 @@

"""
result += "#{identifier}('#{autoStart}');\n" if autoStart
result += "this.#{identifier}('#{autoStart}');\n" if autoStart
callback null, result

@@ -17,9 +17,9 @@ path= require 'path'

assembot.after 'render', (bot)->
assembot.after 'scan', (bot)->
return if bot.target isnt 'js'
return unless bot.options.main? and bot.options.prune
log.info "Scanning resources for internal dependencies..."
log.info "Building dependency list..."
bot.resources.each (res)->
res.dependencies= []
if reqs= res.content.match(reqParser)
if reqs= res.content.match(requireParser)
log.debug res.path

@@ -34,3 +34,3 @@ libs=[]

assembot.before 'assemble', (bot)->
assembot.before 'render', (bot)->
return if bot.target isnt 'js'

@@ -67,1 +67,4 @@ return unless bot.options.main? and bot.options.prune

modParser= /['"]+([\.a-zA-Z0-9_\-/]*)['"]+/
# Should match javascript and coffee sources
requireParser= /(require[\s\(]+['"]?[\.a-zA-Z0-9_\-\/]*['"]?[\s\)]+)/g