Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 9fe0750

Browse files
committed
Configured for GitHub Releases and Travis CI.
1 parent 015e911 commit 9fe0750

File tree

6 files changed

+184
-166
lines changed

6 files changed

+184
-166
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
node_modules/
3+
build/

.travis.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
language: node_js
22
node_js:
3-
- "0.10"
4-
install:
5-
- "npm install -g coffee-script"
6-
- "npm install -g mocha"
3+
- '0.10'
4+
before_install:
5+
- npm install coffee-script
6+
before_script:
7+
- ./node_modules/.bin/cake archive
78
script:
8-
- "cake test"
9+
- ./node_modules/.bin/cake test
10+
deploy:
11+
provider: releases
12+
api_key:
13+
secure: CtQ7v+q6DG7xQw3h1DfXhodjAWxNj4m0gQ1ajl1JoSZvz9ANcLTuVrdkSEzNuUDL/Ysez295ro8OtUwBDubVJxcT3BKPTa8d2XpYjsCHUhPCzJdWfU0N7ZkxELCy6TTVNLaLsLYJyhYHwezETWhAQXnRgNDVrYHoHpsO6XfPrRY=
14+
file: build/APIBlueprintImporter.zip
15+
skip_cleanup: true
16+
on:
17+
tags: true
18+
all_branches: true
19+
repo: apiaryio/Paw-APIBlueprintImporter

APIBlueprintImporter.js

Lines changed: 0 additions & 153 deletions
This file was deleted.

Cakefile

Lines changed: 90 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,97 @@
1-
{exec} = require "child_process"
1+
{spawn, exec} = require 'child_process'
2+
{ncp} = require 'ncp'
3+
mkdirp = require 'mkdirp'
4+
fs = require 'fs'
5+
6+
file = 'APIBlueprintImporter.coffee'
7+
identifier = 'io.apiary.PawExtensions.APIBlueprintImporter'
8+
9+
extensions_dir = "#{ process.env.HOME }/Library/Containers/com.luckymarmot.Paw/Data/Library/Application Support/com.luckymarmot.Paw/Extensions/"
10+
build_root_dir = "build"
11+
build_dir = "#{ build_root_dir }/#{ identifier }"
12+
13+
# compile CoffeeScript
14+
build_coffee = (callback) ->
15+
coffee = spawn 'coffee', ['-c', '-o', build_dir, file]
16+
coffee.stderr.on 'data', (data) ->
17+
process.stderr.write data.toString()
18+
coffee.stdout.on 'data', (data) ->
19+
process.stdout.write data.toString()
20+
coffee.on 'exit', (code) ->
21+
if code is 0
22+
callback?()
23+
else
24+
console.error "Build failed with error: #{ code }"
25+
26+
# copy files to build directory
27+
build_copy = () ->
28+
fs.writeFileSync "#{ build_dir }/README.md", fs.readFileSync("./README.md")
29+
fs.writeFileSync "#{ build_dir }/LICENSE", fs.readFileSync("./LICENSE")
30+
31+
# build: build CoffeeScript and copy files to build directory
32+
build = (callback) ->
33+
# mkdir build dir
34+
mkdirp build_dir, (err) ->
35+
if err
36+
console.error err
37+
else
38+
build_coffee () ->
39+
build_copy()
40+
callback?()
41+
42+
# install: copy files to Extensions directory
43+
install = (callback) ->
44+
ncp build_dir, "#{ extensions_dir }/#{ identifier }", (err) ->
45+
if err
46+
console.error err
47+
else
48+
callback?()
49+
50+
# archive: create a zip archive from the build
51+
archive = (callback) ->
52+
zip_file = "#{ identifier.split('.').pop() }.zip"
53+
54+
# go to build dir
55+
process.chdir "#{ build_root_dir }/"
56+
57+
# delete any previous zip
58+
if fs.existsSync zip_file
59+
fs.unlinkSync zip_file
60+
61+
# zip
62+
zip = spawn 'zip', ["-r", zip_file, "#{ identifier }/"]
63+
zip.stderr.on 'data', (data) ->
64+
process.stderr.write data.toString()
65+
zip.stdout.on 'data', (data) ->
66+
process.stdout.write data.toString()
67+
zip.on 'exit', (code) ->
68+
if code is 0
69+
callback?()
70+
else
71+
console.error "zip returned with error code: #{ code }"
72+
73+
task 'build', ->
74+
build()
275

