Skip to content

Commit

Permalink
add marketplace formula
Browse files Browse the repository at this point in the history
Signed-off-by: GuillaumeFalourd <[email protected]>
  • Loading branch information
GuillaumeFalourd committed Sep 16, 2021
1 parent 6c910f8 commit 9e95ef5
Show file tree
Hide file tree
Showing 51 changed files with 453 additions and 0 deletions.
4 changes: 4 additions & 0 deletions catalog/create/help.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"short": "catalog create commands",
"long": "catalog create commands"
}
13 changes: 13 additions & 0 deletions catalog/create/template/bin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ritclizup/rit-python3-runner

USER root

RUN mkdir /rit
COPY . /rit
RUN sed -i 's/\r//g' /rit/set_umask.sh
RUN sed -i 's/\r//g' /rit/run.sh
RUN chmod +x /rit/set_umask.sh

WORKDIR /app
ENTRYPOINT ["/rit/set_umask.sh"]
CMD ["/rit/run.sh"]
Empty file.
9 changes: 9 additions & 0 deletions catalog/create/template/bin/formula/formula.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/python3
import os
import random

def run():
n = str(random.random())
cmd = "mkdir test" + n
os.system(cmd)
print("Template created!")
6 changes: 6 additions & 0 deletions catalog/create/template/bin/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/python3
import os

from formula import formula

formula.run()
Empty file.
2 changes: 2 additions & 0 deletions catalog/create/template/bin/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ECHO OFF
python main.py
5 changes: 5 additions & 0 deletions catalog/create/template/bin/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
if [ -f /.dockerenv ] ; then
pip3 install -r $(dirname "$0")/requirements.txt --user --disable-pip-version-check >> /dev/null
fi
python3 $(dirname "$0")/main.py
3 changes: 3 additions & 0 deletions catalog/create/template/bin/set_umask.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
umask 0011
$1
4 changes: 4 additions & 0 deletions catalog/list/help.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"short": "catalog list commands",
"long": "catalog list commands"
}
13 changes: 13 additions & 0 deletions catalog/list/templates/bin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ritclizup/rit-python3-runner

USER root

RUN mkdir /rit
COPY . /rit
RUN sed -i 's/\r//g' /rit/set_umask.sh
RUN sed -i 's/\r//g' /rit/run.sh
RUN chmod +x /rit/set_umask.sh

WORKDIR /app
ENTRYPOINT ["/rit/set_umask.sh"]
CMD ["/rit/run.sh"]
Empty file.
20 changes: 20 additions & 0 deletions catalog/list/templates/bin/formula/formula.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/python3
from colored import fg, attr
from distutils.util import strtobool
import os
import random

def Run(input1, input2, input3, input4):
print("Hello World!")
print(f"{fg(2)}My name is {input1}.{attr(0)}")
if strtobool(input2):
print(f"{fg(3)}I've already created formulas using Ritchie.{attr(0)}")
else:
s = "I'm excited in creating new formulas using Ritchie."
print(f"{fg(3)}'{s}'.{attr(0)}")
print(f"{fg(1)}Today, I want to automate {input3}.{attr(0)}")
print(f"{fg(3)}My secret is '{input4}'.{attr(0)}")

n = str(random.random())
cmd = "mkdir test" + n
os.system(cmd)
11 changes: 11 additions & 0 deletions catalog/list/templates/bin/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/python3
import os

from formula import formula


input1 = os.environ.get("RIT_INPUT_TEXT")
input2 = os.environ.get("RIT_INPUT_BOOLEAN")
input3 = os.environ.get("RIT_INPUT_LIST")
input4 = os.environ.get("RIT_INPUT_PASSWORD")
formula.Run(input1, input2, input3, input4)
1 change: 1 addition & 0 deletions catalog/list/templates/bin/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colored==1.4.2
2 changes: 2 additions & 0 deletions catalog/list/templates/bin/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ECHO OFF
python main.py
5 changes: 5 additions & 0 deletions catalog/list/templates/bin/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
if [ -f /.dockerenv ] ; then
pip3 install -r $(dirname "$0")/requirements.txt --user --disable-pip-version-check >> /dev/null
fi
python3 $(dirname "$0")/main.py
3 changes: 3 additions & 0 deletions catalog/list/templates/bin/set_umask.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
umask 0011
$1
4 changes: 4 additions & 0 deletions catalog/run/help.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"short": "catalog run commands",
"long": "catalog run commands"
}
13 changes: 13 additions & 0 deletions catalog/run/templates/bin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ritclizup/rit-python3-runner

USER root

RUN mkdir /rit
COPY . /rit
RUN sed -i 's/\r//g' /rit/set_umask.sh
RUN sed -i 's/\r//g' /rit/run.sh
RUN chmod +x /rit/set_umask.sh

