Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

[CLI] integration verify works on npm 8 for scoped packages (#7933)

Joey346e3595def3
diff --git a/.changeset/verify-npm8-scoped.md b/.changeset/verify-npm8-scoped.md
new file mode 100644
index 0000000000..2ffe5452de
--- /dev/null
+++ b/.changeset/verify-npm8-scoped.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/cli': patch
+---
+
+[fix] `astryx integration verify` works on npm 8 for a scoped package: npm 8 names the tarball `@scope/name-1.0.0.tgz` in its pack output but writes `scope-name-1.0.0.tgz`, so verify reads the file npm wrote instead of failing to find it.
+
+@josephfarina
diff --git a/packages/cli/api/integration/pack-check.mjs b/packages/cli/api/integration/pack-check.mjs
index ffd82b60e2..604fdd2c6c 100644
--- a/packages/cli/api/integration/pack-check.mjs
+++ b/packages/cli/api/integration/pack-check.mjs
@@ -230,7 +230,12 @@ export function parseNpmPackOutput(output) {
throw new Error('npm pack returned a result without a files array.');
}
return {
- filename: info.filename,
+ // npm 8 names a scoped package's tarball `@scope/name-1.0.0.tgz` in its
+ // JSON but writes `scope-name-1.0.0.tgz`, as every later npm reports.
+ filename:
+ typeof info.filename === 'string' && /^@[^/]+\//.test(info.filename)
+ ? info.filename.slice(1).replace('/', '-')
+ : info.filename,
fileCount: info.entryCount,
size: info.size,
unpackedSize: info.unpackedSize,
diff --git a/packages/cli/api/integration/pack-check.test.mjs b/packages/cli/api/integration/pack-check.test.mjs
index 9daad9f1a6..f83a16476a 100644
--- a/packages/cli/api/integration/pack-check.test.mjs
+++ b/packages/cli/api/integration/pack-check.test.mjs
@@ -2038,6 +2038,20 @@ describe('integrationPackCheck', () => {
).toEqual([]);
});
+ it("reads npm 8's scoped tarball name as the file npm writes", () => {
+ const entry = {entryCount: 1, size: 1, unpackedSize: 1, files: []};
+ expect(
+ parseNpmPackOutput(
+ JSON.stringify([{...entry, filename: '@acme/kit-1.0.0.tgz'}]),
+ ).filename,
+ ).toBe('acme-kit-1.0.0.tgz');
+ expect(
+ parseNpmPackOutput(
+ JSON.stringify([{...entry, filename: 'acme-kit-1.0.0.tgz'}]),
+ ).filename,
+ ).toBe('acme-kit-1.0.0.tgz');
+ });
+
it('rejects malformed npm pack output without a raw TypeError', () => {
expect(() =>
parseNpmPackOutput(