@sasjs/cli 4.20.4 → 4.20.5
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var shelljs_1 = __importDefault(require("shelljs"));
|
|
18
|
+
var utils_1 = require("@sasjs/utils");
|
|
19
|
+
var utils_2 = require("../utils");
|
|
20
|
+
jest.mock('shelljs', function () { return ({
|
|
21
|
+
exec: jest.fn(function () { return ({ stdout: '', stderr: '', code: 0 }); }),
|
|
22
|
+
which: jest.fn()
|
|
23
|
+
}); });
|
|
24
|
+
jest.mock('@sasjs/utils', function () { return (__assign(__assign({}, jest.requireActual('@sasjs/utils')), { isLinux: jest.fn(), isWindows: jest.fn() })); });
|
|
25
|
+
describe('downloadFile', function () {
|
|
26
|
+
var exec = shelljs_1.default.exec;
|
|
27
|
+
var which = shelljs_1.default.which;
|
|
28
|
+
var linux = utils_1.isLinux;
|
|
29
|
+
var windows = utils_1.isWindows;
|
|
30
|
+
beforeEach(function () {
|
|
31
|
+
jest.clearAllMocks();
|
|
32
|
+
exec.mockReturnValue({ stdout: '', stderr: '', code: 0 });
|
|
33
|
+
});
|
|
34
|
+
it('uses wget on linux when it is installed', function () {
|
|
35
|
+
linux.mockReturnValue(true);
|
|
36
|
+
windows.mockReturnValue(false);
|
|
37
|
+
which.mockReturnValue('/usr/bin/wget');
|
|
38
|
+
(0, utils_2.downloadFile)('https://example.com/main.zip', 'main.zip');
|
|
39
|
+
expect(exec).toHaveBeenCalledWith('wget https://example.com/main.zip -O main.zip', { silent: true });
|
|
40
|
+
});
|
|
41
|
+
it('falls back to curl on linux when wget is not installed', function () {
|
|
42
|
+
linux.mockReturnValue(true);
|
|
43
|
+
windows.mockReturnValue(false);
|
|
44
|
+
which.mockReturnValue(null);
|
|
45
|
+
(0, utils_2.downloadFile)('https://example.com/main.zip', 'main.zip');
|
|
46
|
+
expect(exec).toHaveBeenCalledWith('curl https://example.com/main.zip -L -f -o main.zip', { silent: true });
|
|
47
|
+
});
|
|
48
|
+
it('uses curl on linux without a filename, saving under the remote basename', function () {
|
|
49
|
+
linux.mockReturnValue(true);
|
|
50
|
+
windows.mockReturnValue(false);
|
|
51
|
+
which.mockReturnValue(null);
|
|
52
|
+
(0, utils_2.downloadFile)('https://example.com/main.zip');
|
|
53
|
+
expect(exec).toHaveBeenCalledWith('curl https://example.com/main.zip -L -f -O', { silent: true });
|
|
54
|
+
});
|
|
55
|
+
it('uses curl on macOS', function () {
|
|
56
|
+
linux.mockReturnValue(false);
|
|
57
|
+
windows.mockReturnValue(false);
|
|
58
|
+
which.mockReturnValue(null);
|
|
59
|
+
(0, utils_2.downloadFile)('https://example.com/main.zip', 'main.zip');
|
|
60
|
+
expect(exec).toHaveBeenCalledWith('curl https://example.com/main.zip -L -f -o main.zip', { silent: true });
|
|
61
|
+
});
|
|
62
|
+
it('uses powershell on windows', function () {
|
|
63
|
+
linux.mockReturnValue(false);
|
|
64
|
+
windows.mockReturnValue(true);
|
|
65
|
+
(0, utils_2.downloadFile)('https://example.com/main.zip', 'main.zip');
|
|
66
|
+
expect(exec.mock.calls[0][0]).toContain('Invoke-WebRequest https://example.com/main.zip -O main.zip');
|
|
67
|
+
});
|
|
68
|
+
});
|
package/build/utils/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ShellString } from 'shelljs';
|
|
1
2
|
import { Target, MacroVars } from '@sasjs/utils';
|
|
2
3
|
import SASjs from '@sasjs/adapter/node';
|
|
3
4
|
import { LogJson } from '../types';
|
|
@@ -7,6 +8,7 @@ export declare function createReactApp(folderPath: string): Promise<void>;
|
|
|
7
8
|
export declare function createAngularApp(folderPath: string): Promise<void>;
|
|
8
9
|
export declare function createMinimalApp(folderPath: string): Promise<void>;
|
|
9
10
|
export declare function createTemplateApp(folderPath: string, template: string): Promise<void>;
|
|
11
|
+
export declare function downloadFile(url: string, filename?: string): ShellString;
|
|
10
12
|
export declare function setupNpmProject(folderName: string): Promise<void>;
|
|
11
13
|
export declare function setupGitIgnore(folderName: string): Promise<void>;
|
|
12
14
|
export declare function setupDoxygen(folderPath: string): Promise<void>;
|
package/build/utils/utils.js
CHANGED
|
@@ -97,6 +97,7 @@ exports.createReactApp = createReactApp;
|
|
|
97
97
|
exports.createAngularApp = createAngularApp;
|
|
98
98
|
exports.createMinimalApp = createMinimalApp;
|
|
99
99
|
exports.createTemplateApp = createTemplateApp;
|
|
100
|
+
exports.downloadFile = downloadFile;
|
|
100
101
|
exports.setupNpmProject = setupNpmProject;
|
|
101
102
|
exports.setupGitIgnore = setupGitIgnore;
|
|
102
103
|
exports.setupDoxygen = setupDoxygen;
|
|
@@ -258,7 +259,7 @@ function createApp(folderPath_1, repoUrl_1, docsUrl_1, errorCallback_1) {
|
|
|
258
259
|
zipName = 'master.zip';
|
|
259
260
|
_b = downloadFile("".concat(repoUrl).concat(zipPath).concat(zipName), zipName), stdout_1 = _b.stdout, stderr_1 = _b.stderr, code_1 = _b.code;
|
|
260
261
|
if (stderr_1.includes('404: Not Found') || code_1) {
|
|
261
|
-
errorCallback("".concat(repoUrl).concat(zipPath, " is
|
|
262
|
+
errorCallback("Could not download ".concat(repoUrl).concat(zipPath, "main.zip or master.zip - is ").concat(repoUrl, " a SASjs repository?"));
|
|
262
263
|
return [2 /*return*/];
|
|
263
264
|
}
|
|
264
265
|
}
|
|
@@ -316,7 +317,7 @@ var loadDocsSubmodule = function (docsUrl, folderPath, zipPath) { return __await
|
|
|
316
317
|
});
|
|
317
318
|
}); };
|
|
318
319
|
function downloadFile(url, filename) {
|
|
319
|
-
if ((0, utils_1.isLinux)()) {
|
|
320
|
+
if ((0, utils_1.isLinux)() && shelljs_1.default.which('wget')) {
|
|
320
321
|
// -O <filename> writes to the given name; without it, wget defaults to the
|
|
321
322
|
// remote URL's basename, which silently ignores the caller's `filename` and
|
|
322
323
|
// can leave an unexpectedly-named file behind (e.g. a repo-existence probe
|
|
@@ -330,9 +331,9 @@ function downloadFile(url, filename) {
|
|
|
330
331
|
return shelljs_1.default.exec("powershell.exe \"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest ".concat(url, " ").concat(filename ? '-O ' + filename : '', "\""), { silent: true });
|
|
331
332
|
}
|
|
332
333
|
else {
|
|
333
|
-
//
|
|
334
|
-
// under the remote URL's basename, ignoring
|
|
335
|
-
// above for the same issue.
|
|
334
|
+
// curl, on macOS and on Linux hosts without wget. -o <filename> writes to
|
|
335
|
+
// the given name; -O instead saves under the remote URL's basename, ignoring
|
|
336
|
+
// `filename` - see the wget note above for the same issue.
|
|
336
337
|
return shelljs_1.default.exec("curl ".concat(url, " -L -f").concat(filename ? ' -o ' + filename : ' -O'), { silent: true });
|
|
337
338
|
}
|
|
338
339
|
}
|
package/package.json
CHANGED
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"registry": "https://registry.npmjs.org"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@sasjs/adapter": "
|
|
73
|
-
"@sasjs/core": "5.2.
|
|
74
|
-
"@sasjs/lint": "
|
|
72
|
+
"@sasjs/adapter": "4.19.1",
|
|
73
|
+
"@sasjs/core": "5.2.10",
|
|
74
|
+
"@sasjs/lint": "4.1.0",
|
|
75
75
|
"@sasjs/utils": "3.6.2",
|
|
76
76
|
"chalk": "4.1.2",
|
|
77
77
|
"dotenv": "17.4.2",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"ws": "8.21.0",
|
|
128
128
|
"nanoid": "3.3.18"
|
|
129
129
|
},
|
|
130
|
-
"version": "4.20.
|
|
130
|
+
"version": "4.20.5"
|
|
131
131
|
}
|