@itcase/config 1.6.79 → 1.6.80
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/package.json +1 -1
- package/smart-commit/cli.js +20 -2
package/package.json
CHANGED
package/smart-commit/cli.js
CHANGED
|
@@ -142,14 +142,25 @@ async function main(argv) {
|
|
|
142
142
|
|
|
143
143
|
ensureGitIndexReady(cwd)
|
|
144
144
|
|
|
145
|
+
const total = activePlans.length
|
|
146
|
+
process.stdout.write(`Creating ${total} commit(s)…\n`)
|
|
147
|
+
|
|
145
148
|
let created = 0
|
|
146
|
-
for (
|
|
149
|
+
for (let index = 0; index < total; index++) {
|
|
150
|
+
const plan = activePlans[index]
|
|
151
|
+
const step = `[${index + 1}/${total}]`
|
|
147
152
|
const planFiles = plan.files.filter((file) => fileHasChanges(cwd, file))
|
|
148
153
|
if (!planFiles.length) {
|
|
149
|
-
process.stdout.write(
|
|
154
|
+
process.stdout.write(`${step} skip empty: ${plan.message}\n`)
|
|
150
155
|
continue
|
|
151
156
|
}
|
|
152
157
|
|
|
158
|
+
const startedAt = Date.now()
|
|
159
|
+
const fileLabel =
|
|
160
|
+
planFiles.length === 1 ? '1 file' : `${planFiles.length} files`
|
|
161
|
+
process.stdout.write(`${step} ${plan.message}\n`)
|
|
162
|
+
process.stdout.write(` staging ${fileLabel}…\n`)
|
|
163
|
+
|
|
153
164
|
// Drop leftover index entries so only this plan's files are committed.
|
|
154
165
|
git(cwd, ['reset', '-q', 'HEAD'])
|
|
155
166
|
stageFiles(cwd, planFiles)
|
|
@@ -162,6 +173,7 @@ async function main(argv) {
|
|
|
162
173
|
)
|
|
163
174
|
}
|
|
164
175
|
|
|
176
|
+
process.stdout.write(' git commit (husky)…\n')
|
|
165
177
|
try {
|
|
166
178
|
git(cwd, ['commit', '-m', plan.message], { inherit: true })
|
|
167
179
|
} catch (error) {
|
|
@@ -170,6 +182,7 @@ async function main(argv) {
|
|
|
170
182
|
})
|
|
171
183
|
}
|
|
172
184
|
created++
|
|
185
|
+
process.stdout.write(` done (${formatElapsed(startedAt)})\n`)
|
|
173
186
|
}
|
|
174
187
|
process.stdout.write(`Created ${created} commit(s).\n`)
|
|
175
188
|
|
|
@@ -887,6 +900,11 @@ function sleepSync(ms) {
|
|
|
887
900
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms)
|
|
888
901
|
}
|
|
889
902
|
|
|
903
|
+
function formatElapsed(startedAt) {
|
|
904
|
+
const elapsed = Math.max(0, Math.floor((Date.now() - startedAt) / 1000))
|
|
905
|
+
return `${elapsed}s`
|
|
906
|
+
}
|
|
907
|
+
|
|
890
908
|
function indexLockPath(cwd) {
|
|
891
909
|
const result = spawnSync('git', ['rev-parse', '--git-path', 'index.lock'], {
|
|
892
910
|
cwd: cwd,
|