create-plasmic-app 0.0.33 → 0.0.37

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.
@@ -0,0 +1,30 @@
1
+ import { banner } from "../lib";
2
+ import { spawnOrFail } from "../utils/cmd-utils";
3
+ import { installUpgrade } from "../utils/npm-utils";
4
+
5
+ export async function installCodegenDeps(opts: { projectPath: string }) {
6
+ const { projectPath } = opts;
7
+ return (
8
+ (await installUpgrade("@plasmicapp/cli", { workingDir: projectPath })) &&
9
+ (await installUpgrade("@plasmicapp/host", { workingDir: projectPath }))
10
+ );
11
+ }
12
+
13
+ export async function runCodegenSync(opts: {
14
+ projectId: string;
15
+ projectApiToken: string | undefined;
16
+ projectPath: string;
17
+ }) {
18
+ const { projectId, projectApiToken, projectPath } = opts;
19
+
20
+ banner("SYNCING PLASMIC COMPONENTS");
21
+
22
+ const project = projectApiToken
23
+ ? `${projectId}:${projectApiToken}`
24
+ : projectId;
25
+
26
+ await spawnOrFail(
27
+ `npx -p @plasmicapp/cli plasmic sync --yes -p ${project}`,
28
+ projectPath
29
+ );
30
+ }
@@ -3,12 +3,18 @@ import path from "path";
3
3
  import * as readline from "readline";
4
4
  import {
5
5
  GATSBY_404,
6
- GATSBY_DEFAULT_PAGE,
7
6
  GATSBY_PLUGIN_CONFIG,
7
+ GATSBY_SSR_CONFIG,
8
+ makeGatsbyDefaultPage,
9
+ makeGatsbyHostPage,
10
+ makeGatsbyPlasmicInit,
11
+ wrapAppRootForCodegen,
8
12
  } from "../templates/gatsby";
9
13
  import { spawnOrFail } from "../utils/cmd-utils";
10
- import { deleteGlob } from "../utils/file-utils";
14
+ import { deleteGlob, overwriteIndex } from "../utils/file-utils";
15
+ import { ensure } from "../utils/lang-utils";
11
16
  import { installUpgrade } from "../utils/npm-utils";
17
+ import { installCodegenDeps, runCodegenSync } from "./common";
12
18
  import { CPAStrategy } from "./types";
13
19
 
