From ecb63a1d0dddc3ef58f2fe8539e8195ed4c2e98a Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Wed, 29 May 2024 23:43:11 +0300 Subject: [PATCH 01/12] fix(apps): `BetterSnapTool` => `BetterTouchTool`, support `AlDente` --- .../install/config/apps-groups/apps.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/commands/install/config/apps-groups/apps.ts b/src/commands/install/config/apps-groups/apps.ts index 767b49b..46c06e6 100755 --- a/src/commands/install/config/apps-groups/apps.ts +++ b/src/commands/install/config/apps-groups/apps.ts @@ -114,16 +114,26 @@ export const APPS: Readonly = [ 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, From 12bd953b3fb38d558ab162b567aa7d2440df3f4e Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Thu, 30 May 2024 00:08:20 +0300 Subject: [PATCH 02/12] fix(node): `package_name` command also return package name & copy it --- zsh/extends/.zshrc.extends.npm.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zsh/extends/.zshrc.extends.npm.sh b/zsh/extends/.zshrc.extends.npm.sh index 4173bcc..0e18d6a 100755 --- a/zsh/extends/.zshrc.extends.npm.sh +++ b/zsh/extends/.zshrc.extends.npm.sh @@ -6,9 +6,12 @@ alias nb="npm run build" alias nt="npm run test" alias nte="npm run test:e2e" -# Get current working directory package name -function package_name () { - cat package.json | jq '.name' | pbcopy +# Get & copy current working directory package name +function package_name() { + local packageName=$(cat package.json | jq '.name') + + echo $packageName | pbcopy + echo $packageName } # Clear all node_modules and reinstall From 87972a3c049481066e4ba141540da57accc16277 Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Thu, 30 May 2024 12:35:13 +0300 Subject: [PATCH 03/12] fix(node): `package_name` raw output --- zsh/extends/.zshrc.extends.npm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh/extends/.zshrc.extends.npm.sh b/zsh/extends/.zshrc.extends.npm.sh index 0e18d6a..1b37a9a 100755 --- a/zsh/extends/.zshrc.extends.npm.sh +++ b/zsh/extends/.zshrc.extends.npm.sh @@ -8,7 +8,7 @@ alias nte="npm run test:e2e" # Get & copy current working directory package name function package_name() { - local packageName=$(cat package.json | jq '.name') + local packageName=$(cat package.json | jq -r '.name') echo $packageName | pbcopy echo $packageName From 6fdb99d1b9ea5fa505911fa2b0f19b0db03c903c Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Sat, 1 Jun 2024 01:57:48 +0300 Subject: [PATCH 04/12] chore: update `CONTRIBUTING.md` file --- CONTRIBUTING.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ef4d1d0..aecdaa2 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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: + +BREAKING CHANGE: +``` ## Contact From f40d40933ade497351a1e81096a1b034d3708c07 Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Mon, 3 Jun 2024 01:00:00 +0300 Subject: [PATCH 05/12] docs(ci): add comments for release process [skip ci] --- .github/workflows/release-ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml index baf4d37..5c116a2 100755 --- a/.github/workflows/release-ci.yml +++ b/.github/workflows/release-ci.yml @@ -58,6 +58,10 @@ jobs: - name: ๐Ÿ–ฅ๏ธ Setup Env uses: ./.github/workflows/install + # ------------------------- + # Check next version + # ------------------------- + - name: ๐Ÿ†š Extract Next Release Version id: extract-version run: | @@ -71,6 +75,10 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + # ------------------------- + # Bail out if no version + # ------------------------- + - name: ๐Ÿ”จ Build Package if: steps.extract-version.outputs.version != '' run: | From 5502bbf178cc64989d3feb8ee2e19cb17673c255 Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Mon, 3 Jun 2024 13:03:06 +0300 Subject: [PATCH 06/12] chore(docs): use repo name variable in navbar --- docs/.vitepress/navbar.config.mts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/.vitepress/navbar.config.mts b/docs/.vitepress/navbar.config.mts index d74adbc..e365e63 100755 --- a/docs/.vitepress/navbar.config.mts +++ b/docs/.vitepress/navbar.config.mts @@ -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: '/' }, @@ -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`, }, ], }, From 1df40fbac367e7cbdbd86718dff3fac9189deee8 Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Mon, 3 Jun 2024 15:35:59 +0300 Subject: [PATCH 07/12] chore(docs): remove `.md` to links --- docs/.vitepress/sidebar.config.mts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/.vitepress/sidebar.config.mts b/docs/.vitepress/sidebar.config.mts index 8c9ace5..590003c 100755 --- a/docs/.vitepress/sidebar.config.mts +++ b/docs/.vitepress/sidebar.config.mts @@ -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', }, ], }, @@ -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', }, ], }, From bbcf0275ae1b8dcad77612ade1fd89e1b1b6c898 Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Wed, 5 Jun 2024 11:55:26 +0300 Subject: [PATCH 08/12] fix(redis): call `redis-server` directly --- zsh/extends/.zshrc.extends.redis.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zsh/extends/.zshrc.extends.redis.sh b/zsh/extends/.zshrc.extends.redis.sh index 7446e9c..013b570 100755 --- a/zsh/extends/.zshrc.extends.redis.sh +++ b/zsh/extends/.zshrc.extends.redis.sh @@ -1,5 +1,6 @@ #! /usr/bin/env zsh function sredis() { - osascript -e 'tell app "Terminal" to do script "cd /tmp && redis-server"' + # osascript -e 'tell app "Terminal" to do script "cd /tmp && redis-server"' + cd /tmp && redis-server } From 3760b9913501d3e86d9d7a3a4b106601a0f48a92 Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Wed, 5 Jun 2024 13:57:14 +0300 Subject: [PATCH 09/12] =?UTF-8?q?fix(apps):=20support=20`Macs=20Fan=20Cont?= =?UTF-8?q?rol`=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/install/config/apps-groups/apps.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/commands/install/config/apps-groups/apps.ts b/src/commands/install/config/apps-groups/apps.ts index 46c06e6..652ef8d 100755 --- a/src/commands/install/config/apps-groups/apps.ts +++ b/src/commands/install/config/apps-groups/apps.ts @@ -148,6 +148,14 @@ export const APPS: Readonly = [ 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', From 7cba32f99be11aa87981946005ede5a06a234d21 Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Thu, 6 Jun 2024 18:16:06 +0300 Subject: [PATCH 10/12] chore: modify GitHub bug template --- .github/ISSUE_TEMPLATE/bug_report.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 298e4c9..8f40a07 100755 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -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. From b4443518a831f7e146a3980b956c2032a1d728c7 Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Thu, 6 Jun 2024 19:04:53 +0300 Subject: [PATCH 11/12] ci: update release process, remove complex code --- .eslintrc.js | 2 +- .github/workflows/release-ci.yml | 40 ---------- .releaserc | 10 ++- package.json | 4 +- project-scripts/pack-local.sh | 2 +- project-scripts/pack.js | 133 +++++++++++++++++++++++++++++++ project-scripts/pack.sh | 8 -- 7 files changed, 145 insertions(+), 54 deletions(-) create mode 100755 project-scripts/pack.js delete mode 100755 project-scripts/pack.sh diff --git a/.eslintrc.js b/.eslintrc.js index 815dc30..fb23498 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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', diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml index 5c116a2..d469d06 100755 --- a/.github/workflows/release-ci.yml +++ b/.github/workflows/release-ci.yml @@ -58,47 +58,7 @@ jobs: - name: ๐Ÿ–ฅ๏ธ Setup Env uses: ./.github/workflows/install - # ------------------------- - # Check next version - # ------------------------- - - - 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 }} - - # ------------------------- - # Bail out if no version - # ------------------------- - - - 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 }} diff --git a/.releaserc b/.releaserc index 6811f4b..5221f5a 100755 --- a/.releaserc +++ b/.releaserc @@ -19,6 +19,12 @@ "changelogFile": "CHANGELOG.md" } ], + [ + "@semantic-release/exec", + { + "prepareCmd": "npm run pack ${nextRelease.version}" + } + ], [ "@semantic-release/git", { @@ -35,7 +41,7 @@ { "assets": [ { - "path": "./pack.zip", + "path": "dist/cli.zip", "label": "cli-v${nextRelease.version}.zip", "name": "cli-v${nextRelease.version}.zip" } @@ -43,4 +49,4 @@ } ] ] -} \ No newline at end of file +} diff --git a/package.json b/package.json index 9bf715b..5761a6e 100755 --- a/package.json +++ b/package.json @@ -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", @@ -138,4 +138,4 @@ "^@commands/(.*)$": "/commands/$1" } } -} \ No newline at end of file +} diff --git a/project-scripts/pack-local.sh b/project-scripts/pack-local.sh index de5ca4f..bdd5d45 100755 --- a/project-scripts/pack-local.sh +++ b/project-scripts/pack-local.sh @@ -1,3 +1,3 @@ npm run pack -cp -f ./bin/cli-* ./executable/shell-config \ No newline at end of file +cp -f ./dist/cli-v* ./executable/shell-config \ No newline at end of file diff --git a/project-scripts/pack.js b/project-scripts/pack.js new file mode 100755 index 0000000..3c88804 --- /dev/null +++ b/project-scripts/pack.js @@ -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}`) + } +})() \ No newline at end of file diff --git a/project-scripts/pack.sh b/project-scripts/pack.sh deleted file mode 100755 index d86212f..0000000 --- a/project-scripts/pack.sh +++ /dev/null @@ -1,8 +0,0 @@ -rm -rf dist -rm -rf bin - -npm run build - -version=$(node -p "require('./package.json').version || 'unknown-version'") -echo "version: $version" -pkg . --output "bin/cli-v$version" \ No newline at end of file From aed408ff074294e2544cee5230aebbc6b2588575 Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Thu, 6 Jun 2024 19:07:02 +0300 Subject: [PATCH 12/12] ci: update pr-checks --- .github/workflows/pr-checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index 48ced04..e1bd152 100755 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -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)