fix(tests): support npm pack object output

This commit is contained in:
dajiaohuang
2026-08-24 20:09:12 -04:00
committed by haelyra
parent 0b04c1bfa1
commit 6d42f32ca8
5 changed files with 77 additions and 4 deletions
+3 -1
View File
@@ -6,6 +6,7 @@ const assert = require("assert")
const fs = require("fs")
const path = require("path")
const { spawnSync } = require("child_process")
const { getNpmPackEntry } = require("../lib/npm-pack-output")
function runTest(name, fn) {
try {
@@ -54,7 +55,8 @@ function main() {
assert.strictEqual(result.status, 0, result.error?.message || result.stderr)
const packOutput = JSON.parse(result.stdout)
const packagedPaths = new Set(packOutput[0]?.files?.map((file) => file.path) ?? [])
const packEntry = getNpmPackEntry(packOutput, packageJson.name)
const packagedPaths = new Set(packEntry?.files?.map((file) => file.path) ?? [])
assert.ok(
packagedPaths.has(".opencode/dist/index.js"),
+4 -2
View File
@@ -11,6 +11,7 @@ const fs = require('fs');
const os = require('os');
const path = require('path');
const { spawnSync } = require('child_process');
const { getNpmPackEntry } = require('../lib/npm-pack-output');
const repoRoot = path.join(__dirname, '..', '..');
const packageJson = JSON.parse(
@@ -123,14 +124,15 @@ function getPackedFixture() {
['pack', '--json', '--ignore-scripts', '--pack-destination', directory]
);
const packOutput = JSON.parse(packResult.stdout);
const filename = packOutput[0]?.filename;
const packEntry = getNpmPackEntry(packOutput, packageJson.name);
const filename = packEntry?.filename;
assert.ok(filename, 'npm pack should report the archive filename');
packedFixture = {
archivePath: path.join(directory, filename),
directory,
publishedPaths: new Set(
packOutput[0]?.files?.map(file => file.path) || []
packEntry?.files?.map(file => file.path) || []
),
};
return packedFixture;
+3 -1
View File
@@ -6,6 +6,7 @@ const assert = require("assert")
const fs = require("fs")
const path = require("path")
const { spawnSync } = require("child_process")
const { getNpmPackEntry } = require("../lib/npm-pack-output")
function runTest(name, fn) {
try {
@@ -149,7 +150,8 @@ function main() {
assert.strictEqual(result.status, 0, result.error?.message || result.stderr)
const packOutput = JSON.parse(result.stdout)
const packagedPaths = new Set(packOutput[0]?.files?.map((file) => file.path) ?? [])
const packEntry = getNpmPackEntry(packOutput, packageJson.name)
const packagedPaths = new Set(packEntry?.files?.map((file) => file.path) ?? [])
for (const requiredPath of [
"scripts/catalog.js",