diff --git a/markdown/bitburner.ns.getfilemetadata.md b/markdown/bitburner.ns.getfilemetadata.md
index fcd0f047c..9c1f8cb69 100644
--- a/markdown/bitburner.ns.getfilemetadata.md
+++ b/markdown/bitburner.ns.getfilemetadata.md
@@ -42,7 +42,7 @@ string
-Name of the file to read the metadata from. It must be a text file (.txt, .json) or a script (.js, .jsx, .ts, .tsx).
+Name of the file to read the metadata from. It must be a text file (.txt, .json, .css) or a script (.js, .jsx, .ts, .tsx).
|
diff --git a/markdown/bitburner.ns.mv.md b/markdown/bitburner.ns.mv.md
index 15efb26ef..f8e9b6cd3 100644
--- a/markdown/bitburner.ns.mv.md
+++ b/markdown/bitburner.ns.mv.md
@@ -90,7 +90,7 @@ RAM cost: 0 GB
Move the source file to the specified destination on the target server.
-This command only works for scripts (.js, .jsx, .ts, .tsx) and text files (.txt, .json). It cannot, however, be used to convert from script to text file, or vice versa.
+This command only works for scripts (.js, .jsx, .ts, .tsx) and text files (.txt, .json, .css). It cannot, however, be used to convert from script to text file, or vice versa.
This function can also be used to rename files.
diff --git a/markdown/bitburner.ns.read.md b/markdown/bitburner.ns.read.md
index 2d4454f74..8779f1129 100644
--- a/markdown/bitburner.ns.read.md
+++ b/markdown/bitburner.ns.read.md
@@ -58,7 +58,7 @@ Data in the specified text file.
RAM cost: 0 GB
-This function is used to read data from a text file (.txt, .json) or script (.js, .jsx, .ts, .tsx).
+This function is used to read data from a text file (.txt, .json, .css) or script (.js, .jsx, .ts, .tsx).
This function will return the data in the specified file. If the file does not exist, an empty string will be returned.
diff --git a/markdown/bitburner.ns.wget.md b/markdown/bitburner.ns.wget.md
index 0337937ea..7e870c968 100644
--- a/markdown/bitburner.ns.wget.md
+++ b/markdown/bitburner.ns.wget.md
@@ -90,7 +90,7 @@ True if the data was successfully retrieved from the URL, false otherwise.
RAM cost: 0 GB
-Retrieves data from a URL and downloads it to a file on the specified server. The data can only be downloaded to a script (.js, .jsx, .ts, .tsx) or a text file (.txt, .json). If the file already exists, it will be overwritten by this command. Note that it will not be possible to download data from many websites because they do not allow cross-origin resource sharing (CORS).
+Retrieves data from a URL and downloads it to a file on the specified server. The data can only be downloaded to a script (.js, .jsx, .ts, .tsx) or a text file (.txt, .json, .css). If the file already exists, it will be overwritten by this command. Note that it will not be possible to download data from many websites because they do not allow cross-origin resource sharing (CORS).
## Example
diff --git a/markdown/bitburner.ns.write.md b/markdown/bitburner.ns.write.md
index 927632060..5a923e69c 100644
--- a/markdown/bitburner.ns.write.md
+++ b/markdown/bitburner.ns.write.md
@@ -88,7 +88,7 @@ void
RAM cost: 0 GB
-This function can be used to write data to a text file (.txt, .json) or a script (.js, .jsx, .ts, .tsx).
+This function can be used to write data to a text file (.txt, .json, .css) or a script (.js, .jsx, .ts, .tsx).
This function will write data to that file. If the specified file does not exist, then it will be created. The third argument mode defines how the data will be written to the file. If mode is set to “w”, then the data is written in “write” mode which means that it will overwrite all existing data on the file. If mode is set to any other value then the data will be written in “append” mode which means that the data will be added at the end of the file.
diff --git a/src/Documentation/doc/en/basic/scripts.md b/src/Documentation/doc/en/basic/scripts.md
index 2ec723ade..a44770fd9 100644
--- a/src/Documentation/doc/en/basic/scripts.md
+++ b/src/Documentation/doc/en/basic/scripts.md
@@ -112,7 +112,7 @@ Check how much [RAM](ram.md) a script requires to run with "n" threads
**nano [script]**
Create/Edit a script.
-The name of a script must end with a script extension (.js, .jsx, .ts, .tsx). You can also create a text file with a text extension (.txt, .json).
+The name of a script must end with a script extension (.js, .jsx, .ts, .tsx). You can also create a text file with a text extension (.txt, .json, .css).
**ps**
diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts
index 458f9aee6..f2e34bd4f 100644
--- a/src/NetscriptFunctions.ts
+++ b/src/NetscriptFunctions.ts
@@ -788,7 +788,7 @@ export const ns: InternalAPI = {
continue;
}
if (!path.endsWith(".lit")) {
- throw helpers.errorMessage(ctx, "Only works for scripts, .lit and .txt files.");
+ throw helpers.errorMessage(ctx, "Only works for script, text, and .lit files");
}
lits.push(path);
}
@@ -1611,7 +1611,7 @@ export const ns: InternalAPI = {
) {
throw helpers.errorMessage(
ctx,
- `'mv' can only be used on scripts (.js, .jsx, .ts, .tsx) and text files (.txt, .json)`,
+ `'mv' can only be used on scripts (.js, .jsx, .ts, .tsx) and text files (.txt, .json, .css)`,
);
}
if (sourcePath === destinationPath) {
diff --git a/src/Paths/TextFilePath.ts b/src/Paths/TextFilePath.ts
index 9e579ce22..4127838aa 100644
--- a/src/Paths/TextFilePath.ts
+++ b/src/Paths/TextFilePath.ts
@@ -7,7 +7,7 @@ export type TextFilePath = FilePath & WithTextExtension;
/** Check extension only */
export function hasTextExtension(path: string): path is WithTextExtension {
- return path.endsWith(".txt") || path.endsWith(".json");
+ return path.endsWith(".txt") || path.endsWith(".json") || path.endsWith(".css");
}
/** Sanitize a player input, resolve any relative paths, and for imports add the correct extension if missing */
diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts
index 1dd926d36..dd2d0a4ff 100644
--- a/src/ScriptEditor/NetscriptDefinitions.d.ts
+++ b/src/ScriptEditor/NetscriptDefinitions.d.ts
@@ -7744,7 +7744,7 @@ export interface NS {
* @remarks
* RAM cost: 0 GB
*
- * This function can be used to write data to a text file (.txt, .json) or a script (.js, .jsx, .ts, .tsx).
+ * This function can be used to write data to a text file (.txt, .json, .css) or a script (.js, .jsx, .ts, .tsx).
*
* This function will write data to that file. If the specified file does not exist,
* then it will be created. The third argument mode defines how the data will be written to
@@ -7792,7 +7792,7 @@ export interface NS {
* @remarks
* RAM cost: 0 GB
*
- * This function is used to read data from a text file (.txt, .json) or script (.js, .jsx, .ts, .tsx).
+ * This function is used to read data from a text file (.txt, .json, .css) or script (.js, .jsx, .ts, .tsx).
*
* This function will return the data in the specified file.
* If the file does not exist, an empty string will be returned.
@@ -7809,7 +7809,7 @@ export interface NS {
*
* This function returns the metadata associated with the specified file.
*
- * @param filename - Name of the file to read the metadata from. It must be a text file (.txt, .json) or a script
+ * @param filename - Name of the file to read the metadata from. It must be a text file (.txt, .json, .css) or a script
* (.js, .jsx, .ts, .tsx).
* @Returns The metadata of the file.
*/
@@ -8186,7 +8186,7 @@ export interface NS {
* RAM cost: 0 GB
*
* Retrieves data from a URL and downloads it to a file on the specified server.
- * The data can only be downloaded to a script (.js, .jsx, .ts, .tsx) or a text file (.txt, .json).
+ * The data can only be downloaded to a script (.js, .jsx, .ts, .tsx) or a text file (.txt, .json, .css).
* If the file already exists, it will be overwritten by this command.
* Note that it will not be possible to download data from many websites because they
* do not allow cross-origin resource sharing (CORS).
@@ -8278,7 +8278,7 @@ export interface NS {
*
* Move the source file to the specified destination on the target server.
*
- * This command only works for scripts (.js, .jsx, .ts, .tsx) and text files (.txt, .json). It cannot, however, be
+ * This command only works for scripts (.js, .jsx, .ts, .tsx) and text files (.txt, .json, .css). It cannot, however, be
* used to convert from script to text file, or vice versa.
*
* This function can also be used to rename files.
diff --git a/src/ScriptEditor/ScriptEditor.ts b/src/ScriptEditor/ScriptEditor.ts
index 31af542e5..138b4041d 100644
--- a/src/ScriptEditor/ScriptEditor.ts
+++ b/src/ScriptEditor/ScriptEditor.ts
@@ -130,6 +130,11 @@ export class ScriptEditor {
//json language server tries to load a schema by default
completionItems: false,
});
+
+ monaco.languages.css.cssDefaults.setModeConfiguration({
+ ...monaco.languages.css.cssDefaults.modeConfiguration,
+ });
+
// Load themes
loadThemes(monaco.editor.defineTheme);
monaco.editor.defineTheme("customTheme", makeTheme(Settings.EditorTheme));
diff --git a/src/ScriptEditor/ui/utils.ts b/src/ScriptEditor/ui/utils.ts
index 8d1145a95..71b49db0d 100644
--- a/src/ScriptEditor/ui/utils.ts
+++ b/src/ScriptEditor/ui/utils.ts
@@ -58,6 +58,9 @@ function makeModel(hostname: string, filename: string, code: string): editor.ITe
case FileType.NS1:
language = "javascript";
break;
+ case FileType.CSS:
+ language = "css";
+ break;
default:
throwIfReachable(fileType);
}
diff --git a/src/Terminal/HelpText.ts b/src/Terminal/HelpText.ts
index 4132c6e6e..f4e9e7b65 100644
--- a/src/Terminal/HelpText.ts
+++ b/src/Terminal/HelpText.ts
@@ -5,7 +5,7 @@ export const TerminalHelpText: string[] = [
" analyze Get information about the current machine ",
" backdoor Install a backdoor on the current machine ",
" buy [-l/-a/program] Purchase a program through the Dark Web",
- " cat [file] Display a .msg, .lit, or .txt file",
+ " cat [file] Display a .msg, .lit, or text file",
" cd [dir] Change to a new directory",
" changelog Display changelog",
" check [script] [args...] Print a script's logs to Terminal",
@@ -39,7 +39,7 @@ export const TerminalHelpText: string[] = [
" [--temporary] [args...]",
" scan Prints all immediately-available network connections",
" scan-analyze [d] [-a] Prints info for all servers up to d nodes away",
- " scp [files...] [server] Copies a file to a destination server",
+ " scp [files...] [server] Copies text or .lit files to a destination server",
" sudov Shows whether you have root access on this computer",
" tail [script/pid] [args...] Displays dynamic logs for the specified script",
" top Displays all running scripts and their RAM usage",
@@ -56,7 +56,7 @@ const TemplatedHelpTexts: Record string[]> = {
`Usage: ${command} [file names...] | [glob]`,
` `,
`Opens up the specified file(s) in the Script Editor. Only scripts (.js, .jsx, .ts, .tsx) `,
- `or text files (.txt, .json) can be edited using the Script Editor. If a file does not exist, a new `,
+ `or text files (.txt, .json, .css) can be edited using the Script Editor. If a file does not exist, a new `,
`one will be created.`,
` `,
`If a glob is provided as the only argument, ${command} can crawl directories and open all matching `,
@@ -142,7 +142,7 @@ export const HelpTexts: Record = {
cat: [
"Usage: cat [file name]",
" ",
- "Display message (.msg), literature (.lit), script (.js, .jsx, .ts, .tsx), or text (.txt, .json) files. Examples:",
+ "Display message (.msg), literature (.lit), script (.js, .jsx, .ts, .tsx), or text (.txt, .json, .css) files. Examples:",
" ",
" cat j1.msg",
" ",
@@ -258,7 +258,7 @@ export const HelpTexts: Record = {
" -h --no-filename suppress printing file name with output lines. Default when one FILE argument passed. Overrides -H",
" -n --line-number print line number with output lines",
" -q --quiet --silent suppress printing to terminal",
- " -O --output OUTFILE pipe output to text file. The following argument must be a valid .txt or .json filename. Does NOT overwrite by default",
+ " -O --output OUTFILE pipe output to text file. The following argument must be a valid text file (.txt, .json, .css). Does NOT overwrite by default",
" -f --allow-overwrite combine with [-O/--output] to allow overwriting provided output file",
" ",
"Context control:",
@@ -386,7 +386,7 @@ export const HelpTexts: Record = {
"Usage: mv [src] [dest]",
" ",
"Move the source file to the specified destination. This can also be used to rename files. ",
- "This command only works for scripts (.js, .jsx, .ts, .tsx) and text files (.txt, .json). This command CANNOT be used to ",
+ "This command only works for scripts (.js, .jsx, .ts, .tsx) and text files (.txt, .json, .css). This command CANNOT be used to ",
"convert to different file types",
" ",
"Note that, unlike the Linux 'mv' command, the destination argument must be the ",
@@ -470,7 +470,7 @@ export const HelpTexts: Record = {
"Usage: scp [file names...] [target server]",
" ",
"Copies the specified file(s) from the current server to the target server. ",
- "This command only works for script files (.js, .jsx, .ts, .tsx), text files (.txt, .json), ",
+ "This command only works for script files (.js, .jsx, .ts, .tsx), text files (.txt, .json, .css), ",
"and literature files (.lit).",
"The second argument passed in must be the hostname or IP of the target server. Examples:",
" ",
@@ -532,7 +532,7 @@ export const HelpTexts: Record = {
"Usage: wget [url] [target file]",
" ",
"Retrieves data from a URL and downloads it to a file on the current server. The data can only ",
- "be downloaded to a script (.js, .jsx, .ts, .tsx) or a text file (.txt, .json).",
+ "be downloaded to a script (.js, .jsx, .ts, .tsx) or a text file (.txt, .json, .css).",
"If the file already exists, it will be overwritten by this command.",
" ",
"Note that it will not be possible to download data from many websites because they do not allow ",
diff --git a/src/Terminal/commands/cat.ts b/src/Terminal/commands/cat.ts
index ae21a6b6b..ce4c53ca6 100644
--- a/src/Terminal/commands/cat.ts
+++ b/src/Terminal/commands/cat.ts
@@ -21,7 +21,7 @@ export function cat(args: (string | number | boolean)[], server: BaseServer): vo
}
if (!path.endsWith(".msg") && !path.endsWith(".lit")) {
return Terminal.error(
- "Invalid file extension. Filename must end with .msg, .lit, a script extension (.js, .jsx, .ts, .tsx) or a text extension (.txt, .json)",
+ "Invalid file extension. Filename must end with .msg, .lit, a script extension (.js, .jsx, .ts, .tsx) or a text extension (.txt, .json, .css)",
);
}
diff --git a/src/Terminal/commands/grep.ts b/src/Terminal/commands/grep.ts
index 522bdf994..9c4598ee1 100644
--- a/src/Terminal/commands/grep.ts
+++ b/src/Terminal/commands/grep.ts
@@ -27,7 +27,7 @@ const ERR = {
outFileExists: (path: string) =>
`grep file output failed: Invalid output file "${path}". Output file must not already exist. Pass -f/--allow-overwrite to overwrite.`,
badOutFile: (path: string) =>
- `grep file output failed: Invalid output file "${path}". Output file path must be a valid .txt file.`,
+ `grep file output failed: Invalid output file "${path}". Output file path must be a valid text file. (.txt, .json, .css)`,
truncated: () =>
`\n${YELLOW}Terminal output truncated to ${Settings.MaxTerminalCapacity} lines (Max terminal capacity)`,
} as const;
diff --git a/src/Terminal/commands/mv.ts b/src/Terminal/commands/mv.ts
index 57a572079..1012bf792 100644
--- a/src/Terminal/commands/mv.ts
+++ b/src/Terminal/commands/mv.ts
@@ -19,7 +19,7 @@ export function mv(args: (string | number | boolean)[], server: BaseServer): voi
(!hasScriptExtension(sourcePath) && !hasTextExtension(sourcePath)) ||
(!hasScriptExtension(destinationPath) && !hasTextExtension(destinationPath))
) {
- return Terminal.error(`'mv' can only be used on scripts (.js, .jsx, .ts, .tsx) and text files (.txt, .json)`);
+ return Terminal.error(`'mv' can only be used on scripts (.js, .jsx, .ts, .tsx) and text files (.txt, .json, .css)`);
}
// Allow content to be moved between scripts and textfiles, no need to limit this.
diff --git a/src/Terminal/commands/scp.ts b/src/Terminal/commands/scp.ts
index de21e54eb..f8e75144c 100644
--- a/src/Terminal/commands/scp.ts
+++ b/src/Terminal/commands/scp.ts
@@ -36,7 +36,7 @@ export function scp(args: (string | number | boolean)[], server: BaseServer): vo
// Error for invalid filetype
if (!hasScriptExtension(path) && !hasTextExtension(path)) {
return Terminal.error(
- `scp failed: ${path} has invalid extension. scp only works for scripts (.js, .jsx, .ts, .tsx), text files (.txt, .json), and literature files (.lit)`,
+ `scp failed: ${path} has invalid extension. scp only works for scripts (.js, .jsx, .ts, .tsx), text files (.txt, .json, .css), and literature files (.lit)`,
);
}
const sourceContentFile = server.getContentFile(path);
diff --git a/src/utils/ScriptTransformer.ts b/src/utils/ScriptTransformer.ts
index 6f0363e00..30e6ee387 100644
--- a/src/utils/ScriptTransformer.ts
+++ b/src/utils/ScriptTransformer.ts
@@ -16,6 +16,7 @@ export enum FileType {
TS,
TSX,
NS1,
+ CSS,
}
export interface FileTypeFeature {
@@ -44,6 +45,8 @@ export function getFileType(filename: string): FileType {
return FileType.TSX;
case "script":
return FileType.NS1;
+ case "css":
+ return FileType.CSS;
default:
throw new Error(`Invalid extension: ${extension}. Filename: ${filename}.`);
}
diff --git a/webpack.config.js b/webpack.config.js
index 42084a307..7bc9ac95f 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -91,7 +91,7 @@ module.exports = (env, argv) => {
return {
plugins: [
- new MonacoWebpackPlugin({ languages: ["javascript", "typescript", "json"] }),
+ new MonacoWebpackPlugin({ languages: ["javascript", "typescript", "json", "css"] }),
new webpack.DefinePlugin({
"process.env.NODE_ENV": isDevelopment ? '"development"' : '"production"',
}),