From 5e26cc06b4ddc11f54c56b671c87ed06adfa8a0b Mon Sep 17 00:00:00 2001 From: INeedJobToStartWork Date: Tue, 17 Dec 2024 20:26:53 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20Feat(commitsmile):=20Release=20v?= =?UTF-8?q?1.0.0!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commitSmile.ts | 4 +- packages/commitsmile/CHANGELOG copy.md | 78 ------- packages/commitsmile/CHANGELOG.md | 13 ++ packages/commitsmile/LICENSE copy | 21 -- packages/commitsmile/README copy.md | 218 ------------------ packages/commitsmile/README.md | 203 +++++++++++++--- .../commitsmile/clean-package.config.json | 12 +- .../commitsmile/config/tsuprc/tsup.base.ts | 2 +- .../commitsmile/config/tsuprc/tsup.prod.ts | 106 ++++++--- packages/commitsmile/package.json | 24 +- packages/commitsmile/src/bin/app.ts | 5 + packages/commitsmile/src/cli/default.ts | 21 +- packages/commitsmile/src/defaultConfig.ts | 10 +- .../commitsmile/src/functions/findConfig.ts | 1 + packages/commitsmile/src/index.ts | 6 - packages/commitsmile/src/types/index.ts | 1 + pnpm-lock.yaml | 9 +- prettier.config.js | 5 - 18 files changed, 315 insertions(+), 424 deletions(-) delete mode 100644 packages/commitsmile/CHANGELOG copy.md delete mode 100644 packages/commitsmile/LICENSE copy delete mode 100644 packages/commitsmile/README copy.md create mode 100644 packages/commitsmile/src/bin/app.ts delete mode 100644 prettier.config.js diff --git a/commitSmile.ts b/commitSmile.ts index a9d06fb..803f91a 100644 --- a/commitSmile.ts +++ b/commitSmile.ts @@ -1,8 +1,8 @@ import { defaultConfig } from "./packages/commitsmile/lib"; -export default defaultConfig({}).deepMerge({ +export default defaultConfig().deepMerge({ prompts: { - scopes: { workspaces:true }, + scopes: { workspaces: true, options: [], custom: false, required: false }, description: false, }, }); diff --git a/packages/commitsmile/CHANGELOG copy.md b/packages/commitsmile/CHANGELOG copy.md deleted file mode 100644 index 43e8ad0..0000000 --- a/packages/commitsmile/CHANGELOG copy.md +++ /dev/null @@ -1,78 +0,0 @@ -# commitsmile - -## 0.6.1 - -### Patch Changes - -- 74c8d45: user config requirements - -## 0.6.0 - -### Minor Changes - -- feat: add possibility to add own formatter -- fix: add default values for prompts.x.custom.count - -## 0.5.1 - -### Patch Changes - -- add full support esm/cts types - -## 0.5.0 - -### Minor Changes - -- FEAT: Add Breaking Changes stage in commiting. - -## 0.4.0 - -### Minor Changes - -- Add `init` command function! - -## 0.3.10 - -### Patch Changes - -- fix commit message bug + scopes bug (same value website and api) - -## 0.3.9 - -### Patch Changes - -- Refactor Code, changed UI (changed consola => @clack/prompts) - -## 0.3.7 - -### Patch Changes - -- fix build output for npm (add ReadMe and reduce size) - -## 0.3.6 - -### Patch Changes - -- fix package.json at npm - -## 0.3.0 - -### Minor Changes - -- added loading/reading file function with ext support .(mjs,cjs,js,mts,cts,ts) and preExt - -## 0.2.0 - -### Minor Changes - -- install command,chalk and add basic util logging and commands - -## 0.1.0 - -### Minor Changes - -- Init Files + Configs - -### Patch Changes - -- Fixed missing "packageManager" at package.json needed at Github Actions and added "engines" diff --git a/packages/commitsmile/CHANGELOG.md b/packages/commitsmile/CHANGELOG.md index 43e8ad0..258aec8 100644 --- a/packages/commitsmile/CHANGELOG.md +++ b/packages/commitsmile/CHANGELOG.md @@ -1,5 +1,18 @@ # commitsmile +## 1.0.0 + +### Major Changes + +- Loader (Refactor Config type) +- Correcting values at the end +- Monorepo support +- Refactor config (Change structure, more parsers etc) +- Refactor description commit +- Final Commands Option +- Changing defaultConfig +- Skip Option + ## 0.6.1 ### Patch Changes diff --git a/packages/commitsmile/LICENSE copy b/packages/commitsmile/LICENSE copy deleted file mode 100644 index 86ed7b0..0000000 --- a/packages/commitsmile/LICENSE copy +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 INeedJobToStartWork - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/commitsmile/README copy.md b/packages/commitsmile/README copy.md deleted file mode 100644 index fe8c4ae..0000000 --- a/packages/commitsmile/README copy.md +++ /dev/null @@ -1,218 +0,0 @@ -![CommitSmileBanner](https://github.com/INeedJobToStartWork/Commit-Smile/assets/97305201/7b18af3e-7472-47f5-99e8-6f97574d2ea7) - -

Commit-Smile

-

Simple Commit Handler!

-

Next MileStones

- -
- -What you get: - -- 🌈 Beautiful Commits -- πŸ“ Standardized commit messages -- 🎯 Simplified commit process - -About package: - -- πŸš€ Install & Use -- βš™οΈ Easy in Configuring -- πŸ”§ High Customizable (Prompts, Formatters) -- πŸ“¦ Support Monorepo -- πŸ“– TSDocs (Internal documentation) -- ♻️ Minified & Compressed -- βœ… Support JS/TS & CJS/ESM - -# πŸ“œ List of Contest - -- [πŸ“œ List of Contest](#-list-of-contest) - - [Install](#install) - - [How to start](#how-to-start) - - [Commands](#commands) - - [Config](#config) - - [Location / Naming](#location--naming) - - [Dedicated File](#dedicated-file) - - [package.json](#packagejson) - - [Default Config \& Types](#default-config--types) - - [Explaination](#explaination) - - [Formatters](#formatters) - - [Prompts](#prompts) - - [finalCommands](#finalcommands) - - [Short hands](#short-hands) - - [Questions and Answers](#questions-and-answers) - - [Can i Remove emojis? (Yes)](#can-i-remove-emojis-yes) - - [Removing All](#removing-all) - - [Removing From Label](#removing-from-label) - - [Removing From Value](#removing-from-value) - -## Install - -NPM - -```bash copy -npm install -D commitsmile -``` - -PNPM - -```bash copy -pnpm add -D commitsmile -``` - -Yarn - -```bash copy -yarn add -D commitsmile -``` - -## How to start - -πŸ‘‹Hello! Glad to see you! There is order task to setup: - -| Command | Description | Link | -| ------- | ----------- | ---- | -| ------- | ----------- | ---- | - -## Commands - -| Command | Description | -| --------- | -------------------------- | -| (default) | Commit Handler (CLI APP) | -| init | Init config file (CLI APP) | - -To get more information about commands, use `--help` - -## Config - -### Location / Naming - -To find config we use `c12` and our system. - -#### Dedicated File - -In Default execute app is looking for files names match -`/commitsmile.*\.(js|ts|mjs|cjs|mts|json|jsonc|json5|yaml|yml|toml)/iu` - -- Name: commitsmile (letters can be uppercase or lowercase or mixed) -- pre ext (optional) -- Ext: `js|ts|mjs|cjs|mts|json|jsonc|json5|yaml|yml|toml` - -examples: - -- `commitsmile.discord.ts` -- `coMMitSmile.json` - -Supports to: - -| βœ… Supports too | -| --------------- | -| `.config/` | -| `.rc` | - -#### package.json - -With `commitsmile` property. - -### Default Config & Types - -Package export `defaultConfig` which can be configured and deep merge your config! - -More info in **internal Documentation** (Code) - -### Explaination - -#### Formatters - -There you can make your own formatters. - -| Stage name | description | -| ------------ | ------------------------------------------------------- | -| `format` | Format formatted stages output (Final format of commit) | -| `type` | Format of `type` | -| `scopes` | Format of `scopes` | -| `isBreaking` | Format of `isBreaking` | -| `title` | Format of `title` | - -#### Prompts - -Part of Config responsible for Commit Stages. - -| Stage name | type of prompt | Special properties | -| ------------- | -------------- | ------------------------------------------------ | -| `type` | multiselect | | -| `scopes` | multiselect | `workspaces` - Show found workspaces in monorepo | -| `isBreaking` | confirm | | -| `title` | text | | -| `description` | select | `always` - Always select that in select menu | - -Every Step is Optional and can be skipped. To do it just use value `false` or `undefined` / `void 0` - -#### finalCommands - -Commands which will be executed at the end (In key order). - -example: - -```ts -{ - gitAdd: "git add .", - commit: (results) => `git commit -m '${results.format()}' ${results.commitDescription ? `-m "${results.commitDescription}"` : ''}`, - gitPush:"git push" -} -``` - -### Short hands - -Every shorthand it's provided by our parser. - -| At | Description | From | To | -| ------------------------------ | ------------------------------------- | ----------------------------- | ----------------------------------------------- | -| `Config.prompts.stage` | If value is just a string | `type:"What type of changes"` | `type:{message:"What type of changes"}` | -| `Config.prompts.stage.options` | If option is just a string | `["Option 1"]` | `[{value:"Option 1"}]` and continue below logic | -| `Config.prompts.stage.options` | If option has a value but not a label | `[{value:"Option 1"}]` | `[{value:"Option 1", label:"Option 1"}]` | -| `Config.prompts.stage.options` | If option has a label but not a value | `[{label:"Option 1"}]` | `[{value:"Option 1", label:"Option 1"}]` | - -## Questions and Answers - -### Can i Remove emojis? (Yes) - -Yes, you can do this,this way: - -#### Removing All - -If you want to remove them totally in CLI view commit - -```ts -{ - emoji: false; -} -``` - -#### Removing From Label - -If you want to remove them in CLI view but stay in commit - -```ts -{ - emoji: { - label: false; - } -} -``` - -#### Removing From Value - -If you want to remove them in commit but stay in CLI view - -```ts -{ - emoji: { - value: false; - } -} -``` diff --git a/packages/commitsmile/README.md b/packages/commitsmile/README.md index 9a78d71..2708579 100644 --- a/packages/commitsmile/README.md +++ b/packages/commitsmile/README.md @@ -1,19 +1,52 @@ ![CommitSmileBanner](https://github.com/INeedJobToStartWork/Commit-Smile/assets/97305201/7b18af3e-7472-47f5-99e8-6f97574d2ea7) +

Commit-Smile

+

Simple Commit Handler!

+

Next MileStones

+ +
+ +[![output](https://github.com/user-attachments/assets/dc4c77cc-de51-4657-820d-5ee142176ad9)](https://asciinema.org/a/zvxJCwhOPCXdnuyIEehfC2DJo) + + + +What you get: + +- 🌈 Beautiful Commits +- πŸ“ Standardized commit messages +- 🎯 Simplified commit process + +About package: + +- πŸš€ Install & Use +- βš™οΈ Easy in Configuring +- πŸ”§ High Customizable (Prompts, Formatters) +- πŸ“¦ Support Monorepo +- πŸ“– TSDocs (Internal documentation) +- ♻️ Minified & Compressed +- βœ… Support JS/TS & CJS/ESM + # πŸ“œ List of Contest - [πŸ“œ List of Contest](#-list-of-contest) - [Install](#install) - - [How to start](#how-to-start) - - [Config](#config) - - [Location / Naming](#location--naming) - - [Package.json](#packagejson) - - [Dedicated file](#dedicated-file) - - [Config Type](#config-type) - - [Config Builder (defaultConfig)](#config-builder-defaultconfig) - - [Custom file path](#custom-file-path) - - [Init config](#init-config) - - [Formatter](#formatter) + - [How to start](#how-to-start) + - [Commands](#commands) + - [Config](#config) + - [Location / Naming](#location--naming) + - [Dedicated File](#dedicated-file) + - [package.json](#packagejson) + - [Default Config \& Types](#default-config--types) + - [Explaination](#explaination) + - [Formatters](#formatters) + - [Prompts](#prompts) + - [finalCommands](#finalcommands) + - [Short hands](#short-hands) + - [Questions and Answers](#questions-and-answers) + - [Can i Remove emojis? (Yes)](#can-i-remove-emojis-yes) + - [Removing All](#removing-all) + - [Removing From Label](#removing-from-label) + - [Removing From Value](#removing-from-value) ## Install @@ -35,27 +68,37 @@ Yarn yarn add -D commitsmile ``` -### How to start +## How to start πŸ‘‹Hello! Glad to see you! There is order task to setup: -| Command | Description | Link | -| ------- | ----------- | ---- | +| Command | Description | +| ----------------------- | ----------------------------------- | +| `pnpm i -D commitsmile` | Install it at repo | +| `pnpm commitsmile init` | Init and configure **_(Optional)_** | +| `pnpm commitsmile` | Use! :D | + +## Commands + +| Command | Description | +| --------- | -------------------------- | +| (default) | Commit Handler (CLI APP) | +| init | Init config file (CLI APP) | -### Config +To get more information about commands, use `--help` -#### Location / Naming +## Config -##### Package.json +### Location / Naming -Add "commitsmile" property to `package.json` file +To find config we use `c12` and our system. -##### Dedicated file +#### Dedicated File In Default execute app is looking for files names match `/commitsmile.*\.(js|ts|mjs|cjs|mts|json|jsonc|json5|yaml|yml|toml)/iu` -- Name: commitsmile (lette rs can be uppercase or lowercase or mixed) +- Name: commitsmile (letters can be uppercase or lowercase or mixed) - pre ext (optional) - Ext: `js|ts|mjs|cjs|mts|json|jsonc|json5|yaml|yml|toml` @@ -64,32 +107,122 @@ examples: - `commitsmile.discord.ts` - `coMMitSmile.json` -#### Config Type +Supports to: -#### Config Builder (defaultConfig) +| βœ… Supports too | +| --------------- | +| `.config/` | +| `.rc` | -### Custom file path +#### package.json -To set custom path to config we can use optional parameter `-C,--config` where `` can be relative or absolute -path: +With `commitsmile` property. -```bash copy -npm run commitsmile -C +### Default Config & Types + +Package export `defaultConfig` which can be configured and deep merge your config! + +```ts +import { defaultConfig } from "commitsmile"; + +export default defaultConfig({ + /* There config for defaultConfig */ +}).deepMerge({ + /* There your config which will be merged with default config*/ +}); ``` -If Path: +More info in **internal Documentation** (Code) -- do not include filename it will use standard process to find. -- include - will just check this file (faster way) +### Explaination -### Init config +#### Formatters -to init config we use `init`: +There you can make your own formatters. -```bash copy -npm run commitsmile init +| Stage name | description | +| ------------ | ------------------------------------------------------- | +| `format` | Format formatted stages output (Final format of commit) | +| `type` | Format of `type` | +| `scopes` | Format of `scopes` | +| `isBreaking` | Format of `isBreaking` | +| `title` | Format of `title` | + +#### Prompts + +Part of Config responsible for Commit Stages. + +| Stage name | type of prompt | Special properties | +| ------------- | -------------- | ------------------------------------------------ | +| `type` | multiselect | | +| `scopes` | multiselect | `workspaces` - Show found workspaces in monorepo | +| `isBreaking` | confirm | | +| `title` | text | | +| `description` | select | `always` - Always select that in select menu | + +Every Step is Optional and can be skipped. To do it just use value `false` or `undefined` / `void 0` + +#### finalCommands + +Commands which will be executed at the end (In key order). + +example: + +```ts +{ + gitAdd: "git add .", + commit: (results) => `git commit -m '${results.format()}' ${results.commitDescription ? `-m "${results.commitDescription}"` : ''}`, + gitPush:"git push" +} ``` -### Formatter +### Short hands + +Every shorthand it's provided by our parser. + +| At | Description | From | To | +| ------------------------------ | ------------------------------------- | ----------------------------- | ----------------------------------------------- | +| `Config.prompts.stage` | If value is just a string | `type:"What type of changes"` | `type:{message:"What type of changes"}` | +| `Config.prompts.stage.options` | If option is just a string | `["Option 1"]` | `[{value:"Option 1"}]` and continue below logic | +| `Config.prompts.stage.options` | If option has a value but not a label | `[{value:"Option 1"}]` | `[{value:"Option 1", label:"Option 1"}]` | +| `Config.prompts.stage.options` | If option has a label but not a value | `[{label:"Option 1"}]` | `[{value:"Option 1", label:"Option 1"}]` | + +## Questions and Answers + +### Can i Remove emojis? (Yes) + +Yes, you can do this,this way: + +#### Removing All + +If you want to remove them totally in CLI view commit -You format your commit message at your rules! +```ts +{ + emoji: false; +} +``` + +#### Removing From Label + +If you want to remove them in CLI view but stay in commit + +```ts +{ + emoji: { + label: false; + } +} +``` + +#### Removing From Value + +If you want to remove them in commit but stay in CLI view + +```ts +{ + emoji: { + value: false; + } +} +``` diff --git a/packages/commitsmile/clean-package.config.json b/packages/commitsmile/clean-package.config.json index e9443d1..1bb6f53 100644 --- a/packages/commitsmile/clean-package.config.json +++ b/packages/commitsmile/clean-package.config.json @@ -7,7 +7,17 @@ "npm:postpack": "clean-package restore" }, "bin": { - "commitsmile": "index.js" + "commitsmile": "./bin/app.js" + }, + "exports": { + ".": { + "types": { + "import": "./index.d.mts", + "require": "./index.d.ts" + }, + "import": "./index.mjs", + "require": "./index.js" + } } } } diff --git a/packages/commitsmile/config/tsuprc/tsup.base.ts b/packages/commitsmile/config/tsuprc/tsup.base.ts index fc20fd0..0f94899 100644 --- a/packages/commitsmile/config/tsuprc/tsup.base.ts +++ b/packages/commitsmile/config/tsuprc/tsup.base.ts @@ -3,7 +3,7 @@ import { defineConfig } from "tsup"; import typiaPlug from "@ryoppippi/unplugin-typia/esbuild"; export default defineConfig({ - entry: ["src/index.ts"], + entry: ["src/index.ts", "src/bin/app.ts"], target: "es2020", clean: true, format: ["esm"], diff --git a/packages/commitsmile/config/tsuprc/tsup.prod.ts b/packages/commitsmile/config/tsuprc/tsup.prod.ts index 0775184..a3bbe33 100644 --- a/packages/commitsmile/config/tsuprc/tsup.prod.ts +++ b/packages/commitsmile/config/tsuprc/tsup.prod.ts @@ -3,38 +3,74 @@ import typiaPlug from "@ryoppippi/unplugin-typia/esbuild"; import { copy } from "esbuild-plugin-copy"; import { defineConfig } from "tsup"; -export default defineConfig({ - ...config, - - dts: true, - splitting: false, - minify: true, - shims: true, - - bundle: true, - - minifyIdentifiers: true, - minifySyntax: true, - minifyWhitespace: true, - - metafile: false, - treeshake: true, - - outDir: "dist", - - noExternal: ["@clack/prompts", "c12", "commander", "jiti", "oh-my-error", "typia", "yaml"], - - format: ["cjs"], - esbuildPlugins: [ - copy({ - assets: [ - { from: "./package.json", to: "./package.json" }, - { from: "./.npmrc", to: "./.npmrc" }, - { from: "./.npmignore", to: "./.npmignore" }, - { from: "./README.md", to: "./README.md" }, - { from: "./src/templates/configs/*", to: "./templates/configs" } - ] - }), - typiaPlug({ tsconfig: "./tsconfig.json", cache: false }) - ] -}); +export default defineConfig([ + { + ...config, + entry: ["src/index.ts"], + + splitting: false, + minify: true, + shims: true, + + bundle: true, + + minifyIdentifiers: true, + minifySyntax: true, + minifyWhitespace: true, + + metafile: false, + treeshake: true, + + outDir: "dist", + external: ["node:stream", "@types/node"], + noExternal: ["@clack/prompts", "c12", "commander", "oh-my-error", "typia", "yaml"], + + format: ["cjs", "esm"], + + esbuildPlugins: [ + copy({ + assets: [ + { from: "./package.json", to: "./package.json" }, + { from: "./.npmrc", to: "./.npmrc" }, + { from: "./.npmignore", to: "./.npmignore" }, + { from: "./README.md", to: "./README.md" }, + { from: "./src/templates/configs/*", to: "./templates/configs" } + ] + }), + typiaPlug({ tsconfig: "./tsconfig.json", cache: false }) + ] + }, + { + entry: ["src/index.ts"], + dts: { + entry: "./src/index.ts", + resolve: true, + only: true + }, + format: ["esm", "cjs"], + external: ["node:stream"] + }, + { + ...config, + entry: ["src/bin/app.ts"], + splitting: true, + minify: true, + shims: true, + + bundle: true, + + minifyIdentifiers: true, + minifySyntax: true, + minifyWhitespace: true, + + metafile: false, + treeshake: true, + + outDir: "dist/bin", + + noExternal: ["@clack/prompts", "c12", "commander", "oh-my-error", "typia", "yaml"], + // noExternal: ["@clack/prompts", "commander", "oh-my-error", "typia", "jiti"], + format: ["esm"], + esbuildPlugins: [typiaPlug({ tsconfig: "./tsconfig.json", cache: false })] + } +]); diff --git a/packages/commitsmile/package.json b/packages/commitsmile/package.json index a28de3c..f8c011b 100644 --- a/packages/commitsmile/package.json +++ b/packages/commitsmile/package.json @@ -1,10 +1,23 @@ { "name": "commitsmile", - "version": "0.6.1", + "version": "1.0.0", "description": "Make smile on your commits", "keywords": [ "commit", - "lint" + "lint", + "git", + "conventional-commits", + "cli", + "tool", + "monorepo", + "commit-message", + "commit-formatter", + "commit-helper", + "commit-convention", + "commit-style", + "commit-linter", + "commit-validator", + "commit-standardization" ], "homepage": "https://github.com/INeedJobToStartWork/Commit-Smile", "bugs": "https://github.com/INeedJobToStartWork/Commit-Smile/issues/new/choose", @@ -17,10 +30,9 @@ "author": "ineedjobtostartwork", "type": "module", "main": "index.js", - "types": "index.d.ts", "bin": { - "commitsmileBuild": "./dist/index.cjs", - "commitsmileDev": "./lib/index.js" + "commitsmileBuild": "./dist/bin/app.mjs", + "commitsmileDev": "./lib/bin/app.js" }, "scripts": { "build": "pnpm tsup --config ./config/tsuprc/tsup.prod.ts", @@ -51,7 +63,6 @@ "@clack/prompts": "^0.8.2", "c12": "^2.0.1", "commander": "^12.1.0", - "jiti": "^2.4.0", "oh-my-error": "^2.0.1", "typia": "6.12.2", "yaml": "^2.6.1" @@ -82,7 +93,6 @@ "@clack/prompts", "c12", "commander", - "jiti", "oh-my-error", "typia", "yaml" diff --git a/packages/commitsmile/src/bin/app.ts b/packages/commitsmile/src/bin/app.ts new file mode 100644 index 0000000..4b4a4c3 --- /dev/null +++ b/packages/commitsmile/src/bin/app.ts @@ -0,0 +1,5 @@ +// eslint-disable-next-line @EslintImports/no-unassigned-import +import "@/cli"; +import { program } from "commander"; + +program.parse(process.argv); diff --git a/packages/commitsmile/src/cli/default.ts b/packages/commitsmile/src/cli/default.ts index 6df9f5b..25deede 100644 --- a/packages/commitsmile/src/cli/default.ts +++ b/packages/commitsmile/src/cli/default.ts @@ -10,6 +10,7 @@ import { myError, myErrorWrapper } from "oh-my-error"; import type { IMyError, TMyErrorList } from "oh-my-error"; import getWorkspaces from "@/functions/getWorkspaces"; import { spawnSync } from "node:child_process"; +import path from "node:path"; //---------------------- // MyError @@ -56,17 +57,29 @@ program let optionsToAdd: Parameters[0]["options"] = []; if ("workspaces" in scopes && scopes.workspaces) { - const foundWorkspaces = Object.keys(getWorkspaces(options.config)); - optionsToAdd = foundWorkspaces.map(repo => ({ + const foundWorkspaces = getWorkspaces(options.config); + const foundWorkspacesKeys = Object.keys(foundWorkspaces); + + optionsToAdd = foundWorkspacesKeys.map(repo => ({ label: `πŸ“¦ ${String(repo[0]).toUpperCase() + String(repo).slice(1)}`, value: repo, - hint: "Repo" + hint: `Repo "${path.relative(process.cwd(), foundWorkspaces[repo as keyof typeof foundWorkspaces])}"` })); } + const optionsMerged = [...optionsToAdd, ...("options" in scopes ? scopes.options : [])]; + if (!optionsMerged.length) { + prompter.outro("No scopes"); + return void 0; + } + if (optionsMerged.length == 1 && "custom" in scopes && !scopes.custom && scopes.required) { + prompter.outro(optionsMerged[0].label); + return optionsMerged[0].value; + } + return select({ ...scopes, - options: [...optionsToAdd, ...("options" in scopes ? scopes.options : [])] + options: optionsMerged }); } } diff --git a/packages/commitsmile/src/defaultConfig.ts b/packages/commitsmile/src/defaultConfig.ts index 39d2dfd..01b362f 100644 --- a/packages/commitsmile/src/defaultConfig.ts +++ b/packages/commitsmile/src/defaultConfig.ts @@ -182,11 +182,11 @@ const configData = (configOptions?: TDefaultConfigProps): TConfig => { multiple: true, required: true, options: [ - { label: `${getStrIfTrue(validatedConfigOptions.emoji.label, "🌍")} Enviroment`, value: "enviroment" }, - { label: `${getStrIfTrue(validatedConfigOptions.emoji.label, "πŸ“–")} Docs`, value: "docs" }, - { label: `${getStrIfTrue(validatedConfigOptions.emoji.label, "🌐")} Website`, value: "web" }, - { label: `${getStrIfTrue(validatedConfigOptions.emoji.label, "πŸ“±")} Mobile`, value: "mobile" }, - { label: `${getStrIfTrue(validatedConfigOptions.emoji.label, "πŸƒ")} API`, value: "api" } + { label: `${getStrIfTrue(validatedConfigOptions.emoji.label, "🌍 ")}Enviroment`, value: "enviroment" }, + { label: `${getStrIfTrue(validatedConfigOptions.emoji.label, "πŸ“– ")}Docs`, value: "docs" }, + { label: `${getStrIfTrue(validatedConfigOptions.emoji.label, "🌐 ")}Website`, value: "web" }, + { label: `${getStrIfTrue(validatedConfigOptions.emoji.label, "πŸ“± ")}Mobile`, value: "mobile" }, + { label: `${getStrIfTrue(validatedConfigOptions.emoji.label, "πŸƒ ")}API`, value: "api" } ] }, isBreaking: { diff --git a/packages/commitsmile/src/functions/findConfig.ts b/packages/commitsmile/src/functions/findConfig.ts index 230135c..010ec56 100644 --- a/packages/commitsmile/src/functions/findConfig.ts +++ b/packages/commitsmile/src/functions/findConfig.ts @@ -24,6 +24,7 @@ export function findConfig(configPath: string): string | undefined { const files = readdirSync(configPath); for (const file of files) { logging.debug(`File: ${file}`); + // eslint-disable-next-line @EslintSecurity/detect-unsafe-regex if (/commitsmile(\.[^.]+)*\.(js|ts|mjs|cjs|mts|json|jsonc|json5|yaml|yml|toml)/iu.test(file)) { logging.debug("Config found"); return path.join(configPath, file); diff --git a/packages/commitsmile/src/index.ts b/packages/commitsmile/src/index.ts index edfe25d..bec959d 100644 --- a/packages/commitsmile/src/index.ts +++ b/packages/commitsmile/src/index.ts @@ -1,8 +1,2 @@ -// eslint-disable-next-line @EslintImports/no-unassigned-import -import "@/cli"; -import { program } from "commander"; - -program.parse(process.argv); - export { defaultConfig } from "@/defaultConfig"; export type { TConfigInput as Config } from "@/types"; diff --git a/packages/commitsmile/src/types/index.ts b/packages/commitsmile/src/types/index.ts index c52dc40..03a9999 100644 --- a/packages/commitsmile/src/types/index.ts +++ b/packages/commitsmile/src/types/index.ts @@ -1,5 +1,6 @@ export * from "./tConfig"; +/** @dontexport */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export type TTodo = any; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24a8b20..4e624e6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,9 +39,6 @@ importers: commander: specifier: ^12.1.0 version: 12.1.0 - jiti: - specifier: ^2.4.0 - version: 2.4.0 oh-my-error: specifier: ^2.0.1 version: 2.0.1 @@ -5111,7 +5108,7 @@ snapshots: '@typescript-eslint/types': 7.3.1 '@typescript-eslint/typescript-estree': 7.3.1(typescript@5.7.2) '@typescript-eslint/visitor-keys': 7.3.1 - debug: 4.3.7 + debug: 4.4.0 eslint: 8.57.1 optionalDependencies: typescript: 5.7.2 @@ -5242,7 +5239,7 @@ snapshots: dependencies: '@typescript-eslint/types': 7.3.1 '@typescript-eslint/visitor-keys': 7.3.1 - debug: 4.3.7 + debug: 4.4.0 globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.3 @@ -8045,7 +8042,7 @@ snapshots: postcss-load-config@4.0.2(postcss@8.4.49): dependencies: - lilconfig: 3.1.2 + lilconfig: 3.1.3 yaml: 2.6.1 optionalDependencies: postcss: 8.4.49 diff --git a/prettier.config.js b/prettier.config.js deleted file mode 100644 index 090b084..0000000 --- a/prettier.config.js +++ /dev/null @@ -1,5 +0,0 @@ -import prettierConfig from "@ineedj/prettierrc"; - -export default { - ...prettierConfig -};