@@ -146,36 +146,62 @@ export async function hasCheckpoint(buildDir, packageName, checkpointName) {
146146 * - Tarball: build/{mode}/checkpoints/{package}/{phase}.tar.gz (if artifactPath provided)
147147 *
148148 * @param {string } buildDir - Build directory path
149- * @param {string } packageName - Package name
150149 * @param {string } checkpointName - Checkpoint name (e.g., 'release', 'patches-applied')
151150 * @param {Function } smokeTest - Async function that validates build artifacts (REQUIRED)
152- * @param {object } data - Checkpoint metadata
153- * @param {string } [data.artifactPath] - Path to file or directory to archive in checkpoint
154- * @param {string[] } [data.sourcePaths] - Source file paths to hash for cache validation
155- * @param {string } [data.packageRoot] - Package root for relative path display
156- * @param {string } [data.platform] - Platform (darwin, linux, win32)
157- * @param {string } [data.arch] - Architecture (x64, arm64)
151+ * @param {object } [options] - Optional checkpoint metadata
152+ * @param {string | undefined } [options.packageName=''] - Package name (defaults to '' for flat structure)
153+ * @param {string | undefined } [options.artifactPath] - Path to file or directory to archive in checkpoint
154+ * @param {string[] | undefined } [options.sourcePaths] - Source file paths to hash for cache validation
155+ * @param {string | undefined } [options.packageRoot] - Package root for relative path display
156+ * @param {string | undefined } [options.platform=process.platform] - Platform (darwin, linux, win32)
157+ * @param {string | undefined } [options.arch=process.arch] - Architecture (x64, arm64)
158+ * @param {string | undefined } [options.binaryPath] - Binary path for macOS code signing
158159 * @returns {Promise<void> }
159160 *
160161 * @example
161- * await createCheckpoint(BUILD_DIR, '', 'release', async () => {
162- * // Smoke test: Verify binary runs
162+ * // Minimal usage
163+ * await createCheckpoint(BUILD_DIR, 'release', async () => {
164+ * await spawn(binaryPath, ['--version'])
165+ * })
166+ *
167+ * // With options
168+ * await createCheckpoint(BUILD_DIR, 'release', async () => {
163169 * await spawn(binaryPath, ['--version'])
164170 * }, {
165- * artifactPath: './out/Release/node', // Archive this binary
166- * sourcePaths: ['build.mjs', 'patches/*.patch'], // Cache key
171+ * artifactPath: './out/Release/node',
172+ * sourcePaths: ['build.mjs', 'patches/*.patch'],
167173 * packageRoot: PACKAGE_ROOT,
168- * platform: 'darwin',
169- * arch: 'arm64',
170174 * })
171175 */
172176export async function createCheckpoint (
173177 buildDir ,
174- packageName ,
175178 checkpointName ,
176179 smokeTest ,
177- data = { } ,
180+ options = { } ,
178181) {
182+ // Extract options with defaults
183+ const {
184+ arch = process . arch ,
185+ artifactPath,
186+ binaryPath,
187+ packageName = '' ,
188+ packageRoot,
189+ platform = process . platform ,
190+ sourcePaths,
191+ ...rest
192+ } = options
193+
194+ // Build data object for legacy code paths
195+ const data = {
196+ artifactPath,
197+ sourcePaths,
198+ packageRoot,
199+ platform,
200+ arch,
201+ binaryPath,
202+ ...rest ,
203+ }
204+
179205 // Enforce smoke test requirement
180206 if ( typeof smokeTest !== 'function' ) {
181207 const actualValue =
@@ -187,18 +213,17 @@ export async function createCheckpoint(
187213 'ERROR: createCheckpoint() called incorrectly!\n' +
188214 `${ '=' . repeat ( 70 ) } \n` +
189215 `Checkpoint: "${ checkpointName } "\n` +
190- `Package: "${ packageName || '(none)' } "\n` +
191216 '\n' +
192- 'Expected parameter 4 : smokeTest callback function\n' +
193- `Actual parameter 4 : ${ actualValue } \n` +
217+ 'Expected parameter 3 : smokeTest callback function\n' +
218+ `Actual parameter 3 : ${ actualValue } \n` +
194219 '\n' +
195220 'Correct pattern:\n' +
196- ' createCheckpoint(buildDir, pkg, name , async () => {\n' +
221+ ' createCheckpoint(buildDir, checkpointName , async () => {\n' +
197222 ' // Smoke test validation code here\n' +
198- ' }, data )\n' +
223+ ' }, options )\n' +
199224 '\n' +
200225 'You passed:\n' +
201- ' createCheckpoint(buildDir, pkg, name, data ) ❌ Missing callback!\n' +
226+ ' createCheckpoint(buildDir, checkpointName, options ) ❌ Missing callback!\n' +
202227 `${ '=' . repeat ( 70 ) } \n` ,
203228 )
204229 }
@@ -213,7 +238,6 @@ export async function createCheckpoint(
213238 }
214239
215240 // Build checkpoint identifier with platform/arch if provided
216- const { arch, packageRoot, platform } = data
217241 let checkpointId = checkpointName
218242 if ( platform && arch ) {
219243 checkpointId = `${ checkpointName } (${ platform } -${ arch } )`
@@ -291,6 +315,16 @@ export async function createCheckpoint(
291315 const unixTarDir = toUnixPath ( tarDir )
292316
293317 try {
318+ // Create tarball with artifact as top-level entry
319+ // -c: create archive
320+ // -z: compress with gzip
321+ // -f: output file
322+ // -C: change to directory before archiving (ensures artifact becomes top-level entry)
323+ // tarBase: the artifact basename to archive (file or directory)
324+ //
325+ // Example: tar -czf checkpoint.tar.gz -C /build/dev/out Final
326+ // → Creates tarball containing Final/ as top-level entry
327+ // → During extraction, use --strip-components=1 to remove this wrapper
294328 await spawn (
295329 tarBin ,
296330 [ '-czf' , unixTarballPath , '-C' , unixTarDir , tarBase ] ,
0 commit comments