@quilted/create 0.1.33 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/templates/app-basic/App.tsx +11 -7
- package/templates/app-basic/features/Start/Start.test.tsx +2 -2
- package/templates/app-basic/features/Start/Start.tsx +7 -0
- package/templates/app-basic/features/Start.tsx +1 -0
- package/templates/app-basic/foundation/Head/Head.test.tsx +4 -4
- package/templates/app-basic/foundation/Head/Head.tsx +2 -0
- package/templates/app-basic/foundation/Head.tsx +1 -0
- package/templates/app-basic/foundation/Http/Http.test.tsx +4 -4
- package/templates/app-basic/foundation/Http/Http.tsx +2 -0
- package/templates/app-basic/foundation/Http.tsx +1 -0
- package/templates/app-basic/foundation/Metrics/Metrics.tsx +23 -0
- package/templates/app-basic/foundation/Metrics.tsx +1 -0
- package/templates/app-basic/tests/mount.tsx +30 -4
- package/templates/app-single-file/App.tsx +39 -14
- package/templates/app-basic/features/Start/index.ts +0 -1
- package/templates/app-basic/foundation/Head/index.ts +0 -1
- package/templates/app-basic/foundation/Http/index.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @quilted/create
|
|
2
2
|
|
|
3
|
+
## 0.1.35
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`84e74cb1`](https://github.com/lemonmade/quilt/commit/84e74cb1748ef4c427d6a4dfb854fa6898868918) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix default navigation performance experience
|
|
8
|
+
|
|
9
|
+
## 0.1.34
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#447](https://github.com/lemonmade/quilt/pull/447) [`6ad741b2`](https://github.com/lemonmade/quilt/commit/6ad741b241027c8d7612e206497935ad938ea6c9) Thanks [@lemonmade](https://github.com/lemonmade)! - Simplify app templates
|
|
14
|
+
|
|
15
|
+
- [`7cadc8fd`](https://github.com/lemonmade/quilt/commit/7cadc8fdcc99e7b95292b61c2af6cb3aabfa1d33) Thanks [@lemonmade](https://github.com/lemonmade)! - Add Metrics component to app templates
|
|
16
|
+
|
|
3
17
|
## 0.1.33
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {QuiltApp, useRoutes, type PropsWithChildren} from '@quilted/quilt';
|
|
2
2
|
|
|
3
3
|
import {Http} from './foundation/Http';
|
|
4
4
|
import {Head} from './foundation/Head';
|
|
5
|
+
import {Metrics} from './foundation/Metrics';
|
|
5
6
|
|
|
6
7
|
import {Start} from './features/Start';
|
|
7
8
|
|
|
@@ -9,13 +10,11 @@ import {Start} from './features/Start';
|
|
|
9
10
|
// app-wide context in this component.
|
|
10
11
|
export default function App() {
|
|
11
12
|
return (
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
<Http />
|
|
15
|
-
<Head />
|
|
13
|
+
<QuiltApp http={<Http />} html={<Head />}>
|
|
14
|
+
<AppContext>
|
|
16
15
|
<Routes />
|
|
17
|
-
</
|
|
18
|
-
</
|
|
16
|
+
</AppContext>
|
|
17
|
+
</QuiltApp>
|
|
19
18
|
);
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -24,3 +23,8 @@ export default function App() {
|
|
|
24
23
|
function Routes() {
|
|
25
24
|
return useRoutes([{match: '/', render: () => <Start />}]);
|
|
26
25
|
}
|
|
26
|
+
|
|
27
|
+
// This component renders any app-wide context.
|
|
28
|
+
function AppContext({children}: PropsWithChildren) {
|
|
29
|
+
return <Metrics>{children}</Metrics>;
|
|
30
|
+
}
|
|
@@ -5,8 +5,8 @@ import {mountWithAppContext} from '~/tests/mount';
|
|
|
5
5
|
import {Start} from './Start';
|
|
6
6
|
|
|
7
7
|
describe('<Start />', () => {
|
|
8
|
-
it('includes a welcome message', () => {
|
|
9
|
-
const start = mountWithAppContext(<Start />);
|
|
8
|
+
it('includes a welcome message', async () => {
|
|
9
|
+
const start = await mountWithAppContext(<Start />);
|
|
10
10
|
expect(start).toContainReactText('Hello world!');
|
|
11
11
|
});
|
|
12
12
|
});
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import {usePerformanceNavigation} from '@quilted/quilt';
|
|
2
|
+
|
|
1
3
|
import styles from './Start.module.css';
|
|
2
4
|
|
|
3
5
|
export function Start() {
|
|
6
|
+
// This hook indicates that the page has loaded. It is used as part of Quilt’s
|
|
7
|
+
// navigation performance tracking feature. If you have disabled this feature,
|
|
8
|
+
// you can remove this hook.
|
|
9
|
+
usePerformanceNavigation();
|
|
10
|
+
|
|
4
11
|
return <div className={styles.Start}>Hello world!</div>;
|
|
5
12
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {Start} from './Start/Start';
|
|
@@ -6,16 +6,16 @@ import {mountWithAppContext} from '~/tests/mount';
|
|
|
6
6
|
import {Head} from './Head';
|
|
7
7
|
|
|
8
8
|
describe('<Head />', () => {
|
|
9
|
-
it('includes a responsive viewport tag', () => {
|
|
10
|
-
const head = mountWithAppContext(<Head />);
|
|
9
|
+
it('includes a responsive viewport tag', async () => {
|
|
10
|
+
const head = await mountWithAppContext(<Head />);
|
|
11
11
|
|
|
12
12
|
expect(head).toContainReactComponent(Viewport, {
|
|
13
13
|
cover: true,
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
it('prevents search robots from indexing the application', () => {
|
|
18
|
-
const head = mountWithAppContext(<Head />);
|
|
17
|
+
it('prevents search robots from indexing the application', async () => {
|
|
18
|
+
const head = await mountWithAppContext(<Head />);
|
|
19
19
|
|
|
20
20
|
expect(head).toContainReactComponent(SearchRobots, {
|
|
21
21
|
index: false,
|
|
@@ -4,6 +4,8 @@ import {Title, Viewport, Favicon, SearchRobots} from '@quilted/quilt/html';
|
|
|
4
4
|
// any of these details based on conditions like the active route, or some
|
|
5
5
|
// state about the user, you can move these components to wherever in your
|
|
6
6
|
// application you can read that state.
|
|
7
|
+
//
|
|
8
|
+
// @see https://github.com/lemonmade/quilt/blob/main/documentation/features/html.md
|
|
7
9
|
export function Head() {
|
|
8
10
|
return (
|
|
9
11
|
<>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {Head} from './Head/Head';
|
|
@@ -6,16 +6,16 @@ import {mountWithAppContext} from '~/tests/mount';
|
|
|
6
6
|
import {Http} from './Http';
|
|
7
7
|
|
|
8
8
|
describe('<Http />', () => {
|
|
9
|
-
it('does not cache the response', () => {
|
|
10
|
-
const http = mountWithAppContext(<Http />);
|
|
9
|
+
it('does not cache the response', async () => {
|
|
10
|
+
const http = await mountWithAppContext(<Http />);
|
|
11
11
|
|
|
12
12
|
expect(http).toContainReactComponent(CacheControl, {
|
|
13
13
|
cache: false,
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
it('adds a content security policy with a strict default policy', () => {
|
|
18
|
-
const http = mountWithAppContext(<Http />);
|
|
17
|
+
it('adds a content security policy with a strict default policy', async () => {
|
|
18
|
+
const http = await mountWithAppContext(<Http />);
|
|
19
19
|
|
|
20
20
|
expect(http).toContainReactComponent(ContentSecurityPolicy, {
|
|
21
21
|
defaultSources: ["'self'"],
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
// requests. If you need to customize any of these details based on conditions like
|
|
13
13
|
// the active route, or some state about the user, you can move these components to
|
|
14
14
|
// wherever in your application you can read that state.
|
|
15
|
+
//
|
|
16
|
+
// @see https://github.com/lemonmade/quilt/blob/main/documentation/features/http.md
|
|
15
17
|
export function Http() {
|
|
16
18
|
const isHttps = useCurrentUrl().protocol === 'https:';
|
|
17
19
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {Http} from './Http/Http';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
usePerformanceNavigationEvent,
|
|
3
|
+
type PropsWithChildren,
|
|
4
|
+
} from '@quilted/quilt';
|
|
5
|
+
import Env from '@quilted/quilt/env';
|
|
6
|
+
|
|
7
|
+
// This component records metrics about your application.
|
|
8
|
+
export function Metrics({children}: PropsWithChildren) {
|
|
9
|
+
usePerformanceNavigationEvent(async (navigation) => {
|
|
10
|
+
if (Env.MODE === 'development') {
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
console.log('Navigation:');
|
|
13
|
+
// eslint-disable-next-line no-console
|
|
14
|
+
console.log(navigation);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// If you have a service that collects metrics, you can send navigation
|
|
19
|
+
// data to them here.
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return <>{children}</>;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {Metrics} from './Metrics/Metrics';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import '@quilted/quilt/matchers';
|
|
2
2
|
|
|
3
|
+
import {type PropsWithChildren} from '@quilted/quilt';
|
|
3
4
|
import {
|
|
4
5
|
createMount,
|
|
5
|
-
|
|
6
|
+
QuiltAppTesting,
|
|
6
7
|
createTestRouter,
|
|
7
8
|
} from '@quilted/quilt/testing';
|
|
8
9
|
|
|
@@ -18,6 +19,11 @@ export interface MountOptions {
|
|
|
18
19
|
* you expect.
|
|
19
20
|
*/
|
|
20
21
|
router?: Router;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A custom locale to use for this component test.
|
|
25
|
+
*/
|
|
26
|
+
locale?: string;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export interface MountContext {
|
|
@@ -36,12 +42,32 @@ export interface MountActions extends Record<string, never> {}
|
|
|
36
42
|
export const mountWithAppContext = createMount<
|
|
37
43
|
MountOptions,
|
|
38
44
|
MountContext,
|
|
39
|
-
MountActions
|
|
45
|
+
MountActions,
|
|
46
|
+
true
|
|
40
47
|
>({
|
|
48
|
+
// Create context that can be used by the `render` function, and referenced by test
|
|
49
|
+
// authors on the `root.context` property. Context is used to share data between your
|
|
50
|
+
// React tree and your test code, and is ideal for mocking out global context providers.
|
|
41
51
|
context({router = createTestRouter()}) {
|
|
42
52
|
return {router};
|
|
43
53
|
},
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
// Render all of our app-wide context providers around each component under test.
|
|
55
|
+
render(element, {router}, {locale}) {
|
|
56
|
+
return (
|
|
57
|
+
<QuiltAppTesting routing={router} localization={locale}>
|
|
58
|
+
<TestAppContext>{element}</TestAppContext>
|
|
59
|
+
</QuiltAppTesting>
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
async afterMount() {
|
|
63
|
+
// If your components need to resolve data before they can render, you can
|
|
64
|
+
// use this hook to wait for that data to be ready. This will cause the
|
|
65
|
+
// `mount` function to return a promise, so that the component is only usable
|
|
66
|
+
// once the data is ready.
|
|
46
67
|
},
|
|
47
68
|
});
|
|
69
|
+
|
|
70
|
+
// This component renders any app-wide context needed for component tests.
|
|
71
|
+
function TestAppContext({children}: PropsWithChildren) {
|
|
72
|
+
return <>{children}</>;
|
|
73
|
+
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
QuiltApp,
|
|
3
|
+
useCurrentUrl,
|
|
4
|
+
usePerformanceNavigation,
|
|
5
|
+
usePerformanceNavigationEvent,
|
|
6
|
+
type Routes,
|
|
7
|
+
} from '@quilted/quilt';
|
|
2
8
|
import {Title, Viewport, Favicon, SearchRobots} from '@quilted/quilt/html';
|
|
3
9
|
import {
|
|
4
10
|
CacheControl,
|
|
@@ -9,29 +15,30 @@ import {
|
|
|
9
15
|
} from '@quilted/quilt/http';
|
|
10
16
|
import Env from '@quilted/quilt/env';
|
|
11
17
|
|
|
18
|
+
// This component renders the routes for your application. If you have a lot
|
|
19
|
+
// of routes, or you need to customize the routes based on React context,
|
|
20
|
+
// you can declare dynamic routes in component with Quilt’s `useRoutes()`
|
|
21
|
+
// hook.
|
|
22
|
+
const routes: Routes = [{match: '/', render: () => <Start />}];
|
|
23
|
+
|
|
12
24
|
// The root component for your application. You will typically render any
|
|
13
25
|
// app-wide context in this component.
|
|
14
26
|
export default function App() {
|
|
15
27
|
return (
|
|
16
|
-
<
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
<Head />
|
|
20
|
-
<Routes />
|
|
21
|
-
</Router>
|
|
22
|
-
</AppContext>
|
|
28
|
+
<QuiltApp http={<Http />} html={<Head />} routes={routes}>
|
|
29
|
+
<Metrics />
|
|
30
|
+
</QuiltApp>
|
|
23
31
|
);
|
|
24
32
|
}
|
|
25
33
|
|
|
26
|
-
// This component renders the routes for your application. If you have a lot
|
|
27
|
-
// of routes, you may want to split this component into its own file.
|
|
28
|
-
function Routes() {
|
|
29
|
-
return useRoutes([{match: '/', render: () => <Start />}]);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
34
|
// This component will be rendered for the root URL of your application. Feel
|
|
33
35
|
// free to edit it, rename it, remove it entirely, or move it to a dedicated file.
|
|
34
36
|
function Start() {
|
|
37
|
+
// This hook indicates that the page has loaded. It is used as part of Quilt’s
|
|
38
|
+
// navigation performance tracking feature. If you have disabled this feature,
|
|
39
|
+
// you can remove this hook.
|
|
40
|
+
usePerformanceNavigation();
|
|
41
|
+
|
|
35
42
|
return <div>Hello world!</div>;
|
|
36
43
|
}
|
|
37
44
|
|
|
@@ -166,3 +173,21 @@ export function Http() {
|
|
|
166
173
|
</>
|
|
167
174
|
);
|
|
168
175
|
}
|
|
176
|
+
|
|
177
|
+
// This component records metrics about your application.
|
|
178
|
+
export function Metrics() {
|
|
179
|
+
usePerformanceNavigationEvent(async (navigation) => {
|
|
180
|
+
if (Env.MODE === 'development') {
|
|
181
|
+
// eslint-disable-next-line no-console
|
|
182
|
+
console.log('Navigation:');
|
|
183
|
+
// eslint-disable-next-line no-console
|
|
184
|
+
console.log(navigation);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// If you have a service that collects metrics, you can send navigation
|
|
189
|
+
// data to them here.
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {Start} from './Start';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {Head} from './Head';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {Http} from './Http';
|