Skip to content

Commit cd39aae

Browse files
committed
refactor update Linux/MacOS versions to 17.01 from different source, added cli Sfx routine, embed retrival retry
1 parent 09e9984 commit cd39aae

File tree

9 files changed

+289
-49
lines changed

9 files changed

+289
-49
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fullArchive('myArchive.7z', 'destination', { p: 'myPassword' } /* 7z options/swi
3535
__How to create Sfx - Self Extracting Archives.__
3636

3737
Executables will be built using 7-zip version _19.00_ on **Windows OS** for Windows targets.
38-
**Linux** and **Apple macOS** will use 7-zip version _16.04_ for all targets.
38+
**Linux** and **Apple macOS** will use 7-zip version _17.02_ for all targets.
3939

4040
import { createSfxWindows, createSfxLinux, createSfxMac } from 'node-7z-archive';
4141

@@ -79,11 +79,12 @@ Installation
7979
This package will download the 7zip binaries at install time. Host system does not need to have 7zip installed or in PATH.
8080

8181
The binaries will be downloaded from:
82-
> On Linux - https://sourceforge.net/projects/p7zip
82+
> 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 which has broken full `7z` version.
8383
8484
> On Windows - https://www.7-zip.org/download.html
8585
86-
> On Mac OSX - https://rudix.org/
86+
> 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/ which has broken full `7z` version.
87+
8788

8889
```shell
8990
npm install --save node-7z-archive
@@ -138,7 +139,7 @@ Full 7zip Console Commands.
138139
Usage: `updateArchive` archivePath files ...options
139140

140141
Create an Sfx - self extracting installation package for targeted platform.
141-
Usage: `createSfx` platform packageName files -destination ...options
142+
Usage: `createSfx` platform packageName files --dir [save/to] --gui | --console ...options
142143

143144
-----------------------------------------------------------------
144145
The `7z` and `7za` binary on your system is located in directory: ...\...\node-7z-archive\binaries\...

cli/7zip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function help() {
6666
'Usage: `updateArchive` archivePath files ...options',
6767
'',
6868
'Create an Sfx - self extracting installation package for targeted platform.',
69-
'Usage: `createSfx` platform packageName files -destination ...options',
69+
'Usage: `createSfx` platform packageName files --dir --gui ...options',
7070
'',
7171
'----------------------------------------------------------------',
7272
'The `7z` and `7za` binary on your system is located in directory: ' + sevenBinary.path,

cli/sfx.js

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/usr/bin/env node
2+
3+
'use strict';
4+
5+
/* eslint-disable no-process-exit */
6+
7+
/*
8+
* Dependencies.
9+
*/
10+
import {
11+
createSfxMac,
12+
createSfxLinux,
13+
createSfxWindows
14+
} from '../lib/index.mjs';
15+
import minimist from 'minimist';
16+
import {
17+
join
18+
} from 'path';
19+
import {
20+
userInfo
21+
} from 'os';
22+
import {
23+
createRequire
24+
} from 'module';
25+
26+
const require = createRequire(
27+
import.meta.url);
28+
const pack = require('../package.json');
29+
30+
/*
31+
* Arguments.
32+
*/
33+
let argv = minimist(process.argv.slice(2));
34+
35+
/*
36+
* Command.
37+
*/
38+
var command = Object.keys(pack.bin)[7];
39+
40+
/**
41+
* Help.
42+
*
43+
* @return {string}
44+
*/
45+
function help() {
46+
return [
47+
'Create an Sfx - self extracting installation package for targeted platform.',
48+
'Usage: ' + command + ' platform packageName files --dir destination --gui --console ...options',
49+
'',
50+
pack.description,
51+
'',
52+
' [platform] - Target platform, either `windows`, `linux`, or `macos`.',
53+
' [name] - Installation package name.',
54+
' [files] - Files to add.',
55+
' --dir - Save the `SFX` package to directory. Defaults to current user desktop',
56+
' --gui - Make the Sfx installation package have a Graphical User Interfere.',
57+
' --console - Make the Sfx installation package have a Console interfere.',
58+
'',
59+
'Options:',
60+
'',
61+
' -h, --help output usage information',
62+
' -v, --version output version number',
63+
'',
64+
' Any of these 7zip switches this command accepts:',
65+
'',
66+
' For Installer config if GUI and targeting Windows:',
67+
' --title - Window title message, Default "`packageName` installation package created on `Current running platform OS`".',
68+
' --prompt - Begin Prompt message, Default "Do you want to install `packageName`?"',
69+
' --progress - Value can be "yes" or "no". Default value is "no".',
70+
' --run - Command from archive for executing after extracting. Default value is "setup.exe". Substring `% % T` will be replaced with path to temporary folder, where files were extracted.',
71+
' --directory - Directory prefix for --run. Default value is `.\\`',
72+
' --execute - Name of some other system file for executing after extraction.',
73+
' --parameters - Parameters for --execute.',
74+
'',
75+
'-----------',
76+
'',
77+
' -i (Include filenames)',
78+
' -m (Set compression Method)',
79+
' -p (Set Password)',
80+
' -r (Recurse subdirectories)',
81+
' -sdel (Delete files after compression)',
82+
' -si (read data from stdin)',
83+
' -sni (Store NT security information)',
84+
' -sns (Store NTFS alternate Streams)',
85+
' -so (write data to stdout)',
86+
' -spf (Use fully qualified file paths)',
87+
' -ssw (Compress files open for writing)',
88+
' -stl (Set archive timestamp from the most recently modified file)',
89+
' -t (set Type of archive)',
90+
' -u (Update options)',
91+
' -v (Create Volumes)',
92+
' -w (set Working directory)',
93+
' -x (Exclude filenames)',
94+
'',
95+
'Example:',
96+
'> ' + command + ' windows Support disc/* support.doc --dir user/desktop --gui --title "Sample Installer Package"',
97+
''
98+
].join('\n ') + '\n';
99+
}
100+
101+
/*
102+
* Program.
103+
*/
104+
if (argv.help || argv.h) {
105+
console.log(help());
106+
} else if (argv.version || argv.v) {
107+
console.log(pack.version);
108+
} else if (argv) {
109+
let options = {};
110+
let files = argv._;
111+
let platform = files.shift();
112+
if (platform) {
113+
let packageName = files.shift();
114+
let sfxPromise = null;
115+
let destination = (argv.dir) ? argv.dir : join(userInfo().homedir, 'Desktop');
116+
let type = (argv.gui) ? 'gui' : 'console';
117+
type = (argv.console || platform === 'linux' || platform === 'macos') ? 'console' : type;
118+
delete argv._;
119+
delete argv.gui;
120+
delete argv.console;
121+
delete argv.dir;
122+
options = Object.assign(options, argv)
123+
124+
if (platform === 'win32')
125+
sfxPromise = createSfxWindows(packageName, files, destination, options, type);
126+
else if (platform === 'macos')
127+
sfxPromise = createSfxMac(packageName, files, destination, options);
128+
else if (platform === 'linux')
129+
sfxPromise = createSfxLinux(packageName, files, destination, options);
130+
131+
if (packageName && files && typeof sfxPromise.then === 'function') {
132+
console.log("Creating Sfx Package...");
133+
sfxPromise.progress((info) => {
134+
console.log(info);
135+
})
136+
.then((file) => {
137+
console.log('Creation of installation package ' + packageName + ' saved to ' + file + ' done!');
138+
})
139+
.catch((error) => {
140+
console.log('--- error:');
141+
console.log(error);
142+
});
143+
} else {
144+
console.log(help());
145+
}
146+
} else {
147+
console.log(help());
148+
}
149+
} else {
150+
console.log(help());
151+
}

cli/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let argv = minimist(process.argv.slice(2));
2727
/*
2828
* Command.
2929
*/
30-
var command = Object.keys(pack.bin)[7];
30+
var command = Object.keys(pack.bin)[8];
3131

3232
/**
3333
* Help.

cli/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let argv = minimist(process.argv.slice(2));
2727
/*
2828
* Command.
2929
*/
30-
var command = Object.keys(pack.bin)[8];
30+
var command = Object.keys(pack.bin)[9];
3131

3232
/**
3333
* Help.

0 commit comments

Comments
 (0)