diff --git a/devMode.ts b/devMode.ts deleted file mode 100644 index 4428c7f..0000000 --- a/devMode.ts +++ /dev/null @@ -1,112 +0,0 @@ -import * as ts from "typescript"; -import chalk = require("chalk"); -import { ChildProcess, spawn } from "child_process"; -import { removeSync, writeFileSync, copySync } from "fs-extra"; -import { extname } from "path"; -import * as glob from "fast-glob"; - -//* Current child process = null -var currChild: ChildProcess = null; - -//* Format Host -const formatHost: ts.FormatDiagnosticsHost = { - getCanonicalFileName: path => path, - getCurrentDirectory: ts.sys.getCurrentDirectory, - getNewLine: () => ts.sys.newLine -}; - -//* Create ts program -const createProgram = ts.createSemanticDiagnosticsBuilderProgram; - -//* Create Watch compoile host -const host = ts.createWatchCompilerHost( - "./tsconfig.json", - {}, - ts.sys, - createProgram, - null, - fileChange -); - -if (process.argv.length == 3 && process.argv[2] == "compile") - prepareDist().then(() => process.exit()); -//* Create watch program -else ts.createWatchProgram(host); - -async function fileChange(diagnostic: ts.Diagnostic) { - //* TS compilation != done - if (diagnostic.code !== 6194) { - //* If error - if ([6031, 6032].includes(diagnostic.code)) - console.log( - chalk.blueBright(ts.formatDiagnostic(diagnostic, formatHost)) - ); - else - console.log(chalk.redBright(ts.formatDiagnostic(diagnostic, formatHost))); - return; - } else - console.log(chalk.greenBright(ts.formatDiagnostic(diagnostic, formatHost))); - - console.log(currChild && currChild.killed); - //* Kill old child if exists && alive - if (currChild && !currChild.killed) currChild.kill(); - - //* Run devMode script - prepareDist(); - - //* Clear console - console.clear(); - - //* Run child - currChild = spawn("yarn start", { - shell: true, - stdio: "inherit" - }); -} - -//* Prepare dist folder -async function prepareDist() { - //* Select files - var dist = await glob("dist/app/**/*", { onlyFiles: true }), - src = await glob("src/**/*", { onlyFiles: true }); - - //* Filter file differences - var nDist = dist.map(f => [f.replace("dist/app/", ""), f]); - src = src - .map(f => f.replace("src/", "").split(".")[0]) - .filter(sf => nDist.find(d => d[0].split(".")[0] == sf)); - - //* Old files, delete - Promise.all( - dist - .filter(f => !src.includes(f.replace("dist/app/", "").split(".")[0])) - .map(f => removeSync(f)) - ); - - //* Copy package.json (minified) - var packageJSON = require("./package.json"), - srcPackageJSON = packageJSON; - - //* Delete scripts, not needed - delete srcPackageJSON.scripts; - - //* only electron as devDependency - srcPackageJSON.devDependencies = { - electron: packageJSON.devDependencies.electron - }; - - //* Write file - await writeFileSync( - "./src/package.json", - JSON.stringify(srcPackageJSON, null, 2) - ); - - //* Copy files from src to dist - copySync("src", "dist/app", { - filter: function(path) { - if (path.includes("node_modules")) return false; - return extname(path) !== ".ts"; - console.log(path); - } - }); -} diff --git a/package.json b/package.json index 124a8a3..3625280 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "premid", "productName": "PreMiD", "description": "Discord Rich Presence for websites.", - "version": "1.0.0", + "version": "2.0.5", "repository": "https://github.com/PreMiD/PreMiD", "scripts": { "init": "tsc && tsc pkg && devScript --copyOnly", diff --git a/tsconfig.json b/tsconfig.json index 2a95b44..7f47b7e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,10 +8,5 @@ "esModuleInterop": true }, "include": ["src/**/*"], - "exclude": [ - "devMode.ts", - "pkg.ts", - "installer_assets/builder.ts", - ".github/deploy.ts" - ] + "exclude": ["pkg.ts", "installer_assets/builder.ts", ".github/deploy.ts"] } diff --git a/util/prepare.ts b/util/prepare.ts index d3ad482..a8ae591 100644 --- a/util/prepare.ts +++ b/util/prepare.ts @@ -1,6 +1,5 @@ import { readFileSync, writeFileSync } from "fs"; import { parse, stringify } from "ini"; -import { ensureDirSync } from "fs-extra"; let file = readFileSync("installer_assets/installer.xml", "utf-8"); @@ -14,7 +13,9 @@ file = file.replace(/(\.\.\/)/g, ""); writeFileSync("installer.xml", file); -let versionId = "0" + require("../package.json").version.replace(/[.]/g, ""), +let versionId = (require("../package.json").version as string) + .replace(/[.]/g, "") + .padStart(4, "0"), updateIni = parse(readFileSync("installer_assets/update.ini", "utf-8")); updateIni.Update.version_id = versionId;