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

Conversation

ChristopherHaws
Copy link

@ChristopherHaws ChristopherHaws commented Jul 28, 2024

The current implementation of STANDARD_CLEAN_PATHS does not have support for the CUSTOM_DEPLOYMENT_PATH environment variable which is used when MINECRAFT_PRODUCT="Custom". This change switches the logic to use the existing getGameDeploymentRootPaths helper method to better generate the clean paths.

This change makes clean work out of the box on linux, as shown here:

chaws@pc:~/dev/mc/bedrock-sample$ pnpm local-deploy

> [email protected] local-deploy /home/chaws/dev/mc/bedrock-sample
> just-scripts local-deploy

[9:31:06 PM] ■ started 'local-deploy'
[9:31:06 PM] ■ started 'clean-local'
Cleaning temp
Cleaning lib
Cleaning dist
[9:31:06 PM] ■ finished 'clean-local' in 0s
[9:31:06 PM] ■ started 'build'
[9:31:06 PM] ■ started 'typescript'
[9:31:06 PM] ■ Running /home/chaws/dev/mc/bedrock-sample/node_modules/typescript/lib/tsc.js with /home/chaws/dev/mc/bedrock-sample/tsconfig.json
[9:31:06 PM] ■ Executing: "/home/chaws/.local/share/pnpm/nodejs/20.12.0/bin/node" "/home/chaws/dev/mc/bedrock-sample/node_modules/typescript/lib/tsc.js" --project "/home/chaws/dev/mc/bedrock-sample/tsconfig.json"
[9:31:07 PM] ■ finished 'typescript' in 0.73s
[9:31:07 PM] ■ started 'bundle'
[9:31:07 PM] ■ finished 'bundle' in 0.07s
[9:31:07 PM] ■ finished 'build' in 0.8s
[9:31:07 PM] ■ started 'package'
[9:31:07 PM] ■ started 'clean-collateral'
Proceeding without APPDATA on this platform. File copy will fail if APPDATA is required.
Proceeding without LOCALAPPDATA on this platform. File copy will fail if LOCALAPPDATA is required.
Cleaning directory /home/chaws/.local/share/mcpelauncher/games/com.mojang/development_behavior_packs/bedrock_sample.
Cleaning directory /home/chaws/.local/share/mcpelauncher/games/com.mojang/development_resource_packs/bedrock_sample.
[9:31:07 PM] ■ finished 'clean-collateral' in 0.01s
[9:31:07 PM] ■ started 'copyArtifacts'
Copying folder /home/chaws/dev/mc/bedrock-sample/behavior_packs/bedrock_sample to /home/chaws/.local/share/mcpelauncher/games/com.mojang/development_behavior_packs/bedrock_sample
Copying folder /home/chaws/dev/mc/bedrock-sample/dist/scripts to /home/chaws/.local/share/mcpelauncher/games/com.mojang/development_behavior_packs/bedrock_sample/scripts
Copying folder /home/chaws/dev/mc/bedrock-sample/resource_packs/bedrock_sample to /home/chaws/.local/share/mcpelauncher/games/com.mojang/development_resource_packs/bedrock_sample
[9:31:07 PM] ■ finished 'copyArtifacts' in 0.01s
[9:31:07 PM] ■ finished 'package' in 0.01s
[9:31:07 PM] ■ finished 'local-deploy' in 0.83s


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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant