Compare commits

..

14 Commits

Author SHA1 Message Date
48305ebb6a v1.20.0
Some checks failed
Default (tags) / security (push) Failing after 1s
Default (tags) / test (push) Failing after 1s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-11-06 00:06:02 +00:00
485c0a3855 feat(commit): Add non-interactive --yes (-y) flag to commit command to auto-accept AI recommendations and optionally push with -p 2025-11-06 00:06:02 +00:00
adc828d9bb 1.19.9
Some checks failed
Default (tags) / security (push) Failing after 0s
Default (tags) / test (push) Failing after 0s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-11-05 22:55:29 +00:00
fff1d39338 fix(mod_commit): Refactor version bumping to a unified implementation for npm and Deno; remove npm-exec based helpers and add file-based version readers/updaters to avoid npm warning pollution 2025-11-05 22:55:29 +00:00
5afbe6ccbc 1.19.8
Some checks failed
Default (tags) / security (push) Failing after 0s
Default (tags) / test (push) Failing after 0s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-11-04 03:44:42 +00:00
9de17a428d fix(package.json): Bump @git.zone/tsdoc dependency to ^1.9.2 2025-11-04 03:44:42 +00:00
c9985102c3 1.19.7
Some checks failed
Default (tags) / security (push) Failing after 0s
Default (tags) / test (push) Failing after 0s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-11-04 02:31:22 +00:00
73f98c1c3f fix(dependencies): Bump @git.zone/tsdoc to ^1.9.1 2025-11-04 02:31:22 +00:00
ae93e6f146 1.19.6
Some checks failed
Default (tags) / security (push) Failing after 0s
Default (tags) / test (push) Failing after 0s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-11-04 02:22:44 +00:00
2abaeee500 fix(cli): Bump @git.zone/tsdoc dependency to ^1.9.0 2025-11-04 02:22:44 +00:00
0538ba2586 1.19.5
Some checks failed
Default (tags) / security (push) Failing after 0s
Default (tags) / test (push) Failing after 0s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-11-04 01:54:04 +00:00
a451779724 fix(cli): Bump @git.zone/tsdoc to ^1.8.3 2025-11-04 01:54:04 +00:00
cd3246d659 1.19.4
Some checks failed
Default (tags) / security (push) Failing after 0s
Default (tags) / test (push) Failing after 0s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-11-03 17:54:18 +00:00
d37ffd7177 fix(tsdoc): update tsdoc 2025-11-03 17:54:07 +00:00
7 changed files with 280 additions and 175 deletions

View File

@@ -1,5 +1,45 @@
# Changelog
## 2025-11-06 - 1.20.0 - feat(commit)
Add non-interactive --yes (-y) flag to commit command to auto-accept AI recommendations and optionally push with -p
- Add -y / --yes flag to gitzone commit to auto-accept AI-generated commit recommendations without interactive prompts
- Support -yp or -y -p combinations to auto-accept and push to origin; -p / --push remains the separate control for pushing
- Implementation creates a smartinteract AnswerBucket programmatically when -y is used and populates commitType, commitScope, commitDescription and pushToOrigin
- Preserves existing UI output and interactive flow when -y is not used; fully backward compatible and CI/CD friendly
- Updated CLI usage and documentation (readme.hints.md) to document the new flags
## 2025-11-05 - 1.19.9 - fix(mod_commit)
Refactor version bumping to a unified implementation for npm and Deno; remove npm-exec based helpers and add file-based version readers/updaters to avoid npm warning pollution
- Removed legacy npm/deno-specific helpers (bumpNpmVersion, syncVersionToDenoJson, bumpDenoVersion) that relied on executing npm and caused warning pollution
- Added readCurrentVersion() to read version from package.json or deno.json
- Added updateVersionFile() helper to write version directly into JSON files
- Added unified bumpProjectVersion() that handles npm, deno and both with a single code path; reuses calculateNewVersion()
- Stages updated files, commits v<newVersion> and creates a tag v<newVersion>
- Benefits: no npm warning pollution in deno.json, simpler git history, consistent behavior across project types
## 2025-11-04 - 1.19.8 - fix(package.json)
Bump @git.zone/tsdoc dependency to ^1.9.2
- Updated dependency @git.zone/tsdoc from ^1.9.1 to ^1.9.2 in package.json
## 2025-11-04 - 1.19.7 - fix(dependencies)
Bump @git.zone/tsdoc to ^1.9.1
- Updated package.json dependency @git.zone/tsdoc from ^1.9.0 to ^1.9.1
## 2025-11-04 - 1.19.6 - fix(cli)
Bump @git.zone/tsdoc dependency to ^1.9.0
- Updated dependency @git.zone/tsdoc from ^1.8.3 to ^1.9.0 in package.json
## 2025-11-04 - 1.19.5 - fix(cli)
Bump @git.zone/tsdoc to ^1.8.3 and add local .claude settings for allowed permissions
- Updated dependency @git.zone/tsdoc from ^1.8.2 to ^1.8.3
- Added .claude/settings.local.json to declare allowed permissions for local tooling (Bash commands, Docker, npm, WebFetch and MCP actions)
## 2025-11-03 - 1.19.3 - fix(tsdoc)
Bump @git.zone/tsdoc to ^1.8.0 and add .claude local settings

View File

@@ -1,7 +1,7 @@
{
"name": "@git.zone/cli",
"private": false,
"version": "1.19.3",
"version": "1.20.0",
"description": "A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.",
"main": "dist_ts/index.ts",
"typings": "dist_ts/index.d.ts",
@@ -68,7 +68,7 @@
"@types/node": "^22.15.18"
},
"dependencies": {
"@git.zone/tsdoc": "^1.8.0",
"@git.zone/tsdoc": "^1.9.2",
"@git.zone/tspublish": "^1.10.3",
"@push.rocks/commitinfo": "^1.0.12",
"@push.rocks/early": "^4.0.4",

75
pnpm-lock.yaml generated
View File

@@ -9,8 +9,8 @@ importers:
.:
dependencies:
'@git.zone/tsdoc':
specifier: ^1.8.0
version: 1.8.0(ws@8.18.3)(zod@3.25.76)
specifier: ^1.9.2
version: 1.9.2(ws@8.18.3)(zod@3.25.76)
'@git.zone/tspublish':
specifier: ^1.10.3
version: 1.10.3
@@ -126,9 +126,14 @@ importers:
packages:
'@anthropic-ai/sdk@0.59.0':
resolution: {integrity: sha512-m9w9tC+N+GUNprwEOhU3VKKSYwXA1fIevRCe7kOFonV4xu5vxqmqyoLy+dkdVvc5W1F4WUTVE/7I4criaF9gnw==}
'@anthropic-ai/sdk@0.65.0':
resolution: {integrity: sha512-zIdPOcrCVEI8t3Di40nH4z9EoeyGZfXbYSvWdDLsB/KkaSYMnEgC7gmcgWu83g2NTn1ZTpbMvpdttWDGGIk6zw==}
hasBin: true
peerDependencies:
zod: ^3.25.0 || ^4.0.0
peerDependenciesMeta:
zod:
optional: true
'@api.global/typedrequest-interfaces@2.0.2':
resolution: {integrity: sha512-D+mkr4IiUZ/eUgrdp5jXjBKOW/iuMcl0z2ZLQsLLypKX/psFGD3viZJ58FNRa+/1OSM38JS5wFyoWl8oPEFLrw==}
@@ -512,8 +517,8 @@ packages:
resolution: {integrity: sha512-gBskgM3ECy9FEmhCWnQahDyFCAjjw/7emjx/KYM/FOlPqGV+hmYzt368zwSlkzOGgYF8k9OZ+mp6vexDL/+f2w==}
hasBin: true
'@git.zone/tsdoc@1.8.0':
resolution: {integrity: sha512-6pixfOwrAYqimt4/6RnfrHJIyNCdR9dPESfEj/aK9pIK12XOtUq5gBNjrFFwUhOlo0SUeBIdqN5lbN5iQ/Klgw==}
'@git.zone/tsdoc@1.9.2':
resolution: {integrity: sha512-ibkQ9VD9kli9uSPJLHzfPLVOoqvIMZwh49CwGkgx1ISOpDzJuWpriCvaZJrH57gaovWiKUYnpgVe2vDFF8Ru8A==}
hasBin: true
'@git.zone/tspublish@1.10.3':
@@ -996,8 +1001,8 @@ packages:
'@push.rocks/qenv@6.1.3':
resolution: {integrity: sha512-+z2hsAU/7CIgpYLFqvda8cn9rUBMHqLdQLjsFfRn5jPoD7dJ5rFlpkbhfM4Ws8mHMniwWaxGKo+q/YBhtzRBLg==}
'@push.rocks/smartai@0.5.11':
resolution: {integrity: sha512-zbnia/1t1ffM2L2i206V7nBCvAF4/kfq7x3n7m7BEmNoyt9Kp6uIEilPFXJ22gGhK//HLypsPl6P3YF0GJ6H9w==}
'@push.rocks/smartai@0.8.0':
resolution: {integrity: sha512-guzi28meUDc3mydC8kpoA+4pzExRQqygXYFDD4qQSWPpIRHQ7qhpeNqJzrrGezT1yOH5Gb9taPEGwT56hI+nwQ==}
'@push.rocks/smartarchive@4.2.2':
resolution: {integrity: sha512-6EpqbKU32D6Gcqsc9+Tn1dOCU5HoTlrqqs/7IdUr9Tirp9Ngtptkapca1Fw/D0kVJ7SSw3kG/miAYnuPMZLEoA==}
@@ -1044,6 +1049,9 @@ packages:
'@push.rocks/smartenv@5.0.13':
resolution: {integrity: sha512-ACXmUcHZHl2CF2jnVuRw9saRRrZvJblCRs2d+K5aLR1DfkYFX3eA21kcMlKeLisI3aGNbIj9vz/rowN5qkRkfA==}
'@push.rocks/smartenv@6.0.0':
resolution: {integrity: sha512-ktW5MqOFs0492sB4vrvl4lgRFQ/sQ4AyREgB+sCIzGqszHWGVvGXR95Y2a3z66jkLPYML2CUWHzmMlfv8fkG+A==}
'@push.rocks/smarterror@2.0.1':
resolution: {integrity: sha512-iCcH1D8tlDJgMFsaJ6lhdOTKhbU0KoprNv9MRP9o7691QOx4JEDXiHtr/lNtxVo8BUtdb9CF6kazaknO9KuORA==}
@@ -1071,8 +1079,8 @@ packages:
'@push.rocks/smartfm@2.2.2':
resolution: {integrity: sha512-kLrBv/vWXJmB558LI5C79fWXLKOnno998vnp3opfB+uyznT2E6LkcpKsxdjwe1V/r+Z5GlhXPOWmGgHPCzUR6w==}
'@push.rocks/smartgit@3.2.1':
resolution: {integrity: sha512-8bn/G7zCmD0V0O/BSc2+dnEk8c6KEouN60DQ6a46eIDW3Mp7ZY13p34+f1aEiwKl7xLC/GaDWgBm5OLMN5Cutw==}
'@push.rocks/smartgit@3.3.1':
resolution: {integrity: sha512-fnyF9Fr5y0ClSFiw/yMAWXlxvteWK2eXJ5i8/wsJcAyWqwTZ9KvMkVe33ofiZ/ZPuQ5JG9CXmoE0MST++5Xv6g==}
'@push.rocks/smartguard@3.1.0':
resolution: {integrity: sha512-J23q84f1O+TwFGmd4lrO9XLHUh2DaLXo9PN/9VmTWYzTkQDv5JehmifXVI0esophXcCIfbdIu6hbt7/aHlDF4A==}
@@ -3095,6 +3103,10 @@ packages:
json-parse-even-better-errors@2.3.1:
resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==}
json-schema-to-ts@3.1.1:
resolution: {integrity: sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==}
engines: {node: '>=16'}
jsonfile@4.0.0:
resolution: {integrity: sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=}
@@ -3990,8 +4002,8 @@ packages:
safer-buffer@2.1.2:
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
sax@1.4.1:
resolution: {integrity: sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==}
sax@1.4.2:
resolution: {integrity: sha512-FySGAa0RGcFiN6zfrO9JvK1r7TB59xuzCcTHOBXBNoKgDejlOQCR2KL/FGk3/iDlsqyYg1ELZpOmlg09B01Czw==}
section-matter@1.0.0:
resolution: {integrity: sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==}
@@ -4284,6 +4296,9 @@ packages:
trough@2.2.0:
resolution: {integrity: sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==}
ts-algebra@2.0.0:
resolution: {integrity: sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==}
tslib@1.14.1:
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
@@ -4570,7 +4585,11 @@ packages:
snapshots:
'@anthropic-ai/sdk@0.59.0': {}
'@anthropic-ai/sdk@0.65.0(zod@3.25.76)':
dependencies:
json-schema-to-ts: 3.1.1
optionalDependencies:
zod: 3.25.76
'@api.global/typedrequest-interfaces@2.0.2': {}
@@ -5333,17 +5352,17 @@ snapshots:
- '@swc/helpers'
- supports-color
'@git.zone/tsdoc@1.8.0(ws@8.18.3)(zod@3.25.76)':
'@git.zone/tsdoc@1.9.2(ws@8.18.3)(zod@3.25.76)':
dependencies:
'@git.zone/tspublish': 1.10.3
'@push.rocks/early': 4.0.4
'@push.rocks/npmextra': 5.3.3
'@push.rocks/qenv': 6.1.3
'@push.rocks/smartai': 0.5.11(typescript@5.9.3)(ws@8.18.3)(zod@3.25.76)
'@push.rocks/smartai': 0.8.0(typescript@5.9.3)(ws@8.18.3)(zod@3.25.76)
'@push.rocks/smartcli': 4.0.19
'@push.rocks/smartdelay': 3.0.5
'@push.rocks/smartfile': 11.2.7
'@push.rocks/smartgit': 3.2.1
'@push.rocks/smartgit': 3.3.1
'@push.rocks/smartinteract': 2.0.16
'@push.rocks/smartlog': 3.1.10
'@push.rocks/smartlog-destination-local': 9.0.2
@@ -6135,9 +6154,9 @@ snapshots:
'@push.rocks/smartlog': 3.1.10
'@push.rocks/smartpath': 6.0.0
'@push.rocks/smartai@0.5.11(typescript@5.9.3)(ws@8.18.3)(zod@3.25.76)':
'@push.rocks/smartai@0.8.0(typescript@5.9.3)(ws@8.18.3)(zod@3.25.76)':
dependencies:
'@anthropic-ai/sdk': 0.59.0
'@anthropic-ai/sdk': 0.65.0(zod@3.25.76)
'@push.rocks/smartarray': 1.1.0
'@push.rocks/smartfile': 11.2.7
'@push.rocks/smartpath': 6.0.0
@@ -6305,6 +6324,10 @@ snapshots:
dependencies:
'@push.rocks/smartpromise': 4.2.3
'@push.rocks/smartenv@6.0.0':
dependencies:
'@push.rocks/smartpromise': 4.2.3
'@push.rocks/smarterror@2.0.1':
dependencies:
clean-stack: 1.3.0
@@ -6376,9 +6399,9 @@ snapshots:
dependencies:
gray-matter: 4.0.3
'@push.rocks/smartgit@3.2.1':
'@push.rocks/smartgit@3.3.1':
dependencies:
'@push.rocks/smartenv': 5.0.13
'@push.rocks/smartenv': 6.0.0
'@push.rocks/smartfile': 11.2.7
'@push.rocks/smartpath': 6.0.0
'@push.rocks/smartpromise': 4.2.3
@@ -6388,6 +6411,7 @@ snapshots:
'@types/diff': 8.0.0
diff: 8.0.2
isomorphic-git: 1.34.2
minimatch: 10.1.1
'@push.rocks/smartguard@3.1.0':
dependencies:
@@ -9009,6 +9033,11 @@ snapshots:
json-parse-even-better-errors@2.3.1: {}
json-schema-to-ts@3.1.1:
dependencies:
'@babel/runtime': 7.28.4
ts-algebra: 2.0.0
jsonfile@4.0.0:
optionalDependencies:
graceful-fs: 4.2.11
@@ -10132,7 +10161,7 @@ snapshots:
safer-buffer@2.1.2: {}
sax@1.4.1: {}
sax@1.4.2: {}
section-matter@1.0.0:
dependencies:
@@ -10520,6 +10549,8 @@ snapshots:
trough@2.2.0: {}
ts-algebra@2.0.0: {}
tslib@1.14.1: {}
tslib@2.8.1: {}
@@ -10736,7 +10767,7 @@ snapshots:
xml2js@0.5.0:
dependencies:
sax: 1.4.1
sax: 1.4.2
xmlbuilder: 11.0.1
xmlbuilder2@3.1.1:

View File

@@ -89,6 +89,41 @@ The format module is responsible for project standardization:
5. **Performance Optimizations**: Parallel execution and caching
6. **Reporting**: Diff views, statistics, verbose logging
7. **Architecture**: Clean separation of concerns with new classes
8. **Unified Version Bumping**: Self-managed version updates eliminating npm warning pollution in deno.json
### Version Bumping Refactor (Latest)
The commit module's version bumping has been refactored to eliminate npm command dependencies:
**Changes:**
- Removed `bumpNpmVersion()` - was causing npm warnings to pollute deno.json
- Removed `syncVersionToDenoJson()` - no longer needed with unified approach
- Removed separate `bumpDenoVersion()` - replaced by unified implementation
- Added `readCurrentVersion()` helper - reads from either package.json or deno.json
- Added `updateVersionFile()` helper - updates JSON files directly
- Unified `bumpProjectVersion()` - handles npm/deno/both with single clean code path
**Benefits:**
- No npm warning pollution in version fields
- Full control over version bumping process
- Simpler git history (no amending, no force-tagging)
- Same code path for all project types
- Reuses existing `calculateNewVersion()` function
### Auto-Accept Flag for Commits
The commit module now supports `-y/--yes` flag for non-interactive commits:
**Usage:**
- `gitzone commit -y` - Auto-accepts AI recommendations without prompts
- `gitzone commit -yp` - Auto-accepts and pushes to origin
- Separate `-p/--push` flag controls push behavior
**Implementation:**
- Creates AnswerBucket programmatically when `-y` flag detected
- Preserves all UI output for transparency
- Fully backward compatible with interactive mode
- CI/CD friendly for automated workflows
## Development Tips
@@ -137,6 +172,27 @@ The format module is responsible for project standardization:
## CLI Usage
### Commit Commands
```bash
# Interactive commit (default)
gitzone commit
# Auto-accept AI recommendations (no prompts)
gitzone commit -y
gitzone commit --yes
# Auto-accept and push to origin
gitzone commit -yp
gitzone commit -y -p
gitzone commit --yes --push
# Run format before commit
gitzone commit --format
```
### Format Commands
```bash
# Basic format
gitzone format

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/cli',
version: '1.19.3',
version: '1.20.0',
description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
}

View File

@@ -27,35 +27,63 @@ export const run = async (argvArg: any) => {
recommendedNextVersionScope: nextCommitObject.recommendedNextVersionScope,
recommendedNextVersionMessage: nextCommitObject.recommendedNextVersionMessage,
});
const commitInteract = new plugins.smartinteract.SmartInteract();
commitInteract.addQuestions([
{
type: 'list',
name: `commitType`,
message: `Choose TYPE of the commit:`,
choices: [`fix`, `feat`, `BREAKING CHANGE`],
default: nextCommitObject.recommendedNextVersionLevel,
},
{
type: 'input',
name: `commitScope`,
message: `What is the SCOPE of the commit:`,
default: nextCommitObject.recommendedNextVersionScope,
},
{
type: `input`,
name: `commitDescription`,
message: `What is the DESCRIPTION of the commit?`,
default: nextCommitObject.recommendedNextVersionMessage,
},
{
type: 'confirm',
name: `pushToOrigin`,
message: `Do you want to push this version now?`,
default: true,
},
]);
const answerBucket = await commitInteract.runQueue();
let answerBucket: plugins.smartinteract.AnswerBucket;
// Check if -y or --yes flag is set to auto-accept recommendations
if (argvArg.y || argvArg.yes) {
// Auto-mode: create AnswerBucket programmatically
logger.log('info', '✓ Auto-accepting AI recommendations (--yes flag)');
answerBucket = new plugins.smartinteract.AnswerBucket();
answerBucket.addAnswer({
name: 'commitType',
value: nextCommitObject.recommendedNextVersionLevel,
});
answerBucket.addAnswer({
name: 'commitScope',
value: nextCommitObject.recommendedNextVersionScope,
});
answerBucket.addAnswer({
name: 'commitDescription',
value: nextCommitObject.recommendedNextVersionMessage,
});
answerBucket.addAnswer({
name: 'pushToOrigin',
value: !!(argvArg.p || argvArg.push), // Only push if -p flag also provided
});
} else {
// Interactive mode: prompt user for input
const commitInteract = new plugins.smartinteract.SmartInteract();
commitInteract.addQuestions([
{
type: 'list',
name: `commitType`,
message: `Choose TYPE of the commit:`,
choices: [`fix`, `feat`, `BREAKING CHANGE`],
default: nextCommitObject.recommendedNextVersionLevel,
},
{
type: 'input',
name: `commitScope`,
message: `What is the SCOPE of the commit:`,
default: nextCommitObject.recommendedNextVersionScope,
},
{
type: `input`,
name: `commitDescription`,
message: `What is the DESCRIPTION of the commit?`,
default: nextCommitObject.recommendedNextVersionMessage,
},
{
type: 'confirm',
name: `pushToOrigin`,
message: `Do you want to push this version now?`,
default: true,
},
]);
answerBucket = await commitInteract.runQueue();
}
const commitString = createCommitStringFromAnswerBucket(answerBucket);
const commitVersionType = (() => {
switch (answerBucket.getAnswerFor('commitType')) {

View File

@@ -91,118 +91,47 @@ function calculateNewVersion(currentVersion: string, versionType: VersionType):
}
/**
* Bumps the version in deno.json, commits the change, and creates a tag
* @param versionType Type of version bump
* @returns The new version string
* Reads the current version from package.json or deno.json
* @param projectType The project type to determine which file to read
* @returns The current version string
*/
export async function bumpDenoVersion(versionType: VersionType): Promise<string> {
const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json');
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
sourceFilePaths: [],
});
function readCurrentVersion(projectType: ProjectType): string {
if (projectType === 'npm' || projectType === 'both') {
const packageJsonPath = plugins.path.join(paths.cwd, 'package.json');
const packageJson = plugins.smartfile.fs.toObjectSync(packageJsonPath) as { version?: string };
try {
// Read deno.json
const denoConfig = plugins.smartfile.fs.toObjectSync(
denoJsonPath
) as { version?: string };
if (!packageJson.version) {
throw new Error('package.json does not contain a version field');
}
return packageJson.version;
} else {
const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json');
const denoConfig = plugins.smartfile.fs.toObjectSync(denoJsonPath) as { version?: string };
if (!denoConfig.version) {
throw new Error('deno.json does not contain a version field');
}
const currentVersion = denoConfig.version;
const newVersion = calculateNewVersion(currentVersion, versionType);
logger.log('info', `Bumping deno.json version: ${currentVersion}${newVersion}`);
// Update version
denoConfig.version = newVersion;
// Write back to disk
await plugins.smartfile.memory.toFs(
JSON.stringify(denoConfig, null, 2) + '\n',
denoJsonPath
);
// Stage the deno.json file
await smartshellInstance.exec('git add deno.json');
// Commit the version bump
await smartshellInstance.exec(`git commit -m "v${newVersion}"`);
// Create the version tag
await smartshellInstance.exec(`git tag v${newVersion} -m "v${newVersion}"`);
logger.log('info', `Created commit and tag v${newVersion}`);
return newVersion;
} catch (error) {
throw new Error(`Failed to bump deno.json version: ${error.message}`);
return denoConfig.version;
}
}
/**
* Bumps the version in package.json using npm version command
* @param versionType Type of version bump
* @returns The new version string
* Updates the version field in a JSON file (package.json or deno.json)
* @param filePath Path to the JSON file
* @param newVersion The new version to write
*/
async function bumpNpmVersion(versionType: VersionType): Promise<string> {
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
sourceFilePaths: [],
});
logger.log('info', `Bumping package.json version using npm version ${versionType}`);
const result = await smartshellInstance.exec(`npm version ${versionType}`);
// npm version returns the new version with a 'v' prefix, e.g., "v1.2.3"
const newVersion = result.stdout.trim().replace(/^v/, '');
return newVersion;
}
/**
* Syncs the version from package.json to deno.json and amends the npm commit
* @param version The version to sync
*/
async function syncVersionToDenoJson(version: string): Promise<void> {
const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json');
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
sourceFilePaths: [],
});
try {
const denoConfig = plugins.smartfile.fs.toObjectSync(
denoJsonPath
) as { version?: string };
logger.log('info', `Syncing version to deno.json: ${version}`);
denoConfig.version = version;
await plugins.smartfile.memory.toFs(
JSON.stringify(denoConfig, null, 2) + '\n',
denoJsonPath
);
// Stage the deno.json file
await smartshellInstance.exec('git add deno.json');
// Amend the npm version commit to include deno.json
await smartshellInstance.exec('git commit --amend --no-edit');
// Re-create the tag with force to update it
await smartshellInstance.exec(`git tag -fa v${version} -m "v${version}"`);
logger.log('info', `Amended commit to include deno.json and updated tag v${version}`);
} catch (error) {
throw new Error(`Failed to sync version to deno.json: ${error.message}`);
}
async function updateVersionFile(filePath: string, newVersion: string): Promise<void> {
const config = plugins.smartfile.fs.toObjectSync(filePath) as { version?: string };
config.version = newVersion;
await plugins.smartfile.memory.toFs(
JSON.stringify(config, null, 2) + '\n',
filePath
);
}
/**
* Bumps the project version based on project type
* Handles npm-only, deno-only, and dual projects with unified logic
* @param projectType The detected project type
* @param versionType The type of version bump
* @param currentStep The current step number for progress display
@@ -215,6 +144,10 @@ export async function bumpProjectVersion(
currentStep?: number,
totalSteps?: number
): Promise<string> {
if (projectType === 'none') {
throw new Error('Cannot bump version: no package.json or deno.json found');
}
const projectEmoji = projectType === 'npm' ? '📦' : projectType === 'deno' ? '🦕' : '🔀';
const description = `🏷️ Bumping version (${projectEmoji} ${projectType})`;
@@ -222,35 +155,52 @@ export async function bumpProjectVersion(
ui.printStep(currentStep, totalSteps, description, 'in-progress');
}
let newVersion: string;
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
sourceFilePaths: [],
});
switch (projectType) {
case 'npm':
newVersion = await bumpNpmVersion(versionType);
break;
try {
// 1. Read current version
const currentVersion = readCurrentVersion(projectType);
case 'deno':
newVersion = await bumpDenoVersion(versionType);
break;
// 2. Calculate new version (reuse existing function!)
const newVersion = calculateNewVersion(currentVersion, versionType);
case 'both': {
// Bump npm version first (it handles git tags)
newVersion = await bumpNpmVersion(versionType);
// Then sync to deno.json
await syncVersionToDenoJson(newVersion);
break;
logger.log('info', `Bumping version: ${currentVersion}${newVersion}`);
// 3. Determine which files to update
const filesToUpdate: string[] = [];
const packageJsonPath = plugins.path.join(paths.cwd, 'package.json');
const denoJsonPath = plugins.path.join(paths.cwd, 'deno.json');
if (projectType === 'npm' || projectType === 'both') {
await updateVersionFile(packageJsonPath, newVersion);
filesToUpdate.push('package.json');
}
case 'none':
throw new Error('Cannot bump version: no package.json or deno.json found');
if (projectType === 'deno' || projectType === 'both') {
await updateVersionFile(denoJsonPath, newVersion);
filesToUpdate.push('deno.json');
}
default:
throw new Error(`Unknown project type: ${projectType}`);
// 4. Stage all updated files
await smartshellInstance.exec(`git add ${filesToUpdate.join(' ')}`);
// 5. Create version commit
await smartshellInstance.exec(`git commit -m "v${newVersion}"`);
// 6. Create version tag
await smartshellInstance.exec(`git tag v${newVersion} -m "v${newVersion}"`);
logger.log('info', `Created commit and tag v${newVersion}`);
if (currentStep && totalSteps) {
ui.printStep(currentStep, totalSteps, description, 'done');
}
return newVersion;
} catch (error) {
throw new Error(`Failed to bump project version: ${error.message}`);
}
if (currentStep && totalSteps) {
ui.printStep(currentStep, totalSteps, description, 'done');
}
return newVersion;
}