@sasjs/cli 3.16.2 → 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/build/commands/init/init.js +7 -10
- package/build/utils/utils.d.ts +0 -1
- package/build/utils/utils.js +91 -80
- package/package.json +3 -3
|
@@ -59,25 +59,22 @@ function init() {
|
|
|
59
59
|
_b.sent();
|
|
60
60
|
return [4 /*yield*/, (0, utils_1.setupGitIgnore)(parentFolderName)];
|
|
61
61
|
case 2:
|
|
62
|
-
_b.sent();
|
|
63
|
-
return [4 /*yield*/, (0, utils_1.setupGhooks)(parentFolderName)];
|
|
64
|
-
case 3:
|
|
65
62
|
_b.sent();
|
|
66
63
|
return [4 /*yield*/, (0, utils_1.setupDoxygen)(parentFolderName)];
|
|
67
|
-
case
|
|
64
|
+
case 3:
|
|
68
65
|
_b.sent();
|
|
69
66
|
return [4 /*yield*/, (0, createConfigFile_1.createConfigFile)(parentFolderName)];
|
|
70
|
-
case
|
|
67
|
+
case 4:
|
|
71
68
|
_b.sent();
|
|
72
69
|
lintConfigPath = path_1.default.join(process.projectDir, parentFolderName, '.sasjslint');
|
|
73
70
|
return [4 /*yield*/, (0, utils_2.fileExists)(lintConfigPath)];
|
|
74
|
-
case
|
|
75
|
-
if (!!(_b.sent())) return [3 /*break*/,
|
|
71
|
+
case 5:
|
|
72
|
+
if (!!(_b.sent())) return [3 /*break*/, 7];
|
|
76
73
|
return [4 /*yield*/, (0, createLintConfigFile_1.createLintConfigFile)(parentFolderName)];
|
|
77
|
-
case
|
|
74
|
+
case 6:
|
|
78
75
|
_b.sent();
|
|
79
|
-
_b.label =
|
|
80
|
-
case
|
|
76
|
+
_b.label = 7;
|
|
77
|
+
case 7: return [2 /*return*/];
|
|
81
78
|
}
|
|
82
79
|
});
|
|
83
80
|
});
|
package/build/utils/utils.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare function createMinimalApp(folderPath: string): Promise<void>;
|
|
|
8
8
|
export declare function createTemplateApp(folderPath: string, template: string): Promise<void>;
|
|
9
9
|
export declare function setupNpmProject(folderName: string): Promise<void>;
|
|
10
10
|
export declare function setupGitIgnore(folderName: string): Promise<void>;
|
|
11
|
-
export declare function setupGhooks(folderName: string): Promise<void>;
|
|
12
11
|
export declare function setupDoxygen(folderPath: string): Promise<void>;
|
|
13
12
|
/**
|
|
14
13
|
* Removes comments from a given block of text.
|
package/build/utils/utils.js
CHANGED
|
@@ -86,7 +86,7 @@ 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.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.
|
|
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"));
|
|
@@ -95,6 +95,7 @@ var utils_1 = require("@sasjs/utils");
|
|
|
95
95
|
var node_1 = __importDefault(require("@sasjs/adapter/node"));
|
|
96
96
|
var displayResult_1 = require("./displayResult");
|
|
97
97
|
var dotenv_1 = __importDefault(require("dotenv"));
|
|
98
|
+
var adm_zip_1 = __importDefault(require("adm-zip"));
|
|
98
99
|
function inExistingProject(folderPath) {
|
|
99
100
|
return __awaiter(this, void 0, void 0, function () {
|
|
100
101
|
var packageJsonExists;
|
|
@@ -127,9 +128,11 @@ function createReactApp(folderPath) {
|
|
|
127
128
|
return __awaiter(this, void 0, void 0, function () {
|
|
128
129
|
var _this = this;
|
|
129
130
|
return __generator(this, function (_a) {
|
|
130
|
-
return [2 /*return*/, new Promise(function (resolve,
|
|
131
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
131
132
|
return __generator(this, function (_a) {
|
|
132
|
-
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
|
+
});
|
|
133
136
|
return [2 /*return*/, resolve()];
|
|
134
137
|
});
|
|
135
138
|
}); })];
|
|
@@ -141,9 +144,11 @@ function createAngularApp(folderPath) {
|
|
|
141
144
|
return __awaiter(this, void 0, void 0, function () {
|
|
142
145
|
var _this = this;
|
|
143
146
|
return __generator(this, function (_a) {
|
|
144
|
-
return [2 /*return*/, new Promise(function (resolve,
|
|
147
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
145
148
|
return __generator(this, function (_a) {
|
|
146
|
-
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
|
+
});
|
|
147
152
|
return [2 /*return*/, resolve()];
|
|
148
153
|
});
|
|
149
154
|
}); })];
|
|
@@ -155,9 +160,11 @@ function createMinimalApp(folderPath) {
|
|
|
155
160
|
return __awaiter(this, void 0, void 0, function () {
|
|
156
161
|
var _this = this;
|
|
157
162
|
return __generator(this, function (_a) {
|
|
158
|
-
return [2 /*return*/, new Promise(function (resolve,
|
|
163
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
159
164
|
return __generator(this, function (_a) {
|
|
160
|
-
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
|
+
});
|
|
161
168
|
return [2 /*return*/, resolve()];
|
|
162
169
|
});
|
|
163
170
|
}); })];
|
|
@@ -172,14 +179,13 @@ function createTemplateApp(folderPath, template) {
|
|
|
172
179
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
173
180
|
var _a, stdout, stderr, code;
|
|
174
181
|
return __generator(this, function (_b) {
|
|
175
|
-
_a =
|
|
176
|
-
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) {
|
|
177
184
|
return [2 /*return*/, reject(new Error("Template \"".concat(template, "\" is not a SASjs template")))];
|
|
178
185
|
}
|
|
179
|
-
|
|
180
|
-
return
|
|
181
|
-
}
|
|
182
|
-
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
|
+
});
|
|
183
189
|
return [2 /*return*/, resolve()];
|
|
184
190
|
});
|
|
185
191
|
}); })];
|
|
@@ -187,37 +193,88 @@ function createTemplateApp(folderPath, template) {
|
|
|
187
193
|
});
|
|
188
194
|
}
|
|
189
195
|
exports.createTemplateApp = createTemplateApp;
|
|
190
|
-
|
|
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) {
|
|
191
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);
|
|
192
211
|
var spinner = (0, ora_1.default)("Creating SASjs project in ".concat(folderPath, "."));
|
|
193
212
|
spinner.start();
|
|
194
|
-
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
else if (repoUrl.includes('angular-seed-app')) {
|
|
206
|
-
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
|
+
}
|
|
207
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')]);
|
|
208
233
|
spinner.stop();
|
|
209
234
|
if (installDependencies) {
|
|
210
235
|
spinner.text = 'Installing dependencies...';
|
|
211
236
|
spinner.start();
|
|
212
|
-
shelljs_1.default.exec("cd \"".concat(folderPath, "\" &&
|
|
237
|
+
shelljs_1.default.exec("cd \"".concat(folderPath, "\" && npm install"), {
|
|
213
238
|
silent: true
|
|
214
239
|
});
|
|
215
240
|
spinner.stop();
|
|
216
241
|
}
|
|
217
242
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
+
}
|
|
221
278
|
function setupNpmProject(folderName) {
|
|
222
279
|
return __awaiter(this, void 0, void 0, function () {
|
|
223
280
|
var folderPath;
|
|
@@ -299,52 +356,6 @@ function setupGitIgnore(folderName) {
|
|
|
299
356
|
});
|
|
300
357
|
}
|
|
301
358
|
exports.setupGitIgnore = setupGitIgnore;
|
|
302
|
-
function setupGhooks(folderName) {
|
|
303
|
-
var _a;
|
|
304
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
305
|
-
var folderPath, packageJsonPath, packageJsonContent, packageJson, preCommitCmd, e_1;
|
|
306
|
-
return __generator(this, function (_b) {
|
|
307
|
-
switch (_b.label) {
|
|
308
|
-
case 0:
|
|
309
|
-
folderPath = path_1.default.join(process.projectDir, folderName);
|
|
310
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info('Installing ghooks');
|
|
311
|
-
shelljs_1.default.exec("cd \"".concat(folderPath, "\" && npm i ghooks --save-dev"), {
|
|
312
|
-
silent: true
|
|
313
|
-
});
|
|
314
|
-
_b.label = 1;
|
|
315
|
-
case 1:
|
|
316
|
-
_b.trys.push([1, 4, , 5]);
|
|
317
|
-
packageJsonPath = path_1.default.join(folderPath, 'package.json');
|
|
318
|
-
return [4 /*yield*/, (0, utils_1.readFile)(packageJsonPath)];
|
|
319
|
-
case 2:
|
|
320
|
-
packageJsonContent = _b.sent();
|
|
321
|
-
packageJson = JSON.parse(packageJsonContent);
|
|
322
|
-
if (!packageJson.config)
|
|
323
|
-
packageJson.config = {};
|
|
324
|
-
if (!packageJson.config.ghooks)
|
|
325
|
-
packageJson.config.ghooks = {};
|
|
326
|
-
preCommitCmd = 'sasjs lint';
|
|
327
|
-
if (packageJson.config.ghooks['pre-commit']) {
|
|
328
|
-
preCommitCmd = ' && sasjs lint';
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
packageJson.config.ghooks['pre-commit'] = '';
|
|
332
|
-
}
|
|
333
|
-
if (!/sasjs lint/.test(packageJson.config.ghooks['pre-commit']))
|
|
334
|
-
packageJson.config.ghooks['pre-commit'] += preCommitCmd;
|
|
335
|
-
return [4 /*yield*/, (0, utils_1.createFile)(packageJsonPath, JSON.stringify(packageJson, null, 2))];
|
|
336
|
-
case 3:
|
|
337
|
-
_b.sent();
|
|
338
|
-
return [3 /*break*/, 5];
|
|
339
|
-
case 4:
|
|
340
|
-
e_1 = _b.sent();
|
|
341
|
-
return [3 /*break*/, 5];
|
|
342
|
-
case 5: return [2 /*return*/];
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
exports.setupGhooks = setupGhooks;
|
|
348
359
|
function setupDoxygen(folderPath) {
|
|
349
360
|
return __awaiter(this, void 0, void 0, function () {
|
|
350
361
|
var doxyFilesPath, doxyFolderPathSource, doxyFolderPath;
|
|
@@ -447,7 +458,7 @@ exports.executeShellScript = executeShellScript;
|
|
|
447
458
|
* @param {object} logJson
|
|
448
459
|
*/
|
|
449
460
|
function parseLogLines(logJson) {
|
|
450
|
-
var
|
|
461
|
+
var e_1, _a;
|
|
451
462
|
var logLines = '';
|
|
452
463
|
try {
|
|
453
464
|
for (var _b = __values(logJson.items), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -455,12 +466,12 @@ function parseLogLines(logJson) {
|
|
|
455
466
|
logLines += "".concat(item.line, "\n");
|
|
456
467
|
}
|
|
457
468
|
}
|
|
458
|
-
catch (
|
|
469
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
459
470
|
finally {
|
|
460
471
|
try {
|
|
461
472
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
462
473
|
}
|
|
463
|
-
finally { if (
|
|
474
|
+
finally { if (e_1) throw e_1.error; }
|
|
464
475
|
}
|
|
465
476
|
return logLines;
|
|
466
477
|
}
|
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
|
}
|