ccommit 4.2.0-canary.1 → 4.2.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/.turbo/turbo-build.log +0 -4
- package/.turbo/turbo-lint$colon$ts.log +0 -1
- package/release.config.js +0 -25
- package/src/commands/commit/commit.ts +0 -72
- package/src/commands/commit/index.ts +0 -3
- package/src/commands/commit/questions.ts +0 -166
- package/src/commands/commit/with-client.ts +0 -33
- package/src/commands/commit/with-hook.ts +0 -33
- package/src/commands/index.ts +0 -2
- package/src/commands/list/index.ts +0 -3
- package/src/commands/list/list.ts +0 -6
- package/src/data/types.ts +0 -632
- package/src/lib/index.ts +0 -107
- package/src/utils/cancel-if.ts +0 -43
- package/src/utils/filter.ts +0 -23
- package/src/utils/find-by.ts +0 -8
- package/src/utils/find-command.ts +0 -80
- package/src/utils/format.ts +0 -51
- package/src/utils/generate-log.ts +0 -40
- package/src/utils/get-chars-left.ts +0 -17
- package/src/utils/get-git-root-dir.ts +0 -12
- package/src/utils/get-issue-tracker.ts +0 -24
- package/src/utils/get-staged-files.ts +0 -9
- package/src/utils/index.ts +0 -17
- package/src/utils/print-dry-run.ts +0 -7
- package/src/utils/register-hook-interruption-handler.ts +0 -16
- package/tsconfig.json +0 -9
- package/tsdown.config.ts +0 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccommit",
|
|
3
|
-
"version": "4.2.0-canary.
|
|
3
|
+
"version": "4.2.0-canary.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "😜 ➕ 👔 🟰 ccommit \n Conventional Commit Generator that interprets commit types from gitmoji and conventional",
|
|
6
6
|
"keywords": [
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"bin": {
|
|
30
30
|
"ccommit": "./src/index.ts"
|
|
31
31
|
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
32
35
|
"type": "module",
|
|
33
36
|
"sideEffects": false,
|
|
34
37
|
"exports": {
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
$ tsc --noEmit --declaration
|
package/release.config.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
import { getConfig } from "@jeromefitz/semantic";
|
|
4
|
-
import isCI from "is-in-ci";
|
|
5
|
-
|
|
6
|
-
import { config as configDefault } from "../../release.config.js";
|
|
7
|
-
|
|
8
|
-
if (!isCI) {
|
|
9
|
-
const dotenv = await import("dotenv");
|
|
10
|
-
dotenv.config({ path: "../../.env" });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const require = createRequire(import.meta.url);
|
|
14
|
-
const pkg = require("./package.json");
|
|
15
|
-
|
|
16
|
-
const { name } = pkg;
|
|
17
|
-
|
|
18
|
-
const configPassed = {
|
|
19
|
-
...configDefault,
|
|
20
|
-
tagFormat: `${name}@\${version}`,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const config = getConfig(configPassed);
|
|
24
|
-
|
|
25
|
-
export default config;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
|
|
3
|
-
import enquirer from "enquirer";
|
|
4
|
-
|
|
5
|
-
import { COMMIT_MODES, FIND_BY, LOGS } from "../../lib/index.ts";
|
|
6
|
-
import {
|
|
7
|
-
cancelIfNeeded,
|
|
8
|
-
findBy,
|
|
9
|
-
formatCommitSubject,
|
|
10
|
-
generateLog,
|
|
11
|
-
registerHookInterruptionHandler,
|
|
12
|
-
} from "../../utils/index.ts";
|
|
13
|
-
import questions from "./questions.ts";
|
|
14
|
-
import withClient from "./with-client.ts";
|
|
15
|
-
import withHook from "./with-hook.ts";
|
|
16
|
-
|
|
17
|
-
const { prompt } = enquirer;
|
|
18
|
-
|
|
19
|
-
export type CommitOptions = {
|
|
20
|
-
message?: string;
|
|
21
|
-
mode: typeof COMMIT_MODES.CLIENT;
|
|
22
|
-
// mode: typeof COMMIT_MODES.CLIENT | typeof COMMIT_MODES.HOOK
|
|
23
|
-
scope?: string;
|
|
24
|
-
skip: boolean;
|
|
25
|
-
title?: string;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @todo(ccommit) this is a hacky way to bypass the generator :X
|
|
30
|
-
*/
|
|
31
|
-
const promptAndCommit = async (options: CommitOptions) => {
|
|
32
|
-
let data: any = {};
|
|
33
|
-
|
|
34
|
-
if (options.skip) {
|
|
35
|
-
data = options;
|
|
36
|
-
// @note(ccommit) very type is an actual type
|
|
37
|
-
data.gitmoji = findBy(data.type, FIND_BY.TYPE, FIND_BY.EMOJI);
|
|
38
|
-
if (!data.gitmoji) {
|
|
39
|
-
console.log(generateLog(LOGS.TYPES.ERROR, LOGS.MESSAGES.TYPE_INCORRECT, data.type));
|
|
40
|
-
process.exit(2);
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
await prompt(questions)
|
|
45
|
-
.then((answers: any) => {
|
|
46
|
-
answers.type = findBy(answers.gitmoji, FIND_BY.EMOJI, FIND_BY.TYPE);
|
|
47
|
-
return answers;
|
|
48
|
-
})
|
|
49
|
-
.then((answers) => {
|
|
50
|
-
data = answers;
|
|
51
|
-
})
|
|
52
|
-
.catch(console.error);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// oxlint-disable-next-line no-extra-boolean-cast
|
|
56
|
-
data.subject = !!data ? formatCommitSubject(options, data) : "";
|
|
57
|
-
|
|
58
|
-
if (options.mode === COMMIT_MODES.HOOK) {
|
|
59
|
-
return withHook(data, options);
|
|
60
|
-
} else {
|
|
61
|
-
return withClient(data, options);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const commit = (options: CommitOptions) => {
|
|
65
|
-
if (options.mode === COMMIT_MODES.HOOK) {
|
|
66
|
-
registerHookInterruptionHandler();
|
|
67
|
-
return cancelIfNeeded().then(() => promptAndCommit(options));
|
|
68
|
-
}
|
|
69
|
-
return promptAndCommit(options);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export default commit;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import colors from "ansi-colors";
|
|
2
|
-
|
|
3
|
-
import commitTypes from "../../data/types.ts";
|
|
4
|
-
import { SCOPE, TITLE } from "../../lib/index.ts";
|
|
5
|
-
import { formatCliEmoji, formatCliType, getCharsLeft, getIssueTracker } from "../../utils/index.ts";
|
|
6
|
-
|
|
7
|
-
const getTypes = () =>
|
|
8
|
-
commitTypes.map(({ description, emoji, emojiLength, type }) => ({
|
|
9
|
-
description,
|
|
10
|
-
emoji,
|
|
11
|
-
emojiLength,
|
|
12
|
-
type,
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
const characterCount = (input, max) => {
|
|
16
|
-
const count = getCharsLeft(input);
|
|
17
|
-
const countMessage = `Character Count (${count}/${max})`;
|
|
18
|
-
return `${colors.dim.cyan(`›`)} ${colors.dim.bold(countMessage)}`;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const prefixState = (state) => {
|
|
22
|
-
return state.submitted
|
|
23
|
-
? state.cancelled
|
|
24
|
-
? colors.magenta("✖")
|
|
25
|
-
: colors.green("✔")
|
|
26
|
-
: colors.cyan("?");
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @note(enquirier) 3.x will "fix" skip passing answers for now
|
|
31
|
-
* you can access "this" state by __not__ using arrow functions
|
|
32
|
-
*/
|
|
33
|
-
const questions = [
|
|
34
|
-
{
|
|
35
|
-
default: "(y/N)",
|
|
36
|
-
format(input) {
|
|
37
|
-
const yn = input ? "yes" : "no";
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
return this.state.submitted ? colors.green(yn) : colors.dim(yn);
|
|
40
|
-
},
|
|
41
|
-
initial: false,
|
|
42
|
-
message: "Is there a breaking change?",
|
|
43
|
-
name: "breaking",
|
|
44
|
-
prefix() {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
return prefixState(this.state);
|
|
47
|
-
},
|
|
48
|
-
styles: { primary: colors.white },
|
|
49
|
-
type: "confirm",
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
footer() {
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
return characterCount(this.state.input, TITLE.MAX);
|
|
55
|
-
},
|
|
56
|
-
message: "Please share breaking change info",
|
|
57
|
-
name: "messageBreaking",
|
|
58
|
-
result(value) {
|
|
59
|
-
return value ? `BREAKING CHANGE: ${value.trim()}` : "";
|
|
60
|
-
},
|
|
61
|
-
skip() {
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
return !this.state.answers.breaking;
|
|
64
|
-
},
|
|
65
|
-
type: "input",
|
|
66
|
-
validate(input) {
|
|
67
|
-
const chars = input?.length || 0;
|
|
68
|
-
// @ts-ignore
|
|
69
|
-
if (!this.state.answers.breaking) {
|
|
70
|
-
return true;
|
|
71
|
-
} else if (chars < 15) {
|
|
72
|
-
return `Must have at least 15 characters`;
|
|
73
|
-
} else if (chars > TITLE.MAX) {
|
|
74
|
-
return `Cannot exceed ${TITLE.MAX} characters`;
|
|
75
|
-
} else {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
choices: getTypes().map(({ description, emoji, emojiLength, type }) => {
|
|
82
|
-
const value = emoji;
|
|
83
|
-
const name = ` ${formatCliEmoji({
|
|
84
|
-
emoji,
|
|
85
|
-
emojiLength,
|
|
86
|
-
})} ${formatCliType(type)} ${description}`;
|
|
87
|
-
return {
|
|
88
|
-
name,
|
|
89
|
-
value,
|
|
90
|
-
};
|
|
91
|
-
}),
|
|
92
|
-
footer() {
|
|
93
|
-
return `${colors.dim.cyan(`›`)} ${colors.dim.bold(`scroll up and down to reveal more ↕`)}`;
|
|
94
|
-
},
|
|
95
|
-
highlight(str) {
|
|
96
|
-
return colors.cyanBright(str);
|
|
97
|
-
},
|
|
98
|
-
limit: 18,
|
|
99
|
-
message: "Please choose a commit type",
|
|
100
|
-
name: "gitmoji",
|
|
101
|
-
type: "autocomplete",
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
footer() {
|
|
105
|
-
// @ts-ignore
|
|
106
|
-
return characterCount(this.state.input, SCOPE.MAX);
|
|
107
|
-
},
|
|
108
|
-
format() {
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
return this.state.submitted ? colors.green(this.value) : this.value;
|
|
111
|
-
},
|
|
112
|
-
message: "Please share the scope (if any)",
|
|
113
|
-
name: "scope",
|
|
114
|
-
type: "input",
|
|
115
|
-
validate(input) {
|
|
116
|
-
const chars = input.length;
|
|
117
|
-
if (chars === 0) {
|
|
118
|
-
return true;
|
|
119
|
-
} else if (chars < SCOPE.MIN) {
|
|
120
|
-
return `Must have at least ${SCOPE.MIN} characters`;
|
|
121
|
-
} else if (chars > SCOPE.MAX) {
|
|
122
|
-
return `Cannot exceed ${SCOPE.MAX} characters`;
|
|
123
|
-
} else {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
footer() {
|
|
130
|
-
// @ts-ignore
|
|
131
|
-
return characterCount(this.state.input, TITLE.MAX);
|
|
132
|
-
},
|
|
133
|
-
hint() {
|
|
134
|
-
// @ts-ignore
|
|
135
|
-
return this.state.initial ? `… tab to use initial value` : "";
|
|
136
|
-
},
|
|
137
|
-
initial: getIssueTracker() ? `${getIssueTracker()} ` : "",
|
|
138
|
-
message: "Please enter the commit title",
|
|
139
|
-
name: "title",
|
|
140
|
-
type: "input",
|
|
141
|
-
validate(input) {
|
|
142
|
-
const chars = input.length;
|
|
143
|
-
if (chars < TITLE.MIN) {
|
|
144
|
-
return `Must have at least ${TITLE.MIN} characters`;
|
|
145
|
-
} else if (chars > TITLE.MAX) {
|
|
146
|
-
return `Cannot exceed ${TITLE.MAX} characters`;
|
|
147
|
-
} else {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
footer() {
|
|
154
|
-
return `${colors.dim.cyan(`›`)} ${colors.dim("Return twice to submit/skip: ⮑ ⮑")}`;
|
|
155
|
-
},
|
|
156
|
-
message: "Please share a more detailed commit message (if applicable)",
|
|
157
|
-
multiline: true,
|
|
158
|
-
name: "message",
|
|
159
|
-
result(input) {
|
|
160
|
-
return input === "\n" ? "" : input;
|
|
161
|
-
},
|
|
162
|
-
type: "input",
|
|
163
|
-
},
|
|
164
|
-
];
|
|
165
|
-
|
|
166
|
-
export default questions;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
|
|
3
|
-
import { execa } from "execa";
|
|
4
|
-
|
|
5
|
-
import { LOGS } from "../../lib/index.ts";
|
|
6
|
-
import { generateLog, printDryRun } from "../../utils/index.ts";
|
|
7
|
-
|
|
8
|
-
const withClient = async (answers, options) => {
|
|
9
|
-
try {
|
|
10
|
-
const title = answers?.subject;
|
|
11
|
-
const message = answers?.message;
|
|
12
|
-
const messageBreaking = answers?.messageBreaking;
|
|
13
|
-
|
|
14
|
-
const commitArray = ["commit", "-m", title];
|
|
15
|
-
if (message) commitArray.push("-m", message);
|
|
16
|
-
if (messageBreaking) commitArray.push("-m", messageBreaking);
|
|
17
|
-
|
|
18
|
-
if (options?.dryrun) {
|
|
19
|
-
printDryRun(["git", ...commitArray].join(" "));
|
|
20
|
-
} else {
|
|
21
|
-
await execa("git", commitArray, {
|
|
22
|
-
buffer: false,
|
|
23
|
-
// env: { HUSKY: '0' },
|
|
24
|
-
stdio: "inherit",
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
} catch (error: any) {
|
|
28
|
-
console.error(generateLog(LOGS.TYPES.ERROR, LOGS.MESSAGES.COMMIT_FAIL, error.escapedCommand));
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default withClient;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
|
|
5
|
-
import { getGitRootDir, printDryRun } from "../../utils/index.ts";
|
|
6
|
-
|
|
7
|
-
const commitMsgFile = join(getGitRootDir(), ".git", "COMMIT_EDITMSG");
|
|
8
|
-
|
|
9
|
-
// oxlint-disable-next-line complexity
|
|
10
|
-
const withHook = (answers, options) => {
|
|
11
|
-
try {
|
|
12
|
-
let commitMessage = answers?.subject;
|
|
13
|
-
if (answers?.message && answers?.message !== "\n") {
|
|
14
|
-
commitMessage += `\n\n${answers.message}`;
|
|
15
|
-
}
|
|
16
|
-
if (answers?.messageBreaking && answers?.messageBreaking !== "\n") {
|
|
17
|
-
commitMessage += `\n\n${answers.messageBreaking}`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (options?.dryrun) {
|
|
21
|
-
printDryRun(commitMessage);
|
|
22
|
-
} else {
|
|
23
|
-
fs.writeFileSync(commitMsgFile, commitMessage);
|
|
24
|
-
}
|
|
25
|
-
} catch (error) {
|
|
26
|
-
console.error(error);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
} finally {
|
|
29
|
-
process.exit(0);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default withHook;
|
package/src/commands/index.ts
DELETED