Skip to content

Commit 2f5c444

Browse files
committed
Scaffolding to run a command
1 parent be1772a commit 2f5c444

File tree

10 files changed

+201
-7
lines changed

10 files changed

+201
-7
lines changed

.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": ["es2015", "stage-2"],
3+
"plugins": [
4+
"transform-class-properties",
5+
"transform-es2015-modules-commonjs",
6+
]
7+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# OSX
22
.DS_Store
33

4+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
5+
.grunt
6+
7+
# Build artifacts.
48
npm-debug.log
59
node_modules
10+
dist/*

Gruntfile.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var fs = require('fs');
2+
3+
module.exports = function(grunt) {
4+
5+
// load all grunt tasks matching the ['grunt-*', '@*/grunt-*'] patterns
6+
require('load-grunt-tasks')(grunt);
7+
8+
var configs = require('load-grunt-configs')(grunt, {
9+
config: {
10+
src: 'tasks/*.js',
11+
},
12+
});
13+
14+
grunt.initConfig(configs);
15+
16+
grunt.registerTask('build', [
17+
'webpack:build',
18+
]);
19+
20+
grunt.registerTask('watch-build', [
21+
'webpack:watchBuild',
22+
]);
23+
24+
grunt.registerTask('test', [
25+
'webpack:build',
26+
'mochaTest',
27+
'newer:eslint',
28+
'newer:jscs',
29+
]);
30+
31+
};

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Ultimately, it aims to support web extensions in a standard, portable,
77
cross-platform way. Initially, it will provide a streamlined experience for developing
88
[Firefox web extensions](https://developer.mozilla.org/en-US/Add-ons/WebExtensions).
99

10+
## Installation
11+
12+
This tool is not yet ready for installation. Stay tuned.
13+
1014
## Should I Use It?
1115

1216
This tool may require using a
@@ -20,6 +24,20 @@ consider [jpm](https://github.com/mozilla-jetpack/jpm/).
2024
Hi! This tool is under active development. To get involved you can watch the repo,
2125
file issues, create pull requests, or ask a question on
2226
[dev-addons](https://mail.mozilla.org/listinfo/dev-addons).
27+
Read on for how to develop new features.
28+
29+
## Development
30+
31+
You'll need:
32+
* [Node.js](https://nodejs.org/en/), 0.12 or higher
33+
* [npm](https://www.npmjs.com/) installed globally
34+
35+
To get started, clone the source and run `npm install`.
36+
37+
### Build web-ext
38+
39+
Run `npm build` to build a new version of the `./bin/web-ext` command. You can
40+
continously rebuild the package as you edit files by running `npm watch-build`.
2341

2442
## Some Questions and Answers
2543

bin/web-ext

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../dist/web-ext').main();

package.json

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22
"name": "web-ext",
33
"version": "0.0.1",
44
"description": "A command line tool to help build, run, and test web extensions",
5-
"main": "index.js",
5+
"main": "dist/web-ext.js",
6+
"bin": {
7+
"web-ext": "bin/web-ext"
8+
},
9+
"scripts": {
10+
"build": "node -e \"require('grunt').cli()\" null build",
11+
"watch-build": "node -e \"require('grunt').cli()\" null watch-build",
12+
"test": "node -e \"require('grunt').cli()\" null test"
13+
},
614
"homepage": "https://github.com/mozilla/web-ext",
715
"repository": {
816
"type": "git",
@@ -23,11 +31,36 @@
2331
"chrome",
2432
"opera"
2533
],
26-
"dependencies": {},
27-
"devDependencies": {},
34+
"dependencies": {
35+
"babel-polyfill": "6.3.14",
36+
"es6-promisify": "3.0.0",
37+
"yargs": "3.32.0"
38+
},
39+
"devDependencies": {
40+
"babel-core": "6.4.5",
41+
"babel-eslint": "4.1.7",
42+
"babel-loader": "6.2.1",
43+
"babel-plugin-transform-class-properties": "6.4.0",
44+
"babel-plugin-transform-es2015-modules-commonjs": "6.4.5",
45+
"babel-preset-es2015": "6.1.2",
46+
"babel-preset-stage-2": "6.1.2",
47+
"chai": "3.5.0",
48+
"eslint": "1.10.3",
49+
"grunt": "0.4.5",
50+
"grunt-contrib-clean": "0.7.0",
51+
"grunt-contrib-copy": "0.8.2",
52+
"grunt-eslint": "17.3.1",
53+
"grunt-jscs": "2.7.0",
54+
"grunt-mocha-test": "0.12.7",
55+
"grunt-newer": "1.1.1",
56+
"grunt-webpack": "1.0.11",
57+
"load-grunt-configs": "0.4.3",
58+
"load-grunt-tasks": "3.3.0",
59+
"mocha": "2.4.5",
60+
"sinon": "1.17.3",
61+
"webpack": "1.12.12",
62+
"webpack-dev-server": "1.14.0"
63+
},
2864
"author": "Kumar McMillan",
29-
"license": "MPL-2.0",
30-
"scripts": {
31-
"test": "echo \"Error: no test specified\" && exit 1"
32-
}
65+
"license": "MPL-2.0"
3366
}

src/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function main() {
2+
console.log("It's nice! Not really. Sooooon.");
3+
}

tasks/mochaTest.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
options: {
3+
timeout: 1000,
4+
reporter: 'spec',
5+
},
6+
all: ['dist/tests.js'],
7+
};

tasks/webpack.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
var grunt = require('grunt');
2+
var path = require('path');
3+
var webpackConfig = require('../webpack.config.js');
4+
5+
var defaultResolve = webpackConfig.resolve;
6+
7+
function noddyClone(obj) {
8+
return JSON.parse(JSON.stringify(obj));
9+
}
10+
11+
var buildResolve = noddyClone(defaultResolve);
12+
buildResolve.modulesDirectories.push('src/');
13+
14+
var testConfig = {
15+
entry: './tests/runner.js',
16+
output: {
17+
path: path.join(__dirname, '../dist'),
18+
filename: 'tests.js',
19+
},
20+
};
21+
22+
module.exports = {
23+
options: webpackConfig,
24+
build: {
25+
resolve: buildResolve,
26+
},
27+
watchBuild: {
28+
watch: true,
29+
keepalive: true,
30+
resolve: buildResolve,
31+
},
32+
test: {
33+
entry: testConfig.entry,
34+
output: testConfig.output,
35+
resolve: buildResolve,
36+
},
37+
};

webpack.config.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
var webpack = require('webpack');
2+
var path = require('path');
3+
var fs = require('fs');
4+
5+
var nodeModules = {};
6+
7+
// This is to filter out node_modules as we don't want them
8+
// to be made part of any bundles.
9+
fs.readdirSync('node_modules')
10+
.filter(function(x) {
11+
return ['.bin'].indexOf(x) === -1;
12+
})
13+
.forEach(function(mod) {
14+
// jscs:disable requireTemplateStrings
15+
nodeModules[mod] = 'commonjs ' + mod;
16+
// jscs:enable requireTemplateStrings
17+
});
18+
19+
20+
module.exports = {
21+
entry: './src/main.js',
22+
target: 'node',
23+
output: {
24+
path: path.join(__dirname, 'dist'),
25+
filename: 'web-ext.js',
26+
libraryTarget: 'commonjs2',
27+
},
28+
module: {
29+
loaders: [
30+
{
31+
exclude: /(node_modules|bower_components)/,
32+
test: /\.js$/,
33+
// babel options are in .babelrc
34+
loaders: ['babel'],
35+
},
36+
],
37+
},
38+
externals: nodeModules,
39+
plugins: [
40+
new webpack.BannerPlugin('require("source-map-support").install();',
41+
{ raw: true, entryOnly: false }),
42+
],
43+
resolve: {
44+
extensions: ['', '.js', '.json'],
45+
modulesDirectories: [
46+
'node_modules',
47+
],
48+
},
49+
devtool: 'sourcemap',
50+
};

0 commit comments

Comments
 (0)