diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index bb8c585..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,43 +0,0 @@ -name: Build - -env: - SLN_PATH: factorio-achievements-fixer/ - -on: - workflow_dispatch: - push: - paths-ignore: - - "README.md" - - "LICENSE" - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Setup Dotnet - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - - name: Install Application Dependencies - run: dotnet restore ${{ env.SLN_PATH }} - - - name: Build Application - run: dotnet publish ${{ env.SLN_PATH }} --no-restore - - - name: Get Version - id: get_version - run: | - VERSION=$(grep -oP '(?<=\[assembly: AssemblyVersion\(")[^"]+' ${{ env.SLN_PATH }}/AssemblyInfo.cs) - echo "result=$VERSION" >> $GITHUB_OUTPUT - - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: factorio-achievements-fixer-${{ steps.get_version.outputs.result }} - if-no-files-found: error - path: ${{ env.SLN_PATH }}/bin/Release/net8.0-windows/win-x86/publish/factorio-achievements-fixer.exe diff --git a/.gitignore b/.gitignore index 7366976..4108b33 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,24 @@ -.idea -bin/ -obj/ -/packages/ -riderModule.iml -/_ReSharper.Caches/ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..d4fef4e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"] +} diff --git a/factorio-achievements-fixer.sln b/factorio-achievements-fixer.sln deleted file mode 100644 index 4b1b87b..0000000 --- a/factorio-achievements-fixer.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.9.34728.123 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "factorio-achievements-fixer", "factorio-achievements-fixer\factorio-achievements-fixer.csproj", "{52CBAB79-17D2-4BBF-98B2-4A19864C7FAF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {52CBAB79-17D2-4BBF-98B2-4A19864C7FAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {52CBAB79-17D2-4BBF-98B2-4A19864C7FAF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {52CBAB79-17D2-4BBF-98B2-4A19864C7FAF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {52CBAB79-17D2-4BBF-98B2-4A19864C7FAF}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {970EF005-D589-4FEA-8466-86C65F557263} - EndGlobalSection -EndGlobal diff --git a/factorio-achievements-fixer/App.xaml b/factorio-achievements-fixer/App.xaml deleted file mode 100644 index 50e7915..0000000 --- a/factorio-achievements-fixer/App.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/factorio-achievements-fixer/App.xaml.cs b/factorio-achievements-fixer/App.xaml.cs deleted file mode 100644 index 1163219..0000000 --- a/factorio-achievements-fixer/App.xaml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Configuration; -using System.Data; -using System.Windows; - -namespace factorio_achievements_fixer; - -/// -/// Interaction logic for App.xaml -/// -public partial class App : Application -{ -} \ No newline at end of file diff --git a/factorio-achievements-fixer/AssemblyInfo.cs b/factorio-achievements-fixer/AssemblyInfo.cs deleted file mode 100644 index 41fe54d..0000000 --- a/factorio-achievements-fixer/AssemblyInfo.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Reflection; -using System.Windows; - -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] -[assembly: AssemblyProduct("Factorio Achievements Fixer")] -[assembly: AssemblyCopyright("Ryan Walters © 2024")] -[assembly: AssemblyTitle("Factorio Achievements Fixer")] - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] \ No newline at end of file diff --git a/factorio-achievements-fixer/InitialWindow.xaml b/factorio-achievements-fixer/InitialWindow.xaml deleted file mode 100644 index b4f9fcb..0000000 --- a/factorio-achievements-fixer/InitialWindow.xaml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/factorio-achievements-fixer/InitialWindow.xaml.cs b/factorio-achievements-fixer/InitialWindow.xaml.cs deleted file mode 100644 index 3eed70d..0000000 --- a/factorio-achievements-fixer/InitialWindow.xaml.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace factorio_achievements_fixer; - -/// -/// Interaction logic for MainWindow.xaml -/// -public partial class InitialWindow : Window -{ - public InitialWindow() - { - // InitializeComponent(); - - var listView = new ListView - { - Margin = new Thickness(10) - }; - - var gridView = new GridView(); - gridView.Columns.Add(new GridViewColumn - { - Header = "File Name", - DisplayMemberBinding = new Binding("FileName") - }); - - listView.View = gridView; - - var grid = new Grid(); - grid.Children.Add(listView); - - Content = grid; - } - - private void Grid_Drop(object sender, DragEventArgs e) - { - if (!e.Data.GetDataPresent(DataFormats.FileDrop)) - return; - - var files = (string[])e.Data.GetData(DataFormats.FileDrop) ?? Array.Empty(); - if (files.Length != 1) - { - - } - } - - private void Grid_DragOver(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.FileDrop)) - { - e.Effects = DragDropEffects.Copy; - } - else - { - e.Effects = DragDropEffects.None; - } - } - - private void FixAchievements_Click(object sender, RoutedEventArgs e) - { - // handle the fix achievements button click here! - } -} \ No newline at end of file diff --git a/factorio-achievements-fixer/factorio-achievements-fixer.csproj b/factorio-achievements-fixer/factorio-achievements-fixer.csproj deleted file mode 100644 index 9c2e2bd..0000000 --- a/factorio-achievements-fixer/factorio-achievements-fixer.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - WinExe - net8.0-windows - win-x86 - factorio_achievements_fixer - enable - enable - true - Factorio Achievements Fixer - false - true - true - true - true - false - - - \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..4064a79 --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ + + + + + + + Tauri + Preact + Typescript + + + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..fa8210d --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "factorio-achievements-fixer", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview", + "tauri": "tauri" + }, + "dependencies": { + "preact": "^10.16.0", + "@tauri-apps/api": "^2", + "@tauri-apps/plugin-shell": "^2" + }, + "devDependencies": { + "@preact/preset-vite": "^2.5.0", + "typescript": "^5.2.2", + "vite": "^5.3.1", + "@tauri-apps/cli": "^2" + } +} diff --git a/public/tauri.svg b/public/tauri.svg new file mode 100644 index 0000000..509dded --- /dev/null +++ b/public/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/public/vite.svg b/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src-tauri/.gitignore b/src-tauri/.gitignore new file mode 100644 index 0000000..d8769d0 --- /dev/null +++ b/src-tauri/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Generated by Tauri +# will have schema files for capabilities auto-completion +/gen/schemas diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml new file mode 100644 index 0000000..1ca9ce4 --- /dev/null +++ b/src-tauri/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "factorio-achievements-fixer" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +# The `_lib` suffix may seem redundant but it is necessary +# to make the lib name unique and wouldn't conflict with the bin name. +# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 +name = "factorio_achievements_fixer_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +[build-dependencies] +tauri-build = { version = "2", features = [] } + +[dependencies] +tauri = { version = "2", features = [] } +tauri-plugin-shell = "2" +serde = { version = "1", features = ["derive"] } +serde_json = "1" + diff --git a/src-tauri/build.rs b/src-tauri/build.rs new file mode 100644 index 0000000..2ba80a8 --- /dev/null +++ b/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json new file mode 100644 index 0000000..8518e23 --- /dev/null +++ b/src-tauri/capabilities/default.json @@ -0,0 +1,10 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "Capability for the main window", + "windows": ["main"], + "permissions": [ + "core:default", + "shell:allow-open" + ] +} diff --git a/src-tauri/icons/128x128.png b/src-tauri/icons/128x128.png new file mode 100644 index 0000000..6be5e50 Binary files /dev/null and b/src-tauri/icons/128x128.png differ diff --git a/src-tauri/icons/128x128@2x.png b/src-tauri/icons/128x128@2x.png new file mode 100644 index 0000000..e81bece Binary files /dev/null and b/src-tauri/icons/128x128@2x.png differ diff --git a/src-tauri/icons/32x32.png b/src-tauri/icons/32x32.png new file mode 100644 index 0000000..a437dd5 Binary files /dev/null and b/src-tauri/icons/32x32.png differ diff --git a/src-tauri/icons/Square107x107Logo.png b/src-tauri/icons/Square107x107Logo.png new file mode 100644 index 0000000..0ca4f27 Binary files /dev/null and b/src-tauri/icons/Square107x107Logo.png differ diff --git a/src-tauri/icons/Square142x142Logo.png b/src-tauri/icons/Square142x142Logo.png new file mode 100644 index 0000000..b81f820 Binary files /dev/null and b/src-tauri/icons/Square142x142Logo.png differ diff --git a/src-tauri/icons/Square150x150Logo.png b/src-tauri/icons/Square150x150Logo.png new file mode 100644 index 0000000..624c7bf Binary files /dev/null and b/src-tauri/icons/Square150x150Logo.png differ diff --git a/src-tauri/icons/Square284x284Logo.png b/src-tauri/icons/Square284x284Logo.png new file mode 100644 index 0000000..c021d2b Binary files /dev/null and b/src-tauri/icons/Square284x284Logo.png differ diff --git a/src-tauri/icons/Square30x30Logo.png b/src-tauri/icons/Square30x30Logo.png new file mode 100644 index 0000000..6219700 Binary files /dev/null and b/src-tauri/icons/Square30x30Logo.png differ diff --git a/src-tauri/icons/Square310x310Logo.png b/src-tauri/icons/Square310x310Logo.png new file mode 100644 index 0000000..f9bc048 Binary files /dev/null and b/src-tauri/icons/Square310x310Logo.png differ diff --git a/src-tauri/icons/Square44x44Logo.png b/src-tauri/icons/Square44x44Logo.png new file mode 100644 index 0000000..d5fbfb2 Binary files /dev/null and b/src-tauri/icons/Square44x44Logo.png differ diff --git a/src-tauri/icons/Square71x71Logo.png b/src-tauri/icons/Square71x71Logo.png new file mode 100644 index 0000000..63440d7 Binary files /dev/null and b/src-tauri/icons/Square71x71Logo.png differ diff --git a/src-tauri/icons/Square89x89Logo.png b/src-tauri/icons/Square89x89Logo.png new file mode 100644 index 0000000..f3f705a Binary files /dev/null and b/src-tauri/icons/Square89x89Logo.png differ diff --git a/src-tauri/icons/StoreLogo.png b/src-tauri/icons/StoreLogo.png new file mode 100644 index 0000000..4556388 Binary files /dev/null and b/src-tauri/icons/StoreLogo.png differ diff --git a/src-tauri/icons/icon.icns b/src-tauri/icons/icon.icns new file mode 100644 index 0000000..12a5bce Binary files /dev/null and b/src-tauri/icons/icon.icns differ diff --git a/src-tauri/icons/icon.ico b/src-tauri/icons/icon.ico new file mode 100644 index 0000000..b3636e4 Binary files /dev/null and b/src-tauri/icons/icon.ico differ diff --git a/src-tauri/icons/icon.png b/src-tauri/icons/icon.png new file mode 100644 index 0000000..e1cd261 Binary files /dev/null and b/src-tauri/icons/icon.png differ diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs new file mode 100644 index 0000000..70acc63 --- /dev/null +++ b/src-tauri/src/lib.rs @@ -0,0 +1,14 @@ +// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +#[cfg_attr(mobile, tauri::mobile_entry_point)] +pub fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_shell::init()) + .invoke_handler(tauri::generate_handler![greet]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs new file mode 100644 index 0000000..c9ed9cf --- /dev/null +++ b/src-tauri/src/main.rs @@ -0,0 +1,6 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + factorio_achievements_fixer_lib::run() +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json new file mode 100644 index 0000000..1a28adf --- /dev/null +++ b/src-tauri/tauri.conf.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "productName": "factorio-achievements-fixer", + "version": "0.1.0", + "identifier": "com.factorio-achievements-fixer.app", + "build": { + "beforeDevCommand": "pnpm dev", + "devUrl": "http://localhost:1420", + "beforeBuildCommand": "pnpm build", + "frontendDist": "../dist" + }, + "app": { + "windows": [ + { + "title": "factorio-achievements-fixer", + "width": 800, + "height": 600 + } + ], + "security": { + "csp": null + } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/src/App.css b/src/App.css new file mode 100644 index 0000000..c1b1dd8 --- /dev/null +++ b/src/App.css @@ -0,0 +1,116 @@ +.logo.vite:hover { + filter: drop-shadow(0 0 2em #747bff); +} + +.logo.preact:hover { + filter: drop-shadow(0 0 2em #673ab8); +} +:root { + font-family: Inter, Avenir, Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 24px; + font-weight: 400; + + color: #0f0f0f; + background-color: #f6f6f6; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +.container { + margin: 0; + padding-top: 10vh; + display: flex; + flex-direction: column; + justify-content: center; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: 0.75s; +} + +.logo.tauri:hover { + filter: drop-shadow(0 0 2em #24c8db); +} + +.row { + display: flex; + justify-content: center; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} + +a:hover { + color: #535bf2; +} + +h1 { + text-align: center; +} + +input, +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + color: #0f0f0f; + background-color: #ffffff; + transition: border-color 0.25s; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2); +} + +button { + cursor: pointer; +} + +button:hover { + border-color: #396cd8; +} +button:active { + border-color: #396cd8; + background-color: #e8e8e8; +} + +input, +button { + outline: none; +} + +#greet-input { + margin-right: 5px; +} + +@media (prefers-color-scheme: dark) { + :root { + color: #f6f6f6; + background-color: #2f2f2f; + } + + a:hover { + color: #24c8db; + } + + input, + button { + color: #ffffff; + background-color: #0f0f0f98; + } + button:active { + background-color: #0f0f0f69; + } +} diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..5ae970e --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,51 @@ +import { useState } from "preact/hooks"; +import preactLogo from "./assets/preact.svg"; +import { invoke } from "@tauri-apps/api/core"; +import "./App.css"; + +function App() { + const [greetMsg, setGreetMsg] = useState(""); + const [name, setName] = useState(""); + + async function greet() { + // Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ + setGreetMsg(await invoke("greet", { name })); + } + + return ( + + Welcome to Tauri + Preact + + + + + + + + + + + + + Click on the Tauri, Vite, and Preact logos to learn more. + + { + e.preventDefault(); + greet(); + }} + > + setName(e.currentTarget.value)} + placeholder="Enter a name..." + /> + Greet + + {greetMsg} + + ); +} + +export default App; diff --git a/src/assets/preact.svg b/src/assets/preact.svg new file mode 100644 index 0000000..c7fda77 --- /dev/null +++ b/src/assets/preact.svg @@ -0,0 +1 @@ + diff --git a/src/main.tsx b/src/main.tsx new file mode 100644 index 0000000..99647f5 --- /dev/null +++ b/src/main.tsx @@ -0,0 +1,4 @@ +import { render } from "preact"; +import App from "./App"; + +render(, document.getElementById("root")!); diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts new file mode 100644 index 0000000..7d0ff9e --- /dev/null +++ b/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..4ea355c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "jsxImportSource": "preact", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 0000000..165a9ba --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..63d31cc --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,32 @@ +import { defineConfig } from "vite"; +import preact from "@preact/preset-vite"; + +// @ts-expect-error process is a nodejs global +const host = process.env.TAURI_DEV_HOST; + +// https://vitejs.dev/config/ +export default defineConfig(async () => ({ + plugins: [preact()], + + // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` + // + // 1. prevent vite from obscuring rust errors + clearScreen: false, + // 2. tauri expects a fixed port, fail if that port is not available + server: { + port: 1420, + strictPort: true, + host: host || false, + hmr: host + ? { + protocol: "ws", + host, + port: 1421, + } + : undefined, + watch: { + // 3. tell vite to ignore watching `src-tauri` + ignored: ["**/src-tauri/**"], + }, + }, +}));
Click on the Tauri, Vite, and Preact logos to learn more.
{greetMsg}