-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
feat(create-jest): Add npm init
/ yarn create
initialiser
#14453
Changes from 4 commits
30e957f
5b580b1
e804edb
546db25
e503b28
0ffab46
df988bf
92db787
66384ac
e8d2043
d160788
c9b4ecb
b126c72
7b366be
0e9aed8
48b3d1d
bbae051
0b4ea0f
8fe5b8d
810fec8
513ad24
dedea5f
8ae6c55
8ca2c6a
77adb36
0dcf317
cc0e430
9e3ddfa
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
**/__mocks__/** | ||
**/__tests__/** | ||
__typetests__ | ||
src | ||
tsconfig.json | ||
tsconfig.tsbuildinfo | ||
api-extractor.json | ||
.eslintcache |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# create-jest | ||
|
||
> Getting started with Jest with a single command | ||
|
||
```bash | ||
npm init jest@latest | ||
# Or for Yarn | ||
yarn create jest | ||
# Or for pnpm | ||
pnpm dlx create-jest | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env node | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const importLocal = require('import-local'); | ||
|
||
if (!importLocal(__filename)) { | ||
require('jest-cli').run(['--init']); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "create-jest", | ||
"description": "Create a new Jest project", | ||
"version": "29.6.4", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jestjs/jest.git", | ||
"directory": "packages/create-jest" | ||
}, | ||
"license": "MIT", | ||
"bin": "./bin/create-jest.js", | ||
"main": "./build/index.js", | ||
"types": "./build/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./build/index.d.ts", | ||
"default": "./build/index.js" | ||
}, | ||
"./package.json": "./package.json", | ||
"./bin/create-jest": "./bin/create-jest.js" | ||
SimenB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
"dependencies": { | ||
"jest-cli": "workspace:^" | ||
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. This means that the whole Jest with all its dependencies will be pulled? Or? I would expect the 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. Perhaps it makes sense to move the whole logic to the new package and deprecate the 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.
I was thinking about standardised global wrapper for the initialisation (adapter for
Sounds fine, or maybe we can reverse the dependencies and use 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. In this case 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. One more idea, I think for now it would be fine to copy the code to 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. That's right. It can reused, I agree. 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. To summarize: in addition to this
we are also adding 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.
How do you feel? I find it useful, but can be implemented later. 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. Yeah, I think that's fine. 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.
I also find it useful, makes sense to do it here I think, it's not that hard |
||
}, | ||
"engines": { | ||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {run as runCLI} from 'jest-cli'; | ||
|
||
export const run = (): Promise<void> => runCLI(['--init']); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "build" | ||
}, | ||
"include": ["./src/**/*"], | ||
"references": [{"path": "../jest-cli"}] | ||
} |
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.
Hm..
import-local
is not included independencies
list?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.
Also not so sure if
import-local
is needed in this case. It does not make sense installingcreate-jest
locally. To be honest, I don’t understand whatimport-local
does ;D So it can be I missed something.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.
I'm ok with removing that, local installation indeed seems strange in this case