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

Windows cache #1178

Draft
wants to merge 15 commits into
base: new-dawn
Choose a base branch
from
64 changes: 32 additions & 32 deletions packages/cache/src/cli/compileWalletSetupFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
import path from 'node:path'
import { globSync } from 'glob'
import { glob } from 'glob'
import { build } from 'tsup'
import { ensureCacheDirExists } from '../ensureCacheDirExists'
import { FIXES_BANNER } from './compilationFixes'

const OUT_DIR_NAME = 'wallet-setup-dist'

function escapeWindowsFilePath(filePath: string, platform: string) {
if (platform !== 'win32') return filePath;
return filePath.replace(/\\/g, '\\\\');
}

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

// **Refined Glob Pattern:**
// Use a normalized glob pattern
const globPattern = path.join(walletSetupDir, '**', '*.setup.{ts,js,mjs}');
const platform = process.platform
// Get file paths using glob, ensuring proper path handling
const fileList = globSync(escapeWindowsFilePath(globPattern, platform));

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

if (debug) {
console.log('[DEBUG] Found the following wallet setup files:');
@@ -47,27 +42,32 @@ export async function compileWalletSetupFunctions(
)
}

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']
}
})


try {
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']
}
})
} catch (e) {
console.log(e)
}
return outDir
}
}