Skip to content

Commit

Permalink
chore: Move Ruby generator to top level (match new repo structure) (#…
Browse files Browse the repository at this point in the history
…2769)

* Move Ruby generator to match rest of repo

* add additional files and update readme

* cr
  • Loading branch information
armandobelardo authored Jan 24, 2024
1 parent 051c179 commit c8b1432
Show file tree
Hide file tree
Showing 653 changed files with 384 additions and 275 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
**/ruby/playground/** linguist-generated=true
**/ruby/seed/** linguist-generated=true
**/ruby/seed/**/seed.yml linguist-generated=false
seed/** linguist-generated=true
seed/**/seed.yml linguist-generated=false
6 changes: 5 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
* dsinghvi
* @dsinghvi
/packages/generators/cli/* @armandobelardo
/packages/generators/commons/* @armandobelardo
/packages/generators/docker/* @armandobelardo
generators/ruby/* @armandobelardo
11 changes: 6 additions & 5 deletions .github/workflows/seed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
seed:
- 'packages/seed/**'
- 'test-definitions/**'
ruby: 'packages/generators/ruby/**'
ruby: 'generators/ruby/**'
openapi: 'generators/openapi/**'
python: 'generators/python/**'
postman: 'generators/postman/**'
ruby-model:
runs-on: ubuntu-latest
needs: changes
if: ${{ contains(needs.changes.outputs.generators_changed, 'ruby') }} ||
if: ${{ contains(needs.changes.outputs.generators_changed, 'ruby') }} || ${{ contains(needs.changes.outputs.generators_changed, 'seed') }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand All @@ -37,11 +37,12 @@ jobs:
- name: Install Seed
run: npm install -g @fern-api/seed-cli

- name: Yarn Install
run: yarn install

- name: Seed Test
run: |
cd packages/generators/ruby
yarn install
seed test --workspace model --parallel 8
yarn seed:local test --workspace ruby-model --parallel 8
- name: Ensure no changes to git-tracked files
run: git --no-pager diff --exit-code
Expand Down
156 changes: 64 additions & 92 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@ For a walkthrough, check out the [Fern + Express video](https://docs.buildwithfe

## Generators

Generators are process that take your OpenAPI or Fern Definition as input and output artifacts (generated SDKs, server
boilerplate, postman collections, etc.). Below you can find a list of all of Fern's generators.

| Generator ID | Description | Latest Version | Changelog | Entrypoint
| ----------------------------- | ---------------------------- | --------------- | ----------------------------------------------------------- | ---------------
| fernapi/fern-python-sdk | Generate a Python SDK | 0.7.7 | [CHANGELOG.md](./generators/python/pydantic//CHANGELOG.md) | [cli.py](./generators/python/src/fern_python/generators/sdk/cli.py)
| fernapi/fern-pydantic-model | Generate Pydantic Models | 0.7.7 | [CHANGELOG.md](./generators/python/sdk/CHANGELOG.md) | [cli.py](./generators/python/src/fern_python/generators/sdk/cli.py)
| fernapi/fern-fastapi-server | Generate FastAPI boilerplate | 0.7.7 | [CHANGELOG.md](./generators/python/fastapi//CHANGELOG.md) | [cli.py](./generators/python/src/fern_python/generators/sdk/cli.py)
| fernapi/fern-openapi | Fern Definition -> OpenAPI | 0.0.30 | [CHANGELOG.md](./generators/openapi/CHANGELOG.md) | [cli.ts](./generators/openapi/src/cli.ts)

Generators are process that take your OpenAPI or Fern Definition as input and output artifacts (generated SDKs, server
boilerplate, postman collections, etc.). Below you can find a list of all of Fern's generators.

| Generator ID | Description | Latest Version | Changelog | Entrypoint |
| --------------------------- | ---------------------------- | -------------- | --------------------------------------------------------- | ------------------------------------------------------------------- |
| fernapi/fern-python-sdk | Generate a Python SDK | 0.7.7 | [CHANGELOG.md](./generators/python/pydantic/CHANGELOG.md) | [cli.py](./generators/python/src/fern_python/generators/sdk/cli.py) |
| fernapi/fern-pydantic-model | Generate Pydantic Models | 0.7.7 | [CHANGELOG.md](./generators/python/sdk/CHANGELOG.md) | [cli.py](./generators/python/src/fern_python/generators/sdk/cli.py) |
| fernapi/fern-fastapi-server | Generate FastAPI boilerplate | 0.7.7 | [CHANGELOG.md](./generators/python/fastapi/CHANGELOG.md) | [cli.py](./generators/python/src/fern_python/generators/sdk/cli.py) |
| fernapi/fern-openapi | Fern Definition -> OpenAPI | 0.0.30 | [CHANGELOG.md](./generators/openapi/CHANGELOG.md) | [cli.ts](./generators/openapi/src/cli.ts) |
| fernapi/fern-ruby-model | Generate Ruby Models | 0.0.6 | [CHANGELOG.md](./generators/ruby/model/CHANGELOG.md) | [cli.ts](./generators/ruby/model/src/cli.ts) |

## Customer Showcase

Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions generators/ruby/model/.depcheckrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"ignores": [
"@types/jest",
"@types/node",
"esbuild",
"@yarnpkg/esbuild-plugin-pnp",
"webpack",
"webpack-cli",
"ts-loader",
"@fern-fern/ir-sdk"
],
"ignore-patterns": ["lib", "dist", "docker/bundle.js"]
}
3 changes: 3 additions & 0 deletions generators/ruby/model/.env-cmdrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
prod: {}
};
28 changes: 28 additions & 0 deletions generators/ruby/model/.mrlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"type": "cli",
"cliName": "fern-ruby-model",
"environment": {
"environments": {
"prod": {
"cliName": "fern-ruby-model",
"cliPackageName": "@fern-api/fern-ruby-model"
}
}
},
"rules": {
"depcheck": {
"ignores": ["webpack", "webpack-cli", "ts-loader", "@fern-fern/ir-sdk"],
"ignore-patterns": ["docker/bundle.js"]
},
"duplicate-dependencies": {
"exclude": ["@fern-fern/ir-sdk"]
},
"package-json": {
"scripts": {
"dockerTagLatest": "yarn dist:cli && docker build -f ./Dockerfile -t fernapi/fern-ruby-model:latest ../../..",
"dockerTagVersion": "yarn dist:cli && docker build -f ./Dockerfile -t fernapi/fern-ruby-model:${0} ../../.."
}
}
},
"private": false
}
1 change: 1 addition & 0 deletions generators/ruby/model/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../../../.prettierrc.json");
12 changes: 12 additions & 0 deletions generators/ruby/model/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## [0.0.6] - 2024-01-24

- Chore: Intialize this changelog
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# syntax = edrevo/dockerfile-plus
INCLUDE+ packages/generators/docker/Dockerfile.base

COPY packages/generators/ruby/model/docker/dist/bundle.js /bundle.js
COPY generators/ruby/model/dist /dist

# Install Ruby and Rubocop for formatting
RUN apk --no-cache add ruby && gem install rubocop

ENTRYPOINT ["node", "/bundle.js"]
ENTRYPOINT ["node", "/dist/cli.cjs", "ruby-model"]
67 changes: 67 additions & 0 deletions generators/ruby/model/build.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const { pnpPlugin } = require("@yarnpkg/esbuild-plugin-pnp");
const { build } = require("esbuild");
const path = require("path");
const { chmod, writeFile, mkdir } = require("fs/promises");

const packageJson = require("./package.json");

main();

async function main() {
const options = {
platform: "node",
target: "node14",
entryPoints: ["./src/cli.ts"],
outfile: "./dist/bundle.cjs",
bundle: true,
external: ["cpu-features"],
plugins: [pnpPlugin()],
define: {
"process.env.CLI_NAME": JSON.stringify("fern-ruby-model"),
"process.env.CLI_VERSION": JSON.stringify(packageJson.version),
"process.env.CLI_PACKAGE_NAME": JSON.stringify("@fern-api/fern-ruby-model")
}
};

await build(options).catch(() => process.exit(1));

process.chdir(path.join(__dirname, "dist"));

// write cli executable
await writeFile(
"cli.cjs",
`#!/usr/bin/env node
require("./bundle.cjs");`
);
await chmod("cli.cjs", "755");

// write cli's package.json
await writeFile(
"package.json",
JSON.stringify(
{
name: "@fern-api/fern-ruby-model",
version: packageJson.version,
repository: packageJson.repository,
files: ["bundle.cjs", "cli.cjs"],
bin: { "fern-ruby-model": "cli.cjs" }
},
undefined,
2
)
);

// write empty yarn.lock so yarn doesn't try to associate this package with the monorepo
await writeFile("yarn.lock", "");

// install package into new yarn.lock
// YARN_ENABLE_IMMUTABLE_INSTALLS=false so we can modify yarn.lock even when in CI
const { exec } = require("child_process");
exec("YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install", undefined, (error) => {
if (error != null) {
console.error(error);
process.exit(1);
}
});
}
1 change: 1 addition & 0 deletions generators/ruby/model/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "../../../shared/jest.config.shared";
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": {
"type": "git",
"url": "https://github.com/fern-api/fern.git",
"directory": "packages/generators/ruby/model"
"directory": "generators/ruby/model"
},
"files": [
"lib"
Expand All @@ -14,18 +14,22 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"sideEffects": false,
"bin": "./dist/bundle.cjs",
"scripts": {
"clean": "rm -rf ./lib && tsc --build --clean",
"compile": "tsc --build",
"test": "yarn compile && jest --passWithNoTests",
"lint:eslint": "eslint --max-warnings 0 . --ignore-path=../../../../.eslintignore --report-unused-disable-directives",
"lint:eslint": "eslint --max-warnings 0 . --ignore-path=../../../.eslintignore --report-unused-disable-directives",
"lint:eslint:fix": "yarn lint:eslint --fix",
"format": "prettier --write --ignore-unknown --ignore-path ../../../../shared/.prettierignore \"**\"",
"format:check": "prettier --check --ignore-unknown --ignore-path ../../../../shared/.prettierignore \"**\"",
"format": "prettier --write --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"",
"format:check": "prettier --check --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"",
"organize-imports": "organize-imports-cli tsconfig.json",
"depcheck": "depcheck",
"dockerTagLocal": "sh ./docker/create_docker.sh local",
"dockerTagVersion": "sh ./docker/create_docker.sh"
"env:prod": "env-cmd -r .env-cmdrc.cjs -e prod",
"dist:cli": "yarn compile && node build.cjs",
"publish:cli": "yarn dist:cli && cd dist && yarn npm publish",
"dockerTagLatest": "yarn dist:cli && docker build -f ./Dockerfile -t fernapi/fern-ruby-model:latest ../../..",
"dockerTagVersion": "yarn dist:cli && docker build -f ./Dockerfile -t fernapi/fern-ruby-model:${0} ../../.."
},
"dependencies": {
"@fern-api/fs-utils": "workspace:*",
Expand All @@ -40,12 +44,14 @@
"@types/jest": "^29.0.3",
"@types/lodash-es": "^4.17.7",
"@types/node": "^18.7.18",
"@yarnpkg/esbuild-plugin-pnp": "^3.0.0-rc.14",
"depcheck": "^1.4.6",
"env-cmd": "toddbluhm/env-cmd",
"esbuild": "^0.15.7",
"eslint": "^8.56.0",
"jest": "^29.7.0",
"organize-imports-cli": "^0.10.0",
"prettier": "^2.7.1",
"simple-progress-webpack-plugin": "^2.0.0",
"ts-loader": "^9.3.1",
"typescript": "4.6.4",
"webpack": "^5.88.2",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions generators/ruby/model/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../shared/tsconfig.shared.json",
"compilerOptions": { "composite": true, "outDir": "lib", "rootDir": "src" },
"include": ["./src"],
"references": [
{ "path": "../../../packages/commons/fs-utils" },
{ "path": "../../../packages/generators/cli" },
{ "path": "../../../packages/generators/commons" }
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions generators/ruby/sdk/.depcheckrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"ignores": [
"@types/jest",
"@types/node",
"esbuild",
"@yarnpkg/esbuild-plugin-pnp",
"webpack",
"webpack-cli",
"ts-loader",
"@fern-fern/ir-sdk"
],
"ignore-patterns": ["lib", "dist", "docker/bundle.js"]
}
3 changes: 3 additions & 0 deletions generators/ruby/sdk/.env-cmdrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
prod: {}
};
22 changes: 22 additions & 0 deletions generators/ruby/sdk/.mrlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"type": "cli",
"cliName": "fern-ruby-sdk",
"environment": {
"environments": {
"prod": {
"cliName": "fern-ruby-sdk",
"cliPackageName": "@fern-api/fern-ruby-sdk"
}
}
},
"rules": {
"depcheck": {
"ignores": ["webpack", "webpack-cli", "ts-loader", "@fern-fern/ir-sdk"],
"ignore-patterns": ["docker/bundle.js"]
},
"duplicate-dependencies": {
"exclude": ["@fern-fern/ir-sdk"]
}
},
"private": false
}
1 change: 1 addition & 0 deletions generators/ruby/sdk/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("../../../.prettierrc.json");
67 changes: 67 additions & 0 deletions generators/ruby/sdk/build.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const { pnpPlugin } = require("@yarnpkg/esbuild-plugin-pnp");
const { build } = require("esbuild");
const path = require("path");
const { chmod, writeFile, mkdir } = require("fs/promises");

const packageJson = require("./package.json");

main();

async function main() {
const options = {
platform: "node",
target: "node14",
entryPoints: ["./src/cli.ts"],
outfile: "./dist/bundle.cjs",
bundle: true,
external: ["cpu-features"],
plugins: [pnpPlugin()],
define: {
"process.env.CLI_NAME": JSON.stringify("fern-ruby-sdk"),
"process.env.CLI_VERSION": JSON.stringify(packageJson.version),
"process.env.CLI_PACKAGE_NAME": JSON.stringify("@fern-api/fern-ruby-sdk")
}
};

await build(options).catch(() => process.exit(1));

process.chdir(path.join(__dirname, "dist"));

// write cli executable
await writeFile(
"cli.cjs",
`#!/usr/bin/env node
require("./bundle.cjs");`
);
await chmod("cli.cjs", "755");

// write cli's package.json
await writeFile(
"package.json",
JSON.stringify(
{
name: "@fern-api/fern-ruby-sdk",
version: packageJson.version,
repository: packageJson.repository,
files: ["bundle.cjs", "cli.cjs"],
bin: { "fern-ruby-sdk": "cli.cjs" }
},
undefined,
2
)
);

// write empty yarn.lock so yarn doesn't try to associate this package with the monorepo
await writeFile("yarn.lock", "");

// install package into new yarn.lock
// YARN_ENABLE_IMMUTABLE_INSTALLS=false so we can modify yarn.lock even when in CI
const { exec } = require("child_process");
exec("YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install", undefined, (error) => {
if (error != null) {
console.error(error);
process.exit(1);
}
});
}
1 change: 1 addition & 0 deletions generators/ruby/sdk/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "../../../shared/jest.config.shared";
Loading

0 comments on commit c8b1432

Please sign in to comment.