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
51 changes: 0 additions & 51 deletions .github/workflows/publish-fix.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env tsx
#!/usr/bin/env node
import path from "node:path";

import { generateFromEntryPoint } from "../src/type-generator";
import { generateFromEntryPoint } from "../dist/type-generator/index.js";

// Parse arguments
const args = process.argv.slice(2);
Expand Down
2 changes: 1 addition & 1 deletion packages/appkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"./package.json": "./package.json"
},
"bin": {
"appkit-generate-types": "./bin/generate-types.ts"
"appkit-generate-types": "./bin/generate-types.js"
},
"scripts": {
"build:package": "tsdown --config tsdown.config.ts",
Expand Down
30 changes: 19 additions & 11 deletions packages/appkit/src/type-generator/vite-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { execSync } from "node:child_process";
import path from "node:path";
import type { Plugin } from "vite";
import { generateFromEntryPoint } from "./index";

/**
* Options for the AppKit types plugin.
Expand All @@ -14,22 +14,31 @@ interface AppKitTypesPluginOptions {

/**
* Vite plugin to generate types for AppKit queries.
* Calls `npx appkit-generate-types` under the hood.
* Calls generateFromEntryPoint under the hood.
* @param options - Options to override default values.
* @returns Vite plugin to generate types for AppKit queries.
*/
export function appKitTypesPlugin(options?: AppKitTypesPluginOptions): Plugin {
let root: string;
let appRoot: string;
let outFile: string;
let watchFolders: string[];

function generate() {
async function generate() {
try {
const args = [appRoot, outFile].join(" ");
execSync(`npx appkit-generate-types ${args}`, {
cwd: appRoot,
stdio: "inherit",
const warehouseId = process.env.DATABRICKS_WAREHOUSE_ID || "";

if (!warehouseId) {
console.warn(
"[AppKit] Warehouse ID not found. Skipping type generation.",
);
return;
}

await generateFromEntryPoint({
outFile,
queryFolder: watchFolders[0],
warehouseId,
noCache: false,
});
} catch (error) {
// throw in production to fail the build
Expand All @@ -42,16 +51,15 @@ export function appKitTypesPlugin(options?: AppKitTypesPluginOptions): Plugin {

return {
name: "appkit-types",

configResolved(config) {
root = config.root;
appRoot = path.resolve(root, "..");

outFile = path.resolve(root, options?.outFile ?? "src/appKitTypes.d.ts");

watchFolders = (options?.watchFolders ?? ["../config/queries"]).map(
(folder) => path.resolve(root, folder),
);
},

buildStart() {
generate();
},
Expand Down
4 changes: 4 additions & 0 deletions tools/dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ fs.writeFileSync("tmp/package.json", JSON.stringify(pkg, null, 2));

fs.cpSync("dist", "tmp/dist", { recursive: true });

if (fs.existsSync("bin")) {
fs.cpSync("bin", "tmp/bin", { recursive: true });
}

// Copy bin and scripts from shared package
if (isAppKitPackage) {
if (fs.existsSync(sharedBin)) {
Expand Down