Skip to content

Commit

Permalink
perf(build): ESM Build (#100)
Browse files Browse the repository at this point in the history
Updated better-commits to use smaller esm build. Removed circular dependency between util and valibot-state.
  • Loading branch information
Everduin94 committed May 2, 2024
1 parent 3034ad4 commit f80111a
Show file tree
Hide file tree
Showing 10 changed files with 3,222 additions and 1,301 deletions.
3,760 changes: 2,839 additions & 921 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "1.15.2",
"description": "A CLI for creating better commits following the conventional commits specification",
"author": "Erik Verduin (https://github.com/everduin94)",
"type": "module",
"keywords": [
"typescript",
"cli",
Expand All @@ -30,7 +31,7 @@
"start": "jiti ./src/index.ts",
"branch": "jiti ./src/branch.ts",
"init": "jiti ./src/init.ts",
"build": "tsup ./src/",
"build": "tsup",
"commit": "jiti ./src/index.ts"
},
"devDependencies": {
Expand All @@ -40,8 +41,9 @@
"jiti": "^1.17.0",
"prettier": "3.2.5",
"semantic-release": "^21.0.1",
"tsup": "^6.6.3",
"tsx": "^3.12.3"
"tsup": "^8.0.2",
"tsx": "^3.12.3",
"typescript": "^5.4.5"
},
"release": {
"branches": [
Expand Down
9 changes: 2 additions & 7 deletions src/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ import Configstore from "configstore";
import color from "picocolors";
import { chdir } from "process";
import { Output, parse } from "valibot";

// This must be imported before ./utils 🤦
import { BranchState, CommitState, Config } from "./vali-state";

import { V_BRANCH_ACTIONS, V_BRANCH_CONFIG_FIELDS, V_BRANCH_FIELDS } from "./valibot-consts";
import { BranchState, CommitState, Config } from "./valibot-state";
import {
BRANCH_ACTION_OPTIONS,
CACHE_PROMPT,
OPTIONAL_PROMPT,
V_BRANCH_ACTIONS,
V_BRANCH_CONFIG_FIELDS,
V_BRANCH_FIELDS,
load_setup,
} from "./utils";

Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import color from "picocolors";
import { execSync } from "child_process";
import { chdir } from "process";
import { Output, parse } from "valibot";
import { CommitState, Config } from "./vali-state";
import { CommitState, Config } from "./valibot-state";
import {
load_setup,
addNewLine,
Expand All @@ -18,13 +18,12 @@ import {
clean_commit_title,
COMMIT_FOOTER_OPTIONS,
infer_type_from_branch,
V_FOOTER_OPTIONS,
CUSTOM_SCOPE_KEY,
get_git_root,
REGEX_SLASH_UND,
REGEX_START_UND,
} from "./utils";
import { git_add, git_status } from "./git";
import { CUSTOM_SCOPE_KEY, V_FOOTER_OPTIONS } from "./valibot-consts";

main(load_setup());

Expand Down
2 changes: 1 addition & 1 deletion src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from "fs";
import color from "picocolors";
import { parse } from "valibot";
import { CONFIG_FILE_NAME, get_git_root } from "./utils";
import { Config } from "./vali-state";
import { Config } from "./valibot-state";

try {
console.clear();
Expand Down
116 changes: 3 additions & 113 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { execSync } from "child_process";
import fs from "fs";
import { homedir } from "os";
import color from "picocolors";
import { Output, ValiError, parse, picklist } from "valibot";
import { Config } from "./vali-state";
import { Output, ValiError, parse } from "valibot";
import { Config } from "./valibot-state";
import { V_BRANCH_ACTIONS } from "./valibot-consts";

export const CONFIG_FILE_NAME = ".better-commits.json";
export const SPACE_TO_SELECT = `${color.dim("(<space> to select)")}`;
Expand All @@ -25,79 +26,6 @@ export const REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
export const REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
export const REGEX_START_NUM = new RegExp(/^(\d+)/);

export const DEFAULT_TYPE_OPTIONS = [
{
value: "feat",
label: "feat",
hint: "A new feature",
emoji: "✨",
trailer: "Changelog: feature",
},
{
value: "fix",
label: "fix",
hint: "A bug fix",
emoji: "🐛",
trailer: "Changelog: fix",
},
{
value: "docs",
label: "docs",
hint: "Documentation only changes",
emoji: "📚",
trailer: "Changelog: documentation",
},
{
value: "refactor",
label: "refactor",
hint: "A code change that neither fixes a bug nor adds a feature",
emoji: "🔨",
trailer: "Changelog: refactor",
},
{
value: "perf",
label: "perf",
hint: "A code change that improves performance",
emoji: "🚀",
trailer: "Changelog: performance",
},
{
value: "test",
label: "test",
hint: "Adding missing tests or correcting existing tests",
emoji: "🚨",
trailer: "Changelog: test",
},
{
value: "build",
label: "build",
hint: "Changes that affect the build system or external dependencies",
emoji: "🚧",
trailer: "Changelog: build",
},
{
value: "ci",
label: "ci",
hint: "Changes to our CI configuration files and scripts",
emoji: "🤖",
trailer: "Changelog: ci",
},
{
value: "chore",
label: "chore",
hint: "Other changes that do not modify src or test files",
emoji: "🧹",
trailer: "Changelog: chore",
},
{ value: "", label: "none" },
];
export const DEFAULT_SCOPE_OPTIONS = [
{ value: "app", label: "app" },
{ value: "shared", label: "shared" },
{ value: "server", label: "server" },
{ value: "tools", label: "tools" },
{ value: "", label: "none" },
];
export const COMMIT_FOOTER_OPTIONS = [
{
value: "closes",
Expand All @@ -117,44 +45,6 @@ export const COMMIT_FOOTER_OPTIONS = [
{ value: "deprecated", label: "deprecated", hint: "Add deprecated change" },
{ value: "custom", label: "custom", hint: "Add a custom footer" },
];
export const CUSTOM_SCOPE_KEY: "custom" = "custom";

export const V_FOOTER_OPTIONS = picklist([
"closes",
"trailer",
"breaking-change",
"deprecated",
"custom",
]);
export const V_BRANCH_FIELDS = picklist([
"user",
"version",
"type",
"ticket",
"description",
]);
export const V_BRANCH_CONFIG_FIELDS = picklist([
"branch_user",
"branch_version",
"branch_type",
"branch_ticket",
"branch_description",
]);
export const BRANCH_ORDER_DEFAULTS: Output<typeof V_BRANCH_FIELDS>[] = [
"user",
"version",
"type",
"ticket",
"description",
];
export const V_BRANCH_ACTIONS = picklist(["branch", "worktree"]);
export const FOOTER_OPTION_VALUES: Output<typeof V_FOOTER_OPTIONS>[] = [
"closes",
"trailer",
"breaking-change",
"deprecated",
"custom",
];
export const BRANCH_ACTION_OPTIONS: {
value: Output<typeof V_BRANCH_ACTIONS>;
label: string;
Expand Down
Loading

0 comments on commit f80111a

Please sign in to comment.