From dbbea91ffad20c7d5cd3de0ad080ced3c9cbf69a Mon Sep 17 00:00:00 2001 From: Piotr Date: Wed, 24 May 2023 08:52:11 +0000 Subject: [PATCH 1/3] hello world writen in ts --- typescript/hello-world-ts/README.md | 24 ++++++++++++++++++++++++ typescript/hello-world-ts/index.ts | 15 +++++++++++++++ typescript/hello-world-ts/package.json | 23 +++++++++++++++++++++++ typescript/hello-world-ts/tsconfig.json | 12 ++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 typescript/hello-world-ts/README.md create mode 100644 typescript/hello-world-ts/index.ts create mode 100644 typescript/hello-world-ts/package.json create mode 100644 typescript/hello-world-ts/tsconfig.json diff --git a/typescript/hello-world-ts/README.md b/typescript/hello-world-ts/README.md new file mode 100644 index 0000000..c86953b --- /dev/null +++ b/typescript/hello-world-ts/README.md @@ -0,0 +1,24 @@ +# Hello world ts + +Simple sequence that outputs "Hello world" written in typescript + +## Running + +Open the terminal and run the following commands: + +```bash +# install dependencies +npm install + +# transpile TS->JS to dist/ +npm run build + +# make a compressed package with Sequence +si seq pack dist + +# send Sequence to transform hub, this will output Sequence ID +si seq send dist.tar.gz + +# start a Sequence +si seq start - +``` diff --git a/typescript/hello-world-ts/index.ts b/typescript/hello-world-ts/index.ts new file mode 100644 index 0000000..ef2101b --- /dev/null +++ b/typescript/hello-world-ts/index.ts @@ -0,0 +1,15 @@ +import { PassThrough } from "stream"; +import { ReadableApp } from "@scramjet/types"; + +const app:ReadableApp = async function(_input) { + // create a clean output stream + const out = new PassThrough({ encoding: "utf-8" }); + + // write some data to the output stream + out.write("Hello World!"); + + // return the output stream so it can be consumed (e.g. by CLI client) + return out; +}; + +export default app; diff --git a/typescript/hello-world-ts/package.json b/typescript/hello-world-ts/package.json new file mode 100644 index 0000000..3a06b4c --- /dev/null +++ b/typescript/hello-world-ts/package.json @@ -0,0 +1,23 @@ +{ + "name": "hello-world-ts", + "version": "1.0.0", + "description": "Simple Sequence that prints out 'Hello World!' to the Instance output.", + "main": "index.js", + + "scripts": { + "build": "tsc -p tsconfig.json", + "postbuild": "cp -r package.json dist/ && (cd dist && npm i --omit=dev)", + "clean": "rm -rf ./dist .bic_cache" +}, + "keywords": [ + "easy" + ], + "engines": { + "node": ">=14" + }, + "author": "piotrek6641", + "license": "ISC", + "devDependencies": { + "@scramjet/types": "^0.33.5" + } +} diff --git a/typescript/hello-world-ts/tsconfig.json b/typescript/hello-world-ts/tsconfig.json new file mode 100644 index 0000000..6c5b594 --- /dev/null +++ b/typescript/hello-world-ts/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "lib": [ "ESNext" ], + "target": "ESNext", + "module": "CommonJS", + "outDir": "./dist", + "esModuleInterop": true, + "skipLibCheck": true, + "resolveJsonModule": true, + } + +} From 62f6569a854ee64173a847894160d8d043493a79 Mon Sep 17 00:00:00 2001 From: Patryk Falba Date: Wed, 24 May 2023 11:01:32 +0200 Subject: [PATCH 2/3] Apply suggestions from code review --- typescript/hello-world-ts/index.ts | 2 +- typescript/hello-world-ts/package.json | 3 +-- typescript/hello-world-ts/tsconfig.json | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/typescript/hello-world-ts/index.ts b/typescript/hello-world-ts/index.ts index ef2101b..dba9950 100644 --- a/typescript/hello-world-ts/index.ts +++ b/typescript/hello-world-ts/index.ts @@ -1,7 +1,7 @@ import { PassThrough } from "stream"; import { ReadableApp } from "@scramjet/types"; -const app:ReadableApp = async function(_input) { +const app: ReadableApp = async function(_input) { // create a clean output stream const out = new PassThrough({ encoding: "utf-8" }); diff --git a/typescript/hello-world-ts/package.json b/typescript/hello-world-ts/package.json index 3a06b4c..49012a1 100644 --- a/typescript/hello-world-ts/package.json +++ b/typescript/hello-world-ts/package.json @@ -3,12 +3,11 @@ "version": "1.0.0", "description": "Simple Sequence that prints out 'Hello World!' to the Instance output.", "main": "index.js", - "scripts": { "build": "tsc -p tsconfig.json", "postbuild": "cp -r package.json dist/ && (cd dist && npm i --omit=dev)", "clean": "rm -rf ./dist .bic_cache" -}, + }, "keywords": [ "easy" ], diff --git a/typescript/hello-world-ts/tsconfig.json b/typescript/hello-world-ts/tsconfig.json index 6c5b594..4f0fb38 100644 --- a/typescript/hello-world-ts/tsconfig.json +++ b/typescript/hello-world-ts/tsconfig.json @@ -8,5 +8,4 @@ "skipLibCheck": true, "resolveJsonModule": true, } - } From b08405d650e0790a54798838a0a7b4db7a5757c7 Mon Sep 17 00:00:00 2001 From: Piotr Date: Wed, 24 May 2023 09:11:12 +0000 Subject: [PATCH 3/3] necessary dependencies added --- typescript/hello-world-ts/package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/typescript/hello-world-ts/package.json b/typescript/hello-world-ts/package.json index 49012a1..0c330a8 100644 --- a/typescript/hello-world-ts/package.json +++ b/typescript/hello-world-ts/package.json @@ -17,6 +17,10 @@ "author": "piotrek6641", "license": "ISC", "devDependencies": { - "@scramjet/types": "^0.33.5" + "@scramjet/types": "^0.33.5", + "@types/node": "^20.2.3" + }, + "dependencies": { + "typescript": "^5.0.4" } }