-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build with urequire (eat your own dogfood). Allows importing of stand…
…ard modules (lodash, uberscore, UError) & use specrunner to autogen specs.
- Loading branch information
Showing
45 changed files
with
63 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,55 @@ | ||
_ = (_B = require 'uberscore')._ | ||
S = if process.platform is 'win32' then '\\' else '/' | ||
startsWith = (string, substring) -> string.lastIndexOf(substring, 0) is 0 | ||
nodeBin = "node_modules#{S}.bin#{S}" | ||
|
||
sourceDir = "source/code" | ||
buildDir = "build/code" | ||
sourceSpecDir = "source/spec" | ||
buildSpecDir = "build/spec" | ||
|
||
module.exports = gruntFunction = (grunt) -> | ||
pkg = grunt.file.readJSON 'package.json' | ||
|
||
gruntConfig = | ||
pkg: pkg | ||
|
||
meta: | ||
banner: """ | ||
/*! | ||
* <%= pkg.name %> - version <%= pkg.version %> | ||
* Compiled on <%= grunt.template.today(\"yyyy-mm-dd\") %> | ||
* <%= pkg.repository.url %> | ||
* Copyright(c) <%= grunt.template.today(\"yyyy\") %> <%= pkg.author.name %> (<%= pkg.author.email %> ) | ||
* Licensed <%= pkg.licenses[0].type %> <%= pkg.licenses[0].url %> | ||
*/\n | ||
""" | ||
varVERSION: "var VERSION = '<%= pkg.version %>'; //injected by grunt:concat\n" | ||
mdVersion: "# <%= pkg.name %> v<%= pkg.version %>\n" | ||
usrBinEnvNode: "#!/usr/bin/env node\n" | ||
|
||
options: {sourceDir, buildDir, sourceSpecDir, buildSpecDir} | ||
|
||
clean: | ||
build: 'build' | ||
temp: 'temp' | ||
|
||
concat: | ||
VERSIONurequire: | ||
options: banner: "<%= meta.banner %><%= meta.varVERSION %>" | ||
src: [ '<%= options.buildDir %>/urequire.js'] | ||
dest: '<%= options.buildDir %>/urequire.js' | ||
|
||
copy: | ||
specResources: | ||
files: [ expand: true, cwd: "#{sourceSpecDir}/NodeRequirer", src: ["*.json"], dest: "#{buildSpecDir}/NodeRequirer"] | ||
urequire: # eat your own dogfood | ||
_all: | ||
dependencies: imports: | ||
lodash: '_' | ||
uberscore: '_B' | ||
'utils/UError': 'UError' | ||
resources:[ | ||
[ '+inject-_B.logger', ['**/*.js'], | ||
(m)-> m.beforeBody = "var l = new _B.Logger('urequire:#{m.path}');"] ] | ||
runtimeInfo: false | ||
bare: true | ||
template: name: 'nodejs' | ||
|
||
lib: | ||
path: 'source/code' | ||
dstPath: 'build/code' | ||
main: 'urequire' | ||
template: banner: true | ||
resources: [ 'inject-version' ] | ||
|
||
spec: | ||
path: 'source/spec' | ||
dstPath: 'build/spec' | ||
copy: /./ | ||
dependencies: | ||
imports: | ||
chai: 'chai' | ||
specHelpers: 'spH' | ||
replace: '../code/utils/UError' : 'utils/UError' | ||
resources: [ | ||
['import-keys', | ||
specHelpers: """ | ||
equal, notEqual, ok, notOk, tru, fals, deepEqual, notDeepEqual, exact, notExact, iqual, | ||
notIqual, ixact, notIxact, like, notLike, likeBA, notLikeBA, equalSet, notEqualSet""" | ||
chai: 'expect' ] ] | ||
afterBuild: require 'urequire-ab-specrunner' | ||
|
||
specWatch: derive: 'spec', watch: true | ||
|
||
copy: wiki: files: [ expand: true, cwd: "source/code/config", src: ["*.md"], dest: "../uRequire.wiki/"] | ||
|
||
clean: build: 'build', temp: 'temp' | ||
|
||
wiki: | ||
files: [ expand: true, cwd: "#{sourceDir}/config/", src: ["*.md"], dest: "../uRequire.wiki/"] | ||
|
||
watch: | ||
dev: # requires `coffeeWatch` to compile changed only files! need a changed-only-files coffee task! | ||
files: ["build/**/*"] | ||
tasks: ['copy', 'mochaCmd'] | ||
|
||
copy: | ||
files: ["source/**/*"] | ||
tasks: ['copy:wiki'] | ||
|
||
shell: | ||
coffee: command: "#{nodeBin}coffee -cb -o ./build ./source" | ||
coffeeWatch: command: "#{nodeBin}coffee -cbw -o ./build ./source" | ||
mochaCmd: command: "#{nodeBin}mocha #{buildSpecDir}/**/*-spec.js --recursive --timeout 5000 --bail" | ||
options: verbose: true, failOnError: true, stdout: true, stderr: true | ||
|
||
# copy build files to wherever urequire is a dev dep testbed | ||
deps = [] #['uberscore'] | ||
for dep in deps | ||
gruntConfig.copy[dep] = | ||
files: [ expand: true, src: ["**/*.js", "**/*.json", "!node_modules/**/*"], dest: "../#{dep}/node_modules/urequire"] | ||
|
||
### shortcuts generation ### | ||
splitTasks = (tasks)-> if (tasks instanceof Array) then tasks else tasks.split(/\s/).filter((f)->!!f) | ||
grunt.registerTask cmd, splitTasks "shell:#{cmd}" for cmd of gruntConfig.shell # shortcut to all "shell:cmd" | ||
grunt.registerTask shortCut, "urequire:#{shortCut}" for shortCut of gruntConfig.urequire | ||
grunt.registerTask shortCut, splitTasks tasks for shortCut, tasks of { | ||
default: "clean build test" | ||
build: "coffee concat copy" | ||
test: "copy:specResources mochaCmd" | ||
|
||
# IDE shortcuts | ||
"alt-c": "copy:wiki" | ||
"alt-b": "build" | ||
"alt-t": "test" | ||
default: 'clean lib spec' | ||
develop: 'clean lib specWatch' | ||
"alt-c": "copy" # IDE shortcuts | ||
"alt-b": "lib" | ||
} | ||
|
||
grunt.loadNpmTasks task for task of pkg.devDependencies when startsWith(task, 'grunt-') | ||
grunt.initConfig gruntConfig | ||
|
||
null | ||
grunt.loadNpmTasks task for task of grunt.file.readJSON('package.json').devDependencies when task.lastIndexOf('grunt-', 0) is 0 | ||
grunt.initConfig gruntConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# uRequire v0.7.0-beta5 | ||
# uRequire v0.7.0-beta10 | ||
|
||
## Beta release note | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
_ = (_B = require 'uberscore')._ | ||
toAST = require './toAST' | ||
|
||
module.exports = isEqualCode = (code1, code2)-> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
_B = require 'uberscore' | ||
toAST = require './toAST' | ||
|
||
module.exports = isLikeCode = (code1, code2)-> | ||
_B.isLike toAST(code1, 'Program')?.body, | ||
toAST(code2, 'Program')?.body | ||
|
||
toAST(code2, 'Program')?.body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
_ = (_B = require 'uberscore')._ | ||
|
||
umatch = require 'umatch' | ||
|
||
module.exports = (val, filename)-> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.