MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / collectBitbucketCloud

Function collectBitbucketCloud

packages/setupWizard/src/bitbucket.ts:29–155  ·  view source on GitHub ↗
(
    connectionName: string,
    config: BitbucketConnectionConfig,
    env: EnvVars,
)

Source from the content-addressed store, hash-verified

27}
28
29async function collectBitbucketCloud(
30 connectionName: string,
31 config: BitbucketConnectionConfig,
32 env: EnvVars,
33): Promise<CollectResult> {
34 const authMethod = await select<'api-token' | 'access-token' | 'app-password'>({
35 message: 'How will you authenticate?',
36 choices: [
37 { value: 'api-token', name: 'API Token', description: 'Recommended by Atlassian' },
38 { value: 'access-token', name: 'Access Token', description: 'Scoped to a repo, project, or workspace' },
39 { value: 'app-password', name: 'App Password (deprecated)', description: 'Deprecated by Atlassian' },
40 ],
41 });
42
43 if (authMethod === 'api-token') {
44 note(
45 'The email you use to sign in to Atlassian (e.g. you@example.com).',
46 'Atlassian account email',
47 );
48
49 const email = await input({
50 message: 'Atlassian account email',
51 validate: (v) => !v?.trim() ? 'Email is required' : true,
52 });
53 config.user = email;
54
55 note(
56 [
57 'Your Bitbucket username (separate from your Atlassian email).',
58 ' Find it at: https://bitbucket.org/account/settings/',
59 ].join('\n'),
60 'Bitbucket username',
61 );
62
63 const gitUser = await input({
64 message: 'Bitbucket username',
65 validate: (v) => !v?.trim() ? 'Username is required' : true,
66 });
67 config.gitUser = gitUser;
68
69 note(
70 [
71 'Create an API Token at:',
72 ' https://id.atlassian.com/manage-profile/security/api-tokens',
73 'Click "Create API token with scopes", choose Bitbucket, and grant:',
74 ' read:repository:bitbucket',
75 ' read:workspace:bitbucket',
76 ].join('\n'),
77 'Bitbucket Cloud API Token',
78 );
79
80 const tokenEnvKey = toEnvKey(connectionName, 'TOKEN');
81 const token = await password({
82 message: `API Token (stored locally in .env as ${tokenEnvKey})`,
83 mask: true,
84 validate: (v) => !v?.trim() ? 'Token is required' : true,
85 });
86 env[tokenEnvKey] = token;

Callers 1

collectBitbucketConfigFunction · 0.85

Calls 3

noteFunction · 0.85
toEnvKeyFunction · 0.85
multiInputFunction · 0.85

Tested by

no test coverage detected