mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-16 15:23:47 -05:00
chore(package): re-init package with commitizen and standard-release
This commit is contained in:
53
node_modules/commitizen/dist/cli/commitizen.js
generated
vendored
Normal file
53
node_modules/commitizen/dist/cli/commitizen.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.bootstrap = undefined;
|
||||
|
||||
var _commitizen = require('../commitizen');
|
||||
|
||||
var _parsers = require('./parsers');
|
||||
|
||||
var _shelljs = require('shelljs');
|
||||
|
||||
var sh = _interopRequireWildcard(_shelljs);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
var parse = _parsers.commitizen.parse;
|
||||
exports.bootstrap = bootstrap;
|
||||
|
||||
/**
|
||||
* This is the main cli entry point.
|
||||
* environment may be used for debugging.
|
||||
*/
|
||||
|
||||
function bootstrap() {
|
||||
var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
|
||||
// Get cli args
|
||||
var rawGitArgs = process.argv.slice(2, process.argv.length);
|
||||
|
||||
// Parse the args
|
||||
var parsedArgs = parse(rawGitArgs);
|
||||
var command = parsedArgs._[0];
|
||||
|
||||
// Do actions based on commands
|
||||
if (command === "init") {
|
||||
var adapterNpmName = parsedArgs._[1];
|
||||
if (adapterNpmName) {
|
||||
console.log('Attempting to initialize using the npm package ' + adapterNpmName);
|
||||
try {
|
||||
(0, _commitizen.init)(sh, process.cwd(), adapterNpmName, parsedArgs);
|
||||
} catch (e) {
|
||||
console.error('Error: ' + e);
|
||||
}
|
||||
} else {
|
||||
console.error('Error: You must provide an adapter name as the second argument.');
|
||||
}
|
||||
} else {
|
||||
console.log('\n \n Commitizen has two command line tools:\n \n 1) commitizen -- used for installing adapters into your project\n 2) git-cz -- used for making commits according to convention\n note: you can run \'git cz\' if installed with -g\n \n Generally if you\'re using someone else\'s repo and they\'ve already set up an\n adapter, you\'re going to just be running:\n \n git-cz\n \n However, if you create a new repo and you want to make it easier for future \n contributors to follow your commit message conventions using commitizen then\n you\'ll need to run a command like this one to add this adapter to your config:\n \n commitizen init cz-conventional-changelog --save\n \n You should swap out cz-conventional-changelog for the NPM package name of the\n adapter you wish you install in your project\'s package.json.\n \n Detailed usage:\n \n 1) commitizen <sub-command>\n \n init <adapter-npm-name> [args]\n \n description: Install a commitizen adapter from npm and adds it to your\n config.commitizen in your package.json file.\n \n args:\n --save Install the adapter to package.json dependencies \n --save-dev Install the adapter to devDependencies\n --save-exact Install an exact version instead of a range\n --force Force install the adapter, even if a previous one exists.\n \n 2) git-cz <any regular git commit arguments>\n \n description: Runs the commitizen prompter, asking you questions so that you\n follow the commit conventions of the repository of the current \n directory.\n \n note: git-cz may even be run as \'git cz\' if installed with -g.\n \n ');
|
||||
}
|
||||
}
|
||||
36
node_modules/commitizen/dist/cli/git-cz.js
generated
vendored
Normal file
36
node_modules/commitizen/dist/cli/git-cz.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.bootstrap = undefined;
|
||||
|
||||
var _commitizen = require('../commitizen');
|
||||
|
||||
var _strategies = require('./strategies');
|
||||
|
||||
exports.bootstrap = bootstrap;
|
||||
|
||||
/**
|
||||
* This is the main cli entry point.
|
||||
* environment may be used for debugging.
|
||||
*/
|
||||
|
||||
function bootstrap() {
|
||||
var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
|
||||
// Get cli args
|
||||
var rawGitArgs = process.argv.slice(2, process.argv.length);
|
||||
|
||||
var adapterConfig = environment.config || _commitizen.configLoader.load();
|
||||
|
||||
// Choose a strategy based on the existance the adapter config
|
||||
if (typeof adapterConfig !== 'undefined') {
|
||||
// This tells commitizen we're in business
|
||||
(0, _strategies.gitCz)(rawGitArgs, environment, adapterConfig);
|
||||
} else {
|
||||
// This tells commitizen that it is not needed, just use git
|
||||
(0, _strategies.git)(rawGitArgs, environment);
|
||||
}
|
||||
}
|
||||
19
node_modules/commitizen/dist/cli/parsers.js
generated
vendored
Normal file
19
node_modules/commitizen/dist/cli/parsers.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.gitCz = exports.commitizen = undefined;
|
||||
|
||||
var _commitizen = require('./parsers/commitizen');
|
||||
|
||||
var commitizen = _interopRequireWildcard(_commitizen);
|
||||
|
||||
var _gitCz = require('./parsers/git-cz');
|
||||
|
||||
var gitCz = _interopRequireWildcard(_gitCz);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
exports.commitizen = commitizen;
|
||||
exports.gitCz = gitCz;
|
||||
31
node_modules/commitizen/dist/cli/parsers/commitizen.js
generated
vendored
Normal file
31
node_modules/commitizen/dist/cli/parsers/commitizen.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.parse = undefined;
|
||||
|
||||
var _minimist = require('minimist');
|
||||
|
||||
var _minimist2 = _interopRequireDefault(_minimist);
|
||||
|
||||
var _util = require('../../common/util');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.parse = parse;
|
||||
|
||||
/**
|
||||
* Takes args, parses with minimist and some ugly vudoo, returns output
|
||||
*
|
||||
* TODO: Aww shit this is ugly. Rewrite with mega leet tests plz, kthnx.
|
||||
*/
|
||||
|
||||
function parse(rawGitArgs) {
|
||||
|
||||
var args = (0, _minimist2.default)(rawGitArgs, {
|
||||
boolean: true
|
||||
});
|
||||
|
||||
return args;
|
||||
}
|
||||
86
node_modules/commitizen/dist/cli/parsers/git-cz.js
generated
vendored
Normal file
86
node_modules/commitizen/dist/cli/parsers/git-cz.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.parse = undefined;
|
||||
|
||||
var _minimist = require('minimist');
|
||||
|
||||
var _minimist2 = _interopRequireDefault(_minimist);
|
||||
|
||||
var _util = require('../../common/util');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.parse = parse;
|
||||
|
||||
|
||||
var reShortMessage = /^-([a-zA-Z]*)m(.*)$/;
|
||||
var reLongMessage = /^--message(=.*)?$/;
|
||||
|
||||
/**
|
||||
* Strip message declaration from git arguments
|
||||
*/
|
||||
function parse(rawGitArgs) {
|
||||
var result = [];
|
||||
var skipNext = false;
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = rawGitArgs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var arg = _step.value;
|
||||
|
||||
var match = void 0;
|
||||
|
||||
if (skipNext) {
|
||||
skipNext = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
match = reShortMessage.exec(arg);
|
||||
|
||||
if (match) {
|
||||
if (match[1]) {
|
||||
result.push('-' + match[1]);
|
||||
}
|
||||
|
||||
if (!match[2]) {
|
||||
skipNext = true;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
match = reLongMessage.exec(arg);
|
||||
|
||||
if (match) {
|
||||
if (!match[1]) {
|
||||
skipNext = true;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
result.push(arg);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
19
node_modules/commitizen/dist/cli/strategies.js
generated
vendored
Normal file
19
node_modules/commitizen/dist/cli/strategies.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.gitCz = exports.git = undefined;
|
||||
|
||||
var _git = require('./strategies/git');
|
||||
|
||||
var _git2 = _interopRequireDefault(_git);
|
||||
|
||||
var _gitCz = require('./strategies/git-cz');
|
||||
|
||||
var _gitCz2 = _interopRequireDefault(_gitCz);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.git = _git2.default;
|
||||
exports.gitCz = _gitCz2.default;
|
||||
106
node_modules/commitizen/dist/cli/strategies/git-cz.js
generated
vendored
Normal file
106
node_modules/commitizen/dist/cli/strategies/git-cz.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _fs = require('fs');
|
||||
|
||||
var _fs2 = _interopRequireDefault(_fs);
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
var _shelljs = require('shelljs');
|
||||
|
||||
var _shelljs2 = _interopRequireDefault(_shelljs);
|
||||
|
||||
var _inquirer = require('inquirer');
|
||||
|
||||
var _inquirer2 = _interopRequireDefault(_inquirer);
|
||||
|
||||
var _findRoot = require('find-root');
|
||||
|
||||
var _findRoot2 = _interopRequireDefault(_findRoot);
|
||||
|
||||
var _util = require('../../common/util');
|
||||
|
||||
var _parsers = require('../parsers');
|
||||
|
||||
var _commitizen = require('../../commitizen');
|
||||
|
||||
var _git = require('../../git');
|
||||
|
||||
var _git2 = require('./git');
|
||||
|
||||
var gitStrategy = _interopRequireWildcard(_git2);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// destructure for shorter apis
|
||||
var parse = _parsers.gitCz.parse;
|
||||
var getPrompter = _commitizen.adapter.getPrompter,
|
||||
resolveAdapterPath = _commitizen.adapter.resolveAdapterPath;
|
||||
var isClean = _commitizen.staging.isClean;
|
||||
exports.default = gitCz;
|
||||
|
||||
|
||||
function gitCz(rawGitArgs, environment, adapterConfig) {
|
||||
|
||||
// See if any override conditions exist.
|
||||
|
||||
// In these very specific scenarios we may want to use a different
|
||||
// commit strategy than git-cz. For example, in the case of --amend
|
||||
var parsedCommitizenArgs = _parsers.commitizen.parse(rawGitArgs);
|
||||
|
||||
if (parsedCommitizenArgs.a) {
|
||||
// console.log('override -a in place');
|
||||
(0, _git.addPath)(_shelljs2.default, process.cwd());
|
||||
}
|
||||
|
||||
if (parsedCommitizenArgs.amend) {
|
||||
// console.log('override --amend in place');
|
||||
gitStrategy.default(rawGitArgs, environment);
|
||||
return;
|
||||
}
|
||||
|
||||
// Now, if we've made it past overrides, proceed with the git-cz strategy
|
||||
var parsedGitCzArgs = parse(rawGitArgs);
|
||||
|
||||
// Determine if we need to process this commit as a retry instead of a
|
||||
// normal commit.
|
||||
var retryLastCommit = rawGitArgs && rawGitArgs[0] === '--retry';
|
||||
|
||||
var resolvedAdapterConfigPath = resolveAdapterPath(adapterConfig.path);
|
||||
var resolvedAdapterRootPath = (0, _findRoot2.default)(resolvedAdapterConfigPath);
|
||||
var prompter = getPrompter(adapterConfig.path);
|
||||
|
||||
isClean(process.cwd(), function (error, stagingIsClean) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (stagingIsClean) {
|
||||
throw new Error('No files added to staging! Did you forget to run git add?');
|
||||
}
|
||||
|
||||
// OH GOD IM SORRY FOR THIS SECTION
|
||||
var adapterPackageJson = (0, _util.getParsedPackageJsonFromPath)(resolvedAdapterRootPath);
|
||||
var cliPackageJson = (0, _util.getParsedPackageJsonFromPath)(environment.cliPath);
|
||||
console.log('cz-cli@' + cliPackageJson.version + ', ' + adapterPackageJson.name + '@' + adapterPackageJson.version + '\n');
|
||||
(0, _commitizen.commit)(_shelljs2.default, _inquirer2.default, process.cwd(), prompter, {
|
||||
args: parsedGitCzArgs,
|
||||
disableAppendPaths: true,
|
||||
emitData: true,
|
||||
quiet: false,
|
||||
retryLastCommit: retryLastCommit
|
||||
}, function (error) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
33
node_modules/commitizen/dist/cli/strategies/git.js
generated
vendored
Normal file
33
node_modules/commitizen/dist/cli/strategies/git.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _child_process = require('child_process');
|
||||
|
||||
var _child_process2 = _interopRequireDefault(_child_process);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.default = git;
|
||||
|
||||
// We don't have a config, so either we use raw args to try to commit
|
||||
// or if debug is enabled then we do a strict check for a config file.
|
||||
|
||||
function git(rawGitArgs, environment) {
|
||||
if (environment.debug === true) {
|
||||
console.error('COMMITIZEN DEBUG: No git-cz friendly config was detected. I looked for .czrc, .cz.json, or czConfig in package.json.');
|
||||
} else {
|
||||
var vanillaGitArgs = ["commit"].concat(rawGitArgs);
|
||||
|
||||
var child = _child_process2.default.spawn('git', vanillaGitArgs, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
child.on('error', function (e, code) {
|
||||
console.error(e);
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
}
|
||||
41
node_modules/commitizen/dist/commitizen.js
generated
vendored
Normal file
41
node_modules/commitizen/dist/commitizen.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.staging = exports.init = exports.configLoader = exports.commit = exports.cache = exports.adapter = undefined;
|
||||
|
||||
var _adapter = require('./commitizen/adapter');
|
||||
|
||||
var adapter = _interopRequireWildcard(_adapter);
|
||||
|
||||
var _cache = require('./commitizen/cache');
|
||||
|
||||
var cache = _interopRequireWildcard(_cache);
|
||||
|
||||
var _commit = require('./commitizen/commit');
|
||||
|
||||
var _commit2 = _interopRequireDefault(_commit);
|
||||
|
||||
var _configLoader = require('./commitizen/configLoader');
|
||||
|
||||
var configLoader = _interopRequireWildcard(_configLoader);
|
||||
|
||||
var _init = require('./commitizen/init');
|
||||
|
||||
var _init2 = _interopRequireDefault(_init);
|
||||
|
||||
var _staging = require('./commitizen/staging');
|
||||
|
||||
var staging = _interopRequireWildcard(_staging);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
exports.adapter = adapter;
|
||||
exports.cache = cache;
|
||||
exports.commit = _commit2.default;
|
||||
exports.configLoader = configLoader;
|
||||
exports.init = _init2.default;
|
||||
exports.staging = staging;
|
||||
198
node_modules/commitizen/dist/commitizen/adapter.js
generated
vendored
Normal file
198
node_modules/commitizen/dist/commitizen/adapter.js
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.resolveAdapterPath = exports.generateNpmInstallAdapterCommand = exports.getPrompter = exports.getNpmInstallStringMappings = exports.getNearestProjectRootDirectory = exports.getNearestNodeModulesDirectory = exports.addPathToAdapterConfig = undefined;
|
||||
|
||||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
var _fs = require('fs');
|
||||
|
||||
var _fs2 = _interopRequireDefault(_fs);
|
||||
|
||||
var _findNodeModules = require('find-node-modules');
|
||||
|
||||
var _findNodeModules2 = _interopRequireDefault(_findNodeModules);
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _detectIndent = require('detect-indent');
|
||||
|
||||
var _detectIndent2 = _interopRequireDefault(_detectIndent);
|
||||
|
||||
var _shelljs = require('shelljs');
|
||||
|
||||
var _shelljs2 = _interopRequireDefault(_shelljs);
|
||||
|
||||
var _util = require('../common/util');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.addPathToAdapterConfig = addPathToAdapterConfig;
|
||||
exports.getNearestNodeModulesDirectory = getNearestNodeModulesDirectory;
|
||||
exports.getNearestProjectRootDirectory = getNearestProjectRootDirectory;
|
||||
exports.getNpmInstallStringMappings = getNpmInstallStringMappings;
|
||||
exports.getPrompter = getPrompter;
|
||||
exports.generateNpmInstallAdapterCommand = generateNpmInstallAdapterCommand;
|
||||
exports.resolveAdapterPath = resolveAdapterPath;
|
||||
|
||||
/**
|
||||
* ADAPTER
|
||||
*
|
||||
* Adapter is generally responsible for actually installing adapters to an
|
||||
* end user's project. It does not perform checks to determine if there is
|
||||
* a previous commitizen adapter installed or if the proper fields were
|
||||
* provided. It defers that responsibility to init.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Modifies the package.json, sets config.commitizen.path to the path of the adapter
|
||||
* Must be passed an absolute path to the cli's root
|
||||
*/
|
||||
|
||||
function addPathToAdapterConfig(sh, cliPath, repoPath, adapterNpmName) {
|
||||
|
||||
var commitizenAdapterConfig = {
|
||||
config: {
|
||||
commitizen: {
|
||||
path: './node_modules/' + adapterNpmName
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var packageJsonPath = _path2.default.join(getNearestProjectRootDirectory(), 'package.json');
|
||||
var packageJsonString = _fs2.default.readFileSync(packageJsonPath, 'utf-8');
|
||||
// tries to detect the indentation and falls back to a default if it can't
|
||||
var indent = (0, _detectIndent2.default)(packageJsonString).indent || ' ';
|
||||
var packageJsonContent = JSON.parse(packageJsonString);
|
||||
var newPackageJsonContent = '';
|
||||
if (_lodash2.default.get(packageJsonContent, 'config.commitizen.path') !== adapterNpmName) {
|
||||
newPackageJsonContent = _lodash2.default.merge(packageJsonContent, commitizenAdapterConfig);
|
||||
}
|
||||
_fs2.default.writeFileSync(packageJsonPath, JSON.stringify(newPackageJsonContent, null, indent) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an npm install command given a map of strings and a package name
|
||||
*/
|
||||
function generateNpmInstallAdapterCommand(stringMappings, adapterNpmName) {
|
||||
|
||||
// Start with an initial npm install command
|
||||
var installAdapterCommand = 'npm install ' + adapterNpmName;
|
||||
|
||||
// Append the neccesary arguments to it based on user preferences
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = stringMappings.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var _step$value = _slicedToArray(_step.value, 2),
|
||||
key = _step$value[0],
|
||||
value = _step$value[1];
|
||||
|
||||
if (value) {
|
||||
installAdapterCommand = installAdapterCommand + ' ' + value;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return installAdapterCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nearest npm_modules directory
|
||||
*/
|
||||
function getNearestNodeModulesDirectory(options) {
|
||||
|
||||
// Get the nearest node_modules directories to the current working directory
|
||||
var nodeModulesDirectories = (0, _findNodeModules2.default)(options);
|
||||
|
||||
// Make sure we find a node_modules folder
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (nodeModulesDirectories && nodeModulesDirectories.length > 0) {
|
||||
return nodeModulesDirectories[0];
|
||||
} else {
|
||||
console.error('Error: Could not locate node_modules in your project\'s root directory. Did you forget to npm init or npm install?');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nearest project root directory
|
||||
*/
|
||||
function getNearestProjectRootDirectory(options) {
|
||||
return _path2.default.join(process.cwd(), getNearestNodeModulesDirectory(options), '/../');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a map of arguments where the value is the corresponding npm strings
|
||||
*/
|
||||
function getNpmInstallStringMappings(save, saveDev, saveExact, force) {
|
||||
return new Map().set('save', save && !saveDev ? '--save' : undefined).set('saveDev', saveDev ? '--save-dev' : undefined).set('saveExact', saveExact ? '--save-exact' : undefined).set('force', force ? '--force' : undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the prompter from an adapter given an adapter path
|
||||
*/
|
||||
function getPrompter(adapterPath) {
|
||||
// Resolve the adapter path
|
||||
var resolvedAdapterPath = resolveAdapterPath(adapterPath);
|
||||
|
||||
// Load the adapter
|
||||
var adapter = require(resolvedAdapterPath);
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (adapter && adapter.prompter && (0, _util.isFunction)(adapter.prompter)) {
|
||||
return adapter.prompter;
|
||||
} else if (adapter && adapter.default && adapter.default.prompter && (0, _util.isFunction)(adapter.default.prompter)) {
|
||||
return adapter.default.prompter;
|
||||
} else {
|
||||
throw "Could not find prompter method in the provided adapter module: " + adapterPath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a resolvable module name or path, which can be a directory or file, will
|
||||
* return a located adapter path or will throw.
|
||||
*/
|
||||
function resolveAdapterPath(inboundAdapterPath) {
|
||||
// Check if inboundAdapterPath is a path or node module name
|
||||
var parsed = _path2.default.parse(inboundAdapterPath);
|
||||
var isPath = parsed.dir.length > 0 && parsed.dir.charAt(0) !== "@";
|
||||
|
||||
// Resolve from the root of the git repo if inboundAdapterPath is a path
|
||||
var absoluteAdapterPath = isPath ? _path2.default.resolve(getGitRootPath(), inboundAdapterPath) : inboundAdapterPath;
|
||||
|
||||
try {
|
||||
// try to resolve the given path
|
||||
return require.resolve(absoluteAdapterPath);
|
||||
} catch (error) {
|
||||
error.message = "Could not resolve " + absoluteAdapterPath + ". " + error.message;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function getGitRootPath() {
|
||||
return _shelljs2.default.exec('git rev-parse --show-toplevel').stdout.trim();
|
||||
}
|
||||
57
node_modules/commitizen/dist/commitizen/cache.js
generated
vendored
Normal file
57
node_modules/commitizen/dist/commitizen/cache.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.setCacheValueSync = exports.readCacheSync = exports.getCacheValueSync = undefined;
|
||||
|
||||
var _fs = require('fs');
|
||||
|
||||
var _fs2 = _interopRequireDefault(_fs);
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
exports.getCacheValueSync = getCacheValueSync;
|
||||
exports.readCacheSync = readCacheSync;
|
||||
exports.setCacheValueSync = setCacheValueSync;
|
||||
|
||||
/**
|
||||
* Reads the entire cache
|
||||
*/
|
||||
|
||||
function readCacheSync(cachePath) {
|
||||
return JSON.parse(_fs2.default.readFileSync(cachePath, 'utf8'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a cache value and writes the file to disk
|
||||
*/
|
||||
function setCacheValueSync(cachePath, key, value) {
|
||||
var originalCache;
|
||||
try {
|
||||
originalCache = readCacheSync(cachePath);
|
||||
} catch (e) {
|
||||
originalCache = {};
|
||||
}
|
||||
var newCache = _lodash2.default.assign(originalCache, _defineProperty({}, key, value));
|
||||
_fs2.default.writeFileSync(cachePath, JSON.stringify(newCache, null, ' '));
|
||||
return newCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a single value from the cache given a key
|
||||
*/
|
||||
function getCacheValueSync(cachePath, repoPath) {
|
||||
try {
|
||||
var cache = readCacheSync(cachePath);
|
||||
return cache[repoPath];
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
93
node_modules/commitizen/dist/commitizen/commit.js
generated
vendored
Normal file
93
node_modules/commitizen/dist/commitizen/commit.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
var _dedent = require('dedent');
|
||||
|
||||
var _dedent2 = _interopRequireDefault(_dedent);
|
||||
|
||||
var _cachedir = require('cachedir');
|
||||
|
||||
var _cachedir2 = _interopRequireDefault(_cachedir);
|
||||
|
||||
var _fsExtra = require('fs-extra');
|
||||
|
||||
var _git = require('../git');
|
||||
|
||||
var _cache = require('./cache');
|
||||
|
||||
var cache = _interopRequireWildcard(_cache);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.default = commit;
|
||||
|
||||
/**
|
||||
* Takes all of the final inputs needed in order to make dispatch a git commit
|
||||
*/
|
||||
|
||||
function dispatchGitCommit(sh, repoPath, template, options, overrideOptions, done) {
|
||||
// Commit the user input -- side effect that we'll test
|
||||
(0, _git.commit)(sh, repoPath, template, _extends({}, options, overrideOptions), function (error) {
|
||||
done(error, template);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously commits files using commitizen
|
||||
*/
|
||||
function commit(sh, inquirer, repoPath, prompter, options, done) {
|
||||
var cacheDirectory = (0, _cachedir2.default)('commitizen');
|
||||
var cachePath = _path2.default.join(cacheDirectory, 'commitizen.json');
|
||||
|
||||
(0, _fsExtra.ensureDir)(cacheDirectory, function (error) {
|
||||
if (error) {
|
||||
console.error("Couldn't create commitizen cache directory: ", error);
|
||||
// TODO: properly handle error?
|
||||
} else {
|
||||
if (options.retryLastCommit) {
|
||||
|
||||
console.log('Retrying last commit attempt.');
|
||||
|
||||
// We want to use the last commit instead of the current commit,
|
||||
// so lets override some options using the values from cache.
|
||||
|
||||
var _cache$getCacheValueS = cache.getCacheValueSync(cachePath, repoPath),
|
||||
retryOptions = _cache$getCacheValueS.options,
|
||||
retryOverrideOptions = _cache$getCacheValueS.overrideOptions,
|
||||
retryTemplate = _cache$getCacheValueS.template;
|
||||
|
||||
dispatchGitCommit(sh, repoPath, retryTemplate, retryOptions, retryOverrideOptions, done);
|
||||
} else {
|
||||
// Get user input -- side effect that is hard to test
|
||||
prompter(inquirer, function (error, template, overrideOptions) {
|
||||
// Allow adapters to error out
|
||||
// (error: Error?, template: String, overrideOptions: Object)
|
||||
if (!(error instanceof Error)) {
|
||||
overrideOptions = template;
|
||||
template = error;
|
||||
error = null;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return done(error);
|
||||
}
|
||||
|
||||
// We don't want to add retries to the cache, only actual commands
|
||||
cache.setCacheValueSync(cachePath, repoPath, { template: template, options: options, overrideOptions: overrideOptions });
|
||||
dispatchGitCommit(sh, repoPath, template, options, overrideOptions, done);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
18
node_modules/commitizen/dist/commitizen/configLoader.js
generated
vendored
Normal file
18
node_modules/commitizen/dist/commitizen/configLoader.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.load = undefined;
|
||||
|
||||
var _configLoader = require('../configLoader');
|
||||
|
||||
exports.load = load;
|
||||
|
||||
// Configuration sources in priority order.
|
||||
|
||||
var configs = ['package.json', '.czrc', '.cz.json'];
|
||||
|
||||
function load(config, cwd) {
|
||||
return (0, _configLoader.loader)(configs, config, cwd);
|
||||
}
|
||||
152
node_modules/commitizen/dist/commitizen/init.js
generated
vendored
Normal file
152
node_modules/commitizen/dist/commitizen/init.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
var _configLoader = require('./configLoader');
|
||||
|
||||
var configLoader = _interopRequireWildcard(_configLoader);
|
||||
|
||||
var _util = require('../common/util');
|
||||
|
||||
var _adapter = require('./adapter');
|
||||
|
||||
var adapter = _interopRequireWildcard(_adapter);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var addPathToAdapterConfig = adapter.addPathToAdapterConfig,
|
||||
generateNpmInstallAdapterCommand = adapter.generateNpmInstallAdapterCommand,
|
||||
getNpmInstallStringMappings = adapter.getNpmInstallStringMappings;
|
||||
exports.default = init;
|
||||
|
||||
|
||||
var CLI_PATH = _path2.default.normalize(__dirname + '/../../');
|
||||
|
||||
/**
|
||||
* CZ INIT
|
||||
*
|
||||
* Init is generally responsible for initializing an adapter in
|
||||
* a user's project. The goal is to be able to run
|
||||
* `commitizen init` and be prompted for certain fields which
|
||||
* will help you install the proper adapter for your project.
|
||||
*
|
||||
* Init does not actually create the adapter (it defers to adapter
|
||||
* for this). Instead, it is specifically designed to help gather
|
||||
* and validate the information needed to install the adapter
|
||||
* properly without interfering with a previous adapter config.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The defaults for init
|
||||
*/
|
||||
var defaultInitOptions = {
|
||||
save: false,
|
||||
saveDev: true,
|
||||
saveExact: false,
|
||||
force: false
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs npm install for the adapter then modifies the config.commitizen as needed
|
||||
*/
|
||||
function init(sh, repoPath, adapterNpmName) {
|
||||
var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : defaultInitOptions,
|
||||
_ref$save = _ref.save,
|
||||
save = _ref$save === undefined ? false : _ref$save,
|
||||
_ref$saveDev = _ref.saveDev,
|
||||
saveDev = _ref$saveDev === undefined ? true : _ref$saveDev,
|
||||
_ref$saveExact = _ref.saveExact,
|
||||
saveExact = _ref$saveExact === undefined ? false : _ref$saveExact,
|
||||
_ref$force = _ref.force,
|
||||
force = _ref$force === undefined ? false : _ref$force;
|
||||
|
||||
// Don't let things move forward if required args are missing
|
||||
checkRequiredArguments(sh, repoPath, adapterNpmName);
|
||||
|
||||
// Move to the correct directory so we can run commands
|
||||
sh.cd(repoPath);
|
||||
|
||||
// Load the current adapter config
|
||||
var adapterConfig = loadAdapterConfig();
|
||||
|
||||
// Get the npm string mappings based on the arguments provided
|
||||
var stringMappings = getNpmInstallStringMappings(save, saveDev, saveExact, force);
|
||||
|
||||
// Generate a string that represents the npm install command
|
||||
var installAdapterCommand = generateNpmInstallAdapterCommand(stringMappings, adapterNpmName);
|
||||
|
||||
// Check for previously installed adapters
|
||||
if (adapterConfig && adapterConfig.path && adapterConfig.path.length > 0) {
|
||||
|
||||
// console.log(`
|
||||
// Previous adapter detected!
|
||||
// `);
|
||||
|
||||
if (!force) {
|
||||
|
||||
// console.log(`
|
||||
// Previous adapter detected!
|
||||
// `);
|
||||
|
||||
throw 'A previous adapter is already configured. Use --force to override';
|
||||
} else {
|
||||
// Override it
|
||||
try {
|
||||
(0, _util.executeShellCommand)(sh, repoPath, installAdapterCommand);
|
||||
addPathToAdapterConfig(sh, CLI_PATH, repoPath, adapterNpmName);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// console.log(`
|
||||
// No previous adapter was detected
|
||||
// `);
|
||||
|
||||
try {
|
||||
|
||||
(0, _util.executeShellCommand)(sh, repoPath, installAdapterCommand);
|
||||
addPathToAdapterConfig(sh, CLI_PATH, repoPath, adapterNpmName);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to make sure that the required arguments are passed
|
||||
* Throws an exception if any are not.
|
||||
*/
|
||||
function checkRequiredArguments(sh, path, adapterNpmName) {
|
||||
if (!sh) {
|
||||
throw "You must pass an instance of shelljs when running init.";
|
||||
}
|
||||
if (!path) {
|
||||
throw "Path is required when running init.";
|
||||
}
|
||||
if (!adapterNpmName) {
|
||||
throw "The adapter's npm name is required when running init.";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CONFIG
|
||||
* Loads and returns the adapter config at key config.commitizen, if it exists
|
||||
*/
|
||||
function loadAdapterConfig() {
|
||||
var config = configLoader.load();
|
||||
if (config) {
|
||||
return config;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
27
node_modules/commitizen/dist/commitizen/staging.js
generated
vendored
Normal file
27
node_modules/commitizen/dist/commitizen/staging.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isClean = undefined;
|
||||
|
||||
var _child_process = require('child_process');
|
||||
|
||||
exports.isClean = isClean;
|
||||
|
||||
/**
|
||||
* Asynchrounously determines if the staging area is clean
|
||||
*/
|
||||
|
||||
function isClean(repoPath, done) {
|
||||
(0, _child_process.exec)('git diff --cached --name-only', {
|
||||
maxBuffer: Infinity,
|
||||
cwd: repoPath || process.cwd()
|
||||
}, function (error, stdout) {
|
||||
if (error) {
|
||||
return done(error);
|
||||
}
|
||||
var output = stdout || '';
|
||||
done(null, output.trim().length === 0);
|
||||
});
|
||||
}
|
||||
99
node_modules/commitizen/dist/common/util.js
generated
vendored
Normal file
99
node_modules/commitizen/dist/common/util.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isInTest = exports.isString = exports.isFunction = exports.isArray = exports.getParsedPackageJsonFromPath = exports.getParsedJsonFromFile = exports.executeShellCommand = undefined;
|
||||
|
||||
var _fs = require('fs');
|
||||
|
||||
var _fs2 = _interopRequireDefault(_fs);
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.executeShellCommand = executeShellCommand;
|
||||
exports.getParsedJsonFromFile = getParsedJsonFromFile;
|
||||
exports.getParsedPackageJsonFromPath = getParsedPackageJsonFromPath;
|
||||
exports.isArray = isArray;
|
||||
exports.isFunction = isFunction;
|
||||
exports.isString = isString;
|
||||
exports.isInTest = isInTest;
|
||||
|
||||
/**
|
||||
* Executes the command passed to it at the path requested
|
||||
* using the instance of shelljs passed in
|
||||
*/
|
||||
|
||||
function executeShellCommand(sh, path, installCommand) {
|
||||
sh.cd(path);
|
||||
sh.exec(installCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parsed contents of a json file
|
||||
*/
|
||||
function getParsedJsonFromFile(filePath, fileName) {
|
||||
var encoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'utf8';
|
||||
|
||||
try {
|
||||
var packageJsonContents = _fs2.default.readFileSync(_path2.default.join(filePath, fileName), encoding);
|
||||
return JSON.parse(packageJsonContents);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper method for getting the contents of package.json at a given path
|
||||
*/
|
||||
function getParsedPackageJsonFromPath(path) {
|
||||
return getParsedJsonFromFile(path, 'package.json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the passed argument is an array
|
||||
*/
|
||||
function isArray(arr) {
|
||||
if (typeof arr === "undefined") {
|
||||
return false;
|
||||
} else if (arr === null) {
|
||||
return false;
|
||||
} else {
|
||||
return arr.constructor === Array;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the passed argument is a function
|
||||
*/
|
||||
function isFunction(functionToCheck) {
|
||||
if (typeof functionToCheck === "undefined") {
|
||||
return false;
|
||||
} else if (functionToCheck === null) {
|
||||
return false;
|
||||
} else {
|
||||
var getType = {};
|
||||
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the passed argument is a string
|
||||
*/
|
||||
function isString(str) {
|
||||
if (typeof str === "undefined") {
|
||||
return false;
|
||||
} else if (str === null) {
|
||||
return false;
|
||||
} else {
|
||||
return Object.prototype.toString.call(str) === '[object String]';
|
||||
}
|
||||
}
|
||||
|
||||
function isInTest() {
|
||||
return typeof global.it === 'function';
|
||||
}
|
||||
29
node_modules/commitizen/dist/configLoader.js
generated
vendored
Normal file
29
node_modules/commitizen/dist/configLoader.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.loader = exports.getNormalizedConfig = exports.getContent = exports.findup = undefined;
|
||||
|
||||
var _findup = require('./configLoader/findup');
|
||||
|
||||
var _findup2 = _interopRequireDefault(_findup);
|
||||
|
||||
var _getContent = require('./configLoader/getContent');
|
||||
|
||||
var _getContent2 = _interopRequireDefault(_getContent);
|
||||
|
||||
var _getNormalizedConfig = require('./configLoader/getNormalizedConfig');
|
||||
|
||||
var _getNormalizedConfig2 = _interopRequireDefault(_getNormalizedConfig);
|
||||
|
||||
var _loader = require('./configLoader/loader');
|
||||
|
||||
var _loader2 = _interopRequireDefault(_loader);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.findup = _findup2.default;
|
||||
exports.getContent = _getContent2.default;
|
||||
exports.getNormalizedConfig = _getNormalizedConfig2.default;
|
||||
exports.loader = _loader2.default;
|
||||
48
node_modules/commitizen/dist/configLoader/findup.js
generated
vendored
Normal file
48
node_modules/commitizen/dist/configLoader/findup.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
var _glob = require('glob');
|
||||
|
||||
var _glob2 = _interopRequireDefault(_glob);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.default = findup;
|
||||
|
||||
// Before, "findup-sync" package was used,
|
||||
// but it does not provide filter callback
|
||||
|
||||
function findup(patterns, options, fn) {
|
||||
/* jshint -W083 */
|
||||
|
||||
var lastpath;
|
||||
var file;
|
||||
|
||||
options = Object.create(options);
|
||||
options.maxDepth = 1;
|
||||
options.cwd = _path2.default.resolve(options.cwd);
|
||||
|
||||
do {
|
||||
file = patterns.filter(function (pattern) {
|
||||
var configPath = _glob2.default.sync(pattern, options)[0];
|
||||
|
||||
if (configPath) {
|
||||
return fn(_path2.default.join(options.cwd, configPath));
|
||||
}
|
||||
})[0];
|
||||
|
||||
if (file) {
|
||||
return _path2.default.join(options.cwd, file);
|
||||
}
|
||||
|
||||
lastpath = options.cwd;
|
||||
options.cwd = _path2.default.resolve(options.cwd, '..');
|
||||
} while (options.cwd !== lastpath);
|
||||
}
|
||||
80
node_modules/commitizen/dist/configLoader/getContent.js
generated
vendored
Normal file
80
node_modules/commitizen/dist/configLoader/getContent.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _fs = require('fs');
|
||||
|
||||
var _fs2 = _interopRequireDefault(_fs);
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
var _pathExists = require('path-exists');
|
||||
|
||||
var _stripJsonComments = require('strip-json-comments');
|
||||
|
||||
var _stripJsonComments2 = _interopRequireDefault(_stripJsonComments);
|
||||
|
||||
var _configLoader = require('../configLoader');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.default = getConfigContent;
|
||||
|
||||
/**
|
||||
* Read the content of a configuration file
|
||||
* - if not js or json: strip any comments
|
||||
* - if js or json: require it
|
||||
* @param {String} configPath - full path to configuration file
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
function readConfigContent(configPath) {
|
||||
var parsedPath = _path2.default.parse(configPath);
|
||||
var isRcFile = parsedPath.ext !== '.js' && parsedPath.ext !== '.json';
|
||||
var jsonString = _fs2.default.readFileSync(configPath, 'utf-8');
|
||||
var parse = isRcFile ? function (contents) {
|
||||
return JSON.parse((0, _stripJsonComments2.default)(contents));
|
||||
} : function (contents) {
|
||||
return JSON.parse(contents);
|
||||
};
|
||||
|
||||
try {
|
||||
var parsed = parse(jsonString);
|
||||
|
||||
Object.defineProperty(parsed, 'configPath', {
|
||||
value: configPath
|
||||
});
|
||||
|
||||
return parsed;
|
||||
} catch (error) {
|
||||
error.message = ['Parsing JSON at ' + configPath + ' for commitizen config failed:', error.mesasge].join('\n');
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content of the configuration file
|
||||
* @param {String} configPath - partial path to configuration file
|
||||
* @param {String} directory - directory path which will be joined with config argument
|
||||
* @return {Object}
|
||||
*/
|
||||
function getConfigContent(configPath, baseDirectory) {
|
||||
if (!configPath) {
|
||||
return;
|
||||
}
|
||||
|
||||
var resolvedPath = _path2.default.resolve(baseDirectory, configPath);
|
||||
var configBasename = _path2.default.basename(resolvedPath);
|
||||
|
||||
if (!(0, _pathExists.sync)(resolvedPath)) {
|
||||
return (0, _configLoader.getNormalizedConfig)(resolvedPath);
|
||||
}
|
||||
|
||||
var content = readConfigContent(resolvedPath);
|
||||
return (0, _configLoader.getNormalizedConfig)(configBasename, content);
|
||||
};
|
||||
33
node_modules/commitizen/dist/configLoader/getNormalizedConfig.js
generated
vendored
Normal file
33
node_modules/commitizen/dist/configLoader/getNormalizedConfig.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = getNormalizedConfig;
|
||||
|
||||
// Given a config and content, plucks the actual
|
||||
// settings that we're interested in
|
||||
|
||||
function getNormalizedConfig(config, content) {
|
||||
|
||||
if (content && config === 'package.json') {
|
||||
|
||||
// PACKAGE.JSON
|
||||
|
||||
// Use the npm config key, be good citizens
|
||||
if (content.config && content.config.commitizen) {
|
||||
return content.config.commitizen;
|
||||
} else if (content.czConfig) {
|
||||
// Old method, will be deprecated in 3.0.0
|
||||
|
||||
// Suppress during test
|
||||
if (typeof global.it !== 'function') {
|
||||
console.error("\n********\nWARNING: This repository's package.json is using czConfig. czConfig will be deprecated in Commitizen 3. \nPlease use this instead:\n{\n \"config\": {\n \"commitizen\": {\n \"path\": \"./path/to/adapter\"\n }\n }\n}\nFor more information, see: http://commitizen.github.io/cz-cli/\n********\n");
|
||||
}
|
||||
return content.czConfig;
|
||||
}
|
||||
} else {
|
||||
// .cz.json or .czrc
|
||||
return content;
|
||||
}
|
||||
}
|
||||
70
node_modules/commitizen/dist/configLoader/loader.js
generated
vendored
Normal file
70
node_modules/commitizen/dist/configLoader/loader.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _path = require('path');
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
var _configLoader = require('../configLoader');
|
||||
|
||||
var _util = require('../common/util.js');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.default = loader;
|
||||
|
||||
/**
|
||||
* Command line config helpers
|
||||
* Shamelessly ripped from with slight modifications:
|
||||
* https://github.com/jscs-dev/node-jscs/blob/master/lib/cli-config.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get content of the configuration file
|
||||
* @param {String} config - partial path to configuration file
|
||||
* @param {String} [cwd = process.cwd()] - directory path which will be joined with config argument
|
||||
* @return {Object|undefined}
|
||||
*/
|
||||
|
||||
function loader(configs, config, cwd) {
|
||||
var content;
|
||||
var directory = cwd || process.cwd();
|
||||
|
||||
// If config option is given, attempt to load it
|
||||
if (config) {
|
||||
return (0, _configLoader.getContent)(config, directory);
|
||||
}
|
||||
|
||||
content = (0, _configLoader.getContent)((0, _configLoader.findup)(configs, { nocase: true, cwd: directory }, function (configPath) {
|
||||
if (_path2.default.basename(configPath) === 'package.json') {
|
||||
// return !!this.getContent(configPath);
|
||||
}
|
||||
|
||||
return true;
|
||||
}));
|
||||
|
||||
if (content) {
|
||||
return content;
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (!(0, _util.isInTest)()) {
|
||||
// Try to load standard configs from home dir
|
||||
var directoryArr = [process.env.USERPROFILE, process.env.HOMEPATH, process.env.HOME];
|
||||
for (var i = 0, dirLen = directoryArr.length; i < dirLen; i++) {
|
||||
if (!directoryArr[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var j = 0, len = configs.length; j < len; j++) {
|
||||
content = (0, _configLoader.getContent)(configs[j], directoryArr[i]);
|
||||
|
||||
if (content) {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
node_modules/commitizen/dist/git.js
generated
vendored
Normal file
19
node_modules/commitizen/dist/git.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.log = exports.init = exports.commit = exports.addPath = undefined;
|
||||
|
||||
var _add = require('./git/add');
|
||||
|
||||
var _commit = require('./git/commit');
|
||||
|
||||
var _init = require('./git/init');
|
||||
|
||||
var _log = require('./git/log');
|
||||
|
||||
exports.addPath = _add.addPath;
|
||||
exports.commit = _commit.commit;
|
||||
exports.init = _init.init;
|
||||
exports.log = _log.log;
|
||||
15
node_modules/commitizen/dist/git/add.js
generated
vendored
Normal file
15
node_modules/commitizen/dist/git/add.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.addPath = addPath;
|
||||
|
||||
/**
|
||||
* Synchronously adds a path to git staging
|
||||
*/
|
||||
|
||||
function addPath(sh, repoPath) {
|
||||
sh.cd(repoPath);
|
||||
sh.exec('git add .');
|
||||
}
|
||||
55
node_modules/commitizen/dist/git/commit.js
generated
vendored
Normal file
55
node_modules/commitizen/dist/git/commit.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.commit = undefined;
|
||||
|
||||
var _os = require('os');
|
||||
|
||||
var _os2 = _interopRequireDefault(_os);
|
||||
|
||||
var _child_process = require('child_process');
|
||||
|
||||
var _dedent = require('dedent');
|
||||
|
||||
var _dedent2 = _interopRequireDefault(_dedent);
|
||||
|
||||
var _util = require('../common/util');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||
|
||||
exports.commit = commit;
|
||||
|
||||
/**
|
||||
* Asynchronously git commit at a given path with a message
|
||||
*/
|
||||
|
||||
function commit(sh, repoPath, message, options, done) {
|
||||
var called = false;
|
||||
var args = ['commit', '-m', (0, _dedent2.default)(message)].concat(_toConsumableArray(options.args || []));
|
||||
var child = (0, _child_process.spawn)('git', args, {
|
||||
cwd: repoPath,
|
||||
stdio: options.quiet ? 'ignore' : 'inherit'
|
||||
});
|
||||
|
||||
child.on('error', function (err) {
|
||||
if (called) return;
|
||||
called = true;
|
||||
|
||||
done(err);
|
||||
});
|
||||
|
||||
child.on('exit', function (code, signal) {
|
||||
if (called) return;
|
||||
called = true;
|
||||
|
||||
if (code) {
|
||||
done(Object.assign(new Error('git exited with error code ' + code), { code: code, signal: signal }));
|
||||
} else {
|
||||
done(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
15
node_modules/commitizen/dist/git/init.js
generated
vendored
Normal file
15
node_modules/commitizen/dist/git/init.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.init = init;
|
||||
|
||||
/**
|
||||
* Synchronously creates a new git repo at a path
|
||||
*/
|
||||
|
||||
function init(sh, repoPath) {
|
||||
sh.cd(repoPath);
|
||||
sh.exec('git init');
|
||||
}
|
||||
26
node_modules/commitizen/dist/git/log.js
generated
vendored
Normal file
26
node_modules/commitizen/dist/git/log.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.log = undefined;
|
||||
|
||||
var _child_process = require('child_process');
|
||||
|
||||
exports.log = log;
|
||||
|
||||
/**
|
||||
* Asynchronously gets the git log output
|
||||
*/
|
||||
|
||||
function log(repoPath, done) {
|
||||
(0, _child_process.exec)('git log', {
|
||||
maxBuffer: Infinity,
|
||||
cwd: repoPath
|
||||
}, function (error, stdout, stderr) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
done(stdout);
|
||||
});
|
||||
}
|
||||
4
node_modules/commitizen/dist/index.js
generated
vendored
Normal file
4
node_modules/commitizen/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
var commitizen = require('./commitizen');
|
||||
module.exports = commitizen;
|
||||
2
node_modules/commitizen/dist/npm.js
generated
vendored
Normal file
2
node_modules/commitizen/dist/npm.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// this file left blank until npm init is implemented
|
||||
"use strict";
|
||||
Reference in New Issue
Block a user