-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📦️ chore: Add
release
package (#1027)
- Loading branch information
1 parent
a433e55
commit bff9f57
Showing
10 changed files
with
180 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import path from 'node:path' | ||
import chalk from 'chalk' | ||
import { Command } from 'commander' | ||
import { rimraf } from 'rimraf' | ||
import { WALLET_SETUP_DIR_NAME } from '../constants' | ||
import { createCache } from '../createCache' | ||
import { prepareExtension } from '../prepareExtension' | ||
import { compileWalletSetupFunctions } from './compileWalletSetupFunctions' | ||
import { footer } from './footer' | ||
|
||
interface CliFlags { | ||
headless: boolean | ||
force: boolean | ||
debug: boolean | ||
} | ||
|
||
// TODO: Add unit tests for the CLI! | ||
export const cliEntrypoint = async () => { | ||
console.log(`⚠️ ${chalk.yellowBright`The CLI is in alpha so expect breaking changes!`} ⚠️\n`) | ||
|
||
const program = new Command() | ||
.name(chalk.magenta('core')) | ||
.description('A CLI for building the cache of wallet setup functions') | ||
.argument('[dir]', 'Directory containing the wallet setup functions', path.join('test', WALLET_SETUP_DIR_NAME)) | ||
.option( | ||
'--headless', | ||
'Build cache in the headless browser mode. Alternatively, set the `HEADLESS` env variable to `true`', | ||
false | ||
) | ||
.option('-f, --force', 'Force the creation of cache even if it already exists', false) | ||
.option('-d, --debug', 'If this flag is present, the compilation files are not going to be deleted', false) | ||
.helpOption(undefined, 'Display help for command') | ||
.addHelpText('afterAll', `\n${footer}\n`) | ||
.parse(process.argv) | ||
|
||
let walletSetupDir = program.args[0] | ||
if (!walletSetupDir) { | ||
walletSetupDir = path.join(process.cwd(), 'test', WALLET_SETUP_DIR_NAME) | ||
} | ||
|
||
const flags: CliFlags = program.opts() | ||
|
||
if (flags.headless) { | ||
process.env.HEADLESS = true | ||
} | ||
|
||
console.log('[DEBUG] Running with the following options:') | ||
console.log({ cacheDir: walletSetupDir, ...flags, headless: Boolean(process.env.HEADLESS) ?? false }, '\n') | ||
|
||
const compiledWalletSetupDirPath = await compileWalletSetupFunctions(walletSetupDir, flags.debug) | ||
|
||
// TODO: We should be using `prepareExtension` function from the wallet itself! | ||
await createCache(compiledWalletSetupDirPath, prepareExtension, flags.force) | ||
|
||
if (!flags.debug) { | ||
await rimraf(compiledWalletSetupDirPath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ packages: | |
- "packages/*" | ||
- "wallets/*" | ||
- "examples/*" | ||
- "release" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "@synthetixio/synpress", | ||
"version": "4.0.0", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./types/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
} | ||
}, | ||
"main": "./dist/index.js", | ||
"bin": "./dist/cli.js", | ||
"files": [ | ||
"dist", | ||
"src", | ||
"types" | ||
], | ||
"scripts": { | ||
"build": "pnpm run clean && pnpm run build:dist && pnpm run build:types", | ||
"build:dist": "tsup", | ||
"build:types": "tsc --emitDeclarationOnly", | ||
"clean": "rimraf dist types", | ||
"lint": "biome check . --apply", | ||
"lint:check": "biome check . --verbose", | ||
"lint:unsafe": "biome check . --apply-unsafe", | ||
"prepublishOnly": "pnpm run build", | ||
"types:check": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"@synthetixio/synpress-core": "workspace:*", | ||
"@synthetixio/synpress-fixtures": "workspace:*", | ||
"@synthetixio/synpress-metamask": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.8.0", | ||
"rimraf": "^5.0.1", | ||
"tsconfig": "workspace:*", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
}, | ||
"peerDependencies": { | ||
"@playwright/test": "1.40.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env node | ||
|
||
import { cliEntrypoint } from '@synthetixio/synpress-core' | ||
|
||
cliEntrypoint().catch((err) => { | ||
console.log('Aborting...') | ||
|
||
if (err instanceof Error) { | ||
console.error(err) | ||
} else { | ||
console.error('Unknown error occurred!', err) | ||
} | ||
|
||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { defineWalletSetup } from '@synthetixio/synpress-core' | ||
import { getExtensionId, testWithSynpress } from '@synthetixio/synpress-fixtures' | ||
import { MetaMask, unlockForFixture } from '@synthetixio/synpress-metamask' | ||
|
||
export { defineWalletSetup, testWithSynpress, getExtensionId, MetaMask, unlockForFixture } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "tsconfig/base.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "types", | ||
"declaration": true, | ||
"sourceMap": false, | ||
"declarationMap": true | ||
}, | ||
"include": ["src/index.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from 'tsup' | ||
|
||
export default defineConfig({ | ||
name: 'synpress', | ||
entry: ['src/index.ts', 'src/cli.ts'], | ||
outDir: 'dist', | ||
format: 'esm', | ||
splitting: false, | ||
sourcemap: false | ||
}) |