create-plasmic-app 0.0.47 → 0.0.50
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/dist/strategies/gatsby.js +15 -16
- package/dist/templates/gatsby.js +8 -4
- package/dist/templates/nextjs.js +2 -1
- package/package.json +1 -1
- package/src/strategies/gatsby.ts +20 -25
- package/src/templates/gatsby.ts +11 -4
- package/src/templates/nextjs.ts +2 -1
|
@@ -62,25 +62,24 @@ const gatsbyStrategy = {
|
|
|
62
62
|
yield cmd_utils_1.spawnOrFail(`${createCommand}`, parent);
|
|
63
63
|
}),
|
|
64
64
|
installDeps: ({ projectPath, scheme, useTypescript }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
const installedHelmet = yield npm_utils_1.installUpgrade("react-helmet", {
|
|
66
|
+
workingDir: projectPath,
|
|
67
|
+
});
|
|
68
|
+
const installedHelmetTypes = !useTypescript ||
|
|
69
|
+
(yield npm_utils_1.installUpgrade("@types/react-helmet", {
|
|
70
70
|
workingDir: projectPath,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
dev: true,
|
|
72
|
+
}));
|
|
73
|
+
const installedHelmetPlugin = yield npm_utils_1.installUpgrade("gatsby-plugin-react-helmet", {
|
|
74
|
+
workingDir: projectPath,
|
|
75
|
+
});
|
|
76
|
+
if (!installedHelmet || !installedHelmetPlugin || !installedHelmetTypes) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (scheme === "loader") {
|
|
80
|
+
return yield npm_utils_1.installUpgrade("@plasmicapp/loader-gatsby", {
|
|
78
81
|
workingDir: projectPath,
|
|
79
82
|
});
|
|
80
|
-
return (installedLoader &&
|
|
81
|
-
installedHelmet &&
|
|
82
|
-
installedHelmetPlugin &&
|
|
83
|
-
installedHelmetTypes);
|
|
84
83
|
}
|
|
85
84
|
else {
|
|
86
85
|
return yield common_1.installCodegenDeps({ projectPath });
|
package/dist/templates/gatsby.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
InitOptions,
|
|
14
14
|
ComponentRenderData,`)}
|
|
15
15
|
} from "@plasmicapp/loader-gatsby";
|
|
16
|
-
import { graphql } from "gatsby";
|
|
16
|
+
import { graphql${file_utils_1.ifTs(ts, ", PageProps")} } from "gatsby";
|
|
17
17
|
import { initPlasmicLoaderWithRegistrations } from "../plasmic-init";
|
|
18
18
|
|
|
19
19
|
export const query = graphql\`
|
|
@@ -23,14 +23,14 @@ export const query = graphql\`
|
|
|
23
23
|
}
|
|
24
24
|
\`;
|
|
25
25
|
|
|
26
|
-
${file_utils_1.ifTs(ts, `interface PlasmicGatsbyPageProps {
|
|
26
|
+
${file_utils_1.ifTs(ts, `interface PlasmicGatsbyPageProps extends PageProps {
|
|
27
27
|
data: {
|
|
28
28
|
plasmicOptions: InitOptions
|
|
29
29
|
plasmicComponents: ComponentRenderData
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
`)}
|
|
33
|
-
const PlasmicGatsbyPage = ({ data }${file_utils_1.ifTs(ts, ": PlasmicGatsbyPageProps")}) => {
|
|
33
|
+
const PlasmicGatsbyPage = ({ data, location }${file_utils_1.ifTs(ts, ": PlasmicGatsbyPageProps")}) => {
|
|
34
34
|
const {
|
|
35
35
|
plasmicComponents,
|
|
36
36
|
plasmicOptions,
|
|
@@ -41,6 +41,9 @@ const PlasmicGatsbyPage = ({ data }${file_utils_1.ifTs(ts, ": PlasmicGatsbyPageP
|
|
|
41
41
|
<PlasmicRootProvider
|
|
42
42
|
loader={initPlasmicLoaderWithRegistrations(plasmicOptions)}
|
|
43
43
|
prefetchedData={plasmicComponents}
|
|
44
|
+
pageParams={pageMeta.params}
|
|
45
|
+
pageQuery={Object.fromEntries(new URLSearchParams(location.search))}
|
|
46
|
+
Head={Helmet}
|
|
44
47
|
>
|
|
45
48
|
<Helmet>
|
|
46
49
|
{pageMetadata?.title && <title>{pageMetadata.title}</title>}
|
|
@@ -210,10 +213,11 @@ function wrapAppRootForCodegen() {
|
|
|
210
213
|
return `
|
|
211
214
|
import React from "react";
|
|
212
215
|
import { PlasmicRootProvider } from "@plasmicapp/react-web";
|
|
216
|
+
import Helmet from "react-helmet";
|
|
213
217
|
|
|
214
218
|
export const wrapRootElement = ({ element }) => {
|
|
215
219
|
return (
|
|
216
|
-
<PlasmicRootProvider>
|
|
220
|
+
<PlasmicRootProvider Head={Helmet}>
|
|
217
221
|
{element}
|
|
218
222
|
</PlasmicRootProvider>
|
|
219
223
|
);
|
package/dist/templates/nextjs.js
CHANGED
|
@@ -146,10 +146,11 @@ function wrapAppRootForCodegen() {
|
|
|
146
146
|
return `
|
|
147
147
|
import '../styles/globals.css'
|
|
148
148
|
import { PlasmicRootProvider } from "@plasmicapp/react-web";
|
|
149
|
+
import Head from "next/head";
|
|
149
150
|
|
|
150
151
|
function MyApp({ Component, pageProps }) {
|
|
151
152
|
return (
|
|
152
|
-
<PlasmicRootProvider>
|
|
153
|
+
<PlasmicRootProvider Head={Head}>
|
|
153
154
|
<Component {...pageProps} />
|
|
154
155
|
</PlasmicRootProvider>
|
|
155
156
|
);
|
package/package.json
CHANGED
package/src/strategies/gatsby.ts
CHANGED
|
@@ -37,34 +37,29 @@ const gatsbyStrategy: CPAStrategy = {
|
|
|
37
37
|
await spawnOrFail(`${createCommand}`, parent);
|
|
38
38
|
},
|
|
39
39
|
installDeps: async ({ projectPath, scheme, useTypescript }) => {
|
|
40
|
+
const installedHelmet = await installUpgrade("react-helmet", {
|
|
41
|
+
workingDir: projectPath,
|
|
42
|
+
});
|
|
43
|
+
const installedHelmetTypes =
|
|
44
|
+
!useTypescript ||
|
|
45
|
+
(await installUpgrade("@types/react-helmet", {
|
|
46
|
+
workingDir: projectPath,
|
|
47
|
+
dev: true,
|
|
48
|
+
}));
|
|
49
|
+
const installedHelmetPlugin = await installUpgrade(
|
|
50
|
+
"gatsby-plugin-react-helmet",
|
|
51
|
+
{
|
|
52
|
+
workingDir: projectPath,
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
if (!installedHelmet || !installedHelmetPlugin || !installedHelmetTypes) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
40
59
|
if (scheme === "loader") {
|
|
41
|
-
|
|
42
|
-
"@plasmicapp/loader-gatsby",
|
|
43
|
-
{
|
|
44
|
-
workingDir: projectPath,
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
const installedHelmet = await installUpgrade("react-helmet", {
|
|
60
|
+
return await installUpgrade("@plasmicapp/loader-gatsby", {
|
|
48
61
|
workingDir: projectPath,
|
|
49
62
|
});
|
|
50
|
-
const installedHelmetTypes =
|
|
51
|
-
!useTypescript ||
|
|
52
|
-
(await installUpgrade("@types/react-helmet", {
|
|
53
|
-
workingDir: projectPath,
|
|
54
|
-
dev: true,
|
|
55
|
-
}));
|
|
56
|
-
const installedHelmetPlugin = await installUpgrade(
|
|
57
|
-
"gatsby-plugin-react-helmet",
|
|
58
|
-
{
|
|
59
|
-
workingDir: projectPath,
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
return (
|
|
63
|
-
installedLoader &&
|
|
64
|
-
installedHelmet &&
|
|
65
|
-
installedHelmetPlugin &&
|
|
66
|
-
installedHelmetTypes
|
|
67
|
-
);
|
|
68
63
|
} else {
|
|
69
64
|
return await installCodegenDeps({ projectPath });
|
|
70
65
|
}
|
package/src/templates/gatsby.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
ComponentRenderData,`
|
|
16
16
|
)}
|
|
17
17
|
} from "@plasmicapp/loader-gatsby";
|
|
18
|
-
import { graphql } from "gatsby";
|
|
18
|
+
import { graphql${ifTs(ts, ", PageProps")} } from "gatsby";
|
|
19
19
|
import { initPlasmicLoaderWithRegistrations } from "../plasmic-init";
|
|
20
20
|
|
|
21
21
|
export const query = graphql\`
|
|
@@ -27,7 +27,7 @@ export const query = graphql\`
|
|
|
27
27
|
|
|
28
28
|
${ifTs(
|
|
29
29
|
ts,
|
|
30
|
-
`interface PlasmicGatsbyPageProps {
|
|
30
|
+
`interface PlasmicGatsbyPageProps extends PageProps {
|
|
31
31
|
data: {
|
|
32
32
|
plasmicOptions: InitOptions
|
|
33
33
|
plasmicComponents: ComponentRenderData
|
|
@@ -35,7 +35,10 @@ ${ifTs(
|
|
|
35
35
|
}
|
|
36
36
|
`
|
|
37
37
|
)}
|
|
38
|
-
const PlasmicGatsbyPage = ({ data }${ifTs(
|
|
38
|
+
const PlasmicGatsbyPage = ({ data, location }${ifTs(
|
|
39
|
+
ts,
|
|
40
|
+
": PlasmicGatsbyPageProps"
|
|
41
|
+
)}) => {
|
|
39
42
|
const {
|
|
40
43
|
plasmicComponents,
|
|
41
44
|
plasmicOptions,
|
|
@@ -46,6 +49,9 @@ const PlasmicGatsbyPage = ({ data }${ifTs(ts, ": PlasmicGatsbyPageProps")}) => {
|
|
|
46
49
|
<PlasmicRootProvider
|
|
47
50
|
loader={initPlasmicLoaderWithRegistrations(plasmicOptions)}
|
|
48
51
|
prefetchedData={plasmicComponents}
|
|
52
|
+
pageParams={pageMeta.params}
|
|
53
|
+
pageQuery={Object.fromEntries(new URLSearchParams(location.search))}
|
|
54
|
+
Head={Helmet}
|
|
49
55
|
>
|
|
50
56
|
<Helmet>
|
|
51
57
|
{pageMetadata?.title && <title>{pageMetadata.title}</title>}
|
|
@@ -236,10 +242,11 @@ export function wrapAppRootForCodegen(): string {
|
|
|
236
242
|
return `
|
|
237
243
|
import React from "react";
|
|
238
244
|
import { PlasmicRootProvider } from "@plasmicapp/react-web";
|
|
245
|
+
import Helmet from "react-helmet";
|
|
239
246
|
|
|
240
247
|
export const wrapRootElement = ({ element }) => {
|
|
241
248
|
return (
|
|
242
|
-
<PlasmicRootProvider>
|
|
249
|
+
<PlasmicRootProvider Head={Helmet}>
|
|
243
250
|
{element}
|
|
244
251
|
</PlasmicRootProvider>
|
|
245
252
|
);
|
package/src/templates/nextjs.ts
CHANGED
|
@@ -155,10 +155,11 @@ export function wrapAppRootForCodegen(): string {
|
|
|
155
155
|
return `
|
|
156
156
|
import '../styles/globals.css'
|
|
157
157
|
import { PlasmicRootProvider } from "@plasmicapp/react-web";
|
|
158
|
+
import Head from "next/head";
|
|
158
159
|
|
|
159
160
|
function MyApp({ Component, pageProps }) {
|
|
160
161
|
return (
|
|
161
|
-
<PlasmicRootProvider>
|
|
162
|
+
<PlasmicRootProvider Head={Head}>
|
|
162
163
|
<Component {...pageProps} />
|
|
163
164
|
</PlasmicRootProvider>
|
|
164
165
|
);
|