Plan safe package release and migration
Review the package before any registry operation
A release candidate is not the same as a published package. Start with a clean reviewed source tree, a public API diff, a changelog and tests. The local package can be packed without network access or registry credentials. npm pack creates a tarball; its dry-run reports what would be included. Both can run lifecycle scripts in ordinary projects, so use --ignore-scripts on this reviewed fixture. A package manifest allowlist is not a substitute for inspecting the actual archive. An actual publication would need explicit approval, correct registry and access, verified ownership, license and provenance decisions; none is part of this lab.
export function inspectPack(manifest, paths) { const issues = []; if (!manifest.peerDependencies?.react) issues.push('React peer missing'); if (manifest.dependencies?.react || manifest.bundleDependencies?.includes?.('react')) issues.push('React must not be a bundled or direct runtime dependency in this fixture'); const expected = new Set(['package.json', ...manifest.files]); for (const path of paths) { if (!expected.has(path)) issues.push(`Unexpected file: ${path}`); expected.delete(path); } for (const path of expected) issues.push(`Missing file: ${path}`); for (const entry of Object.values(manifest.exports)) { for (const target of typeof entry === 'string' ? [entry] : Object.values(entry)) { if (!target.startsWith('./') || !paths.includes(target.slice(2))) issues.push(`Missing export: ${target}`); } } return issues;}This deliberately narrow release policy compares the exact known fixture file list, checks React peer metadata and verifies that export targets are present. It rejects unexpected files even if they might be legitimate in a different package. It does not evaluate arbitrary export patterns, check semantic-version ranges, scan secrets within permitted files, detect duplicated React inside compiled code or audit licenses. These checks are a starting point for the release gate, not a security certification.
Test the policy before using it
import test from 'node:test';import assert from 'node:assert/strict';import {readFileSync} from 'node:fs';import {inspectPack} from './release-check.mjs';import {statusLabel} from './package/status.mjs';const m = JSON.parse(readFileSync(new URL('./package/package.json', import.meta.url), 'utf8'));const files = ['package.json', ...m.files];test('expected files and exports', () => assert.deepEqual(inspectPack(m, files), []));test('reject unexpected file', () => assert.ok(inspectPack(m, [...files, '.env']).length));test('reject missing declaration', () => assert.ok(inspectPack(m, files.filter(x => x !== 'index.d.ts')).length));test('reject missing peer', () => assert.ok(inspectPack({...m, peerDependencies: {}}, files).length));test('reject direct React dependency', () => assert.ok(inspectPack({...m, dependencies: {react:'19.0.0'}}, files).length));test('reject missing export', () => assert.ok(inspectPack({...m, exports: {'.':'./missing.mjs'}}, files).length));test('ready label', () => assert.equal(statusLabel('ready'), 'Ready'));test('waiting label', () => assert.equal(statusLabel('waiting'), 'Waiting'));test('unknown label rejected', () => assert.throws(() => statusLabel('unknown'), RangeError));Run node --test release-check.test.mjs from the chapter directory. The tests cover the expected file list, extra and missing files, missing peer, an incorrect direct dependency, an unresolved export, and valid and invalid status inputs. These are pure Node checks and do not load React. The final package file list must come from the actual archive, not from package.json itself.
Rehearse the local release and migration
# Run from the chapter fixture directory, with npm available.# Use a clean lab directory; never run unknown package scripts.cd packagenpm pack --dry-run --json --ignore-scripts --offlinenpm pack --json --ignore-scripts --offline# Inspect the actual tarball; do not publish it.tar -tzf bytemind-lab-status-badge-1.0.0.tgzThe expected tarball contains package.json, entry and declaration files, status helper and its declaration, CSS and README. Review content and test extraction into a disposable consumer; import the helper using its package subpath. The React component requires an approved installed React dependency and separate renderer tests. For a stable public API, a new optional compatible prop is generally minor, a compatible correction patch, and an incompatible required prop or removed export major. Document migration steps and test old and new consumers, including the supported React peer ranges. Keep rollback options such as pinning the previously tested version; publishing a replacement is a distinct authorized operation. Practice: write a release note for removing the status subpath, and explain why a successful npm pack cannot prove React compatibility.