Skip to content

Commit

Permalink
s/rome/biome (#1636)
Browse files Browse the repository at this point in the history
  • Loading branch information
lolopinto authored Sep 5, 2023
1 parent 748ef42 commit e0482ff
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] @swc/[email protected] @swc/[email protected] jest rome@12.0.0
- run: npm install -g ts-node prettier@3.0.3 [email protected] @swc/[email protected] @swc/[email protected] jest @biomejs/biome@1.0.0
- run: |
cd ts
npm ci
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/advanced-topics/running-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ python3 -m pip install auto_schema==0.0.26
* Install the following TypeScript packages globally:

```shell
npm install -g [email protected] prettier@2.3.2 [email protected] @swc/[email protected] @swc/[email protected] rome@10.0.1
npm install -g [email protected] prettier@3.0.3 [email protected] @swc/[email protected] @swc/[email protected] @biomejs/biome@1.0.0
```

* Install `tsconfig-paths` and `@swc-node/register` locally:
Expand Down
2 changes: 2 additions & 0 deletions examples/ent-rsvp/backend/src/schema/schema.py

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

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

2 changes: 2 additions & 0 deletions examples/todo-sqlite/src/schema/schema.py

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

22 changes: 11 additions & 11 deletions internal/codegen/codegen_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions internal/codegen/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
Expand 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",
}

Expand Down
13 changes: 7 additions & 6 deletions internal/schema/input/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion release_image/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ RUN \

RUN apt update && apt --assume-yes install zsh && \
rm -rf /var/lib/apt/lists/*
RUN npm install -g [email protected] [email protected].0 [email protected] @swc/[email protected] @swc/[email protected] [email protected]
RUN npm install -g [email protected] [email protected].3 [email protected] @swc/[email protected] @swc/[email protected] @biomejs/[email protected]

WORKDIR /app
RUN npm install --save-dev [email protected] @swc-node/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion ts/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ RUN \
RUN apt update && apt --assume-yes install zsh && \
rm -rf /var/lib/apt/lists/*

RUN npm install -g [email protected] [email protected].0 [email protected] @swc/[email protected] @swc/[email protected] [email protected]
RUN npm install -g [email protected] [email protected].3 [email protected] @swc/[email protected] @swc/[email protected] [email protected]

WORKDIR /app
RUN npm install --save-dev [email protected] @swc-node/[email protected]
Expand Down
22 changes: 11 additions & 11 deletions ts/package-lock.json

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

2 changes: 1 addition & 1 deletion ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 8 additions & 7 deletions ts/src/parse_schema/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ interface Result {
patterns: patternsDict;
globalSchema?: ProcessedGlobalSchema;
config?: {
rome?: RomeConfig;
// TODO rename this to biome eventually...
rome?: BiomeConfig;
};
}

Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tsent/cmd/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tsent/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit e0482ff

Please sign in to comment.