Skip to content

Commit 04cbb24

Browse files
committed
use @iarna/toml parser for extractClientId instead of regex
1 parent fa365b7 commit 04cbb24

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

packages/e2e/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
}
3030
},
3131
"devDependencies": {
32+
"@iarna/toml": "2.2.5",
3233
"@playwright/test": "^1.50.0",
3334
"@types/node": "18.19.70",
3435
"dotenv": "16.4.7",

packages/e2e/setup/app.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import {authFixture} from './auth.js'
33
import {navigateToDashboard} from './browser.js'
44
import {CLI_TIMEOUT, BROWSER_TIMEOUT} from './constants.js'
5+
import * as toml from '@iarna/toml'
56
import * as path from 'path'
67
import * as fs from 'fs'
78
import type {CLIContext, CLIProcess, ExecResult} from './cli.js'
@@ -84,12 +85,13 @@ export async function createApp(ctx: {
8485
* Read the client_id from a shopify.app.toml file.
8586
*/
8687
export function extractClientId(appDir: string): string {
87-
const toml = fs.readFileSync(path.join(appDir, 'shopify.app.toml'), 'utf8')
88-
const match = toml.match(/client_id\s*=\s*"([^"]+)"/)
89-
if (!match?.[1]) {
90-
throw new Error(`Could not find client_id in ${path.join(appDir, 'shopify.app.toml')}`)
88+
const tomlPath = path.join(appDir, 'shopify.app.toml')
89+
const parsed = toml.parse(fs.readFileSync(tomlPath, 'utf8'))
90+
const clientId = parsed.client_id as string | undefined
91+
if (!clientId) {
92+
throw new Error(`Could not find client_id in ${tomlPath}`)
9193
}
92-
return match[1]
94+
return clientId
9395
}
9496

9597
/**

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)