@sasjs/cli 3.0.3 → 3.3.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/add/addCredential.d.ts +6 -2
- package/build/commands/add/addCredential.js +79 -47
- package/build/commands/add/addTarget.js +32 -20
- package/build/commands/add/internal/input.d.ts +7 -0
- package/build/commands/add/internal/input.js +53 -8
- package/build/commands/add/spec/addTarget.spec.js +78 -0
- package/build/commands/compile/internal/compileServiceFile.js +31 -14
- package/build/commands/create/spec/reactAppFiles.js +5 -5
- package/build/commands/deploy/spec/cbd.spec.js +19 -3
- package/build/commands/job/internal/execute/viya.js +0 -6
- package/build/commands/job/internal/utils.js +6 -8
- package/build/commands/job/jobCommand.d.ts +1 -0
- package/build/commands/job/jobCommand.js +8 -3
- package/build/commands/job/spec/jobCommand.spec.js +10 -3
- package/build/commands/shared/fetchLogFileContent.js +6 -8
- package/build/commands/testing/internal/saveOutput.d.ts +1 -0
- package/build/commands/testing/internal/saveOutput.js +41 -1
- package/build/commands/testing/spec/testing.spec.server.js +10 -1
- package/build/commands/testing/test.js +6 -2
- package/build/commands/web/internal/getTags.d.ts +2 -1
- package/build/commands/web/internal/getTags.js +10 -12
- package/build/commands/web/internal/sasjsout.d.ts +1 -1
- package/build/commands/web/internal/sasjsout.js +1 -1
- package/build/commands/web/internal/spec/updateLinkTag.spec.d.ts +4 -0
- package/build/commands/web/internal/spec/updateLinkTag.spec.js +32 -0
- package/build/commands/web/internal/updateAllTags.js +33 -8
- package/build/commands/web/internal/updateLinkTag.d.ts +4 -0
- package/build/commands/web/internal/updateLinkTag.js +24 -0
- package/build/utils/auth.d.ts +10 -4
- package/build/utils/auth.js +17 -15
- package/build/utils/config.d.ts +1 -1
- package/build/utils/config.js +12 -14
- package/build/utils/utils.js +1 -5
- package/package.json +7 -13
- package/build/commands/web/internal/updateLinkHref.d.ts +0 -4
- package/build/commands/web/internal/updateLinkHref.js +0 -18
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateLinkTag = void 0;
|
|
4
|
+
var updateLinkTag = function (linkTag, assetPathMap, tagType) {
|
|
5
|
+
if (tagType === void 0) { tagType = 'link'; }
|
|
6
|
+
var linkSourcePath = tagType === 'link'
|
|
7
|
+
? linkTag.getAttribute('href')
|
|
8
|
+
: linkTag.getAttribute('src');
|
|
9
|
+
if (!linkSourcePath)
|
|
10
|
+
return;
|
|
11
|
+
var isUrl = linkSourcePath.startsWith('http') || linkSourcePath.startsWith('//');
|
|
12
|
+
if (isUrl)
|
|
13
|
+
return;
|
|
14
|
+
var assetPath = assetPathMap.find(function (entry) {
|
|
15
|
+
return entry.source === linkSourcePath || "./" + entry.source === linkSourcePath;
|
|
16
|
+
});
|
|
17
|
+
if (!(assetPath === null || assetPath === void 0 ? void 0 : assetPath.target)) {
|
|
18
|
+
throw new Error("Unable to find file: " + linkSourcePath);
|
|
19
|
+
}
|
|
20
|
+
tagType === 'link'
|
|
21
|
+
? linkTag.setAttribute('href', assetPath.target)
|
|
22
|
+
: linkTag.setAttribute('src', assetPath.target);
|
|
23
|
+
};
|
|
24
|
+
exports.updateLinkTag = updateLinkTag;
|
package/build/utils/auth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ServerType, Target } from '@sasjs/utils';
|
|
2
2
|
import SASjs from '@sasjs/adapter/node';
|
|
3
|
-
export declare
|
|
3
|
+
export declare const getAuthUrl: (serverType: ServerType, serverUrl: string, clientId: string) => string;
|
|
4
4
|
export declare function getAuthCode(authUrl: string): Promise<string>;
|
|
5
5
|
/**
|
|
6
6
|
* Checks if the Access Token is expired or is expiring in 1 hour. A default Access Token
|
|
@@ -18,5 +18,11 @@ export declare function isAccessTokenExpiring(token: string): boolean;
|
|
|
18
18
|
* @param {string} token- token string that will be evaluated
|
|
19
19
|
*/
|
|
20
20
|
export declare function isRefreshTokenExpiring(token?: string): boolean;
|
|
21
|
-
export declare function refreshTokens(sasjsInstance: SASjs, clientId: string, clientSecret: string, refreshToken: string): Promise<
|
|
22
|
-
|
|
21
|
+
export declare function refreshTokens(sasjsInstance: SASjs, clientId: string, clientSecret: string, refreshToken: string): Promise<{
|
|
22
|
+
access_token: string;
|
|
23
|
+
refresh_token: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function getNewAccessToken(sasjsInstance: SASjs, clientId: string, clientSecret: string, target: Target): Promise<{
|
|
26
|
+
access_token: string;
|
|
27
|
+
refresh_token: string;
|
|
28
|
+
}>;
|
package/build/utils/auth.js
CHANGED
|
@@ -42,9 +42,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.getNewAccessToken = exports.refreshTokens = exports.isRefreshTokenExpiring = exports.isAccessTokenExpiring = exports.getAuthCode = exports.getAuthUrl = void 0;
|
|
43
43
|
var utils_1 = require("@sasjs/utils");
|
|
44
44
|
var jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
45
|
-
function
|
|
46
|
-
return
|
|
47
|
-
|
|
45
|
+
var getAuthUrl = function (serverType, serverUrl, clientId) {
|
|
46
|
+
return serverType === utils_1.ServerType.Sasjs
|
|
47
|
+
? serverUrl + "/#/SASjsLogon?client_id=" + clientId + "&response_type=code"
|
|
48
|
+
: serverUrl + "/SASLogon/oauth/authorize?client_id=" + clientId + "&response_type=code";
|
|
49
|
+
};
|
|
48
50
|
exports.getAuthUrl = getAuthUrl;
|
|
49
51
|
function getAuthCode(authUrl) {
|
|
50
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -100,13 +102,13 @@ function isRefreshTokenExpiring(token) {
|
|
|
100
102
|
exports.isRefreshTokenExpiring = isRefreshTokenExpiring;
|
|
101
103
|
function refreshTokens(sasjsInstance, clientId, clientSecret, refreshToken) {
|
|
102
104
|
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
var
|
|
104
|
-
return __generator(this, function (
|
|
105
|
-
switch (
|
|
105
|
+
var _a, access_token, refresh_token;
|
|
106
|
+
return __generator(this, function (_b) {
|
|
107
|
+
switch (_b.label) {
|
|
106
108
|
case 0: return [4 /*yield*/, sasjsInstance.refreshTokens(clientId, clientSecret, refreshToken)];
|
|
107
109
|
case 1:
|
|
108
|
-
|
|
109
|
-
return [2 /*return*/,
|
|
110
|
+
_a = _b.sent(), access_token = _a.access_token, refresh_token = _a.refresh_token;
|
|
111
|
+
return [2 /*return*/, { access_token: access_token, refresh_token: refresh_token }];
|
|
110
112
|
}
|
|
111
113
|
});
|
|
112
114
|
});
|
|
@@ -114,18 +116,18 @@ function refreshTokens(sasjsInstance, clientId, clientSecret, refreshToken) {
|
|
|
114
116
|
exports.refreshTokens = refreshTokens;
|
|
115
117
|
function getNewAccessToken(sasjsInstance, clientId, clientSecret, target) {
|
|
116
118
|
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
-
var authUrl, authCode,
|
|
118
|
-
return __generator(this, function (
|
|
119
|
-
switch (
|
|
119
|
+
var authUrl, authCode, _a, access_token, refresh_token;
|
|
120
|
+
return __generator(this, function (_b) {
|
|
121
|
+
switch (_b.label) {
|
|
120
122
|
case 0:
|
|
121
|
-
authUrl = getAuthUrl(target.serverUrl, clientId);
|
|
123
|
+
authUrl = exports.getAuthUrl(target.serverType, target.serverUrl, clientId);
|
|
122
124
|
return [4 /*yield*/, getAuthCode(authUrl)];
|
|
123
125
|
case 1:
|
|
124
|
-
authCode =
|
|
126
|
+
authCode = _b.sent();
|
|
125
127
|
return [4 /*yield*/, sasjsInstance.getAccessToken(clientId, clientSecret, authCode)];
|
|
126
128
|
case 2:
|
|
127
|
-
|
|
128
|
-
return [2 /*return*/,
|
|
129
|
+
_a = _b.sent(), access_token = _a.access_token, refresh_token = _a.refresh_token;
|
|
130
|
+
return [2 /*return*/, { access_token: access_token, refresh_token: refresh_token }];
|
|
129
131
|
}
|
|
130
132
|
});
|
|
131
133
|
});
|
package/build/utils/config.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare function getMacroFolders(target?: Target): Promise<string[]>;
|
|
|
51
51
|
* @param {Target} target- the target to check stream configuration for.
|
|
52
52
|
*/
|
|
53
53
|
export declare function getStreamConfig(target?: Target): Promise<StreamConfig>;
|
|
54
|
-
export declare
|
|
54
|
+
export declare const getMacroCorePath: () => string;
|
|
55
55
|
/**
|
|
56
56
|
* Sanitizes app location string.
|
|
57
57
|
* @param {string} appLoc - app location
|
package/build/utils/config.js
CHANGED
|
@@ -691,10 +691,7 @@ function getStreamConfig(target) {
|
|
|
691
691
|
});
|
|
692
692
|
}
|
|
693
693
|
exports.getStreamConfig = getStreamConfig;
|
|
694
|
-
function
|
|
695
|
-
var macroCorePath = process.sasjsConstants.macroCorePath;
|
|
696
|
-
return macroCorePath;
|
|
697
|
-
}
|
|
694
|
+
var getMacroCorePath = function () { return process.sasjsConstants.macroCorePath; };
|
|
698
695
|
exports.getMacroCorePath = getMacroCorePath;
|
|
699
696
|
/**
|
|
700
697
|
* Sanitizes app location string.
|
|
@@ -761,7 +758,7 @@ exports.getProjectRoot = getProjectRoot;
|
|
|
761
758
|
function getAuthConfig(target) {
|
|
762
759
|
var _a, _b, _c, _d;
|
|
763
760
|
return __awaiter(this, void 0, void 0, function () {
|
|
764
|
-
var access_token, refresh_token, client, secret,
|
|
761
|
+
var access_token, refresh_token, client, secret, sasjs, tokens;
|
|
765
762
|
return __generator(this, function (_e) {
|
|
766
763
|
switch (_e.label) {
|
|
767
764
|
case 0:
|
|
@@ -811,18 +808,19 @@ function getAuthConfig(target) {
|
|
|
811
808
|
httpsAgentOptions: target.httpsAgentOptions,
|
|
812
809
|
serverType: target.serverType
|
|
813
810
|
});
|
|
811
|
+
tokens = void 0;
|
|
814
812
|
if (!auth_1.isRefreshTokenExpiring(refresh_token)) return [3 /*break*/, 4];
|
|
815
813
|
return [4 /*yield*/, auth_1.getNewAccessToken(sasjs, client, secret, target)];
|
|
816
814
|
case 3:
|
|
817
|
-
|
|
815
|
+
tokens = _e.sent();
|
|
818
816
|
return [3 /*break*/, 6];
|
|
819
817
|
case 4: return [4 /*yield*/, auth_1.refreshTokens(sasjs, client, secret, refresh_token)];
|
|
820
818
|
case 5:
|
|
821
|
-
|
|
819
|
+
tokens = _e.sent();
|
|
822
820
|
_e.label = 6;
|
|
823
821
|
case 6:
|
|
824
|
-
access_token = (
|
|
825
|
-
refresh_token = (
|
|
822
|
+
access_token = (tokens === null || tokens === void 0 ? void 0 : tokens.access_token) || access_token;
|
|
823
|
+
refresh_token = (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token) || refresh_token;
|
|
826
824
|
_e.label = 7;
|
|
827
825
|
case 7: return [2 /*return*/, {
|
|
828
826
|
access_token: access_token,
|
|
@@ -852,7 +850,7 @@ exports.getAuthConfig = getAuthConfig;
|
|
|
852
850
|
function getAccessToken(target, checkIfExpiring) {
|
|
853
851
|
if (checkIfExpiring === void 0) { checkIfExpiring = true; }
|
|
854
852
|
return __awaiter(this, void 0, void 0, function () {
|
|
855
|
-
var accessToken, sasjs, client, secret, refreshToken,
|
|
853
|
+
var accessToken, sasjs, client, secret, refreshToken, tokens;
|
|
856
854
|
return __generator(this, function (_a) {
|
|
857
855
|
switch (_a.label) {
|
|
858
856
|
case 0:
|
|
@@ -907,18 +905,18 @@ function getAccessToken(target, checkIfExpiring) {
|
|
|
907
905
|
(refreshToken.trim() === 'null' || refreshToken.trim() === 'undefined')
|
|
908
906
|
? undefined
|
|
909
907
|
: refreshToken;
|
|
910
|
-
|
|
908
|
+
tokens = void 0;
|
|
911
909
|
if (!auth_1.isRefreshTokenExpiring(refreshToken)) return [3 /*break*/, 4];
|
|
912
910
|
return [4 /*yield*/, auth_1.getNewAccessToken(sasjs, client, secret, target)];
|
|
913
911
|
case 3:
|
|
914
|
-
|
|
912
|
+
tokens = _a.sent();
|
|
915
913
|
return [3 /*break*/, 6];
|
|
916
914
|
case 4: return [4 /*yield*/, auth_1.refreshTokens(sasjs, client, secret, refreshToken)];
|
|
917
915
|
case 5:
|
|
918
|
-
|
|
916
|
+
tokens = _a.sent();
|
|
919
917
|
_a.label = 6;
|
|
920
918
|
case 6:
|
|
921
|
-
accessToken =
|
|
919
|
+
accessToken = tokens === null || tokens === void 0 ? void 0 : tokens.access_token;
|
|
922
920
|
_a.label = 7;
|
|
923
921
|
case 7: return [2 /*return*/, accessToken];
|
|
924
922
|
}
|
package/build/utils/utils.js
CHANGED
|
@@ -186,11 +186,7 @@ function createApp(folderPath, repoUrl, installDependencies) {
|
|
|
186
186
|
if (installDependencies === void 0) { installDependencies = true; }
|
|
187
187
|
var spinner = ora_1.default("Creating SASjs project in " + folderPath + ".");
|
|
188
188
|
spinner.start();
|
|
189
|
-
var gitBranch = repoUrl.includes('template_sasonly')
|
|
190
|
-
? 'master'
|
|
191
|
-
: repoUrl.includes('template_jobs')
|
|
192
|
-
? 'master'
|
|
193
|
-
: 'main';
|
|
189
|
+
var gitBranch = repoUrl.includes('template_sasonly') ? 'master' : 'main';
|
|
194
190
|
shelljs_1.default.exec("cd \"" + folderPath + "\" && git clone --depth 1 -b " + gitBranch + " " + repoUrl + " .", { silent: true });
|
|
195
191
|
shelljs_1.default.rm('-rf', path_1.default.join(folderPath, '.git'));
|
|
196
192
|
spinner.stop();
|
package/package.json
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"test:mocked": "jest --silent --runInBand --config=jest.config.js --coverage",
|
|
20
20
|
"semantic-release": "semantic-release -d",
|
|
21
21
|
"lint:fix": "npx prettier --write \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
|
|
22
|
-
"lint": "npx prettier --check \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\""
|
|
22
|
+
"lint": "npx prettier --check \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,yml,md,graphql}\"",
|
|
23
|
+
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
|
|
23
24
|
},
|
|
24
25
|
"release": {
|
|
25
26
|
"branches": [
|
|
@@ -47,14 +48,9 @@
|
|
|
47
48
|
"publishConfig": {
|
|
48
49
|
"access": "public"
|
|
49
50
|
},
|
|
50
|
-
"config": {
|
|
51
|
-
"ghooks": {
|
|
52
|
-
"commit-msg": "validate-commit-msg"
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
51
|
"dependencies": {
|
|
56
|
-
"@sasjs/adapter": "3.
|
|
57
|
-
"@sasjs/core": "2.
|
|
52
|
+
"@sasjs/adapter": "3.3.0",
|
|
53
|
+
"@sasjs/core": "2.54.1",
|
|
58
54
|
"@sasjs/lint": "1.11.2",
|
|
59
55
|
"@sasjs/utils": "2.34.1",
|
|
60
56
|
"chalk": "4.1.2",
|
|
@@ -90,9 +86,8 @@
|
|
|
90
86
|
"@types/xml": "1.0.6",
|
|
91
87
|
"babel-jest": "27.2.4",
|
|
92
88
|
"copyfiles": "2.4.1",
|
|
93
|
-
"ghooks": "2.0.4",
|
|
94
89
|
"jest": "27.2.4",
|
|
95
|
-
"jest-cli": "27.
|
|
90
|
+
"jest-cli": "27.3.1",
|
|
96
91
|
"jest-extended": "1.1.0",
|
|
97
92
|
"nodemon": "2.0.13",
|
|
98
93
|
"semantic-release": "17.4.7",
|
|
@@ -100,8 +95,7 @@
|
|
|
100
95
|
"ts-node": "10.2.1",
|
|
101
96
|
"tslib": "2.3.1",
|
|
102
97
|
"typescript": "4.3.5",
|
|
103
|
-
"util": "0.12.4"
|
|
104
|
-
"validate-commit-msg": "1.1.3"
|
|
98
|
+
"util": "0.12.4"
|
|
105
99
|
},
|
|
106
|
-
"version": "3.0
|
|
100
|
+
"version": "3.3.0"
|
|
107
101
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateLinkHref = void 0;
|
|
4
|
-
var updateLinkHref = function (linkTag, assetPathMap) {
|
|
5
|
-
var linkSourcePath = linkTag.getAttribute('href') || '';
|
|
6
|
-
var isUrl = linkSourcePath.startsWith('http') || linkSourcePath.startsWith('//');
|
|
7
|
-
if (!isUrl) {
|
|
8
|
-
var assetPath = assetPathMap.find(function (entry) {
|
|
9
|
-
return entry.source === linkSourcePath ||
|
|
10
|
-
"./" + entry.source === linkSourcePath;
|
|
11
|
-
});
|
|
12
|
-
if (!(assetPath === null || assetPath === void 0 ? void 0 : assetPath.target)) {
|
|
13
|
-
throw new Error("Unable to find file: " + linkSourcePath);
|
|
14
|
-
}
|
|
15
|
-
linkTag.setAttribute('href', assetPath.target);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
exports.updateLinkHref = updateLinkHref;
|