Skip to content

Commit

Permalink
temp revert 607
Browse files Browse the repository at this point in the history
This reverts commit 82e674c.
  • Loading branch information
ThePansmith committed Sep 12, 2024
1 parent 5d7bfdb commit 7ab5904
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/build_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ on:
required: true
default: "build-all"
type: string
version:
required: false
type: string
secrets:
API_TOKEN:
required: true
Expand Down Expand Up @@ -61,7 +58,7 @@ jobs:
- name: Pack Modpack
env:
CFCORE_API_TOKEN: ${{ secrets.API_TOKEN }}
run: bash tools/build/build -c ${{ inputs.target }} --version ${{ inputs.version }}
run: bash tools/build/build -c ${{ inputs.target }}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ jobs:
uses: ./.github/workflows/build_pr.yml
with:
target: build-all
version: ${{needs.pre-build.outputs.version}}
secrets: inherit

release:
Expand Down
36 changes: 9 additions & 27 deletions tools/build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,18 @@ const symlinkSync = (ourDir, newDir) => {
* @param {(file: string) => boolean} filter
*/
const cpSyncFiltered = (ourDir, newDir, filter) => {
for (const file of fs.readdirSync(ourDir, { recursive: false })) {
for (const file of fs.readdirSync(ourDir, { recursive:false })) {
if (!filter(file)) continue;
fs.copyFileSync(path.join(ourDir, file), path.join(newDir, file))
}
}

function updateManifest(group, version) {
const jsonData = JSON.parse(fs.readFileSync(`dist/.tmp/${group}/manifest.json`, 'utf-8'))
if (version) {
jsonData.version = version
}
fs.writeFileSync(`dist/.tmp/${group}/manifest.json`, JSON.stringify(jsonData, null, 2))
}

async function packMod(group, version) {
async function packMod(group) {
Juke.rm(`dist/.tmp/${group}`, { recursive: true });
// copy dir to dist/.tmp
fs.mkdirSync(`dist/.tmp/${group}`, { recursive: true })
fs.cpSync(`dist/${group}`, `dist/.tmp/${group}/overrides`, { recursive: true, force: true })
fs.copyFileSync('manifest.json', `dist/.tmp/${group}/manifest.json`)
updateManifest(group, version)
fs.copyFileSync('dist/modlist.html', `dist/.tmp/${group}/modlist.html`)
fs.copyFileSync('LICENSE.md', `dist/.tmp/${group}/LICENSE.md`)
// Turns out you cant package bat files in CF releases anymore.
Expand Down Expand Up @@ -127,11 +118,6 @@ export const KeyParameter = new Juke.Parameter({
type: 'string'
})

// for --version=1.0.0
export const VersionParameter = new Juke.Parameter({
type: 'string'
});

export const BuildModlistTarget = new Juke.Target({
parameters: [KeyParameter],
inputs: ['manifest.json'],
Expand Down Expand Up @@ -185,7 +171,7 @@ export const DownloadModsTarget = new Juke.Target({

// filter returns changed mods, lets see now who owns them
for (const pid of oldDataKeys.filter(pid => !newDataKeys.includes(pid))
.concat(newDataKeys.filter(x => !oldDataKeys.includes(x)))) {
.concat(newDataKeys.filter(x => !oldDataKeys.includes(x)))) {
const fromOldData = oldData[`${pid}`];
if (fromOldData) {
// from old, which means this is removed
Expand All @@ -197,13 +183,13 @@ export const DownloadModsTarget = new Juke.Target({
if (newData[`${pid}`] && !mIdToDownload.includes(`${pid}`)) { // new mod added
mIdToDownload.push(`${pid}`);
Juke.logger.info(`Mod was added from modpack: ${pid}`)
oldData[`${pid}`] = { ...newData[`${pid}`] } // copy
oldData[`${pid}`] = {...newData[`${pid}`]} // copy
}
}

// now filter changed *fileids*, could prolly b optimized and use 1 loop instead of 2
for (const pid of oldDataKeys.filter(pid => (
newData[pid] && oldData[pid]['fileID'] !== newData[pid]['fileID']))) {
newData[pid] && oldData[pid]['fileID'] !== newData[pid]['fileID']))) {
const fromOldData = oldData[`${pid}`];
// from old, which means this is updated
if (fromOldData) {
Expand Down Expand Up @@ -242,7 +228,6 @@ export const DownloadModsTarget = new Juke.Target({

export const BuildClientTarget = new Juke.Target({
dependsOn: [BuildModlistTarget],
parameters: [VersionParameter],
inputs: [
...includeList,
"dist/modlist.html"
Expand All @@ -252,20 +237,18 @@ export const BuildClientTarget = new Juke.Target({
"dist/client.zip",
...includeList.map(v => `dist/client/${v}`)
]),
executes: async ({ get }) => {
const version = get(VersionParameter)
executes: async () => {
fs.mkdirSync("dist/client", { recursive: true })
for (const folders of includeList) {
fs.cpSync(folders, `dist/client/${folders}`, { recursive: true })
}

await packMod("client", version)
await packMod("client");
}
})

export const BuildServerTarget = new Juke.Target({
dependsOn: [BuildModlistTarget, DownloadModsTarget],
parameters: [VersionParameter],
inputs: [
...includeList,
"dist/modlist.html"
Expand All @@ -275,8 +258,7 @@ export const BuildServerTarget = new Juke.Target({
"dist/server.zip",
...includeList.map(v => `dist/server/${v}`)
]),
executes: async ({ get }) => {
const version = get(VersionParameter)
executes: async () => {
fs.mkdirSync("dist/server", { recursive: true })
for (const folders of includeList) {
fs.cpSync(folders, `dist/server/${folders}`, { recursive: true })
Expand All @@ -296,7 +278,7 @@ export const BuildServerTarget = new Juke.Target({
)
})

await packMod("server", version);
await packMod("server");
}
})

Expand Down

0 comments on commit 7ab5904

Please sign in to comment.