Skip to content

Commit afa7938

Browse files
committed
feat: Added example and defaults for path, aliases, ssh-config
1 parent 2b2b5d3 commit afa7938

4 files changed

Lines changed: 80 additions & 3 deletions

File tree

src/resources/shell/aliases/aliases-resource.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
CreatePlan,
33
DestroyPlan,
4+
ExampleConfig,
45
ModifyPlan,
56
ParameterChange,
67
RefreshContext,
@@ -36,13 +37,52 @@ export const schema = z.object({
3637
.describe('Aliases resource. Can be used to manage multiple aliases');
3738

3839
export type AliasesConfig = z.infer<typeof schema>;
40+
41+
const defaultConfig: Partial<AliasesConfig> = {
42+
aliases: [],
43+
}
44+
45+
const exampleGitAliases: ExampleConfig = {
46+
title: 'Git aliases',
47+
description: 'Common shortcuts for everyday Git workflows - checking status, staging, committing, pushing, and viewing history.',
48+
configs: [{
49+
type: 'aliases',
50+
aliases: [
51+
{ alias: 'gs', value: 'git status' },
52+
{ alias: 'ga', value: 'git add .' },
53+
{ alias: 'gc', value: 'git commit -m' },
54+
{ alias: 'gp', value: 'git push origin HEAD' },
55+
{ alias: 'gl', value: 'git log --oneline --graph --decorate' },
56+
],
57+
}]
58+
}
59+
60+
const exampleSystemAliases: ExampleConfig = {
61+
title: 'System and safety shortcuts',
62+
description: 'Handy aliases for common system tasks and safer defaults - clearing the screen, confirming deletions, and checking disk and process usage.',
63+
configs: [{
64+
type: 'aliases',
65+
aliases: [
66+
{ alias: 'c', value: 'clear' },
67+
{ alias: 'rm', value: 'rm -i' },
68+
{ alias: 'dfh', value: 'df -h' },
69+
{ alias: 'psg', value: 'ps aux | grep -v grep | grep' },
70+
],
71+
}]
72+
}
73+
3974
export class AliasesResource extends Resource<AliasesConfig> {
4075
private readonly ALIAS_DECLARATION_REGEX = /^\s*alias\s+([A-Z_a-z][\w-]*)\s*=\s*(["']?)(.+?)\2\s*(?:#.*)?$/gm;
4176
readonly filePaths = Utils.getShellRcFiles()
4277

4378
getSettings(): ResourceSettings<AliasesConfig> {
4479
return {
4580
id: 'aliases',
81+
defaultConfig,
82+
exampleConfigs: {
83+
example1: exampleGitAliases,
84+
example2: exampleSystemAliases,
85+
},
4686
operatingSystems: [OS.Darwin, OS.Linux],
4787
schema,
4888
parameterSettings: {

src/resources/shell/path/path-resource.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
CreatePlan,
33
DestroyPlan,
4+
ExampleConfig,
45
getPty,
56
ModifyPlan,
67
ParameterChange,
@@ -25,13 +26,31 @@ export interface PathConfig extends StringIndexedObject {
2526
declarationsOnly: boolean;
2627
}
2728

29+
const defaultConfig: Partial<PathConfig> = {
30+
paths: [],
31+
declarationsOnly: true,
32+
}
33+
34+
const exampleConfig: ExampleConfig = {
35+
title: 'Example path config',
36+
configs: [{
37+
type: 'path',
38+
paths: ['~/.local', '~/bin'],
39+
declarationsOnly: true,
40+
}]
41+
}
42+
2843
export class PathResource extends Resource<PathConfig> {
2944
private readonly PATH_DECLARATION_REGEX = /((export PATH=)|(path+=\()|(path=\())(.+?)[\n;]/g;
3045
private readonly filePaths = Utils.getShellRcFiles()
3146

3247
getSettings(): ResourceSettings<PathConfig> {
3348
return {
3449
id: 'path',
50+
defaultConfig,
51+
exampleConfigs: {
52+
example1: exampleConfig,
53+
},
3554
operatingSystems: [OS.Darwin, OS.Linux],
3655
schema: Schema,
3756
parameterSettings: {

src/resources/ssh/examples.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ExampleConfigs } from '@codifycli/plugin-core';
22

33
export const exampleSshConfigs: ExampleConfigs = {
4-
example1: {
4+
example2: {
55
title: 'Example git ssh setup',
66
configs: [
77
{

src/resources/ssh/ssh-config.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
ExampleConfig,
23
getPty,
34
Resource,
45
ResourceSettings
@@ -39,17 +40,34 @@ const defaultConfig: Partial<SshConfig> = {
3940
Host: "*",
4041
AddKeysToAgent: true,
4142
UseKeychain: true,
42-
IdentityFile: "~/.ssh/id_ed25519",
43+
IdentityFile: "<Replace me here!>",
4344
IgnoreUnknown: "UseKeychain"
4445
}]
4546
}
4647

48+
const exampleConfig: ExampleConfig = {
49+
title: 'Example ssh config',
50+
configs: [{
51+
type: 'ssh-config',
52+
hosts: [{
53+
Host: "*",
54+
AddKeysToAgent: true,
55+
UseKeychain: true,
56+
IdentityFile: "~/.ssh/id_ed25519",
57+
IgnoreUnknown: "UseKeychain"
58+
}]
59+
}]
60+
}
61+
4762
export class SshConfigFileResource extends Resource<SshConfig> {
4863
getSettings(): ResourceSettings<SshConfig> {
4964
return {
5065
id: 'ssh-config',
5166
defaultConfig,
52-
exampleConfigs: exampleSshConfigs,
67+
exampleConfigs: {
68+
example1: exampleConfig,
69+
...exampleSshConfigs
70+
},
5371
operatingSystems: [OS.Darwin, OS.Linux],
5472
schema: Schema,
5573
isSensitive: true,

0 commit comments

Comments
 (0)