Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
version = 1

exclude_patterns = [
"Mod Manager/src/torchlight/**",
"src/quickentity1136.js",
"src/quickentity20.js"
"Mod Manager/src/torchlight/**"
]

[[analyzers]]
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error"
"@typescript-eslint/no-misused-promises": "error",
"no-fallthrough": "off"
}
}
17 changes: 16 additions & 1 deletion .github/workflows/artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
with:
node-version: 18

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-msvc
default: true

- name: Cache
id: cache
uses: actions/cache@v2.1.6
Expand All @@ -37,7 +43,16 @@ jobs:

- name: Prep
run: |
npm install -g pkg typescript
npm install -g pkg typescript @napi-rs/cli

- name: Build Rust code
run: |
cd rust
yarn
yarn build
cd ../
copy ./rust/index.d.ts ./src/smf-rust.d.ts
copy ./rust/rust.win32-x64-msvc.node ./src/smf-rust.node

- name: Build EXE
env:
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
with:
node-version: 18

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-msvc
default: true

- name: Cache
id: cache
uses: actions/cache@v2.1.6
Expand All @@ -37,7 +43,16 @@ jobs:

- name: Prep
run: |
npm install -g pkg typescript
npm install -g pkg typescript @napi-rs/cli

- name: Build Rust code
run: |
cd rust
yarn
yarn build
cd ../
copy ./rust/index.d.ts ./src/smf-rust.d.ts
copy ./rust/rust.win32-x64-msvc.node ./src/smf-rust.node

- name: Build EXE
env:
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ jobs:
with:
node-version: 18

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-msvc
default: true

- name: Cache
id: cache
uses: actions/cache@v3
Expand All @@ -40,7 +46,16 @@ jobs:

- name: Prep
run: |
npm install -g pkg typescript
npm install -g pkg typescript @napi-rs/cli

- name: Build Rust code
run: |
cd rust
yarn
yarn build
cd ../
copy ./rust/index.d.ts ./src/smf-rust.d.ts
copy ./rust/rust.win32-x64-msvc.node ./src/smf-rust.node

- name: Build EXE
env:
Expand Down Expand Up @@ -160,4 +175,4 @@ jobs:
with:
environment: production
version: ${{ github.ref }}
sourcemaps: './compiled/core-singleton.js.map ./compiled/core.js.map ./compiled/crc32.js.map ./compiled/deploy.js.map ./compiled/difference.js.map ./compiled/discover.js.map ./compiled/main.js.map ./compiled/patchWorker.js.map ./compiled/quickentity-3.js.map ./compiled/quickentity-rs.js.map ./compiled/quickentity.js.map ./compiled/quickentity20.js.map ./compiled/quickentity1136.js.map ./compiled/rpkg.js.map ./compiled/three-onlymath.min.js.map ./compiled/types.js.map ./compiled/typescript.js.map ./compiled/utils.js.map'
sourcemaps: './compiled/core-singleton.js.map ./compiled/core.js.map ./compiled/crc32.js.map ./compiled/deploy.js.map ./compiled/difference.js.map ./compiled/discover.js.map ./compiled/main.js.map ./compiled/patchWorker.js.map ./compiled/quickentity-rs.js.map ./compiled/rpkg.js.map ./compiled/types.js.map ./compiled/typescript.js.map ./compiled/utils.js.map'
21 changes: 21 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Close inactive issues
on:
schedule:
- cron: "30 1 * * *"

jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v4.1.1
with:
days-before-issue-stale: 5
days-before-issue-close: 5
stale-issue-label: "stale"
stale-issue-message: "This issue has been marked as stale because it has been open for 5 days with no further activity."
close-issue-message: "This issue was closed because it was inactive for 5 days since being marked as stale."
days-before-pr-stale: -1
days-before-pr-close: -1
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ Third-Party/ResourceTool.exe
Third-Party/ResourceTool.pdb
compiled
/Mods
config.json
config.json
rust/npm/win32-x64-msvc/package.json
rust/npm/win32-x64-msvc/README.md
rust/index.d.ts
rust/index.js
src/smf-rust.node
src/smf-rust.d.ts
18 changes: 9 additions & 9 deletions Mod Manager/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Mod Manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@
"svelte-check": "^2.8.0",
"svelte-preprocess": "^4.10.7",
"typescript": "^4.7.4",
"vite": "^2.9.13"
"vite": "^2.9.16"
}
}
10 changes: 5 additions & 5 deletions Mod Manager/src/electron.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ ipcMain.on("deploy", () => {
cwd: ".."
})

let deployOutput = ""
let deployOutput = Buffer.from("")

mainWindow.webContents.send("frameworkDeployModalOpen")

deployProcess.stdout.on("data", (data) => {
deployOutput += String(data)
mainWindow.webContents.send("frameworkDeployOutput", deployOutput)
deployOutput = Buffer.concat([deployOutput, data])
mainWindow.webContents.send("frameworkDeployOutput", String(deployOutput))
})

deployProcess.stderr.on("data", (data) => {
deployOutput += String(data)
mainWindow.webContents.send("frameworkDeployOutput", deployOutput)
deployOutput = Buffer.concat([deployOutput, data])
mainWindow.webContents.send("frameworkDeployOutput", String(deployOutput))
})

deployProcess.on("close", (data) => {
Expand Down
4 changes: 3 additions & 1 deletion Mod Manager/src/lib/entity-patch-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,9 @@
"$ref": "#/definitions/FullRef"
},
{
"type": "string"
"type": "string",
"minLength":16,
"maxLength":16
},
{
"type": "null"
Expand Down
6 changes: 2 additions & 4 deletions Mod Manager/src/lib/repository-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,8 @@
"BurstAngleVMultiplier": { "type": "number" },
"BurstRandomizationFactorMultiplier": { "type": "number" },
"Items": { "type": "array", "items": { "type": "string" } },
"Guids": { "type": "array", "items": { "type": "string" } },
"_popdensitycomment": { "type": "string" }
},
"title": "Unlockable"
"Guids": { "type": "array", "items": { "type": "string" } }
}
},
"Configuration": {
"type": "object",
Expand Down
6 changes: 2 additions & 4 deletions Mod Manager/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,10 @@ export function validateModFolder(modFolder: string): [boolean, string] {

switch (file.split(".").slice(1).join(".")) {
case "entity.json":
if (fileContents.quickEntityVersion === 3.1 && !validateEntity(fileContents))
return [false, `Invalid file ${file} due to non-matching schema: ${new Ajv({ strict: false }).errorsText(validateEntity.errors)}`]
if (!validateEntity(fileContents)) return [false, `Invalid file ${file} due to non-matching schema: ${new Ajv({ strict: false }).errorsText(validateEntity.errors)}`]
break
case "entity.patch.json":
if (fileContents.patchVersion === 6 && !validateEntityPatch(fileContents))
return [false, `Invalid file ${file} due to non-matching schema: ${new Ajv({ strict: false }).errorsText(validateEntityPatch.errors)}`]
if (!validateEntityPatch(fileContents)) return [false, `Invalid file ${file} due to non-matching schema: ${new Ajv({ strict: false }).errorsText(validateEntityPatch.errors)}`]
break
case "repository.json":
if (!validateRepository(fileContents)) return [false, `Invalid file ${file} due to non-matching schema: ${new Ajv({ strict: false }).errorsText(validateRepository.errors)}`]
Expand Down
72 changes: 62 additions & 10 deletions Mod Manager/src/routes/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@

if (
window.fs
.readdirSync(window.path.join("..", "Mods")).filter(a=>a!="Managed by SMF, do not touch")
.readdirSync(window.path.join("..", "Mods"))
.filter((a) => a != "Managed by SMF, do not touch")
.map((a) => window.path.resolve(window.path.join("..", "Mods", a)))
.some((a) => window.isFile(a))
) {
Expand All @@ -107,7 +108,8 @@
} catch {
invalidModText =
window.fs
.readdirSync(window.path.join("..", "Mods")).filter(a=>a!="Managed by SMF, do not touch")
.readdirSync(window.path.join("..", "Mods"))
.filter((a) => a != "Managed by SMF, do not touch")
.map((a) => window.path.resolve(window.path.join("..", "Mods", a)))
.find((a) => window.fs.existsSync(window.path.join(a, "manifest.json")) && !json5.parse(window.fs.readFileSync(window.path.join(a, "manifest.json"), "utf8")).id)
?.split(window.path.sep)
Expand Down Expand Up @@ -404,12 +406,24 @@
throw new Error("Mod update ZIP has files in the root!")
}

window.fs.removeSync(getModFolder(updatingMod!.id))
if (
window.fs
.readdirSync("./staging")
.some(
(a) =>
json5.parse(window.fs.readFileSync(window.path.join("./staging", a, "manifest.json"), "utf8")).scripts ||
json5.parse(window.fs.readFileSync(window.path.join("./staging", a, "manifest.json"), "utf8")).options?.some((b) => b.scripts)
)
) {
updatingModScriptsWarningOpen = true
} else {
window.fs.removeSync(getModFolder(updatingMod!.id))

window.fs.copySync("./staging", "../Mods")
window.fs.copySync("./staging", "../Mods")

window.fs.removeSync("./staging")
window.fs.removeSync("./tempArchive")
window.fs.removeSync("./staging")
window.fs.removeSync("./tempArchive")
}
} catch (e) {
window.alert("Couldn't extract and apply the mod update! Contact the mod author for help.\n\n" + e)
updatingMod = null
Expand All @@ -421,6 +435,8 @@
window.location.reload()
}

let updatingModScriptsWarningOpen = false

const trustedHosts = new Set(["github.com", "raw.githubusercontent.com", "dropbox.com", "dl.dropboxusercontent.com", "drive.google.com", "hitman-resources.netlify.app"])
</script>

Expand Down Expand Up @@ -456,9 +472,8 @@
{#if semver.lt(FrameworkVersion, release.tag_name)}
<div class="flex items-center">
<h3 class="flex-grow">
{{ patch: "Patch update available", minor: "Feature update available", major: "Major update available" }[
semver.diff(FrameworkVersion, release.tag_name)
] || "Update available"}
{{ patch: "Patch update available", minor: "Feature update available", major: "Major update available" }[semver.diff(FrameworkVersion, release.tag_name)] ||
"Update available"}
</h3>
<p>{FrameworkVersion} → {release.tag_name}</p>
</div>
Expand Down Expand Up @@ -514,7 +529,13 @@
</div>
</div>
{/each}
{#each updates.filter(([modID, update]) => update && (!(trustedHosts.has(new URL(update.check_url).hostname) || new URL(update.check_url).hostname.split(".").slice(1).join(".") === "github.io") || !(trustedHosts.has(new URL(update.url).hostname) || new URL(update.url).hostname.split(".").slice(1).join(".") === "github.io"))) as [modID, update]}
{#each updates.filter(([modID, update]) => update && (!(trustedHosts.has(new URL(update.check_url).hostname) || new URL(update.check_url).hostname
.split(".")
.slice(1)
.join(".") === "github.io") || !(trustedHosts.has(new URL(update.url).hostname) || new URL(update.url).hostname
.split(".")
.slice(1)
.join(".") === "github.io"))) as [modID, update]}
<div class="flex items-center">
<p class="flex-grow">The author of {getManifestFromModID(modID).name} may be able to find which IPs have their mod downloaded</p>
<Asterisk />
Expand Down Expand Up @@ -711,6 +732,37 @@
{/if}
</Modal>

<Modal
danger
bind:open={updatingModScriptsWarningOpen}
modalHeading="Mod now contains scripts"
primaryButtonText="I'm sure"
secondaryButtonText="Cancel"
shouldSubmitOnEnter={false}
on:click:button--secondary={() => {
updatingMod = null
updatingModScriptsWarningOpen = false
}}
on:click:button--primary={() => {
window.fs.removeSync(getModFolder(updatingMod.id))

window.fs.copySync("./staging", "../Mods")

window.fs.removeSync("./staging")
window.fs.removeSync("./tempArchive")

updatingMod = null

window.location.reload()
}}
>
<p>
The mod you're updating has added scripts; that means it is able to execute its own (external to the framework) code whenever you apply your mods. Scripts can do cool things and make a lot of
mods possible, but it's possible for them to cause problems, or even install malware (though the framework tries its best to avoid this). Make sure you trust whoever developed this mod, and
wherever you downloaded it from. Are you sure you want to add this mod?
</p>
</Modal>

<style>
:global(h2) {
font-size: 1.5rem;
Expand Down
Loading