@camunda8/cli 4.1.0 → 4.1.1-alpha.1

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.
@@ -550,45 +550,61 @@ async function extractArchive(archivePath, targetDir) {
550
550
 
551
551
  mkdirSync(targetDir, { recursive: true });
552
552
 
553
- if (archivePath.endsWith('.zip')) {
554
- return new Promise((resolve, reject) => {
555
- const proc = spawn('unzip', ['-q', archivePath, '-d', targetDir], {
556
- stdio: 'inherit',
557
- });
558
- proc.on('exit', (code) => {
559
- if (code === 0) {
560
- logger.info('Extraction complete.');
561
- resolve();
562
- } else {
563
- reject(new Error(`Extraction failed with code ${code}`));
564
- }
565
- });
566
- proc.on('error', (err) => {
567
- reject(
568
- new Error(
569
- `Failed to run unzip command: ${err.message}. Make sure unzip is installed.`,
570
- ),
571
- );
572
- });
553
+ const { command, args } = resolveExtractCommand({
554
+ archivePath,
555
+ targetDir,
556
+ platform: osPlatform(),
557
+ });
558
+
559
+ return new Promise((resolve, reject) => {
560
+ const proc = spawn(command, args, { stdio: 'inherit' });
561
+ proc.on('exit', (code, signal) => {
562
+ if (code === 0) {
563
+ logger.info('Extraction complete.');
564
+ resolve();
565
+ } else if (signal) {
566
+ reject(new Error(`Extraction terminated by signal ${signal}`));
567
+ } else {
568
+ reject(new Error(`Extraction failed with code ${code}`));
569
+ }
573
570
  });
574
- } else if (archivePath.endsWith('.tar.gz')) {
575
- return new Promise((resolve, reject) => {
576
- const proc = spawn('tar', ['-xzf', archivePath, '-C', targetDir], {
577
- stdio: 'inherit',
578
- });
579
- proc.on('exit', (code) => {
580
- if (code === 0) {
581
- logger.info('Extraction complete.');
582
- resolve();
583
- } else {
584
- reject(new Error(`Extraction failed with code ${code}`));
585
- }
586
- });
587
- proc.on('error', reject);
571
+ proc.on('error', (err) => {
572
+ reject(
573
+ new Error(
574
+ `Failed to extract archive with "${command}": ${err.message}. ` +
575
+ `Make sure "${command}" is available on your PATH.`,
576
+ ),
577
+ );
588
578
  });
589
- } else {
590
- throw new Error(`Unsupported archive format: ${archivePath}`);
579
+ });
580
+ }
581
+
582
+ /**
583
+ * Decide which extractor to spawn for a given archive and platform.
584
+ *
585
+ * Windows has no POSIX `unzip`, but ships bsdtar/libarchive as
586
+ * C:\Windows\System32\tar.exe (Windows 10 1803 / Server 2019+), and libarchive
587
+ * reads ZIP — so on win32 we extract a `.zip` with `tar -xf`. Any other
588
+ * platform extracts a `.zip` with `unzip -q`: macOS ships `unzip`
589
+ * preinstalled, and in practice Linux callers only ever pass a `.tar.gz`
590
+ * (handled below), never a `.zip`. If a Linux `.zip` were ever passed here it
591
+ * would resolve to `unzip`, and extractArchive() surfaces a clear "make sure unzip is
592
+ * on your PATH" error if the binary is missing.
593
+ *
594
+ * @param {{ archivePath: string, targetDir: string, platform: string }} opts
595
+ * @returns {{ command: string, args: string[] }}
596
+ */
597
+ export function resolveExtractCommand({ archivePath, targetDir, platform }) {
598
+ if (archivePath.endsWith('.zip')) {
599
+ if (platform === 'win32') {
600
+ return { command: 'tar', args: ['-xf', archivePath, '-C', targetDir] };
601
+ }
602
+ return { command: 'unzip', args: ['-q', archivePath, '-d', targetDir] };
603
+ }
604
+ if (archivePath.endsWith('.tar.gz')) {
605
+ return { command: 'tar', args: ['-xzf', archivePath, '-C', targetDir] };
591
606
  }
607
+ throw new Error(`Unsupported archive format: ${archivePath}`);
592
608
  }
593
609
 
594
610
  export function findC8RunBinaryPath(config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda8/cli",
3
- "version": "4.1.0",
3
+ "version": "4.1.1-alpha.1",
4
4
  "description": "Camunda 8 CLI - minimal-dependency CLI for Camunda 8 operations",
5
5
  "type": "module",
6
6
  "engines": {