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
Move create-keystone-app package inside the monorepo #9102
base: main
Are you sure you want to change the base?
Move create-keystone-app package inside the monorepo #9102
Conversation
01d031a
to
2ffc70a
Compare
2ffc70a
to
c5f6d71
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit aa5a82f:
|
@dcousens please take a look, and tell me please if I need to change something else. |
I don't mind the idea of different templates, but let's focus on this being a 1:1 move into this monorepo from our |
@iamandrewluca before I review this in depth, can you please highlight any changes you needed to make when porting this from https://github.com/keystonejs/create-keystone-app (as comments on the diff). This will help me focus on what is different instead of reviewing the existing |
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.
The process of creating this package was to do these steps:
- Make a copy of
auth
module - Cleanup everything from
auth
module and leave the bare minimum - Copy starter files from other repo
- Copy source code from other repo
- Apply the changes from this MR on source-code
- Adjust package.json and cli.js to build and run ok with preconstruct
const installDeps = async (cwd: string): Promise<string> => { | ||
const pkgManager = pkgManagerFromUserAgent(process.env.npm_config_user_agent); | ||
const spinner = ora( | ||
`Installing dependencies with ${pkgManager}. This may take a few minutes.` | ||
).start(); | ||
try { | ||
await execa(pkgManager, ['install'], { cwd }); | ||
spinner.succeed(`Installed dependencies with ${pkgManager}.`); | ||
return pkgManager; | ||
} catch (err) { | ||
spinner.fail(`Failed to install with ${pkgManager}.`); | ||
throw err; | ||
} | ||
}; |
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 function was refactored to detect the package manager instead of trying yarn and then npm
pkgManagerFromUserAgent
is an adaptation of https://github.com/vitejs/vite/blob/2d50be2a5424e4f4c22774652ed313d2a232f8af/packages/create-vite/src/index.ts#L538-L546
import { UserError } from './utils'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
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.
Marked the package with "type": "module"
in the package.json
so we cannot use __dirname
(not available in ESM) had to use this alternative
PS: The latest version of Node introduced back dirname for ESM via import.meta
"exports": { | ||
".": { | ||
"module": "./dist/create-keystone-app.esm.js", | ||
"default": "./dist/create-keystone-app.cjs.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"preconstruct": { | ||
"entrypoints": [ | ||
"index.ts" | ||
] | ||
}, |
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.
Copied the package.json
from the auth
module and adjusted it to work with this one.
Also marked as "type": "module"
@dcousens I left some comments PS: I synced the branch with the main from upstream. Please check if the pnpm lock file has been updated correctly (don't have much experience with pnpm) On conflict I picked the version from main, then I run a |
PS: I was looking at create-payload-app maybe we can borrow that code for KS also, which will allow multiple KS templates
pnpm publish --dry-run