-
Notifications
You must be signed in to change notification settings - Fork 10
Update translatte commands #2099
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,12 +13,15 @@ | |
| "translatte": "tsx scripts/translatte/main.ts", | ||
| "translatte:generate": "pnpm translatte generate-migration ../translationMigrations ./src/**/i18n.json ../packages/ui/src/**/i18n.json", | ||
| "translatte:lint": "pnpm translatte lint ./src/**/i18n.json ../packages/ui/src/**/i18n.json", | ||
| "initialize:type": "mkdir -p generated/ && pnpm initialize:type:go-api && pnpm initialize:type:risk-api", | ||
| "translatte:lint-migrations": "pnpm translatte lint-migrations ../translationMigrations", | ||
| "initialize:type": "mkdir -p generated/ && pnpm initialize:type:go-api && pnpm initialize:type:risk-api && pnpm initialize:type:translations", | ||
| "initialize:type:go-api": "test -f ./generated/types.ts && true || cp types.stub.ts ./generated/types.ts", | ||
| "initialize:type:risk-api": "test -f ./generated/riskTypes.ts && true || cp types.stub.ts ./generated/riskTypes.ts", | ||
| "generate:type": "pnpm generate:type:go-api && pnpm generate:type:risk-api", | ||
| "initialize:type:translations": "test -f ./generated/translationTypes.ts && true || cp types.stub.ts ./generated/translationTypes.ts", | ||
| "generate:type": "pnpm generate:type:go-api && pnpm generate:type:risk-api && pnpm generate:type:translations", | ||
| "generate:type:go-api": "openapi-typescript ../go-api/assets/openapi-schema.yaml -o ./generated/types.ts --alphabetize", | ||
| "generate:type:risk-api": "dotenv -- cross-var openapi-typescript ../go-risk-module-api/openapi-schema.yaml -o ./generated/riskTypes.ts --alphabetize", | ||
| "generate:type:risk-api": "openapi-typescript ../go-risk-module-api/openapi-schema.yaml -o ./generated/riskTypes.ts --alphabetize", | ||
| "generate:type:translations": "dotenv -- cross-var openapi-typescript \"%APP_TRANSLATION_API_ENDPOINT%openapi.json\" -o ./generated/translationTypes.ts --alphabetize", | ||
| "prestart": "pnpm initialize:type", | ||
| "start": "pnpm -F @ifrc-go/ui build && vite", | ||
| "prebuild": "pnpm initialize:type", | ||
|
|
@@ -29,7 +32,7 @@ | |
| "prelint:js": "pnpm initialize:type", | ||
| "lint:js": "eslint src", | ||
| "lint:css": "stylelint \"./src/**/*.css\"", | ||
| "lint:translation": "pnpm translatte:lint", | ||
| "lint:translation": "pnpm translatte:lint && pnpm translatte:lint-migrations", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need a separate lint-migrations command?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It checks for "divirging" migrations |
||
| "lint": "pnpm lint:js && pnpm lint:css && pnpm lint:translation", | ||
| "lint:fix": "pnpm lint:js --fix && pnpm lint:css --fix", | ||
| "test": "vitest", | ||
|
|
@@ -48,7 +51,7 @@ | |
| "@togglecorp/toggle-request": "^1.0.0-beta.3", | ||
| "@turf/bbox": "^6.5.0", | ||
| "@turf/buffer": "^6.5.0", | ||
| "exceljs": "^4.3.0", | ||
| "exceljs": "^4.4.0", | ||
| "file-saver": "^2.0.5", | ||
| "html-to-image": "^1.11.11", | ||
| "mapbox-gl": "^1.13.0", | ||
|
|
@@ -57,7 +60,8 @@ | |
| "react": "^18.2.0", | ||
| "react-dom": "^18.2.0", | ||
| "react-router-dom": "^6.18.0", | ||
| "sanitize-html": "^2.10.0" | ||
| "sanitize-html": "^2.10.0", | ||
| "xlsx": "^0.18.5" | ||
| }, | ||
| "devDependencies": { | ||
| "@eslint/eslintrc": "^3.2.0", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { listToGroupList } from '@togglecorp/fujs'; | ||
| import { getMigrationFilesAttrs } from '../utils'; | ||
|
|
||
| async function lintMigrations(projectPath: string, path: string) { | ||
| const migrationFileAttrs = await getMigrationFilesAttrs(projectPath, path); | ||
| console.info(`Found ${migrationFileAttrs.length} migration files.`); | ||
|
|
||
| const migrationGroups = listToGroupList( | ||
| migrationFileAttrs, | ||
| ({ migrationName }) => migrationName, | ||
| ); | ||
|
|
||
| const duplicates = Object.values(migrationGroups).filter((group) => group.length > 1); | ||
|
|
||
| if (duplicates.length > 0) { | ||
| const duplicateStr = duplicates.map((duplicate) => ( | ||
| duplicate.map(({ migrationName }) => migrationName).join(' <> ') | ||
| )).join('\n'); | ||
|
|
||
| console.info(duplicateStr); | ||
|
|
||
| throw `Error: found divirging migrations!`; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Msot liekly |
||
| } | ||
|
|
||
| console.info('All good! No divirging migrations!'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yse! |
||
| } | ||
|
|
||
| export default lintMigrations; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just add a dummy URL here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used to generate the typings