Skip to content

Commit

Permalink
🤘 Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
VandeurenGlenn committed Feb 20, 2017
0 parents commit e7698a1
Show file tree
Hide file tree
Showing 13 changed files with 382 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
.tmp
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- v7
- v6
- v5
- v4
- '0.12'
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Glenn Vandeuren <[email protected]>

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.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# backed-cli [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url]
> A command line interface for fast es6 development
## Installation

```sh
$ npm install --save backed-cli
```

## Usage

- Create a 'backed.json' file in your projects root [example](https://githug.com/vandeurenglenn/backed-cli/config/backed.json)

Soon

## License

MIT © [Glenn Vandeuren]()

[npm-image]: https://badge.fury.io/js/backed-cli.svg
[npm-url]: https://npmjs.org/package/backed-cli
[travis-image]: https://travis-ci.org/VandeurenGlenn/backed-cli.svg?branch=master
[travis-url]: https://travis-ci.org/VandeurenGlenn/backed-cli
[daviddm-image]: https://david-dm.org/VandeurenGlenn/backed-cli.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/VandeurenGlenn/backed-cli
[coveralls-image]: https://coveralls.io/repos/VandeurenGlenn/backed-cli/badge.svg
[coveralls-url]: https://coveralls.io/r/VandeurenGlenn/backed-cli
58 changes: 58 additions & 0 deletions bin/backed-cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env node
(function () {
'use strict';

const {rollup} = require('rollup');
const json = require('rollup-plugin-json');
const babel = require('rollup-plugin-babel');
let cache;

const importConfig = () => {
let config;
try {
config = require('backed.json');
return config;
} catch (error) {
return console.warn('Backed::backed.json not found, checkout https://github.com/basicelements/backed-cli for more info');
}
};

const backedBuilder$1 = () => {
const config = importConfig();

return rollup({
entry: config.src,
// Use the previous bundle as starting point.
cache: cache
}).then(bundle => {
// Cache our bundle for later use (optional)
cache = bundle;

bundle.write({
format: config.format || 'es',
sourceMap: config.sourceMap || true,
plugins: [
json(),
babel()
],
dest: config.dest
});
});
};

process.title = 'backed';
const commander = require('commander');
const {version} = require('package.json');

commander
.version(version)
.option('-b, --build', 'build your app/component')
.parse(process.argv);

let build = commander.build;

if (build) {
backedBuilder$1();
}

}());
6 changes: 6 additions & 0 deletions config/backed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
"src": "src/backed-cli",
"dest": "dist/backed-cli.js",
"format": "es",
"sourceMap": true
}
114 changes: 114 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
'use strict';
var path = require('path');
var {task, src, dest, watch, series} = require('gulp');
var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');
var coveralls = require('gulp-coveralls');
var rollup = require('rollup');
var json = require('rollup-plugin-json');
var babel = require('rollup-plugin-babel');
var fs = require('fs');
var del = require('del');
var merge = require('merge-stream');

let cache;
let cliCache;

task('static', () => {
return src('**/*.js')
.pipe(excludeGitignore())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});

task('nsp', cb => {
nsp({package: path.resolve('package.json')}, cb);
});

task('pre-test', () => {
return src('lib/**/*.js')
.pipe(excludeGitignore())
.pipe(istanbul({
includeUntested: true
}))
.pipe(istanbul.hookRequire());
});
task('test:after', cb => {
var mochaErr;

src('test/**/*.js')
.pipe(plumber())
.pipe(mocha({reporter: 'spec'}))
.on('error', err => {
mochaErr = err;
})
.pipe(istanbul.writeReports())
.on('end', () => {
cb(mochaErr);
});
});
task('test', series('pre-test', 'test:after'));

task('watch', () => {
watch(['lib/**/*.js', 'test/**'], ['test']);
});

task('coveralls:after', () => {
if (!process.env.CI) {
return;
}

return src(path.join(__dirname, 'coverage/lcov.info'))
.pipe(coveralls());
});

task('coveralls', series('test', 'coveralls:after'));

task('rollup:run', () => {
return rollup.rollup({
entry: 'src/backed-cli.js',
// Use the previous bundle as starting point.
cache: cliCache
}).then(bundle => {
var result = bundle.generate({
format: 'iife',
moduleName: 'backedCli',
plugins: [json(), babel()]
});
// Cache our bundle for later use (optional)
cache = bundle;
fs.writeFileSync('.tmp/backed-cli.js', result.code);
});
});

task('rollup:before', cb => {
fs.mkdirSync('.tmp');
cb();
});

task('rollup:after', () => {
var string = fs.readFileSync('.tmp/backed-cli.js').toString();
string = string.replace('(function', `#!/usr/bin/env node
(function`);
fs.unlinkSync('.tmp/backed-cli.js');
fs.writeFileSync('.tmp/backed-cli.js', string);
var cli = src('.tmp/backed-cli.js').pipe(dest('bin'));

return merge(cli);
});

task('clean', cb => {
del.sync(['.tmp/', 'bin/', 'lib/']);
cb();
});

task('rollup', series('rollup:before', 'rollup:run', 'rollup:after'));

task('build', series('clean', 'rollup'));
task('prepublish', series('nsp'));
task('default', series('static', 'test', 'coveralls'));
69 changes: 69 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "backed-cli",
"version": "0.0.0",
"description": "The official command line interface for Backed",
"homepage": "https://github.com/vandeurenglenn/backed-cli",
"author": {
"name": "Glenn Vandeuren",
"email": "[email protected]",
"url": ""
},
"files": [
"lib",
"bin",
"src"
],
"main": "lib/index.js",
"keywords": [
""
],
"devDependencies": {
"babel-plugin-external-helpers": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"del": "^2.2.2",
"eslint": "^3.1.1",
"eslint-config-xo-space": "^0.15.0",
"gulp": "gulpjs/gulp#4.0",
"gulp-coveralls": "^0.1.0",
"gulp-eslint": "^3.0.1",
"gulp-exclude-gitignore": "^1.0.0",
"gulp-istanbul": "^1.0.0",
"gulp-line-ending-corrector": "^1.0.1",
"gulp-mocha": "^3.0.1",
"gulp-nsp": "^2.1.0",
"gulp-plumber": "^1.0.0",
"merge-stream": "^1.0.1",
"rollup": "^0.40.2",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-json": "^2.1.0"
},
"eslintConfig": {
"extends": "xo-space",
"env": {
"browser": true,
"mocha": true
}
},
"repository": "VandeurenGlenn/backed-cli",
"scripts": {
"prepublish": "gulp prepublish",
"test": "gulp"
},
"license": "MIT",
"dependencies": {
"inject-template": "^0.2.0"
},
"babel": {
"presets": [
[
"es2015",
{
"modules": false
}
]
],
"plugins": [
"external-helpers"
]
}
}
16 changes: 16 additions & 0 deletions src/backed-cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
process.title = 'backed';
const commander = require('commander');
const {version} = require('package.json');

import builder from './builder.js';

commander
.version(version)
.option('-b, --build', 'build your app/component')
.parse(process.argv);

let build = commander.build;

if (build) {
builder();
}
39 changes: 39 additions & 0 deletions src/builder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';
const {rollup} = require('rollup');
const json = require('rollup-plugin-json');
const babel = require('rollup-plugin-babel');
let cache;

const importConfig = () => {
let config;
try {
config = require('backed.json');
return config;
} catch (error) {
return console.warn('Backed::backed.json not found, checkout https://github.com/basicelements/backed-cli for more info');
}
};

const backedBuilder = () => {
const config = importConfig();

return rollup({
entry: config.src,
// Use the previous bundle as starting point.
cache: cache
}).then(bundle => {
// Cache our bundle for later use (optional)
cache = bundle;

bundle.write({
format: config.format || 'es',
sourceMap: config.sourceMap || true,
plugins: [
json(),
babel()
],
dest: config.dest
});
});
};
export default backedBuilder;
10 changes: 10 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

var assert = require('assert');
var backed = require('../lib');

describe('backed', function () {
it('should have unit test!', function () {
assert(false, 'we expected this package author to add actual unit tests.');
});
});

0 comments on commit e7698a1

Please sign in to comment.