Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Name the pacote path when the OK publish step cannot load it (#5583)

Nick Gomez8de05ba3f3d0
diff --git a/.github/scripts/release-cascade-shape.test.mjs b/.github/scripts/release-cascade-shape.test.mjs
index 17f503a6e..119c10dc3 100644
--- a/.github/scripts/release-cascade-shape.test.mjs
+++ b/.github/scripts/release-cascade-shape.test.mjs
@@ -2317,7 +2317,7 @@ describe('the release App credential never shares a job with installed packages'
};
const tgz = (...blocks) => gzipSync(Buffer.concat([...blocks, ZERO_BLOCK, ZERO_BLOCK]));
let cases = 0;
- const publishWith = ({ tarballs, action = '', beta = '0.82.0-beta.9', stable = '', view = '' }) => {
+ const publishWith = ({ tarballs, action = '', beta = '0.82.0-beta.9', stable = '', view = '', globalRoot = nodeGlobalRoot }) => {
cases += 1;
const dir = join(root, `case-${cases}`);
const packageDir = join(dir, 'npm-package');
@@ -2346,7 +2346,7 @@ describe('the release App credential never shares a job with installed packages'
PACKAGE_DIR: packageDir,
NPM_LOG: log,
NPM_VIEW: view,
- NPM_GLOBAL_ROOT: nodeGlobalRoot,
+ NPM_GLOBAL_ROOT: globalRoot,
HTTPS_PROXY: 'http://127.0.0.1:9',
HTTP_PROXY: 'http://127.0.0.1:9',
https_proxy: 'http://127.0.0.1:9',
@@ -2364,6 +2364,37 @@ describe('the release App credential never shares a job with installed packages'
expect(commands(publishStep())).not.toMatch(/\btar\s/);
});
+ test('a pacote that does not load from the computed path is named by that path, and the tarball is not blamed', () => {
+ const globalRoot = join(root, 'no-pacote');
+ mkdirSync(globalRoot);
+ const pacote = join(globalRoot, 'npm', 'node_modules', 'pacote');
+ const result = publishWith({ tarballs: [cli('0.82.0-beta.9')], globalRoot });
+ expect(result.status).toBe(1);
+ expect(result.publishes).toEqual([]);
+ const lines = `${result.stdout}\n${result.stderr}`.split('\n');
+ expect(lines.filter((line) => line.startsWith('::error::'))).toEqual([expect.stringContaining(pacote)]);
+ expect(lines.filter((line) => line.includes('packed tarball'))).toEqual([]);
+ expect(result.stderr).toContain(`"Cannot find module '${pacote}'`);
+ });
+
+ test('a tarball pacote loads but cannot read gets the tarball message, not the pacote one', () => {
+ const result = publishWith({ tarballs: [Buffer.from('not a gzip tarball\n')] });
+ expect(result.status).toBe(1);
+ expect(result.publishes).toEqual([]);
+ const lines = `${result.stdout}\n${result.stderr}`.split('\n');
+ expect(lines.filter((line) => line.startsWith('::error::'))).toEqual([
+ "::error::npm cannot read the packed tarball's manifest; its reason is printed above, JSON-encoded. Refusing to publish.",
+ ]);
+ const reasons = result.stderr.split('\n').filter((line) => {
+ try {
+ return typeof JSON.parse(line) === 'string';
+ } catch {
+ return false;
+ }
+ });
+ expect(reasons).toHaveLength(1);
+ });
+
test('the step passes provenance and the registry as CLI flags, which publishConfig cannot override, and names the package it checks', () => {
expect(commands(publishStep()).split('\n').map((line) => line.trim()).filter((line) => /\bnpm\s+publish\b/.test(line))).toEqual([TARBALL_PUBLISH]);
expect(publishStep().env).not.toHaveProperty('NPM_CONFIG_PROVENANCE');
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8878fbaf1..d96bd8f08 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -768,17 +768,26 @@ jobs:
fi
TARBALL="${tarballs[0]}"
pacote="$(npm root -g)/npm/node_modules/pacote"
- if ! manifest=$(node -e '
- require(process.argv[1])
- .manifest("file:" + process.argv[2], { fullMetadata: true, fullReadJson: true })
- .then(
- (manifest) => process.stdout.write(JSON.stringify(manifest)),
- (error) => {
- process.stderr.write(JSON.stringify(String(error && error.message)) + "\n");
- process.exit(1);
- },
- )
- ' "$pacote" "$TARBALL"); then
+ read_status=0
+ manifest=$(node -e '
+ const fail = (status) => (error) => {
+ process.stderr.write(JSON.stringify(String(error && error.message)) + "\n");
+ process.exit(status);
+ };
+ let reading;
+ try {
+ reading = require(process.argv[1])
+ .manifest("file:" + process.argv[2], { fullMetadata: true, fullReadJson: true });
+ } catch (error) {
+ fail(2)(error);
+ }
+ reading.then((manifest) => process.stdout.write(JSON.stringify(manifest)), fail(1));
+ ' "$pacote" "$TARBALL") || read_status=$?
+ if (( read_status == 2 )); then
+ echo "::error::npm's pacote did not load from ${pacote}, or threw before opening the tarball; its reason is printed above, JSON-encoded. Refusing to publish."
+ exit 1
+ fi
+ if (( read_status != 0 )); then
echo "::error::npm cannot read the packed tarball's manifest; its reason is printed above, JSON-encoded. Refusing to publish."
exit 1
fi
diff --git a/knip.config.ts b/knip.config.ts
index d3638888e..65f0e8807 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -147,15 +147,11 @@ export default {
'packages/server': {
entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],
project: 'src/**',
- ignoreDependencies: [
- '@types/shell-quote',
- ],
+ ignoreDependencies: ['@types/shell-quote'],
},
'packages/cli': {
entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],
- ignoreDependencies: [
- 'yjs',
- ],
+ ignoreDependencies: ['yjs'],
},
'packages/desktop': {
entry: [
diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
index a28cc2b18..8a60e5826 100644
--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
@@ -1,4 +1,3 @@
-
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { setTimeout as wait } from 'node:timers/promises';
diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
index 4fc2c11f9..6fcdc23f2 100644
--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { normalizeBridge } from '@inkeep/open-knowledge-core';
import { updateYFragment } from '@tiptap/y-tiptap';
diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.ts
index 9f2f6feb6..40b5cdfd6 100644
--- a/packages/app/tests/integration/interior-edit-freshness.test.ts
+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
index 2a085742b..93666af70 100644
--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.ts
index 878d5196b..867598d34 100644
--- a/packages/app/tests/integration/producer-guard-wiring.test.ts
+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
index 4ada3cf26..0970ac12f 100644
--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
@@ -1,4 +1,3 @@
-
import { randomUUID } from 'node:crypto';
import { afterEach, describe, expect, test } from 'vitest';
import { agentWriteMd, createTestServer, type TestServer } from './test-harness';
diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
index cbe2b705f..b632185e1 100644
--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
@@ -1,4 +1,3 @@
-
import { execFileSync } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { join } from 'node:path';
diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
index 89bc9b4d9..c530ce4ba 100644
--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
@@ -1,4 +1,3 @@
-
import { randomUUID } from 'node:crypto';
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';
import type * as Y from 'yjs';
diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.ts
index a78aeb0e4..d3767adc9 100644
--- a/packages/app/tests/integration/undo-after-rollback.test.ts
+++ b/packages/app/tests/integration/undo-after-rollback.test.ts
@@ -1,4 +1,3 @@
-
import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import * as Y from 'yjs';
diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.ts
index e7cc69c3f..b076f955c 100644
--- a/packages/app/tests/integration/undo-recycle-reset.test.ts
+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts
@@ -1,4 +1,3 @@
-
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { setTimeout as wait } from 'node:timers/promises';
diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.ts
index 9ddcd0730..7935e35f8 100644
--- a/packages/app/tests/integration/undo-rederive-survival.test.ts
+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts
@@ -1,4 +1,3 @@
-
import { prependFrontmatter } from '@inkeep/open-knowledge-core';
import { Plugin, PluginKey } from '@tiptap/pm/state';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.ts
index 2a597ec3d..f4cc8a286 100644
--- a/packages/core/src/bridge/compose.ts
+++ b/packages/core/src/bridge/compose.ts
@@ -1,4 +1,3 @@
-
import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';
export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';
diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index 01ef76a9f..8fb428b90 100644
--- a/packages/core/src/bridge/doc-boundary-space.ts
+++ b/packages/core/src/bridge/doc-boundary-space.ts
@@ -1,4 +1,3 @@
-
import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';
import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';
diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index fb0ba5a7c..fc267cbea 100644
--- a/packages/core/src/markdown/comment-promoter.ts
+++ b/packages/core/src/markdown/comment-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.ts
index fa3cfcd86..bfd7e3109 100644
--- a/packages/core/src/markdown/merged-walker.ts
+++ b/packages/core/src/markdown/merged-walker.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parent, Root } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.ts
index 8be632ba4..4d3250d3a 100644
--- a/packages/core/src/markdown/safe-url.ts
+++ b/packages/core/src/markdown/safe-url.ts
@@ -1,4 +1,3 @@
-
export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;
const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');