@sasjs/cli 4.20.1 → 4.20.3
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/README.md +11 -0
- package/build/cli.js +4 -5
- package/build/cli.spec.js +19 -9
- package/build/commands/add/addCommand.js +2 -2
- package/build/commands/add/addCredential.js +2 -2
- package/build/commands/add/addTarget.js +13 -14
- package/build/commands/add/internal/input.js +14 -14
- package/build/commands/add/internal/saveConfig.js +3 -4
- package/build/commands/add/spec/addCommand.spec.js +19 -9
- package/build/commands/add/spec/addCredential.spec.js +19 -9
- package/build/commands/add/spec/addTarget.spec.js +19 -9
- package/build/commands/auth/authCommand.js +8 -8
- package/build/commands/auth/login.js +40 -14
- package/build/commands/auth/spec/authCommand.spec.js +19 -9
- package/build/commands/auth/spec/login.spec.js +19 -9
- package/build/commands/build/build.js +25 -26
- package/build/commands/build/buildCommand.js +2 -2
- package/build/commands/build/compileBuildCommand.js +3 -3
- package/build/commands/build/internal/config.js +2 -2
- package/build/commands/build/spec/build.spec.js +2 -2
- package/build/commands/build/spec/buildCommand.spec.js +19 -9
- package/build/commands/build/spec/cb.spec.server.viya.js +2 -2
- package/build/commands/build/spec/compileBuildCommand.spec.js +19 -9
- package/build/commands/compile/compile.js +29 -20
- package/build/commands/compile/compileCommand.js +2 -2
- package/build/commands/compile/compileSingleFile.js +15 -15
- package/build/commands/compile/internal/checkCompileStatus.js +3 -4
- package/build/commands/compile/internal/compareFolders.js +2 -2
- package/build/commands/compile/internal/compileFile.js +6 -7
- package/build/commands/compile/internal/compileTestFile.js +17 -13
- package/build/commands/compile/internal/copySyncFolder.js +2 -2
- package/build/commands/compile/internal/getAllFolders.js +3 -3
- package/build/commands/compile/internal/identifySasFile.js +2 -2
- package/build/commands/compile/internal/loadDependencies.js +10 -10
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +2 -2
- package/build/commands/compile/internal/spec/getAllFolders.spec.js +19 -9
- package/build/commands/compile/spec/compareFolders.spec.js +3 -3
- package/build/commands/compile/spec/compile.spec.js +19 -9
- package/build/commands/compile/spec/compileCommand.spec.js +19 -9
- package/build/commands/compile/spec/compileFile.spec.js +19 -9
- package/build/commands/compile/spec/compileSingleFile.spec.js +19 -9
- package/build/commands/compile/spec/copyFilesToBuildFolder.spec.js +20 -10
- package/build/commands/compile/spec/loadDependencies.spec.js +19 -9
- package/build/commands/context/contextCommand.js +3 -3
- package/build/commands/context/create.js +4 -5
- package/build/commands/context/delete.js +4 -5
- package/build/commands/context/edit.js +4 -5
- package/build/commands/context/export.js +4 -5
- package/build/commands/context/internal/parseConfig.js +1 -2
- package/build/commands/context/internal/validateConfigPath.js +3 -4
- package/build/commands/context/list.js +4 -5
- package/build/commands/context/spec/contextCommand.spec.js +19 -9
- package/build/commands/context/spec/create.spec.js +2 -2
- package/build/commands/context/spec/delete.spec.js +2 -2
- package/build/commands/context/spec/edit.spec.js +2 -2
- package/build/commands/context/spec/export.spec.js +19 -9
- package/build/commands/context/spec/list.spec.js +2 -2
- package/build/commands/create/create.js +4 -5
- package/build/commands/create/createCommand.js +2 -2
- package/build/commands/create/createTemplate.js +1 -1
- package/build/commands/create/internal/createReadme.js +3 -4
- package/build/commands/create/spec/create.spec.js +2 -2
- package/build/commands/create/spec/createCommand.spec.js +19 -9
- package/build/commands/db/db.js +8 -9
- package/build/commands/db/dbCommand.js +2 -2
- package/build/commands/db/spec/db.spec.js +2 -2
- package/build/commands/db/spec/dbCommand.spec.js +19 -9
- package/build/commands/deploy/compileBuildDeployCommand.js +8 -8
- package/build/commands/deploy/deploy.js +4 -5
- package/build/commands/deploy/deployCommand.js +2 -2
- package/build/commands/deploy/internal/deployToSASJSWithServicePack.js +11 -12
- package/build/commands/deploy/internal/executeDeployScript.js +3 -4
- package/build/commands/deploy/internal/executeDeployScriptSas9.js +10 -11
- package/build/commands/deploy/internal/executeDeployScriptSasViya.js +11 -12
- package/build/commands/deploy/internal/executeDeployScriptSasjs.js +12 -13
- package/build/commands/deploy/internal/executeNonSasScript.js +4 -5
- package/build/commands/deploy/internal/executeSasScript.js +5 -6
- package/build/commands/deploy/internal/getDeployScripts.js +4 -5
- package/build/commands/deploy/spec/cbd.spec.js +19 -9
- package/build/commands/deploy/spec/cbd.spec.server.viya.js +19 -9
- package/build/commands/deploy/spec/compileBuildDeployCommand.spec.js +19 -9
- package/build/commands/deploy/spec/deploy.spec.js +19 -9
- package/build/commands/deploy/spec/deployCommand.spec.js +19 -9
- package/build/commands/deploy/spec/getDeployScripts.spec.js +2 -2
- package/build/commands/deploy/spec/utils.js +41 -8
- package/build/commands/docs/docsCommand.js +2 -2
- package/build/commands/docs/generateDocs.js +11 -12
- package/build/commands/docs/generateDot.js +3 -4
- package/build/commands/docs/initDocs.js +3 -4
- package/build/commands/docs/internal/createDotFiles.js +4 -5
- package/build/commands/docs/internal/getDocConfig.d.ts +8 -8
- package/build/commands/docs/internal/getDocConfig.js +1 -2
- package/build/commands/docs/internal/getDotFileContent.js +3 -4
- package/build/commands/docs/internal/getFileInputs.js +1 -2
- package/build/commands/docs/internal/getFileOutputs.js +1 -2
- package/build/commands/docs/internal/getFoldersForDocs.js +1 -2
- package/build/commands/docs/internal/populateNodeDictionary.js +1 -2
- package/build/commands/docs/internal/populateParamNodeTypes.js +21 -22
- package/build/commands/docs/spec/docsCommand.spec.js +19 -9
- package/build/commands/docs/spec/generateDocs.spec.js +2 -2
- package/build/commands/docs/spec/generateDot.spec.js +2 -2
- package/build/commands/docs/spec/getDocConfig.spec.js +2 -2
- package/build/commands/docs/spec/initDocs.spec.js +2 -2
- package/build/commands/flow/execute.js +6 -7
- package/build/commands/flow/flowCommand.js +2 -2
- package/build/commands/flow/internal/executeFlow.js +2 -2
- package/build/commands/flow/internal/saveLog.js +34 -5
- package/build/commands/flow/internal/saveToCsv.js +2 -2
- package/build/commands/flow/internal/spec/executeFlow.spec.js +19 -9
- package/build/commands/flow/internal/spec/saveToCsv.spec.js +2 -2
- package/build/commands/flow/internal/spec/validateParams.spec.js +19 -9
- package/build/commands/flow/internal/validateParams.d.ts +4 -4
- package/build/commands/flow/internal/validateParams.js +2 -2
- package/build/commands/flow/spec/flow.spec.js +19 -9
- package/build/commands/flow/spec/flow.spec.server.viya.js +2 -2
- package/build/commands/flow/spec/flowCommand.spec.js +19 -9
- package/build/commands/folder/create.js +2 -2
- package/build/commands/folder/delete.js +2 -2
- package/build/commands/folder/folderCommand.js +13 -13
- package/build/commands/folder/list.js +2 -2
- package/build/commands/folder/move.js +2 -2
- package/build/commands/folder/spec/folder.spec.server.viya.js +2 -2
- package/build/commands/folder/spec/folderCommand.spec.js +19 -9
- package/build/commands/fs/fsCommand.js +34 -36
- package/build/commands/fs/internal/executeCode.js +2 -2
- package/build/commands/fs/spec/executeCode.spec.js +19 -9
- package/build/commands/fs/spec/fsCommand.spec.js +19 -9
- package/build/commands/help/help.js +3 -4
- package/build/commands/help/helpCommand.js +2 -2
- package/build/commands/help/spec/help.spec.js +2 -2
- package/build/commands/help/spec/helpCommand.spec.js +19 -9
- package/build/commands/index.js +1 -1
- package/build/commands/init/init.js +5 -5
- package/build/commands/init/initCommand.js +2 -2
- package/build/commands/init/spec/init.spec.js +2 -2
- package/build/commands/init/spec/initCommand.spec.js +19 -9
- package/build/commands/job/internal/execute/sas9.js +3 -4
- package/build/commands/job/internal/execute/sasjs.js +4 -5
- package/build/commands/job/internal/execute/viya.js +9 -10
- package/build/commands/job/internal/utils.js +2 -2
- package/build/commands/job/jobCommand.js +19 -19
- package/build/commands/job/spec/execute.spec.js +19 -9
- package/build/commands/job/spec/getContextName.spec.js +2 -2
- package/build/commands/job/spec/job.spec.server.viya.js +24 -16
- package/build/commands/job/spec/jobCommand.spec.js +19 -9
- package/build/commands/lint/initLint.js +3 -4
- package/build/commands/lint/lintCommand.js +2 -2
- package/build/commands/lint/processLint.js +13 -14
- package/build/commands/lint/spec/lintCommand.spec.js +19 -9
- package/build/commands/request/request.js +3 -4
- package/build/commands/request/requestCommand.js +2 -2
- package/build/commands/request/spec/request.spec.server.sas9.js +19 -9
- package/build/commands/request/spec/request.spec.server.viya.js +19 -9
- package/build/commands/request/spec/requestCommand.spec.js +19 -9
- package/build/commands/request/spec/utils.js +2 -2
- package/build/commands/run/run.js +29 -30
- package/build/commands/run/runCommand.js +2 -2
- package/build/commands/run/spec/run.spec.js +19 -9
- package/build/commands/run/spec/run.spec.server.sas9.js +2 -2
- package/build/commands/run/spec/run.spec.server.sasjs.js +2 -2
- package/build/commands/run/spec/run.spec.server.viya.js +4 -4
- package/build/commands/run/spec/runCommand.spec.js +19 -9
- package/build/commands/servicepack/deploy.js +7 -8
- package/build/commands/servicepack/servicePackCommand.js +7 -7
- package/build/commands/servicepack/spec/servicepack.spec.server.viya.js +2 -2
- package/build/commands/servicepack/spec/servicepackCommand.spec.js +19 -9
- package/build/commands/shared/createConfigFile.js +2 -2
- package/build/commands/shared/createFileStructure.js +2 -2
- package/build/commands/shared/createLintConfigFile.js +2 -2
- package/build/commands/shared/deployToSasViyaWithServicePack.js +6 -7
- package/build/commands/shared/fetchLogFileContent.js +2 -2
- package/build/commands/shared/spec/deployToSasViyaWithServicePack.spec.js +19 -9
- package/build/commands/snippets/snippets.js +3 -4
- package/build/commands/snippets/snippetsCommand.js +2 -2
- package/build/commands/snippets/spec/snippets.spec.js +2 -2
- package/build/commands/snippets/spec/snippetsCommand.spec.js +19 -9
- package/build/commands/testing/internal/saveOutput.js +23 -15
- package/build/commands/testing/spec/testCommand.spec.js +19 -9
- package/build/commands/testing/spec/testing.spec.js +19 -9
- package/build/commands/testing/test.js +14 -14
- package/build/commands/testing/testCommand.js +2 -2
- package/build/commands/version/spec/version.spec.js +2 -2
- package/build/commands/version/spec/versionCommand.spec.js +19 -9
- package/build/commands/version/version.js +4 -5
- package/build/commands/version/versionCommand.js +2 -2
- package/build/commands/web/internal/createAssetServices.js +39 -41
- package/build/commands/web/internal/sas9/createClickMeService.js +2 -2
- package/build/commands/web/internal/sas9/generateAssetService.js +2 -2
- package/build/commands/web/internal/sas9/getWebServiceContent.js +34 -5
- package/build/commands/web/internal/sasViya/createClickMeFile.js +2 -2
- package/build/commands/web/internal/spec/updateSasjstag.spec.js +2 -2
- package/build/commands/web/internal/spec/updateScriptTag.spec.js +2 -2
- package/build/commands/web/internal/spec/updateStyleTag.spec.js +2 -2
- package/build/commands/web/internal/updateAllTags.js +86 -88
- package/build/commands/web/internal/updateLinkTag.d.ts +1 -1
- package/build/commands/web/internal/updateScriptTag.js +2 -2
- package/build/commands/web/internal/updateStyleTag.js +2 -2
- package/build/commands/web/spec/web.spec.js +2 -2
- package/build/commands/web/spec/webCommand.spec.js +19 -9
- package/build/commands/web/web.js +10 -11
- package/build/commands/web/webCommand.js +2 -2
- package/build/types/command/commandAliases.d.ts +1 -1
- package/build/types/command/commandBase.js +2 -2
- package/build/types/command/commandFactory.d.ts +1 -1
- package/build/types/command/returnCode.js +1 -1
- package/build/types/command/spec/commandBase.spec.js +2 -2
- package/build/types/command/spec/targetCommand.spec.js +19 -9
- package/build/types/command/targetCommand.js +2 -2
- package/build/types/flow.js +1 -1
- package/build/types/targetScope.js +1 -1
- package/build/types/testing.js +3 -3
- package/build/utils/auth.js +8 -8
- package/build/utils/compressAndSave.js +11 -6
- package/build/utils/config.js +82 -84
- package/build/utils/displayResult.js +2 -3
- package/build/utils/file.js +13 -13
- package/build/utils/loadEnvVariables.js +4 -5
- package/build/utils/parseSourceFile.js +3 -4
- package/build/utils/saveLog.js +34 -5
- package/build/utils/setConstants.js +34 -5
- package/build/utils/setProjectDir.js +2 -2
- package/build/utils/spec/auth.spec.js +2 -2
- package/build/utils/spec/config.spec.js +19 -9
- package/build/utils/spec/file.spec.js +2 -2
- package/build/utils/spec/saveLog.spec.js +2 -2
- package/build/utils/spec/setConstants.spec.js +20 -10
- package/build/utils/spec/utils.spec.js +2 -2
- package/build/utils/spec/zip.spec.d.ts +1 -0
- package/build/utils/spec/zip.spec.js +282 -0
- package/build/utils/test.d.ts +2 -3
- package/build/utils/test.js +103 -40
- package/build/utils/utils.js +102 -78
- package/build/utils/zip.d.ts +20 -0
- package/build/utils/zip.js +277 -0
- package/package.json +37 -34
package/build/utils/saveLog.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -35,6 +35,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
+
if (!m) return o;
|
|
41
|
+
var i = m.call(o), r, ar = [], e;
|
|
42
|
+
try {
|
|
43
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) { e = { error: error }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e) throw e.error; }
|
|
51
|
+
}
|
|
52
|
+
return ar;
|
|
53
|
+
};
|
|
54
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
+
if (ar || !(i in from)) {
|
|
57
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
+
ar[i] = from[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
+
};
|
|
38
63
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
64
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
65
|
};
|
|
@@ -50,11 +75,15 @@ var _1 = require(".");
|
|
|
50
75
|
* @param jobPath - file path to job, job name will be used as a fallback name for log file.
|
|
51
76
|
* @param silent - boolean indicating if additional info should be logged.
|
|
52
77
|
*/
|
|
53
|
-
var saveLog = function (
|
|
54
|
-
|
|
55
|
-
|
|
78
|
+
var saveLog = function (logData_1, logFile_1, jobPath_1) {
|
|
79
|
+
var args_1 = [];
|
|
80
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
|
81
|
+
args_1[_i - 3] = arguments[_i];
|
|
82
|
+
}
|
|
83
|
+
return __awaiter(void 0, __spreadArray([logData_1, logFile_1, jobPath_1], __read(args_1), false), void 0, function (logData, logFile, jobPath, silent) {
|
|
56
84
|
var error, logPath, folderPath, parentFolderPath, logLines;
|
|
57
85
|
var _a;
|
|
86
|
+
if (silent === void 0) { silent = false; }
|
|
58
87
|
return __generator(this, function (_b) {
|
|
59
88
|
switch (_b.label) {
|
|
60
89
|
case 0:
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -35,6 +35,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
+
if (!m) return o;
|
|
41
|
+
var i = m.call(o), r, ar = [], e;
|
|
42
|
+
try {
|
|
43
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) { e = { error: error }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e) throw e.error; }
|
|
51
|
+
}
|
|
52
|
+
return ar;
|
|
53
|
+
};
|
|
54
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
+
if (ar || !(i in from)) {
|
|
57
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
+
ar[i] = from[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
+
};
|
|
38
63
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
64
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
65
|
};
|
|
@@ -44,11 +69,15 @@ var path_1 = __importDefault(require("path"));
|
|
|
44
69
|
var utils_1 = require("./utils");
|
|
45
70
|
var utils_2 = require("@sasjs/utils");
|
|
46
71
|
exports.contextName = 'sasjs cli compute context';
|
|
47
|
-
var setConstants = function (
|
|
48
|
-
|
|
49
|
-
|
|
72
|
+
var setConstants = function () {
|
|
73
|
+
var args_1 = [];
|
|
74
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
75
|
+
args_1[_i] = arguments[_i];
|
|
76
|
+
}
|
|
77
|
+
return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (isLocal, target, configuration) {
|
|
50
78
|
var buildOutputFolder, buildResultsFolder, homeDir, buildSourceFolder, buildSourceDbFolder, buildDestinationFolder, buildDestinationServicesFolder, buildDestinationTestFolder, buildDestinationJobsFolder, buildDestinationDbFolder, buildDestinationDocsFolder, macroCorePath, buildDestinationResultsFolder, buildDestinationResultsLogsFolder, sas9CredentialsError, invalidSasError, sas9GUID;
|
|
51
79
|
var _a;
|
|
80
|
+
if (isLocal === void 0) { isLocal = true; }
|
|
52
81
|
return __generator(this, function (_b) {
|
|
53
82
|
switch (_b.label) {
|
|
54
83
|
case 0:
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g =
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -26,13 +26,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
26
26
|
}) : function(o, v) {
|
|
27
27
|
o["default"] = v;
|
|
28
28
|
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
36
46
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
47
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
48
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -43,8 +53,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
53
|
});
|
|
44
54
|
};
|
|
45
55
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g =
|
|
56
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
57
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
58
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
59
|
function step(op) {
|
|
50
60
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -26,13 +26,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
26
26
|
}) : function(o, v) {
|
|
27
27
|
o["default"] = v;
|
|
28
28
|
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
36
46
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
47
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
48
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -43,8 +53,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
53
|
});
|
|
44
54
|
};
|
|
45
55
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g =
|
|
56
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
57
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
58
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
59
|
function step(op) {
|
|
50
60
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -235,7 +245,7 @@ describe('setConstants', function () {
|
|
|
235
245
|
return [4 /*yield*/, (0, setConstants_1.setConstants)()];
|
|
236
246
|
case 1:
|
|
237
247
|
_a.sent();
|
|
238
|
-
expect(getNodeModulePathSpy).
|
|
248
|
+
expect(getNodeModulePathSpy).toHaveBeenCalledTimes(0);
|
|
239
249
|
return [2 /*return*/];
|
|
240
250
|
}
|
|
241
251
|
});
|
|
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g =
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var fs_1 = __importDefault(require("fs"));
|
|
43
|
+
var path_1 = __importDefault(require("path"));
|
|
44
|
+
var yazl_1 = __importDefault(require("yazl"));
|
|
45
|
+
var utils_1 = require("@sasjs/utils");
|
|
46
|
+
var zip_1 = require("../zip");
|
|
47
|
+
var utils_2 = require("@sasjs/utils");
|
|
48
|
+
var makeZip = function (entries, zipPath) {
|
|
49
|
+
return new Promise(function (resolve, reject) {
|
|
50
|
+
var zip = new yazl_1.default.ZipFile();
|
|
51
|
+
entries.forEach(function (e) {
|
|
52
|
+
return zip.addBuffer(Buffer.from(e.content, 'utf8'), e.name, { mode: e.mode });
|
|
53
|
+
});
|
|
54
|
+
zip.outputStream.pipe(fs_1.default.createWriteStream(zipPath)).on('close', resolve);
|
|
55
|
+
zip.outputStream.on('error', reject);
|
|
56
|
+
zip.end();
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Rewrites the versionMadeBy host platform byte (high byte of the central
|
|
61
|
+
* directory field) of every entry, simulating an archive created on a
|
|
62
|
+
* different host (e.g. 0 = MS-DOS/Windows). Used to prove that mode bits
|
|
63
|
+
* from non-unix hosts are ignored.
|
|
64
|
+
*/
|
|
65
|
+
var setEntryPlatform = function (zipPath, platform) {
|
|
66
|
+
var buffer = fs_1.default.readFileSync(zipPath);
|
|
67
|
+
var eocd = buffer.lastIndexOf(Buffer.from([0x50, 0x4b, 0x05, 0x06]));
|
|
68
|
+
if (eocd < 0)
|
|
69
|
+
throw new Error('end of central directory record not found');
|
|
70
|
+
var cdSize = buffer.readUInt32LE(eocd + 12);
|
|
71
|
+
var cdOffset = buffer.readUInt32LE(eocd + 16);
|
|
72
|
+
var p = cdOffset;
|
|
73
|
+
var end = cdOffset + cdSize;
|
|
74
|
+
while (p < end) {
|
|
75
|
+
if (buffer.readUInt32LE(p) !== 0x02014b50)
|
|
76
|
+
break; // central file header
|
|
77
|
+
var versionMadeBy = buffer.readUInt16LE(p + 4);
|
|
78
|
+
buffer.writeUInt16LE((versionMadeBy & 0xff) | (platform << 8), p + 4);
|
|
79
|
+
var nlen = buffer.readUInt16LE(p + 28);
|
|
80
|
+
var elen = buffer.readUInt16LE(p + 30);
|
|
81
|
+
var clen = buffer.readUInt16LE(p + 32);
|
|
82
|
+
p += 46 + nlen + elen + clen;
|
|
83
|
+
}
|
|
84
|
+
fs_1.default.writeFileSync(zipPath, buffer);
|
|
85
|
+
};
|
|
86
|
+
describe('zip', function () {
|
|
87
|
+
var tmpRoot = path_1.default.join(__dirname, "zip-spec-".concat((0, utils_2.generateTimestamp)()));
|
|
88
|
+
var destDir = path_1.default.join(tmpRoot, 'dest');
|
|
89
|
+
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
fs_1.default.mkdirSync(destDir, { recursive: true });
|
|
92
|
+
return [2 /*return*/];
|
|
93
|
+
});
|
|
94
|
+
}); });
|
|
95
|
+
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
+
return __generator(this, function (_a) {
|
|
97
|
+
switch (_a.label) {
|
|
98
|
+
case 0: return [4 /*yield*/, (0, utils_2.deleteFolder)(tmpRoot).catch(function () { })];
|
|
99
|
+
case 1:
|
|
100
|
+
_a.sent();
|
|
101
|
+
return [2 /*return*/];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}); });
|
|
105
|
+
describe('extractZip', function () {
|
|
106
|
+
it('should extract nested files and create implicit directories', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
var zipPath, nested, top;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
zipPath = path_1.default.join(tmpRoot, 'app.zip');
|
|
112
|
+
return [4 /*yield*/, makeZip([
|
|
113
|
+
{ name: 'app-main/a/b/file.txt', content: 'nested content' },
|
|
114
|
+
{ name: 'app-main/top.txt', content: 'top content' }
|
|
115
|
+
], zipPath)];
|
|
116
|
+
case 1:
|
|
117
|
+
_a.sent();
|
|
118
|
+
return [4 /*yield*/, (0, zip_1.extractZip)(zipPath, destDir, true)];
|
|
119
|
+
case 2:
|
|
120
|
+
_a.sent();
|
|
121
|
+
return [4 /*yield*/, (0, utils_2.readFile)(path_1.default.join(destDir, 'app-main', 'a', 'b', 'file.txt'))];
|
|
122
|
+
case 3:
|
|
123
|
+
nested = _a.sent();
|
|
124
|
+
expect(nested).toEqual('nested content');
|
|
125
|
+
return [4 /*yield*/, (0, utils_2.readFile)(path_1.default.join(destDir, 'app-main', 'top.txt'))];
|
|
126
|
+
case 4:
|
|
127
|
+
top = _a.sent();
|
|
128
|
+
expect(top).toEqual('top content');
|
|
129
|
+
return [2 /*return*/];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}); });
|
|
133
|
+
it('should create explicit directory entries', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
134
|
+
var zipPath;
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
switch (_a.label) {
|
|
137
|
+
case 0:
|
|
138
|
+
zipPath = path_1.default.join(tmpRoot, 'dirs.zip');
|
|
139
|
+
return [4 /*yield*/, makeZip([{ name: 'app-main/public/docs/.gitkeep', content: '' }], zipPath)];
|
|
140
|
+
case 1:
|
|
141
|
+
_a.sent();
|
|
142
|
+
return [4 /*yield*/, (0, zip_1.extractZip)(zipPath, destDir, true)];
|
|
143
|
+
case 2:
|
|
144
|
+
_a.sent();
|
|
145
|
+
expect(fs_1.default.existsSync(path_1.default.join(destDir, 'app-main', 'public', 'docs'))).toBeTrue();
|
|
146
|
+
return [2 /*return*/];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}); });
|
|
150
|
+
it('should preserve unix mode bits', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
151
|
+
var zipPath, hookMode;
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (_a.label) {
|
|
154
|
+
case 0:
|
|
155
|
+
if ((0, utils_1.isWindows)())
|
|
156
|
+
return [2 /*return*/]; // chmod exec bits are a no-op on Windows
|
|
157
|
+
zipPath = path_1.default.join(tmpRoot, 'modes.zip');
|
|
158
|
+
return [4 /*yield*/, makeZip([
|
|
159
|
+
{ name: 'app-main/hook', content: '#!/bin/bash\n', mode: 493 },
|
|
160
|
+
{ name: 'app-main/plain.txt', content: 'plain', mode: 420 }
|
|
161
|
+
], zipPath)];
|
|
162
|
+
case 1:
|
|
163
|
+
_a.sent();
|
|
164
|
+
return [4 /*yield*/, (0, zip_1.extractZip)(zipPath, destDir, true)];
|
|
165
|
+
case 2:
|
|
166
|
+
_a.sent();
|
|
167
|
+
hookMode = fs_1.default.statSync(path_1.default.join(destDir, 'app-main', 'hook')).mode;
|
|
168
|
+
expect(hookMode & 73).not.toEqual(0);
|
|
169
|
+
return [2 /*return*/];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}); });
|
|
173
|
+
it('should not apply mode bits from non-unix (e.g. Windows) archives', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
+
var zipPath, mode;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
if ((0, utils_1.isWindows)())
|
|
179
|
+
return [2 /*return*/]; // chmod exec bits are a no-op on Windows
|
|
180
|
+
zipPath = path_1.default.join(tmpRoot, 'winmodes.zip');
|
|
181
|
+
return [4 /*yield*/, makeZip([{ name: 'app-main/binary', content: 'MZ', mode: 493 }], zipPath)
|
|
182
|
+
// Simulate a Windows-created archive: same externalFileAttributes
|
|
183
|
+
// (exec bits set by yazl), but versionMadeBy platform 0 (MS-DOS).
|
|
184
|
+
];
|
|
185
|
+
case 1:
|
|
186
|
+
_a.sent();
|
|
187
|
+
// Simulate a Windows-created archive: same externalFileAttributes
|
|
188
|
+
// (exec bits set by yazl), but versionMadeBy platform 0 (MS-DOS).
|
|
189
|
+
setEntryPlatform(zipPath, 0);
|
|
190
|
+
return [4 /*yield*/, (0, zip_1.extractZip)(zipPath, destDir, true)
|
|
191
|
+
// The entry's externalFileAttributes high bits are not a unix mode
|
|
192
|
+
// on non-unix platforms - applying them would chmod the file 755.
|
|
193
|
+
];
|
|
194
|
+
case 2:
|
|
195
|
+
_a.sent();
|
|
196
|
+
mode = fs_1.default.statSync(path_1.default.join(destDir, 'app-main', 'binary')).mode;
|
|
197
|
+
expect(mode & 73).toEqual(0);
|
|
198
|
+
return [2 /*return*/];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}); });
|
|
202
|
+
it('should not write through a symlink at the destination', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
203
|
+
var zipPath, victimPath, victim;
|
|
204
|
+
return __generator(this, function (_a) {
|
|
205
|
+
switch (_a.label) {
|
|
206
|
+
case 0:
|
|
207
|
+
if ((0, utils_1.isWindows)())
|
|
208
|
+
return [2 /*return*/]; // symlink creation needs elevated privileges
|
|
209
|
+
zipPath = path_1.default.join(tmpRoot, 'evil.zip');
|
|
210
|
+
return [4 /*yield*/, makeZip([{ name: 'app-main/target.txt', content: 'EVIL' }], zipPath)];
|
|
211
|
+
case 1:
|
|
212
|
+
_a.sent();
|
|
213
|
+
victimPath = path_1.default.join(tmpRoot, 'victim.txt');
|
|
214
|
+
return [4 /*yield*/, (0, utils_2.createFile)(victimPath, 'ORIGINAL')
|
|
215
|
+
// plant a symlink where the entry wants to write
|
|
216
|
+
];
|
|
217
|
+
case 2:
|
|
218
|
+
_a.sent();
|
|
219
|
+
// plant a symlink where the entry wants to write
|
|
220
|
+
fs_1.default.mkdirSync(path_1.default.join(destDir, 'app-main'), { recursive: true });
|
|
221
|
+
fs_1.default.symlinkSync(victimPath, path_1.default.join(destDir, 'app-main', 'target.txt'));
|
|
222
|
+
return [4 /*yield*/, expect((0, zip_1.extractZip)(zipPath, destDir, true)).rejects.toThrow(/symbolic link/)];
|
|
223
|
+
case 3:
|
|
224
|
+
_a.sent();
|
|
225
|
+
return [4 /*yield*/, (0, utils_2.readFile)(victimPath)];
|
|
226
|
+
case 4:
|
|
227
|
+
victim = _a.sent();
|
|
228
|
+
expect(victim).toEqual('ORIGINAL');
|
|
229
|
+
return [2 /*return*/];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}); });
|
|
233
|
+
it('should not extract into a symlinked parent directory', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
234
|
+
var zipPath, realDir, linkDir;
|
|
235
|
+
return __generator(this, function (_a) {
|
|
236
|
+
switch (_a.label) {
|
|
237
|
+
case 0:
|
|
238
|
+
if ((0, utils_1.isWindows)())
|
|
239
|
+
return [2 /*return*/]; // symlink creation needs elevated privileges
|
|
240
|
+
zipPath = path_1.default.join(tmpRoot, 'evilparent.zip');
|
|
241
|
+
return [4 /*yield*/, makeZip([{ name: 'app-main/x.txt', content: 'x' }], zipPath)];
|
|
242
|
+
case 1:
|
|
243
|
+
_a.sent();
|
|
244
|
+
realDir = path_1.default.join(tmpRoot, 'realdir');
|
|
245
|
+
fs_1.default.mkdirSync(realDir, { recursive: true });
|
|
246
|
+
linkDir = path_1.default.join(tmpRoot, 'linkdir');
|
|
247
|
+
fs_1.default.symlinkSync(realDir, linkDir);
|
|
248
|
+
return [4 /*yield*/, expect((0, zip_1.extractZip)(zipPath, linkDir, true)).rejects.toThrow(/symbolic link/)];
|
|
249
|
+
case 2:
|
|
250
|
+
_a.sent();
|
|
251
|
+
expect(fs_1.default.readdirSync(realDir).length).toEqual(0);
|
|
252
|
+
return [2 /*return*/];
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}); });
|
|
256
|
+
it('should skip existing files when overwrite is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
257
|
+
var zipPath, existingPath, content;
|
|
258
|
+
return __generator(this, function (_a) {
|
|
259
|
+
switch (_a.label) {
|
|
260
|
+
case 0:
|
|
261
|
+
zipPath = path_1.default.join(tmpRoot, 'skip.zip');
|
|
262
|
+
return [4 /*yield*/, makeZip([{ name: 'app-main/skipme.txt', content: 'NEW' }], zipPath)];
|
|
263
|
+
case 1:
|
|
264
|
+
_a.sent();
|
|
265
|
+
existingPath = path_1.default.join(destDir, 'app-main', 'skipme.txt');
|
|
266
|
+
fs_1.default.mkdirSync(path_1.default.join(destDir, 'app-main'), { recursive: true });
|
|
267
|
+
return [4 /*yield*/, (0, utils_2.createFile)(existingPath, 'EXISTING')];
|
|
268
|
+
case 2:
|
|
269
|
+
_a.sent();
|
|
270
|
+
return [4 /*yield*/, (0, zip_1.extractZip)(zipPath, destDir, false)];
|
|
271
|
+
case 3:
|
|
272
|
+
_a.sent();
|
|
273
|
+
return [4 /*yield*/, (0, utils_2.readFile)(existingPath)];
|
|
274
|
+
case 4:
|
|
275
|
+
content = _a.sent();
|
|
276
|
+
expect(content).toEqual('EXISTING');
|
|
277
|
+
return [2 /*return*/];
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}); });
|
|
281
|
+
});
|
|
282
|
+
});
|
package/build/utils/test.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
1
|
import { ServerType, Target, TargetJson, Configuration } from '@sasjs/utils/types';
|
|
3
2
|
import { Folder } from '../types';
|
|
4
3
|
import { ServiceConfig, JobConfig } from '@sasjs/utils/types/config';
|
|
@@ -9,8 +8,8 @@ export declare const removeTestApp: (parentFolder: string, appName: string) => P
|
|
|
9
8
|
export declare const removeTestServerFolder: (folderPath: string, target: Target) => Promise<void>;
|
|
10
9
|
export declare const generateTestTarget: (targetName: string, appLoc: string, serviceConfig?: ServiceConfig, serverType?: ServerType, jobConfig?: JobConfig) => Target;
|
|
11
10
|
export declare const createTestGlobalTarget: (targetName: string, appLoc: string, serviceConfig?: ServiceConfig, serverType?: ServerType) => Promise<Target>;
|
|
12
|
-
export declare const verifyStep: (step?:
|
|
13
|
-
export declare const mockProcessExit: () => jest.SpyInstance<never, [code?: number | undefined], any>;
|
|
11
|
+
export declare const verifyStep: (step?: "db" | "compile" | "build", buildFileName?: string, customFiles?: "custom" | "no") => Promise<void>;
|
|
12
|
+
export declare const mockProcessExit: () => jest.SpyInstance<never, [code?: string | number | null | undefined], any>;
|
|
14
13
|
export declare const verifyFolder: (folder: Folder, parentFolderName?: string) => Promise<boolean>;
|
|
15
14
|
export declare const verifyPackageJsonContent: (parentFolderName?: string) => Promise<void>;
|
|
16
15
|
export declare const removeAllTargetsFromConfigs: () => Promise<void>;
|