diff --git a/package-lock.json b/package-lock.json index cdfc53f765e..e5b4bee3e61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -76,16 +76,15 @@ "lambda-local": "2.2.0", "locate-path": "7.2.0", "lodash": "4.17.21", - "log-symbols": "7.0.0", "log-update": "6.1.0", "maxstache": "1.0.7", "maxstache-stream": "1.0.4", "multiparty": "4.2.3", + "nanospinner": "^1.2.2", "netlify": "13.3.3", "netlify-redirector": "0.5.0", "node-fetch": "3.3.2", "open": "10.1.0", - "ora": "8.2.0", "p-filter": "4.1.0", "p-map": "7.0.3", "p-wait-for": "5.0.2", @@ -13125,17 +13124,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-interactive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz", - "integrity": "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-node-process": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz", @@ -14076,32 +14064,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/log-symbols": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-7.0.0.tgz", - "integrity": "sha512-zrc91EDk2M+2AXo/9BTvK91pqb7qrPg2nX/Hy+u8a5qQlbaOflCKO+6SqgZ+M+xUFxGdKTgwnGiL96b1W3ikRA==", - "dependencies": { - "is-unicode-supported": "^2.0.0", - "yoctocolors": "^2.1.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/log-symbols/node_modules/is-unicode-supported": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", - "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/log-update": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/log-update/-/log-update-6.1.0.tgz", @@ -14773,6 +14735,15 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/nanospinner": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/nanospinner/-/nanospinner-1.2.2.tgz", + "integrity": "sha512-Zt/AmG6qRU3e+WnzGGLuMCEAO/dAu45stNbHY223tUxldaDAeE+FxSPsd9Q+j+paejmm0ZbrNVs5Sraqy3dRxA==", + "license": "MIT", + "dependencies": { + "picocolors": "^1.1.1" + } + }, "node_modules/napi-build-utils": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", @@ -15253,140 +15224,6 @@ "node": ">= 0.8.0" } }, - "node_modules/ora": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/ora/-/ora-8.2.0.tgz", - "integrity": "sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw==", - "dependencies": { - "chalk": "^5.3.0", - "cli-cursor": "^5.0.0", - "cli-spinners": "^2.9.2", - "is-interactive": "^2.0.0", - "is-unicode-supported": "^2.0.0", - "log-symbols": "^6.0.0", - "stdin-discarder": "^0.2.2", - "string-width": "^7.2.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ora/node_modules/cli-cursor": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", - "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", - "dependencies": { - "restore-cursor": "^5.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ora/node_modules/emoji-regex": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", - "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==" - }, - "node_modules/ora/node_modules/is-unicode-supported": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", - "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ora/node_modules/log-symbols": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-6.0.0.tgz", - "integrity": "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==", - "dependencies": { - "chalk": "^5.3.0", - "is-unicode-supported": "^1.3.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ora/node_modules/log-symbols/node_modules/is-unicode-supported": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", - "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ora/node_modules/onetime": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", - "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", - "dependencies": { - "mimic-function": "^5.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ora/node_modules/restore-cursor": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", - "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", - "dependencies": { - "onetime": "^7.0.0", - "signal-exit": "^4.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ora/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/ora/node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/os-name": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/os-name/-/os-name-5.0.1.tgz", @@ -17589,17 +17426,6 @@ "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==" }, - "node_modules/stdin-discarder": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/stdin-discarder/-/stdin-discarder-0.2.2.tgz", - "integrity": "sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/steno": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/steno/-/steno-0.4.4.tgz", @@ -20376,17 +20202,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/yoctocolors": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/yoctocolors/-/yoctocolors-2.1.1.tgz", - "integrity": "sha512-GQHQqAopRhwU8Kt1DDM8NjibDXHC8eoh1erhGAJPEyveY9qqVeXvVikNKrDz69sHowPMorbPUrH/mx8c50eiBQ==", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/zip-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-6.0.1.tgz", @@ -29273,11 +29088,6 @@ "is-path-inside": "^4.0.0" } }, - "is-interactive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz", - "integrity": "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==" - }, "is-node-process": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz", @@ -29975,22 +29785,6 @@ } } }, - "log-symbols": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-7.0.0.tgz", - "integrity": "sha512-zrc91EDk2M+2AXo/9BTvK91pqb7qrPg2nX/Hy+u8a5qQlbaOflCKO+6SqgZ+M+xUFxGdKTgwnGiL96b1W3ikRA==", - "requires": { - "is-unicode-supported": "^2.0.0", - "yoctocolors": "^2.1.1" - }, - "dependencies": { - "is-unicode-supported": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", - "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==" - } - } - }, "log-update": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/log-update/-/log-update-6.1.0.tgz", @@ -30477,6 +30271,14 @@ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==" }, + "nanospinner": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/nanospinner/-/nanospinner-1.2.2.tgz", + "integrity": "sha512-Zt/AmG6qRU3e+WnzGGLuMCEAO/dAu45stNbHY223tUxldaDAeE+FxSPsd9Q+j+paejmm0ZbrNVs5Sraqy3dRxA==", + "requires": { + "picocolors": "^1.1.1" + } + }, "napi-build-utils": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", @@ -30815,90 +30617,6 @@ "word-wrap": "^1.2.5" } }, - "ora": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/ora/-/ora-8.2.0.tgz", - "integrity": "sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw==", - "requires": { - "chalk": "^5.3.0", - "cli-cursor": "^5.0.0", - "cli-spinners": "^2.9.2", - "is-interactive": "^2.0.0", - "is-unicode-supported": "^2.0.0", - "log-symbols": "^6.0.0", - "stdin-discarder": "^0.2.2", - "string-width": "^7.2.0", - "strip-ansi": "^7.1.0" - }, - "dependencies": { - "cli-cursor": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", - "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", - "requires": { - "restore-cursor": "^5.0.0" - } - }, - "emoji-regex": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", - "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==" - }, - "is-unicode-supported": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", - "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==" - }, - "log-symbols": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-6.0.0.tgz", - "integrity": "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==", - "requires": { - "chalk": "^5.3.0", - "is-unicode-supported": "^1.3.0" - }, - "dependencies": { - "is-unicode-supported": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", - "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==" - } - } - }, - "onetime": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", - "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", - "requires": { - "mimic-function": "^5.0.0" - } - }, - "restore-cursor": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", - "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", - "requires": { - "onetime": "^7.0.0", - "signal-exit": "^4.1.0" - } - }, - "signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==" - }, - "string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "requires": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - } - } - } - }, "os-name": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/os-name/-/os-name-5.0.1.tgz", @@ -32493,11 +32211,6 @@ "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==" }, - "stdin-discarder": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/stdin-discarder/-/stdin-discarder-0.2.2.tgz", - "integrity": "sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==" - }, "steno": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/steno/-/steno-0.4.4.tgz", @@ -34296,11 +34009,6 @@ "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true }, - "yoctocolors": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/yoctocolors/-/yoctocolors-2.1.1.tgz", - "integrity": "sha512-GQHQqAopRhwU8Kt1DDM8NjibDXHC8eoh1erhGAJPEyveY9qqVeXvVikNKrDz69sHowPMorbPUrH/mx8c50eiBQ==" - }, "zip-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-6.0.1.tgz", diff --git a/package.json b/package.json index 94d84ce09e7..d919c0bbc4d 100644 --- a/package.json +++ b/package.json @@ -129,16 +129,15 @@ "lambda-local": "2.2.0", "locate-path": "7.2.0", "lodash": "4.17.21", - "log-symbols": "7.0.0", "log-update": "6.1.0", "maxstache": "1.0.7", "maxstache-stream": "1.0.4", "multiparty": "4.2.3", + "nanospinner": "^1.2.2", "netlify": "13.3.3", "netlify-redirector": "0.5.0", "node-fetch": "3.3.2", "open": "10.1.0", - "ora": "8.2.0", "p-filter": "4.1.0", "p-map": "7.0.3", "p-wait-for": "5.0.2", diff --git a/scripts/prepare-for-publish.js b/scripts/prepare-for-publish.js index 88edbe36ca7..f331d8dbe11 100644 --- a/scripts/prepare-for-publish.js +++ b/scripts/prepare-for-publish.js @@ -3,7 +3,7 @@ import { dirname, join } from 'path' import { fileURLToPath } from 'url' import execa from 'execa' -import ora from 'ora' +import { createSpinner } from 'nanospinner' // These scripts from package.json need to be preserved on publish const preserveScripts = new Set([ @@ -15,10 +15,7 @@ const preserveScripts = new Set([ 'prepublishOnly', ]) -let spinner = ora({ - spinner: 'star', - text: 'Patching package.json (removing devDependencies, scripts, etc)', -}).start() +let spinner = createSpinner('Patching package.json (removing devDependencies, scripts, etc)').start() const dir = dirname(fileURLToPath(import.meta.url)) const packageJsonPath = join(dir, '../package.json') @@ -41,18 +38,12 @@ pkgJson.scripts.postinstall = pkgJson.scripts['postinstall-pack'] delete pkgJson.scripts['postinstall-pack'] await writeFile(packageJsonPath, JSON.stringify(pkgJson, null, 2)) -spinner.succeed() +spinner.success() -spinner = ora({ - spinner: 'star', - text: 'Running `npm install --no-audit`', -}).start() +spinner = createSpinner('Running `npm install --no-audit`').start() await execa('npm', ['install', '--no-audit']) -spinner.succeed() +spinner.success() -spinner = ora({ - spinner: 'star', - text: 'Running `npm shrinkwrap`', -}).start() +spinner = createSpinner('Running `npm shrinkwrap`').start() await execa('npm', ['shrinkwrap']) -spinner.succeed() +spinner.success() diff --git a/src/commands/deploy/deploy.ts b/src/commands/deploy/deploy.ts index ef4c0b4396b..1930da49012 100644 --- a/src/commands/deploy/deploy.ts +++ b/src/commands/deploy/deploy.ts @@ -17,7 +17,7 @@ import { getBootstrapURL } from '../../lib/edge-functions/bootstrap.js' import { featureFlags as edgeFunctionsFeatureFlags } from '../../lib/edge-functions/consts.js' import { normalizeFunctionsConfig } from '../../lib/functions/config.js' import { BACKGROUND_FUNCTIONS_WARNING } from '../../lib/log.js' -import { startSpinner, stopSpinner } from '../../lib/spinner.js' +import { type Spinner, startSpinner, stopSpinner } from '../../lib/spinner.js' import { detectFrameworkSettings, getDefaultConfig } from '../../utils/build-info.js' import { NETLIFYDEV, @@ -33,7 +33,7 @@ import { APIError, } from '../../utils/command-helpers.js' import { DEFAULT_DEPLOY_TIMEOUT } from '../../utils/deploy/constants.js' -import { deploySite } from '../../utils/deploy/deploy-site.js' +import { type DeployEvent, deploySite } from '../../utils/deploy/deploy-site.js' import { getEnvelopeEnv } from '../../utils/env/index.js' import { getFunctionsManifestPath, getInternalFunctionsDir } from '../../utils/functions/index.js' import openBrowser from '../../utils/open-browser.js' @@ -309,40 +309,30 @@ const reportDeployError = ({ error_, failAndExit }) => { } const deployProgressCb = function () { - /** - * @type {Record} - */ - const events = {} - // @ts-expect-error TS(7006) FIXME: Parameter 'event' implicitly has an 'any' type. - return (event) => { + const spinnersByType: Record = {} + return (event: DeployEvent) => { switch (event.phase) { case 'start': { - // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message - events[event.type] = startSpinner({ + spinnersByType[event.type] = startSpinner({ text: event.msg, }) return } case 'progress': { - // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message - const spinner = events[event.type] + const spinner = spinnersByType[event.type] if (spinner) { - spinner.text = event.msg + spinner.update({ text: event.msg }) } return } case 'error': - // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message - stopSpinner({ error: true, spinner: events[event.type], text: event.msg }) - // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message - delete events[event.type] + stopSpinner({ error: true, spinner: spinnersByType[event.type], text: event.msg }) + delete spinnersByType[event.type] return case 'stop': default: { - // @ts-expect-error TS(2345) FIXME: Argument of type '{ spinner: any; text: any; }' is... Remove this comment to see the full error message - stopSpinner({ spinner: events[event.type], text: event.msg }) - // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message - delete events[event.type] + stopSpinner({ spinner: spinnersByType[event.type], text: event.msg }) + delete spinnersByType[event.type] } } } diff --git a/src/commands/functions/functions-create.ts b/src/commands/functions/functions-create.ts index 10d98945f8e..77e783f678a 100644 --- a/src/commands/functions/functions-create.ts +++ b/src/commands/functions/functions-create.ts @@ -11,7 +11,7 @@ import { findUp } from 'find-up' import fuzzy from 'fuzzy' import inquirer from 'inquirer' import fetch from 'node-fetch' -import ora from 'ora' +import { createSpinner } from 'nanospinner' import { fileExistsAsync } from '../../lib/fs.js' import { getAddons, getCurrentAddon, getSiteData } from '../../utils/addons/prepare.js' @@ -45,6 +45,11 @@ const languages = [ { name: 'Rust', value: 'rust' }, ] +const MOON_SPINNER = { + interval: 80, + frames: ['🌑 ', '🌒 ', '🌓 ', '🌔 ', '🌕 ', '🌖 ', '🌗 ', '🌘 '], +} + /** * prompt for a name if name not supplied * @param {string} argumentName @@ -541,12 +546,9 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun // npm install if (functionPackageJson !== undefined) { - const spinner = ora({ - text: `Installing dependencies for ${name}`, - spinner: 'moon', - }).start() + const spinner = createSpinner(`Installing dependencies for ${name}`, MOON_SPINNER).start() await installDeps({ functionPackageJson, functionPath, functionsDir }) - spinner.succeed(`Installed dependencies for ${name}`) + spinner.success(`Installed dependencies for ${name}`) } if (funcType === 'edge') { diff --git a/src/commands/sites/sites-list.ts b/src/commands/sites/sites-list.ts index 19b2e9fee92..0540a214f14 100644 --- a/src/commands/sites/sites-list.ts +++ b/src/commands/sites/sites-list.ts @@ -8,7 +8,6 @@ import BaseCommand from '../base-command.js' export const sitesList = async (options: OptionValues, command: BaseCommand) => { const { api } = command.netlify - /** @type {import('ora').Ora} */ let spinner if (!options.json) { spinner = startSpinner({ text: 'Loading your sites' }) @@ -16,8 +15,7 @@ export const sitesList = async (options: OptionValues, command: BaseCommand) => await command.authenticate() const sites = await listSites({ api, options: { filter: 'all' } }) - if (!options.json) { - // @ts-expect-error TS(2345) FIXME: Argument of type '{ spinner: Ora | undefined; }' i... Remove this comment to see the full error message + if (spinner) { stopSpinner({ spinner }) } diff --git a/src/commands/watch/watch.ts b/src/commands/watch/watch.ts index 8bbd3ba0837..a41bf4f9d13 100644 --- a/src/commands/watch/watch.ts +++ b/src/commands/watch/watch.ts @@ -1,8 +1,9 @@ import { OptionValues } from 'commander' import pWaitFor from 'p-wait-for' import prettyjson from 'prettyjson' +import type { NetlifyAPI } from 'netlify' -import { startSpinner, stopSpinner } from '../../lib/spinner.js' +import { type Spinner, startSpinner, stopSpinner } from '../../lib/spinner.js' import { chalk, error, log } from '../../utils/command-helpers.js' import BaseCommand from '../base-command.js' import { init } from '../init/init.js' @@ -15,28 +16,18 @@ const BUILD_FINISH_INTERVAL = 1e3 // 20 minutes const BUILD_FINISH_TIMEOUT = 12e5 -/** - * - * @param {import('netlify').NetlifyAPI} api - * @param {string} siteId - * @param {import('ora').Ora} spinner - * @returns {Promise} - */ -// @ts-expect-error TS(7006) FIXME: Parameter 'api' implicitly has an 'any' type. -const waitForBuildFinish = async function (api, siteId, spinner) { +const waitForBuildFinish = async function (api: NetlifyAPI, siteId: string, spinner: Spinner) { let firstPass = true const waitForBuildToFinish = async function () { const builds = await api.listSiteBuilds({ siteId }) // build.error - // @ts-expect-error TS(7006) FIXME: Parameter 'build' implicitly has an 'any' type. const currentBuilds = builds.filter((build) => !build.done) // if build.error // @TODO implement build error messages into this if (!currentBuilds || currentBuilds.length === 0) { - // @ts-expect-error TS(2345) FIXME: Argument of type '{ spinner: any; }' is not assign... Remove this comment to see the full error message stopSpinner({ spinner }) return true } @@ -64,7 +55,7 @@ export const watch = async (options: OptionValues, command: BaseCommand) => { if (!siteId) { // TODO: build init command const siteData = await init({}, command) - siteId = siteData.id + siteId = siteData.id as string } // wait for 1 sec for everything to kickoff @@ -101,7 +92,7 @@ export const watch = async (options: OptionValues, command: BaseCommand) => { const noActiveBuilds = await waitForBuildFinish(client, siteId, spinner) - const siteData = await client.getSite({ siteId: siteId as string }) + const siteData = await client.getSite({ siteId }) const message = chalk.cyanBright.bold.underline(noActiveBuilds ? 'Last build' : 'Deploy complete') log() diff --git a/src/lib/api.ts b/src/lib/api.ts index 14502613f70..6ca6a314fad 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -16,7 +16,7 @@ const MAX_PAGES = 10 const MAX_PER_PAGE = 100 // @ts-expect-error TS(7023) FIXME: 'listSites' implicitly has return type 'any' becau... Remove this comment to see the full error message -export const listSites = async ({ api, options }): SiteInfo[] => { +export const listSites = async ({ api, options }): Promise => { const { maxPages = MAX_PAGES, page = FIRST_PAGE, ...rest } = options const sites = await api.listSites({ page, per_page: MAX_PER_PAGE, ...rest }) // TODO: use pagination headers when js-client returns them diff --git a/src/lib/edge-functions/proxy.ts b/src/lib/edge-functions/proxy.ts index 2e3c52ea014..a522d2e3df0 100644 --- a/src/lib/edge-functions/proxy.ts +++ b/src/lib/edge-functions/proxy.ts @@ -13,7 +13,7 @@ import { FeatureFlags, getFeatureFlagsFromSiteInfo } from '../../utils/feature-f import { BlobsContextWithEdgeAccess } from '../blobs/blobs.js' import { getGeoLocation } from '../geo-location.js' import { getPathInProject } from '../settings.js' -import { startSpinner, stopSpinner } from '../spinner.js' +import { type Spinner, startSpinner, stopSpinner } from '../spinner.js' import { getBootstrapURL } from './bootstrap.js' import { DIST_IMPORT_MAP_PATH, EDGE_FUNCTIONS_SERVE_FOLDER } from './consts.js' @@ -25,7 +25,7 @@ const headersSymbol = Symbol('Edge Functions Headers') const LOCAL_HOST = '127.0.0.1' const getDownloadUpdateFunctions = () => { - let spinner: ReturnType + let spinner: Spinner const onAfterDownload = (error_: unknown) => { stopSpinner({ error: Boolean(error_), spinner }) diff --git a/src/lib/spinner.ts b/src/lib/spinner.ts index e7ee72d29aa..2da6a7562ba 100644 --- a/src/lib/spinner.ts +++ b/src/lib/spinner.ts @@ -1,34 +1,34 @@ -import logSymbols from 'log-symbols' -import ora, { Ora } from 'ora' +import { createSpinner, type Spinner } from 'nanospinner' + +const DOTS_SPINNER = { + interval: 80, + frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'], +} /** * Creates a spinner with the following text */ -export const startSpinner = ({ text }: { text: string }) => - ora({ - text, - }).start() +export const startSpinner = ({ text }: { text: string }) => createSpinner(text, DOTS_SPINNER).start() /** * Stops the spinner with the following text */ -export const stopSpinner = ({ error, spinner, text }: { error: boolean; spinner: Ora; text?: string }) => { +export const stopSpinner = ({ error, spinner, text }: { error?: boolean; spinner: Spinner; text?: string }) => { if (!spinner) { return } - // TODO: refactor no package needed `log-symbols` for that - const symbol = error ? logSymbols.error : logSymbols.success - spinner.stopAndPersist({ - text, - symbol, - }) + if (error === true) { + spinner.error(text) + } else { + spinner.stop(text) + } } /** * Clears the spinner */ -export const clearSpinner = ({ spinner }: { spinner: Ora }) => { - if (spinner) { - spinner.stop() - } +export const clearSpinner = ({ spinner }: { spinner: Spinner }) => { + spinner.clear() } + +export type { Spinner } diff --git a/src/utils/deploy/deploy-site.ts b/src/utils/deploy/deploy-site.ts index 5cb12efca61..3062ac0c4e7 100644 --- a/src/utils/deploy/deploy-site.ts +++ b/src/utils/deploy/deploy-site.ts @@ -28,6 +28,13 @@ const buildStatsString = (possibleParts: Array) => { return parts.length > 1 ? `${message} and ${parts[parts.length - 1]}` : message } +// TODO(serhalp) This is alternatingly called "event", "status", and "progress". Standardize. +export interface DeployEvent { + type: string + msg: string + phase: 'start' | 'progress' | 'error' | 'stop' +} + export const deploySite = async ( command: BaseCommand, api: $TSFixMe, @@ -74,7 +81,7 @@ export const deploySite = async ( deployTimeout?: number draft?: boolean maxRetry?: number - statusCb?: (status: { type: string; msg: string; phase: string }) => void + statusCb?: (status: DeployEvent) => void syncFileLimit?: number tmpDir?: string fnDir?: string[] diff --git a/src/utils/framework-server.ts b/src/utils/framework-server.ts index 52d2d49c206..32cf25c9693 100644 --- a/src/utils/framework-server.ts +++ b/src/utils/framework-server.ts @@ -44,7 +44,9 @@ export const startFrameworkServer = async function ({ await rm(settings.dist, { recursive: true, force: true }) } - runCommand(settings.command, { env: settings.env, spinner, cwd }) + if (settings.command) { + runCommand(settings.command, { env: settings.env, spinner, cwd }) + } let port: { open: boolean; ipVersion?: 4 | 6 } | undefined try { diff --git a/src/utils/shell.ts b/src/utils/shell.ts index 2648cea8e93..ee08a8145bc 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -4,6 +4,7 @@ import execa from 'execa' // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'stri... Remove this comment to see the full error message import stripAnsiCc from 'strip-ansi-control-characters' +import type { Spinner } from '../lib/spinner.js' import { chalk, log, NETLIFYDEVERR, NETLIFYDEVWARN } from './command-helpers.js' import { processOnExit } from './dev.js' @@ -33,19 +34,15 @@ const cleanupBeforeExit = async ({ exitCode }) => { } } -/** - * Run a command and pipe stdout, stderr and stdin - * @param {string} command - * @param {object} options - * @param {import('ora').Ora|null} [options.spinner] - * @param {NodeJS.ProcessEnv} [options.env] - * @param {string} [options.cwd] - * @returns {execa.ExecaChildProcess} - */ -// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. -export const runCommand = (command, options = {}) => { - // @ts-expect-error TS(2339) FIXME: Property 'cwd' does not exist on type '{}'. - const { cwd, env = {}, spinner = null } = options +export const runCommand = ( + command: string, + options: { + spinner?: Spinner + env?: NodeJS.ProcessEnv + cwd: string + }, +) => { + const { cwd, env = {}, spinner } = options const commandProcess = execa.command(command, { preferLocal: true, // we use reject=false to avoid rejecting synchronously when the command doesn't exist @@ -62,16 +59,13 @@ export const runCommand = (command, options = {}) => { // This ensures that an active spinner stays at the bottom of the commandline // even though the actual framework command might be outputting stuff - // @ts-expect-error TS(7006) FIXME: Parameter 'writeStream' implicitly has an 'any' ty... Remove this comment to see the full error message - const pipeDataWithSpinner = (writeStream, chunk) => { - if (spinner && spinner.isSpinning) { + const pipeDataWithSpinner = (writeStream: NodeJS.WriteStream, chunk: any) => { + if (spinner?.isSpinning) { spinner.clear() - spinner.isSilent = true } writeStream.write(chunk, () => { - if (spinner && spinner.isSpinning) { - spinner.isSilent = false - spinner.render() + if (spinner?.isSpinning) { + spinner.start() } }) }