From 44b4222bc02f102480d1afe05d940612ff6cb983 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 27 Mar 2022 17:56:40 +0200 Subject: WIP Alicorn port (abandonned, To be removed) --- commands/upgrade.js | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'commands/upgrade.js') diff --git a/commands/upgrade.js b/commands/upgrade.js index ac36fd9..0113278 100644 --- a/commands/upgrade.js +++ b/commands/upgrade.js @@ -55,7 +55,7 @@ async function processQueue() { spinner = ora("Checking dependencies...").start(); for (let dependency of pkg.depends) { let cmd = "which"; - if (os.platform() === "win32") { cmd = "where"; } + if (twiplatform === "win32") { cmd = "where"; } try { if (require('child_process').spawnSync(cmd, [dependency]).status !== 0) { spinner.fail("Checking dependencies... failed") @@ -100,7 +100,7 @@ async function processQueue() { spinner = ora("Extracting package...").start(); if (fs.existsSync(home + "/packages/" + pkg.id + "--update-" + version)) fs.rmSync(home + "/packages/" + pkg.id + "--update-" + version, { recursive: true }) fs.renameSync(home + "/buildroot", home + "/packages/" + pkg.id + "--update-" + version); - let change = require('../hooks/diff')(pkg.id, pkg.id + "--update-" + version); + let change = require('../hooks/diff')((twiplatform === "alicorn" ? pkg.id.replaceAll("_", "-").replaceAll(".", "-").split("-").map((i) => { return i.substring(0, 1).toUpperCase() + i.substring(1).toLowerCase() }).join("") : pkg.id), pkg.id + "--update-" + version); require('../hooks/apply_update')(pkg.id, pkg.id + "--update-" + version); fs.rmSync(home + "/packages/" + pkg.id + "--update-" + version, { recursive: true }); delete installed[installed.map(i => i.id).indexOf(pkg.id)]; @@ -119,20 +119,24 @@ async function processQueue() { exec = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + pkg.id + ".json").toString()).execname; } - if (os.platform() === "win32" && typeof pkg.executable.windows === "string") { + if (twiplatform === "win32" && typeof pkg.executable.windows === "string") { fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + pkg.id + ".bat", pkg.executable.windows); - } else if (os.platform() === "linux" && typeof pkg.executable.linux === "string") { + } else if (twiplatform === "linux" && typeof pkg.executable.linux === "string") { fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.linux); require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ]) - } else if (os.platform() === "darwin" && typeof pkg.executable.mac === "string") { + } else if (twiplatform === "darwin" && typeof pkg.executable.mac === "string") { fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.mac); require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ]) + } else if (twiplatform === "alicorn" && typeof pkg.executable.alicorn === "string") { + fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec, pkg.executable.alicorn); + require('child_process').spawnSync("chmod", [ "+x", os.homedir() + "/.twilight/binaries/" + exec ]) } let postinstall = []; - if (os.platform() === "win32") postinstall = pkg.postinstall.windows; - if (os.platform() === "linux") postinstall = pkg.postinstall.linux; - if (os.platform() === "darwin") postinstall = pkg.postinstall.mac; + if (twiplatform === "win32") postinstall = pkg.postinstall.windows; + if (twiplatform === "linux") postinstall = pkg.postinstall.linux; + if (twiplatform === "darwin") postinstall = pkg.postinstall.mac; + if (twiplatform === "alicorn") postinstall = pkg.postinstall.alicorn; if (postinstall.length > 0) { spinner = ora("Running post-install hooks...").start(); @@ -168,23 +172,28 @@ module.exports = async (argv) => { if ((argv.package !== undefined && argv.package === pack.id) || argv.package === undefined) { updated = true; - if (os.platform() === "win32" && pkg.platforms.windows === 0) { + if (twiplatform === "win32" && pkg.platforms.windows === 0) { console.log(c.yellow("warn: ") + "package '" + pack.id + "' not available on platform 'win32' anymore"); installable = false; - } else if (os.platform() === "linux" && pkg.platforms.linux === 0) { + } else if (twiplatform === "linux" && pkg.platforms.linux === 0) { console.log(c.yellow("warn: ") + "package '" + pack.id + "' not available on platform 'linux' anymore"); installable = false; - } else if (os.platform() === "darwin" && pkg.platforms.mac === 0) { + } else if (twiplatform === "darwin" && pkg.platforms.mac === 0) { console.log(c.yellow("warn: ") + "package '" + pack.id + "' not available on platform 'macos' anymore"); installable = false; + } else if (twiplatform === "alicorn" && pkg.platforms.alicorn === 0) { + console.log(c.yellow("warn: ") + "package '" + pack.id + "' not available on platform 'alicorn' anymore"); + installable = false; } - if (os.platform() === "win32" && pkg.platforms.windows === 1) { + if (twiplatform === "win32" && pkg.platforms.windows === 1) { console.log(c.yellow("warn: ") + "package '" + pack.id + "' is experimental on platform 'win32'"); - } else if (os.platform() === "linux" && pkg.platforms.linux === 1) { + } else if (twiplatform === "linux" && pkg.platforms.linux === 1) { console.log(c.yellow("warn: ") + "package '" + pack.id + "' is experimental on platform 'linux'"); - } else if (os.platform() === "darwin" && pkg.platforms.mac === 1) { + } else if (twiplatform === "darwin" && pkg.platforms.mac === 1) { console.log(c.yellow("warn: ") + "package '" + pack.id + "' is experimental on platform 'macos'"); + } else if (twiplatform === "alicorn" && pkg.platforms.mac === 1) { + console.log(c.yellow("warn: ") + "package '" + pack.id + "' is experimental on platform 'alicorn'"); } if (installable) { -- cgit