Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ A package is a directory with a `scryer-manifest.pl`, the current schema is some
name("name_of_the_package").
% Optional. The file that will be imported when this package is used.
main_file("main.pl").
% The license of the package
license(name("Unlicense"), path("./UNLICENSE"))
% Optional
dependencies([
% A git url to clone
Expand Down
2 changes: 2 additions & 0 deletions example/scryer-manifest.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name("name_of_the_package").
% Optional. The file that will be imported when this package is used.
main_file("main.pl").
%License
license(name("UNLICENSE")).
% Optional
dependencies([
% A git url to clone
Expand Down
4 changes: 3 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ build: codegen-scripts
cat ./src/shebang.sh > "./build/{{BUILD_NAME}}"
cat ./src/bakage.pl >> "./build/{{BUILD_NAME}}"
printf "\n" >> "./build/{{BUILD_NAME}}"
cat ./src/validation.pl >> "./build/{{BUILD_NAME}}"
printf "\n" >> "./build/{{BUILD_NAME}}"
cat ./src/cli.pl >> "./build/{{BUILD_NAME}}"
printf "\n" >> "./build/{{BUILD_NAME}}"
cat ./build/scripts.pl >> "./build/{{BUILD_NAME}}"
Expand All @@ -26,7 +28,7 @@ build: codegen-scripts
codegen-scripts: ensure-build-directory
#!/bin/sh
set -eu

touch ./build/scripts.pl

for file in scripts/*.sh; do
Expand Down
131 changes: 12 additions & 119 deletions src/bakage.pl
Original file line number Diff line number Diff line change
Expand Up @@ -131,116 +131,14 @@
current_output(Out),
phrase_to_stream((portray_clause_(D), "is malformed: ", Error, "\n"), Out).

% A valid dependency
valid_dependencies([]) --> [].

valid_dependencies([dependency(Name, path(Path))| Ds]) --> {
if_(
(memberd_t(';', Name)
; memberd_t('|', Name)
; memberd_t(';', Path)
; memberd_t('|', Path)
),
(
Error = "the name and the path of the dependency should not contain an \";\" or an \"|\" caracter",
M = validate_dependency(dependency(Name, path(Path)))-error(Error),
user_message_malformed_dependency(dependency(Name, path(Path)), Error)
),
M = validate_dependency(dependency(Name, path(Path)))-success
)
},
[M],
valid_dependencies(Ds).

valid_dependencies([dependency(Name, git(Url))| Ds]) --> {
if_(
(memberd_t(';', Name)
; memberd_t('|', Name)
; memberd_t(';', Url)
; memberd_t('|', Url)
),
(
Error = "the name of the dependency and the url should not contain an \";\" or an \"|\" caracter",
M = validate_dependency(dependency(Name, git(Url)))-error(Error),
user_message_malformed_dependency(dependency(Name, git(Url)), Error)
),
M = validate_dependency(dependency(Name, git(Url)))-success
)
},
[M],
valid_dependencies(Ds).

valid_dependencies([dependency(Name, git(Url, branch(Branch)))| Ds]) --> {
if_(
(memberd_t(';', Name)
; memberd_t('|', Name)
; memberd_t(';', Url)
; memberd_t('|', Url)
; memberd_t(';', Branch)
; memberd_t('|', Branch)),
(
Error = "the name, the url and the branch of dependency should not contain an \";\" or an \"|\" caracter",
M = validate_dependency(dependency(Name, git(Url, branch(Branch))))-error(Error),
user_message_malformed_dependency(dependency(Name, git(Url, branch(Branch))), Error)
),(
M = validate_dependency(dependency(Name, git(Url, branch(Branch))))-success
)
)
},
[M],
valid_dependencies(Ds).

valid_dependencies([dependency(Name, git(Url, tag(Tag)))|Ds]) --> {
if_(
(memberd_t(';', Name)
; memberd_t('|', Name)
; memberd_t(';', Url)
; memberd_t('|', Url)
; memberd_t(';', Tag)
; memberd_t('|', Tag)),
(
Error = "the name, the url and the tag of dependency should not contain an \";\" or an \"|\" caracter",
M = validate_dependency(dependency(Name, git(Url, tag(Tag))))-error(Error),
user_message_malformed_dependency(dependency(Name, git(Url, tag(Tag))), Error)
),
M = validate_dependency(dependency(Name, git(Url, tag(Tag))))-success
)
},
[M],
valid_dependencies(Ds).

valid_dependencies([dependency(Name, git(Url, hash(Hash)))|Ds]) --> {
if_(
(memberd_t(';', Name)
; memberd_t('|', Name)
; memberd_t(';', Url)
; memberd_t('|', Url)
; memberd_t(';', Hash)
; memberd_t('|', Hash)),
(
Error = "the name, the url and the hash of dependency should not contain an \";\" or an \"|\" caracter",
M = validate_dependency(dependency(Name, git(Url, hash(Hash))))-error(Error),
user_message_malformed_dependency(dependency(Name, git(Url, hash(Hash))), Error)
),
M = validate_dependency(dependency(Name, git(Url, hash(Hash))))-success
)
},
[M],
valid_dependencies(Ds).

all_dependencies_valid_t([], true).
all_dependencies_valid_t([validate_dependency(_)-success| Vs], T) :- all_dependencies_valid_t(Vs, T).
all_dependencies_valid_t([validate_dependency(_)-error(_)| _], false).


% A prolog file knowledge base represented as a list of terms
prolog_kb_list(Stream) --> {read(Stream, Term), dif(Term, end_of_file)}, [Term], prolog_kb_list(Stream).
prolog_kb_list(Stream) --> {read(Stream, Term), Term == end_of_file}, [].

parse_manifest(Filename, Manifest) :-
setup_call_cleanup(
open(Filename, read, Stream),
once(phrase(prolog_kb_list(Stream), Manifest)),
catch(once(phrase(prolog_kb_list(Stream), Manifest)), error(E, I), throw(error_formating_of_manifest(E, I))),
close(Stream)
).

Expand Down Expand Up @@ -291,23 +189,18 @@
setenv("SHELL", "/bin/sh"),
setenv("GIT_ADVICE", "0"),
directory_files("scryer_libs/packages", Installed_Packages),
(member(dependencies(Deps), Manifest) ->
(
phrase(valid_dependencies(Deps), Validation_Report),
if_(all_dependencies_valid_t(Validation_Report),
call_cleanup(
(
logical_plan(Plan, Deps, Installed_Packages),
installation_execution(Plan, Installation_Report),
append(Validation_Report, Installation_Report, Report)
),
delete_directory("scryer_libs/temp")
),
if_(valid_manifest_t(Manifest, Validation_Report),
(member(dependencies(Deps), Manifest) ->
call_cleanup(
(
Report = Validation_Report
)
)
); Report = []
logical_plan(Plan, Deps, Installed_Packages),
installation_execution(Plan, Installation_Report),
append(Validation_Report, Installation_Report, Report)
),
delete_directory("scryer_libs/temp")
) ; Report = Validation_Report
),
Report = Validation_Report
).

% A logical plan to install the dependencies
Expand Down
Loading