-
Notifications
You must be signed in to change notification settings - Fork 1
/
package-scripts.js
121 lines (112 loc) · 4.43 KB
/
package-scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const dotenv = require('dotenv');
const { series } = require('nps-utils');
const { resolve } = require('path');
const { ajblueprintDir } = require('./package-scripts/shared-consts');
const { assertEnvironmentVariables } = require('./package-scripts/utils');
dotenv.config();
assertEnvironmentVariables([
'ASSETS_DIR',
'BLOCKBENCH_PATH',
'DATAPACK',
'RESOURCEPACK',
]);
const assetsDir = process.env.ASSETS_DIR;
const blockbenchPath = process.env.BLOCKBENCH_PATH;
const datapack = process.env.DATAPACK;
const resourcePack = process.env.RESOURCEPACK;
// we have to resolve this path so we can use it with Blockbench
const ajexportScriptPath = resolve('./package-scripts/modules/ajexport.js');
const watchScriptPath = './package-scripts/watch.js';
const allAnimatedJavaExportFiles = [
'datapacks/animated_java/data',
'datapacks/animated_java/data.ajmeta',
'resourcepack/assets.ajmeta',
'resourcepack/assets/animated_java',
'resourcepack/assets/minecraft/models/item/pink_dye.json',
`${ajblueprintDir}/last_exported_hashes.json`,
];
const allAnimatedJavaExportFilesFormatted =
allAnimatedJavaExportFiles.join(',');
const floweyWorldSyncPath = './world.zip';
const minecraftPath = process.env.MINECRAFT_PATH;
const worldName = process.env.WORLD_NAME;
const minecraftWorldPath = `${minecraftPath}/saves/${worldName}`;
const worldSyncArgs = `--backup-path="${floweyWorldSyncPath}" --world-path="${minecraftWorldPath}"`;
const smithedSummitWorldSyncPath =
'./bin/smithed-summit-2024/world/smithed-summit-2024-omegaflowey-plot.zip';
const smithedSummitWorldSyncArgs = `--backup-path="${smithedSummitWorldSyncPath}" --world-path="${process.env.SMITHED_SUMMIT_WORLD_PATH}"`;
module.exports = {
scripts: {
default: 'nps watch',
build: {
default: 'nps build.summit',
clean: 'rimraf ./build',
summit: 'node ./package-scripts/build',
},
export: {
default: 'nps export.run',
run: `yarn exec "${blockbenchPath}" --script="${ajexportScriptPath}" --cwd="${process.cwd()}" --assets-dir="${assetsDir}" --datapack="${datapack}" --resourcepack="${resourcePack}"`,
// forcibly purge the `animated_java` export-cache
force: series(
`rimraf ${allAnimatedJavaExportFiles.join(' ')}`,
'nps export',
),
},
lint: {
default: 'nps lint.custom lint.scripts',
fix: series.nps('lint.custom.fix', 'lint.scripts.fix'),
scripts: {
default: 'nps lint.scripts.check',
check: series.nps(
'lint.scripts.prettier.check',
'lint.scripts.eslint.check',
),
fix: series.nps('lint.scripts.prettier.fix', 'lint.scripts.eslint.fix'),
eslint: {
default: 'nps lint.scripts.eslint.check',
check: 'eslint .',
fix: 'eslint --fix .',
},
prettier: {
default: 'nps lint.scripts.prettier.check',
check: 'prettier --check .',
fix: 'prettier --write .',
},
},
custom: {
default: 'nps lint.custom.all',
all: series.nps(
'lint.custom.datapacks',
'lint.custom.resourcepack',
'lint.custom.other',
),
fix: 'nps "lint.custom.datapacks --fix"',
datapacks: `node ./package-scripts/run-linting-rules --fix --include "datapacks/**/*" --exclude "${allAnimatedJavaExportFilesFormatted}"`,
resourcepack: `node ./package-scripts/run-linting-rules --include "resourcepack/**/*" --exclude "${allAnimatedJavaExportFilesFormatted}"`,
other:
'node ./package-scripts/run-linting-rules --include "**/*" --exclude "resourcepack/**/*,datapacks/**/*"',
},
},
log: `code -r "${minecraftPath}/logs/latest.log"`,
stats: {
default: 'nps stats.sounds',
sounds: `yarn exec pwsh -Command "./package-scripts/list-sound-stats.ps1" -Path "resourcepack/assets/omega-flowey/sounds" -Out "resourcepack/assets/omega-flowey/sounds/stats.txt"`,
},
sync: {
default: 'nps sync.summit',
world: {
default: 'nps sync.world.up',
down: `node ./package-scripts/sync-world --down ${worldSyncArgs}`,
up: `node ./package-scripts/sync-world --up ${worldSyncArgs}"`,
},
summit: {
default: 'nps sync.summit.up',
down: `node ./package-scripts/sync-world --down ${smithedSummitWorldSyncArgs}`,
up: `node ./package-scripts/sync-world --up ${smithedSummitWorldSyncArgs}`,
},
},
watch: {
default: `node ${watchScriptPath}`,
},
},
};