wmx-os-core 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +12 -0
- package/dist/config.js +26 -0
- package/dist/context.d.ts +8 -0
- package/dist/context.js +11 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.js +19 -0
- package/dist/plugin.d.ts +12 -0
- package/dist/plugin.js +1 -0
- package/package.json +7 -2
- package/src/config.d.ts +12 -0
- package/src/config.js +26 -0
- package/src/context.d.ts +8 -0
- package/src/context.js +11 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +3 -0
- package/src/logger.d.ts +8 -0
- package/src/logger.js +19 -0
- package/src/plugin.d.ts +12 -0
- package/src/plugin.js +1 -0
- package/tsconfig.json +0 -8
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface WmxConfig {
|
|
2
|
+
framework?: string;
|
|
3
|
+
backend?: string;
|
|
4
|
+
database?: string;
|
|
5
|
+
ignore?: string[];
|
|
6
|
+
plugins?: string[];
|
|
7
|
+
deploy?: {
|
|
8
|
+
provider: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function loadConfig(cwd: string): WmxConfig | null;
|
|
12
|
+
export declare function saveConfig(config: WmxConfig, dir: string): void;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
2
|
+
import { join, resolve } from "path";
|
|
3
|
+
const CONFIG_FILENAME = ".wmxrc.json";
|
|
4
|
+
export function loadConfig(cwd) {
|
|
5
|
+
let current = resolve(cwd);
|
|
6
|
+
while (true) {
|
|
7
|
+
const candidate = join(current, CONFIG_FILENAME);
|
|
8
|
+
if (existsSync(candidate)) {
|
|
9
|
+
try {
|
|
10
|
+
const raw = readFileSync(candidate, "utf-8");
|
|
11
|
+
return JSON.parse(raw);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const parent = resolve(current, "..");
|
|
18
|
+
if (parent === current)
|
|
19
|
+
return null;
|
|
20
|
+
current = parent;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function saveConfig(config, dir) {
|
|
24
|
+
const configPath = join(dir, CONFIG_FILENAME);
|
|
25
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
26
|
+
}
|
package/dist/context.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { logger, Logger } from "./logger.js";
|
|
2
|
+
export type { WmxConfig } from "./config.js";
|
|
3
|
+
export { loadConfig, saveConfig } from "./config.js";
|
|
4
|
+
export type { WmxContext } from "./context.js";
|
|
5
|
+
export { createContext } from "./context.js";
|
|
6
|
+
export type { WmxCommand, WmxPlugin } from "./plugin.js";
|
package/dist/index.js
ADDED
package/dist/logger.d.ts
ADDED
package/dist/logger.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export class Logger {
|
|
3
|
+
info(message) {
|
|
4
|
+
console.log(`${chalk.blue("[i]")} ${message}`);
|
|
5
|
+
}
|
|
6
|
+
success(message) {
|
|
7
|
+
console.log(`${chalk.green("[ok]")} ${message}`);
|
|
8
|
+
}
|
|
9
|
+
warn(message) {
|
|
10
|
+
console.warn(`${chalk.yellow("[!]")} ${message}`);
|
|
11
|
+
}
|
|
12
|
+
error(message) {
|
|
13
|
+
console.error(`${chalk.red("[x]")} ${message}`);
|
|
14
|
+
}
|
|
15
|
+
debug(message) {
|
|
16
|
+
console.log(`${chalk.gray("[...]")} ${message}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const logger = new Logger();
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WmxContext } from "./context.js";
|
|
2
|
+
export interface WmxCommand {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
options?: Record<string, string>;
|
|
6
|
+
run(options: Record<string, unknown>, context: WmxContext): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface WmxPlugin {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
commands?: WmxCommand[];
|
|
12
|
+
}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wmx-os-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,5 +14,10 @@
|
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/node": "^26.0.1",
|
|
16
16
|
"typescript": "^5.4.0"
|
|
17
|
-
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"src",
|
|
21
|
+
"package.json"
|
|
22
|
+
]
|
|
18
23
|
}
|
package/src/config.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface WmxConfig {
|
|
2
|
+
framework?: string;
|
|
3
|
+
backend?: string;
|
|
4
|
+
database?: string;
|
|
5
|
+
ignore?: string[];
|
|
6
|
+
plugins?: string[];
|
|
7
|
+
deploy?: {
|
|
8
|
+
provider: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function loadConfig(cwd: string): WmxConfig | null;
|
|
12
|
+
export declare function saveConfig(config: WmxConfig, dir: string): void;
|
package/src/config.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
2
|
+
import { join, resolve } from "path";
|
|
3
|
+
const CONFIG_FILENAME = ".wmxrc.json";
|
|
4
|
+
export function loadConfig(cwd) {
|
|
5
|
+
let current = resolve(cwd);
|
|
6
|
+
while (true) {
|
|
7
|
+
const candidate = join(current, CONFIG_FILENAME);
|
|
8
|
+
if (existsSync(candidate)) {
|
|
9
|
+
try {
|
|
10
|
+
const raw = readFileSync(candidate, "utf-8");
|
|
11
|
+
return JSON.parse(raw);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const parent = resolve(current, "..");
|
|
18
|
+
if (parent === current)
|
|
19
|
+
return null;
|
|
20
|
+
current = parent;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function saveConfig(config, dir) {
|
|
24
|
+
const configPath = join(dir, CONFIG_FILENAME);
|
|
25
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
26
|
+
}
|
package/src/context.d.ts
ADDED
package/src/context.js
ADDED
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { logger, Logger } from "./logger.js";
|
|
2
|
+
export type { WmxConfig } from "./config.js";
|
|
3
|
+
export { loadConfig, saveConfig } from "./config.js";
|
|
4
|
+
export type { WmxContext } from "./context.js";
|
|
5
|
+
export { createContext } from "./context.js";
|
|
6
|
+
export type { WmxCommand, WmxPlugin } from "./plugin.js";
|
package/src/index.js
ADDED
package/src/logger.d.ts
ADDED
package/src/logger.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export class Logger {
|
|
3
|
+
info(message) {
|
|
4
|
+
console.log(`${chalk.blue("[i]")} ${message}`);
|
|
5
|
+
}
|
|
6
|
+
success(message) {
|
|
7
|
+
console.log(`${chalk.green("[ok]")} ${message}`);
|
|
8
|
+
}
|
|
9
|
+
warn(message) {
|
|
10
|
+
console.warn(`${chalk.yellow("[!]")} ${message}`);
|
|
11
|
+
}
|
|
12
|
+
error(message) {
|
|
13
|
+
console.error(`${chalk.red("[x]")} ${message}`);
|
|
14
|
+
}
|
|
15
|
+
debug(message) {
|
|
16
|
+
console.log(`${chalk.gray("[...]")} ${message}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const logger = new Logger();
|
package/src/plugin.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WmxContext } from "./context.js";
|
|
2
|
+
export interface WmxCommand {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
options?: Record<string, string>;
|
|
6
|
+
run(options: Record<string, unknown>, context: WmxContext): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface WmxPlugin {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
commands?: WmxCommand[];
|
|
12
|
+
}
|
package/src/plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|