Skip to content

Commit 1615a7c

Browse files
feat: add ssh resources
* Add ssh-key resource and tests * Add ssh config resource and tests * Added support for ssh configs with Match and fixed tests * Add ssh add key resource and added dependencies for the other ssh resources. * Added comment to failed ssh-add-key test * Build fix and bug fix * Fixed bugs from testing
1 parent e3d0e05 commit 1615a7c

22 files changed

Lines changed: 895 additions & 22 deletions

.cirrus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ integration_test_dev_task:
2020
fingerprint_script: cat package-lock.json
2121
populate_script: npm ci
2222
test_script:
23-
- npm run test:integration -- --disable-console-intercept --inspect --no-file-parallelism
23+
- npm run test:integration -- --disable-console-intercept $DEBUG --no-file-parallelism
2424

2525
integration_individual_test_task:
2626
macos_instance:
@@ -31,4 +31,4 @@ integration_individual_test_task:
3131
populate_script: npm ci
3232
test_script:
3333
- echo $FILE_NAME
34-
- npm run test -- $FILE_NAME --disable-console-intercept --inspect --no-file-parallelism
34+
- npm run test -- $FILE_NAME --disable-console-intercept $DEBUG --no-file-parallelism

package-lock.json

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

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
"ajv": "^8.12.0",
2323
"ajv-formats": "^2.1.1",
2424
"semver": "^7.6.0",
25-
"codify-plugin-lib": "1.0.100",
25+
"codify-plugin-lib": "1.0.106",
2626
"codify-schemas": "1.0.52",
2727
"chalk": "^5.3.0",
2828
"debug": "^4.3.4",
29-
"plist": "^3.1.0"
29+
"plist": "^3.1.0",
30+
"lodash.isequal": "^4.5.0"
3031
},
3132
"devDependencies": {
3233
"rollup": "^4.12.0",
@@ -44,7 +45,8 @@
4445
"@types/commander": "^2.12.2",
4546
"@types/debug": "4.1.12",
4647
"@types/plist": "^3.0.5",
47-
"codify-plugin-test": "0.0.13",
48+
"@types/lodash.isequal": "^4.5.8",
49+
"codify-plugin-test": "0.0.12",
4850
"commander": "^12.1.0",
4951
"eslint": "^8.51.0",
5052
"eslint-config-oclif": "^5",

scripts/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const plugin = fork(
4343
// Use default true to test plugins in secure mode (un-able to request sudo directly)
4444
detached: true,
4545
env: { ...process.env },
46-
execArgv: ['--import', 'tsx/esm', '--inspect=9221'],
46+
execArgv: ['--import', 'tsx/esm'],
4747
},
4848
)
4949

