Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: dep updates #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ publish/src
publish/package
demo/report/report.html
demo/report/stats.json
package-lock.json
package-lock.json
*.tgz
3 changes: 2 additions & 1 deletion src/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.map
*.ts
!*.d.ts
tsconfig.json
tsconfig.json
*.tgz
19 changes: 9 additions & 10 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-zip",
"version": "4.0.2",
"name": "@nativescript/zip",
"version": "5.0.0",
"description": "A simple utility class for zipping and unzipping files in NativeScript",
"main": "zip",
"typings": "index.d.ts",
Expand All @@ -13,17 +13,16 @@
"scripts": {
"tsc": "tsc -skipLibCheck",
"build": "npm i && tsc",
"postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src && npm run plugin.link",
"postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src",
"test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch",
"test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch",
"tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/+(node_modules|typings)/**\"",
"plugin.link": "npm link && cd ../demo && npm link nativescript-zip && cd ../src",
"plugin.tscwatch": "npm run tsc -- -w",
"demo.ios": "npm i && npm run tsc && cd ../demo && tns run ios --syncAllFiles",
"demo.android": "npm i && npm run tsc && cd ../demo && tns run android --syncAllFiles",
"demo.reset": "cd ../demo && rimraf platforms",
"plugin.prepare": "npm run tsc && cd ../demo && tns plugin remove nativescript-zip && tns plugin add ../src",
"clean": "cd ../demo && rimraf hooks node_modules platforms && cd ../src && rimraf node_modules && npm run plugin.link",
"clean": "cd ../demo && npx rimraf hooks node_modules platforms package-lock.json && cd ../src && npx rimraf node_modules package-lock.json",
"ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/+(node_modules|typings)/**'"
},
"keywords": [
Expand Down Expand Up @@ -51,12 +50,12 @@
"homepage": "https://github.com/triniwiz/nativescript-zip",
"readmeFilename": "README.md",
"devDependencies": {
"tns-core-modules": "^6.0.0",
"tns-platform-declarations": "^6.0.0",
"typescript": "~3.7.2",
"@nativescript/core": "rc",
"@nativescript/types": "rc",
"typescript": "~3.9.0",
"prompt": "^1.0.0",
"rimraf": "^2.5.0",
"tslint": "^5.0.0"
"rimraf": "^3.0.2",
"tslint": "^6.1.3"
},
"dependencies": {},
"bootstrapper": "nativescript-plugin-seed"
Expand Down
6 changes: 3 additions & 3 deletions src/references.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
/// <reference path="./node_modules/@nativescript/core/global-types.d.ts" />
/// <reference path="./node_modules/@nativescript/types/ios.d.ts" />
/// <reference path="./node_modules/@nativescript/types/android.d.ts" />
/// <reference path="./typings/objc!SSZipArchive.d.ts" />
/// <reference path="./typings/tns-worker.d.ts" />
/// <reference path="./typings/zip-request.d.ts" />
Expand Down
5 changes: 3 additions & 2 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"target": "es2017",
"module": "esnext",
"moduleResolution": "node",
"declaration": true,
"removeComments": true,
"noLib": false,
Expand Down
15 changes: 7 additions & 8 deletions src/zip.android.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as fs from 'tns-core-modules/file-system';
import * as types from 'tns-core-modules/utils/types';
import { File, knownFolders, Folder, path, Utils } from '@nativescript/core';
import { UnZipOptions, ZipOptions } from './common';

export { UnZipOptions, ZipOptions } from './common';
Expand All @@ -18,11 +17,11 @@ export class Zip {

public static zip(options: ZipOptions): Promise<string> {
return new Promise((resolve, reject) => {
if (!fs.Folder.exists(options?.directory)) {
if (!Folder.exists(options?.directory)) {
return reject('Directory does not exist, invalid directory path: ' + options?.directory);
}
try {
const archive = options?.archive ?? fs.path.join(fs.knownFolders.temp().path, `${java.util.UUID.randomUUID().toString()}_archive.zip`);
const archive = options?.archive ?? path.join(knownFolders.temp().path, `${java.util.UUID.randomUUID().toString()}_archive.zip`);
this.debug(
'Zip.zip - folder=' +
options?.directory +
Expand All @@ -34,7 +33,7 @@ export class Zip {
const zipFile = new net.lingala.zip4j.ZipFile(new java.io.File(archive));
zipFile.setRunInThread(true);
const parameters = new net.lingala.zip4j.model.ZipParameters();
if (types.isString(options?.password)) {
if (Utils.isString(options?.password)) {
parameters.setEncryptionMethod(net.lingala.zip4j.model.enums.EncryptionMethod.AES);
zipFile.setPassword((java.lang.String.valueOf(options?.password) as any).toCharArray());
}
Expand Down Expand Up @@ -78,7 +77,7 @@ export class Zip {
}

public static unzip(options: UnZipOptions): Promise<any> {
if (!options?.archive || !fs.File.exists(options?.archive)) {
if (!options?.archive || !File.exists(options?.archive)) {
return Promise.reject(
`File does not exist, invalid archive path: ${options?.archive}`
);
Expand All @@ -88,10 +87,10 @@ export class Zip {
this.debug(`Zip.unzip - archive=${options?.archive}`);
const zipFile = new net.lingala.zip4j.ZipFile(options?.archive);
zipFile.setRunInThread(true);
if (zipFile.isEncrypted() && types.isString(options?.password)) {
if (zipFile.isEncrypted() && Utils.isString(options?.password)) {
zipFile.setPassword((java.lang.String.valueOf(options?.password) as any).toCharArray());
}
const tempDir = fs.path.join(fs.knownFolders.temp().path, java.util.UUID.randomUUID().toString());
const tempDir = path.join(knownFolders.temp().path, java.util.UUID.randomUUID().toString());
const directory = options?.directory ?? tempDir;
const d = new java.io.File(directory);

Expand Down
10 changes: 5 additions & 5 deletions src/zip.ios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from 'tns-core-modules/file-system';
import { Folder, path, knownFolders, File } from '@nativescript/core';
import { UnZipOptions, ZipOptions } from './common';

const background_queue = dispatch_get_global_queue(qos_class_t.QOS_CLASS_DEFAULT, 0);
Expand All @@ -18,12 +18,12 @@ export class Zip {

private static _zipRequest(options: ZipOptions): Promise<string> {
return new Promise((resolve, reject) => {
if (!options?.directory || !fs.Folder.exists(options?.directory)) {
if (!options?.directory || !Folder.exists(options?.directory)) {
return reject('Directory does not exist, invalid directory path: ' + options?.directory);
}

dispatch_async(background_queue, () => {
const archive = options?.archive ?? fs.path.join(fs.knownFolders.temp().path, `${NSUUID.UUID().UUIDString}_archive.zip`);
const archive = options?.archive ?? path.join(knownFolders.temp().path, `${NSUUID.UUID().UUIDString}_archive.zip`);
this.debug(
'Zip.zip - folder=' +
options?.directory +
Expand Down Expand Up @@ -66,10 +66,10 @@ export class Zip {

private static _unzipRequest(options: UnZipOptions): Promise<string> {
return new Promise((resolve, reject) => {
if (!fs.File.exists(options?.archive)) {
if (!File.exists(options?.archive)) {
return reject(`File does not exist, invalid archive path: ${options?.archive}`);
}
const destination = options?.directory ?? fs.path.join(fs.knownFolders.temp().path, NSUUID.UUID().UUIDString);
const destination = options?.directory ?? path.join(knownFolders.temp().path, NSUUID.UUID().UUIDString);
dispatch_async(background_queue, () => {
this.debug(`Zip.unzip - archive=${options?.archive}`);
let lastProgressPercent = 0;
Expand Down