-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
897 changed files
with
15,773 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { AbstractGeneratorContext } from "../AbstractGeneratorContext"; | ||
import { AbsoluteFilePath } from "@fern-api/fs-utils"; | ||
import { File } from "./File"; | ||
|
||
export abstract class AbstractProject<GeneratorContext extends AbstractGeneratorContext> { | ||
public readonly absolutePathToOutputDirectory: AbsoluteFilePath; | ||
public readonly rawFiles: File[] = []; | ||
|
||
public constructor(public readonly context: GeneratorContext) { | ||
this.absolutePathToOutputDirectory = AbsoluteFilePath.of(this.context.config.output.path); | ||
} | ||
|
||
public addRawFiles(file: File): void { | ||
this.rawFiles.push(file); | ||
} | ||
|
||
public async writeRawFiles(): Promise<void> { | ||
await Promise.all(this.rawFiles.map(async (file) => await file.write(this.absolutePathToOutputDirectory))); | ||
} | ||
|
||
/** | ||
* Persists the project by writing it to disk. | ||
*/ | ||
protected abstract persist(): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { AbstractProject } from "./AbstractProject"; | ||
export { File } from "./File"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
export enum AsIsFiles {} | ||
export enum AsIsFiles { | ||
GitIgnore = ".gitignore", | ||
GithubCiYml = "github-ci.yml", | ||
PhpStanNeon = "phpstan.neon", | ||
PhpUnitXml = "phpunit.xml", | ||
RawClient = "RawClient.Template.php", | ||
RawClientTest = "RawClientTest.Template.php" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.php-cs-fixer.cache | ||
.phpunit.result.cache | ||
composer.lock | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace <%= namespace%>; | ||
|
||
class RawClient | ||
{ | ||
public function __construct() | ||
{ | ||
// TODO: Implement me! | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
generators/php/codegen/src/asIs/RawClientTest.Template.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace <%= namespace%>; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class RawClientTest extends TestCase | ||
{ | ||
public function testRawClient() | ||
{ | ||
$this->assertTrue(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: ci | ||
|
||
on: [push] | ||
|
||
jobs: | ||
compile: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Composer | ||
uses: php-actions/composer@v6 | ||
with: | ||
php_version: "8.1" | ||
version: "2.7.9" | ||
|
||
- name: Install tools | ||
run: | | ||
composer install | ||
- name: Build | ||
run: | | ||
composer build | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Composer | ||
uses: php-actions/composer@v6 | ||
with: | ||
php_version: "8.1" | ||
version: "2.7.9" | ||
|
||
- name: Install tools | ||
run: | | ||
composer install | ||
- name: Run Tests | ||
run: | | ||
composer test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
parameters: | ||
level: max | ||
paths: | ||
- src | ||
- tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<phpunit bootstrap="vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
generators/php/codegen/src/context/AbstractPhpGeneratorContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,48 @@ | ||
import { AbstractGeneratorContext, FernGeneratorExec, GeneratorNotificationService } from "@fern-api/generator-commons"; | ||
import { IntermediateRepresentation } from "@fern-fern/ir-sdk/api"; | ||
import { BasePhpCustomConfigSchema } from "../custom-config/BasePhpCustomConfigSchema"; | ||
import { PhpProject } from "../project"; | ||
import { camelCase, upperFirst } from "lodash-es"; | ||
|
||
export abstract class AbstractPhpGeneratorContext< | ||
CustomConfig extends BasePhpCustomConfigSchema | ||
> extends AbstractGeneratorContext { | ||
private namespace: string; | ||
public readonly project: PhpProject; | ||
|
||
public constructor( | ||
public readonly ir: IntermediateRepresentation, | ||
public readonly config: FernGeneratorExec.config.GeneratorConfig, | ||
public readonly customConfig: CustomConfig, | ||
public readonly generatorNotificationService: GeneratorNotificationService | ||
) { | ||
super(config, generatorNotificationService); | ||
this.namespace = this.customConfig.namespace ?? upperFirst(camelCase(`${this.config.organization}`)); | ||
this.project = new PhpProject({ | ||
context: this, | ||
name: this.namespace | ||
}); | ||
} | ||
|
||
public getNamespace(): string { | ||
return this.namespace; | ||
} | ||
|
||
public getTestsNamespace(): string { | ||
return `${this.namespace}\\Tests`; | ||
} | ||
|
||
public getCoreNamespace(): string { | ||
return `${this.namespace}\\Core`; | ||
} | ||
|
||
public getCoreTestsNamespace(): string { | ||
return `${this.namespace}\\Core\\Tests`; | ||
} | ||
|
||
public abstract getRawAsIsFiles(): string[]; | ||
|
||
public abstract getCoreAsIsFiles(): string[]; | ||
|
||
public abstract getCoreTestAsIsFiles(): string[]; | ||
} |
4 changes: 3 additions & 1 deletion
4
generators/php/codegen/src/custom-config/BasePhpCustomConfigSchema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { z } from "zod"; | ||
|
||
export const BasePhpCustomConfigSchema = z.object({}); | ||
export const BasePhpCustomConfigSchema = z.object({ | ||
namespace: z.string().optional() | ||
}); | ||
|
||
export type BasePhpCustomConfigSchema = z.infer<typeof BasePhpCustomConfigSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.