revojs 0.2.43 → 0.2.45
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/bin/index.d.ts +2 -0
- package/dist/bin/index.js +69 -0
- package/dist/commands/index.d.ts +75 -2
- package/dist/commands/index.js +106 -122
- package/dist/module/index.d.ts +0 -24
- package/dist/module/index.js +3 -6
- package/dist/package.js +6 -2
- package/dist/types/index.d.ts +1 -1
- package/package.json +6 -2
- package/src/types/index.d.ts +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createCommandTree, runCommands } from "../commands/index.js";
|
|
3
|
+
import { createRunnableDevEnvironment, createServer, isRunnableDevEnvironment, loadEnv } from "vite";
|
|
4
|
+
import { parseArgs } from "util";
|
|
5
|
+
//#region src/bin/index.ts
|
|
6
|
+
var args = process.argv.slice(2);
|
|
7
|
+
var parsed = parseArgs({
|
|
8
|
+
args,
|
|
9
|
+
strict: false,
|
|
10
|
+
allowPositionals: true,
|
|
11
|
+
options: { environment: {
|
|
12
|
+
type: "string",
|
|
13
|
+
short: "e"
|
|
14
|
+
} }
|
|
15
|
+
});
|
|
16
|
+
var server = await createServer({
|
|
17
|
+
appType: "custom",
|
|
18
|
+
environments: { command: {
|
|
19
|
+
consumer: "server",
|
|
20
|
+
dev: { createEnvironment(name, config) {
|
|
21
|
+
return createRunnableDevEnvironment(name, config);
|
|
22
|
+
} }
|
|
23
|
+
} },
|
|
24
|
+
server: {
|
|
25
|
+
middlewareMode: true,
|
|
26
|
+
hmr: false
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var environment = typeof parsed.values.environment === "string" ? server.environments[parsed.values.environment] : server.environments.command ?? Object.values(server.environments).find((environment) => isRunnableDevEnvironment(environment) && environment.config.consumer === "server") ?? Object.values(server.environments).find(isRunnableDevEnvironment);
|
|
30
|
+
if (!environment || !isRunnableDevEnvironment(environment)) {
|
|
31
|
+
await server.close();
|
|
32
|
+
throw new Error(typeof parsed.values.environment === "string" ? `No runnable environment named "${parsed.values.environment}" found.` : "No runnable Vite environment found.");
|
|
33
|
+
}
|
|
34
|
+
var environments = new Array();
|
|
35
|
+
for (const [name, entry] of Object.entries(server.environments)) if (isRunnableDevEnvironment(entry)) environments.push({
|
|
36
|
+
name,
|
|
37
|
+
description: [entry.config.consumer, name === "ssr" ? "default" : void 0].filter(Boolean).join(", ")
|
|
38
|
+
});
|
|
39
|
+
environments.sort((a, b) => a.name.localeCompare(b.name));
|
|
40
|
+
try {
|
|
41
|
+
const commands = await environment.runner.import("#commands").then((module) => module.default);
|
|
42
|
+
process.exitCode = await runCommands({
|
|
43
|
+
name: "revojs",
|
|
44
|
+
description: "Commands are discovered from ./commands (via the revojs \"commands\" source) and run inside the project's Vite dev server, sharing the same module graph and virtuals.",
|
|
45
|
+
args,
|
|
46
|
+
tree: await createCommandTree(commands),
|
|
47
|
+
flags: [{
|
|
48
|
+
name: "environment",
|
|
49
|
+
description: "Vite dev environment used for command execution",
|
|
50
|
+
short: "e",
|
|
51
|
+
type: "string"
|
|
52
|
+
}],
|
|
53
|
+
sections: { Environments: environments },
|
|
54
|
+
async run(command, context) {
|
|
55
|
+
const { createScope, VARIABLE_CONTEXT } = await environment.runner.import("revojs");
|
|
56
|
+
await command.run(await createScope({ context: { [VARIABLE_CONTEXT]: loadEnv(environment.config.mode, environment.config.envDir, "") } }), {
|
|
57
|
+
...context,
|
|
58
|
+
environment
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(error);
|
|
64
|
+
process.exitCode = 1;
|
|
65
|
+
} finally {
|
|
66
|
+
await server.close();
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export {};
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -1,2 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { parseArgs, type ParseArgsOptionDescriptor, type ParseArgsOptionsConfig } from "node:util";
|
|
2
|
+
import type { RunnableDevEnvironment } from "vite";
|
|
3
|
+
import type { Scope } from "../scope";
|
|
4
|
+
import type { Awaitable } from "../shared";
|
|
5
|
+
export type CommandValues<T extends ParseArgsOptionsConfig> = ReturnType<typeof parseArgs<{
|
|
6
|
+
options: T;
|
|
7
|
+
allowPositionals: true;
|
|
8
|
+
strict: true;
|
|
9
|
+
}>>["values"];
|
|
10
|
+
export type CommandLoaders = Record<string, Record<string, () => Promise<Command<CommandArguments>>>>;
|
|
11
|
+
export interface CommandArgument extends ParseArgsOptionDescriptor {
|
|
12
|
+
description?: string;
|
|
13
|
+
}
|
|
14
|
+
export type CommandArguments = ParseArgsOptionsConfig & Record<string, CommandArgument>;
|
|
15
|
+
export interface CommandContext<T extends ParseArgsOptionsConfig = ParseArgsOptionsConfig> {
|
|
16
|
+
input: Array<string>;
|
|
17
|
+
arguments: CommandValues<T>;
|
|
18
|
+
environment?: RunnableDevEnvironment;
|
|
19
|
+
}
|
|
20
|
+
export interface Command<T extends ParseArgsOptionsConfig = ParseArgsOptionsConfig> {
|
|
21
|
+
description?: string;
|
|
22
|
+
arguments?: T;
|
|
23
|
+
run: (scope: Scope, context: CommandContext<T>) => Awaitable<void>;
|
|
24
|
+
}
|
|
25
|
+
export interface CommandTree {
|
|
26
|
+
value?: Command<CommandArguments>;
|
|
27
|
+
children: Record<string, CommandTree>;
|
|
28
|
+
}
|
|
29
|
+
export interface CommandHelpEntry {
|
|
30
|
+
name: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface CommandFlag {
|
|
34
|
+
name: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
multiple?: boolean;
|
|
37
|
+
short?: string;
|
|
38
|
+
type: "string" | "boolean";
|
|
39
|
+
}
|
|
40
|
+
export interface CommandMatch {
|
|
41
|
+
tree: CommandTree;
|
|
42
|
+
path: Array<string>;
|
|
43
|
+
command?: Command<CommandArguments>;
|
|
44
|
+
}
|
|
45
|
+
export interface CommandHelpOptions {
|
|
46
|
+
name: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
match: CommandMatch;
|
|
49
|
+
flags?: Array<CommandFlag>;
|
|
50
|
+
sections?: Record<string, Array<CommandHelpEntry>>;
|
|
51
|
+
}
|
|
52
|
+
export interface CommandRunOptions {
|
|
53
|
+
name: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
args: Array<string>;
|
|
56
|
+
tree: CommandTree;
|
|
57
|
+
flags?: Array<CommandFlag>;
|
|
58
|
+
sections?: Record<string, Array<CommandHelpEntry>>;
|
|
59
|
+
run: (command: Command<CommandArguments>, context: CommandContext<CommandArguments>) => Awaitable<void>;
|
|
60
|
+
}
|
|
61
|
+
export declare function defineCommand<const T extends ParseArgsOptionsConfig>(command: Command<T>): Command<T>;
|
|
62
|
+
export declare function createCommandTree(commands: CommandLoaders): Promise<CommandTree>;
|
|
63
|
+
export declare function findCommand(tree: CommandTree, positionals: Array<string>): CommandMatch;
|
|
64
|
+
export declare function formatSection(title: string, entries: Array<CommandHelpEntry>): string[];
|
|
65
|
+
export declare function formatFlag(flag: CommandFlag): string;
|
|
66
|
+
export declare function formatHelp(options: CommandHelpOptions): string;
|
|
67
|
+
export declare function parseCommand(command: Command<CommandArguments>, args: Array<string>, path: Array<string>): {
|
|
68
|
+
values: {
|
|
69
|
+
[longOption: string]: string | boolean | undefined;
|
|
70
|
+
} & {
|
|
71
|
+
help?: string | boolean | undefined;
|
|
72
|
+
};
|
|
73
|
+
positionals: string[];
|
|
74
|
+
};
|
|
75
|
+
export declare function runCommands(options: CommandRunOptions): Promise<0 | 1>;
|
package/dist/commands/index.js
CHANGED
|
@@ -1,153 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
import { createRunnableDevEnvironment, createServer, isRunnableDevEnvironment, loadEnv } from "vite";
|
|
3
|
-
import { parseArgs } from "util";
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
4
2
|
//#region src/commands/index.ts
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
function defineCommand(command) {
|
|
4
|
+
return command;
|
|
5
|
+
}
|
|
6
|
+
async function createCommandTree(commands) {
|
|
7
|
+
const tree = { children: {} };
|
|
8
|
+
for (const source of Object.values(commands)) for (const [path, value] of Object.entries(source)) {
|
|
9
|
+
let node = tree;
|
|
10
|
+
for (const segment of path.replace(/\\/g, "/").replace(/(^|\/)index$/, "").split("/").filter(Boolean)) node = node.children[segment] ??= { children: {} };
|
|
11
|
+
node.value = await value();
|
|
12
|
+
}
|
|
13
|
+
return tree;
|
|
14
|
+
}
|
|
15
|
+
function findCommand(tree, positionals) {
|
|
16
|
+
const path = new Array();
|
|
17
|
+
let node = tree;
|
|
18
|
+
if (positionals[0] !== "help") for (const positional of positionals) {
|
|
19
|
+
const child = node.children[positional];
|
|
20
|
+
if (!child) break;
|
|
21
|
+
node = child;
|
|
22
|
+
path.push(positional);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
tree: node,
|
|
26
|
+
path,
|
|
27
|
+
command: node.value
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function formatSection(title, entries) {
|
|
31
|
+
if (entries.length === 0) return [];
|
|
32
|
+
const width = Math.max(...entries.map((entry) => entry.name.length));
|
|
33
|
+
return [
|
|
34
|
+
"",
|
|
35
|
+
`${title}:`,
|
|
36
|
+
...entries.map((entry) => ` ${entry.name.padEnd(width)} ${entry.description ?? ""}`.trimEnd())
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
function formatFlag(flag) {
|
|
40
|
+
return [flag.short ? `-${flag.short}` : void 0, flag.type === "string" ? `--${flag.name}=<value>${flag.multiple ? "..." : ""}` : `--${flag.name}`].filter(Boolean).join(", ");
|
|
41
|
+
}
|
|
42
|
+
function formatHelp(options) {
|
|
43
|
+
const flags = new Array();
|
|
44
|
+
for (const [name, descriptor] of Object.entries(options.match.command?.arguments ?? {})) flags.push({
|
|
13
45
|
name,
|
|
14
46
|
description: descriptor.description,
|
|
15
47
|
multiple: descriptor.multiple,
|
|
16
48
|
short: descriptor.short,
|
|
17
49
|
type: descriptor.type
|
|
18
50
|
});
|
|
19
|
-
|
|
51
|
+
flags.push({
|
|
20
52
|
name: "help",
|
|
21
53
|
description: "Show help",
|
|
22
54
|
short: "h",
|
|
23
55
|
type: "boolean"
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
short: "e",
|
|
28
|
-
type: "string"
|
|
29
|
-
});
|
|
30
|
-
const commandMeta = new Array();
|
|
31
|
-
for (const [name, child] of Object.entries(node.children)) {
|
|
56
|
+
}, ...options.flags ?? []);
|
|
57
|
+
const commands = new Array();
|
|
58
|
+
for (const [name, child] of Object.entries(options.match.tree.children)) {
|
|
32
59
|
let target = child;
|
|
33
60
|
while (target && !target.value) target = Object.values(target.children)[0];
|
|
34
|
-
|
|
61
|
+
commands.push({
|
|
35
62
|
name,
|
|
36
63
|
description: target?.value?.description
|
|
37
64
|
});
|
|
38
65
|
}
|
|
39
|
-
|
|
40
|
-
commandMeta.sort((a, b) => a.name.localeCompare(b.name));
|
|
66
|
+
commands.sort((a, b) => a.name.localeCompare(b.name));
|
|
41
67
|
const lines = new Array();
|
|
42
|
-
lines.push(`Usage: ${[
|
|
43
|
-
const description = command?.description ?? (path.length === 0 ?
|
|
68
|
+
lines.push(`Usage: ${[options.name, ...options.match.path].join(" ")} [flags]${commands.length > 0 ? " [command]" : ""}`);
|
|
69
|
+
const description = options.match.command?.description ?? (options.match.path.length === 0 ? options.description : void 0);
|
|
44
70
|
if (description) lines.push("", description);
|
|
45
|
-
|
|
46
|
-
|
|
71
|
+
for (const [title, entries] of Object.entries(options.sections ?? {})) lines.push(...formatSection(title, entries));
|
|
72
|
+
lines.push(...formatSection("Flags", flags.map((flag) => ({
|
|
73
|
+
name: formatFlag(flag),
|
|
47
74
|
description: flag.description
|
|
48
|
-
}))), ...
|
|
49
|
-
|
|
75
|
+
}))), ...formatSection("Commands", commands));
|
|
76
|
+
return lines.join("\n");
|
|
50
77
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
78
|
+
function parseCommand(command, args, path) {
|
|
79
|
+
const consumable = [...path];
|
|
80
|
+
return parseArgs({
|
|
81
|
+
args: args.filter((argument) => {
|
|
82
|
+
const index = consumable.indexOf(argument);
|
|
83
|
+
if (index === -1) return true;
|
|
84
|
+
consumable.splice(index, 1);
|
|
85
|
+
return false;
|
|
86
|
+
}),
|
|
87
|
+
strict: false,
|
|
88
|
+
allowPositionals: true,
|
|
89
|
+
options: {
|
|
90
|
+
...command.arguments,
|
|
91
|
+
help: {
|
|
92
|
+
type: "boolean",
|
|
93
|
+
short: "h",
|
|
94
|
+
description: "Show this help"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
59
98
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
help: {
|
|
99
|
+
async function runCommands(options) {
|
|
100
|
+
const parsed = parseArgs({
|
|
101
|
+
args: options.args,
|
|
102
|
+
strict: false,
|
|
103
|
+
allowPositionals: true,
|
|
104
|
+
options: { help: {
|
|
67
105
|
type: "boolean",
|
|
68
106
|
short: "h",
|
|
69
107
|
default: false
|
|
70
|
-
},
|
|
71
|
-
environment: {
|
|
72
|
-
type: "string",
|
|
73
|
-
short: "e"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
var server = await createServer({
|
|
78
|
-
appType: "custom",
|
|
79
|
-
environments: { command: {
|
|
80
|
-
consumer: "server",
|
|
81
|
-
dev: { createEnvironment(name, config) {
|
|
82
|
-
return createRunnableDevEnvironment(name, config);
|
|
83
108
|
} }
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
109
|
+
});
|
|
110
|
+
const helpRequested = parsed.values.help === true || parsed.positionals[0] === "help";
|
|
111
|
+
const match = findCommand(options.tree, parsed.positionals);
|
|
112
|
+
const help = () => {
|
|
113
|
+
console.log(formatHelp({
|
|
114
|
+
name: options.name,
|
|
115
|
+
description: options.description,
|
|
116
|
+
match,
|
|
117
|
+
flags: options.flags,
|
|
118
|
+
sections: options.sections
|
|
119
|
+
}));
|
|
120
|
+
};
|
|
121
|
+
if (!match.command || helpRequested) {
|
|
122
|
+
help();
|
|
123
|
+
return helpRequested || match.command ? 0 : 1;
|
|
88
124
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (!environment || !isRunnableDevEnvironment(environment)) {
|
|
92
|
-
await server.close();
|
|
93
|
-
throw new Error(typeof parsed.values.environment === "string" ? `No runnable environment named "${parsed.values.environment}" found.` : "No runnable Vite environment found.");
|
|
94
|
-
}
|
|
95
|
-
var commands = await environment.runner.import("#commands").then((module) => module.default);
|
|
96
|
-
var radix = { children: {} };
|
|
97
|
-
for (const source of Object.values(commands)) for (const [path, value] of Object.entries(source)) {
|
|
98
|
-
let node = radix;
|
|
99
|
-
for (const segment of path.replace(/\\/g, "/").split("/")) node = node.children[segment] ??= { children: {} };
|
|
100
|
-
node.value = await value();
|
|
101
|
-
}
|
|
102
|
-
var helpRequested = parsed.values.help === true || parsed.positionals[0] === "help";
|
|
103
|
-
var path = new Array();
|
|
104
|
-
var node = radix;
|
|
105
|
-
if (parsed.positionals[0] !== "help") for (const positional of parsed.positionals) {
|
|
106
|
-
const child = node.children[positional];
|
|
107
|
-
if (!child) break;
|
|
108
|
-
node = child;
|
|
109
|
-
path.push(positional);
|
|
110
|
-
}
|
|
111
|
-
var command = node.value;
|
|
112
|
-
try {
|
|
113
|
-
if (command && !helpRequested) {
|
|
114
|
-
const consumable = [...path];
|
|
115
|
-
const context = parseArgs({
|
|
116
|
-
args: args.filter((argument) => {
|
|
117
|
-
const index = consumable.indexOf(argument);
|
|
118
|
-
if (index === -1) return true;
|
|
119
|
-
consumable.splice(index, 1);
|
|
120
|
-
return false;
|
|
121
|
-
}),
|
|
122
|
-
strict: false,
|
|
123
|
-
allowPositionals: true,
|
|
124
|
-
options: {
|
|
125
|
-
...command.arguments,
|
|
126
|
-
help: {
|
|
127
|
-
type: "boolean",
|
|
128
|
-
short: "h",
|
|
129
|
-
description: "Show this help"
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
if (context.values.help) help();
|
|
134
|
-
else {
|
|
135
|
-
const { createScope, VARIABLE_CONTEXT } = await environment.runner.import("revojs");
|
|
136
|
-
await command.run(await createScope({ context: { [VARIABLE_CONTEXT]: loadEnv(environment.config.mode, environment.config.envDir, "") } }), {
|
|
137
|
-
input: context.positionals,
|
|
138
|
-
arguments: context.values,
|
|
139
|
-
environment
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
125
|
+
const context = parseCommand(match.command, options.args, match.path);
|
|
126
|
+
if (context.values.help) {
|
|
143
127
|
help();
|
|
144
|
-
|
|
128
|
+
return 0;
|
|
145
129
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
130
|
+
await options.run(match.command, {
|
|
131
|
+
input: context.positionals,
|
|
132
|
+
arguments: context.values
|
|
133
|
+
});
|
|
134
|
+
return 0;
|
|
151
135
|
}
|
|
152
136
|
//#endregion
|
|
153
|
-
export {};
|
|
137
|
+
export { createCommandTree, defineCommand, findCommand, formatFlag, formatHelp, formatSection, parseCommand, runCommands };
|
package/dist/module/index.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import type { parseArgs } from "node:util";
|
|
2
|
-
import { type ParseArgsOptionDescriptor, type ParseArgsOptionsConfig } from "node:util";
|
|
3
|
-
import type { RunnableDevEnvironment } from "vite";
|
|
4
1
|
import { type PluginOption, type UserConfig } from "vite";
|
|
5
|
-
import type { Scope } from "../scope/index.ts";
|
|
6
2
|
import { type Awaitable, type Mergeable } from "../shared/index.ts";
|
|
7
|
-
export type CommandValues<T extends ParseArgsOptionsConfig> = ReturnType<typeof parseArgs<{
|
|
8
|
-
options: T;
|
|
9
|
-
allowPositionals: true;
|
|
10
|
-
strict: true;
|
|
11
|
-
}>>["values"];
|
|
12
3
|
export type Consumer = "client" | "server";
|
|
13
4
|
export type Template = (consumer: Consumer) => Awaitable<undefined | string>;
|
|
14
5
|
export type Variable = StringVariable | NumberVariable | BooleanVariable | EnumVariable;
|
|
@@ -31,20 +22,6 @@ export type ModuleInput<TModules extends ReadonlyArray<Module>> = Mergeable<Conf
|
|
|
31
22
|
modules?: TModules;
|
|
32
23
|
};
|
|
33
24
|
export type ModuleSetupResult<TName extends string, TConfig, TDependencies extends ReadonlyArray<Module> = []> = void | (Mergeable<Config> & Mergeable<Record<TName, TConfig>> & Mergeable<InferModuleConfigs<TDependencies>>);
|
|
34
|
-
export interface CommandArgument extends ParseArgsOptionDescriptor {
|
|
35
|
-
description?: string;
|
|
36
|
-
}
|
|
37
|
-
export type CommandArguments = ParseArgsOptionsConfig & Record<string, CommandArgument>;
|
|
38
|
-
export interface CommandContext<T extends ParseArgsOptionsConfig = ParseArgsOptionsConfig> {
|
|
39
|
-
input: Array<string>;
|
|
40
|
-
arguments: CommandValues<T>;
|
|
41
|
-
environment: RunnableDevEnvironment;
|
|
42
|
-
}
|
|
43
|
-
export interface Command<T extends ParseArgsOptionsConfig = ParseArgsOptionsConfig> {
|
|
44
|
-
description?: string;
|
|
45
|
-
arguments?: T;
|
|
46
|
-
run: (scope: Scope, context: CommandContext<T>) => Awaitable<void>;
|
|
47
|
-
}
|
|
48
25
|
export type SourceFormat = "object" | "named";
|
|
49
26
|
export interface Source {
|
|
50
27
|
from: Array<string>;
|
|
@@ -101,7 +78,6 @@ export interface ModuleDefinition<TName extends string, TConfig = Record<string,
|
|
|
101
78
|
modules?: TDependencies;
|
|
102
79
|
setup: (config: Config & Record<TName, TConfig> & InferModuleConfigs<TDependencies>) => Awaitable<ModuleSetupResult<TName, TConfig, TDependencies>>;
|
|
103
80
|
}
|
|
104
|
-
export declare function defineCommand<const T extends ParseArgsOptionsConfig>(command: Command<T>): Command<T>;
|
|
105
81
|
export declare function defineModule<const TName extends string, TConfig = Record<string, never>, const TDependencies extends ReadonlyArray<Module> = []>(definition: ModuleDefinition<TName, TConfig, TDependencies>): Module<TName, TConfig, TDependencies>;
|
|
106
82
|
export declare function addVirtual(config: Config, name: string, virtual: Template): void;
|
|
107
83
|
export declare function addTemplate(config: Config, name: string, template: Template): void;
|
package/dist/module/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { mergeObjects, toExportNames } from "../shared/index.js";
|
|
|
3
3
|
import package_default from "../package.js";
|
|
4
4
|
import { findPackageJSON } from "node:module";
|
|
5
5
|
import { spawnSync } from "child_process";
|
|
6
|
-
import { copyFileSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "fs";
|
|
6
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "fs";
|
|
7
7
|
import { createRequire } from "module";
|
|
8
8
|
import { globSync } from "node:fs";
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
@@ -11,9 +11,6 @@ import { dirname, extname, isAbsolute, join, posix, relative, resolve, win32 } f
|
|
|
11
11
|
import { fileURLToPath } from "url";
|
|
12
12
|
import "vite";
|
|
13
13
|
//#region src/module/index.ts
|
|
14
|
-
function defineCommand(command) {
|
|
15
|
-
return command;
|
|
16
|
-
}
|
|
17
14
|
function defineModule(definition) {
|
|
18
15
|
return definition;
|
|
19
16
|
}
|
|
@@ -359,7 +356,7 @@ async function revojs(inputConfig) {
|
|
|
359
356
|
builder: {
|
|
360
357
|
sharedConfigBuild: true,
|
|
361
358
|
async buildApp(builder) {
|
|
362
|
-
for (const environment of Object.values(builder.environments)) if (environment.config.consumer === "client") await builder.build(environment);
|
|
359
|
+
for (const environment of Object.values(builder.environments)) if (environment.config.consumer === "client" && (environment.config.build.rolldownOptions.input !== void 0 || existsSync(resolve(environment.config.root, "index.html")))) await builder.build(environment);
|
|
363
360
|
for (const environment of Object.values(builder.environments)) if (environment.config.consumer === "server") await builder.build(environment);
|
|
364
361
|
}
|
|
365
362
|
}
|
|
@@ -400,4 +397,4 @@ async function revojs(inputConfig) {
|
|
|
400
397
|
}
|
|
401
398
|
var PACKAGE_CACHE = /* @__PURE__ */ new Map();
|
|
402
399
|
//#endregion
|
|
403
|
-
export { addTemplate, addTypes, addVirtual, core, createConfig,
|
|
400
|
+
export { addTemplate, addTypes, addVirtual, core, createConfig, defineModule, matchesConsumer, module, posixPath, resolveFrameworkPackages, resolvePaths, resolvePattern, resolveSource, revojs, useModule };
|
package/dist/package.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
//#region package.json
|
|
2
2
|
var name = "revojs";
|
|
3
|
-
var version = "0.2.
|
|
3
|
+
var version = "0.2.45";
|
|
4
4
|
var repository = {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/tellua/revojs.git"
|
|
7
7
|
};
|
|
8
|
-
var bin = { "revojs": "dist/
|
|
8
|
+
var bin = { "revojs": "dist/bin/index.js" };
|
|
9
9
|
var files = ["dist", "src/types"];
|
|
10
10
|
var type = "module";
|
|
11
11
|
var main = "./dist/index.js";
|
|
@@ -16,6 +16,10 @@ var exports = {
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"import": "./dist/index.js"
|
|
18
18
|
},
|
|
19
|
+
"./commands": {
|
|
20
|
+
"types": "./dist/commands/index.d.ts",
|
|
21
|
+
"import": "./dist/commands/index.js"
|
|
22
|
+
},
|
|
19
23
|
"./module": {
|
|
20
24
|
"types": "./dist/module/index.d.ts",
|
|
21
25
|
"import": "./dist/module/index.js"
|
package/dist/types/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare module "#hooks" {
|
|
|
21
21
|
|
|
22
22
|
declare module "#commands" {
|
|
23
23
|
import type { Source } from "revojs";
|
|
24
|
-
import type { Command } from "revojs/
|
|
24
|
+
import type { Command } from "revojs/commands";
|
|
25
25
|
|
|
26
26
|
const entries: Source<Command>;
|
|
27
27
|
export default entries;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "revojs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.45",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/tellua/revojs.git"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
|
-
"revojs": "dist/
|
|
10
|
+
"revojs": "dist/bin/index.js"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"import": "./dist/index.js"
|
|
25
25
|
},
|
|
26
|
+
"./commands": {
|
|
27
|
+
"types": "./dist/commands/index.d.ts",
|
|
28
|
+
"import": "./dist/commands/index.js"
|
|
29
|
+
},
|
|
26
30
|
"./module": {
|
|
27
31
|
"types": "./dist/module/index.d.ts",
|
|
28
32
|
"import": "./dist/module/index.js"
|
package/src/types/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare module "#hooks" {
|
|
|
21
21
|
|
|
22
22
|
declare module "#commands" {
|
|
23
23
|
import type { Source } from "revojs";
|
|
24
|
-
import type { Command } from "revojs/
|
|
24
|
+
import type { Command } from "revojs/commands";
|
|
25
25
|
|
|
26
26
|
const entries: Source<Command>;
|
|
27
27
|
export default entries;
|