Skip to content

fix: improve package.json serialization#8

Merged
anonrig merged 2 commits intomainfrom
improve-package-json
Jul 15, 2023
Merged

fix: improve package.json serialization#8
anonrig merged 2 commits intomainfrom
improve-package-json

Conversation

@anonrig
Copy link
Copy Markdown
Member

@anonrig anonrig commented Jul 15, 2023

Previously, package.json serializer removed unknown attributes. We now use a serde_json::Value to define the value and store the reference to it.

@anonrig anonrig merged commit bd27a78 into main Jul 15, 2023
@anonrig anonrig deleted the improve-package-json branch July 15, 2023 19:31
@KSXGitHub KSXGitHub mentioned this pull request Apr 30, 2026
zkochan added a commit to Saturate/pacquet that referenced this pull request May 7, 2026
Match upstream's NDJSON wire format for the build phase so
@pnpm/cli.default-reporter parses pacquet's lifecycle output the same
way it parses pnpm's.

- Add `LogEvent::Lifecycle(LifecycleLog)` with the three upstream
  message shapes (Script, Stdio, Exit) as a `#[serde(untagged)]`
  union, mirroring `core/core-loggers/src/lifecycleLogger.ts`.
- Add `LogEvent::IgnoredScripts(IgnoredScriptsLog)` carrying
  `packageNames` (camelCase), mirroring `ignoredScriptsLogger.ts`.
- `pacquet-executor` depends on `pacquet-reporter`. `run_postinstall_hooks`
  / `run_lifecycle_hook` are now generic over `R: Reporter`. The hook
  switches from `Stdio::inherit()` to `Stdio::piped()` and reads each
  stream on its own thread, emitting one `Stdio` event per line. A
  `Script` event fires before spawn, `Exit` fires after wait — same
  ordering as `runLifecycleHook.ts:102/165`.
- `BuildModules::run::<R>` collects sorted (peer-stripped) keys of
  packages that hit the "not in allowBuilds" branch and returns them
  as `Vec<String>`. Explicit `false` is silently skipped, matching
  upstream's switch in `building/during-install/src/index.ts:88-101`.
- `InstallFrozenLockfile::run` emits one `pnpm:ignored-scripts` event
  with the returned list (always, even when empty) — mirrors the
  unconditional emit at `installing/deps-installer/src/install/index.ts:414`.

Tests:
- Wire-shape tests for both new variants pin the JSON output.
- Recording-fake tests for `run_postinstall_hooks` cover Script→Stdio→Exit
  ordering and non-zero exit propagation.
- Recording-fake tests for `BuildModules::run` cover the ignored-builds
  return value (sorted, peer-stripped, excludes explicit-deny).
- Updated `install_emits_pnpm_event_sequence` to expect the new
  `IgnoredScripts` event between `Stats` and `ImportingDone`.

Addresses items pnpm#6 and pnpm#8 from pnpm#397.

Upstream refs at `pnpm/pnpm@80037699fb`:
- core/core-loggers/src/lifecycleLogger.ts
- core/core-loggers/src/ignoredScriptsLogger.ts
- exec/lifecycle/src/runLifecycleHook.ts
- building/during-install/src/index.ts
- installing/deps-installer/src/install/index.ts
zkochan added a commit to Saturate/pacquet that referenced this pull request May 7, 2026
Match upstream's NDJSON wire format for the build phase so
@pnpm/cli.default-reporter parses pacquet's lifecycle output the same
way it parses pnpm's.

- Add `LogEvent::Lifecycle(LifecycleLog)` with the three upstream
  message shapes (Script, Stdio, Exit) as a `#[serde(untagged)]`
  union, mirroring `core/core-loggers/src/lifecycleLogger.ts`.
- Add `LogEvent::IgnoredScripts(IgnoredScriptsLog)` carrying
  `packageNames` (camelCase), mirroring `ignoredScriptsLogger.ts`.
- `pacquet-executor` depends on `pacquet-reporter`. `run_postinstall_hooks`
  / `run_lifecycle_hook` are now generic over `R: Reporter`. The hook
  switches from `Stdio::inherit()` to `Stdio::piped()` and reads each
  stream on its own thread, emitting one `Stdio` event per line. A
  `Script` event fires before spawn, `Exit` fires after wait — same
  ordering as `runLifecycleHook.ts:102/165`.
- `BuildModules::run::<R>` collects sorted (peer-stripped) keys of
  packages that hit the "not in allowBuilds" branch and returns them
  as `Vec<String>`. Explicit `false` is silently skipped, matching
  upstream's switch in `building/during-install/src/index.ts:88-101`.
- `InstallFrozenLockfile::run` emits one `pnpm:ignored-scripts` event
  with the returned list (always, even when empty) — mirrors the
  unconditional emit at `installing/deps-installer/src/install/index.ts:414`.

Tests:
- Wire-shape tests for both new variants pin the JSON output.
- Recording-fake tests for `run_postinstall_hooks` cover Script→Stdio→Exit
  ordering and non-zero exit propagation.
- Recording-fake tests for `BuildModules::run` cover the ignored-builds
  return value (sorted, peer-stripped, excludes explicit-deny).
- Updated `install_emits_pnpm_event_sequence` to expect the new
  `IgnoredScripts` event between `Stats` and `ImportingDone`.

Addresses items pnpm#6 and pnpm#8 from pnpm#397.

