@sasjs/cli 4.20.6 → 4.20.8
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/build/commands/add/spec/addTarget.spec.js +5 -5
- package/build/commands/build/spec/build.spec.js +3 -3
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +1 -1
- package/build/commands/compile/spec/compareFolders.spec.js +2 -1
- package/build/commands/compile/spec/compile.spec.js +7 -7
- package/build/commands/compile/spec/compileFile.spec.js +1 -1
- package/build/commands/compile/spec/copyFilesToBuildFolder.spec.js +1 -1
- package/build/commands/compile/spec/loadDependencies.spec.js +1 -1
- package/build/commands/create/spec/create.spec.js +45 -11
- package/build/commands/db/spec/db.spec.js +1 -1
- package/build/commands/deploy/spec/cbd.spec.js +1 -1
- package/build/commands/deploy/spec/deploy.spec.js +1 -1
- package/build/commands/deploy/spec/getDeployScripts.spec.js +1 -1
- package/build/commands/docs/generateDocs.js +2 -2
- package/build/commands/docs/spec/generateDocs.spec.js +41 -8
- package/build/commands/docs/spec/generateDot.spec.js +3 -3
- package/build/commands/docs/spec/initDocs.spec.js +1 -1
- package/build/commands/flow/internal/spec/saveToCsv.spec.js +4 -3
- package/build/commands/flow/internal/spec/validateParams.spec.js +2 -1
- package/build/commands/init/spec/init.spec.js +3 -3
- package/build/commands/testing/spec/testing.spec.js +1 -1
- package/build/commands/version/version.js +4 -9
- package/build/commands/web/internal/spec/updateScriptTag.spec.js +2 -1
- package/build/commands/web/internal/spec/updateStyleTag.spec.js +2 -1
- package/build/commands/web/spec/web.spec.js +1 -1
- package/build/utils/auth.d.ts +6 -0
- package/build/utils/auth.js +7 -1
- package/build/utils/shell.d.ts +60 -0
- package/build/utils/shell.js +155 -0
- package/build/utils/spec/auth.spec.js +13 -0
- package/build/utils/spec/config.spec.js +13 -13
- package/build/utils/spec/downloadFile.spec.js +37 -10
- package/build/utils/spec/file.spec.js +2 -1
- package/build/utils/spec/shell.spec.d.ts +1 -0
- package/build/utils/spec/shell.spec.js +156 -0
- package/build/utils/spec/utils.spec.js +5 -5
- package/build/utils/spec/zip.spec.js +2 -1
- package/build/utils/test.d.ts +10 -0
- package/build/utils/test.js +16 -1
- package/build/utils/utils.d.ts +2 -2
- package/build/utils/utils.js +65 -31
- package/package.json +8 -11
|
@@ -343,7 +343,7 @@ describe('utils', function () {
|
|
|
343
343
|
});
|
|
344
344
|
});
|
|
345
345
|
describe('loadEnvVariables', function () {
|
|
346
|
-
var fileName = ".env.".concat((0,
|
|
346
|
+
var fileName = ".env.".concat((0, test_1.generateUniqueTimestamp)());
|
|
347
347
|
var filePath = path_1.default.join(process.projectDir, fileName);
|
|
348
348
|
beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
349
349
|
var fileContent;
|
|
@@ -426,7 +426,7 @@ describe('utils', function () {
|
|
|
426
426
|
return __generator(this, function (_a) {
|
|
427
427
|
switch (_a.label) {
|
|
428
428
|
case 0:
|
|
429
|
-
projectDir = path_1.default.join(__dirname, "is-sasjs-project-".concat((0,
|
|
429
|
+
projectDir = path_1.default.join(__dirname, "is-sasjs-project-".concat((0, test_1.generateUniqueTimestamp)()));
|
|
430
430
|
originalProjectDir = process.projectDir;
|
|
431
431
|
return [4 /*yield*/, (0, utils_2.createFolder)(path_1.default.join(projectDir, 'sasjs'))];
|
|
432
432
|
case 1:
|
|
@@ -451,7 +451,7 @@ describe('utils', function () {
|
|
|
451
451
|
return __generator(this, function (_a) {
|
|
452
452
|
switch (_a.label) {
|
|
453
453
|
case 0:
|
|
454
|
-
projectDir = path_1.default.join(require('os').tmpdir(), "not-a-sasjs-project-".concat((0,
|
|
454
|
+
projectDir = path_1.default.join(require('os').tmpdir(), "not-a-sasjs-project-".concat((0, test_1.generateUniqueTimestamp)()));
|
|
455
455
|
originalProjectDir = process.projectDir;
|
|
456
456
|
return [4 /*yield*/, (0, utils_2.createFolder)(projectDir)];
|
|
457
457
|
case 1:
|
|
@@ -498,8 +498,8 @@ describe('utils', function () {
|
|
|
498
498
|
return __generator(this, function (_a) {
|
|
499
499
|
switch (_a.label) {
|
|
500
500
|
case 0:
|
|
501
|
-
fakeModuleName = "sasjs-test-fake-module-".concat((0,
|
|
502
|
-
fromDir = path_1.default.join(require('os').tmpdir(), "getNodeModulePath-".concat((0,
|
|
501
|
+
fakeModuleName = "sasjs-test-fake-module-".concat((0, test_1.generateUniqueTimestamp)());
|
|
502
|
+
fromDir = path_1.default.join(require('os').tmpdir(), "getNodeModulePath-".concat((0, test_1.generateUniqueTimestamp)()));
|
|
503
503
|
fakeModuleDir = path_1.default.join(fromDir, 'node_modules', fakeModuleName);
|
|
504
504
|
return [4 /*yield*/, (0, utils_2.createFolder)(fakeModuleDir)];
|
|
505
505
|
case 1:
|
|
@@ -43,6 +43,7 @@ var fs_1 = __importDefault(require("fs"));
|
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
44
|
var yazl_1 = __importDefault(require("yazl"));
|
|
45
45
|
var utils_1 = require("@sasjs/utils");
|
|
46
|
+
var test_1 = require("../test");
|
|
46
47
|
var zip_1 = require("../zip");
|
|
47
48
|
var utils_2 = require("@sasjs/utils");
|
|
48
49
|
var makeZip = function (entries, zipPath) {
|
|
@@ -84,7 +85,7 @@ var setEntryPlatform = function (zipPath, platform) {
|
|
|
84
85
|
fs_1.default.writeFileSync(zipPath, buffer);
|
|
85
86
|
};
|
|
86
87
|
describe('zip', function () {
|
|
87
|
-
var tmpRoot = path_1.default.join(__dirname, "zip-spec-".concat((0,
|
|
88
|
+
var tmpRoot = path_1.default.join(__dirname, "zip-spec-".concat((0, test_1.generateUniqueTimestamp)()));
|
|
88
89
|
var destDir = path_1.default.join(tmpRoot, 'dest');
|
|
89
90
|
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
91
|
return __generator(this, function (_a) {
|
package/build/utils/test.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { ServerType, Target, TargetJson, Configuration } from '@sasjs/utils/types';
|
|
2
2
|
import { Folder } from '../types';
|
|
3
3
|
import { ServiceConfig, JobConfig } from '@sasjs/utils/types/config';
|
|
4
|
+
/**
|
|
5
|
+
* A name for a test app or output folder that two specs cannot collide on.
|
|
6
|
+
*
|
|
7
|
+
* `generateTimestamp()` is second-resolution - year, month, day, hour, minute,
|
|
8
|
+
* second, and nothing finer - so two specs in one directory starting within the
|
|
9
|
+
* same second build the same folder name and clobber each other, which is what
|
|
10
|
+
* the docs specs do whenever jest runs them in parallel. The milliseconds and a
|
|
11
|
+
* short random suffix make that impossible while keeping the name readable.
|
|
12
|
+
*/
|
|
13
|
+
export declare const generateUniqueTimestamp: () => string;
|
|
4
14
|
export declare const createTestApp: (parentFolder: string, appName: string) => Promise<void>;
|
|
5
15
|
export declare const createTestJobsApp: (parentFolder: string, appName: string) => Promise<void>;
|
|
6
16
|
export declare const createTestMinimalApp: (parentFolder: string, appName: string) => Promise<void>;
|
package/build/utils/test.js
CHANGED
|
@@ -75,7 +75,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
75
75
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
76
76
|
};
|
|
77
77
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
|
-
exports.verifyGitNotPresent = exports.verifyCompiledJob = exports.verifyCompiledService = exports.verifyDotFilesNotGenerated = exports.verifyDotFiles = exports.verifyDocs = exports.updateConfig = exports.updateTarget = exports.removeAllTargetsFromConfigs = exports.verifyPackageJsonContent = exports.verifyFolder = exports.mockProcessExit = exports.verifyStep = exports.createTestGlobalTarget = exports.generateTestTarget = exports.removeTestServerFolder = exports.removeTestApp = exports.createTestMinimalApp = exports.createTestJobsApp = exports.createTestApp = void 0;
|
|
78
|
+
exports.verifyGitNotPresent = exports.verifyCompiledJob = exports.verifyCompiledService = exports.verifyDotFilesNotGenerated = exports.verifyDotFiles = exports.verifyDocs = exports.updateConfig = exports.updateTarget = exports.removeAllTargetsFromConfigs = exports.verifyPackageJsonContent = exports.verifyFolder = exports.mockProcessExit = exports.verifyStep = exports.createTestGlobalTarget = exports.generateTestTarget = exports.removeTestServerFolder = exports.removeTestApp = exports.createTestMinimalApp = exports.createTestJobsApp = exports.createTestApp = exports.generateUniqueTimestamp = void 0;
|
|
79
79
|
var path_1 = __importDefault(require("path"));
|
|
80
80
|
var dotenv_1 = __importDefault(require("dotenv"));
|
|
81
81
|
var utils_1 = require("@sasjs/utils");
|
|
@@ -89,6 +89,21 @@ var builtFiles_1 = require("./fileStructures/builtFiles");
|
|
|
89
89
|
var builtFilesCustom1_1 = require("./fileStructures/builtFilesCustom1");
|
|
90
90
|
var create_1 = require("../commands/create/create");
|
|
91
91
|
var setConstants_1 = require("./setConstants");
|
|
92
|
+
/**
|
|
93
|
+
* A name for a test app or output folder that two specs cannot collide on.
|
|
94
|
+
*
|
|
95
|
+
* `generateTimestamp()` is second-resolution - year, month, day, hour, minute,
|
|
96
|
+
* second, and nothing finer - so two specs in one directory starting within the
|
|
97
|
+
* same second build the same folder name and clobber each other, which is what
|
|
98
|
+
* the docs specs do whenever jest runs them in parallel. The milliseconds and a
|
|
99
|
+
* short random suffix make that impossible while keeping the name readable.
|
|
100
|
+
*/
|
|
101
|
+
var generateUniqueTimestamp = function () {
|
|
102
|
+
return "".concat((0, utils_1.generateTimestamp)(), "-").concat(Date.now() % 1000, "-").concat(Math.random()
|
|
103
|
+
.toString(36)
|
|
104
|
+
.slice(2, 7));
|
|
105
|
+
};
|
|
106
|
+
exports.generateUniqueTimestamp = generateUniqueTimestamp;
|
|
92
107
|
var createTestApp = function (parentFolder, appName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
108
|
var _a;
|
|
94
109
|
return __generator(this, function (_b) {
|
package/build/utils/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ShellResult } from './shell';
|
|
2
2
|
import { Target, MacroVars } from '@sasjs/utils';
|
|
3
3
|
import SASjs from '@sasjs/adapter/node';
|
|
4
4
|
import { LogJson } from '../types';
|
|
@@ -8,7 +8,7 @@ export declare function createReactApp(folderPath: string): Promise<void>;
|
|
|
8
8
|
export declare function createAngularApp(folderPath: string): Promise<void>;
|
|
9
9
|
export declare function createMinimalApp(folderPath: string): Promise<void>;
|
|
10
10
|
export declare function createTemplateApp(folderPath: string, template: string): Promise<void>;
|
|
11
|
-
export declare function downloadFile(url: string, filename?: string):
|
|
11
|
+
export declare function downloadFile(url: string, filename?: string): ShellResult;
|
|
12
12
|
export declare function setupNpmProject(folderName: string): Promise<void>;
|
|
13
13
|
export declare function setupGitIgnore(folderName: string): Promise<void>;
|
|
14
14
|
export declare function setupDoxygen(folderPath: string): Promise<void>;
|
package/build/utils/utils.js
CHANGED
|
@@ -110,8 +110,10 @@ exports.checkNodeVersion = checkNodeVersion;
|
|
|
110
110
|
exports.getAdapterInstance = getAdapterInstance;
|
|
111
111
|
exports.displaySasjsRunnerError = displaySasjsRunnerError;
|
|
112
112
|
exports.prefixAppLoc = prefixAppLoc;
|
|
113
|
-
var
|
|
113
|
+
var shell_1 = require("./shell");
|
|
114
114
|
var node_powershell_1 = require("node-powershell");
|
|
115
|
+
var fs_1 = __importDefault(require("fs"));
|
|
116
|
+
var os_1 = __importDefault(require("os"));
|
|
115
117
|
var path_1 = __importDefault(require("path"));
|
|
116
118
|
var ora_1 = __importDefault(require("ora"));
|
|
117
119
|
var axios_1 = __importDefault(require("axios"));
|
|
@@ -208,15 +210,17 @@ function createTemplateApp(folderPath, template) {
|
|
|
208
210
|
var _this = this;
|
|
209
211
|
return __generator(this, function (_a) {
|
|
210
212
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
211
|
-
var probeFile, _a, stderr, code;
|
|
213
|
+
var probeDir, probeFile, _a, stderr, code;
|
|
212
214
|
return __generator(this, function (_b) {
|
|
213
215
|
switch (_b.label) {
|
|
214
216
|
case 0:
|
|
215
|
-
|
|
217
|
+
probeDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'sasjs-probe-'));
|
|
218
|
+
probeFile = path_1.default.join(probeDir, 'response.txt');
|
|
216
219
|
_a = downloadFile("https://username:password@github.com/sasjs/template_".concat(template), probeFile), stderr = _a.stderr, code = _a.code;
|
|
217
220
|
return [4 /*yield*/, (0, utils_1.deleteFile)(probeFile).catch(function () { })];
|
|
218
221
|
case 1:
|
|
219
222
|
_b.sent();
|
|
223
|
+
(0, shell_1.rm)([probeDir], true);
|
|
220
224
|
if (stderr.includes('404: Not Found') || code) {
|
|
221
225
|
return [2 /*return*/, reject(new Error("Template \"".concat(template, "\" is not a SASjs template")))];
|
|
222
226
|
}
|
|
@@ -242,43 +246,64 @@ function createTemplateApp(folderPath, template) {
|
|
|
242
246
|
*/
|
|
243
247
|
function createApp(folderPath_1, repoUrl_1, docsUrl_1, errorCallback_1) {
|
|
244
248
|
return __awaiter(this, arguments, void 0, function (folderPath, repoUrl, docsUrl, errorCallback, installDependencies) {
|
|
245
|
-
var zipName, zipPath, fullZipPath, spinner,
|
|
249
|
+
var zipName, zipPath, fullZipPath, spinner, workspace, _a, stderr, code, _b, stderr_1, code_1, zipWithoutExtension, extractedFolder, err_1;
|
|
250
|
+
var _c;
|
|
246
251
|
if (installDependencies === void 0) { installDependencies = true; }
|
|
247
|
-
return __generator(this, function (
|
|
248
|
-
switch (
|
|
252
|
+
return __generator(this, function (_d) {
|
|
253
|
+
switch (_d.label) {
|
|
249
254
|
case 0:
|
|
250
255
|
zipName = 'main.zip';
|
|
251
256
|
zipPath = "/archive/refs/heads/";
|
|
252
257
|
fullZipPath = "".concat(zipPath).concat(zipName);
|
|
253
258
|
spinner = (0, ora_1.default)("Creating SASjs project in ".concat(folderPath, "."));
|
|
254
259
|
spinner.start();
|
|
255
|
-
|
|
260
|
+
workspace = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'sasjs-create-'));
|
|
261
|
+
_a = downloadFile("".concat(repoUrl).concat(fullZipPath), path_1.default.join(workspace, zipName)), stderr = _a.stderr, code = _a.code;
|
|
256
262
|
// If doesn't exist, we try again, but with master.zip for the zip name.
|
|
257
263
|
// Since that's the name generated from branch name.
|
|
258
264
|
if (stderr.includes('404: Not Found') || code) {
|
|
259
265
|
zipName = 'master.zip';
|
|
260
|
-
_b = downloadFile("".concat(repoUrl).concat(zipPath).concat(zipName), zipName),
|
|
266
|
+
_b = downloadFile("".concat(repoUrl).concat(zipPath).concat(zipName), path_1.default.join(workspace, zipName)), stderr_1 = _b.stderr, code_1 = _b.code;
|
|
261
267
|
if (stderr_1.includes('404: Not Found') || code_1) {
|
|
268
|
+
spinner.stop();
|
|
269
|
+
(0, shell_1.rm)([workspace], true);
|
|
262
270
|
errorCallback("Could not download ".concat(repoUrl).concat(zipPath, "main.zip or master.zip - is ").concat(repoUrl, " a SASjs repository?"));
|
|
263
271
|
return [2 /*return*/];
|
|
264
272
|
}
|
|
265
273
|
}
|
|
266
274
|
zipWithoutExtension = zipName.replace('.zip', '');
|
|
267
|
-
|
|
275
|
+
_d.label = 1;
|
|
268
276
|
case 1:
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
shelljs_1.default.rm('-rf', ["./*".concat(zipWithoutExtension)]);
|
|
272
|
-
shelljs_1.default.rm('-rf', ["./".concat(zipName)]);
|
|
273
|
-
return [4 /*yield*/, loadDocsSubmodule(docsUrl, folderPath, fullZipPath)];
|
|
277
|
+
_d.trys.push([1, 5, 6, 7]);
|
|
278
|
+
return [4 /*yield*/, (0, zip_1.extractZip)(path_1.default.join(workspace, zipName), workspace, true)];
|
|
274
279
|
case 2:
|
|
275
|
-
|
|
276
|
-
|
|
280
|
+
_d.sent();
|
|
281
|
+
extractedFolder = (0, shell_1.ls)(path_1.default.join(workspace, "*".concat(zipWithoutExtension)))[0];
|
|
282
|
+
if (!extractedFolder) {
|
|
283
|
+
spinner.stop();
|
|
284
|
+
return [2 /*return*/, errorCallback("Could not find the unzipped ".concat(zipWithoutExtension, " folder."))];
|
|
285
|
+
}
|
|
286
|
+
return [4 /*yield*/, (0, shell_1.cp)("".concat(extractedFolder, "/."), folderPath)];
|
|
287
|
+
case 3:
|
|
288
|
+
_d.sent();
|
|
289
|
+
return [4 /*yield*/, loadDocsSubmodule(docsUrl, folderPath, workspace, fullZipPath)];
|
|
290
|
+
case 4:
|
|
291
|
+
_d.sent();
|
|
292
|
+
(0, shell_1.rm)([path_1.default.join(folderPath, '.gitmodules')]);
|
|
293
|
+
return [3 /*break*/, 7];
|
|
294
|
+
case 5:
|
|
295
|
+
err_1 = _d.sent();
|
|
296
|
+
spinner.stop();
|
|
297
|
+
return [2 /*return*/, errorCallback((_c = err_1 === null || err_1 === void 0 ? void 0 : err_1.message) !== null && _c !== void 0 ? _c : String(err_1))];
|
|
298
|
+
case 6:
|
|
299
|
+
(0, shell_1.rm)([workspace], true);
|
|
300
|
+
return [7 /*endfinally*/];
|
|
301
|
+
case 7:
|
|
277
302
|
spinner.stop();
|
|
278
303
|
if (installDependencies) {
|
|
279
304
|
spinner.text = 'Installing dependencies...';
|
|
280
305
|
spinner.start();
|
|
281
|
-
|
|
306
|
+
(0, shell_1.exec)("cd \"".concat(folderPath, "\" && npm install"), {
|
|
282
307
|
silent: true
|
|
283
308
|
});
|
|
284
309
|
spinner.stop();
|
|
@@ -292,10 +317,11 @@ function createApp(folderPath_1, repoUrl_1, docsUrl_1, errorCallback_1) {
|
|
|
292
317
|
* It will download and unzip `sasjs/docs` into newly created folder into `docs` subfolder
|
|
293
318
|
* @param docsUrl sasjs/docs repo url
|
|
294
319
|
* @param folderPath full path to the newly created folder that contains the seed app
|
|
320
|
+
* @param workspace directory this run unpacks into
|
|
295
321
|
* @param zipPath fixed path of where github puts zip for repo download
|
|
296
322
|
*/
|
|
297
|
-
var loadDocsSubmodule = function (docsUrl, folderPath, zipPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
298
|
-
var docsFolderPath;
|
|
323
|
+
var loadDocsSubmodule = function (docsUrl, folderPath, workspace, zipPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
324
|
+
var docsFolderPath, docsWorkspace, docsFolder;
|
|
299
325
|
return __generator(this, function (_a) {
|
|
300
326
|
switch (_a.label) {
|
|
301
327
|
case 0:
|
|
@@ -305,36 +331,44 @@ var loadDocsSubmodule = function (docsUrl, folderPath, zipPath) { return __await
|
|
|
305
331
|
case 1:
|
|
306
332
|
if (!(_a.sent()))
|
|
307
333
|
docsFolderPath = "".concat(folderPath, "/docs"); // If not, we load submodule in root
|
|
308
|
-
|
|
309
|
-
|
|
334
|
+
docsWorkspace = path_1.default.join(workspace, 'docs');
|
|
335
|
+
fs_1.default.mkdirSync(docsWorkspace, { recursive: true });
|
|
336
|
+
downloadFile("".concat(docsUrl).concat(zipPath), path_1.default.join(docsWorkspace, 'main.zip'));
|
|
337
|
+
return [4 /*yield*/, (0, zip_1.extractZip)(path_1.default.join(docsWorkspace, 'main.zip'), docsWorkspace, true)];
|
|
310
338
|
case 2:
|
|
311
339
|
_a.sent();
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
340
|
+
docsFolder = (0, shell_1.ls)(path_1.default.join(docsWorkspace, '*-main'))[0];
|
|
341
|
+
if (!docsFolder) {
|
|
342
|
+
throw new Error('Could not find the unzipped docs folder.');
|
|
343
|
+
}
|
|
344
|
+
return [4 /*yield*/, (0, shell_1.cp)("".concat(docsFolder, "/."), docsFolderPath)];
|
|
345
|
+
case 3:
|
|
346
|
+
_a.sent();
|
|
315
347
|
return [2 /*return*/];
|
|
316
348
|
}
|
|
317
349
|
});
|
|
318
350
|
}); };
|
|
319
351
|
function downloadFile(url, filename) {
|
|
320
|
-
if ((0, utils_1.isLinux)() &&
|
|
352
|
+
if ((0, utils_1.isLinux)() && (0, shell_1.which)('wget')) {
|
|
321
353
|
// -O <filename> writes to the given name; without it, wget defaults to the
|
|
322
354
|
// remote URL's basename, which silently ignores the caller's `filename` and
|
|
323
355
|
// can leave an unexpectedly-named file behind (e.g. a repo-existence probe
|
|
324
356
|
// meant to be discarded as `response.txt` instead landing as the repo name).
|
|
325
|
-
return
|
|
357
|
+
return (0, shell_1.exec)("wget ".concat(url).concat(filename ? ' -O ' + filename : ''), {
|
|
326
358
|
silent: true
|
|
327
359
|
});
|
|
328
360
|
}
|
|
329
361
|
else if ((0, utils_1.isWindows)()) {
|
|
330
362
|
// First We set TLS12 & then we invoke request to download file.
|
|
331
|
-
return
|
|
363
|
+
return (0, shell_1.exec)("powershell.exe \"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest ".concat(url, " ").concat(filename ? '-O ' + filename : '', "\""), { silent: true });
|
|
332
364
|
}
|
|
333
365
|
else {
|
|
334
366
|
// curl, on macOS and on Linux hosts without wget. -o <filename> writes to
|
|
335
367
|
// the given name; -O instead saves under the remote URL's basename, ignoring
|
|
336
368
|
// `filename` - see the wget note above for the same issue.
|
|
337
|
-
return
|
|
369
|
+
return (0, shell_1.exec)("curl ".concat(url, " -L -f").concat(filename ? ' -o ' + filename : ' -O'), {
|
|
370
|
+
silent: true
|
|
371
|
+
});
|
|
338
372
|
}
|
|
339
373
|
}
|
|
340
374
|
function setupNpmProject(folderName) {
|
|
@@ -353,7 +387,7 @@ function setupNpmProject(folderName) {
|
|
|
353
387
|
isExistingProject = _d.sent();
|
|
354
388
|
if (!isExistingProject) {
|
|
355
389
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Initialising NPM project in ".concat(folderPath));
|
|
356
|
-
|
|
390
|
+
(0, shell_1.exec)("cd \"".concat(folderPath, "\" && npm init --yes"), {
|
|
357
391
|
silent: true
|
|
358
392
|
});
|
|
359
393
|
}
|
|
@@ -361,7 +395,7 @@ function setupNpmProject(folderName) {
|
|
|
361
395
|
(_b = process.logger) === null || _b === void 0 ? void 0 : _b.success('Existing NPM project detected.');
|
|
362
396
|
}
|
|
363
397
|
(_c = process.logger) === null || _c === void 0 ? void 0 : _c.info('Installing @sasjs/core');
|
|
364
|
-
|
|
398
|
+
(0, shell_1.exec)("cd \"".concat(folderPath, "\" && npm i @sasjs/core --save"), {
|
|
365
399
|
silent: true
|
|
366
400
|
});
|
|
367
401
|
return [2 /*return*/, resolve()];
|
|
@@ -465,7 +499,7 @@ function executeShellScript(filePath, logFilePath) {
|
|
|
465
499
|
switch (_b.label) {
|
|
466
500
|
case 0:
|
|
467
501
|
shellCommand = (0, utils_1.isWindows)() ? "".concat(filePath) : "bash ".concat(filePath);
|
|
468
|
-
result =
|
|
502
|
+
result = (0, shell_1.exec)(shellCommand, { silent: true });
|
|
469
503
|
if (!result.code) return [3 /*break*/, 1];
|
|
470
504
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("Error: ".concat(result.stderr));
|
|
471
505
|
reject(result.code);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sasjs/cli",
|
|
3
3
|
"description": "Command line interface for SASjs",
|
|
4
4
|
"engines": {
|
|
5
|
-
"node": ">=
|
|
5
|
+
"node": "^14.18.0 || >=16.10.0"
|
|
6
6
|
},
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"files": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
12
|
"nodeVersionMessage": "echo \u001b[33m make sure you are running node lts version \u001b[0m",
|
|
13
|
-
"checkNodeVersion": "node -e \"console.log('
|
|
13
|
+
"checkNodeVersion": "node -e \"console.log('\\u001b[36m', 'Checking your Node.js version...'); const v = process.versions && process.versions.node; const ok = v && (() => { const [m, n] = v.split('.').map(Number); if (m === 14) return n >= 18; if (m === 15) return false; if (m === 16) return n >= 10; return m > 16 })(); if (!ok) { console.log('\\u001b[31m', '\\u274c You must be running Node.js ^14.18.0 || >=16.10.0 to install SASjs CLI.\\nYour current version is ' + v + '.\\nPlease install a more recent version and try again.'); process.exit(1) } else { console.log('\\u001b[32m', '\\u2705 Node.js version check passed. Continuing...') } console.log('\\u001b[0m', '');\"",
|
|
14
14
|
"start:ci": "npm run build && npm run set:permissions",
|
|
15
15
|
"start": "nodemon --watch \"src/**/*\" --exec \"npm run build && npm run set:permissions\"",
|
|
16
16
|
"set:permissions": "node -e \"require('fs').chmodSync('build/index.js', '755')\"",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"test:mocked": "jest --silent --runInBand --config=jest.config.js --coverage",
|
|
23
23
|
"lint:fix": "npx prettier --write \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
|
|
24
24
|
"lint": "npx prettier --check \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
|
|
25
|
-
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true",
|
|
26
25
|
"doc": "npx compodoc -p tsconfig.doc.json --coverageTest 16 --coverageTestThresholdFail"
|
|
27
26
|
},
|
|
28
27
|
"testServerTypes": "sasjs",
|
|
@@ -72,13 +71,12 @@
|
|
|
72
71
|
"registry": "https://registry.npmjs.org"
|
|
73
72
|
},
|
|
74
73
|
"dependencies": {
|
|
75
|
-
"@sasjs/adapter": "4.19.
|
|
76
|
-
"@sasjs/core": "5.
|
|
77
|
-
"@sasjs/lint": "4.1.
|
|
78
|
-
"@sasjs/utils": "3.6.
|
|
74
|
+
"@sasjs/adapter": "4.19.2",
|
|
75
|
+
"@sasjs/core": "5.3.0",
|
|
76
|
+
"@sasjs/lint": "4.1.2",
|
|
77
|
+
"@sasjs/utils": "3.6.4",
|
|
79
78
|
"chalk": "4.1.2",
|
|
80
79
|
"dotenv": "17.4.2",
|
|
81
|
-
"find": "0.3.0",
|
|
82
80
|
"js-base64": "3.9.3",
|
|
83
81
|
"jsdom": "26.0.0",
|
|
84
82
|
"jwt-decode": "3.1.2",
|
|
@@ -88,7 +86,6 @@
|
|
|
88
86
|
"node-powershell": "5.0.1",
|
|
89
87
|
"ora": "5.4.1",
|
|
90
88
|
"prompts": "2.4.2",
|
|
91
|
-
"shelljs": "0.10.0",
|
|
92
89
|
"ssl-root-cas": "1.3.1",
|
|
93
90
|
"xml": "1.0.1",
|
|
94
91
|
"yargs": "17.6.2",
|
|
@@ -107,7 +104,7 @@
|
|
|
107
104
|
"@types/lodash.groupby": "4.6.9",
|
|
108
105
|
"@types/lodash.uniqby": "4.7.9",
|
|
109
106
|
"@types/node": "22.10.2",
|
|
110
|
-
"@types/
|
|
107
|
+
"@types/prompts": "2.4.9",
|
|
111
108
|
"@types/url-parse": "1.4.11",
|
|
112
109
|
"@types/xml": "1.0.11",
|
|
113
110
|
"@types/yauzl": "3.4.0",
|
|
@@ -130,5 +127,5 @@
|
|
|
130
127
|
"ws": "8.21.0",
|
|
131
128
|
"nanoid": "3.3.18"
|
|
132
129
|
},
|
|
133
|
-
"version": "4.20.
|
|
130
|
+
"version": "4.20.8"
|
|
134
131
|
}
|