0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Replace ora with yocto-spinner (#12073)

This commit is contained in:
Bjorn Lu 2024-09-25 16:17:02 +01:00 committed by GitHub
parent 9693ad4ffa
commit acf264d8c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 57 additions and 122 deletions

View file

@ -0,0 +1,7 @@
---
'@astrojs/studio': patch
'astro': patch
'@astrojs/db': patch
---
Replaces `ora` with `yocto-spinner`

View file

@ -162,7 +162,6 @@
"micromatch": "^4.0.8",
"mrmime": "^2.0.0",
"neotraverse": "^0.6.18",
"ora": "^8.1.0",
"p-limit": "^6.1.0",
"p-queue": "^8.0.1",
"preferred-pm": "^4.0.0",
@ -181,6 +180,7 @@
"which-pm": "^3.0.0",
"xxhash-wasm": "^1.0.2",
"yargs-parser": "^21.1.1",
"yocto-spinner": "^0.1.0",
"zod": "^3.23.8",
"zod-to-json-schema": "^3.23.2",
"zod-to-ts": "^1.2.0"

View file

@ -6,7 +6,7 @@ import { diffWords } from 'diff';
import { bold, cyan, dim, green, magenta, red, yellow } from 'kleur/colors';
import { type ASTNode, type ProxifiedModule, builders, generateCode, loadFile } from 'magicast';
import { getDefaultExportOptions } from 'magicast/helpers';
import ora from 'ora';
import yoctoSpinner from 'yocto-spinner';
import preferredPM from 'preferred-pm';
import prompts from 'prompts';
import maxSatisfying from 'semver/ranges/max-satisfying.js';
@ -665,7 +665,7 @@ async function tryToInstallIntegrations({
);
if (await askToContinue({ flags })) {
const spinner = ora('Installing dependencies...').start();
const spinner = yoctoSpinner({ text: 'Installing dependencies...' }).start();
try {
await exec(
installCommand.pm,
@ -683,10 +683,10 @@ async function tryToInstallIntegrations({
},
},
);
spinner.succeed();
spinner.success();
return UpdateResult.updated;
} catch (err: any) {
spinner.fail();
spinner.error();
logger.debug('add', 'Error installing dependencies', err);
// NOTE: `err.stdout` can be an empty string, so log the full error instead for a more helpful log
// eslint-disable-next-line no-console
@ -700,7 +700,7 @@ async function tryToInstallIntegrations({
}
async function validateIntegrations(integrations: string[]): Promise<IntegrationInfo[]> {
const spinner = ora('Resolving packages...').start();
const spinner = yoctoSpinner({ text: 'Resolving packages...' }).start();
try {
const integrationEntries = await Promise.all(
integrations.map(async (integration): Promise<IntegrationInfo> => {
@ -718,9 +718,9 @@ async function validateIntegrations(integrations: string[]): Promise<Integration
const firstPartyPkgCheck = await fetchPackageJson('@astrojs', name, tag);
if (firstPartyPkgCheck instanceof Error) {
if (firstPartyPkgCheck.message) {
spinner.warn(yellow(firstPartyPkgCheck.message));
spinner.warning(yellow(firstPartyPkgCheck.message));
}
spinner.warn(yellow(`${bold(integration)} is not an official Astro package.`));
spinner.warning(yellow(`${bold(integration)} is not an official Astro package.`));
const response = await prompts({
type: 'confirm',
name: 'askToContinue',
@ -745,7 +745,7 @@ async function validateIntegrations(integrations: string[]): Promise<Integration
const thirdPartyPkgCheck = await fetchPackageJson(scope, name, tag);
if (thirdPartyPkgCheck instanceof Error) {
if (thirdPartyPkgCheck.message) {
spinner.warn(yellow(thirdPartyPkgCheck.message));
spinner.warning(yellow(thirdPartyPkgCheck.message));
}
throw new Error(`Unable to fetch ${bold(integration)}. Does the package exist?`);
} else {
@ -790,11 +790,11 @@ async function validateIntegrations(integrations: string[]): Promise<Integration
return { id: integration, packageName, dependencies, type: integrationType };
}),
);
spinner.succeed();
spinner.success();
return integrationEntries;
} catch (e) {
if (e instanceof Error) {
spinner.fail(e.message);
spinner.error(e.message);
process.exit(1);
} else {
throw e;

View file

@ -2,7 +2,7 @@ import { createRequire } from 'node:module';
import boxen from 'boxen';
import ci from 'ci-info';
import { bold, cyan, dim, magenta } from 'kleur/colors';
import ora from 'ora';
import yoctoSpinner from 'yocto-spinner';
import preferredPM from 'preferred-pm';
import prompts from 'prompts';
import { exec } from 'tinyexec';
@ -139,19 +139,19 @@ async function installPackage(
}
if (Boolean(response)) {
const spinner = ora('Installing dependencies...').start();
const spinner = yoctoSpinner({ text: 'Installing dependencies...' }).start();
try {
await exec(
installCommand.pm,
[installCommand.command, ...installCommand.flags, ...installCommand.dependencies],
{ nodeOptions: { cwd: cwd } },
);
spinner.succeed();
spinner.success();
return true;
} catch (err) {
logger.debug('add', 'Error installing dependencies', err);
spinner.fail();
spinner.error();
return false;
}

View file

@ -78,10 +78,10 @@
"kleur": "^4.1.5",
"nanoid": "^5.0.7",
"open": "^10.1.0",
"ora": "^8.1.0",
"prompts": "^2.4.2",
"strip-ansi": "^7.1.0",
"yargs-parser": "^21.1.1",
"yocto-spinner": "^0.1.0",
"zod": "^3.23.8"
},
"devDependencies": {

View file

@ -9,7 +9,7 @@ import {
} from '@astrojs/studio';
import { slug } from 'github-slugger';
import { bgRed, cyan } from 'kleur/colors';
import ora from 'ora';
import yoctoSpinner from 'yocto-spinner';
import prompts from 'prompts';
import { safeFetch } from '../../../../runtime/utils.js';
import type { Result } from '../../../utils.js';
@ -33,7 +33,7 @@ export async function cmd() {
const workspaceId = await promptWorkspace(sessionToken);
const newProjectName = await promptNewProjectName();
const newProjectRegion = await promptNewProjectRegion();
const spinner = ora('Creating new project...').start();
const spinner = yoctoSpinner({text:'Creating new project...'}).start();
const newProjectData = await createNewProject({
workspaceId,
name: newProjectName,
@ -42,7 +42,7 @@ export async function cmd() {
// TODO(fks): Actually listen for project creation before continuing
// This is just a dumb spinner that roughly matches database creation time.
await new Promise((r) => setTimeout(r, 4000));
spinner.succeed('Project created!');
spinner.success('Project created!');
return await linkProject(newProjectData.id);
}
}

View file

@ -5,7 +5,7 @@ import type { AstroConfig } from 'astro';
import { listen } from 'async-listen';
import { cyan } from 'kleur/colors';
import open from 'open';
import ora from 'ora';
import yoctoSpinner from 'yocto-spinner';
import prompt from 'prompts';
import type { Arguments } from 'yargs-parser';
import type { DBConfig } from '../../../types.js';
@ -48,9 +48,9 @@ export async function cmd({
console.log(cyan(loginUrl.href));
console.log(`If something goes wrong, copy-and-paste the URL into your browser.`);
open(loginUrl.href);
const spinner = ora('Waiting for confirmation...');
const spinner = yoctoSpinner({ text: 'Waiting for confirmation...' });
session = await promise;
spinner.succeed('Successfully logged in');
spinner.success('Successfully logged in');
}
await mkdir(new URL('.', SESSION_LOGIN_FILE), { recursive: true });

View file

@ -36,7 +36,7 @@
"dependencies": {
"ci-info": "^4.0.0",
"kleur": "^4.1.5",
"ora": "^8.1.0"
"yocto-spinner": "^0.1.0"
},
"devDependencies": {
"astro": "workspace:*",

View file

@ -4,7 +4,7 @@ import { join } from 'node:path';
import { pathToFileURL } from 'node:url';
import ci from 'ci-info';
import { green } from 'kleur/colors';
import ora from 'ora';
import yoctoSpinner from 'yocto-spinner';
import {
MISSING_PROJECT_ID_ERROR,
MISSING_SESSION_ID_CI_ERROR,
@ -52,7 +52,7 @@ class ManagedRemoteAppToken implements ManagedAppToken {
sessionToken: string,
projectId: string,
): Promise<{ token: string; ttl: number }> {
const spinner = ora('Connecting to remote database...').start();
const spinner = yoctoSpinner({ text: 'Connecting to remote database...' }).start();
const response = await safeFetch(
new URL(`${getAstroStudioUrl()}/auth/cli/token-create`),
{
@ -66,7 +66,7 @@ class ManagedRemoteAppToken implements ManagedAppToken {
throw new Error(`Failed to create token: ${res.status} ${res.statusText}`);
},
);
spinner.succeed(green('Connected to remote database.'));
spinner.success(green('Connected to remote database.'));
const { token, ttl } = await response.json();
return { token, ttl };

View file

@ -657,9 +657,6 @@ importers:
neotraverse:
specifier: ^0.6.18
version: 0.6.18
ora:
specifier: ^8.1.0
version: 8.1.0
p-limit:
specifier: ^6.1.0
version: 6.1.0
@ -714,6 +711,9 @@ importers:
yargs-parser:
specifier: ^21.1.1
version: 21.1.1
yocto-spinner:
specifier: ^0.1.0
version: 0.1.0
zod:
specifier: ^3.23.8
version: 3.23.8
@ -4283,9 +4283,6 @@ importers:
open:
specifier: ^10.1.0
version: 10.1.0
ora:
specifier: ^8.1.0
version: 8.1.0
prompts:
specifier: ^2.4.2
version: 2.4.2
@ -4295,6 +4292,9 @@ importers:
yargs-parser:
specifier: ^21.1.1
version: 21.1.1
yocto-spinner:
specifier: ^0.1.0
version: 0.1.0
zod:
specifier: ^3.23.8
version: 3.23.8
@ -5459,9 +5459,9 @@ importers:
kleur:
specifier: ^4.1.5
version: 4.1.5
ora:
specifier: ^8.1.0
version: 8.1.0
yocto-spinner:
specifier: ^0.1.0
version: 0.1.0
devDependencies:
astro:
specifier: workspace:*
@ -7644,14 +7644,6 @@ packages:
resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
cli-cursor@5.0.0:
resolution: {integrity: sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==}
engines: {node: '>=18'}
cli-spinners@2.9.2:
resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==}
engines: {node: '>=6'}
cli-table3@0.6.4:
resolution: {integrity: sha512-Lm3L0p+/npIQWNIiyF/nAn7T5dnOwR3xNTHXYEBFBFVPXzCVNZ5lqEC/1eo/EVfpDsQ1I+TX4ORPQgp+UI0CRw==}
engines: {node: 10.* || >= 12.*}
@ -7728,7 +7720,7 @@ packages:
resolution: {integrity: sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w==}
concat-map@0.0.1:
resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=}
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
consola@3.2.3:
resolution: {integrity: sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==}
@ -8649,10 +8641,6 @@ packages:
engines: {node: '>=14.16'}
hasBin: true
is-interactive@2.0.0:
resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==}
engines: {node: '>=12'}
is-number@7.0.0:
resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
engines: {node: '>=0.12.0'}
@ -8679,14 +8667,6 @@ packages:
resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==}
engines: {node: '>=4'}
is-unicode-supported@1.3.0:
resolution: {integrity: sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==}
engines: {node: '>=12'}
is-unicode-supported@2.0.0:
resolution: {integrity: sha512-FRdAyx5lusK1iHG0TWpVtk9+1i+GjrzRffhDg4ovQ7mcidMQ6mj+MhKPmvh7Xwyv5gIS06ns49CA7Sqg7lC22Q==}
engines: {node: '>=18'}
is-what@4.1.16:
resolution: {integrity: sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==}
engines: {node: '>=12.13'}
@ -8870,10 +8850,6 @@ packages:
lodash@4.17.21:
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
log-symbols@6.0.0:
resolution: {integrity: sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==}
engines: {node: '>=18'}
log-update@5.0.1:
resolution: {integrity: sha512-5UtUDQ/6edw4ofyljDNcOVJQ4c7OjDro4h3y8e1GQL5iYElYclVHJ3zeWchylvMaKnDbDilC8irOVyexnA/Slw==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
@ -9171,10 +9147,6 @@ packages:
resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==}
engines: {node: '>=12'}
mimic-function@5.0.1:
resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==}
engines: {node: '>=18'}
mini-svg-data-uri@1.4.4:
resolution: {integrity: sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==}
hasBin: true
@ -9350,10 +9322,6 @@ packages:
resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==}
engines: {node: '>=12'}
onetime@7.0.0:
resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==}
engines: {node: '>=18'}
only-allow@1.2.1:
resolution: {integrity: sha512-M7CJbmv7UCopc0neRKdzfoGWaVZC+xC1925GitKH9EAqYFzX9//25Q7oX4+jw0tiCCj+t5l6VZh8UPH23NZkMA==}
hasBin: true
@ -9369,10 +9337,6 @@ packages:
resolution: {integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==}
engines: {node: '>= 0.8.0'}
ora@8.1.0:
resolution: {integrity: sha512-GQEkNkH/GHOhPFXcqZs3IDahXEQcQxsSjEkK4KvEEST4t7eNzoMjxTzef+EZ+JluDEV+Raoi3WQ2CflnRdSVnQ==}
engines: {node: '>=18'}
os-tmpdir@1.0.2:
resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==}
engines: {node: '>=0.10.0'}
@ -9969,10 +9933,6 @@ packages:
resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
restore-cursor@5.1.0:
resolution: {integrity: sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==}
engines: {node: '>=18'}
retext-latin@4.0.0:
resolution: {integrity: sha512-hv9woG7Fy0M9IlRQloq/N6atV82NxLGveq+3H2WOi79dtIYWN8OaxogDm77f8YnVXJL2VD3bbqowu5E3EMhBYA==}
@ -10207,10 +10167,6 @@ packages:
std-env@3.7.0:
resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==}
stdin-discarder@0.2.2:
resolution: {integrity: sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==}
engines: {node: '>=18'}
stream-replace-string@2.0.0:
resolution: {integrity: sha512-TlnjJ1C0QrmxRNrON00JvaFFlNh5TTG00APw23j74ET7gkQpTASi6/L2fuiav8pzK715HXtUeClpBTw2NPSn6w==}
@ -11074,6 +11030,14 @@ packages:
resolution: {integrity: sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g==}
engines: {node: '>=12.20'}
yocto-spinner@0.1.0:
resolution: {integrity: sha512-sBra0N4uhNn5UibnOz/HJxB1a0tzZ5zXbqnDe+tfRR3BGy+BmOrzrnQCZRJI7C++JiSZaPygPeNon4QCUmMQ4g==}
engines: {node: '>=18.19'}
yoctocolors@2.1.1:
resolution: {integrity: sha512-GQHQqAopRhwU8Kt1DDM8NjibDXHC8eoh1erhGAJPEyveY9qqVeXvVikNKrDz69sHowPMorbPUrH/mx8c50eiBQ==}
engines: {node: '>=18'}
zod-to-json-schema@3.23.2:
resolution: {integrity: sha512-uSt90Gzc/tUfyNqxnjlfBs8W6WSGpNBv0rVsNxP/BVSMHMKGdthPYff4xtCHYloJGM0CFxFsb3NbC0eqPhfImw==}
peerDependencies:
@ -13425,12 +13389,6 @@ snapshots:
dependencies:
restore-cursor: 4.0.0
cli-cursor@5.0.0:
dependencies:
restore-cursor: 5.1.0
cli-spinners@2.9.2: {}
cli-table3@0.6.4:
dependencies:
string-width: 4.2.3
@ -14442,8 +14400,6 @@ snapshots:
dependencies:
is-docker: 3.0.0
is-interactive@2.0.0: {}
is-number@7.0.0: {}
is-path-inside@3.0.3: {}
@ -14462,10 +14418,6 @@ snapshots:
dependencies:
better-path-resolve: 1.0.0
is-unicode-supported@1.3.0: {}
is-unicode-supported@2.0.0: {}
is-what@4.1.16: {}
is-windows@1.0.2: {}
@ -14672,11 +14624,6 @@ snapshots:
lodash@4.17.21: {}
log-symbols@6.0.0:
dependencies:
chalk: 5.3.0
is-unicode-supported: 1.3.0
log-update@5.0.1:
dependencies:
ansi-escapes: 5.0.0
@ -15260,8 +15207,6 @@ snapshots:
mimic-fn@4.0.0: {}
mimic-function@5.0.1: {}
mini-svg-data-uri@1.4.4: {}
minimatch@3.1.2:
@ -15412,10 +15357,6 @@ snapshots:
dependencies:
mimic-fn: 4.0.0
onetime@7.0.0:
dependencies:
mimic-function: 5.0.1
only-allow@1.2.1:
dependencies:
which-pm-runs: 1.1.0
@ -15438,18 +15379,6 @@ snapshots:
prelude-ls: 1.2.1
type-check: 0.4.0
ora@8.1.0:
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
os-tmpdir@1.0.2: {}
outdent@0.5.0: {}
@ -16134,11 +16063,6 @@ snapshots:
onetime: 5.1.2
signal-exit: 3.0.7
restore-cursor@5.1.0:
dependencies:
onetime: 7.0.0
signal-exit: 4.1.0
retext-latin@4.0.0:
dependencies:
'@types/nlcst': 2.0.3
@ -16422,8 +16346,6 @@ snapshots:
std-env@3.7.0: {}
stdin-discarder@0.2.2: {}
stream-replace-string@2.0.0: {}
string-width@4.2.3:
@ -17333,6 +17255,12 @@ snapshots:
yocto-queue@1.1.1: {}
yocto-spinner@0.1.0:
dependencies:
yoctocolors: 2.1.1
yoctocolors@2.1.1: {}
zod-to-json-schema@3.23.2(zod@3.23.8):
dependencies:
zod: 3.23.8