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

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquecarv committed Dec 17, 2018
0 parents commit 84b9228
Show file tree
Hide file tree
Showing 10 changed files with 1,901 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

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

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "google",
"parserOptions": {
"ecmaVersion": 2018
}
}
86 changes: 86 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# 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 (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

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

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

#DynamoDB Local files
.dynamodb/

# End of https://www.gitignore.io/api/node
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Henrique Carvalho da Cruz

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.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# gulp-bump-beta

Gulp plugin to bump beta version property in versioning files

[![LICENSE](https://img.shields.io/github/license/henriquecarv/gulp-bump-beta.svg)](./LICENSE)
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=henriquecarv/gulp-bump-beta)](https://dependabot.com)

## System Requirements

- **[NodeJS](https://nodejs.org/en/)** (version >= 10).

## Installing

- `npm i -D gulp gulp-bump-beta`

## Usage

- Create a gulpfile to run your tasks.

```javascript
const gulp = require('gulp');
const beta = require('gulp-bump-beta');

const paths = { package: './package.json', manifest: './manifest.json' };

const bumpBeta = () => {
return gulp
.src(Object.values(paths))
.pipe(beta())
.pipe(gulp.dest('./'));
};

gulp.task('bump-beta', gulp.series(bumpBeta));
```

### License

Copylefted (c) 2018 [Henrique Carvalho da Cruz][1] Licensed under the [MIT license][2].

[1]: https://henriquecarv.com
[2]: ./LICENSE
32 changes: 32 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

const log = require('plugin-log');
const pluginError = require('plugin-error');
const through = require('through2');
const bump = require('./lib/bump');

const PLUGIN_NAME = 'gulp-bump-beta';

module.exports = () => {
return through.obj((file, encoding, cb) => {
if (file.isNull()) {
return cb(null, file);
}
if (file.isStream()) {
// eslint-disable-next-line new-cap
return cb(new pluginError(PLUGIN_NAME, 'Streaming not supported'));
}

const {previousVersion, fileString, newVersion} = bump(file);

file.contents = Buffer.from(fileString);

log(
`Bumped ${log.colors.cyan(previousVersion)} to ${log.colors.magenta(
newVersion
)} with type: ${log.colors.cyan('beta')}`
);

cb(null, file);
});
};
25 changes: 25 additions & 0 deletions lib/bump.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

const bump = (file) => {
const fileContents = String(file.contents);
const fileJson = JSON.parse(fileContents);

const previousVersion = fileJson.version;

const versionArray = previousVersion.split('-beta.');
const [stable, betaVersion] = versionArray;

let newVersion = '';

if (betaVersion) {
newVersion = `${stable}-beta.${parseInt(betaVersion.slice(-1)) + 1}`;
} else newVersion = `${stable.replace('-beta', '')}-beta.${1}`;

fileJson.version = newVersion;

const fileString = JSON.stringify(fileJson, null, 4);

return {previousVersion, fileString, newVersion};
};

module.exports = bump;
Loading

0 comments on commit 84b9228

Please sign in to comment.