Skip to content

Commit 7410a5b

Browse files
committed
chore(gates): require bundled license notices in npm packages
1 parent b49dc8d commit 7410a5b

5 files changed

Lines changed: 38 additions & 1 deletion

File tree

‎scripts/__tests__/fixtures/size-report-npm-pack.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"unpackedSize": 2319,
33
"files": [
4+
{
5+
"path": "dist/src/THIRD_PARTY_NOTICES.txt",
6+
"size": 100
7+
},
48
{
59
"path": "dist/src/index.js",
610
"size": 401

‎scripts/__tests__/size-report-package.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ const helperManifestSource = [
2323
' name: "AgentDeviceMacOSInputTests",',
2424
].join('\n');
2525

26+
test('publish package requires bundled dependency license notices', () => {
27+
assert.throws(
28+
() =>
29+
assertPublishPackageContents(
30+
fixturePack.files.filter((entry) => entry.path !== 'dist/src/THIRD_PARTY_NOTICES.txt'),
31+
{ macosHelperManifestSource: helperManifestSource },
32+
),
33+
/THIRD_PARTY_NOTICES\.txt/,
34+
);
35+
assert.throws(
36+
() =>
37+
assertPublishPackageContents(
38+
fixturePack.files.map((entry) =>
39+
entry.path === 'dist/src/THIRD_PARTY_NOTICES.txt' ? { ...entry, size: 0 } : entry,
40+
),
41+
{ macosHelperManifestSource: helperManifestSource },
42+
),
43+
/non-empty.*THIRD_PARTY_NOTICES\.txt/,
44+
);
45+
});
46+
2647
test('publish package requires both Android helpers and excludes benchmark scripts', () => {
2748
assert.doesNotThrow(() =>
2849
assertPublishPackageContents(fixturePack.files, {

‎scripts/check-package.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
type PackedManifest as PackedDependencies,
3232
} from './lib/shipped-imports.ts';
3333
import { assertInstalledSnapshotBridge } from './size-report-install.mjs';
34+
import { assertBundledLicenseNotices } from './size-report-package.mjs';
3435
import { testOnlyContentFailures, testOnlyPathFailures } from './lib/shipped-test-code.ts';
3536
import { DAEMON_SOURCE_ENTRY, isSourceCheckoutProjectRoot } from '@agent-device/host-kit/version';
3637

@@ -102,7 +103,8 @@ function packTarball(): { tarball: string; packedPaths: string[] } {
102103
['pack', '--ignore-scripts', '--json', '--pack-destination', packDestination],
103104
repoRoot,
104105
),
105-
) as [{ filename: string; files: { path: string }[] }];
106+
) as [{ filename: string; files: { path: string; size: number }[] }];
107+
assertBundledLicenseNotices(packed[0].files);
106108
return {
107109
tarball: path.join(packDestination, packed[0].filename),
108110
packedPaths: packed[0].files.map((file) => file.path),

‎scripts/size-report-package.mjs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,16 @@ export function collectNpmPack(root) {
6565
};
6666
}
6767

68+
export function assertBundledLicenseNotices(entries) {
69+
if (
70+
!entries.some((entry) => entry.path === 'dist/src/THIRD_PARTY_NOTICES.txt' && entry.size > 0)
71+
) {
72+
throw new Error('npm pack is missing non-empty dist/src/THIRD_PARTY_NOTICES.txt');
73+
}
74+
}
75+
6876
export function assertPublishPackageContents(entries, options = {}) {
77+
assertBundledLicenseNotices(entries);
6978
const paths = entries.map((entry) => entry.path);
7079
const requiredAssets = [
7180
{ directory: 'android/snapshot-helper/dist/', suffix: '.apk' },

‎vitest.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export default defineConfig({
181181
// Package attribution models npm-pack output. Keep it in the fast lane so every new
182182
// package path remains accounted for.
183183
'scripts/__tests__/size-report-package.test.ts',
184+
'scripts/__tests__/bundled-license-notices.test.ts',
184185
// Publish preparation spawns only fixture-owned scripts and proves both Android
185186
// helper families are rebuilt through the shared release/size-report owner.
186187
'scripts/__tests__/prepare-publish-assets.test.ts',

0 commit comments

Comments
 (0)