Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(seed): introduce scripts to generators so fern bot can build the SDKs #4788

Merged
merged 10 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions packages/cli/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@fern-api/fern-definition-formatter": "workspace:*",
"@fern-api/cli-migrations": "workspace:*",
"@fern-api/fern-definition-schema": "workspace:*",
"@fern-fern/generators-sdk": "0.109.0-21be2e5be",
"@fern-fern/generators-sdk": "0.114.0-5745f9e74",
"@fern-fern/fiddle-sdk": "0.0.584",
"@types/get-port": "^4.2.0",
"ansi-escapes": "^5.0.0",
Expand Down Expand Up @@ -115,4 +115,4 @@
"prettier": "^2.7.1",
"typescript": "4.6.4"
}
}
}
4 changes: 2 additions & 2 deletions packages/cli/configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@fern-api/fern-definition-schema": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.108.0-dcb0f740c",
"@fern-fern/fiddle-sdk": "0.0.584",
"@fern-fern/generators-sdk": "0.109.0-21be2e5be",
"@fern-fern/generators-sdk": "0.114.0-5745f9e74",
"find-up": "^6.3.0",
"js-yaml": "^4.1.0",
"lodash-es": "^4.17.21",
Expand All @@ -57,4 +57,4 @@
"typescript": "4.6.4",
"vitest": "^2.0.5"
}
}
}
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@fern-fern/fdr-cjs-sdk": "0.108.0-dcb0f740c",
"@fern-fern/generators-sdk": "0.107.0-00fe26566",
"@fern-fern/generators-sdk": "0.114.0-5745f9e74",
"@fern-api/venus-api-sdk": "0.0.38",
"@fern-fern/fdr-test-sdk": "^0.0.5297",
"@fern-fern/fiddle-sdk": "0.0.584"
Expand All @@ -44,4 +44,4 @@
"prettier": "^2.7.1",
"typescript": "4.6.4"
}
}
}
86 changes: 50 additions & 36 deletions packages/seed/fern/definition/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ types:
publishGa: PublishCommand
publishRc: PublishCommand
publishDev: PublishCommand
changelogLocation:
changelogLocation:
type: optional<string>
docs: |
docs: |
The location of the changelog file, the schema of which must follow FDR's `GeneratorReleaseRequest` object.

SeedWorkspaceConfiguration:
Expand All @@ -18,30 +18,32 @@ types:
irVersion: string
test: TestConfiguration
publish: PublishConfiguration
changelogLocation:
changelogLocation:
type: optional<string>
docs: |
docs: |
The location of the changelog file, the schema of which must follow FDR's `GeneratorReleaseRequest` object.

language: optional<Language>
defaultCustomConfig: optional<map<string, unknown>>
defaultOutputMode: OutputMode
generatorType: GeneratorType

customFixtureConfig:
artifactMetadata: optional<ArtifactMetadata>

customFixtureConfig:
type: optional<FixtureConfigurations>
docs: |
Configuration that will be used for any custom fixture specified by --custom-fixture
fixtures:
type: optional<map<string, list<FixtureConfigurations>>>
scripts: optional<list<ScriptConfig>>
allowedFailures:
scripts: optional<list<DockerScriptConfig>>
allowedFailures:
type: optional<list<string>>
docs: |
List any fixtures that are okay to fail. For normal fixtures
docs: |
List any fixtures that are okay to fail. For normal fixtures
just list the fixture name. For configured fixture list {fixture}:{outputFolder}.
features: optional<features.GeneratorFeatures>

PublishDockerConfiguration:
properties:
context: string
Expand All @@ -63,18 +65,18 @@ types:
Commands can be multi-line, we'll run them all!
properties:
workingDirectory: optional<string>
versionSubstitution:
versionSubstitution:
type: optional<string>
docs: |
docs: |
The string to substitute for the version in the command. ex. `"$VERSION"`
command: DockerCommand

PublishConfiguration:
discriminated: false
union:
union:
- PublishDocker
- PublishCommand

TestDockerConfiguration:
properties:
image: string
Expand All @@ -85,38 +87,50 @@ types:
docker: TestDockerConfiguration
local: optional<LocalBuildInfo>

