Skip to content

Conversation

@AtofStryker
Copy link
Contributor

@AtofStryker AtofStryker commented Nov 13, 2025

  • Closes

Additional details

Converts files, fixtures, resolve, status_code, system, and a few other files to TypeScript

Steps to test

How has the user experience changed?

PR Tasks


Note

Migrates key server modules (files, fixture, terminal, tty, resolve, status_code, system) and related tests to TypeScript, updates call sites/imports and typings, and adds safe error serialization.

  • Server/Utilities:
    • Convert util/{terminal.ts, tty.ts, resolve.ts, status_code.ts, system.ts} to TypeScript; adjust consumers to import * as ... where needed.
    • Add fs.readJsonAsync to util/fs.ts; remove legacy TS ignores in util/file.ts.
    • Update server-base.ts, project-base.ts, modes/run.ts to use typed utilities and minor typing tweaks.
  • Fixtures/Files:
    • Replace lib/files.js and lib/fixture.js with lib/files.ts and lib/fixture.ts; update usages in socket-base.ts, controllers/xhrs.ts, and privileged-commands-manager.ts (get as fixtureGet, * as files).
    • Implement queueing/encoding logic in TS and preserve existing behavior; minor Bluebird delays and type guards.
  • Cloud:
    • cloud/exception.ts: switch to * as system import and add safeErrorSerialize() for robust error stringification.
  • CLI Startup:
    • start-cypress.js: import override from util/tty and call directly.
  • Printing/Output:
    • util/print-run.ts: type fixes (e.g., HorizontalAlignment) and table alignment updates.
  • Tests:
    • Migrate unit tests to TS where applicable (files_spec.ts, fixture_spec.ts, status_code_spec.ts, util/terminal_spec.ts, util/tty_spec.ts) and update snapshots.
    • Child process test sets NODE_OPTIONS='--import tsx' for TS config loading.

Written by Cursor Bugbot for commit 7db621a. This will update automatically on new commits. Configure here.

@AtofStryker AtofStryker self-assigned this Nov 13, 2025
@cypress
Copy link

cypress bot commented Nov 13, 2025

cypress    Run #67420

Run Properties:  status check errored Errored #67420  •  git commit 7db621a15d: empty commit
Project cypress
Branch Review chore/server-files-p3
Run status status check errored Errored #67420
Run duration 18m 23s
Commit git commit 7db621a15d: empty commit
Committer Bill Glesias
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 72
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 5641
View all changes introduced in this branch ↗︎

Warning

Partial Report: The results for the Application Quality reports may be incomplete.


Warning

No Report: Something went wrong and we could not generate a report for the Application Quality products.

@AtofStryker AtofStryker force-pushed the chore/server-files-p3 branch 2 times, most recently from 0d1dd13 to f262fa7 Compare November 14, 2025 15:12
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Silent Encoding Failure in `readJson` Calls

The fs.readJsonAsync call passes 'utf8' as a second parameter, but fs-extra's readJson/readJsonSync methods only accept an options object as the second parameter, not an encoding string. This will cause the encoding to be ignored or potentially throw an error. The original code had a @ts-expect-error comment acknowledging this type mismatch, which was removed during the TypeScript conversion without fixing the underlying issue.

packages/server/lib/util/file.ts#L161-L162

return fs.readJsonAsync(this.path, 'utf8')

Fix in Cursor Fix in Web


@AtofStryker AtofStryker force-pushed the chore/server-files-p3 branch from 32aa387 to 1fea56c Compare November 14, 2025 16:57
@AtofStryker AtofStryker force-pushed the chore/server-files-p3 branch from 0d5411e to 1fd4bad Compare November 14, 2025 18:56
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: `readJsonAsync` Parameter Type Mismatch

The fs.readJsonAsync call passes 'utf8' as a second parameter, but fs-extra's readJson method expects an options object, not a direct encoding string. When promisified by Bluebird, readJsonAsync should be called as fs.readJsonAsync(this.path, { encoding: 'utf8' }) or simply fs.readJsonAsync(this.path) since utf8 is the default encoding. This will cause the method to fail or behave unexpectedly.

packages/server/lib/util/file.ts#L161-L162

return fs.readJsonAsync(this.path, 'utf8')

Fix in Cursor Fix in Web


@AtofStryker AtofStryker changed the title chore: convert server files p3 chore: convert additional server files to TypeScript Nov 18, 2025

// needed to run these tests locally
// sinon.stub(ctx.browser, 'machineBrowsers').resolves([
// {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eventually when we convert these tests to vitest we need to address this problem, as the tests don't run locally without this stub but run fine in CI because electron is installed

@AtofStryker AtofStryker force-pushed the chore/server-files-p3 branch from 03ffbf0 to 0989d19 Compare November 18, 2025 16:02
@AtofStryker AtofStryker force-pushed the chore/server-files-p3 branch from 0989d19 to 7db621a Compare November 18, 2025 16:03
@jennifer-shehane jennifer-shehane self-requested a review November 19, 2025 14:34
Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments, fine to merge

Comment on lines +84 to +85
// @ts-expect-error
return fixtureGet(config.fixturesFolder, filePath, options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a contextual comment for this expect-error?

Comment on lines +189 to +190
// @ts-expect-error
const colors = <string[]>[].concat(options.color)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add context to this comment?

Comment on lines +34 to +49
export async function readFiles (projectRoot: string, options: { files: { path: string, encoding?: BufferEncoding }[] } = { files: [] }) {
const files = await Promise.all(options.files.map(async (file) => {
const { contents, filePath } = await readFile(projectRoot, {
file: file.path,
encoding: file.encoding,
})

return {
...file,
filePath,
contents,
}
}))

return files
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a direct translation, but just wondering if this should have a try/catch here.

Comment on lines +93 to +94
// @ts-expect-error
err.code = 'ENOENT'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment on this expect-error?


export async function parseFile (p: string, fixture: string, options: { encoding?: (ObjectEncodingOptions & { flag?: string | undefined }) | BufferEncoding | null } = {}) {
if (queue[p]) {
await Bluebird.delay(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Bluebird here exactly?

Comment on lines +181 to +183
const dc = process.env.NODE_DISABLE_COLORS

process.env.NODE_DISABLE_COLORS = '0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the zero context on why this is necessary 😆

Comment on lines +198 to +216
export async function parseHtml (p: string, fixture: string) {
try {
const content = await fs.readFileAsync(p, 'utf8')

return content
} catch (err) {
throw new Error(`Unable to parse '${fixture}'.\n${err.toString()}`)
}
}

export async function parse (p: string, fixture: string, encoding: (ObjectEncodingOptions & { flag?: string | undefined }) | BufferEncoding | null | undefined) {
try {
const content = await fs.readFileAsync(p, encoding)

return content
} catch (err) {
throw new Error(`Unable to parse '${fixture}'.\n${err.toString()}`)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems these can be consolidated, but maybe another time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants