Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions knip_output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

> @0.0.0 knip /app
> knip --workspace \@shopify/app
8 changes: 4 additions & 4 deletions packages/app/src/cli/services/app/env/pull.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('env pull', () => {
"Created ${filePath}:

SHOPIFY_API_KEY=api-key
SHOPIFY_API_SECRET=api-secret
SHOPIFY_API_SECRET=******
SCOPES=my-scope
"
`)
Expand All @@ -66,15 +66,15 @@ describe('env pull', () => {
"Updated ${filePath} to be:

SHOPIFY_API_KEY=api-key
SHOPIFY_API_SECRET=api-secret
SHOPIFY_API_SECRET=******
SCOPES=my-scope

Here's what changed:

- SHOPIFY_API_KEY=ABC
- SHOPIFY_API_SECRET=XYZ
- SHOPIFY_API_SECRET=******
+ SHOPIFY_API_KEY=api-key
+ SHOPIFY_API_SECRET=api-secret
+ SHOPIFY_API_SECRET=******
SCOPES=my-scope
"
`)
Expand Down
15 changes: 12 additions & 3 deletions packages/app/src/cli/services/app/env/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,32 @@ export async function pullEnv({app, remoteApp, organization, envFile}: PullEnvOp
await writeFile(envFile, updatedEnvFileContent)

const diff = diffLines(envFileContent ?? '', updatedEnvFileContent)
const redactedDiff = diff.map((change) => ({
...change,
value: change.value.replace(/^(SHOPIFY_API_SECRET=)(.*)$/gm, '$1******'),
}))

const redactedEnvFileContent = updatedEnvFileContent.replace(/^(SHOPIFY_API_SECRET=)(.*)$/gm, '$1******')

return outputContent`Updated ${outputToken.path(envFile)} to be:

${updatedEnvFileContent}
${redactedEnvFileContent}

Here's what changed:

${outputToken.linesDiff(diff)}
${outputToken.linesDiff(redactedDiff)}
`
}
} else {
const newEnvFileContent = patchEnvFile(null, updatedValues)

await writeFile(envFile, newEnvFileContent)

const redactedEnvFileContent = newEnvFileContent.replace(/^(SHOPIFY_API_SECRET=)(.*)$/gm, '$1******')

return outputContent`Created ${outputToken.path(envFile)}:

${newEnvFileContent}
${redactedEnvFileContent}
`
}
}
2 changes: 1 addition & 1 deletion packages/app/src/cli/services/app/env/show.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('env show', () => {
expect(unstyled(stringifyMessage(result))).toMatchInlineSnapshot(`
"
SHOPIFY_API_KEY=api-key
SHOPIFY_API_SECRET=api-secret
SHOPIFY_API_SECRET=******
SCOPES=my-scope
"
`)
Expand Down
5 changes: 3 additions & 2 deletions packages/app/src/cli/services/app/env/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ export async function outputEnv(
): Promise<OutputMessage> {
await logMetadataForLoadedContext(remoteApp, organization.source)

const redactedApiSecret = remoteApp.apiSecretKeys[0]?.secret ? '******' : ''
if (format === 'json') {
return outputContent`${outputToken.json({
SHOPIFY_API_KEY: remoteApp.apiKey,
SHOPIFY_API_SECRET: remoteApp.apiSecretKeys[0]?.secret,
SHOPIFY_API_SECRET: redactedApiSecret,
SCOPES: getAppScopes(app.configuration),
})}`
} else {
return outputContent`
${outputToken.green('SHOPIFY_API_KEY')}=${remoteApp.apiKey}
${outputToken.green('SHOPIFY_API_SECRET')}=${remoteApp.apiSecretKeys[0]?.secret ?? ''}
${outputToken.green('SHOPIFY_API_SECRET')}=${redactedApiSecret}
${outputToken.green('SCOPES')}=${getAppScopes(app.configuration)}
`
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/cli/services/info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('info', () => {
expect(unstyled(stringifyMessage(result))).toMatchInlineSnapshot(`
"
SHOPIFY_API_KEY=api-key
SHOPIFY_API_SECRET=api-secret
SHOPIFY_API_SECRET=******
SCOPES=my-scope
"
`)
Expand All @@ -121,7 +121,7 @@ describe('info', () => {
expect(unstyled(stringifyMessage(result))).toMatchInlineSnapshot(`
"{
"SHOPIFY_API_KEY": "api-key",
"SHOPIFY_API_SECRET": "api-secret",
"SHOPIFY_API_SECRET": "******",
"SCOPES": "my-scope"
}"
`)
Expand Down
Loading