@minecraft/core-build-tasks 1.0.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 ADDED
@@ -0,0 +1,5 @@
1
+ # Core Build Tasks
2
+
3
+ This package contains common build tasks used through the src-ts turbo build. If a task is used by `just` in multiple packages, it is moved into this package to reduce duplication. An example of this is the api-extractor task which is used by almost all packages in the src-ts subdirectory.
4
+
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 ADDED
@@ -0,0 +1 @@
1
+ export * from './tasks';
package/lib/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./tasks"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ (0, vitest_1.describe)('Remove when tests are added', () => {
5
+ (0, vitest_1.it)('Is always true', () => {
6
+ (0, vitest_1.expect)(true).toBe(true);
7
+ });
8
+ });
9
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";;AAAA,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,6 @@
1
+ /**
2
+ * A just task which executes API extractor based on the api-extractor.json configuration in the root of a package.
3
+ * @param jsonFile - the api-extractor.json file to use
4
+ * @beta
5
+ */
6
+ export declare function apiExtractorTask(jsonFile: string, localBuild: boolean): () => Promise<void>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiExtractorTask = void 0;
4
+ const api_extractor_1 = require("@microsoft/api-extractor");
5
+ /**
6
+ * A just task which executes API extractor based on the api-extractor.json configuration in the root of a package.
7
+ * @param jsonFile - the api-extractor.json file to use
8
+ * @beta
9
+ */
10
+ function apiExtractorTask(jsonFile, localBuild) {
11
+ return () => {
12
+ console.log(`Running a ${localBuild ? 'local' : 'production'} api extractor build.`);
13
+ const apiExtractorJsonPath = jsonFile;
14
+ const extractorConfig = api_extractor_1.ExtractorConfig.loadFileAndPrepare(apiExtractorJsonPath);
15
+ const extractorResult = api_extractor_1.Extractor.invoke(extractorConfig, {
16
+ // Equivalent to the "--local" command-line parameter
17
+ localBuild,
18
+ // Equivalent to the "--verbose" command-line parameter
19
+ showVerboseMessages: true,
20
+ });
21
+ if (extractorResult.succeeded) {
22
+ console.log(`API Extractor completed successfully`);
23
+ process.exitCode = 0;
24
+ return Promise.resolve();
25
+ }
26
+ const message = `API Extractor did not complete successfully. ${extractorResult.errorCount} errors found and ${extractorResult.warningCount} warnings found. These must be addressed for the test to succeed.`;
27
+ console.error(message);
28
+ process.exitCode = 1;
29
+ return Promise.reject(new Error(message));
30
+ };
31
+ }
32
+ exports.apiExtractorTask = apiExtractorTask;
33
+ //# sourceMappingURL=api-extractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-extractor.js","sourceRoot":"","sources":["../../src/tasks/api-extractor.ts"],"names":[],"mappings":";;;AAAA,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,2 @@
1
+ export declare const DEFAULT_CLEAN_DIRECTORIES: string[];
2
+ export declare function cleanTask(dirs: string[]): () => void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.cleanTask = exports.DEFAULT_CLEAN_DIRECTORIES = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const rimraf_1 = __importDefault(require("rimraf"));
9
+ exports.DEFAULT_CLEAN_DIRECTORIES = ['temp', 'lib', 'dist'];
10
+ function cleanTask(dirs) {
11
+ return () => {
12
+ for (const dir of dirs) {
13
+ console.log(`Cleaning ${dir}`);
14
+ (0, rimraf_1.default)(path_1.default.resolve(process.cwd(), dir), () => {
15
+ // no-op on unable to clean
16
+ });
17
+ }
18
+ };
19
+ }
20
+ exports.cleanTask = cleanTask;
21
+ //# sourceMappingURL=clean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clean.js","sourceRoot":"","sources":["../../src/tasks/clean.ts"],"names":[],"mappings":";;;;;;AAAA,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,2 @@
1
+ import type { TaskFunction } from 'just-scripts';
2
+ export declare function coreLint(files: string[], fix?: boolean): TaskFunction;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.coreLint = void 0;
7
+ const fs_1 = require("fs");
8
+ const just_scripts_1 = require("just-scripts");
9
+ const path_1 = __importDefault(require("path"));
10
+ const process_1 = __importDefault(require("process"));
11
+ function coreLint(files, fix) {
12
+ (0, just_scripts_1.task)('verify-lint', () => {
13
+ // If the process working directory does not have an `.eslintrc.js` file, fail the build
14
+ const lintConfig = path_1.default.resolve(process_1.default.cwd(), '.eslintrc.js');
15
+ if (!(0, fs_1.existsSync)(lintConfig)) {
16
+ throw new Error(`.eslintrc.js not found at ${lintConfig}.`);
17
+ }
18
+ });
19
+ (0, just_scripts_1.task)('eslint', (0, just_scripts_1.eslintTask)({ files, fix }));
20
+ (0, just_scripts_1.task)('prettier-fix', (0, just_scripts_1.prettierTask)({ files }));
21
+ (0, just_scripts_1.task)('prettier-check', (0, just_scripts_1.prettierCheckTask)({ files }));
22
+ return (0, just_scripts_1.series)('verify-lint', 'eslint', (0, just_scripts_1.condition)('prettier-check', () => !fix), (0, just_scripts_1.condition)('prettier-fix', () => !!fix));
23
+ }
24
+ exports.coreLint = coreLint;
25
+ //# sourceMappingURL=coreLint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coreLint.js","sourceRoot":"","sources":["../../src/tasks/coreLint.ts"],"names":[],"mappings":";;;;;;AAAA,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,4 @@
1
+ export * from './api-extractor';
2
+ export * from './clean';
3
+ export * from './coreLint';
4
+ export * from './vitest';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api-extractor"), exports);
18
+ __exportStar(require("./clean"), exports);
19
+ __exportStar(require("./coreLint"), exports);
20
+ __exportStar(require("./vitest"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,0CAAwB;AACxB,6CAA2B;AAC3B,2CAAyB"}
@@ -0,0 +1 @@
1
+ export declare function vitestTask(): () => void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vitestTask = void 0;
4
+ const child_process_1 = require("child_process");
5
+ function vitestTask() {
6
+ return () => {
7
+ (0, child_process_1.execSync)('vitest', { stdio: 'inherit' });
8
+ };
9
+ }
10
+ exports.vitestTask = vitestTask;
11
+ //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../src/tasks/vitest.ts"],"names":[],"mappings":";;;AAAA,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"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@minecraft/core-build-tasks",
3
+ "version": "1.0.0",
4
+ "description": "Common build tasks uses through this repository",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "author": "Raphael Landaverde (rlanda@microsoft.com)",
8
+ "scripts": {
9
+ "build-tools": "just-scripts build-tools",
10
+ "clean-tools": "just-scripts clean-tools",
11
+ "test": "just-scripts test"
12
+ },
13
+ "files": [
14
+ "lib"
15
+ ],
16
+ "dependencies": {
17
+ "@rushstack/node-core-library": "^3.59.6",
18
+ "@microsoft/api-extractor": "^7.38.3",
19
+ "rimraf": "^3.0.2",
20
+ "vitest": "^0.34.6",
21
+ "webpack": "^5.86.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^14.0.0 || ^16.0.0 || ^18.0.0",
25
+ "@types/rimraf": "^3.0.2",
26
+ "just-scripts": "^2.1.3",
27
+ "ts-node": "^10.9.1",
28
+ "tsconfig": "*",
29
+ "typescript": "^5.2.2"
30
+ }
31
+ }