Skip to content

Commit f1a0bd2

Browse files
committed
Updated git, terraform, python, vscode, xcode-tools, git, files, actions and asdf
1 parent 549c800 commit f1a0bd2

35 files changed

+239
-557
lines changed

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ 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 { AsdfGlobalResource } from './resources/asdf/asdf-global.js';
65
import { AsdfInstallResource } from './resources/asdf/asdf-install.js';
7-
import { AsdfLocalResource } from './resources/asdf/asdf-local.js';
86
import { AsdfPluginResource } from './resources/asdf/asdf-plugin.js';
97
import { AwsCliResource } from './resources/aws-cli/cli/aws-cli.js';
108
import { AwsProfileResource } from './resources/aws-cli/profile/aws-profile.js';
@@ -60,8 +58,6 @@ runPlugin(Plugin.create(
6058
new AndroidStudioResource(),
6159
new AsdfResource(),
6260
new AsdfPluginResource(),
63-
new AsdfGlobalResource(),
64-
new AsdfLocalResource(),
6561
new AsdfInstallResource(),
6662
new SshKeyResource(),
6763
new SshConfigFileResource(),

src/resources/asdf/asdf-global-schema.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/resources/asdf/asdf-global.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/resources/asdf/asdf-install.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
import { CreatePlan, DestroyPlan, getPty, Resource, ResourceSettings, untildify, } from 'codify-plugin-lib';
2-
import { ResourceConfig } from 'codify-schemas';
1+
import {
2+
CreatePlan,
3+
DestroyPlan,
4+
Resource,
5+
ResourceSettings,
6+
SpawnStatus,
7+
getPty,
8+
} from 'codify-plugin-lib';
9+
import { OS, ResourceConfig } from 'codify-schemas';
310
import * as fs from 'node:fs/promises';
411
import path from 'node:path';
512

6-
import { SpawnStatus, codifySpawn } from '../../utils/codify-spawn.js';
713
import { FileUtils } from '../../utils/file-utils.js';
814
import AsdfInstallSchema from './asdf-install-schema.json';
9-
import { AsdfPluginVersionsParameter } from './version-parameter.js';
1015

1116
export interface AsdfInstallConfig extends ResourceConfig {
1217
plugin?: string;
1318
versions?: string[];
1419
directory?: string;
1520
}
1621

17-
const CURRENT_VERSION_REGEX = /[^ ]+ +([^ ]+).*/;
22+
const CURRENT_VERSION_REGEX = /^([^ ]+?)\s+([^ ]+?)\s+.*/;
1823
const TOOL_VERSIONS_REGEX = /^([^ ]+) +([^ ]+)$/;
1924

2025

2126
export class AsdfInstallResource extends Resource<AsdfInstallConfig> {
2227
getSettings(): ResourceSettings<AsdfInstallConfig> {
2328
return {
2429
id: 'asdf-install',
30+
operatingSystems: [OS.Darwin, OS.Linux],
2531
dependencies: ['asdf'],
2632
schema: AsdfInstallSchema,
2733
parameterSettings: {
@@ -60,13 +66,13 @@ export class AsdfInstallResource extends Resource<AsdfInstallConfig> {
6066
const desiredTools = await this.getToolVersions(parameters.directory);
6167

6268
for (const { plugin, version } of desiredTools) {
63-
const { status, data } = await $.spawnSafe(`asdf current ${plugin}`, { cwd: parameters.directory });
69+
const { status, data } = await $.spawnSafe(`asdf current ${plugin} --no-header`, { cwd: parameters.directory });
6470
if (status === SpawnStatus.ERROR || data.trim() === '') {
6571
return null;
6672
}
6773

68-
const [_, currentVersion] = data.match(CURRENT_VERSION_REGEX)!;
69-
if (currentVersion !== version) {
74+
const [_, currentPlugin, currentVersion] = data.match(CURRENT_VERSION_REGEX)!;
75+
if (currentPlugin !== plugin || currentVersion !== version) {
7076
return null;
7177
}
7278
}
@@ -78,12 +84,12 @@ export class AsdfInstallResource extends Resource<AsdfInstallConfig> {
7884

7985
// Directly check plugin version
8086
const versionsQuery = await $.spawnSafe(`asdf list ${parameters.plugin}`);
81-
if (versionsQuery.status === SpawnStatus.ERROR || versionsQuery.data.trim() === 'No versions installed') {
87+
if (versionsQuery.status === SpawnStatus.ERROR || versionsQuery.data.trim().includes('No compatible versions installed')) {
8288
return null;
8389
}
8490

8591
const latest = parameters.versions?.includes('latest')
86-
? (await codifySpawn(`asdf latest ${parameters.plugin}`)).data.trim()
92+
? (await $.spawnSafe(`asdf latest ${parameters.plugin}`)).data.trim()
8793
: null;
8894

8995
const versions = versionsQuery.data.split(/\n/)
@@ -99,37 +105,40 @@ export class AsdfInstallResource extends Resource<AsdfInstallConfig> {
99105
}
100106

101107
async create(plan: CreatePlan<AsdfInstallConfig>): Promise<void> {
108+
const $ = getPty();
109+
102110
if (plan.desiredConfig.directory) {
103111
const desiredTools = await this.getToolVersions(plan.desiredConfig.directory);
104112

105113
// Make sure all of the plugins are installed. If not installed, then install them
106114
for (const { plugin } of desiredTools) {
107-
if ((await codifySpawn(`asdf list ${plugin}`, { throws: false })).status === SpawnStatus.ERROR) {
108-
await codifySpawn(`asdf plugin add ${plugin}`);
115+
if ((await $.spawnSafe(`asdf list ${plugin}`)).status === SpawnStatus.ERROR) {
116+
await $.spawn(`asdf plugin add ${plugin}`, { interactive: true });
109117
}
110118
}
111119

112-
await codifySpawn('asdf install', { cwd: plan.desiredConfig.directory });
120+
await $.spawn('asdf install', { cwd: plan.desiredConfig.directory, interactive: true });
113121
return;
114122
}
115123

116-
await codifySpawn(`asdf install ${plan.desiredConfig?.plugin} ${plan.desiredConfig.versions?.join(' ')}`);
124+
await $.spawn(`asdf install ${plan.desiredConfig?.plugin} ${plan.desiredConfig.versions?.join(' ')}`, { interactive: true });
117125
}
118126

119127
async destroy(plan: DestroyPlan<AsdfInstallConfig>): Promise<void> {
128+
const $ = getPty();
120129
if (plan.currentConfig.directory) {
121130
const desiredTools = await this.getToolVersions(plan.currentConfig.directory);
122131

123132
// Uninstall plugin versions listed in .tool-versions
124133
for (const { plugin, version } of desiredTools) {
125-
await codifySpawn(`asdf uninstall ${plugin} ${version}`);
134+
await $.spawn(`asdf uninstall ${plugin} ${version}`, { interactive: true });
126135
}
127136

128137
return;
129138
}
130139

131140
// Other path is uninstalled through the stateful parameter
132-
await codifySpawn(`asdf uninstall ${plan.currentConfig?.plugin} ${plan.currentConfig.versions?.join(' ')}`);
141+
await $.spawn(`asdf uninstall ${plan.currentConfig?.plugin} ${plan.currentConfig.versions?.join(' ')}`, { interactive: true });
133142
}
134143

135144
private async getToolVersions(directory: string): Promise<Array<{ plugin: string; version: string }>> {

src/resources/asdf/asdf-local-schema.json

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)