@shopify/cli-kit 3.87.1 → 3.87.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLI_KIT_VERSION = "3.87.
|
|
1
|
+
export declare const CLI_KIT_VERSION = "3.87.3";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const CLI_KIT_VERSION = '3.87.
|
|
1
|
+
export const CLI_KIT_VERSION = '3.87.3';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.87.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.87.3'\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { relativePath, joinPath, dirname } from './path.js';
|
|
2
|
-
import { glob, removeFile
|
|
2
|
+
import { glob, removeFile } from './fs.js';
|
|
3
3
|
import { outputDebug, outputContent, outputToken } from '../../public/node/output.js';
|
|
4
4
|
import archiver from 'archiver';
|
|
5
5
|
import { createWriteStream, readFileSync, writeFileSync } from 'fs';
|
|
6
|
+
import { readFile } from 'fs/promises';
|
|
6
7
|
import { tmpdir } from 'os';
|
|
7
8
|
import { randomUUID } from 'crypto';
|
|
8
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../../src/public/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,WAAW,CAAA;AAC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AC,CAAA;QAEF,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC9C,CAAC;QAED,aAAa,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;IAC/C,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,MAAM,UAAU,CAAC,WAAW,CAAC,CAAA;YAC7B,qDAAqD;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,aAAa,CAAA,sCAAsC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;QACjG,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import {relativePath, joinPath, dirname} from './path.js'\nimport {glob, removeFile, readFile} from './fs.js'\nimport {outputDebug, outputContent, outputToken} from '../../public/node/output.js'\nimport archiver from 'archiver'\nimport {createWriteStream, readFileSync, writeFileSync} from 'fs'\nimport {tmpdir} from 'os'\nimport {randomUUID} from 'crypto'\n\ninterface ZipOptions {\n /**\n * The absolute path to the directory to be zipped.\n */\n inputDirectory: string\n\n /**\n * The absolute path to the output zip file.\n */\n outputZipPath: string\n\n /**\n * Pattern(s) to match when adding files to zip, uses glob expressions.\n */\n matchFilePattern?: string | string[]\n}\n\n/**\n * It zips a directory and by default normalizes the paths to be forward-slash.\n * Even with forward-slash paths, zip files should still be able to be opened on\n * Windows.\n *\n * @param options - ZipOptions.\n */\nexport async function zip(options: ZipOptions): Promise<void> {\n const {inputDirectory, outputZipPath, matchFilePattern = '**/*'} = options\n outputDebug(outputContent`Zipping ${outputToken.path(inputDirectory)} into ${outputToken.path(outputZipPath)}`)\n const pathsToZip = await glob(matchFilePattern, {\n cwd: inputDirectory,\n absolute: true,\n dot: true,\n followSymbolicLinks: false,\n })\n\n return new Promise((resolve, reject) => {\n const archive = archiver('zip')\n\n const output = createWriteStream(outputZipPath)\n output.on('close', () => {\n resolve()\n })\n archive.on('error', (error) => {\n reject(error)\n })\n archive.pipe(output)\n\n const directoriesToAdd = new Set<string>()\n for (const filePath of pathsToZip) {\n const fileRelativePath = relativePath(inputDirectory, filePath)\n collectParentDirectories(fileRelativePath, directoriesToAdd)\n }\n\n const sortedDirs = Array.from(directoriesToAdd).sort((left, right) => left.localeCompare(right))\n for (const dir of sortedDirs) {\n const dirName = dir.endsWith('/') ? dir : `${dir}/`\n archive.append(Buffer.alloc(0), {name: dirName})\n }\n\n // Read all files immediately before adding to archive to prevent ENOENT errors\n // Using archive.file() causes lazy loading which fails if files are deleted before finalize()\n const addFilesPromises = pathsToZip.map(async (filePath) => {\n await archiveFile(inputDirectory, filePath, archive)\n })\n\n // Wait for all files to be read and added before finalizing\n Promise.all(addFilesPromises)\n .then(() => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n archive.finalize()\n })\n .catch((error) => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(error)\n })\n })\n}\n\nfunction collectParentDirectories(fileRelativePath: string, accumulator: Set<string>): void {\n let currentDir = dirname(fileRelativePath)\n while (currentDir && currentDir !== '.' && currentDir !== '/') {\n accumulator.add(currentDir)\n const parent = dirname(currentDir)\n if (parent === currentDir) break\n currentDir = parent\n }\n}\n\nasync function archiveFile(inputDirectory: string, filePath: string, archive: archiver.Archiver): Promise<void> {\n const fileRelativePath = relativePath(inputDirectory, filePath)\n if (!filePath || !fileRelativePath) return\n\n // Read file content immediately to avoid race conditions\n const fileContent = await readFile(filePath)\n // Use append with Buffer instead of file() to avoid lazy file reading\n archive.append(fileContent, {name: fileRelativePath})\n}\n\nexport interface BrotliOptions {\n /**\n * The directory to compress.\n */\n inputDirectory: string\n\n /**\n * The path where the compressed file will be saved.\n */\n outputPath: string\n\n /**\n * An optional glob pattern to match files.\n */\n matchFilePattern?: string | string[]\n\n /**\n * Brotli compression level (0-11, default: 11).\n */\n level?: number\n}\n\n/**\n * Options for decompressing a Brotli compressed tar archive.\n */\nexport interface DecompressionOptions {\n /**\n * Path to the compressed file.\n */\n inputFile: string\n\n /**\n * Directory where files should be extracted.\n */\n outputDirectory: string\n}\n\n/**\n * It compresses a directory with Brotli.\n * First creates a tar archive to preserve directory structure,\n * then compresses it with Brotli.\n *\n * @param options - BrotliOptions.\n */\nexport async function brotliCompress(options: BrotliOptions): Promise<void> {\n const tempTarPath = joinPath(tmpdir(), `${randomUUID()}.tar`)\n\n try {\n // Create tar archive using archiver\n await new Promise<void>((resolve, reject) => {\n const archive = archiver('tar')\n const output = createWriteStream(tempTarPath)\n\n output.on('close', () => resolve())\n archive.on('error', (error) => reject(error))\n archive.pipe(output)\n\n glob(options.matchFilePattern ?? '**/*', {\n cwd: options.inputDirectory,\n absolute: true,\n dot: true,\n followSymbolicLinks: false,\n })\n .then(async (pathsToZip) => {\n // Read all files immediately to prevent ENOENT errors during race conditions\n const addFilesPromises = pathsToZip.map(async (filePath) => {\n await archiveFile(options.inputDirectory, filePath, archive)\n })\n\n await Promise.all(addFilesPromises)\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n archive.finalize()\n })\n .catch((error) => {\n reject(error instanceof Error ? error : new Error(String(error)))\n })\n })\n\n const tarContent = readFileSync(tempTarPath)\n const brotli = await import('brotli')\n const compressed = brotli.default.compress(tarContent, {\n quality: 7,\n mode: 0,\n })\n\n if (!compressed) {\n throw new Error('Brotli compression failed')\n }\n\n writeFileSync(options.outputPath, compressed)\n } finally {\n try {\n await removeFile(tempTarPath)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n outputDebug(outputContent`Failed to clean up temporary file: ${outputToken.path(tempTarPath)}`)\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../../src/public/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,WAAW,CAAA;AACzD,OAAO,EAAC,IAAI,EAAE,UAAU,EAAC,MAAM,SAAS,CAAA;AACxC,OAA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U,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC9C,CAAC;QAED,aAAa,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;IAC/C,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,MAAM,UAAU,CAAC,WAAW,CAAC,CAAA;YAC7B,qDAAqD;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,aAAa,CAAA,sCAAsC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;QACjG,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import {relativePath, joinPath, dirname} from './path.js'\nimport {glob, removeFile} from './fs.js'\nimport {outputDebug, outputContent, outputToken} from '../../public/node/output.js'\nimport archiver from 'archiver'\nimport {createWriteStream, readFileSync, writeFileSync} from 'fs'\nimport {readFile} from 'fs/promises'\nimport {tmpdir} from 'os'\nimport {randomUUID} from 'crypto'\n\ninterface ZipOptions {\n /**\n * The absolute path to the directory to be zipped.\n */\n inputDirectory: string\n\n /**\n * The absolute path to the output zip file.\n */\n outputZipPath: string\n\n /**\n * Pattern(s) to match when adding files to zip, uses glob expressions.\n */\n matchFilePattern?: string | string[]\n}\n\n/**\n * It zips a directory and by default normalizes the paths to be forward-slash.\n * Even with forward-slash paths, zip files should still be able to be opened on\n * Windows.\n *\n * @param options - ZipOptions.\n */\nexport async function zip(options: ZipOptions): Promise<void> {\n const {inputDirectory, outputZipPath, matchFilePattern = '**/*'} = options\n outputDebug(outputContent`Zipping ${outputToken.path(inputDirectory)} into ${outputToken.path(outputZipPath)}`)\n const pathsToZip = await glob(matchFilePattern, {\n cwd: inputDirectory,\n absolute: true,\n dot: true,\n followSymbolicLinks: false,\n })\n\n return new Promise((resolve, reject) => {\n const archive = archiver('zip')\n\n const output = createWriteStream(outputZipPath)\n output.on('close', () => {\n resolve()\n })\n archive.on('error', (error) => {\n reject(error)\n })\n archive.pipe(output)\n\n const directoriesToAdd = new Set<string>()\n for (const filePath of pathsToZip) {\n const fileRelativePath = relativePath(inputDirectory, filePath)\n collectParentDirectories(fileRelativePath, directoriesToAdd)\n }\n\n const sortedDirs = Array.from(directoriesToAdd).sort((left, right) => left.localeCompare(right))\n for (const dir of sortedDirs) {\n const dirName = dir.endsWith('/') ? dir : `${dir}/`\n archive.append(Buffer.alloc(0), {name: dirName})\n }\n\n // Read all files immediately before adding to archive to prevent ENOENT errors\n // Using archive.file() causes lazy loading which fails if files are deleted before finalize()\n const addFilesPromises = pathsToZip.map(async (filePath) => {\n await archiveFile(inputDirectory, filePath, archive)\n })\n\n // Wait for all files to be read and added before finalizing\n Promise.all(addFilesPromises)\n .then(() => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n archive.finalize()\n })\n .catch((error) => {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(error)\n })\n })\n}\n\nfunction collectParentDirectories(fileRelativePath: string, accumulator: Set<string>): void {\n let currentDir = dirname(fileRelativePath)\n while (currentDir && currentDir !== '.' && currentDir !== '/') {\n accumulator.add(currentDir)\n const parent = dirname(currentDir)\n if (parent === currentDir) break\n currentDir = parent\n }\n}\n\nasync function archiveFile(inputDirectory: string, filePath: string, archive: archiver.Archiver): Promise<void> {\n const fileRelativePath = relativePath(inputDirectory, filePath)\n if (!filePath || !fileRelativePath) return\n\n // Read file content immediately to avoid race conditions\n const fileContent = await readFile(filePath)\n // Use append with Buffer instead of file() to avoid lazy file reading\n archive.append(fileContent, {name: fileRelativePath})\n}\n\nexport interface BrotliOptions {\n /**\n * The directory to compress.\n */\n inputDirectory: string\n\n /**\n * The path where the compressed file will be saved.\n */\n outputPath: string\n\n /**\n * An optional glob pattern to match files.\n */\n matchFilePattern?: string | string[]\n\n /**\n * Brotli compression level (0-11, default: 11).\n */\n level?: number\n}\n\n/**\n * Options for decompressing a Brotli compressed tar archive.\n */\nexport interface DecompressionOptions {\n /**\n * Path to the compressed file.\n */\n inputFile: string\n\n /**\n * Directory where files should be extracted.\n */\n outputDirectory: string\n}\n\n/**\n * It compresses a directory with Brotli.\n * First creates a tar archive to preserve directory structure,\n * then compresses it with Brotli.\n *\n * @param options - BrotliOptions.\n */\nexport async function brotliCompress(options: BrotliOptions): Promise<void> {\n const tempTarPath = joinPath(tmpdir(), `${randomUUID()}.tar`)\n\n try {\n // Create tar archive using archiver\n await new Promise<void>((resolve, reject) => {\n const archive = archiver('tar')\n const output = createWriteStream(tempTarPath)\n\n output.on('close', () => resolve())\n archive.on('error', (error) => reject(error))\n archive.pipe(output)\n\n glob(options.matchFilePattern ?? '**/*', {\n cwd: options.inputDirectory,\n absolute: true,\n dot: true,\n followSymbolicLinks: false,\n })\n .then(async (pathsToZip) => {\n // Read all files immediately to prevent ENOENT errors during race conditions\n const addFilesPromises = pathsToZip.map(async (filePath) => {\n await archiveFile(options.inputDirectory, filePath, archive)\n })\n\n await Promise.all(addFilesPromises)\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n archive.finalize()\n })\n .catch((error) => {\n reject(error instanceof Error ? error : new Error(String(error)))\n })\n })\n\n const tarContent = readFileSync(tempTarPath)\n const brotli = await import('brotli')\n const compressed = brotli.default.compress(tarContent, {\n quality: 7,\n mode: 0,\n })\n\n if (!compressed) {\n throw new Error('Brotli compression failed')\n }\n\n writeFileSync(options.outputPath, compressed)\n } finally {\n try {\n await removeFile(tempTarPath)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n outputDebug(outputContent`Failed to clean up temporary file: ${outputToken.path(tempTarPath)}`)\n }\n }\n}\n"]}
|