@bf6mods/cli 1.2.2 → 1.2.3
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/dist/cli/index.js +2 -3
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import * as prompts from "@clack/prompts";
|
|
|
16
16
|
import { genExport, genInlineTypeImport } from "knitwork";
|
|
17
17
|
|
|
18
18
|
//#region package.json
|
|
19
|
-
var version$1 = "1.2.
|
|
19
|
+
var version$1 = "1.2.3";
|
|
20
20
|
var description = "CLI and library for bundling BF6 mods";
|
|
21
21
|
var bin = { "bf6mods": "./dist/cli/index.js" };
|
|
22
22
|
|
|
@@ -792,9 +792,8 @@ program.command("dev").description("watch the changes in src, and recompile as n
|
|
|
792
792
|
await dev();
|
|
793
793
|
});
|
|
794
794
|
program.command("import").argument("<input>").argument("<output>").option("--no-install-dependencies", `Prevents install of dependencies`).description("decompiles the json config of a mod into a new project").action(async (input, output, options) => {
|
|
795
|
-
const { installDependencies: installDependencies$1 } = options;
|
|
796
795
|
await importFile(input, output, void 0, true);
|
|
797
|
-
if (installDependencies
|
|
796
|
+
if (options?.installDependencies) installDependencies(output);
|
|
798
797
|
});
|
|
799
798
|
program.command("log").argument("[input]").description("logs the output from a locally running server").action(async (input) => {
|
|
800
799
|
new Bf6Logger(input).start();
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["program","key:\n\t\t\t\t\t\t\t| string\n\t\t\t\t\t\t\t| number\n\t\t\t\t\t\t\t| bigint\n\t\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t\t| RegExp\n\t\t\t\t\t\t\t| null\n\t\t\t\t\t\t\t| undefined","MapIdEnum","tsAttachment: Attachment | undefined","__filename","__dirname","attachments: Attachment[]","mapRotation: MapType[]","mapId: MapIdEnum","scene: string","finalJson: ConfigType","watcher: FSWatcher | undefined","timer: NodeJS.Timeout | undefined","targets: string[]","logger: Bf6Logger | undefined","bf6CliPackageJson.version","bf6SdkPackageJson.version","path","overwrite: \"yes\" | \"no\" | \"ignore\" | undefined","template","MapIdEnum","typescriptFile: string | undefined","stringsFile: string | undefined","scenes: [string, string][]","promises: Promise<unknown>[]","ext: string","path","__filename","__dirname","pkg.bin","pkg.description","pkg.version","installDependencies"],"sources":["../../package.json","../../src/resources/prepare/types/config.ts","../../src/cli/utils.ts","../../src/cli/build/generated-strings.ts","../../src/cli/build/index.ts","../../src/cli/log.ts","../../src/cli/dev.ts","../../../sdk/package.json","../../src/cli/init.ts","../../src/cli/import.ts","../../src/cli/prepare.ts","../../src/cli/index.ts"],"sourcesContent":["{\n\t\"name\": \"@bf6mods/cli\",\n\t\"version\": \"1.2.2\",\n\t\"description\": \"CLI and library for bundling BF6 mods\",\n\t\"license\": \"MIT\",\n\t\"type\": \"module\",\n\t\"bin\": {\n\t\t\"bf6mods\": \"./dist/cli/index.js\"\n\t},\n\t\"main\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.ts\",\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"start\": \"cross-env EXIT_CODE=none tsx ./src/cli/index.ts\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"import\": \"./dist/index.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist/\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/bf6mods/bf6mods.git\"\n\t},\n\t\"dependencies\": {\n\t\t\"@bf6mods/sdk\": \"*\",\n\t\t\"@clack/prompts\": \"^0.11.0\",\n\t\t\"chokidar\": \"^4.0.3\",\n\t\t\"colors\": \"^1.4.0\",\n\t\t\"commander\": \"^14.0.1\",\n\t\t\"jiti\": \"^2.6.1\",\n\t\t\"knitwork\": \"^1.2.0\",\n\t\t\"rolldown\": \"^1.0.0-beta.44\",\n\t\t\"stringify-object\": \"^6.0.0\",\n\t\t\"strip-ansi\": \"^7.1.2\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@oxc-project/types\": \"^0.95.0\",\n\t\t\"@types/stringify-object\": \"^4.0.5\",\n\t\t\"cross-env\": \"^10.1.0\",\n\t\t\"execa\": \"^9.6.0\",\n\t\t\"tsx\": \"^4.20.6\"\n\t}\n}\n","import type { ConfigType } from \"@bf6mods/sdk\";\n\nexport enum MapId {\n\tFireStorm = \"MP_FireStorm-ModBuilderCustom0\",\n\tSiegeOfCairo = \"MP_Abbasid-ModBuilderCustom0\",\n\tEmpireState = \"MP_Aftermath-ModBuilderCustom0\",\n\tIberianOffensive = \"MP_Battery-ModBuilderCustom0\",\n\tLiberationPeak = \"MP_Capstone-ModBuilderCustom0\",\n\tManhattanBridge = \"MP_Dumbo-ModBuilderCustom0\",\n\tSaintsQuarter = \"MP_Limestone-ModBuilderCustom0\",\n\tNewSobekCity = \"MP_Outskirts-ModBuilderCustom0\",\n\tMirakValley = \"MP_Tungsten-ModBuilderCustom0\",\n}\n\n/**\n * Represents the root configuration for a Battlefield 6 mod project.\n *\n * This file combines both build-level settings (like entrypoints and output directories)\n * and in-game configuration data (such as mutators and asset restrictions)\n * under the `game` key.\n *\n * Use {@link defineBf6Config} to define and validate this structure\n * in your `bf6.config.ts` file.\n */\nexport type Bf6Config = {\n\t/**\n\t * The human-readable name of the mod.\n\t *\n\t * Typically matches the project name used in the BF6 mod editor or\n\t * the display name shown in the in-game mod browser.\n\t */\n\tname: string;\n\n\t/**\n\t * A short description of the mod’s purpose or content.\n\t * Used for display and metadata purposes.\n\t */\n\tdescription: string;\n\n\t/**\n\t * The output directory where compiled or bundled files are written.\n\t * Usually something like `\"dist\"` or `\"build\"`.\n\t */\n\toutDir: string;\n\n\t/**\n\t * Whether or not to output the built files like the entrypoint typescript file\n\t */\n\toutputArtifacts?: boolean;\n\n\t/**\n\t * The main entrypoint for your mod’s TypeScript source file.\n\t *\n\t * This is typically something like `\"src/index.ts\"` or `\"src/main.ts\"`.\n\t */\n\tentrypoint?: string;\n\n\t/**\n\t * One or more scene file paths (.json) that the mod includes.\n\t * If no file path is provided, it loads in the default spatial data.\n\t */\n\tscenes?: ([MapId, string] | MapId)[];\n\n\t/**\n\t * Path to a JSON file or other source that defines localized strings\n\t * used by the mod (optional).\n\t */\n\tstrings?: string;\n\n\t/**\n\t * Generate strings automatically, by default this is enabled\n\t */\n\tgenerateStrings?: boolean;\n\n\t/**\n\t * Controls whether build output should be minified.\n\t *\n\t * Can be a boolean (to toggle all minification),\n\t * or an object specifying independent settings for JS and JSON files.\n\t *\n\t * @example\n\t * ```ts\n\t * minify: true\n\t * // or\n\t * minify: { js: true, json: false }\n\t * ```\n\t */\n\tminify?:\n\t\t| {\n\t\t\t\t/** Whether to minify JavaScript output. */\n\t\t\t\tjs?: boolean;\n\t\t\t\t/** Whether to minify JSON output. */\n\t\t\t\tjson?: boolean;\n\t\t }\n\t\t/** Enables or disables all minification. */\n\t\t| boolean;\n\n\t/**\n\t * The underlying in-game configuration derived from `ConfigType`\n\t * in the BF6 SDK. Includes gameplay-level details like mutators,\n\t * asset restrictions, and team compositions.\n\t *\n\t * The following properties are **excluded**:\n\t * - `attachments`\n\t * - `workspace`\n\t * - `mapRotation`\n\t * - `name`\n\t * - `description`\n\t *\n\t * since those are either redundant or handled elsewhere.\n\t */\n\tgame: Omit<\n\t\tConfigType,\n\t\t\"attachments\" | \"workspace\" | \"mapRotation\" | \"name\" | \"description\"\n\t>;\n};\n\n/**\n * Defines and validates a Battlefield 6 mod configuration object.\n *\n * This helper ensures your config is properly typed and can be\n * statically analyzed by TypeScript.\n *\n * @example\n * ```ts\n * export default defineBf6Config({\n * name: \"My Custom Mod\",\n * description: \"Adds custom rules\",\n * outDir: \"dist\",\n * entrypoint: \"src/main.ts\",\n * game: {\n * mutators: [],\n * assetRestrictions: {},\n * teamComposition: [],\n * },\n * });\n * ```\n *\n * @param bf6Config The configuration object to validate and return.\n * @returns The validated Battlefield 6 configuration object.\n */\nexport function defineBf6Config(bf6Config: Bf6Config): Bf6Config {\n\treturn bf6Config;\n}\n","import colors from \"colors\";\nimport stripAnsi from \"strip-ansi\";\n\n/**\n * Safely prints a message with a right-aligned timestamp.\n */\nexport const printToConsole = (message: string, error: boolean = false) => {\n\tconst now = new Date();\n\tconst formattedTime = colors.grey(now.toLocaleTimeString());\n\tconst terminalWidth = process.stdout.columns || 80;\n\n\tconst timeLength = stripAnsi(formattedTime).length;\n\tconst messageLength = stripAnsi(message).length;\n\tconst available = terminalWidth - (messageLength + timeLength);\n\n\tconst spacing = available > 1 ? \" \".repeat(available) : \" \";\n\n\tif (error) console.error(`${message}${spacing}${formattedTime}`);\n\telse console.log(`${message}${spacing}${formattedTime}`);\n};\n\nexport const readableList = (initialValues: readonly string[]) => {\n\tconst values = initialValues.map((v) => `\"${v}\"`);\n\tif (values.length > 1)\n\t\treturn `${values.slice(0, -1).join(\", \")} or ${values.slice(-1)}`;\n\treturn values[0];\n};\n","import type { Node, VariableDeclarator } from \"@oxc-project/types\";\nimport colors from \"colors\";\nimport type { Plugin } from \"rolldown\";\n\nexport function extractBf6Strings(\n\tbf6Strings: Record<string, string>,\n\tgenerateFromLiterals: boolean,\n): Plugin {\n\treturn {\n\t\tname: \"extract-bf6-strings\",\n\t\tgenerateBundle(_options, bundle) {\n\t\t\tif (!generateFromLiterals) return;\n\n\t\t\tlet id = 0;\n\t\t\tconst existingStrings = new Set(Object.values(bf6Strings));\n\n\t\t\tfor (const [_file, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== \"chunk\") continue;\n\t\t\t\tconst code = output.code;\n\n\t\t\t\t// Parse the code with rolldown’s parser\n\t\t\t\tconst program = this.parse(code, {\n\t\t\t\t\tlang: \"ts\",\n\t\t\t\t\tastType: \"js\",\n\t\t\t\t\trange: true,\n\t\t\t\t});\n\n\t\t\t\t// Visit every node recursively to collect string literals\n\t\t\t\tfunction walk(node: Node) {\n\t\t\t\t\tif (node.type === \"Literal\") {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttypeof node.value !== \"string\" ||\n\t\t\t\t\t\t\tnode.value === \"\" ||\n\t\t\t\t\t\t\tnode.value === \"----uniquename----\"\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!(node.value in bf6Strings) &&\n\t\t\t\t\t\t\t!existingStrings.has(node.value)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\texistingStrings.add(node.value);\n\t\t\t\t\t\t\tbf6Strings[`__auto__${id++}`] = node.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const value of Object.values(node)) {\n\t\t\t\t\t\tif (!value) continue;\n\t\t\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t\t\tfor (const v of value) {\n\t\t\t\t\t\t\t\tif (v && typeof v === \"object\" && \"type\" in v) walk(v as Node);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (typeof value === \"object\" && \"type\" in value) {\n\t\t\t\t\t\t\twalk(value as Node);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const item of program.body) {\n\t\t\t\t\twalk(item);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tmoduleParsed(moduleInfo) {\n\t\t\tif (moduleInfo.code && moduleInfo.exports.includes(\"bf6Strings\")) {\n\t\t\t\tconst code = moduleInfo.code;\n\t\t\t\tconst getSnippet = (\n\t\t\t\t\tstart: number,\n\t\t\t\t\tend: number,\n\t\t\t\t\tlinesBefore = 2,\n\t\t\t\t\tlinesAfter = 2,\n\t\t\t\t) => {\n\t\t\t\t\tconst lines = code.split(/\\r?\\n/);\n\t\t\t\t\tconst startLine = Math.max(\n\t\t\t\t\t\t0,\n\t\t\t\t\t\tcode.slice(0, start).split(/\\r?\\n/).length - 1 - linesBefore,\n\t\t\t\t\t);\n\t\t\t\t\tconst endLine = Math.min(\n\t\t\t\t\t\tlines.length,\n\t\t\t\t\t\tcode.slice(0, end).split(/\\r?\\n/).length - 1 + linesAfter,\n\t\t\t\t\t);\n\t\t\t\t\treturn lines\n\t\t\t\t\t\t.slice(startLine, endLine)\n\t\t\t\t\t\t.map((line, i) => {\n\t\t\t\t\t\t\tconst actualLine = startLine + i + 1;\n\t\t\t\t\t\t\treturn `${actualLine.toString().padStart(3)} | ${line}`;\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join(\"\\n\");\n\t\t\t\t};\n\n\t\t\t\tconst program = this.parse(code, {\n\t\t\t\t\tlang: \"ts\",\n\t\t\t\t\tastType: \"js\",\n\t\t\t\t\trange: true,\n\t\t\t\t});\n\n\t\t\t\tconst extractObjectLiteral = (declaration: VariableDeclarator) => {\n\t\t\t\t\tif (declaration.init?.type !== \"ObjectExpression\") {\n\t\t\t\t\t\tconst snippet = getSnippet(...(declaration.range ?? [0, 0]));\n\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} Invalid bf6Strings export: expected an object literal.\\n\\n${snippet}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const property of declaration.init.properties) {\n\t\t\t\t\t\tif (property.type !== \"Property\") {\n\t\t\t\t\t\t\tconst snippet = getSnippet(...(property.range ?? [0, 0]));\n\t\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} Invalid bf6Strings property: expected a key/value pair.\\nFound type: ${property.type}\\n\\n${snippet}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet key:\n\t\t\t\t\t\t\t| string\n\t\t\t\t\t\t\t| number\n\t\t\t\t\t\t\t| bigint\n\t\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t\t| RegExp\n\t\t\t\t\t\t\t| null\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tif (property.key.type === \"Literal\") {\n\t\t\t\t\t\t\tkey = property.key.value;\n\t\t\t\t\t\t} else if (property.key.type === \"Identifier\") {\n\t\t\t\t\t\t\tkey = property.key.name;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst snippet = getSnippet(...(property.range ?? [0, 0]));\n\t\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} Invalid bf6Strings key: expected a string literal or identifier.\\nFound type: ${property.key.type}\\n\\n${snippet}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (property.value.type !== \"Literal\") {\n\t\t\t\t\t\t\tconst snippet = getSnippet(...(property.range ?? [0, 0]));\n\t\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} Invalid bf6Strings value: expected a string literal.\\nFound type: ${property.value.type}\\n\\n${snippet}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst value = property.value.value;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttypeof key !== \"string\" &&\n\t\t\t\t\t\t\ttypeof key !== \"number\" &&\n\t\t\t\t\t\t\ttypeof key !== \"bigint\" &&\n\t\t\t\t\t\t\ttypeof key !== \"boolean\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst snippet = getSnippet(...(property.range ?? [0, 0]));\n\t\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} bf6Strings key must be a string, found: ${typeof key}\\n\\n${snippet}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttypeof value !== \"string\" &&\n\t\t\t\t\t\t\ttypeof value !== \"number\" &&\n\t\t\t\t\t\t\ttypeof value !== \"bigint\" &&\n\t\t\t\t\t\t\ttypeof value !== \"boolean\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst snippet = getSnippet(...(property.range ?? [0, 0]));\n\t\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} bf6Strings value must be a string, found: ${typeof value}\\n\\n${snippet}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbf6Strings[`${key}`] = `${value}`;\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tfor (const item of program.body) {\n\t\t\t\t\t// Case 1: plain variable `var bf6Strings = {...}`\n\t\t\t\t\tif (item.type === \"VariableDeclaration\") {\n\t\t\t\t\t\tfor (const declaration of item.declarations) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdeclaration.type === \"VariableDeclarator\" &&\n\t\t\t\t\t\t\t\tdeclaration.id.type === \"Identifier\" &&\n\t\t\t\t\t\t\t\tdeclaration.id.name === \"bf6Strings\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\textractObjectLiteral(declaration);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Case 2: exported variable `export const bf6Strings = {...}`\n\t\t\t\t\tif (\n\t\t\t\t\t\titem.type === \"ExportNamedDeclaration\" &&\n\t\t\t\t\t\titem.declaration?.type === \"VariableDeclaration\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tfor (const declaration of item.declaration.declarations) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdeclaration.type === \"VariableDeclarator\" &&\n\t\t\t\t\t\t\t\tdeclaration.id.type === \"Identifier\" &&\n\t\t\t\t\t\t\t\tdeclaration.id.name === \"bf6Strings\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\textractObjectLiteral(declaration);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n\ttype Attachment,\n\tAttachmentType,\n\ttype ConfigType,\n\ttype MapType,\n} from \"@bf6mods/sdk\";\nimport colors from \"colors\";\nimport { createJiti } from \"jiti\";\nimport { rolldown } from \"rolldown\";\nimport {\n\ttype Bf6Config,\n\tMapId as MapIdEnum,\n} from \"../../resources/prepare/types/config.ts\";\nimport { printToConsole } from \"../utils.ts\";\nimport { extractBf6Strings } from \"./generated-strings.ts\";\n\ndeclare global {\n\tvar defineBf6Config: ((config: Bf6Config) => Bf6Config) | undefined;\n\tvar MapId: typeof MapIdEnum | undefined;\n}\n\n/**\n * Dynamically imports and validates bf6.config.ts\n */\nexport async function getBf6Config(rootDir: string): Promise<Bf6Config> {\n\tglobalThis.defineBf6Config = (c) => c;\n\tglobalThis.MapId = MapIdEnum;\n\tconst jiti = createJiti(rootDir, { interopDefault: true });\n\tconst result = await jiti.import(\"./bf6.config\", { default: true });\n\tdelete globalThis.defineBf6Config;\n\tdelete globalThis.MapId;\n\treturn result as Bf6Config;\n}\n\n/**\n * Builds the entire mod project once (for production or single run).\n */\nexport async function build() {\n\tconst workingDir = path.resolve(\".\");\n\tconst config = await getBf6Config(workingDir);\n\n\tconst outDir = path.resolve(workingDir, config.outDir);\n\tif (fs.existsSync(outDir))\n\t\tfs.rmSync(outDir, { recursive: true, force: true });\n\tfs.mkdirSync(outDir, { recursive: true });\n\n\tconst minifyJson =\n\t\ttypeof config.minify === \"boolean\"\n\t\t\t? config.minify\n\t\t\t: (config.minify?.json ?? false);\n\n\tconst generatedStrings = {};\n\tlet tsAttachment: Attachment | undefined;\n\tif (config.entrypoint) {\n\t\tconst entryAbs = path.resolve(workingDir, config.entrypoint);\n\t\tconst compiled = await buildEntrypoint(\n\t\t\tentryAbs,\n\t\t\tgeneratedStrings,\n\t\t\tconfig.generateStrings ?? true,\n\t\t);\n\t\ttsAttachment = createTsAttachment(entryAbs, compiled);\n\t}\n\n\tconst { attachments, mapRotation } = await collectAttachments(\n\t\tconfig,\n\t\tworkingDir,\n\t\ttsAttachment,\n\t\tgeneratedStrings,\n\t);\n\n\tawait writeModJson(config, outDir, attachments, mapRotation, minifyJson);\n\tprintToConsole(`${colors.green.bold(\"✓\")} Built mod: ${config.name}`);\n}\n\n/**\n * Compiles the TypeScript entrypoint using rolldown and returns the compiled code.\n */\nexport async function buildEntrypoint(\n\tentry: string,\n\tbf6Strings: Record<string, string>,\n\tgenerateStringsFromLiterals: boolean,\n): Promise<string> {\n\tconst bundle = await rolldown({\n\t\tinput: entry,\n\t\tplugins: [extractBf6Strings(bf6Strings, generateStringsFromLiterals)],\n\t\tlogLevel: \"debug\",\n\t\tresolve: {\n\t\t\talias: {\n\t\t\t\tmodlib: \"@bf6mods/sdk\",\n\t\t\t},\n\t\t},\n\t});\n\tconst result = await bundle.generate({\n\t\tformat: \"esm\",\n\t\tinlineDynamicImports: true,\n\t});\n\n\tconst code = result.output[0].code;\n\treturn code;\n}\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\nconst spatialsDir = path.resolve(__dirname, \"../resources/maps/spatial\");\n/**\n * Collects all attachments (TS, scenes, strings) and returns them + mapRotation.\n */\nexport async function collectAttachments(\n\tconfig: Bf6Config,\n\tworkingDir: string,\n\ttsAttachment: Attachment | undefined,\n\tgeneratedStrings: Record<string, number | string> | undefined,\n) {\n\tconst attachments: Attachment[] = [];\n\tconst mapRotation: MapType[] = [];\n\n\tif (tsAttachment) attachments.push(tsAttachment);\n\n\t// Strings\n\tif (config.strings || Object.keys(generatedStrings ?? {}).length > 0) {\n\t\tconst strPath = path.resolve(workingDir, config.strings ?? \"strings.json\");\n\t\tlet raw = \"{}\";\n\t\tif (fs.existsSync(strPath)) {\n\t\t\traw = await fs.promises.readFile(strPath, \"utf8\");\n\t\t} else {\n\t\t\t// Create a placeholder for clarity (optional)\n\t\t\tprintToConsole(\n\t\t\t\tcolors.yellow(\n\t\t\t\t\t`⚠️ No strings.json found, generating from literals only.`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst attachment = createStringsAttachment(strPath, raw, generatedStrings);\n\t\tattachments.push(attachment);\n\t}\n\n\t// Scenes\n\tif (config.scenes) {\n\t\tlet mapIdx = 0;\n\t\tfor (const map of config.scenes) {\n\t\t\tlet mapId: MapIdEnum;\n\t\t\tlet scene: string;\n\t\t\tif (Array.isArray(map)) {\n\t\t\t\t[mapId, scene] = map;\n\t\t\t} else {\n\t\t\t\tmapId = map;\n\t\t\t\tscene = path.resolve(spatialsDir, `${mapId}.spatial.json`);\n\t\t\t}\n\n\t\t\tconst scenePath = path.resolve(workingDir, scene);\n\t\t\tif (!fs.existsSync(scenePath))\n\t\t\t\tthrow new Error(`Cannot find spatial data file: ${scene}`);\n\t\t\tconst raw = await fs.promises.readFile(scenePath, \"utf8\");\n\t\t\tconst spatial = createSpatialAttachment(scenePath, raw, mapIdx++);\n\t\t\tattachments.push(spatial);\n\t\t\tmapRotation.push({ id: mapId, spatialAttachment: spatial });\n\t\t}\n\t}\n\n\treturn { attachments, mapRotation };\n}\n\n/**\n * Writes the mod.json output to disk.\n */\nexport async function writeModJson(\n\tconfig: Bf6Config,\n\toutDir: string,\n\tattachments: ConfigType[\"attachments\"],\n\tmapRotation: MapType[],\n\tminify: boolean,\n) {\n\tconst baseGame = config.game;\n\tconst finalJson: ConfigType = {\n\t\tname: config.name,\n\t\tdescription: config.description,\n\t\tgameMode: \"ModBuilderCustom\",\n\t\tmutators: baseGame.mutators ?? {},\n\t\tassetRestrictions: baseGame.assetRestrictions ?? {},\n\t\tteamComposition: baseGame.teamComposition ?? [],\n\t\tmapRotation,\n\t\tattachments,\n\t};\n\n\tconst jsonOutput = minify\n\t\t? JSON.stringify(finalJson)\n\t\t: JSON.stringify(finalJson, null, 2);\n\tawait fs.promises.writeFile(path.resolve(outDir, \"mod.json\"), jsonOutput);\n\n\tif (config.outputArtifacts && finalJson?.attachments) {\n\t\tfor (const attachment of finalJson.attachments) {\n\t\t\tconst attachmentsDir = path.resolve(outDir, \"attachments\");\n\t\t\tif (!fs.existsSync(attachmentsDir))\n\t\t\t\tfs.mkdirSync(attachmentsDir, {\n\t\t\t\t\trecursive: true,\n\t\t\t\t});\n\t\t\tawait fs.promises.writeFile(\n\t\t\t\tpath.resolve(outDir, \"attachments\", attachment.filename),\n\t\t\t\tatob(attachment.attachmentData.original),\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function createTsAttachment(\n\tfilePath: string,\n\tcompiled: string,\n): Attachment {\n\treturn {\n\t\tid: crypto.randomUUID(),\n\t\tversion: \"1.0\",\n\t\tfilename: `${path.parse(filePath).name}.js`,\n\t\tisProcessable: true,\n\t\tprocessingStatus: 2,\n\t\tattachmentType: AttachmentType.TypeScript,\n\t\tattachmentData: { original: toBase64(compiled), compiled: \"\" },\n\t\terrors: [],\n\t};\n}\n\nexport function createStringsAttachment(\n\tfilePath: string,\n\traw: string,\n\tgeneratedStrings?: Record<string, number | string> | undefined,\n): Attachment {\n\tlet result = raw;\n\tif (generatedStrings) {\n\t\tresult = JSON.stringify(\n\t\t\t{\n\t\t\t\t...generatedStrings,\n\t\t\t\t...JSON.parse(raw),\n\t\t\t},\n\t\t\tnull,\n\t\t\t4,\n\t\t);\n\t}\n\n\treturn {\n\t\tid: crypto.randomUUID(),\n\t\tversion: \"1.0\",\n\t\tfilename: path.basename(filePath),\n\t\tisProcessable: true,\n\t\tprocessingStatus: 2,\n\t\tattachmentType: AttachmentType.Strings,\n\t\tattachmentData: { original: toBase64(result), compiled: \"\" },\n\t\terrors: [],\n\t};\n}\n\nexport function createSpatialAttachment(\n\tfilePath: string,\n\traw: string,\n\tmapIdx: number,\n): MapType[\"spatialAttachment\"] {\n\treturn {\n\t\tid: crypto.randomUUID(),\n\t\tversion: \"1.0\",\n\t\tfilename: path.basename(filePath),\n\t\tisProcessable: true,\n\t\tprocessingStatus: 2,\n\t\tattachmentType: AttachmentType.SpatialData,\n\t\tattachmentData: { original: toBase64(raw), compiled: \"\" },\n\t\tmetadata: `mapIdx=${mapIdx}`,\n\t\terrors: [],\n\t};\n}\n\nexport function toBase64(input: string | Buffer): string {\n\treturn Buffer.isBuffer(input)\n\t\t? input.toString(\"base64\")\n\t\t: Buffer.from(input, \"utf8\").toString(\"base64\");\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport chokidar, { type FSWatcher } from \"chokidar\";\nimport colors from \"colors\";\nimport { printToConsole } from \"./utils.ts\";\n\nexport class Bf6Logger {\n\tprivate static instance: Bf6Logger | undefined;\n\n\tprivate watchTarget: string;\n\tprivate watcher?: FSWatcher;\n\tprivate lastSize: number;\n\n\tconstructor(input?: string) {\n\t\tif (Bf6Logger.instance) {\n\t\t\tprintToConsole(\n\t\t\t\tcolors.yellow(\"⚠ Existing logger found — closing it first...\"),\n\t\t\t);\n\t\t\tBf6Logger.instance.stop();\n\t\t}\n\n\t\tif (input) this.watchTarget = path.resolve(input);\n\t\telse if (process.env.LOCALAPPDATA)\n\t\t\tthis.watchTarget = path.resolve(\n\t\t\t\tprocess.env.LOCALAPPDATA,\n\t\t\t\t\"temp\",\n\t\t\t\t\"Battlefieldâ„¢ 6\",\n\t\t\t\t\"PortalLog.txt\",\n\t\t\t);\n\t\telse\n\t\t\tthrow new Error(\n\t\t\t\t`${colors.red.bold(\"✗\")} Env variable LOCALAPPDATA not defined, and input file to watch was not provided!`,\n\t\t\t);\n\n\t\tif (!fs.existsSync(this.watchTarget))\n\t\t\tthrow new Error(\n\t\t\t\t`${colors.red.bold(\"✗\")} Cannot find file '${this.watchTarget}' to watch for changes`,\n\t\t\t);\n\n\t\tthis.lastSize = fs.statSync(this.watchTarget).size;\n\t\tBf6Logger.instance = this;\n\t}\n\n\tasync start() {\n\t\tprintToConsole(\n\t\t\tcolors.cyan(\n\t\t\t\t`👀 Watching Battlefield logs at: ${colors.yellow(this.watchTarget)}`,\n\t\t\t),\n\t\t);\n\n\t\tthis.watcher = chokidar.watch(this.watchTarget, {\n\t\t\tpersistent: true,\n\t\t\tignoreInitial: true,\n\t\t});\n\n\t\tthis.watcher.on(\"change\", this.handleChange.bind(this));\n\t}\n\n\tasync stop() {\n\t\tif (this.watcher) {\n\t\t\tthis.watcher.close();\n\t\t\tthis.watcher = undefined;\n\t\t\tprintToConsole(\n\t\t\t\tcolors.yellow(\n\t\t\t\t\t`${colors.red.bold(\"✗\")} Stopped watching: ${colors.gray(this.watchTarget)}`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tBf6Logger.instance = undefined;\n\t}\n\n\tprivate handleChange(file: string, stats?: fs.Stats) {\n\t\tif (!stats) return;\n\t\tif (stats.size > this.lastSize) {\n\t\t\tconst newBytes = stats.size - this.lastSize;\n\t\t\tconst fd = fs.openSync(file, \"r\");\n\t\t\tconst buffer = Buffer.alloc(newBytes);\n\t\t\tfs.readSync(fd, buffer, 0, newBytes, this.lastSize);\n\t\t\tfs.closeSync(fd);\n\n\t\t\tconst newContent = buffer\n\t\t\t\t.toString(\"utf8\")\n\t\t\t\t.split(\"QuickJS: \")\n\t\t\t\t.filter((debug) => debug.trim() !== \"\")\n\t\t\t\t.map((debug) => debug.trim())\n\t\t\t\t.map((debug) => {\n\t\t\t\t\tif (debug.startsWith(\"console.log: \")) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: \"console.log\",\n\t\t\t\t\t\t\ttext: debug.replace(\"console.log: \", \"\"),\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (debug.startsWith(\"Exception:\")) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: \"exception\",\n\t\t\t\t\t\t\ttext: debug.replace(\"Exception:\", \"\"),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"unknown\",\n\t\t\t\t\t\ttext: debug,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\tfor (const content of newContent) {\n\t\t\t\tif (content.type === \"console.log\")\n\t\t\t\t\tprintToConsole(colors.gray(content.text));\n\t\t\t\telse if (content.type === \"exception\")\n\t\t\t\t\tprintToConsole(colors.red(content.text), true);\n\t\t\t\telse printToConsole(colors.bold(content.text));\n\t\t\t}\n\t\t}\n\t\tthis.lastSize = stats.size;\n\t}\n}\n","import fs from \"node:fs\";\nimport { glob } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport chokidar, { type FSWatcher } from \"chokidar\";\nimport colors from \"colors\";\nimport { build, getBf6Config } from \"./build/index.ts\";\nimport { Bf6Logger } from \"./log.ts\";\nimport { printToConsole } from \"./utils.ts\";\n\nexport async function dev() {\n\tconst workingDir = path.resolve(\".\");\n\tlet config = await getBf6Config(workingDir);\n\tconst outDir = path.resolve(workingDir, config.outDir);\n\tfs.mkdirSync(outDir, { recursive: true });\n\n\tprintToConsole(colors.cyan(`▶ Starting dev for ${config.name}`));\n\n\tlet watcher: FSWatcher | undefined;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: doesn't really matter in this case\n\tfunction debounce<T extends (...args: any[]) => void>(fn: T, delay: number) {\n\t\tlet timer: NodeJS.Timeout | undefined;\n\t\treturn (...args: Parameters<T>) => {\n\t\t\tif (timer) clearTimeout(timer);\n\t\t\ttimer = setTimeout(() => fn(...args), delay);\n\t\t};\n\t}\n\n\tconst rebuild = async (trigger: string) => {\n\t\tprintToConsole(\n\t\t\tcolors.yellow(\n\t\t\t\t`↻ Change detected in ${path.basename(trigger)}, rebuilding...`,\n\t\t\t),\n\t\t);\n\t\tconst start = performance.now();\n\t\ttry {\n\t\t\tawait build();\n\t\t\tconst duration = ((performance.now() - start) / 1000).toFixed(2);\n\t\t\tprintToConsole(\n\t\t\t\t`${colors.green.bold(\"✓\")} Updated mod.json (${duration}s)`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tprintToConsole(\n\t\t\t\tcolors.red(\n\t\t\t\t\t`${colors.red.bold(\"✗\")} Rebuild failed: ${(err as Error).message}`,\n\t\t\t\t),\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\t};\n\n\tconst debouncedRebuild = debounce(rebuild, 200);\n\n\tasync function collectWatchTargets(): Promise<string[]> {\n\t\tconst targets: string[] = [];\n\n\t\tif (config.entrypoint)\n\t\t\ttargets.push(path.resolve(workingDir, config.entrypoint));\n\t\tif (config.scenes)\n\t\t\tfor (const [, scene] of config.scenes)\n\t\t\t\ttargets.push(path.resolve(workingDir, scene));\n\t\tif (config.strings) targets.push(path.resolve(workingDir, config.strings));\n\t\tfor await (const entry of glob(\"bf6.config.*\")) targets.push(entry);\n\t\tfor await (const entry of glob(\"src/**/*\")) targets.push(entry);\n\n\t\treturn targets;\n\t}\n\n\tasync function setupWatcher() {\n\t\tif (watcher) {\n\t\t\tawait watcher.close();\n\t\t\tprintToConsole(\n\t\t\t\tcolors.grey(\"♻ Reloading watcher due to config change...\"),\n\t\t\t);\n\t\t\tawait new Promise((r) => setTimeout(r, 10));\n\t\t}\n\n\t\tconst watchTargets = await collectWatchTargets();\n\t\tprintToConsole(colors.cyan(`👀 Watching ${watchTargets.length} files...`));\n\n\t\twatcher = chokidar.watch(watchTargets, {\n\t\t\tpersistent: true,\n\t\t\tignoreInitial: true,\n\t\t\tawaitWriteFinish: { stabilityThreshold: 250, pollInterval: 100 },\n\t\t\tignored: [outDir, `${outDir}/**`, \"node_modules/**\", \".git/**\"],\n\t\t});\n\n\t\twatcher.on(\"error\", (err) => {\n\t\t\tprintToConsole(\n\t\t\t\tcolors.red(`⚠ Watcher error: ${(err as Error).message}`),\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tsetTimeout(setupWatcher, 1000);\n\t\t});\n\n\t\twatcher.on(\"change\", async (file) => {\n\t\t\tif (file.includes(\"bf6.config.\")) {\n\t\t\t\tprintToConsole(\n\t\t\t\t\tcolors.magenta(\"⚙ Config changed — reloading watcher...\"),\n\t\t\t\t);\n\t\t\t\tconfig = await getBf6Config(workingDir);\n\t\t\t\tawait setupWatcher();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdebouncedRebuild(file);\n\t\t});\n\n\t\twatcher.on(\"add\", debouncedRebuild);\n\t\tawait rebuild(\"initial\");\n\t}\n\n\tprocess.on(\"SIGINT\", async () => {\n\t\tprintToConsole(colors.red(`\\n${colors.red.bold(\"✗\")} Exiting dev mode...`));\n\t\tawait watcher?.close();\n\t\tprocess.exit(0);\n\t});\n\n\tawait setupWatcher();\n\n\tlet logger: Bf6Logger | undefined;\n\ttry {\n\t\tlogger = new Bf6Logger();\n\t\tlogger.start();\n\t} catch (error) {\n\t\tprintToConsole(\n\t\t\tcolors.grey(\n\t\t\t\t\"Failed to start logging for the following reason (building will still work)\",\n\t\t\t),\n\t\t\ttrue,\n\t\t);\n\t\tprintToConsole((error as Error).message, true);\n\t}\n}\n","{\n\t\"name\": \"@bf6mods/sdk\",\n\t\"version\": \"1.2.0\",\n\t\"description\": \"TypeScript definitions for the BF6 modding API\",\n\t\"type\": \"module\",\n\t\"license\": \"MIT\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"import\": \"./dist/index.js\"\n\t\t},\n\t\t\"./std\": {\n\t\t\t\"types\": \"./dist/std/index.d.ts\",\n\t\t\t\"import\": \"./dist/std/index.js\"\n\t\t}\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/bf6mods/bf6mods.git\"\n\t},\n\t\"files\": [\n\t\t\"dist/\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\"\n\t},\n\t\"keywords\": [\n\t\t\"bf6\",\n\t\t\"mods\",\n\t\t\"typescript\",\n\t\t\"definitions\",\n\t\t\"api\"\n\t],\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n","import child_process from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport * as prompts from \"@clack/prompts\";\nimport bf6SdkPackageJson from \"../../../sdk/package.json\" with { type: \"json\" };\nimport bf6CliPackageJson from \"../../package.json\" with { type: \"json\" };\nimport { importFile } from \"./import.ts\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst templatesDir = path.resolve(__dirname, \"../resources/templates\");\n\nfunction renameFilesRecursively(dir: string, modName: string) {\n\tconst entries = fs.readdirSync(dir, { withFileTypes: true });\n\tfor (const entry of entries) {\n\t\tconst oldPath = path.join(dir, entry.name);\n\t\tlet newPath = oldPath;\n\n\t\t// Rename file or folder if it includes {name}\n\t\tif (entry.name.includes(\"{name}\")) {\n\t\t\tconst newName = entry.name.replace(\"{name}\", modName);\n\t\t\tnewPath = path.join(dir, newName);\n\t\t\tfs.renameSync(oldPath, newPath);\n\t\t}\n\n\t\t// If it's a bf6.config.ts, replace the {bf6ConfigName} placeholder\n\t\tif (entry.name === \"bf6.config.ts\") {\n\t\t\tlet content = fs.readFileSync(newPath, \"utf-8\");\n\t\t\tcontent = content.replace(/{bf6ConfigName}/g, modName);\n\t\t\tfs.writeFileSync(newPath, content, \"utf-8\");\n\t\t}\n\n\t\t// If it's a package.json, rewrite the \"name\" field\n\t\tif (entry.name === \"package.json\") {\n\t\t\tconst pkg = JSON.parse(fs.readFileSync(newPath, \"utf-8\"));\n\t\t\tpkg.name = modName;\n\t\t\tif (!pkg.devDependencies) pkg.devDependencies = {};\n\t\t\tpkg.devDependencies[\"@bf6mods/cli\"] = `^${bf6CliPackageJson.version}`;\n\t\t\tpkg.devDependencies[\"@bf6mods/sdk\"] = `^${bf6SdkPackageJson.version}`;\n\t\t\tfs.writeFileSync(newPath, JSON.stringify(pkg, null, 2));\n\t\t}\n\n\t\t// Recurse into directories (using the new name if renamed)\n\t\tif (fs.statSync(newPath).isDirectory()) {\n\t\t\trenameFilesRecursively(newPath, modName);\n\t\t}\n\t}\n}\n\nexport const templates = [\n\t\"Basic\",\n\t\"AcePursuit\",\n\t\"BombSquad\",\n\t\"Exfil\",\n\t\"Vertigo\",\n] as const;\n\nexport async function startProject(\n\tdestination: string,\n\ttemplate: (typeof templates)[number] | \"None\",\n\tname?: string,\n) {\n\tif ([\"AcePursuit\", \"BombSquad\", \"Exfil\", \"Vertigo\"].includes(template)) {\n\t\tconst importPath = path.resolve(templatesDir, `${template}.json`);\n\t\tawait importFile(importPath, destination, name);\n\t} else if (template === \"None\") {\n\t\t// Do nothing if none\n\t} else {\n\t\t// Handles the Basic and any other template provided\n\t\tconst templateDir = path.resolve(templatesDir, template);\n\t\tfs.cpSync(templateDir, destination, { recursive: true });\n\t}\n\n\tfs.cpSync(path.resolve(templatesDir, \"All\"), destination, {\n\t\trecursive: true,\n\t});\n\n\tif (name) renameFilesRecursively(destination, name);\n}\n\nexport function installDependencies(projectDir: string) {\n\ttry {\n\t\tchild_process.execSync(`npm install`, {\n\t\t\tstdio: \"inherit\",\n\t\t\tcwd: projectDir,\n\t\t});\n\t\treturn true;\n\t} catch (_err) {\n\t\treturn false;\n\t}\n}\n\nconst _defaultTargetDir = \"bf6-mod\";\nconst cancel = () => prompts.cancel(\"Operation cancelled\");\n\nfunction isEmpty(path: string) {\n\tconst files = fs.readdirSync(path);\n\treturn files.length === 0 || (files.length === 1 && files[0] === \".git\");\n}\n\nfunction emptyDir(dir: string) {\n\tif (!fs.existsSync(dir)) {\n\t\treturn;\n\t}\n\tfor (const file of fs.readdirSync(dir)) {\n\t\tif (file === \".git\") {\n\t\t\tcontinue;\n\t\t}\n\t\tfs.rmSync(path.resolve(dir, file), { recursive: true, force: true });\n\t}\n}\n\nexport async function init(\n\targTargetDir?: string,\n\toptions?: {\n\t\tname?: string;\n\t\ttemplate?: (typeof templates)[number];\n\t\tonExists?: \"overwrite\" | \"cancel\" | \"ignore\";\n\t\tinstallDependencies?: boolean;\n\t},\n) {\n\tprompts.intro(\"Initialize Bf6 Mod\");\n\n\tconst path = argTargetDir\n\t\t? argTargetDir\n\t\t: await prompts.text({\n\t\t\t\tmessage: \"Where should we create your project?\",\n\t\t\t\tplaceholder: \"./ace-pursuit\",\n\t\t\t\tvalidate: (value) => {\n\t\t\t\t\tif (!value) return \"Please enter a path.\";\n\t\t\t\t\tif (value[0] !== \".\") return \"Please enter a relative path.\";\n\t\t\t\t},\n\t\t\t});\n\tif (prompts.isCancel(path)) return cancel();\n\n\tlet name = options?.name\n\t\t? options.name\n\t\t: await prompts.text({\n\t\t\t\tmessage: \"What is the name of your mod?\",\n\t\t\t\tplaceholder: \"Ace Pursuit\",\n\t\t\t\tvalidate: (value) => {\n\t\t\t\t\tif (!value.trim()) return \"Please enter a name.\";\n\t\t\t\t},\n\t\t\t});\n\tif (prompts.isCancel(name)) return cancel();\n\tname = name.trim();\n\n\tif (fs.existsSync(path) && !isEmpty(path)) {\n\t\tlet overwrite: \"yes\" | \"no\" | \"ignore\" | undefined;\n\t\tif (options?.onExists) {\n\t\t\tswitch (options.onExists) {\n\t\t\t\tcase \"overwrite\":\n\t\t\t\t\toverwrite = \"yes\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"cancel\":\n\t\t\t\t\toverwrite = \"no\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"ignore\":\n\t\t\t\t\toverwrite = \"ignore\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tconst res = overwrite\n\t\t\t? overwrite\n\t\t\t: await prompts.select({\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t(path === \".\"\n\t\t\t\t\t\t\t? \"Current directory\"\n\t\t\t\t\t\t\t: `Target directory \"${path}\"`) +\n\t\t\t\t\t\t` is not empty. Please choose how to proceed:`,\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: \"Cancel operation\",\n\t\t\t\t\t\t\tvalue: \"no\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: \"Remove existing files and continue\",\n\t\t\t\t\t\t\tvalue: \"yes\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: \"Ignore files and continue\",\n\t\t\t\t\t\t\tvalue: \"ignore\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t});\n\t\tif (prompts.isCancel(res)) return cancel();\n\t\toverwrite = res;\n\n\t\tswitch (overwrite) {\n\t\t\tcase \"yes\":\n\t\t\t\temptyDir(path);\n\t\t\t\tbreak;\n\t\t\tcase \"no\":\n\t\t\t\tcancel();\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\tconst template = options?.template\n\t\t? options.template\n\t\t: await prompts.select({\n\t\t\t\tmessage: \"Select a template:\",\n\t\t\t\toptions: templates.map((template) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tlabel: template,\n\t\t\t\t\t\tvalue: template,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t});\n\tif (prompts.isCancel(template)) return cancel();\n\n\tawait startProject(path, template, name);\n\n\tif (options?.installDependencies) {\n\t\tconst s = prompts.spinner();\n\t\ts.start(\"Installing via npm\");\n\t\tconst installed = installDependencies(path);\n\t\tif (installed) s.stop(\"Installed via npm\");\n\t\telse s.stop(\"Failed to install via npm\", 1);\n\n\t\tconst nextSteps = `cd ${path}\\nnpm run build`;\n\n\t\tprompts.note(nextSteps, \"Next steps.\");\n\t} else {\n\t\tconst nextSteps = `cd ${path}\\nnpm i\\nnpm run build`;\n\n\t\tprompts.note(nextSteps, \"Next steps.\");\n\t}\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { AttachmentType, type ConfigType } from \"@bf6mods/sdk\";\nimport colors from \"colors\";\nimport stringifyObject from \"stringify-object\";\nimport { MapId as MapIdEnum } from \"../resources/prepare/types/config.ts\";\nimport { startProject } from \"./init.ts\";\nimport { printToConsole } from \"./utils.ts\";\n\nasync function writeFileSafe(filePath: string, data: string | Buffer) {\n\tconst dir = path.dirname(filePath);\n\tawait fs.promises.mkdir(dir, { recursive: true });\n\tawait fs.promises.writeFile(filePath, data);\n}\n\nfunction getMapKeyByValue(value: string): keyof typeof MapIdEnum | undefined {\n\treturn Object.keys(MapIdEnum).find(\n\t\t(k) => MapIdEnum[k as keyof typeof MapIdEnum] === value,\n\t) as keyof typeof MapIdEnum | undefined;\n}\n\nexport async function importFile(\n\tinput: string,\n\toutput: string,\n\tname?: string,\n\tlogging = false,\n) {\n\tconst start = performance.now();\n\tconst workingDir = path.resolve(\".\");\n\tconst entrypoint = path.resolve(workingDir, input);\n\tconst outDir = path.resolve(workingDir, output);\n\n\tif (!fs.existsSync(entrypoint)) throw new Error(\"Cannot find strings file\");\n\n\tif (logging)\n\t\tprintToConsole(colors.cyan(`📦 Importing config from: ${entrypoint}`));\n\n\tconst config = JSON.parse(\n\t\tawait fs.promises.readFile(entrypoint, { encoding: \"utf8\" }),\n\t) as ConfigType;\n\n\tif (!fs.existsSync(outDir)) {\n\t\tawait fs.promises.mkdir(outDir, { recursive: true });\n\t\tif (logging)\n\t\t\tprintToConsole(colors.cyan(`📁 Created output directory: ${outDir}`));\n\t}\n\n\tawait startProject(outDir, \"None\", name ?? config.name);\n\n\tlet typescriptFile: string | undefined;\n\tlet stringsFile: string | undefined;\n\tconst scenes: [string, string][] = [];\n\tconst promises: Promise<unknown>[] = [];\n\n\tif (config.attachments) {\n\t\tlet unamedAttachmentIndex = 0;\n\t\tfor (const attachment of config.attachments) {\n\t\t\tlet filename = attachment.filename?.trim();\n\t\t\tif (!filename) {\n\t\t\t\tunamedAttachmentIndex++;\n\n\t\t\t\tlet ext: string = \"\";\n\t\t\t\tif (attachment.attachmentType === AttachmentType.TypeScript)\n\t\t\t\t\text = \".ts\";\n\t\t\t\telse if (attachment.attachmentType === AttachmentType.Strings)\n\t\t\t\t\text = \".strings.json\";\n\t\t\t\telse if (attachment.attachmentType === AttachmentType.SpatialData)\n\t\t\t\t\text = \".spatial.json\";\n\n\t\t\t\tif (unamedAttachmentIndex > 1)\n\t\t\t\t\tfilename = `attachment_${unamedAttachmentIndex}${ext}`;\n\t\t\t\telse filename = `attachment${ext}`;\n\t\t\t}\n\n\t\t\tif (attachment.attachmentType === AttachmentType.TypeScript)\n\t\t\t\ttypescriptFile = filename;\n\n\t\t\tif (attachment.attachmentType === AttachmentType.Strings)\n\t\t\t\tstringsFile = filename;\n\n\t\t\tif (attachment.attachmentType === AttachmentType.SpatialData) {\n\t\t\t\t// We'll just use the data attached to mapRotation instead\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tpromises.push(\n\t\t\t\twriteFileSafe(\n\t\t\t\t\tpath.resolve(outDir, \"src\", filename),\n\t\t\t\t\tatob(attachment.attachmentData.original),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (logging)\n\t\t\t\tprintToConsole(\n\t\t\t\t\t`${colors.green(\"✓\")} Wrote attachment: ${colors.yellow(filename)}`,\n\t\t\t\t);\n\t\t}\n\t}\n\n\t// Extract spatial scenes from mapRotation instead of guessing\n\tif (config.mapRotation?.length) {\n\t\tfor (const map of config.mapRotation) {\n\t\t\tpromises.push(\n\t\t\t\twriteFileSafe(\n\t\t\t\t\tpath.resolve(outDir, \"src\", \"scenes\", map.spatialAttachment.filename),\n\t\t\t\t\tatob(map.spatialAttachment.attachmentData.original),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tscenes.push([map.id, `src/scenes/${map.spatialAttachment.filename}`]);\n\n\t\t\tif (logging)\n\t\t\t\tprintToConsole(\n\t\t\t\t\t`${colors.green(\"✓\")} Added scene: ${colors.yellow(map.id)}`,\n\t\t\t\t);\n\t\t}\n\t}\n\n\t// build the new bf6.config.ts structure\n\tconst bf6Config = {\n\t\tname: name ?? config.name,\n\t\tdescription: config.description,\n\t\toutDir: \"dist\",\n\t\tentrypoint: typescriptFile ? `src/${typescriptFile}` : undefined,\n\t\tscenes: scenes\n\t\t\t? scenes.map(([id, path]) => [\n\t\t\t\t\t`MapId.${getMapKeyByValue(id) ?? id}`,\n\t\t\t\t\tpath,\n\t\t\t\t])\n\t\t\t: undefined,\n\t\tstrings: stringsFile ? `src/${stringsFile}` : undefined,\n\t\tgame: {\n\t\t\tmutators: config.mutators,\n\t\t\tassetRestrictions: config.assetRestrictions,\n\t\t\tgameMode: config.gameMode,\n\t\t\tteamComposition: config.teamComposition,\n\t\t},\n\t};\n\n\tconst bf6ConfigContent = `export default defineBf6Config(${stringifyWithRaw(\n\t\tbf6Config,\n\t)});\\n`;\n\n\tpromises.push(\n\t\twriteFileSafe(path.resolve(outDir, \"bf6.config.ts\"), bf6ConfigContent),\n\t);\n\n\tawait Promise.all(promises);\n\n\tconst duration = ((performance.now() - start) / 1000).toFixed(2);\n\tif (logging)\n\t\tprintToConsole(\n\t\t\t`${colors.green.bold(\"✓\")} Import complete (${duration}s) → ${colors.yellow(outDir)}`,\n\t\t);\n}\n\nfunction stringifyWithRaw(value: unknown, options = {}) {\n\treturn stringifyObject(value, {\n\t\tindent: \" \", // 4 spaces\n\t\tsingleQuotes: true,\n\t\ttransform: (_obj, _prop, originalResult) => {\n\t\t\t// Remove quotes from MapId.* expressions\n\t\t\tif (/^['\"]MapId\\.[A-Za-z0-9_]+['\"]$/.test(originalResult)) {\n\t\t\t\treturn originalResult.slice(1, -1); // remove surrounding quotes\n\t\t\t}\n\t\t\treturn originalResult;\n\t\t},\n\t\t...options,\n\t});\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport colors from \"colors\";\nimport { genExport, genInlineTypeImport } from \"knitwork\";\nimport { printToConsole } from \"./utils.js\";\n\nexport async function prepare() {\n\ttry {\n\t\tconst __filename = fileURLToPath(import.meta.url);\n\t\tconst __dirname = path.dirname(__filename);\n\n\t\tconst _workingDir = path.resolve(\".\");\n\t\tconst buildDir = path.resolve(\".bf6\");\n\n\t\tconst resources = path.resolve(__dirname, \"../resources/prepare\");\n\n\t\tfs.cpSync(\n\t\t\tpath.resolve(resources, \"tsconfig.json\"),\n\t\t\tpath.resolve(buildDir, \"tsconfig.json\"),\n\t\t);\n\t\tfs.cpSync(\n\t\t\tpath.resolve(resources, \"bf6.d.ts\"),\n\t\t\tpath.resolve(buildDir, \"bf6.d.ts\"),\n\t\t);\n\t\tfs.cpSync(\n\t\t\tpath.resolve(resources, \"types\", \"config.ts\"),\n\t\t\tpath.resolve(buildDir, \"types\", \"config.ts\"),\n\t\t);\n\n\t\tconst ConfigFileExports = genExport(\"./types/config.ts\", [\n\t\t\t\"defineBf6Config\",\n\t\t]);\n\t\tfs.writeFileSync(\n\t\t\tpath.resolve(buildDir, \"imports.d.ts\"),\n\t\t\t`${ConfigFileExports}\\n`,\n\t\t);\n\n\t\tconst augmentations: Record<string, string> = {\n\t\t\tdefineBf6Config: genInlineTypeImport(\n\t\t\t\t\"./types/config.ts\",\n\t\t\t\t`defineBf6Config`,\n\t\t\t),\n\t\t\tMapId: genInlineTypeImport(\"./types/config.ts\", `MapId`),\n\t\t};\n\n\t\tconst args = genNamespaceAugmentation(\"global\", augmentations);\n\t\tfs.writeFileSync(\n\t\t\tpath.resolve(buildDir, \"globals.d.ts\"),\n\t\t\t`export {}\\n\\n${args}\\n`,\n\t\t);\n\n\t\tprintToConsole(`${colors.green.bold(\"✓\")} Types generated in .bf6`);\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\tprintToConsole(\n\t\t\t`${colors.red.bold(\"✗\")} Types failed to generate in .bf6`,\n\t\t\ttrue,\n\t\t);\n\t}\n}\n\nconst genNamespaceAugmentation = (\n\tname: string,\n\tcontents: Record<string, string>,\n) => {\n\tif (!contents || Object.keys(contents).length === 0)\n\t\treturn `declare ${name} {}`;\n\tconst decls = Object.entries(contents)\n\t\t.map(([k, v]) => `\\tconst ${k}: ${v};`)\n\t\t.join(\"\\n\");\n\treturn `declare ${name} {\\n${decls}\\n}`;\n};\n","#!/usr/bin/env node\nimport colors from \"colors\";\nimport { Command } from \"commander\";\nimport pkg from \"../../package.json\" with { type: \"json\" };\nimport { build } from \"./build/index.ts\";\nimport { dev } from \"./dev.ts\";\nimport { importFile } from \"./import.ts\";\nimport { init, templates } from \"./init.js\";\nimport { Bf6Logger } from \"./log.ts\";\nimport { prepare } from \"./prepare.js\";\nimport { printToConsole, readableList } from \"./utils.ts\";\n\nconst program = new Command();\n\nprogram\n\t.name(Object.keys(pkg.bin)[0])\n\t.description(pkg.description)\n\t.version(pkg.version);\n\nprogram\n\t.command(\"init\")\n\t.argument(\"[directory]\")\n\t.option(\"--name <name>\", \"The name of your mod\")\n\t.option(\"--template <template>\", \"The template to use\")\n\t.option(\n\t\t\"--on-exists <action>\",\n\t\t`Either \"overwrite\", \"cancel\", or \"ignore\" as to what to do if files exist in the directory`,\n\t)\n\t.option(\"--no-install-dependencies\", `Prevents install of dependencies`)\n\t.description(\"Create a new bf6 mod\")\n\t.action(async (directory, options) => {\n\t\tconst { name, template, onExists, installDependencies } = options;\n\t\tif (\n\t\t\tonExists !== undefined &&\n\t\t\t![\"overwrite\", \"cancel\", \"ignore\"].includes(onExists)\n\t\t) {\n\t\t\tprintToConsole(\n\t\t\t\t`${colors.red.bold(\"✗\")} Invalid value for --on-exists: \"${onExists}\". Expected one of \"overwrite\", \"cancel\", or \"ignore\".`,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tif (template !== undefined && !templates.includes(template)) {\n\t\t\tprintToConsole(\n\t\t\t\t`${colors.red.bold(\"✗\")} Invalid value for --template: \"${template}\". Expected one of ${readableList(templates)}.`,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tawait init(directory, {\n\t\t\tname,\n\t\t\ttemplate,\n\t\t\tonExists,\n\t\t\tinstallDependencies,\n\t\t});\n\t});\n\nprogram\n\t.command(\"build\")\n\t.description(\"build the bf6 mod\")\n\t.action(async () => {\n\t\tawait build();\n\t});\n\nprogram\n\t.command(\"prepare\")\n\t.description(\"prepare the types for bf6 mod\")\n\t.action(async () => {\n\t\tawait prepare();\n\t});\n\nprogram\n\t.command(\"dev\")\n\t.description(\"watch the changes in src, and recompile as needed\")\n\t.action(async () => {\n\t\tawait dev();\n\t});\n\nprogram\n\t.command(\"import\")\n\t.argument(\"<input>\")\n\t.argument(\"<output>\")\n\t.option(\"--no-install-dependencies\", `Prevents install of dependencies`)\n\t.description(\"decompiles the json config of a mod into a new project\")\n\t.action(async (input, output, options) => {\n\t\tconst { installDependencies } = options;\n\t\tawait importFile(input as string, output as string, undefined, true);\n\t\tif (installDependencies) installDependencies(output);\n\t});\n\nprogram\n\t.command(\"log\")\n\t.argument(\"[input]\")\n\t.description(\"logs the output from a locally running server\")\n\t.action(async (input) => {\n\t\tconst logger = new Bf6Logger(input);\n\t\tlogger.start();\n\t});\n\nprogram.exitOverride((_err) => {\n\tif (process.env.EXIT_CODE === \"none\") process.exit(0);\n});\n\nif (!process.argv.slice(2).length) {\n\tprogram.outputHelp();\n\tprocess.exit(0);\n}\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;gBAEY;kBACI;UAGR,EACN,WAAW,uBACX;;;;ACNF,IAAY,0CAAL;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACLD,MAAa,kBAAkB,SAAiB,QAAiB,UAAU;CAC1E,MAAM,sBAAM,IAAI,MAAM;CACtB,MAAM,gBAAgB,OAAO,KAAK,IAAI,oBAAoB,CAAC;CAC3D,MAAM,gBAAgB,QAAQ,OAAO,WAAW;CAEhD,MAAM,aAAa,UAAU,cAAc,CAAC;CAE5C,MAAM,YAAY,iBADI,UAAU,QAAQ,CAAC,SACU;CAEnD,MAAM,UAAU,YAAY,IAAI,IAAI,OAAO,UAAU,GAAG;AAExD,KAAI,MAAO,SAAQ,MAAM,GAAG,UAAU,UAAU,gBAAgB;KAC3D,SAAQ,IAAI,GAAG,UAAU,UAAU,gBAAgB;;AAGzD,MAAa,gBAAgB,kBAAqC;CACjE,MAAM,SAAS,cAAc,KAAK,MAAM,IAAI,EAAE,GAAG;AACjD,KAAI,OAAO,SAAS,EACnB,QAAO,GAAG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AkB,QAAW,KAAK;AACpE,KAAIC,sBAAqB,uBAAoB,OAAO;EACnD;AAEH,QACE,QAAQ,MAAM,CACd,SAAS,UAAU,CACnB,YAAY,gDAAgD,CAC5D,OAAO,OAAO,UAAU;AAExB,CADe,IAAI,UAAU,MAAM,CAC5B,OAAO;EACb;AAEH,QAAQ,cAAc,SAAS;AAC9B,KAAI,QAAQ,IAAI,cAAc,OAAQ,SAAQ,KAAK,EAAE;EACpD;AAEF,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC,QAAQ;AAClC,SAAQ,YAAY;AACpB,SAAQ,KAAK,EAAE;;AAGhB,QAAQ,OAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["program","key:\n\t\t\t\t\t\t\t| string\n\t\t\t\t\t\t\t| number\n\t\t\t\t\t\t\t| bigint\n\t\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t\t| RegExp\n\t\t\t\t\t\t\t| null\n\t\t\t\t\t\t\t| undefined","MapIdEnum","tsAttachment: Attachment | undefined","__filename","__dirname","attachments: Attachment[]","mapRotation: MapType[]","mapId: MapIdEnum","scene: string","finalJson: ConfigType","watcher: FSWatcher | undefined","timer: NodeJS.Timeout | undefined","targets: string[]","logger: Bf6Logger | undefined","bf6CliPackageJson.version","bf6SdkPackageJson.version","path","overwrite: \"yes\" | \"no\" | \"ignore\" | undefined","template","MapIdEnum","typescriptFile: string | undefined","stringsFile: string | undefined","scenes: [string, string][]","promises: Promise<unknown>[]","ext: string","path","__filename","__dirname","pkg.bin","pkg.description","pkg.version"],"sources":["../../package.json","../../src/resources/prepare/types/config.ts","../../src/cli/utils.ts","../../src/cli/build/generated-strings.ts","../../src/cli/build/index.ts","../../src/cli/log.ts","../../src/cli/dev.ts","../../../sdk/package.json","../../src/cli/init.ts","../../src/cli/import.ts","../../src/cli/prepare.ts","../../src/cli/index.ts"],"sourcesContent":["{\n\t\"name\": \"@bf6mods/cli\",\n\t\"version\": \"1.2.3\",\n\t\"description\": \"CLI and library for bundling BF6 mods\",\n\t\"license\": \"MIT\",\n\t\"type\": \"module\",\n\t\"bin\": {\n\t\t\"bf6mods\": \"./dist/cli/index.js\"\n\t},\n\t\"main\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.ts\",\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"start\": \"cross-env EXIT_CODE=none tsx ./src/cli/index.ts\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"import\": \"./dist/index.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist/\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/bf6mods/bf6mods.git\"\n\t},\n\t\"dependencies\": {\n\t\t\"@bf6mods/sdk\": \"*\",\n\t\t\"@clack/prompts\": \"^0.11.0\",\n\t\t\"chokidar\": \"^4.0.3\",\n\t\t\"colors\": \"^1.4.0\",\n\t\t\"commander\": \"^14.0.1\",\n\t\t\"jiti\": \"^2.6.1\",\n\t\t\"knitwork\": \"^1.2.0\",\n\t\t\"rolldown\": \"^1.0.0-beta.44\",\n\t\t\"stringify-object\": \"^6.0.0\",\n\t\t\"strip-ansi\": \"^7.1.2\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@oxc-project/types\": \"^0.95.0\",\n\t\t\"@types/stringify-object\": \"^4.0.5\",\n\t\t\"cross-env\": \"^10.1.0\",\n\t\t\"execa\": \"^9.6.0\",\n\t\t\"tsx\": \"^4.20.6\"\n\t}\n}\n","import type { ConfigType } from \"@bf6mods/sdk\";\n\nexport enum MapId {\n\tFireStorm = \"MP_FireStorm-ModBuilderCustom0\",\n\tSiegeOfCairo = \"MP_Abbasid-ModBuilderCustom0\",\n\tEmpireState = \"MP_Aftermath-ModBuilderCustom0\",\n\tIberianOffensive = \"MP_Battery-ModBuilderCustom0\",\n\tLiberationPeak = \"MP_Capstone-ModBuilderCustom0\",\n\tManhattanBridge = \"MP_Dumbo-ModBuilderCustom0\",\n\tSaintsQuarter = \"MP_Limestone-ModBuilderCustom0\",\n\tNewSobekCity = \"MP_Outskirts-ModBuilderCustom0\",\n\tMirakValley = \"MP_Tungsten-ModBuilderCustom0\",\n}\n\n/**\n * Represents the root configuration for a Battlefield 6 mod project.\n *\n * This file combines both build-level settings (like entrypoints and output directories)\n * and in-game configuration data (such as mutators and asset restrictions)\n * under the `game` key.\n *\n * Use {@link defineBf6Config} to define and validate this structure\n * in your `bf6.config.ts` file.\n */\nexport type Bf6Config = {\n\t/**\n\t * The human-readable name of the mod.\n\t *\n\t * Typically matches the project name used in the BF6 mod editor or\n\t * the display name shown in the in-game mod browser.\n\t */\n\tname: string;\n\n\t/**\n\t * A short description of the mod’s purpose or content.\n\t * Used for display and metadata purposes.\n\t */\n\tdescription: string;\n\n\t/**\n\t * The output directory where compiled or bundled files are written.\n\t * Usually something like `\"dist\"` or `\"build\"`.\n\t */\n\toutDir: string;\n\n\t/**\n\t * Whether or not to output the built files like the entrypoint typescript file\n\t */\n\toutputArtifacts?: boolean;\n\n\t/**\n\t * The main entrypoint for your mod’s TypeScript source file.\n\t *\n\t * This is typically something like `\"src/index.ts\"` or `\"src/main.ts\"`.\n\t */\n\tentrypoint?: string;\n\n\t/**\n\t * One or more scene file paths (.json) that the mod includes.\n\t * If no file path is provided, it loads in the default spatial data.\n\t */\n\tscenes?: ([MapId, string] | MapId)[];\n\n\t/**\n\t * Path to a JSON file or other source that defines localized strings\n\t * used by the mod (optional).\n\t */\n\tstrings?: string;\n\n\t/**\n\t * Generate strings automatically, by default this is enabled\n\t */\n\tgenerateStrings?: boolean;\n\n\t/**\n\t * Controls whether build output should be minified.\n\t *\n\t * Can be a boolean (to toggle all minification),\n\t * or an object specifying independent settings for JS and JSON files.\n\t *\n\t * @example\n\t * ```ts\n\t * minify: true\n\t * // or\n\t * minify: { js: true, json: false }\n\t * ```\n\t */\n\tminify?:\n\t\t| {\n\t\t\t\t/** Whether to minify JavaScript output. */\n\t\t\t\tjs?: boolean;\n\t\t\t\t/** Whether to minify JSON output. */\n\t\t\t\tjson?: boolean;\n\t\t }\n\t\t/** Enables or disables all minification. */\n\t\t| boolean;\n\n\t/**\n\t * The underlying in-game configuration derived from `ConfigType`\n\t * in the BF6 SDK. Includes gameplay-level details like mutators,\n\t * asset restrictions, and team compositions.\n\t *\n\t * The following properties are **excluded**:\n\t * - `attachments`\n\t * - `workspace`\n\t * - `mapRotation`\n\t * - `name`\n\t * - `description`\n\t *\n\t * since those are either redundant or handled elsewhere.\n\t */\n\tgame: Omit<\n\t\tConfigType,\n\t\t\"attachments\" | \"workspace\" | \"mapRotation\" | \"name\" | \"description\"\n\t>;\n};\n\n/**\n * Defines and validates a Battlefield 6 mod configuration object.\n *\n * This helper ensures your config is properly typed and can be\n * statically analyzed by TypeScript.\n *\n * @example\n * ```ts\n * export default defineBf6Config({\n * name: \"My Custom Mod\",\n * description: \"Adds custom rules\",\n * outDir: \"dist\",\n * entrypoint: \"src/main.ts\",\n * game: {\n * mutators: [],\n * assetRestrictions: {},\n * teamComposition: [],\n * },\n * });\n * ```\n *\n * @param bf6Config The configuration object to validate and return.\n * @returns The validated Battlefield 6 configuration object.\n */\nexport function defineBf6Config(bf6Config: Bf6Config): Bf6Config {\n\treturn bf6Config;\n}\n","import colors from \"colors\";\nimport stripAnsi from \"strip-ansi\";\n\n/**\n * Safely prints a message with a right-aligned timestamp.\n */\nexport const printToConsole = (message: string, error: boolean = false) => {\n\tconst now = new Date();\n\tconst formattedTime = colors.grey(now.toLocaleTimeString());\n\tconst terminalWidth = process.stdout.columns || 80;\n\n\tconst timeLength = stripAnsi(formattedTime).length;\n\tconst messageLength = stripAnsi(message).length;\n\tconst available = terminalWidth - (messageLength + timeLength);\n\n\tconst spacing = available > 1 ? \" \".repeat(available) : \" \";\n\n\tif (error) console.error(`${message}${spacing}${formattedTime}`);\n\telse console.log(`${message}${spacing}${formattedTime}`);\n};\n\nexport const readableList = (initialValues: readonly string[]) => {\n\tconst values = initialValues.map((v) => `\"${v}\"`);\n\tif (values.length > 1)\n\t\treturn `${values.slice(0, -1).join(\", \")} or ${values.slice(-1)}`;\n\treturn values[0];\n};\n","import type { Node, VariableDeclarator } from \"@oxc-project/types\";\nimport colors from \"colors\";\nimport type { Plugin } from \"rolldown\";\n\nexport function extractBf6Strings(\n\tbf6Strings: Record<string, string>,\n\tgenerateFromLiterals: boolean,\n): Plugin {\n\treturn {\n\t\tname: \"extract-bf6-strings\",\n\t\tgenerateBundle(_options, bundle) {\n\t\t\tif (!generateFromLiterals) return;\n\n\t\t\tlet id = 0;\n\t\t\tconst existingStrings = new Set(Object.values(bf6Strings));\n\n\t\t\tfor (const [_file, output] of Object.entries(bundle)) {\n\t\t\t\tif (output.type !== \"chunk\") continue;\n\t\t\t\tconst code = output.code;\n\n\t\t\t\t// Parse the code with rolldown’s parser\n\t\t\t\tconst program = this.parse(code, {\n\t\t\t\t\tlang: \"ts\",\n\t\t\t\t\tastType: \"js\",\n\t\t\t\t\trange: true,\n\t\t\t\t});\n\n\t\t\t\t// Visit every node recursively to collect string literals\n\t\t\t\tfunction walk(node: Node) {\n\t\t\t\t\tif (node.type === \"Literal\") {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttypeof node.value !== \"string\" ||\n\t\t\t\t\t\t\tnode.value === \"\" ||\n\t\t\t\t\t\t\tnode.value === \"----uniquename----\"\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!(node.value in bf6Strings) &&\n\t\t\t\t\t\t\t!existingStrings.has(node.value)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\texistingStrings.add(node.value);\n\t\t\t\t\t\t\tbf6Strings[`__auto__${id++}`] = node.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const value of Object.values(node)) {\n\t\t\t\t\t\tif (!value) continue;\n\t\t\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t\t\tfor (const v of value) {\n\t\t\t\t\t\t\t\tif (v && typeof v === \"object\" && \"type\" in v) walk(v as Node);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (typeof value === \"object\" && \"type\" in value) {\n\t\t\t\t\t\t\twalk(value as Node);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const item of program.body) {\n\t\t\t\t\twalk(item);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tmoduleParsed(moduleInfo) {\n\t\t\tif (moduleInfo.code && moduleInfo.exports.includes(\"bf6Strings\")) {\n\t\t\t\tconst code = moduleInfo.code;\n\t\t\t\tconst getSnippet = (\n\t\t\t\t\tstart: number,\n\t\t\t\t\tend: number,\n\t\t\t\t\tlinesBefore = 2,\n\t\t\t\t\tlinesAfter = 2,\n\t\t\t\t) => {\n\t\t\t\t\tconst lines = code.split(/\\r?\\n/);\n\t\t\t\t\tconst startLine = Math.max(\n\t\t\t\t\t\t0,\n\t\t\t\t\t\tcode.slice(0, start).split(/\\r?\\n/).length - 1 - linesBefore,\n\t\t\t\t\t);\n\t\t\t\t\tconst endLine = Math.min(\n\t\t\t\t\t\tlines.length,\n\t\t\t\t\t\tcode.slice(0, end).split(/\\r?\\n/).length - 1 + linesAfter,\n\t\t\t\t\t);\n\t\t\t\t\treturn lines\n\t\t\t\t\t\t.slice(startLine, endLine)\n\t\t\t\t\t\t.map((line, i) => {\n\t\t\t\t\t\t\tconst actualLine = startLine + i + 1;\n\t\t\t\t\t\t\treturn `${actualLine.toString().padStart(3)} | ${line}`;\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join(\"\\n\");\n\t\t\t\t};\n\n\t\t\t\tconst program = this.parse(code, {\n\t\t\t\t\tlang: \"ts\",\n\t\t\t\t\tastType: \"js\",\n\t\t\t\t\trange: true,\n\t\t\t\t});\n\n\t\t\t\tconst extractObjectLiteral = (declaration: VariableDeclarator) => {\n\t\t\t\t\tif (declaration.init?.type !== \"ObjectExpression\") {\n\t\t\t\t\t\tconst snippet = getSnippet(...(declaration.range ?? [0, 0]));\n\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} Invalid bf6Strings export: expected an object literal.\\n\\n${snippet}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const property of declaration.init.properties) {\n\t\t\t\t\t\tif (property.type !== \"Property\") {\n\t\t\t\t\t\t\tconst snippet = getSnippet(...(property.range ?? [0, 0]));\n\t\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} Invalid bf6Strings property: expected a key/value pair.\\nFound type: ${property.type}\\n\\n${snippet}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet key:\n\t\t\t\t\t\t\t| string\n\t\t\t\t\t\t\t| number\n\t\t\t\t\t\t\t| bigint\n\t\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t\t| RegExp\n\t\t\t\t\t\t\t| null\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tif (property.key.type === \"Literal\") {\n\t\t\t\t\t\t\tkey = property.key.value;\n\t\t\t\t\t\t} else if (property.key.type === \"Identifier\") {\n\t\t\t\t\t\t\tkey = property.key.name;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst snippet = getSnippet(...(property.range ?? [0, 0]));\n\t\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} Invalid bf6Strings key: expected a string literal or identifier.\\nFound type: ${property.key.type}\\n\\n${snippet}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (property.value.type !== \"Literal\") {\n\t\t\t\t\t\t\tconst snippet = getSnippet(...(property.range ?? [0, 0]));\n\t\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} Invalid bf6Strings value: expected a string literal.\\nFound type: ${property.value.type}\\n\\n${snippet}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst value = property.value.value;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttypeof key !== \"string\" &&\n\t\t\t\t\t\t\ttypeof key !== \"number\" &&\n\t\t\t\t\t\t\ttypeof key !== \"bigint\" &&\n\t\t\t\t\t\t\ttypeof key !== \"boolean\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst snippet = getSnippet(...(property.range ?? [0, 0]));\n\t\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} bf6Strings key must be a string, found: ${typeof key}\\n\\n${snippet}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttypeof value !== \"string\" &&\n\t\t\t\t\t\t\ttypeof value !== \"number\" &&\n\t\t\t\t\t\t\ttypeof value !== \"bigint\" &&\n\t\t\t\t\t\t\ttypeof value !== \"boolean\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst snippet = getSnippet(...(property.range ?? [0, 0]));\n\t\t\t\t\t\t\tthis.error(\n\t\t\t\t\t\t\t\t`${colors.red.bold(\"✗\")} bf6Strings value must be a string, found: ${typeof value}\\n\\n${snippet}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbf6Strings[`${key}`] = `${value}`;\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tfor (const item of program.body) {\n\t\t\t\t\t// Case 1: plain variable `var bf6Strings = {...}`\n\t\t\t\t\tif (item.type === \"VariableDeclaration\") {\n\t\t\t\t\t\tfor (const declaration of item.declarations) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdeclaration.type === \"VariableDeclarator\" &&\n\t\t\t\t\t\t\t\tdeclaration.id.type === \"Identifier\" &&\n\t\t\t\t\t\t\t\tdeclaration.id.name === \"bf6Strings\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\textractObjectLiteral(declaration);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Case 2: exported variable `export const bf6Strings = {...}`\n\t\t\t\t\tif (\n\t\t\t\t\t\titem.type === \"ExportNamedDeclaration\" &&\n\t\t\t\t\t\titem.declaration?.type === \"VariableDeclaration\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tfor (const declaration of item.declaration.declarations) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdeclaration.type === \"VariableDeclarator\" &&\n\t\t\t\t\t\t\t\tdeclaration.id.type === \"Identifier\" &&\n\t\t\t\t\t\t\t\tdeclaration.id.name === \"bf6Strings\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\textractObjectLiteral(declaration);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n\ttype Attachment,\n\tAttachmentType,\n\ttype ConfigType,\n\ttype MapType,\n} from \"@bf6mods/sdk\";\nimport colors from \"colors\";\nimport { createJiti } from \"jiti\";\nimport { rolldown } from \"rolldown\";\nimport {\n\ttype Bf6Config,\n\tMapId as MapIdEnum,\n} from \"../../resources/prepare/types/config.ts\";\nimport { printToConsole } from \"../utils.ts\";\nimport { extractBf6Strings } from \"./generated-strings.ts\";\n\ndeclare global {\n\tvar defineBf6Config: ((config: Bf6Config) => Bf6Config) | undefined;\n\tvar MapId: typeof MapIdEnum | undefined;\n}\n\n/**\n * Dynamically imports and validates bf6.config.ts\n */\nexport async function getBf6Config(rootDir: string): Promise<Bf6Config> {\n\tglobalThis.defineBf6Config = (c) => c;\n\tglobalThis.MapId = MapIdEnum;\n\tconst jiti = createJiti(rootDir, { interopDefault: true });\n\tconst result = await jiti.import(\"./bf6.config\", { default: true });\n\tdelete globalThis.defineBf6Config;\n\tdelete globalThis.MapId;\n\treturn result as Bf6Config;\n}\n\n/**\n * Builds the entire mod project once (for production or single run).\n */\nexport async function build() {\n\tconst workingDir = path.resolve(\".\");\n\tconst config = await getBf6Config(workingDir);\n\n\tconst outDir = path.resolve(workingDir, config.outDir);\n\tif (fs.existsSync(outDir))\n\t\tfs.rmSync(outDir, { recursive: true, force: true });\n\tfs.mkdirSync(outDir, { recursive: true });\n\n\tconst minifyJson =\n\t\ttypeof config.minify === \"boolean\"\n\t\t\t? config.minify\n\t\t\t: (config.minify?.json ?? false);\n\n\tconst generatedStrings = {};\n\tlet tsAttachment: Attachment | undefined;\n\tif (config.entrypoint) {\n\t\tconst entryAbs = path.resolve(workingDir, config.entrypoint);\n\t\tconst compiled = await buildEntrypoint(\n\t\t\tentryAbs,\n\t\t\tgeneratedStrings,\n\t\t\tconfig.generateStrings ?? true,\n\t\t);\n\t\ttsAttachment = createTsAttachment(entryAbs, compiled);\n\t}\n\n\tconst { attachments, mapRotation } = await collectAttachments(\n\t\tconfig,\n\t\tworkingDir,\n\t\ttsAttachment,\n\t\tgeneratedStrings,\n\t);\n\n\tawait writeModJson(config, outDir, attachments, mapRotation, minifyJson);\n\tprintToConsole(`${colors.green.bold(\"✓\")} Built mod: ${config.name}`);\n}\n\n/**\n * Compiles the TypeScript entrypoint using rolldown and returns the compiled code.\n */\nexport async function buildEntrypoint(\n\tentry: string,\n\tbf6Strings: Record<string, string>,\n\tgenerateStringsFromLiterals: boolean,\n): Promise<string> {\n\tconst bundle = await rolldown({\n\t\tinput: entry,\n\t\tplugins: [extractBf6Strings(bf6Strings, generateStringsFromLiterals)],\n\t\tlogLevel: \"debug\",\n\t\tresolve: {\n\t\t\talias: {\n\t\t\t\tmodlib: \"@bf6mods/sdk\",\n\t\t\t},\n\t\t},\n\t});\n\tconst result = await bundle.generate({\n\t\tformat: \"esm\",\n\t\tinlineDynamicImports: true,\n\t});\n\n\tconst code = result.output[0].code;\n\treturn code;\n}\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\nconst spatialsDir = path.resolve(__dirname, \"../resources/maps/spatial\");\n/**\n * Collects all attachments (TS, scenes, strings) and returns them + mapRotation.\n */\nexport async function collectAttachments(\n\tconfig: Bf6Config,\n\tworkingDir: string,\n\ttsAttachment: Attachment | undefined,\n\tgeneratedStrings: Record<string, number | string> | undefined,\n) {\n\tconst attachments: Attachment[] = [];\n\tconst mapRotation: MapType[] = [];\n\n\tif (tsAttachment) attachments.push(tsAttachment);\n\n\t// Strings\n\tif (config.strings || Object.keys(generatedStrings ?? {}).length > 0) {\n\t\tconst strPath = path.resolve(workingDir, config.strings ?? \"strings.json\");\n\t\tlet raw = \"{}\";\n\t\tif (fs.existsSync(strPath)) {\n\t\t\traw = await fs.promises.readFile(strPath, \"utf8\");\n\t\t} else {\n\t\t\t// Create a placeholder for clarity (optional)\n\t\t\tprintToConsole(\n\t\t\t\tcolors.yellow(\n\t\t\t\t\t`⚠️ No strings.json found, generating from literals only.`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst attachment = createStringsAttachment(strPath, raw, generatedStrings);\n\t\tattachments.push(attachment);\n\t}\n\n\t// Scenes\n\tif (config.scenes) {\n\t\tlet mapIdx = 0;\n\t\tfor (const map of config.scenes) {\n\t\t\tlet mapId: MapIdEnum;\n\t\t\tlet scene: string;\n\t\t\tif (Array.isArray(map)) {\n\t\t\t\t[mapId, scene] = map;\n\t\t\t} else {\n\t\t\t\tmapId = map;\n\t\t\t\tscene = path.resolve(spatialsDir, `${mapId}.spatial.json`);\n\t\t\t}\n\n\t\t\tconst scenePath = path.resolve(workingDir, scene);\n\t\t\tif (!fs.existsSync(scenePath))\n\t\t\t\tthrow new Error(`Cannot find spatial data file: ${scene}`);\n\t\t\tconst raw = await fs.promises.readFile(scenePath, \"utf8\");\n\t\t\tconst spatial = createSpatialAttachment(scenePath, raw, mapIdx++);\n\t\t\tattachments.push(spatial);\n\t\t\tmapRotation.push({ id: mapId, spatialAttachment: spatial });\n\t\t}\n\t}\n\n\treturn { attachments, mapRotation };\n}\n\n/**\n * Writes the mod.json output to disk.\n */\nexport async function writeModJson(\n\tconfig: Bf6Config,\n\toutDir: string,\n\tattachments: ConfigType[\"attachments\"],\n\tmapRotation: MapType[],\n\tminify: boolean,\n) {\n\tconst baseGame = config.game;\n\tconst finalJson: ConfigType = {\n\t\tname: config.name,\n\t\tdescription: config.description,\n\t\tgameMode: \"ModBuilderCustom\",\n\t\tmutators: baseGame.mutators ?? {},\n\t\tassetRestrictions: baseGame.assetRestrictions ?? {},\n\t\tteamComposition: baseGame.teamComposition ?? [],\n\t\tmapRotation,\n\t\tattachments,\n\t};\n\n\tconst jsonOutput = minify\n\t\t? JSON.stringify(finalJson)\n\t\t: JSON.stringify(finalJson, null, 2);\n\tawait fs.promises.writeFile(path.resolve(outDir, \"mod.json\"), jsonOutput);\n\n\tif (config.outputArtifacts && finalJson?.attachments) {\n\t\tfor (const attachment of finalJson.attachments) {\n\t\t\tconst attachmentsDir = path.resolve(outDir, \"attachments\");\n\t\t\tif (!fs.existsSync(attachmentsDir))\n\t\t\t\tfs.mkdirSync(attachmentsDir, {\n\t\t\t\t\trecursive: true,\n\t\t\t\t});\n\t\t\tawait fs.promises.writeFile(\n\t\t\t\tpath.resolve(outDir, \"attachments\", attachment.filename),\n\t\t\t\tatob(attachment.attachmentData.original),\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function createTsAttachment(\n\tfilePath: string,\n\tcompiled: string,\n): Attachment {\n\treturn {\n\t\tid: crypto.randomUUID(),\n\t\tversion: \"1.0\",\n\t\tfilename: `${path.parse(filePath).name}.js`,\n\t\tisProcessable: true,\n\t\tprocessingStatus: 2,\n\t\tattachmentType: AttachmentType.TypeScript,\n\t\tattachmentData: { original: toBase64(compiled), compiled: \"\" },\n\t\terrors: [],\n\t};\n}\n\nexport function createStringsAttachment(\n\tfilePath: string,\n\traw: string,\n\tgeneratedStrings?: Record<string, number | string> | undefined,\n): Attachment {\n\tlet result = raw;\n\tif (generatedStrings) {\n\t\tresult = JSON.stringify(\n\t\t\t{\n\t\t\t\t...generatedStrings,\n\t\t\t\t...JSON.parse(raw),\n\t\t\t},\n\t\t\tnull,\n\t\t\t4,\n\t\t);\n\t}\n\n\treturn {\n\t\tid: crypto.randomUUID(),\n\t\tversion: \"1.0\",\n\t\tfilename: path.basename(filePath),\n\t\tisProcessable: true,\n\t\tprocessingStatus: 2,\n\t\tattachmentType: AttachmentType.Strings,\n\t\tattachmentData: { original: toBase64(result), compiled: \"\" },\n\t\terrors: [],\n\t};\n}\n\nexport function createSpatialAttachment(\n\tfilePath: string,\n\traw: string,\n\tmapIdx: number,\n): MapType[\"spatialAttachment\"] {\n\treturn {\n\t\tid: crypto.randomUUID(),\n\t\tversion: \"1.0\",\n\t\tfilename: path.basename(filePath),\n\t\tisProcessable: true,\n\t\tprocessingStatus: 2,\n\t\tattachmentType: AttachmentType.SpatialData,\n\t\tattachmentData: { original: toBase64(raw), compiled: \"\" },\n\t\tmetadata: `mapIdx=${mapIdx}`,\n\t\terrors: [],\n\t};\n}\n\nexport function toBase64(input: string | Buffer): string {\n\treturn Buffer.isBuffer(input)\n\t\t? input.toString(\"base64\")\n\t\t: Buffer.from(input, \"utf8\").toString(\"base64\");\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport chokidar, { type FSWatcher } from \"chokidar\";\nimport colors from \"colors\";\nimport { printToConsole } from \"./utils.ts\";\n\nexport class Bf6Logger {\n\tprivate static instance: Bf6Logger | undefined;\n\n\tprivate watchTarget: string;\n\tprivate watcher?: FSWatcher;\n\tprivate lastSize: number;\n\n\tconstructor(input?: string) {\n\t\tif (Bf6Logger.instance) {\n\t\t\tprintToConsole(\n\t\t\t\tcolors.yellow(\"⚠ Existing logger found — closing it first...\"),\n\t\t\t);\n\t\t\tBf6Logger.instance.stop();\n\t\t}\n\n\t\tif (input) this.watchTarget = path.resolve(input);\n\t\telse if (process.env.LOCALAPPDATA)\n\t\t\tthis.watchTarget = path.resolve(\n\t\t\t\tprocess.env.LOCALAPPDATA,\n\t\t\t\t\"temp\",\n\t\t\t\t\"Battlefieldâ„¢ 6\",\n\t\t\t\t\"PortalLog.txt\",\n\t\t\t);\n\t\telse\n\t\t\tthrow new Error(\n\t\t\t\t`${colors.red.bold(\"✗\")} Env variable LOCALAPPDATA not defined, and input file to watch was not provided!`,\n\t\t\t);\n\n\t\tif (!fs.existsSync(this.watchTarget))\n\t\t\tthrow new Error(\n\t\t\t\t`${colors.red.bold(\"✗\")} Cannot find file '${this.watchTarget}' to watch for changes`,\n\t\t\t);\n\n\t\tthis.lastSize = fs.statSync(this.watchTarget).size;\n\t\tBf6Logger.instance = this;\n\t}\n\n\tasync start() {\n\t\tprintToConsole(\n\t\t\tcolors.cyan(\n\t\t\t\t`👀 Watching Battlefield logs at: ${colors.yellow(this.watchTarget)}`,\n\t\t\t),\n\t\t);\n\n\t\tthis.watcher = chokidar.watch(this.watchTarget, {\n\t\t\tpersistent: true,\n\t\t\tignoreInitial: true,\n\t\t});\n\n\t\tthis.watcher.on(\"change\", this.handleChange.bind(this));\n\t}\n\n\tasync stop() {\n\t\tif (this.watcher) {\n\t\t\tthis.watcher.close();\n\t\t\tthis.watcher = undefined;\n\t\t\tprintToConsole(\n\t\t\t\tcolors.yellow(\n\t\t\t\t\t`${colors.red.bold(\"✗\")} Stopped watching: ${colors.gray(this.watchTarget)}`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tBf6Logger.instance = undefined;\n\t}\n\n\tprivate handleChange(file: string, stats?: fs.Stats) {\n\t\tif (!stats) return;\n\t\tif (stats.size > this.lastSize) {\n\t\t\tconst newBytes = stats.size - this.lastSize;\n\t\t\tconst fd = fs.openSync(file, \"r\");\n\t\t\tconst buffer = Buffer.alloc(newBytes);\n\t\t\tfs.readSync(fd, buffer, 0, newBytes, this.lastSize);\n\t\t\tfs.closeSync(fd);\n\n\t\t\tconst newContent = buffer\n\t\t\t\t.toString(\"utf8\")\n\t\t\t\t.split(\"QuickJS: \")\n\t\t\t\t.filter((debug) => debug.trim() !== \"\")\n\t\t\t\t.map((debug) => debug.trim())\n\t\t\t\t.map((debug) => {\n\t\t\t\t\tif (debug.startsWith(\"console.log: \")) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: \"console.log\",\n\t\t\t\t\t\t\ttext: debug.replace(\"console.log: \", \"\"),\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (debug.startsWith(\"Exception:\")) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: \"exception\",\n\t\t\t\t\t\t\ttext: debug.replace(\"Exception:\", \"\"),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: \"unknown\",\n\t\t\t\t\t\ttext: debug,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\tfor (const content of newContent) {\n\t\t\t\tif (content.type === \"console.log\")\n\t\t\t\t\tprintToConsole(colors.gray(content.text));\n\t\t\t\telse if (content.type === \"exception\")\n\t\t\t\t\tprintToConsole(colors.red(content.text), true);\n\t\t\t\telse printToConsole(colors.bold(content.text));\n\t\t\t}\n\t\t}\n\t\tthis.lastSize = stats.size;\n\t}\n}\n","import fs from \"node:fs\";\nimport { glob } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport chokidar, { type FSWatcher } from \"chokidar\";\nimport colors from \"colors\";\nimport { build, getBf6Config } from \"./build/index.ts\";\nimport { Bf6Logger } from \"./log.ts\";\nimport { printToConsole } from \"./utils.ts\";\n\nexport async function dev() {\n\tconst workingDir = path.resolve(\".\");\n\tlet config = await getBf6Config(workingDir);\n\tconst outDir = path.resolve(workingDir, config.outDir);\n\tfs.mkdirSync(outDir, { recursive: true });\n\n\tprintToConsole(colors.cyan(`▶ Starting dev for ${config.name}`));\n\n\tlet watcher: FSWatcher | undefined;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: doesn't really matter in this case\n\tfunction debounce<T extends (...args: any[]) => void>(fn: T, delay: number) {\n\t\tlet timer: NodeJS.Timeout | undefined;\n\t\treturn (...args: Parameters<T>) => {\n\t\t\tif (timer) clearTimeout(timer);\n\t\t\ttimer = setTimeout(() => fn(...args), delay);\n\t\t};\n\t}\n\n\tconst rebuild = async (trigger: string) => {\n\t\tprintToConsole(\n\t\t\tcolors.yellow(\n\t\t\t\t`↻ Change detected in ${path.basename(trigger)}, rebuilding...`,\n\t\t\t),\n\t\t);\n\t\tconst start = performance.now();\n\t\ttry {\n\t\t\tawait build();\n\t\t\tconst duration = ((performance.now() - start) / 1000).toFixed(2);\n\t\t\tprintToConsole(\n\t\t\t\t`${colors.green.bold(\"✓\")} Updated mod.json (${duration}s)`,\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tprintToConsole(\n\t\t\t\tcolors.red(\n\t\t\t\t\t`${colors.red.bold(\"✗\")} Rebuild failed: ${(err as Error).message}`,\n\t\t\t\t),\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\t};\n\n\tconst debouncedRebuild = debounce(rebuild, 200);\n\n\tasync function collectWatchTargets(): Promise<string[]> {\n\t\tconst targets: string[] = [];\n\n\t\tif (config.entrypoint)\n\t\t\ttargets.push(path.resolve(workingDir, config.entrypoint));\n\t\tif (config.scenes)\n\t\t\tfor (const [, scene] of config.scenes)\n\t\t\t\ttargets.push(path.resolve(workingDir, scene));\n\t\tif (config.strings) targets.push(path.resolve(workingDir, config.strings));\n\t\tfor await (const entry of glob(\"bf6.config.*\")) targets.push(entry);\n\t\tfor await (const entry of glob(\"src/**/*\")) targets.push(entry);\n\n\t\treturn targets;\n\t}\n\n\tasync function setupWatcher() {\n\t\tif (watcher) {\n\t\t\tawait watcher.close();\n\t\t\tprintToConsole(\n\t\t\t\tcolors.grey(\"♻ Reloading watcher due to config change...\"),\n\t\t\t);\n\t\t\tawait new Promise((r) => setTimeout(r, 10));\n\t\t}\n\n\t\tconst watchTargets = await collectWatchTargets();\n\t\tprintToConsole(colors.cyan(`👀 Watching ${watchTargets.length} files...`));\n\n\t\twatcher = chokidar.watch(watchTargets, {\n\t\t\tpersistent: true,\n\t\t\tignoreInitial: true,\n\t\t\tawaitWriteFinish: { stabilityThreshold: 250, pollInterval: 100 },\n\t\t\tignored: [outDir, `${outDir}/**`, \"node_modules/**\", \".git/**\"],\n\t\t});\n\n\t\twatcher.on(\"error\", (err) => {\n\t\t\tprintToConsole(\n\t\t\t\tcolors.red(`⚠ Watcher error: ${(err as Error).message}`),\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tsetTimeout(setupWatcher, 1000);\n\t\t});\n\n\t\twatcher.on(\"change\", async (file) => {\n\t\t\tif (file.includes(\"bf6.config.\")) {\n\t\t\t\tprintToConsole(\n\t\t\t\t\tcolors.magenta(\"⚙ Config changed — reloading watcher...\"),\n\t\t\t\t);\n\t\t\t\tconfig = await getBf6Config(workingDir);\n\t\t\t\tawait setupWatcher();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdebouncedRebuild(file);\n\t\t});\n\n\t\twatcher.on(\"add\", debouncedRebuild);\n\t\tawait rebuild(\"initial\");\n\t}\n\n\tprocess.on(\"SIGINT\", async () => {\n\t\tprintToConsole(colors.red(`\\n${colors.red.bold(\"✗\")} Exiting dev mode...`));\n\t\tawait watcher?.close();\n\t\tprocess.exit(0);\n\t});\n\n\tawait setupWatcher();\n\n\tlet logger: Bf6Logger | undefined;\n\ttry {\n\t\tlogger = new Bf6Logger();\n\t\tlogger.start();\n\t} catch (error) {\n\t\tprintToConsole(\n\t\t\tcolors.grey(\n\t\t\t\t\"Failed to start logging for the following reason (building will still work)\",\n\t\t\t),\n\t\t\ttrue,\n\t\t);\n\t\tprintToConsole((error as Error).message, true);\n\t}\n}\n","{\n\t\"name\": \"@bf6mods/sdk\",\n\t\"version\": \"1.2.0\",\n\t\"description\": \"TypeScript definitions for the BF6 modding API\",\n\t\"type\": \"module\",\n\t\"license\": \"MIT\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"import\": \"./dist/index.js\"\n\t\t},\n\t\t\"./std\": {\n\t\t\t\"types\": \"./dist/std/index.d.ts\",\n\t\t\t\"import\": \"./dist/std/index.js\"\n\t\t}\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/bf6mods/bf6mods.git\"\n\t},\n\t\"files\": [\n\t\t\"dist/\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\"\n\t},\n\t\"keywords\": [\n\t\t\"bf6\",\n\t\t\"mods\",\n\t\t\"typescript\",\n\t\t\"definitions\",\n\t\t\"api\"\n\t],\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n","import child_process from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport * as prompts from \"@clack/prompts\";\nimport bf6SdkPackageJson from \"../../../sdk/package.json\" with { type: \"json\" };\nimport bf6CliPackageJson from \"../../package.json\" with { type: \"json\" };\nimport { importFile } from \"./import.ts\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst templatesDir = path.resolve(__dirname, \"../resources/templates\");\n\nfunction renameFilesRecursively(dir: string, modName: string) {\n\tconst entries = fs.readdirSync(dir, { withFileTypes: true });\n\tfor (const entry of entries) {\n\t\tconst oldPath = path.join(dir, entry.name);\n\t\tlet newPath = oldPath;\n\n\t\t// Rename file or folder if it includes {name}\n\t\tif (entry.name.includes(\"{name}\")) {\n\t\t\tconst newName = entry.name.replace(\"{name}\", modName);\n\t\t\tnewPath = path.join(dir, newName);\n\t\t\tfs.renameSync(oldPath, newPath);\n\t\t}\n\n\t\t// If it's a bf6.config.ts, replace the {bf6ConfigName} placeholder\n\t\tif (entry.name === \"bf6.config.ts\") {\n\t\t\tlet content = fs.readFileSync(newPath, \"utf-8\");\n\t\t\tcontent = content.replace(/{bf6ConfigName}/g, modName);\n\t\t\tfs.writeFileSync(newPath, content, \"utf-8\");\n\t\t}\n\n\t\t// If it's a package.json, rewrite the \"name\" field\n\t\tif (entry.name === \"package.json\") {\n\t\t\tconst pkg = JSON.parse(fs.readFileSync(newPath, \"utf-8\"));\n\t\t\tpkg.name = modName;\n\t\t\tif (!pkg.devDependencies) pkg.devDependencies = {};\n\t\t\tpkg.devDependencies[\"@bf6mods/cli\"] = `^${bf6CliPackageJson.version}`;\n\t\t\tpkg.devDependencies[\"@bf6mods/sdk\"] = `^${bf6SdkPackageJson.version}`;\n\t\t\tfs.writeFileSync(newPath, JSON.stringify(pkg, null, 2));\n\t\t}\n\n\t\t// Recurse into directories (using the new name if renamed)\n\t\tif (fs.statSync(newPath).isDirectory()) {\n\t\t\trenameFilesRecursively(newPath, modName);\n\t\t}\n\t}\n}\n\nexport const templates = [\n\t\"Basic\",\n\t\"AcePursuit\",\n\t\"BombSquad\",\n\t\"Exfil\",\n\t\"Vertigo\",\n] as const;\n\nexport async function startProject(\n\tdestination: string,\n\ttemplate: (typeof templates)[number] | \"None\",\n\tname?: string,\n) {\n\tif ([\"AcePursuit\", \"BombSquad\", \"Exfil\", \"Vertigo\"].includes(template)) {\n\t\tconst importPath = path.resolve(templatesDir, `${template}.json`);\n\t\tawait importFile(importPath, destination, name);\n\t} else if (template === \"None\") {\n\t\t// Do nothing if none\n\t} else {\n\t\t// Handles the Basic and any other template provided\n\t\tconst templateDir = path.resolve(templatesDir, template);\n\t\tfs.cpSync(templateDir, destination, { recursive: true });\n\t}\n\n\tfs.cpSync(path.resolve(templatesDir, \"All\"), destination, {\n\t\trecursive: true,\n\t});\n\n\tif (name) renameFilesRecursively(destination, name);\n}\n\nexport function installDependencies(projectDir: string) {\n\ttry {\n\t\tchild_process.execSync(`npm install`, {\n\t\t\tstdio: \"inherit\",\n\t\t\tcwd: projectDir,\n\t\t});\n\t\treturn true;\n\t} catch (_err) {\n\t\treturn false;\n\t}\n}\n\nconst _defaultTargetDir = \"bf6-mod\";\nconst cancel = () => prompts.cancel(\"Operation cancelled\");\n\nfunction isEmpty(path: string) {\n\tconst files = fs.readdirSync(path);\n\treturn files.length === 0 || (files.length === 1 && files[0] === \".git\");\n}\n\nfunction emptyDir(dir: string) {\n\tif (!fs.existsSync(dir)) {\n\t\treturn;\n\t}\n\tfor (const file of fs.readdirSync(dir)) {\n\t\tif (file === \".git\") {\n\t\t\tcontinue;\n\t\t}\n\t\tfs.rmSync(path.resolve(dir, file), { recursive: true, force: true });\n\t}\n}\n\nexport async function init(\n\targTargetDir?: string,\n\toptions?: {\n\t\tname?: string;\n\t\ttemplate?: (typeof templates)[number];\n\t\tonExists?: \"overwrite\" | \"cancel\" | \"ignore\";\n\t\tinstallDependencies?: boolean;\n\t},\n) {\n\tprompts.intro(\"Initialize Bf6 Mod\");\n\n\tconst path = argTargetDir\n\t\t? argTargetDir\n\t\t: await prompts.text({\n\t\t\t\tmessage: \"Where should we create your project?\",\n\t\t\t\tplaceholder: \"./ace-pursuit\",\n\t\t\t\tvalidate: (value) => {\n\t\t\t\t\tif (!value) return \"Please enter a path.\";\n\t\t\t\t\tif (value[0] !== \".\") return \"Please enter a relative path.\";\n\t\t\t\t},\n\t\t\t});\n\tif (prompts.isCancel(path)) return cancel();\n\n\tlet name = options?.name\n\t\t? options.name\n\t\t: await prompts.text({\n\t\t\t\tmessage: \"What is the name of your mod?\",\n\t\t\t\tplaceholder: \"Ace Pursuit\",\n\t\t\t\tvalidate: (value) => {\n\t\t\t\t\tif (!value.trim()) return \"Please enter a name.\";\n\t\t\t\t},\n\t\t\t});\n\tif (prompts.isCancel(name)) return cancel();\n\tname = name.trim();\n\n\tif (fs.existsSync(path) && !isEmpty(path)) {\n\t\tlet overwrite: \"yes\" | \"no\" | \"ignore\" | undefined;\n\t\tif (options?.onExists) {\n\t\t\tswitch (options.onExists) {\n\t\t\t\tcase \"overwrite\":\n\t\t\t\t\toverwrite = \"yes\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"cancel\":\n\t\t\t\t\toverwrite = \"no\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"ignore\":\n\t\t\t\t\toverwrite = \"ignore\";\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tconst res = overwrite\n\t\t\t? overwrite\n\t\t\t: await prompts.select({\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t(path === \".\"\n\t\t\t\t\t\t\t? \"Current directory\"\n\t\t\t\t\t\t\t: `Target directory \"${path}\"`) +\n\t\t\t\t\t\t` is not empty. Please choose how to proceed:`,\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: \"Cancel operation\",\n\t\t\t\t\t\t\tvalue: \"no\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: \"Remove existing files and continue\",\n\t\t\t\t\t\t\tvalue: \"yes\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: \"Ignore files and continue\",\n\t\t\t\t\t\t\tvalue: \"ignore\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t});\n\t\tif (prompts.isCancel(res)) return cancel();\n\t\toverwrite = res;\n\n\t\tswitch (overwrite) {\n\t\t\tcase \"yes\":\n\t\t\t\temptyDir(path);\n\t\t\t\tbreak;\n\t\t\tcase \"no\":\n\t\t\t\tcancel();\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\tconst template = options?.template\n\t\t? options.template\n\t\t: await prompts.select({\n\t\t\t\tmessage: \"Select a template:\",\n\t\t\t\toptions: templates.map((template) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tlabel: template,\n\t\t\t\t\t\tvalue: template,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t});\n\tif (prompts.isCancel(template)) return cancel();\n\n\tawait startProject(path, template, name);\n\n\tif (options?.installDependencies) {\n\t\tconst s = prompts.spinner();\n\t\ts.start(\"Installing via npm\");\n\t\tconst installed = installDependencies(path);\n\t\tif (installed) s.stop(\"Installed via npm\");\n\t\telse s.stop(\"Failed to install via npm\", 1);\n\n\t\tconst nextSteps = `cd ${path}\\nnpm run build`;\n\n\t\tprompts.note(nextSteps, \"Next steps.\");\n\t} else {\n\t\tconst nextSteps = `cd ${path}\\nnpm i\\nnpm run build`;\n\n\t\tprompts.note(nextSteps, \"Next steps.\");\n\t}\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { AttachmentType, type ConfigType } from \"@bf6mods/sdk\";\nimport colors from \"colors\";\nimport stringifyObject from \"stringify-object\";\nimport { MapId as MapIdEnum } from \"../resources/prepare/types/config.ts\";\nimport { startProject } from \"./init.ts\";\nimport { printToConsole } from \"./utils.ts\";\n\nasync function writeFileSafe(filePath: string, data: string | Buffer) {\n\tconst dir = path.dirname(filePath);\n\tawait fs.promises.mkdir(dir, { recursive: true });\n\tawait fs.promises.writeFile(filePath, data);\n}\n\nfunction getMapKeyByValue(value: string): keyof typeof MapIdEnum | undefined {\n\treturn Object.keys(MapIdEnum).find(\n\t\t(k) => MapIdEnum[k as keyof typeof MapIdEnum] === value,\n\t) as keyof typeof MapIdEnum | undefined;\n}\n\nexport async function importFile(\n\tinput: string,\n\toutput: string,\n\tname?: string,\n\tlogging = false,\n) {\n\tconst start = performance.now();\n\tconst workingDir = path.resolve(\".\");\n\tconst entrypoint = path.resolve(workingDir, input);\n\tconst outDir = path.resolve(workingDir, output);\n\n\tif (!fs.existsSync(entrypoint)) throw new Error(\"Cannot find strings file\");\n\n\tif (logging)\n\t\tprintToConsole(colors.cyan(`📦 Importing config from: ${entrypoint}`));\n\n\tconst config = JSON.parse(\n\t\tawait fs.promises.readFile(entrypoint, { encoding: \"utf8\" }),\n\t) as ConfigType;\n\n\tif (!fs.existsSync(outDir)) {\n\t\tawait fs.promises.mkdir(outDir, { recursive: true });\n\t\tif (logging)\n\t\t\tprintToConsole(colors.cyan(`📁 Created output directory: ${outDir}`));\n\t}\n\n\tawait startProject(outDir, \"None\", name ?? config.name);\n\n\tlet typescriptFile: string | undefined;\n\tlet stringsFile: string | undefined;\n\tconst scenes: [string, string][] = [];\n\tconst promises: Promise<unknown>[] = [];\n\n\tif (config.attachments) {\n\t\tlet unamedAttachmentIndex = 0;\n\t\tfor (const attachment of config.attachments) {\n\t\t\tlet filename = attachment.filename?.trim();\n\t\t\tif (!filename) {\n\t\t\t\tunamedAttachmentIndex++;\n\n\t\t\t\tlet ext: string = \"\";\n\t\t\t\tif (attachment.attachmentType === AttachmentType.TypeScript)\n\t\t\t\t\text = \".ts\";\n\t\t\t\telse if (attachment.attachmentType === AttachmentType.Strings)\n\t\t\t\t\text = \".strings.json\";\n\t\t\t\telse if (attachment.attachmentType === AttachmentType.SpatialData)\n\t\t\t\t\text = \".spatial.json\";\n\n\t\t\t\tif (unamedAttachmentIndex > 1)\n\t\t\t\t\tfilename = `attachment_${unamedAttachmentIndex}${ext}`;\n\t\t\t\telse filename = `attachment${ext}`;\n\t\t\t}\n\n\t\t\tif (attachment.attachmentType === AttachmentType.TypeScript)\n\t\t\t\ttypescriptFile = filename;\n\n\t\t\tif (attachment.attachmentType === AttachmentType.Strings)\n\t\t\t\tstringsFile = filename;\n\n\t\t\tif (attachment.attachmentType === AttachmentType.SpatialData) {\n\t\t\t\t// We'll just use the data attached to mapRotation instead\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tpromises.push(\n\t\t\t\twriteFileSafe(\n\t\t\t\t\tpath.resolve(outDir, \"src\", filename),\n\t\t\t\t\tatob(attachment.attachmentData.original),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tif (logging)\n\t\t\t\tprintToConsole(\n\t\t\t\t\t`${colors.green(\"✓\")} Wrote attachment: ${colors.yellow(filename)}`,\n\t\t\t\t);\n\t\t}\n\t}\n\n\t// Extract spatial scenes from mapRotation instead of guessing\n\tif (config.mapRotation?.length) {\n\t\tfor (const map of config.mapRotation) {\n\t\t\tpromises.push(\n\t\t\t\twriteFileSafe(\n\t\t\t\t\tpath.resolve(outDir, \"src\", \"scenes\", map.spatialAttachment.filename),\n\t\t\t\t\tatob(map.spatialAttachment.attachmentData.original),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tscenes.push([map.id, `src/scenes/${map.spatialAttachment.filename}`]);\n\n\t\t\tif (logging)\n\t\t\t\tprintToConsole(\n\t\t\t\t\t`${colors.green(\"✓\")} Added scene: ${colors.yellow(map.id)}`,\n\t\t\t\t);\n\t\t}\n\t}\n\n\t// build the new bf6.config.ts structure\n\tconst bf6Config = {\n\t\tname: name ?? config.name,\n\t\tdescription: config.description,\n\t\toutDir: \"dist\",\n\t\tentrypoint: typescriptFile ? `src/${typescriptFile}` : undefined,\n\t\tscenes: scenes\n\t\t\t? scenes.map(([id, path]) => [\n\t\t\t\t\t`MapId.${getMapKeyByValue(id) ?? id}`,\n\t\t\t\t\tpath,\n\t\t\t\t])\n\t\t\t: undefined,\n\t\tstrings: stringsFile ? `src/${stringsFile}` : undefined,\n\t\tgame: {\n\t\t\tmutators: config.mutators,\n\t\t\tassetRestrictions: config.assetRestrictions,\n\t\t\tgameMode: config.gameMode,\n\t\t\tteamComposition: config.teamComposition,\n\t\t},\n\t};\n\n\tconst bf6ConfigContent = `export default defineBf6Config(${stringifyWithRaw(\n\t\tbf6Config,\n\t)});\\n`;\n\n\tpromises.push(\n\t\twriteFileSafe(path.resolve(outDir, \"bf6.config.ts\"), bf6ConfigContent),\n\t);\n\n\tawait Promise.all(promises);\n\n\tconst duration = ((performance.now() - start) / 1000).toFixed(2);\n\tif (logging)\n\t\tprintToConsole(\n\t\t\t`${colors.green.bold(\"✓\")} Import complete (${duration}s) → ${colors.yellow(outDir)}`,\n\t\t);\n}\n\nfunction stringifyWithRaw(value: unknown, options = {}) {\n\treturn stringifyObject(value, {\n\t\tindent: \" \", // 4 spaces\n\t\tsingleQuotes: true,\n\t\ttransform: (_obj, _prop, originalResult) => {\n\t\t\t// Remove quotes from MapId.* expressions\n\t\t\tif (/^['\"]MapId\\.[A-Za-z0-9_]+['\"]$/.test(originalResult)) {\n\t\t\t\treturn originalResult.slice(1, -1); // remove surrounding quotes\n\t\t\t}\n\t\t\treturn originalResult;\n\t\t},\n\t\t...options,\n\t});\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport colors from \"colors\";\nimport { genExport, genInlineTypeImport } from \"knitwork\";\nimport { printToConsole } from \"./utils.js\";\n\nexport async function prepare() {\n\ttry {\n\t\tconst __filename = fileURLToPath(import.meta.url);\n\t\tconst __dirname = path.dirname(__filename);\n\n\t\tconst _workingDir = path.resolve(\".\");\n\t\tconst buildDir = path.resolve(\".bf6\");\n\n\t\tconst resources = path.resolve(__dirname, \"../resources/prepare\");\n\n\t\tfs.cpSync(\n\t\t\tpath.resolve(resources, \"tsconfig.json\"),\n\t\t\tpath.resolve(buildDir, \"tsconfig.json\"),\n\t\t);\n\t\tfs.cpSync(\n\t\t\tpath.resolve(resources, \"bf6.d.ts\"),\n\t\t\tpath.resolve(buildDir, \"bf6.d.ts\"),\n\t\t);\n\t\tfs.cpSync(\n\t\t\tpath.resolve(resources, \"types\", \"config.ts\"),\n\t\t\tpath.resolve(buildDir, \"types\", \"config.ts\"),\n\t\t);\n\n\t\tconst ConfigFileExports = genExport(\"./types/config.ts\", [\n\t\t\t\"defineBf6Config\",\n\t\t]);\n\t\tfs.writeFileSync(\n\t\t\tpath.resolve(buildDir, \"imports.d.ts\"),\n\t\t\t`${ConfigFileExports}\\n`,\n\t\t);\n\n\t\tconst augmentations: Record<string, string> = {\n\t\t\tdefineBf6Config: genInlineTypeImport(\n\t\t\t\t\"./types/config.ts\",\n\t\t\t\t`defineBf6Config`,\n\t\t\t),\n\t\t\tMapId: genInlineTypeImport(\"./types/config.ts\", `MapId`),\n\t\t};\n\n\t\tconst args = genNamespaceAugmentation(\"global\", augmentations);\n\t\tfs.writeFileSync(\n\t\t\tpath.resolve(buildDir, \"globals.d.ts\"),\n\t\t\t`export {}\\n\\n${args}\\n`,\n\t\t);\n\n\t\tprintToConsole(`${colors.green.bold(\"✓\")} Types generated in .bf6`);\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\tprintToConsole(\n\t\t\t`${colors.red.bold(\"✗\")} Types failed to generate in .bf6`,\n\t\t\ttrue,\n\t\t);\n\t}\n}\n\nconst genNamespaceAugmentation = (\n\tname: string,\n\tcontents: Record<string, string>,\n) => {\n\tif (!contents || Object.keys(contents).length === 0)\n\t\treturn `declare ${name} {}`;\n\tconst decls = Object.entries(contents)\n\t\t.map(([k, v]) => `\\tconst ${k}: ${v};`)\n\t\t.join(\"\\n\");\n\treturn `declare ${name} {\\n${decls}\\n}`;\n};\n","#!/usr/bin/env node\nimport colors from \"colors\";\nimport { Command } from \"commander\";\nimport pkg from \"../../package.json\" with { type: \"json\" };\nimport { build } from \"./build/index.ts\";\nimport { dev } from \"./dev.ts\";\nimport { importFile } from \"./import.ts\";\nimport { init, installDependencies, templates } from \"./init.js\";\nimport { Bf6Logger } from \"./log.ts\";\nimport { prepare } from \"./prepare.js\";\nimport { printToConsole, readableList } from \"./utils.ts\";\n\nconst program = new Command();\n\nprogram\n\t.name(Object.keys(pkg.bin)[0])\n\t.description(pkg.description)\n\t.version(pkg.version);\n\nprogram\n\t.command(\"init\")\n\t.argument(\"[directory]\")\n\t.option(\"--name <name>\", \"The name of your mod\")\n\t.option(\"--template <template>\", \"The template to use\")\n\t.option(\n\t\t\"--on-exists <action>\",\n\t\t`Either \"overwrite\", \"cancel\", or \"ignore\" as to what to do if files exist in the directory`,\n\t)\n\t.option(\"--no-install-dependencies\", `Prevents install of dependencies`)\n\t.description(\"Create a new bf6 mod\")\n\t.action(async (directory, options) => {\n\t\tconst { name, template, onExists, installDependencies } = options;\n\t\tif (\n\t\t\tonExists !== undefined &&\n\t\t\t![\"overwrite\", \"cancel\", \"ignore\"].includes(onExists)\n\t\t) {\n\t\t\tprintToConsole(\n\t\t\t\t`${colors.red.bold(\"✗\")} Invalid value for --on-exists: \"${onExists}\". Expected one of \"overwrite\", \"cancel\", or \"ignore\".`,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tif (template !== undefined && !templates.includes(template)) {\n\t\t\tprintToConsole(\n\t\t\t\t`${colors.red.bold(\"✗\")} Invalid value for --template: \"${template}\". Expected one of ${readableList(templates)}.`,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tawait init(directory, {\n\t\t\tname,\n\t\t\ttemplate,\n\t\t\tonExists,\n\t\t\tinstallDependencies,\n\t\t});\n\t});\n\nprogram\n\t.command(\"build\")\n\t.description(\"build the bf6 mod\")\n\t.action(async () => {\n\t\tawait build();\n\t});\n\nprogram\n\t.command(\"prepare\")\n\t.description(\"prepare the types for bf6 mod\")\n\t.action(async () => {\n\t\tawait prepare();\n\t});\n\nprogram\n\t.command(\"dev\")\n\t.description(\"watch the changes in src, and recompile as needed\")\n\t.action(async () => {\n\t\tawait dev();\n\t});\n\nprogram\n\t.command(\"import\")\n\t.argument(\"<input>\")\n\t.argument(\"<output>\")\n\t.option(\"--no-install-dependencies\", `Prevents install of dependencies`)\n\t.description(\"decompiles the json config of a mod into a new project\")\n\t.action(async (input, output, options) => {\n\t\tawait importFile(input as string, output as string, undefined, true);\n\t\tif (options?.installDependencies) installDependencies(output);\n\t});\n\nprogram\n\t.command(\"log\")\n\t.argument(\"[input]\")\n\t.description(\"logs the output from a locally running server\")\n\t.action(async (input) => {\n\t\tconst logger = new Bf6Logger(input);\n\t\tlogger.start();\n\t});\n\nprogram.exitOverride((_err) => {\n\tif (process.env.EXIT_CODE === \"none\") process.exit(0);\n});\n\nif (!process.argv.slice(2).length) {\n\tprogram.outputHelp();\n\tprocess.exit(0);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