1
0
Fork 0

chore(skeleton): Provide basic library skeleton

This commit is contained in:
Pixelastic 2015-11-26 12:03:01 +01:00
parent aed7d828cb
commit d65cb99f9a
16 changed files with 7552 additions and 2 deletions

3
.babelrc Normal file
View file

@ -0,0 +1,3 @@
{
"stage": 2
}

3
.eslintignore Normal file
View file

@ -0,0 +1,3 @@
dist/
dist-es5-module/
docs/

3
.eslintrc Normal file
View file

@ -0,0 +1,3 @@
{
"extends": "algolia"
}

8
.gitignore vendored
View file

@ -1,2 +1,6 @@
_site
.sass-cache
node_modules/
dist/
dist-es5-module/
npm-debug.log
docs/_site

5
.npmignore Normal file
View file

@ -0,0 +1,5 @@
dev/bundle.js*
# we do not want to lock down dependencies when used as an npm dependency,
# only when we build
npm-shrinkwrap.json
demo.gif

16
.travis.yml Normal file
View file

@ -0,0 +1,16 @@
language: node_js
node_js: 4
before_install: npm prune
before_cache: npm prune
install: npm install
script: npm test
branches:
only:
- master
- develop
# force container based infra
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/#Routing-your-build-to-container-based-infrastructure
sudo: false
cache:
directories:
- node_modules

7
dev/app.js Normal file
View file

@ -0,0 +1,7 @@
import documentationSearch from '../index.js';
documentationSearch({
apiKey: 'aaa',
indexName: 'bbb',
inputSelector: 'ccc'
});

19
dev/index.html Normal file
View file

@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>documentationsearch.js</title>
<link rel="stylesheet" href="style.css">
<!--[if lte IE 9]>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
<![endif]-->
</head>
<body>
<h1>documentationsearch.js</h1>
<h2>Search in docs: <input type="text" id="search-input" /></h2>
<script src="bundle.js"></script>
</body>
</html>

0
dev/style.css Normal file
View file

11
index.js Normal file
View file

@ -0,0 +1,11 @@
/* global google */
function documentationSearch({
apiKey,
indexName,
inputSelector
}) {
console.info(apiKey, indexName, inputSelector);
}
export default documentationSearch;

7360
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load diff

41
package.json Normal file
View file

@ -0,0 +1,41 @@
{
"name": "documentationsearch.js",
"version": "0.0.1",
"description": "Add an autocomplete dropdown to your documentation",
"main": "dist-es5-module/index.js",
"scripts": {
"dev": "webpack-dev-server --config webpack.dev.config.babel.js --hot --inline --no-info",
"shrinkwrap": "npm-shrinkwrap --dev",
"prepublish": "NODE_ENV=production npm run build",
"build": "./scripts/build.sh",
"release": "./scripts/release.sh",
"lint": "eslint .",
"test": "npm run lint"
},
"author": "Algolia <support@algolia.com> (https://github.com/algolia/)",
"license": "MIT",
"repository": "algolia/documentationsearch.js",
"devDependencies": {
"babel": "^5.8.29",
"babel-core": "^5.8.29",
"babel-eslint": "^4.1.3",
"babel-loader": "^5.3.2",
"conventional-changelog": "^0.5.1",
"doctoc": "^0.15.0",
"eslint": "^1.6.0",
"eslint-config-airbnb": "^0.1.0",
"eslint-config-algolia": "^4.2.0",
"eslint-plugin-react": "^3.5.1",
"json": "^9.0.3",
"mversion": "^1.10.1",
"npm-shrinkwrap": "^200.4.0",
"pretty-bytes": "^2.0.1",
"uglifyjs": "^2.4.10",
"webpack": "^1.12.2",
"webpack-dev-server": "^1.12.1"
},
"peerDependencies": {},
"dependencies": {
"lodash": "^3.10.1"
}
}

33
scripts/build.sh Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -e # exit when error
mkdir -p dist/
mkdir -p dist-es5-module/
rm -rf dist/*
rm -rf dist-es5-module/*
VERSION=$(json version < package.json)
bundle='documentationsearch'
license="/*! ${bundle} ${VERSION:-UNRELEASED} | © Algolia | github.com/algolia/documentationsearch.js */"
webpack --config webpack.config.jsdelivr.babel.js
# only transpile to ES5 for package.json main entry
babel -q index.js -o dist-es5-module/index.js
declare -a sources=("src")
for source in "${sources[@]}"
do
babel -q --out-dir dist-es5-module/${source} ${source}
done
echo "$license" | cat - dist/${bundle}.js > /tmp/out && mv /tmp/out dist/${bundle}.js
cd dist
uglifyjs ${bundle}.js --source-map ${bundle}.min.map --preamble "$license" -c warnings=false -m -o ${bundle}.min.js
cd ..
gzip_size=$(gzip -9 < dist/${bundle}.min.js | wc -c | pretty-bytes)
echo "=> ${bundle}.min.js gzipped will weight $gzip_size-bytes"

11
scripts/release.sh Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -e # exit when error
mversion "${SEMVER_TOKEN:-PLEASE_PROVIDE_A_SEMVER_TOKEN_LIKE_MAJOR_MINOR_PATCH}"
conventional-changelog -p angular -i CHANGELOG.md -w
doctoc --maxlevel 3 README.md
git commit -am "$(json version < package.json)"
git push origin master
git push origin --tags
npm publish

View file

@ -0,0 +1,16 @@
export default {
entry: './index.js',
output: {
path: './dist/',
filename: 'documentationsearch.js',
library: 'documentationSearch',
libraryTarget: 'umd'
},
module: {
loaders: [{
test: /\.js$/, exclude: /node_modules/, loader: 'babel'
}]
},
externals: [],
plugins: []
};

View file

@ -0,0 +1,18 @@
export default {
entry: './dev/app.js',
devtool: 'source-map',
output: {
path: './dev/',
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.js$/, exclude: /node_modules/, loader: 'babel'
}]
},
devServer: {
contentBase: 'dev/',
host: '0.0.0.0',
compress: true
}
};