docs(changelog test): i test how to automate ChangeLog
This commit is contained in:
86
node_modules/commitizen/dist/cli/commitizen.js
generated
vendored
Normal file
86
node_modules/commitizen/dist/cli/commitizen.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.bootstrap = bootstrap;
|
||||
var _commitizen = require("../commitizen");
|
||||
var _parsers = require("./parsers");
|
||||
let {
|
||||
parse
|
||||
} = _parsers.commitizen;
|
||||
/**
|
||||
* This is the main cli entry point.
|
||||
* environment may be used for debugging.
|
||||
*/
|
||||
function bootstrap(environment = {}, argv = process.argv) {
|
||||
// Get cli args
|
||||
let rawGitArgs = argv.slice(2, argv.length);
|
||||
|
||||
// Parse the args
|
||||
let parsedArgs = parse(rawGitArgs);
|
||||
let command = parsedArgs._[0];
|
||||
|
||||
// Do actions based on commands
|
||||
if (command === "init") {
|
||||
let adapterNpmName = parsedArgs._[1];
|
||||
if (adapterNpmName) {
|
||||
console.log(`Attempting to initialize using the npm package ${adapterNpmName}`);
|
||||
try {
|
||||
(0, _commitizen.init)(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(`
|
||||
|
||||
Commitizen has two command line tools:
|
||||
|
||||
1) cz -- used for making commits according to convention
|
||||
note: you can run 'git cz' if installed with -g
|
||||
2) git-cz -- alias for 'cz'
|
||||
3) commitizen -- used for installing adapters into your project
|
||||
|
||||
Generally if you're using someone else's repo and they've already set up an
|
||||
adapter, you're going to just be running:
|
||||
|
||||
cz
|
||||
|
||||
However, if you create a new repo and you want to make it easier for future
|
||||
contributors to follow your commit message conventions using commitizen then
|
||||
you'll need to run a command like this one to add this adapter to your config:
|
||||
|
||||
commitizen init cz-conventional-changelog --save
|
||||
|
||||
You should swap out cz-conventional-changelog for the NPM package name of the
|
||||
adapter you wish you install in your project's package.json.
|
||||
|
||||
Detailed usage:
|
||||
|
||||
1) commitizen <sub-command>
|
||||
|
||||
init <adapter-npm-name> [args]
|
||||
|
||||
description: Install a commitizen adapter from npm and adds it to your
|
||||
config.commitizen in your package.json file.
|
||||
|
||||
args:
|
||||
--save Install the adapter to package.json dependencies
|
||||
--save-dev Install the adapter to devDependencies
|
||||
--save-exact Install an exact version instead of a range
|
||||
--force Force install the adapter, even if a previous one exists.
|
||||
|
||||
2) cz <any regular git commit arguments>
|
||||
|
||||
description: Runs the commitizen prompter, asking you questions so that you
|
||||
follow the commit conventions of the repository of the current
|
||||
directory.
|
||||
|
||||
note: cz may even be run as 'git cz' if installed with -g.
|
||||
|
||||
`);
|
||||
}
|
||||
}
|
26
node_modules/commitizen/dist/cli/git-cz.js
generated
vendored
Normal file
26
node_modules/commitizen/dist/cli/git-cz.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.bootstrap = bootstrap;
|
||||
var _commitizen = require("../commitizen");
|
||||
var _strategies = require("./strategies");
|
||||
/**
|
||||
* This is the main cli entry point.
|
||||
* environment may be used for debugging.
|
||||
*/
|
||||
function bootstrap(environment = {}, argv = process.argv) {
|
||||
// Get cli args
|
||||
let rawGitArgs = argv.slice(2, argv.length);
|
||||
let 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);
|
||||
}
|
||||
}
|
12
node_modules/commitizen/dist/cli/parsers.js
generated
vendored
Normal file
12
node_modules/commitizen/dist/cli/parsers.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.gitCz = exports.commitizen = void 0;
|
||||
var commitizen = _interopRequireWildcard(require("./parsers/commitizen"));
|
||||
exports.commitizen = commitizen;
|
||||
var gitCz = _interopRequireWildcard(require("./parsers/git-cz"));
|
||||
exports.gitCz = gitCz;
|
||||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
||||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
19
node_modules/commitizen/dist/cli/parsers/commitizen.js
generated
vendored
Normal file
19
node_modules/commitizen/dist/cli/parsers/commitizen.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.parse = parse;
|
||||
var _minimist = _interopRequireDefault(require("minimist"));
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
/**
|
||||
* 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, _minimist.default)(rawGitArgs, {
|
||||
boolean: true
|
||||
});
|
||||
return args;
|
||||
}
|
42
node_modules/commitizen/dist/cli/parsers/git-cz.js
generated
vendored
Normal file
42
node_modules/commitizen/dist/cli/parsers/git-cz.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.parse = parse;
|
||||
const reShortMessage = /^-([a-zA-Z]*)m(.*)$/;
|
||||
const reLongMessage = /^--message(=.*)?$/;
|
||||
|
||||
/**
|
||||
* Strip message declaration from git arguments
|
||||
*/
|
||||
function parse(rawGitArgs) {
|
||||
let result = [];
|
||||
let skipNext = false;
|
||||
for (const arg of rawGitArgs) {
|
||||
let match;
|
||||
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);
|
||||
}
|
||||
return result;
|
||||
}
|
20
node_modules/commitizen/dist/cli/strategies.js
generated
vendored
Normal file
20
node_modules/commitizen/dist/cli/strategies.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "git", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _git.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "gitCz", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _gitCz.default;
|
||||
}
|
||||
});
|
||||
var _git = _interopRequireDefault(require("./strategies/git"));
|
||||
var _gitCz = _interopRequireDefault(require("./strategies/git-cz"));
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
81
node_modules/commitizen/dist/cli/strategies/git-cz.js
generated
vendored
Normal file
81
node_modules/commitizen/dist/cli/strategies/git-cz.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _inquirer = _interopRequireDefault(require("inquirer"));
|
||||
var _findRoot = _interopRequireDefault(require("find-root"));
|
||||
var _util = require("../../common/util");
|
||||
var _parsers = require("../parsers");
|
||||
var _commitizen = require("../../commitizen");
|
||||
var gitStrategy = _interopRequireWildcard(require("./git"));
|
||||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
||||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
// destructure for shorter apis
|
||||
let {
|
||||
parse
|
||||
} = _parsers.gitCz;
|
||||
let {
|
||||
getPrompter,
|
||||
resolveAdapterPath,
|
||||
getGitRootPath
|
||||
} = _commitizen.adapter;
|
||||
let {
|
||||
isClean
|
||||
} = _commitizen.staging;
|
||||
var _default = gitCz;
|
||||
exports.default = _default;
|
||||
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
|
||||
let parsedCommitizenArgs = _parsers.commitizen.parse(rawGitArgs);
|
||||
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
|
||||
let parsedGitCzArgs = parse(rawGitArgs);
|
||||
|
||||
// Determine if we need to process this commit as a retry instead of a
|
||||
// normal commit.
|
||||
let retryLastCommit = rawGitArgs && rawGitArgs[0] === '--retry';
|
||||
|
||||
// Determine if we need to process this commit using interactive hook mode
|
||||
// for husky prepare-commit-message
|
||||
let hookMode = !(typeof parsedCommitizenArgs.hook === 'undefined');
|
||||
let resolvedAdapterConfigPath = resolveAdapterPath(adapterConfig.path);
|
||||
let resolvedAdapterRootPath = (0, _findRoot.default)(resolvedAdapterConfigPath);
|
||||
let prompter = getPrompter(adapterConfig.path);
|
||||
let shouldStageAllFiles = rawGitArgs.includes('-a') || rawGitArgs.includes('--all');
|
||||
isClean(process.cwd(), function (error, stagingIsClean) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
if (stagingIsClean && !parsedGitCzArgs.includes('--allow-empty')) {
|
||||
throw new Error('No files added to staging! Did you forget to run git add?');
|
||||
}
|
||||
|
||||
// OH GOD IM SORRY FOR THIS SECTION
|
||||
let adapterPackageJson = (0, _util.getParsedPackageJsonFromPath)(resolvedAdapterRootPath);
|
||||
let cliPackageJson = (0, _util.getParsedPackageJsonFromPath)(environment.cliPath);
|
||||
console.log(`cz-cli@${cliPackageJson.version}, ${adapterPackageJson.name}@${adapterPackageJson.version}\n`);
|
||||
(0, _commitizen.commit)(_inquirer.default, getGitRootPath(), prompter, {
|
||||
args: parsedGitCzArgs,
|
||||
disableAppendPaths: true,
|
||||
emitData: true,
|
||||
quiet: false,
|
||||
retryLastCommit,
|
||||
hookMode
|
||||
}, function (error) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}, shouldStageAllFiles);
|
||||
}
|
25
node_modules/commitizen/dist/cli/strategies/git.js
generated
vendored
Normal file
25
node_modules/commitizen/dist/cli/strategies/git.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _child_process = _interopRequireDefault(require("child_process"));
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
var _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.
|
||||
exports.default = _default;
|
||||
function git(rawGitArgs, environment) {
|
||||
if (environment.debug === true) {
|
||||
console.error('COMMITIZEN DEBUG: No 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_process.default.spawn('git', vanillaGitArgs, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
child.on('error', function (e, code) {
|
||||
console.error(e);
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user