Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/publish-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
"@commandkit/ai:packages/ai"
"@commandkit/queue:packages/queue"
"@commandkit/tasks:packages/tasks"
"@commandkit/workflow:packages/workflow"
)

for entry in "${PACKAGES[@]}"; do
Expand All @@ -84,6 +85,7 @@ jobs:
"@commandkit/ai"
"@commandkit/queue"
"@commandkit/tasks"
"@commandkit/workflow"
)

for pkg in "${PACKAGES[@]}"; do
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
"@commandkit/ai:packages/ai"
"@commandkit/queue:packages/queue"
"@commandkit/tasks:packages/tasks"
"@commandkit/workflow:packages/workflow"
)

for entry in "${PACKAGES[@]}"; do
Expand Down
4 changes: 2 additions & 2 deletions apps/test-bot/commandkit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { cache } from '@commandkit/cache';
import { ai } from '@commandkit/ai';
import { tasks, setDriver } from '@commandkit/tasks';
import { BullMQDriver } from '@commandkit/tasks/bullmq';
import { workflowRollupPlugin } from 'workflow/rollup';
import { workflow } from '@commandkit/workflow';

noBuildOnly(() => {
setDriver(
Expand All @@ -16,7 +16,6 @@ noBuildOnly(() => {
})();

export default defineConfig({
rolldownPlugins: [workflowRollupPlugin()],
plugins: [
i18n(),
devtools(),
Expand All @@ -25,5 +24,6 @@ export default defineConfig({
tasks({
initializeDefaultDriver: false,
}),
workflow(),
],
});
3 changes: 2 additions & 1 deletion apps/test-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
"@commandkit/i18n": "workspace:*",
"@commandkit/legacy": "workspace:*",
"@commandkit/tasks": "workspace:*",
"@commandkit/workflow": "workspace:*",
"commandkit": "workspace:*",
"discord.js": "catalog:discordjs",
"dotenv": "^16.4.7",
"ms": "^2.1.3",
"workflow": "4.0.1-beta.11",
"workflow": "catalog:workflow",
"zod": "^4.1.1"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CompilerPluginRuntime is a runtime for managing compiler plugins in CommandKit.
```ts title="Signature"
class CompilerPluginRuntime {
public readonly name = 'CompilerPluginRuntime';
constructor(plugins: CompilerPlugin[])
constructor(plugins: CompilerPlugin[], isDevMode: boolean)
getPlugins() => ;
isEmpty() => ;
registerTemplate(name: string, handler: TemplateHandler) => ;
Expand All @@ -43,7 +43,7 @@ class CompilerPluginRuntime {

### constructor

<MemberInfo kind="method" type={`(plugins: <a href='/docs/api-reference/commandkit/classes/compiler-plugin#compilerplugin'>CompilerPlugin</a>[]) => CompilerPluginRuntime`} />
<MemberInfo kind="method" type={`(plugins: <a href='/docs/api-reference/commandkit/classes/compiler-plugin#compilerplugin'>CompilerPlugin</a>[], isDevMode: boolean) => CompilerPluginRuntime`} />

Creates a new instance of CompilerPluginRuntime.
### getPlugins
Expand Down
4 changes: 2 additions & 2 deletions examples/with-workflow/commandkit.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'commandkit/config';
import { workflowRollupPlugin } from 'workflow/rollup';
import { workflow } from '@commandkit/workflow';

export default defineConfig({
rolldownPlugins: [workflowRollupPlugin()],
plugins: [workflow()],
});
2 changes: 1 addition & 1 deletion examples/with-workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"dependencies": {
"commandkit": "^1.2.0-rc.12",
"discord.js": "^14.24.0",
"workflow": "^4.0.1-beta.11"
"workflow": "^4.0.1-beta.12"
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useClient } from 'commandkit/hooks';
import { commandkit } from 'commandkit';

export async function greetUser(userId: string, again = false) {
'use step';

const client = useClient<true>();
const user = await client.users.fetch(userId);
const user = await commandkit.client.users.fetch(userId);

const message = again ? 'Hello again!' : 'Hello!';

Expand Down
1 change: 1 addition & 0 deletions packages/commandkit/src/cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export async function buildApplication({

const pluginRuntime = new CompilerPluginRuntime(
(plugins || []) as CompilerPlugin[],
!!isDev,
);

rolldownPlugins ??= [];
Expand Down
1 change: 1 addition & 0 deletions packages/commandkit/src/cli/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export async function bootstrapCommandkitCLI(
const { plugins } = await loadConfigFile();
const runtime = new CompilerPluginRuntime(
plugins.filter((p) => isCompilerPlugin(p)) as CompilerPlugin[],
true,
);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ export class CompilerPluginRuntime {
/**
* Creates a new instance of CompilerPluginRuntime.
* @param plugins An array of compiler plugins to be managed by this runtime.
* @param isDevMode Whether the build is in development mode.
*/
public constructor(private readonly plugins: CompilerPlugin[]) {
public constructor(
private readonly plugins: CompilerPlugin[],
public readonly isDevMode: boolean,
) {
this.plugins = this.plugins.filter((p) => !!p && isCompilerPlugin(p));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export abstract class CommonDirectiveTransformer extends CompilerPlugin<CommonDi
if (!this.options.enabled) return null;
if (!this.transformer) return null;
if (/\.json$/.test(params.id)) return null;
if (!params.code.includes(this.options.directive)) return null;

const result = await this.transformer(params.code.toString(), params.id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class MacroPlugin extends CompilerPlugin {
): Promise<MaybeFalsey<TransformedResult>> {
if (!this.options.enabled) return null;
if (/\.json$/.test(params.id)) return null;
if (!params.code.includes('use macro')) return null;

const { contents } = await this.macroTransformer.transform(
params.code,
Expand Down
Loading