From c0488088aab7dd5513346184d797649089aa6b7e Mon Sep 17 00:00:00 2001 From: Bharat Middha <5100938+bmiddha@users.noreply.github.com> Date: Tue, 30 Sep 2025 14:59:08 -0700 Subject: [PATCH 1/6] update snapshots --- apps/zipsync/src/__snapshots__/start.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/zipsync/src/__snapshots__/start.test.ts.snap b/apps/zipsync/src/__snapshots__/start.test.ts.snap index 6c68a44b411..966c59704be 100644 --- a/apps/zipsync/src/__snapshots__/start.test.ts.snap +++ b/apps/zipsync/src/__snapshots__/start.test.ts.snap @@ -2,7 +2,7 @@ exports[`CLI Tool Tests should display help for "zipsync --help" 1`] = ` " -zipsync 0.0.0 - https://rushstack.io +zipsync 0.1.0 - https://rushstack.io usage: zipsync [-h] [-d] [-v] -m {pack,unpack} -a ARCHIVE_PATH -t TARGET_DIRECTORIES -b BASE_DIR -z {store,deflate,zstd,auto} From f39b8cd14c21fab1be85e1ea17df3593dc139d89 Mon Sep 17 00:00:00 2001 From: Bharat Middha <5100938+bmiddha@users.noreply.github.com> Date: Tue, 30 Sep 2025 15:09:11 -0700 Subject: [PATCH 2/6] rush change --- .../bmiddha-fix-snapshots_2025-09-30-22-09.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@rushstack/zipsync/bmiddha-fix-snapshots_2025-09-30-22-09.json diff --git a/common/changes/@rushstack/zipsync/bmiddha-fix-snapshots_2025-09-30-22-09.json b/common/changes/@rushstack/zipsync/bmiddha-fix-snapshots_2025-09-30-22-09.json new file mode 100644 index 00000000000..56706305c1e --- /dev/null +++ b/common/changes/@rushstack/zipsync/bmiddha-fix-snapshots_2025-09-30-22-09.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/zipsync", + "comment": "", + "type": "none" + } + ], + "packageName": "@rushstack/zipsync" +} \ No newline at end of file From c65fe0c9ee2353d830bcc651a171e17ca1c45785 Mon Sep 17 00:00:00 2001 From: Bharat Middha <5100938+bmiddha@users.noreply.github.com> Date: Tue, 30 Sep 2025 15:12:38 -0700 Subject: [PATCH 3/6] fix version logging in test snapshot --- apps/zipsync/src/__snapshots__/start.test.ts.snap | 14 +++++++------- apps/zipsync/src/start.test.ts | 8 ++++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/zipsync/src/__snapshots__/start.test.ts.snap b/apps/zipsync/src/__snapshots__/start.test.ts.snap index 966c59704be..6693e98799a 100644 --- a/apps/zipsync/src/__snapshots__/start.test.ts.snap +++ b/apps/zipsync/src/__snapshots__/start.test.ts.snap @@ -2,15 +2,15 @@ exports[`CLI Tool Tests should display help for "zipsync --help" 1`] = ` " -zipsync 0.1.0 - https://rushstack.io +zipsync {version} - https://rushstack.io usage: zipsync [-h] [-d] [-v] -m {pack,unpack} -a ARCHIVE_PATH -t TARGET_DIRECTORIES -b BASE_DIR -z {store,deflate,zstd,auto} - + Optional arguments: -h, --help Show this help message and exit. - -d, --debug Show the full call stack if an error occurs while + -d, --debug Show the full call stack if an error occurs while executing the tool -v, --verbose Show verbose output -m {pack,unpack}, --mode {pack,unpack} @@ -23,10 +23,10 @@ Optional arguments: -b BASE_DIR, --base-dir BASE_DIR Base directory for relative paths within the archive -z {store,deflate,zstd,auto}, --compression {store,deflate,zstd,auto} - Compression strategy when packing. \\"deflate\\" and - \\"zlib\\" attempts compression for every file (keeps - only if smaller); \\"auto\\" first skips - likely-compressed types before attempting \\"deflate\\" + Compression strategy when packing. \\"deflate\\" and + \\"zlib\\" attempts compression for every file (keeps + only if smaller); \\"auto\\" first skips + likely-compressed types before attempting \\"deflate\\" compression; \\"store\\" disables compression. For detailed help about a specific command, use: zipsync -h diff --git a/apps/zipsync/src/start.test.ts b/apps/zipsync/src/start.test.ts index ce4cb7fba4d..34acc24517c 100644 --- a/apps/zipsync/src/start.test.ts +++ b/apps/zipsync/src/start.test.ts @@ -5,7 +5,11 @@ import { execSync } from 'child_process'; describe('CLI Tool Tests', () => { it('should display help for "zipsync --help"', () => { - const startOutput = execSync('node lib/start.js --help').toString(); - expect(startOutput).toMatchSnapshot(); + const startOutput = execSync('node lib/start.js --help', { encoding: 'utf-8' }); + const normalized = startOutput.replace( + /zipsync \d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)? - https:\/\/rushstack\.io/, + 'zipsync {version} - https://rushstack.io' + ); + expect(normalized).toMatchSnapshot(); }); }); From 379b0b4707529839ba680d5854a0835237421037 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Tue, 30 Sep 2025 18:15:41 -0400 Subject: [PATCH 4/6] Move some stuff around. --- apps/zipsync/src/{ => cli}/ZipSyncCommandLineParser.ts | 4 ++-- .../{ => cli/test}/__snapshots__/start.test.ts.snap | 0 apps/zipsync/src/{ => cli/test}/start.test.ts | 0 apps/zipsync/src/start.ts | 2 +- apps/zipsync/src/{ => test}/benchmark.test.ts | 10 ++++++---- apps/zipsync/src/{ => test}/crc32.test.ts | 2 +- apps/zipsync/src/{ => test}/index.test.ts | 8 ++++---- apps/zipsync/src/{ => test}/testUtils.ts | 2 +- apps/zipsync/src/{ => test}/workerAsync.test.ts | 4 ++-- 9 files changed, 17 insertions(+), 15 deletions(-) rename apps/zipsync/src/{ => cli}/ZipSyncCommandLineParser.ts (97%) rename apps/zipsync/src/{ => cli/test}/__snapshots__/start.test.ts.snap (100%) rename apps/zipsync/src/{ => cli/test}/start.test.ts (100%) rename apps/zipsync/src/{ => test}/benchmark.test.ts (98%) rename apps/zipsync/src/{ => test}/crc32.test.ts (95%) rename apps/zipsync/src/{ => test}/index.test.ts (92%) rename apps/zipsync/src/{ => test}/testUtils.ts (97%) rename apps/zipsync/src/{ => test}/workerAsync.test.ts (94%) diff --git a/apps/zipsync/src/ZipSyncCommandLineParser.ts b/apps/zipsync/src/cli/ZipSyncCommandLineParser.ts similarity index 97% rename from apps/zipsync/src/ZipSyncCommandLineParser.ts rename to apps/zipsync/src/cli/ZipSyncCommandLineParser.ts index c0c71bcc306..594ad4c9ab6 100644 --- a/apps/zipsync/src/ZipSyncCommandLineParser.ts +++ b/apps/zipsync/src/cli/ZipSyncCommandLineParser.ts @@ -11,8 +11,8 @@ import type { import type { ConsoleTerminalProvider } from '@rushstack/terminal/lib/ConsoleTerminalProvider'; import type { ITerminal } from '@rushstack/terminal/lib/ITerminal'; -import type { IZipSyncMode, ZipSyncOptionCompression } from './zipSyncUtils'; -import { pack, unpack } from './index'; +import type { IZipSyncMode, ZipSyncOptionCompression } from '../zipSyncUtils'; +import { pack, unpack } from '../index'; export class ZipSyncCommandLineParser extends CommandLineParser { private readonly _debugParameter: CommandLineFlagParameter; diff --git a/apps/zipsync/src/__snapshots__/start.test.ts.snap b/apps/zipsync/src/cli/test/__snapshots__/start.test.ts.snap similarity index 100% rename from apps/zipsync/src/__snapshots__/start.test.ts.snap rename to apps/zipsync/src/cli/test/__snapshots__/start.test.ts.snap diff --git a/apps/zipsync/src/start.test.ts b/apps/zipsync/src/cli/test/start.test.ts similarity index 100% rename from apps/zipsync/src/start.test.ts rename to apps/zipsync/src/cli/test/start.test.ts diff --git a/apps/zipsync/src/start.ts b/apps/zipsync/src/start.ts index f1bf39e55c0..14e23e53406 100644 --- a/apps/zipsync/src/start.ts +++ b/apps/zipsync/src/start.ts @@ -5,7 +5,7 @@ import { ConsoleTerminalProvider } from '@rushstack/terminal/lib/ConsoleTerminal import { Terminal } from '@rushstack/terminal/lib/Terminal'; import { version } from '../package.json'; -import { ZipSyncCommandLineParser } from './ZipSyncCommandLineParser'; +import { ZipSyncCommandLineParser } from './cli/ZipSyncCommandLineParser'; const toolVersion: string = version; diff --git a/apps/zipsync/src/benchmark.test.ts b/apps/zipsync/src/test/benchmark.test.ts similarity index 98% rename from apps/zipsync/src/benchmark.test.ts rename to apps/zipsync/src/test/benchmark.test.ts index fdbdaa67d6b..57c4f222434 100644 --- a/apps/zipsync/src/benchmark.test.ts +++ b/apps/zipsync/src/test/benchmark.test.ts @@ -10,9 +10,9 @@ import { createHash, randomUUID } from 'crypto'; import { NoOpTerminalProvider, Terminal } from '@rushstack/terminal'; -import type { ZipSyncOptionCompression } from './zipSyncUtils'; -import { pack } from './pack'; -import { unpack } from './unpack'; +import type { ZipSyncOptionCompression } from '../zipSyncUtils'; +import { pack } from '../pack'; +import { unpack } from '../unpack'; const compressionOptions = ['store', 'deflate', 'zstd', 'auto'] satisfies ZipSyncOptionCompression[]; @@ -461,7 +461,9 @@ zipsync internally handles cleaning as part of its operation. outputLines.push('| OS | Arch | Node | CPU | Logical Cores | Memory |'); outputLines.push('| --- | --- | --- | --- | ---: | --- |'); outputLines.push( - `| ${platform()} ${release()} | ${arch()} | ${process.version} | ${cpuModel} | ${logicalCores} | ${memGB} GB |` + `| ${platform()} ${release()} | ${arch()} | ${ + process.version + } | ${cpuModel} | ${logicalCores} | ${memGB} GB |` ); outputLines.push(''); } catch { diff --git a/apps/zipsync/src/crc32.test.ts b/apps/zipsync/src/test/crc32.test.ts similarity index 95% rename from apps/zipsync/src/crc32.test.ts rename to apps/zipsync/src/test/crc32.test.ts index fb73eb5f9d5..9fbdf3cf019 100644 --- a/apps/zipsync/src/crc32.test.ts +++ b/apps/zipsync/src/test/crc32.test.ts @@ -3,7 +3,7 @@ import * as zlib from 'zlib'; -import { fallbackCrc32 } from './crc32'; +import { fallbackCrc32 } from '../crc32'; describe('crc32', () => { it('fallbackCrc32 should match zlib.crc32', () => { diff --git a/apps/zipsync/src/index.test.ts b/apps/zipsync/src/test/index.test.ts similarity index 92% rename from apps/zipsync/src/index.test.ts rename to apps/zipsync/src/test/index.test.ts index 5fe98676aca..32dbef71ddd 100644 --- a/apps/zipsync/src/index.test.ts +++ b/apps/zipsync/src/test/index.test.ts @@ -7,10 +7,10 @@ import * as fs from 'node:fs'; import { NoOpTerminalProvider } from '@rushstack/terminal/lib/NoOpTerminalProvider'; import { Terminal } from '@rushstack/terminal/lib/Terminal'; -import { pack } from './pack'; -import { unpack } from './unpack'; -import { getDemoDataDirectoryDisposable } from './testUtils'; -import type { ZipSyncOptionCompression } from './zipSyncUtils'; +import { pack } from '../pack'; +import { unpack } from '../unpack'; +import { getDemoDataDirectoryDisposable } from '../testUtils'; +import type { ZipSyncOptionCompression } from '../zipSyncUtils'; describe('zipSync tests', () => { it(`basic pack test`, () => { diff --git a/apps/zipsync/src/testUtils.ts b/apps/zipsync/src/test/testUtils.ts similarity index 97% rename from apps/zipsync/src/testUtils.ts rename to apps/zipsync/src/test/testUtils.ts index ed1555c3cd8..5adc33184d6 100644 --- a/apps/zipsync/src/testUtils.ts +++ b/apps/zipsync/src/test/testUtils.ts @@ -5,7 +5,7 @@ import { tmpdir } from 'node:os'; import * as path from 'node:path'; import * as fs from 'node:fs'; import * as crypto from 'node:crypto'; -import type { IMetadata } from './zipSyncUtils'; +import type { IMetadata } from '../zipSyncUtils'; export function getTempDir(): string { const randomId: string = crypto.randomUUID(); diff --git a/apps/zipsync/src/workerAsync.test.ts b/apps/zipsync/src/test/workerAsync.test.ts similarity index 94% rename from apps/zipsync/src/workerAsync.test.ts rename to apps/zipsync/src/test/workerAsync.test.ts index 1392f51223f..07a09357259 100644 --- a/apps/zipsync/src/workerAsync.test.ts +++ b/apps/zipsync/src/test/workerAsync.test.ts @@ -4,8 +4,8 @@ import * as path from 'node:path'; import * as fs from 'node:fs'; -import { unpackWorkerAsync } from './unpackWorkerAsync'; -import { packWorkerAsync } from './packWorkerAsync'; +import { unpackWorkerAsync } from '../unpackWorkerAsync'; +import { packWorkerAsync } from '../packWorkerAsync'; import { getDemoDataDirectoryDisposable } from './testUtils'; describe('zipSyncWorkerAsync tests', () => { From 109495569d0d90a3274d8bc26f909ef3b5760dc7 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Tue, 30 Sep 2025 18:28:08 -0400 Subject: [PATCH 5/6] fixup! Move some stuff around. --- apps/zipsync/src/cli/test/start.test.ts | 2 +- apps/zipsync/src/test/benchmark.test.ts | 10 +++++----- apps/zipsync/src/test/crc32.test.ts | 2 +- apps/zipsync/src/test/index.test.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/zipsync/src/cli/test/start.test.ts b/apps/zipsync/src/cli/test/start.test.ts index 34acc24517c..5c207ff7f02 100644 --- a/apps/zipsync/src/cli/test/start.test.ts +++ b/apps/zipsync/src/cli/test/start.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import { execSync } from 'child_process'; +import { execSync } from 'node:child_process'; describe('CLI Tool Tests', () => { it('should display help for "zipsync --help"', () => { diff --git a/apps/zipsync/src/test/benchmark.test.ts b/apps/zipsync/src/test/benchmark.test.ts index 57c4f222434..dab74ac15c5 100644 --- a/apps/zipsync/src/test/benchmark.test.ts +++ b/apps/zipsync/src/test/benchmark.test.ts @@ -2,11 +2,11 @@ // See LICENSE in the project root for license information. /* eslint-disable no-console */ -import { execSync } from 'child_process'; -import { tmpdir, cpus, platform, release, arch, totalmem } from 'os'; -import * as path from 'path'; -import * as fs from 'fs'; -import { createHash, randomUUID } from 'crypto'; +import { execSync } from 'node:child_process'; +import { tmpdir, cpus, platform, release, arch, totalmem } from 'node:os'; +import * as path from 'node:path'; +import * as fs from 'node:fs'; +import { createHash, randomUUID } from 'node:crypto'; import { NoOpTerminalProvider, Terminal } from '@rushstack/terminal'; diff --git a/apps/zipsync/src/test/crc32.test.ts b/apps/zipsync/src/test/crc32.test.ts index 9fbdf3cf019..67ccbb9180c 100644 --- a/apps/zipsync/src/test/crc32.test.ts +++ b/apps/zipsync/src/test/crc32.test.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import * as zlib from 'zlib'; +import * as zlib from 'node:zlib'; import { fallbackCrc32 } from '../crc32'; diff --git a/apps/zipsync/src/test/index.test.ts b/apps/zipsync/src/test/index.test.ts index 32dbef71ddd..42dd8d96331 100644 --- a/apps/zipsync/src/test/index.test.ts +++ b/apps/zipsync/src/test/index.test.ts @@ -9,7 +9,7 @@ import { Terminal } from '@rushstack/terminal/lib/Terminal'; import { pack } from '../pack'; import { unpack } from '../unpack'; -import { getDemoDataDirectoryDisposable } from '../testUtils'; +import { getDemoDataDirectoryDisposable } from './testUtils'; import type { ZipSyncOptionCompression } from '../zipSyncUtils'; describe('zipSync tests', () => { From 854f6f30dc134ceeb79ff9ec64fd137c4fb4ba53 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Tue, 30 Sep 2025 18:35:35 -0400 Subject: [PATCH 6/6] Ensure tests run in the project folder. --- .../src/cli/test/__snapshots__/start.test.ts.snap | 12 ++++++------ apps/zipsync/src/cli/test/start.test.ts | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/zipsync/src/cli/test/__snapshots__/start.test.ts.snap b/apps/zipsync/src/cli/test/__snapshots__/start.test.ts.snap index 6693e98799a..e005983feb4 100644 --- a/apps/zipsync/src/cli/test/__snapshots__/start.test.ts.snap +++ b/apps/zipsync/src/cli/test/__snapshots__/start.test.ts.snap @@ -6,11 +6,11 @@ zipsync {version} - https://rushstack.io usage: zipsync [-h] [-d] [-v] -m {pack,unpack} -a ARCHIVE_PATH -t TARGET_DIRECTORIES -b BASE_DIR -z {store,deflate,zstd,auto} - + Optional arguments: -h, --help Show this help message and exit. - -d, --debug Show the full call stack if an error occurs while + -d, --debug Show the full call stack if an error occurs while executing the tool -v, --verbose Show verbose output -m {pack,unpack}, --mode {pack,unpack} @@ -23,10 +23,10 @@ Optional arguments: -b BASE_DIR, --base-dir BASE_DIR Base directory for relative paths within the archive -z {store,deflate,zstd,auto}, --compression {store,deflate,zstd,auto} - Compression strategy when packing. \\"deflate\\" and - \\"zlib\\" attempts compression for every file (keeps - only if smaller); \\"auto\\" first skips - likely-compressed types before attempting \\"deflate\\" + Compression strategy when packing. \\"deflate\\" and + \\"zlib\\" attempts compression for every file (keeps + only if smaller); \\"auto\\" first skips + likely-compressed types before attempting \\"deflate\\" compression; \\"store\\" disables compression. For detailed help about a specific command, use: zipsync -h diff --git a/apps/zipsync/src/cli/test/start.test.ts b/apps/zipsync/src/cli/test/start.test.ts index 5c207ff7f02..f57f26a3ce6 100644 --- a/apps/zipsync/src/cli/test/start.test.ts +++ b/apps/zipsync/src/cli/test/start.test.ts @@ -1,11 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. +import path from 'node:path'; import { execSync } from 'node:child_process'; describe('CLI Tool Tests', () => { it('should display help for "zipsync --help"', () => { - const startOutput = execSync('node lib/start.js --help', { encoding: 'utf-8' }); + const packageFolder: string = path.resolve(__dirname, '../../..'); + const startOutput = execSync('node lib/start.js --help', { encoding: 'utf-8', cwd: packageFolder }); const normalized = startOutput.replace( /zipsync \d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)? - https:\/\/rushstack\.io/, 'zipsync {version} - https://rushstack.io'