@revojs/terminal 0.2.45 → 0.2.47
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/index.d.ts +1 -0
- package/dist/index.js +23 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +5 -0
- package/dist/module/index.d.ts +9 -0
- package/dist/module/index.js +47 -0
- package/package.json +38 -38
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runTerminal(args?: string[]): Promise<0 | 1>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import commands from "#commands";
|
|
2
|
+
import config from "#config/terminal";
|
|
3
|
+
import { VARIABLE_CONTEXT, createScope } from "revojs";
|
|
4
|
+
import { createCommandTree, runCommands } from "revojs/commands";
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
async function runTerminal(args = process.argv.slice(2)) {
|
|
7
|
+
try {
|
|
8
|
+
return await runCommands({
|
|
9
|
+
name: config.name,
|
|
10
|
+
description: config.description || void 0,
|
|
11
|
+
args,
|
|
12
|
+
tree: await createCommandTree(commands),
|
|
13
|
+
async run(command, context) {
|
|
14
|
+
await command.run(await createScope({ context: { [VARIABLE_CONTEXT]: process.env } }), context);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error(error instanceof Error ? error.message : error);
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { runTerminal };
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface TerminalConfig {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
outDir: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function readPackageName(path?: string): string | undefined;
|
|
7
|
+
export declare const TERMINAL = "terminal";
|
|
8
|
+
declare const _default: import("revojs/module").Module<"terminal", TerminalConfig, []>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
import { defineModule, useModule } from "revojs/module";
|
|
4
|
+
//#region src/module/index.ts
|
|
5
|
+
function readPackageName(path = resolve("package.json")) {
|
|
6
|
+
try {
|
|
7
|
+
const manifest = JSON.parse(readFileSync(path, "utf8"));
|
|
8
|
+
if (manifest.bin && typeof manifest.bin === "object") {
|
|
9
|
+
const [name] = Object.keys(manifest.bin);
|
|
10
|
+
if (name) return name;
|
|
11
|
+
}
|
|
12
|
+
return manifest.name?.split("/").pop();
|
|
13
|
+
} catch {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
var TERMINAL = "terminal";
|
|
18
|
+
var module_default = defineModule({
|
|
19
|
+
name: "terminal",
|
|
20
|
+
config: () => ({
|
|
21
|
+
name: "",
|
|
22
|
+
description: "",
|
|
23
|
+
outDir: "./dist/terminal"
|
|
24
|
+
}),
|
|
25
|
+
setup(config) {
|
|
26
|
+
const { fromModule } = useModule(import.meta.url);
|
|
27
|
+
if (!config.terminal.name) config.terminal.name = readPackageName() ?? "revojs";
|
|
28
|
+
return { vite: { environments: { [TERMINAL]: {
|
|
29
|
+
consumer: "server",
|
|
30
|
+
resolve: { noExternal: true },
|
|
31
|
+
build: {
|
|
32
|
+
outDir: config.terminal.outDir,
|
|
33
|
+
emptyOutDir: true,
|
|
34
|
+
rolldownOptions: {
|
|
35
|
+
input: fromModule("../main.js"),
|
|
36
|
+
output: {
|
|
37
|
+
entryFileNames: "index.js",
|
|
38
|
+
codeSplitting: false,
|
|
39
|
+
banner: "#!/usr/bin/env node"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} } } };
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { TERMINAL, module_default as default, readPackageName };
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@revojs/terminal",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/tellua/revojs.git"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"dist"
|
|
11
|
-
],
|
|
12
|
-
"type": "module",
|
|
13
|
-
"main": "./dist/index.js",
|
|
14
|
-
"module": "./dist/index.js",
|
|
15
|
-
"types": "./dist/index.d.ts",
|
|
16
|
-
"exports": {
|
|
17
|
-
".": {
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
19
|
-
"import": "./dist/index.js"
|
|
20
|
-
},
|
|
21
|
-
"./module": {
|
|
22
|
-
"types": "./dist/module/index.d.ts",
|
|
23
|
-
"import": "./dist/module/index.js"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"build": "vite build",
|
|
28
|
-
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
29
|
-
"watch": "vite build --watch"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"revojs": "*"
|
|
33
|
-
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@revojs/tsconfig": "*",
|
|
36
|
-
"@types/node": "^26.6.4"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@revojs/terminal",
|
|
3
|
+
"version": "0.2.47",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/tellua/revojs.git"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./module": {
|
|
22
|
+
"types": "./dist/module/index.d.ts",
|
|
23
|
+
"import": "./dist/module/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "vite build",
|
|
28
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
29
|
+
"watch": "vite build --watch"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"revojs": "*"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@revojs/tsconfig": "*",
|
|
36
|
+
"@types/node": "^26.6.4"
|
|
37
|
+
}
|
|
38
|
+
}
|