Skip to content

Commit 78066a9

Browse files
committed
feat: Added asdf and aws
1 parent dbd54fd commit 78066a9

5 files changed

Lines changed: 160 additions & 2 deletions

File tree

src/resources/asdf/asdf-install.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
CreatePlan,
33
DestroyPlan,
4+
ExampleConfig,
45
Resource,
56
ResourceSettings,
67
SpawnStatus,
@@ -30,6 +31,38 @@ const schema = z.object({
3031
.describe('Install specific version of tools using asdf.');
3132

3233
export type AsdfInstallConfig = z.infer<typeof schema>;
34+
35+
const defaultConfig: Partial<AsdfInstallConfig> = {
36+
plugin: '<Replace me here!>',
37+
versions: ['latest'],
38+
}
39+
40+
const examplePluginInstall: ExampleConfig = {
41+
title: 'Install specific versions via asdf',
42+
description: 'Install one or more specific versions of a language runtime using an asdf plugin.',
43+
configs: [{
44+
type: 'asdf-install',
45+
plugin: 'nodejs',
46+
versions: ['22.0.0', 'latest'],
47+
}]
48+
}
49+
50+
const exampleFullInstall: ExampleConfig = {
51+
title: 'Full asdf setup — install, plugin, and version',
52+
description: 'Install asdf, add the Node.js plugin, and activate a specific version - a complete setup from scratch.',
53+
configs: [
54+
{
55+
type: 'asdf',
56+
plugins: ['nodejs'],
57+
},
58+
{
59+
type: 'asdf-install',
60+
plugin: 'nodejs',
61+
versions: ['22.0.0'],
62+
},
63+
]
64+
}
65+
3366
const CURRENT_VERSION_REGEX = /^([^ ]+?)\s+([^ ]+?)\s+.*/;
3467
const TOOL_VERSIONS_REGEX = /^([^ ]+) +([^ ]+)$/;
3568

@@ -38,6 +71,11 @@ export class AsdfInstallResource extends Resource<AsdfInstallConfig> {
3871
getSettings(): ResourceSettings<AsdfInstallConfig> {
3972
return {
4073
id: 'asdf-install',
74+
defaultConfig,
75+
exampleConfigs: {
76+
example1: examplePluginInstall,
77+
example2: exampleFullInstall,
78+
},
4179
operatingSystems: [OS.Darwin, OS.Linux],
4280
dependencies: ['asdf'],
4381
schema,

src/resources/asdf/asdf-plugin.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
Resource,
56
ResourceSettings,
67
SpawnStatus,
@@ -26,12 +27,51 @@ const schema = z
2627
.describe('Asdf plugin resource for installing asdf plugins.');
2728
export type AsdfPluginConfig = z.infer<typeof schema>;
2829

30+
const defaultConfig: Partial<AsdfPluginConfig> = {
31+
plugin: '<Replace me here!>',
32+
}
33+
34+
const exampleNodejs: ExampleConfig = {
35+
title: 'Node.js plugin via asdf',
36+
description: 'Install the asdf Node.js plugin and pin specific versions for your environment.',
37+
configs: [{
38+
type: 'asdf-plugin',
39+
plugin: 'nodejs',
40+
versions: ['22.0.0', 'lts'],
41+
}]
42+
}
43+
44+
const exampleFullInstall: ExampleConfig = {
45+
title: 'Full asdf setup — install, plugin, and version',
46+
description: 'Install asdf, add the Node.js plugin, and activate a specific version - a complete setup from scratch.',
47+
configs: [
48+
{
49+
type: 'asdf',
50+
plugins: ['nodejs'],
51+
},
52+
{
53+
type: 'asdf-plugin',
54+
plugin: 'nodejs',
55+
},
56+
{
57+
type: 'asdf-install',
58+
plugin: 'nodejs',
59+
versions: ['22.0.0'],
60+
},
61+
]
62+
}
63+
2964
const PLUGIN_LIST_REGEX = /^([^ ]+?)\s+([^ ]+)/
3065

3166
export class AsdfPluginResource extends Resource<AsdfPluginConfig> {
3267
getSettings(): ResourceSettings<AsdfPluginConfig> {
3368
return {
3469
id: 'asdf-plugin',
70+
defaultConfig,
71+
exampleConfigs: {
72+
example1: exampleNodejs,
73+
example2: exampleFullInstall,
74+
},
3575
operatingSystems: [OS.Darwin, OS.Linux],
3676
dependencies: ['asdf'],
3777
schema,

src/resources/asdf/asdf.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CreatePlan, FileUtils, Resource, ResourceSettings, SpawnStatus, getPty, z } from '@codifycli/plugin-core';
1+
import { CreatePlan, ExampleConfig, FileUtils, Resource, ResourceSettings, SpawnStatus, getPty, z } from '@codifycli/plugin-core';
22
import { OS } from '@codifycli/schemas';
33
import fs from 'node:fs/promises';
44
import os from 'node:os';
@@ -19,10 +19,48 @@ const schema = z.object({
1919

2020
export type AsdfConfig = z.infer<typeof schema>
2121

22+
const defaultConfig: Partial<AsdfConfig> = {
23+
plugins: [],
24+
}
25+
26+
const exampleNodePython: ExampleConfig = {
27+
title: 'Node.js and Python via asdf',
28+
description: 'Install asdf with plugins for Node.js and Python - a common setup for web and scripting work.',
29+
configs: [{
30+
type: 'asdf',
31+
plugins: ['nodejs', 'python'],
32+
}]
33+
}
34+
35+
const exampleFullInstall: ExampleConfig = {
36+
title: 'Full asdf setup — install, plugin, and version',
37+
description: 'Install asdf, add the Node.js plugin, and activate a specific version - a complete setup from scratch.',
38+
configs: [
39+
{
40+
type: 'asdf',
41+
plugins: ['nodejs'],
42+
},
43+
{
44+
type: 'asdf-plugin',
45+
plugin: 'nodejs',
46+
},
47+
{
48+
type: 'asdf-install',
49+
plugin: 'nodejs',
50+
versions: ['22.0.0'],
51+
},
52+
]
53+
}
54+
2255
export class AsdfResource extends Resource<AsdfConfig> {
2356
getSettings(): ResourceSettings<AsdfConfig> {
2457
return {
2558
id: 'asdf',
59+
defaultConfig,
60+
exampleConfigs: {
61+
example1: exampleNodePython,
62+
example2: exampleFullInstall,
63+
},
2664
operatingSystems: [OS.Darwin, OS.Linux],
2765
schema,
2866
parameterSettings: {

src/resources/aws-cli/cli/aws-cli.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class AwsCliResource extends Resource<AwsCliConfig> {
2222
};
2323
}
2424

25-
2625
override async refresh(): Promise<Partial<AwsCliConfig> | null> {
2726
const $ = getPty();
2827

src/resources/aws-cli/profile/aws-profile.ts

Lines changed: 43 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
Resource,
@@ -27,11 +28,53 @@ export interface AwsProfileConfig extends StringIndexedObject {
2728
region: string;
2829
}
2930

31+
const defaultConfig: Partial<AwsProfileConfig> = {
32+
profile: 'default',
33+
region: '<Replace me here!>',
34+
output: 'json',
35+
}
36+
37+
const exampleProfile: ExampleConfig = {
38+
title: 'AWS named profile',
39+
description: 'Configure a named AWS CLI profile with credentials and a default region and output format.',
40+
configs: [{
41+
type: 'aws-profile',
42+
profile: 'default',
43+
awsAccessKeyId: '<Replace me here!>',
44+
awsSecretAccessKey: '<Replace me here!>',
45+
region: 'us-east-1',
46+
output: 'json',
47+
}]
48+
}
49+
50+
const exampleWithCli: ExampleConfig = {
51+
title: 'Install AWS CLI and configure a profile',
52+
description: 'Install the AWS CLI and set up a default profile with credentials — a complete AWS setup from scratch.',
53+
configs: [
54+
{
55+
type: 'aws-cli',
56+
},
57+
{
58+
type: 'aws-profile',
59+
profile: 'default',
60+
awsAccessKeyId: '<Replace me here!>',
61+
awsSecretAccessKey: '<Replace me here!>',
62+
region: 'us-east-1',
63+
output: 'json',
64+
},
65+
]
66+
}
67+
3068
export class AwsProfileResource extends Resource<AwsProfileConfig> {
3169

3270
getSettings(): ResourceSettings<AwsProfileConfig> {
3371
return {
3472
id: 'aws-profile',
73+
defaultConfig,
74+
exampleConfigs: {
75+
example1: exampleProfile,
76+
example2: exampleWithCli,
77+
},
3578
operatingSystems: [OS.Darwin, OS.Linux],
3679
dependencies: ['aws-cli'],
3780
schema: Schema,

0 commit comments

Comments
 (0)