{"id":21884393,"url":"https://github.com/thetechstech/node-7z-archive","last_synced_at":"2025-04-15T07:18:47.041Z","repository":{"id":39626646,"uuid":"316104159","full_name":"TheTechsTech/node-7z-archive","owner":"TheTechsTech","description":"ESM front-end to 7-Zip, featuring alternative 7z CLI tool, binaries for Linux, Windows, Mac OSX, and seamlessly create 7zip SFX self extracting archives targeting different platforms.","archived":false,"fork":false,"pushed_at":"2023-07-24T20:27:31.000Z","size":293,"stargazers_count":14,"open_issues_count":5,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T07:18:40.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheTechsTech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-11-26T02:34:40.000Z","updated_at":"2025-03-19T07:02:01.000Z","dependencies_parsed_at":"2023-02-10T00:31:24.711Z","dependency_job_id":"27f7a557-9565-4198-9137-e90c2ae31e63","html_url":"https://github.com/TheTechsTech/node-7z-archive","commit_stats":null,"previous_names":["techno-express/node-7z-archive"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheTechsTech%2Fnode-7z-archive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheTechsTech%2Fnode-7z-archive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheTechsTech%2Fnode-7z-archive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheTechsTech%2Fnode-7z-archive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheTechsTech","download_url":"https://codeload.github.com/TheTechsTech/node-7z-archive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023745,"owners_count":21199961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T10:13:50.413Z","updated_at":"2025-04-15T07:18:47.013Z","avatar_url":"https://github.com/TheTechsTech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"node-7z-archive\n=======\n\n[![NPM](https://nodei.co/npm/node-7z-archive.png)](https://nodei.co/npm/node-7z-archive/)\n\n[![Dependencies Status][david-image]][david-url] [![Node.js CI](https://github.com/techno-express/node-7z-archive/workflows/Node.js%20CI/badge.svg)](https://github.com/techno-express/node-7z-archive) [![codecov](https://codecov.io/gh/techno-express/node-7z-archive/branch/master/graph/badge.svg?token=WGQxlF48sk)](https://codecov.io/gh/techno-express/node-7z-archive) [![Maintainability][codeclimate-image]][codeclimate-url][![Release][npm-image]][npm-url]\n\n\u003e ESM front-end to 7-Zip, featuring alternative full 7z CLI tool, binaries for **Linux**, **Windows**, **Mac OSX**, seamlessly create 7zip SFX self extracting archives targeting different platforms.\n\nUsage\n-----\n\nThis library use *Promises*, it's API is consistent with standard use:\n\n```js\nimport { fullArchive } from 'node-7z-archive';\n\nfullArchive('myArchive.7z', 'destination', { p: 'myPassword' } /* 7z options/switches */)\n// Equivalent to `on('data', function (files) { // ... });`\n.progress(function (files) {\n  console.log('Some files are extracted: %s', files);\n})\n\n// When all is done\n.then(function () {\n  console.log('Extracting done!');\n})\n\n// On error\n.catch(function (err) {\n  console.error(err);\n});\n```\n\n__How to create Sfx - Self Extracting Archives.__\n\nExecutables will be built using 7-zip version _19.00_ on **Windows OS** for Windows targets.\n**Linux** and **Apple macOS** will use 7-zip version _17.02_ for all targets.\n\nimport { createSfxWindows, createSfxLinux, createSfxMac } from 'node-7z-archive';\n\n- **createSfxWindows**(name, files, destination, options, type);\n\n- **createSfxLinux**(name, files, destination, options);\n\n- **createSfxMac**(name, files, destination, options);\n\nEach will in turn call:\n**createSfx**(name, files, destination, options, type, platform, extension) as:\n\n- `name` Application name.\n- `files` Files to add.\n- `destination` Application root for the `SfxPackages` directory, will default to package root.\n  - All Sfx package archives are stored in the **created** `SfxPackages` directory.\n  - The `destination` directory must already exists.\n\n- `options` For installer config file and 7-zip switch options.\n  * `{`\n  * `title:` - Window title message, Default \"`name` installation package created on `Current running platform OS`\"\n  * `beginPrompt:` - Begin Prompt message, Default \"Do you want to install `name`?\"\"\n  * `installPath:` - \"path_to_extract\", Sets the extraction path. The extraction folder will not be deleted after the extraction.\n  * `progress:` - Value can be \"yes\" or \"no\". Default value is \"yes\".\n  * `runProgram:` - Command for executing. Default value is \"setup.exe\".\n  * Substring `% % T` will be replaced with path to temporary folder,\n  * where files were extracted\n  * `directory:` - Directory prefix for `RunProgram`. Default value is `.\\`\n  * `executeFile:` Name of file for executing\n  * `executeParameters:` Parameters for `ExecuteFile`\n  * `}`\n\n * `type` Application type `gui` or `console`. Default `gui`. Only `console` possible on **Linux** and **Mac** OS.\n * `platform` What platform application targeting? Either `win32`, `darwin`, or `linux`.\n * `extension` Binary extension name.\n\nInstallation\n------------\n\nThis package will download the 7zip binaries at install time. Host system does not need to have 7zip installed or in PATH.\n\nThe binaries will be downloaded from:\n\u003e On Linux - [![Release](https://github.com/techno-express/p7zip/workflows/Release/badge.svg)](https://github.com/techno-express/p7zip/actions/runs/401873413) compiled and available at [releases](https://github.com/techno-express/p7zip/releases/) previously https://sourceforge.net/projects/p7zip.\n\n\u003e On Windows - https://www.7-zip.org/download.html.\n\n\u003e On Mac OSX - [![Release](https://github.com/techno-express/p7zip/workflows/Release/badge.svg)](https://github.com/techno-express/p7zip/actions/runs/401873413) compiled and available at [releases](https://github.com/techno-express/p7zip/releases/) previously https://rudix.org/.\n\n```shell\nnpm install --save node-7z-archive\n```\n\nCLI\n---\n\nFor using full **7zip** from command line without installation package.\n\n```shell\nnpm install -g node-7z-archive\n```\n\nWill have **`createArchive`, `deleteArchive`, `extractArchive`, `fullArchive`, `listArchive`, `renameArchive`, `testArchive`, `updateArchive`**, **`createSfx`** available globally. To always see available commands, and binary location type:\n\n```shell\n7zip\n```\n\nOutputs:\n\n```md\nFull 7zip Console Commands.\n\n ESM front-end to 7-Zip, featuring alternative full 7z CLI tools, binaries for Linux, Windows, Mac OSX, seamlessly create 7zip SFX self extracting archives targeting different platforms.\n\n **Commands**\n\n Adds files to archive.\n Usage: `createArchive` archivePath files ...options\n\n Deletes files from archive.\n Usage: `deleteArchive` archivePath files ...options\n\n Extracts files from an archive to the current directory or to the output directory.\n Usage: `extractArchive` archivePath destination ...options\n\n Extracts files from an archive with their full paths in the current directory, or in an output directory\n Usage: `fullArchive` archivePath destination ...options\n\n Extracts only the selected files from an archive to the current directory, or in an output directory\n Usage: `onlyArchive` archivePath destination files ...options'\n\n Lists contents of archive.\n Usage: `listArchive` archivePath ...options\n\n Renames files in archive.\n Usage: `renameArchive` archivePath file pairs ...options\n\n Tests archive files.\n Usage: `testArchive` archivePath ...options\n\n Update older files in the archive and add files that are not already in the archive.\n Usage: `updateArchive` archivePath files ...options\n\n Create an Sfx - self extracting installation package for targeted platform.\n Usage: `createSfx` platform packageName files --dir [save/to] --gui | --console ...options\n\n-----------------------------------------------------------------\n The `7z` and `7za` binary on your system is located in directory: ...\\...\\node-7z-archive\\binaries\\...\n```\n\n\u003e ____This package is a rewrite of [node-7z-forall](https://github.com/techno-express/node-7z-forall)____. The original author has removed the version it was a fork of [node-7z](https://github.com/quentinrossetti/node-7z). The methods are still backwards compatible with previous naming of `add`, `delete`, `extract`, `extractFull`, `list`, `rename`, `test`, `update`.\n\nAPI\n---\n\n\u003e See the [7-Zip documentation](http://sevenzip.sourceforge.jp/chm/cmdline/index.htm) Or [7 Zip Command Line Examples](https://www.dotnetperls.com/7-zip-examples)\n\u003e for the full list of usages and options (**switches**).\n\n\u003e The type of the list of files can be either *String* or *Array*.\n\n**import SevenZip from 'node-7z-archive';**\n\n**const { SevenZip } = require('node-7z-archive');**\n\n*By method name:*\n**import { createArchive, deleteArchive, extractArchive, fullArchive, listArchive, renameArchive, testArchive, updateArchive } from 'node-7z-archive';**\n\n_____Options:_____ 7-Zip Switches, use without initial `'-'`.\n\n```md\n  -- : Stop switches and @listfile parsing\n  -ai[r[-|0]]{@listfile|!wildcard} : Include archives\n  -ax[r[-|0]]{@listfile|!wildcard} : eXclude archives\n  -ao{a|s|t|u} : set Overwrite mode\n  -an : disable archive_name field\n  -bb[0-3] : set output log level\n  -bd : disable progress indicator\n  -bs{o|e|p}{0|1|2} : set output stream for output/error/progress line\n  -bt : show execution time statistics\n  -i[r[-|0]]{@listfile|!wildcard} : Include filenames\n  -m{Parameters} : set compression Method\n    -mmt[N] : set number of CPU threads\n    -mx[N] : set compression level: -mx1 (fastest) ... -mx9 (ultra)\n  -o{Directory} : set Output directory\n  -p{Password} : set Password\n  -r[-|0] : Recurse subdirectories\n  -sa{a|e|s} : set Archive name mode\n  -scc{UTF-8|WIN|DOS} : set charset for console input/output\n  -scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files\n  -scrc[CRC32|CRC64|SHA1|SHA256|*] : set hash function for x, e, h commands\n  -sdel : delete files after compression\n  -seml[.] : send archive by email\n  -sfx[{name}] : Create SFX archive\n  -si[{name}] : read data from stdin\n  -slp : set Large Pages mode\n  -slt : show technical information for l (List) command\n  -snh : store hard links as links\n  -snl : store symbolic links as links\n  -sni : store NT security information\n  -sns[-] : store NTFS alternate streams\n  -so : write data to stdout\n  -spd : disable wildcard matching for file names\n  -spe : eliminate duplication of root folder for extract command\n  -spf : use fully qualified file paths\n  -ssc[-] : set sensitive case mode\n  -sse : stop archive creating, if it can't open some input file\n  -ssw : compress shared files\n  -stl : set archive timestamp from the most recently modified file\n  -stm{HexMask} : set CPU thread affinity mask (hexadecimal number)\n  -stx{Type} : exclude archive type\n  -t{Type} : Set type of archive\n  -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName] : Update options\n  -v{Size}[b|k|m|g] : Create volumes\n  -w[{path}] : assign Work directory. Empty path means a temporary directory\n  -x[r[-|0]]{@listfile|!wildcard} : eXclude filenames\n  -y : assume Yes on all queries\n```\n\n### `createArchive`(filepath, files, options)\n\n**Arguments**\n * `filepath` Path to the archive you want to create.\n * `files` The file list to add.\n * `options` An object of options (7-Zip switches).\n\n**Progress**\n * `files` A array of all the added files. The `/`\n   character is used as a path separator on every platform.\n\n**Error**\n * `err` An Error object.\n\n### `deleteArchive`(filepath, files, options)\n\n**Arguments**\n * `filepath` Path to the archive you want to delete files from.\n * `files` The file list to delete.\n * `options` An object of options (7-Zip switches).\n\n**Error**\n * `err` An Error object.\n\n### `extractArchive`(filepath, dest, options)\n\n**Arguments**\n * `filepath` The path to the archive you want to extract.\n * `dest` Where to extract the archive.\n * `options` An object of options.\n\n**Progress**\n * `files` A array of all the extracted files *AND* directories. The `/` character is used as a path separator on every platform.\n\n**Error**\n * `err` An Error object.\n\n### `fullArchive`(filepath, dest, options)\n\n**Arguments**\n * `filepath` The path to the archive you want to extract.\n * `dest` Where to extract with full paths, the archive (creates folders for you).\n * `options` An object of options.\n\n**Progress**\n * `files` A array of all the extracted files *AND* directories. The `/`\n   character is used as a path separator on every platform.\n\n**Error**\n * `err` An Error object.\n\n### `listArchive`(filepath, options)\n\n**Arguments**\n * `filepath` The path to the archive you want to analyze, list contents of archive.\n * `options` An object of options.\n\n**Progress**\n * `files` A array of objects of all the extracted files *AND* directories.\n   The `/` character is used as a path separator on every platform. Object's\n   properties are: `date`, `attr`, `size` and `name`.\n\n**Then - Resolved**\n * `spec` An object of tech spec about the archive. Properties are: `path`,\n   `type`, `method`, `physicalSize` and `headersSize` (Some of them may be\n   missing with non-7z archives).\n\n**Error**\n * `err` An Error object.\n\n### `onlyArchive`(filepath, dest, files, options)\n\n**Arguments**\n * `filepath` The path to the archive you want to extract selected files from.\n * `dest` Where to extract with full paths, the archive (creates folders for you).\n * `files` What files to extract, will overwrite if file exits.\n * `options` An object of options.\n\n**Progress**\n * `files` A array of all the extracted files *AND* directories. The `/`\n   character is used as a path separator on every platform.\n\n**Error**\n * `err` An Error object.\n\n### `renameArchive`(filepath, files, options)\n\n**Arguments**\n * `filepath` The path to the archive that has the file to rename.\n * `files` The file list in pairs to rename in archive.\n * `options` An object of options.\n\n**Progress**\n * `files` A array of files renamed.\n\n**Error**\n * `err` An Error object.\n\n### `testArchive`(filepath, options)\n\n**Arguments**\n * `filepath` The path to the archive you want to analyze, test integrity of archive.\n * `options` An object of options.\n\n**Progress**\n * `files` A array of all the tested files. The `/`\n   character is used as a path separator on every platform.\n\n**Error**\n * `err` An Error object.\n\n### `updateArchive`(filepath, files, options)\n\n**Arguments**\n * `filepath` Path to the archive you want to update.\n * `files` The file list to update.\n * `options` An object of options (7-Zip switches).\n\n**Progress**\n * `files` A array of all the updated files. The `/`\n   character is used as a path separator on every platform.\n\n**Error**\n * `err` An Error object.\n\n\nAdvanced usage\n--------------\n\n### Compression method\n\nWith the `7z` binary compression is made like that:\n\n```shell\n# adds *.exe and *.dll files to solid archive archive.7z using LZMA method\n# with 2 MB dictionary and BCJ filter.\n7z a archive.7z *.exe -m0=BCJ -m1=LZMA:d=21\n```\n\nWith **node-7z-archive** you can translate it like that:\n\n```js\nimport { createArchive } from 'node-7z-archive';\n\ncreateArchive('archive.7z', '*.exe', {\n  m0: '=BCJ',\n  m1: '=LZMA:d=21'\n})\n.then(function () {\n  // Do stuff...\n});\n```\n\n### createArchive, deleteArchive and updateArchive multiple files\n\nWhen adding, deleting or updating archives you can pass either a string or an array as second parameter (the `files` parameter).\n\n```js\nimport { deleteArchive } from 'node-7z-archive';\n\ndeleteArchive('bigArchive.7z', [ 'file1', 'file2' ])\n.then(function () {\n  // Do stuff...\n});\n```\n\n### Wildcards\n\nYou can extract with wildcards to specify one or more file extensions. To do\nthis add a `wildcards` attribute to the `options` object. The `wildcard`\nattribute takes an *Array* as value. In this array each item is a wildcard.\n\n```js\nimport { fullArchive } from 'node-7z-archive';\n\nfullArchive('archive.zip', 'destination/', {\n  wildcards: [ '*.txt', '*.md' ], // extract all text and Markdown files\n  r: true // in each subfolder too\n})\n.progress(function (files) {\n  // Do stuff with files...\n})\n.then(function () {\n  // Do stuff...\n});\n```\n\nNote that the `r` (for recursive) attribute is passed in this example.\n\n### Raw inputs\n\nSometimes you just want to use the lib as the original command line. For\ninstance you want to apply to switches with different values (e.g.:\n`-i!*.jpg -i!*.png` to target only two types of extensions).\n\nIn such cases the default behavior of the `options` argument is not enough. You\ncan use the custom `raw` key in your `options` object and pass it an *Array* of\nvalues.\n\n```js\nimport { listArchive } from 'node-7z-archive';\n\nlistArchive('archive.zip', {\n  raw: [ '-i!*.jpg', '-i!*.png' ], // only images\n})\n.progress(function (files) {\n  // Do stuff with files...\n})\n.then(function () {\n  // Do stuff...\n});\n```\n\n***\n\n[david-url]: https://david-dm.org/techno-express/node-7z-archive\n[david-image]: http://img.shields.io/david/techno-express/node-7z-archive.svg\n[codeclimate-url]: https://codeclimate.com/github/techno-express/node-7z-archive/maintainability\n[codeclimate-image]: https://api.codeclimate.com/v1/badges/28d7f386668a12f3ca84/maintainability\n[npm-url]: https://www.npmjs.org/package/node-7z-archive\n[npm-image]: http://img.shields.io/npm/v/node-7z-archive.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthetechstech%2Fnode-7z-archive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthetechstech%2Fnode-7z-archive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthetechstech%2Fnode-7z-archive/lists"}