diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..03b1b3d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,61 @@ +name: Build App + +on: + push: + branches: + - main # Change this to your main branch name + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install Dependencies + run: npm ci # Adjust this based on your project's dependencies + + - name: Build app for all platforms + run: npm run build + + - name: Zip artifacts + run: | + cd dist + for dir in */; do + zip -r "${dir%/}.zip" "$dir" + done + + - name: List artifacts + run: ls dist | grep .zip + + - name: Upload (linux_arm64) + uses: actions/upload-artifact@v4 + with: + name: AutoEvent_linux_arm64 + path: dist/linux_arm64.zip + - name: Upload (linux_armhf) + uses: actions/upload-artifact@v4 + with: + name: AutoEvent_linux_armhf + path: dist/linux_armhf.zip + - name: Upload (linux_x64) + uses: actions/upload-artifact@v4 + with: + name: AutoEvent_linux_x64 + path: dist/linux_x64.zip + - name: Upload (mac_universal) + uses: actions/upload-artifact@v4 + with: + name: AutoEvent_mac_universal + path: dist/mac_universal.zip + - name: Upload (win_x64) + uses: actions/upload-artifact@v4 + with: + name: AutoEvent_win_x64 + path: dist/win_x64.zip \ No newline at end of file diff --git a/neutralino.config.json b/neutralino.config.json index 5ba728c..0bba2c9 100644 --- a/neutralino.config.json +++ b/neutralino.config.json @@ -33,10 +33,10 @@ "binaryVersion": "4.14.1", "clientVersion": "3.12.0", "frontendLibrary": { - "buildCommand": "npm run neu:checkup", + "buildCommand": "npm run neu:empty", "patchFile": "/frontend/index.html", "devUrl": "http://localhost:5173", - "devCommand": "npm run vite:dev", + "devCommand": "npm run neu:empty", "projectPath": "/", "initCommand": "npm install" } diff --git a/package-lock.json b/package-lock.json index 2808e16..15bfe3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,11 +7,12 @@ "": { "name": "neutralino-svelte", "version": "1.1.0", - "license": "ISC", + "license": "MIT", "dependencies": { "@neutralinojs/lib": "^5.0.0" }, "devDependencies": { + "@expo/spawn-async": "^1.7.2", "@neutralinojs/neu": "^10.1.0", "@sveltejs/vite-plugin-svelte": "^3.0.2", "@tsconfig/svelte": "^5.0.2", @@ -412,6 +413,18 @@ "node": ">=12" } }, + "node_modules/@expo/spawn-async": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@expo/spawn-async/-/spawn-async-1.7.2.tgz", + "integrity": "sha512-QdWi16+CHB9JYP7gma19OVVg0BFkvU8zNj9GjWorYI8Iv8FUxjOCcYRuAmX4s/h91e4e7BPsskc8cSrZYho9Ew==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", @@ -1404,6 +1417,20 @@ "node": ">= 6.9.0" } }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/crypto-random-string": { "version": "2.0.0", "dev": true, @@ -2441,6 +2468,12 @@ "dev": true, "license": "MIT" }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, "node_modules/isobject": { "version": "3.0.1", "dev": true, @@ -2998,6 +3031,15 @@ "node": ">=0.10.0" } }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/pathe": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", @@ -3368,6 +3410,27 @@ "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", "dev": true }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/signal-exit": { "version": "3.0.7", "dev": true, @@ -4059,6 +4122,21 @@ "dev": true, "license": "MIT" }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/wrappy": { "version": "1.0.2", "dev": true, diff --git a/package.json b/package.json index 18a249d..69dbc58 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "dev": "vite-node scripts/package/dev.ts", "build": "vite-node scripts/build/ts/index.ts", "check": "svelte-check --tsconfig ./tsconfig.json", - "neu:checkup": "" + "neu:empty": "" }, "keywords": [ "svelte", @@ -20,10 +20,12 @@ "author": "OrigamingWasTaken", "license": "MIT", "devDependencies": { + "@expo/spawn-async": "^1.7.2", "@neutralinojs/neu": "^10.1.0", "@sveltejs/vite-plugin-svelte": "^3.0.2", "@tsconfig/svelte": "^5.0.2", "@types/signale": "^1.4.7", + "@types/tar": "^6.1.11", "await-exec-typescript": "github:artemhp/await-exec-typescript", "jszip": "^3.10.1", "resedit": "^2.0.0", @@ -35,8 +37,7 @@ "typescript": "^5.3.3", "vite": "^5.1.3", "vite-node": "^1.3.1", - "vite-plugin-html": "^3.2.2", - "@types/tar": "^6.1.11" + "vite-plugin-html": "^3.2.2" }, "dependencies": { "@neutralinojs/lib": "^5.0.0" diff --git a/scripts/build/ts/index.ts b/scripts/build/ts/index.ts index 5ab1bfd..b7ae0ed 100644 --- a/scripts/build/ts/index.ts +++ b/scripts/build/ts/index.ts @@ -6,6 +6,7 @@ import fs from 'fs'; import {winBuild} from './win-bundle'; import {Signale} from 'signale'; import {linuxBuild} from './linux-bundle'; +import { exec } from "child_process" export async function build() { const initTime = performance.now(); @@ -34,6 +35,15 @@ export async function build() { copyFolderSync(path.resolve('.tmpbuild'), path.resolve('./dist')); fs.rmSync(path.resolve('.tmpbuild'), {recursive: true, force: true}); logger.success(`Built in ${((performance.now() - initTime) / 1000).toFixed(3)}s`); + switch (process.platform) { + case "linux": + case "darwin": + exec(`open ${path.resolve("./dist")}`); + break; + case "win32": + exec(`start ${path.resolve("./dist")}`); + break; + } } build(); diff --git a/scripts/package/dev.ts b/scripts/package/dev.ts index e8cab6f..176c6a3 100644 --- a/scripts/package/dev.ts +++ b/scripts/package/dev.ts @@ -1,8 +1,13 @@ -import {spawn} from 'child_process'; +import spawn, { type SpawnPromise, type SpawnResult} from '@expo/spawn-async'; import path from 'path'; -import {existsSync, chmodSync} from 'fs'; +import { existsSync, chmodSync, rmSync } from 'fs'; -function main() { +async function main() { + // Clear terminal + process.stdout.write('\x1b[2J') + process.stdout.write('\x1b[0f'); + + // Get the correct binary name let binaryOS = 'linux'; switch (process.platform) { case 'darwin': @@ -11,37 +16,53 @@ function main() { case 'win32': binaryOS = 'win'; break; + default: + break; } - const vite = spawn('vite', { + // Start the vite dev server + const vite = spawn('vite', ["dev"], { cwd: process.cwd(), detached: false, stdio: 'inherit', }); + // Delay to be sure vite was built + console.log("Waiting 2500ms...") + await new Promise(r => setTimeout(r, 2500)); + const args = [ '--window-enable-inspector=true', - '--export-auth-info', '--load-dir-res', `--path=${path.resolve('.')}`, '--neu-dev-extension', '--url=http://localhost:5173', + "--port=5174" ]; - chmodSync(`./bin/neutralino-${binaryOS}_${process.arch}`,"755") - const neu = spawn(`./bin/neutralino-${binaryOS}_${process.arch}`, args, { + // Chmod +x the binary to be able to run it + let bpath: string; + if (process.platform !== "win32") { + bpath = path.resolve(`./bin/neutralino-${binaryOS}_${process.arch}`) + chmodSync(bpath,"755"); + } else { + bpath = path.resolve(`./bin/neutralino-${binaryOS}_winx64.exe`) + } + + await spawn(bpath, args, { cwd: process.cwd(), detached: false, stdio: 'inherit', - }).on('close', () => { - vite.kill(); + }).child.on('close', () => { + vite.child.kill(); process.exit(); }); } +// If the binary folder doesn't exist, then we download it if (!existsSync(path.resolve('./bin'))) { - const neuInstall = spawn('npx', ['neu', 'update'], { + spawn('npx', ['neu', 'update'], { cwd: process.cwd(), detached: false, stdio: 'inherit', - }).on('exit', main); + }).child.on('exit', main); } else { main(); } diff --git a/vite.config.ts b/vite.config.ts index b616bc2..88f8778 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,16 +2,8 @@ import {defineConfig} from 'vite'; import {svelte} from '@sveltejs/vite-plugin-svelte'; import * as path from 'path'; import {createHtmlPlugin} from 'vite-plugin-html'; -import {readFileSync, existsSync} from 'node:fs'; -function getUrl() { - try { - const {port} = JSON.parse(readFileSync('./.tmp/auth_info.json', 'utf-8')); - return `http://localhost:${port}`; - } catch { - return '%PUBLIC_URL%'; - } -} +const NEU_PORRT = 5174 // https://vitejs.dev/config/ export default defineConfig({ @@ -22,7 +14,7 @@ export default defineConfig({ template: 'index.html', inject: { data: { - url: getUrl(), + url: `http://localhost:5174` }, }, }),