alemonjs 2.1.91 → 2.1.92
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/bin/publish.js +8 -7
- package/package.json +2 -1
package/bin/publish.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import os from 'os';
|
|
5
|
-
import { execSync
|
|
5
|
+
import { execSync } from 'child_process';
|
|
6
|
+
import spawn from 'cross-spawn';
|
|
6
7
|
|
|
7
8
|
const RELEASE_TYPES = new Set(['patch', 'minor', 'major', 'prepatch', 'preminor', 'premajor', 'prerelease']);
|
|
8
9
|
const PRERELEASE_IDS = new Set(['alpha', 'beta', 'rc', 'next']);
|
|
@@ -24,7 +25,7 @@ function readPackageJson() {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
function runCommand(command, args, options = {}) {
|
|
27
|
-
const result =
|
|
28
|
+
const result = spawn.sync(command, args, {
|
|
28
29
|
cwd: process.cwd(),
|
|
29
30
|
stdio: 'inherit',
|
|
30
31
|
shell: false,
|
|
@@ -49,7 +50,7 @@ function getCommandOutput(command) {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
function hasCommand(command) {
|
|
52
|
-
const result =
|
|
53
|
+
const result = spawn.sync(command, ['--version'], {
|
|
53
54
|
cwd: process.cwd(),
|
|
54
55
|
stdio: 'ignore'
|
|
55
56
|
});
|
|
@@ -293,7 +294,7 @@ function getLatestReleaseVersion() {
|
|
|
293
294
|
}
|
|
294
295
|
|
|
295
296
|
function remoteBranchExists(branch) {
|
|
296
|
-
const result =
|
|
297
|
+
const result = spawn.sync('git', ['ls-remote', '--exit-code', '--heads', 'origin', branch], {
|
|
297
298
|
cwd: process.cwd(),
|
|
298
299
|
stdio: 'ignore'
|
|
299
300
|
});
|
|
@@ -302,7 +303,7 @@ function remoteBranchExists(branch) {
|
|
|
302
303
|
}
|
|
303
304
|
|
|
304
305
|
function localBranchExists(branch) {
|
|
305
|
-
const result =
|
|
306
|
+
const result = spawn.sync('git', ['show-ref', '--verify', '--quiet', `refs/heads/${branch}`], {
|
|
306
307
|
cwd: process.cwd(),
|
|
307
308
|
stdio: 'ignore'
|
|
308
309
|
});
|
|
@@ -330,7 +331,7 @@ function cleanupWorktree(worktreeDir) {
|
|
|
330
331
|
return;
|
|
331
332
|
}
|
|
332
333
|
|
|
333
|
-
|
|
334
|
+
spawn.sync('git', ['worktree', 'remove', '--force', worktreeDir], {
|
|
334
335
|
cwd: process.cwd(),
|
|
335
336
|
stdio: 'ignore'
|
|
336
337
|
});
|
|
@@ -428,7 +429,7 @@ export async function publish(release, options = {}) {
|
|
|
428
429
|
copyDirContents(publishDir, worktreeDir);
|
|
429
430
|
|
|
430
431
|
runCommand('git', ['-C', worktreeDir, 'add', '-A']);
|
|
431
|
-
const hasChanges =
|
|
432
|
+
const hasChanges = spawn.sync('git', ['-C', worktreeDir, 'diff', '--cached', '--quiet']).status !== 0;
|
|
432
433
|
if (!hasChanges) {
|
|
433
434
|
console.log('release 分支无文件变化,跳过提交');
|
|
434
435
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alemonjs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.92",
|
|
4
4
|
"description": "bot script",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"chalk": "^5.6.2",
|
|
53
53
|
"commander": "^13.1.0",
|
|
54
54
|
"cron": "^4.4.0",
|
|
55
|
+
"cross-spawn": "^7.0.6",
|
|
55
56
|
"file-type": "21.0.0",
|
|
56
57
|
"flatted": "^3.3.3",
|
|
57
58
|
"koa": "^3.0.1",
|