@knowcode/doc-builder 1.5.17 → 1.5.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/publish.sh CHANGED
@@ -72,16 +72,43 @@ echo ""
72
72
 
73
73
  # Check for uncommitted changes
74
74
  print_step "Checking for uncommitted changes..."
75
- if ! git diff-index --quiet HEAD --; then
76
- print_warning "You have uncommitted changes!"
77
- echo ""
78
- git status --short
79
- echo ""
80
- read -p "Do you want to continue anyway? (y/N) " -n 1 -r
81
- echo ""
82
- if [[ ! $REPLY =~ ^[Yy]$ ]]; then
83
- print_info "Publishing cancelled."
84
- exit 1
75
+
76
+ # Count uncommitted changes excluding html directory
77
+ UNCOMMITTED_COUNT=$(git diff-index HEAD -- | grep -v "^:.*html/" | wc -l | xargs)
78
+ HTML_CHANGES=$(git diff-index HEAD -- | grep "^:.*html/" | wc -l | xargs)
79
+
80
+ if [ "$UNCOMMITTED_COUNT" -gt 0 ] || [ "$HTML_CHANGES" -gt 0 ]; then
81
+ if [ "$UNCOMMITTED_COUNT" -gt 0 ]; then
82
+ print_warning "You have uncommitted changes!"
83
+ echo ""
84
+ git status --short | grep -v "^ M html/"
85
+ echo ""
86
+ fi
87
+
88
+ if [ "$HTML_CHANGES" -gt 0 ]; then
89
+ print_info "Generated HTML files have changed (${HTML_CHANGES} files)"
90
+ echo ""
91
+ read -p "Commit generated HTML files? (Y/n) " -n 1 -r
92
+ echo ""
93
+
94
+ if [[ ! $REPLY =~ ^[Nn]$ ]]; then
95
+ print_step "Committing HTML files..."
96
+ git add html/
97
+ git commit -m "chore: update generated HTML files" > /dev/null
98
+ print_success "HTML files committed"
99
+ fi
100
+ fi
101
+
102
+ # Check again for non-HTML changes
103
+ UNCOMMITTED_COUNT=$(git diff-index HEAD -- | grep -v "^:.*html/" | wc -l | xargs)
104
+ if [ "$UNCOMMITTED_COUNT" -gt 0 ]; then
105
+ echo ""
106
+ read -p "Continue with uncommitted changes? (y/N) " -n 1 -r
107
+ echo ""
108
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
109
+ print_info "Publishing cancelled."
110
+ exit 1
111
+ fi
85
112
  fi
86
113
  else
87
114
  print_success "Working directory is clean"
@@ -92,7 +119,6 @@ echo ""
92
119
  print_step "Checking if version ${CURRENT_VERSION} is already published..."
93
120
  if npm view "${PACKAGE_NAME}@${CURRENT_VERSION}" version &> /dev/null; then
94
121
  print_error "Version ${CURRENT_VERSION} is already published!"
95
- print_info "Please update the version in package.json first."
96
122
  echo ""
97
123
 
98
124
  # Show last few published versions
@@ -103,11 +129,84 @@ if npm view "${PACKAGE_NAME}@${CURRENT_VERSION}" version &> /dev/null; then
103
129
  # Suggest next version
104
130
  LATEST_VERSION=$(npm view "${PACKAGE_NAME}" version)
105
131
  print_info "Latest published version: ${LATEST_VERSION}"
132
+
133
+ # Calculate next versions
134
+ PATCH_VERSION=$(npx semver ${LATEST_VERSION} -i patch)
135
+ MINOR_VERSION=$(npx semver ${LATEST_VERSION} -i minor)
136
+ MAJOR_VERSION=$(npx semver ${LATEST_VERSION} -i major)
137
+
106
138
  print_info "Suggested next versions:"
