Skip to content

Commit

Permalink
Merge branch 'canary' into fork-work
Browse files Browse the repository at this point in the history
  • Loading branch information
flybayer authored Oct 19, 2021
2 parents 7f88eb6 + 6f37571 commit 82bbde7
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 116 deletions.
3 changes: 2 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -3292,7 +3292,8 @@
"profile": "https://github.com/mochi-sann",
"contributions": [
"code",
"test"
"test",
"doc"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
<td align="center"><a href="https://github.com/MuckHub"><img src="https://avatars.githubusercontent.com/u/54979136?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aleksei Vesselko</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=MuckHub" title="Documentation">📖</a></td>
<td align="center"><a href="https://p-siriphanthong.github.io/"><img src="https://avatars.githubusercontent.com/u/29949429?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Punn Siriphanthong</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=p-siriphanthong" title="Code">💻</a></td>
<td align="center"><a href="https://my-portfolio-292eb.web.app"><img src="https://avatars.githubusercontent.com/u/83679827?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shawn Fetanat</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=shawn-fetanat" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/mochi-sann"><img src="https://avatars.githubusercontent.com/u/44772513?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Moyuru</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=mochi-sann" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=mochi-sann" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/mochi-sann"><img src="https://avatars.githubusercontent.com/u/44772513?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Moyuru</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=mochi-sann" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=mochi-sann" title="Tests">⚠️</a> <a href="https://github.com/blitz-js/blitz/commits?author=mochi-sann" title="Documentation">📖</a></td>
</tr>
</table>

Expand Down
9 changes: 9 additions & 0 deletions packages/cli/test/commands/new.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ describe("`new` command", () => {
})
})

testIfNotWindows("accepts --dry-run flag and doesn't create files", async () => {
const newAppDir = fs.mkdtempSync(path.join(tempDir, "full-install-"))
await whileStayingInCWD(() => New.run([newAppDir, "--skip-upgrade", "--dry-run"]))

expect(fs.existsSync(newAppDir)).toBe(true)
expect(fs.existsSync(path.join(newAppDir, "package.json"))).toBe(false)
expect(stdout.output).toContain("Would create")
})

