[ci] format

This commit is contained in:
natemoo-re 2023-08-28 21:05:20 +00:00 committed by astrobot-houston
parent 0c7b42dc67
commit 04fa5a1453
4 changed files with 18 additions and 18 deletions

View file

@ -11,7 +11,7 @@ export async function notify() {
await telemetry.notify(() => { await telemetry.notify(() => {
console.log(msg.telemetryNotice() + '\n'); console.log(msg.telemetryNotice() + '\n');
return true; return true;
}) });
} }
export async function update(subcommand: string, { flags }: TelemetryOptions) { export async function update(subcommand: string, { flags }: TelemetryOptions) {

View file

@ -107,28 +107,28 @@ export function serverStart({
export function telemetryNotice() { export function telemetryNotice() {
const headline = `${cyan('◆')} Astro collects completely anonymous usage data.`; const headline = `${cyan('◆')} Astro collects completely anonymous usage data.`;
const why = dim(' This optional program helps shape our roadmap.') const why = dim(' This optional program helps shape our roadmap.');
const disable = dim(' Run `npm run astro telemetry disable` to opt-out.'); const disable = dim(' Run `npm run astro telemetry disable` to opt-out.');
const details = ` Details: ${underline('https://astro.build/telemetry')}`; const details = ` Details: ${underline('https://astro.build/telemetry')}`;
return [headline, why, disable, details].map(v => ' ' + v).join('\n'); return [headline, why, disable, details].map((v) => ' ' + v).join('\n');
} }
export function telemetryEnabled() { export function telemetryEnabled() {
return `${green('◉')} Anonymous telemetry is now ${bgGreen( return `${green('◉')} Anonymous telemetry is now ${bgGreen(black(' enabled '))}\n ${dim(
black(' enabled ') 'Thank you for improving Astro!'
)}\n ${dim('Thank you for improving Astro!')}\n`; )}\n`;
} }
export function telemetryDisabled() { export function telemetryDisabled() {
return `${yellow('◯')} Anonymous telemetry is now ${bgYellow( return `${yellow('◯')} Anonymous telemetry is now ${bgYellow(black(' disabled '))}\n ${dim(
black(' disabled ') "We won't ever record your usage data."
)}\n ${dim('We won\'t ever record your usage data.')}\n`; )}\n`;
} }
export function telemetryReset() { export function telemetryReset() {
return `${cyan('◆')} Anonymous telemetry has been ${bgCyan( return `${cyan('◆')} Anonymous telemetry has been ${bgCyan(black(' reset '))}\n ${dim(
black(' reset ') 'You may be prompted again.'
)}\n ${dim('You may be prompted again.')}\n`; )}\n`;
} }
export function fsStrictWarning() { export function fsStrictWarning() {

View file

@ -115,13 +115,13 @@ export class AstroTelemetry {
// The end-user has already been notified about our telemetry integration! // The end-user has already been notified about our telemetry integration!
// Don't bother them about it again. // Don't bother them about it again.
if (this.isValidNotice()) { if (this.isValidNotice()) {
this.debug(`[notify] last notified on ${this.notifyDate}`) this.debug(`[notify] last notified on ${this.notifyDate}`);
return; return;
} }
const enabled = await callback(); const enabled = await callback();
this.config.set(KEY.TELEMETRY_NOTIFY_DATE, new Date().valueOf().toString()); this.config.set(KEY.TELEMETRY_NOTIFY_DATE, new Date().valueOf().toString());
this.config.set(KEY.TELEMETRY_ENABLED, enabled); this.config.set(KEY.TELEMETRY_ENABLED, enabled);
this.debug(`[notify] telemetry has been ${enabled ? 'enabled' : 'disabled'}`) this.debug(`[notify] telemetry has been ${enabled ? 'enabled' : 'disabled'}`);
} }
async record(event: TelemetryEvent | TelemetryEvent[] = []) { async record(event: TelemetryEvent | TelemetryEvent[] = []) {

View file

@ -15,18 +15,18 @@ function setup() {
telemetry.debug.enabled = true; telemetry.debug.enabled = true;
telemetry.debug.log = (...args) => logs.push(args); telemetry.debug.log = (...args) => logs.push(args);
return { telemetry, config, logs } return { telemetry, config, logs };
} }
describe('AstroTelemetry', () => { describe('AstroTelemetry', () => {
let oldCI; let oldCI;
before(() => { before(() => {
oldCI = process.env.CI; oldCI = process.env.CI;
// Stub process.env.CI to `false` // Stub process.env.CI to `false`
process.env.CI = 'false'; process.env.CI = 'false';
}) });
after(() => { after(() => {
process.env.CI = oldCI; process.env.CI = oldCI;
}) });
it('initializes when expected arguments are given', () => { it('initializes when expected arguments are given', () => {
const { telemetry } = setup(); const { telemetry } = setup();
expect(telemetry).to.be.instanceOf(AstroTelemetry); expect(telemetry).to.be.instanceOf(AstroTelemetry);