[Release] v0.2.0

This commit is contained in:
Patryk Rzucidlo (PTKDev)
2023-02-11 01:11:16 +01:00
parent abbcd24b5f
commit 770dea9257
81 changed files with 18255 additions and 701 deletions

31
scripts/changelog.ts Normal file
View File

@@ -0,0 +1,31 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/**
* Reset CHANGELOG
* =====================
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
* Alì Shadman [@AliShadman95] (https://github.com/AliShadman95)
*
* @license: MIT License
*
*/
import * as fs from "fs";
declare const __dirname: string;
const changelog = `# v1.0.0 (${new Date().toLocaleString("en-us", {
month: "long",
year: "numeric",
day: "numeric",
})})
- First release
<!-- all-shields/sponsors-badges:START -->
<!-- all-shields/sponsors-badges:END -->
`;
fs.unlinkSync(`${__dirname}/../CHANGELOG.md`);
fs.writeFileSync(`${__dirname}/../CHANGELOG.md`, `${changelog}`, {
encoding: "utf8",
});

6
scripts/changelog_release.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
CHANGELOG=$(cat ./CHANGELOG_RELEASE.txt)
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
echo ::set-output name=changelog::$CHANGELOG

View File

@@ -0,0 +1,31 @@
/**
* Version
* =====================
* Increment package.json version
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
*
* @license: MIT License
*
*/
import * as fs from "fs";
import Logger from "@ptkdev/logger";
const logger = new Logger();
if (fs.existsSync("./CHANGELOG.md")) {
fs.readFile("./CHANGELOG.md", "utf8", (error, data) => {
if (error) {
logger.error(JSON.stringify(error));
}
const changelog = data.match(/\n([\s\S]*)-->\n/gm);
changelog?.forEach((c) => {
fs.writeFile("./CHANGELOG_RELEASE.txt", c, function writeJSON(error) {
if (error) {
logger.error(JSON.stringify(error));
}
});
});
});
}

20
scripts/configs.ts Normal file
View File

@@ -0,0 +1,20 @@
/**
* Check configs.js
* =====================
* Check if configs/config.js exist, if don't exist rename .tpl
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
*
* @license: MIT License
*
*/
import * as fs from "fs";
import * as shell from "shelljs";
declare const __dirname: string;
const path = `${__dirname}/../app/configs/config.js`;
if (!fs.existsSync(path)) {
shell.cp("-Rf", `${__dirname}/../app/configs/config.js.tpl`, path);
}

25
scripts/debug.ts Normal file
View File

@@ -0,0 +1,25 @@
/**
* Disable debug
* =====================
* Check if configs/config.js has debug to off
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
*
* @license: MIT License
*
*/
import * as fs from "fs";
import * as shell from "shelljs";
import { argv } from "yargs";
declare const __dirname: string;
const path = `${__dirname}/../app/configs/config.js`;
if (fs.existsSync(path)) {
if (argv.enable) {
shell.sed("-i", 'debug: "disabled"', 'debug: "enabled"', path);
} else {
shell.sed("-i", 'debug: "enabled"', 'debug: "disabled"', path);
}
}

33
scripts/githash.ts Normal file
View File

@@ -0,0 +1,33 @@
import Logger from "@ptkdev/logger";
import fs from "fs";
import path from "path";
import { execSync } from "child_process";
import semver from "../package.json";
const gitdotfile = `${__dirname}/../.git/config`;
const logger = new Logger();
let branch = "";
let hash = "";
const execSyncWrapper = (command: string) => {
let stdout = "";
try {
stdout = execSync(command).toString().trim();
} catch (error) {
logger.error(JSON.stringify(error));
}
return stdout;
};
if (fs.existsSync(gitdotfile)) {
branch = execSyncWrapper("git rev-parse --abbrev-ref HEAD");
hash = execSyncWrapper("git rev-parse --short=7 HEAD");
}
const obj = {
semver: semver.version.split("-")[0],
branch,
hash,
};
fs.writeFileSync(path.resolve("app/configs", "version.json"), JSON.stringify(obj, null, "\t"));

23
scripts/init.ts Normal file
View File

@@ -0,0 +1,23 @@
/**
* Init
* =====================
* Configure telegram token and username
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
* Alì Shadman [@AliShadman95] (https://github.com/AliShadman95)
*
* @license: MIT License
*
*/
import * as fs from "fs";
import * as shell from "shelljs";
import { argv } from "yargs";
declare const __dirname: string;
console.log(argv, argv._[0]);
const path = `${__dirname}/../app/configs/config.js`;
if (fs.existsSync(path)) {
shell.sed("-i", "BOT_USERNAME", `${argv._[0]}`, path);
shell.sed("-i", "BOT_TOKEN", `${argv._[1]}`, path);
}

16
scripts/rmdist.ts Normal file
View File

@@ -0,0 +1,16 @@
/**
* Delete dist folder
* =====================
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
* Alì Shadman [@AliShadman95] (https://github.com/AliShadman95)
*
* @license: MIT License
*
*/
import * as shell from "shelljs";
declare const __dirname: string;
const path = `${__dirname}/../dist`;
shell.rm("-Rf", path);

3
scripts/version.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
PACKAGE_VERSION=$(cat ./package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
echo ::set-output name=pkgversion::$PACKAGE_VERSION

54
scripts/version.ts Normal file
View File

@@ -0,0 +1,54 @@
/**
* Version
* =====================
* Increment package.json version
*
* @contributors: Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)
*
* @license: MIT License
*
*/
import * as fs from "fs";
import Logger from "@ptkdev/logger";
import { argv } from "yargs";
import pkg from "../package.json";
const logger = new Logger();
const version = pkg.version.split(".");
let next_version, patch;
switch (argv.cmd) {
case "nightly":
next_version = `${version[0]}.${version[1]}.${version[2]}.${Number(version[3]) + 1}`;
break;
case "nightly-next":
patch = version[2].split("-");
next_version = `${version[0]}.${version[1]}.${Number(patch[0]) + 1}-nightly.0`;
break;
case "beta":
patch = version[2].split("-");
next_version = `${version[0]}.${version[1]}.${Number(patch[0])}-beta.1`;
break;
case "main":
patch = version[2].split("-");
next_version = `${version[0]}.${version[1]}.${Number(patch[0])}`;
break;
default:
next_version = "0.0.0";
break;
}
pkg.version = next_version;
if (fs.existsSync("./package.json")) {
fs.writeFile("./package.json", JSON.stringify(pkg), function writeJSON(error) {
if (error) {
logger.error(JSON.stringify(error));
}
});
}