mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
fmt and lint
This commit is contained in:
@@ -7,6 +7,7 @@ Useful to analyze a player's save game for anomalies.
|
||||
It decodes the save and prettifies the output. Canno be used to modify a save game directly since it drops some properties.
|
||||
|
||||
**Usage**
|
||||
|
||||
```sh
|
||||
node ./pretty-save.js 'C:\\Users\\martin\\Desktop\\bitburnerSave_1641395736_BN12x14.json' 'C:\\Users\\martin\\Desktop\\pretty.json'
|
||||
```
|
||||
@@ -16,6 +17,7 @@ node ./pretty-save.js 'C:\\Users\\martin\\Desktop\\bitburnerSave_1641395736_BN12
|
||||
Used to synchronize the achievements info in steamworks to the game's data.json
|
||||
|
||||
**Usage**
|
||||
|
||||
```sh
|
||||
# Get your key here: https://steamcommunity.com/dev/apikey
|
||||
node fetch-steam-achievements-data.js DEVKEYDEVKEYDEVKEYDEVKEY
|
||||
@@ -28,6 +30,7 @@ The key is a personnal access token, from https://github.com/settings/tokens.
|
||||
It requires the "gist" scope as the result is pushed to a secret gist.
|
||||
|
||||
**Usage**
|
||||
|
||||
```sh
|
||||
cd ./tools/fetch-changelog
|
||||
npm install
|
||||
@@ -41,6 +44,7 @@ Used to update the game's various version identifier.
|
||||
Requires pandoc installed to convert .md to .rst
|
||||
|
||||
**Usage**
|
||||
|
||||
```sh
|
||||
cd ./tools/bump-version
|
||||
npm install
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// import { Octokit } from "@octokit/rest";
|
||||
import commandLineArgs from "command-line-args";
|
||||
|
||||
import fs from 'fs/promises';
|
||||
import { readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import pandoc from 'node-pandoc';
|
||||
import fs from "fs/promises";
|
||||
import { readFileSync } from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import pandoc from "node-pandoc";
|
||||
|
||||
// https://github.com/75lb/command-line-args
|
||||
const optionDefinitions = [
|
||||
{ name: 'version', alias: 'v', type: String, required: true },
|
||||
{ name: 'versionNumber', alias: 'n', type: Number },
|
||||
{ name: 'versionDescription', alias: 'd', type: String },
|
||||
{ name: 'changelog', alias: 'l', type: String },
|
||||
{ name: "version", alias: "v", type: String, required: true },
|
||||
{ name: "versionNumber", alias: "n", type: Number },
|
||||
{ name: "versionDescription", alias: "d", type: String },
|
||||
{ name: "changelog", alias: "l", type: String },
|
||||
];
|
||||
|
||||
const cliArgs = commandLineArgs(optionDefinitions);
|
||||
@@ -28,62 +28,69 @@ appPaths.sphinxChangelog = path.join(appPaths.root, "./doc/source/changelog.rst"
|
||||
async function main(version, versionNumber, changelog) {
|
||||
console.log(`Updating app files to match v${version}`);
|
||||
|
||||
const [ major, minor ]= version.split('.');
|
||||
const [major, minor] = version.split(".");
|
||||
const shortVersion = `${major}.${minor}`;
|
||||
const modifiedMainPackage = (await fs.readFile(appPaths.mainPackage, 'utf8')).
|
||||
replace(/(^\s*"version":\s)"(.*)",$/m, `$1"${version}",`);
|
||||
const modifiedMainPackage = (await fs.readFile(appPaths.mainPackage, "utf8")).replace(
|
||||
/(^\s*"version":\s)"(.*)",$/m,
|
||||
`$1"${version}",`,
|
||||
);
|
||||
await fs.writeFile(appPaths.mainPackage, modifiedMainPackage);
|
||||
console.log(`Modified ${appPaths.mainPackage}`);
|
||||
|
||||
const modifiedElectronPackage = (await fs.readFile(appPaths.electronPackage, 'utf8')).
|
||||
replace(/(^\s*"version":\s)"(.*)",$/m, `$1"${version}",`);
|
||||
const modifiedElectronPackage = (await fs.readFile(appPaths.electronPackage, "utf8")).replace(
|
||||
/(^\s*"version":\s)"(.*)",$/m,
|
||||
`$1"${version}",`,
|
||||
);
|
||||
await fs.writeFile(appPaths.electronPackage, modifiedElectronPackage);
|
||||
console.log(`Modified ${appPaths.electronPackage}`);
|
||||
|
||||
let modifiedConstants = (await fs.readFile(appPaths.constants, 'utf8')).
|
||||
replace(/(^\s*?VersionString:\s)"(.*)",/m, `$1"${version}",`);
|
||||
modifiedConstants = modifiedConstants.
|
||||
replace(/(^\s*?VersionNumber:\s)(.*),/m, `$1${versionNumber},`);
|
||||
let modifiedConstants = (await fs.readFile(appPaths.constants, "utf8")).replace(
|
||||
/(^\s*?VersionString:\s)"(.*)",/m,
|
||||
`$1"${version}",`,
|
||||
);
|
||||
modifiedConstants = modifiedConstants.replace(/(^\s*?VersionNumber:\s)(.*),/m, `$1${versionNumber},`);
|
||||
|
||||
if (changelog.trim() !== '') {
|
||||
let htmlChangelog = '';
|
||||
if (changelog.trim() !== "") {
|
||||
let htmlChangelog = "";
|
||||
try {
|
||||
htmlChangelog = await transform(changelog, 'html');
|
||||
console.log('Converted markdown changelog to html')
|
||||
htmlChangelog = await transform(changelog, "html");
|
||||
console.log("Converted markdown changelog to html");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
const paddedChangelog = htmlChangelog.split('\n').
|
||||
map((line) => (line.trim() !== '' ? ' ' + line : '')).
|
||||
join('\n').replaceAll('`', '\\`');
|
||||
const paddedChangelog = htmlChangelog
|
||||
.split("\n")
|
||||
.map((line) => (line.trim() !== "" ? " " + line : ""))
|
||||
.join("\n")
|
||||
.replaceAll("`", "\\`");
|
||||
|
||||
modifiedConstants = modifiedConstants.
|
||||
replace(/(^\s*?LatestUpdate:\s`\n)(.*)`,$/ms, `$1${paddedChangelog}\n\`,`);
|
||||
modifiedConstants = modifiedConstants.replace(/(^\s*?LatestUpdate:\s`\n)(.*)`,$/ms, `$1${paddedChangelog}\n\`,`);
|
||||
}
|
||||
await fs.writeFile(appPaths.constants, modifiedConstants);
|
||||
console.log(`Modified ${appPaths.constants}`);
|
||||
|
||||
let modifiedSphinxConfig = (await fs.readFile(appPaths.sphinxConf, 'utf8')).
|
||||
replace(/(^version = ')(.*)'$/m, `$1${shortVersion}'`);
|
||||
modifiedSphinxConfig = modifiedSphinxConfig.
|
||||
replace(/(^release = ')(.*)'$/m, `$1${version}'`);
|
||||
let modifiedSphinxConfig = (await fs.readFile(appPaths.sphinxConf, "utf8")).replace(
|
||||
/(^version = ')(.*)'$/m,
|
||||
`$1${shortVersion}'`,
|
||||
);
|
||||
modifiedSphinxConfig = modifiedSphinxConfig.replace(/(^release = ')(.*)'$/m, `$1${version}'`);
|
||||
await fs.writeFile(appPaths.sphinxConf, modifiedSphinxConfig);
|
||||
console.log(`Modified ${appPaths.sphinxConf}`);
|
||||
|
||||
if (changelog.trim() !== '') {
|
||||
let modifiedSphinxChangelog = await fs.readFile(appPaths.sphinxChangelog, 'utf8');
|
||||
const lines = modifiedSphinxChangelog.split('\n');
|
||||
let rstChangelog = '';
|
||||
if (changelog.trim() !== "") {
|
||||
let modifiedSphinxChangelog = await fs.readFile(appPaths.sphinxChangelog, "utf8");
|
||||
const lines = modifiedSphinxChangelog.split("\n");
|
||||
let rstChangelog = "";
|
||||
try {
|
||||
rstChangelog = await transform(changelog, 'rst');
|
||||
console.log('Converted markdown changelog to rst')
|
||||
rstChangelog = await transform(changelog, "rst");
|
||||
console.log("Converted markdown changelog to rst");
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
lines.splice(5, 0, rstChangelog);
|
||||
modifiedSphinxChangelog = lines.join('\n');
|
||||
modifiedSphinxChangelog = lines.join("\n");
|
||||
await fs.writeFile(appPaths.sphinxChangelog, modifiedSphinxChangelog);
|
||||
console.log(`Modified ${appPaths.sphinxChangelog}`);
|
||||
}
|
||||
@@ -106,13 +113,12 @@ async function getChangelog() {
|
||||
// Read from stdin
|
||||
// https://stackoverflow.com/a/56012724
|
||||
try {
|
||||
return readFileSync(0, 'utf-8').replace('\r\n', '\n');
|
||||
return readFileSync(0, "utf-8").replace("\r\n", "\n");
|
||||
} catch (error) {
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
getChangelog().then((changes) => {
|
||||
main(cliArgs.version, cliArgs.versionNumber, changes).then(() => console.log('Done'));
|
||||
})
|
||||
|
||||
main(cliArgs.version, cliArgs.versionNumber, changes).then(() => console.log("Done"));
|
||||
});
|
||||
|
||||
@@ -2,432 +2,365 @@ const numSpaces = 4;
|
||||
const maxLineLength = 160;
|
||||
|
||||
module.exports = {
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
env: {
|
||||
es6: true,
|
||||
node: true,
|
||||
},
|
||||
extends: "eslint:recommended",
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
experimentalObjectRestSpread: true,
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"experimentalObjectRestSpread": true
|
||||
},
|
||||
"ecmaVersion": 8,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"accessor-pairs": [
|
||||
"error",
|
||||
{
|
||||
"getWithoutSet": false,
|
||||
"setWithoutGet": true
|
||||
}
|
||||
],
|
||||
"array-bracket-newline": ["error"],
|
||||
"array-bracket-spacing": ["error"],
|
||||
"array-callback-return": ["error"],
|
||||
"array-element-newline": ["error"],
|
||||
"arrow-body-style": ["error"],
|
||||
"arrow-parens": ["error"],
|
||||
"arrow-spacing": ["error"],
|
||||
"block-scoped-var": ["error"],
|
||||
"block-spacing": ["error"],
|
||||
"brace-style": ["error"],
|
||||
"callback-return": ["error"],
|
||||
"camelcase": ["error"],
|
||||
"capitalized-comments": ["error"],
|
||||
"class-methods-use-this": ["error"],
|
||||
"comma-dangle": ["error"],
|
||||
"comma-spacing": ["error"],
|
||||
"comma-style": [
|
||||
"error",
|
||||
"last"
|
||||
],
|
||||
"complexity": ["error"],
|
||||
"computed-property-spacing": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"consistent-return": ["error"],
|
||||
"consistent-this": ["error"],
|
||||
"constructor-super": ["error"],
|
||||
"curly": ["error"],
|
||||
"default-case": ["error"],
|
||||
"dot-location": [
|
||||
"error",
|
||||
"property"
|
||||
],
|
||||
"dot-notation": ["error"],
|
||||
"eol-last": ["error"],
|
||||
"eqeqeq": ["error"],
|
||||
"for-direction": ["error"],
|
||||
"func-call-spacing": ["error"],
|
||||
"func-name-matching": ["error"],
|
||||
"func-names": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"func-style": ["error"],
|
||||
"function-paren-newline": ["error"],
|
||||
"generator-star-spacing": [
|
||||
"error",
|
||||
"before"
|
||||
],
|
||||
"getter-return": [
|
||||
"error",
|
||||
{
|
||||
"allowImplicit": false
|
||||
}
|
||||
],
|
||||
"global-require": ["error"],
|
||||
"guard-for-in": ["error"],
|
||||
"handle-callback-err": ["error"],
|
||||
"id-blacklist": ["error"],
|
||||
"id-length": ["error"],
|
||||
"id-match": ["error"],
|
||||
"implicit-arrow-linebreak": [
|
||||
"error",
|
||||
"beside"
|
||||
],
|
||||
"indent": [
|
||||
"error",
|
||||
numSpaces,
|
||||
{
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"init-declarations": ["error"],
|
||||
"jsx-quotes": ["error"],
|
||||
"key-spacing": ["error"],
|
||||
"keyword-spacing": ["error"],
|
||||
"line-comment-position": ["error"],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"windows"
|
||||
],
|
||||
"lines-around-comment": ["error"],
|
||||
"lines-between-class-members": ["error"],
|
||||
"max-depth": ["error"],
|
||||
"max-len": [
|
||||
"error",
|
||||
maxLineLength
|
||||
],
|
||||
"max-lines": [
|
||||
"error",
|
||||
{
|
||||
"skipBlankLines": true,
|
||||
"skipComments": true
|
||||
}
|
||||
],
|
||||
"max-nested-callbacks": ["error"],
|
||||
"max-params": ["error"],
|
||||
"max-statements": ["error"],
|
||||
"max-statements-per-line": ["error"],
|
||||
"multiline-comment-style": [
|
||||
"off",
|
||||
"starred-block"
|
||||
],
|
||||
"multiline-ternary": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"new-cap": ["error"],
|
||||
"new-parens": ["error"],
|
||||
"newline-before-return": ["error"],
|
||||
"newline-per-chained-call": ["error"],
|
||||
"no-alert": ["error"],
|
||||
"no-array-constructor": ["error"],
|
||||
"no-await-in-loop": ["error"],
|
||||
"no-bitwise": ["error"],
|
||||
"no-buffer-constructor": ["error"],
|
||||
"no-caller": ["error"],
|
||||
"no-case-declarations": ["error"],
|
||||
"no-catch-shadow": ["error"],
|
||||
"no-class-assign": ["error"],
|
||||
"no-compare-neg-zero": ["error"],
|
||||
"no-cond-assign": [
|
||||
"error",
|
||||
"except-parens"
|
||||
],
|
||||
"no-confusing-arrow": ["error"],
|
||||
"no-console": ["error"],
|
||||
"no-const-assign": ["error"],
|
||||
"no-constant-condition": [
|
||||
"error",
|
||||
{
|
||||
"checkLoops": false
|
||||
}
|
||||
],
|
||||
"no-continue": ["off"],
|
||||
"no-control-regex": ["error"],
|
||||
"no-debugger": ["error"],
|
||||
"no-delete-var": ["error"],
|
||||
"no-div-regex": ["error"],
|
||||
"no-dupe-args": ["error"],
|
||||
"no-dupe-class-members": ["error"],
|
||||
"no-dupe-keys": ["error"],
|
||||
"no-duplicate-case": ["error"],
|
||||
"no-duplicate-imports": [
|
||||
"error",
|
||||
{
|
||||
"includeExports": true
|
||||
}
|
||||
],
|
||||
"no-else-return": ["error"],
|
||||
"no-empty": [
|
||||
"error",
|
||||
{
|
||||
"allowEmptyCatch": false
|
||||
}
|
||||
],
|
||||
"no-empty-character-class": ["error"],
|
||||
"no-empty-function": ["error"],
|
||||
"no-empty-pattern": ["error"],
|
||||
"no-eq-null": ["error"],
|
||||
"no-eval": ["error"],
|
||||
"no-ex-assign": ["error"],
|
||||
"no-extend-native": ["error"],
|
||||
"no-extra-bind": ["error"],
|
||||
"no-extra-boolean-cast": ["error"],
|
||||
"no-extra-label": ["error"],
|
||||
"no-extra-parens": [
|
||||
"error",
|
||||
"all",
|
||||
{
|
||||
"conditionalAssign": false
|
||||
}
|
||||
],
|
||||
"no-extra-semi": ["error"],
|
||||
"no-fallthrough": ["error"],
|
||||
"no-floating-decimal": ["error"],
|
||||
"no-func-assign": ["error"],
|
||||
"no-global-assign": ["error"],
|
||||
"no-implicit-coercion": ["error"],
|
||||
"no-implicit-globals": ["error"],
|
||||
"no-implied-eval": ["error"],
|
||||
"no-inline-comments": ["error"],
|
||||
"no-inner-declarations": [
|
||||
"error",
|
||||
"both"
|
||||
],
|
||||
"no-invalid-regexp": ["error"],
|
||||
"no-invalid-this": ["error"],
|
||||
"no-irregular-whitespace": [
|
||||
"error",
|
||||
{
|
||||
"skipComments": false,
|
||||
"skipRegExps": false,
|
||||
"skipStrings": false,
|
||||
"skipTemplates": false
|
||||
}
|
||||
],
|
||||
"no-iterator": ["error"],
|
||||
"no-label-var": ["error"],
|
||||
"no-labels": ["error"],
|
||||
"no-lone-blocks": ["error"],
|
||||
"no-lonely-if": ["error"],
|
||||
"no-loop-func": ["error"],
|
||||
"no-magic-numbers": [
|
||||
"error",
|
||||
{
|
||||
"ignore": [
|
||||
-1,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"ignoreArrayIndexes": true
|
||||
}
|
||||
],
|
||||
"no-mixed-operators": ["error"],
|
||||
"no-mixed-requires": ["error"],
|
||||
"no-mixed-spaces-and-tabs": ["error"],
|
||||
"no-multi-assign": ["error"],
|
||||
"no-multi-spaces": ["error"],
|
||||
"no-multi-str": ["error"],
|
||||
"no-multiple-empty-lines": [
|
||||
"error",
|
||||
{
|
||||
"max": 1
|
||||
}
|
||||
],
|
||||
"no-native-reassign": ["error"],
|
||||
"no-negated-condition": ["error"],
|
||||
"no-negated-in-lhs": ["error"],
|
||||
"no-nested-ternary": ["error"],
|
||||
"no-new": ["error"],
|
||||
"no-new-func": ["error"],
|
||||
"no-new-object": ["error"],
|
||||
"no-new-require": ["error"],
|
||||
"no-new-symbol": ["error"],
|
||||
"no-new-wrappers": ["error"],
|
||||
"no-obj-calls": ["error"],
|
||||
"no-octal": ["error"],
|
||||
"no-octal-escape": ["error"],
|
||||
"no-param-reassign": ["error"],
|
||||
"no-path-concat": ["error"],
|
||||
"no-plusplus": [
|
||||
"error",
|
||||
{
|
||||
"allowForLoopAfterthoughts": true
|
||||
}
|
||||
],
|
||||
"no-process-env": ["error"],
|
||||
"no-process-exit": ["error"],
|
||||
"no-proto": ["error"],
|
||||
"no-prototype-builtins": ["error"],
|
||||
"no-redeclare": ["error"],
|
||||
"no-regex-spaces": ["error"],
|
||||
"no-restricted-globals": ["error"],
|
||||
"no-restricted-imports": ["error"],
|
||||
"no-restricted-modules": ["error"],
|
||||
"no-restricted-properties": [
|
||||
"error",
|
||||
{
|
||||
"message": "'log' is too general, use an appropriate level when logging.",
|
||||
"object": "console",
|
||||
"property": "log"
|
||||
}
|
||||
],
|
||||
"no-restricted-syntax": ["error"],
|
||||
"no-return-assign": ["error"],
|
||||
"no-return-await": ["error"],
|
||||
"no-script-url": ["error"],
|
||||
"no-self-assign": [
|
||||
"error",
|
||||
{
|
||||
"props": false
|
||||
}
|
||||
],
|
||||
"no-self-compare": ["error"],
|
||||
"no-sequences": ["error"],
|
||||
"no-shadow": ["error"],
|
||||
"no-shadow-restricted-names": ["error"],
|
||||
"no-spaced-func": ["error"],
|
||||
"no-sparse-arrays": ["error"],
|
||||
"no-sync": ["error"],
|
||||
"no-tabs": ["error"],
|
||||
"no-template-curly-in-string": ["error"],
|
||||
"no-ternary": ["off"],
|
||||
"no-this-before-super": ["error"],
|
||||
"no-throw-literal": ["error"],
|
||||
"no-trailing-spaces": ["error"],
|
||||
"no-undef": ["error"],
|
||||
"no-undef-init": ["error"],
|
||||
"no-undefined": ["error"],
|
||||
"no-underscore-dangle": ["error"],
|
||||
"no-unexpected-multiline": ["error"],
|
||||
"no-unmodified-loop-condition": ["error"],
|
||||
"no-unneeded-ternary": ["error"],
|
||||
"no-unreachable": ["error"],
|
||||
"no-unsafe-finally": ["error"],
|
||||
"no-unsafe-negation": ["error"],
|
||||
"no-unused-expressions": ["error"],
|
||||
"no-unused-labels": ["error"],
|
||||
"no-unused-vars": ["error"],
|
||||
"no-use-before-define": ["error"],
|
||||
"no-useless-call": ["error"],
|
||||
"no-useless-computed-key": ["error"],
|
||||
"no-useless-concat": ["error"],
|
||||
"no-useless-constructor": ["error"],
|
||||
"no-useless-escape": ["error"],
|
||||
"no-useless-rename": [
|
||||
"error",
|
||||
{
|
||||
"ignoreDestructuring": false,
|
||||
"ignoreExport": false,
|
||||
"ignoreImport": false
|
||||
}
|
||||
],
|
||||
"no-useless-return": ["error"],
|
||||
"no-var": ["error"],
|
||||
"no-void": ["error"],
|
||||
"no-warning-comments": ["error"],
|
||||
"no-whitespace-before-property": ["error"],
|
||||
"no-with": ["error"],
|
||||
"nonblock-statement-body-position": [
|
||||
"error",
|
||||
"below"
|
||||
],
|
||||
"object-curly-newline": ["error"],
|
||||
"object-curly-spacing": ["error"],
|
||||
"object-property-newline": ["error"],
|
||||
"object-shorthand": ["error"],
|
||||
"one-var": ["off"],
|
||||
"one-var-declaration-per-line": ["error"],
|
||||
"operator-assignment": ["error"],
|
||||
"operator-linebreak": [
|
||||
"error",
|
||||
"none"
|
||||
],
|
||||
"padded-blocks": ["off"],
|
||||
"padding-line-between-statements": ["error"],
|
||||
"prefer-arrow-callback": ["error"],
|
||||
"prefer-const": ["error"],
|
||||
"prefer-destructuring": ["off"],
|
||||
"prefer-numeric-literals": ["error"],
|
||||
"prefer-promise-reject-errors": ["off"],
|
||||
"prefer-reflect": ["error"],
|
||||
"prefer-rest-params": ["error"],
|
||||
"prefer-spread": ["error"],
|
||||
"prefer-template": ["error"],
|
||||
"quote-props": ["error"],
|
||||
"quotes": ["error"],
|
||||
"radix": [
|
||||
"error",
|
||||
"as-needed"
|
||||
],
|
||||
"require-await": ["error"],
|
||||
"require-jsdoc": ["off"],
|
||||
"require-yield": ["error"],
|
||||
"rest-spread-spacing": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"semi": ["error"],
|
||||
"semi-spacing": ["error"],
|
||||
"semi-style": [
|
||||
"error",
|
||||
"last"
|
||||
],
|
||||
"sort-imports": ["error"],
|
||||
"sort-keys": ["error"],
|
||||
"sort-vars": ["error"],
|
||||
"space-before-blocks": ["error"],
|
||||
"space-before-function-paren": ["off"],
|
||||
"space-in-parens": ["error"],
|
||||
"space-infix-ops": ["error"],
|
||||
"space-unary-ops": ["error"],
|
||||
"spaced-comment": ["error"],
|
||||
"strict": ["error"],
|
||||
"switch-colon-spacing": [
|
||||
"error",
|
||||
{
|
||||
"after": true,
|
||||
"before": false
|
||||
}
|
||||
],
|
||||
"symbol-description": ["error"],
|
||||
"template-curly-spacing": ["error"],
|
||||
"template-tag-spacing": ["error"],
|
||||
"unicode-bom": [
|
||||
"error",
|
||||
"never"
|
||||
],
|
||||
"use-isnan": ["error"],
|
||||
"valid-jsdoc": ["error"],
|
||||
"valid-typeof": ["error"],
|
||||
"vars-on-top": ["error"],
|
||||
"wrap-iife": [
|
||||
"error",
|
||||
"any"
|
||||
],
|
||||
"wrap-regex": ["error"],
|
||||
"yield-star-spacing": [
|
||||
"error",
|
||||
"before"
|
||||
],
|
||||
"yoda": [
|
||||
"error",
|
||||
"never"
|
||||
]
|
||||
}
|
||||
ecmaVersion: 8,
|
||||
sourceType: "module",
|
||||
},
|
||||
rules: {
|
||||
"accessor-pairs": [
|
||||
"error",
|
||||
{
|
||||
getWithoutSet: false,
|
||||
setWithoutGet: true,
|
||||
},
|
||||
],
|
||||
"array-bracket-newline": ["error"],
|
||||
"array-bracket-spacing": ["error"],
|
||||
"array-callback-return": ["error"],
|
||||
"array-element-newline": ["error"],
|
||||
"arrow-body-style": ["error"],
|
||||
"arrow-parens": ["error"],
|
||||
"arrow-spacing": ["error"],
|
||||
"block-scoped-var": ["error"],
|
||||
"block-spacing": ["error"],
|
||||
"brace-style": ["error"],
|
||||
"callback-return": ["error"],
|
||||
camelcase: ["error"],
|
||||
"capitalized-comments": ["error"],
|
||||
"class-methods-use-this": ["error"],
|
||||
"comma-dangle": ["error"],
|
||||
"comma-spacing": ["error"],
|
||||
"comma-style": ["error", "last"],
|
||||
complexity: ["error"],
|
||||
"computed-property-spacing": ["error", "never"],
|
||||
"consistent-return": ["error"],
|
||||
"consistent-this": ["error"],
|
||||
"constructor-super": ["error"],
|
||||
curly: ["error"],
|
||||
"default-case": ["error"],
|
||||
"dot-location": ["error", "property"],
|
||||
"dot-notation": ["error"],
|
||||
"eol-last": ["error"],
|
||||
eqeqeq: ["error"],
|
||||
"for-direction": ["error"],
|
||||
"func-call-spacing": ["error"],
|
||||
"func-name-matching": ["error"],
|
||||
"func-names": ["error", "never"],
|
||||
"func-style": ["error"],
|
||||
"function-paren-newline": ["error"],
|
||||
"generator-star-spacing": ["error", "before"],
|
||||
"getter-return": [
|
||||
"error",
|
||||
{
|
||||
allowImplicit: false,
|
||||
},
|
||||
],
|
||||
"global-require": ["error"],
|
||||
"guard-for-in": ["error"],
|
||||
"handle-callback-err": ["error"],
|
||||
"id-blacklist": ["error"],
|
||||
"id-length": ["error"],
|
||||
"id-match": ["error"],
|
||||
"implicit-arrow-linebreak": ["error", "beside"],
|
||||
indent: [
|
||||
"error",
|
||||
numSpaces,
|
||||
{
|
||||
SwitchCase: 1,
|
||||
},
|
||||
],
|
||||
"init-declarations": ["error"],
|
||||
"jsx-quotes": ["error"],
|
||||
"key-spacing": ["error"],
|
||||
"keyword-spacing": ["error"],
|
||||
"line-comment-position": ["error"],
|
||||
"linebreak-style": ["error", "windows"],
|
||||
"lines-around-comment": ["error"],
|
||||
"lines-between-class-members": ["error"],
|
||||
"max-depth": ["error"],
|
||||
"max-len": ["error", maxLineLength],
|
||||
"max-lines": [
|
||||
"error",
|
||||
{
|
||||
skipBlankLines: true,
|
||||
skipComments: true,
|
||||
},
|
||||
],
|
||||
"max-nested-callbacks": ["error"],
|
||||
"max-params": ["error"],
|
||||
"max-statements": ["error"],
|
||||
"max-statements-per-line": ["error"],
|
||||
"multiline-comment-style": ["off", "starred-block"],
|
||||
"multiline-ternary": ["error", "never"],
|
||||
"new-cap": ["error"],
|
||||
"new-parens": ["error"],
|
||||
"newline-before-return": ["error"],
|
||||
"newline-per-chained-call": ["error"],
|
||||
"no-alert": ["error"],
|
||||
"no-array-constructor": ["error"],
|
||||
"no-await-in-loop": ["error"],
|
||||
"no-bitwise": ["error"],
|
||||
"no-buffer-constructor": ["error"],
|
||||
"no-caller": ["error"],
|
||||
"no-case-declarations": ["error"],
|
||||
"no-catch-shadow": ["error"],
|
||||
"no-class-assign": ["error"],
|
||||
"no-compare-neg-zero": ["error"],
|
||||
"no-cond-assign": ["error", "except-parens"],
|
||||
"no-confusing-arrow": ["error"],
|
||||
"no-console": ["error"],
|
||||
"no-const-assign": ["error"],
|
||||
"no-constant-condition": [
|
||||
"error",
|
||||
{
|
||||
checkLoops: false,
|
||||
},
|
||||
],
|
||||
"no-continue": ["off"],
|
||||
"no-control-regex": ["error"],
|
||||
"no-debugger": ["error"],
|
||||
"no-delete-var": ["error"],
|
||||
"no-div-regex": ["error"],
|
||||
"no-dupe-args": ["error"],
|
||||
"no-dupe-class-members": ["error"],
|
||||
"no-dupe-keys": ["error"],
|
||||
"no-duplicate-case": ["error"],
|
||||
"no-duplicate-imports": [
|
||||
"error",
|
||||
{
|
||||
includeExports: true,
|
||||
},
|
||||
],
|
||||
"no-else-return": ["error"],
|
||||
"no-empty": [
|
||||
"error",
|
||||
{
|
||||
allowEmptyCatch: false,
|
||||
},
|
||||
],
|
||||
"no-empty-character-class": ["error"],
|
||||
"no-empty-function": ["error"],
|
||||
"no-empty-pattern": ["error"],
|
||||
"no-eq-null": ["error"],
|
||||
"no-eval": ["error"],
|
||||
"no-ex-assign": ["error"],
|
||||
"no-extend-native": ["error"],
|
||||
"no-extra-bind": ["error"],
|
||||
"no-extra-boolean-cast": ["error"],
|
||||
"no-extra-label": ["error"],
|
||||
"no-extra-parens": [
|
||||
"error",
|
||||
"all",
|
||||
{
|
||||
conditionalAssign: false,
|
||||
},
|
||||
],
|
||||
"no-extra-semi": ["error"],
|
||||
"no-fallthrough": ["error"],
|
||||
"no-floating-decimal": ["error"],
|
||||
"no-func-assign": ["error"],
|
||||
"no-global-assign": ["error"],
|
||||
"no-implicit-coercion": ["error"],
|
||||
"no-implicit-globals": ["error"],
|
||||
"no-implied-eval": ["error"],
|
||||
"no-inline-comments": ["error"],
|
||||
"no-inner-declarations": ["error", "both"],
|
||||
"no-invalid-regexp": ["error"],
|
||||
"no-invalid-this": ["error"],
|
||||
"no-irregular-whitespace": [
|
||||
"error",
|
||||
{
|
||||
skipComments: false,
|
||||
skipRegExps: false,
|
||||
skipStrings: false,
|
||||
skipTemplates: false,
|
||||
},
|
||||
],
|
||||
"no-iterator": ["error"],
|
||||
"no-label-var": ["error"],
|
||||
"no-labels": ["error"],
|
||||
"no-lone-blocks": ["error"],
|
||||
"no-lonely-if": ["error"],
|
||||
"no-loop-func": ["error"],
|
||||
"no-magic-numbers": [
|
||||
"error",
|
||||
{
|
||||
ignore: [-1, 0, 1],
|
||||
ignoreArrayIndexes: true,
|
||||
},
|
||||
],
|
||||
"no-mixed-operators": ["error"],
|
||||
"no-mixed-requires": ["error"],
|
||||
"no-mixed-spaces-and-tabs": ["error"],
|
||||
"no-multi-assign": ["error"],
|
||||
"no-multi-spaces": ["error"],
|
||||
"no-multi-str": ["error"],
|
||||
"no-multiple-empty-lines": [
|
||||
"error",
|
||||
{
|
||||
max: 1,
|
||||
},
|
||||
],
|
||||
"no-native-reassign": ["error"],
|
||||
"no-negated-condition": ["error"],
|
||||
"no-negated-in-lhs": ["error"],
|
||||
"no-nested-ternary": ["error"],
|
||||
"no-new": ["error"],
|
||||
"no-new-func": ["error"],
|
||||
"no-new-object": ["error"],
|
||||
"no-new-require": ["error"],
|
||||
"no-new-symbol": ["error"],
|
||||
"no-new-wrappers": ["error"],
|
||||
"no-obj-calls": ["error"],
|
||||
"no-octal": ["error"],
|
||||
"no-octal-escape": ["error"],
|
||||
"no-param-reassign": ["error"],
|
||||
"no-path-concat": ["error"],
|
||||
"no-plusplus": [
|
||||
"error",
|
||||
{
|
||||
allowForLoopAfterthoughts: true,
|
||||
},
|
||||
],
|
||||
"no-process-env": ["error"],
|
||||
"no-process-exit": ["error"],
|
||||
"no-proto": ["error"],
|
||||
"no-prototype-builtins": ["error"],
|
||||
"no-redeclare": ["error"],
|
||||
"no-regex-spaces": ["error"],
|
||||
"no-restricted-globals": ["error"],
|
||||
"no-restricted-imports": ["error"],
|
||||
"no-restricted-modules": ["error"],
|
||||
"no-restricted-properties": [
|
||||
"error",
|
||||
{
|
||||
message: "'log' is too general, use an appropriate level when logging.",
|
||||
object: "console",
|
||||
property: "log",
|
||||
},
|
||||
],
|
||||
"no-restricted-syntax": ["error"],
|
||||
"no-return-assign": ["error"],
|
||||
"no-return-await": ["error"],
|
||||
"no-script-url": ["error"],
|
||||
"no-self-assign": [
|
||||
"error",
|
||||
{
|
||||
props: false,
|
||||
},
|
||||
],
|
||||
"no-self-compare": ["error"],
|
||||
"no-sequences": ["error"],
|
||||
"no-shadow": ["error"],
|
||||
"no-shadow-restricted-names": ["error"],
|
||||
"no-spaced-func": ["error"],
|
||||
"no-sparse-arrays": ["error"],
|
||||
"no-sync": ["error"],
|
||||
"no-tabs": ["error"],
|
||||
"no-template-curly-in-string": ["error"],
|
||||
"no-ternary": ["off"],
|
||||
"no-this-before-super": ["error"],
|
||||
"no-throw-literal": ["error"],
|
||||
"no-trailing-spaces": ["error"],
|
||||
"no-undef": ["error"],
|
||||
"no-undef-init": ["error"],
|
||||
"no-undefined": ["error"],
|
||||
"no-underscore-dangle": ["error"],
|
||||
"no-unexpected-multiline": ["error"],
|
||||
"no-unmodified-loop-condition": ["error"],
|
||||
"no-unneeded-ternary": ["error"],
|
||||
"no-unreachable": ["error"],
|
||||
"no-unsafe-finally": ["error"],
|
||||
"no-unsafe-negation": ["error"],
|
||||
"no-unused-expressions": ["error"],
|
||||
"no-unused-labels": ["error"],
|
||||
"no-unused-vars": ["error"],
|
||||
"no-use-before-define": ["error"],
|
||||
"no-useless-call": ["error"],
|
||||
"no-useless-computed-key": ["error"],
|
||||
"no-useless-concat": ["error"],
|
||||
"no-useless-constructor": ["error"],
|
||||
"no-useless-escape": ["error"],
|
||||
"no-useless-rename": [
|
||||
"error",
|
||||
{
|
||||
ignoreDestructuring: false,
|
||||
ignoreExport: false,
|
||||
ignoreImport: false,
|
||||
},
|
||||
],
|
||||
"no-useless-return": ["error"],
|
||||
"no-var": ["error"],
|
||||
"no-void": ["error"],
|
||||
"no-warning-comments": ["error"],
|
||||
"no-whitespace-before-property": ["error"],
|
||||
"no-with": ["error"],
|
||||
"nonblock-statement-body-position": ["error", "below"],
|
||||
"object-curly-newline": ["error"],
|
||||
"object-curly-spacing": ["error"],
|
||||
"object-property-newline": ["error"],
|
||||
"object-shorthand": ["error"],
|
||||
"one-var": ["off"],
|
||||
"one-var-declaration-per-line": ["error"],
|
||||
"operator-assignment": ["error"],
|
||||
"operator-linebreak": ["error", "none"],
|
||||
"padded-blocks": ["off"],
|
||||
"padding-line-between-statements": ["error"],
|
||||
"prefer-arrow-callback": ["error"],
|
||||
"prefer-const": ["error"],
|
||||
"prefer-destructuring": ["off"],
|
||||
"prefer-numeric-literals": ["error"],
|
||||
"prefer-promise-reject-errors": ["off"],
|
||||
"prefer-reflect": ["error"],
|
||||
"prefer-rest-params": ["error"],
|
||||
"prefer-spread": ["error"],
|
||||
"prefer-template": ["error"],
|
||||
"quote-props": ["error"],
|
||||
quotes: ["error"],
|
||||
radix: ["error", "as-needed"],
|
||||
"require-await": ["error"],
|
||||
"require-jsdoc": ["off"],
|
||||
"require-yield": ["error"],
|
||||
"rest-spread-spacing": ["error", "never"],
|
||||
semi: ["error"],
|
||||
"semi-spacing": ["error"],
|
||||
"semi-style": ["error", "last"],
|
||||
"sort-imports": ["error"],
|
||||
"sort-keys": ["error"],
|
||||
"sort-vars": ["error"],
|
||||
"space-before-blocks": ["error"],
|
||||
"space-before-function-paren": ["off"],
|
||||
"space-in-parens": ["error"],
|
||||
"space-infix-ops": ["error"],
|
||||
"space-unary-ops": ["error"],
|
||||
"spaced-comment": ["error"],
|
||||
strict: ["error"],
|
||||
"switch-colon-spacing": [
|
||||
"error",
|
||||
{
|
||||
after: true,
|
||||
before: false,
|
||||
},
|
||||
],
|
||||
"symbol-description": ["error"],
|
||||
"template-curly-spacing": ["error"],
|
||||
"template-tag-spacing": ["error"],
|
||||
"unicode-bom": ["error", "never"],
|
||||
"use-isnan": ["error"],
|
||||
"valid-jsdoc": ["error"],
|
||||
"valid-typeof": ["error"],
|
||||
"vars-on-top": ["error"],
|
||||
"wrap-iife": ["error", "any"],
|
||||
"wrap-regex": ["error"],
|
||||
"yield-star-spacing": ["error", "before"],
|
||||
yoda: ["error", "never"],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -8,66 +8,74 @@ const path = require("path");
|
||||
const exec = require("child_process").exec;
|
||||
const semver = require("./semver");
|
||||
|
||||
const getPackageJson = () => new Promise((resolve, reject) => {
|
||||
const getPackageJson = () =>
|
||||
new Promise((resolve, reject) => {
|
||||
try {
|
||||
/* eslint-disable-next-line global-require */
|
||||
resolve(require(path.resolve(process.cwd(), "package.json")));
|
||||
/* eslint-disable-next-line global-require */
|
||||
resolve(require(path.resolve(process.cwd(), "package.json")));
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const getEngines = (data) => new Promise((resolve, reject) => {
|
||||
const getEngines = (data) =>
|
||||
new Promise((resolve, reject) => {
|
||||
let versions = null;
|
||||
|
||||
if (data.engines) {
|
||||
versions = data.engines;
|
||||
versions = data.engines;
|
||||
}
|
||||
|
||||
if (versions) {
|
||||
resolve(versions);
|
||||
resolve(versions);
|
||||
} else {
|
||||
reject("Missing or improper 'engines' property in 'package.json'");
|
||||
reject("Missing or improper 'engines' property in 'package.json'");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const checkNpmVersion = (engines) => new Promise((resolve, reject) => {
|
||||
const checkNpmVersion = (engines) =>
|
||||
new Promise((resolve, reject) => {
|
||||
exec("npm -v", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(`Unable to find NPM version\n${stderr}`);
|
||||
}
|
||||
if (error) {
|
||||
reject(`Unable to find NPM version\n${stderr}`);
|
||||
}
|
||||
|
||||
const npmVersion = stdout.trim();
|
||||
const engineVersion = engines.npm || ">=0";
|
||||
const npmVersion = stdout.trim();
|
||||
const engineVersion = engines.npm || ">=0";
|
||||
|
||||
if (semver.satisfies(npmVersion, engineVersion)) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(`Incorrect npm version\n'package.json' specifies "${engineVersion}", you are currently running "${npmVersion}".`);
|
||||
}
|
||||
if (semver.satisfies(npmVersion, engineVersion)) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(
|
||||
`Incorrect npm version\n'package.json' specifies "${engineVersion}", you are currently running "${npmVersion}".`,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const checkNodeVersion = (engines) => new Promise((resolve, reject) => {
|
||||
const checkNodeVersion = (engines) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const nodeVersion = process.version.substring(1);
|
||||
|
||||
if (semver.satisfies(nodeVersion, engines.node)) {
|
||||
resolve(engines);
|
||||
resolve(engines);
|
||||
} else {
|
||||
reject(`Incorrect node version\n'package.json' specifies "${engines.node}", you are currently running "${process.version}".`);
|
||||
reject(
|
||||
`Incorrect node version\n'package.json' specifies "${engines.node}", you are currently running "${process.version}".`,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
getPackageJson()
|
||||
.then(getEngines)
|
||||
.then(checkNodeVersion)
|
||||
.then(checkNpmVersion)
|
||||
.then(
|
||||
() => true,
|
||||
(error) => {
|
||||
// Specifically disable these as the error message gets lost in the normal unhandled output.
|
||||
/* eslint-disable no-console, no-process-exit */
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
);
|
||||
.then(getEngines)
|
||||
.then(checkNodeVersion)
|
||||
.then(checkNpmVersion)
|
||||
.then(
|
||||
() => true,
|
||||
(error) => {
|
||||
// Specifically disable these as the error message gets lost in the normal unhandled output.
|
||||
/* eslint-disable no-console, no-process-exit */
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
},
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,13 +3,13 @@ import { Octokit } from "@octokit/rest";
|
||||
import commandLineArgs from "command-line-args";
|
||||
|
||||
const owner = "danielyxie";
|
||||
const repo = "bitburner"
|
||||
const repo = "bitburner";
|
||||
const basePath = `https://github.com/${owner}/${repo}`;
|
||||
|
||||
const cliArgs = commandLineArgs([
|
||||
{ name: 'from', alias: 'f', type: String },
|
||||
{ name: 'to', alias: 't', type: String },
|
||||
{ name: 'detailed', alias: 'd', type: Boolean }
|
||||
{ name: "from", alias: "f", type: String },
|
||||
{ name: "to", alias: "t", type: String },
|
||||
{ name: "detailed", alias: "d", type: Boolean },
|
||||
]);
|
||||
|
||||
class MergeChangelog {
|
||||
@@ -18,15 +18,13 @@ class MergeChangelog {
|
||||
}
|
||||
|
||||
async getCommitsSearchResults(query) {
|
||||
const iterator = this.octokit.paginate.iterator(
|
||||
this.octokit.rest.search.commits,
|
||||
{
|
||||
owner, repo,
|
||||
q: query,
|
||||
sort: 'updated',
|
||||
direction: 'desc',
|
||||
},
|
||||
);
|
||||
const iterator = this.octokit.paginate.iterator(this.octokit.rest.search.commits, {
|
||||
owner,
|
||||
repo,
|
||||
q: query,
|
||||
sort: "updated",
|
||||
direction: "desc",
|
||||
});
|
||||
const searchResults = [];
|
||||
for await (const response of iterator) {
|
||||
const entries = response.data.map((entry) => ({
|
||||
@@ -47,15 +45,13 @@ class MergeChangelog {
|
||||
}
|
||||
|
||||
async getPullsSearchResults(query) {
|
||||
const iterator = this.octokit.paginate.iterator(
|
||||
this.octokit.rest.search.issuesAndPullRequests,
|
||||
{
|
||||
owner, repo,
|
||||
q: query,
|
||||
sort: 'committer-date',
|
||||
direction: 'desc',
|
||||
},
|
||||
);
|
||||
const iterator = this.octokit.paginate.iterator(this.octokit.rest.search.issuesAndPullRequests, {
|
||||
owner,
|
||||
repo,
|
||||
q: query,
|
||||
sort: "committer-date",
|
||||
direction: "desc",
|
||||
});
|
||||
|
||||
const searchResults = [];
|
||||
for await (const response of iterator) {
|
||||
@@ -81,14 +77,17 @@ class MergeChangelog {
|
||||
|
||||
const pulls = [];
|
||||
for (const entry of searchResults) {
|
||||
const r = await (this.octokit.rest.pulls.get({
|
||||
owner, repo,
|
||||
pull_number: entry.number,
|
||||
}).then((response) => ({
|
||||
...entry,
|
||||
merge_commit_sha: response.data.merge_commit_sha,
|
||||
head_commit_sha: response.data.head.sha,
|
||||
})));
|
||||
const r = await this.octokit.rest.pulls
|
||||
.get({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: entry.number,
|
||||
})
|
||||
.then((response) => ({
|
||||
...entry,
|
||||
merge_commit_sha: response.data.merge_commit_sha,
|
||||
head_commit_sha: response.data.head.sha,
|
||||
}));
|
||||
pulls.push(r);
|
||||
await sleep(1000);
|
||||
}
|
||||
@@ -97,7 +96,8 @@ class MergeChangelog {
|
||||
|
||||
async getCommit(sha) {
|
||||
const response = await this.octokit.rest.git.getCommit({
|
||||
owner, repo,
|
||||
owner,
|
||||
repo,
|
||||
commit_sha: sha,
|
||||
});
|
||||
const commit = {
|
||||
@@ -105,7 +105,7 @@ class MergeChangelog {
|
||||
message: response.data.message,
|
||||
sha: response.data.sha,
|
||||
url: response.data.html_url,
|
||||
}
|
||||
};
|
||||
return commit;
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ class MergeChangelog {
|
||||
from.date = new Date(from.commit.date);
|
||||
|
||||
if (!sha_to) {
|
||||
const newest = await this.getLastCommitByBranch('dev');
|
||||
to.commit = await this.getCommit(newest)
|
||||
const newest = await this.getLastCommitByBranch("dev");
|
||||
to.commit = await this.getCommit(newest);
|
||||
} else {
|
||||
to.commit = await this.getCommit(sha_to);
|
||||
}
|
||||
@@ -128,32 +128,35 @@ class MergeChangelog {
|
||||
const pullQuery = `user:${owner} repo:${repo} is:pr is:merged merged:"${from.date.toISOString()}..${to.date.toISOString()}"`;
|
||||
|
||||
const commits = await this.getCommitsSearchResults(commitQuery);
|
||||
await sleep(5000)
|
||||
await sleep(5000);
|
||||
const pulls = await this.getPullsSearchResults(pullQuery);
|
||||
await sleep(5000)
|
||||
await sleep(5000);
|
||||
// We only have the merge commit sha & the HEAD sha in this data, but it can exclude some entries
|
||||
const pullsCommitSha = pulls.
|
||||
map((p) => [p.merge_commit_sha, p.head_commit_sha]).
|
||||
reduce((all, current) => [...all, ...current]);
|
||||
const pullsCommitSha = pulls
|
||||
.map((p) => [p.merge_commit_sha, p.head_commit_sha])
|
||||
.reduce((all, current) => [...all, ...current]);
|
||||
|
||||
let danglingCommits = commits.filter((c) => !pullsCommitSha.includes(c.sha));
|
||||
const listPullsPromises = [];
|
||||
for (const commit of danglingCommits) {
|
||||
const promise = this.octokit.rest.repos.listPullRequestsAssociatedWithCommit({
|
||||
owner, repo, commit_sha: commit.sha
|
||||
}).then((response) => ({
|
||||
...commit,
|
||||
nbPulls: response.data.length,
|
||||
}));
|
||||
const promise = this.octokit.rest.repos
|
||||
.listPullRequestsAssociatedWithCommit({
|
||||
owner,
|
||||
repo,
|
||||
commit_sha: commit.sha,
|
||||
})
|
||||
.then((response) => ({
|
||||
...commit,
|
||||
nbPulls: response.data.length,
|
||||
}));
|
||||
listPullsPromises.push(promise);
|
||||
}
|
||||
|
||||
const commitsThatAreIncludedInPulls = (await Promise.all(listPullsPromises)).
|
||||
filter((c) => c.nbPulls > 0).
|
||||
map((c) => c.sha);
|
||||
const commitsThatAreIncludedInPulls = (await Promise.all(listPullsPromises))
|
||||
.filter((c) => c.nbPulls > 0)
|
||||
.map((c) => c.sha);
|
||||
|
||||
danglingCommits = danglingCommits.
|
||||
filter((c) => !commitsThatAreIncludedInPulls.includes(c.sha));
|
||||
danglingCommits = danglingCommits.filter((c) => !commitsThatAreIncludedInPulls.includes(c.sha));
|
||||
return {
|
||||
from,
|
||||
to,
|
||||
@@ -161,7 +164,7 @@ class MergeChangelog {
|
||||
danglingCommits,
|
||||
pullQuery,
|
||||
commitQuery,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async getLastCommitByBranch(branch) {
|
||||
@@ -177,9 +180,9 @@ class MergeChangelog {
|
||||
const changes = await this.getPullsMergedBetween(from, to);
|
||||
const pullLines = changes.pulls.map((line) => this.getPullMarkdown(line, detailedOutput));
|
||||
const commitLines = changes.danglingCommits.map((line) => this.getCommitMarkdown(line, detailedOutput));
|
||||
commitLines.push(`* Nerf noodle bar.`)
|
||||
const shortFrom = changes.from.date.toISOString().split('T')[0];
|
||||
const shortTo = changes.to.date.toISOString().split('T')[0]
|
||||
commitLines.push(`* Nerf noodle bar.`);
|
||||
const shortFrom = changes.from.date.toISOString().split("T")[0];
|
||||
const shortTo = changes.to.date.toISOString().split("T")[0];
|
||||
const shortFromSha = changes.from.commit.sha.slice(0, 7);
|
||||
const shortToSha = changes.to.commit.sha.slice(0, 7);
|
||||
const title = `## [draft] v1.x.x - ${shortFrom} to ${shortTo}`;
|
||||
@@ -194,7 +197,7 @@ Modifications included between **${shortFrom}** and **${shortTo}** (\`${shortFro
|
||||
|
||||
#### Merged Pull Requests
|
||||
|
||||
${pullLines.join('\n')}
|
||||
${pullLines.join("\n")}
|
||||
|
||||
`;
|
||||
|
||||
@@ -202,7 +205,7 @@ ${pullLines.join('\n')}
|
||||
log += `
|
||||
#### Other Changes
|
||||
|
||||
${commitLines.join('\n')}
|
||||
${commitLines.join("\n")}
|
||||
`;
|
||||
}
|
||||
return {
|
||||
@@ -213,33 +216,33 @@ ${commitLines.join('\n')}
|
||||
|
||||
getPullMarkdown(pr, detailedOutput) {
|
||||
if (!detailedOutput) {
|
||||
return `* ` +
|
||||
`${pr.title} (by @${pr.user.login})` +
|
||||
` #[${pr.number}](${pr.url})`;
|
||||
return `* ${pr.title} (by @${pr.user.login}) #[${pr.number}](${pr.url})`;
|
||||
} else {
|
||||
return `* [${pr.merge_commit_sha.slice(0, 7)}](${basePath}/commit/${pr.merge_commit_sha}) | ` +
|
||||
return (
|
||||
`* [${pr.merge_commit_sha.slice(0, 7)}](${basePath}/commit/${pr.merge_commit_sha}) | ` +
|
||||
`${pr.title} ([@${pr.user.login}](${pr.user.url}))` +
|
||||
` PR #[${pr.number}](${pr.url})`;
|
||||
}
|
||||
` PR #[${pr.number}](${pr.url})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
getCommitMarkdown(commit, detailedOutput) {
|
||||
if (!detailedOutput) {
|
||||
return `* ` +
|
||||
`${commit.message} (by @${commit.user.login})` +
|
||||
` - [${commit.sha.slice(0, 7)}](${commit.url})`;
|
||||
return `* ${commit.message} (by @${commit.user.login}) - [${commit.sha.slice(0, 7)}](${commit.url})`;
|
||||
} else {
|
||||
return `* [${commit.sha.slice(0, 7)}](${commit.url}) | ` +
|
||||
`${commit.message} ([@${commit.user.login}](${commit.user.url}))`;
|
||||
return (
|
||||
`* [${commit.sha.slice(0, 7)}](${commit.url}) | ` +
|
||||
`${commit.message} ([@${commit.user.login}](${commit.user.url}))`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const sleep = async (wait) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, wait)
|
||||
})
|
||||
}
|
||||
setTimeout(resolve, wait);
|
||||
});
|
||||
};
|
||||
|
||||
const api = new MergeChangelog({ auth: process.env.GITHUB_API_TOKEN });
|
||||
api.getChangelog(cliArgs.from, cliArgs.to, cliArgs.detailed).then((data) => {
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const https = require('https')
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
const https = require("https");
|
||||
const fs = require("fs").promises;
|
||||
const path = require("path");
|
||||
|
||||
const key = process.argv[2]
|
||||
const key = process.argv[2];
|
||||
|
||||
function getRawJSON() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const options = {
|
||||
hostname: 'api.steampowered.com',
|
||||
hostname: "api.steampowered.com",
|
||||
port: 443,
|
||||
path: `/ISteamUserStats/GetSchemaForGame/v0002/?appid=1812820&key=${key}`,
|
||||
method: 'GET',
|
||||
method: "GET",
|
||||
headers: {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0",
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
||||
}
|
||||
}
|
||||
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
||||
},
|
||||
};
|
||||
|
||||
let data = [];
|
||||
const req = https.request(options, res => {
|
||||
console.log(`statusCode: ${res.statusCode}`)
|
||||
const req = https.request(options, (res) => {
|
||||
console.log(`statusCode: ${res.statusCode}`);
|
||||
|
||||
res.on('data', chunk => {
|
||||
data.push(chunk)
|
||||
})
|
||||
res.on("data", (chunk) => {
|
||||
data.push(chunk);
|
||||
});
|
||||
|
||||
res.on('end', () => {
|
||||
console.log('Response ended: ');
|
||||
res.on("end", () => {
|
||||
console.log("Response ended: ");
|
||||
resolve(Buffer.concat(data).toString());
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
req.on('error', error => {
|
||||
console.error(error)
|
||||
req.on("error", (error) => {
|
||||
console.error(error);
|
||||
req.end();
|
||||
reject(error);
|
||||
});
|
||||
@@ -52,18 +52,17 @@ async function fetchAchievementsData() {
|
||||
Name: a.displayName,
|
||||
Description: a.description,
|
||||
};
|
||||
})
|
||||
});
|
||||
|
||||
const data = {
|
||||
note: '***** Generated from a script, overwritten by steam achievements data *****',
|
||||
note: "***** Generated from a script, overwritten by steam achievements data *****",
|
||||
fetchedOn: new Date().getTime(),
|
||||
achievements,
|
||||
}
|
||||
};
|
||||
|
||||
const jsonPath = path.resolve(__dirname, '../src/Achievements/AchievementData.json');
|
||||
const jsonPath = path.resolve(__dirname, "../src/Achievements/AchievementData.json");
|
||||
await fs.writeFile(jsonPath, JSON.stringify(data, null, 2));
|
||||
return data;
|
||||
}
|
||||
|
||||
fetchAchievementsData().
|
||||
then((json) => console.log(JSON.stringify(json, null, 2)));
|
||||
fetchAchievementsData().then((json) => console.log(JSON.stringify(json, null, 2)));
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
const fs = require("fs").promises;
|
||||
const path = require("path");
|
||||
|
||||
async function getSave(file) {
|
||||
const data = await fs.readFile(file, 'utf8');
|
||||
const data = await fs.readFile(file, "utf8");
|
||||
|
||||
const save = JSON.parse(decodeURIComponent(escape(atob(data))));
|
||||
const saveData = save.data;
|
||||
@@ -19,8 +19,8 @@ async function getSave(file) {
|
||||
VersionSave: JSON.parse(saveData.VersionSave),
|
||||
LastExportBonus: JSON.parse(saveData.LastExportBonus),
|
||||
StaneksGiftSave: JSON.parse(saveData.StaneksGiftSave),
|
||||
SaveTimestamp: new Date(parseInt(saveData.SaveTimestamp ?? '0', 10)).toLocaleString(),
|
||||
}
|
||||
SaveTimestamp: new Date(parseInt(saveData.SaveTimestamp ?? "0", 10)).toLocaleString(),
|
||||
};
|
||||
|
||||
const serverStrings = JSON.parse(saveData.AllServersSave);
|
||||
const servers = {};
|
||||
@@ -38,9 +38,9 @@ async function getSave(file) {
|
||||
}
|
||||
|
||||
async function main(input, output) {
|
||||
const result = await getSave(input)
|
||||
const result = await getSave(input);
|
||||
await fs.writeFile(output, JSON.stringify(result, null, 2));
|
||||
return result
|
||||
return result;
|
||||
}
|
||||
|
||||
const input = path.resolve(process.argv[2]);
|
||||
@@ -50,5 +50,5 @@ console.log(`Input: ${input}`);
|
||||
console.log(`Output: ${output}`);
|
||||
|
||||
main(input, output).then(() => {
|
||||
console.log('Done!');
|
||||
})
|
||||
console.log("Done!");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user