Skip to content

Commit

Permalink
feat(tools-executors-typescript): Added the storm schema code gener…
Browse files Browse the repository at this point in the history
…ation executor
  • Loading branch information
sullivanpj committed Aug 7, 2023
1 parent b9789cb commit e4c570d
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 11 deletions.
17 changes: 12 additions & 5 deletions apps/web/shell/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ import RootProvider from "./root-provider";
() => import("./(components)/cookie-policy-banner.client")
);*/

const title = "Pat Sullivan Development";
const description = "Software designed for tomorrow's brands";
const image =
"https://pub-e71cff0f90204755bc910518d63cacf8.r2.dev/circle-logo.png";

const contactJsonLd: WithContext<ContactPoint> = {
"@context": "https://schema.org",
"@type": "ContactPoint",
Expand Down Expand Up @@ -64,26 +69,28 @@ const personJsonLd: WithContext<Person> = {
hasOccupation: architectJsonLd,
jobTitle: "Software Architect",
knowsLanguage: "en",
description: "Software designed for tomorrow's brands",
description:
"A financial technology developer based out of the New York metropolitan area.",
contactPoint: contactJsonLd,
};

export const metadata = {
colorScheme: "dark",
themeColor: "#18181B",
title: {
template: "%s - Pat Sullivan Development",
default: "Pat Sullivan Development",
template: `%s - ${title}`,
default: title,
images: [image],
},
authors: [{ name: "Pat Sullivan", url: "https://patsullivan.org" }],
metadataBase: new URL("https://patsullivan.org"),
description: "Software designed for tomorrow's brands",
description: description,
manifest: "https://patsullivan.org/manifest.json",
noindex: false,
nofollow: false,
canonical: "https://patsullivan.org",
generator: "Pat Sullivan",
applicationName: "Pat Sullivan Development",
applicationName: title,
referrer: "origin-when-cross-origin",
keywords: [
"Pat",
Expand Down
5 changes: 2 additions & 3 deletions apps/workers/contact-api/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
ContactApiServerContext,
DB,
builder,
} from "@open-system/contact-server-data-access";
} from "@open-system/contact-server-graphql";
import { initContextCache } from "@pothos/core";
import {
YogaInitialContext,
Expand Down Expand Up @@ -51,7 +50,7 @@ const handler = {
}),
};

return yoga.fetch(request, context as ContactApiServerContext);
return yoga.fetch(request, context);
} catch (e: any) {
return new Response(e?.message, { status: 500 });
}
Expand Down
7 changes: 4 additions & 3 deletions tools/async-api/kafka/renderers/ClassRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export class ClassRenderer extends TypeScriptObjectRenderer {
await this.runAdditionalContentPreset(),
];

return `class ${
this.model.name ?? this.model.name
} extends IntegrationEvent {
return `
@Event()
class ${this.model.name ?? this.model.name} extends IntegrationEvent {
${this.indent(this.renderBlock(content, 2))}
}`;
}
Expand Down
5 changes: 5 additions & 0 deletions tools/executors/typescript/executors.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"implementation": "../../../dist/tools/executors/typescript/design-tokens-build/impl",
"schema": "../../../dist/tools/executors/typescript/design-tokens-build/schema.json",
"description": "Build the latest design tokens code from the extracted figma JSON."
},
"storm-generate": {
"implementation": "../../../dist/tools/executors/typescript/storm-generate/impl",
"schema": "../../../dist/tools/executors/typescript/storm-generate/schema.json",
"description": "Generate code based on a provided Storm model."
}
}
}
12 changes: 12 additions & 0 deletions tools/executors/typescript/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@
"output": "."
}
]
},
"storm-generate": {
"outputPath": "dist/tools/executors/typescript/storm-generate",
"main": "tools/executors/typescript/storm-generate/impl.ts",
"deleteOutputPath": true,
"assets": [
{
"input": "tools/executors/typescript/storm-generate",
"glob": "schema.json",
"output": "."
}
]
}
}
},
Expand Down
57 changes: 57 additions & 0 deletions tools/executors/typescript/storm-generate/impl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ExecutorContext, workspaceRoot } from "@nx/devkit";
import { executeAsync } from "@open-system/core-server-utilities";
import { ConsoleLogger } from "@open-system/core-shared-utilities";
import { generateAction } from "@open-system/tools-storm-schema";
import { existsSync } from "fs";
import Path from "path";
import { StormGenerateExecutorSchema } from "./schema";

export default async function (
options: StormGenerateExecutorSchema,
context: ExecutorContext
) {
let result!: unknown;
try {
ConsoleLogger.info("Executing Storm (Code Generation) executor...");

const buildTarget =
context.workspace.projects[context.projectName].targets.build;

const schemaPath = Path.join(workspaceRoot, options.schema);
if (!existsSync(schemaPath)) {
ConsoleLogger.error(
`No Storm schema file could be found at: "${schemaPath}" `
);
return { success: false };
}

const outputPath = Path.join(workspaceRoot, buildTarget.options.outputPath);
if (existsSync(outputPath)) {
result = await executeAsync(`rmdir /S /Q "${outputPath}" `);
if (result) {
ConsoleLogger.error(result);
return { success: false };
}
}

await generateAction({
schema: schemaPath,
packageManager: options.packageManager,
dependencyCheck: options.dependencyCheck,
outDir: outputPath,
});

ConsoleLogger.success(
`Storm (Code Generation) executor successfully ran for ${context.projectName}.`
);

return { success: !result };
} catch (e) {
ConsoleLogger.error(
`An error occurred syncing client API for ${context.projectName}`
);
ConsoleLogger.error(e);

return { success: false };
}
}
8 changes: 8 additions & 0 deletions tools/executors/typescript/storm-generate/schema.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type PackageManagers = "npm" | "yarn" | "pnpm";

export interface StormGenerateExecutorSchema {
schema: string;
outputPath: string;
packageManager: PackageManagers;
dependencyCheck: boolean;
}
34 changes: 34 additions & 0 deletions tools/executors/typescript/storm-generate/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "http://json-schema.org/schema",
"cli": "nx",
"id": "storm-generate",
"title": "Open System - Storm Generate",
"description": "Generate code based on a provided Storm model",
"type": "object",
"properties": {
"schema": {
"type": "string",
"description": "The `.storm` file name and path of the Storm model to use",
"default": "./schema.storm"
},
"outputPath": {
"type": "string",
"description": "Path to the directory where the files will be generated",
"default": "src/__generated__"
},
"packageManager": {
"type": "string",
"description": "Name of the package manager used by this repository",
"options": [
"npm", "yarn", "pnpm"
],
"default": "npm"
},
"dependencyCheck": {
"type": "boolean",
"description": "Should the currently installed Prisma version be checked",
"default": true
}
},
"required": ["stormFile", "outputPath", "packageManager", "dependencyCheck"]
}

0 comments on commit e4c570d

Please sign in to comment.