@sasjs/cli 3.16.0 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/build/commands/add/addCredential.js +25 -18
- package/build/commands/add/addTarget.js +14 -9
- package/build/commands/add/spec/addTarget.spec.js +7 -0
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +5 -3
- package/build/commands/deploy/spec/cbd.spec.js +38 -17
- package/build/commands/init/init.js +7 -10
- package/build/commands/testing/spec/testing.spec.js +5 -0
- package/build/commands/web/internal/createAssetServices.d.ts +11 -2
- package/build/commands/web/internal/createAssetServices.js +83 -92
- package/build/commands/web/internal/getAssetPath.d.ts +2 -0
- package/build/commands/web/internal/getAssetPath.js +17 -0
- package/build/commands/web/internal/modifyLinksInContent.d.ts +2 -0
- package/build/commands/web/internal/modifyLinksInContent.js +11 -0
- package/build/commands/web/internal/sas9/createClickMeService.d.ts +6 -0
- package/build/commands/web/internal/sas9/createClickMeService.js +91 -0
- package/build/commands/web/internal/sas9/generateAssetService.d.ts +7 -0
- package/build/commands/web/internal/sas9/generateAssetService.js +75 -0
- package/build/commands/web/internal/sas9/getWebServiceContent.d.ts +7 -0
- package/build/commands/web/internal/{getWebServiceContent.js → sas9/getWebServiceContent.js} +12 -8
- package/build/commands/web/internal/sas9/index.d.ts +3 -0
- package/build/commands/web/internal/sas9/index.js +15 -0
- package/build/commands/web/internal/sasViya/createClickMeFile.d.ts +6 -0
- package/build/commands/web/internal/sasViya/createClickMeFile.js +63 -0
- package/build/commands/web/internal/sasViya/index.d.ts +1 -0
- package/build/commands/web/internal/sasViya/index.js +13 -0
- package/build/commands/web/internal/sasjsout.d.ts +1 -1
- package/build/commands/web/internal/sasjsout.js +2 -1
- package/build/commands/web/internal/updateAllTags.d.ts +7 -4
- package/build/commands/web/internal/updateAllTags.js +5 -0
- package/build/commands/web/internal/updateLinkTag.d.ts +2 -4
- package/build/commands/web/internal/updateScriptTag.d.ts +2 -4
- package/build/commands/web/internal/updateScriptTag.js +32 -32
- package/build/commands/web/internal/updateStyleTag.d.ts +2 -4
- package/build/commands/web/internal/updateStyleTag.js +32 -32
- package/build/commands/web/web.js +30 -79
- package/build/constants.d.ts +1 -0
- package/build/utils/setConstants.js +4 -2
- package/build/utils/utils.d.ts +1 -1
- package/build/utils/utils.js +112 -80
- package/package.json +3 -3
- package/build/commands/web/internal/getWebServiceContent.d.ts +0 -2
package/build/utils/utils.js
CHANGED
|
@@ -86,14 +86,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
86
86
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
87
87
|
};
|
|
88
88
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89
|
-
exports.getNodeModulePath = exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.
|
|
89
|
+
exports.isSasJsServerInServerMode = exports.getNodeModulePath = exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
|
|
90
90
|
var shelljs_1 = __importDefault(require("shelljs"));
|
|
91
91
|
var path_1 = __importDefault(require("path"));
|
|
92
92
|
var ora_1 = __importDefault(require("ora"));
|
|
93
|
+
var axios_1 = __importDefault(require("axios"));
|
|
93
94
|
var utils_1 = require("@sasjs/utils");
|
|
94
95
|
var node_1 = __importDefault(require("@sasjs/adapter/node"));
|
|
95
96
|
var displayResult_1 = require("./displayResult");
|
|
96
97
|
var dotenv_1 = __importDefault(require("dotenv"));
|
|
98
|
+
var adm_zip_1 = __importDefault(require("adm-zip"));
|
|
97
99
|
function inExistingProject(folderPath) {
|
|
98
100
|
return __awaiter(this, void 0, void 0, function () {
|
|
99
101
|
var packageJsonExists;
|
|
@@ -126,9 +128,11 @@ function createReactApp(folderPath) {
|
|
|
126
128
|
return __awaiter(this, void 0, void 0, function () {
|
|
127
129
|
var _this = this;
|
|
128
130
|
return __generator(this, function (_a) {
|
|
129
|
-
return [2 /*return*/, new Promise(function (resolve,
|
|
131
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
130
132
|
return __generator(this, function (_a) {
|
|
131
|
-
createApp(folderPath, 'https://github.com/sasjs/react-seed-app.
|
|
133
|
+
createApp(folderPath, 'https://github.com/sasjs/react-seed-app', 'https://github.com/sasjs/docs', function (err) {
|
|
134
|
+
return reject(new Error(err));
|
|
135
|
+
});
|
|
132
136
|
return [2 /*return*/, resolve()];
|
|
133
137
|
});
|
|
134
138
|
}); })];
|
|
@@ -140,9 +144,11 @@ function createAngularApp(folderPath) {
|
|
|
140
144
|
return __awaiter(this, void 0, void 0, function () {
|
|
141
145
|
var _this = this;
|
|
142
146
|
return __generator(this, function (_a) {
|
|
143
|
-
return [2 /*return*/, new Promise(function (resolve,
|
|
147
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
144
148
|
return __generator(this, function (_a) {
|
|
145
|
-
createApp(folderPath, 'https://github.com/sasjs/angular-seed-app.
|
|
149
|
+
createApp(folderPath, 'https://github.com/sasjs/angular-seed-app', 'https://github.com/sasjs/docs', function (err) {
|
|
150
|
+
return reject(new Error(err));
|
|
151
|
+
});
|
|
146
152
|
return [2 /*return*/, resolve()];
|
|
147
153
|
});
|
|
148
154
|
}); })];
|
|
@@ -154,9 +160,11 @@ function createMinimalApp(folderPath) {
|
|
|
154
160
|
return __awaiter(this, void 0, void 0, function () {
|
|
155
161
|
var _this = this;
|
|
156
162
|
return __generator(this, function (_a) {
|
|
157
|
-
return [2 /*return*/, new Promise(function (resolve,
|
|
163
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
158
164
|
return __generator(this, function (_a) {
|
|
159
|
-
createApp(folderPath, 'https://github.com/sasjs/minimal-seed-app.
|
|
165
|
+
createApp(folderPath, 'https://github.com/sasjs/minimal-seed-app', 'https://github.com/sasjs/docs', function (err) {
|
|
166
|
+
return reject(new Error(err));
|
|
167
|
+
});
|
|
160
168
|
return [2 /*return*/, resolve()];
|
|
161
169
|
});
|
|
162
170
|
}); })];
|
|
@@ -171,14 +179,13 @@ function createTemplateApp(folderPath, template) {
|
|
|
171
179
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
172
180
|
var _a, stdout, stderr, code;
|
|
173
181
|
return __generator(this, function (_b) {
|
|
174
|
-
_a =
|
|
175
|
-
if (stderr.includes('
|
|
182
|
+
_a = downloadFile("https://username:password@github.com/sasjs/template_".concat(template)), stdout = _a.stdout, stderr = _a.stderr, code = _a.code;
|
|
183
|
+
if (stderr.includes('404: Not Found') || code) {
|
|
176
184
|
return [2 /*return*/, reject(new Error("Template \"".concat(template, "\" is not a SASjs template")))];
|
|
177
185
|
}
|
|
178
|
-
|
|
179
|
-
return
|
|
180
|
-
}
|
|
181
|
-
createApp(folderPath, "https://github.com/sasjs/template_".concat(template, ".git"));
|
|
186
|
+
createApp(folderPath, "https://github.com/sasjs/template_".concat(template), 'https://github.com/sasjs/docs', function (err) {
|
|
187
|
+
return reject(new Error(err));
|
|
188
|
+
});
|
|
182
189
|
return [2 /*return*/, resolve()];
|
|
183
190
|
});
|
|
184
191
|
}); })];
|
|
@@ -186,37 +193,88 @@ function createTemplateApp(folderPath, template) {
|
|
|
186
193
|
});
|
|
187
194
|
}
|
|
188
195
|
exports.createTemplateApp = createTemplateApp;
|
|
189
|
-
|
|
196
|
+
/**
|
|
197
|
+
* This function will first download / unzip the target app from repoUrl, then download / unzip the sasjs/docs repo into a subdirectory named 'docs'.
|
|
198
|
+
* Finally, if installDependencies is true, the npm install command will be executed.
|
|
199
|
+
* @param folderPath full path of the directory where desired seed app will be created
|
|
200
|
+
* @param repoUrl sasjs/{seed-app} repo url
|
|
201
|
+
* @param docsUrl sasjs/docs repo url
|
|
202
|
+
* @params installDependencies whether or not to do `npm install`
|
|
203
|
+
*/
|
|
204
|
+
function createApp(folderPath, repoUrl, docsUrl, errorCallback, installDependencies) {
|
|
190
205
|
if (installDependencies === void 0) { installDependencies = true; }
|
|
206
|
+
//In past we used GIT to clone the repos. But many users potentially won't have GIT installed.
|
|
207
|
+
//So we will use shell tools to set up the apps.
|
|
208
|
+
var zipName = 'main.zip';
|
|
209
|
+
var zipPath = "/archive/refs/heads/";
|
|
210
|
+
var fullZipPath = "".concat(zipPath).concat(zipName);
|
|
191
211
|
var spinner = (0, ora_1.default)("Creating SASjs project in ".concat(folderPath, "."));
|
|
192
212
|
spinner.start();
|
|
193
|
-
|
|
194
|
-
var
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
else if (repoUrl.includes('angular-seed-app')) {
|
|
205
|
-
deleteGitFolder(path_1.default.join(folderPath, 'docs'));
|
|
213
|
+
//Get repo zip, assuming main branch is called `main`
|
|
214
|
+
var _a = downloadFile("".concat(repoUrl).concat(fullZipPath)), stdout = _a.stdout, stderr = _a.stderr, code = _a.code;
|
|
215
|
+
// If doesn't exist, we try again, but with master.zip for the zip name.
|
|
216
|
+
// Since that's the name generated from branch name.
|
|
217
|
+
if (stderr.includes('404: Not Found') || code) {
|
|
218
|
+
zipName = 'master.zip';
|
|
219
|
+
var _b = downloadFile("".concat(repoUrl).concat(zipPath).concat(zipName)), stdout_1 = _b.stdout, stderr_1 = _b.stderr, code_1 = _b.code;
|
|
220
|
+
if (stderr_1.includes('404: Not Found') || code_1) {
|
|
221
|
+
errorCallback("".concat(repoUrl).concat(zipPath, " is not SASjs repository!"));
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
206
224
|
}
|
|
225
|
+
var zipWithoutExtension = zipName.replace('.zip', '');
|
|
226
|
+
var zip = new adm_zip_1.default(zipName);
|
|
227
|
+
zip.extractAllTo("./", true);
|
|
228
|
+
shelljs_1.default.cp('-r', "./*".concat(zipWithoutExtension, "/."), folderPath);
|
|
229
|
+
shelljs_1.default.rm('-rf', ["./*".concat(zipWithoutExtension)]);
|
|
230
|
+
shelljs_1.default.rm('-rf', ["./".concat(zipName)]);
|
|
231
|
+
loadDocsSubmodule(docsUrl, folderPath, fullZipPath);
|
|
232
|
+
shelljs_1.default.rm('-f', [path_1.default.join(folderPath, '.gitmodules')]);
|
|
207
233
|
spinner.stop();
|
|
208
234
|
if (installDependencies) {
|
|
209
235
|
spinner.text = 'Installing dependencies...';
|
|
210
236
|
spinner.start();
|
|
211
|
-
shelljs_1.default.exec("cd \"".concat(folderPath, "\" &&
|
|
237
|
+
shelljs_1.default.exec("cd \"".concat(folderPath, "\" && npm install"), {
|
|
212
238
|
silent: true
|
|
213
239
|
});
|
|
214
240
|
spinner.stop();
|
|
215
241
|
}
|
|
216
242
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
243
|
+
/**
|
|
244
|
+
* It will download and unzip `sasjs/docs` into newly created folder into `docs` subfolder
|
|
245
|
+
* @param docsUrl sasjs/docs repo url
|
|
246
|
+
* @param folderPath full path to the newly created folder that contains the seed app
|
|
247
|
+
* @param zipPath fixed path of where github puts zip for repo download
|
|
248
|
+
*/
|
|
249
|
+
var loadDocsSubmodule = function (docsUrl, folderPath, zipPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
250
|
+
var docsFolderPath, zip;
|
|
251
|
+
return __generator(this, function (_a) {
|
|
252
|
+
switch (_a.label) {
|
|
253
|
+
case 0:
|
|
254
|
+
docsFolderPath = "".concat(folderPath, "/public/docs") //We first look if docs submodule is inside `public` folder. (react-seed-app for example)
|
|
255
|
+
;
|
|
256
|
+
return [4 /*yield*/, (0, utils_1.fileExists)(docsFolderPath)];
|
|
257
|
+
case 1:
|
|
258
|
+
if (!(_a.sent()))
|
|
259
|
+
docsFolderPath = "".concat(folderPath, "/docs"); //If not, we load submodule in root
|
|
260
|
+
downloadFile("".concat(docsUrl).concat(zipPath));
|
|
261
|
+
zip = new adm_zip_1.default('main.zip');
|
|
262
|
+
zip.extractAllTo('./', true);
|
|
263
|
+
shelljs_1.default.cp('-r', "./*-main/.", docsFolderPath);
|
|
264
|
+
shelljs_1.default.rm('-rf', ["./*-main"]);
|
|
265
|
+
shelljs_1.default.rm('-rf', ["./main.zip"]);
|
|
266
|
+
return [2 /*return*/];
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}); };
|
|
270
|
+
function downloadFile(url) {
|
|
271
|
+
if ((0, utils_1.isLinux)()) {
|
|
272
|
+
return shelljs_1.default.exec("wget ".concat(url), { silent: true });
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
return shelljs_1.default.exec("curl ".concat(url, " -LO -f"), { silent: true });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
220
278
|
function setupNpmProject(folderName) {
|
|
221
279
|
return __awaiter(this, void 0, void 0, function () {
|
|
222
280
|
var folderPath;
|
|
@@ -298,52 +356,6 @@ function setupGitIgnore(folderName) {
|
|
|
298
356
|
});
|
|
299
357
|
}
|
|
300
358
|
exports.setupGitIgnore = setupGitIgnore;
|
|
301
|
-
function setupGhooks(folderName) {
|
|
302
|
-
var _a;
|
|
303
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
304
|
-
var folderPath, packageJsonPath, packageJsonContent, packageJson, preCommitCmd, e_1;
|
|
305
|
-
return __generator(this, function (_b) {
|
|
306
|
-
switch (_b.label) {
|
|
307
|
-
case 0:
|
|
308
|
-
folderPath = path_1.default.join(process.projectDir, folderName);
|
|
309
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info('Installing ghooks');
|
|
310
|
-
shelljs_1.default.exec("cd \"".concat(folderPath, "\" && npm i ghooks --save-dev"), {
|
|
311
|
-
silent: true
|
|
312
|
-
});
|
|
313
|
-
_b.label = 1;
|
|
314
|
-
case 1:
|
|
315
|
-
_b.trys.push([1, 4, , 5]);
|
|
316
|
-
packageJsonPath = path_1.default.join(folderPath, 'package.json');
|
|
317
|
-
return [4 /*yield*/, (0, utils_1.readFile)(packageJsonPath)];
|
|
318
|
-
case 2:
|
|
319
|
-
packageJsonContent = _b.sent();
|
|
320
|
-
packageJson = JSON.parse(packageJsonContent);
|
|
321
|
-
if (!packageJson.config)
|
|
322
|
-
packageJson.config = {};
|
|
323
|
-
if (!packageJson.config.ghooks)
|
|
324
|
-
packageJson.config.ghooks = {};
|
|
325
|
-
preCommitCmd = 'sasjs lint';
|
|
326
|
-
if (packageJson.config.ghooks['pre-commit']) {
|
|
327
|
-
preCommitCmd = ' && sasjs lint';
|
|
328
|
-
}
|
|
329
|
-
else {
|
|
330
|
-
packageJson.config.ghooks['pre-commit'] = '';
|
|
331
|
-
}
|
|
332
|
-
if (!/sasjs lint/.test(packageJson.config.ghooks['pre-commit']))
|
|
333
|
-
packageJson.config.ghooks['pre-commit'] += preCommitCmd;
|
|
334
|
-
return [4 /*yield*/, (0, utils_1.createFile)(packageJsonPath, JSON.stringify(packageJson, null, 2))];
|
|
335
|
-
case 3:
|
|
336
|
-
_b.sent();
|
|
337
|
-
return [3 /*break*/, 5];
|
|
338
|
-
case 4:
|
|
339
|
-
e_1 = _b.sent();
|
|
340
|
-
return [3 /*break*/, 5];
|
|
341
|
-
case 5: return [2 /*return*/];
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
exports.setupGhooks = setupGhooks;
|
|
347
359
|
function setupDoxygen(folderPath) {
|
|
348
360
|
return __awaiter(this, void 0, void 0, function () {
|
|
349
361
|
var doxyFilesPath, doxyFolderPathSource, doxyFolderPath;
|
|
@@ -446,7 +458,7 @@ exports.executeShellScript = executeShellScript;
|
|
|
446
458
|
* @param {object} logJson
|
|
447
459
|
*/
|
|
448
460
|
function parseLogLines(logJson) {
|
|
449
|
-
var
|
|
461
|
+
var e_1, _a;
|
|
450
462
|
var logLines = '';
|
|
451
463
|
try {
|
|
452
464
|
for (var _b = __values(logJson.items), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -454,12 +466,12 @@ function parseLogLines(logJson) {
|
|
|
454
466
|
logLines += "".concat(item.line, "\n");
|
|
455
467
|
}
|
|
456
468
|
}
|
|
457
|
-
catch (
|
|
469
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
458
470
|
finally {
|
|
459
471
|
try {
|
|
460
472
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
461
473
|
}
|
|
462
|
-
finally { if (
|
|
474
|
+
finally { if (e_1) throw e_1.error; }
|
|
463
475
|
}
|
|
464
476
|
return logLines;
|
|
465
477
|
}
|
|
@@ -638,3 +650,23 @@ var getNodeModulePath = function (module) { return __awaiter(void 0, void 0, voi
|
|
|
638
650
|
});
|
|
639
651
|
}); };
|
|
640
652
|
exports.getNodeModulePath = getNodeModulePath;
|
|
653
|
+
var isSasJsServerInServerMode = function (target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
654
|
+
var res, error_1, message;
|
|
655
|
+
return __generator(this, function (_a) {
|
|
656
|
+
switch (_a.label) {
|
|
657
|
+
case 0:
|
|
658
|
+
_a.trys.push([0, 2, , 3]);
|
|
659
|
+
return [4 /*yield*/, axios_1.default.get("".concat(target.serverUrl, "/SASjsApi/info"))];
|
|
660
|
+
case 1:
|
|
661
|
+
res = _a.sent();
|
|
662
|
+
return [2 /*return*/, res.data.mode === 'server'];
|
|
663
|
+
case 2:
|
|
664
|
+
error_1 = _a.sent();
|
|
665
|
+
message = "An error occurred while fetching server info from ".concat(target.serverUrl, "/SASjsApi/info");
|
|
666
|
+
(0, displayResult_1.displayError)(error_1, message);
|
|
667
|
+
throw new Error(message);
|
|
668
|
+
case 3: return [2 /*return*/];
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
}); };
|
|
672
|
+
exports.isSasJsServerInServerMode = isSasJsServerInServerMode;
|
package/package.json
CHANGED
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@sasjs/adapter": "3.
|
|
50
|
+
"@sasjs/adapter": "3.10.8",
|
|
51
51
|
"@sasjs/core": "4.32.2",
|
|
52
52
|
"@sasjs/lint": "1.11.2",
|
|
53
|
-
"@sasjs/utils": "2.
|
|
53
|
+
"@sasjs/utils": "2.47.0",
|
|
54
54
|
"adm-zip": "0.5.9",
|
|
55
55
|
"chalk": "4.1.2",
|
|
56
56
|
"csv-stringify": "5.6.5",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"typescript": "4.5.4",
|
|
97
97
|
"util": "0.12.4"
|
|
98
98
|
},
|
|
99
|
-
"version": "3.
|
|
99
|
+
"version": "3.17.0"
|
|
100
100
|
}
|