WORKDIR /app
ENTRYPOINT ["/rit/set_umask.sh"]
CMD ["/rit/run.sh"]
Empty file.
15 changes: 15 additions & 0 deletions catalog/run/templates/bin/formula/formula.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/python3
from colored import fg, attr
from distutils.util import strtobool


def Run(input1, input2, input3, input4):
print("Hello World!")
print(f"{fg(2)}My name is {input1}.{attr(0)}")
if strtobool(input2):
print(f"{fg(3)}I've already created formulas using Ritchie.{attr(0)}")
else:
s = "I'm excited in creating new formulas using Ritchie."
print(f"{fg(3)}'{s}'.{attr(0)}")
print(f"{fg(1)}Today, I want to automate {input3}.{attr(0)}")
print(f"{fg(3)}My secret is '{input4}'.{attr(0)}")
11 changes: 11 additions & 0 deletions catalog/run/templates/bin/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/python3
import os

from formula import formula


input1 = os.environ.get("RIT_INPUT_TEXT")
input2 = os.environ.get("RIT_INPUT_BOOLEAN")
input3 = os.environ.get("RIT_INPUT_LIST")
input4 = os.environ.get("RIT_INPUT_PASSWORD")
formula.Run(input1, input2, input3, input4)
1 change: 1 addition & 0 deletions catalog/run/templates/bin/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colored==1.4.2
2 changes: 2 additions & 0 deletions catalog/run/templates/bin/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ECHO OFF
python main.py
5 changes: 5 additions & 0 deletions catalog/run/templates/bin/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
if [ -f /.dockerenv ] ; then
pip3 install -r $(dirname "$0")/requirements.txt --user --disable-pip-version-check >> /dev/null
fi
python3 $(dirname "$0")/main.py
3 changes: 3 additions & 0 deletions catalog/run/templates/bin/set_umask.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
umask 0011
$1
4 changes: 4 additions & 0 deletions catalog/test/help.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"short": "catalog test commands",
"long": "catalog test commands"
}
4 changes: 4 additions & 0 deletions marketplace/help.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"short": "marketplace commands",
"long": "marketplace commands"
}
13 changes: 13 additions & 0 deletions marketplace/test/command/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ritclizup/rit-python3-runner

USER root

RUN mkdir /rit
COPY . /rit
RUN sed -i 's/\r//g' /rit/set_umask.sh
RUN sed -i 's/\r//g' /rit/run.sh
RUN chmod +x /rit/set_umask.sh

WORKDIR /app
ENTRYPOINT ["/rit/set_umask.sh"]
CMD ["/rit/run.sh"]
28 changes: 28 additions & 0 deletions marketplace/test/command/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# The Makefile file will be deprecated in March 2021. It will be replaced by the current build.sh file
# SH
BINARY_NAME=run.sh
BINARY_NAME_WINDOWS=run.bat
BIN_FOLDER=bin
BIN_CONFIG_VENV=config_env.sh

build: python-build sh_unix bat_windows docker

python-build:
mkdir -p $(BIN_FOLDER)
cp -r src/* $(BIN_FOLDER)
pip3 install -r $(BIN_FOLDER)/requirements.txt --user --disable-pip-version-check

sh_unix:
echo '#!/bin/bash' > $(BIN_FOLDER)/$(BINARY_NAME)
echo 'if [ -f /.dockerenv ] ; then' >> $(BIN_FOLDER)/$(BINARY_NAME)
echo 'pip3 install -r "$$(dirname "$$0")"/requirements.txt --user --disable-pip-version-check >> /dev/null' >> $(BIN_FOLDER)/$(BINARY_NAME)
echo 'fi' >> $(BIN_FOLDER)/$(BINARY_NAME)
echo 'python3 "$$(dirname "$$0")"/main.py' >> $(BIN_FOLDER)/$(BINARY_NAME)
chmod +x $(BIN_FOLDER)/$(BINARY_NAME)

bat_windows:
echo '@ECHO OFF' > $(BIN_FOLDER)/$(BINARY_NAME_WINDOWS)
echo 'python main.py' >> $(BIN_FOLDER)/$(BINARY_NAME_WINDOWS)

docker:
cp Dockerfile set_umask.sh $(BIN_FOLDER)
13 changes: 13 additions & 0 deletions marketplace/test/command/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Description

Formula description

## Command

```bash
rit marketplace test command
```

## Requirements

## Demonstration
13 changes: 13 additions & 0 deletions marketplace/test/command/bin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ritclizup/rit-python3-runner

USER root

RUN mkdir /rit
COPY . /rit
RUN sed -i 's/\r//g' /rit/set_umask.sh
RUN sed -i 's/\r//g' /rit/run.sh
RUN chmod +x /rit/set_umask.sh

WORKDIR /app
ENTRYPOINT ["/rit/set_umask.sh"]
CMD ["/rit/run.sh"]
Empty file.
15 changes: 15 additions & 0 deletions marketplace/test/command/bin/formula/formula.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/python3
from colored import fg, attr
from distutils.util import strtobool


def Run(input1, input2, input3, input4):
print("Hello World!")
print(f"{fg(2)}My name is {input1}.{attr(0)}")
if strtobool(input2):
print(f"{fg(3)}I've already created formulas using Ritchie.{attr(0)}")
else:
s = "I'm excited in creating new formulas using Ritchie."
print(f"{fg(3)}'{s}'.{attr(0)}")
print(f"{fg(1)}Today, I want to automate {input3}.{attr(0)}")
print(f"{fg(3)}My secret is '{input4}'.{attr(0)}")
11 changes: 11 additions & 0 deletions marketplace/test/command/bin/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/python3
import os

from formula import formula


input1 = os.environ.get("RIT_INPUT_TEXT")
input2 = os.environ.get("RIT_INPUT_BOOLEAN")
input3 = os.environ.get("RIT_INPUT_LIST")
input4 = os.environ.get("RIT_INPUT_PASSWORD")
formula.Run(input1, input2, input3, input4)
1 change: 1 addition & 0 deletions marketplace/test/command/bin/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colored==1.4.2
2 changes: 2 additions & 0 deletions marketplace/test/command/bin/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@ECHO OFF
python main.py
5 changes: 5 additions & 0 deletions marketplace/test/command/bin/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
if [ -f /.dockerenv ] ; then
pip3 install -r $(dirname "$0")/requirements.txt --user --disable-pip-version-check >> /dev/null
fi
python3 $(dirname "$0")/main.py
3 changes: 3 additions & 0 deletions marketplace/test/command/bin/set_umask.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
umask 0011
$1
41 changes: 41 additions & 0 deletions marketplace/test/command/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
:: Python parameters
echo off
SETLOCAL
SET BIN_FOLDER=bin
SET BAT_FILE=%BIN_FOLDER%\run.bat
SET SH_FILE=%BIN_FOLDER%\run.sh
:build
call :checkCommand python3
call :checkCommand pip3

mkdir %BIN_FOLDER%
xcopy /E /I src %BIN_FOLDER%
CALL :BAT_WINDOWS
CALL :SH_LINUX
CALL :CP_DOCKER
pip3 install -r %BIN_FOLDER%/requirements.txt
GOTO DONE

:BAT_WINDOWS
echo @ECHO OFF > %BAT_FILE%
echo SET mypath=%%~dp0 >> %BAT_FILE%
echo start /B /D "%%mypath%%" /WAIT python main.py >> %BAT_FILE%

:SH_LINUX
echo #!/bin/bash > %SH_FILE%
echo if [ -f /.dockerenv ] ; then >> %SH_FILE%
echo pip3 install -r "$(dirname "$0")"/requirements.txt ^>^> /dev/null >> %SH_FILE%
echo fi >> %SH_FILE%
echo python3 "$(dirname "$0")"/main.py >> %SH_FILE%
GOTO DONE

:CP_DOCKER
copy Dockerfile %BIN_FOLDER%
copy set_umask.sh %BIN_FOLDER%
GOTO DONE

:checkCommand
WHERE %1 >nul 2>nul
IF %ERRORLEVEL% NEQ 0 ECHO %1 required 1>&2 && exit 1

:DONE
38 changes: 38 additions & 0 deletions marketplace/test/command/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

BINARY_NAME=run.sh
BINARY_NAME_WINDOWS=run.bat
BIN_FOLDER=bin

checkCommand () {
if ! command -v "$1" >/dev/null; then
echo "$1 required" >&2;
exit 1;
fi
}

#python-build:
checkCommand python3
checkCommand pip3
mkdir -p $BIN_FOLDER
cp -r src/* $BIN_FOLDER
pip3 install -r $BIN_FOLDER/requirements.txt --user --disable-pip-version-check

#sh_unix:
{
echo "#!/bin/bash"
echo "if [ -f /.dockerenv ] ; then"
echo "pip3 install -r \$(dirname \"\$0\")/requirements.txt --user --disable-pip-version-check >> /dev/null"
echo "fi"
echo "python3 \$(dirname \"\$0\")/main.py"
} >> $BIN_FOLDER/$BINARY_NAME
chmod +x $BIN_FOLDER/$BINARY_NAME

#bat_windows:
{
echo "@ECHO OFF"
echo "python main.py"
} >> $BIN_FOLDER/$BINARY_NAME_WINDOWS

#docker:
cp Dockerfile set_umask.sh $BIN_FOLDER
Loading

0 comments on commit 9e95ef5

Please sign in to comment.