From 746a8e767b36d9270f66f0d8d710767141990c46 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Wed, 8 Nov 2023 05:43:10 +0000 Subject: [PATCH] feat: handle pipeline arguments --- deno.lock | 19 +++++++++++++++++++ deps.ts | 8 +++++--- src/dagger/runner.ts | 16 +++++++++++++++- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/deno.lock b/deno.lock index 8e5412a..c01f868 100644 --- a/deno.lock +++ b/deno.lock @@ -36,6 +36,8 @@ "https://cdn.jsdelivr.net/gh/tsirysndr/tar@v0.1.1/deps.ts": "096395daebc7ed8a18f0484e4ffcc3a7f70e50946735f7df9611a7fcfd8272cc", "https://cdn.jsdelivr.net/gh/tsirysndr/tar@v0.1.1/mod.ts": "e269d71c72ae68e82c1960e5db2a0c7419c97c9683ef717de0ab75d90f364713", "https://cdn.jsdelivr.net/gh/tsirysndr/tar@v0.1.1/src/tar.ts": "9b02eaaa784b225ad7a23d2769cd492adf113ea7c11c02e3646849e98f4ae43b", + "https://cdn.skypack.dev/-/lodash@v4.17.21-K6GEbP02mWFnLA45zAmi/dist=es2019,mode=imports/optimized/lodash.js": "10c4df47937ffc78548d136dd535a021df5f57182a653260d715c0690dd22978", + "https://cdn.skypack.dev/lodash": "8280de0b3efd87f06ea0eb330d15b8de32c059556023b8c6524e9eb9e4844dc0", "https://deno.land/std@0.129.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74", "https://deno.land/std@0.129.0/_util/os.ts": "49b92edea1e82ba295ec946de8ffd956ed123e2948d9bd1d3e901b04e4307617", "https://deno.land/std@0.129.0/archive/tar.ts": "35ea1baddec7988cc4034765a2cee7613bc8074bd40940d3f5e98f63070a716a", @@ -154,6 +156,9 @@ "https://deno.land/std@0.203.0/path/to_file_url.ts": "00e6322373dd51ad109956b775e4e72e5f9fa68ce2c6b04e4af2a6eed3825d31", "https://deno.land/std@0.203.0/path/to_namespaced_path.ts": "1b1db3055c343ab389901adfbda34e82b7386bcd1c744d54f9c1496ee0fd0c3d", "https://deno.land/std@0.203.0/path/win32.ts": "8b3f80ef7a462511d5e8020ff490edcaa0a0d118f1b1e9da50e2916bdd73f9dd", + "https://deno.land/std@0.205.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", + "https://deno.land/std@0.205.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", + "https://deno.land/std@0.205.0/flags/mod.ts": "0948466fc437f017f00c0b972a422b3dc3317a790bcf326429d23182977eaf9f", "https://deno.land/std@0.52.0/fmt/colors.ts": "ec9d653672a9a3c7b6eafe53c5bc797364a2db2dcf766ab649c1155fea7a80b2", "https://deno.land/x/crc32@v0.2.0/mod.ts": "de7a3fa2d4ef24b96fc21e1cc4d2d65d1d2b1dcea92f63960e3e11bfa82df0fa", "https://deno.land/x/fluent_aws_codepipeline@v0.2.3/mod.ts": "79cc758901d20a3573d7e3cc2db9f0a5fe56833f4d9befcedc072b94d542eec7", @@ -197,6 +202,7 @@ "https://deno.land/x/zod@v3.22.1/mod.ts": "64e55237cb4410e17d968cd08975566059f27638ebb0b86048031b987ba251c4", "https://deno.land/x/zod@v3.22.1/types.ts": "4edc1823385f446532c8c9f676d84550c6dc54b17135e34508576647d9612d0e", "https://esm.sh/@dagger.io/dagger@0.8.4": "053a78de7a401ac4e2604e77a5521a45fbd192c1cfce05f413407dd4cc88f184", + "https://esm.sh/@dagger.io/dagger@0.8.8": "615a37f0edf04b25a6efefe7ea8c4cb0f801830b5dbe0a57164919e16a3ef6e6", "https://esm.sh/graphql-tag@2.12.6": "6e93f81d26bddf63270317b4fce53a03747ec5322a26e5b78fb0abd098a1f6ea", "https://esm.sh/nanoid@4.0.2": "51031602a4d76c7dd62da9439016cdfd6d1121101e489925e4423d88bf8fa0e1", "https://esm.sh/stringify-tree@1.1.1": "4d0252ece34f52f7f312a6d270ed2714e57e1610f7a7f71c2fdceceb948e87b2", @@ -209,18 +215,22 @@ "https://esm.sh/v131/yaml@2.3.1": "1fe2490feb3d9c6d2c71c64dbdbed90acd4164b00628b3c68a311b6731ca38b5", "https://esm.sh/v131/yaml@2.3.1/denonext/yaml.mjs": "71f677b4bfc69271af9d98db5194e354f9a1863955e208e26d32a9ef78bd89f5", "https://esm.sh/v133/@dagger.io/dagger@0.8.4/denonext/dagger.mjs": "27877de9a0ada44a87ada6c4afde2f07ebfa39501e0eb983a22b5e530b548391", + "https://esm.sh/v133/@dagger.io/dagger@0.8.8/denonext/dagger.mjs": "c4bd80a72add877450ef029ab71091f862f02af8ebc7c4c7f5bb6aab1854095f", "https://esm.sh/v133/adm-zip@0.5.10/denonext/adm-zip.mjs": "9ccca01e6dea77f3c20386125c0eea2a811aa0f9b73243517b747264df8af046", "https://esm.sh/v133/chownr@2.0.0/denonext/chownr.mjs": "d7282b2612a9f13c62084c76fc72cdfb20503bccce959178b77b6def14d3ffd2", "https://esm.sh/v133/cross-fetch@3.1.8/denonext/cross-fetch.mjs": "8fba9e7c3fbaf0d2168beb63ce0cd21b5bfbfbd77e2fcbf8d957d533a71222f6", "https://esm.sh/v133/cross-spawn@7.0.3/denonext/cross-spawn.mjs": "0a698bfa213c75e5d20176a3f2f65870d31cd26745451d5f56c58e08df138118", "https://esm.sh/v133/env-paths@3.0.0/denonext/env-paths.mjs": "77984a05eb16450087f25060a070ed500ec546719d471143e16d976ca73ca956", "https://esm.sh/v133/execa@7.2.0/denonext/execa.mjs": "ffc76bbf7aef8ac5ce352310b9fefe0595eec43f2f3cf72cdd9e7bad26ce2cb1", + "https://esm.sh/v133/execa@8.0.1/denonext/execa.mjs": "775e244075c8f23a4caf786116722314a5f2839ee135dba7fde444fc67d5e643", "https://esm.sh/v133/fs-minipass@2.1.0/denonext/fs-minipass.mjs": "de8b7228c151f04326a852ce57655d36bf9171f8efcd212e34ac8bce3fbd84a0", "https://esm.sh/v133/get-stream@6.0.1/denonext/get-stream.mjs": "40659bc61ff2e49a7acf20f46d53c9b09b6d594f15bce414257f377f6f3934a7", + "https://esm.sh/v133/get-stream@8.0.1/denonext/get-stream.mjs": "b8ab640bf2638c1ae704a217b79e0a56e7a1f97bb48bbe40d723d5ea87eb0ecb", "https://esm.sh/v133/graphql-request@6.1.0/denonext/graphql-request.mjs": "7206b27d14333f19f8d2aa3615a81f9e3035f4d33b7a9edff44f990e69fe1964", "https://esm.sh/v133/graphql-tag@2.12.6/denonext/graphql-tag.mjs": "af56d5f8b96e688f433ccca87d8a2bfcf171686e7f7a3b27cde61df816ad8472", "https://esm.sh/v133/graphql@16.8.1/denonext/graphql.mjs": "585b84022623b931e27a7a8134cd24ec50b33ea12fd18b43254527628a0fddac", "https://esm.sh/v133/human-signals@4.3.1/denonext/human-signals.mjs": "3889110cedd907804443d018cffe0a1d892d5e7467661376caf967feff55cbe9", + "https://esm.sh/v133/human-signals@5.0.0/denonext/human-signals.mjs": "8d8663d92280b1ed15bb1b1a0a79601e17f6b165335e85f94c40e56129542077", "https://esm.sh/v133/is-stream@3.0.0/denonext/is-stream.mjs": "5c8b65f2fa051c4b18e88bbae11dac8bba9caf57752577d69bcea86d1f05c5b7", "https://esm.sh/v133/isexe@2.0.0/denonext/isexe.mjs": "4675d9d53a332f096efd344cb1418dbda8e6f2effc8a5c81edd43cdd56636be7", "https://esm.sh/v133/lodash.flatten@4.4.0/denonext/lodash.flatten.mjs": "8e86ab607deea15cc3c1acfb5eae278ecbc5b80f24167b4e8f4c56df3278cd55", @@ -241,6 +251,7 @@ "https://esm.sh/v133/shebang-command@2.0.0/denonext/shebang-command.mjs": "23d8e6099e8d3927b5ea0e396d3da92e082dfa32f27d36df9e892a8653b08437", "https://esm.sh/v133/shebang-regex@3.0.0/denonext/shebang-regex.mjs": "03983ba59dd2cba9402935e21b46d05f5249364cba9f5757aef23c6c2fea65b9", "https://esm.sh/v133/signal-exit@3.0.7/denonext/signal-exit.mjs": "bf418caffe54af9f76da6c7a4998b093dd95740016482c3ababa83da7fb1bb6c", + "https://esm.sh/v133/signal-exit@4.1.0/denonext/signal-exit.mjs": "c450b9024df3b59ded71e7b52aada1ac4b3856aad93e9d64bbc6ea3cdd181824", "https://esm.sh/v133/stringify-tree@1.1.1/denonext/stringify-tree.mjs": "7640f153ff571180467c1087934154aa2a96acba9e17d5782daeb6e1f6b45759", "https://esm.sh/v133/strip-final-newline@3.0.0/denonext/strip-final-newline.mjs": "03d9be4e8a249d63cbbddeb2fb675a1bbbcb335283e604d4ce56c88c90e6f102", "https://esm.sh/v133/tar@6.2.0/denonext/tar.mjs": "e13b28512d8a017442db9665e2c4bf7f134c1b74deb96ba5fd07e5ec6c905617", @@ -249,8 +260,16 @@ "https://esm.sh/v133/yallist@4.0.0/denonext/yallist.mjs": "61f180d807dda50bac17028eda05d5722a3fecef6e98a9064e2353ea6864fd82", "https://esm.sh/v133/yaml@2.3.1/denonext/yaml.mjs": "71f677b4bfc69271af9d98db5194e354f9a1863955e208e26d32a9ef78bd89f5", "https://esm.sh/yaml@v2.3.1": "1eebb55f799726dfa0698314b3ba178bc478cba64b31c8309284899c96f8ff8f", + "https://nix.fluentci.io/v0.5.2/deps.ts": "6ccc8510c72998a52c24bc02c848b669413b5ef1d15dccd7e03a25dd0e408564", + "https://nix.fluentci.io/v0.5.2/src/dagger/steps.ts": "b766f4fa9624a032e7af884a5ca47bc666a529c4a472d38b74b55ca0d63cf81d", "https://nix.fluentci.io/zenith/deps.ts": "a8fd3aa32faea5de2779cc6494471b4fd9588f039d199ff1a1ff1b00343aef26", "https://nix.fluentci.io/zenith/src/dagger/steps.ts": "b766f4fa9624a032e7af884a5ca47bc666a529c4a472d38b74b55ca0d63cf81d", + "https://sdk.fluentci.io/v0.2.0/deps.ts": "20dd191afaf88662b82c2a42164afe6d06f2e79942f40ce07aa0972719fc858f", + "https://sdk.fluentci.io/v0.2.0/mod.ts": "261ba81a4728f5def4e327a5cd80664ea8449515a2f4eea5f3f416acae39a1fa", + "https://sdk.fluentci.io/v0.2.0/src/client.ts": "d350d4f59763e32a9b35f3f06f0b1058e5c8e5a3824e6d096cdaf3fc4332dcf6", + "https://sdk.fluentci.io/v0.2.0/src/connect.ts": "4aff111c403cf78672384a10214a9885e08319dde579ec458f98a7bb04874101", + "https://sdk.fluentci.io/v0.2.0/src/context.ts": "2939ff58d0a79d7377d5553e725c9a2110a0013035a5a57abe9a9a5da975c4ce", + "https://sdk.fluentci.io/v0.2.0/src/utils.ts": "5dcd6d83553930502069d067ff42bc44698e22c23426fdb78630c4b39769d308", "https://sdk.fluentci.io/z1/deps.ts": "1b036b7614a602b11e062a6911f26a6e2ac4e470cc74ac230125afd466cc77ea", "https://sdk.fluentci.io/z1/mod.ts": "261ba81a4728f5def4e327a5cd80664ea8449515a2f4eea5f3f416acae39a1fa", "https://sdk.fluentci.io/z1/src/client.ts": "d350d4f59763e32a9b35f3f06f0b1058e5c8e5a3824e6d096cdaf3fc4332dcf6", diff --git a/deps.ts b/deps.ts index 4a9e5f6..f7a430e 100644 --- a/deps.ts +++ b/deps.ts @@ -1,10 +1,10 @@ export { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts"; -import Client from "https://sdk.fluentci.io/z1/mod.ts"; +import Client from "https://sdk.fluentci.io/v0.2.0/mod.ts"; export default Client; -export { connect, uploadContext } from "https://sdk.fluentci.io/z1/mod.ts"; +export { connect, uploadContext } from "https://sdk.fluentci.io/v0.2.0/mod.ts"; export { brightGreen } from "https://deno.land/std@0.191.0/fmt/colors.ts"; -export { withDevbox } from "https://nix.fluentci.io/zenith/src/dagger/steps.ts"; +export { withDevbox } from "https://nix.fluentci.io/v0.5.2/src/dagger/steps.ts"; export { stringifyTree } from "https://esm.sh/stringify-tree@1.1.1"; import gql from "https://esm.sh/graphql-tag@2.12.6"; export { gql }; @@ -21,6 +21,8 @@ export { join, resolve, } from "https://deno.land/std@0.203.0/path/mod.ts"; +export { parse } from "https://deno.land/std@0.205.0/flags/mod.ts"; +export { snakeCase, camelCase } from "https://cdn.skypack.dev/lodash"; export * as FluentGitlabCI from "https://deno.land/x/fluent_gitlab_ci@v0.4.2/mod.ts"; export * as FluentGithubActions from "https://deno.land/x/fluent_github_actions@v0.2.1/mod.ts"; diff --git a/src/dagger/runner.ts b/src/dagger/runner.ts index ce5e3a5..59f82f5 100644 --- a/src/dagger/runner.ts +++ b/src/dagger/runner.ts @@ -1,3 +1,17 @@ import pipeline from "./pipeline.ts"; +import { parse, camelCase, snakeCase } from "../../deps.ts"; -await pipeline(".", Deno.args); +const args = parse(Deno.args.map((x) => x.split(" ")).flat()); + +if (!Array.isArray(Deno.args)) { + for (const param of Object.keys(args) + .filter((x) => x !== "_") + .map((x) => snakeCase(x).toUpperCase())) { + Deno.env.set(param, args[camelCase(param)]); + } +} + +await pipeline( + ".", + Array.isArray(Deno.args) ? Deno.args : (args._ as string[]) +);