Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clean support for Custom deployment paths #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions tools/core-build-tasks/src/tasks/cleanCollateral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,33 @@ import * as fs from 'fs';
import * as Path from 'path';
import rimraf from 'rimraf';
import { getOrThrowFromProcess } from './helpers/getOrThrowFromProcess';
import { getGameDeploymentRootPaths } from './helpers/getGameDeploymentRootPaths';

/** @deprecated Use {@link getStandardCleanPaths} instead of {@link STANDARD_CLEAN_PATHS} */
export const STANDARD_CLEAN_PATHS = [
'LOCALAPPDATA/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/PROJECT_NAME',
'LOCALAPPDATA/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_resource_packs/PROJECT_NAME',
'LOCALAPPDATA/Packages/Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/PROJECT_NAME',
'LOCALAPPDATA/Packages/Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe/LocalState/games/com.mojang/development_resource_packs/PROJECT_NAME',
];

export function getStandardCleanPaths() {
const projectName = getOrThrowFromProcess('PROJECT_NAME');
const results = Object.values(getGameDeploymentRootPaths())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to note here is that getGameDeploymentRootPaths doesn't use the APPDATA path, it only uses LOCALAPPDATA which would be a breaking change I suppose? I don't think the copyTask task would work if LOCALAPPDATA wasn't set correctly so I don't think this would actually be breaking anything.

.filter(rootPath => rootPath !== undefined)
.flatMap(rootPath => [
Path.resolve(rootPath, 'development_behavior_packs', projectName),
Path.resolve(rootPath, 'development_resource_packs', projectName),
]);

if (results.length === 0) {
// Fallback logic
return STANDARD_CLEAN_PATHS;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this fallback is removed, getStandardCleanPaths could be passed to cleanTask instead since the full path is resolved without needing env var replacements. Going this route would mean that the cleanCollateralTask could probably be deprecated/removed.

}

return results;
}

/**
* Cleans the specified outputs. Outputs could be either folders or files. Has support for the following variable replacements
*
Expand Down