Skip to content

Commit

Permalink
Merge pull request #103 from Avivbens/more-apps
Browse files Browse the repository at this point in the history
fix(apps): `BetterSnapTool` => `BetterTouchTool`, support `AlDente`
  • Loading branch information
Avivbens committed Jun 6, 2024
2 parents 05b83dd + aed408f commit d66d548
Show file tree
Hide file tree
Showing 15 changed files with 199 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
ignorePatterns: ['.eslintrc.js', 'project-scripts/pack.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**

- OS: [e.g. iOS]
- Version [e.g. 22]
- OS Version [e.g. 22]
- CLI Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
uses: ./.github/workflows/health-check

- name: 🧪 Check pack script
run: npm run pack
run: npm run pack $(jq -r .version package.json)
32 changes: 0 additions & 32 deletions .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,7 @@ jobs:
- name: 🖥️ Setup Env
uses: ./.github/workflows/install

- name: 🆚 Extract Next Release Version
id: extract-version
run: |
npx semantic-release --no-ci --dry-run --plugins @semantic-release/commit-analyzer,@semantic-release/release-notes-generator > output.txt
NEXT_VERSION=$(cat output.txt \
| grep "The next release version is" \
| node -e "console.log(require('fs').readFileSync(0, 'utf-8').match(/The next release version is (\d+\.\d+\.\d+(-beta\.\d+)?)/)?.[1] ?? '')")
echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

- name: 🔨 Build Package
if: steps.extract-version.outputs.version != ''
run: |
# update package.json version - for packing purposes
node -e "const fs = require('fs'); \
const pkg = require('./package.json'); \
pkg.version = '${{ steps.extract-version.outputs.version }}'; \
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 4));"
npm run pack
- name: 🤐 Archive pack file
if: steps.extract-version.outputs.version != ''
uses: thedoctor0/zip-release@master
with:
path: ./bin/*
filename: pack.zip

- name: 🚀 Release
if: steps.extract-version.outputs.version != ''
env:
# This is required to make semantic-release work with GitHub Actions
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
Expand Down
10 changes: 8 additions & 2 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "npm run pack ${nextRelease.version}"
}
],
[
"@semantic-release/git",
{
Expand All @@ -35,12 +41,12 @@
{
"assets": [
{
"path": "./pack.zip",
"path": "dist/cli.zip",
"label": "cli-v${nextRelease.version}.zip",
"name": "cli-v${nextRelease.version}.zip"
}
]
}
]
]
}
}
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ We follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0

Available types:

1. `chore` - changes that should not affect production user code, e.g. update dev-dependencies
1. `fix` - bug fixes, e.g. fix linting errors
1. `feat` - new features, e.g. add new command
1. `docs` - changes to documentation
1. `feat!` - breaking changes, e.g. remove command
1. `ci` - changes to CI configuration
1. For breaking changes, add a `BREAKING CHANGE` section to the commit message body:

```git
feat: <description>
BREAKING CHANGE: <description>
```

## Contact

Expand Down
9 changes: 5 additions & 4 deletions docs/.vitepress/navbar.config.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DefaultTheme } from 'vitepress'
// @ts-expect-error
import { version } from '../../package.json'
import { REPOSITORY_FULLNAME } from './constants/repository.mjs'

export const NAVBAR: DefaultTheme.NavItem[] = [
{ text: 'Home', link: '/' },
Expand All @@ -9,19 +10,19 @@ export const NAVBAR: DefaultTheme.NavItem[] = [
items: [
{
text: 'Changelog',
link: `https://github.com/Avivbens/shell-config/blob/v${version}/CHANGELOG.md`,
link: `https://github.com/${REPOSITORY_FULLNAME}/blob/v${version}/CHANGELOG.md`,
},
{
text: 'Contributing',
link: `https://github.com/Avivbens/shell-config/blob/v${version}/CONTRIBUTING.md`,
link: `https://github.com/${REPOSITORY_FULLNAME}/blob/v${version}/CONTRIBUTING.md`,
},
{
text: 'License',
link: `https://github.com/Avivbens/shell-config/blob/v${version}/LICENSE`,
link: `https://github.com/${REPOSITORY_FULLNAME}/blob/v${version}/LICENSE`,
},
{
text: 'Security',
link: `https://github.com/Avivbens/shell-config/blob/v${version}/SECURITY.md`,
link: `https://github.com/${REPOSITORY_FULLNAME}/blob/v${version}/SECURITY.md`,
},
],
},
Expand Down
12 changes: 6 additions & 6 deletions docs/.vitepress/sidebar.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ export const SIDEBAR: DefaultTheme.Sidebar = [
items: [
{
text: 'Install',
link: '/install.md',
link: '/install',
},
{
text: 'Shell',
link: '/shell.md',
link: '/shell',
},
{
text: 'Assets',
link: '/assets.md',
link: '/assets',
},
{
text: 'Update',
link: '/update.md',
link: '/update',
},
],
},
Expand All @@ -33,11 +33,11 @@ export const SIDEBAR: DefaultTheme.Sidebar = [
items: [
{
text: 'Permissions',
link: '/permissions.md',
link: '/permissions',
},
{
text: 'Not Found',
link: '/not-found.md',
link: '/not-found',
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"homepage": "https://github.com/Avivbens/shell-config#readme",
"scripts": {
"build": "nest build",
"pack": "./project-scripts/pack.sh",
"pack": "./project-scripts/pack.js",
"pack-local": "./project-scripts/pack-local.sh",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"lint": "eslint",
Expand Down Expand Up @@ -138,4 +138,4 @@
"^@commands/(.*)$": "<rootDir>/commands/$1"
}
}
}
}
2 changes: 1 addition & 1 deletion project-scripts/pack-local.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
npm run pack

cp -f ./bin/cli-* ./executable/shell-config
cp -f ./dist/cli-v* ./executable/shell-config
133 changes: 133 additions & 0 deletions project-scripts/pack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#!/usr/bin/env node

const { cwd } = require('node:process')
const { resolve } = require('node:path')
const { exec } = require('node:child_process')
const { rm, readFile, writeFile } = require('node:fs/promises')
const { promisify } = require('node:util')

const execPromise = promisify(exec)

const DIRECTORIES_TO_DELETE = ['dist', 'bin']
const PACKAGE_JSON_FILE = 'package.json'
const PACKAGE_JSON_LOCK_FILE = 'package-lock.json'

const DEFAULT_OPTIONS = { lockfile: false }

function isCI() {
return (
process.env.CI === 'true' ||
process.env.GITHUB_ACTIONS === 'true' ||
process.env.GITLAB_CI === 'true' ||
process.env.CIRCLECI === 'true' ||
process.env.TF_BUILD === 'true' ||
process.env.APPVEYOR === 'True'
)
}

async function readPrettierConfig() {
try {
const filePath = resolve(cwd(), '.prettierrc')

const rawData = await readFile(filePath, 'utf-8')
const jsonData = JSON.parse(rawData)

return jsonData
} catch (error) {
console.error(`Error reading prettier config: ${error.stack}`)
throw error
}
}

async function readWorkflowPackageJson({ lockfile = false } = DEFAULT_OPTIONS) {
try {
const filePath = resolve(cwd(), lockfile ? PACKAGE_JSON_LOCK_FILE : PACKAGE_JSON_FILE)

const rawData = await readFile(filePath, 'utf-8')
const jsonData = JSON.parse(rawData)

return jsonData
} catch (error) {
console.error(`Error reading workflow package.json: ${error.stack}`)
throw error
}
}

async function writeWorkflowPackageJson(
data,
{ lockfile = false } = DEFAULT_OPTIONS,
) {
try {
const { tabWidth = 2 } = await readPrettierConfig()

const filePath = resolve(cwd(), lockfile ? PACKAGE_JSON_LOCK_FILE : PACKAGE_JSON_FILE)

const dataToWrite = JSON.stringify(data, null, tabWidth)

await writeFile(filePath, dataToWrite)
} catch (error) {
console.error(`Error writing workflow package.json: ${error.stack}`)
throw error
}
}

; (async () => {
try {

let [targetVersion] = process.argv.slice(2)
if (!targetVersion) {
if (isCI()) {
console.error('Please provide a version number!')
process.exit(1)
}

console.warn('No version number provided, using 1.0.0')
targetVersion = '1.0.0'
}

/**
* Clean up
* */
console.log('Cleaning up...')
const deletePrm = DIRECTORIES_TO_DELETE.map(dir => rm(dir, { recursive: true, force: true }))
await Promise.all(deletePrm)

/**
* Bump up versions
*/
if (isCI()) {
console.log('Bumping up versions...')

const packageJson = await readWorkflowPackageJson()
packageJson.version = targetVersion
await writeWorkflowPackageJson(packageJson)

const packageLockJson = await readWorkflowPackageJson({ lockfile: true })
packageLockJson.version = targetVersion
await writeWorkflowPackageJson(packageLockJson, { lockfile: true })
} else {
console.warn('Skipping version bumping because it is not running in CI')
}

/**
* Build
*/
console.log('Building...')
await execPromise('npm run build')

/**
* Pack
*/
console.log('Packing...')
await execPromise(`pkg . --output "dist/cli-v${targetVersion}"`)

/**
* ZIP
*/
console.log('Zipping...')
// await execPromise(`zip -9 dist/cli.zip dist/cli-v${targetVersion}`)
await execPromise(`cd dist && zip -9 -r "cli.zip" ./cli-v${targetVersion}`)
} catch (error) {
console.error(`Error: ${error.stack}`)
}
})()
8 changes: 0 additions & 8 deletions project-scripts/pack.sh

