diff --git a/.editorconfig b/.editorconfig index 7a5d9d3..0c09dc7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,8 +7,9 @@ charset = utf-8 indent_size = 4 trim_trailing_whitespace = true -[*.{js,jsx,html}] +[*.json] indent_style = space +indent_size = 2 -[*.{frag,vert}] -indent_style = tab +[*.{js}] +indent_style = space diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..3dddf3f --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +dist/* +node_modules/* diff --git a/.eslintrc b/.eslintrc index 0d67347..428dd67 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,18 +1,3 @@ { - "rules": { - "curly": [2, "multi-line"], - "eol-last": [2], - "indent": [2, 4], - "quotes": [2, "single"], - "linebreak-style": [2, "unix"], - "max-len": [2, 80, 4], - "semi": [2, "always"], - "strict": [2, "never"], - "no-console": [2, {"allow": ["log", "warn", "error"]}] - }, - "env": { - "node": true, - "browser": true - }, - "extends": "eslint:recommended" + "extends": "eslint-config-scratch" } diff --git a/.gitignore b/.gitignore index ff74a5c..5612849 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ npm-* # IDEA /.idea + +# Build +/dist diff --git a/README.md b/README.md new file mode 100644 index 0000000..de1a742 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +## scratch-storage +#### Scratch Storage is a library for loading and storing project and asset files for Scratch 3.0 diff --git a/package.json b/package.json new file mode 100644 index 0000000..147a98b --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "scratch-storage", + "version": "0.0.1", + "description": "Load and store project and asset files for Scratch 3.0", + "license": "BSD-3-Clause", + "homepage": "https://github.com/LLK/scratch-storage#readme", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/LLK/scratch-storage.git" + }, + "main": "./dist.js", + "scripts": { + "build": "./node_modules/.bin/webpack --progress --colors --bail", + "coverage": "./node_modules/.bin/tap ./test/{unit,integration}/*.js --coverage --coverage-report=lcov", + "lint": "./node_modules/.bin/eslint .", + "prepublish": "npm run build", + "prepublish-watch": "npm run watch", + "start": "./node_modules/.bin/webpack-dev-server", + "tap-integration": "./node_modules/.bin/tap ./test/integration/*.js", + "tap-unit": "./node_modules/.bin/tap ./test/unit/*.js", + "test": "npm run lint && npm run tap-unit && npm run tap-integration", + "version": "./node_modules/.bin/json -f package.json -I -e \"this.repository.sha = '$(git log -n1 --pretty=format:%H)'\"", + "watch": "./node_modules/.bin/webpack --progress --colors --watch-poll" + }, + "devDependencies": { + "babel-core": "^6.17.0", + "babel-eslint": "^7.0.0", + "babel-loader": "^6.2.5", + "babel-polyfill": "^6.16.0", + "babel-preset-es2015": "^6.16.0", + "debug": "^2.2.0", + "eslint": "^3.8.1", + "eslint-plugin-react": "^6.4.1", + "webpack": "^1.13.2" + } +} diff --git a/src/ScratchStorage.js b/src/ScratchStorage.js new file mode 100644 index 0000000..b6debcd --- /dev/null +++ b/src/ScratchStorage.js @@ -0,0 +1,5 @@ +class ScratchStorage { + +} + +module.exports = ScratchStorage; diff --git a/src/index-web.js b/src/index-web.js new file mode 100644 index 0000000..672d46e --- /dev/null +++ b/src/index-web.js @@ -0,0 +1,7 @@ +require('babel-polyfill'); + +/** + * Export for use on a web page. + * @type {ScratchStorage} + */ +window.ScratchStorage = require('./index'); diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..c9b0564 --- /dev/null +++ b/src/index.js @@ -0,0 +1,7 @@ +const ScratchStorage = require('./ScratchStorage'); + +/** + * Export for use with NPM & Node.js. + * @type {ScratchStorage} + */ +module.exports = ScratchStorage; diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..c60e4a6 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,59 @@ +const path = require('path'); +const webpack = require('webpack'); + +const base = { + module: { + loaders: [ + { + include: [ + path.resolve(__dirname, 'src') + ], + test: /\.js$/, + loader: 'babel-loader', + query: { + presets: ['es2015'] + } + }, + { + test: /\.json$/, + loader: 'json-loader' + } + ] + }, + plugins: [ + new webpack.optimize.UglifyJsPlugin({ + include: /\.min\.js$/, + minimize: true, + compress: { + warnings: false + } + }) + ] +}; + +module.exports = [ + // Web-compatible + Object.assign({}, base, { + entry: { + 'scratch-storage': './src/index-web.js', + 'scratch-storage.min': './src/index-web.js' + }, + output: { + path: __dirname, + filename: 'dist/web/[name].js' + } + }), + + // Webpack-compatible + Object.assign({}, base, { + entry: { + 'scratch-storage': './src/index.js' + }, + output: { + library: 'ScratchStorage', + libraryTarget: 'commonjs2', + path: __dirname, + filename: 'dist/node/[name].js' + } + }) +];