scripts/run-tests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async function launchSingleTest(test: string, debug: boolean) {
4545
async function run(cmd: string, debug: boolean, simple = true) {
4646
const messageBuffer: string[] = [];
4747

48+
cmd += (debug ? ' -e DEBUG="--inspect=9229"' : '');
4849
const cp = spawn(
4950
'source ~/.zshrc; ' + cmd,
5051
[],

src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { Plugin, runPlugin } from 'codify-plugin-lib';
22

33
import { AndroidStudioResource } from './resources/android/android-studio.js';
44
import { AsdfResource } from './resources/asdf/asdf.js';
5-
import { AsdfPluginResource } from './resources/asdf/asdf-plugin.js';
65
import { AsdfGlobalResource } from './resources/asdf/asdf-global.js';
6+
import { AsdfInstallResource } from './resources/asdf/asdf-install.js';
77
import { AsdfLocalResource } from './resources/asdf/asdf-local.js';
8+
import { AsdfPluginResource } from './resources/asdf/asdf-plugin.js';
89
import { AwsCliResource } from './resources/aws-cli/cli/aws-cli.js';
910
import { AwsProfileResource } from './resources/aws-cli/profile/aws-profile.js';
1011
import { GitCloneResource } from './resources/git/clone/git-clone.js';
@@ -17,10 +18,12 @@ import { PgcliResource } from './resources/pgcli/pgcli.js';
1718
import { PyenvResource } from './resources/python/pyenv/pyenv.js';
1819
import { AliasResource } from './resources/shell/alias/alias-resource.js';
1920
import { PathResource } from './resources/shell/path/path-resource.js';
21+
import { SshAddKeyResource } from './resources/ssh/ssh-add-key.js';
22+
import { SshConfigFileResource } from './resources/ssh/ssh-config.js';
23+
import { SshKeyResource } from './resources/ssh/ssh-key.js';
2024
import { TerraformResource } from './resources/terraform/terraform.js';
2125
import { VscodeResource } from './resources/vscode/vscode.js';
2226
import { XcodeToolsResource } from './resources/xcode-tools/xcode-tools.js';
23-
import { AsdfInstallResource } from './resources/asdf/asdf-install.js';
2427

2528
runPlugin(Plugin.create(
2629
'default',
@@ -45,6 +48,9 @@ runPlugin(Plugin.create(
4548
new AsdfPluginResource(),
4649
new AsdfGlobalResource(),
4750
new AsdfLocalResource(),
48-
new AsdfInstallResource()
51+
new AsdfInstallResource(),
52+
new SshKeyResource(),
53+
new SshConfigFileResource(),
54+
new SshAddKeyResource()
4955
])
5056
)

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ export class GitCloneResource extends Resource<GitCloneConfig> {
2727
},
2828
import: {
2929
requiredParameters: ['directory']
30-
}
30+
},
31+
dependencies: [
32+
'ssh-key',
33+
'ssh-add-key',
34+
'ssh-config'
35+
]
3136
}
3237
}
3338

src/resources/homebrew/homebrew.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class HomebrewResource extends Resource<HomebrewConfig> {
5858
return this.installBrewInCustomDir(plan.desiredConfig.directory)
5959
}
6060

61-
await codifySpawn(`SUDO_ASKPASS=${SUDO_ASKPASS_PATH} NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`)
61+
await codifySpawn(`SUDO_ASKPASS=${SUDO_ASKPASS_PATH} NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`, { requestsTTY: true })
6262
await codifySpawn('(echo; echo \'eval "$(/opt/homebrew/bin/brew shellenv)"\') >> /Users/$USER/.zshrc'); // TODO: may need to support non zsh shells here
6363

6464
// TODO: Add a check here to see if homebrew is writable
@@ -72,7 +72,7 @@ export class HomebrewResource extends Resource<HomebrewConfig> {
7272
if (homebrewDirectory === '/opt/homebrew') {
7373
await codifySpawn(
7474
`SUDO_ASKPASS=${SUDO_ASKPASS_PATH} NONINTERACTIVE=1 /bin/bash -c "$(/usr/bin/curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"`,
75-
{ throws: false }
75+
{ throws: false, requestsTTY: true }
7676
)
7777
}
7878

src/resources/node/nvm/nvm.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import Schema from './nvm-schema.json';
1010
export interface NvmConfig extends ResourceConfig {
1111
global?: string,
1212
nodeVersions?: string[],
13-
// TODO: Add option here to use homebrew to install instead. Default to true. Maybe add option to set default values to resource config.
1413
}
1514

1615
export class NvmResource extends Resource<NvmConfig> {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "https://www.codifycli.com/ssh-key.json",
4+
"title": "Ssh key resource",
5+
"type": "object",
6+
"properties": {
7+
"path": {
8+
"type": "string",
9+
"description": "The path to the ssh-key to add"
10+
},
11+
"appleUseKeychain": {
12+
"type": "boolean",
13+
"description": "Corresponds to the --apple-use-keychain parameter. Controls whether the key should be loaded into the apple keychain. Only keys with a passphrase can be loaded"
14+
}
15+
},
16+
"required": ["path"],
17+
"additionalProperties": false
18+
}

0 commit comments

Comments
 (0)