LocalBuildInfo:
properties:
workingDirectory:
LocalBuildInfo:
properties:
workingDirectory:
type: string
docs: |
The working directory for the generator.
buildCommand:
docs: |
The working directory for the generator.
buildCommand:
type: list<string>
docs: |
The command to build the generator locally.
`yarn workspace @fern-api/openapi-generator build` for example.
docs: |
The command to build the generator locally.
`yarn workspace @fern-api/openapi-generator build` for example.
runCommand:
type: string
docs: |
The command to run the generator locally.
docs: |
The command to run the generator locally.
`node generators/openapi/dist/cli.cjs` for example.
env:
env:
type: optional<map<string, string>>
docs: |
docs: |
Environment variables to set when running the generator locally.

DockerCommand:
ArtifactMetadata:
docs: Metadata relating to the artifact produced by this generator
properties:
preInstallScript: optional<Script>
installScript: optional<Script>
compileScript: optional<Script>
testScript: optional<Script>

DockerCommand:
discriminated: false
union:
union:
- string
- list<string>

ScriptConfig:
Script:
properties:
docker: string
commands: list<string>

DockerScriptConfig:
extends: Script
properties:
docker: string

Language:
enum:
- python
Expand Down Expand Up @@ -144,7 +158,7 @@ types:
audiences: optional<list<string>>
outputFolder: string
outputVersion: optional<string>
outputMode:
outputMode:
type: optional<OutputMode>
docs: Overrides the default output mode

Expand All @@ -157,7 +171,7 @@ types:

ReadmeEndpoint:
discriminated: false
union:
union:
- string
- ReadmeEndpointObject

Expand All @@ -166,9 +180,9 @@ types:
method: string
path: string
stream: optional<boolean>
OutputMode:
enum:

OutputMode:
enum:
- github
- local_files
- publish
4 changes: 2 additions & 2 deletions packages/seed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@fern-api/workspace-loader": "workspace:*",
"@fern-fern/fiddle-sdk": "0.0.584",
"@fern-fern/generator-exec-sdk": "^0.0.898",
"@fern-fern/generators-sdk": "0.109.0-21be2e5be",
"@fern-fern/generators-sdk": "0.114.0-5745f9e74",
"@types/pretty-ms": "^5.0.1",
"chalk": "^5.3.0",
"console-table-printer": "^2.12.0",
Expand Down Expand Up @@ -79,4 +79,4 @@
"typescript": "4.6.4",
"vitest": "^2.0.5"
}
}
}
3 changes: 2 additions & 1 deletion packages/seed/src/commands/register/registerGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export async function registerGenerator({
displayName: generatorConfig.displayName,
generatorType: convertGeneratorType(generatorConfig.generatorType),
generatorLanguage: generatorConfig.language,
dockerImage: generatorConfig.image
dockerImage: generatorConfig.image,
scripts: generatorConfig.artifactMetadata
});

// Register generator versions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as FernSeedConfig from "../../..";

/**
* Metadata relating to the artifact produced by this generator
*/
export interface ArtifactMetadata {
preInstallScript?: FernSeedConfig.Script;
installScript?: FernSeedConfig.Script;
compileScript?: FernSeedConfig.Script;
testScript?: FernSeedConfig.Script;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as FernSeedConfig from "../../..";

export interface DockerScriptConfig extends FernSeedConfig.Script {
docker: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* This file was auto-generated by Fern from our API Definition.
*/

export interface ScriptConfig {
docker: string;
export interface Script {
commands: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export interface SeedWorkspaceConfiguration {
defaultCustomConfig?: Record<string, unknown>;
defaultOutputMode: FernSeedConfig.OutputMode;
generatorType: FernSeedConfig.GeneratorType;
artifactMetadata?: FernSeedConfig.ArtifactMetadata;
/** Configuration that will be used for any custom fixture specified by --custom-fixture */
customFixtureConfig?: FernSeedConfig.FixtureConfigurations;
fixtures?: Record<string, FernSeedConfig.FixtureConfigurations[]>;
scripts?: FernSeedConfig.ScriptConfig[];
scripts?: FernSeedConfig.DockerScriptConfig[];
/**
* List any fixtures that are okay to fail. For normal fixtures
* just list the fixture name. For configured fixture list {fixture}:{outputFolder}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ export * from "./PublishConfiguration";
export * from "./TestDockerConfiguration";
export * from "./TestConfiguration";
export * from "./LocalBuildInfo";
export * from "./ArtifactMetadata";
export * from "./DockerCommand";
export * from "./ScriptConfig";
export * from "./Script";
export * from "./DockerScriptConfig";
export * from "./Language";
export * from "./GeneratorType";
export * from "./FixtureConfigurations";
Expand Down
Loading
Loading