107
- echo " - Patch: $(npx semver ${LATEST_VERSION} -i patch)"
108
- echo " - Minor: $(npx semver ${LATEST_VERSION} -i minor)"
109
- echo " - Major: $(npx semver ${LATEST_VERSION} -i major)"
110
- exit 1
139
+ echo " 1) Patch: ${PATCH_VERSION} (bug fixes)"
140
+ echo " 2) Minor: ${MINOR_VERSION} (new features)"
141
+ echo " 3) Major: ${MAJOR_VERSION} (breaking changes)"
142
+ echo ""
143
+
144
+ # Ask user to choose
145
+ read -p "Would you like to auto-increment the version? (1/2/3/N) " -n 1 -r
146
+ echo ""
147
+
148
+ case $REPLY in
149
+ 1)
150
+ NEW_VERSION=$PATCH_VERSION
151
+ VERSION_TYPE="patch"
152
+ ;;
153
+ 2)
154
+ NEW_VERSION=$MINOR_VERSION
155
+ VERSION_TYPE="minor"
156
+ ;;
157
+ 3)
158
+ NEW_VERSION=$MAJOR_VERSION
159
+ VERSION_TYPE="major"
160
+ ;;
161
+ *)
162
+ print_info "Please update the version in package.json manually."
163
+ exit 1
164
+ ;;
165
+ esac
166
+
167
+ print_step "Updating version to ${NEW_VERSION}..."
168
+
169
+ # Update package.json
170
+ npm version ${VERSION_TYPE} --no-git-tag-version > /dev/null
171
+
172
+ # Update CHANGELOG.md if it exists
173
+ if [ -f "CHANGELOG.md" ]; then
174
+ print_step "Updating CHANGELOG.md..."
175
+
176
+ # Create new changelog entry
177
+ DATE=$(date +%Y-%m-%d)
178
+ NEW_ENTRY="## [${NEW_VERSION}] - ${DATE}\n\n### Changed\n- \n\n"
179
+
180
+ # Insert after the header (assuming standard changelog format)
181
+ sed -i.bak "/^## \[/i\\
182
+ ${NEW_ENTRY}" CHANGELOG.md
183
+ rm CHANGELOG.md.bak
184
+
185
+ print_warning "Please edit CHANGELOG.md to add your changes"
186
+ print_info "Opening CHANGELOG.md in default editor..."
187
+
188
+ # Open in default editor if available
189
+ if command -v code &> /dev/null; then
190
+ code CHANGELOG.md
191
+ elif command -v nano &> /dev/null; then
192
+ nano CHANGELOG.md
193
+ elif command -v vim &> /dev/null; then
194
+ vim CHANGELOG.md
195
+ fi
196
+
197
+ echo ""
198
+ read -p "Press enter when you've updated the CHANGELOG..." -r
199
+ echo ""
200
+ fi
201
+
202
+ # Commit the version bump
203
+ print_step "Committing version bump..."
204
+ git add package.json package-lock.json CHANGELOG.md 2>/dev/null
205
+ git commit -m "chore: bump version to ${NEW_VERSION}" > /dev/null
206
+ print_success "Version bumped to ${NEW_VERSION}"
207
+
208
+ # Update current version for the rest of the script
209
+ CURRENT_VERSION=$NEW_VERSION
111
210
  else
112
211
  print_success "Version ${CURRENT_VERSION} is not yet published"
113
212
  fi
@@ -183,12 +282,31 @@ if npm publish; then
183
282
  echo " npx ${PACKAGE_NAME}@latest"
184
283
  echo ""
185
284
 
186
- # Suggest next steps
285
+ # Automatically create and push git tag
286
+ print_step "Creating git tag v${CURRENT_VERSION}..."
287
+ if git tag "v${CURRENT_VERSION}" 2>/dev/null; then
288
+ print_success "Git tag created"
289
+
290
+ echo ""
291
+ read -p "Push tag to origin? (Y/n) " -n 1 -r
292
+ echo ""
293
+
294
+ if [[ ! $REPLY =~ ^[Nn]$ ]]; then
295
+ print_step "Pushing tag to origin..."
296
+ if git push origin "v${CURRENT_VERSION}"; then
297
+ print_success "Tag pushed successfully"
298
+ else
299
+ print_warning "Failed to push tag. Run manually: git push origin v${CURRENT_VERSION}"
300
+ fi
301
+ fi
302
+ else
303
+ print_warning "Tag v${CURRENT_VERSION} already exists"
304
+ fi
305
+
306
+ echo ""
187
307
  print_info "Next steps:"
188
- echo " 1. Create a git tag: git tag v${CURRENT_VERSION}"
189
- echo " 2. Push the tag: git push origin v${CURRENT_VERSION}"
190
- echo " 3. Create a GitHub release"
191
- echo " 4. Update CHANGELOG.md for the next version"
308
+ echo " 1. Create a GitHub release at: https://github.com/knowcode/doc-builder/releases/new"
309
+ echo " 2. Deploy example site: npx @knowcode/doc-builder@latest deploy"
192
310
  echo ""
193
311
  else
194
312
  echo ""