Skip to content

Commit

Permalink
🐛 Fix(commitsmile): Problem with init template (wrong template path)
Browse files Browse the repository at this point in the history
  • Loading branch information
INeedJobToStartWork committed Dec 24, 2024
1 parent 979c24f commit 7c62b53
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
6 changes: 6 additions & 0 deletions packages/commitsmile/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# commitsmile

## 1.0.3

### Patch Changes

- fix: template path update

## 1.0.2

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/commitsmile/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "commitsmile",
"version": "1.0.2",
"version": "1.0.3",
"description": "Make smile on your commits",
"keywords": [
"commit",
Expand Down Expand Up @@ -32,7 +32,7 @@
"main": "index.js",
"bin": {
"commitsmileBuild": "./bin/app.js",
"commitsmileDev": "./bin/app.js"
"commitsmileDev2": "./bin/app.js"
},
"scripts": {
"build": "pnpm tsup --config ./config/tsuprc/tsup.prod.ts",
Expand Down
27 changes: 24 additions & 3 deletions packages/commitsmile/src/cli/init.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { TOptionsConfig, TOptionsDebugger } from "@/helpers";
import { optionDebugger } from "@/helpers";
import * as prompter from "@clack/prompts";
import { program } from "commander";
Expand All @@ -10,11 +11,23 @@ import { copyFile, existsSync } from "node:fs";
import { fileURLToPath } from "node:url";
import path, { dirname } from "node:path";

//----------------------
// Types
//----------------------
/** @internal @dontexport */
type TOptions = TOptionsConfig & TOptionsDebugger;

//----------------------
// CLI APP
//----------------------
program
.command("init")
.addOption(optionDebugger) //TODO: Fix to make it work (Only work in one command at time rn)
.description("Init configuration file")
.addOption(optionDebugger)
.action(async () => {
.action(async (options: TOptions) => {
process.env.DEBUG = options.debugger ? "TRUE" : "FALSE";
logging.debug("Test debug message");
logging.debug(options);
const test = await new StageRunner()
.addStep({
intro: () => {
Expand Down Expand Up @@ -104,9 +117,14 @@ program
const destination = `${process.cwd()}/${finalname}`;
const templatePath = path.resolve(
dirname(fileURLToPath(import.meta.url)),
`./templates/configs/config.${ext}.hbs`
`../templates/configs/config.${ext}.hbs`
);

logging.debug(`Template Path: ${templatePath}`);

//TODO: Error if it do not exist
logging.debug(`Template Path Exist: ${existsSync(templatePath)}`);

if (existsSync(destination)) {
logging.warn("File already exists!");
const overwrite = await prompter.confirm({ message: "Overwrite file?", initialValue: false });
Expand All @@ -119,6 +137,7 @@ program
copyFile(templatePath, destination, (err: unknown): void => {
if (err) logging.error(err);
});

prompter.outro(chalk.bgGreen("File created successfully!"));
}
})
Expand All @@ -132,3 +151,5 @@ program

process.exit(0);
});

// program.parse(process.argv);

0 comments on commit 7c62b53

Please sign in to comment.