From e0482ffae625ea0ca24631c2d054c71e6bde56a3 Mon Sep 17 00:00:00 2001 From: Ola Okelola <10857143+lolopinto@users.noreply.github.com> Date: Tue, 5 Sep 2023 16:22:59 -0700 Subject: [PATCH] s/rome/biome (#1636) --- .github/workflows/e2e.yml | 2 +- docs/docs/advanced-topics/running-locally.md | 2 +- .../ent-rsvp/backend/src/schema/schema.py | 2 ++ .../feedback/actions/feedback_builder.ts | 4 +--- examples/todo-sqlite/src/schema/schema.py | 2 ++ internal/codegen/codegen_processor.go | 22 +++++++++---------- internal/codegen/config.go | 10 ++++----- internal/schema/input/input.go | 13 ++++++----- release_image/main.go | 2 +- ts/Dockerfile | 2 +- ts/Dockerfile.tmpl | 2 +- ts/package-lock.json | 22 +++++++++---------- ts/package.json | 2 +- ts/src/parse_schema/parse.ts | 15 +++++++------ tsent/cmd/codegen.go | 2 +- tsent/cmd/root.go | 2 +- 16 files changed, 55 insertions(+), 51 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 28e46466a..547db6475 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -68,7 +68,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18.x - - run: npm install -g ts-node prettier@2.8.8 typescript@5.0.4 @swc/core@1.3.57 @swc/cli@0.1.62 jest rome@12.0.0 + - run: npm install -g ts-node prettier@3.0.3 typescript@5.0.4 @swc/core@1.3.57 @swc/cli@0.1.62 jest @biomejs/biome@1.0.0 - run: | cd ts npm ci diff --git a/docs/docs/advanced-topics/running-locally.md b/docs/docs/advanced-topics/running-locally.md index 49c8dd499..dcf742c16 100644 --- a/docs/docs/advanced-topics/running-locally.md +++ b/docs/docs/advanced-topics/running-locally.md @@ -32,7 +32,7 @@ python3 -m pip install auto_schema==0.0.26 * Install the following TypeScript packages globally: ```shell -npm install -g typescript@4.4.2 prettier@2.3.2 ts-node@10.7 @swc/core@1.3.57 @swc/cli@0.1.62 rome@10.0.1 +npm install -g typescript@4.4.2 prettier@3.0.3 ts-node@10.7 @swc/core@1.3.57 @swc/cli@0.1.62 @biomejs/biome@1.0.0 ``` * Install `tsconfig-paths` and `@swc-node/register` locally: diff --git a/examples/ent-rsvp/backend/src/schema/schema.py b/examples/ent-rsvp/backend/src/schema/schema.py index a57863342..a3c9469c1 100644 --- a/examples/ent-rsvp/backend/src/schema/schema.py +++ b/examples/ent-rsvp/backend/src/schema/schema.py @@ -177,5 +177,7 @@ + + def get_metadata(): return metadata diff --git a/examples/simple/src/ent/generated/mixins/feedback/actions/feedback_builder.ts b/examples/simple/src/ent/generated/mixins/feedback/actions/feedback_builder.ts index c026b2d87..15046498b 100644 --- a/examples/simple/src/ent/generated/mixins/feedback/actions/feedback_builder.ts +++ b/examples/simple/src/ent/generated/mixins/feedback/actions/feedback_builder.ts @@ -7,9 +7,7 @@ import { AssocEdgeInputOptions, Ent, ID } from "@snowtop/ent"; import { Builder, Orchestrator } from "@snowtop/ent/action"; import { EdgeType, NodeType } from "../../../types"; import { Comment, IFeedback, User } from "../../../../internal"; -import { - ExampleViewer as ExampleViewerAlias, -} from "../../../../../viewer/viewer"; +import { ExampleViewer as ExampleViewerAlias } from "../../../../../viewer/viewer"; interface IEntWithFeedback extends Ent, IFeedback {} diff --git a/examples/todo-sqlite/src/schema/schema.py b/examples/todo-sqlite/src/schema/schema.py index 8455386c0..f06d462a1 100644 --- a/examples/todo-sqlite/src/schema/schema.py +++ b/examples/todo-sqlite/src/schema/schema.py @@ -173,5 +173,7 @@ + + def get_metadata(): return metadata diff --git a/internal/codegen/codegen_processor.go b/internal/codegen/codegen_processor.go index 4f8680f58..4b5e2163d 100644 --- a/internal/codegen/codegen_processor.go +++ b/internal/codegen/codegen_processor.go @@ -207,12 +207,12 @@ func (p *Processor) FormatTS() error { return p.formatWithPrettier() } - return p.formatWithRome() + return p.formatWithBiome() } -func (p *Processor) formatWithRome() error { - rome := p.Config.GetRomeConfig() - // get files without "generated" in the path and pass them manually to rome +func (p *Processor) formatWithBiome() error { + biome := p.Config.GetBiomeConfig() + // get files without "generated" in the path and pass them manually to biome // for the generated paths, we'll pass src/ent/generated and src/graphql/generated to handle that var nonGenerated []string root := p.Config.GetAbsPathToRoot() @@ -230,14 +230,14 @@ func (p *Processor) formatWithRome() error { } var args []string - if rome != nil { - args = rome.GetArgs() + if biome != nil { + args = biome.GetArgs() } else { - args = defaultRomeArgs + args = defaultBiomeArgs } if len(args) == 0 { if p.debugMode { - fmt.Printf("no args to pass to rome to format\n") + fmt.Printf("no args to pass to biome to format\n") } return nil } @@ -259,7 +259,7 @@ func (p *Processor) formatWithRome() error { args = append(args, nonGenerated...) args = append([]string{"format"}, args...) - cmd := exec.Command("rome", args...) + cmd := exec.Command("biome", args...) var stderr bytes.Buffer cmd.Stderr = &stderr if err := cmd.Run(); err != nil { @@ -381,9 +381,9 @@ type constructOption struct { debugFilesMode bool writeAll bool forceWriteAll bool - // we're using rome as default for now so + // we're using biome as default for now so // this provides a way to force prettier if we want to test or if somehow something - // wrong with rome + // wrong with biome forcePrettier bool buildInfo *build_info.BuildInfo cfg *Config diff --git a/internal/codegen/config.go b/internal/codegen/config.go index 2efababb1..699251b53 100644 --- a/internal/codegen/config.go +++ b/internal/codegen/config.go @@ -295,11 +295,11 @@ func (cfg *Config) DummyWrite() bool { return cfg.dummyWrite } -func (cfg *Config) GetRomeConfig() *input.RomeConfig { +func (cfg *Config) GetBiomeConfig() *input.BiomeConfig { if cfg.inputConfig == nil { return nil } - return cfg.inputConfig.RomeConfig + return cfg.inputConfig.BiomeConfig } func (cfg *Config) SetDummyWrite(val bool) { @@ -500,7 +500,7 @@ func (cfg *Config) CustomSQLExclude() []string { const DEFAULT_PRETTIER_GLOB = "src/**/*.ts" const PRETTIER_FILE_CHUNKS = 20 -// use rome instead of prettier to speed up +// use biome instead of prettier to speed up // options: https://prettier.io/docs/en/options.html var defaultArgs = []string{ "--trailing-comma", "all", @@ -509,9 +509,9 @@ var defaultArgs = []string{ "--end-of-line", "lf", } -// options: https://docs.rome.tools/formatter/#use-the-formatter-with-the-cli +// options: https://biomejs.dev/reference/cli/#biome // everything else is sticking with default... -var defaultRomeArgs = []string{ +var defaultBiomeArgs = []string{ "--indent-style", "space", } diff --git a/internal/schema/input/input.go b/internal/schema/input/input.go index d24c9959c..433dbca4b 100644 --- a/internal/schema/input/input.go +++ b/internal/schema/input/input.go @@ -20,15 +20,16 @@ type Schema struct { type Config struct { // the prettier config that's being used is parsed and sent up to format the files as needed - // since we're trying to use rome... - RomeConfig *RomeConfig `json:"rome"` + // since we're trying to use biome... + // for now keep this named as rome but eventually change to biome? + BiomeConfig *BiomeConfig `json:"rome"` } -// indicates the rome onfig that should be used here +// indicates the biome onfig that should be used here // taken from the prettier config // https://prettier.io/docs/en/options.html#quotes -// https://docs.rome.tools/formatter/#use-the-formatter-with-the-cli -type RomeConfig struct { +// https://biomejs.dev/reference/cli/#biome +type BiomeConfig struct { // we always do --indent-style=space IndentStyle *string `json:"indentStyle"` LineWidth *int `json:"lineWidth"` @@ -38,7 +39,7 @@ type RomeConfig struct { TrailingComma *string `json:"trailingComma"` } -func (cfg *RomeConfig) GetArgs() []string { +func (cfg *BiomeConfig) GetArgs() []string { var ret []string if cfg.IndentStyle != nil { diff --git a/release_image/main.go b/release_image/main.go index 69d83e2da..54a31cae9 100644 --- a/release_image/main.go +++ b/release_image/main.go @@ -18,7 +18,7 @@ import ( ) // next tag to use -const TAG = "v0.1.8.-test4" +const TAG = "v0.1.8.-test5" // current node gets latest tag... const CURRENT_NODE_VERSION = 18 diff --git a/ts/Dockerfile b/ts/Dockerfile index 8f6387d8d..4c909eb3a 100644 --- a/ts/Dockerfile +++ b/ts/Dockerfile @@ -62,7 +62,7 @@ RUN \ RUN apt update && apt --assume-yes install zsh && \ rm -rf /var/lib/apt/lists/* -RUN npm install -g typescript@5.1.6 prettier@3.0.0 ts-node@10.9.1 @swc/core@1.3.68 @swc/cli@0.1.62 rome@12.1.3 +RUN npm install -g typescript@5.1.6 prettier@3.0.3 ts-node@10.9.1 @swc/core@1.3.68 @swc/cli@0.1.62 @biomejs/biome@1.0.0 WORKDIR /app RUN npm install --save-dev tsconfig-paths@4.2.0 @swc-node/register@1.6.6 diff --git a/ts/Dockerfile.tmpl b/ts/Dockerfile.tmpl index ceccc6ce6..a865a46b1 100644 --- a/ts/Dockerfile.tmpl +++ b/ts/Dockerfile.tmpl @@ -62,7 +62,7 @@ RUN \ RUN apt update && apt --assume-yes install zsh && \ rm -rf /var/lib/apt/lists/* -RUN npm install -g typescript@5.1.6 prettier@3.0.0 ts-node@10.9.1 @swc/core@1.3.68 @swc/cli@0.1.62 rome@12.1.3 +RUN npm install -g typescript@5.1.6 prettier@3.0.3 ts-node@10.9.1 @swc/core@1.3.68 @swc/cli@0.1.62 rome@12.1.3 WORKDIR /app RUN npm install --save-dev tsconfig-paths@4.2.0 @swc-node/register@1.6.6 diff --git a/ts/package-lock.json b/ts/package-lock.json index d3bdbae55..d269dc063 100644 --- a/ts/package-lock.json +++ b/ts/package-lock.json @@ -1,12 +1,12 @@ { "name": "@snowtop/ent", - "version": "0.1.0-rc1", + "version": "0.1.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@snowtop/ent", - "version": "0.1.0-rc1", + "version": "0.1.12", "license": "MIT", "dependencies": { "@types/node": "^20.2.5", @@ -22,7 +22,7 @@ "minimist": "^1.2.8", "pascal-case": "^3.1.2", "pg": "^8.11.0", - "prettier": "^2.8.8", + "prettier": "^3.0.3", "snake-case": "^3.0.4", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", @@ -5424,14 +5424,14 @@ } }, "node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", + "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" @@ -10801,9 +10801,9 @@ } }, "prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", + "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==" }, "pretty-format": { "version": "29.5.0", diff --git a/ts/package.json b/ts/package.json index 6a2b59c8e..b5fe375e3 100644 --- a/ts/package.json +++ b/ts/package.json @@ -21,7 +21,7 @@ "minimist": "^1.2.8", "pascal-case": "^3.1.2", "pg": "^8.11.0", - "prettier": "^2.8.8", + "prettier": "^3.0.3", "snake-case": "^3.0.4", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", diff --git a/ts/src/parse_schema/parse.ts b/ts/src/parse_schema/parse.ts index 5226ff7d6..b533b33df 100644 --- a/ts/src/parse_schema/parse.ts +++ b/ts/src/parse_schema/parse.ts @@ -392,7 +392,8 @@ interface Result { patterns: patternsDict; globalSchema?: ProcessedGlobalSchema; config?: { - rome?: RomeConfig; + // TODO rename this to biome eventually... + rome?: BiomeConfig; }; } @@ -493,19 +494,19 @@ export async function parseSchema( schemas[key] = processedSchema; } - const rome = translatePrettier(); + const biome = translatePrettier(); return { schemas, patterns, globalSchema: parsedGlobalSchema, config: { - rome, + rome: biome, }, }; } -interface RomeConfig { +interface BiomeConfig { indentStyle?: string; lineWidth?: number; indentSize?: number; @@ -514,12 +515,12 @@ interface RomeConfig { trailingComma?: string; } -function translatePrettier(): RomeConfig | undefined { +function translatePrettier(): BiomeConfig | undefined { const r = cosmiconfigSync("prettier").search(); if (!r) { return; } - const ret: RomeConfig = {}; + const ret: BiomeConfig = {}; if (r.config.printWidth !== undefined) { ret.lineWidth = parseInt(r.config.printWidth); } @@ -538,7 +539,7 @@ function translatePrettier(): RomeConfig | undefined { } if (r.config.quoteProps !== undefined) { if (r.config.quoteProps === "consistent") { - // rome doesn't support this + // biome doesn't support this ret.quoteProperties = "as-needed"; } else { ret.quoteProperties = r.config.quoteProps; diff --git a/tsent/cmd/codegen.go b/tsent/cmd/codegen.go index 603781749..edba0b4d3 100644 --- a/tsent/cmd/codegen.go +++ b/tsent/cmd/codegen.go @@ -85,7 +85,7 @@ var codegenCmd = &cobra.Command{ if codegenInfo.forcePrettier { opts = append(opts, codegen.ForcePrettier()) } else { - // automatically force write-all with rome + // automatically force write-all with biome opts = append(opts, codegen.ForceWriteAll()) } // same as ParseSchemaFromTSDir. default to schema. we want a flag here eventually diff --git a/tsent/cmd/root.go b/tsent/cmd/root.go index d6ff62c31..d1964d601 100644 --- a/tsent/cmd/root.go +++ b/tsent/cmd/root.go @@ -102,7 +102,7 @@ func init() { codegenCmd.Flags().BoolVar(&codegenInfo.disableCustomGraphQL, "disable-custom-graphql", false, "to disable custom graphql during codegen. used when we need to rebuild everything and minimize parsing code") codegenCmd.Flags().BoolVar(&codegenInfo.disablePrompts, "disable_prompts", false, "disable prompts") codegenCmd.Flags().BoolVar(&codegenInfo.disableUpgrade, "disable_upgrade", false, "disable upgrade when running codegen. codegen automatically checks that the db is upgraded before making any changes. if you want to disable that for any reason, use this flag") - codegenCmd.Flags().BoolVar(&codegenInfo.forcePrettier, "force_prettier", false, "force prettier instead of rome when running codegen.") + codegenCmd.Flags().BoolVar(&codegenInfo.forcePrettier, "force_prettier", false, "force prettier instead of biome when running codegen.") generateSchemasCmd.Flags().StringVar(&schemasInfo.file, "file", "", "file to get data from. also supports piping it through") generateSchemasCmd.Flags().BoolVar(&schemasInfo.force, "force", false, "if force is true, it overwrites existing schema, otherwise throws error")