<commit_before>'use strict';

var message = {
	type: 'list',
	name: 'bump',
	message: 'What type of version bump would you like to do?',
	choices: ['patch', 'minor', 'major'],
	"default": 'patch'
};

/**
 * Recipe:
 * bump version
 *
 * Ingredients:
 * gulp-bump
 * gulp-config-sync
 * gulp-prompt
 *
 */
function bumpTask(gulp, config, stream, done) {
	// lazy loading required modules.
	var _ = require('lodash'),
		bump = require('gulp-bump'),
		configSync = require('gulp-config-sync'),
		prompt = require('gulp-prompt').prompt;

	var options = _.defaultsDeep({}, config.options, defaults.options);

	// prompt value is in res.bump
	prompt(message, function(res) {
		// note:
		// gulp-bump 可以一次修改多個 .json 檔案，但是並不遵循 single source of truth 原則。
		// gulp-bump 針對每個檔案讀取其 version 資訊，然後各自修改其版本號碼。所以可能造成設定不同步的狀況。
		// 因此，實際使用時，最好只指定 package.json 進行版本修定，然後再利用 gulp-config-sync 之類的 plugin 來進行同步。
		gulp.src(config.source)
			.pipe(bump({
				type: res.bump
			}))
			.pipe(gulp.dest(config.base))
			.pipe(gulp.src(config.target, {
				base: config.base
			}))
			.pipe(configSync(options))
			.pipe(gulp.dest(config.base))
			.on('end', done);
	});
}

bumpTask.schema = {
	"title": "bump",
	"description": "",
	"properties": {
		"base": {
			"description": "",
			// 注意：這裡若不指定 base 的話，manifest.json 會輸出到 . 而非 app 目錄。
			"default": "."
		},
		"source": {
			"description": "",
			"default": "package.json"
		},
		"target": {
			"description": "",
			"type": "array",
			"items": {
				"type": "string"
			}
			//, "default": ['bower.json', 'app/manifest.json']
		},
		"options": {
			"description": "",
			"properties": {
				"fields": {
					"description": "",
					"type": "array",
					"items": {
						"type": "string"
					},
					"default": ["version"]
				}
			}
		}
	},
	"required": ["target"]
};

module.exports = bumpTask;
<commit_msg>make bump task use gulp-bump only<commit_after>'use strict';

var messages = {
	version: {
		type: 'list',
		name: 'type',
		message: 'What type of version bump would you like to do?',
		choices: ['patch', 'minor', 'major'],
		"default": 'patch'
	},
	release: {
		type: 'list',
		name: 'release',
		message: 'What type of release would you like to do?',
		choices: ['release', 'prerelease', 'beta', 'alpha'],
		"default": 'release'
	}
};

/**
 * Recipe:
 * bump version
 *
 * Ingredients:
 * gulp-bump
 * gulp-prompt
 *
 * Note:
 * gulp-bump 可以一次修改多個 .json 檔案，針對每個檔案讀取其 version 資訊，然後各自修改其版本號碼。
 * 所以可能造成設定不同步的狀況，並不遵循 single source of truth 原則。
 */
function bumpTask(gulp, config, stream, done) {
	// lazy loading required modules.
	var _ = require('lodash'),
		bump = require('gulp-bump'),
		prompt = require('gulp-prompt').prompt,
		semver = require('semver');

	var cwd,
		pkg,
		newVersion;

	cwd = process.cwd();
	pkg = require(cwd + '/package.json', 'utf8');

	if (config.options.interactive) {
		// prompt value is in res.bump
		prompt(messages.version, function(res1) {
			prompt(messages.release, function(res2) {
				newVersion = semver.inc(pkg.version, res1.type, res2.release === 'release' ? '' : res2.release);
				bumpTo(newVersion)
					.on('end', done);
			});
		});
	} else {
		newVersion = semver.inc(pkg.version, 'patch');
		return bumpTo(newVersion);
	}

	function bumpTo(newVersion) {
		return gulp.src(config.src.globs)
			.pipe(bump({ version: newVersion }))
			.pipe(gulp.dest(config.dest.path));
	}
}

bumpTask.schema = {
	"title": "bump",
	"description": "",
	"properties": {
		"base": {
			"description": "",
			// 注意：這裡若不指定 base 的話，manifest.json 會輸出到 . 而非 app 目錄。
			"default": "."
		},
		"source": {
			"description": "",
			"default": "package.json"
		},
		"target": {
			"description": "",
			"type": "array",
			"items": {
				"type": "string"
			}
			//, "default": ['bower.json', 'app/manifest.json']
		},
		"options": {
			"description": "",
			"properties": {
				"fields": {
					"description": "",
					"type": "array",
					"items": {
						"type": "string"
					},
					"default": ["version"]
				}
			}
		}
	},
	"required": ["target"]
};

module.exports = bumpTask;

{'fraction_non_alphanumeric': 0.19718309859154928, 'fraction_numerical': 0.0014825796886582653, 'mean_word_length': 3.2298850574712645, 'pattern_counts': {'":': 53, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1730229', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1676, 'n_words': 317}