Skip to content

Commit

Permalink
Merge branch 'new-dawn-dev' into feat/optional-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Seroxdesign authored Jul 9, 2024
2 parents 8c57cd9 + 02d451e commit 8457a41
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 70 deletions.
9 changes: 1 addition & 8 deletions docs/docs/platform-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
While in **alpha**, the compatibility of Synpress is limited, but we're working hard to support more frameworks and platforms as soon as possible.
:::

Synpress, in its current state, is only compatible with Playwright (>=1.39.0) and requires Node 18+. Synpress is compatible with MacOS and Linux.
Synpress, in its current state, is only compatible with Playwright (>=1.39.0) and requires Node 18+. Synpress is compatible with MacOS, Windows, and Linux.

## Supported CI Providers

Expand All @@ -17,10 +17,3 @@ See the [CI](./guides/ci) section for more information about how to set up Synpr
:::

- [GitHub Actions](https://github.com/features/actions)

## Windows

Currently, Synpress is not compatible with Windows. In the meantime, we recommend using WSL.
::: tip NOTE
If you're knowledgeable about working with Windows and the Node.js environment, and you'd like to help us make Synpress compatible with Windows, please reach out to us on our Discord.
:::
1 change: 1 addition & 0 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"types:check": "tsc --noEmit"
},
"dependencies": {
"app-root-path": "3.1.0",
"axios": "1.6.7",
"chalk": "5.3.0",
"commander": "12.0.0",
Expand Down
11 changes: 0 additions & 11 deletions packages/cache/src/cli/cliEntrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os from 'node:os'
import path from 'node:path'
import chalk from 'chalk'
import { Command } from 'commander'
Expand Down Expand Up @@ -50,16 +49,6 @@ export const cliEntrypoint = async () => {
console.log({ cacheDir: walletSetupDir, ...flags, headless: Boolean(process.env.HEADLESS) ?? false }, '\n')
}

if (os.platform() === 'win32') {
console.log(
[
chalk.redBright('🚨 Sorry, building cache on Windows is currently not supported. Please use WSL instead! 🚨'),
chalk.gray('You can still run tests on windows without cache by setting USE_CACHE=FALSE in your ENV')
].join('\n')
)
process.exit(1)
}

const compiledWalletSetupDirPath = await compileWalletSetupFunctions(walletSetupDir, flags.debug)

// TODO: We should be using `prepareExtension` function from the wallet itself!
Expand Down
58 changes: 33 additions & 25 deletions packages/cache/src/cli/compileWalletSetupFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import path from 'node:path'
import path, { posix, win32 } from 'node:path'
import { glob } from 'glob'
import { build } from 'tsup'
import { ensureCacheDirExists } from '../ensureCacheDirExists'
import { FIXES_BANNER } from './compilationFixes'

const OUT_DIR_NAME = 'wallet-setup-dist'

const createGlobPattern = (walletSetupDir: string) => path.join(walletSetupDir, '**', '*.setup.{ts,js,mjs}')

export async function compileWalletSetupFunctions(walletSetupDir: string, debug: boolean) {
const outDir = path.join(ensureCacheDirExists(), OUT_DIR_NAME)

const globPattern = createGlobPattern(walletSetupDir)
const fileList = await glob(globPattern)
// Use a normalized glob pattern
const globPattern = path.join(walletSetupDir, '**', '*.setup.{ts,js,mjs}')

// Use glob to find files, ensuring proper path handling
const fileList: string[] = await glob(globPattern, { absolute: false, windowsPathsNoEscape: true })

if (debug) {
console.log('[DEBUG] Found the following wallet setup files:')
Expand All @@ -29,27 +30,34 @@ export async function compileWalletSetupFunctions(walletSetupDir: string, debug:
)
}

await build({
name: 'cli-build',
silent: true,
entry: fileList,
clean: true,
outDir,
format: 'esm',
splitting: true,
sourcemap: false,
config: false,
// TODO: Make this list configurable.
external: ['@synthetixio/synpress', '@playwright/test', 'playwright-core', 'esbuild', 'tsup'],
banner: {
js: FIXES_BANNER
},
esbuildOptions(options) {
// TODO: In this step, if the debug file is present, we should modify `console.log` so it prints from which file the log is coming from.
// We're dropping `console.log` and `debugger` statements because they do not play nicely with the Playwright Test Runner.
options.drop = debug ? [] : ['console', 'debugger']
}
const normalized = fileList.map((file) => {
return file.split(win32.sep).join(posix.sep)
})

try {
await build({
name: 'cli-build',
silent: true,
entry: normalized,
clean: true,
outDir,
format: 'esm',
splitting: true,
sourcemap: false,
config: false,
// TODO: Make this list configurable.
external: ['@synthetixio/synpress', '@playwright/test', 'playwright-core', 'esbuild', 'tsup'],
banner: {
js: FIXES_BANNER
},
esbuildOptions(options) {
// TODO: In this step, if the debug file is present, we should modify `console.log` so it prints from which file the log is coming from.
// We're dropping `console.log` and `debugger` statements because they do not play nicely with the Playwright Test Runner.
options.drop = debug ? [] : ['console', 'debugger']
}
})
} catch (e) {
console.log('error within compile', e)
}
return outDir
}
3 changes: 0 additions & 3 deletions packages/cache/src/createCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { triggerCacheCreation } from './utils/triggerCacheCreation'

export async function createCache(walletSetupDirPath: string, downloadExtension: () => Promise<string>, force = false) {
const setupFunctions = await getUniqueWalletSetupFunctions(walletSetupDirPath)

const cacheCreationPromises = await triggerCacheCreation(setupFunctions, downloadExtension, force)

if (cacheCreationPromises.length === 0) {
console.log('No new setup functions to cache. Exiting...')
return
}

// TODO: This line has no unit test. Not sure how to do it. Look into it later.
await Promise.all(cacheCreationPromises)

Expand Down
1 change: 0 additions & 1 deletion packages/cache/src/utils/getWalletSetupFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ export async function getWalletSetupFiles(walletSetupDirPath: string) {
].join('\n')
)
}

return fileList
}
4 changes: 2 additions & 2 deletions packages/cache/src/utils/importWalletSetupFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const WalletSetupModule = z.object({
})

export async function importWalletSetupFile(walletSetupFilePath: string) {
const walletSetupModule = await import(walletSetupFilePath)

const fileToImport = process.platform === 'win32' ? `file:\\\\\\${walletSetupFilePath}` : walletSetupFilePath
const walletSetupModule = await import(fileToImport)
const result = WalletSetupModule.safeParse(walletSetupModule)
if (!result.success) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"types:check": "tsc --noEmit"
},
"devDependencies": {
"@synthetixio/synpress-tsconfig": "0.0.1-alpha.7",
"@synthetixio/synpress-tsconfig": "workspace:*",
"@types/node": "20.11.17",
"rimraf": "5.0.5",
"tsup": "8.0.2",
Expand Down
13 changes: 8 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
},
"dependencies": {
"@synthetixio/ethereum-wallet-mock": "0.0.1-alpha.7",
"@synthetixio/synpress-cache": "0.0.1-alpha.7",
"@synthetixio/synpress-core": "0.0.1-alpha.7",
"@synthetixio/synpress-cache": "workspace:*",
"@synthetixio/synpress-core": "workspace:*",
"@synthetixio/synpress-metamask": "0.0.1-alpha.7"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions wallets/metamask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"types:check": "tsc --noEmit"
},
"dependencies": {
"@synthetixio/synpress-cache": "0.0.1-alpha.7",
"@synthetixio/synpress-core": "0.0.1-alpha.7",
"@synthetixio/synpress-cache": "workspace:*",
"@synthetixio/synpress-core": "workspace:*",
"@viem/anvil": "0.0.7",
"app-root-path": "3.1.0",
"axios": "1.6.7",
Expand Down
9 changes: 0 additions & 9 deletions wallets/metamask/test/wallet-setup/basic.setup.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion wallets/metamask/test/wallet-setup/basic.setup.d.ts.map

This file was deleted.

0 comments on commit 8457a41

Please sign in to comment.