notes
This commit is contained in:
@@ -1,29 +1,7 @@
|
||||
import { Command, FileSystem, Path } from '@effect/platform';
|
||||
import { BunContext, BunRuntime } from '@effect/platform-bun';
|
||||
import { Effect, Logger, LogLevel, pipe, Stream, String } from 'effect';
|
||||
import { convertFromString } from './json-schema-to-effect';
|
||||
|
||||
// Helper function to collect stream output as a string
|
||||
const runString = <E, R>(
|
||||
stream: Stream.Stream<Uint8Array, E, R>,
|
||||
): Effect.Effect<string, E, R> =>
|
||||
stream.pipe(Stream.decodeText(), Stream.runFold(String.empty, String.concat));
|
||||
|
||||
const runCommand = (command: Command.Command) =>
|
||||
pipe(
|
||||
Command.start(command),
|
||||
Effect.flatMap((process) =>
|
||||
Effect.all(
|
||||
[
|
||||
process.exitCode,
|
||||
runString(process.stdout),
|
||||
runString(process.stderr),
|
||||
],
|
||||
{ concurrency: 3 },
|
||||
),
|
||||
),
|
||||
Effect.map(([exitCode, stdout, stderr]) => ({ exitCode, stdout, stderr })),
|
||||
);
|
||||
import { Effect, Logger, LogLevel } from 'effect';
|
||||
import { jsonSchemaToEffectSchema, runCommand } from './lib/script-utils';
|
||||
|
||||
const getDscJsonSchema = (schemaType: string) =>
|
||||
Effect.gen(function* () {
|
||||
@@ -62,28 +40,6 @@ const getPossibleDscSchemaTypes = () =>
|
||||
return possibleTypes;
|
||||
});
|
||||
|
||||
const jsonSchemaToEffectSchema = (params: {
|
||||
jsonSchema: string;
|
||||
name: string;
|
||||
}) =>
|
||||
Effect.gen(function* () {
|
||||
yield* Effect.logDebug(`Converting schema: ${params.name}`);
|
||||
|
||||
const result = convertFromString(params.jsonSchema, params.name);
|
||||
|
||||
yield* Effect.logDebug(
|
||||
`Converted "${params.name}" - types: ${result.typeNames.join(', ')}`,
|
||||
);
|
||||
|
||||
if (result.recursiveTypes.length > 0) {
|
||||
yield* Effect.logInfo(
|
||||
`Recursive types in ${params.name}: ${result.recursiveTypes.join(', ')}`,
|
||||
);
|
||||
}
|
||||
|
||||
return result.code;
|
||||
});
|
||||
|
||||
const genDscTypes = Effect.gen(function* () {
|
||||
yield* Effect.log('Starting DSC types generation...');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user