@riebeckite/test 0.0.37 → 0.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,13 +7,15 @@ end-to-end engine.
7
7
 
8
8
  ## Overview
9
9
 
10
- `@riebeckite/test` has two entry points:
10
+ `@riebeckite/test` has three entry points:
11
11
 
12
12
  - `@riebeckite/test` — dependency-free helpers for package unit tests.
13
13
  - `@riebeckite/test/e2e` — a reusable engine for testing a built site end to
14
14
  end against published tarballs. It knows nothing about the Riebeckite
15
15
  monorepo: the repository root, the package list, the fixtures, and the
16
16
  content assertions are all supplied by the caller.
17
+ - `@riebeckite/test/fixtures` — helpers for building Markdown fixtures and
18
+ temporary directories.
17
19
 
18
20
  ## Installation
19
21
 
package/README_ja.md CHANGED
@@ -6,10 +6,11 @@ Riebeckite パッケージ共通のテストユーティリティと、汎用の
6
6
 
7
7
  ## 概要
8
8
 
9
- `@riebeckite/test` には 2 つのエントリポイントがあります。
9
+ `@riebeckite/test` には 3 つのエントリポイントがあります。
10
10
 
11
11
  - `@riebeckite/test` — パッケージの単体テスト向けの依存ゼロ helper。
12
12
  - `@riebeckite/test/e2e` — ビルド済みサイトを公開 tarball に対して end-to-end で検証する再利用可能な engine。Riebeckite モノレポを一切知りません。リポジトリルート、パッケージ一覧、fixture、コンテンツのアサーションはすべて呼び出し側が渡します。
13
+ - `@riebeckite/test/fixtures` — Markdown の fixture と一時ディレクトリを作る helper。
13
14
 
14
15
  ## インストール
15
16
 
@@ -1,4 +1,5 @@
1
1
  import type { Logger } from "./logger.js";
2
+ import type { PackedPackages } from "./pack.js";
2
3
  /** A path that must exist after installation, with its failure message. */
3
4
  export interface RequiredInstallPath {
4
5
  /** Label used in the success line, e.g. `"vite/client"`. */
@@ -49,6 +50,12 @@ export interface AssertPublishedArtifactsOptions {
49
50
  * outside the repository (never a symlink back into the monorepo).
50
51
  */
51
52
  export declare function assertPublishedArtifacts(siteDir: string, options: AssertPublishedArtifactsOptions): void;
53
+ export interface AssertPackedInstallOptions {
54
+ packed: PackedPackages;
55
+ scope: string;
56
+ logger: Logger;
57
+ }
58
+ export declare function assertPackedInstall(siteDir: string, options: AssertPackedInstallOptions): void;
52
59
  export interface AssertDeclaredDependenciesOptions {
53
60
  /** Absolute path to the undeclared-dependency checker script. */
54
61
  dependencyCheckScript: string;
@@ -8,7 +8,7 @@
8
8
  * {@link runExternalSiteE2E}. Lower-level primitives are exported so a
9
9
  * repository can compose its own flow.
10
10
  */
11
- export { type AssertDeclaredDependenciesOptions, type AssertIsolatedInstallOptions, type AssertNoMonorepoEscapeHatchesOptions, type AssertPublishedArtifactsOptions, assertDeclaredDependencies, assertIsolatedInstall, assertNoMonorepoEscapeHatches, assertPublishedArtifacts, type RequiredInstallPath, } from "./assertions.js";
11
+ export { type AssertDeclaredDependenciesOptions, type AssertIsolatedInstallOptions, type AssertNoMonorepoEscapeHatchesOptions, type AssertPackedInstallOptions, type AssertPublishedArtifactsOptions, assertDeclaredDependencies, assertIsolatedInstall, assertNoMonorepoEscapeHatches, assertPackedInstall, assertPublishedArtifacts, type RequiredInstallPath, } from "./assertions.js";
12
12
  export { cliText, type RunCliOptions, runCli, runTypecheck, } from "./cli.js";
13
13
  export { type FilePredicate, walkFiles, } from "./files.js";
14
14
  export { formatBytes } from "./format.js";
package/dist/e2e/index.js CHANGED
@@ -246,6 +246,49 @@ function assertPublishedArtifacts(siteDir, options) {
246
246
  console.log(` ${scope}/${entry} -> ${real}`);
247
247
  }
248
248
  }
249
+ function assertPackedInstall(siteDir, options) {
250
+ const { packed, scope, logger } = options;
251
+ logger.step(`verifying ${scope}/* installs come from packed tarballs`);
252
+ const manifest = JSON.parse(
253
+ fs2.readFileSync(path2.join(siteDir, "package.json"), "utf8")
254
+ );
255
+ const declared = {
256
+ ...manifest.dependencies,
257
+ ...manifest.devDependencies
258
+ };
259
+ const overrides = manifest.overrides ?? {};
260
+ for (const name of packed.keys()) {
261
+ for (const [label, spec] of [
262
+ ["dependency", declared[name]],
263
+ ["override", overrides[name]]
264
+ ]) {
265
+ if (typeof spec !== "string" || !spec.startsWith("file:")) {
266
+ logger.fail(
267
+ `${name} must use a file: ${label} so it cannot fall back to the public registry`
268
+ );
269
+ }
270
+ }
271
+ }
272
+ const scopeDir = path2.join(siteDir, "node_modules", ...scope.split("/"));
273
+ if (!fs2.existsSync(scopeDir)) return;
274
+ for (const entry of fs2.readdirSync(scopeDir)) {
275
+ const name = `${scope}/${entry}`;
276
+ const artifact = packed.get(name);
277
+ if (!artifact) {
278
+ logger.fail(
279
+ `${name} was installed but is not part of the packed workspace; it would come from the public registry`
280
+ );
281
+ }
282
+ const installed = JSON.parse(
283
+ fs2.readFileSync(path2.join(scopeDir, entry, "package.json"), "utf8")
284
+ );
285
+ if (installed.version !== artifact.version) {
286
+ logger.fail(
287
+ `${name}@${String(installed.version)} does not match the packed ${artifact.version}`
288
+ );
289
+ }
290
+ }
291
+ }
249
292
  function assertDeclaredDependencies(siteDir, options) {
250
293
  const { dependencyCheckScript, cwd, logger } = options;
251
294
  logger.step("checking the site for undeclared (hoisted) dependencies");
@@ -567,6 +610,11 @@ async function runExternalSiteE2E(config) {
567
610
  scope: config.scope,
568
611
  logger
569
612
  });
613
+ assertPackedInstall(siteDir, {
614
+ packed,
615
+ scope: config.scope,
616
+ logger
617
+ });
570
618
  const workspace = {
571
619
  repoRoot: config.repoRoot,
572
620
  tempRoot,
@@ -608,6 +656,7 @@ export {
608
656
  assertDeclaredDependencies,
609
657
  assertIsolatedInstall,
610
658
  assertNoMonorepoEscapeHatches,
659
+ assertPackedInstall,
611
660
  assertPublishedArtifacts,
612
661
  cliText,
613
662
  createLogger,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/test",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",