@minecraft/core-build-tasks 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/index.test.js +2 -0
- package/lib/index.test.js.map +1 -1
- package/lib/platforms/MinecraftProduct.d.ts +8 -0
- package/lib/platforms/MinecraftProduct.js +15 -0
- package/lib/platforms/MinecraftProduct.js.map +1 -0
- package/lib/platforms/index.d.ts +1 -0
- package/lib/platforms/index.js +20 -0
- package/lib/platforms/index.js.map +1 -0
- package/lib/setupEnvironment.d.ts +5 -0
- package/lib/setupEnvironment.js +18 -0
- package/lib/setupEnvironment.js.map +1 -0
- package/lib/tasks/api-extractor.js +2 -0
- package/lib/tasks/api-extractor.js.map +1 -1
- package/lib/tasks/bundle.d.ts +14 -0
- package/lib/tasks/bundle.js +24 -0
- package/lib/tasks/bundle.js.map +1 -0
- package/lib/tasks/clean.js +2 -0
- package/lib/tasks/clean.js.map +1 -1
- package/lib/tasks/cleanCollateral.d.ts +10 -0
- package/lib/tasks/cleanCollateral.js +88 -0
- package/lib/tasks/cleanCollateral.js.map +1 -0
- package/lib/tasks/copy.d.ts +20 -0
- package/lib/tasks/copy.js +41 -0
- package/lib/tasks/copy.js.map +1 -0
- package/lib/tasks/coreLint.js +2 -0
- package/lib/tasks/coreLint.js.map +1 -1
- package/lib/tasks/helpers/copyFiles.d.ts +1 -0
- package/lib/tasks/helpers/copyFiles.js +31 -0
- package/lib/tasks/helpers/copyFiles.js.map +1 -0
- package/lib/tasks/helpers/getGameDeploymentRootPaths.d.ts +3 -0
- package/lib/tasks/helpers/getGameDeploymentRootPaths.js +65 -0
- package/lib/tasks/helpers/getGameDeploymentRootPaths.js.map +1 -0
- package/lib/tasks/helpers/getOrThrowFromProcess.d.ts +9 -0
- package/lib/tasks/helpers/getOrThrowFromProcess.js +22 -0
- package/lib/tasks/helpers/getOrThrowFromProcess.js.map +1 -0
- package/lib/tasks/helpers/index.d.ts +3 -0
- package/lib/tasks/helpers/index.js +22 -0
- package/lib/tasks/helpers/index.js.map +1 -0
- package/lib/tasks/index.d.ts +7 -0
- package/lib/tasks/index.js +9 -0
- package/lib/tasks/index.js.map +1 -1
- package/lib/tasks/updateWorld.d.ts +15 -0
- package/lib/tasks/updateWorld.js +26 -0
- package/lib/tasks/updateWorld.js.map +1 -0
- package/lib/tasks/vitest.js +2 -0
- package/lib/tasks/vitest.js.map +1 -1
- package/lib/tasks/watch.d.ts +8 -0
- package/lib/tasks/watch.js +62 -0
- package/lib/tasks/watch.js.map +1 -0
- package/lib/tasks/zip.d.ts +26 -0
- package/lib/tasks/zip.js +82 -0
- package/lib/tasks/zip.js.map +1 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Core Build Tasks
|
|
2
2
|
|
|
3
|
-
This package contains common build tasks used
|
|
3
|
+
This package contains common build tasks used within the minecraft-scripting-libraries build, but can be used in other repositories as well. If a task is used by `just` in multiple packages, it is moved into this package to reduce duplication.
|
|
4
4
|
|
|
5
5
|
This subdirectory only runs the `build` step, and more specifically, only runs `tsc` today since this package itself defines build tasks, so it must be kept lightweight.
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
2
4
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
5
|
if (k2 === undefined) k2 = k;
|
|
4
6
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -14,5 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
17
|
};
|
|
16
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./platforms"), exports);
|
|
20
|
+
__exportStar(require("./setupEnvironment"), exports);
|
|
17
21
|
__exportStar(require("./tasks"), exports);
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;AAElC,8CAA4B;AAC5B,qDAAmC;AACnC,0CAAwB"}
|
package/lib/index.test.js
CHANGED
package/lib/index.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,mCAA8C;AAE9C,IAAA,iBAAQ,EAAC,6BAA6B,EAAE,GAAG,EAAE;IACzC,IAAA,WAAE,EAAC,gBAAgB,EAAE,GAAG,EAAE;QACtB,IAAA,eAAM,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.MinecraftProduct = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Non-exhaustive list of product variants used to deploy files to the correct location.
|
|
8
|
+
*/
|
|
9
|
+
var MinecraftProduct;
|
|
10
|
+
(function (MinecraftProduct) {
|
|
11
|
+
MinecraftProduct["Bedrock"] = "BedrockUWP";
|
|
12
|
+
MinecraftProduct["Preview"] = "PreviewUWP";
|
|
13
|
+
MinecraftProduct["Custom"] = "Custom";
|
|
14
|
+
})(MinecraftProduct || (exports.MinecraftProduct = MinecraftProduct = {}));
|
|
15
|
+
//# sourceMappingURL=MinecraftProduct.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinecraftProduct.js","sourceRoot":"","sources":["../../src/platforms/MinecraftProduct.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;GAEG;AACH,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IACxB,0CAAsB,CAAA;IACtB,0CAAsB,CAAA;IACtB,qCAAiB,CAAA;AACrB,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MinecraftProduct';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./MinecraftProduct"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platforms/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;AAElC,qDAAmC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.setupEnvironment = void 0;
|
|
9
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
10
|
+
/**
|
|
11
|
+
* Loads the environment variables.
|
|
12
|
+
* @param envPath - path to the .env file.
|
|
13
|
+
*/
|
|
14
|
+
function setupEnvironment(envPath) {
|
|
15
|
+
dotenv_1.default.config({ path: envPath });
|
|
16
|
+
}
|
|
17
|
+
exports.setupEnvironment = setupEnvironment;
|
|
18
|
+
//# sourceMappingURL=setupEnvironment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupEnvironment.js","sourceRoot":"","sources":["../src/setupEnvironment.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,oDAA4B;AAE5B;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,OAAe;IAC5C,gBAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AACrC,CAAC;AAFD,4CAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-extractor.js","sourceRoot":"","sources":["../../src/tasks/api-extractor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-extractor.js","sourceRoot":"","sources":["../../src/tasks/api-extractor.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,4DAAuF;AAEvF;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,QAAgB,EAAE,UAAmB;IAClE,OAAO,GAAG,EAAE;QACR,OAAO,CAAC,GAAG,CAAC,aAAa,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,uBAAuB,CAAC,CAAC;QAErF,MAAM,oBAAoB,GAAW,QAAQ,CAAC;QAC9C,MAAM,eAAe,GAAoB,+BAAe,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;QAElG,MAAM,eAAe,GAAoB,yBAAS,CAAC,MAAM,CAAC,eAAe,EAAE;YACvE,qDAAqD;YACrD,UAAU;YAEV,uDAAuD;YACvD,mBAAmB,EAAE,IAAI;SAC5B,CAAC,CAAC;QAEH,IAAI,eAAe,CAAC,SAAS,EAAE;YAC3B,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;YACpD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;QAED,MAAM,OAAO,GAAG,gDAAgD,eAAe,CAAC,UAAU,qBAAqB,eAAe,CAAC,YAAY,mEAAmE,CAAC;QAE/M,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAC;AACN,CAAC;AA3BD,4CA2BC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { parallel } from 'just-scripts';
|
|
2
|
+
export type BundleTaskParameters = {
|
|
3
|
+
/** Initial script to be evaluated for the build. Documentation: https://esbuild.github.io/api/#entry-points */
|
|
4
|
+
entryPoint: string;
|
|
5
|
+
/** Packages to be considered as external. Documentation: https://esbuild.github.io/api/#external */
|
|
6
|
+
external?: string[];
|
|
7
|
+
/** When enabled, the generated code will be minified instead of pretty-printed. Documentation: https://esbuild.github.io/api/#minify */
|
|
8
|
+
minifyWhitespace?: boolean;
|
|
9
|
+
/** The output file for the bundle. Documentation: https://esbuild.github.io/api/#outfile */
|
|
10
|
+
outfile: string;
|
|
11
|
+
/** Flag to specify how to generate source map. Documentation: https://esbuild.github.io/api/#sourcemap */
|
|
12
|
+
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both';
|
|
13
|
+
};
|
|
14
|
+
export declare function bundleTask(options: BundleTaskParameters): ReturnType<typeof parallel>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.bundleTask = void 0;
|
|
9
|
+
const esbuild_1 = __importDefault(require("esbuild"));
|
|
10
|
+
function bundleTask(options) {
|
|
11
|
+
return async () => {
|
|
12
|
+
return esbuild_1.default.build({
|
|
13
|
+
entryPoints: [options.entryPoint],
|
|
14
|
+
bundle: true,
|
|
15
|
+
format: 'esm',
|
|
16
|
+
minifyWhitespace: options.minifyWhitespace,
|
|
17
|
+
outfile: options.outfile,
|
|
18
|
+
sourcemap: options.sourcemap,
|
|
19
|
+
external: options.external,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.bundleTask = bundleTask;
|
|
24
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/tasks/bundle.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAGlC,sDAA8B;AAmB9B,SAAgB,UAAU,CAAC,OAA6B;IACpD,OAAO,KAAK,IAAI,EAAE;QACd,OAAO,iBAAO,CAAC,KAAK,CAAC;YACjB,WAAW,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;YACjC,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,KAAK;YACb,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC7B,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAZD,gCAYC"}
|
package/lib/tasks/clean.js
CHANGED
package/lib/tasks/clean.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../src/tasks/clean.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../src/tasks/clean.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,gDAAwB;AACxB,oDAA4B;AAEf,QAAA,yBAAyB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEjE,SAAgB,SAAS,CAAC,IAAc;IACpC,OAAO,GAAG,EAAE;QACR,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACpB,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC,CAAC;YAC/B,IAAA,gBAAM,EAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE;gBAC1C,2BAA2B;YAC/B,CAAC,CAAC,CAAC;SACN;IACL,CAAC,CAAC;AACN,CAAC;AATD,8BASC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const STANDARD_CLEAN_PATHS: string[];
|
|
2
|
+
/**
|
|
3
|
+
* Cleans the specified outputs. Outputs could be either folders or files. Has support for the following variable replacements
|
|
4
|
+
*
|
|
5
|
+
* APPDATA, LOCALAPPDATA, PROJECT_NAME
|
|
6
|
+
*
|
|
7
|
+
* This constant is replaced at task execution with a value provided by the process environment.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare function cleanCollateralTask(pathsToClean: string[]): () => void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.cleanCollateralTask = exports.STANDARD_CLEAN_PATHS = void 0;
|
|
32
|
+
const fs = __importStar(require("fs"));
|
|
33
|
+
const Path = __importStar(require("path"));
|
|
34
|
+
const rimraf_1 = __importDefault(require("rimraf"));
|
|
35
|
+
const getOrThrowFromProcess_1 = require("./helpers/getOrThrowFromProcess");
|
|
36
|
+
exports.STANDARD_CLEAN_PATHS = [
|
|
37
|
+
'LOCALAPPDATA/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/PROJECT_NAME',
|
|
38
|
+
'LOCALAPPDATA/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_resource_packs/PROJECT_NAME',
|
|
39
|
+
'LOCALAPPDATA/Packages/Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe/LocalState/games/com.mojang/development_behavior_packs/PROJECT_NAME',
|
|
40
|
+
'LOCALAPPDATA/Packages/Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe/LocalState/games/com.mojang/development_resource_packs/PROJECT_NAME',
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* Cleans the specified outputs. Outputs could be either folders or files. Has support for the following variable replacements
|
|
44
|
+
*
|
|
45
|
+
* APPDATA, LOCALAPPDATA, PROJECT_NAME
|
|
46
|
+
*
|
|
47
|
+
* This constant is replaced at task execution with a value provided by the process environment.
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
function cleanCollateralTask(pathsToClean) {
|
|
51
|
+
return () => {
|
|
52
|
+
const projectName = (0, getOrThrowFromProcess_1.getOrThrowFromProcess)('PROJECT_NAME');
|
|
53
|
+
// The following variables are not used on all platforms. In those cases, set up an error token so that if the
|
|
54
|
+
// config requires these on the platform, we error out immediately.
|
|
55
|
+
const errorToken = '$ERROR_TOKEN$';
|
|
56
|
+
let appData = process.env.APPDATA;
|
|
57
|
+
if (!appData) {
|
|
58
|
+
console.warn('Proceeding without APPDATA on this platform. File copy will fail if APPDATA is required.');
|
|
59
|
+
appData = errorToken;
|
|
60
|
+
}
|
|
61
|
+
let localAppData = process.env.LOCALAPPDATA;
|
|
62
|
+
if (!localAppData) {
|
|
63
|
+
console.warn('Proceeding without LOCALAPPDATA on this platform. File copy will fail if LOCALAPPDATA is required.');
|
|
64
|
+
localAppData = errorToken;
|
|
65
|
+
}
|
|
66
|
+
// For each output path, replace tokens with env values
|
|
67
|
+
for (const cleanPathRaw of pathsToClean) {
|
|
68
|
+
const cleanPath = cleanPathRaw
|
|
69
|
+
.replace('LOCALAPPDATA', localAppData)
|
|
70
|
+
.replace('APPDATA', appData)
|
|
71
|
+
.replace('PROJECT_NAME', projectName);
|
|
72
|
+
if (cleanPath.includes(errorToken)) {
|
|
73
|
+
console.warn(`Skipping clean of ${cleanPath} on current platform due to APPDATA or LOCALAPPDATA being missing.`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const stats = fs.statSync(cleanPath);
|
|
78
|
+
console.log(`Cleaning ${stats.isDirectory() ? 'directory' : 'file'} ${Path.resolve(cleanPath)}.`);
|
|
79
|
+
rimraf_1.default.sync(cleanPath);
|
|
80
|
+
}
|
|
81
|
+
catch (_) {
|
|
82
|
+
// File or directory did not exist, so we no-op
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
exports.cleanCollateralTask = cleanCollateralTask;
|
|
88
|
+
//# sourceMappingURL=cleanCollateral.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanCollateral.js","sourceRoot":"","sources":["../../src/tasks/cleanCollateral.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kC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KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBAClG,gBAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aAC1B;YAAC,OAAO,CAAU,EAAE;gBACjB,+CAA+C;aAClD;SACJ;IACL,CAAC,CAAC;AACN,CAAC;AA5CD,kDA4CC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type CopyTaskParameters = {
|
|
2
|
+
/**
|
|
3
|
+
* The paths to copy to behavior packs directory in the game.
|
|
4
|
+
*/
|
|
5
|
+
copyToBehaviorPacks: string[];
|
|
6
|
+
/**
|
|
7
|
+
* The paths to copy to the scripts directory in the game.
|
|
8
|
+
* This is copied after copyToBehaviorPacks.
|
|
9
|
+
*/
|
|
10
|
+
copyToScripts: string[];
|
|
11
|
+
/**
|
|
12
|
+
* The paths to copy to resource packs directory in the game.
|
|
13
|
+
*/
|
|
14
|
+
copyToResourcePacks?: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A just task which copies files to a specified output location.
|
|
18
|
+
* Where there may be multiple output paths, and for each output path there may be multiple files.
|
|
19
|
+
*/
|
|
20
|
+
export declare function copyTask(params: CopyTaskParameters): () => void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.copyTask = void 0;
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const copyFiles_1 = require("./helpers/copyFiles");
|
|
11
|
+
const getOrThrowFromProcess_1 = require("./helpers/getOrThrowFromProcess");
|
|
12
|
+
const getGameDeploymentRootPaths_1 = require("./helpers/getGameDeploymentRootPaths");
|
|
13
|
+
const BehaviorPacksPath = 'development_behavior_packs';
|
|
14
|
+
const ResourcePacksPath = 'development_resource_packs';
|
|
15
|
+
/**
|
|
16
|
+
* A just task which copies files to a specified output location.
|
|
17
|
+
* Where there may be multiple output paths, and for each output path there may be multiple files.
|
|
18
|
+
*/
|
|
19
|
+
function copyTask(params) {
|
|
20
|
+
return () => {
|
|
21
|
+
const projectName = (0, getOrThrowFromProcess_1.getOrThrowFromProcess)('PROJECT_NAME');
|
|
22
|
+
let deploymentPath = undefined;
|
|
23
|
+
try {
|
|
24
|
+
const product = (0, getOrThrowFromProcess_1.getOrThrowFromProcess)('MINECRAFT_PRODUCT');
|
|
25
|
+
deploymentPath = (0, getGameDeploymentRootPaths_1.getGameDeploymentRootPaths)()[product];
|
|
26
|
+
}
|
|
27
|
+
catch (_) {
|
|
28
|
+
throw new Error('Unable to get deployment path. Make sure to configure package root correctly.');
|
|
29
|
+
}
|
|
30
|
+
if (deploymentPath === undefined) {
|
|
31
|
+
throw new Error('Deployment path is undefined. Make sure to configure package root correctly.');
|
|
32
|
+
}
|
|
33
|
+
(0, copyFiles_1.copyFiles)(params.copyToBehaviorPacks, path_1.default.join(deploymentPath, BehaviorPacksPath, projectName));
|
|
34
|
+
(0, copyFiles_1.copyFiles)(params.copyToScripts, path_1.default.join(deploymentPath, BehaviorPacksPath, projectName, 'scripts'));
|
|
35
|
+
if (params.copyToResourcePacks) {
|
|
36
|
+
(0, copyFiles_1.copyFiles)(params.copyToResourcePacks, path_1.default.join(deploymentPath, ResourcePacksPath, projectName));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.copyTask = copyTask;
|
|
41
|
+
//# sourceMappingURL=copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.js","sourceRoot":"","sources":["../../src/tasks/copy.ts"],"names":[],"mappings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sourceRoot":"","sources":["../../src/tasks/coreLint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coreLint.js","sourceRoot":"","sources":["../../src/tasks/coreLint.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,2BAAgC;AAEhC,+CAAoG;AACpG,gDAAwB;AACxB,sDAA8B;AAE9B,SAAgB,QAAQ,CAAC,KAAe,EAAE,GAAa;IACnD,IAAA,mBAAI,EAAC,aAAa,EAAE,GAAG,EAAE;QACrB,wFAAwF;QACxF,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,iBAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,6BAA6B,UAAU,GAAG,CAAC,CAAC;SAC/D;IACL,CAAC,CAAC,CAAC;IACH,IAAA,mBAAI,EAAC,QAAQ,EAAE,IAAA,yBAAU,EAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IAC3C,IAAA,mBAAI,EAAC,cAAc,EAAE,IAAA,2BAAY,EAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC9C,IAAA,mBAAI,EAAC,gBAAgB,EAAE,IAAA,gCAAiB,EAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAErD,OAAO,IAAA,qBAAM,EACT,aAAa,EACb,QAAQ,EACR,IAAA,wBAAS,EAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,EACvC,IAAA,wBAAS,EAAC,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CACzC,CAAC;AACN,CAAC;AAlBD,4BAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copyFiles(originPaths: string[], outputPath: string): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.copyFiles = void 0;
|
|
9
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
function copyFiles(originPaths, outputPath) {
|
|
12
|
+
let destinationPath = path_1.default.resolve(outputPath);
|
|
13
|
+
for (const originPath of originPaths) {
|
|
14
|
+
const inputPath = path_1.default.resolve(originPath);
|
|
15
|
+
const pathStats = node_core_library_1.FileSystem.getLinkStatistics(inputPath);
|
|
16
|
+
if (pathStats.isDirectory()) {
|
|
17
|
+
console.log(`Copying folder ${inputPath} to ${destinationPath}`);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const filename = path_1.default.parse(inputPath).base;
|
|
21
|
+
destinationPath = path_1.default.resolve(destinationPath, filename);
|
|
22
|
+
console.log(`Copying file ${inputPath} to ${destinationPath}`);
|
|
23
|
+
}
|
|
24
|
+
node_core_library_1.FileSystem.copyFiles({
|
|
25
|
+
sourcePath: inputPath,
|
|
26
|
+
destinationPath: destinationPath,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.copyFiles = copyFiles;
|
|
31
|
+
//# sourceMappingURL=copyFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyFiles.js","sourceRoot":"","sources":["../../../src/tasks/helpers/copyFiles.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,oEAA0D;AAC1D,gDAAwB;AAExB,SAAgB,SAAS,CAAC,WAAqB,EAAE,UAAkB;IAC/D,IAAI,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QAClC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC3C,MAAM,SAAS,GAAG,8BAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAC1D,IAAI,SAAS,CAAC,WAAW,EAAE,EAAE;YACzB,OAAO,CAAC,GAAG,CAAC,kBAAkB,SAAS,OAAO,eAAe,EAAE,CAAC,CAAC;SACpE;aAAM;YACH,MAAM,QAAQ,GAAG,cAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;YAC5C,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;YAC1D,OAAO,CAAC,GAAG,CAAC,gBAAgB,SAAS,OAAO,eAAe,EAAE,CAAC,CAAC;SAClE;QAED,8BAAU,CAAC,SAAS,CAAC;YACjB,UAAU,EAAE,SAAS;YACrB,eAAe,EAAE,eAAe;SACnC,CAAC,CAAC;KACN;AACL,CAAC;AAlBD,8BAkBC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.getTargetWorldPath = exports.getGameDeploymentRootPaths = void 0;
|
|
29
|
+
const platforms_1 = require("../../platforms");
|
|
30
|
+
const path_1 = __importStar(require("path"));
|
|
31
|
+
const getOrThrowFromProcess_1 = require("./getOrThrowFromProcess");
|
|
32
|
+
function getGameDeploymentRootPaths() {
|
|
33
|
+
const localAppDataPath = process.env['LOCALAPPDATA'];
|
|
34
|
+
const customDeploymentPath = process.env['CUSTOM_DEPLOYMENT_PATH'];
|
|
35
|
+
return {
|
|
36
|
+
BedrockUWP: localAppDataPath
|
|
37
|
+
? (0, path_1.resolve)(localAppDataPath, 'Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/')
|
|
38
|
+
: undefined,
|
|
39
|
+
PreviewUWP: localAppDataPath
|
|
40
|
+
? (0, path_1.resolve)(localAppDataPath, 'Packages/Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe/LocalState/games/com.mojang/')
|
|
41
|
+
: undefined,
|
|
42
|
+
Custom: customDeploymentPath ? customDeploymentPath : undefined,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
exports.getGameDeploymentRootPaths = getGameDeploymentRootPaths;
|
|
46
|
+
function getTargetWorldPath() {
|
|
47
|
+
let deploymentPath = undefined;
|
|
48
|
+
let product;
|
|
49
|
+
try {
|
|
50
|
+
product = (0, getOrThrowFromProcess_1.getOrThrowFromProcess)('MINECRAFT_PRODUCT');
|
|
51
|
+
deploymentPath = getGameDeploymentRootPaths()[product];
|
|
52
|
+
}
|
|
53
|
+
catch (_) {
|
|
54
|
+
throw new Error('Unable to get deployment path. Make sure to configure package root correctly.');
|
|
55
|
+
}
|
|
56
|
+
if (deploymentPath === undefined) {
|
|
57
|
+
throw new Error('Deployment path is undefined. Make sure to configure package root correctly.');
|
|
58
|
+
}
|
|
59
|
+
const projectName = (0, getOrThrowFromProcess_1.getOrThrowFromProcess)('PROJECT_NAME');
|
|
60
|
+
const worldsFolderName = product == platforms_1.MinecraftProduct.Custom ? 'worlds' : 'minecraftWorlds';
|
|
61
|
+
const activeWorldFolderName = product == platforms_1.MinecraftProduct.Custom ? 'Bedrock level' : `${projectName}world`;
|
|
62
|
+
return path_1.default.join(deploymentPath, worldsFolderName, activeWorldFolderName);
|
|
63
|
+
}
|
|
64
|
+
exports.getTargetWorldPath = getTargetWorldPath;
|
|
65
|
+
//# sourceMappingURL=getGameDeploymentRootPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGameDeploymentRootPaths.js","sourceRoot":"","sources":["../../../src/tasks/helpers/getGameDeploymentRootPaths.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,+CAAmD;AACnD,6CAAqC;AACrC,mEAAgE;AAEhE,SAAgB,0BAA0B;IACtC,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACrD,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACnE,OAAO;QACH,UAAU,EAAE,gBAAgB;YACxB,CAAC,CAAC,IAAA,cAAO,EAAC,gBAAgB,EAAE,4EAA4E,CAAC;YACzG,CAAC,CAAC,SAAS;QACf,UAAU,EAAE,gBAAgB;YACxB,CAAC,CAAC,IAAA,cAAO,EACH,gBAAgB,EAChB,oFAAoF,CACvF;YACH,CAAC,CAAC,SAAS;QACf,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS;KAClE,CAAC;AACN,CAAC;AAfD,gEAeC;AAED,SAAgB,kBAAkB;IAC9B,IAAI,cAAc,GAAuB,SAAS,CAAC;IACnD,IAAI,OAAyB,CAAC;IAC9B,IAAI;QACA,OAAO,GAAG,IAAA,6CAAqB,EAAmB,mBAAmB,CAAC,CAAC;QACvE,cAAc,GAAG,0BAA0B,EAAE,CAAC,OAAO,CAAC,CAAC;KAC1D;IAAC,OAAO,CAAC,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;KACpG;IAED,IAAI,cAAc,KAAK,SAAS,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;KACnG;IAED,MAAM,WAAW,GAAG,IAAA,6CAAqB,EAAC,cAAc,CAAC,CAAC;IAC1D,MAAM,gBAAgB,GAAG,OAAO,IAAI,4BAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAC3F,MAAM,qBAAqB,GAAG,OAAO,IAAI,4BAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,WAAW,OAAO,CAAC;IAC3G,OAAO,cAAI,CAAC,IAAI,CAAC,cAAc,EAAE,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;AAC9E,CAAC;AAlBD,gDAkBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks process.env for the desired key and returns the value if it exists, otherwise throws an error. Generic parameter
|
|
3
|
+
* is used to ensure the correct type is returned
|
|
4
|
+
*
|
|
5
|
+
* @param key - The key to query from process env
|
|
6
|
+
* @param message - Message to include in thrown error on failure
|
|
7
|
+
* @returns Value from process env or throws an error
|
|
8
|
+
*/
|
|
9
|
+
export declare function getOrThrowFromProcess<T = string>(key: string, messageOverride?: string): T;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.getOrThrowFromProcess = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Checks process.env for the desired key and returns the value if it exists, otherwise throws an error. Generic parameter
|
|
8
|
+
* is used to ensure the correct type is returned
|
|
9
|
+
*
|
|
10
|
+
* @param key - The key to query from process env
|
|
11
|
+
* @param message - Message to include in thrown error on failure
|
|
12
|
+
* @returns Value from process env or throws an error
|
|
13
|
+
*/
|
|
14
|
+
function getOrThrowFromProcess(key, messageOverride) {
|
|
15
|
+
const value = process.env[key];
|
|
16
|
+
if (!value) {
|
|
17
|
+
throw new Error(messageOverride ?? `Missing environment variable ${key}. Make sure to configure project.`);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
exports.getOrThrowFromProcess = getOrThrowFromProcess;
|
|
22
|
+
//# sourceMappingURL=getOrThrowFromProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrThrowFromProcess.js","sourceRoot":"","sources":["../../../src/tasks/helpers/getOrThrowFromProcess.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CAAa,GAAW,EAAE,eAAwB;IACnF,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,CAAC,KAAK,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,gCAAgC,GAAG,mCAAmC,CAAC,CAAC;KAC9G;IAED,OAAO,KAAU,CAAC;AACtB,CAAC;AAPD,sDAOC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./copyFiles"), exports);
|
|
20
|
+
__exportStar(require("./getOrThrowFromProcess"), exports);
|
|
21
|
+
__exportStar(require("./getGameDeploymentRootPaths"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tasks/helpers/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;AAElC,8CAA4B;AAC5B,0DAAwC;AACxC,+DAA6C"}
|
package/lib/tasks/index.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export * from './api-extractor';
|
|
2
|
+
export * from './bundle';
|
|
2
3
|
export * from './clean';
|
|
4
|
+
export * from './cleanCollateral';
|
|
5
|
+
export * from './copy';
|
|
3
6
|
export * from './coreLint';
|
|
7
|
+
export * from './helpers';
|
|
4
8
|
export * from './vitest';
|
|
9
|
+
export * from './updateWorld';
|
|
10
|
+
export * from './watch';
|
|
11
|
+
export * from './zip';
|
package/lib/tasks/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
2
4
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
5
|
if (k2 === undefined) k2 = k;
|
|
4
6
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -15,7 +17,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
17
|
};
|
|
16
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
19
|
__exportStar(require("./api-extractor"), exports);
|
|
20
|
+
__exportStar(require("./bundle"), exports);
|
|
18
21
|
__exportStar(require("./clean"), exports);
|
|
22
|
+
__exportStar(require("./cleanCollateral"), exports);
|
|
23
|
+
__exportStar(require("./copy"), exports);
|
|
19
24
|
__exportStar(require("./coreLint"), exports);
|
|
25
|
+
__exportStar(require("./helpers"), exports);
|
|
20
26
|
__exportStar(require("./vitest"), exports);
|
|
27
|
+
__exportStar(require("./updateWorld"), exports);
|
|
28
|
+
__exportStar(require("./watch"), exports);
|
|
29
|
+
__exportStar(require("./zip"), exports);
|
|
21
30
|
//# sourceMappingURL=index.js.map
|
package/lib/tasks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;AAElC,kDAAgC;AAChC,2CAAyB;AACzB,0CAAwB;AACxB,oDAAkC;AAClC,yCAAuB;AACvB,6CAA2B;AAC3B,4CAA0B;AAC1B,2CAAyB;AACzB,gDAA8B;AAC9B,0CAAwB;AACxB,wCAAsB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TaskFunction } from 'just-scripts';
|
|
2
|
+
export type UpdateWorldParameters = {
|
|
3
|
+
/**
|
|
4
|
+
* The path to the world backup directory.
|
|
5
|
+
*/
|
|
6
|
+
backupPath: string;
|
|
7
|
+
/**
|
|
8
|
+
* The path to the development world directory.
|
|
9
|
+
*/
|
|
10
|
+
devWorldPath: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A just task which updates the world in the game from the development path. Original world is backed up.
|
|
14
|
+
*/
|
|
15
|
+
export declare function updateWorldTask(params: UpdateWorldParameters): TaskFunction;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.updateWorldTask = void 0;
|
|
9
|
+
const just_scripts_1 = require("just-scripts");
|
|
10
|
+
const clean_1 = require("./clean");
|
|
11
|
+
const helpers_1 = require("./helpers");
|
|
12
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
/**
|
|
15
|
+
* A just task which updates the world in the game from the development path. Original world is backed up.
|
|
16
|
+
*/
|
|
17
|
+
function updateWorldTask(params) {
|
|
18
|
+
const targetWorldPath = path_1.default.resolve((0, helpers_1.getTargetWorldPath)());
|
|
19
|
+
(0, just_scripts_1.task)('clean_localmc_world_backup', (0, clean_1.cleanTask)([params.backupPath]));
|
|
20
|
+
(0, just_scripts_1.task)('backup_localmc_world', () => (0, helpers_1.copyFiles)([targetWorldPath], params.backupPath));
|
|
21
|
+
(0, just_scripts_1.task)('clean_localmc_world', (0, clean_1.cleanTask)([targetWorldPath]));
|
|
22
|
+
(0, just_scripts_1.task)('deploy_localmc_world', () => (0, helpers_1.copyFiles)([params.devWorldPath], targetWorldPath));
|
|
23
|
+
return (0, just_scripts_1.series)('clean_localmc_world_backup', (0, just_scripts_1.condition)('backup_localmc_world', () => node_core_library_1.FileSystem.exists(targetWorldPath)), 'clean_localmc_world', 'deploy_localmc_world');
|
|
24
|
+
}
|
|
25
|
+
exports.updateWorldTask = updateWorldTask;
|
|
26
|
+
//# sourceMappingURL=updateWorld.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateWorld.js","sourceRoot":"","sources":["../../src/tasks/updateWorld.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,+CAAqE;AACrE,mCAAoC;AACpC,uCAA0D;AAC1D,oEAA0D;AAC1D,gDAAwB;AAcxB;;GAEG;AACH,SAAgB,eAAe,CAAC,MAA6B;IACzD,MAAM,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,IAAA,4BAAkB,GAAE,CAAC,CAAC;IAC3D,IAAA,mBAAI,EAAC,4BAA4B,EAAE,IAAA,iBAAS,EAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACnE,IAAA,mBAAI,EAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAS,EAAC,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACpF,IAAA,mBAAI,EAAC,qBAAqB,EAAE,IAAA,iBAAS,EAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAA,mBAAI,EAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAS,EAAC,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;IACtF,OAAO,IAAA,qBAAM,EACT,4BAA4B,EAC5B,IAAA,wBAAS,EAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,8BAAU,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAC3E,qBAAqB,EACrB,sBAAsB,CACzB,CAAC;AACN,CAAC;AAZD,0CAYC"}
|
package/lib/tasks/vitest.js
CHANGED
package/lib/tasks/vitest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../src/tasks/vitest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../src/tasks/vitest.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,iDAAyC;AAEzC,SAAgB,UAAU;IACtB,OAAO,GAAG,EAAE;QACR,IAAA,wBAAQ,EAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7C,CAAC,CAAC;AACN,CAAC;AAJD,gCAIC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TaskFunction } from 'just-scripts';
|
|
2
|
+
/**
|
|
3
|
+
* If command line parameter `option` is present, watch for changes in the specified files and run the specified task.
|
|
4
|
+
* Otherwise, just run the task.
|
|
5
|
+
* @param globs The file globs to watch.
|
|
6
|
+
* @param taskFunction The task to run when changes are detected.
|
|
7
|
+
*/
|
|
8
|
+
export declare function watchTask(globs: string | string[], taskFunction: TaskFunction): TaskFunction;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.watchTask = void 0;
|
|
6
|
+
const just_scripts_1 = require("just-scripts");
|
|
7
|
+
const WATCH_TASK_NAME = 'watch-task';
|
|
8
|
+
(0, just_scripts_1.option)('watch');
|
|
9
|
+
/**
|
|
10
|
+
* If command line parameter `option` is present, watch for changes in the specified files and run the specified task.
|
|
11
|
+
* Otherwise, just run the task.
|
|
12
|
+
* @param globs The file globs to watch.
|
|
13
|
+
* @param taskFunction The task to run when changes are detected.
|
|
14
|
+
*/
|
|
15
|
+
function watchTask(globs, taskFunction) {
|
|
16
|
+
return () => {
|
|
17
|
+
if (!(0, just_scripts_1.argv)().watch) {
|
|
18
|
+
return taskFunction;
|
|
19
|
+
}
|
|
20
|
+
let taskInProgress = true;
|
|
21
|
+
let pendingWork = false;
|
|
22
|
+
const onFinished = (args) => {
|
|
23
|
+
if (args.name === WATCH_TASK_NAME) {
|
|
24
|
+
if (pendingWork) {
|
|
25
|
+
just_scripts_1.logger.info('Processing pending changes...');
|
|
26
|
+
pendingWork = false;
|
|
27
|
+
origTask.call();
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
just_scripts_1.logger.info('Waiting for new changes...');
|
|
31
|
+
taskInProgress = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
just_scripts_1.undertaker.on('start', function (args) {
|
|
36
|
+
if (args.name === WATCH_TASK_NAME) {
|
|
37
|
+
taskInProgress = true;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
just_scripts_1.undertaker.on('stop', function (args) {
|
|
41
|
+
onFinished(args);
|
|
42
|
+
});
|
|
43
|
+
just_scripts_1.undertaker.on('error', function (args) {
|
|
44
|
+
onFinished(args);
|
|
45
|
+
});
|
|
46
|
+
(0, just_scripts_1.task)(WATCH_TASK_NAME, (0, just_scripts_1.series)(taskFunction));
|
|
47
|
+
let origTask = (0, just_scripts_1.series)(WATCH_TASK_NAME);
|
|
48
|
+
// Start execution.
|
|
49
|
+
origTask.call();
|
|
50
|
+
(0, just_scripts_1.watch)(globs, () => {
|
|
51
|
+
if (!taskInProgress) {
|
|
52
|
+
origTask.call();
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
pendingWork = true;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return Promise.resolve();
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.watchTask = watchTask;
|
|
62
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/tasks/watch.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,+CAAmG;AAEnG,MAAM,eAAe,GAAG,YAAY,CAAC;AAErC,IAAA,qBAAM,EAAC,OAAO,CAAC,CAAC;AAEhB;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,KAAwB,EAAE,YAA0B;IAC1E,OAAO,GAAG,EAAE;QACR,IAAI,CAAC,IAAA,mBAAI,GAAE,CAAC,KAAK,EAAE;YACf,OAAO,YAAY,CAAC;SACvB;QAED,IAAI,cAAc,GAAG,IAAI,CAAC;QAC1B,IAAI,WAAW,GAAG,KAAK,CAAC;QAExB,MAAM,UAAU,GAAG,CAAC,IAAS,EAAE,EAAE;YAC7B,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE;gBAC/B,IAAI,WAAW,EAAE;oBACb,qBAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;oBAC7C,WAAW,GAAG,KAAK,CAAC;oBACnB,QAAgB,CAAC,IAAI,EAAE,CAAC;iBAC5B;qBAAM;oBACH,qBAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;oBAC1C,cAAc,GAAG,KAAK,CAAC;iBAC1B;aACJ;QACL,CAAC,CAAC;QAEF,yBAAU,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,IAAS;YACtC,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE;gBAC/B,cAAc,GAAG,IAAI,CAAC;aACzB;QACL,CAAC,CAAC,CAAC;QAEH,yBAAU,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,IAAS;YACrC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QAEH,yBAAU,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,IAAS;YACtC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QAEH,IAAA,mBAAI,EAAC,eAAe,EAAE,IAAA,qBAAM,EAAC,YAAY,CAAC,CAAC,CAAC;QAC5C,IAAI,QAAQ,GAAG,IAAA,qBAAM,EAAC,eAAe,CAAC,CAAC;QAEvC,mBAAmB;QAClB,QAAgB,CAAC,IAAI,EAAE,CAAC;QAEzB,IAAA,oBAAK,EAAC,KAAK,EAAE,GAAG,EAAE;YACd,IAAI,CAAC,cAAc,EAAE;gBAChB,QAAgB,CAAC,IAAI,EAAE,CAAC;aAC5B;iBAAM;gBACH,WAAW,GAAG,IAAI,CAAC;aACtB;QACL,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC,CAAC;AACN,CAAC;AAnDD,8BAmDC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CopyTaskParameters } from '.';
|
|
2
|
+
import { TaskFunction, parallel } from 'just-scripts';
|
|
3
|
+
export type ZipTaskParameters = CopyTaskParameters & {
|
|
4
|
+
/**
|
|
5
|
+
* The path to the output file to write the zip file to.
|
|
6
|
+
*/
|
|
7
|
+
outputFile: string;
|
|
8
|
+
};
|
|
9
|
+
export type ZipContent = {
|
|
10
|
+
/**
|
|
11
|
+
* The contents to add to the zip.
|
|
12
|
+
*/
|
|
13
|
+
contents: string[];
|
|
14
|
+
/**
|
|
15
|
+
* The relative path to the root. In case of provided contents are added into this folder inside the zip.
|
|
16
|
+
*/
|
|
17
|
+
targetPath?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A just task which compresses files into a specified output file.
|
|
21
|
+
*/
|
|
22
|
+
export declare function zipTask(outputFile: string, zipContents: ZipContent[]): ReturnType<typeof parallel>;
|
|
23
|
+
/**
|
|
24
|
+
* A just task which creates the mcaddon file.
|
|
25
|
+
*/
|
|
26
|
+
export declare function mcaddonTask(params: ZipTaskParameters): TaskFunction;
|
package/lib/tasks/zip.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.mcaddonTask = exports.zipTask = void 0;
|
|
9
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const zip_lib_1 = require("zip-lib");
|
|
12
|
+
const just_scripts_1 = require("just-scripts");
|
|
13
|
+
function addContentsToZip(zipContents, zip) {
|
|
14
|
+
for (const content of zipContents) {
|
|
15
|
+
for (const originPath of content.contents) {
|
|
16
|
+
const inputPath = path_1.default.resolve(originPath);
|
|
17
|
+
const pathStats = node_core_library_1.FileSystem.getLinkStatistics(inputPath);
|
|
18
|
+
if (pathStats.isDirectory()) {
|
|
19
|
+
console.log(`Adding folder ${inputPath} to package`);
|
|
20
|
+
zip.addFolder(inputPath, content.targetPath);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const metadataPath = content.targetPath
|
|
24
|
+
? path_1.default.join(content.targetPath, path_1.default.parse(inputPath).base)
|
|
25
|
+
: undefined;
|
|
26
|
+
console.log(`Adding file ${inputPath} to package`);
|
|
27
|
+
zip.addFile(inputPath, metadataPath);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A just task which compresses files into a specified output file.
|
|
34
|
+
*/
|
|
35
|
+
function zipTask(outputFile, zipContents) {
|
|
36
|
+
return async function zip() {
|
|
37
|
+
if (zipContents.length === 0 || !zipContents.some(content => content.contents.length > 0)) {
|
|
38
|
+
process.exitCode = 0;
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
}
|
|
41
|
+
const zip = new zip_lib_1.Zip();
|
|
42
|
+
addContentsToZip(zipContents, zip);
|
|
43
|
+
let isSucceeded = true;
|
|
44
|
+
let errorMessage = '';
|
|
45
|
+
await zip.archive(outputFile).then(function () {
|
|
46
|
+
console.error(`Compressed file created at ${outputFile}`);
|
|
47
|
+
}, function (err) {
|
|
48
|
+
isSucceeded = false;
|
|
49
|
+
errorMessage = `Compressed file failed to be created at ${outputFile}: ${err}`;
|
|
50
|
+
console.error(errorMessage);
|
|
51
|
+
});
|
|
52
|
+
if (isSucceeded) {
|
|
53
|
+
process.exitCode = 0;
|
|
54
|
+
return Promise.resolve();
|
|
55
|
+
}
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
return Promise.reject(new Error(errorMessage));
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
exports.zipTask = zipTask;
|
|
61
|
+
/**
|
|
62
|
+
* A just task which creates the mcaddon file.
|
|
63
|
+
*/
|
|
64
|
+
function mcaddonTask(params) {
|
|
65
|
+
const targetFolder = path_1.default.parse(params.outputFile).dir;
|
|
66
|
+
const outputFileName = path_1.default.parse(params.outputFile).name;
|
|
67
|
+
const behaviorPackFile = path_1.default.join(targetFolder, `${outputFileName}_bp.mcpack`);
|
|
68
|
+
const resourcePackFile = path_1.default.join(targetFolder, `${outputFileName}_rp.mcpack`);
|
|
69
|
+
const mcaddonContents = { contents: [behaviorPackFile] };
|
|
70
|
+
if (params.copyToResourcePacks && params.copyToResourcePacks.length > 0) {
|
|
71
|
+
mcaddonContents.contents.push(resourcePackFile);
|
|
72
|
+
}
|
|
73
|
+
(0, just_scripts_1.task)('packBP', zipTask(behaviorPackFile, [
|
|
74
|
+
{ contents: params.copyToBehaviorPacks },
|
|
75
|
+
{ contents: params.copyToScripts, targetPath: 'scripts' },
|
|
76
|
+
]));
|
|
77
|
+
(0, just_scripts_1.task)('packRP', zipTask(resourcePackFile, [{ contents: params.copyToResourcePacks ?? [] }]));
|
|
78
|
+
(0, just_scripts_1.task)('packMcaddon', zipTask(params.outputFile, [mcaddonContents]));
|
|
79
|
+
return (0, just_scripts_1.series)((0, just_scripts_1.parallel)('packBP', 'packRP'), 'packMcaddon');
|
|
80
|
+
}
|
|
81
|
+
exports.mcaddonTask = mcaddonTask;
|
|
82
|
+
//# sourceMappingURL=zip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../src/tasks/zip.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;AAElC,oEAA0D;AAC1D,gDAAwB;AAExB,qCAA8B;AAC9B,+CAAoE;AAoBpE,SAAS,gBAAgB,CAAC,WAAyB,EAAE,GAAQ;IACzD,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE;QAC/B,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,QAAQ,EAAE;YACvC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAC3C,MAAM,SAAS,GAAG,8BAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YAE1D,IAAI,SAAS,CAAC,WAAW,EAAE,EAAE;gBACzB,OAAO,CAAC,GAAG,CAAC,iBAAiB,SAAS,aAAa,CAAC,CAAC;gBACrD,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;aAChD;iBAAM;gBACH,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU;oBACnC,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;oBAC3D,CAAC,CAAC,SAAS,CAAC;gBAChB,OAAO,CAAC,GAAG,CAAC,eAAe,SAAS,aA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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minecraft/core-build-tasks",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Common build tasks
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Common build tasks used for minecraft-scripting-libraries",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"author": "Raphael Landaverde (rlanda@microsoft.com)",
|
|
@@ -16,9 +16,13 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@rushstack/node-core-library": "^3.59.6",
|
|
18
18
|
"@microsoft/api-extractor": "^7.38.3",
|
|
19
|
+
"esbuild": "^0.20.1",
|
|
20
|
+
"dotenv": "^16.0.2",
|
|
21
|
+
"prettier": "^2.8.2",
|
|
19
22
|
"rimraf": "^3.0.2",
|
|
20
23
|
"vitest": "^0.34.6",
|
|
21
|
-
"webpack": "^5.86.0"
|
|
24
|
+
"webpack": "^5.86.0",
|
|
25
|
+
"zip-lib": "^0.7.3"
|
|
22
26
|
},
|
|
23
27
|
"devDependencies": {
|
|
24
28
|
"@types/node": "^14.0.0 || ^16.0.0 || ^18.0.0",
|