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(cli): allow fern to push generated code to a sub directory #5715

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions fern/apis/generators-yml/definition/group.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ types:
repository: string
license: optional<license.GithubLicenseSchema>
mode: optional<GithubCommitAndReleaseMode>
path:
type: optional<string>
docs: The relative path in the GitHub repository where the generated code should be committed
# Add properties for commit and release configuration

GithubCommitAndReleaseMode:
Expand All @@ -100,6 +103,9 @@ types:
license: optional<license.GithubLicenseSchema>
mode: literal<"pull-request">
reviewers: optional<reviewers.ReviewersSchema>
path:
type: optional<string>
docs: The relative path in the GitHub repository where the generated code should be committed
# Add properties for pull request configuration

GithubPushSchema:
Expand All @@ -108,6 +114,9 @@ types:
license: optional<license.GithubLicenseSchema>
mode: literal<"push">
branch: optional<string>
path:
type: optional<string>
docs: The relative path in the GitHub repository where the generated code should be committed
# Add properties for push configuration

NpmOutputLocationSchema:
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@fern-api/task-context": "workspace:*",
"@fern-api/venus-api-sdk": "0.10.2",
"@fern-api/workspace-loader": "workspace:*",
"@fern-fern/fiddle-sdk": "0.0.584",
"@fern-fern/fiddle-sdk": "0.0.610",
"@fern-fern/generators-sdk": "0.114.0-5745f9e74",
"@fern-typescript/fetcher": "workspace:*",
"@inquirer/prompts": "^7.1.0",
Expand Down
16 changes: 16 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
- changelogEntry:
- summary: |
Added support for specifying a subdirectory path in GitHub repositories via the `path`
key under `github` configuration in generators.yml. This allows generating SDKs into specific subdirectories:

```yml
generators:
- name: fernapi/fern-typescript-sdk
github:
repository: owner/repo
path: packages/typescript # SDK will be generated in this subdirectory
```
type: feat
irVersion: 55
version: 0.51.3

- changelogEntry:
- summary: |
Improved error messages when docs.yml doesn't match schema by showing more specific
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/configuration-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@fern-api/task-context": "workspace:*",
"@fern-api/fern-definition-schema": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.127.5-72dd47f6f",
"@fern-fern/fiddle-sdk": "0.0.584",
"@fern-fern/fiddle-sdk": "0.0.610",
"@fern-fern/generators-sdk": "0.114.0-5745f9e74",
"find-up": "^6.3.0",
"js-yaml": "^4.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ async function convertOutputMode({
})
: undefined;
const mode = generator.github.mode ?? "release";
const path = generator.github.path;
switch (mode) {
case "commit":
case "release":
Expand All @@ -554,7 +555,8 @@ async function convertOutputMode({
repo,
license,
publishInfo,
downloadSnippets
downloadSnippets,
directory: path
})
);
case "pull-request": {
Expand All @@ -570,7 +572,8 @@ async function convertOutputMode({
license,
publishInfo,
downloadSnippets,
reviewers
reviewers,
directory: path
})
);
}
Expand All @@ -582,7 +585,8 @@ async function convertOutputMode({
branch: generator.github.mode === "push" ? generator.github.branch : undefined,
license,
publishInfo,
downloadSnippets
downloadSnippets,
directory: path
})
);
default:
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@fern-api/path-utils": "workspace:*",
"@fern-api/fern-definition-schema": "workspace:*",
"@fern-fern/fdr-cjs-sdk": "0.127.5-72dd47f6f",
"@fern-fern/fiddle-sdk": "0.0.584",
"@fern-fern/fiddle-sdk": "0.0.610",
"zod": "^3.22.3"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ export interface GithubCommitAndReleaseSchema {
repository: string;
license?: FernDefinition.GithubLicenseSchema;
mode?: FernDefinition.GithubCommitAndReleaseMode;
/** The relative path in the GitHub repository where the generated code should be committed */
path?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ export interface GithubPullRequestSchema {
license?: FernDefinition.GithubLicenseSchema;
mode: "pull-request";
reviewers?: FernDefinition.ReviewersSchema;
/** The relative path in the GitHub repository where the generated code should be committed */
path?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export interface GithubPushSchema {
license?: FernDefinition.GithubLicenseSchema;
mode: "push";
branch?: string;
/** The relative path in the GitHub repository where the generated code should be committed */
path?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ export const GithubCommitAndReleaseSchema: core.serialization.ObjectSchema<
repository: core.serialization.string(),
license: GithubLicenseSchema.optional(),
mode: GithubCommitAndReleaseMode.optional(),
path: core.serialization.string().optional(),
});

export declare namespace GithubCommitAndReleaseSchema {
export interface Raw {
repository: string;
license?: GithubLicenseSchema.Raw | null;
mode?: GithubCommitAndReleaseMode.Raw | null;
path?: string | null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const GithubPullRequestSchema: core.serialization.ObjectSchema<
license: GithubLicenseSchema.optional(),
mode: core.serialization.stringLiteral("pull-request"),
reviewers: ReviewersSchema.optional(),
path: core.serialization.string().optional(),
});

export declare namespace GithubPullRequestSchema {
Expand All @@ -26,5 +27,6 @@ export declare namespace GithubPullRequestSchema {
license?: GithubLicenseSchema.Raw | null;
mode: "pull-request";
reviewers?: ReviewersSchema.Raw | null;
path?: string | null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const GithubPushSchema: core.serialization.ObjectSchema<
license: GithubLicenseSchema.optional(),
mode: core.serialization.stringLiteral("push"),
branch: core.serialization.string().optional(),
path: core.serialization.string().optional(),
});

export declare namespace GithubPushSchema {
Expand All @@ -23,5 +24,6 @@ export declare namespace GithubPushSchema {
license?: GithubLicenseSchema.Raw | null;
mode: "push";
branch?: string | null;
path?: string | null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@fern-api/task-context": "workspace:*",
"@fern-api/typescript-dynamic-snippets": "workspace:*",
"@fern-api/workspace-loader": "workspace:*",
"@fern-fern/fiddle-sdk": "0.0.584",
"@fern-fern/fiddle-sdk": "0.0.610",
"@fern-fern/generator-exec-sdk": "^0.0.898",
"chalk": "^5.3.0",
"decompress": "^4.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@fern-api/register": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-api/workspace-loader": "workspace:*",
"@fern-fern/fiddle-sdk": "0.0.584",
"@fern-fern/fiddle-sdk": "0.0.610",
"axios": "^1.7.7",
"chalk": "^5.3.0",
"decompress": "^4.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/workspace/lazy-fern-workspace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@fern-api/openapi-ir-parser": "workspace:*",
"@fern-api/semver-utils": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-fern/fiddle-sdk": "0.0.584",
"@fern-fern/fiddle-sdk": "0.0.610",
"@redocly/openapi-core": "^1.4.1",
"@types/uuid": "^9.0.8",
"axios": "^1.7.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/seed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"typescript": "5.7.2",
"vitest": "^2.1.8",
"@fern-api/workspace-loader": "workspace:*",
"@fern-fern/fiddle-sdk": "0.0.584",
"@fern-fern/fiddle-sdk": "0.0.610",
"@fern-fern/generator-exec-sdk": "^0.0.898",
"@fern-fern/generators-sdk": "0.114.0-5745f9e74",
"@types/find-up": "^4.0.0",
Expand Down
41 changes: 27 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading