Skip to content

Commit a1165fc

Browse files
committed
fix: bug fixes and improvements to dependencies for git-repository, virtualenv-project. Improvements to xcode-tools and wait-github-ssh-key
1 parent ac572af commit a1165fc

File tree

5 files changed

+39
-7
lines changed

5 files changed

+39
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "default",
3-
"version": "0.12.3",
3+
"version": "0.13.0",
44
"description": "",
55
"main": "dist/index.js",
66
"scripts": {

src/resources/git/clone/git-repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class GitCloneResource extends Resource<GitCloneConfig> {
5656
},
5757
dependencies: [
5858
'ssh-key',
59-
'ssh-add-key',
59+
'ssh-add',
6060
'ssh-config',
6161
'wait-github-ssh-key'
6262
]

src/resources/git/wait-github-ssh-key/wait-github-ssh-key.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import chalk from 'chalk';
12
import {
23
CodifyCliSender,
34
Resource,
45
ResourceSettings,
56
getPty
67
} from 'codify-plugin-lib';
78
import { ResourceConfig } from 'codify-schemas';
9+
import fs from 'node:fs/promises';
10+
import os from 'node:os';
11+
import path from 'node:path';
812

913
import { codifySpawn } from '../../../utils/codify-spawn.js';
1014

@@ -16,7 +20,7 @@ export class WaitGithubSshKey extends Resource<WaitGithubSshKeyConfig> {
1620
id: 'wait-github-ssh-key',
1721
dependencies: [
1822
'ssh-key',
19-
'ssh-add-key',
23+
'ssh-add',
2024
'ssh-config',
2125
]
2226
}
@@ -36,14 +40,41 @@ export class WaitGithubSshKey extends Resource<WaitGithubSshKeyConfig> {
3640
async create(): Promise<void> {
3741
let attemptCount = 0;
3842

43+
const publicKeys: string[] = []
44+
try {
45+
const sshFolder = path.join(os.homedir(), '.ssh');
46+
const publicKeysFiles = (await fs.readdir(sshFolder))
47+
.filter((name) => name.endsWith('.pub'));
48+
49+
if (publicKeysFiles.length === 0) {
50+
throw new Error();
51+
}
52+
53+
publicKeys.push(...(await Promise.all(publicKeysFiles.map(
54+
(name) => fs.readFile(path.join(sshFolder, name), 'utf8'))
55+
)));
56+
} catch {}
57+
3958
do {
4059
if (attemptCount > 0) {
4160
console.error('Unable to verify that github ssh access is connected.')
4261
}
4362

4463
await CodifyCliSender.requestPressKeyToContinuePrompt(
45-
(attemptCount > 0 ? 'Unable to verify that github ssh access is connected. Please try again. \n\n' : '') +
46-
'Waiting for user to add ssh-key to github. For instructions please follow: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account.')
64+
(attemptCount > 0 ? chalk.redBright('Unable to verify that github ssh access is connected. Please try again. \n\n') : '') +
65+
`${chalk.bold('Waiting for user to add ssh public to github')}
66+
Add ssh public key to: ${chalk.underline('https://github.com/settings/ssh/new')}
67+
68+
${publicKeys.length > 0
69+
? `${chalk.bold('Public keys found:')}
70+
${publicKeys.map((l, idx) => `${chalk.underline.italic(`key ${idx + 1}:\n`)}${l}`).join('\n')}
71+
72+
Paste one of the above key/keys into github and then press any key to continue.`
73+
: 'No public keys were found in your .ssh folder. Please use a public key located elsewhere or visit: https://docs.codifycli.com/core-resources/ssh/ssh-key/ to generate an ssh key using Codify.'
74+
}
75+
76+
For additional information visit: ${chalk.underline('https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account')}`
77+
)
4778
attemptCount++;
4879
} while(!(await this.isConnectedToGithub()));
4980
}

src/resources/python/virtualenv/virtualenv-project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class VirtualenvProject extends Resource<VirtualenvProjectConfig> {
4040
allowMultiple: {
4141
identifyingParameters: ['dest'],
4242
},
43-
dependencies: ['virtualenv', 'homebrew', 'pyenv']
43+
dependencies: ['virtualenv', 'homebrew', 'pyenv', 'git-repository']
4444
}
4545
}
4646

src/resources/xcode-tools/xcode-tools.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { StringIndexedObject } from 'codify-schemas';
33
import path from 'node:path';
44

55
import { SpawnStatus, codifySpawn } from '../../utils/codify-spawn.js';
6+
import fs from 'node:fs/promises';
67

78
interface XCodeToolsConfig extends StringIndexedObject {}
89

@@ -53,7 +54,7 @@ export class XcodeToolsResource extends Resource<XCodeToolsConfig> {
5354
await codifySpawn(`softwareupdate -i "${xcodeToolsVersion[0]}" --verbose`, { requiresRoot: true });
5455

5556
} finally {
56-
await codifySpawn('rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress')
57+
await fs.rm('/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress', { force: true, recursive: true });
5758
}
5859
}
5960

0 commit comments

Comments
 (0)