Skip to content

chore(repo): Add 1Password CLI script #6168

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

Merged
merged 1 commit into from
Jun 23, 2025
Merged
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
2 changes: 2 additions & 0 deletions .changeset/odd-doors-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
13 changes: 3 additions & 10 deletions integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,9 @@ Before you begin writing tests, you should already have:

You'll only need to follow these instructions once when you setup the integration test suite.

1. Navigate to the `integration` folder:
```shell
cd integration
```
1. Make local duplicates of the sample files. They'll be automatically ignored by git:
```shell
cp .env.local.sample .env.local
cp .keys.json.sample .keys.json
```
1. Open Clerk's 1Password and search for **JS SDKs integration tests**. Inside the secure note you'll find the secret keys that should go into `.env.local` and `.keys.json`. Copy them over.
1. Make sure you have the [1Password CLI installed](https://developer.1password.com/docs/cli/get-started/) and have access to Clerk's "Shared" vault. You will also need to [enable the 1Password desktop app integration](https://developer.1password.com/docs/cli/get-started/#step-2-turn-on-the-1password-desktop-app-integration).

1. Run `pnpm integration:secrets`.

1. Generate the required session keys by running the following command in the `./certs` directory: `mkcert -cert-file sessions.pem -key-file sessions-key.pem "example.com" "*.example.com"`.

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"format": "prettier --write .",
"format:check": "prettier --cache --check .",
"preinstall": "npx only-allow pnpm",
"integration:secrets": "node ./scripts/1password-keys.mjs",
"lint": "node ./scripts/lint.mjs",
"lint:attw": "FORCE_COLOR=1 turbo lint:attw",
"lint:fix": "FORCE_COLOR=1 turbo lint -- --fix",
Expand Down
48 changes: 48 additions & 0 deletions scripts/1password-keys.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env node

import { writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { $ } from 'zx';

const is1PasswordInstalled = await $`op --version`.then(res => res.exitCode === 0).catch(() => false);

if (!is1PasswordInstalled) {
console.error('1Password CLI is not installed. Install it with `brew install 1password-cli`.');
process.exit(1);
}

const envItem = await $`op read 'op://Shared/JS SDKs integration tests/add more/.env.local'`
.then(res => {
if (res.exitCode === 0) {
return res.stdout;
}

return null;
})
.catch(err => {
return null;
});

const keysItem = await $`op read 'op://Shared/JS SDKs integration tests/add more/.keys.json'`
.then(res => {
if (res.exitCode === 0) {
return res.stdout;
}

return null;
})
.catch(err => {
return null;
});

if (!envItem || !keysItem) {
console.error(
'Failed to read from 1Password. Have you enabled the 1Password CLI in your 1Password settings? See https://developer.1password.com/docs/cli/get-started/#step-2-turn-on-the-1password-desktop-app-integration for more information.',
);
process.exit(1);
}

await writeFile(join(process.cwd(), 'integration', '.env.local'), envItem);
await writeFile(join(process.cwd(), 'integration', '.keys.json'), keysItem);

console.log('Keys and env written to .keys.json and .env.local');
Loading