Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Michiel Kalkman committed Apr 9, 2012
0 parents commit a3a1d64
Show file tree
Hide file tree
Showing 21 changed files with 281 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
npm-test.sh
npm-test.js
node_modules

3 changes: 3 additions & 0 deletions CREDITS
@@ -0,0 +1,3 @@

- The ASCII art goldfish used for the cli.js module was created by 'jgs'.

21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
Copyright (c) 2011 Michiel Kalkman

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

12 changes: 12 additions & 0 deletions README.md
@@ -0,0 +1,12 @@
# ranchu

ranchu is a command-line tool for developing Mendix JavaScript Custom widgets.
It builds on nodejs, npm and many supporting libraries (see package.json and CREDITS).

At the moment it isn't even ALPHA and very much under development.

It is named after a Japanese goldfish http://en.wikipedia.org/wiki/Ranchu
because Mendix has the goldfish as its mascot.

Contributions are welcome - pull requests are preferred over feature requests.

15 changes: 15 additions & 0 deletions bin/ranchu
@@ -0,0 +1,15 @@
#!/usr/bin/env node

console.log("** Running ranchu CLI");
console.log(" /-----\\ _, _,");
console.log(" | BLUP! | .' ( .-' /");
console.log(" \\-----/ _/..._'. .' /");
console.log(" \\ .-'` ` '-./ _.'");
console.log(" ( o) ;= <_");
console.log(" '-.,/__ __.-;`\\ '.");
console.log(" \\) |`\\ \\) '. \\ ");
console.log(" \\_/ jgs -._/ ");

require('coffee-script');
require('../lib/ranchu').cli();

Empty file added examples/.gitignore
Empty file.
5 changes: 5 additions & 0 deletions lib/cli.coffee
@@ -0,0 +1,5 @@
ranchu = require './ranchu'

cli = module.exports = (args)->


19 changes: 19 additions & 0 deletions lib/helpers/config.coffee
@@ -0,0 +1,19 @@
fs = require 'fs'

module.exports = ()->
is_ranchu = yes

try
file = fs.readFileSync 'config.json', 'utf-8'
catch e
is_ranchu = no

if is_ranchu
config = JSON.parse file
console.log "Project #{config.name} at version #{config.version}"
config
else
{}



6 changes: 6 additions & 0 deletions lib/plugins/build.coffee
@@ -0,0 +1,6 @@
ranchu = require '../ranchu'

build = module.exports = (args)->

config = ranchu.config()

18 changes: 18 additions & 0 deletions lib/plugins/cli.coffee
@@ -0,0 +1,18 @@
ranchu = require '../ranchu'

cli = module.exports = ()->
ranchu.log "Running cli.."
argv = process.argv
arg = argv[2]

if arg?
ranchu.log "Found #{arg}"
if ranchu[arg]
ranchu.log "Running #{arg}"
ranchu[arg](argv.splice(3, argv.length))
else
ranchu.log "No task #{arg} found"
else
ranchu.log "No parameters given, try help"


10 changes: 10 additions & 0 deletions lib/plugins/compress.coffee
@@ -0,0 +1,10 @@
ranchu = require '../ranchu'

jsp = require("uglify-js").parser
pro = require("uglify-js").uglify

module.exports = (code) ->
ast = jsp.parse(code)
ast = pro.ast_mangle(ast)
ast = pro.ast_squeeze(ast)
pro.gen_code(ast)
49 changes: 49 additions & 0 deletions lib/plugins/genxml.coffee
@@ -0,0 +1,49 @@
ltx = require 'ltx'

# <?xml version="1.0" encoding="utf-8" ?>
# <package xmlns="http://www.mendix.com/package/1.0/">
# <clientModule name="boolslide" version="0.1" xmlns="http://www.mendix.com/clientModule/1.0/">
# <widgetFiles>
# <widgetFile path="boolslide/Slider.xml"/>
# </widgetFiles>
# <files>
# <file path="boolslide/"/>
# </files>
# </clientModule>
# </package>

