Skip to content

Commit

Permalink
Template rename
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemilla committed Jul 9, 2024
1 parent 05de907 commit e436edc
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 36 deletions.
6 changes: 3 additions & 3 deletions generators/template/codegen/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@fern-api/SHORT_LANG-codegen",
"name": "@fern-api/template-codegen",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "https://github.com/fern-api/fern.git",
"directory": "generators/SHORT_LANG/codegen"
"directory": "generators/template/codegen"
},
"files": [
"lib"
Expand Down Expand Up @@ -42,4 +42,4 @@
"prettier": "^2.7.1",
"typescript": "4.6.4"
}
}
}
2 changes: 1 addition & 1 deletion generators/template/codegen/src/ast/Class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AstNode, Writer } from "@fern-api/generator-commons";
import LANGUAGE, { Func } from "../SHORT_LANG";
import LANGUAGE, { Func } from "../template";

export declare namespace Class {
interface Args {
Expand Down
2 changes: 1 addition & 1 deletion generators/template/codegen/src/ast/File.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AstNode, Writer } from "@fern-api/generator-commons";
import LANGUAGE, { Class } from "../SHORT_LANG";
import LANGUAGE, { Class } from "../template";

export declare namespace File {
interface Args {
Expand Down
2 changes: 1 addition & 1 deletion generators/template/codegen/src/ast/Func.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AstNode, Writer } from "@fern-api/generator-commons";
import LANGUAGE from "../SHORT_LANG";
import LANGUAGE from "../template";

export declare namespace Func {
interface Args {
Expand Down
6 changes: 3 additions & 3 deletions generators/template/codegen/src/ast/__test__/Language.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import LANGUAGE from "../../SHORT_LANG";
import LANGUAGE from "../../template";
import { FileGenerator } from "@fern-api/generator-commons";

describe("LANGUAGE Language", () => {
Expand Down Expand Up @@ -28,7 +28,7 @@ describe("LANGUAGE Language", () => {

it("makes file", () => {
const output = LANGUAGE.makeFile({
name: "FernExample.SHORT_LANG",
name: "FernExample.template",
class: LANGUAGE.makeClass({
name: "Example",
functions: [
Expand All @@ -42,7 +42,7 @@ describe("LANGUAGE Language", () => {
FileGenerator.generate({
fileName: "Sample",
node: output,
extension: "SHORT_LANG",
extension: "template",
outputDir: "src/ast/__test__",
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as Ast from "./ast";
export * from "./ast";

export default class FULL_LANGUAGE_NAME {
export default class LANGUAGE {

static indentSize = 4;

Expand Down
8 changes: 4 additions & 4 deletions scripts/create-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ replace_full_language_name() {
# Call the function to replace "LANGUAGE" in all files within the new directory
replace_full_language_name "$original_name"

# Function to recursively replace "SHORT_LANG" in all files and filenames
# Function to recursively replace "template" in all files and filenames
replace_language_name() {
local directory="$1"
local new_name="$2"

# Replace in filenames first
find "$directory" -depth -name "*SHORT_LANG*" -execdir bash -c 'mv "$1" "${1//SHORT_LANG/'"$new_name"'}"' _ {} \;
find "$directory" -depth -name "*template*" -execdir bash -c 'mv "$1" "${1//template/'"$new_name"'}"' _ {} \;

# Replace in file contents
find "$directory" -type f -exec sed -i '' -e "s/SHORT_LANG/$new_name/g" {} +
find "$directory" -type f -exec sed -i '' -e "s/template/$new_name/g" {} +
}

# Call the function to replace "SHORT_LANG" in all files and filenames within the new directory
# Call the function to replace "template" in all files and filenames within the new directory
replace_language_name "$new_dir" "$new_name"

echo "Directory '$new_name' created successfully at '$new_dir'"
Expand Down
62 changes: 40 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1810,28 +1810,6 @@ __metadata:
languageName: node
linkType: hard

"@fern-api/SHORT_LANG-codegen@workspace:generators/template/codegen":
version: 0.0.0-use.local
resolution: "@fern-api/SHORT_LANG-codegen@workspace:generators/template/codegen"
dependencies:
"@fern-api/core-utils": "workspace:*"
"@fern-api/fs-utils": "workspace:*"
"@fern-api/generator-commons": "workspace:*"
"@fern-api/logging-execa": "workspace:*"
"@types/jest": ^29.0.3
"@types/lodash-es": ^4.17.12
"@types/node": ^18.7.18
depcheck: ^1.4.6
eslint: ^8.56.0
jest: ^29.7.0
lodash-es: ^4.17.21
organize-imports-cli: ^0.10.0
prettier: ^2.7.1
typescript: 4.6.4
zod: ^3.22.3
languageName: unknown
linkType: soft

"@fern-api/auth@workspace:*, @fern-api/auth@workspace:packages/cli/auth":
version: 0.0.0-use.local
resolution: "@fern-api/auth@workspace:packages/cli/auth"
Expand Down Expand Up @@ -2998,6 +2976,26 @@ __metadata:
languageName: unknown
linkType: soft

"@fern-api/rust-codegen@workspace:generators/rust/codegen":
version: 0.0.0-use.local
resolution: "@fern-api/rust-codegen@workspace:generators/rust/codegen"
dependencies:
"@fern-api/core-utils": "workspace:*"
"@fern-api/fs-utils": "workspace:*"
"@fern-api/generator-commons": "workspace:*"
"@fern-api/logging-execa": "workspace:*"
"@types/jest": ^29.0.3
"@types/node": ^18.7.18
depcheck: ^1.4.6
eslint: ^8.56.0
jest: ^29.7.0
organize-imports-cli: ^0.10.0
prettier: ^2.7.1
typescript: 4.6.4
zod: ^3.22.3
languageName: unknown
linkType: soft

"@fern-api/scripts@workspace:packages/scripts":
version: 0.0.0-use.local
resolution: "@fern-api/scripts@workspace:packages/scripts"
Expand Down Expand Up @@ -3124,6 +3122,26 @@ __metadata:
languageName: unknown
linkType: soft

"@fern-api/template-codegen@workspace:generators/template/codegen":
version: 0.0.0-use.local
resolution: "@fern-api/template-codegen@workspace:generators/template/codegen"
dependencies:
"@fern-api/core-utils": "workspace:*"
"@fern-api/fs-utils": "workspace:*"
"@fern-api/generator-commons": "workspace:*"
"@fern-api/logging-execa": "workspace:*"
"@types/jest": ^29.0.3
"@types/node": ^18.7.18
depcheck: ^1.4.6
eslint: ^8.56.0
jest: ^29.7.0
organize-imports-cli: ^0.10.0
prettier: ^2.7.1
typescript: 4.6.4
zod: ^3.22.3
languageName: unknown
linkType: soft

"@fern-api/validator@workspace:*, @fern-api/validator@workspace:packages/cli/yaml/validator":
version: 0.0.0-use.local
resolution: "@fern-api/validator@workspace:packages/cli/yaml/validator"
Expand Down

0 comments on commit e436edc

Please sign in to comment.