14
20
  const gatsbyStrategy: CPAStrategy = {
@@ -17,59 +23,117 @@ const gatsbyStrategy: CPAStrategy = {
17
23
  const createCommand = `npx -p gatsby gatsby new ${projectPath}`;
18
24
  const templateArg = template ? ` ${template}` : "";
19
25
 
20
- // Default Gatsby starter already supports Typescript
21
- // See where we `touch tsconfig.json` later on
22
26
  await spawnOrFail(`${createCommand}${templateArg}`);
23
27
  },
24
- configLoader: async (args) => {
25
- const { projectId, projectPath, projectApiToken } = args;
26
-
27
- const installResult = await installUpgrade("@plasmicapp/loader-gatsby", {
28
- workingDir: projectPath,
29
- });
30
-
31
- if (!installResult) {
32
- throw new Error("Failed to install the Plasmic dependency");
28
+ installDeps: async ({ projectPath, scheme }) => {
29
+ if (scheme === "loader") {
30
+ return await installUpgrade("@plasmicapp/loader-gatsby", {
31
+ workingDir: projectPath,
32
+ });
33
+ } else {
34
+ return await installCodegenDeps({ projectPath });
33
35
  }
36
+ },
37
+ overwriteConfig: async (args) => {
38
+ const {
39
+ projectId,
40
+ projectPath,
41
+ projectApiToken,
42
+ useTypescript,
43
+ scheme,
44
+ } = args;
34
45
 
35
- // create-gatsby will create a default gatsby-config.js that we need to modify
36
- const gatsbyConfigFile = path.join(projectPath, "gatsby-config.js");
37
- const rl = readline.createInterface({
38
- input: createReadStream(gatsbyConfigFile),
39
- crlfDelay: Infinity,
40
- });
41
- let result = "";
42
- for await (const line of rl) {
43
- result += line + "\n";
44
- // Prepend PlasmicLoader to list of plugins
45
- if (line.includes("plugins:")) {
46
- result += GATSBY_PLUGIN_CONFIG(projectId, projectApiToken);
46
+ if (scheme === "loader") {
47
+ // create-gatsby will create a default gatsby-config.js that we need to modify
48
+ const gatsbyConfigFile = path.join(projectPath, "gatsby-config.js");
49
+ const rl = readline.createInterface({
50
+ input: createReadStream(gatsbyConfigFile),
51
+ crlfDelay: Infinity,
52
+ });
53
+ let result = "";
54
+ for await (const line of rl) {
55
+ result += line + "\n";
56
+ // Prepend PlasmicLoader to list of plugins
57
+ if (line.includes("plugins:")) {
58
+ result += GATSBY_PLUGIN_CONFIG(
59
+ projectId,
60
+ ensure(projectApiToken),
61
+ useTypescript
62
+ );
63
+ }
47
64
  }
65
+ await fs.writeFile(gatsbyConfigFile, result);
48
66
  }
49
- await fs.writeFile(gatsbyConfigFile, result);
50
67
  },
51
- overwriteFiles: async (args) => {
68
+ generateFiles: async (args) => {
52
69
  // in gatsby we can delete all existing pages/components, since all pages are going
53
70
  // to be handled by templates/defaultPlasmicPage
54
- const { projectPath } = args;
71
+ const {
72
+ projectId,
73
+ projectApiToken,
74
+ projectPath,
75
+ useTypescript,
76
+ scheme,
77
+ } = args;
78
+
79
+ const extension = useTypescript ? "ts" : "js";
55
80
 
56
81
  deleteGlob(path.join(projectPath, "src/@(pages|components|templates)/*.*"));
57
82
 
58
83
  // Create a very basic 404 page - `gatsby build` fails without it.
59
- // We've deleted the components that the default 404 page depended
60
- // on, so
61
- await fs.writeFile(path.join(projectPath, "src/pages/404.js"), GATSBY_404);
84
+ await fs.writeFile(path.join(projectPath, `src/pages/404.js`), GATSBY_404);
85
+
86
+ // Add plasmic-host page
87
+ await fs.writeFile(
88
+ path.join(projectPath, `src/pages/plasmic-host.${extension}x`),
89
+ makeGatsbyHostPage({
90
+ useTypescript,
91
+ scheme,
92
+ })
93
+ );
62
94
 
63
95
  // Start with an empty gatsby-node.js
64
96
  await fs.writeFile(path.join(projectPath, "gatsby-node.js"), "");
65
97
 
66
- const templatesFolder = path.join(projectPath, "src/templates");
67
- const defaultPagePath = path.join(templatesFolder, "defaultPlasmicPage.js");
98
+ // Updates `gatsby-ssr` to include script tag for preamble
99
+ await fs.writeFile(
100
+ path.join(projectPath, "gatsby-ssr.js"),
101
+ GATSBY_SSR_CONFIG
102
+ );
103
+
104
+ if (scheme === "loader") {
105
+ await fs.writeFile(
106
+ path.join(projectPath, `src/plasmic-init.${extension}`),
107
+ makeGatsbyPlasmicInit(extension)
108
+ );
109
+
110
+ const templatesFolder = path.join(projectPath, "src/templates");
111
+ if (!existsSync(templatesFolder)) {
112
+ await fs.mkdir(templatesFolder);
113
+ }
114
+ const defaultPagePath = path.join(
115
+ templatesFolder,
116
+ `defaultPlasmicPage.${extension}x`
117
+ );
118
+ await fs.writeFile(defaultPagePath, makeGatsbyDefaultPage(extension));
119
+ } else {
120
+ await runCodegenSync({
121
+ projectId,
122
+ projectApiToken,
123
+ projectPath,
124
+ });
125
+
126
+ // Overwrite the index file
127
+ await overwriteIndex(projectPath, "gatsby", scheme);
128
+
129
+ // Overwrite the wrapper files to wrap PlasmicRootProvider
130
+ const wrapperContent = wrapAppRootForCodegen();
131
+ const browserFilePath = path.join(projectPath, "gatsby-browser.js");
132
+ await fs.writeFile(browserFilePath, wrapperContent);
68
133
 
69
- if (!existsSync(templatesFolder)) {
70
- await fs.mkdir(templatesFolder);
134
+ const ssrFilePath = path.join(projectPath, "gatsby-ssr.js");
135
+ await fs.writeFile(ssrFilePath, wrapperContent);
71
136
  }
72
- await fs.writeFile(defaultPagePath, GATSBY_DEFAULT_PAGE);
73
137
  },
74
138
  build: async (args) => {
75
139
  const { npmRunCmd, projectPath } = args;
@@ -1,7 +1,16 @@
1
+ import fs from "fs/promises";
1
2
  import path from "path";
3
+ import {
4
+ makeNextjsCatchallPage,
5
+ makeNextjsHostPage,
6
+ makeNextjsInitPage,
7
+ wrapAppRootForCodegen,
8
+ } from "../templates/nextjs";
2
9
  import { spawnOrFail } from "../utils/cmd-utils";
3
- import { deleteGlob, writeDefaultNextjsConfig } from "../utils/file-utils";
10
+ import { deleteGlob, overwriteIndex } from "../utils/file-utils";
11
+ import { ensure } from "../utils/lang-utils";
4
12
  import { installUpgrade } from "../utils/npm-utils";
13
+ import { installCodegenDeps, runCodegenSync } from "./common";
5
14
  import { CPAStrategy } from "./types";
6
15
 
7
16
  const nextjsStrategy: CPAStrategy = {
@@ -16,35 +25,88 @@ const nextjsStrategy: CPAStrategy = {
16
25
  // See where we `touch tsconfig.json` later on
17
26
  await spawnOrFail(`${createCommand}${templateArg}`);
18
27
  },
19
- configLoader: async (args) => {
20
- const { projectId, projectPath, projectApiToken, useTypescript } = args;
21
-
22
- const installResult = await installUpgrade("@plasmicapp/loader-nextjs", {
23
- workingDir: projectPath,
24
- });
25
-
26
- if (!installResult) {
27
- throw new Error("Failed to install the Plasmic dependency");
28
+ installDeps: async ({ scheme, projectPath }) => {
29
+ if (scheme === "loader") {
30
+ return await installUpgrade("@plasmicapp/loader-nextjs", {
31
+ workingDir: projectPath,
32
+ });
33
+ } else {
34
+ return await installCodegenDeps({ projectPath });
28
35
  }
36
+ },
37
+ overwriteConfig: async (args) => {
38
+ const { projectPath, scheme } = args;
29
39
 
30
- await writeDefaultNextjsConfig(
31
- projectPath,
32
- projectId,
33
- true,
34
- projectApiToken,
35
- useTypescript
36
- );
40
+ if (scheme === "codegen") {
41
+ const nextjsConfigFile = path.join(projectPath, "next.config.js");
42
+ await fs.writeFile(
43
+ nextjsConfigFile,
44
+ `
45
+ module.exports = {
46
+ eslint: {
47
+ ignoreDuringBuilds: true,
48
+ },
49
+ trailingSlash: true,
50
+ // Your NextJS config.
51
+ };
52
+ `
53
+ );
54
+ }
37
55
  },
38
- overwriteFiles: async (args) => {
56
+ generateFiles: async (args) => {
39
57
  // this is supposed to be called for loader case, so we are supposed to remove
40
58
  // all the files from pages/ since we have inserted a optional catch all
41
- const { projectPath } = args;
59
+ const {
60
+ projectPath,
61
+ scheme,
62
+ useTypescript,
63
+ projectId,
64
+ projectApiToken,
65
+ } = args;
42
66
 
67
+ // Always start fresh
43
68
  const pagesPath = path.join(projectPath, "pages");
44
- deleteGlob(path.join(pagesPath, `*.*`), [
45
- "[[...catchall]]",
46
- "plasmic-host",
47
- ]);
69
+ deleteGlob(path.join(pagesPath, `*.*`));
70
+
71
+ const hostPage = path.join(
72
+ pagesPath,
73
+ `plasmic-host.${useTypescript ? "tsx" : "jsx"}`
74
+ );
75
+ await fs.writeFile(hostPage, makeNextjsHostPage(scheme));
76
+
77
+ if (scheme === "loader") {
78
+ const initFile = path.join(
79
+ projectPath,
80
+ `plasmic-init.${useTypescript ? "ts" : "js"}`
81
+ );
82
+ await fs.writeFile(
83
+ initFile,
84
+ makeNextjsInitPage(projectId, ensure(projectApiToken))
85
+ );
86
+
87
+ // Write catch-all page for loader
88
+ const loaderPage = path.join(
89
+ pagesPath,
90
+ `[[...catchall]].${useTypescript ? "tsx" : "jsx"}`
91
+ );
92
+ await fs.writeFile(
93
+ loaderPage,
94
+ makeNextjsCatchallPage(useTypescript ? "ts" : "js")
95
+ );
96
+ } else {
97
+ await runCodegenSync({
98
+ projectId,
99
+ projectApiToken,
100
+ projectPath,
101
+ });
102
+
103
+ // Overwrite the index file
104
+ await overwriteIndex(projectPath, "nextjs", scheme);
105
+
106
+ // Overwrite the wrapper files to wrap PlasmicRootProvider
107
+ const appFilePath = path.join(projectPath, "pages", `_app.js`);
108
+ await fs.writeFile(appFilePath, wrapAppRootForCodegen());
109
+ }
48
110
  },
49
111
  build: async (args) => {
50
112
  const { npmRunCmd, projectPath } = args;
@@ -1,5 +1,7 @@
1
1
  import { spawnOrFail } from "../utils/cmd-utils";
2
+ import { overwriteIndex } from "../utils/file-utils";
2
3
  import { installUpgrade } from "../utils/npm-utils";
4
+ import { installCodegenDeps, runCodegenSync } from "./common";
3
5
  import { CPAStrategy } from "./types";
4
6
 
5
7
  const reactStrategy: CPAStrategy = {
@@ -15,19 +17,36 @@ const reactStrategy: CPAStrategy = {
15
17
  const templateArg = template ? ` --template ${template}` : "";
16
18
  await spawnOrFail(`${createCommand}${templateArg}`);
17
19
  },
18
- configLoader: async (args) => {
19
- // this is unreachable for now, but should we have it ??
20
- const { projectPath } = args;
21
-
22
- const installResult = await installUpgrade("@plasmicapp/loader-react", {
23
- workingDir: projectPath,
24
- });
25
-
26
- if (!installResult) {
27
- throw new Error("Failed to install the Plasmic dependency");
20
+ installDeps: async ({ projectPath, scheme }) => {
21
+ if (scheme === "loader") {
22
+ return await installUpgrade("@plasmicapp/loader-react", {
23
+ workingDir: projectPath,
24
+ });
25
+ } else {
26
+ return await installCodegenDeps({ projectPath });
28
27
  }
29
28
  },
30
- overwriteFiles: async () => {
29
+ overwriteConfig: async (args) => {
30
+ // No config to overwrite
31
+ },
32
+ generateFiles: async ({
33
+ scheme,
34
+ projectApiToken,
35
+ projectId,
36
+ projectPath,
37
+ }) => {
38
+ if (scheme === "loader") {
39
+ // Nothing to do
40
+ } else {
41
+ await runCodegenSync({
42
+ projectId,
43
+ projectApiToken,
44
+ projectPath,
45
+ });
46
+
47
+ // Overwrite the index file
48
+ await overwriteIndex(projectPath, "react", scheme);
49
+ }
31
50
  return;
32
51
  },
33
52
  build: async (args) => {
@@ -1,3 +1,5 @@
1
+ import { CodeScheme } from "..";
2
+
1
3
  interface CreateArgs {
2
4
  projectPath: string;
3
5
  template?: string;
@@ -7,12 +9,17 @@ interface CreateArgs {
7
9
  interface ConfigArgs {
8
10
  projectId: string;
9
11
  projectPath: string;
10
- projectApiToken: string;
11
12
  useTypescript: boolean;
13
+ scheme: CodeScheme;
14
+ projectApiToken: string | undefined;
12
15
  }
13
16
 
14
- interface OverwriteFilesArgs {
17
+ interface GenerateFilesArgs {
15
18
  projectPath: string;
19
+ useTypescript: boolean;
20
+ scheme: CodeScheme;
21
+ projectId: string;
22
+ projectApiToken: string | undefined;
16
23
  }
17
24
 
18
25
  interface BuildArgs {
@@ -20,9 +27,15 @@ interface BuildArgs {
20
27
  npmRunCmd: string;
21
28
  }
22
29
 
30
+ interface InstallArgs {
31
+ scheme: CodeScheme;
32
+ projectPath: string;
33
+ }
34
+
23
35
  export interface CPAStrategy {
24
36
  create: (args: CreateArgs) => Promise<void>;
25
- configLoader: (args: ConfigArgs) => Promise<void>;
26
- overwriteFiles: (args: OverwriteFilesArgs) => Promise<void>;
37
+ installDeps: (args: InstallArgs) => Promise<boolean>;
38
+ overwriteConfig: (args: ConfigArgs) => Promise<void>;
39
+ generateFiles: (args: GenerateFilesArgs) => Promise<void>;
27
40
  build: (args: BuildArgs) => Promise<void>;
28
41
  }
@@ -1,12 +1,22 @@
1
- export const GATSBY_DEFAULT_PAGE = `
1
+ import { CodeScheme } from "..";
2
+ import { ifTs } from "../utils/file-utils";
3
+
4
+ export const makeGatsbyDefaultPage = (format: "ts" | "js"): string => {
5
+ const ts = format === "ts";
6
+ return `
2
7
  import React from "react";
3
8
  import Helmet from "react-helmet";
4
9
  import {
5
- initPlasmicLoader,
6
10
  PlasmicComponent,
7
- PlasmicRootProvider,
11
+ PlasmicRootProvider,${ifTs(
12
+ ts,
13
+ `
14
+ InitOptions,
15
+ ComponentRenderData,`
16
+ )}
8
17
  } from "@plasmicapp/loader-gatsby";
9
18
  import { graphql } from "gatsby";
19
+ import { initPlasmicLoaderWithRegistrations } from "../plasmic-init";
10
20
 
11
21
  export const query = graphql\`
12
22
  query ($path: String) {
@@ -15,7 +25,17 @@ export const query = graphql\`
15
25
  }
16
26
  \`;
17
27
 
18
- const PlasmicGatsbyPage = ({ data, location }) => {
28
+ ${ifTs(
29
+ ts,
30
+ `interface PlasmicGatsbyPageProps {
31
+ data: {
32
+ plasmicOptions: InitOptions
33
+ plasmicComponents: ComponentRenderData
34
+ }
35
+ }
36
+ `
37
+ )}
38
+ const PlasmicGatsbyPage = ({ data }${ifTs(ts, ": PlasmicGatsbyPageProps")}) => {
19
39
  const {
20
40
  plasmicComponents,
21
41
  plasmicOptions,
@@ -24,7 +44,7 @@ const PlasmicGatsbyPage = ({ data, location }) => {
24
44
  const pageMetadata = pageMeta.pageMetadata;
25
45
  return (
26
46
  <PlasmicRootProvider
27
- loader={initPlasmicLoader(plasmicOptions)}
47
+ loader={initPlasmicLoaderWithRegistrations(plasmicOptions)}
28
48
  prefetchedData={plasmicComponents}
29
49
  >
30
50
  <Helmet>
@@ -40,6 +60,7 @@ const PlasmicGatsbyPage = ({ data, location }) => {
40
60
 
41
61
  export default PlasmicGatsbyPage;
42
62
  `.trim();
63
+ };
43
64
 
44
65
  export const GATSBY_404 = `
45
66
  const NotFound = () => {
@@ -50,7 +71,8 @@ export default NotFound;
50
71
 
51
72
  export const GATSBY_PLUGIN_CONFIG = (
52
73
  projectId: string,
53
- projectApiToken: string
74
+ projectApiToken: string,
75
+ useTypescript: boolean
54
76
  ): string => `
55
77
  {
56
78
  resolve: "@plasmicapp/loader-gatsby",
@@ -61,7 +83,148 @@ export const GATSBY_PLUGIN_CONFIG = (
61
83
  token: "${projectApiToken}",
62
84
  },
63
85
  ], // An array of project ids.
64
- defaultPlasmicPage: require.resolve("./src/templates/defaultPlasmicPage.js"),
86
+ defaultPlasmicPage: require.resolve("./src/templates/defaultPlasmicPage.${
87
+ useTypescript ? "tsx" : "jsx"
88
+ }"),
65
89
  },
66
90
  },
67
91
  `;
92
+
93
+ export const makeGatsbyHostPage = (opts: {
94
+ useTypescript: boolean;
95
+ scheme: CodeScheme;
96
+ }): string => {
97
+ const { useTypescript, scheme } = opts;
98
+ if (scheme === "loader") {
99
+ return `
100
+ import * as React from "react"
101
+ import {
102
+ PlasmicCanvasHost${ifTs(useTypescript, `, InitOptions`)}
103
+ } from "@plasmicapp/loader-gatsby"
104
+ import { graphql } from "gatsby"
105
+ import { initPlasmicLoaderWithRegistrations } from "../plasmic-init"
106
+
107
+ export const query = graphql\`
108
+ query {
109
+ plasmicOptions
110
+ }
111
+ \`
112
+
113
+ ${ifTs(
114
+ useTypescript,
115
+ `interface HostProps {
116
+ data: {
117
+ plasmicOptions: InitOptions;
118
+ }
119
+ }
120
+ `
121
+ )}
122
+ export default function Host({ data }${ifTs(useTypescript, ": HostProps")}) {
123
+ const { plasmicOptions } = data
124
+ initPlasmicLoaderWithRegistrations(plasmicOptions)
125
+ return <PlasmicCanvasHost />
126
+ }
127
+ `.trim();
128
+ } else {
129
+ return `
130
+ import * as React from "react"
131
+ import { PlasmicCanvasHost, registerComponent } from "@plasmicapp/host";
132
+
133
+ // You can register any code components that you want to use here; see
134
+ // https://docs.plasmic.app/learn/code-components-ref/
135
+ // And configure your Plasmic project to use the host url pointing at
136
+ // the /plasmic-host page of your nextjs app (for example,
137
+ // http://localhost:3000/plasmic-host). See
138
+ // https://docs.plasmic.app/learn/app-hosting/#set-a-plasmic-project-to-use-your-app-host
139
+
140
+ // registerComponent(...)
141
+
142
+ export default function PlasmicHost() {
143
+ return (
144
+ <PlasmicCanvasHost />
145
+ );
146
+ }
147
+ `;
148
+ }
149
+ };
150
+
151
+ export const GATSBY_SSR_CONFIG = `
152
+ /**
153
+ * Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
154
+ *
155
+ * See: https://www.gatsbyjs.com/docs/ssr-apis/
156
+ */
157
+
158
+ const React = require("react")
159
+
160
+ /**
161
+ * Add preamble to allow functional code components in studio.
162
+ *
163
+ * See: https://docs.plasmic.app/learn/functional-code-components/
164
+ */
165
+ const HeadComponents = [
166
+ <script
167
+ key="plasmic-preamble"
168
+ src="https://static1.plasmic.app/preamble.js"
169
+ />,
170
+ ]
171
+
172
+ const isProduction = process.env.NODE_ENV === "production"
173
+
174
+ exports.onRenderBody = ({ pathname, setHeadComponents }) => {
175
+ /**
176
+ * We add the preamble tag script to all pages during development mode
177
+ * because during development all pages are dynamically rendered based
178
+ * on \`/\` route, during production we add it only in \`/plasmic-host/\`
179
+ */
180
+ if (!isProduction || pathname === "/plasmic-host/") {
181
+ setHeadComponents(HeadComponents)
182
+ }
183
+ }
184
+ `.trim();
185
+
186
+ export const makeGatsbyPlasmicInit = (format: "ts" | "js"): string => {
187
+ const ts = format === "ts";
188
+ return `
189
+ import {
190
+ initPlasmicLoader,${ifTs(
191
+ ts,
192
+ `
193
+ InitOptions,`
194
+ )}
195
+ } from "@plasmicapp/loader-gatsby";
196
+
197
+ export function initPlasmicLoaderWithRegistrations(plasmicOptions${ifTs(
198
+ ts,
199
+ ": InitOptions"
200
+ )}) {
201
+ const PLASMIC = initPlasmicLoader(plasmicOptions);
202
+
203
+ // You can register any code components that you want to use here; see
204
+ // https://docs.plasmic.app/learn/code-components-ref/
205
+ // And configure your Plasmic project to use the host url pointing at
206
+ // the /plasmic-host page of your nextjs app (for example,
207
+ // http://localhost:8000/plasmic-host). See
208
+ // https://docs.plasmic.app/learn/app-hosting/#set-a-plasmic-project-to-use-your-app-host
209
+
210
+ // PLASMIC.registerComponent(...);
211
+
212
+ return PLASMIC;
213
+ }
214
+ `.trim();
215
+ };
216
+
217
+ export function wrapAppRootForCodegen() {
218
+ return `
219
+ import React from "react";
220
+ import { PlasmicRootProvider } from "@plasmicapp/react-web";
221
+
222
+ export const wrapRootElement = ({ element }) => {
223
+ return (
224
+ <PlasmicRootProvider>
225
+ {element}
226
+ </PlasmicRootProvider>
227
+ );
228
+ }
229
+ `;
230
+ }