This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* set inicial files for typescript template Signed-off-by: Bruno N. Melo <[email protected]> * fix on build and makefile Signed-off-by: Bruno N. Melo <[email protected]> * update and fix imports Signed-off-by: Bruno N. Melo <[email protected]> * adding new line on end of tsconfig Signed-off-by: Bruno N. Melo <[email protected]> * fix tsconfig Pretty format to pass on test Signed-off-by: Bruno N. Melo <[email protected]> * Fixing pretty Signed-off-by: Bruno N. Melo <[email protected]> * update on hello-world formula to the new template Signed-off-by: Bruno N. Melo <[email protected]> * fix some bugs Signed-off-by: Bruno N. Melo <[email protected]> * simplifying template removing interface Signed-off-by: Bruno N. Melo <[email protected]> * rename variables Signed-off-by: Bruno N. Melo <[email protected]>
- Loading branch information
1 parent
1929c42
commit f3ac1e7
Showing
11 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM cimg/node:14.0 | ||
|
||
USER root | ||
|
||
RUN curl -fsSL https://commons-repo.ritchiecli.io/install.sh | bash | ||
|
||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Make Run Node | ||
BINARY_NAME_UNIX=run.sh | ||
BINARY_NAME_WINDOWS=run.bat | ||
BIN_FOLDER=bin | ||
|
||
build: node-build docker | ||
|
||
node-build: | ||
mkdir -p $(BIN_FOLDER) | ||
cp -r src/* $(BIN_FOLDER) | ||
npm install --silent --no-progress --prefix $(BIN_FOLDER) | ||
npm run build --silent --prefix $(BIN_FOLDER) | ||
echo '#!/bin/sh' > $(BIN_FOLDER)/$(BINARY_NAME_UNIX) | ||
echo 'node "$$(dirname "$$0")"/dist/index.js' >> $(BIN_FOLDER)/$(BINARY_NAME_UNIX) | ||
echo 'node /dist/index.js' > $(BIN_FOLDER)/$(BINARY_NAME_WINDOWS) | ||
chmod +x $(BIN_FOLDER)/$(BINARY_NAME_UNIX) | ||
|
||
docker: | ||
cp Dockerfile set_umask.sh $(BIN_FOLDER) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Ritchie Formula | ||
|
||
## Command | ||
|
||
```bash | ||
#rit-replace{formulaCmd} | ||
``` | ||
|
||
## Description | ||
|
||
Formula description |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
:: Node parameters | ||
echo off | ||
SETLOCAL | ||
SET BIN_FOLDER=bin | ||
SET BAT_FILE=%BIN_FOLDER%\run.bat | ||
SET SH_FILE=%BIN_FOLDER%\run.sh | ||
:build | ||
mkdir %BIN_FOLDER% | ||
xcopy /E /I src %BIN_FOLDER% | ||
cd %BIN_FOLDER% | ||
call npm install --silent | ||
call npm run build --silent | ||
cd .. | ||
call :BAT_WINDOWS | ||
call :SH_LINUX | ||
call :CP_DOCKER | ||
GOTO DONE | ||
|
||
:BAT_WINDOWS | ||
echo @ECHO OFF > %BAT_FILE% | ||
echo SET mypath=%%~dp0 >> %BAT_FILE% | ||
echo start /B /WAIT node %%mypath:~0,-1%%/dist/index.js >> %BAT_FILE% | ||
|
||
:SH_LINUX | ||
echo node "$(dirname "$0")"/dist/index.js > %SH_FILE% | ||
GOTO DONE | ||
|
||
:CP_DOCKER | ||
copy Dockerfile %BIN_FOLDER% | ||
copy set_umask.sh %BIN_FOLDER% | ||
GOTO DONE | ||
|
||
:DONE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"dockerImageBuilder": "cimg/node:14.0", | ||
"inputs": [ | ||
{ | ||
"cache": { | ||
"active": true, | ||
"newLabel": "Type new value. ", | ||
"qty": 3 | ||
}, | ||
"label": "Type your name: ", | ||
"name": "input_text", | ||
"type": "text" | ||
}, | ||
{ | ||
"default": "false", | ||
"items": [ | ||
"false", | ||
"true" | ||
], | ||
"label": "Have you ever used Ritchie? ", | ||
"name": "input_boolean", | ||
"type": "bool" | ||
}, | ||
{ | ||
"default": "everything", | ||
"items": [ | ||
"daily tasks", | ||
"workflows", | ||
"toils", | ||
"everything" | ||
], | ||
"label": "What do you want to automate? ", | ||
"name": "input_list", | ||
"type": "text" | ||
}, | ||
{ | ||
"label": "Tell us a secret: ", | ||
"name": "input_password", | ||
"type": "password" | ||
} | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
templates/create_formula/languages/typescript/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"execution": [ | ||
"local", | ||
"docker" | ||
], | ||
"os": { | ||
"deps": [], | ||
"support": [ | ||
"windows", | ||
"mac", | ||
"linux" | ||
] | ||
}, | ||
"tags": [ | ||
"#rit-replace{formulaTags}" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
umask 0011 | ||
$1 |
20 changes: 20 additions & 0 deletions
20
templates/create_formula/languages/typescript/src/formula/Formula.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as chalk from 'chalk' | ||
|
||
function run(inputText: string, inputBoolean: boolean, inputList: string, inputPassword: string) { | ||
console.log('Hello World!') | ||
|
||
console.log(chalk.green(`My name is ${inputText}.`)) | ||
|
||
if (inputBoolean) { | ||
console.log(chalk.blue('I’ve already created formulas using Ritchie.')) | ||
} else { | ||
console.log(chalk.red('I’m excited in creating new formulas using Ritchie.')) | ||
} | ||
|
||
console.log(chalk.yellow(`Today, I want to automate ${inputList}.`)) | ||
|
||
console.log(chalk.cyan(`My secret is ${inputPassword}.`)) | ||
} | ||
|
||
const Formula = run | ||
export default Formula |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import run from './formula/Formula' | ||
|
||
const inputText: string = process.env.INPUT_TEXT | ||
const inputBoolean: boolean = JSON.parse(process.env.INPUT_BOOLEAN.toLowerCase()) | ||
const inputList: string = process.env.INPUT_LIST | ||
const inputPassword: string = process.env.INPUT_PASSWORD | ||
|
||
run(inputText, inputBoolean, inputList, inputPassword) |
15 changes: 15 additions & 0 deletions
15
templates/create_formula/languages/typescript/src/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"dependencies": { | ||
"chalk": "^4.1.0", | ||
"typescript": "^3.1.6" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14.11.2" | ||
}, | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"version": "1.0.0" | ||
} |
17 changes: 17 additions & 0 deletions
17
templates/create_formula/languages/typescript/src/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "dist", | ||
"sourceMap": true, | ||
"target": "es6", | ||
"types": [ | ||
"node" | ||
] | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
], | ||
"include": [ | ||
"./**/*.ts" | ||
] | ||
} |