From 7b027edb6a5fe8e9aae3acb89ce264f8c00966b6 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Mon, 28 Aug 2023 17:24:01 +0800 Subject: [PATCH] :bug: change ps1 to node --- .github/workflows/pake-cli.yaml | 7 ++++- ...th_pake_cli.js => build_with_pake_cli.mjs} | 27 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) rename script/{build_with_pake_cli.js => build_with_pake_cli.mjs} (75%) diff --git a/.github/workflows/pake-cli.yaml b/.github/workflows/pake-cli.yaml index 7a6c43d..809e84c 100644 --- a/.github/workflows/pake-cli.yaml +++ b/.github/workflows/pake-cli.yaml @@ -110,9 +110,14 @@ jobs: node_modules/pake-cli/src-tauri/target/ key: ${{ inputs.platform }}-cargo-${{ hashFiles('node_modules/pake-cli/src-tauri/Cargo.lock') }} + - name: Install dependencies + run: | + npm install shelljs + npm install axios + - name: build with pake-cli run: | - node ./script/build_with_pake_cli.js + node ./script/build_with_pake_cli.mjs env: URL: ${{ inputs.url }} NAME: ${{ inputs.name }} diff --git a/script/build_with_pake_cli.js b/script/build_with_pake_cli.mjs similarity index 75% rename from script/build_with_pake_cli.js rename to script/build_with_pake_cli.mjs index f56ea32..1726a42 100644 --- a/script/build_with_pake_cli.js +++ b/script/build_with_pake_cli.mjs @@ -1,9 +1,16 @@ -const shell = require('shelljs'); -const axios = require('axios'); -const fs = require('fs'); -const path = require('path'); +import { exec, cd, mv } from 'shelljs'; +import axios from 'axios'; +import { promises as fs } from 'fs'; +import { fileURLToPath } from 'url'; +import path, { dirname } from 'path'; -console.log("Welcome to use Pake Cli~"); +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +console.log("Welcome to use Pake Cli"); +console.log("\n======================="); +console.log("build for app"); +console.log("Node.js info in your localhost ", process.version); console.log("\n=======================\n"); console.log("\n======================="); @@ -19,7 +26,7 @@ console.log("is multi arch? only for Mac: ", process.env.MULTI_ARCH); console.log("targets type? only for Linux: ", process.env.TARGETS); console.log("===========================\n"); -shell.cd('node_modules/pake-cli'); +cd('node_modules/pake-cli'); let params = `node cli.js ${process.env.URL} --name ${process.env.NAME}`; if (process.env.ICON) { @@ -45,7 +52,7 @@ if (process.env.FULLSCREEN === 'true') { } if (process.env.MULTI_ARCH === 'true') { - shell.exec('rustup target add aarch64-apple-darwin'); + exec('rustup target add aarch64-apple-darwin'); params = `${params} --multi-arch`; } @@ -67,11 +74,11 @@ if (process.platform === 'darwin') { console.log("Pake parameters is: ", params); console.log("compile...."); -shell.exec(params); +exec(params); if (!fs.existsSync('output')) { fs.mkdirSync('output'); } -shell.mv(`${process.env.NAME}.*`, 'output/'); +mv(`${process.env.NAME}.*`, 'output/'); console.log("Build Success"); -shell.cd('../..'); +cd('../..');