@coze-arch/rush-publish-plugin 0.0.5-alpha.e7fa7b → 0.0.5-alpha.f2ff2e
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/command-line.json +8 -0
- package/lib/action/release/plan.d.ts +1 -1
- package/lib/action/release/types.d.ts +1 -0
- package/lib/const/index.d.ts +4 -0
- package/lib/index.js +21 -4
- package/package.json +1 -1
package/command-line.json
CHANGED
|
@@ -159,6 +159,14 @@
|
|
|
159
159
|
"shortName": "-r",
|
|
160
160
|
"description": "NPM registry URL (default: https://registry.npmjs.org)",
|
|
161
161
|
"associatedCommands": ["release", "pub"]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"parameterKind": "stringList",
|
|
165
|
+
"argumentName": "ALLOW_BRANCHES",
|
|
166
|
+
"longName": "--allow-branches",
|
|
167
|
+
"description": "Branches allowed for LATEST release (default: main, feat/auto-publish)",
|
|
168
|
+
"associatedCommands": ["release"],
|
|
169
|
+
"required": false
|
|
162
170
|
}
|
|
163
171
|
]
|
|
164
172
|
}
|
|
@@ -5,4 +5,4 @@ export declare enum ReleaseType {
|
|
|
5
5
|
LATEST = "latest"
|
|
6
6
|
}
|
|
7
7
|
export declare const calReleaseType: (version: string) => ReleaseType;
|
|
8
|
-
export declare const checkReleasePlan: (releaseManifests: ReleaseManifest[], branchName: string) => boolean;
|
|
8
|
+
export declare const checkReleasePlan: (releaseManifests: ReleaseManifest[], branchName: string, allowBranches?: string[]) => boolean;
|
package/lib/const/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -158,6 +158,11 @@ const DEFAULT_NPM_REGISTRY = 'https://registry.npmjs.org';
|
|
|
158
158
|
*/
|
|
159
159
|
const DEFAULT_BRANCH_PREFIX = 'bump';
|
|
160
160
|
|
|
161
|
+
/**
|
|
162
|
+
* 默认允许发布正式版本的分支列表
|
|
163
|
+
*/
|
|
164
|
+
const DEFAULT_ALLOW_BRANCHES = ['main', 'feat/auto-publish'];
|
|
165
|
+
|
|
161
166
|
// Copyright (c) 2025 coze-dev
|
|
162
167
|
// SPDX-License-Identifier: MIT
|
|
163
168
|
|
|
@@ -471,13 +476,16 @@ const calReleasePlan = (releaseManifests) => {
|
|
|
471
476
|
const checkReleasePlan = (
|
|
472
477
|
releaseManifests,
|
|
473
478
|
branchName,
|
|
479
|
+
allowBranches = ['main', 'feat/auto-publish'],
|
|
474
480
|
) => {
|
|
475
481
|
const releasePlan = calReleasePlan(releaseManifests);
|
|
476
482
|
if (
|
|
477
483
|
releasePlan === ReleaseType.LATEST &&
|
|
478
|
-
!
|
|
484
|
+
!allowBranches.includes(branchName)
|
|
479
485
|
) {
|
|
480
|
-
throw new Error(
|
|
486
|
+
throw new Error(
|
|
487
|
+
`For LATEST release, should be on one of these branches: ${allowBranches.join(', ')}. Current Branch: ${branchName}`,
|
|
488
|
+
);
|
|
481
489
|
}
|
|
482
490
|
return true;
|
|
483
491
|
};
|
|
@@ -546,7 +554,12 @@ const getPackagesToPublish = async (
|
|
|
546
554
|
|
|
547
555
|
|
|
548
556
|
async function release(options) {
|
|
549
|
-
const {
|
|
557
|
+
const {
|
|
558
|
+
dryRun = false,
|
|
559
|
+
registry,
|
|
560
|
+
packages,
|
|
561
|
+
allowBranches = DEFAULT_ALLOW_BRANCHES,
|
|
562
|
+
} = options;
|
|
550
563
|
let { commit } = options;
|
|
551
564
|
const hasPassedCommit = !!options.commit;
|
|
552
565
|
|
|
@@ -582,7 +595,7 @@ async function release(options) {
|
|
|
582
595
|
false,
|
|
583
596
|
);
|
|
584
597
|
const branchName = await getCurrentBranchName();
|
|
585
|
-
checkReleasePlan(releaseManifests, branchName);
|
|
598
|
+
checkReleasePlan(releaseManifests, branchName, allowBranches);
|
|
586
599
|
|
|
587
600
|
// 只有在指定了 commit 且与当前 HEAD 不同时才切换
|
|
588
601
|
if (hasPassedCommit) {
|
|
@@ -614,6 +627,10 @@ const installAction$2 = (program) => {
|
|
|
614
627
|
`发布到的 registry (默认: ${DEFAULT_NPM_REGISTRY})`,
|
|
615
628
|
DEFAULT_NPM_REGISTRY,
|
|
616
629
|
)
|
|
630
|
+
.option(
|
|
631
|
+
'--allow-branches <branches...>',
|
|
632
|
+
`允许发布正式版本的分支列表 (默认: ${DEFAULT_ALLOW_BRANCHES.join(', ')})`,
|
|
633
|
+
)
|
|
617
634
|
.action(async (options) => {
|
|
618
635
|
try {
|
|
619
636
|
if (!process.env.NPM_AUTH_TOKEN) {
|