Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(codegen): fix use of prettier.format for codegen #2393

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
},
"devDependencies": {
"@atproto/dev-env": "workspace:^",
"@babel/core": "^7.18.6",
"@babel/preset-env": "^7.18.6",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@swc/core": "^1.3.42",
Expand All @@ -40,7 +38,6 @@
"@types/node": "^18.19.24",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"babel-eslint": "^10.1.0",
"dotenv": "^16.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -50,7 +47,7 @@
"pino-pretty": "^9.1.0",
"prettier": "^3.2.5",
"prettier-config-standard": "^7.0.0",
"typescript": "^5.3.3"
"typescript": "^5.4.4"
},
"workspaces": {
"packages": [
Expand Down
3 changes: 2 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"devDependencies": {
"@atproto/lex-cli": "workspace:^",
"get-port": "^6.1.2",
"jest": "^28.1.2"
"jest": "^28.1.2",
"prettier": "^3.2.5"
}
}
2 changes: 1 addition & 1 deletion packages/api/scripts/code/labels.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function gen() {
2,
)}
`,
{ semi: false, parser: 'babel', singleQuote: true },
{ semi: false, parser: 'typescript', singleQuote: true },
)
}

Expand Down
1 change: 1 addition & 0 deletions packages/lex-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@atproto/syntax": "workspace:^",
"chalk": "^4.1.2",
"commander": "^9.4.0",
"prettier": "^3.2.5",
"ts-morph": "^16.0.0",
"yesno": "^0.4.0",
"zod": "^3.21.4"
Expand Down
26 changes: 13 additions & 13 deletions packages/lex-cli/src/codegen/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import prettier from 'prettier'
import { GeneratedFile } from '../types'

const PRETTIER_OPTS = {
parser: 'babel-ts',
parser: 'typescript',
tabWidth: 2,
semi: false,
singleQuote: true,
Expand All @@ -14,17 +14,17 @@ const PRETTIER_OPTS = {
export const utilTs = (project) =>
gen(project, '/util.ts', async (file) => {
file.replaceWithText(`
export function isObj(v: unknown): v is Record<string, unknown> {
return typeof v === 'object' && v !== null
}
export function hasProp<K extends PropertyKey>(
data: object,
prop: K,
): data is Record<K, unknown> {
return prop in data
}
`)
export function isObj(v: unknown): v is Record<string, unknown> {
return typeof v === 'object' && v !== null
}

export function hasProp<K extends PropertyKey>(
data: object,
prop: K,
): data is Record<K, unknown> {
return prop in data
}
`)
})

export const lexiconsTs = (project, lexicons: LexiconDoc[]) =>
Expand Down Expand Up @@ -122,7 +122,7 @@ export async function gen(
const src = project.getFileSystem().readFileSync(path)
return {
path: path,
content: `${banner()}${prettier.format(src, PRETTIER_OPTS)}`,
content: `${banner()}${await prettier.format(src, PRETTIER_OPTS)}`,
}
}

Expand Down
Loading
Loading