NETSCRIPT: Add .script deprecation notice & migration guide (#1007)

This commit is contained in:
LJ
2024-01-07 06:15:24 -07:00
committed by GitHub
parent 9827fda4a4
commit a433c8284c
11 changed files with 134 additions and 9 deletions
+7
View File
@@ -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 });
}