module.exports = (config)->
el = new ltx.Element('package', {
'xmlns' :'http://www.mendix.com/package/1.0/'
}).c('clientModule', {
'name' : config.name
'version' : config.version,
'xmlns' : 'http : //www.mendix.com/clientModule/1.0/'
})

el.c('widgetFiles')
for path in config.widgetFiles
el.c('widgetFile', {
'path' : path
}).up()

el.c('file')
for path in config.files
el.c('file', {
'path' : path
}).up()

# cfg = {
# name : 'ZorkName',
# version : '1.0',
# widgetFiles : [
# 'boolslider.xml'
# ],
# files : [
# 'boolslide'
# ]
# }
#
# console.log genpackage(cfg).toString()


10 changes: 10 additions & 0 deletions lib/plugins/help.coffee
@@ -0,0 +1,10 @@
ranchu = require '../ranchu'

help = module.exports = (args)->
ranchu.log "Help .."
ranchu.log "Available commands are,"
ranchu.plugins.forEach (plugin) ->
ranchu.log " #{plugin}"



24 changes: 24 additions & 0 deletions lib/plugins/new.coffee
@@ -0,0 +1,24 @@
ranchu = require '../ranchu'
fs = require 'fs'

module.exports = (args)->
project = args[0]
ranchu.log "Creating new project #{project}.."

fs.mkdirSync project
process.chdir(project)

["src", "build"].forEach (dir) ->
fs.mkdirSync dir

fs.writeFileSync "config.json", JSON.stringify({
"name" : project
"version" : "0.0.1",
"widgets" : [
],
"compress" : true,
"coffee" : false
}, null, 4)



9 changes: 9 additions & 0 deletions lib/plugins/test.coffee
@@ -0,0 +1,9 @@
ranchu = require '../ranchu'

config = require '../helpers/config'

module.exports = (args)->
console.log "Testing ..."



38 changes: 38 additions & 0 deletions lib/ranchu.coffee
@@ -0,0 +1,38 @@
path = require "path"
fs = require "fs"

logging = true

console.log " *** Loading helpers"
config = require './helpers/config'

console.log " *** Loading plugins"

pluginDirs = [
__dirname + "/plugins",
"~/.ranchu/plugins"
]

plugins = pluginDirs.reduce((prev, curr) ->
console.log " *** Checking #{curr}"
if fs.existsSync curr
prev.concat fs.readdirSync(curr).map (plugin)->
plugin.replace(/\.\w*$/, '')
else
prev

, [])


ranchu = module.exports = {
config : config,
plugins : plugins,
version : '0.0.1',
log : (str) ->
if logging then console.log " *** #{str}"
}

plugins.forEach (plugin) ->
ranchu.log "Adding plugin #{plugin}"
ranchu[plugin] = require "./plugins/" + plugin

27 changes: 27 additions & 0 deletions package.json
@@ -0,0 +1,27 @@
{
"name" : "ranchu",
"version" : "0.0.1",
"author" : "Michiel Kalkman <michielkalkman@gmail.com>",
"directories" : { "lib" : "./lib" },
"main" : "./lib/ranchu",
"bin" : "./bin/ranchu",
"repository" : {
"type" : "git",
"url" : "http://github.com/michiel/ranchu.git"
},
"engines": {
"node": ">= 0.6.0"
},
"preferGlobal": false,
"dependencies": {
"ltx" : "0.x.x",
"jshint" : "0.x.x",
"uglify-js" : "0.x.x",
"sequencer" : "0.x.x",
"coffee-script" : "0.x.x"
},
"description" : "A build tool for Mendix JavaScript custom widget development",
"keywords" : [
"mendix"
]
}
Empty file added template/build/.gitignore
Empty file.
11 changes: 11 additions & 0 deletions template/config.json
@@ -0,0 +1,11 @@
{
"name" : "ZorkName",
"version" : "1.0",
"widgetFiles" : [
"zorkthing.xml"
],
"files" : [
"zorkthing"
]
}

Empty file added template/src/.gitignore
Empty file.
Empty file added test/.gitignore
Empty file.

0 comments on commit a3a1d64

Please sign in to comment.