@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
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
})
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
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
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
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
|
-
}
|
|
590
|
-
|
|
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) {
|