gyomu 0.1.0 → 0.2.0
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.
- package/index.js +3 -0
- package/lib/archive/abstract.d.ts +7 -7
- package/lib/archive/abstract.js +23 -30
- package/lib/archive/gz.d.ts +15 -16
- package/lib/archive/gz.js +49 -66
- package/lib/archive/index.d.ts +3 -3
- package/lib/archive/index.js +3 -19
- package/lib/archive/tar.d.ts +17 -17
- package/lib/archive/tar.js +128 -165
- package/lib/archive/zip.d.ts +27 -28
- package/lib/archive/zip.js +210 -254
- package/lib/base64.d.ts +5 -6
- package/lib/base64.js +17 -24
- package/lib/buffer.d.ts +3 -4
- package/lib/buffer.js +22 -23
- package/lib/configurator.d.ts +16 -16
- package/lib/configurator.js +40 -53
- package/lib/dateOperation.d.ts +3 -3
- package/lib/dateOperation.js +17 -23
- package/lib/dbsingleton.d.ts +7 -11
- package/lib/dbsingleton.js +15 -13
- package/lib/dbutil.d.ts +3 -3
- package/lib/dbutil.js +23 -44
- package/lib/dictionary.d.ts +8 -8
- package/lib/dictionary.js +51 -55
- package/lib/encryption.d.ts +31 -17
- package/lib/encryption.js +179 -202
- package/lib/errors.d.ts +31 -31
- package/lib/errors.js +52 -64
- package/lib/excel.d.ts +1 -1
- package/lib/excel.js +7 -34
- package/lib/fileModel.d.ts +96 -96
- package/lib/fileModel.js +170 -170
- package/lib/fileOperation.d.ts +11 -11
- package/lib/fileOperation.js +196 -275
- package/lib/generated/prisma/browser.d.ts +99 -0
- package/lib/generated/prisma/browser.js +17 -0
- package/lib/generated/prisma/client.d.ts +116 -0
- package/lib/generated/prisma/client.js +32 -0
- package/lib/generated/prisma/commonInputTypes.d.ts +367 -0
- package/lib/generated/prisma/commonInputTypes.js +10 -0
- package/lib/generated/prisma/enums.d.ts +1 -0
- package/lib/generated/prisma/enums.js +10 -0
- package/lib/generated/prisma/internal/class.d.ts +324 -0
- package/lib/generated/prisma/internal/class.js +41 -0
- package/lib/generated/prisma/internal/prismaNamespace.d.ts +2052 -0
- package/lib/generated/prisma/internal/prismaNamespace.js +243 -0
- package/lib/generated/prisma/internal/prismaNamespaceBrowser.d.ts +221 -0
- package/lib/generated/prisma/internal/prismaNamespaceBrowser.js +213 -0
- package/lib/generated/prisma/models/gyomu_apps_info_cdtbl.d.ts +1013 -0
- package/lib/generated/prisma/models/gyomu_apps_info_cdtbl.js +1 -0
- package/lib/generated/prisma/models/gyomu_market_holiday.d.ts +983 -0
- package/lib/generated/prisma/models/gyomu_market_holiday.js +1 -0
- package/lib/generated/prisma/models/gyomu_milestone_cdtbl.d.ts +909 -0
- package/lib/generated/prisma/models/gyomu_milestone_cdtbl.js +1 -0
- package/lib/generated/prisma/models/gyomu_milestone_daily.d.ts +987 -0
- package/lib/generated/prisma/models/gyomu_milestone_daily.js +1 -0
- package/lib/generated/prisma/models/gyomu_param_master.d.ts +942 -0
- package/lib/generated/prisma/models/gyomu_param_master.js +1 -0
- package/lib/generated/prisma/models/gyomu_service_cdtbl.d.ts +1009 -0
- package/lib/generated/prisma/models/gyomu_service_cdtbl.js +1 -0
- package/lib/generated/prisma/models/gyomu_service_type_cdtbl.d.ts +1003 -0
- package/lib/generated/prisma/models/gyomu_service_type_cdtbl.js +1 -0
- package/lib/generated/prisma/models/gyomu_status_handler.d.ts +1075 -0
- package/lib/generated/prisma/models/gyomu_status_handler.js +1 -0
- package/lib/generated/prisma/models/gyomu_status_info.d.ts +1236 -0
- package/lib/generated/prisma/models/gyomu_status_info.js +1 -0
- package/lib/generated/prisma/models/gyomu_status_type_cdtbl.d.ts +947 -0
- package/lib/generated/prisma/models/gyomu_status_type_cdtbl.js +1 -0
- package/lib/generated/prisma/models/gyomu_task_data.d.ts +1111 -0
- package/lib/generated/prisma/models/gyomu_task_data.js +1 -0
- package/lib/generated/prisma/models/gyomu_task_data_log.d.ts +1015 -0
- package/lib/generated/prisma/models/gyomu_task_data_log.js +1 -0
- package/lib/generated/prisma/models/gyomu_task_data_status.d.ts +1015 -0
- package/lib/generated/prisma/models/gyomu_task_data_status.js +1 -0
- package/lib/generated/prisma/models/gyomu_task_info_access_list.d.ts +1074 -0
- package/lib/generated/prisma/models/gyomu_task_info_access_list.js +1 -0
- package/lib/generated/prisma/models/gyomu_task_info_cdtbl.d.ts +1098 -0
- package/lib/generated/prisma/models/gyomu_task_info_cdtbl.js +1 -0
- package/lib/generated/prisma/models/gyomu_task_instance.d.ts +1161 -0
- package/lib/generated/prisma/models/gyomu_task_instance.js +1 -0
- package/lib/generated/prisma/models/gyomu_task_instance_submit_information.d.ts +981 -0
- package/lib/generated/prisma/models/gyomu_task_instance_submit_information.js +1 -0
- package/lib/generated/prisma/models/gyomu_task_scheduler_config.d.ts +1167 -0
- package/lib/generated/prisma/models/gyomu_task_scheduler_config.js +1 -0
- package/lib/generated/prisma/models/gyomu_variable_parameter.d.ts +909 -0
- package/lib/generated/prisma/models/gyomu_variable_parameter.js +1 -0
- package/lib/generated/prisma/models.d.ts +20 -0
- package/lib/generated/prisma/models.js +1 -0
- package/lib/holidays.d.ts +20 -20
- package/lib/holidays.js +159 -200
- package/lib/index.d.ts +11 -15
- package/lib/index.js +11 -31
- package/lib/milestone.d.ts +25 -19
- package/lib/milestone.js +100 -169
- package/lib/net/_ftp.js +228 -228
- package/lib/net/ftp.d.ts +19 -19
- package/lib/net/ftp.js +97 -160
- package/lib/net/remoteConnection.d.ts +11 -11
- package/lib/net/remoteConnection.js +29 -26
- package/lib/net/sftp.d.ts +19 -19
- package/lib/net/sftp.js +86 -155
- package/lib/numberOperation.d.ts +3 -3
- package/lib/numberOperation.js +18 -24
- package/lib/parameter.d.ts +15 -14
- package/lib/parameter.js +166 -291
- package/lib/platform/common.d.ts +28 -0
- package/lib/platform/common.js +29 -0
- package/lib/platform/index.d.ts +24 -0
- package/lib/platform/index.js +3 -0
- package/lib/platform/linux.d.ts +24 -0
- package/lib/platform/linux.js +4 -0
- package/lib/platform/windows.d.ts +24 -0
- package/lib/platform/windows.js +4 -0
- package/lib/result-legacy.d.ts +22 -0
- package/lib/result-legacy.js +40 -0
- package/lib/result-new.d.ts +3 -0
- package/lib/result-new.js +7 -0
- package/lib/result.d.ts +3 -23
- package/lib/result.js +5 -47
- package/lib/timer.d.ts +12 -11
- package/lib/timer.js +33 -62
- package/lib/user.d.ts +11 -11
- package/lib/user.js +20 -23
- package/lib/variable.d.ts +11 -11
- package/lib/variable.js +378 -280
- package/lib/web/attribute.d.ts +6 -6
- package/lib/web/attribute.js +12 -29
- package/lib/web/element.d.ts +24 -24
- package/lib/web/element.js +113 -119
- package/lib/web/index.d.ts +7 -7
- package/lib/web/index.js +7 -19
- package/lib/web/page.d.ts +23 -22
- package/lib/web/page.js +82 -102
- package/lib/web/table.d.ts +15 -15
- package/lib/web/table.js +94 -110
- package/lib/web/tableColumn.d.ts +10 -10
- package/lib/web/tableColumn.js +18 -21
- package/lib/web/tableRow.d.ts +10 -10
- package/lib/web/tableRow.js +69 -80
- package/lib/web/util.d.ts +12 -12
- package/lib/web/util.js +17 -22
- package/package.json +86 -43
package/index.js
ADDED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare abstract class AbstractBaseArchive {
|
|
2
|
-
readonly archiveFileName: string;
|
|
3
|
-
constructor(tarFilename: string);
|
|
4
|
-
protected __massageEntryPath(fileName: string): string;
|
|
5
|
-
protected __createDirectoryFromFileNameIfNotExist(destinationFilename: string): void;
|
|
6
|
-
protected __createDirectoryIfNotExist(destinationPath: string): void;
|
|
7
|
-
}
|
|
1
|
+
export declare abstract class AbstractBaseArchive {
|
|
2
|
+
readonly archiveFileName: string;
|
|
3
|
+
constructor(tarFilename: string);
|
|
4
|
+
protected __massageEntryPath(fileName: string): string;
|
|
5
|
+
protected __createDirectoryFromFileNameIfNotExist(destinationFilename: string): void;
|
|
6
|
+
protected __createDirectoryIfNotExist(destinationPath: string): void;
|
|
7
|
+
}
|
package/lib/archive/abstract.js
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
directoryName
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (!fs_1.default.existsSync(directoryName)) {
|
|
25
|
-
//console.log(directoryName + ' to be created');
|
|
26
|
-
fs_1.default.mkdirSync(directoryName);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.AbstractBaseArchive = AbstractBaseArchive;
|
|
1
|
+
import { platform } from '../platform';
|
|
2
|
+
export class AbstractBaseArchive {
|
|
3
|
+
archiveFileName;
|
|
4
|
+
constructor(tarFilename) {
|
|
5
|
+
this.archiveFileName = tarFilename;
|
|
6
|
+
}
|
|
7
|
+
__massageEntryPath(fileName) {
|
|
8
|
+
return fileName.replace(/\\/g, '/');
|
|
9
|
+
}
|
|
10
|
+
__createDirectoryFromFileNameIfNotExist(destinationFilename) {
|
|
11
|
+
let directoryName = platform.dirname(destinationFilename);
|
|
12
|
+
if (destinationFilename.endsWith(platform.sep))
|
|
13
|
+
directoryName = destinationFilename;
|
|
14
|
+
return this.__createDirectoryIfNotExist(directoryName);
|
|
15
|
+
}
|
|
16
|
+
__createDirectoryIfNotExist(destinationPath) {
|
|
17
|
+
const directoryName = destinationPath;
|
|
18
|
+
if (!platform.existsSync(directoryName)) {
|
|
19
|
+
//console.log(directoryName + ' to be created');
|
|
20
|
+
platform.mkdirSync(directoryName);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
package/lib/archive/gz.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
static
|
|
12
|
-
static
|
|
13
|
-
static
|
|
14
|
-
static
|
|
15
|
-
|
|
16
|
-
}
|
|
1
|
+
import { ArchiveError } from '../errors';
|
|
2
|
+
import { ResultAsync } from '../result';
|
|
3
|
+
import { AbstractBaseArchive } from './abstract';
|
|
4
|
+
import zlib from 'zlib';
|
|
5
|
+
/**
|
|
6
|
+
* @remarks
|
|
7
|
+
* This class (extract side) doesn't support stream based retrieval yet
|
|
8
|
+
*/
|
|
9
|
+
export declare class GzipArchive extends AbstractBaseArchive {
|
|
10
|
+
static create(gzipFilename: string, sourceFilename: string): ResultAsync<boolean, ArchiveError>;
|
|
11
|
+
static extract(gzipFilename: string, destinationFilename: string): ResultAsync<boolean, ArchiveError>;
|
|
12
|
+
static getGzipTransform(): zlib.Gzip;
|
|
13
|
+
static getGunzipTransform(): zlib.Gunzip;
|
|
14
|
+
static extractStream(gzipFilename: string): zlib.Gunzip;
|
|
15
|
+
}
|
package/lib/archive/gz.js
CHANGED
|
@@ -1,66 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
static
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.on('finish', () => {
|
|
51
|
-
resolve((0, result_1.success)(true));
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
static getGzipTransform() {
|
|
57
|
-
return zlib_1.default.createGzip();
|
|
58
|
-
}
|
|
59
|
-
static getGunzipTransform() {
|
|
60
|
-
return zlib_1.default.createGunzip();
|
|
61
|
-
}
|
|
62
|
-
static extractStream(gzipFilename) {
|
|
63
|
-
return fs_1.default.createReadStream(gzipFilename).pipe(zlib_1.default.createGunzip());
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.GzipArchive = GzipArchive;
|
|
1
|
+
import { ArchiveError } from '../errors';
|
|
2
|
+
// import { fail, Result, success, PromiseResult, Failure } from '../result';
|
|
3
|
+
import { ResultAsync } from '../result';
|
|
4
|
+
import { AbstractBaseArchive } from './abstract';
|
|
5
|
+
import zlib from 'zlib';
|
|
6
|
+
import { platform } from '../platform';
|
|
7
|
+
/**
|
|
8
|
+
* @remarks
|
|
9
|
+
* This class (extract side) doesn't support stream based retrieval yet
|
|
10
|
+
*/
|
|
11
|
+
export class GzipArchive extends AbstractBaseArchive {
|
|
12
|
+
static create(gzipFilename, sourceFilename) {
|
|
13
|
+
return ResultAsync.fromSafePromise(new Promise((resolve, reject) => {
|
|
14
|
+
platform
|
|
15
|
+
.createReadStream(sourceFilename)
|
|
16
|
+
.pipe(zlib.createGzip())
|
|
17
|
+
.pipe(platform.createWriteStream(gzipFilename))
|
|
18
|
+
.on('error', (err) => {
|
|
19
|
+
reject(new ArchiveError('Error on gzip compression', err));
|
|
20
|
+
})
|
|
21
|
+
.on('finish', () => {
|
|
22
|
+
resolve(true);
|
|
23
|
+
});
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
static extract(gzipFilename, destinationFilename) {
|
|
27
|
+
return ResultAsync.fromSafePromise(new Promise((resolve, reject) => {
|
|
28
|
+
platform
|
|
29
|
+
.createReadStream(gzipFilename)
|
|
30
|
+
.pipe(zlib.createGunzip())
|
|
31
|
+
.pipe(platform.createWriteStream(destinationFilename))
|
|
32
|
+
.on('error', (err) => {
|
|
33
|
+
reject(new ArchiveError('Error on gzip uncompression', err));
|
|
34
|
+
})
|
|
35
|
+
.on('finish', () => {
|
|
36
|
+
resolve(true);
|
|
37
|
+
});
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
static getGzipTransform() {
|
|
41
|
+
return zlib.createGzip();
|
|
42
|
+
}
|
|
43
|
+
static getGunzipTransform() {
|
|
44
|
+
return zlib.createGunzip();
|
|
45
|
+
}
|
|
46
|
+
static extractStream(gzipFilename) {
|
|
47
|
+
return platform.createReadStream(gzipFilename).pipe(zlib.createGunzip());
|
|
48
|
+
}
|
|
49
|
+
}
|
package/lib/archive/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './gz';
|
|
2
|
-
export * from './tar';
|
|
3
|
-
export * from './zip';
|
|
1
|
+
export * from './gz';
|
|
2
|
+
export * from './tar';
|
|
3
|
+
export * from './zip';
|
package/lib/archive/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./gz"), exports);
|
|
18
|
-
__exportStar(require("./tar"), exports);
|
|
19
|
-
__exportStar(require("./zip"), exports);
|
|
1
|
+
export * from './gz';
|
|
2
|
+
export * from './tar';
|
|
3
|
+
export * from './zip';
|
package/lib/archive/tar.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { FileTransportInfo } from '../fileModel';
|
|
2
|
-
import { ArchiveError } from '../errors';
|
|
3
|
-
import {
|
|
4
|
-
import { AbstractBaseArchive } from './abstract';
|
|
5
|
-
/**
|
|
6
|
-
* @remarks
|
|
7
|
-
* This class (extract side) doesn't support stream based retrieval yet
|
|
8
|
-
*/
|
|
9
|
-
export declare class TarArchive extends AbstractBaseArchive {
|
|
10
|
-
static create(tarFileName: string, transferInformation: FileTransportInfo, needGZipCompression?: boolean):
|
|
11
|
-
constructor(tarFilename: string);
|
|
12
|
-
fileExists(fileName: string):
|
|
13
|
-
extractSingileFile(sourceEntryFullName: string, destinationFolderName: string):
|
|
14
|
-
extractDirectory(sourceDirectory: string, destinationDirectory: string):
|
|
15
|
-
extractAll(destinationDirectory: string):
|
|
16
|
-
extract(transferInformation: FileTransportInfo):
|
|
17
|
-
}
|
|
1
|
+
import { FileTransportInfo } from '../fileModel';
|
|
2
|
+
import { ArchiveError } from '../errors';
|
|
3
|
+
import { ResultAsync } from '../result';
|
|
4
|
+
import { AbstractBaseArchive } from './abstract';
|
|
5
|
+
/**
|
|
6
|
+
* @remarks
|
|
7
|
+
* This class (extract side) doesn't support stream based retrieval yet
|
|
8
|
+
*/
|
|
9
|
+
export declare class TarArchive extends AbstractBaseArchive {
|
|
10
|
+
static create(tarFileName: string, transferInformation: FileTransportInfo, needGZipCompression?: boolean): ResultAsync<boolean, ArchiveError>;
|
|
11
|
+
constructor(tarFilename: string);
|
|
12
|
+
fileExists(fileName: string): ResultAsync<boolean, ArchiveError>;
|
|
13
|
+
extractSingileFile(sourceEntryFullName: string, destinationFolderName: string): ResultAsync<boolean, ArchiveError>;
|
|
14
|
+
extractDirectory(sourceDirectory: string, destinationDirectory: string): ResultAsync<boolean, ArchiveError>;
|
|
15
|
+
extractAll(destinationDirectory: string): ResultAsync<boolean, ArchiveError>;
|
|
16
|
+
extract(transferInformation: FileTransportInfo): ResultAsync<boolean, ArchiveError>;
|
|
17
|
+
}
|
package/lib/archive/tar.js
CHANGED
|
@@ -1,165 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
this.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return !targetEntryName || path.startsWith(targetEntryName);
|
|
130
|
-
},
|
|
131
|
-
strip: numPathElementToSkip,
|
|
132
|
-
})
|
|
133
|
-
.then(() => {
|
|
134
|
-
resolve((0, result_1.success)(true));
|
|
135
|
-
})
|
|
136
|
-
.catch((reason) => {
|
|
137
|
-
resolve(new result_1.Failure(new errors_1.ArchiveError(`Fail to untar ${this.archiveFileName} -> ${targetEntryName}`, reason)));
|
|
138
|
-
});
|
|
139
|
-
}));
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
extractAll(destinationDirectory) {
|
|
143
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
-
return this.extractDirectory('', destinationDirectory);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
extract(transferInformation) {
|
|
148
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
//console.log('directory', directory);
|
|
150
|
-
const targetEntryName = this.__massageEntryPath(transferInformation.sourceFullName);
|
|
151
|
-
if (transferInformation.sourceFileName !==
|
|
152
|
-
transferInformation.destinationFileName)
|
|
153
|
-
return (0, result_1.fail)('Destination filename must be same as original filename', errors_1.ArchiveError);
|
|
154
|
-
//console.log('targetEntryName:', targetEntryName, ':');
|
|
155
|
-
//const directory = await unzipper.Open.file(this.zipFilename);
|
|
156
|
-
if (!transferInformation.isSourceDirectory) {
|
|
157
|
-
return yield this.extractSingileFile(transferInformation.sourceFullName, transferInformation.destinationPath);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
return yield this.extractDirectory(transferInformation.sourceFullName, transferInformation.destinationFullName);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
exports.TarArchive = TarArchive;
|
|
1
|
+
import { ArchiveError } from '../errors';
|
|
2
|
+
//import { fail, Result, success, PromiseResult, Failure } from '../result';
|
|
3
|
+
import { ResultAsync, errAsync, okAsync } from '../result';
|
|
4
|
+
// import tarStream from 'tar-stream';
|
|
5
|
+
// import tar from 'tar-fs';
|
|
6
|
+
import * as tar from 'tar';
|
|
7
|
+
import { AbstractBaseArchive } from './abstract';
|
|
8
|
+
/**
|
|
9
|
+
* @remarks
|
|
10
|
+
* This class (extract side) doesn't support stream based retrieval yet
|
|
11
|
+
*/
|
|
12
|
+
export class TarArchive extends AbstractBaseArchive {
|
|
13
|
+
static create(tarFileName, transferInformation, needGZipCompression = false) {
|
|
14
|
+
// let currentDirectory = path.dirname(
|
|
15
|
+
// transferInformation.sourceFullNameWithBasePath
|
|
16
|
+
// );
|
|
17
|
+
// let targetPathForTar =
|
|
18
|
+
// transferInformation.sourceFullNameWithBasePath.substring(
|
|
19
|
+
// currentDirectory.length + path.sep.length
|
|
20
|
+
// );
|
|
21
|
+
// console.log('current', currentDirectory);
|
|
22
|
+
// console.log('target', targetPathForTar);
|
|
23
|
+
if (!transferInformation.isSourceDirectory) {
|
|
24
|
+
return errAsync(new ArchiveError('Single File is not supported'));
|
|
25
|
+
}
|
|
26
|
+
// let tarOptions: tar.CreateOptions & tar.FileOptions;
|
|
27
|
+
// tarOptions = {
|
|
28
|
+
// file: tarFileName,
|
|
29
|
+
// cwd: transferInformation.sourceFullNameWithBasePath,
|
|
30
|
+
// };
|
|
31
|
+
// if (needGZipCompression) {
|
|
32
|
+
// tarOptions = {
|
|
33
|
+
// file: tarFileName,
|
|
34
|
+
// cwd: transferInformation.sourceFullNameWithBasePath,
|
|
35
|
+
// gzip: true,
|
|
36
|
+
// };
|
|
37
|
+
// }
|
|
38
|
+
return ResultAsync.fromSafePromise(new Promise((resolve, reject) => {
|
|
39
|
+
let result;
|
|
40
|
+
if (!needGZipCompression) {
|
|
41
|
+
result = tar.create({
|
|
42
|
+
file: tarFileName,
|
|
43
|
+
cwd: transferInformation.sourceFullNameWithBasePath,
|
|
44
|
+
}, ['']);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
result = tar.create({
|
|
48
|
+
file: tarFileName,
|
|
49
|
+
cwd: transferInformation.sourceFullNameWithBasePath,
|
|
50
|
+
gzip: true,
|
|
51
|
+
}, ['']);
|
|
52
|
+
}
|
|
53
|
+
result
|
|
54
|
+
.then(() => {
|
|
55
|
+
return resolve(true);
|
|
56
|
+
})
|
|
57
|
+
.catch((err) => {
|
|
58
|
+
return reject(new ArchiveError('Fail to Tar archive', err));
|
|
59
|
+
});
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
constructor(tarFilename) {
|
|
63
|
+
super(tarFilename);
|
|
64
|
+
}
|
|
65
|
+
fileExists(fileName) {
|
|
66
|
+
fileName = this.__massageEntryPath(fileName);
|
|
67
|
+
let isExist = false;
|
|
68
|
+
return ResultAsync.fromPromise(tar.list({
|
|
69
|
+
file: this.archiveFileName,
|
|
70
|
+
onentry: (entry) => {
|
|
71
|
+
if (entry.path === fileName)
|
|
72
|
+
isExist = true;
|
|
73
|
+
},
|
|
74
|
+
}), () => new ArchiveError('Fail to list tar archive')).andThen(() => okAsync(isExist));
|
|
75
|
+
}
|
|
76
|
+
extractSingileFile(sourceEntryFullName, destinationFolderName) {
|
|
77
|
+
const targetEntryName = this.__massageEntryPath(sourceEntryFullName);
|
|
78
|
+
const numPathElementToSkip = (targetEntryName.match(/\//g) || []).length;
|
|
79
|
+
this.__createDirectoryIfNotExist(destinationFolderName);
|
|
80
|
+
return ResultAsync.fromSafePromise(tar
|
|
81
|
+
.extract({
|
|
82
|
+
cwd: destinationFolderName,
|
|
83
|
+
file: this.archiveFileName,
|
|
84
|
+
filter: (path) => path === targetEntryName,
|
|
85
|
+
strip: numPathElementToSkip,
|
|
86
|
+
})
|
|
87
|
+
.then(() => true)
|
|
88
|
+
.catch((reason) => {
|
|
89
|
+
throw new ArchiveError(`Fail to untar ${this.archiveFileName} -> ${targetEntryName}`, reason);
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
extractDirectory(sourceDirectory, destinationDirectory) {
|
|
93
|
+
const targetEntryName = this.__massageEntryPath(sourceDirectory);
|
|
94
|
+
const numPathElementToSkip = !sourceDirectory
|
|
95
|
+
? 0
|
|
96
|
+
: (targetEntryName.match(/\//g) || []).length + 1;
|
|
97
|
+
//let directoryName = path.dirname(destinationDirectory);
|
|
98
|
+
this.__createDirectoryIfNotExist(destinationDirectory);
|
|
99
|
+
return ResultAsync.fromPromise(tar
|
|
100
|
+
.extract({
|
|
101
|
+
cwd: destinationDirectory,
|
|
102
|
+
file: this.archiveFileName,
|
|
103
|
+
filter: (path) => !targetEntryName || path.startsWith(targetEntryName),
|
|
104
|
+
strip: numPathElementToSkip,
|
|
105
|
+
})
|
|
106
|
+
.then(() => true), (reason) => new ArchiveError(`Fail to untar ${this.archiveFileName} -> ${targetEntryName}`, reason));
|
|
107
|
+
}
|
|
108
|
+
extractAll(destinationDirectory) {
|
|
109
|
+
return this.extractDirectory('', destinationDirectory);
|
|
110
|
+
}
|
|
111
|
+
extract(transferInformation) {
|
|
112
|
+
//console.log('directory', directory);
|
|
113
|
+
// const targetEntryName = this.__massageEntryPath(
|
|
114
|
+
// transferInformation.sourceFullName
|
|
115
|
+
// );
|
|
116
|
+
if (transferInformation.sourceFileName !==
|
|
117
|
+
transferInformation.destinationFileName)
|
|
118
|
+
return errAsync(new ArchiveError('Destination filename must be same as original filename'));
|
|
119
|
+
//console.log('targetEntryName:', targetEntryName, ':');
|
|
120
|
+
//const directory = await unzipper.Open.file(this.zipFilename);
|
|
121
|
+
if (!transferInformation.isSourceDirectory) {
|
|
122
|
+
return this.extractSingileFile(transferInformation.sourceFullName, transferInformation.destinationPath);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
return this.extractDirectory(transferInformation.sourceFullName, transferInformation.destinationFullName);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|