Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ora with yocto-spinner #12073

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/poor-seals-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astrojs/studio': patch
'astro': patch
'@astrojs/db': patch
---

Replaces `ora` with `yocto-spinner`
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
20 changes: 10 additions & 10 deletions packages/astro/src/cli/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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> => {
Expand All @@ -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',
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions packages/astro/src/cli/install-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions packages/db/src/core/cli/commands/link/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand All @@ -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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/db/src/core/cli/commands/login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion packages/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
6 changes: 3 additions & 3 deletions packages/studio/src/core/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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`),
{
Expand All @@ -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 };
Expand Down
Loading
Loading