From da86ef2769e9f09532ed09e8ebfdeb115f917200 Mon Sep 17 00:00:00 2001 From: Ando Date: Thu, 16 Nov 2023 20:37:24 +0300 Subject: [PATCH 1/6] feat: create a github action to check install script and deno --- .github/workflows/install.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/install.yml diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml new file mode 100644 index 0000000..b49b447 --- /dev/null +++ b/.github/workflows/install.yml @@ -0,0 +1,20 @@ +name: pull-request + +on: push + +jobs: + install-compiled: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: | + chmod +x scripts/install.sh + ./scripts/install.sh + - run: | + if command -v deno &>/dev/null; then + echo "Deno is installed." + deno --version + else + echo "Deno installation failed." + exit 1 + fi From be8384b570f188635b03e83c8090c680ea302488 Mon Sep 17 00:00:00 2001 From: Ando Date: Thu, 16 Nov 2023 21:00:27 +0300 Subject: [PATCH 2/6] feat: export path and deno install on install script --- scripts/install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install.sh b/scripts/install.sh index 0a00475..a240d33 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -31,6 +31,9 @@ if ! is_deno_installed; then install_deno fi +export DENO_INSTALL="/home/runner/.deno" +export PATH="$DENO_INSTALL/bin:$PATH" + # Build the Deno project deno compile -A --output cocli https://deno.land/x/cocli/cli.ts From 026b2b656aa7050d3d1b5dce35118b1a4486217f Mon Sep 17 00:00:00 2001 From: Ando Date: Thu, 16 Nov 2023 21:03:47 +0300 Subject: [PATCH 3/6] feat: update check deno is installed on install github action --- .github/workflows/install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index b49b447..2ff467f 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -11,7 +11,7 @@ jobs: chmod +x scripts/install.sh ./scripts/install.sh - run: | - if command -v deno &>/dev/null; then + if command -v deno; then echo "Deno is installed." deno --version else From dfce4c61dff95743c92b4b9319676328d08692de Mon Sep 17 00:00:00 2001 From: Ando Date: Fri, 17 Nov 2023 20:16:31 +0300 Subject: [PATCH 4/6] feat: add run script to check if executable is installed globally --- .github/workflows/install.yml | 10 +++++++++- scripts/install.sh | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 2ff467f..746b0ea 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -11,10 +11,18 @@ jobs: chmod +x scripts/install.sh ./scripts/install.sh - run: | - if command -v deno; then + if command -v deno &>/dev/null; then echo "Deno is installed." deno --version else echo "Deno installation failed." exit 1 fi + - run: | + if command -v cocli &>/dev/null; then + echo "Cocli is installed globally." + cocli --version + else + echo "Cocli installation globally failed." + exit 1 + fi diff --git a/scripts/install.sh b/scripts/install.sh index a240d33..9c2bc61 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -35,7 +35,9 @@ export DENO_INSTALL="/home/runner/.deno" export PATH="$DENO_INSTALL/bin:$PATH" # Build the Deno project +echo "Compiling Cocli...📦" deno compile -A --output cocli https://deno.land/x/cocli/cli.ts +echo "Compilation finished..✅" if [[ -f cocli ]]; then echo "Executable compiled successfully.📦" From 7d39859780cf0e96184c617ad0aa16dee14b5f8d Mon Sep 17 00:00:00 2001 From: Ando Date: Fri, 17 Nov 2023 20:27:29 +0300 Subject: [PATCH 5/6] feat: add setup deno in gh install workflow --- .github/workflows/install.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 746b0ea..f7ba1a3 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -7,6 +7,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - uses: denolib/setup-deno@v2 + with: + deno-version: 1.37.1 - run: | chmod +x scripts/install.sh ./scripts/install.sh From 025ae7c77baf4d1989698dc7b5f6044af066ee49 Mon Sep 17 00:00:00 2001 From: Ando Date: Fri, 17 Nov 2023 20:45:40 +0300 Subject: [PATCH 6/6] feat: add version flag show cli version --- cli.ts | 9 ++++++++- deno.json | 4 ++-- deno.lock | 11 +++++++++++ deps.ts | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/cli.ts b/cli.ts index b3d7a14..fe8a963 100644 --- a/cli.ts +++ b/cli.ts @@ -1,4 +1,4 @@ -import { green, yellow } from './deps.ts' +import { green, yellow, parseFlags } from './deps.ts' import { isGitRepository, isTreeClean, @@ -16,6 +16,13 @@ import { // Learn more at https://deno.land/manual/examples/module_metadata#concepts if (import.meta.main) { + const { flags } = parseFlags(Deno.args) + + if (flags.version) { + console.log('v0.1.0') + Deno.exit(1) + } + console.log(green('-'.repeat(50))) console.log() console.log('Cocli - v0.1.0 🌱🚀') diff --git a/deno.json b/deno.json index 12b2802..a084cbf 100644 --- a/deno.json +++ b/deno.json @@ -1,7 +1,7 @@ { "importMap": "./import_map.json", "tasks": { - "start": "deno run --allow-all --unstable --import-map=import_map.json cli.ts", - "dev": "deno run --watch cli.ts" + "start": "deno run -A cli.ts", + "dev": "deno run -A --watch cli.ts" } } diff --git a/deno.lock b/deno.lock index a8d27cc..ba9c374 100644 --- a/deno.lock +++ b/deno.lock @@ -21,6 +21,17 @@ "https://deno.land/x/cliffy@v1.0.0-rc.3/ansi/cursor_position.ts": "caa008d29f7a904908bda514f9839bfbb7a93f2d5f5580501675b646d26a87ff", "https://deno.land/x/cliffy@v1.0.0-rc.3/ansi/deps.ts": "f48ae5d066684793f4a203524db2a9fd61f514527934b458006f3e57363c0215", "https://deno.land/x/cliffy@v1.0.0-rc.3/ansi/tty.ts": "155aacdcb7dc00f3f95352616a2415c622ffb88db51c5934e5d2e8341eab010b", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/_errors.ts": "f1fbb6bfa009e7950508c9d491cfb4a5551027d9f453389606adb3f2327d048f", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/_utils.ts": "340d3ecab43cde9489187e1f176504d2c58485df6652d1cdd907c0e9c3ce4cc2", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/_validate_flags.ts": "e60b9038c0136ab7e6bd1baf0e993a07bf23f18afbfb6e12c59adf665a622957", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/deprecated.ts": "a72a35de3cc7314e5ebea605ca23d08385b218ef171c32a3f135fb4318b08126", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/flags.ts": "3e62c4a9756b5705aada29e7e94847001356b3a83cd18ad56f4207387a71cf51", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/mod.ts": "a96262acdb33089b4ff2ce50a95858c86e3b2d146f397d0f357660e70fbff28f", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types.ts": "9e2f75edff2217d972fc711a21676a59dfd88378da2f1ace440ea84c07db1dcc", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/boolean.ts": "4c026dd66ec9c5436860dc6d0241427bdb8d8e07337ad71b33c08193428a2236", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/integer.ts": "b60d4d590f309ddddf066782d43e4dc3799f0e7d08e5ede7dc62a5ee94b9a6d9", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/number.ts": "610936e2d29de7c8c304b65489a75ebae17b005c6122c24e791fbed12444d51e", + "https://deno.land/x/cliffy@v1.0.0-rc.3/flags/types/string.ts": "e89b6a5ce322f65a894edecdc48b44956ec246a1d881f03e97bbda90dd8638c5", "https://deno.land/x/cliffy@v1.0.0-rc.3/keycode/_key_codes.ts": "917f0a2da0dbace08cf29bcfdaaa2257da9fe7e705fff8867d86ed69dfb08cfe", "https://deno.land/x/cliffy@v1.0.0-rc.3/keycode/key_code.ts": "730fa675ca12fc2a99ba718aa8dbebb1f2c89afd47484e30ef3cb705ddfca367", "https://deno.land/x/cliffy@v1.0.0-rc.3/prompt/_figures.ts": "e22413ddd51bb271b6b861a058742e83aaa3f62c14e8162cb73ae6f047062f51", diff --git a/deps.ts b/deps.ts index 394252b..ab8387f 100644 --- a/deps.ts +++ b/deps.ts @@ -3,6 +3,7 @@ export { Input, Confirm, } from 'https://deno.land/x/cliffy@v1.0.0-rc.3/prompt/mod.ts' +export { parseFlags } from 'https://deno.land/x/cliffy@v1.0.0-rc.3/flags/mod.ts' export { green, dim,