Skip to content

Commit dfa19d3

Browse files
committed
warn dependency changes on single-package publish
1 parent 7992ec6 commit dfa19d3

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
9696
packageIdRequired: 'Please provide packageId or packageVersion parameter',
9797
packageUploadSuccess:
9898
'Successfully uploaded new hot update package (id: {{id}})',
99+
depsChangeWarningTitle: 'Dependency changes detected',
99100
depsChangeSummary:
100101
'Dependency changes: added {{added}}, removed {{removed}}, changed {{changed}}.',
101102
depsChangeTargetPackage:

src/locales/zh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export default {
8989
operationSuccess: '操作成功',
9090
packageIdRequired: '请提供 packageId 或 packageVersion 参数',
9191
packageUploadSuccess: '已成功上传新热更包(id: {{id}})',
92+
depsChangeWarningTitle: '检测到依赖变化',
9293
depsChangeSummary:
9394
'依赖变化:新增 {{added}} 项,移除 {{removed}} 项,版本变更 {{changed}} 项。',
9495
depsChangeTargetPackage: '目标原生包:{{packageName}} (id: {{packageId}})',

src/versions.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface VersionCommandOptions {
2525
rollout?: string;
2626
dryRun?: boolean;
2727
versionDeps?: Record<string, string>;
28+
warnDepsChanges?: boolean;
2829
}
2930

3031
type Deps = Record<string, string>;
@@ -193,6 +194,7 @@ function printDepsChangesForPackage({
193194
]);
194195

195196
console.log('');
197+
console.log(chalk.bgYellow.black.bold(` ${t('depsChangeWarningTitle')} `));
196198
console.log(
197199
chalk.yellow(
198200
t('depsChangeTargetPackage', {
@@ -243,7 +245,7 @@ async function printDepsChangesForPublish({
243245
pkgs: Package[];
244246
providedVersionDeps?: Deps;
245247
}) {
246-
if (!versionId || pkgs.length === 0) {
248+
if (!versionId || pkgs.length !== 1) {
247249
return;
248250
}
249251

@@ -464,13 +466,19 @@ export const versionCommands = {
464466
rollout,
465467
dryRun,
466468
versionDeps: depVersions,
469+
warnDepsChanges: true,
467470
},
468471
});
469472
} else {
470473
const q = await question(t('updateNativePackageQuestion'));
471474
if (q.toLowerCase() === 'y') {
472475
await this.update({
473-
options: { versionId: id, platform, versionDeps: depVersions },
476+
options: {
477+
versionId: id,
478+
platform,
479+
versionDeps: depVersions,
480+
warnDepsChanges: true,
481+
},
474482
});
475483
}
476484
}
@@ -570,12 +578,14 @@ export const versionCommands = {
570578
}
571579
}
572580

573-
await printDepsChangesForPublish({
574-
appId: String(appId),
575-
versionId: String(versionId),
576-
pkgs: pkgsToBind,
577-
providedVersionDeps: options.versionDeps,
578-
});
581+
if (options.warnDepsChanges) {
582+
await printDepsChangesForPublish({
583+
appId: String(appId),
584+
versionId: String(versionId),
585+
pkgs: pkgsToBind,
586+
providedVersionDeps: options.versionDeps,
587+
});
588+
}
579589

580590
await bindVersionToPackages({
581591
appId: String(appId),

0 commit comments

Comments
 (0)