Skip to content

Commit 821bef6

Browse files
committed
fix: Bug fix for MacOS oclif installer bug. It doesn't clear the oclif update plugin directory so older versions are still usable after re-installing
1 parent a681d7f commit 821bef6

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

scripts/pkg.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import chalk from 'chalk'
22
import { execSync } from 'node:child_process'
33
import fs from 'node:fs/promises'
4+
import path from 'node:path';
45

56
console.log(chalk.magenta('Removing everything in ./.build except tmp'))
67
await fs.readdir('./.build')
@@ -28,7 +29,8 @@ console.log(chalk.magenta('Install production dependencies'))
2829
execSync('npm install --production', { cwd: './.build', shell: 'zsh' })
2930

3031
console.log(chalk.magenta('Running oclif pkg macos'))
31-
execSync('oclif pack macos -r .', { cwd: './.build', shell: 'zsh' })
32+
execSync('oclif pack macos -r .', { cwd: './.build', shell: 'zsh' });
33+
await patchMacOsInstallers()
3234

3335
console.log(chalk.magenta('Running oclif pkg tarballs'))
3436
execSync('oclif pack tarballs -r . -t darwin-arm64,darwin-x64', { cwd: './.build', shell: 'zsh' })
@@ -44,3 +46,24 @@ async function ignoreError(fn: () => Promise<any> | any): Promise<void> {
4446
} catch (e) {
4547
}
4648
}
49+
50+
// Oclif has a bug where the installer doesn't clear out the auto-updater location. This causes older versions
51+
// to be re-used even with a clean install
52+
async function patchMacOsInstallers() {
53+
console.log(chalk.magenta('Patching MacOS installers with bug fix'))
54+
55+
const pkgFolder = './.build/dist/macos';
56+
const files = await fs.readdir(pkgFolder)
57+
const pkgFiles = files.filter((name) => name.endsWith('.pkg'))
58+
59+
for (const pkgFile of pkgFiles) {
60+
const pkgPath = path.join(pkgFolder, pkgFile);
61+
const tmpPath = path.join(pkgFolder, 'tmp');
62+
63+
execSync(`pkgutil --expand ${pkgPath} ${tmpPath}`)
64+
await fs.appendFile(path.join(tmpPath, 'Scripts', 'preinstall'), '\nsudo rm -rf ~/.local/share/codify', 'utf8');
65+
execSync(`pkgutil --flatten ${tmpPath} ${pkgPath} `)
66+
execSync(`rm -rf ${tmpPath}`);
67+
console.log(chalk.magenta(`Done patching installer ${pkgFile}`))
68+
}
69+
}

src/connect/http-routes/handlers/refresh-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function refreshHandler() {
3030
}
3131

3232
if (type === RefreshType.REFRESH_SPECIFIC && (!resourceTypes || !Array.isArray(resourceTypes))) {
33-
throw new Error('For refresh specific, a list of resource types must be provided');
33+
throw new Error(`For refresh specific, a list of resource types must be provided, received: ${resourceTypes}`);
3434
}
3535

3636
if (!validator(codifyConfig)) {

0 commit comments

Comments
 (0)