From ddb8d9d3a53edbff3fe9e77edd57d5991e03a193 Mon Sep 17 00:00:00 2001 From: Andrii Date: Thu, 28 Dec 2023 22:32:54 +0100 Subject: [PATCH 1/5] Redirect functionality with checks implemented --- cli.ts | 29 +++++ package-lock.json | 302 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 2 + 3 files changed, 324 insertions(+), 9 deletions(-) diff --git a/cli.ts b/cli.ts index e4d35a6..af1ae52 100644 --- a/cli.ts +++ b/cli.ts @@ -16,6 +16,8 @@ import { getApiDefinitions } from "./lib/get-api-definitions" import commandLineUsage from "command-line-usage" import { ContextHelpers } from "./lib/types" import { version } from './package.json'; +import open from "open" +import clipboardy from "clipboardy" const sections = [ { @@ -168,6 +170,33 @@ async function cli(args: ParsedArgs) { logResponse(response) + if (isEqual(selectedCommand, ["connect-webviews", "create"])) { + if (response.data && response.data.connect_webview && response.data.connect_webview.url) { + const url = response.data.connect_webview.url; + + if (process.env.INSIDE_WEB_BROWSER !== '1') { + const { action } = await prompts({ + type: 'select', + name: 'action', + message: 'What do you want to do with the connect webview URL?', + choices: [ + { title: 'Open in browser', value: 'open' }, + { title: 'Copy to clipboard', value: 'copy' }, + ], + }); + + if (action === 'open') { + await open(url); + } else if (action === 'copy') { + clipboardy.writeSync(url); + console.log('URL copied to clipboard!'); + } + } else { + console.log("Running in a web browser. Prompting is skipped."); + } + } + } + if ("action_attempt" in response.data) { const { poll_for_action_attempt } = await prompts({ name: "poll_for_action_attempt", diff --git a/package-lock.json b/package-lock.json index 2a7ed39..d2b5e21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,8 @@ "dependencies": { "@seamapi/http": "^0.12.0", "@seamapi/types": "^1.70.0", + "clipboardy": "^4.0.0", + "open": "^10.0.2", "swagger-parser": "^10.0.3" }, "bin": { @@ -1298,6 +1300,20 @@ "integrity": "sha512-GnElqUSGWvFP1Hxv2FdxLuCDzUcHZ1ac/QrOOpZ18r2RHig+S+JXIOT0YIvrHo4XwqLeurlB6CqYminiCxQIEw==", "dev": true }, + "node_modules/bundle-name": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", + "integrity": "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==", + "dependencies": { + "run-applescript": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/bundle-require": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-4.0.2.tgz", @@ -1403,6 +1419,146 @@ "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", "dev": true }, + "node_modules/clipboardy": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-4.0.0.tgz", + "integrity": "sha512-5mOlNS0mhX0707P2I0aZ2V/cmHUEO/fL7VFLqszkhUsxt7RwnmrInf/eEQKlf5GzvYeHIjT+Ov1HRfNmymlG0w==", + "dependencies": { + "execa": "^8.0.1", + "is-wsl": "^3.1.0", + "is64bit": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/clipboardy/node_modules/execa": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": ">=16.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/clipboardy/node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/clipboardy/node_modules/human-signals": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "engines": { + "node": ">=16.17.0" + } + }, + "node_modules/clipboardy/node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/clipboardy/node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/clipboardy/node_modules/npm-run-path": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.2.0.tgz", + "integrity": "sha512-W4/tgAXFqFA0iL7fk0+uQ3g7wkL8xJmx3XdK0VGb4cHW//eZTtKGvFBBoRKVTpY7n6ze4NL9ly7rgXcHufqXKg==", + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/clipboardy/node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/clipboardy/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/clipboardy/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/clipboardy/node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -1535,7 +1691,6 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -1619,6 +1774,43 @@ "node": ">=4.0.0" } }, + "node_modules/default-browser": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.2.1.tgz", + "integrity": "sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==", + "dependencies": { + "bundle-name": "^4.1.0", + "default-browser-id": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser-id": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.0.tgz", + "integrity": "sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/define-lazy-prop": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", + "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -2155,6 +2347,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2185,6 +2391,23 @@ "node": ">=0.10.0" } }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -2232,6 +2455,34 @@ "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", "dev": true }, + "node_modules/is-wsl": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", + "integrity": "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==", + "dependencies": { + "is-inside-container": "^1.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is64bit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is64bit/-/is64bit-2.0.0.tgz", + "integrity": "sha512-jv+8jaWCl0g2lSBkNSVXdzfBA0npK1HGC2KtWM9FumFRoGS94g3NbCCLVnCYHLjp4GrW2KZeeSTMo5ddtznmGw==", + "dependencies": { + "system-architecture": "^0.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -2241,8 +2492,7 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, "node_modules/joycon": { "version": "3.1.1", @@ -2369,8 +2619,7 @@ "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" }, "node_modules/merge2": { "version": "1.4.1", @@ -2624,6 +2873,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/open": { + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/open/-/open-10.0.2.tgz", + "integrity": "sha512-GnYLdE+E3K8NeSE23N0g67/9q9AXRph5oTUbz6IbIgElPigEnQ2aHuqRge3y0JUr67qoc84xME5kF03fDc3fcA==", + "dependencies": { + "default-browser": "^5.2.1", + "define-lazy-prop": "^3.0.0", + "is-inside-container": "^1.0.0", + "is-wsl": "^3.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/openapi-types": { "version": "12.1.3", "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.3.tgz", @@ -2651,7 +2917,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, "engines": { "node": ">=8" } @@ -3060,6 +3325,17 @@ "fsevents": "~2.3.2" } }, + "node_modules/run-applescript": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.0.0.tgz", + "integrity": "sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A==", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -3108,7 +3384,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -3120,7 +3395,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, "engines": { "node": ">=8" } @@ -3339,6 +3613,17 @@ "node": ">=10" } }, + "node_modules/system-architecture": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/system-architecture/-/system-architecture-0.1.0.tgz", + "integrity": "sha512-ulAk51I9UVUyJgxlv9M6lFot2WP3e7t8Kz9+IS6D4rVba1tR9kON+Ey69f+1R4Q8cd45Lod6a4IcJIxnzGc/zA==", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/table-layout": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-3.0.2.tgz", @@ -4044,7 +4329,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, "dependencies": { "isexe": "^2.0.0" }, diff --git a/package.json b/package.json index d1dcb53..bfd8247 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,8 @@ "dependencies": { "@seamapi/http": "^0.12.0", "@seamapi/types": "^1.70.0", + "clipboardy": "^4.0.0", + "open": "^10.0.2", "swagger-parser": "^10.0.3" } } From 7a46c807ab385555c1b50e92724c90ee2884bb3d Mon Sep 17 00:00:00 2001 From: Andrii Date: Thu, 28 Dec 2023 22:43:24 +0100 Subject: [PATCH 2/5] Requested changes --- cli.ts | 42 +++++++++++++++++++----------------------- package.json | 1 - 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/cli.ts b/cli.ts index af1ae52..4f08635 100644 --- a/cli.ts +++ b/cli.ts @@ -15,9 +15,8 @@ import logResponse from "./lib/util/log-response" import { getApiDefinitions } from "./lib/get-api-definitions" import commandLineUsage from "command-line-usage" import { ContextHelpers } from "./lib/types" -import { version } from './package.json'; +import { version } from "./package.json" import open from "open" -import clipboardy from "clipboardy" const sections = [ { @@ -71,7 +70,7 @@ async function cli(args: ParsedArgs) { console.log(usage) return } - + if ( !config.get(`${getServer()}.pat`) && args._[0] !== "login" && @@ -170,29 +169,26 @@ async function cli(args: ParsedArgs) { logResponse(response) - if (isEqual(selectedCommand, ["connect-webviews", "create"])) { - if (response.data && response.data.connect_webview && response.data.connect_webview.url) { - const url = response.data.connect_webview.url; - - if (process.env.INSIDE_WEB_BROWSER !== '1') { + if (response.data.connect_webview) { + if ( + response.data && + response.data.connect_webview && + response.data.connect_webview.url + ) { + const url = response.data.connect_webview.url + + if (process.env.INSIDE_WEB_BROWSER !== "1") { const { action } = await prompts({ - type: 'select', - name: 'action', - message: 'What do you want to do with the connect webview URL?', - choices: [ - { title: 'Open in browser', value: 'open' }, - { title: 'Copy to clipboard', value: 'copy' }, - ], - }); - - if (action === 'open') { - await open(url); - } else if (action === 'copy') { - clipboardy.writeSync(url); - console.log('URL copied to clipboard!'); + type: "confirm", + name: "action", + message: "Would you like to open the webview in your browser?", + }) + + if (action) { + await open(url) } } else { - console.log("Running in a web browser. Prompting is skipped."); + //TODO: Figure out how to open the webview in the browser } } } diff --git a/package.json b/package.json index 877b7bb..096a147 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ }, "dependencies": { "@seamapi/http": "^0.12.0", - "clipboardy": "^4.0.0", "open": "^10.0.2", "@seamapi/types": "^1.74.0", "swagger-parser": "^10.0.3" From 56a7367321f9f1015ef6ee7c5ad1ac3618631480 Mon Sep 17 00:00:00 2001 From: Mike Wu Date: Wed, 3 Jan 2024 17:58:02 +0900 Subject: [PATCH 3/5] feat: add scripts/install.sh (#51) * feat: add scripts/install.sh * fix missing curl_download --- scripts/install.sh | 445 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 445 insertions(+) create mode 100755 scripts/install.sh diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000..6bb3279 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,445 @@ +#!/usr/bin/env sh + +set -e + +# error codes +# 1 general +# 2 insufficient perms + +DEBUG=0 +CLEAN_EXIT=0 +BINARY_INSTALLED_PATH="" + +tempdir="" +filename="" +sig_filename="" +key_filename="" + +cleanup() { + exit_code=$? + if [ "$exit_code" -ne 0 ] && [ "$CLEAN_EXIT" -ne 1 ]; then + log "$exit_code" + log "ERROR: script failed during execution" + + if [ "$DEBUG" -eq 0 ]; then + log "For more verbose output, re-run this script with the debug flag (./install.sh --debug)" + fi + fi + + if [ -n "$tempdir" ]; then + delete_tempdir + fi + + clean_exit "$exit_code" +} +trap cleanup EXIT +trap cleanup INT + +clean_exit() { + CLEAN_EXIT=1 + exit "$1" +} + +log() { + # print to stderr + >&2 echo "$1" +} + +log_debug() { + if [ "$DEBUG" -eq 1 ]; then + # print to stderr + >&2 echo "DEBUG: $1" + fi +} + +log_warning() { + # print to stderr + >&2 echo "WARNING: $1" +} + +delete_tempdir() { + # log_debug "Removing temp directory" + # rm -rf "$tempdir" + tempdir="" +} + +linux_shell() { + user="$(whoami)" + grep -E "^$user:" < /etc/passwd | cut -f 7 -d ":" | head -1 +} + +macos_shell() { + dscl . -read ~/ UserShell | sed 's/UserShell: //' +} + +# we currently only support Git Bash for Windows with this script +# so the shell will always be /usr/bin/bash +windows_shell() { + echo "/usr/bin/bash" +} + +# exit code +# 0=installed +# 1=path not writable +# 2=path not in PATH +# 3=path not a directory +# 4=path not found +install_binary() { + install_dir="$1" + # defaults to true + require_dir_in_path="$2" + # defaults to false + create_if_not_exist="$3" + + if [ "$require_dir_in_path" != "false" ] && ! is_dir_in_path "$install_dir"; then + return 2 + fi + + if [ "$create_if_not_exist" = "true" ] && [ ! -e "$install_dir" ]; then + log_debug "$install_dir is in PATH but doesn't exist" + log_debug "Creating $install_dir" + mkdir -m 755 "$install_dir" > /dev/null 2>&1 + fi + + if [ ! -e "$install_dir" ]; then + return 4 + fi + + if [ ! -d "$install_dir" ]; then + return 3 + fi + + if ! is_path_writable "$install_dir"; then + return 1 + fi + + log_debug "Moving binary to $install_dir" + mv -f "$filename" "$install_dir" + return 0 +} + +curl_download() { + url="$1" + output_file="$2" + component="$3" + + # allow curl to fail w/o exiting + set +e + headers=$(curl --tlsv1.2 --proto "=https" -w "%{http_code}" --silent --retry 5 -o "$output_file" -LN -D - "$url" 2>&1) + exit_code=$? + set -e + + status_code="$(echo "$headers" | tail -1)" + + if [ "$status_code" -ne 200 ]; then + log_debug "Request failed with http status $status_code" + log_debug "Response headers:" + log_debug "$headers" + fi + + if [ "$exit_code" -ne 0 ]; then + log "ERROR: curl failed with exit code $exit_code" + + if [ "$exit_code" -eq 60 ]; then + log "" + log "Ensure the ca-certificates package is installed for your distribution" + elif [ "$exit_code" -eq 35 ]; then + # A TLS/SSL connect error. The SSL handshake failed. The SSL handshake can fail due to numerous different reasons so the error message may offer some additional clues. Maybe the parties could not agree to a SSL/TLS version, an agreeable cipher suite or similar. + log "" + log "Failed to complete TLS handshake. Please ensure your system's TLS library is up-to-date (OpenSSL, GnuTLS, libressl, etc.)" + fi + clean_exit 1 + fi + + + # this could be >255, so print HTTP status code rather than using as return code + echo "$status_code" +} + +# note: wget does not retry on 5xx +wget_download() { + url="$1" + output_file="$2" + component="$3" + + security_flags="--secure-protocol=TLSv1_2 --https-only" + # determine if using BusyBox wget (bad) or GNU wget (good) + (wget --help 2>&1 | head -1 | grep -iv busybox > /dev/null 2>&1) || security_flags="" + # only print this warning once per script invocation + if [ -z "$security_flags" ] && [ "$component" = "Binary" ]; then + log_debug "Skipping additional security flags that are unsupported by BusyBox wget" + # log to stderr b/c this function's stdout is parsed + log_warning "This system's wget binary is provided by BusyBox. Doppler strongly suggests installing GNU wget, which provides additional security features." + fi + + # allow wget to fail w/o exiting + set +e + # we explicitly disable shellcheck here b/c security_flags isn't parsed properly when quoted + # shellcheck disable=SC2086 + headers=$(wget $security_flags -q -t 5 -S -O "$output_file" "$url" 2>&1) + exit_code=$? + set -e + + status_code="$(echo "$headers" | grep -o -E '^\s*HTTP/[0-9.]+ [0-9]{3}' | tail -1 | grep -o -E '[0-9]{3}')" + # it's possible for this value to be blank, so confirm that it's a valid status code + valid_status_code=0 + if expr "$status_code" : '[0-9][0-9][0-9]$'>/dev/null; then + valid_status_code=1 + fi + + if [ "$exit_code" -ne 0 ]; then + if [ "$valid_status_code" -eq 1 ]; then + # print the code and continue + log_debug "Request failed with http status $status_code" + log_debug "Response headers:" + log_debug "$headers" + else + # exit immediately + log "ERROR: wget failed with exit code $exit_code" + + if [ "$exit_code" -eq 5 ]; then + log "" + log "Ensure the ca-certificates package is installed for your distribution" + fi + clean_exit 1 + fi + fi + + + # this could be >255, so print HTTP status code rather than using as return code + echo "$status_code" +} + +check_http_status() { + status_code="$1" + component="$2" + + if [ "$status_code" -ne 200 ]; then + error="ERROR: $component download failed with status code $status_code." + if [ "$status_code" -ne 404 ]; then + error="${error} Please try again." + fi + + log "" + log "$error" + + if [ "$status_code" -eq 404 ]; then + log "" + log "Please report this issue:" + log "https://github.com/DopplerHQ/cli/issues/new?template=bug_report.md&title=[BUG]%20Unexpected%20404%20using%20CLI%20install%20script" + fi + + clean_exit 1 + fi +} + +is_dir_in_path() { + dir="$1" + # ensure dir is the full path and not a substring of some longer path. + # after performing a regex search, perform another search w/o regex to filter out matches due to special characters in `$dir` + echo "$PATH" | grep -o -E "(^|:)$dir(:|$)" | grep -q -F "$dir" +} + +is_path_writable() { + dir="$1" + test -w "$dir" +} + +# flag parsing +for arg; do + if [ "$arg" = "--debug" ]; then + DEBUG=1 + fi +done + + +# identify OS +os="unknown" +uname_os=$(uname -s) +case "$uname_os" in + Darwin) os="macos" ;; + Linux) os="linux" ;; + FreeBSD) os="freebsd" ;; + OpenBSD) os="openbsd" ;; + NetBSD) os="netbsd" ;; + *MINGW64*) os="win" ;; + *) + log "ERROR: Unsupported OS '$uname_os'" + log "" + log "Please report this issue:" + log "https://github.com/DopplerHQ/cli/issues/new?template=bug_report.md&title=[BUG]%20Unsupported%20OS" + clean_exit 1 + ;; +esac + +log_debug "Detected OS '$os'" + +# identify arch +arch="unknown" +uname_machine=$(uname -m) +if [ "$uname_machine" = "i386" ] || [ "$uname_machine" = "i686" ]; then + arch="i386" +elif [ "$uname_machine" = "amd64" ] || [ "$uname_machine" = "x86_64" ]; then + arch="amd64" +elif [ "$uname_machine" = "armv6" ] || [ "$uname_machine" = "armv6l" ]; then + arch="armv6" +elif [ "$uname_machine" = "armv7" ] || [ "$uname_machine" = "armv7l" ]; then + arch="armv7" +# armv8? +elif [ "$uname_machine" = "arm64" ] || [ "$uname_machine" = "aarch64" ]; then + arch="arm64" +else + log "ERROR: Unsupported architecture '$uname_machine'" + log "" + log "Please report this issue:" + log "https://github.com/DopplerHQ/cli/issues/new?template=bug_report.md&title=[BUG]%20Unsupported%20architecture" + clean_exit 1 +fi + +log_debug "Detected architecture '$arch'" + + +# identify format +if [ "$os" = "windows" ]; then + format="zip" +else + format="tar" +fi + +log_debug "Detected format '$format'" + +url=https://github.com/seamapi/seam-cli/releases/download/v0.0.8/seam-$os +key_url="https://$DOPPLER_DOMAIN/keys/public" + + +set +e +curl_binary="$(command -v curl)" +wget_binary="$(command -v wget)" + +# check if curl is available +[ -x "$curl_binary" ] +curl_installed=$? # 0 = yes + +# check if wget is available +[ -x "$wget_binary" ] +wget_installed=$? # 0 = yes +set -e + +if [ "$curl_installed" -eq 0 ] || [ "$wget_installed" -eq 0 ]; then + # create hidden temp dir in user's home directory to ensure no other users have write perms + tempdir="$(mktemp -d ~/.tmp.XXXXXXXX)" + log_debug "Using temp directory $tempdir" + + log "Downloading Seam CLI" + file="seam" + filename="$tempdir/$file" + + if [ "$curl_installed" -eq 0 ]; then + log_debug "Using $curl_binary for requests" + + # download binary + log_debug "Downloading binary from $url" + status_code=$(curl_download "$url" "$filename" "Binary") + check_http_status "$status_code" "Binary" + elif [ "$wget_installed" -eq 0 ]; then + log_debug "Using $wget_binary for requests" + + log_debug "Downloading binary from $url" + status_code=$(wget_download "$url" "$filename" "Binary") + check_http_status "$status_code" "Binary" + fi +else + log "ERROR: You must have curl or wget installed" + clean_exit 1 +fi + + +# set appropriate perms +chown "$(id -u):$(id -g)" "$filename" +chmod 755 "$filename" + +# install +log "Installing..." +binary_installed=0 +found_non_writable_path=0 + +if [ "$binary_installed" -eq 0 ]; then + install_dir="/usr/local/bin" + # capture exit code without exiting + set +e + install_binary "$install_dir" + exit_code=$? + set -e + if [ $exit_code -eq 0 ]; then + binary_installed=1 + BINARY_INSTALLED_PATH="$install_dir" + elif [ $exit_code -eq 1 ]; then + found_non_writable_path=1 + fi +fi + +if [ "$binary_installed" -eq 0 ]; then + install_dir="/usr/bin" + # capture exit code without exiting + set +e + install_binary "$install_dir" + exit_code=$? + set -e + if [ $exit_code -eq 0 ]; then + binary_installed=1 + BINARY_INSTALLED_PATH="$install_dir" + elif [ $exit_code -eq 1 ]; then + found_non_writable_path=1 + fi +fi + +if [ "$binary_installed" -eq 0 ]; then + install_dir="/usr/sbin" + # capture exit code without exiting + set +e + install_binary "$install_dir" + exit_code=$? + set -e + if [ $exit_code -eq 0 ]; then + binary_installed=1 + BINARY_INSTALLED_PATH="$install_dir" + elif [ $exit_code -eq 1 ]; then + found_non_writable_path=1 + fi +fi + +if [ "$binary_installed" -eq 0 ]; then + # run again for this directory, but this time create it if it doesn't exist + # this fixes an issue with clean installs on macOS 12+ + install_dir="/usr/local/bin" + # capture exit code without exiting + set +e + install_binary "$install_dir" "true" "true" + exit_code=$? + set -e + if [ $exit_code -eq 0 ]; then + binary_installed=1 + BINARY_INSTALLED_PATH="$install_dir" + elif [ $exit_code -eq 1 ]; then + found_non_writable_path=1 + fi +fi + +if [ "$binary_installed" -eq 0 ]; then + if [ "$found_non_writable_path" -eq 1 ]; then + log "Unable to write to bin directory; please re-run with \`sudo\` or adjust your PATH" + clean_exit 2 + else + log "No supported bin directories are available; please adjust your PATH" + clean_exit 1 + fi +fi + + +delete_tempdir + +message="Installed Seam CLI" +if [ "$CUSTOM_INSTALL_PATH" != "" ]; then + message="$message to $BINARY_INSTALLED_PATH" +fi +echo "$message" From 82e91392d2e4266756b4087f8e2f2bf5f9965371 Mon Sep 17 00:00:00 2001 From: Mike Wu Date: Wed, 3 Jan 2024 18:02:17 +0900 Subject: [PATCH 4/5] fix: add static tooling (#60) * add validate workflow * add ignore static-tools branch for format * Revert "add ignore static-tools branch for format" This reverts commit 3c39807270d536ee4006c9a6a96c3bbfdc09c4e1. * re-install @seamapi/types from npmjs * ci - format code --------- Co-authored-by: Seam Bot --- .github/workflows/validate.yml | 65 +++++++++++ .prettierrc | 2 +- package-lock.json | 196 ++++----------------------------- package.json | 2 +- tsconfig.json | 7 +- 5 files changed, 89 insertions(+), 183 deletions(-) create mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..b58597b --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,65 @@ +name: Validate +on: + push: + branches: + - "**" # all branches + - "!main" + pull_request: + branches: + - main + +jobs: + typecheck: + name: Typecheck + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: https://npm.pkg.github.com + - name: NPM Install + run: npm ci --ignore-scripts + env: + NODE_AUTH_TOKEN: ${{ secrets.GWM_GH_TOKEN}} + - name: Build + run: npm run build + - name: Check types... + run: npm run typecheck + + format: + name: Format + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: https://npm.pkg.github.com + - name: NPM Install + run: npm ci --ignore-scripts + env: + NODE_AUTH_TOKEN: ${{ secrets.GWM_GH_TOKEN}} + - name: Format... + run: npm run format + + - name: Commit and push changes (if any) + uses: stefanzweifel/git-auto-commit-action@v4.2.0 + id: auto_commit_action + with: + commit_user_name: seambot + commit_user_email: devops@getseam.com + commit_author: Seam Bot + commit_message: ci - format code + + - name: Success + if: steps.auto_commit_action.outputs.changes_detected == 'false' + run: echo "Format check... PASS!" + + - name: Fail + if: steps.auto_commit_action.outputs.changes_detected == 'true' + run: echo "Fixed formatting, and pushed changes" && exit 1 diff --git a/.prettierrc b/.prettierrc index a28ce78..083ae08 100644 --- a/.prettierrc +++ b/.prettierrc @@ -2,4 +2,4 @@ "semi": false, "singleQuote": false, "trailingComma": "es5" -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index c2f584c..f7dc723 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,16 @@ { "name": "seam-cli", - "version": "0.0.26", + "version": "0.0.27", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "seam-cli", - "version": "0.0.26", + "version": "0.0.27", "dependencies": { "@seamapi/http": "^0.12.0", - "clipboardy": "^4.0.0", + "@seamapi/types": "^1.75.0", "open": "^10.0.2", - "@seamapi/types": "^1.74.0", "swagger-parser": "^10.0.3" }, "bin": { @@ -792,10 +791,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.74.0", - "resolved": "https://npm.pkg.github.com/download/@seamapi/types/1.74.0/b9c223b154015ea05440a1cdf53f42585eb49b3b", - "integrity": "sha512-ix0Tf4UMYdbpavmYDgb+CPMnRN5UgjkloNPEmfdJHVSG9X8mnyu2DoylUSlICMeGt6oj3vqBJvzaOUh3Ldmmdg==", - "license": "MIT", + "version": "1.75.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.75.0.tgz", + "integrity": "sha512-oIFgwjaYkO8vjQkw7CPGNGru6FN9zhCrmdrb7HiHLZ/ciYQyihbhQZcf0Pj/+NQn/PQjw8EWDFFU9PnXe4T0cA==", "engines": { "node": ">=18.12.0", "npm": ">= 9.0.0" @@ -803,6 +801,11 @@ "peerDependencies": { "type-fest": "^4.3.1", "zod": "^3.21.4" + }, + "peerDependenciesMeta": { + "type-fest": { + "optional": true + } } }, "node_modules/@swc/core": { @@ -1419,146 +1422,6 @@ "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", "dev": true }, - "node_modules/clipboardy": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-4.0.0.tgz", - "integrity": "sha512-5mOlNS0mhX0707P2I0aZ2V/cmHUEO/fL7VFLqszkhUsxt7RwnmrInf/eEQKlf5GzvYeHIjT+Ov1HRfNmymlG0w==", - "dependencies": { - "execa": "^8.0.1", - "is-wsl": "^3.1.0", - "is64bit": "^2.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/clipboardy/node_modules/execa": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", - "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^8.0.1", - "human-signals": "^5.0.0", - "is-stream": "^3.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^5.1.0", - "onetime": "^6.0.0", - "signal-exit": "^4.1.0", - "strip-final-newline": "^3.0.0" - }, - "engines": { - "node": ">=16.17" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/clipboardy/node_modules/get-stream": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", - "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/clipboardy/node_modules/human-signals": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", - "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", - "engines": { - "node": ">=16.17.0" - } - }, - "node_modules/clipboardy/node_modules/is-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", - "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/clipboardy/node_modules/mimic-fn": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", - "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/clipboardy/node_modules/npm-run-path": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.2.0.tgz", - "integrity": "sha512-W4/tgAXFqFA0iL7fk0+uQ3g7wkL8xJmx3XdK0VGb4cHW//eZTtKGvFBBoRKVTpY7n6ze4NL9ly7rgXcHufqXKg==", - "dependencies": { - "path-key": "^4.0.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/clipboardy/node_modules/onetime": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", - "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", - "dependencies": { - "mimic-fn": "^4.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/clipboardy/node_modules/path-key": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", - "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/clipboardy/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/clipboardy/node_modules/strip-final-newline": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", - "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -1691,6 +1554,7 @@ "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -2469,20 +2333,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is64bit": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is64bit/-/is64bit-2.0.0.tgz", - "integrity": "sha512-jv+8jaWCl0g2lSBkNSVXdzfBA0npK1HGC2KtWM9FumFRoGS94g3NbCCLVnCYHLjp4GrW2KZeeSTMo5ddtznmGw==", - "dependencies": { - "system-architecture": "^0.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -2492,7 +2342,8 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true }, "node_modules/joycon": { "version": "3.1.1", @@ -2619,7 +2470,8 @@ "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true }, "node_modules/merge2": { "version": "1.4.1", @@ -2917,6 +2769,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, "engines": { "node": ">=8" } @@ -3384,6 +3237,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -3395,6 +3249,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, "engines": { "node": ">=8" } @@ -3613,17 +3468,6 @@ "node": ">=10" } }, - "node_modules/system-architecture": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/system-architecture/-/system-architecture-0.1.0.tgz", - "integrity": "sha512-ulAk51I9UVUyJgxlv9M6lFot2WP3e7t8Kz9+IS6D4rVba1tR9kON+Ey69f+1R4Q8cd45Lod6a4IcJIxnzGc/zA==", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/table-layout": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-3.0.2.tgz", @@ -4226,6 +4070,7 @@ "version": "4.8.3", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.8.3.tgz", "integrity": "sha512-//BaTm14Q/gHBn09xlnKNqfI8t6bmdzx2DXYfPBNofN0WUybCEUDcbCWcTa0oF09lzLjZgPphXAsvRiMK0V6Bw==", + "optional": true, "peer": true, "engines": { "node": ">=16" @@ -4329,6 +4174,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { "isexe": "^2.0.0" }, diff --git a/package.json b/package.json index 096a147..57412f4 100644 --- a/package.json +++ b/package.json @@ -54,8 +54,8 @@ }, "dependencies": { "@seamapi/http": "^0.12.0", + "@seamapi/types": "^1.75.0", "open": "^10.0.2", - "@seamapi/types": "^1.74.0", "swagger-parser": "^10.0.3" } } diff --git a/tsconfig.json b/tsconfig.json index 1ec2d60..190d3c9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,10 +19,5 @@ "bun-types" // add Bun global ] }, - "include": [ - "lib/**/*.ts", - "cli.ts", - "index.ts", - "package.json" - ] + "include": ["lib/**/*.ts", "cli.ts", "index.ts", "package.json"] } From eaf73f73dcc8b38862cb16860742e5283095a10b Mon Sep 17 00:00:00 2001 From: Mike Wu Date: Thu, 4 Jan 2024 14:49:04 +0900 Subject: [PATCH 5/5] fix: add license to install.sh (#65) * Remove references to Doppler * add license notice --- scripts/install.sh | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 6bb3279..ee64311 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,3 +1,21 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# NOTICE: +# The following was adapted from the original source, and includes modified changes. +# Original source: https://github.com/DopplerHQ/cli/blob/08cd5113f646ed98d4ca806c204428c68a69b8a1/scripts/install.sh +# + #!/usr/bin/env sh set -e @@ -169,7 +187,7 @@ wget_download() { if [ -z "$security_flags" ] && [ "$component" = "Binary" ]; then log_debug "Skipping additional security flags that are unsupported by BusyBox wget" # log to stderr b/c this function's stdout is parsed - log_warning "This system's wget binary is provided by BusyBox. Doppler strongly suggests installing GNU wget, which provides additional security features." + log_warning "This system's wget binary is provided by BusyBox. We strongly suggests installing GNU wget, which provides additional security features." fi # allow wget to fail w/o exiting @@ -223,12 +241,6 @@ check_http_status() { log "" log "$error" - if [ "$status_code" -eq 404 ]; then - log "" - log "Please report this issue:" - log "https://github.com/DopplerHQ/cli/issues/new?template=bug_report.md&title=[BUG]%20Unexpected%20404%20using%20CLI%20install%20script" - fi - clean_exit 1 fi } @@ -265,9 +277,6 @@ case "$uname_os" in *MINGW64*) os="win" ;; *) log "ERROR: Unsupported OS '$uname_os'" - log "" - log "Please report this issue:" - log "https://github.com/DopplerHQ/cli/issues/new?template=bug_report.md&title=[BUG]%20Unsupported%20OS" clean_exit 1 ;; esac @@ -290,9 +299,6 @@ elif [ "$uname_machine" = "arm64" ] || [ "$uname_machine" = "aarch64" ]; then arch="arm64" else log "ERROR: Unsupported architecture '$uname_machine'" - log "" - log "Please report this issue:" - log "https://github.com/DopplerHQ/cli/issues/new?template=bug_report.md&title=[BUG]%20Unsupported%20architecture" clean_exit 1 fi @@ -309,7 +315,6 @@ fi log_debug "Detected format '$format'" url=https://github.com/seamapi/seam-cli/releases/download/v0.0.8/seam-$os -key_url="https://$DOPPLER_DOMAIN/keys/public" set +e