-- hJS & hpm Installer for ComputerCraft / CraftOS -- Run via: wget run https://cc.jeremyleonklink.de/hjs local origin = "https://cc.jeremyleonklink.de" term.setTextColor(colors.yellow or 32) print("====================================") print(" Installing hJS & hpm v1.0.0") print(" JavaScript for ComputerCraft") print("====================================") term.setTextColor(colors.white or 1) local binDir = fs.exists("/usr/bin") and "/usr/bin" or (fs.exists("/bin") and "/bin" or "") local hjsDest = binDir ~= "" and (binDir .. "/hjs") or "hjs" local hpmDest = binDir ~= "" and (binDir .. "/hpm") or "hpm" print("Downloading hJS engine from " .. origin .. "/hjs.lua ...") local res = http.get(origin .. "/hjs.lua") if not res then term.setTextColor(colors.red or 16384) print("Failed to download hjs.lua! Check HTTP settings in CC config.") return end local hjsCode = res.readAll() res.close() local f = fs.open(hjsDest, "w") f.write(hjsCode) f.close() term.setTextColor(colors.lime or 8) print("✓ Installed hJS to " .. hjsDest) term.setTextColor(colors.white or 1) print("Downloading hpm package manager from " .. origin .. "/hpm.lua ...") local res2 = http.get(origin .. "/hpm.lua") if not res2 then term.setTextColor(colors.red or 16384) print("Failed to download hpm.lua!") return end local hpmCode = res2.readAll() res2.close() local f2 = fs.open(hpmDest, "w") f2.write(hpmCode) f2.close() term.setTextColor(colors.lime or 8) print("✓ Installed hpm to " .. hpmDest) term.setTextColor(colors.white or 1) -- Set up hjs.lua alias in /usr/bin if present if binDir ~= "" then local f3 = fs.open(binDir .. "/hjs.lua", "w") f3.write('shell.run("' .. hjsDest .. '", ...)\n') f3.close() end term.setTextColor(colors.yellow or 32) print("====================================") term.setTextColor(colors.lime or 8) print("✓ hJS & hpm successfully installed!") term.setTextColor(colors.white or 1) print("Quick start:") print(" hjs -- interactive REPL") print(" hpm init -- create new hJS project") print(" hpm install -- install package from cc-hub") print(" hjs run -- execute hJS script") print("Documentation: " .. origin .. "/hjs/docs")