mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-05 20:42:26 +00:00
compiles, needs some cleanup
This commit is contained in:
parent
6011d9d401
commit
82d79b4647
7 changed files with 153 additions and 167 deletions
24
makefile
24
makefile
|
|
@ -20,17 +20,18 @@ all: http
|
|||
$(VOC) -s \
|
||||
../src/vpkGit.Mod \
|
||||
../src/vpkFsHelper.Mod \
|
||||
../src/vpkConf.Mod \
|
||||
../src/vpkUserDetails.Mod \
|
||||
../src/vpkSettings.Mod \
|
||||
../src/vpkTime.Mod \
|
||||
../src/vpkLogger.Mod \
|
||||
../src/vpkConf.Mod \
|
||||
../src/vpkFileManager.Mod \
|
||||
../lists/src/Sys.Mod \
|
||||
../lists/src/List.Mod \
|
||||
../lists/src/strutils.Mod \
|
||||
../src/vpkCharacterStack.Mod \
|
||||
../src/vpkCharacterStack.Mod \
|
||||
../src/vpkJsonParser.Mod \
|
||||
../src/vpkFileManager.Mod \
|
||||
../src/vpkSyncer.Mod \
|
||||
../src/vpkUserDetails.Mod \
|
||||
../src/vpkTime.Mod \
|
||||
../src/vpkLogger.Mod \
|
||||
../src/vpkPackageResolver.Mod \
|
||||
../src/vpkDependencyResolver.Mod \
|
||||
../src/vpkPackageFileParser.Mod \
|
||||
|
|
@ -51,17 +52,6 @@ http: clean
|
|||
../Internet/src/Internet.Mod \
|
||||
../src/vpkHttp.Mod
|
||||
|
||||
json:
|
||||
cd $(BUILDDIR) && \
|
||||
$(VOC) -s \
|
||||
../src/vpkTime.Mod \
|
||||
../src/vpkLogger.Mod \
|
||||
../lists/src/Sys.Mod \
|
||||
../lists/src/List.Mod \
|
||||
../lists/src/strutils.Mod \
|
||||
../src/vpkCharacterStack.Mod \
|
||||
../src/vpkJsonParser.Mod
|
||||
|
||||
clean:
|
||||
if [ -d "$(BUILDDIR)" ]; then rm -rf $(BUILDDIR); fi
|
||||
|
||||
|
|
|
|||
130
src/vipack.Mod
130
src/vipack.Mod
|
|
@ -1,22 +1,6 @@
|
|||
MODULE vipack;
|
||||
IMPORT vpkFileManager,vpkJsonParser,vpkGit, vpkConf, vpkLogger, vpkPackageFileParser, Texts, Strings, In, Platform, Oberon, Out;
|
||||
|
||||
PROCEDURE main();
|
||||
|
||||
CONST confFileName = "vipackConf.json";
|
||||
CONST syncDirName = "vipackTree";
|
||||
CONST quote = '"';
|
||||
CONST startBracket = "{";
|
||||
CONST endBracket = "}";
|
||||
|
||||
VAR user, str: ARRAY 32 OF CHAR;
|
||||
vpkDirPath, treePath, confPath, jsonString : ARRAY 120 OF CHAR;
|
||||
i : INTEGER;
|
||||
ch : CHAR;
|
||||
S: Texts.Scanner;
|
||||
jsonData,string,defaultUrl,gitUrl,project,command, jsonPathLine : ARRAY 500 OF CHAR;
|
||||
success: BOOLEAN;
|
||||
jsonRecord: vpkJsonParser.JsonTypePointer;
|
||||
IMPORT Texts, Strings, Oberon, Out,
|
||||
vpkJsonParser, vpkGit, vpkConf, vpkLogger, vpkPackageFileParser, vpkSyncer;
|
||||
|
||||
PROCEDURE help();
|
||||
BEGIN
|
||||
|
|
@ -26,94 +10,38 @@ BEGIN
|
|||
Out.String("vipackTree path -> $HOME/.vipack/vipackTree")
|
||||
END help;
|
||||
|
||||
|
||||
PROCEDURE main();
|
||||
VAR
|
||||
user, str: ARRAY 32 OF CHAR;
|
||||
i : INTEGER;
|
||||
ch : CHAR;
|
||||
S: Texts.Scanner;
|
||||
project, command: ARRAY 500 OF CHAR;
|
||||
jsonRecord: vpkJsonParser.JsonTypePointer;
|
||||
BEGIN
|
||||
(* Getting 1 argument and outputting it *)
|
||||
Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos);
|
||||
Texts.Scan(S);
|
||||
Out.String(S.s); Out.Ln;
|
||||
(* Getting 1 argument and outputting it *)
|
||||
Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos);
|
||||
Texts.Scan(S);
|
||||
Out.String(S.s); Out.Ln;
|
||||
|
||||
defaultUrl := "https://github.com/vishaps/vipackTree";
|
||||
command := S.s;
|
||||
|
||||
command := S.s;
|
||||
IF Strings.Match(command, "") OR Strings.Match(command, "help")THEN
|
||||
help;
|
||||
ELSE
|
||||
vpkConf.configure;
|
||||
IF command = "sync" THEN
|
||||
vpkSyncer.sync;
|
||||
END;
|
||||
|
||||
IF Strings.Match(command, "") OR Strings.Match(command, "help")THEN
|
||||
help;
|
||||
ELSE
|
||||
IF command = "install" THEN
|
||||
Texts.Scan(S);
|
||||
project := S.s;
|
||||
Out.String(project);Out.Ln;
|
||||
vpkPackageFileParser.install();
|
||||
END;
|
||||
|
||||
IF ~(vpkConf.varCheck("HOME", vpkDirPath)) THEN
|
||||
Out.String("HOME variable is not found"); Out.Ln;
|
||||
END;
|
||||
|
||||
Strings.Append("/.vipack/",vpkDirPath);
|
||||
confPath := vpkDirPath;
|
||||
treePath := vpkDirPath;
|
||||
|
||||
(* Checking if ~/.vipack directory already exists *)
|
||||
IF vpkConf.makeDir(vpkDirPath) THEN
|
||||
Out.String("Creating directory "); Out.String(vpkDirPath);Out.Ln;
|
||||
ELSE Out.String(vpkDirPath); Out.String(" already exists or path is wrong");Out.Ln;
|
||||
END;
|
||||
|
||||
(* Checking if vipack.conf already exists *)
|
||||
Strings.Append(confFileName,confPath);
|
||||
|
||||
IF ~(vpkConf.confExists(confPath)) THEN
|
||||
Out.String("Creating the configuration file "); Out.String(confPath);Out.Ln;
|
||||
jsonPathLine := "";
|
||||
vpkConf.makeFile(confPath);
|
||||
Strings.Append(startBracket, jsonPathLine);
|
||||
Strings.Append('"path" : ', jsonPathLine);
|
||||
Strings.Append(quote, jsonPathLine);
|
||||
Strings.Append(defaultUrl,jsonPathLine);
|
||||
Strings.Append(quote, jsonPathLine);
|
||||
Strings.Append(endBracket,jsonPathLine);
|
||||
vpkConf.writeInFile(confPath,jsonPathLine,0);
|
||||
ELSE
|
||||
Out.String("File already exists");Out.Ln;
|
||||
END;
|
||||
|
||||
|
||||
IF command = "sync" THEN
|
||||
treePath := vpkDirPath;
|
||||
Strings.Append(syncDirName, treePath);
|
||||
Strings.Append("/",treePath);
|
||||
Out.String("*****************************************"); Out.Ln;
|
||||
Out.String("TreePath = "); Out.String(treePath);
|
||||
|
||||
(* Check tree directory if doesn't exist create*)
|
||||
IF vpkConf.makeDir(treePath) THEN
|
||||
Out.String("Creating "); Out.String(treePath); Out.String("for syncing");Out.Ln;
|
||||
ELSE Out.String("Some error occured or directory already exist");
|
||||
END;
|
||||
(* Syncing *)
|
||||
success := vpkFileManager.Read(confPath,jsonData);
|
||||
jsonRecord := vpkJsonParser.Create(jsonData);
|
||||
success := vpkJsonParser.GetTerminal(jsonRecord,"path", jsonString);
|
||||
Out.String("URL = ");
|
||||
Out.String(jsonString);Out.Ln;
|
||||
gitUrl := jsonString;
|
||||
string := gitUrl;
|
||||
Strings.Delete(string,19,Strings.Length(string)-17);
|
||||
Out.String(string);Out.Ln;
|
||||
(* Checking the URL of vipackConf.json path key *)
|
||||
IF Strings.Match(string,"https://github.com/") OR Strings.Match(string,"git://github.com/") THEN
|
||||
Out.String("YES"); Out.Ln;
|
||||
vpkGit.pull(gitUrl,treePath);
|
||||
END;
|
||||
END;
|
||||
|
||||
|
||||
|
||||
IF command = "install" THEN
|
||||
Texts.Scan(S);
|
||||
project := S.s;
|
||||
Out.String(project);Out.Ln;
|
||||
vpkPackageFileParser.install();
|
||||
|
||||
END;
|
||||
|
||||
END;
|
||||
END;
|
||||
END main;
|
||||
|
||||
|
||||
|
|
|
|||
112
src/vpkConf.Mod
112
src/vpkConf.Mod
|
|
@ -1,45 +1,97 @@
|
|||
MODULE vpkConf;
|
||||
IMPORT Out, Files, Strings, Platform,
|
||||
vpkFsHelper;
|
||||
vpkFsHelper, vpkSettings;
|
||||
|
||||
PROCEDURE confExists*(VAR confFile: ARRAY OF CHAR ):BOOLEAN;
|
||||
VAR
|
||||
conf, confDir : ARRAY 256 OF CHAR;
|
||||
|
||||
PROCEDURE mkConfContent(VAR path: ARRAY OF CHAR);
|
||||
BEGIN
|
||||
IF Files.Old(confFile) = NIL THEN RETURN FALSE;
|
||||
ELSE RETURN TRUE;
|
||||
END;
|
||||
Strings.Append('{"path" : "', path);
|
||||
Strings.Append(vpkSettings.treeURL, path);
|
||||
Strings.Append('"}, "type" : "git"}', path);
|
||||
END mkConfContent;
|
||||
|
||||
END confExists;
|
||||
|
||||
PROCEDURE makeFile*(VAR confFilePath: ARRAY OF CHAR);
|
||||
VAR f : Files.File;
|
||||
PROCEDURE makeFile(VAR confFilePath: ARRAY OF CHAR; VAR f: Files.File; VAR r: Files.Rider);
|
||||
BEGIN
|
||||
f := Files.New(confFilePath);
|
||||
Files.Register(f);
|
||||
|
||||
Files.Set(r, f, 0);
|
||||
END makeFile;
|
||||
|
||||
PROCEDURE makeDir*(VAR confDirPath: ARRAY OF CHAR):BOOLEAN;
|
||||
PROCEDURE writeInFile(VAR f: Files.File; r: Files.Rider; VAR text : ARRAY OF CHAR);
|
||||
BEGIN
|
||||
RETURN vpkFsHelper.mkDir(confDirPath);
|
||||
END makeDir;
|
||||
|
||||
PROCEDURE varCheck*(variable : ARRAY OF CHAR;VAR value : ARRAY OF CHAR): BOOLEAN;
|
||||
BEGIN
|
||||
RETURN Platform.getEnv(variable,value);
|
||||
END varCheck;
|
||||
|
||||
PROCEDURE writeInFile*(VAR pathToFile : ARRAY OF CHAR;VAR text : ARRAY OF CHAR; posRider : INTEGER);
|
||||
VAR f : Files.File;
|
||||
r : Files.Rider;
|
||||
BEGIN
|
||||
f := Files.Old(pathToFile);
|
||||
Files.Set(r,f,posRider);
|
||||
Files.WriteBytes(r, text, Strings.Length(text));
|
||||
Files.Close(f);
|
||||
Files.WriteBytes(r, text, Strings.Length(text));
|
||||
END writeInFile;
|
||||
|
||||
PROCEDURE closeFile(VAR f: Files.File);
|
||||
BEGIN
|
||||
Files.Register(f);
|
||||
Files.Close(f);
|
||||
END closeFile;
|
||||
|
||||
PROCEDURE mkConfDirPath(home: ARRAY OF CHAR; VAR path: ARRAY OF CHAR);
|
||||
BEGIN
|
||||
confDir := home;
|
||||
Strings.Append("/", path);
|
||||
Strings.Append(vpkSettings.vpkConfDir, path);
|
||||
END mkConfDirPath;
|
||||
|
||||
PROCEDURE setConfPath;
|
||||
VAR
|
||||
home: ARRAY 128 OF CHAR;
|
||||
BEGIN
|
||||
vpkSettings.getHome(home);
|
||||
mkConfDirPath(home, confDir);
|
||||
conf := confDir;
|
||||
Strings.Append("/", conf);
|
||||
Strings.Append(vpkSettings.vpkConfFile, conf);
|
||||
END setConfPath;
|
||||
|
||||
PROCEDURE getConfPath*(VAR path: ARRAY OF CHAR);
|
||||
BEGIN
|
||||
COPY(conf, path);
|
||||
END getConfPath;
|
||||
|
||||
PROCEDURE getConfDir*(VAR path: ARRAY OF CHAR);
|
||||
BEGIN
|
||||
COPY(confDir, path);
|
||||
END getConfDir;
|
||||
|
||||
PROCEDURE configure*;
|
||||
VAR
|
||||
content: ARRAY 256 OF CHAR;
|
||||
file : vpkFsHelper.fileInfo;
|
||||
fd: Files.File;
|
||||
rd: Files.Rider;
|
||||
BEGIN
|
||||
file.name := conf;
|
||||
IF ~vpkFsHelper.Exists(file) THEN
|
||||
(* Checking if ~/.vipack directory already exists *)
|
||||
file.name := confDir;
|
||||
IF ~vpkFsHelper.Exists(file) THEN (* exists!!! *)
|
||||
Out.String("Creating directory "); Out.String(confDir);Out.Ln;
|
||||
IF ~vpkFsHelper.mkDir(confDir) THEN
|
||||
Out.String("failed to create "); Out.String(confDir); Out.String(" directory"); Out.Ln;
|
||||
HALT(1);
|
||||
END;
|
||||
ELSE
|
||||
IF ~(vpkFsHelper.dir IN file.attr) THEN
|
||||
Out.String(confDir); Out.String(" exists, but is not a directory"); Out.Ln;
|
||||
HALT(1);
|
||||
END;
|
||||
END;
|
||||
(* create conf file *)
|
||||
Out.String("Creating the configuration file "); Out.String(conf);Out.Ln;
|
||||
content := "";
|
||||
makeFile(conf, fd, rd);
|
||||
mkConfContent(content);
|
||||
writeInFile(fd, rd, content);
|
||||
closeFile(fd);
|
||||
ELSE
|
||||
Out.String("File already exists");Out.Ln;
|
||||
END;
|
||||
END configure;
|
||||
|
||||
BEGIN
|
||||
|
||||
|
||||
setConfPath;
|
||||
END vpkConf.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ CONST
|
|||
|
||||
TYPE
|
||||
fileInfo* = RECORD;
|
||||
name* : ARRAY 64 OF CHAR;
|
||||
name* : ARRAY 256 OF CHAR;
|
||||
attr- : SET
|
||||
END;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
MODULE vpkGit;
|
||||
IMPORT Out,Strings, Platform;
|
||||
IMPORT Out, Strings, Platform;
|
||||
|
||||
PROCEDURE pull*(URL : ARRAY OF CHAR; dst : ARRAY OF CHAR);
|
||||
VAR i : INTEGER;
|
||||
cmd : ARRAY 120 OF CHAR;
|
||||
cmd : ARRAY 120 OF CHAR;
|
||||
BEGIN
|
||||
cmd:= "git init ";
|
||||
Strings.Append(dst, cmd);
|
||||
i:=Platform.System(cmd);
|
||||
cmd := "";
|
||||
cmd := "git -C ";
|
||||
Strings.Append(dst,cmd);
|
||||
Strings.Append(" pull ",cmd);
|
||||
Strings.Append(URL, cmd);
|
||||
i := Platform.System(cmd);
|
||||
Out.Int(i,0);
|
||||
cmd:= "git init ";
|
||||
Strings.Append(dst, cmd);
|
||||
i:=Platform.System(cmd);
|
||||
cmd := "";
|
||||
cmd := "git -C ";
|
||||
Strings.Append(dst,cmd);
|
||||
Strings.Append(" pull ",cmd);
|
||||
Strings.Append(URL, cmd);
|
||||
i := Platform.System(cmd);
|
||||
Out.Int(i,0);
|
||||
END pull;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ CONST
|
|||
symbolBracketStart = "{";
|
||||
symbolBracketEnd = "}";
|
||||
(* TODO: Reverse " and ' *)
|
||||
quote = vpkSettings.quote;
|
||||
coma = ",";
|
||||
quote = '"';
|
||||
TYPE
|
||||
TString* = ARRAY ArrayMaxNumberChar OF CHAR;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,24 @@
|
|||
MODULE vpkSettings;
|
||||
IMPORT Platform, Out;
|
||||
CONST
|
||||
packageFileName* = "VersionFile.json";
|
||||
host* = "localhost";
|
||||
port* = "80";
|
||||
installPath* = "dependencies";
|
||||
quote* = '"';
|
||||
vpkConfDir* = ".vipack";
|
||||
vpkConfFile* = "vipackConf.json";
|
||||
vpkTreeDir* = "vipackTree";
|
||||
treeURL* = "https://github.com/vishaps/vipackTree";
|
||||
confTypGit* = "git";
|
||||
confType* = "type";
|
||||
confTermPath* = "path";
|
||||
packageFileName* = "VersionFile.json";
|
||||
host* = "localhost";
|
||||
port* = "80";
|
||||
installPath* = "dependencies";
|
||||
|
||||
PROCEDURE getHome*(VAR path: ARRAY OF CHAR);
|
||||
BEGIN
|
||||
IF ~(Platform.getEnv("HOME", path)) THEN
|
||||
Out.String("HOME variable is not found"); Out.Ln;
|
||||
HALT(1);
|
||||
END;
|
||||
END getHome;
|
||||
|
||||
END vpkSettings.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue