Skip to content

Commit 32065aa

Browse files
committed
fix: Fixed cask parameter installations. Fixed docker deteching volume breaking entire apply. Filter corepack out of npm install
1 parent 695fb40 commit 32065aa

5 files changed

Lines changed: 46 additions & 33 deletions

File tree

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "default",
3-
"version": "1.1.0-beta.1",
3+
"version": "1.1.0-beta.4",
44
"description": "Default plugin for Codify - provides 50+ declarative resources for managing development tools and system configuration across macOS and Linux",
55
"main": "dist/index.js",
66
"scripts": {
@@ -41,8 +41,8 @@
4141
"license": "ISC",
4242
"type": "module",
4343
"dependencies": {
44-
"@codifycli/plugin-core": "1.1.0-beta17",
45-
"@codifycli/schemas": "1.1.0-beta6",
44+
"@codifycli/plugin-core": "1.1.0-beta20",
45+
"@codifycli/schemas": "1.1.0-beta8",
4646
"ajv": "^8.18.0",
4747
"ajv-formats": "^2.1.1",
4848
"chalk": "^5.3.0",

src/resources/docker/docker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class DockerResource extends Resource<DockerConfig> {
8585

8686
// TODO: Attempt to sleep until Docker is ready
8787
await this.sleep(1000);
88-
await $.spawn('hdiutil detach /Volumes/Docker', { cwd: tmpDir })
88+
await $.spawnSafe('hdiutil detach /Volumes/Docker', { cwd: tmpDir })
8989
} finally {
9090
await fs.rm(tmpDir, { recursive: true, force: true })
9191
}

src/resources/homebrew/casks-parameter.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,31 @@ export class CasksParameter extends StatefulParameter<HomebrewConfig, string[]>
9797
return;
9898
}
9999

100-
const result = await $.spawnSafe(`brew install --casks --adopt ${casksToInstall.join(' ')}`, {
101-
interactive: true,
102-
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
103-
})
100+
for (const cask of casksToInstall) {
101+
const result = await $.spawnSafe(`brew install --casks ${cask}`, {
102+
interactive: true,
103+
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
104+
})
104105

105-
if (result.status === SpawnStatus.SUCCESS) {
106-
// Casks can't detect if a program was installed by other means. If it returns this message, throw an error
107-
if (result.data.includes('It seems there is already an App at')) {
108-
throw new Error(`A program already exists for cask ${casks}`)
106+
if (result.status === SpawnStatus.SUCCESS) {
107+
console.log(`Installed cask: ${cask}`);
108+
continue;
109109
}
110110

111-
console.log(`Installed casks: ${casks.join(' ')}`);
112-
} else {
113-
throw new Error(`Failed to install casks: ${casks}. ${JSON.stringify(result.data, null, 2)}`)
111+
if (result.data?.includes('It seems there is already an App at')) {
112+
const adoptResult = await $.spawnSafe(`brew install --casks --adopt ${cask}`, {
113+
interactive: true,
114+
env: { HOMEBREW_NO_AUTO_UPDATE: 1 }
115+
})
116+
117+
if (adoptResult.status === SpawnStatus.SUCCESS) {
118+
console.log(`Installed cask (adopted): ${cask}`);
119+
} else {
120+
throw new Error(`Failed to install cask ${cask} with --adopt: ${JSON.stringify(adoptResult.data, null, 2)}`)
121+
}
122+
} else {
123+
throw new Error(`Failed to install cask: ${cask}. ${JSON.stringify(result.data, null, 2)}`)
124+
}
114125
}
115126
}
116127

src/resources/javascript/npm/global-install.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ export class NpmInstallParameter extends StatefulParameter<NpmConfig, string[]>
3939

4040
const parsedData = JSON.parse(data) as NpmLsResponse;
4141

42-
return Object.entries(parsedData.dependencies ?? {}).map(([name, info]) => {
43-
// If desired entry has a version specifier, return name@version so equality checks work
44-
if (desired?.some((d) => d.includes('@') && packageName(d) === name)) {
45-
return `${name}@${info.version}`
46-
}
47-
return name
48-
})
42+
return Object.entries(parsedData.dependencies ?? {})
43+
.filter(([name]) => name !== 'corepack')
44+
.map(([name, info]) => {
45+
// If desired entry has a version specifier, return name@version so equality checks work
46+
if (desired?.some((d) => d.includes('@') && packageName(d) === name)) {
47+
return `${name}@${info.version}`
48+
}
49+
return name
50+
})
4951
}
5052

5153
async add(valueToAdd: string[], plan: Plan<NpmConfig>): Promise<void> {

0 commit comments

Comments
 (0)