Skip to content

Commit

Permalink
fix: clean up mods setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jomik committed Feb 16, 2024
1 parent d9d8eb0 commit 10317b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ RUN --mount=type=cache,target=/var/cache/apk \
USER node
COPY --from=screeps --chown=node:node /screeps /screeps/

# Init mods package
WORKDIR /screeps/mods
RUN npm init -y

# Move the database file to shared directory
WORKDIR /data
RUN mv /screeps/db.json /data/db.json && \
Expand All @@ -42,8 +38,13 @@ RUN mv /screeps/assets /data/assets && \
sed -i "s/assetdir = assets/assetdir = \/data\/assets/" /screeps/.screepsrc

WORKDIR /screeps

# Init mods package
RUN mkdir ./mods && echo "{}" > ./mods/package.json

COPY screeps-cli.js ./bin/cli
COPY screeps-start.js ./bin/start

ENV SERVER_DIR=/screeps NODE_ENV=production PATH="/screeps/bin:${PATH}"

VOLUME [ "/data" ]
Expand Down
12 changes: 3 additions & 9 deletions screeps-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ const RootDir = process.env["SERVER_DIR"];
if (!RootDir) {
throw new Error("Missing environment variable $SERVER_DIR");
}
const ModsDir = path.join(RootDir, "mods");
const ConfigPath = path.join(RootDir, "config.yml");

process.chdir(RootDir);

const ConfigPath = path.join(RootDir, "config.yml");
const config = yaml.load(fs.readFileSync(ConfigPath, "utf8"));

const loadPackage = (dir) =>
JSON.parse(fs.readFileSync(path.resolve(dir, "package.json"), "utf8"));

const ModsDir = "./mods";

const isDependency = (pkg, [name, version]) =>
pkg.includes(name) || version.includes(pkg);

Expand Down Expand Up @@ -80,12 +80,6 @@ const installPackages = () => {
);
}

const newPackage = loadPackage(ModsDir);
fs.writeFileSync(
path.resolve(ModsDir, "package.json"),
JSON.stringify(newPackage, null, 2),
);

console.log("Done updating");
};

Expand Down

0 comments on commit 10317b7

Please sign in to comment.