Compare commits

...

9 Commits

Author SHA1 Message Date
di-sukharev
1a32bff538 0.0.19 2023-03-06 22:13:32 +08:00
di-sukharev
297ccac45b * 🐛 fix(package.json): change cli file extension from .cjs to .mjs
* 🐛 fix(githook.ts): change cli file path to match new extension
The cli file extension has been changed from .cjs to .mjs to improve compatibility with Node.js ESM modules. The file path in githook.ts has been updated to match the new extension.
2023-03-06 22:12:37 +08:00
di-sukharev
3859533eff * 🐛 fix(githook.ts): fix HOOK_PATH import URL
The HOOK_PATH import URL was incorrect and has been fixed to point to the correct location.
2023-03-06 21:49:19 +08:00
di-sukharev
757faba0c4 0.0.18 2023-03-06 21:42:05 +08:00
di-sukharev
422d38d51e * 🐛 fix(githook.ts): update HOOK_PATH to point to the correct file path
The HOOK_PATH variable was pointing to the wrong file path, which caused the hook to fail. The file path has been updated to point to the correct file path.
2023-03-06 21:41:58 +08:00
di-sukharev
ee02be56b2 0.0.17 2023-03-06 21:40:49 +08:00
di-sukharev
1c762a6e8c * 🚀 feat(package.json): add deploy script
The deploy script builds the application, increments the patch version, and publishes the package to the registry. This makes it easier to deploy new versions of the application.
2023-03-06 21:40:39 +08:00
di-sukharev
6126fad25c 0.0.16 2023-03-06 21:38:26 +08:00
di-sukharev
01cdd2f58d removed async iife 2023-03-06 21:36:37 +08:00
3 changed files with 59 additions and 63 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "open-commit",
"version": "0.0.15",
"version": "0.0.19",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "open-commit",
"version": "0.0.15",
"version": "0.0.19",
"license": "ISC",
"dependencies": {
"@clack/prompts": "^0.6.1",

View File

@@ -1,6 +1,6 @@
{
"name": "opencommit",
"version": "0.0.15",
"version": "0.0.19",
"description": "AI generates conventional commits with mind-blowing accuracy.",
"keywords": [
"git",
@@ -12,8 +12,8 @@
],
"main": "cli.js",
"bin": {
"opencommit": "./out/cli.cjs",
"oc": "./out/cli.cjs"
"opencommit": "./out/cli.mjs",
"oc": "./out/cli.mjs"
},
"repository": {
"url": "https://github.com/di-sukharev/opencommit"
@@ -34,10 +34,10 @@
},
"scripts": {
"watch": "npm run -S build -- --sourcemap --watch",
"start": "node ./out/cli.cjs",
"start": "node ./out/cli.mjs",
"dev": "ts-node ./src/cli.ts",
"build": "rimraf out && esbuild ./src/cli.ts --bundle --outfile=out/cli.cjs --format=cjs --platform=node",
"patch": "npm version patch",
"build": "rimraf out && esbuild ./src/cli.ts --bundle --outfile=out/cli.mjs --format=esm --platform=node --banner:js=\"import {createRequire} from 'module';const require=createRequire(import.meta.url);\"",
"deploy": "npm run build && npm version patch && npm publish",
"lint": "eslint src --ext ts && tsc --noEmit"
},
"devDependencies": {

View File

@@ -19,71 +19,67 @@ export const hookCommand = command(
name: 'hook',
parameters: ['<set/unset>']
},
(argv) => {
const HOOK_PATH = fileURLToPath(new URL('cli.cjs', import.meta.url));
async (argv) => {
const HOOK_PATH = fileURLToPath(new URL('cli.mjs', import.meta.url));
(async () => {
try {
await assertGitRepo();
try {
await assertGitRepo();
const { setUnset: mode } = argv._;
const { setUnset: mode } = argv._;
if (mode === 'set') {
intro(`setting opencommit as '${HOOK_NAME}' hook`);
if (mode === 'set') {
intro(`setting opencommit as '${HOOK_NAME}' hook`);
if (isHookExists) {
let realPath;
try {
realPath = await fs.realpath(SYMLINK_URL);
console.log(123, { realPath });
} catch (error) {
console.log(321, { realPath });
outro(error as string);
realPath = null;
}
if (realPath === HOOK_PATH)
return outro(`opencommit is already set as '${HOOK_NAME}'`);
throw new Error(
`Different ${HOOK_NAME} is already set. Remove it before setting opencommit as '${HOOK_NAME}' hook.`
);
if (isHookExists) {
let realPath;
try {
realPath = await fs.realpath(SYMLINK_URL);
} catch (error) {
outro(error as string);
realPath = null;
}
await fs.mkdir(path.dirname(SYMLINK_URL), { recursive: true });
await fs.symlink(HOOK_PATH, SYMLINK_URL, 'file');
await fs.chmod(SYMLINK_URL, 0o755);
if (realPath === HOOK_PATH)
return outro(`opencommit is already set as '${HOOK_NAME}'`);
return outro(`${chalk.green('✔')} Hook set`);
throw new Error(
`Different ${HOOK_NAME} is already set. Remove it before setting opencommit as '${HOOK_NAME}' hook.`
);
}
if (mode === 'unset') {
intro(`unsetting opencommit as '${HOOK_NAME}' hook`);
await fs.mkdir(path.dirname(SYMLINK_URL), { recursive: true });
await fs.symlink(HOOK_PATH, SYMLINK_URL, 'file');
await fs.chmod(SYMLINK_URL, 0o755);
if (!isHookExists) {
return outro(
`opencommit wasn't previously set as '${HOOK_NAME}' hook, nothing to remove`
);
}
const realpath = await fs.realpath(SYMLINK_URL);
if (realpath !== HOOK_PATH) {
return outro(
`opencommit wasn't previously set as '${HOOK_NAME}' hook, but different hook was, if you want to remove it — do it manually`
);
}
await fs.rm(SYMLINK_URL);
return outro(`${chalk.green('✔')} Hook is removed`);
}
throw new Error(
`unsupported mode: ${mode}. Supported modes are: 'set' or 'unset'`
);
} catch (error) {
outro(`${chalk.red('✖')} ${error}`);
process.exit(1);
return outro(`${chalk.green('✔')} Hook set`);
}
})();
if (mode === 'unset') {
intro(`unsetting opencommit as '${HOOK_NAME}' hook`);
if (!isHookExists) {
return outro(
`opencommit wasn't previously set as '${HOOK_NAME}' hook, nothing to remove`
);
}
const realpath = await fs.realpath(SYMLINK_URL);
if (realpath !== HOOK_PATH) {
return outro(
`opencommit wasn't previously set as '${HOOK_NAME}' hook, but different hook was, if you want to remove it — do it manually`
);
}
await fs.rm(SYMLINK_URL);
return outro(`${chalk.green('✔')} Hook is removed`);
}
throw new Error(
`unsupported mode: ${mode}. Supported modes are: 'set' or 'unset'`
);
} catch (error) {
outro(`${chalk.red('✖')} ${error}`);
process.exit(1);
}
}
);