mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 15:33:12 +09:00
Migrate to ECMAScript Modules
Migrate the usage of CommonJS specific code and imports to ESM. Roughly summarised this: - Changes all require() calls to import statement or expressions. - Changes usage of module.exports to export statements. - Replaces require.resolve with import.meta.resolve. - Replaces conditional imports with conditional subpath imports. - Replaces module === require.main with import.meta.main. - Adds the full filename with extention to all relative imports. - Changes all usage of __dirname and __filename to their import.meta equivalents. - Sets "type": "module" in package.json files. - Removes usage of "use strict". - Adds .ts an an alias of .js for the webpack build. Due to differences in how require and import resolves files the plugin entrypoints will have to include the filename and extension after this migration in order to work.
This commit is contained in:
1 parent
b69111dda3
commit
5dcaca4d0b
261 files changed
+1115
-1330
No files matched your search
@@ -1,17 +1,17 @@
|
||||
import type { Argv } from "yargs";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import type BaseCtlPlugin from "./BaseCtlPlugin";
|
||||
import { controllerCommands } from "./commands_controller";
|
||||
import { hostCommands } from "./commands_host";
|
||||
import { instanceCommands } from "./commands_instance";
|
||||
import { modPackCommands } from "./commands_mod_pack";
|
||||
import { modCommands } from "./commands_mod";
|
||||
import { permissionCommands } from "./commands_permission";
|
||||
import { roleCommands } from "./commands_role";
|
||||
import { userCommands } from "./commands_user";
|
||||
import { logCommands } from "./commands_log";
|
||||
import { debugCommands } from "./commands_debug";
|
||||
import type BaseCtlPlugin from "./BaseCtlPlugin.js";
|
||||
import { controllerCommands } from "./commands_controller.js";
|
||||
import { hostCommands } from "./commands_host.js";
|
||||
import { instanceCommands } from "./commands_instance.js";
|
||||
import { modPackCommands } from "./commands_mod_pack.js";
|
||||
import { modCommands } from "./commands_mod.js";
|
||||
import { permissionCommands } from "./commands_permission.js";
|
||||
import { roleCommands } from "./commands_role.js";
|
||||
import { userCommands } from "./commands_user.js";
|
||||
import { logCommands } from "./commands_log.js";
|
||||
import { debugCommands } from "./commands_debug.js";
|
||||
|
||||
export async function registerCommands(ctlPlugins: Map<string, BaseCtlPlugin>, yargs: Argv) {
|
||||
const rootCommands = new lib.CommandTree({ name: "clusterioctl", description: "Manage cluster" });
|
||||
|
||||
@@ -5,9 +5,9 @@ import os from "os";
|
||||
import child_process from "child_process";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import type { Control } from "../ctl";
|
||||
import { print } from "./command_ops";
|
||||
import { serializedConfigToString, getEditor, configToKeyVal } from "./config_ops";
|
||||
import type { Control } from "../ctl.js";
|
||||
import { print } from "./command_ops.js";
|
||||
import { serializedConfigToString, getEditor, configToKeyVal } from "./config_ops.js";
|
||||
|
||||
const asTable = asTableModule.configure({ delimiter: " | " });
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as lib from "@clusterio/lib";
|
||||
import type { Control } from "../ctl";
|
||||
import type { Control } from "../ctl.js";
|
||||
|
||||
export const debugCommands = new lib.CommandTree({ name: "debug", description: "Debugging utilities" });
|
||||
debugCommands.add(new lib.Command({
|
||||
|
||||
@@ -6,9 +6,9 @@ import child_process from "child_process";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { logger } from "@clusterio/lib";
|
||||
import type { Control } from "../ctl";
|
||||
import { print } from "./command_ops";
|
||||
import { serializedConfigToString, getEditor, configToKeyVal } from "./config_ops";
|
||||
import type { Control } from "../ctl.js";
|
||||
import { print } from "./command_ops.js";
|
||||
import { serializedConfigToString, getEditor, configToKeyVal } from "./config_ops.js";
|
||||
|
||||
const asTable = asTableModule.configure({ delimiter: " | " });
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import util from "util";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { logger } from "@clusterio/lib";
|
||||
import type { Control } from "../ctl";
|
||||
import { print } from "./command_ops";
|
||||
import { serializedConfigToString, getEditor, configToKeyVal } from "./config_ops";
|
||||
import type { Control } from "../ctl.js";
|
||||
import { print } from "./command_ops.js";
|
||||
import { serializedConfigToString, getEditor, configToKeyVal } from "./config_ops.js";
|
||||
|
||||
const asTable = asTableModule.configure({ delimiter: " | " });
|
||||
const finished = util.promisify(stream.finished);
|
||||
|
||||
@@ -2,7 +2,7 @@ import winston from "winston";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { ConsoleTransport, levels, logger } from "@clusterio/lib";
|
||||
import type { Control } from "../ctl";
|
||||
import type { Control } from "../ctl.js";
|
||||
|
||||
export const logCommands = new lib.CommandTree({ name: "log", description: "Log inspection" });
|
||||
logCommands.add(new lib.Command({
|
||||
|
||||
@@ -7,8 +7,8 @@ import util from "util";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { logger } from "@clusterio/lib";
|
||||
import type { Control } from "../ctl";
|
||||
import { print } from "./command_ops";
|
||||
import type { Control } from "../ctl.js";
|
||||
import { print } from "./command_ops.js";
|
||||
|
||||
const asTable = asTableModule.configure({ delimiter: " | " });
|
||||
const finished = util.promisify(stream.finished);
|
||||
|
||||
@@ -2,8 +2,8 @@ import asTableModule from "as-table";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { logger } from "@clusterio/lib";
|
||||
import type { Control } from "../ctl";
|
||||
import { print } from "./command_ops";
|
||||
import type { Control } from "../ctl.js";
|
||||
import { print } from "./command_ops.js";
|
||||
|
||||
const asTable = asTableModule.configure({ delimiter: " | " });
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import asTableModule from "as-table";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import type { Control } from "../ctl";
|
||||
import { print } from "./command_ops";
|
||||
import type { Control } from "../ctl.js";
|
||||
import { print } from "./command_ops.js";
|
||||
|
||||
const asTable = asTableModule.configure({ delimiter: " | " });
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import asTableModule from "as-table";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { logger } from "@clusterio/lib";
|
||||
import type { Control } from "../ctl";
|
||||
import { print } from "./command_ops";
|
||||
import type { Control } from "../ctl.js";
|
||||
import { print } from "./command_ops.js";
|
||||
|
||||
const asTable = asTableModule.configure({ delimiter: " | " });
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import asTableModule from "as-table";
|
||||
import path from "path";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import type { Control } from "../ctl";
|
||||
import { print } from "./command_ops";
|
||||
import type { Control } from "../ctl.js";
|
||||
import { print } from "./command_ops.js";
|
||||
|
||||
const asTable = asTableModule.configure({ delimiter: " | " });
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
// This needs to be a separate file due to ECMAScript Modules evaluating code in
|
||||
// imported modules before any code in the file that imports it.
|
||||
(global as any).lazySchemaCompilation = true;
|
||||
Reference in new issue
Block a user