Upstream refs at `pnpm/pnpm@80037699fb`:
- core/core-loggers/src/lifecycleLogger.ts
- core/core-loggers/src/ignoredScriptsLogger.ts
- exec/lifecycle/src/runLifecycleHook.ts
- building/during-install/src/index.ts
- installing/deps-installer/src/install/index.ts
zkochan added a commit to Saturate/pacquet that referenced this pull request May 7, 2026
Match upstream's NDJSON wire format for the build phase so
@pnpm/cli.default-reporter parses pacquet's lifecycle output the same
way it parses pnpm's.

- Add `LogEvent::Lifecycle(LifecycleLog)` with the three upstream
  message shapes (Script, Stdio, Exit) as a `#[serde(untagged)]`
  union, mirroring `core/core-loggers/src/lifecycleLogger.ts`.
- Add `LogEvent::IgnoredScripts(IgnoredScriptsLog)` carrying
  `packageNames` (camelCase), mirroring `ignoredScriptsLogger.ts`.
- `pacquet-executor` depends on `pacquet-reporter`. `run_postinstall_hooks`
  / `run_lifecycle_hook` are now generic over `R: Reporter`. The hook
  switches from `Stdio::inherit()` to `Stdio::piped()` and reads each
  stream on its own thread, emitting one `Stdio` event per line. A
  `Script` event fires before spawn, `Exit` fires after wait — same
  ordering as `runLifecycleHook.ts:102/165`.
- `BuildModules::run::<R>` collects sorted (peer-stripped) keys of
  packages that hit the "not in allowBuilds" branch and returns them
  as `Vec<String>`. Explicit `false` is silently skipped, matching
  upstream's switch in `building/during-install/src/index.ts:88-101`.
- `InstallFrozenLockfile::run` emits one `pnpm:ignored-scripts` event
  with the returned list (always, even when empty) — mirrors the
  unconditional emit at `installing/deps-installer/src/install/index.ts:414`.

Tests:
- Wire-shape tests for both new variants pin the JSON output.
- Recording-fake tests for `run_postinstall_hooks` cover Script→Stdio→Exit
  ordering and non-zero exit propagation.
- Recording-fake tests for `BuildModules::run` cover the ignored-builds
  return value (sorted, peer-stripped, excludes explicit-deny).
- Updated `install_emits_pnpm_event_sequence` to expect the new
  `IgnoredScripts` event between `Stats` and `ImportingDone`.

Addresses items pnpm#6 and pnpm#8 from pnpm#397.

Upstream refs at `pnpm/pnpm@80037699fb`:
- core/core-loggers/src/lifecycleLogger.ts
- core/core-loggers/src/ignoredScriptsLogger.ts
- exec/lifecycle/src/runLifecycleHook.ts
- building/during-install/src/index.ts
- installing/deps-installer/src/install/index.ts
zkochan added a commit to Saturate/pacquet that referenced this pull request May 9, 2026
Match upstream's NDJSON wire format for the build phase so
@pnpm/cli.default-reporter parses pacquet's lifecycle output the same
way it parses pnpm's.

- Add `LogEvent::Lifecycle(LifecycleLog)` with the three upstream
  message shapes (Script, Stdio, Exit) as a `#[serde(untagged)]`
  union, mirroring `core/core-loggers/src/lifecycleLogger.ts`.
- Add `LogEvent::IgnoredScripts(IgnoredScriptsLog)` carrying
  `packageNames` (camelCase), mirroring `ignoredScriptsLogger.ts`.
- `pacquet-executor` depends on `pacquet-reporter`. `run_postinstall_hooks`
  / `run_lifecycle_hook` are now generic over `R: Reporter`. The hook
  switches from `Stdio::inherit()` to `Stdio::piped()` and reads each
  stream on its own thread, emitting one `Stdio` event per line. A
  `Script` event fires before spawn, `Exit` fires after wait — same
  ordering as `runLifecycleHook.ts:102/165`.
- `BuildModules::run::<R>` collects sorted (peer-stripped) keys of
  packages that hit the "not in allowBuilds" branch and returns them
  as `Vec<String>`. Explicit `false` is silently skipped, matching
  upstream's switch in `building/during-install/src/index.ts:88-101`.
- `InstallFrozenLockfile::run` emits one `pnpm:ignored-scripts` event
  with the returned list (always, even when empty) — mirrors the
  unconditional emit at `installing/deps-installer/src/install/index.ts:414`.

Tests:
- Wire-shape tests for both new variants pin the JSON output.
- Recording-fake tests for `run_postinstall_hooks` cover Script→Stdio→Exit
  ordering and non-zero exit propagation.
- Recording-fake tests for `BuildModules::run` cover the ignored-builds
  return value (sorted, peer-stripped, excludes explicit-deny).
- Updated `install_emits_pnpm_event_sequence` to expect the new
  `IgnoredScripts` event between `Stats` and `ImportingDone`.

Addresses items pnpm#6 and pnpm#8 from pnpm#397.

Upstream refs at `pnpm/pnpm@80037699fb`:
- core/core-loggers/src/lifecycleLogger.ts
- core/core-loggers/src/ignoredScriptsLogger.ts
- exec/lifecycle/src/runLifecycleHook.ts
- building/during-install/src/index.ts
- installing/deps-installer/src/install/index.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant