Skip to content

Commit

Permalink
feat: create symlinks from binAliases to bin for pack:macos (#1109)
Browse files Browse the repository at this point in the history
* feat: create symlinks from binAliases to bin for pack:macos

* chore: bump oclif/core
  • Loading branch information
WillieRuemmele committed Feb 22, 2023
1 parent 930647a commit 70f0b27
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
/test/tmp
package-lock.json
**/.DS_Store
/.idea
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"bugs": "https://github.com/oclif/oclif/issues",
"dependencies": {
"@oclif/core": "^2.0.3",
"@oclif/core": "^2.3.0",
"@oclif/plugin-help": "^5.1.19",
"@oclif/plugin-not-found": "^2.3.7",
"@oclif/plugin-warn-if-update-available": "^2.0.14",
Expand Down Expand Up @@ -141,4 +141,4 @@
"registry": "https://registry.npmjs.org"
},
"types": "lib/index.d.ts"
}
}
12 changes: 8 additions & 4 deletions src/commands/pack/macos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import * as path from 'path'

import * as _ from 'lodash'
import * as fs from 'fs-extra'
import {Command, Flags} from '@oclif/core'
import {Interfaces} from '@oclif/core'
import {Command, Flags, Interfaces} from '@oclif/core'

import * as Tarballs from '../../tarballs'
import {templateShortKey} from '../../upload-util'
import {exec as execSync} from 'child_process'
import {promisify} from 'node:util'
import * as os from 'os'

