Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

Commit

Permalink
feat: Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
randytarampi committed Mar 12, 2019
0 parents commit d754074
Show file tree
Hide file tree
Showing 21 changed files with 12,989 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "2"
checks:
method-lines:
enabled: true
config:
threshold: 100
method-complexity:
config:
threshold: 10
method-count:
config:
threshold: 25
plugins:
editorconfig:
enabled: false
eslint:
enabled: true
channel: eslint-5
config: .eslintrc.yaml
fixme:
enabled: true
git-legal:
enabled: true
shellcheck:
enabled: true
exclude_patterns:
- "node_modules/"
- "dist/"
- "docs/"
- "test/"
34 changes: 34 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# EditorConfig is awesome: http://EditorConfig.org
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.json]
indent_size = 2

[*.yaml]
indent_size = 2

[*.yml]
indent_size = 2

[*.config]
indent_size = 2

[*.babelrc]
indent_size = 2

[*.nycrc]
indent_size = 2

[**/{node_modules, dist, build, es5, esm, docs, coverage, .nyc_output, .serverless, .webpack, .dynamodb, .idea}/**]
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
indent_style = unset
indent_size = unset
12 changes: 12 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
dist
build
es5
esm
docs
coverage
.nyc_output
.serverless
.webpack
.dynamodb
.idea
33 changes: 33 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
extends:
- eslint:recommended
rules:
no-useless-escape: 1
eqeqeq: 2
semi: 2
quotes:
- 2
- double
import/named: 2
import/export: 2
import/no-mutable-exports: 2
import/first: 2
import/no-duplicates: 2
import/no-unresolved: 2
import/default: 2
no-global-assign: 2
parserOptions:
ecmaVersion: 6
env:
node: true
es6: true
mocha: true
globals:
Promise: true
plugins:
- import
settings:
import/resolver:
node:
extensions:
- .js
- .json
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Project files
*.iml
*.idea

# OS files
.DS_Store
39 changes: 39 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"extension": [
".jsx"
],
"exclude": [
"node_modules/**",
"coverage/**",
".nyc_output/**",
"test/**",
"*.js"
],
"reporter": [
"text-summary",
"lcov"
],
"cache": true,
"all": true,
"check-coverage": true,
"sourceMap": true,
"instrument": true,
"watermarks": {
"lines": [
70,
90
],
"functions": [
70,
90
],
"branches": [
70,
90
],
"statements": [
70,
90
]
}
}
12 changes: 12 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/changelog"
- "@semantic-release/npm"
- - "@semantic-release/git"
- assets:
- package.json
- package-lock.json
- CHANGELOG.md
message: "release(travis): Release ${nextRelease.version}\n\n[skip ci]\n\n${nextRelease.notes}"
- "@semantic-release/github"
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: node_js
notifications:
email: false
dist: xenial
node_js:
- 8
- 6
- 10
- node
before_deploy:
- git config --local user.name "$TRAVIS_AUTHOR_NAME"
- git config --local user.email "$TRAVIS_AUTHOR_EMAIL"
deploy:
provider: script
script: npx semantic-release
skip_cleanup: true
on:
branch: master
node: 8
os: linux
sudo: false
env:
global:
- secure: SyCNOdW+Z3kQNPVwjoBBnHJ8ooD2O/QeKQXMdO8We6N31VfviJf2EgNXPC3FEhTNgLiaD37lT/jcYnZk0cAtZqS4Of77dCqR6GdNFnCECTYDUaIFYKI3/cNT0AhGvIUJLZytxVV4BpG213RC/lFb4GpiJsLhwovZYItnhnIlVmYVuw5Woqclpt1zUE/PfeFeQ79AMgGFhYU4WifKT6oW+ni/FJtJjOR/7sFFg4sWi7ntibPytXVPdQBupCWzFAtc9t+2shPwX1U2DaQFrISZ94scUfGgJXR3v2zNkawWE5hiJK2EPKQwfpO+dsrBvXTD1PBqF/tAO4E8xFAOb9ahOHLZzkcx0wd35tt7f/7TFGqh3xnr0Kl8CfTetqXM0SKPFYaLp8lSC4VNAR9nxVHiZphgDXrrQU5Mmy+SI6EH0gLBEU20DVbKMYeDdbxdCFYSdFRJ8+jJJDC94WSuROawLKvrRDL+RhkxjCdC8qMfds1btkQ1Zr/GrLTqm8LltHi9Q8hnn7DuTsxvChicP6hFJW/YlHBpRNnj0qbh6vS6RpRnhvbGOVYJPmMr+oZASNMOuRbRFY2uzOInHfkp84og19898DSE69+hO6nd/7e8QBb75Mob0GkXZEfPDkQdAT4l+yForrZFChSPClNJB3dEfDgGrXVEAk2SGyKjO2TFoBA=
- secure: cBOnfRvIL5pzS+iPEFw3soYHTD6dEFOHpRxGJQnOGOZKEpyMsptip+FVoyidPzePLUHon88qLbn9bZRcDjRj4ZelhUaRbJAX0UbUOezP4zUXAgc6rVMetcc7KEiDaORE+posSQqomJoFiZ8oa4L/YfaxlkKh2QU2+ZQKP4LacOr6/9zjh+5d1pxCvazBbJPSxOg2X08nVSPa8Xm7J0FDV4TI9It5XLdf+UidhCZ0IUAvptNN/BBNyHcgBKjn6f20HGPiagLaF/NbbQnkZAo6K0n8B/7V+5VoiT6Mul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cZd62ubA=
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) 2016 Randy Tarampi

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.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
pwa-asset-generator
---

[![npm versions](https://img.shields.io/npm/v/@randy.tarampi/pwa-asset-generator.svg?style=flat-square)](https://www.npmjs.org/package/@randy.tarampi/pwa-asset-generator)
[![npm downloads](https://img.shields.io/npm/dt/@randy.tarampi/pwa-asset-generator.svg?style=flat-square)](https://www.npmjs.com/package/@randy.tarampi/pwa-asset-generator)
[![npm license](https://img.shields.io/npm/l/@randy.tarampi/pwa-asset-generator.svg?registry_uri=https%3A%2F%2Fregistry.npmjs.com&style=flat-square)](https://www.npmjs.com/package/@randy.tarampi/pwa-asset-generator)
[![Build status](https://img.shields.io/travis/com/randytarampi/pwa-asset-generator.svg?style=flat-square)](https://travis-ci.com/randytarampi/pwa-asset-generator)
[![Coverage status](https://img.shields.io/coveralls/randytarampi/pwa-asset-generator.svg?style=flat-square)](https://coveralls.io/github/randytarampi/pwa-asset-generator?branch=master)
[![Maintainability status](https://img.shields.io/codeclimate/maintainability-percentage/randytarampi/pwa-asset-generator.svg?style=flat-square)](https://codeclimate.com/github/randytarampi/pwa-asset-generator/maintainability)
[![Waffle.io board](https://badge.waffle.io/randytarampi/randytarampi.github.io.svg?columns=all&style=flat-square)](https://waffle.io/randytarampi/randytarampi.github.io)
[![Analytics](https://ga-beacon.appspot.com/UA-50921068-1/beacon/github/randytarampi/pwa-asset-generator/?flat&useReferrer)](https://github.com/igrigorik/ga-beacon)
[![Greenkeeper badge](https://badges.greenkeeper.io/randytarampi/pwa-asset-generator.svg)](https://greenkeeper.io/)

[![Install @randy.tarampi/pwa-asset-generator](https://nodeico.herokuapp.com/@randy.tarampi/pwa-asset-generator.svg)](https://www.npmjs.com/package/@randy.tarampi/pwa-asset-generator)

Use `sharp` to quickly generate image assets for a Progressive Web Application.

A single solution that wholly replaces [`@randy.tarampi/android-icon-resize`](https://www.npmjs.com/package/@randy.tarampi/android-icon-resize), [`@randy.tarampi/android-splash-generate`](https://www.npmjs.com/package/@randy.tarampi/android-splash-generate), [`@randy.tarampi/ios-icon-resize`](https://www.npmjs.com/package/@randy.tarampi/ios-icon-resize) and [`@randy.tarampi/ios-splash-generate`](https://www.npmjs.com/package/@randy.tarampi/ios-splash-generate), or their old `lwip` relatives [`android-icon-resize`](https://www.npmjs.com/package/android-icon-resize), [`android-splash-generate`](https://www.npmjs.com/package/android-splash-generate), [`ios-icon-resize`](https://www.npmjs.com/package/ios-icon-resize) and [`ios-splash-generate`](https://www.npmjs.com/package/ios-splash-generate).

# Dependencies
```bash
brew install nvm
nvm install 8
npm install -g npm
```

# Installation

```bash
npm install -g @randy.tarampi/pwa-asset-generator
```

# Usage

```bash
# Generate icons and splash screens from a single file to the current working directory
pwa-asset-generator ./path/to/input/file

# Generate icons and splash screens from a single file to a specific directory
pwa-asset-generator ./path/to/input/file ./path/to/output/directory

# Generate splash screens from `./path/to/input/file` and icons from `./path/to/icon/file`
pwa-asset-generator ./path/to/input/file --icon ./path/to/icon/file

# Generate splash screens from `./path/to/splash/file` and icons from `./path/to/input/file`
pwa-asset-generator ./path/to/input/file --splash ./path/to/splash/file

# Generate icons and splash screens for a given format
pwa-asset-generator ./path/to/input/file --format webp
```

# Testing

```bash
npm test
```
42 changes: 42 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env node

const commander = require("commander");
const { errorMessage } = require("@randy.tarampi/generic-icon-splash-generate");
const { generateIcons, generateSplashScreens } = require("../src");
const packageJson = require("../package.json");

commander
.version(packageJson.version)
.usage("[options] <inputImagePath> [outputImageDirectoryPath]")
.description(packageJson.description)
.option("--icon <iconInputImagePath>", "Path to a distinct icon source image")
.option("--splash <splashInputImagePath>", "Path to a distinct splash screen source image")
.option("-f --format <outputImageFormat>", "Generate files for a particular file format {png|jpeg|jpg|tiff|webp}",
/^(png|jpeg|jpg|tiff|webp)$/gm)
.action((inputImagePath, outputImageDirectoryPath) => {
if (typeof inputImagePath !== "string") {
commander.help();
process.exit(1);
}
if (typeof outputImageDirectoryPath !== "string") {
outputImageDirectoryPath = undefined;
}

const iconInputImagePath = commander.icon || inputImagePath;
const splashInputImagePath = commander.splash || inputImagePath;
const outputImageFormat = commander.format;

return Promise.all([
generateIcons(iconInputImagePath, outputImageDirectoryPath, outputImageFormat),
generateSplashScreens(splashInputImagePath, outputImageDirectoryPath, outputImageFormat)
])
.then(() => {
return process.exit(0);
})
.catch(error => {
errorMessage(error);
return process.exit(1);
});
});

commander.parse(process.argv);
37 changes: 37 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const gulp = require("gulp");

function isFixed(file) {
return file.eslint && file.eslint.fixed;
}

gulp.task("eslint", () => {
const path = require("path");
const eslint = require("gulp-eslint");
const gulpIf = require("gulp-if");

return gulp.src(["**/*.js"])
.pipe(eslint({fix: true, ignorePath: path.join(__dirname, ".eslintignore")}))
.pipe(eslint.format())
.pipe(gulpIf(isFixed, gulp.dest("./")))
.pipe(eslint.failAfterError());
});

gulp.task("lint", gulp.parallel(["eslint"]));

gulp.task("test.unit", () => {
const mocha = require("gulp-mocha");
const mochaConfig = require("./mocha.config");

return gulp.src("test/unit/**/*.js", {read: false})
.pipe(mocha(mochaConfig));
});

gulp.task("test.integration", () => {
const mocha = require("gulp-mocha");
const mochaConfig = require("./mocha.config");

return gulp.src("test/integration/**/*.js", {read: false})
.pipe(mocha(mochaConfig));
});

gulp.task("test", gulp.parallel(["test.unit", "test.integration"]));

0 comments on commit d754074

Please sign in to comment.