@sasjs/core 4.40.1 → 4.42.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/base/mp_gitreleaseinfo.sas +74 -0
- package/package.json +1 -1
- package/viya/mfv_existsashdat.sas +60 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Pulls latest release info from a GIT repository
|
|
4
|
+
@details Useful for grabbing the latest version number or other attributes
|
|
5
|
+
from a GIT server. Supported providers are GitLab and GitHub. Pull requests
|
|
6
|
+
are welcome if you'd like to see additional providers!
|
|
7
|
+
|
|
8
|
+
Note that each provider provides slightly different JSON output. Therefore
|
|
9
|
+
the macro simply extracts the JSON and assigns the libname (using the JSON
|
|
10
|
+
engine).
|
|
11
|
+
|
|
12
|
+
Example usage (eg, to grab latest release version from github):
|
|
13
|
+
|
|
14
|
+
%mp_gitreleaseinfo(GITHUB,sasjs/core,outlib=mylibref)
|
|
15
|
+
|
|
16
|
+
data _null_;
|
|
17
|
+
set mylibref.root;
|
|
18
|
+
putlog TAG_NAME=;
|
|
19
|
+
run;
|
|
20
|
+
|
|
21
|
+
@param [in] provider The GIT provider for the release info. Accepted values:
|
|
22
|
+
@li GITLAB
|
|
23
|
+
@li GITHUB - Tables include root, assets, author, alldata
|
|
24
|
+
@param [in] project The link to the repository. This has different formats
|
|
25
|
+
depending on the vendor:
|
|
26
|
+
@li GITHUB - org/repo, eg sasjs/core
|
|
27
|
+
@li GITLAB - project, eg 1343223
|
|
28
|
+
@param [in] server= (0) If your repo is self-hosted, then provide the domain
|
|
29
|
+
here. Otherwise it will default to the provider domain (eg gitlab.com).
|
|
30
|
+
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
31
|
+
@param [out] outlib= (GITREL) The JSON-engine libref to be created, which will
|
|
32
|
+
point at the returned JSON
|
|
33
|
+
|
|
34
|
+
<h4> SAS Macros </h4>
|
|
35
|
+
@li mf_getuniquefileref.sas
|
|
36
|
+
|
|
37
|
+
<h4> Related Files </h4>
|
|
38
|
+
@li mp_gitreleaseinfo.test.sas
|
|
39
|
+
|
|
40
|
+
**/
|
|
41
|
+
|
|
42
|
+
%macro mp_gitreleaseinfo(provider,project,server=0,outlib=GITREL,mdebug=0);
|
|
43
|
+
%local url fref;
|
|
44
|
+
|
|
45
|
+
%let provider=%upcase(&provider);
|
|
46
|
+
|
|
47
|
+
%if &provider=GITHUB %then %do;
|
|
48
|
+
%if "&server"="0" %then %let server=https://api.github.com;
|
|
49
|
+
%let url=&server/repos/&project/releases/latest;
|
|
50
|
+
%end;
|
|
51
|
+
%else %if &provider=GITLAB %then %do;
|
|
52
|
+
%if "&server"="0" %then %let server=https://gitlab.com;
|
|
53
|
+
%let url=&server/api/v4/projects/&project/releases;
|
|
54
|
+
%end;
|
|
55
|
+
|
|
56
|
+
%let fref=%mf_getuniquefileref();
|
|
57
|
+
|
|
58
|
+
proc http method='GET' out=&fref url="&url";
|
|
59
|
+
%if &mdebug=1 %then %do;
|
|
60
|
+
debug level = 3;
|
|
61
|
+
%end;
|
|
62
|
+
run;
|
|
63
|
+
|
|
64
|
+
libname &outlib JSON fileref=&fref;
|
|
65
|
+
|
|
66
|
+
%if &mdebug=1 %then %do;
|
|
67
|
+
data _null_;
|
|
68
|
+
infile &fref;
|
|
69
|
+
input;
|
|
70
|
+
putlog _infile_;
|
|
71
|
+
run;
|
|
72
|
+
%end;
|
|
73
|
+
|
|
74
|
+
%mend mp_gitreleaseinfo;
|
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file mfv_existsashdat.sas
|
|
3
|
+
@brief Checks whether a CAS sashdat dataset exists in persistent storage.
|
|
4
|
+
@details Can be used in open code, eg as follows:
|
|
5
|
+
|
|
6
|
+
%if %mfv_existsashdat(libds=casuser.sometable) %then %put yes it does!;
|
|
7
|
+
|
|
8
|
+
The function uses `dosubl()` to run the `table.fileinfo` action, for the
|
|
9
|
+
specified library, filtering for `*.sashdat` tables. The results are stored
|
|
10
|
+
in a WORK table (&outprefix._&lib). If that table already exists, it is
|
|
11
|
+
queried instead, to avoid the dosubl() performance hit.
|
|
12
|
+
|
|
13
|
+
To force a rescan, just use a new `&outprefix` value, or delete the table(s)
|
|
14
|
+
before running the function.
|
|
15
|
+
|
|
16
|
+
@param libds library.dataset
|
|
17
|
+
@param outprefix= (work.mfv_existsashdat) Used to store the current HDATA
|
|
18
|
+
tables to improve subsequent query performance. This reference is a prefix
|
|
19
|
+
and is converted to `&prefix._{libref}`
|
|
20
|
+
|
|
21
|
+
@return output returns 1 or 0
|
|
22
|
+
|
|
23
|
+
@version 0.2
|
|
24
|
+
@author Mathieu Blauw
|
|
25
|
+
**/
|
|
26
|
+
|
|
27
|
+
%macro mfv_existsashdat(libds,outprefix=work.mfv_existsashdat
|
|
28
|
+
);
|
|
29
|
+
%local rc dsid name lib ds;
|
|
30
|
+
%let lib=%upcase(%scan(&libds,1,'.'));
|
|
31
|
+
%let ds=%upcase(%scan(&libds,-1,'.'));
|
|
32
|
+
|
|
33
|
+
/* if table does not exist, create it */
|
|
34
|
+
%if %sysfunc(exist(&outprefix._&lib)) ne 1 %then %do;
|
|
35
|
+
%let rc=%sysfunc(dosubl(%nrstr(
|
|
36
|
+
/* Read in table list (once per &lib per session) */
|
|
37
|
+
proc cas;
|
|
38
|
+
table.fileinfo result=source_list /caslib="&lib";
|
|
39
|
+
val=findtable(source_list);
|
|
40
|
+
saveresult val dataout=&outprefix._&lib;
|
|
41
|
+
quit;
|
|
42
|
+
/* Only keep name, without file extension */
|
|
43
|
+
data &outprefix._&lib;
|
|
44
|
+
set &outprefix._&lib(where=(Name like '%.sashdat') keep=Name);
|
|
45
|
+
Name=upcase(scan(Name,1,'.'));
|
|
46
|
+
run;
|
|
47
|
+
)));
|
|
48
|
+
%end;
|
|
49
|
+
|
|
50
|
+
/* Scan table for hdat existence */
|
|
51
|
+
%let dsid=%sysfunc(open(&outprefix._&lib(where=(name="&ds"))));
|
|
52
|
+
%syscall set(dsid);
|
|
53
|
+
%let rc = %sysfunc(fetch(&dsid));
|
|
54
|
+
%let rc = %sysfunc(close(&dsid));
|
|
55
|
+
|
|
56
|
+
/* Return result */
|
|
57
|
+
%if "%trim(&name)"="%trim(&ds)" %then 1;
|
|
58
|
+
%else 0;
|
|
59
|
+
|
|
60
|
+
%mend mfv_existsashdat;
|