forked from andrzejsliwa/coffeeapp
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b18d2ad
Showing
5 changed files
with
178 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# CoffeeApp - coffee-script wrapper for CouchApp | ||
# Copyright 2010 Andrzej Sliwa (andrzej.sliwa@i-tool.eu) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
.PHONY: all build install clean uninstall | ||
|
||
all: build | ||
|
||
build: | ||
@echo 'CoffeeApp built.' | ||
|
||
install: | ||
@cp ./lib/coffeeapp.coffee /usr/local/bin/coffeeapp && \ | ||
chmod 755 /usr/local/bin/coffeeapp && \ | ||
echo 'CoffeeApp installed.' | ||
|
||
clean: | ||
@true | ||
|
||
uninstall: | ||
@rm -f /usr/local/bin/coffeeapp && \ | ||
echo 'CoffeeApp uninstalled.' |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
### CoffeeApp -- coffee-script wrapper for CouchApp | ||
|
||
### Installing | ||
|
||
Prerequisites: CoffeeScript requires Node.js (<http://nodejs.org/>), Npm (http://npmjs.org/) | ||
|
||
Get CoffeeApp: | ||
|
||
git clone git://github.com/andrzejsliwa/coffeeapp.git | ||
|
||
Build Jake: | ||
|
||
cd coffeeapp && make && sudo make install | ||
|
||
### Installing with [npm](http://npmjs.org/) | ||
|
||
npm install coffeeapp | ||
|
||
Or, get the code, and `npm link` in the code root. | ||
|
||
### Basic usage | ||
|
||
coffeeapp [couchapp options] | ||
|
||
|
||
### Description | ||
|
||
CoffeeApp is a simple wrapper for couchapp command. | ||
CoffeeApp overide normal push behavoir, by adding .releases directory which contain deployment snapshots | ||
While files are copied to release snapshot... coffee-script files (.coffee) are converted on the fly to | ||
java-script (.js) files. | ||
|
||
.releases directory should be added to .gitignore or .hgignore or whatever you have using to prevent versioning. | ||
|
||
|
||
### Author | ||
|
||
Andrzej Sliwa, andrzej.sliwa@i-tool.eu |
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/env coffee | ||
# | ||
# CoffeeApp - coffee-script wrapper for CouchApp | ||
# Copyright 2010 Andrzej Sliwa (andrzej.sliwa@i-tool.eu) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
exist = require('path').existsSync | ||
joinPath = require('path').join | ||
extName = require('path').extname | ||
mkDir = require('fs').mkdirSync | ||
readDir = require('fs').readdirSync | ||
writeFile = require('fs').writeFileSync | ||
readFile = require('fs').readFileSync | ||
getStats = require('fs').statSync | ||
coffeeCompile = require('coffee-script').compile | ||
exec = require('child_process').exec | ||
|
||
padTwo = (number) -> | ||
result = if number < 10 then '0' else '' | ||
result + String(number) | ||
|
||
|
||
getTimestamp = -> | ||
date = new Date() | ||
date.getFullYear() + | ||
padTwo(date.getMonth() + 1) + | ||
padTwo(date.getDate()) + | ||
padTwo(date.getHours() + 1) + | ||
padTwo(date.getMinutes() + 1) + | ||
padTwo(date.getSeconds() + 1) | ||
|
||
processRecursive = (currentDir, destination) -> | ||
fileList = readDir(currentDir) | ||
for fileName in fileList | ||
filePath = joinPath(currentDir, fileName) | ||
destFilePath = joinPath(destination, filePath) | ||
if getStats(filePath).isDirectory() | ||
unless fileName[0] == '.' | ||
mkDir(destFilePath, 0700) | ||
processRecursive(filePath, destination) | ||
else | ||
if extName(filePath) == '.coffee' | ||
console.log('processing ' + filePath + '...') | ||
writeFile(destFilePath.replace(/\.coffee$/, '.js'), | ||
coffeeCompile(readFile(filePath, encoding = 'utf8'), noWrap: yes).replace(/^\(/,'').replace(/\);$/, ''), encoding = 'utf8') | ||
else | ||
writeFile(destFilePath, readFile(filePath, encoding = 'utf8'), encoding = 'utf8') | ||
|
||
grindCoffee = -> | ||
releasesDir = '.releases' | ||
unless exist(releasesDir) | ||
console.log 'initialize ' + releasesDir + ' directory' | ||
mkDir(releasesDir, 0700) | ||
releasePath = joinPath(releasesDir, getTimestamp()) | ||
mkDir(releasePath, 0700) | ||
processRecursive('.', releasePath) | ||
process.chdir(releasePath) | ||
exec('couchapp push', (error, stdout, stderr) -> | ||
console.log(stdout) | ||
console.log(stderr) | ||
if (error != null) | ||
console.log('exec error: ' + error) | ||
) | ||
process.cwd() | ||
|
||
|
||
if 'push' in process.argv | ||
grindCoffee() | ||
else | ||
options = '' | ||
for opt in process.argv | ||
options += " " + opt | ||
|
||
exec('couchapp' + options, (error, stdout, stderr) -> | ||
console.log(stdout) | ||
console.log(stderr) | ||
if (error != null) | ||
console.log('exec error: ' + error) | ||
) | ||
|
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ "name" : "coffeeapp" | ||
, "version" : "0.0.1" | ||
, "author" : "Andrzej Sliwa <andrzej.sliwa@i-tool.eu> (http://andrzejsliwa.com)" | ||
, "main" : "./lib/coffeeapp.coffee" | ||
, "bin" : { "coffeeapp" : "./lib/coffeeapp.coffee" } | ||
, "dependencies": { "coffee-script" : "0.9.4" } | ||
, "repository": { | ||
"type": "git", | ||
"url": "git://github.com/andrzejsliwa/coffeeapp.git" | ||
}, | ||
|
||
} |