This file was deleted.

28 changes: 23 additions & 5 deletions src/commands/install/config/apps-groups/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,26 @@ export const APPS: Readonly<IAppSetup[]> = [
commands: () => [OPEN_APP_STORE_APP_LINK('amphetamine/id937984704')],
},
{
name: 'BetterSnapTool',
description: 'Easy window resize & organize',
name: 'BetterTouchTool',
description: 'Customize input devices on macOS, window snapping, etc.',
group: 'apps',
tags: ['super-user'],
openUrl: () => `open https://folivora.ai/bettersnaptool`,
commands: () => [OPEN_APP_STORE_APP_LINK('bettersnaptool/id417375580')],
paid: true,
openUrl: () => `open https://folivora.ai/`,
commands: () => [BREW_CASK('bettertouchtool')],
},
{
name: 'AlDente',
description: 'Manage and limit maximum charging percentage',
group: 'apps',
tags: ['super-user'],
paid: true,
openUrl: () => BREW_HOME('aldente', true),
commands: () => [BREW_CASK('aldente')],
},
{
name: 'TextSniper',
description: 'Extract and copy text from images',
description: 'Extract and copy text from images (Built-in feature in CleanShot X)',
group: 'apps',
tags: ['productivity'],
paid: true,
Expand All @@ -138,6 +148,14 @@ export const APPS: Readonly<IAppSetup[]> = [
openUrl: () => BREW_HOME('rocket', true),
commands: () => [BREW_CASK('rocket')],
},
{
name: 'Macs Fan Control',
description: 'Control fan speed and monitor temperatures',
group: 'apps',
openUrl: () => BREW_HOME('macs-fan-control', true),
commands: () => [BREW_CASK('macs-fan-control')],
fallbackCommands: () => [BROW_CASK('macs-fan-control')],
},
{
name: 'TinkerTool',
description: 'Access hidden system settings on macOS',
Expand Down
Loading

0 comments on commit d66d548

Please sign in to comment.