mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2024-11-21 13:38:21 -05:00
Initial Commit
This commit is contained in:
commit
55bf3e2c44
133
.gitignore
vendored
Normal file
133
.gitignore
vendored
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# yarn v2
|
||||||
|
.yarn/cache
|
||||||
|
.yarn/unplugged
|
||||||
|
.yarn/build-state.yml
|
||||||
|
.yarn/install-state.gz
|
||||||
|
.pnp.*
|
||||||
|
|
||||||
|
server/
|
83
package-lock.json
generated
Normal file
83
package-lock.json
generated
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
{
|
||||||
|
"name": "mod-manager",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "mod-manager",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"chalk": "^5.0.1",
|
||||||
|
"commander": "^9.4.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^18.6.3",
|
||||||
|
"typescript": "^4.7.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/node": {
|
||||||
|
"version": "18.6.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.3.tgz",
|
||||||
|
"integrity": "sha512-6qKpDtoaYLM+5+AFChLhHermMQxc3TOEFIDzrZLPRGHPrLEwqFkkT5Kx3ju05g6X7uDPazz3jHbKPX0KzCjntg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/chalk": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==",
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/commander": {
|
||||||
|
"version": "9.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/commander/-/commander-9.4.0.tgz",
|
||||||
|
"integrity": "sha512-sRPT+umqkz90UA8M1yqYfnHlZA7fF6nSphDtxeywPZ49ysjxDQybzk13CL+mXekDRG92skbcqCLVovuCusNmFw==",
|
||||||
|
"engines": {
|
||||||
|
"node": "^12.20.0 || >=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/typescript": {
|
||||||
|
"version": "4.7.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
|
||||||
|
"integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"tsc": "bin/tsc",
|
||||||
|
"tsserver": "bin/tsserver"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": {
|
||||||
|
"version": "18.6.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.3.tgz",
|
||||||
|
"integrity": "sha512-6qKpDtoaYLM+5+AFChLhHermMQxc3TOEFIDzrZLPRGHPrLEwqFkkT5Kx3ju05g6X7uDPazz3jHbKPX0KzCjntg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"chalk": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w=="
|
||||||
|
},
|
||||||
|
"commander": {
|
||||||
|
"version": "9.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/commander/-/commander-9.4.0.tgz",
|
||||||
|
"integrity": "sha512-sRPT+umqkz90UA8M1yqYfnHlZA7fF6nSphDtxeywPZ49ysjxDQybzk13CL+mXekDRG92skbcqCLVovuCusNmFw=="
|
||||||
|
},
|
||||||
|
"typescript": {
|
||||||
|
"version": "4.7.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
|
||||||
|
"integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
package.json
Normal file
21
package.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "mod-manager",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"chalk": "^5.0.1",
|
||||||
|
"commander": "^9.4.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^18.6.3",
|
||||||
|
"typescript": "^4.7.4"
|
||||||
|
}
|
||||||
|
}
|
16
src/commands/init_command.ts
Normal file
16
src/commands/init_command.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { Command } from "commander";
|
||||||
|
import Initialiser from "../util/initialiser.js";
|
||||||
|
import Subcommand from "./subcommand.js";
|
||||||
|
|
||||||
|
export default class InitCommand extends Subcommand {
|
||||||
|
registerCommand(program: Command) {
|
||||||
|
program.command("init")
|
||||||
|
.description("Initalises mod manager")
|
||||||
|
.action(this.execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
execute() {
|
||||||
|
Initialiser.initialise();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
6
src/commands/subcommand.ts
Normal file
6
src/commands/subcommand.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { Command } from "commander";
|
||||||
|
|
||||||
|
export default abstract class Subcommand {
|
||||||
|
abstract registerCommand(program: Command): void;
|
||||||
|
abstract execute(): void;
|
||||||
|
}
|
39
src/mod-manager.ts
Normal file
39
src/mod-manager.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import { Command } from "commander";
|
||||||
|
import InitCommand from "./commands/init_command.js";
|
||||||
|
import Subcommand from "./commands/subcommand.js";
|
||||||
|
import Initialiser from "./util/initialiser.js";
|
||||||
|
import PrintUtils from "./util/print_utils.js";
|
||||||
|
|
||||||
|
export default class ModManager {
|
||||||
|
private static program: Command = new Command();
|
||||||
|
|
||||||
|
private static subcommands: Array<Subcommand> = [
|
||||||
|
new InitCommand()
|
||||||
|
];
|
||||||
|
|
||||||
|
static init() {
|
||||||
|
this.program
|
||||||
|
.name('mod-manager')
|
||||||
|
.description('A package (mod) manager for Fabric Minecraft Servers');
|
||||||
|
|
||||||
|
this.subcommands.forEach(command => {
|
||||||
|
command.registerCommand(ModManager.program);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.program.parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
static execute(callback: () => any): void {
|
||||||
|
if (Initialiser.isInitialised()) {
|
||||||
|
callback();
|
||||||
|
} else {
|
||||||
|
PrintUtils.error("Mod Manager is not initialised");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ModManager.init();
|
||||||
|
|
||||||
|
|
53
src/util/initialiser.ts
Normal file
53
src/util/initialiser.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { existsSync, mkdirSync } from "fs";
|
||||||
|
import PrintUtils from "./print_utils.js";
|
||||||
|
|
||||||
|
export default class Initialiser {
|
||||||
|
private static readonly MOD_MANAGER_FOLDER = ".mod-manager"
|
||||||
|
|
||||||
|
public static initialise(): void {
|
||||||
|
if (!this.isInitialised()) {
|
||||||
|
if (this.isDirFabricServer()) {
|
||||||
|
const success: boolean = this.setupFolderStructure();
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
PrintUtils.success("Sucessfully initialised Mod Manager!");
|
||||||
|
} else {
|
||||||
|
PrintUtils.error("Unable to set up the Mod Manager folder structure");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
PrintUtils.error("Unable to initialise Mod Manager as this is not a Fabric Minecraft Server");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
PrintUtils.warn("Mod Manager is already initialised!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static isInitialised(): boolean {
|
||||||
|
return existsSync(this.getModManagerFolderPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static isDirFabricServer(): boolean {
|
||||||
|
const workingDirectory = process.cwd();
|
||||||
|
|
||||||
|
const serverProperties = `${workingDirectory}/server.properties`;
|
||||||
|
const fabric = `${workingDirectory}/.fabric`;
|
||||||
|
|
||||||
|
return existsSync(serverProperties) && existsSync(fabric);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static setupFolderStructure(): boolean {
|
||||||
|
if (!existsSync(this.getModManagerFolderPath())) {
|
||||||
|
mkdirSync(this.getModManagerFolderPath());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getModManagerFolderPath(): string {
|
||||||
|
const workingDirectory = process.cwd();
|
||||||
|
|
||||||
|
return `${workingDirectory}/${this.MOD_MANAGER_FOLDER}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
src/util/print_utils.ts
Normal file
19
src/util/print_utils.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import chalk from "chalk";
|
||||||
|
|
||||||
|
export default class PrintUtils {
|
||||||
|
static info(print: string) {
|
||||||
|
console.log(chalk.white(print));
|
||||||
|
}
|
||||||
|
|
||||||
|
static warn(print: string) {
|
||||||
|
console.log(chalk.yellowBright(print));
|
||||||
|
}
|
||||||
|
|
||||||
|
static success(print: string) {
|
||||||
|
console.log(chalk.greenBright(print));
|
||||||
|
}
|
||||||
|
|
||||||
|
static error(print: string) {
|
||||||
|
console.log(chalk.redBright(print));
|
||||||
|
}
|
||||||
|
}
|
38
tsconfig.json
Normal file
38
tsconfig.json
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
// project options
|
||||||
|
"lib": [
|
||||||
|
"ESNext",
|
||||||
|
"dom"
|
||||||
|
], // specifies which default set of type definitions to use ("DOM", "ES6", etc)
|
||||||
|
"outDir": "dist", // .js (as well as .d.ts, .js.map, etc.) files will be emitted into this directory.,
|
||||||
|
"removeComments": true, // Strips all comments from TypeScript files when converting into JavaScript- you rarely read compiled code so this saves space
|
||||||
|
"target": "ES6", // Target environment. Most modern browsers support ES6, but you may want to set it to newer or older. (defaults to ES3)
|
||||||
|
|
||||||
|
// Module resolution
|
||||||
|
"baseUrl": "./", // Lets you set a base directory to resolve non-absolute module names.
|
||||||
|
"esModuleInterop": true, // fixes some issues TS originally had with the ES6 spec where TypeScript treats CommonJS/AMD/UMD modules similar to ES6 module
|
||||||
|
"moduleResolution": "node", // Pretty much always node for modern JS. Other option is "classic"
|
||||||
|
"paths": {}, // A series of entries which re-map imports to lookup locations relative to the baseUrl
|
||||||
|
|
||||||
|
// Source Map
|
||||||
|
"sourceMap": true, // enables the use of source maps for debuggers and error reporting etc
|
||||||
|
"sourceRoot": "/", // Specify the location where a debugger should locate TypeScript files instead of relative source locations.
|
||||||
|
|
||||||
|
// Strict Checks
|
||||||
|
"alwaysStrict": true, // Ensures that your files are parsed in the ECMAScript strict mode, and emit “use strict” for each source file.
|
||||||
|
"allowUnreachableCode": false, // pick up dead code paths
|
||||||
|
"noImplicitAny": true, // In some cases where no type annotations are present, TypeScript will fall back to a type of any for a variable when it cannot infer the type.
|
||||||
|
"strictNullChecks": true, // When strictNullChecks is true, null and undefined have their own distinct types and you’ll get a type error if you try to use them where a concrete value is expected.
|
||||||
|
|
||||||
|
// Linter Checks
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noUncheckedIndexedAccess": true, // accessing index must always check for undefined
|
||||||
|
"noUnusedLocals": true, // Report errors on unused local variables.
|
||||||
|
"noUnusedParameters": true // Report errors on unused parameters in functions
|
||||||
|
},
|
||||||
|
"include": ["./**/*.ts"],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules/**/*"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user