const exec = promisify(execSync)
type OclifConfig = {
Expand All @@ -33,11 +33,13 @@ sudo rm -rf /usr/local/bin/${config.bin}
${additionalCLI ?
`sudo rm -rf /usr/local/${additionalCLI}
sudo rm -rf /usr/local/bin/${additionalCLI}` : ''}
${config.binAliases ? config.binAliases.map(alias => `sudo rm -rf /usr/local/bin/${alias}`).join(os.EOL) : ''}
`,
postinstall: (config: Interfaces.Config, additionalCLI: string | undefined) => `#!/usr/bin/env bash
set -x
sudo mkdir -p /usr/local/bin
sudo ln -sf /usr/local/lib/${config.dirname}/bin/${config.bin} /usr/local/bin/${config.bin}
${config.binAliases ? config.binAliases?.map(alias => `sudo ln -sf /usr/local/lib/${config.dirname}/bin/${config.bin} /usr/local/bin/${alias}`).join(os.EOL) : ''}
${additionalCLI ? `sudo ln -sf /usr/local/lib/${config.dirname}/bin/${additionalCLI} /usr/local/bin/${additionalCLI}` : ''}
`,
uninstall: (config: Interfaces.Config, additionalCLI: string | undefined) => {
Expand Down Expand Up @@ -79,6 +81,8 @@ while [ "$1" != "-y" ]; do
done
echo "Application uninstalling process started"
# remove bin aliases link
${config.binAliases ? config.binAliases.map(alias => `find "/usr/local/bin/" -name "${alias}" | xargs rm`).join(os.EOL) : ''}
# remove link to shortcut file
find "/usr/local/bin/" -name "${config.bin}" | xargs rm
${additionalCLI ? `find "/usr/local/bin/" -name "${additionalCLI}" | xargs rm` : ''}
Expand All @@ -93,9 +97,9 @@ fi
pkgutil --forget "${packageIdentifier}" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "[2/3] [DONE] Successfully deleted application informations"
echo "[2/3] [DONE] Successfully deleted application information"
else
echo "[2/3] [ERROR] Could not delete application informations" >&2
echo "[2/3] [ERROR] Could not delete application information" >&2
fi
#remove application source distribution
Expand Down
50 changes: 42 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -560,20 +560,20 @@
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/core@^2.0.3":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-2.0.3.tgz#ce71efbfc6e4c2655579ce81adce6471be2bc799"
integrity sha512-Dr6tghg32KKEivcWYqrx9bgC8FDE4i47FLR1wjnLg3jNJWf+blTYorj6aHize2WF0wiwkvB28Cr5TUNBooB4AQ==
"@oclif/core@^2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-2.3.0.tgz#f63071a8116118ae02e457ac1d28a7649904aecf"
integrity sha512-xA53NIZDqz9nuxyCMA5Pz5b1RSgyTNWbtOdwbUJeZa/ajtVrVO9yA8k/4vJRsffUuLyP8tNbh4cH3DDZKwIFnw==
dependencies:
"@types/cli-progress" "^3.11.0"
ansi-escapes "^4.3.2"
ansi-styles "^4.3.0"
cardinal "^2.1.1"
chalk "^4.1.2"
clean-stack "^3.0.1"
cli-progress "^3.10.0"
cli-progress "^3.11.2"
debug "^4.3.4"
ejs "^3.1.6"
ejs "^3.1.8"
fs-extra "^9.1.0"
get-package-type "^0.1.0"
globby "^11.1.0"
Expand All @@ -589,7 +589,7 @@
strip-ansi "^6.0.1"
supports-color "^8.1.1"
supports-hyperlinks "^2.2.0"
tslib "^2.4.1"
tslib "^2.5.0"
widest-line "^3.1.0"
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"
Expand Down Expand Up @@ -1396,6 +1396,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d"
integrity sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=

async@^3.2.3:
version "3.2.4"
resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c"
integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==

at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
Expand Down Expand Up @@ -1681,7 +1686,7 @@ chalk@^3.0.0:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
Expand Down Expand Up @@ -1762,6 +1767,13 @@ cli-progress@^3.10.0:
dependencies:
string-width "^4.2.0"

cli-progress@^3.11.2:
version "3.12.0"
resolved "https://registry.yarnpkg.com/cli-progress/-/cli-progress-3.12.0.tgz#807ee14b66bcc086258e444ad0f19e7d42577942"
integrity sha512-tRkV3HJ1ASwm19THiiLIXLO7Im7wlTuKnvkYaTkyoAPefqjNg7W7DHKUlGRxy9vxDvbyCYQkQozvptuMkGCg8A==
dependencies:
string-width "^4.2.3"

cli-spinners@^2.5.0:
version "2.6.1"
resolved "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.6.1.tgz#adc954ebe281c37a6319bfa401e6dd2488ffb70d"
Expand Down Expand Up @@ -2357,6 +2369,13 @@ ejs@^3.1.6:
dependencies:
jake "^10.6.1"

ejs@^3.1.8:
version "3.1.8"
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.8.tgz#758d32910c78047585c7ef1f92f9ee041c1c190b"
integrity sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==
dependencies:
jake "^10.8.5"

electron-to-chromium@^1.3.886:
version "1.3.894"
resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.894.tgz#54554ecb40d40ddac7241c4a42887e86180015d8"
Expand Down Expand Up @@ -3864,6 +3883,16 @@ jake@^10.6.1:
filelist "^1.0.1"
minimatch "^3.0.4"

jake@^10.8.5:
version "10.8.5"
resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.5.tgz#f2183d2c59382cb274226034543b9c03b8164c46"
integrity sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw==
dependencies:
async "^3.2.3"
chalk "^4.0.2"
filelist "^1.0.1"
minimatch "^3.0.4"

[email protected]:
version "0.16.0"
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.16.0.tgz#b15b0a85dfd4d930d43e69ed605943c802785076"
Expand Down Expand Up @@ -6175,6 +6204,11 @@ tslib@^2, tslib@^2.0.0, tslib@^2.1.0, tslib@^2.3.1, tslib@^2.4.1:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e"
integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==

tslib@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==

tsutils@^3.21.0:
version "3.21.0"
resolved "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
Expand Down

0 comments on commit 70f0b27

Please sign in to comment.