-
-
Notifications
You must be signed in to change notification settings - Fork 83
Url utils TS migration setup #684
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
Conversation
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.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on December 3
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
d309898 to
69a8293
Compare
3ae53e0 to
34cd4e4
Compare
34cd4e4 to
41554dc
Compare
108f965 to
9bb7431
Compare
ec936c8 to
2dec475
Compare
751eac0 to
9f15a9e
Compare
allouis
left a comment
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.
Can we compile to the lib directory instead of cjs?
That will give us better backwards compatibility with koenig as it reads directly from lib, for example here https://github.com/TryGhost/Koenig/blob/main/packages/kg-default-cards/lib/cards/file.js#L5
packages/url-utils/.gitignore
Outdated
| @@ -0,0 +1,4 @@ | |||
| cjs/ | |||
| umd/ | |||
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.
Do we generate any umd, es or types directories?
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.
No we don't. This didn't get cleared up from rollup.
packages/url-utils/package.json
Outdated
| "pretest": "yarn build", | ||
| "test": "NODE_ENV=testing c8 --src cjs --all --reporter text --reporter cobertura --reporter html mocha './test/**/*.test.js'", | ||
| "build": "tsc -p tsconfig.json", | ||
| "lint": "eslint . --ext .js,.ts --cache", |
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.
If we run this on src explicitly we can get rid of the .eslintignore file
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.
Done
packages/url-utils/tsconfig.json
Outdated
| @@ -0,0 +1,16 @@ | |||
| { | |||
| "compilerOptions": { | |||
| "target": "ES2019", | |||
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.
Any reason for this target? Ghost & ActivityPub use ES2022
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.
No reason actually, updated.
- Added `typescript` to devDependencies - Added `@types/node`, `@types/lodash`, `@types/cheerio` to devDependencies
- Added build scripts to package.json: * build: Compile TypeScript and generate type definitions * pretest: Build before running tests * prepare: Build before publish - Updated files field to include build output directories
- Moved entire `lib/` directory to `src/` directory to follow TypeScript convention - Updated test files to use the new path - Added @ts-nocheck to skip type-check - Updated `index.js` to use compiled output instead of TypeScript source
…ts-nocheck - Allowed @ts-nocheck comments in TypeScript files - Disabled @typescript-eslint/no-var-requires for .ts files - Disabled prefer-const rule for .ts files This ensures linting passes while TypeScript migration is in progress.
3d96b0d to
8045015
Compare
TypeScript Migration for @tryghost/url-utils
Overview
This PR does the basic TS setup for urlUtils without changing/adding the actual types. This adds // @ts-nocheck in code files and changes the dir structure with TS conventions.
Current State
index.js→lib/UrlUtils.jslib/utils/Migration Steps
Checks after this set-up
✅ All tests pass
✅ TypeScript compiles without errors
✅ Package can be imported and used as before
Cursor Summary
Note
Introduce TypeScript build/tooling for
@tryghost/url-utils, migrating sources tosrc/*.ts(ts-nocheck), adding a new early-exit helper, and updating scripts/lint to build tolib/with type declarations.tsconfig.json, compile tolib/withtsc, and export types via"types": "lib/UrlUtils.d.ts".package.jsonscripts (build,prepare,pretest,testnow targetslib,lintsupports.ts), and.gitignoreto ignorelib/.plugin:ghost/tswith overrides for// @ts-nocheckfiles.typescript,@types/*).src/and convert files to.tswith// @ts-nocheck; keep CommonJS exports.src/utils/build-early-exit-match.ts; update HTML/Markdown/plaintext transforms to use it where applicable.index.js->./lib/UrlUtils.Written by Cursor Bugbot for commit 8045015. This will update automatically on new commits. Configure here.