mirror of
https://github.com/Xevion/dotfiles.git
synced 2025-12-15 08:11:38 -06:00
feat: major dotfiles refactor with documentation and multi-platform improvements
- Add comprehensive CLAUDE.md with chezmoi best practices and AI assistant guidelines - Restructure TODO.md with prioritized tasks and detailed organization - Add PowerShell profile template for Windows platform support - Split git configs into identity-specific templates (ryan/xevion) - Convert nushell env.nu and gitconfig to templates for cross-platform rendering - Refactor chezmoi hooks to TypeScript (.init_pre.ts, .update_pre.ts) - Update .chezmoiignore with better platform-specific file handling - Remove deprecated shellchecker.sh and tasks.json from VS Code config - Add mise integration to shell configs (bash, zsh, nushell, PowerShell) - Clean up commonrc.sh.tmpl WSL-specific code - Disable Deno in VS Code settings, enable simple dialog mode - Add nushell extension recommendation to VS Code This commit establishes better cross-platform support (Windows/WSL/Linux), improves documentation for future maintenance, and standardizes configuration management patterns across the repository.
This commit is contained in:
@@ -1,28 +1,27 @@
|
||||
#!/usr/bin/env -S deno run -A
|
||||
#!/usr/bin/env bun
|
||||
console.log("init_pre.ts");
|
||||
|
||||
import { resolve } from "https://deno.land/std/path/mod.ts";
|
||||
import { exists } from "jsr:@std/fs";
|
||||
import { exists } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { $, os } from "npm:zx@8.3.2";
|
||||
import { homedir } from "node:os";
|
||||
import { $ } from "bun";
|
||||
|
||||
const { exit } = Deno;
|
||||
const filePath = join(os.homedir(), "key.txt");
|
||||
const filePath = join(homedir(), "key.txt");
|
||||
|
||||
|
||||
if (await exists(resolve(filePath))) {
|
||||
if (await exists(filePath)) {
|
||||
console.log("key.txt already exists");
|
||||
Deno.exit(0);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Acquire the secret from Doppler
|
||||
const result = await $`doppler secrets get KEY_TXT --plain`;
|
||||
const result = await $`doppler secrets get KEY_TXT --plain`.quiet();
|
||||
|
||||
// Check if the command was successful
|
||||
if (result.exitCode !== 0) {
|
||||
console.error("Failed to get secret KEY_TXT");
|
||||
exit(1);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Write the secret to a file
|
||||
await Deno.writeTextFile(resolve(filePath), result.stdout);
|
||||
await Bun.write(filePath, result.stdout);
|
||||
console.log("key.txt bootstrapped");
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
# Flag variables
|
||||
LATE_FAIL_EXIT=false # Set to true if any installation fails, but only raise an exit at the end
|
||||
DOPPLER_UNAVAILABLE=false # Set to true if Doppler is not available
|
||||
|
||||
apt_update() {
|
||||
# Only run apt update once
|
||||
if [ -f /tmp/.apt-updated ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
sudo apt update >/dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "chezmoi: Critical issue - failed to update apt!"
|
||||
exit 1
|
||||
else
|
||||
touch /tmp/.apt-updated
|
||||
fi
|
||||
}
|
||||
|
||||
install_age() {
|
||||
# Test if age is installed
|
||||
command -v age >/dev/null 2>&1 && return
|
||||
|
||||
# Install age
|
||||
apt_update
|
||||
sudo apt install age
|
||||
}
|
||||
|
||||
# install_cargo_binstall() {
|
||||
# # Test if cargo binstall is installed
|
||||
# cargo binstall --help >/dev/null 2>&1
|
||||
# if [ $? -eq 0 ]; then
|
||||
# return
|
||||
# fi
|
||||
# curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
||||
|
||||
# # Test again
|
||||
# cargo binstall --help
|
||||
# if [ $? -ne 0 ]; then
|
||||
# echo "Failed to install cargo binstall"
|
||||
# exit 1
|
||||
# fi
|
||||
# }
|
||||
|
||||
install_inotify() {
|
||||
if ! dpkg -l inotify-tools >/dev/null 2>&1; then
|
||||
echo "Installing inotify-tools"
|
||||
apt_update
|
||||
sudo apt install inotify-tools
|
||||
fi
|
||||
}
|
||||
|
||||
install_doppler() {
|
||||
if ! command -v doppler >/dev/null 2>&1; then
|
||||
echo "You need to install the Doppler CLI manually (for security purposes)."
|
||||
echo "https://docs.doppler.com/docs/cli#installation"
|
||||
|
||||
DOPPLER_UNAVAILABLE=true
|
||||
LATE_FAIL_EXIT=true
|
||||
fi
|
||||
}
|
||||
|
||||
require_doppler_login() {
|
||||
doppler me >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "You need to login to Doppler."
|
||||
echo "https://docs.doppler.com/docs/cli#logging-in"
|
||||
fi
|
||||
}
|
||||
|
||||
install_deno() {
|
||||
if ! command -v deno >/dev/null 2>&1; then
|
||||
echo "Installing Deno"
|
||||
curl -fsSL https://deno.land/install.sh | sh
|
||||
fi
|
||||
}
|
||||
|
||||
install_inotify
|
||||
install_age
|
||||
# install_cargo_binstall
|
||||
if [ $DOPPLER_UNAVAILABLE = false ]; then
|
||||
install_doppler
|
||||
fi
|
||||
|
||||
if [ $LATE_FAIL_EXIT = true ]; then
|
||||
echo "chezmoi: Some installation(s) failed. Please fix the issues detailed before trying again."
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# chezmoi update --init does not invoke the 'hooks.init.pre' hook, so we do it ourselves
|
||||
if grep -q 'init' <<<$CHEZMOI_ARGS; then
|
||||
# CHEZMOI_UPDATE is just a hint in case we need to know if we're updating
|
||||
CHEZMOI_UPDATE=1 $(dirname $0)/.init_pre.ts
|
||||
fi
|
||||
19
home/hooks/.update_pre.ts
Normal file
19
home/hooks/.update_pre.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
// chezmoi update --init does not invoke the 'hooks.init.pre' hook, so we do it ourselves
|
||||
const chezmoiArgs = process.env.CHEZMOI_ARGS || '';
|
||||
|
||||
if (chezmoiArgs.includes('init')) {
|
||||
// CHEZMOI_UPDATE is just a hint in case we need to know if we're updating
|
||||
const scriptDir = import.meta.dir;
|
||||
const initPreScript = `${scriptDir}/.init_pre.ts`;
|
||||
|
||||
await Bun.spawn(['bun', initPreScript], {
|
||||
env: {
|
||||
...process.env,
|
||||
CHEZMOI_UPDATE: '1'
|
||||
},
|
||||
stdout: 'inherit',
|
||||
stderr: 'inherit'
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user