mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-05 15:17:48 +02:00
NETSCRIPT: Add .script deprecation notice & migration guide (#1007)
This commit is contained in:
@@ -6,6 +6,7 @@ import { CursorPositions } from "../../../ScriptEditor/CursorPositions";
|
||||
import { ScriptFilePath, hasScriptExtension } from "../../../Paths/ScriptFilePath";
|
||||
import { TextFilePath, hasTextExtension } from "../../../Paths/TextFilePath";
|
||||
import { getGlobbedFileMap } from "../../../Paths/GlobbedFiles";
|
||||
import { sendDeprecationNotice } from "./deprecation";
|
||||
|
||||
// 2.3: Globbing implementation was removed from this file. Globbing will be reintroduced as broader functionality and integrated here.
|
||||
|
||||
@@ -30,12 +31,14 @@ export function commonEditor(
|
||||
): void {
|
||||
if (args.length < 1) return Terminal.error(`Incorrect usage of ${command} command. Usage: ${command} [scriptname]`);
|
||||
const files = new Map<ScriptFilePath | TextFilePath, string>();
|
||||
let hasNs1 = false;
|
||||
for (const arg of args) {
|
||||
const pattern = String(arg);
|
||||
|
||||
// Glob of existing files
|
||||
if (pattern.includes("*") || pattern.includes("?")) {
|
||||
for (const [path, file] of getGlobbedFileMap(pattern, server, Terminal.currDir)) {
|
||||
if (path.endsWith(".script")) hasNs1 = true;
|
||||
files.set(path, file.content);
|
||||
}
|
||||
continue;
|
||||
@@ -47,10 +50,14 @@ export function commonEditor(
|
||||
if (!hasScriptExtension(path) && !hasTextExtension(path)) {
|
||||
return Terminal.error(`${command}: Only scripts or text files can be edited. Invalid file type: ${arg}`);
|
||||
}
|
||||
if (path.endsWith(".script")) hasNs1 = true;
|
||||
const file = server.getContentFile(path);
|
||||
const content = file ? file.content : isNs2(path) ? newNs2Template : "";
|
||||
files.set(path, content);
|
||||
if (content === newNs2Template) CursorPositions.saveCursor(path, { row: 3, column: 5 });
|
||||
}
|
||||
if (hasNs1) {
|
||||
sendDeprecationNotice();
|
||||
}
|
||||
Router.toPage(Page.ScriptEditor, { files, options });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user