@sap-ux/environment-check 0.13.0 → 0.14.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/dist/archive/index.d.ts +11 -0
- package/dist/archive/index.d.ts.map +1 -0
- package/dist/archive/index.js +111 -0
- package/dist/archive/index.js.map +1 -0
- package/dist/formatter.d.ts +7 -0
- package/dist/formatter.d.ts.map +1 -1
- package/dist/formatter.js +16 -1
- package/dist/formatter.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/output/zip.d.ts +0 -10
- package/dist/output/zip.d.ts.map +1 -1
- package/dist/output/zip.js +3 -81
- package/dist/output/zip.js.map +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Archive a project to zip file. Result file is written to parent of the project root folder.
|
|
3
|
+
*
|
|
4
|
+
* @param projectRoot - root of the project, where package.json is located
|
|
5
|
+
* @param targetFileName - optional file name, defaults to project folder + timestamp + .zip
|
|
6
|
+
*/
|
|
7
|
+
export declare function archiveProject(projectRoot: string, targetFileName?: string): Promise<{
|
|
8
|
+
path: string;
|
|
9
|
+
size: string;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/archive/index.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAsB,cAAc,CAChC,WAAW,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAiCzC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.archiveProject = void 0;
|
|
35
|
+
const fs_1 = require("fs");
|
|
36
|
+
const path_1 = require("path");
|
|
37
|
+
const archiver = __importStar(require("archiver"));
|
|
38
|
+
const glob_gitignore_1 = require("glob-gitignore");
|
|
39
|
+
const ignore_1 = __importDefault(require("ignore"));
|
|
40
|
+
const i18n_1 = require("../i18n");
|
|
41
|
+
const formatter_1 = require("../formatter");
|
|
42
|
+
/**
|
|
43
|
+
* Archive a project to zip file. Result file is written to parent of the project root folder.
|
|
44
|
+
*
|
|
45
|
+
* @param projectRoot - root of the project, where package.json is located
|
|
46
|
+
* @param targetFileName - optional file name, defaults to project folder + timestamp + .zip
|
|
47
|
+
*/
|
|
48
|
+
function archiveProject(projectRoot, targetFileName) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
if (!fs_1.existsSync(projectRoot)) {
|
|
51
|
+
return Promise.reject(new Error(i18n_1.t('error.noProjectRoot', { projectRoot })));
|
|
52
|
+
}
|
|
53
|
+
const fileList = yield getFileList(projectRoot);
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
try {
|
|
56
|
+
const zip = archiver.default('zip', { zlib: { level: 9 } });
|
|
57
|
+
let targetName = '';
|
|
58
|
+
if (typeof targetFileName === 'string') {
|
|
59
|
+
targetName = targetFileName.toLocaleLowerCase().endsWith('.zip')
|
|
60
|
+
? targetFileName
|
|
61
|
+
: targetFileName + '.zip';
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
targetName = `${path_1.basename(projectRoot)}-${new Date()
|
|
65
|
+
.toISOString()
|
|
66
|
+
.replace('T', '')
|
|
67
|
+
.replace(':', '')
|
|
68
|
+
.substring(0, 14)}.zip`;
|
|
69
|
+
}
|
|
70
|
+
const targetPath = path_1.join(path_1.dirname(projectRoot), targetName);
|
|
71
|
+
const writeStream = fs_1.createWriteStream(targetPath);
|
|
72
|
+
zip.pipe(writeStream);
|
|
73
|
+
zip.on('error', (error) => reject(error));
|
|
74
|
+
for (const file of fileList) {
|
|
75
|
+
zip.file(path_1.join(projectRoot, file), { name: file });
|
|
76
|
+
}
|
|
77
|
+
writeStream.on('close', () => resolve({ path: targetPath, size: formatter_1.byteNumberToSizeString(zip.pointer()) }));
|
|
78
|
+
zip.finalize();
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
reject(error);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.archiveProject = archiveProject;
|
|
87
|
+
/**
|
|
88
|
+
* Get list of files to be added to archive. Depending on the existence of file {cwd}/.gitignore, we use either a default filter
|
|
89
|
+
* or the .gitignore content.
|
|
90
|
+
*
|
|
91
|
+
* @param cwd - working directory, usually the project root
|
|
92
|
+
* @returns - list of files to add to the archive, relative to cwd
|
|
93
|
+
*/
|
|
94
|
+
function getFileList(cwd) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const gitignorePath = path_1.join(cwd, '.gitignore');
|
|
97
|
+
const hasGitignore = fs_1.existsSync(gitignorePath);
|
|
98
|
+
const globPattern = hasGitignore ? ['**'] : ['**', '.cdsrc.json', '.extconfig.json'];
|
|
99
|
+
const dot = hasGitignore;
|
|
100
|
+
const ignores = hasGitignore ? (yield fs_1.promises.readFile(gitignorePath)).toString() : ['**/.env', '**/node_modules'];
|
|
101
|
+
const skip = hasGitignore ? undefined : ['**/node_modules/**'];
|
|
102
|
+
const files = yield glob_gitignore_1.glob(globPattern, {
|
|
103
|
+
cwd,
|
|
104
|
+
dot,
|
|
105
|
+
ignore: ignore_1.default().add(ignores),
|
|
106
|
+
skip
|
|
107
|
+
});
|
|
108
|
+
return files;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/archive/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAA6D;AAC7D,+BAA+C;AAC/C,mD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,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC;QAE/D,MAAM,KAAK,GAAG,MAAM,qBAAI,CAAC,WAAW,EAAE;YAClC,GAAG;YACH,GAAG;YACH,MAAM,EAAE,gBAAM,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;YAC7B,IAAI;SACP,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACjB,CAAC;CAAA"}
|
package/dist/formatter.d.ts
CHANGED
|
@@ -21,4 +21,11 @@ export declare function getServiceCountText(count: number): string;
|
|
|
21
21
|
* @returns - replacer that replaces circular structures
|
|
22
22
|
*/
|
|
23
23
|
export declare function getCircularReplacer(): (key: string, value: any) => any;
|
|
24
|
+
/**
|
|
25
|
+
* Convert an int byte number to a nice output format like 1.23 KB.
|
|
26
|
+
*
|
|
27
|
+
* @param byteNumber - int number of bytes
|
|
28
|
+
* @returns output string
|
|
29
|
+
*/
|
|
30
|
+
export declare function byteNumberToSizeString(byteNumber: number): string;
|
|
24
31
|
//# sourceMappingURL=formatter.d.ts.map
|
package/dist/formatter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,CAAC,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAMhF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,UAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAWtE"}
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,CAAC,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAMhF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,UAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAWtE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAOjE"}
|
package/dist/formatter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCircularReplacer = exports.getServiceCountText = exports.countNumberOfServices = void 0;
|
|
3
|
+
exports.byteNumberToSizeString = exports.getCircularReplacer = exports.getServiceCountText = exports.countNumberOfServices = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Count the number of services from the result of a catalog call.
|
|
6
6
|
*
|
|
@@ -45,4 +45,19 @@ function getCircularReplacer() {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
exports.getCircularReplacer = getCircularReplacer;
|
|
48
|
+
/**
|
|
49
|
+
* Convert an int byte number to a nice output format like 1.23 KB.
|
|
50
|
+
*
|
|
51
|
+
* @param byteNumber - int number of bytes
|
|
52
|
+
* @returns output string
|
|
53
|
+
*/
|
|
54
|
+
function byteNumberToSizeString(byteNumber) {
|
|
55
|
+
if (byteNumber === 0) {
|
|
56
|
+
return '0 Bytes';
|
|
57
|
+
}
|
|
58
|
+
const units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
59
|
+
const i = Math.floor(Math.log(byteNumber) / Math.log(1024));
|
|
60
|
+
return `${parseFloat((byteNumber / Math.pow(1024, i)).toFixed(2))} ${units[i]}`;
|
|
61
|
+
}
|
|
62
|
+
exports.byteNumberToSizeString = byteNumberToSizeString;
|
|
48
63
|
//# sourceMappingURL=formatter.js.map
|
package/dist/formatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,aAAkC;IACpE,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QAC9B,cAAc,GAAG,aAAa,CAAC,MAAM,CAAC;KACzC;IACD,OAAO,cAAc,CAAC;AAC1B,CAAC;AAND,sDAMC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,KAAa;IAC7C,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,KAAK,WAAW,CAAC;AAClE,CAAC;AAFD,kDAEC;AAED;;;;;;GAMG;AACH,SAAgB,mBAAmB;IAC/B,MAAM,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;IAC3B,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAClB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;YAC7C,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBACjB,OAAO,sBAAsB,CAAC;aACjC;YACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SACnB;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC;AACN,CAAC;AAXD,kDAWC"}
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,aAAkC;IACpE,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,KAAK,CAAC,OAAO,CAAC,a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CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACpF,CAAC;AAPD,wDAOC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export * from './checks';
|
|
3
|
-
export { convertResultsToMarkdown, storeResultsZip,
|
|
3
|
+
export { convertResultsToMarkdown, storeResultsZip, convertResultsToString } from './output';
|
|
4
|
+
export { archiveProject } from './archive';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,12 +10,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.archiveProject = exports.convertResultsToString = exports.storeResultsZip = exports.convertResultsToMarkdown = void 0;
|
|
14
14
|
__exportStar(require("./types"), exports);
|
|
15
15
|
__exportStar(require("./checks"), exports);
|
|
16
16
|
var output_1 = require("./output");
|
|
17
17
|
Object.defineProperty(exports, "convertResultsToMarkdown", { enumerable: true, get: function () { return output_1.convertResultsToMarkdown; } });
|
|
18
18
|
Object.defineProperty(exports, "storeResultsZip", { enumerable: true, get: function () { return output_1.storeResultsZip; } });
|
|
19
|
-
Object.defineProperty(exports, "archiveProject", { enumerable: true, get: function () { return output_1.archiveProject; } });
|
|
20
19
|
Object.defineProperty(exports, "convertResultsToString", { enumerable: true, get: function () { return output_1.convertResultsToString; } });
|
|
20
|
+
var archive_1 = require("./archive");
|
|
21
|
+
Object.defineProperty(exports, "archiveProject", { enumerable: true, get: function () { return archive_1.archiveProject; } });
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,mCAA6F;AAApF,kHAAA,wBAAwB,OAAA;AAAE,yGAAA,eAAe,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAC1E,qCAA2C;AAAlC,yGAAA,cAAc,OAAA"}
|
package/dist/output/zip.d.ts
CHANGED
|
@@ -6,14 +6,4 @@ import type { EnvironmentCheckResult } from '../types';
|
|
|
6
6
|
* @param targetFile - path and filename of target zip archive. Default is 'envcheck-results.zip'.
|
|
7
7
|
*/
|
|
8
8
|
export declare function storeResultsZip(results: EnvironmentCheckResult, targetFile?: string): void;
|
|
9
|
-
/**
|
|
10
|
-
* Archive a project to zip file. Result file is written to parent of the project root folder.
|
|
11
|
-
*
|
|
12
|
-
* @param projectRoot - root of the project, where package.json is located
|
|
13
|
-
* @param targetFileName - optional file name, defaults to project folder + timestamp + .zip
|
|
14
|
-
*/
|
|
15
|
-
export declare function archiveProject(projectRoot: string, targetFileName?: string): Promise<{
|
|
16
|
-
path: string;
|
|
17
|
-
size: string;
|
|
18
|
-
}>;
|
|
19
9
|
//# sourceMappingURL=zip.d.ts.map
|
package/dist/output/zip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../src/output/zip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../src/output/zip.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAIvD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,EAAE,UAAU,SAAyB,GAAG,IAAI,CA0B1G"}
|
package/dist/output/zip.js
CHANGED
|
@@ -18,36 +18,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.
|
|
22
|
+
exports.storeResultsZip = void 0;
|
|
32
23
|
const fs_1 = require("fs");
|
|
33
|
-
const path_1 = require("path");
|
|
34
24
|
const archiver = __importStar(require("archiver"));
|
|
25
|
+
const formatter_1 = require("../formatter");
|
|
35
26
|
const markdown_1 = require("./markdown");
|
|
36
|
-
const i18n_1 = require("../i18n");
|
|
37
|
-
/**
|
|
38
|
-
* Convert a int byte number to a nice output format like 1.23 KB.
|
|
39
|
-
*
|
|
40
|
-
* @param byteNumber - int number of bytes
|
|
41
|
-
* @returns output string
|
|
42
|
-
*/
|
|
43
|
-
function byteNumberToSizeString(byteNumber) {
|
|
44
|
-
if (byteNumber === 0) {
|
|
45
|
-
return '0 Bytes';
|
|
46
|
-
}
|
|
47
|
-
const units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
48
|
-
const i = Math.floor(Math.log(byteNumber) / Math.log(1024));
|
|
49
|
-
return `${parseFloat((byteNumber / Math.pow(1024, i)).toFixed(2))} ${units[i]}`;
|
|
50
|
-
}
|
|
51
27
|
/**
|
|
52
28
|
* Store output results to zip archive. This includes the markdown report and the raw JSON.
|
|
53
29
|
*
|
|
@@ -58,7 +34,7 @@ function storeResultsZip(results, targetFile = 'envcheck-results.zip') {
|
|
|
58
34
|
const zip = archiver.default('zip', { zlib: { level: 9 } });
|
|
59
35
|
const writeStream = fs_1.createWriteStream(targetFile);
|
|
60
36
|
writeStream.on('close', () => {
|
|
61
|
-
console.log(`Results written to file '${targetFile}' ${byteNumberToSizeString(zip.pointer())}`);
|
|
37
|
+
console.log(`Results written to file '${targetFile}' ${formatter_1.byteNumberToSizeString(zip.pointer())}`);
|
|
62
38
|
});
|
|
63
39
|
zip.on('warning', (error) => {
|
|
64
40
|
if (error.code === 'ENOENT') {
|
|
@@ -80,58 +56,4 @@ function storeResultsZip(results, targetFile = 'envcheck-results.zip') {
|
|
|
80
56
|
zip.finalize();
|
|
81
57
|
}
|
|
82
58
|
exports.storeResultsZip = storeResultsZip;
|
|
83
|
-
/**
|
|
84
|
-
* Archive a project to zip file. Result file is written to parent of the project root folder.
|
|
85
|
-
*
|
|
86
|
-
* @param projectRoot - root of the project, where package.json is located
|
|
87
|
-
* @param targetFileName - optional file name, defaults to project folder + timestamp + .zip
|
|
88
|
-
*/
|
|
89
|
-
function archiveProject(projectRoot, targetFileName) {
|
|
90
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
return new Promise((resolve, reject) => {
|
|
92
|
-
if (fs_1.existsSync(projectRoot)) {
|
|
93
|
-
try {
|
|
94
|
-
const zip = archiver.default('zip', { zlib: { level: 9 } });
|
|
95
|
-
let targetName = '';
|
|
96
|
-
if (typeof targetFileName === 'string') {
|
|
97
|
-
targetName = targetFileName.toLocaleLowerCase().endsWith('.zip')
|
|
98
|
-
? targetFileName
|
|
99
|
-
: targetFileName + '.zip';
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
targetName = `${path_1.basename(projectRoot)}-${new Date()
|
|
103
|
-
.toISOString()
|
|
104
|
-
.replace('T', '')
|
|
105
|
-
.replace(':', '')
|
|
106
|
-
.substring(0, 14)}.zip`;
|
|
107
|
-
}
|
|
108
|
-
const targetPath = path_1.join(path_1.dirname(projectRoot), targetName);
|
|
109
|
-
const writeStream = fs_1.createWriteStream(targetPath);
|
|
110
|
-
// To define which files to include/exclude archiver uses node-readdir-glob. If we use
|
|
111
|
-
// ignore: ['**/node_modules/**', '**/.env'] here it takes time, as ignore still enters directories.
|
|
112
|
-
// Using skip instead, which is way faster because directories are skipped completely in this
|
|
113
|
-
// case (https://github.com/yqnn/node-readdir-glob#options). Unfortunately, @types/glob -> IOptions
|
|
114
|
-
// hasn't skip defined. It works as it is supported by node-readdir-glob. Define it here as 'unknown'
|
|
115
|
-
const globOptions = {
|
|
116
|
-
cwd: projectRoot,
|
|
117
|
-
ignore: ['**/.env', '**/node_modules'],
|
|
118
|
-
skip: ['**/node_modules/**']
|
|
119
|
-
};
|
|
120
|
-
zip.glob('**', globOptions, {})
|
|
121
|
-
.on('error', (error) => reject(error))
|
|
122
|
-
.pipe(writeStream);
|
|
123
|
-
writeStream.on('close', () => resolve({ path: targetPath, size: byteNumberToSizeString(zip.pointer()) }));
|
|
124
|
-
zip.finalize();
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
reject(error);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
reject(new Error(i18n_1.t('error.noProjectRoot', { projectRoot })));
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
exports.archiveProject = archiveProject;
|
|
137
59
|
//# sourceMappingURL=zip.js.map
|
package/dist/output/zip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../src/output/zip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../src/output/zip.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2BAAuC;AACvC,mDAAqC;AAErC,4CAAsD;AACtD,yCAAsD;AAEtD;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,OAA+B,EAAE,UAAU,GAAG,sBAAsB;IAChG,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5D,MAAM,WAAW,GAAG,sBAAiB,CAAC,UAAU,CAAC,CAAC;IAClD,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACzB,OAAO,CAAC,GAAG,CAAC,4BAA4B,UAAU,KAAK,kCAAsB,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACpG,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QACxB,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;YACzB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACvB;aAAM;YACH,MAAM,KAAK,CAAC;SACf;IACL,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACtB,MAAM,KAAK,CAAC;IAChB,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAEtB,qCAAqC;IACrC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,mCAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;IAChE,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAEtD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACjE,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC,CAAC;IAE1D,GAAG,CAAC,QAAQ,EAAE,CAAC;AACnB,CAAC;AA1BD,0CA0BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/environment-check",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "SAP Fiori environment check",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": {
|
|
@@ -16,16 +16,17 @@
|
|
|
16
16
|
"@sap-ux/store": "0.3.8",
|
|
17
17
|
"@sap-ux/ui5-config": "0.16.1",
|
|
18
18
|
"@sap/bas-sdk": "3.1.0",
|
|
19
|
-
"archiver": "5.3.
|
|
19
|
+
"archiver": "5.3.1",
|
|
20
20
|
"axios": "0.24.0",
|
|
21
|
-
"
|
|
21
|
+
"glob-gitignore": "1.0.14",
|
|
22
22
|
"i18next": "20.3.2",
|
|
23
|
+
"ignore": "5.2.4",
|
|
23
24
|
"minimist": "1.2.6",
|
|
24
25
|
"prompts": "2.4.2",
|
|
25
26
|
"yamljs": "0.3.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@types/archiver": "5.
|
|
29
|
+
"@types/archiver": "5.3.1",
|
|
29
30
|
"@types/minimist": "1.2.2",
|
|
30
31
|
"@types/prompts": "2.0.14",
|
|
31
32
|
"@types/vscode": "1.39.0"
|