@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
|
@@ -0,0 +1,277 @@
|
|
|
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 __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
39
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
40
|
+
var m = o[Symbol.asyncIterator], i;
|
|
41
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
42
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
43
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
44
|
+
};
|
|
45
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
46
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
47
|
+
if (!m) return o;
|
|
48
|
+
var i = m.call(o), r, ar = [], e;
|
|
49
|
+
try {
|
|
50
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
51
|
+
}
|
|
52
|
+
catch (error) { e = { error: error }; }
|
|
53
|
+
finally {
|
|
54
|
+
try {
|
|
55
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
56
|
+
}
|
|
57
|
+
finally { if (e) throw e.error; }
|
|
58
|
+
}
|
|
59
|
+
return ar;
|
|
60
|
+
};
|
|
61
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
62
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
63
|
+
if (ar || !(i in from)) {
|
|
64
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
65
|
+
ar[i] = from[i];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
69
|
+
};
|
|
70
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
71
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
+
exports.extractZip = void 0;
|
|
75
|
+
var fs_1 = __importDefault(require("fs"));
|
|
76
|
+
var path_1 = __importDefault(require("path"));
|
|
77
|
+
var yauzl_1 = require("yauzl");
|
|
78
|
+
/**
|
|
79
|
+
* Extracts a zip archive to the given directory.
|
|
80
|
+
*
|
|
81
|
+
* Replaces adm-zip's extractAllTo (GHSA-vwc7-r8mq-g2x9: extraction follows
|
|
82
|
+
* destination symlinks, allowing arbitrary file overwrite). This
|
|
83
|
+
* implementation never follows symlinks at the destination: every path
|
|
84
|
+
* component is checked with fs.lstatSync and extraction of an entry aborts
|
|
85
|
+
* if a symlink is found where a directory or file is expected.
|
|
86
|
+
*
|
|
87
|
+
* Directories mentioned only implicitly by entry paths are created; explicit
|
|
88
|
+
* directory entries are honoured. Unix file mode bits are preserved (needed
|
|
89
|
+
* by e.g. .git-hooks files in seed apps, which git requires to be
|
|
90
|
+
* executable). Overwriting of existing regular files is opt-in; existing
|
|
91
|
+
* symlinks are never written through.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} zipPath - path of the zip archive to extract.
|
|
94
|
+
* @param {string} destDir - directory to extract into (created if missing).
|
|
95
|
+
* @param {boolean} overwrite - whether existing regular files are replaced.
|
|
96
|
+
*/
|
|
97
|
+
var extractZip = function (zipPath_1, destDir_1) {
|
|
98
|
+
var args_1 = [];
|
|
99
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
100
|
+
args_1[_i - 2] = arguments[_i];
|
|
101
|
+
}
|
|
102
|
+
return __awaiter(void 0, __spreadArray([zipPath_1, destDir_1], __read(args_1), false), void 0, function (zipPath, destDir, overwrite) {
|
|
103
|
+
var zipfile, _a, _b, _c, entry, e_1_1;
|
|
104
|
+
var _d, e_1, _e, _f;
|
|
105
|
+
if (overwrite === void 0) { overwrite = false; }
|
|
106
|
+
return __generator(this, function (_g) {
|
|
107
|
+
switch (_g.label) {
|
|
108
|
+
case 0: return [4 /*yield*/, (0, yauzl_1.openPromise)(zipPath, {
|
|
109
|
+
lazyEntries: true,
|
|
110
|
+
decodeStrings: true,
|
|
111
|
+
validateEntrySizes: true
|
|
112
|
+
})];
|
|
113
|
+
case 1:
|
|
114
|
+
zipfile = _g.sent();
|
|
115
|
+
_g.label = 2;
|
|
116
|
+
case 2:
|
|
117
|
+
_g.trys.push([2, , 16, 17]);
|
|
118
|
+
_g.label = 3;
|
|
119
|
+
case 3:
|
|
120
|
+
_g.trys.push([3, 9, 10, 15]);
|
|
121
|
+
_a = true, _b = __asyncValues(zipfile.eachEntry());
|
|
122
|
+
_g.label = 4;
|
|
123
|
+
case 4: return [4 /*yield*/, _b.next()];
|
|
124
|
+
case 5:
|
|
125
|
+
if (!(_c = _g.sent(), _d = _c.done, !_d)) return [3 /*break*/, 8];
|
|
126
|
+
_f = _c.value;
|
|
127
|
+
_a = false;
|
|
128
|
+
entry = _f;
|
|
129
|
+
return [4 /*yield*/, extractEntry(zipfile, entry, destDir, overwrite)];
|
|
130
|
+
case 6:
|
|
131
|
+
_g.sent();
|
|
132
|
+
_g.label = 7;
|
|
133
|
+
case 7:
|
|
134
|
+
_a = true;
|
|
135
|
+
return [3 /*break*/, 4];
|
|
136
|
+
case 8: return [3 /*break*/, 15];
|
|
137
|
+
case 9:
|
|
138
|
+
e_1_1 = _g.sent();
|
|
139
|
+
e_1 = { error: e_1_1 };
|
|
140
|
+
return [3 /*break*/, 15];
|
|
141
|
+
case 10:
|
|
142
|
+
_g.trys.push([10, , 13, 14]);
|
|
143
|
+
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 12];
|
|
144
|
+
return [4 /*yield*/, _e.call(_b)];
|
|
145
|
+
case 11:
|
|
146
|
+
_g.sent();
|
|
147
|
+
_g.label = 12;
|
|
148
|
+
case 12: return [3 /*break*/, 14];
|
|
149
|
+
case 13:
|
|
150
|
+
if (e_1) throw e_1.error;
|
|
151
|
+
return [7 /*endfinally*/];
|
|
152
|
+
case 14: return [7 /*endfinally*/];
|
|
153
|
+
case 15: return [3 /*break*/, 17];
|
|
154
|
+
case 16:
|
|
155
|
+
zipfile.close();
|
|
156
|
+
return [7 /*endfinally*/];
|
|
157
|
+
case 17: return [2 /*return*/];
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
exports.extractZip = extractZip;
|
|
163
|
+
var extractEntry = function (zipfile, entry, destDir, overwrite) { return __awaiter(void 0, void 0, void 0, function () {
|
|
164
|
+
var entryPath, isDirectoryEntry, destPath, parents, destStat, readStream, mode;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0:
|
|
168
|
+
entryPath = entry.fileName;
|
|
169
|
+
isDirectoryEntry = entryPath.endsWith('/');
|
|
170
|
+
destPath = path_1.default.join(destDir, entryPath);
|
|
171
|
+
parents = path_1.default.dirname(destPath);
|
|
172
|
+
return [4 /*yield*/, ensureDirNoSymlink(destDir, parents)];
|
|
173
|
+
case 1:
|
|
174
|
+
_a.sent();
|
|
175
|
+
if (isDirectoryEntry) {
|
|
176
|
+
// Explicit directory entry: create it (mode as-is; dirs are rwxr-xr-x by default).
|
|
177
|
+
fs_1.default.mkdirSync(destPath, { recursive: true });
|
|
178
|
+
return [2 /*return*/];
|
|
179
|
+
}
|
|
180
|
+
destStat = null;
|
|
181
|
+
try {
|
|
182
|
+
destStat = fs_1.default.lstatSync(destPath);
|
|
183
|
+
}
|
|
184
|
+
catch (_b) {
|
|
185
|
+
destStat = null;
|
|
186
|
+
}
|
|
187
|
+
if (destStat) {
|
|
188
|
+
if (destStat.isSymbolicLink()) {
|
|
189
|
+
throw new Error("Refusing to extract \"".concat(entryPath, "\": destination is a symbolic link."));
|
|
190
|
+
}
|
|
191
|
+
if (!destStat.isFile()) {
|
|
192
|
+
throw new Error("Refusing to extract \"".concat(entryPath, "\": destination is not a regular file."));
|
|
193
|
+
}
|
|
194
|
+
if (!overwrite)
|
|
195
|
+
return [2 /*return*/];
|
|
196
|
+
}
|
|
197
|
+
return [4 /*yield*/, zipfile.openReadStreamPromise(entry)];
|
|
198
|
+
case 2:
|
|
199
|
+
readStream = _a.sent();
|
|
200
|
+
return [4 /*yield*/, streamToFile(readStream, destPath)
|
|
201
|
+
// Preserve unix mode bits (external attrs high 16 bits), e.g. the exec bit
|
|
202
|
+
// on .git-hooks files in seed apps. Only entries created on a unix host
|
|
203
|
+
// (versionMadeBy platform 3) are honoured: archives created on other
|
|
204
|
+
// hosts (Windows, DOS, ...) leave these bits zero or repurpose them, and
|
|
205
|
+
// chmod-ing a mode derived from them would give the file garbage
|
|
206
|
+
// permissions.
|
|
207
|
+
];
|
|
208
|
+
case 3:
|
|
209
|
+
_a.sent();
|
|
210
|
+
mode = entry.versionMadeBy >>> 8 === 3
|
|
211
|
+
? (entry.externalFileAttributes >>> 16) & 4095
|
|
212
|
+
: 0;
|
|
213
|
+
if (mode)
|
|
214
|
+
fs_1.default.chmodSync(destPath, mode);
|
|
215
|
+
return [2 /*return*/];
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}); };
|
|
219
|
+
/**
|
|
220
|
+
* Creates dirPath (which must be at or under rootDir), creating parents as
|
|
221
|
+
* needed, and throws if any existing path component is a symbolic link.
|
|
222
|
+
*
|
|
223
|
+
* NOTE: the existsSync/lstatSync/mkdirSync sequence is inherently racy
|
|
224
|
+
* (TOCTOU) - a symlink swapped in between the check and the mkdir is
|
|
225
|
+
* traversed. Extraction is therefore strictly sequential, one entry at a
|
|
226
|
+
* time. Do not extract entries in parallel into a shared destDir without
|
|
227
|
+
* closing this window first.
|
|
228
|
+
*/
|
|
229
|
+
var ensureDirNoSymlink = function (rootDir, dirPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
230
|
+
var rootParts, targetParts, current, i, exists, stat;
|
|
231
|
+
return __generator(this, function (_a) {
|
|
232
|
+
rootParts = path_1.default.resolve(rootDir).split(path_1.default.sep);
|
|
233
|
+
targetParts = path_1.default.resolve(dirPath).split(path_1.default.sep);
|
|
234
|
+
current = rootParts[0] || path_1.default.sep;
|
|
235
|
+
for (i = 1; i < targetParts.length; i++) {
|
|
236
|
+
current = path_1.default.join(current, targetParts[i]);
|
|
237
|
+
exists = fs_1.default.existsSync(current);
|
|
238
|
+
if (exists) {
|
|
239
|
+
stat = fs_1.default.lstatSync(current);
|
|
240
|
+
if (stat.isSymbolicLink()) {
|
|
241
|
+
throw new Error("Refusing to extract into \"".concat(current, "\": symbolic link in destination path."));
|
|
242
|
+
}
|
|
243
|
+
if (!stat.isDirectory()) {
|
|
244
|
+
throw new Error("Cannot extract into \"".concat(current, "\": exists and is not a directory."));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
fs_1.default.mkdirSync(current, { recursive: false });
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return [2 /*return*/];
|
|
252
|
+
});
|
|
253
|
+
}); };
|
|
254
|
+
var streamToFile = function (readStream, destPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
255
|
+
var writeStream;
|
|
256
|
+
return __generator(this, function (_a) {
|
|
257
|
+
switch (_a.label) {
|
|
258
|
+
case 0:
|
|
259
|
+
writeStream = fs_1.default.createWriteStream(destPath, {
|
|
260
|
+
flags: 'w',
|
|
261
|
+
mode: 438
|
|
262
|
+
});
|
|
263
|
+
return [4 /*yield*/, pipelinePromise(readStream, writeStream)];
|
|
264
|
+
case 1:
|
|
265
|
+
_a.sent();
|
|
266
|
+
return [2 /*return*/];
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}); };
|
|
270
|
+
var pipelinePromise = function (readable, writable) {
|
|
271
|
+
return new Promise(function (resolve, reject) {
|
|
272
|
+
readable.on('error', reject);
|
|
273
|
+
writable.on('error', reject);
|
|
274
|
+
writable.on('close', resolve);
|
|
275
|
+
readable.pipe(writable);
|
|
276
|
+
});
|
|
277
|
+
};
|
package/package.json
CHANGED
|
@@ -70,59 +70,62 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@sasjs/adapter": "^4.19.0",
|
|
73
|
-
"@sasjs/core": "
|
|
74
|
-
"@sasjs/lint": "2.
|
|
75
|
-
"@sasjs/utils": "
|
|
76
|
-
"adm-zip": "0.6.0",
|
|
73
|
+
"@sasjs/core": "5.2.4",
|
|
74
|
+
"@sasjs/lint": "2.5.0",
|
|
75
|
+
"@sasjs/utils": "3.6.2",
|
|
77
76
|
"chalk": "4.1.2",
|
|
78
|
-
"dotenv": "
|
|
77
|
+
"dotenv": "17.4.2",
|
|
79
78
|
"find": "0.3.0",
|
|
80
|
-
"js-base64": "3.
|
|
81
|
-
"jsdom": "
|
|
79
|
+
"js-base64": "3.9.3",
|
|
80
|
+
"jsdom": "26.0.0",
|
|
82
81
|
"jwt-decode": "3.1.2",
|
|
83
82
|
"lodash.groupby": "4.6.0",
|
|
84
83
|
"lodash.uniqby": "4.7.0",
|
|
85
84
|
"node-graphviz": "0.1.1",
|
|
86
85
|
"node-powershell": "5.0.1",
|
|
87
86
|
"ora": "5.4.1",
|
|
88
|
-
"prompts": "2.4.
|
|
87
|
+
"prompts": "2.4.2",
|
|
89
88
|
"shelljs": "0.10.0",
|
|
90
89
|
"ssl-root-cas": "1.3.1",
|
|
91
90
|
"xml": "1.0.1",
|
|
92
|
-
"yargs": "17.6.2"
|
|
91
|
+
"yargs": "17.6.2",
|
|
92
|
+
"yauzl": "3.4.0",
|
|
93
|
+
"yazl": "3.3.1"
|
|
93
94
|
},
|
|
94
95
|
"devDependencies": {
|
|
95
96
|
"@babel/core": "7.29.7",
|
|
96
|
-
"@babel/preset-env": "7.
|
|
97
|
-
"@babel/preset-typescript": "7.
|
|
98
|
-
"@
|
|
99
|
-
"@types/debug": "4.1.
|
|
100
|
-
"@types/find": "0.2.
|
|
101
|
-
"@types/jest": "
|
|
97
|
+
"@babel/preset-env": "7.29.7",
|
|
98
|
+
"@babel/preset-typescript": "7.29.7",
|
|
99
|
+
"@nogoo9/gitleaks": "8.30.1-post.2",
|
|
100
|
+
"@types/debug": "4.1.13",
|
|
101
|
+
"@types/find": "0.2.4",
|
|
102
|
+
"@types/jest": "30.0.0",
|
|
102
103
|
"@types/jsdom": "21.1.1",
|
|
103
|
-
"@types/lodash.groupby": "4.6.
|
|
104
|
-
"@types/lodash.uniqby": "4.7.
|
|
105
|
-
"@types/node": "
|
|
106
|
-
"@types/shelljs": "0.8.
|
|
107
|
-
"@types/url-parse": "1.4.
|
|
108
|
-
"@types/xml": "1.0.
|
|
109
|
-
"
|
|
104
|
+
"@types/lodash.groupby": "4.6.9",
|
|
105
|
+
"@types/lodash.uniqby": "4.7.9",
|
|
106
|
+
"@types/node": "22.10.2",
|
|
107
|
+
"@types/shelljs": "0.8.10",
|
|
108
|
+
"@types/url-parse": "1.4.11",
|
|
109
|
+
"@types/xml": "1.0.11",
|
|
110
|
+
"@types/yauzl": "3.4.0",
|
|
111
|
+
"@types/yazl": "3.3.1",
|
|
112
|
+
"babel-jest": "30.5.1",
|
|
110
113
|
"copyfiles": "2.4.1",
|
|
111
|
-
"jest": "
|
|
112
|
-
"jest-cli": "
|
|
113
|
-
"jest-environment-jsdom": "
|
|
114
|
-
"jest-extended": "
|
|
115
|
-
"nodemon": "3.
|
|
116
|
-
"prettier": "
|
|
117
|
-
"ts-jest": "29.
|
|
118
|
-
"ts-node": "10.
|
|
119
|
-
"tslib": "2.
|
|
120
|
-
"typescript": "
|
|
121
|
-
"util": "0.12.
|
|
114
|
+
"jest": "30.5.1",
|
|
115
|
+
"jest-cli": "30.5.1",
|
|
116
|
+
"jest-environment-jsdom": "30.5.1",
|
|
117
|
+
"jest-extended": "4.0.2",
|
|
118
|
+
"nodemon": "3.1.14",
|
|
119
|
+
"prettier": "3.9.6",
|
|
120
|
+
"ts-jest": "29.4.12",
|
|
121
|
+
"ts-node": "10.9.2",
|
|
122
|
+
"tslib": "2.8.1",
|
|
123
|
+
"typescript": "5.9.3",
|
|
124
|
+
"util": "0.12.5"
|
|
122
125
|
},
|
|
123
126
|
"overrides": {
|
|
124
127
|
"ws": "8.21.0",
|
|
125
128
|
"nanoid": "3.3.18"
|
|
126
129
|
},
|
|
127
|
-
"version": "4.20.
|
|
130
|
+
"version": "4.20.3"
|
|
128
131
|
}
|