commandkit 0.1.11-dev.20250406115909 → 0.1.11-dev.20250408053600
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 +30 -1
- package/dist/index.js +121 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1717,6 +1717,35 @@ interface CommandKitConfiguration {
|
|
|
1717
1717
|
getMessageCommandPrefix: (message: Message$1) => Awaitable<string | string[]>;
|
|
1718
1718
|
}
|
|
1719
1719
|
declare let commandkit: CommandKit;
|
|
1720
|
+
type BootstrapFunction = GenericFunction<[CommandKit]> | AsyncFunction<[CommandKit]>;
|
|
1721
|
+
/**
|
|
1722
|
+
* Registers a bootstrap hook that will be called when the CommandKit instance is created.
|
|
1723
|
+
* This is useful for plugins that need to run some code after the CommandKit instance is fully initialized.
|
|
1724
|
+
* Note that not all commandkit dependiencs are available at this point. It is recommended to use the `onApplicationBootstrap` hook instead,
|
|
1725
|
+
* if you need access to the commandkit dependencies.
|
|
1726
|
+
* @param fn The bootstrap function to register.
|
|
1727
|
+
* @example ```ts
|
|
1728
|
+
* import { onBootstrap } from 'commandkit';
|
|
1729
|
+
*
|
|
1730
|
+
* onBootstrap(async (commandkit) => {
|
|
1731
|
+
* // Do something with the commandkit instance
|
|
1732
|
+
* })
|
|
1733
|
+
* ```
|
|
1734
|
+
*/
|
|
1735
|
+
declare function onBootstrap<F extends BootstrapFunction>(fn: F): void;
|
|
1736
|
+
/**
|
|
1737
|
+
* Registers a bootstrap hook that will be called when the CommandKit instance is created.
|
|
1738
|
+
* This is useful for plugins that need to run some code after the CommandKit instance is fully initialized.
|
|
1739
|
+
* @param fn The bootstrap function to register.
|
|
1740
|
+
* @example ```ts
|
|
1741
|
+
* import { onApplicationBootstrap } from 'commandkit';
|
|
1742
|
+
*
|
|
1743
|
+
* onApplicationBootstrap(async (commandkit) => {
|
|
1744
|
+
* // Do something with the commandkit instance
|
|
1745
|
+
* })
|
|
1746
|
+
* ```
|
|
1747
|
+
*/
|
|
1748
|
+
declare function onApplicationBootstrap<F extends BootstrapFunction>(fn: F): void;
|
|
1720
1749
|
declare class CommandKit extends EventEmitter {
|
|
1721
1750
|
#private;
|
|
1722
1751
|
private readonly options;
|
|
@@ -1970,4 +1999,4 @@ declare function devOnly<T extends (...args: any[]) => any>(fn: T): T;
|
|
|
1970
1999
|
*/
|
|
1971
2000
|
declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
|
|
1972
2001
|
|
|
1973
|
-
export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, COMMANDKIT_BOOTSTRAP_MODE, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, type CacheContext, type CacheEntry, type CacheMetadata, CacheProvider, ChannelSelectMenu, ChannelSelectMenuKit, type ChannelSelectMenuKitPredicate, type ChannelSelectMenuProps, type Command, type CommandBuilderLike, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, CommandKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd, type CommandKitConfiguration, type CommandKitElement, type CommandKitElementData, CommandKitEnvironment, type CommandKitEnvironmentInternalData, CommandKitEnvironmentType, type CommandKitHMREvent, type CommandKitLoggerOptions, type CommandKitModalBuilderInteractionCollectorDispatch, type CommandKitModalBuilderInteractionCollectorDispatchContextData, type CommandKitModalBuilderOnEnd, type CommandKitOptions, type CommandKitPlugin, CommandKitPluginRuntime, type CommandKitSelectMenuBuilderInteractionCollectorDispatch, type CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, type CommandKitSelectMenuBuilderOnEnd, CommandRegistrar, type CommandSource, type CommandTypeData, CommandsRouter, type CommandsRouterOptions, type CommonBuilderKit, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Context, type ContextParameters, DefaultLogger, ElementType, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, EventsRouter, type EventsRouterOptions, type EventsTree, Fragment, type FragmentElementProps, type GenericFunction, HMREventType, type ILogger, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, type Loader, type Location, Logger, type LoggerImpl, type MaybeArray, type MaybeFalsey, MemoryCache, MentionableSelectMenu, MentionableSelectMenuKit, type MentionableSelectMenuKitPredicate, type MentionableSelectMenuProps, type Message, type MessageCommand, type MessageCommandContext, type MessageCommandMiddlewareContext, MessageCommandOptions, type MessageCommandOptionsSchema, MessageCommandParser, type MessageContextMenuCommand, type MessageContextMenuCommandContext, type MessageContextMenuCommandMiddlewareContext, type Middleware, MiddlewareContext, type MiddlewareContextArgs, Modal, ModalKit, type ModalKitPredicate, type ModalProps, type OnButtonKitClick, type OnButtonKitEnd, type OnChannelSelectMenuKitSubmit, type OnLoadArgs, type OnLoadOptions, type OnLoadResult, type OnMentionableSelectMenuKitSubmit, type OnModalKitEnd, type OnModalKitSubmit, type OnResolveArgs, type OnResolveOptions, type OnResolveResult, type OnRoleSelectMenuKitSubmit, type OnSelectMenuKitEnd, type OnSelectMenuKitSubmit, type OnStringSelectMenuKitSubmit, type OnUserSelectMenuKitSubmit, ParagraphInput, type ParsedCommandData, type ParsedEvent, type ParsedMessageCommand, type PluginTransformParameters, type PreRegisterCommandsEvent, type PreparedAppCommandExecution, type ResolvableCommand, type ResolveBuilderInteraction, type ResolveKind, type ResolveResult, RoleSelectMenu, RoleSelectMenuKit, type RoleSelectMenuKitPredicate, type RoleSelectMenuProps, type RunCommand, RuntimePlugin, type SelectMenuKitPredicate, type SelectMenuProps, type Setup, ShortInput, type SlashCommand, type SlashCommandContext, type SlashCommandMiddlewareContext, StringSelectMenu, StringSelectMenuKit, type StringSelectMenuKitPredicate, StringSelectMenuOption, type StringSelectMenuOptionProps, type StringSelectMenuProps, TextInput, type TextInputProps, type TransformedResult, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, type UserSelectMenuKitPredicate, type UserSelectMenuProps, afterCommand, bootstrapCommandkitCLI, cache, cacheLife, cacheTag, cancelAfterCommand, commandkit, createElement, createLogger, debounce, CommandKit as default, defineConfig, devOnly, exitContext, exitMiddleware, fromEsbuildPlugin, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getSourceDirectories, invalidate, isCachedFunction, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, makeContextAwareFunction, provideContext, redirect, rethrow, revalidate, useEnvironment, version, zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired };
|
|
2002
|
+
export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, type BootstrapFunction, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, COMMANDKIT_BOOTSTRAP_MODE, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, type CacheContext, type CacheEntry, type CacheMetadata, CacheProvider, ChannelSelectMenu, ChannelSelectMenuKit, type ChannelSelectMenuKitPredicate, type ChannelSelectMenuProps, type Command, type CommandBuilderLike, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, CommandKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd, type CommandKitConfiguration, type CommandKitElement, type CommandKitElementData, CommandKitEnvironment, type CommandKitEnvironmentInternalData, CommandKitEnvironmentType, type CommandKitHMREvent, type CommandKitLoggerOptions, type CommandKitModalBuilderInteractionCollectorDispatch, type CommandKitModalBuilderInteractionCollectorDispatchContextData, type CommandKitModalBuilderOnEnd, type CommandKitOptions, type CommandKitPlugin, CommandKitPluginRuntime, type CommandKitSelectMenuBuilderInteractionCollectorDispatch, type CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, type CommandKitSelectMenuBuilderOnEnd, CommandRegistrar, type CommandSource, type CommandTypeData, CommandsRouter, type CommandsRouterOptions, type CommonBuilderKit, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Context, type ContextParameters, DefaultLogger, ElementType, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, EventsRouter, type EventsRouterOptions, type EventsTree, Fragment, type FragmentElementProps, type GenericFunction, HMREventType, type ILogger, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, type Loader, type Location, Logger, type LoggerImpl, type MaybeArray, type MaybeFalsey, MemoryCache, MentionableSelectMenu, MentionableSelectMenuKit, type MentionableSelectMenuKitPredicate, type MentionableSelectMenuProps, type Message, type MessageCommand, type MessageCommandContext, type MessageCommandMiddlewareContext, MessageCommandOptions, type MessageCommandOptionsSchema, MessageCommandParser, type MessageContextMenuCommand, type MessageContextMenuCommandContext, type MessageContextMenuCommandMiddlewareContext, type Middleware, MiddlewareContext, type MiddlewareContextArgs, Modal, ModalKit, type ModalKitPredicate, type ModalProps, type OnButtonKitClick, type OnButtonKitEnd, type OnChannelSelectMenuKitSubmit, type OnLoadArgs, type OnLoadOptions, type OnLoadResult, type OnMentionableSelectMenuKitSubmit, type OnModalKitEnd, type OnModalKitSubmit, type OnResolveArgs, type OnResolveOptions, type OnResolveResult, type OnRoleSelectMenuKitSubmit, type OnSelectMenuKitEnd, type OnSelectMenuKitSubmit, type OnStringSelectMenuKitSubmit, type OnUserSelectMenuKitSubmit, ParagraphInput, type ParsedCommandData, type ParsedEvent, type ParsedMessageCommand, type PluginTransformParameters, type PreRegisterCommandsEvent, type PreparedAppCommandExecution, type ResolvableCommand, type ResolveBuilderInteraction, type ResolveKind, type ResolveResult, RoleSelectMenu, RoleSelectMenuKit, type RoleSelectMenuKitPredicate, type RoleSelectMenuProps, type RunCommand, RuntimePlugin, type SelectMenuKitPredicate, type SelectMenuProps, type Setup, ShortInput, type SlashCommand, type SlashCommandContext, type SlashCommandMiddlewareContext, StringSelectMenu, StringSelectMenuKit, type StringSelectMenuKitPredicate, StringSelectMenuOption, type StringSelectMenuOptionProps, type StringSelectMenuProps, TextInput, type TextInputProps, type TransformedResult, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, type UserSelectMenuKitPredicate, type UserSelectMenuProps, afterCommand, bootstrapCommandkitCLI, cache, cacheLife, cacheTag, cancelAfterCommand, commandkit, createElement, createLogger, debounce, CommandKit as default, defineConfig, devOnly, exitContext, exitMiddleware, fromEsbuildPlugin, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getSourceDirectories, invalidate, isCachedFunction, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, redirect, rethrow, revalidate, useEnvironment, version, zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired };
|
package/dist/index.js
CHANGED
|
@@ -4249,9 +4249,9 @@ var init_AppCommandRunner = __esm({
|
|
|
4249
4249
|
});
|
|
4250
4250
|
|
|
4251
4251
|
// src/utils/types-package.ts
|
|
4252
|
-
async function generateTypesPackage() {
|
|
4252
|
+
async function generateTypesPackage(force = false) {
|
|
4253
4253
|
const location = (0, import_node_path2.join)(process.cwd(), "node_modules", "commandkit-types");
|
|
4254
|
-
if (!COMMANDKIT_IS_DEV) return location;
|
|
4254
|
+
if (!COMMANDKIT_IS_DEV && !force) return location;
|
|
4255
4255
|
const packageJSON = (0, import_node_path2.join)(location, "package.json");
|
|
4256
4256
|
const index = (0, import_node_path2.join)(location, "index.js");
|
|
4257
4257
|
const types = (0, import_node_path2.join)(location, "index.d.ts");
|
|
@@ -5095,12 +5095,52 @@ async function ensureTypeScript(target) {
|
|
|
5095
5095
|
await loadTypeScript();
|
|
5096
5096
|
return true;
|
|
5097
5097
|
}
|
|
5098
|
+
function detectPackageManager() {
|
|
5099
|
+
if (packageManager) return packageManager;
|
|
5100
|
+
const lockfiles = {
|
|
5101
|
+
"yarn.lock": "yarn",
|
|
5102
|
+
"pnpm-lock.yaml": "pnpm",
|
|
5103
|
+
"package-lock.json": "npm",
|
|
5104
|
+
"bun.lock": "bun",
|
|
5105
|
+
"bun.lockb": "bun"
|
|
5106
|
+
};
|
|
5107
|
+
for (const [lockfile, manager] of Object.entries(lockfiles)) {
|
|
5108
|
+
if (import_node_fs5.default.existsSync((0, import_node_path5.join)(process.cwd(), lockfile))) {
|
|
5109
|
+
packageManager = manager;
|
|
5110
|
+
break;
|
|
5111
|
+
}
|
|
5112
|
+
}
|
|
5113
|
+
if (!packageManager) {
|
|
5114
|
+
packageManager = "npm";
|
|
5115
|
+
}
|
|
5116
|
+
return packageManager;
|
|
5117
|
+
}
|
|
5098
5118
|
async function loadTypeScript(e) {
|
|
5099
5119
|
if (ts) return ts;
|
|
5100
5120
|
try {
|
|
5101
5121
|
ts = await import("typescript");
|
|
5102
|
-
} catch {
|
|
5103
|
-
|
|
5122
|
+
} catch (e2) {
|
|
5123
|
+
if (e2 instanceof Error && "code" in e2 && e2.code === "MODULE_NOT_FOUND") {
|
|
5124
|
+
try {
|
|
5125
|
+
const packageManager2 = detectPackageManager();
|
|
5126
|
+
(0, import_node_child_process.execSync)(`${packageManager2} add typescript`, {
|
|
5127
|
+
stdio: "inherit",
|
|
5128
|
+
cwd: process.cwd()
|
|
5129
|
+
});
|
|
5130
|
+
console.log(
|
|
5131
|
+
colors_default.cyan(
|
|
5132
|
+
`TypeScript has been installed automatically, restarting...`
|
|
5133
|
+
)
|
|
5134
|
+
);
|
|
5135
|
+
ts = await import("typescript");
|
|
5136
|
+
return ts;
|
|
5137
|
+
} catch {
|
|
5138
|
+
panic(
|
|
5139
|
+
"TypeScript is not installed and could not be installed automatically. Please install it manually."
|
|
5140
|
+
);
|
|
5141
|
+
}
|
|
5142
|
+
}
|
|
5143
|
+
panic(e2 || "TypeScript must be installed to use TypeScript config files.");
|
|
5104
5144
|
}
|
|
5105
5145
|
return ts;
|
|
5106
5146
|
}
|
|
@@ -5154,7 +5194,7 @@ async function copyLocaleFiles(_from, _to) {
|
|
|
5154
5194
|
});
|
|
5155
5195
|
}
|
|
5156
5196
|
}
|
|
5157
|
-
var import_rimraf, import_node_path5, import_node_fs5, ts;
|
|
5197
|
+
var import_rimraf, import_node_path5, import_node_fs5, import_node_child_process, ts, packageManager;
|
|
5158
5198
|
var init_common2 = __esm({
|
|
5159
5199
|
"src/cli/common.ts"() {
|
|
5160
5200
|
"use strict";
|
|
@@ -5164,9 +5204,11 @@ var init_common2 = __esm({
|
|
|
5164
5204
|
import_node_fs5 = __toESM(require("fs"));
|
|
5165
5205
|
init_colors();
|
|
5166
5206
|
init_types_package();
|
|
5207
|
+
import_node_child_process = require("child_process");
|
|
5167
5208
|
__name(write, "write");
|
|
5168
5209
|
__name(panic, "panic");
|
|
5169
5210
|
__name(ensureTypeScript, "ensureTypeScript");
|
|
5211
|
+
__name(detectPackageManager, "detectPackageManager");
|
|
5170
5212
|
__name(loadTypeScript, "loadTypeScript");
|
|
5171
5213
|
__name(loadConfigFileFromPath, "loadConfigFileFromPath");
|
|
5172
5214
|
__name(ensureExists, "ensureExists");
|
|
@@ -5331,7 +5373,13 @@ var init_CommandKitEventsChannel = __esm({
|
|
|
5331
5373
|
});
|
|
5332
5374
|
|
|
5333
5375
|
// src/CommandKit.ts
|
|
5334
|
-
|
|
5376
|
+
function onBootstrap(fn) {
|
|
5377
|
+
bootstrapHooks.add(fn);
|
|
5378
|
+
}
|
|
5379
|
+
function onApplicationBootstrap(fn) {
|
|
5380
|
+
onApplicationBootstrapHooks.add(fn);
|
|
5381
|
+
}
|
|
5382
|
+
var import_node_events2, import_discord19, import_node_path7, import_node_fs7, commandkit, bootstrapHooks, onApplicationBootstrapHooks, _started, _CommandKit_instances, bootstrapHooks_fn, applicationBootstrapHooks_fn, init_fn, initCommands_fn, initEvents_fn, _CommandKit, CommandKit;
|
|
5335
5383
|
var init_CommandKit = __esm({
|
|
5336
5384
|
"src/CommandKit.ts"() {
|
|
5337
5385
|
"use strict";
|
|
@@ -5357,6 +5405,10 @@ var init_CommandKit = __esm({
|
|
|
5357
5405
|
init_plugins();
|
|
5358
5406
|
init_types_package();
|
|
5359
5407
|
init_Logger();
|
|
5408
|
+
bootstrapHooks = /* @__PURE__ */ new Set();
|
|
5409
|
+
onApplicationBootstrapHooks = /* @__PURE__ */ new Set();
|
|
5410
|
+
__name(onBootstrap, "onBootstrap");
|
|
5411
|
+
__name(onApplicationBootstrap, "onApplicationBootstrap");
|
|
5360
5412
|
_CommandKit = class _CommandKit extends import_node_events2.default {
|
|
5361
5413
|
/**
|
|
5362
5414
|
* Create a new command and event handler with CommandKit.
|
|
@@ -5401,6 +5453,7 @@ var init_CommandKit = __esm({
|
|
|
5401
5453
|
_CommandKit.instance = this;
|
|
5402
5454
|
}
|
|
5403
5455
|
commandkit = _CommandKit.instance;
|
|
5456
|
+
__privateMethod(this, _CommandKit_instances, bootstrapHooks_fn).call(this);
|
|
5404
5457
|
}
|
|
5405
5458
|
/**
|
|
5406
5459
|
* Starts the commandkit application.
|
|
@@ -5436,9 +5489,8 @@ var init_CommandKit = __esm({
|
|
|
5436
5489
|
var _a;
|
|
5437
5490
|
return (_a = plugin.onBeforeClientLogin) == null ? void 0 : _a.call(plugin, ctx);
|
|
5438
5491
|
});
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
);
|
|
5492
|
+
const botToken = token ?? this.options.client.token ?? process.env.TOKEN ?? process.env.DISCORD_TOKEN;
|
|
5493
|
+
await this.options.client.login(botToken);
|
|
5442
5494
|
await this.plugins.execute((ctx, plugin) => {
|
|
5443
5495
|
var _a;
|
|
5444
5496
|
return (_a = plugin.onAfterClientLogin) == null ? void 0 : _a.call(plugin, ctx);
|
|
@@ -5447,6 +5499,7 @@ var init_CommandKit = __esm({
|
|
|
5447
5499
|
await this.commandHandler.registrar.register();
|
|
5448
5500
|
}
|
|
5449
5501
|
__privateSet(this, _started, true);
|
|
5502
|
+
await __privateMethod(this, _CommandKit_instances, applicationBootstrapHooks_fn).call(this);
|
|
5450
5503
|
}
|
|
5451
5504
|
/**
|
|
5452
5505
|
* Loads all the plugins.
|
|
@@ -5559,6 +5612,30 @@ var init_CommandKit = __esm({
|
|
|
5559
5612
|
};
|
|
5560
5613
|
_started = new WeakMap();
|
|
5561
5614
|
_CommandKit_instances = new WeakSet();
|
|
5615
|
+
bootstrapHooks_fn = /* @__PURE__ */ __name(async function() {
|
|
5616
|
+
for (const hook of bootstrapHooks) {
|
|
5617
|
+
try {
|
|
5618
|
+
await hook(this);
|
|
5619
|
+
} catch (e) {
|
|
5620
|
+
Logger.error("Error while executing bootstrap hook: ", e);
|
|
5621
|
+
} finally {
|
|
5622
|
+
bootstrapHooks.delete(hook);
|
|
5623
|
+
}
|
|
5624
|
+
}
|
|
5625
|
+
bootstrapHooks.clear();
|
|
5626
|
+
}, "#bootstrapHooks");
|
|
5627
|
+
applicationBootstrapHooks_fn = /* @__PURE__ */ __name(async function() {
|
|
5628
|
+
for (const hook of onApplicationBootstrapHooks) {
|
|
5629
|
+
try {
|
|
5630
|
+
await hook(this);
|
|
5631
|
+
} catch (e) {
|
|
5632
|
+
Logger.error("Error while executing application bootstrap hook: ", e);
|
|
5633
|
+
} finally {
|
|
5634
|
+
onApplicationBootstrapHooks.delete(hook);
|
|
5635
|
+
}
|
|
5636
|
+
}
|
|
5637
|
+
onApplicationBootstrapHooks.clear();
|
|
5638
|
+
}, "#applicationBootstrapHooks");
|
|
5562
5639
|
init_fn = /* @__PURE__ */ __name(async function() {
|
|
5563
5640
|
const appDir2 = this.getAppDirectory();
|
|
5564
5641
|
if (!appDir2) return;
|
|
@@ -5617,16 +5694,26 @@ var init_version = __esm({
|
|
|
5617
5694
|
"use strict";
|
|
5618
5695
|
init_cjs_shims();
|
|
5619
5696
|
version = /* @__MACRO__ $version */
|
|
5620
|
-
"0.1.11-dev.
|
|
5697
|
+
"0.1.11-dev.20250408053600";
|
|
5621
5698
|
}
|
|
5622
5699
|
});
|
|
5623
5700
|
|
|
5624
5701
|
// src/cli/env.ts
|
|
5625
|
-
function DevEnv() {
|
|
5626
|
-
|
|
5702
|
+
function DevEnv(_static = false) {
|
|
5703
|
+
const common = {
|
|
5627
5704
|
NODE_ENV: "development",
|
|
5628
5705
|
COMMANDKIT_IS_DEV: "true"
|
|
5629
|
-
}
|
|
5706
|
+
};
|
|
5707
|
+
if (_static) return Object.assign({}, common);
|
|
5708
|
+
return Object.assign({}, process.env, common);
|
|
5709
|
+
}
|
|
5710
|
+
function ProdEnv(_static = false) {
|
|
5711
|
+
const common = {
|
|
5712
|
+
NODE_ENV: "production",
|
|
5713
|
+
COMMANDKIT_IS_DEV: "false"
|
|
5714
|
+
};
|
|
5715
|
+
if (_static) return Object.assign({}, common);
|
|
5716
|
+
return Object.assign({}, process.env, common);
|
|
5630
5717
|
}
|
|
5631
5718
|
var CommonEnvFiles, DevEnvFiles, ProdEnvFiles, devEnvFileArgs, prodEnvFileArgs;
|
|
5632
5719
|
var init_env = __esm({
|
|
@@ -5634,17 +5721,10 @@ var init_env = __esm({
|
|
|
5634
5721
|
"use strict";
|
|
5635
5722
|
init_cjs_shims();
|
|
5636
5723
|
__name(DevEnv, "DevEnv");
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
".env.local"
|
|
5642
|
-
];
|
|
5643
|
-
ProdEnvFiles = [
|
|
5644
|
-
".env.production",
|
|
5645
|
-
".env.production.local",
|
|
5646
|
-
".env.local"
|
|
5647
|
-
];
|
|
5724
|
+
__name(ProdEnv, "ProdEnv");
|
|
5725
|
+
CommonEnvFiles = [".env", ".env.local"];
|
|
5726
|
+
DevEnvFiles = [".env.development", ".env.development.local"];
|
|
5727
|
+
ProdEnvFiles = [".env.production", ".env.production.local"];
|
|
5648
5728
|
devEnvFileArgs = [...CommonEnvFiles, ...DevEnvFiles];
|
|
5649
5729
|
prodEnvFileArgs = [...CommonEnvFiles, ...ProdEnvFiles];
|
|
5650
5730
|
}
|
|
@@ -5663,7 +5743,7 @@ function createAppProcess(fileName, cwd, isDev) {
|
|
|
5663
5743
|
panic(`Could not locate the entrypoint file: ${fileName}`);
|
|
5664
5744
|
}
|
|
5665
5745
|
const stdio = getStdio(isDev);
|
|
5666
|
-
const ps = (0,
|
|
5746
|
+
const ps = (0, import_node_child_process2.spawn)(
|
|
5667
5747
|
"node",
|
|
5668
5748
|
[
|
|
5669
5749
|
`--title="CommandKit ${isDev ? "Development" : "Production"}"`,
|
|
@@ -5673,7 +5753,7 @@ function createAppProcess(fileName, cwd, isDev) {
|
|
|
5673
5753
|
{
|
|
5674
5754
|
cwd,
|
|
5675
5755
|
windowsHide: true,
|
|
5676
|
-
env: DevEnv(),
|
|
5756
|
+
env: isDev ? DevEnv() : ProdEnv(),
|
|
5677
5757
|
stdio
|
|
5678
5758
|
}
|
|
5679
5759
|
);
|
|
@@ -5681,12 +5761,12 @@ function createAppProcess(fileName, cwd, isDev) {
|
|
|
5681
5761
|
(_b = ps.stderr) == null ? void 0 : _b.pipe(process.stderr);
|
|
5682
5762
|
return ps;
|
|
5683
5763
|
}
|
|
5684
|
-
var
|
|
5764
|
+
var import_node_child_process2, import_node_path8, import_node_fs8;
|
|
5685
5765
|
var init_app_process = __esm({
|
|
5686
5766
|
"src/cli/app-process.ts"() {
|
|
5687
5767
|
"use strict";
|
|
5688
5768
|
init_cjs_shims();
|
|
5689
|
-
|
|
5769
|
+
import_node_child_process2 = require("child_process");
|
|
5690
5770
|
init_env();
|
|
5691
5771
|
import_node_path8 = require("path");
|
|
5692
5772
|
import_node_fs8 = require("fs");
|
|
@@ -5849,6 +5929,7 @@ async function buildApplication({
|
|
|
5849
5929
|
sourcemap: true,
|
|
5850
5930
|
target: "node16",
|
|
5851
5931
|
outDir: dest,
|
|
5932
|
+
env: isDev ? DevEnv(true) : ProdEnv(true),
|
|
5852
5933
|
entry: [
|
|
5853
5934
|
"src",
|
|
5854
5935
|
`!${config.distDir}`,
|
|
@@ -6185,7 +6266,7 @@ async function bootstrapProductionServer(configPath) {
|
|
|
6185
6266
|
`Could not locate the entrypoint. Did you forget to build the application? Run 'commandkit build' to build the application first.`
|
|
6186
6267
|
);
|
|
6187
6268
|
}
|
|
6188
|
-
return createAppProcess(mainFile, cwd,
|
|
6269
|
+
return createAppProcess(mainFile, cwd, false);
|
|
6189
6270
|
}
|
|
6190
6271
|
async function createProductionBuild(configPath) {
|
|
6191
6272
|
process.env.COMMANDKIT_BOOTSTRAP_MODE = "production";
|
|
@@ -6401,7 +6482,7 @@ function findPackageVersion(packageName) {
|
|
|
6401
6482
|
}
|
|
6402
6483
|
function getBinaryVersion(binary) {
|
|
6403
6484
|
try {
|
|
6404
|
-
const version2 = (0,
|
|
6485
|
+
const version2 = (0, import_node_child_process3.execSync)(`${binary} --version`).toString().trim();
|
|
6405
6486
|
return version2;
|
|
6406
6487
|
} catch {
|
|
6407
6488
|
return null;
|
|
@@ -6469,13 +6550,13 @@ async function showInformation() {
|
|
|
6469
6550
|
}
|
|
6470
6551
|
console.log(output.trim());
|
|
6471
6552
|
}
|
|
6472
|
-
var import_node_os,
|
|
6553
|
+
var import_node_os, import_node_child_process3, import_node_fs10, import_node_path11;
|
|
6473
6554
|
var init_information = __esm({
|
|
6474
6555
|
"src/cli/information.ts"() {
|
|
6475
6556
|
"use strict";
|
|
6476
6557
|
init_cjs_shims();
|
|
6477
6558
|
import_node_os = __toESM(require("os"));
|
|
6478
|
-
|
|
6559
|
+
import_node_child_process3 = require("child_process");
|
|
6479
6560
|
init_version();
|
|
6480
6561
|
import_node_fs10 = __toESM(require("fs"));
|
|
6481
6562
|
import_node_path11 = __toESM(require("path"));
|
|
@@ -6565,6 +6646,8 @@ __export(index_exports, {
|
|
|
6565
6646
|
isMessageSource: () => isMessageSource,
|
|
6566
6647
|
isRuntimePlugin: () => isRuntimePlugin,
|
|
6567
6648
|
makeContextAwareFunction: () => makeContextAwareFunction,
|
|
6649
|
+
onApplicationBootstrap: () => onApplicationBootstrap,
|
|
6650
|
+
onBootstrap: () => onBootstrap,
|
|
6568
6651
|
provideContext: () => provideContext,
|
|
6569
6652
|
redirect: () => redirect,
|
|
6570
6653
|
rethrow: () => rethrow,
|
|
@@ -6622,6 +6705,7 @@ init_cjs_shims();
|
|
|
6622
6705
|
var import_node_fs11 = require("fs");
|
|
6623
6706
|
var import_promises8 = require("fs/promises");
|
|
6624
6707
|
var import_node_path12 = require("path");
|
|
6708
|
+
init_types_package();
|
|
6625
6709
|
async function bootstrapCommandkitCLI(argv, options) {
|
|
6626
6710
|
process.title = "CommandKit CLI";
|
|
6627
6711
|
const { Command } = await import("commander");
|
|
@@ -6663,12 +6747,14 @@ async function bootstrapCommandkitCLI(argv, options) {
|
|
|
6663
6747
|
console.error("Please specify what to create: --command or --event");
|
|
6664
6748
|
}
|
|
6665
6749
|
});
|
|
6666
|
-
await program.parseAsync(argv, options);
|
|
6667
6750
|
const types = (0, import_node_path12.join)(process.cwd(), "node_modules", "commandkit-types");
|
|
6668
6751
|
if (!(0, import_node_fs11.existsSync)(types)) {
|
|
6669
6752
|
await (0, import_promises8.mkdir)(types, { recursive: true }).catch(() => {
|
|
6670
6753
|
});
|
|
6754
|
+
await generateTypesPackage(true).catch(() => {
|
|
6755
|
+
});
|
|
6671
6756
|
}
|
|
6757
|
+
await program.parseAsync(argv, options);
|
|
6672
6758
|
}
|
|
6673
6759
|
__name(bootstrapCommandkitCLI, "bootstrapCommandkitCLI");
|
|
6674
6760
|
|
|
@@ -6752,6 +6838,8 @@ var index_default = CommandKit;
|
|
|
6752
6838
|
isMessageSource,
|
|
6753
6839
|
isRuntimePlugin,
|
|
6754
6840
|
makeContextAwareFunction,
|
|
6841
|
+
onApplicationBootstrap,
|
|
6842
|
+
onBootstrap,
|
|
6755
6843
|
provideContext,
|
|
6756
6844
|
redirect,
|
|
6757
6845
|
rethrow,
|