376
task 'test', ->
4-
exec 'mocha --compilers coffee:coffee-script/register test.coffee', (err, output) ->
77+
exec './node_modules/mocha/bin/mocha --compilers coffee:coffee-script/register test.coffee', (err, output) ->
578
throw err if err
679
console.log output
780

8-
task 'build', ->
9-
exec 'coffee --compile APIBlueprintImporter.coffee'
10-
console.log "APIBlueprintImporter.js has been built."
81+
task 'install', ->
82+
build () ->
83+
install()
1184

12-
task 'watch', ->
13-
exec 'coffee --watch --compile APIBlueprintImporter.coffee'
85+
task 'archive', ->
86+
build () ->
87+
archive()
1488

89+
task 'watch', ->
90+
# find all files in directory
91+
for filename in fs.readdirSync '.'
92+
# only watch non-hidden files
93+
if not filename.match(/^\./) and fs.lstatSync("./#{ filename }").isFile()
94+
fs.watchFile "./#{ filename }", {persistent:true, interval:500}, (_event, _filename) ->
95+
# when a file is changed, build and install
96+
build () ->
97+
install()

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,64 @@ Paw API Blueprint Importer Extension
66
This extension depends on a pre-released version of Paw and is not yet ready
77
for public consumption.
88

9+
### Installation
10+
11+
The [Paw extension](http://luckymarmot.com/paw/extensions/APIBlueprintImporter) can be installed with one simple step by clicking [here](paw://extensions/io.apiary.PawExtensions.APIBlueprintImporter?install).
12+
13+
#### Development Instructions
14+
15+
If you would like to develop the extension, you have follow these steps to get a development environment setup.
16+
17+
##### Clone
18+
19+
First of all, clone this repository in any convenient location (e.g `~/Desktop`).
20+
21+
```bash
22+
$ git clone https://github.com/apiaryio/Paw-APIBlueprintImporter
23+
```
24+
25+
##### Prerequisites
26+
27+
Install `npm` if needed (e.g. below using [Homebrew](http://brew.sh/)):
28+
29+
```bash
30+
$ brew install npm
31+
```
32+
33+
Install dependencies using `npm`:
34+
35+
```bash
36+
$ npm install
37+
```
38+
39+
##### Development Installation
40+
41+
During development, build the `.js` script using:
42+
43+
```bash
44+
$ cake build
45+
```
46+
47+
To install into the Paw Extension directory:
48+
49+
```bash
50+
$ cake install
51+
```
52+
53+
Alternatively, use the `watch` command to automatically build and install when a file has been modified:
54+
55+
```bash
56+
$ cake watch
57+
```
58+
59+
##### Tests
60+
61+
Run the tests:
62+
63+
```bash
64+
$ cake test
65+
```
66+
967
### License
1068

1169
MIT License. See the [LICENSE](LICENSE) file.
12-

package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "Paw-APIBlueprintGenerator",
3+
"version": "1.0.0",
4+
"devDependencies": {
5+
"coffee-script": "latest",
6+
"mkdirp": "~0.5.0",
7+
"ncp": "~1.0.1",
8+
"mocha": "latest"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "[email protected]:apiaryio/Paw-APIBlueprintGenerator.git"
13+
},
14+
"scripts": {
15+
"test": "./node_modules/.bin/cake test"
16+
}
17+
}

0 commit comments

Comments
 (0)