keystone icon indicating copy to clipboard operation
keystone copied to clipboard

Move create-keystone-app package inside the monorepo

Open unrevised6419 opened this issue 1 year ago • 5 comments
trafficstars

  • [X] Move create-keystone-app inside mono-repo
  • [X] https://github.com/keystonejs/create-keystone-app/pull/427

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
✔ You're on branch "feat/move-create-keystone-app" but your "publish-branch" is set to "master|main". Do you want to continue? (y/N) · true
npm notice
npm notice 📦  [email protected]
npm notice === Tarball Contents ===
npm notice 1.1kB LICENSE
npm notice 356B  README.md
npm notice 63B   cli.js
npm notice 295B  dist/create-keystone-app.cjs.d.ts
npm notice 6.6kB dist/create-keystone-app.cjs.dev.js
npm notice 200B  dist/create-keystone-app.cjs.js
npm notice 6.6kB dist/create-keystone-app.cjs.prod.js
npm notice 4.8kB dist/create-keystone-app.esm.js
npm notice 46B   dist/declarations/src/index.d.ts
npm notice 109B  dist/declarations/src/index.d.ts.map
npm notice 971B  package.json
npm notice 42B   starter/_gitignore
npm notice 2.7kB starter/auth.ts
npm notice 1.0kB starter/CHANGELOG.md
npm notice 1.0kB starter/keystone.ts
npm notice 397B  starter/package.json
npm notice 2.9kB starter/README.md
npm notice 9.5kB starter/schema.graphql
npm notice 1.1kB starter/schema.prisma
npm notice 5.2kB starter/schema.ts
npm notice 195B  starter/tsconfig.json
npm notice === Tarball Details ===
npm notice name:          create-keystone-app
npm notice version:       9.0.1
npm notice filename:      create-keystone-app-9.0.1.tgz
npm notice package size:  11.7 kB
npm notice unpacked size: 45.2 kB
npm notice shasum:        decfd7d53d50872d7d10daf98aaa27700786eb95
npm notice integrity:     sha512-CHG5zV1StXuDF[...]WvYe3RzlrnuEw==
npm notice total files:   21
npm notice
npm notice Publishing to https://registry.npmjs.org/ with tag latest and default access (dry-run)
+ [email protected]

unrevised6419 avatar Apr 17 '24 20:04 unrevised6419

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 f4b7d78aeb5d8b7d37f7ccf4c6276dd45233abbe:

Sandbox Source
@keystone-6/sandbox Configuration

codesandbox-ci[bot] avatar Apr 17 '24 20:04 codesandbox-ci[bot]

@dcousens please take a look, and tell me please if I need to change something else.

unrevised6419 avatar Apr 17 '24 20:04 unrevised6419

I was looking at create-payload-app maybe we can borrow that code for KS also, which will allow multiple KS templates

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 create-keystone-app repository, wherever we can, and then we can talk about any UX improvements in a different pull request.

dcousens avatar Apr 24 '24 02:04 dcousens

@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 create-keystone-app code [which is needing a re-write, but that's a different discussion to have after this pull request]

dcousens avatar Apr 24 '24 02:04 dcousens

@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 pnpm install (usually this is what I do with npm on lock conflicts)

unrevised6419 avatar Apr 24 '24 07:04 unrevised6419

Checking the diff against https://github.com/keystonejs/create-keystone-app, and removing a few deprecated files from create-keystone-app, and ignoring the package.json:

diff -r ../../../create-keystone-app/cli.js ./cli.js
2,3c2
< 'use strict';
< require('.');
---
> import './dist/create-keystone-app.esm.js'
diff -r ../../../create-keystone-app/src/index.ts ./src/index.ts
5c5
< import execa, { ExecaError } from 'execa';
---
> import execa from 'execa';
7,8d6
< import { checkVersion } from './checkVersion';
< import { UserError } from './utils';
10a9,11
> import { checkVersion } from './checkVersion';
> import { UserError } from './utils';
> import { fileURLToPath } from 'url';
11a13
> const __dirname = path.dirname(fileURLToPath(import.meta.url));
50c52,53
< const installDeps = async (cwd: string): Promise<'yarn' | 'npm'> => {
---
> async function installDeps (cwd: string) {
>   const pkgManager = (process.env.npm_config_user_agent ?? 'npm').split('/').shift()
52c55
<     'Installing dependencies with yarn. This may take a few minutes.'
---
>     `Installing dependencies with ${pkgManager}. This may take a few minutes.`
55,75c58,62
<     await execa('yarn', ['install'], { cwd });
<     spinner.succeed('Installed dependencies with yarn.');
<     return 'yarn';
<   } catch (_err: any) {
<     let err: ExecaError = _err;
<     if (err.failed) {
<       process.stdout.write('\n');
<       spinner.warn('Failed to install with yarn.');
<       spinner.start(
<         'Installing dependencies with npm. This may take a few minutes.'
<       );
<       try {
<         await execa('npm', ['install'], { cwd });
<         spinner.succeed('Installed dependencies with npm.');
<       } catch (npmErr) {
<         spinner.fail('Failed to install with npm.');
<         throw npmErr;
<       }
<       process.stdout.write('\n');
<       return 'npm';
<     }
---
>     await execa(pkgManager, ['install'], { cwd });
>     spinner.succeed(`Installed dependencies with ${pkgManager}.`);
>     return pkgManager;
>   } catch (err) {
>     spinner.fail(`Failed to install with ${pkgManager}.`);
78c65
< };
---
> }
116c103
<   - ${packageManager === 'yarn' ? 'yarn' : 'npm run'} dev
---
>   - ${packageManager} run dev

I'm happy with this!

dcousens avatar Jul 18 '24 05:07 dcousens

Hooray 🎉

unrevised6419 avatar Jul 18 '24 07:07 unrevised6419