@coze-arch/rush-publish-plugin 0.0.4 → 0.0.5-alpha.0f1107
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 +11 -3
- package/lib/action/publish/packages.d.ts +1 -1
- package/lib/action/publish/version.d.ts +1 -1
- package/lib/index.js +296 -42
- package/lib/utils/ci.d.ts +86 -0
- package/package.json +6 -10
package/command-line.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"required": false
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
"parameterKind": "
|
|
37
|
+
"parameterKind": "stringList",
|
|
38
38
|
"shortName": "-t",
|
|
39
39
|
"longName": "--to",
|
|
40
40
|
"description": "Publish specified packages and their downstream dependencies",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"required": false
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
|
-
"parameterKind": "
|
|
46
|
+
"parameterKind": "stringList",
|
|
47
47
|
"shortName": "-f",
|
|
48
48
|
"longName": "--from",
|
|
49
49
|
"description": "Publish specified packages and their upstream/downstream dependencies",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"required": false
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
|
-
"parameterKind": "
|
|
55
|
+
"parameterKind": "stringList",
|
|
56
56
|
"shortName": "-o",
|
|
57
57
|
"longName": "--only",
|
|
58
58
|
"description": "Only publish specified packages",
|
|
@@ -135,6 +135,14 @@
|
|
|
135
135
|
"shortName": "-c",
|
|
136
136
|
"description": "Git commit hash",
|
|
137
137
|
"associatedCommands": ["release"]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"parameterKind": "string",
|
|
141
|
+
"argumentName": "REGISTRY",
|
|
142
|
+
"longName": "--registry",
|
|
143
|
+
"shortName": "-r",
|
|
144
|
+
"description": "Registry",
|
|
145
|
+
"associatedCommands": ["release"]
|
|
138
146
|
}
|
|
139
147
|
]
|
|
140
148
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type RushConfigurationProject } from '@rushstack/rush-sdk';
|
|
2
2
|
import { type PublishOptions } from './types';
|
|
3
|
-
export declare const validateAndGetPackages: (options: PublishOptions) =>
|
|
3
|
+
export declare const validateAndGetPackages: (options: PublishOptions) => RushConfigurationProject[];
|
|
@@ -9,7 +9,7 @@ interface VersionOptions {
|
|
|
9
9
|
/**
|
|
10
10
|
* 生成发布清单
|
|
11
11
|
*/
|
|
12
|
-
export declare const generatePublishManifest: (packages:
|
|
12
|
+
export declare const generatePublishManifest: (packages: RushConfigurationProject[], options: VersionOptions) => Promise<{
|
|
13
13
|
manifests: PublishManifest[];
|
|
14
14
|
bumpPolicy: BumpType | string | undefined;
|
|
15
15
|
}>;
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,9 @@ var prompts = require('@inquirer/prompts');
|
|
|
13
13
|
var dayjs = require('dayjs');
|
|
14
14
|
var ChangeFile = require('@rushstack/rush-sdk/lib/api/ChangeFile');
|
|
15
15
|
|
|
16
|
+
// Copyright (c) 2025 coze-dev
|
|
17
|
+
// SPDX-License-Identifier: MIT
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* 日志工具
|
|
18
21
|
*
|
|
@@ -142,6 +145,16 @@ const logger = {
|
|
|
142
145
|
},
|
|
143
146
|
};
|
|
144
147
|
|
|
148
|
+
// Copyright (c) 2025 coze-dev
|
|
149
|
+
// SPDX-License-Identifier: MIT
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
145
158
|
class ExecError extends Error {
|
|
146
159
|
|
|
147
160
|
|
|
@@ -168,6 +181,10 @@ const exec = (
|
|
|
168
181
|
});
|
|
169
182
|
});
|
|
170
183
|
|
|
184
|
+
// Copyright (c) 2025 coze-dev
|
|
185
|
+
// SPDX-License-Identifier: MIT
|
|
186
|
+
|
|
187
|
+
|
|
171
188
|
const serializeFilesName = (output) =>
|
|
172
189
|
output
|
|
173
190
|
.split('\n')
|
|
@@ -238,6 +255,10 @@ const getCurrentOrigin = async (
|
|
|
238
255
|
}
|
|
239
256
|
};
|
|
240
257
|
|
|
258
|
+
// Copyright (c) 2025 coze-dev
|
|
259
|
+
// SPDX-License-Identifier: MIT
|
|
260
|
+
|
|
261
|
+
|
|
241
262
|
const readJsonFile = async ( path) => {
|
|
242
263
|
const content = await fs.readFile(path, 'utf8');
|
|
243
264
|
return JSON.parse(content) ;
|
|
@@ -259,7 +280,11 @@ const isDirExists = async (path) =>
|
|
|
259
280
|
.then(() => true)
|
|
260
281
|
.catch(() => false);
|
|
261
282
|
|
|
262
|
-
|
|
283
|
+
// Copyright (c) 2025 coze-dev
|
|
284
|
+
// SPDX-License-Identifier: MIT
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
const getRushConfiguration$1 = (() => {
|
|
263
288
|
let rushConfiguration = null;
|
|
264
289
|
return (useCache = true) => {
|
|
265
290
|
if (!useCache) {
|
|
@@ -271,19 +296,32 @@ const getRushConfiguration = (() => {
|
|
|
271
296
|
};
|
|
272
297
|
})();
|
|
273
298
|
|
|
299
|
+
// Copyright (c) 2025 coze-dev
|
|
300
|
+
// SPDX-License-Identifier: MIT
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
274
310
|
/**
|
|
275
311
|
* 更新依赖版本
|
|
276
312
|
*/
|
|
277
313
|
const updateDependencyVersions = async (
|
|
278
314
|
packageJson,
|
|
279
315
|
) => {
|
|
280
|
-
const rushConfiguration = getRushConfiguration();
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
316
|
+
const rushConfiguration = getRushConfiguration$1();
|
|
317
|
+
const depTypes = ['dependencies', 'peerDependencies'];
|
|
318
|
+
for (const depType of depTypes) {
|
|
319
|
+
if (packageJson[depType]) {
|
|
320
|
+
for (const [dep, ver] of Object.entries(packageJson[depType])) {
|
|
321
|
+
const project = rushConfiguration.getProjectByName(dep);
|
|
322
|
+
if (/^workspace:/.test(ver) && project) {
|
|
323
|
+
packageJson[depType][dep] = project.packageJson.version;
|
|
324
|
+
}
|
|
287
325
|
}
|
|
288
326
|
}
|
|
289
327
|
}
|
|
@@ -417,22 +455,37 @@ const checkReleasePlan = (
|
|
|
417
455
|
return true;
|
|
418
456
|
};
|
|
419
457
|
|
|
458
|
+
// Copyright (c) 2025 coze-dev
|
|
459
|
+
// SPDX-License-Identifier: MIT
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
420
463
|
/**
|
|
421
464
|
* 构建发布依赖树
|
|
422
465
|
*/
|
|
423
466
|
function buildReleaseManifest(
|
|
424
467
|
packages,
|
|
425
468
|
) {
|
|
426
|
-
const rushConfiguration = getRushConfiguration();
|
|
427
|
-
return packages
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
469
|
+
const rushConfiguration = getRushConfiguration$1();
|
|
470
|
+
return packages
|
|
471
|
+
.map(pkg => {
|
|
472
|
+
const project = rushConfiguration.getProjectByName(pkg.packageName);
|
|
473
|
+
if (!project) {
|
|
474
|
+
throw new Error(`Cannot find project: ${pkg.packageName}`);
|
|
475
|
+
}
|
|
476
|
+
if (project.shouldPublish) {
|
|
477
|
+
return { project, version: project.packageJson.version };
|
|
478
|
+
}
|
|
479
|
+
return undefined;
|
|
480
|
+
})
|
|
481
|
+
.filter(Boolean) ;
|
|
434
482
|
}
|
|
435
483
|
|
|
484
|
+
// Copyright (c) 2025 coze-dev
|
|
485
|
+
// SPDX-License-Identifier: MIT
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
436
489
|
/**
|
|
437
490
|
* 从 git tag 中解析需要发布的包信息
|
|
438
491
|
*/
|
|
@@ -461,6 +514,10 @@ const getPackagesToPublish = async (
|
|
|
461
514
|
return packages;
|
|
462
515
|
};
|
|
463
516
|
|
|
517
|
+
// Copyright (c) 2025 coze-dev
|
|
518
|
+
// SPDX-License-Identifier: MIT
|
|
519
|
+
|
|
520
|
+
|
|
464
521
|
async function release(options) {
|
|
465
522
|
const { commit, dryRun = false, registry } = options;
|
|
466
523
|
|
|
@@ -522,7 +579,14 @@ const installAction$2 = (program) => {
|
|
|
522
579
|
});
|
|
523
580
|
};
|
|
524
581
|
|
|
525
|
-
|
|
582
|
+
// Copyright (c) 2025 coze-dev
|
|
583
|
+
// SPDX-License-Identifier: MIT
|
|
584
|
+
|
|
585
|
+
const GIT_REPO_URL_REGEX = /git@.+:([^\/]+)\/([^\.]+)\.git/;
|
|
586
|
+
|
|
587
|
+
// Copyright (c) 2025 coze-dev
|
|
588
|
+
// SPDX-License-Identifier: MIT
|
|
589
|
+
|
|
526
590
|
|
|
527
591
|
/**
|
|
528
592
|
* 生成指定长度的随机字符串(使用 crypto 模块)
|
|
@@ -544,6 +608,10 @@ var BumpType; (function (BumpType) {
|
|
|
544
608
|
const MAJOR = 'major'; BumpType["MAJOR"] = MAJOR;
|
|
545
609
|
})(BumpType || (BumpType = {}));
|
|
546
610
|
|
|
611
|
+
// Copyright (c) 2025 coze-dev
|
|
612
|
+
// SPDX-License-Identifier: MIT
|
|
613
|
+
|
|
614
|
+
|
|
547
615
|
/**
|
|
548
616
|
* 获取更新类型的描述
|
|
549
617
|
*/
|
|
@@ -592,6 +660,16 @@ const requestBumpType = async () => {
|
|
|
592
660
|
}
|
|
593
661
|
};
|
|
594
662
|
|
|
663
|
+
// Copyright (c) 2025 coze-dev
|
|
664
|
+
// SPDX-License-Identifier: MIT
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
|
|
595
673
|
/**
|
|
596
674
|
* 根据当前版本和发布类型计算新版本号
|
|
597
675
|
*/
|
|
@@ -718,6 +796,18 @@ const generatePublishManifest = async (
|
|
|
718
796
|
};
|
|
719
797
|
};
|
|
720
798
|
|
|
799
|
+
// Copyright (c) 2025 coze-dev
|
|
800
|
+
// SPDX-License-Identifier: MIT
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
|
|
721
811
|
async function commitChanges({
|
|
722
812
|
sessionId,
|
|
723
813
|
files,
|
|
@@ -754,6 +844,21 @@ async function push({ refs, cwd, repoUrl }) {
|
|
|
754
844
|
});
|
|
755
845
|
}
|
|
756
846
|
|
|
847
|
+
// Copyright (c) 2025 coze-dev
|
|
848
|
+
// SPDX-License-Identifier: MIT
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
|
|
757
862
|
const pushToRemote = async (options) => {
|
|
758
863
|
const {
|
|
759
864
|
sessionId,
|
|
@@ -830,9 +935,109 @@ const pushToRemote = async (options) => {
|
|
|
830
935
|
}
|
|
831
936
|
};
|
|
832
937
|
|
|
938
|
+
// Copyright (c) 2025 coze-dev
|
|
939
|
+
// SPDX-License-Identifier: MIT
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
const getRushConfiguration = (() => {
|
|
943
|
+
const cachedRushConfigs = new Map();
|
|
944
|
+
return (startingFolder) => {
|
|
945
|
+
startingFolder = startingFolder || process.cwd();
|
|
946
|
+
const possibleRushFile = rushSdk.RushConfiguration.tryFindRushJsonLocation({
|
|
947
|
+
startingFolder,
|
|
948
|
+
});
|
|
949
|
+
if (!possibleRushFile) {
|
|
950
|
+
throw new Error(
|
|
951
|
+
`rush.json not found from starting folder: ${startingFolder}`,
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
if (cachedRushConfigs.has(possibleRushFile)) {
|
|
955
|
+
return cachedRushConfigs.get(possibleRushFile) ;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
const rushConfig =
|
|
959
|
+
rushSdk.RushConfiguration.loadFromConfigurationFile(possibleRushFile);
|
|
960
|
+
cachedRushConfigs.set(startingFolder, rushConfig);
|
|
961
|
+
return rushConfig;
|
|
962
|
+
};
|
|
963
|
+
})();
|
|
964
|
+
|
|
965
|
+
const lookupTo = (to) => {
|
|
966
|
+
const cached = new Map();
|
|
967
|
+
const config = getRushConfiguration();
|
|
968
|
+
const core = (pkgName) => {
|
|
969
|
+
if (cached.has(pkgName)) {
|
|
970
|
+
return cached.get(pkgName);
|
|
971
|
+
}
|
|
972
|
+
const result = [pkgName];
|
|
973
|
+
cached.set(pkgName, result);
|
|
974
|
+
const projects = config.projects.filter(p => p.packageName === pkgName);
|
|
975
|
+
if (projects.length === 0) {
|
|
976
|
+
throw new Error(`Project ${pkgName} not found`);
|
|
977
|
+
}
|
|
978
|
+
const project = projects[0];
|
|
979
|
+
const deps = Array.from(project.dependencyProjects.values()).map(
|
|
980
|
+
p => p.packageName,
|
|
981
|
+
);
|
|
982
|
+
result.push(...deps);
|
|
983
|
+
deps.forEach(dep => {
|
|
984
|
+
const subPkgs = core(dep);
|
|
985
|
+
if (subPkgs) {
|
|
986
|
+
result.push(...subPkgs);
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
return result;
|
|
990
|
+
};
|
|
991
|
+
const result = core(to);
|
|
992
|
+
return [...new Set(result)];
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
const lookupFrom = (from) => {
|
|
996
|
+
const cached = new Map();
|
|
997
|
+
const config = getRushConfiguration();
|
|
998
|
+
const core = (pkgName) => {
|
|
999
|
+
if (cached.has(pkgName)) {
|
|
1000
|
+
return cached.get(pkgName);
|
|
1001
|
+
}
|
|
1002
|
+
const result = new Set();
|
|
1003
|
+
cached.set(pkgName, result);
|
|
1004
|
+
const projects = config.projects.filter(p => p.packageName === pkgName);
|
|
1005
|
+
if (projects.length === 0) {
|
|
1006
|
+
throw new Error(`Project ${pkgName} not found`);
|
|
1007
|
+
}
|
|
1008
|
+
const project = projects[0];
|
|
1009
|
+
const deps = Array.from([
|
|
1010
|
+
...project.dependencyProjects.values(),
|
|
1011
|
+
...project.consumingProjects.values(),
|
|
1012
|
+
]).map(p => p.packageName);
|
|
1013
|
+
deps.forEach(dep => {
|
|
1014
|
+
result.add(dep);
|
|
1015
|
+
const subPkgs = cached.has(dep) ? cached.get(dep) : core(dep);
|
|
1016
|
+
if (subPkgs) {
|
|
1017
|
+
subPkgs.forEach(p => {
|
|
1018
|
+
result.add(p);
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
1022
|
+
return result;
|
|
1023
|
+
};
|
|
1024
|
+
const result = core(from);
|
|
1025
|
+
return [...new Set(result)];
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
const lookupOnly = (packageName) => {
|
|
1029
|
+
const config = getRushConfiguration();
|
|
1030
|
+
const projects = config.projects.filter(p => p.packageName === packageName);
|
|
1031
|
+
if (projects.length === 0) {
|
|
1032
|
+
throw new Error(`Project ${packageName} not found`);
|
|
1033
|
+
}
|
|
1034
|
+
return projects[0];
|
|
1035
|
+
};
|
|
1036
|
+
|
|
833
1037
|
function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
834
1038
|
|
|
835
1039
|
|
|
1040
|
+
|
|
836
1041
|
var RetrievePattern; (function (RetrievePattern) {
|
|
837
1042
|
const TO = 'to'; RetrievePattern["TO"] = TO;
|
|
838
1043
|
const FROM = 'from'; RetrievePattern["FROM"] = FROM;
|
|
@@ -843,10 +1048,9 @@ const retrievePackages = (
|
|
|
843
1048
|
pattern,
|
|
844
1049
|
packages,
|
|
845
1050
|
) => {
|
|
846
|
-
const rushConfiguration = getRushConfiguration();
|
|
847
1051
|
const matchedPackages = new Set();
|
|
848
1052
|
packages.forEach(pkg => {
|
|
849
|
-
const project =
|
|
1053
|
+
const project = lookupOnly(pkg);
|
|
850
1054
|
if (!project) {
|
|
851
1055
|
throw new Error(`Package "${pkg}" not found in rush configuration`);
|
|
852
1056
|
}
|
|
@@ -858,16 +1062,15 @@ const retrievePackages = (
|
|
|
858
1062
|
const matched = [];
|
|
859
1063
|
switch (pattern) {
|
|
860
1064
|
case 'to': {
|
|
861
|
-
matched.push(
|
|
1065
|
+
matched.push(...lookupTo(pkg));
|
|
862
1066
|
break;
|
|
863
1067
|
}
|
|
864
1068
|
case 'from': {
|
|
865
|
-
matched.push(
|
|
866
|
-
matched.push(project.dependencyProjects);
|
|
1069
|
+
matched.push(...lookupFrom(pkg));
|
|
867
1070
|
break;
|
|
868
1071
|
}
|
|
869
1072
|
case 'only': {
|
|
870
|
-
|
|
1073
|
+
matched.push(pkg);
|
|
871
1074
|
break;
|
|
872
1075
|
}
|
|
873
1076
|
default: {
|
|
@@ -875,16 +1078,12 @@ const retrievePackages = (
|
|
|
875
1078
|
}
|
|
876
1079
|
}
|
|
877
1080
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
matchedPackages.add(p);
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
matchedPackages.add(project);
|
|
1081
|
+
matched.forEach(pkgName => {
|
|
1082
|
+
matchedPackages.add(pkgName);
|
|
1083
|
+
});
|
|
886
1084
|
});
|
|
887
|
-
|
|
1085
|
+
|
|
1086
|
+
return [...matchedPackages];
|
|
888
1087
|
};
|
|
889
1088
|
|
|
890
1089
|
const validateAndGetPackages = (options) => {
|
|
@@ -892,16 +1091,35 @@ const validateAndGetPackages = (options) => {
|
|
|
892
1091
|
if (retrievePatterns.every(pattern => (_optionalChain$1([options, 'access', _ => _[pattern], 'optionalAccess', _2 => _2.length]) || 0) <= 0)) {
|
|
893
1092
|
throw new Error('No packages to publish');
|
|
894
1093
|
}
|
|
895
|
-
|
|
1094
|
+
const res = retrievePatterns.reduce((acc, pattern) => {
|
|
896
1095
|
const packages = options[pattern];
|
|
897
1096
|
if (!packages || packages.length <= 0) {
|
|
898
1097
|
return acc;
|
|
899
1098
|
}
|
|
900
1099
|
const placeholders = retrievePackages(pattern , packages);
|
|
901
|
-
|
|
1100
|
+
placeholders.forEach(pkgName => {
|
|
1101
|
+
acc.add(pkgName);
|
|
1102
|
+
});
|
|
1103
|
+
return acc;
|
|
902
1104
|
}, new Set());
|
|
1105
|
+
const result = [...res]
|
|
1106
|
+
.map(pkgName => {
|
|
1107
|
+
const p = lookupOnly(pkgName);
|
|
1108
|
+
if (p && p.shouldPublish) {
|
|
1109
|
+
return p;
|
|
1110
|
+
}
|
|
1111
|
+
return undefined;
|
|
1112
|
+
})
|
|
1113
|
+
.filter(Boolean) ;
|
|
1114
|
+
return result;
|
|
903
1115
|
};
|
|
904
1116
|
|
|
1117
|
+
// Copyright (c) 2025 coze-dev
|
|
1118
|
+
// SPDX-License-Identifier: MIT
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
905
1123
|
const confirmForPublish = async (
|
|
906
1124
|
publishManifest,
|
|
907
1125
|
dryRun,
|
|
@@ -927,7 +1145,8 @@ const confirmForPublish = async (
|
|
|
927
1145
|
}
|
|
928
1146
|
};
|
|
929
1147
|
|
|
930
|
-
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1148
|
+
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// Copyright (c) 2025 coze-dev
|
|
1149
|
+
|
|
931
1150
|
|
|
932
1151
|
|
|
933
1152
|
|
|
@@ -1132,6 +1351,11 @@ const generateChangelog$1 = ({
|
|
|
1132
1351
|
};
|
|
1133
1352
|
};
|
|
1134
1353
|
|
|
1354
|
+
// Copyright (c) 2025 coze-dev
|
|
1355
|
+
// SPDX-License-Identifier: MIT
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1135
1359
|
const deleteFiles = async (files) => {
|
|
1136
1360
|
await Promise.all(
|
|
1137
1361
|
files.map(async file => {
|
|
@@ -1187,7 +1411,7 @@ const readPreviousChangelog = async (
|
|
|
1187
1411
|
|
|
1188
1412
|
const generateChangelogForProject = async (manifest) => {
|
|
1189
1413
|
const { project, newVersion } = manifest;
|
|
1190
|
-
const rushConfiguration = getRushConfiguration();
|
|
1414
|
+
const rushConfiguration = getRushConfiguration$1();
|
|
1191
1415
|
const { changesFolder } = rushConfiguration;
|
|
1192
1416
|
const changedFolderOfPkg = path.resolve(changesFolder, project.packageName);
|
|
1193
1417
|
const changelogJsonPath = path.resolve(
|
|
@@ -1229,6 +1453,12 @@ const generateChangelog = async (
|
|
|
1229
1453
|
return modifiedFiles.flat();
|
|
1230
1454
|
};
|
|
1231
1455
|
|
|
1456
|
+
// Copyright (c) 2025 coze-dev
|
|
1457
|
+
// SPDX-License-Identifier: MIT
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
|
|
1461
|
+
|
|
1232
1462
|
const updatePackageVersion = async (
|
|
1233
1463
|
project,
|
|
1234
1464
|
newVersion,
|
|
@@ -1257,6 +1487,10 @@ const applyPublishManifest = async (
|
|
|
1257
1487
|
return modifiedFiles;
|
|
1258
1488
|
};
|
|
1259
1489
|
|
|
1490
|
+
// Copyright (c) 2025 coze-dev
|
|
1491
|
+
// SPDX-License-Identifier: MIT
|
|
1492
|
+
|
|
1493
|
+
|
|
1260
1494
|
// 针对不同类型的发布,对应不同 sideEffects:
|
|
1261
1495
|
// 1. alpha: 直接创建并push 分支,触发 CI,执行发布;
|
|
1262
1496
|
// 2. beta: 本分支直接切换版本号,并发布
|
|
@@ -1264,7 +1498,7 @@ const applyPublishManifest = async (
|
|
|
1264
1498
|
|
|
1265
1499
|
const publish = async (options) => {
|
|
1266
1500
|
const sessionId = randomHash(6);
|
|
1267
|
-
const rushConfiguration = getRushConfiguration();
|
|
1501
|
+
const rushConfiguration = getRushConfiguration$1();
|
|
1268
1502
|
const rushFolder = rushConfiguration.rushJsonFolder;
|
|
1269
1503
|
if (process.env.SKIP_UNCOMMITTED_CHECK !== 'true') {
|
|
1270
1504
|
await ensureNotUncommittedChanges();
|
|
@@ -1272,7 +1506,7 @@ const publish = async (options) => {
|
|
|
1272
1506
|
|
|
1273
1507
|
// 1. 验证并获取需要发布的包列表
|
|
1274
1508
|
const packagesToPublish = validateAndGetPackages(options);
|
|
1275
|
-
if (packagesToPublish.
|
|
1509
|
+
if (packagesToPublish.length === 0) {
|
|
1276
1510
|
logger.error(
|
|
1277
1511
|
'No packages to publish, should specify some package by `--to` or `--from` or `--only`',
|
|
1278
1512
|
);
|
|
@@ -1381,6 +1615,10 @@ const installAction$1 = (program) => {
|
|
|
1381
1615
|
});
|
|
1382
1616
|
};
|
|
1383
1617
|
|
|
1618
|
+
// Copyright (c) 2025 coze-dev
|
|
1619
|
+
// SPDX-License-Identifier: MIT
|
|
1620
|
+
|
|
1621
|
+
|
|
1384
1622
|
const whoAmI = async () => {
|
|
1385
1623
|
const [name, email] = await Promise.all([
|
|
1386
1624
|
exec('git config user.name', { cwd: __dirname, silent: true }),
|
|
@@ -1392,6 +1630,10 @@ const whoAmI = async () => {
|
|
|
1392
1630
|
};
|
|
1393
1631
|
};
|
|
1394
1632
|
|
|
1633
|
+
// Copyright (c) 2025 coze-dev
|
|
1634
|
+
// SPDX-License-Identifier: MIT
|
|
1635
|
+
|
|
1636
|
+
|
|
1395
1637
|
// 这两个包没有 module 导出
|
|
1396
1638
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1397
1639
|
const { sync } = require('conventional-commits-parser');
|
|
@@ -1408,7 +1650,7 @@ const collectShouldUpdateChangesProjects = async (
|
|
|
1408
1650
|
|
|
1409
1651
|
) => {
|
|
1410
1652
|
const changedFiles = await getChangedFilesFromCached();
|
|
1411
|
-
const rushConfiguration = getRushConfiguration();
|
|
1653
|
+
const rushConfiguration = getRushConfiguration$1();
|
|
1412
1654
|
const lookup = rushConfiguration.getProjectLookupForRoot(
|
|
1413
1655
|
rushConfiguration.rushJsonFolder,
|
|
1414
1656
|
);
|
|
@@ -1520,7 +1762,7 @@ async function generateAllChangesFile(
|
|
|
1520
1762
|
comment,
|
|
1521
1763
|
patchType,
|
|
1522
1764
|
) {
|
|
1523
|
-
const rushConfiguration = getRushConfiguration();
|
|
1765
|
+
const rushConfiguration = getRushConfiguration$1();
|
|
1524
1766
|
const needUpdateProjects = await collectShouldUpdateChangesProjects();
|
|
1525
1767
|
const { email } = await whoAmI();
|
|
1526
1768
|
|
|
@@ -1544,9 +1786,13 @@ async function generateAllChangesFile(
|
|
|
1544
1786
|
}
|
|
1545
1787
|
}
|
|
1546
1788
|
|
|
1789
|
+
// Copyright (c) 2025 coze-dev
|
|
1790
|
+
// SPDX-License-Identifier: MIT
|
|
1791
|
+
|
|
1792
|
+
|
|
1547
1793
|
const amendCommit = async () => {
|
|
1548
1794
|
const changedFiles = await getChangedFilesFromCached();
|
|
1549
|
-
const rushConfiguration = getRushConfiguration();
|
|
1795
|
+
const rushConfiguration = getRushConfiguration$1();
|
|
1550
1796
|
|
|
1551
1797
|
const relativeChangesFolder = path.relative(
|
|
1552
1798
|
rushConfiguration.rushJsonFolder,
|
|
@@ -1561,6 +1807,10 @@ const amendCommit = async () => {
|
|
|
1561
1807
|
}
|
|
1562
1808
|
};
|
|
1563
1809
|
|
|
1810
|
+
// Copyright (c) 2025 coze-dev
|
|
1811
|
+
// SPDX-License-Identifier: MIT
|
|
1812
|
+
|
|
1813
|
+
|
|
1564
1814
|
const generateChangeFiles = async (options) => {
|
|
1565
1815
|
// CI 环境的提交不做处理
|
|
1566
1816
|
if (options.ci || process.env.CI === 'true') {
|
|
@@ -1573,7 +1823,7 @@ const generateChangeFiles = async (options) => {
|
|
|
1573
1823
|
try {
|
|
1574
1824
|
let { commitMsg } = options;
|
|
1575
1825
|
if (!commitMsg) {
|
|
1576
|
-
const rushConfiguration = getRushConfiguration();
|
|
1826
|
+
const rushConfiguration = getRushConfiguration$1();
|
|
1577
1827
|
commitMsg = await fs.readFile(
|
|
1578
1828
|
path.resolve(rushConfiguration.rushJsonFolder, '.git/COMMIT_EDITMSG'),
|
|
1579
1829
|
'utf-8',
|
|
@@ -1606,6 +1856,10 @@ const installAction = (program) => {
|
|
|
1606
1856
|
});
|
|
1607
1857
|
};
|
|
1608
1858
|
|
|
1859
|
+
// Copyright (c) 2025 coze-dev
|
|
1860
|
+
// SPDX-License-Identifier: MIT
|
|
1861
|
+
|
|
1862
|
+
|
|
1609
1863
|
const main = () => {
|
|
1610
1864
|
const packageJson = JSON.parse(
|
|
1611
1865
|
fs$1.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8'),
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CI 环境检测工具
|
|
3
|
+
*/
|
|
4
|
+
export declare const ciEnvironment: {
|
|
5
|
+
/**
|
|
6
|
+
* 检查是否在 GitHub Actions 环境中
|
|
7
|
+
*/
|
|
8
|
+
isGitHubActions(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 检查是否在任何 CI 环境中
|
|
11
|
+
*/
|
|
12
|
+
isCI(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* 获取 GitHub 仓库信息
|
|
15
|
+
*/
|
|
16
|
+
getRepository(): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* 获取当前工作流名称
|
|
19
|
+
*/
|
|
20
|
+
getWorkflow(): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* 获取运行 ID
|
|
23
|
+
*/
|
|
24
|
+
getRunId(): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* 获取当前分支名
|
|
27
|
+
*/
|
|
28
|
+
getBranch(): string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* 检查是否是 Pull Request 事件
|
|
31
|
+
*/
|
|
32
|
+
isPullRequest(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 检查是否是 Push 事件
|
|
35
|
+
*/
|
|
36
|
+
isPush(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 获取触发用户
|
|
39
|
+
*/
|
|
40
|
+
getActor(): string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* 获取提交 SHA
|
|
43
|
+
*/
|
|
44
|
+
getCommitSha(): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* 获取运行器操作系统
|
|
47
|
+
*/
|
|
48
|
+
getRunnerOS(): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* 获取完整的环境信息
|
|
51
|
+
*/
|
|
52
|
+
getEnvironmentInfo(): {
|
|
53
|
+
name: string;
|
|
54
|
+
isCI: boolean;
|
|
55
|
+
isGitHubActions: boolean;
|
|
56
|
+
repository?: undefined;
|
|
57
|
+
workflow?: undefined;
|
|
58
|
+
runId?: undefined;
|
|
59
|
+
branch?: undefined;
|
|
60
|
+
actor?: undefined;
|
|
61
|
+
commitSha?: undefined;
|
|
62
|
+
runnerOS?: undefined;
|
|
63
|
+
eventName?: undefined;
|
|
64
|
+
isPullRequest?: undefined;
|
|
65
|
+
isPush?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
name: string;
|
|
68
|
+
isCI: boolean;
|
|
69
|
+
isGitHubActions: boolean;
|
|
70
|
+
repository: string | undefined;
|
|
71
|
+
workflow: string | undefined;
|
|
72
|
+
runId: string | undefined;
|
|
73
|
+
branch: string | undefined;
|
|
74
|
+
actor: string | undefined;
|
|
75
|
+
commitSha: string | undefined;
|
|
76
|
+
runnerOS: string | undefined;
|
|
77
|
+
eventName: string | undefined;
|
|
78
|
+
isPullRequest: boolean;
|
|
79
|
+
isPush: boolean;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* 简单的检查函数
|
|
84
|
+
*/
|
|
85
|
+
export declare const isGitHubActions: () => boolean;
|
|
86
|
+
export declare const isCI: () => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coze-arch/rush-publish-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5-alpha.0f1107",
|
|
4
4
|
"description": "rush plugin to generate change log and publish packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rush",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"release",
|
|
10
10
|
"publish"
|
|
11
11
|
],
|
|
12
|
-
"license": "
|
|
12
|
+
"license": "MIT",
|
|
13
13
|
"author": "tecvan.fe@gmail.com",
|
|
14
14
|
"maintainers": [],
|
|
15
15
|
"main": "./lib/index.js",
|
|
@@ -42,24 +42,20 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@commitlint/types": "^17.4.0",
|
|
45
|
+
"@coze-arch/build-lib-preset": "workspace:*",
|
|
45
46
|
"@coze-arch/eslint-config": "workspace:*",
|
|
46
47
|
"@coze-arch/fs-enhance": "workspace:*",
|
|
47
48
|
"@coze-arch/logger": "workspace:*",
|
|
49
|
+
"@coze-arch/monorepo-kits": "workspace:*",
|
|
48
50
|
"@coze-arch/ts-config": "workspace:*",
|
|
49
51
|
"@coze-arch/vitest-config": "workspace:*",
|
|
50
|
-
"@
|
|
51
|
-
"@rollup/plugin-json": "~6.0.0",
|
|
52
|
-
"@rollup/plugin-node-resolve": "~15.0.1",
|
|
53
|
-
"@rollup/plugin-sucrase": "^5.0.2",
|
|
54
|
-
"@types/node": "^22.13.13",
|
|
52
|
+
"@types/node": "^22",
|
|
55
53
|
"@types/semver": "^7.5.8",
|
|
56
54
|
"@types/shelljs": "^0.8.15",
|
|
57
55
|
"@vitest/coverage-v8": "^3.0.9",
|
|
58
56
|
"commander": "^13.1.0",
|
|
59
|
-
"rollup": "^4.
|
|
60
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
57
|
+
"rollup": "^4.41.1",
|
|
61
58
|
"sucrase": "^3.32.0",
|
|
62
|
-
"tsx": "^4.19.3",
|
|
63
59
|
"vitest": "^3.0.9"
|
|
64
60
|
},
|
|
65
61
|
"peerDependencies": {
|