it("fetches latest version from template", async () => {
const expectedVersion = "3.0.0"
const templatePackage = {name: "eslint-plugin-react-hooks", version: "3.x"}
Expand Down
1 change: 1 addition & 0 deletions packages/generator/src/conflict-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class ConflictChecker extends Transform {
super({
objectMode: true,
})
this.options = options
}

_transform(file: File, _encoding: string, cb: TransformCallback): void {
Expand Down
1 change: 0 additions & 1 deletion packages/generator/templates/app/.husky/.gitignore

This file was deleted.

4 changes: 3 additions & 1 deletion packages/generator/templates/app/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ db/migrations
.next
.blitz
.yarn
.pnp*
.pnp.*
node_modules
.blitz.config.compiled.js
116 changes: 58 additions & 58 deletions packages/generator/templates/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,65 +66,65 @@ Here is the starting structure of your app.
```
__name__
├── app/
   ├── api/
   ├── auth/
   │   ├── components/
   │   │   ├── LoginForm.tsx
   │   │   └── SignupForm.tsx
   │   ├── mutations/
   │   │   ├── changePassword.ts
   │   │   ├── forgotPassword.test.ts
   │   │   ├── forgotPassword.ts
   │   │   ├── login.ts
   │   │   ├── logout.ts
   │   │   ├── resetPassword.test.ts
   │   │   ├── resetPassword.ts
   │   │   └── signup.ts
   │   ├── pages/
   │   │   ├── forgot-password.tsx
   │   │   ├── login.tsx
   │   │   ├── reset-password.tsx
   │   │   └── signup.tsx
   │   └── validations.ts
   ├── core/
   │   ├── components/
   │   │   ├── Form.tsx
   │   │   └── LabeledTextField.tsx
   │   ├── hooks/
   │   │   └── useCurrentUser.ts
   │   └── layouts/
   │   └── Layout.tsx
   ├── pages/
   │   ├── 404.tsx
   │   ├── _app.tsx
   │   ├── _document.tsx
   │   ├── index.test.tsx
   │   └── index.tsx
   └── users/
   └── queries/
   └── getCurrentUser.ts
├── api/
├── auth/
├── components/
│ │ ├── LoginForm.tsx
│ │ └── SignupForm.tsx
├── mutations/
│ │ ├── changePassword.ts
│ │ ├── forgotPassword.test.ts
│ │ ├── forgotPassword.ts
│ │ ├── login.ts
│ │ ├── logout.ts
│ │ ├── resetPassword.test.ts
│ │ ├── resetPassword.ts
│ │ └── signup.ts
├── pages/
│ │ ├── forgot-password.tsx
│ │ ├── login.tsx
│ │ ├── reset-password.tsx
│ │ └── signup.tsx
└── validations.ts
├── core/
├── components/
│ │ ├── Form.tsx
│ │ └── LabeledTextField.tsx
├── hooks/
│ │ └── useCurrentUser.ts
└── layouts/
└── Layout.tsx
├── pages/
├── _app.tsx
├── _document.tsx
├── 404.tsx
├── index.test.tsx
└── index.tsx
└── users/
└── queries/
└── getCurrentUser.ts
├── db/
│   ├── index.ts
│   ├── schema.prisma
│   └── seeds.ts
│ ├── migrations/
│ ├── index.ts
│ ├── schema.prisma
│ └── seeds.ts
├── integrations/
├── mailers/
   └── forgotPasswordMailer.ts
└── forgotPasswordMailer.ts
├── public/
   ├── favicon.ico*
   └── logo.png
├── favicon.ico
└── logo.png
├── test/
   ├── setup.ts
   └── utils.tsx
├── README.md
├── setup.ts
└── utils.tsx
├── .eslintrc.js
├── babel.config.js
├── blitz.config.js
├── jest.config.js
├── blitz.config.ts
├── jest.config.ts
├── package.json
├── README.md
├── tsconfig.json
├── types.d.ts
├── types.ts
└── yarn.lock
└── types.ts
```

These files are:
Expand All @@ -143,9 +143,9 @@ These files are:

- `tsconfig.json` is our recommended setup for TypeScript.

- `.babelrc.js`, `.env`, etc. ("dotfiles") are configuration files for various bits of JavaScript tooling.
- `.babel.config.js`, `.eslintrc.js`, `.env`, etc. ("dotfiles") are configuration files for various bits of JavaScript tooling.

- `blitz.config.js` is for advanced custom configuration of Blitz. It extends [`next.config.js`](https://nextjs.org/docs/api-reference/next.config.js/introduction).
- `blitz.config.ts` is for advanced custom configuration of Blitz. [Here you can learn how to use it](https://blitzjs.com/docs/blitz-config).

- `jest.config.js` contains config for Jest tests. You can [customize it if needed](https://jestjs.io/docs/en/configuration).

Expand All @@ -155,18 +155,18 @@ You can read more about it in the [File Structure](https://blitzjs.com/docs/file

Blitz comes with a set of tools that corrects and formats your code, facilitating its future maintenance. You can modify their options and even uninstall them.

- **ESLint**: It lints your code: searches for bad practices and tell you about it. You can customize it via the `.eslintrc.js`, and you can install (or even write) plugins to have it the way you like it. It already comes with the [`blitz`](https://github.com/blitz-js/blitz/tree/canary/packages/eslint-config) config, but you can remove it safely. [Learn More](https://eslint.org).
- **Husky**: It adds [githooks](https://git-scm.com/docs/githooks), little pieces of code that get executed when certain Git events are triggerd. For example, `pre-commit` is triggered just before a commit is created. You can see the current hooks inside `.husky/`. If are having problems commiting and pushing, check out ther [troubleshooting](https://typicode.github.io/husky/#/?id=troubleshoot) guide. [Learn More](https://typicode.github.io/husky).
- **Prettier**: It formats your code to look the same everywhere. You can configure it via the `.prettierrc` file. The `.prettierignore` contains the files that should be ignored by Prettier; useful when you have large files or when you want to keep a custom formatting. [Learn More](https://prettier.io).
- **ESLint**: It lints your code: searches for bad practices and tell you about it. You can customize it via the `.eslintrc.js`, and you can install (or even write) plugins to have it the way you like it. It already comes with the [`blitz`](https://github.com/blitz-js/blitz/tree/canary/packages/eslint-config) config, but you can remove it safely. [Learn More](https://blitzjs.com/docs/eslint-config).
- **Husky**: It adds [githooks](https://git-scm.com/docs/githooks), little pieces of code that get executed when certain Git events are triggerd. For example, `pre-commit` is triggered just before a commit is created. You can see the current hooks inside `.husky/`. If are having problems commiting and pushing, check out ther [troubleshooting](https://typicode.github.io/husky/#/?id=troubleshoot) guide. [Learn More](https://blitzjs.com/docs/husky-config).
- **Prettier**: It formats your code to look the same everywhere. You can configure it via the `.prettierrc` file. The `.prettierignore` contains the files that should be ignored by Prettier; useful when you have large files or when you want to keep a custom formatting. [Learn More](https://blitzjs.com/docs/prettier-config).

## Learn more

Read the [Blitz.js Documentation](https://blitzjs.com/docs/getting-started) to learn more.

The Blitz community is warm, safe, diverse, inclusive, and fun! Feel free to reach out to us in any of our communication channels.

- [Website](https://blitzjs.com/)
- [Discord](https://discord.blitzjs.com/)
- [Website](https://blitzjs.com)
- [Discord](https://blitzjs.com/discord)
- [Report an issue](https://github.com/blitz-js/blitz/issues/new/choose)
- [Forum discussions](https://github.com/blitz-js/blitz/discussions)
- [How to Contribute](https://blitzjs.com/docs/contributing)
Expand Down
2 changes: 1 addition & 1 deletion packages/generator/templates/app/app/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Document, Html, DocumentHead, Main, BlitzScript /*DocumentContext*/} from 'blitz'
import { Document, Html, DocumentHead, Main, BlitzScript /*DocumentContext*/ } from "blitz"

class MyDocument extends Document {
// Only uncomment if you need to customize this behaviour
Expand Down
8 changes: 4 additions & 4 deletions packages/generator/templates/app/package.js.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
},
"devDependencies": {
"eslint": "7.x",
"husky": "6.x",
"lint-staged": "10.x",
"prettier-plugin-prisma": "0.x",
"husky": "7.x",
"lint-staged": "11.x",
"prettier-plugin-prisma": "3.x",
"prettier": "2.x",
"pretty-quick": "3.x",
"preview-email": "3.x",
"prisma": "3.x"
},
"private": true
}
}
10 changes: 5 additions & 5 deletions packages/generator/templates/app/package.ts.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
"@types/preview-email": "2.x",
"@types/react": "17.x",
"eslint": "7.x",
"husky": "6.x",
"lint-staged": "10.x",
"prettier-plugin-prisma": "0.x",
"husky": "7.x",
"lint-staged": "11.x",
"prettier-plugin-prisma": "3.x",
"prettier": "2.x",
"pretty-quick": "3.x",
"preview-email": "3.x",
"prisma": "3.x",
"typescript": "~4.3"
"typescript": "~4.4"
},
"private": true
}
}
16 changes: 11 additions & 5 deletions packages/generator/templates/app/test/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export * from "@testing-library/react"
// router: { pathname: '/my-custom-pathname' },
// });
// --------------------------------------------------
export function render(ui: RenderUI, { wrapper, router, dehydratedState, ...options }: RenderOptions = {}) {
export function render(
ui: RenderUI,
{ wrapper, router, dehydratedState, ...options }: RenderOptions = {}
) {
if (!wrapper) {
// Add a default context wrapper if one isn't supplied from the test
wrapper = ({ children }) => (
Expand All @@ -51,7 +54,7 @@ export function render(ui: RenderUI, { wrapper, router, dehydratedState, ...opti
// --------------------------------------------------
export function renderHook(
hook: RenderHook,
{ wrapper, router, dehydratedState,...options }: RenderHookOptions = {}
{ wrapper, router, dehydratedState, ...options }: RenderHookOptions = {}
) {
if (!wrapper) {
// Add a default context wrapper if one isn't supplied from the test
Expand All @@ -66,7 +69,7 @@ export function renderHook(
return defaultRenderHook(hook, { wrapper, ...options })
}

export const mockRouter: BlitzRouter = {
export const mockRouter: BlitzRouter = {
basePath: "",
pathname: "/",
route: "/",
Expand All @@ -92,8 +95,11 @@ export const mockRouter: BlitzRouter = {

type DefaultParams = Parameters<typeof defaultRender>
type RenderUI = DefaultParams[0]
type RenderOptions = DefaultParams[1] & { router?: Partial<BlitzRouter>, dehydratedState?: unknown }
type RenderOptions = DefaultParams[1] & { router?: Partial<BlitzRouter>; dehydratedState?: unknown }

type DefaultHookParams = Parameters<typeof defaultRenderHook>
type RenderHook = DefaultHookParams[0]
type RenderHookOptions = DefaultHookParams[1] & { router?: Partial<BlitzRouter>, dehydratedState?: unknown }
type RenderHookOptions = DefaultHookParams[1] & {
router?: Partial<BlitzRouter>
dehydratedState?: unknown
}
1 change: 0 additions & 1 deletion packages/generator/templates/minimalapp/.husky/.gitignore

This file was deleted.

4 changes: 4 additions & 0 deletions packages/generator/templates/minimalapp/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
*.lock
.next
.blitz
.yarn
.pnp.*
node_modules
.blitz.config.compiled.js
45 changes: 22 additions & 23 deletions packages/generator/templates/minimalapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,26 @@ Here is the starting structure of your app.
```
__name__
├── app/
   ├── pages/
   │   ├── 404.tsx
   │   ├── _app.tsx
   │   ├── _document.tsx
   │   ├── index.test.tsx
   │   └── index.tsx
├── pages/
├── _app.tsx
├── _document.tsx
├── 404.tsx
├── index.test.tsx
└── index.tsx
├── public/
   ├── favicon.ico*
   └── logo.png
├── favicon.ico
└── logo.png
├── test/
   ├── setup.ts
   └── utils.tsx
├── README.md
├── setup.ts
└── utils.tsx
├── .eslintrc.js
├── babel.config.js
├── blitz.config.js
├── jest.config.js
├── blitz.config.ts
├── jest.config.ts
├── package.json
├── README.md
├── tsconfig.json
├── types.d.ts
├── types.ts
└── yarn.lock
└── types.ts
```

These files are:
Expand All @@ -87,9 +86,9 @@ These files are:

- `tsconfig.json` is our recommended setup for TypeScript.

- `.babelrc.js`, `.env`, etc. ("dotfiles") are configuration files for various bits of JavaScript tooling.
- `.babel.config.js`, `.eslintrc.js`, `.env`, etc. ("dotfiles") are configuration files for various bits of JavaScript tooling.

- `blitz.config.js` is for advanced custom configuration of Blitz. It extends [`next.config.js`](https://nextjs.org/docs/api-reference/next.config.js/introduction).
- `blitz.config.ts` is for advanced custom configuration of Blitz. [Here you can learn how to use it](https://blitzjs.com/docs/blitz-config).

- `jest.config.js` contains config for Jest tests. You can [customize it if needed](https://jestjs.io/docs/en/configuration).

Expand All @@ -99,18 +98,18 @@ You can read more about it in the [File Structure](https://blitzjs.com/docs/file

Blitz comes with a set of tools that corrects and formats your code, facilitating its future maintenance. You can modify their options and even uninstall them.

- **ESLint**: It lints your code: searches for bad practices and tell you about it. You can customize it via the `.eslintrc.js`, and you can install (or even write) plugins to have it the way you like it. It already comes with the [`blitz`](https://github.com/blitz-js/blitz/tree/canary/packages/eslint-config) config, but you can remove it safely. [Learn More](https://eslint.org).
- **Husky**: It adds [githooks](https://git-scm.com/docs/githooks), little pieces of code that get executed when certain Git events are triggerd. For example, `pre-commit` is triggered just before a commit is created. You can see the current hooks inside `.husky/`. If are having problems commiting and pushing, check out ther [troubleshooting](https://typicode.github.io/husky/#/?id=troubleshoot) guide. [Learn More](https://typicode.github.io/husky).
- **Prettier**: It formats your code to look the same everywhere. You can configure it via the `.prettierrc` file. The `.prettierignore` contains the files that should be ignored by Prettier; useful when you have large files or when you want to keep a custom formatting. [Learn More](https://prettier.io).
- **ESLint**: It lints your code: searches for bad practices and tell you about it. You can customize it via the `.eslintrc.js`, and you can install (or even write) plugins to have it the way you like it. It already comes with the [`blitz`](https://github.com/blitz-js/blitz/tree/canary/packages/eslint-config) config, but you can remove it safely. [Learn More](https://blitzjs.com/docs/eslint-config).
- **Husky**: It adds [githooks](https://git-scm.com/docs/githooks), little pieces of code that get executed when certain Git events are triggerd. For example, `pre-commit` is triggered just before a commit is created. You can see the current hooks inside `.husky/`. If are having problems commiting and pushing, check out ther [troubleshooting](https://typicode.github.io/husky/#/?id=troubleshoot) guide. [Learn More](https://blitzjs.com/docs/husky-config).
- **Prettier**: It formats your code to look the same everywhere. You can configure it via the `.prettierrc` file. The `.prettierignore` contains the files that should be ignored by Prettier; useful when you have large files or when you want to keep a custom formatting. [Learn More](https://blitzjs.com/docs/prettier-config).

## Learn more

Read the [Blitz.js Documentation](https://blitzjs.com/docs/getting-started) to learn more.

The Blitz community is warm, safe, diverse, inclusive, and fun! Feel free to reach out to us in any of our communication channels.

- [Website](https://blitzjs.com/)
- [Discord](https://discord.blitzjs.com/)
- [Website](https://blitzjs.com)
- [Discord](https://blitzjs.com/discord)
- [Report an issue](https://github.com/blitz-js/blitz/issues/new/choose)
- [Forum discussions](https://github.com/blitz-js/blitz/discussions)
- [How to Contribute](https://blitzjs.com/docs/contributing)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Document, Html, DocumentHead, Main, BlitzScript /*DocumentContext*/} from 'blitz'
import { Document, Html, DocumentHead, Main, BlitzScript /*DocumentContext*/ } from "blitz"

class MyDocument extends Document {
// Only uncomment if you need to customize this behaviour
Expand Down
Loading

0 comments on commit 82bbde7

Please sign in to comment.