1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-03 15:40:05 +00:00

feat(*): recreate library as scoped package

This commit is contained in:
Krishna Acondy
2020-07-07 21:27:24 +01:00
commit 8beb0048a3
144 changed files with 30478 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
/**
@file
@brief Deletes a metadata folder
@details Deletes a metadata folder (and contents) using the batch tools, as
documented here:
https://documentation.sas.com/?docsetId=bisag&docsetTarget=p0zqp8fmgs4o0kn1tt7j8ho829fv.htm&docsetVersion=9.4&locale=en
Usage:
%mmx_deletemetafolder(loc=/some/meta/folder,user=sasdemo,pass=mars345)
<h4> Dependencies </h4>
@li mf_loc.sas
@param loc= the metadata folder to delete
@param user= username
@param pass= password
@version 9.4
@author Allan Bowe
**/
%macro mmx_deletemetafolder(loc=,user=,pass=);
%local host port path connx_string;
%let host=%sysfunc(getoption(metaserver));
%let port=%sysfunc(getoption(metaport));
%let path=%mf_loc(POF)/tools;
%let connx_string= -host &host -port &port -user '&user' -password '&pass';
/* remove directory */
data _null_;
infile " &path/sas-delete-objects &connx_string ""&loc"" -deleteContents 2>&1"
pipe lrecl=10000;
input;
putlog _infile_;
run;
%mend;

91
metax/mmx_spkexport.sas Normal file
View File

@@ -0,0 +1,91 @@
/**
@file mmx_spkexport.sas
@brief Exports everything in a particular metadata folder
@details Will export everything in a metadata folder to a specified location.
Note - the batch tools require a username and password. For security,
these are expected to have been provided in a protected directory.
Usage:
%* import the macros (or make them available some other way);
filename mc url "https://raw.githubusercontent.com/macropeople/macrocore/master/mc_all.sas";
%inc mc;
%* create sample text file as input to the macro;
filename tmp temp;
data _null_;
file tmp;
put '%let mmxuser=sasdemo;';
put '%let mmxpass=Mars321';
run;
filename outref "%sysfunc(pathname(work))";
%mmx_spkexport(metaloc=%str(/30.Projects/3001.Internal/300115.DataController/dc1)
,secureref=tmp
,outspkpath=%str(/tmp)
)
<h4> Dependencies </h4>
@li mf_loc.sas
@li mm_tree.sas
@li mf_getuniquefileref.sas
@li mp_abort.sas
@param metaloc= the metadata folder to export
@param secureref= fileref containing the username / password (should point to
a file in a secure location)
@param outspkname= name of the spk to be created (default is mmxport).
@param outspkpath= directory in which to create the SPK. Default is WORK.
@version 9.4
@author Allan Bowe
**/
%macro mmx_spkexport(metaloc=
,secureref=
,outspkname=mmxport
,outspkpath=%sysfunc(pathname(work))
);
%local host port platform_object_path connx_string;
%let host=%sysfunc(getoption(metaserver));
%let port=%sysfunc(getoption(metaport));
%let platform_object_path=%mf_loc(POF);
/* get creds */
%inc &secureref/nosource;
%let connx_string=%str(-host &host -port &port -user '&mmxuser' -password '&mmxpass');
%mm_tree(root=%str(&metaloc) ,types=EXPORTABLE ,outds=exportable)
%local fref1;
%let fref1=%mf_getuniquefileref();
data ;
set exportable end=last;
file &fref1 lrecl=32767;
length str $32767;
if _n_=1 then do;
put 'data _null_;';
put 'infile "cd ""&platform_object_path"" %trim(';
put ') cd ""&platform_object_path"" %trim(';
put '); ./ExportPackage &connx_string -disableX11 %trim(';
put ') -package ""&outspkpath/&outspkname..spk"" %trim(';
end;
str=') -objects '!!cats('""',path,'/',name,"(",publictype,')"" %trim(');
put str;
if last then do;
put ') -log ""&outspkpath/&outspkname..log"" 2>&1" pipe lrecl=10000;';
put 'input;putlog _infile_;run;';
end;
run;
%mp_abort(iftrue= (&syscc ne 0)
,mac=&sysmacroname
,msg=%str(syscc=&syscc)
)
%inc &fref1;
%mend;