Skip to content

Commit

Permalink
Start inlining the data
Browse files Browse the repository at this point in the history
  • Loading branch information
libraryaddict committed Jan 7, 2025
1 parent 164177d commit 1c8fbf4
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 42 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/webpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@ jobs:
git config user.name "Build Script"
git config user.email "<>"
git fetch --all
cp data built/data -r
git switch release
rm -r scripts/
rm -r data/
mv built/scripts scripts
mv built/data data
git add scripts/
git add data/
git commit -m "Build Mafia files for commit $GITHUB_SHA"
git push origin release
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
13 changes: 5 additions & 8 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module.exports = function (api) {
api.cache(true);

return {
exclude: [],
presets: [
Expand All @@ -10,15 +11,11 @@ module.exports = function (api) {
"@babel/preset-env",
{
targets: { rhino: "1.7.13" },
corejs: "3.8.0",
},
],
],
plugins: [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
corejs: "3.8.0"
}
]
],
retainLines: true,
compact: false,
compact: false
};
};
25 changes: 8 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,19 @@
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "npm run build:types && npm run build:js",
"build:types": "tsc",
"prepublish": "tsc",
"build:js": "webpack",
"build": "webpack",
"watch": "webpack --watch --progress"
},
"devDependencies": {
"@babel/cli": "^7.14.8",
"@babel/core": "^7.15.0",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-decorators": "^7.14.5",
"@babel/preset-env": "^7.15.0",
"@babel/preset-typescript": "^7.12.7",
"babel-loader": "^8.2.2",
"@babel/preset-env": "^7.26.0",
"@babel/preset-typescript": "^7.26.0",
"babel-loader": "^9.2.1",
"kol-mallhistory": "0.0.5",
"typescript": "^4.0.3",
"webpack": "^5.8.0",
"webpack-cli": "^4.2.0",
"babel-plugin-polyfill-corejs3": "^0.2.5",
"@babel/plugin-proposal-object-rest-spread": "^7.20.7"
"typescript": "^5.2.2",
"webpack": "^5.88.2",
"webpack-cli": "^4.2.0"
},
"dependencies": {
"kolmafia": "5.27000.0"
"kolmafia": "^5.28094.0"
}
}
8 changes: 4 additions & 4 deletions src/ItemResolver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
Familiar,
familiarEquippedEquipment,
fileToBuffer,
getCampground,
getPermedSkills,
getProperty,
Expand All @@ -18,12 +17,13 @@ import {
toBoolean,
toInt,
toItem,
visitUrl,
visitUrl
} from "kolmafia";
import { ItemStatus, ValItem } from "./AccountValLogic";
import { AccountValColors } from "./AccountValColors";
import { CoinmasterResolver } from "./CoinmasterResolver";
import { PriceResolver } from "./PriceResolver";
import accountvalBinds from "../data/accountval_binds.txt";

class AccValStuff {
itemType: ItemType;
Expand Down Expand Up @@ -58,7 +58,7 @@ export enum ItemType {

CAMPGROUND,

SCRIPT,
SCRIPT
}

export class ItemResolver {
Expand Down Expand Up @@ -323,7 +323,7 @@ export class ItemResolver {
}

loadAccountValStuff(): AccValStuff[] {
const buffer = fileToBuffer("accountval_binds.txt");
const buffer = accountvalBinds;
const values: AccValStuff[] = [];

for (const line of buffer.split(/(\n|\r)+/)) {
Expand Down
4 changes: 4 additions & 0 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*.txt" {
const value: string;
export default value;
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": false,
"pretty": true,
"declaration": false,
"strict": false,
"target": "esnext",
"useDefineForClassFields": true,
"outDir": "../scripts/mine", // Ensure that .d.ts files are created by tsc, but not .js files
// Ensure that Babel can safely transpile files in the TypeScript project
"isolatedModules": false
},
Expand Down
23 changes: 15 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires, no-undef
const path = require("path");

// eslint-disable-next-line no-undef
module.exports = {
entry: {
accountval: "./src/AccountVal.ts",
accountval: "./src/AccountVal.ts"
},
mode: "production",
module: {
Expand All @@ -11,22 +13,27 @@ module.exports = {
// Include ts, tsx, js, and jsx files.
test: /\.(ts|js)x?$/,
//exclude: /node_modules/,
loader: "babel-loader",
loader: "babel-loader"
},
],
{
test: /\.txt/,
type: "asset/source"
}
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
extensions: [".tsx", ".ts", ".js"]
},
output: {
filename: "[name].js",
// eslint-disable-next-line no-undef
path: path.join(__dirname, "./built/scripts/"),
libraryTarget: "commonjs",
libraryTarget: "commonjs"
},
externals: {
kolmafia: "commonjs kolmafia",
kolmafia: "commonjs kolmafia"
},
optimization: {
minimize: false,
},
minimize: false
}
};

0 comments on commit 1c8fbf4

Please sign in to comment.