create-plasmic-app 0.0.63 → 0.0.64
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/README.internal.md +6 -2
- package/cpa-out/.gitignore +15 -0
- package/cpa-out/gatsby-codegen-js/gatsby-browser.jsx +11 -0
- package/cpa-out/gatsby-codegen-js/gatsby-config.js +9 -0
- package/cpa-out/gatsby-codegen-js/gatsby-node.js +0 -0
- package/cpa-out/gatsby-codegen-js/gatsby-ssr.jsx +11 -0
- package/cpa-out/gatsby-codegen-js/package.json +26 -0
- package/cpa-out/gatsby-codegen-js/plasmic.json +79 -0
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.jsx +29 -0
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +206 -0
- package/cpa-out/gatsby-codegen-js/src/pages/404.js +4 -0
- package/cpa-out/gatsby-codegen-js/src/pages/index.jsx +39 -0
- package/cpa-out/gatsby-codegen-ts/gatsby-browser.tsx +11 -0
- package/cpa-out/gatsby-codegen-ts/gatsby-config.ts +14 -0
- package/cpa-out/gatsby-codegen-ts/gatsby-node.ts +0 -0
- package/cpa-out/gatsby-codegen-ts/gatsby-ssr.tsx +11 -0
- package/cpa-out/gatsby-codegen-ts/package.json +34 -0
- package/cpa-out/gatsby-codegen-ts/plasmic.json +79 -0
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +30 -0
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +290 -0
- package/cpa-out/gatsby-codegen-ts/src/pages/404.js +4 -0
- package/cpa-out/gatsby-codegen-ts/src/pages/index.tsx +41 -0
- package/cpa-out/gatsby-codegen-ts/tsconfig.json +102 -0
- package/cpa-out/gatsby-loader-js/gatsby-config.js +25 -0
- package/cpa-out/gatsby-loader-js/gatsby-node.js +0 -0
- package/cpa-out/gatsby-loader-js/gatsby-ssr.jsx +44 -0
- package/cpa-out/gatsby-loader-js/package.json +24 -0
- package/cpa-out/gatsby-loader-js/src/pages/404.js +4 -0
- package/cpa-out/gatsby-loader-js/src/pages/plasmic-host.jsx +19 -0
- package/cpa-out/gatsby-loader-js/src/plasmic-init.js +18 -0
- package/cpa-out/gatsby-loader-js/src/templates/defaultPlasmicPage.jsx +44 -0
- package/cpa-out/gatsby-loader-ts/gatsby-config.ts +31 -0
- package/cpa-out/gatsby-loader-ts/gatsby-node.ts +0 -0
- package/cpa-out/gatsby-loader-ts/gatsby-ssr.tsx +44 -0
- package/cpa-out/gatsby-loader-ts/package.json +32 -0
- package/cpa-out/gatsby-loader-ts/src/pages/404.ts +4 -0
- package/cpa-out/gatsby-loader-ts/src/pages/plasmic-host.tsx +24 -0
- package/cpa-out/gatsby-loader-ts/src/plasmic-init.ts +19 -0
- package/cpa-out/gatsby-loader-ts/src/templates/defaultPlasmicPage.tsx +52 -0
- package/cpa-out/gatsby-loader-ts/tsconfig.json +102 -0
- package/cpa-out/nextjs-app-loader-js/app/[[...catchall]]/page.jsx +56 -0
- package/cpa-out/nextjs-app-loader-js/app/head.js +10 -0
- package/cpa-out/nextjs-app-loader-js/app/layout.js +14 -0
- package/cpa-out/nextjs-app-loader-js/app/plasmic-host/page.jsx +6 -0
- package/cpa-out/nextjs-app-loader-js/next.config.js +13 -0
- package/cpa-out/nextjs-app-loader-js/package.json +20 -0
- package/cpa-out/nextjs-app-loader-js/pages/api/hello.js +5 -0
- package/cpa-out/nextjs-app-loader-js/plasmic-init-client.jsx +65 -0
- package/cpa-out/nextjs-app-loader-js/plasmic-init.js +16 -0
- package/cpa-out/nextjs-app-loader-ts/app/[[...catchall]]/page.tsx +59 -0
- package/cpa-out/nextjs-app-loader-ts/app/head.tsx +10 -0
- package/cpa-out/nextjs-app-loader-ts/app/layout.tsx +18 -0
- package/cpa-out/nextjs-app-loader-ts/app/plasmic-host/page.tsx +6 -0
- package/cpa-out/nextjs-app-loader-ts/next.config.js +13 -0
- package/cpa-out/nextjs-app-loader-ts/package.json +24 -0
- package/cpa-out/nextjs-app-loader-ts/pages/api/hello.ts +13 -0
- package/cpa-out/nextjs-app-loader-ts/plasmic-init-client.tsx +65 -0
- package/cpa-out/nextjs-app-loader-ts/plasmic-init.ts +16 -0
- package/cpa-out/nextjs-app-loader-ts/tsconfig.json +29 -0
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.jsx +29 -0
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +205 -0
- package/cpa-out/nextjs-pages-codegen-js/next.config.js +10 -0
- package/cpa-out/nextjs-pages-codegen-js/package.json +22 -0
- package/cpa-out/nextjs-pages-codegen-js/pages/_app.jsx +11 -0
- package/cpa-out/nextjs-pages-codegen-js/pages/api/hello.js +5 -0
- package/cpa-out/nextjs-pages-codegen-js/pages/index.jsx +35 -0
- package/cpa-out/nextjs-pages-codegen-js/pages/plasmic-host.jsx +15 -0
- package/cpa-out/nextjs-pages-codegen-js/plasmic.json +79 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +30 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +287 -0
- package/cpa-out/nextjs-pages-codegen-ts/next.config.js +10 -0
- package/cpa-out/nextjs-pages-codegen-ts/package.json +26 -0
- package/cpa-out/nextjs-pages-codegen-ts/pages/_app.tsx +12 -0
- package/cpa-out/nextjs-pages-codegen-ts/pages/api/hello.ts +13 -0
- package/cpa-out/nextjs-pages-codegen-ts/pages/index.tsx +37 -0
- package/cpa-out/nextjs-pages-codegen-ts/pages/plasmic-host.tsx +15 -0
- package/cpa-out/nextjs-pages-codegen-ts/plasmic.json +79 -0
- package/cpa-out/nextjs-pages-codegen-ts/tsconfig.json +24 -0
- package/cpa-out/nextjs-pages-loader-js/next.config.js +10 -0
- package/cpa-out/nextjs-pages-loader-js/package.json +20 -0
- package/cpa-out/nextjs-pages-loader-js/pages/[[...catchall]].jsx +66 -0
- package/cpa-out/nextjs-pages-loader-js/pages/api/hello.js +5 -0
- package/cpa-out/nextjs-pages-loader-js/pages/plasmic-host.jsx +7 -0
- package/cpa-out/nextjs-pages-loader-js/plasmic-init.js +25 -0
- package/cpa-out/nextjs-pages-loader-ts/next.config.js +10 -0
- package/cpa-out/nextjs-pages-loader-ts/package.json +24 -0
- package/cpa-out/nextjs-pages-loader-ts/pages/[[...catchall]].tsx +70 -0
- package/cpa-out/nextjs-pages-loader-ts/pages/api/hello.ts +13 -0
- package/cpa-out/nextjs-pages-loader-ts/pages/plasmic-host.tsx +7 -0
- package/cpa-out/nextjs-pages-loader-ts/plasmic-init.ts +25 -0
- package/cpa-out/nextjs-pages-loader-ts/tsconfig.json +24 -0
- package/cpa-out/react-codegen-js/package.json +41 -0
- package/cpa-out/react-codegen-js/plasmic.json +76 -0
- package/cpa-out/react-codegen-js/src/App.jsx +9 -0
- package/cpa-out/react-codegen-js/src/components/Homepage.jsx +26 -0
- package/cpa-out/react-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.jsx +29 -0
- package/cpa-out/react-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +196 -0
- package/cpa-out/react-codegen-js/src/index.js +17 -0
- package/cpa-out/react-codegen-js/src/reportWebVitals.js +13 -0
- package/cpa-out/react-codegen-js/src/setupTests.js +5 -0
- package/cpa-out/react-codegen-ts/package.json +46 -0
- package/cpa-out/react-codegen-ts/plasmic.json +76 -0
- package/cpa-out/react-codegen-ts/src/App.tsx +9 -0
- package/cpa-out/react-codegen-ts/src/components/Homepage.tsx +45 -0
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +30 -0
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +280 -0
- package/cpa-out/react-codegen-ts/src/index.tsx +19 -0
- package/cpa-out/react-codegen-ts/src/react-app-env.d.ts +1 -0
- package/cpa-out/react-codegen-ts/src/reportWebVitals.ts +15 -0
- package/cpa-out/react-codegen-ts/src/setupTests.ts +5 -0
- package/cpa-out/react-codegen-ts/tsconfig.json +26 -0
- package/cpa-out/react-loader-js/package.json +41 -0
- package/cpa-out/react-loader-js/plasmic.json +76 -0
- package/cpa-out/react-loader-js/src/App.jsx +9 -0
- package/cpa-out/react-loader-js/src/components/Homepage.jsx +26 -0
- package/cpa-out/react-loader-js/src/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.jsx +29 -0
- package/cpa-out/react-loader-js/src/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +196 -0
- package/cpa-out/react-loader-js/src/index.js +17 -0
- package/cpa-out/react-loader-js/src/reportWebVitals.js +13 -0
- package/cpa-out/react-loader-js/src/setupTests.js +5 -0
- package/cpa-out/react-loader-ts/package.json +46 -0
- package/cpa-out/react-loader-ts/plasmic.json +76 -0
- package/cpa-out/react-loader-ts/src/App.tsx +9 -0
- package/cpa-out/react-loader-ts/src/components/Homepage.tsx +45 -0
- package/cpa-out/react-loader-ts/src/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +30 -0
- package/cpa-out/react-loader-ts/src/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +280 -0
- package/cpa-out/react-loader-ts/src/index.tsx +19 -0
- package/cpa-out/react-loader-ts/src/react-app-env.d.ts +1 -0
- package/cpa-out/react-loader-ts/src/reportWebVitals.ts +15 -0
- package/cpa-out/react-loader-ts/src/setupTests.ts +5 -0
- package/cpa-out/react-loader-ts/tsconfig.json +26 -0
- package/dist/gatsby/gatsby.d.ts +6 -0
- package/dist/{strategies → gatsby}/gatsby.js +26 -29
- package/dist/gatsby/template.d.ts +11 -0
- package/dist/{templates/gatsby.js → gatsby/template.js} +34 -42
- package/dist/index.d.ts +1 -1
- package/dist/index.js +57 -27
- package/dist/lib.d.ts +3 -4
- package/dist/lib.js +22 -12
- package/dist/nextjs/nextjs.d.ts +2 -0
- package/dist/nextjs/nextjs.js +155 -0
- package/dist/nextjs/templates/app-loader/catchall-page.d.ts +2 -0
- package/dist/nextjs/templates/app-loader/catchall-page.js +67 -0
- package/dist/nextjs/templates/app-loader/plasmic-host.d.ts +1 -0
- package/dist/nextjs/templates/app-loader/plasmic-host.js +13 -0
- package/dist/nextjs/templates/app-loader/plasmic-init-client.d.ts +2 -0
- package/dist/nextjs/templates/app-loader/plasmic-init-client.js +73 -0
- package/dist/nextjs/templates/app-loader/plasmic-init.d.ts +1 -0
- package/dist/nextjs/templates/app-loader/plasmic-init.js +23 -0
- package/dist/nextjs/templates/pages-codegen/app.d.ts +2 -0
- package/dist/nextjs/templates/pages-codegen/app.js +20 -0
- package/dist/nextjs/templates/pages-codegen/plasmic-host.d.ts +1 -0
- package/dist/nextjs/templates/pages-codegen/plasmic-host.js +22 -0
- package/dist/nextjs/templates/pages-loader/catchall-page.d.ts +2 -0
- package/dist/nextjs/templates/pages-loader/catchall-page.js +77 -0
- package/dist/nextjs/templates/pages-loader/plasmic-host.d.ts +1 -0
- package/dist/nextjs/templates/pages-loader/plasmic-host.js +14 -0
- package/dist/nextjs/templates/pages-loader/plasmic-init.d.ts +1 -0
- package/dist/nextjs/templates/pages-loader/plasmic-init.js +32 -0
- package/dist/react/react.d.ts +2 -0
- package/dist/{strategies → react}/react.js +10 -10
- package/dist/templates/readme.d.ts +2 -2
- package/dist/templates/readme.js +5 -4
- package/dist/templates/welcomePage.d.ts +2 -2
- package/dist/templates/welcomePage.js +5 -5
- package/dist/{strategies/common.d.ts → utils/codegen.d.ts} +0 -0
- package/dist/{strategies/common.js → utils/codegen.js} +0 -0
- package/dist/utils/file-utils.d.ts +2 -2
- package/dist/utils/file-utils.js +3 -3
- package/dist/{strategies/types.d.ts → utils/strategy.d.ts} +16 -14
- package/dist/{strategies/types.js → utils/strategy.js} +0 -0
- package/dist/utils/types.d.ts +9 -0
- package/dist/utils/types.js +7 -0
- package/package.json +4 -3
- package/run-cpa.ts +151 -0
- package/src/{strategies → gatsby}/gatsby.ts +28 -46
- package/src/{templates/gatsby.ts → gatsby/template.ts} +41 -51
- package/src/index.ts +86 -56
- package/src/lib.ts +30 -15
- package/src/nextjs/nextjs.ts +180 -0
- package/src/nextjs/templates/app-loader/catchall-page.ts +71 -0
- package/src/nextjs/templates/app-loader/plasmic-host.ts +9 -0
- package/src/nextjs/templates/app-loader/plasmic-init-client.ts +74 -0
- package/src/nextjs/templates/app-loader/plasmic-init.ts +22 -0
- package/src/nextjs/templates/pages-codegen/app.ts +24 -0
- package/src/nextjs/templates/pages-codegen/plasmic-host.ts +18 -0
- package/src/nextjs/templates/pages-loader/catchall-page.ts +81 -0
- package/src/nextjs/templates/pages-loader/plasmic-host.ts +10 -0
- package/src/nextjs/templates/pages-loader/plasmic-init.ts +31 -0
- package/src/{strategies → react}/react.ts +8 -10
- package/src/templates/readme.ts +5 -5
- package/src/templates/welcomePage.ts +6 -7
- package/src/{strategies/common.ts → utils/codegen.ts} +0 -0
- package/src/utils/file-utils.ts +4 -4
- package/src/utils/strategy.ts +48 -0
- package/src/utils/types.ts +12 -0
- package/dist/strategies/gatsby.d.ts +0 -7
- package/dist/strategies/index.d.ts +0 -2
- package/dist/strategies/index.js +0 -22
- package/dist/strategies/nextjs.d.ts +0 -3
- package/dist/strategies/nextjs.js +0 -104
- package/dist/strategies/react.d.ts +0 -3
- package/dist/templates/gatsby.d.ts +0 -11
- package/dist/templates/nextjs.d.ts +0 -5
- package/dist/templates/nextjs.js +0 -162
- package/src/strategies/index.ts +0 -21
- package/src/strategies/nextjs.ts +0 -131
- package/src/strategies/types.ts +0 -42
- package/src/templates/nextjs.ts +0 -170
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeCatchallPage_app_loader = void 0;
|
|
4
|
+
const file_utils_1 = require("../../../utils/file-utils");
|
|
5
|
+
function makeCatchallPage_app_loader(jsOrTs) {
|
|
6
|
+
return `import { PlasmicComponent } from "@plasmicapp/loader-nextjs";
|
|
7
|
+
import { notFound } from "next/navigation";
|
|
8
|
+
import { PLASMIC } from "plasmic-init";
|
|
9
|
+
import { ClientPlasmicRootProvider } from "plasmic-init-client";
|
|
10
|
+
|
|
11
|
+
// Use revalidate if you want incremental static regeneration
|
|
12
|
+
export const revalidate = 60;
|
|
13
|
+
|
|
14
|
+
export default async function PlasmicLoaderPage({
|
|
15
|
+
params,
|
|
16
|
+
searchParams,
|
|
17
|
+
}${(0, file_utils_1.ifTs)(jsOrTs, `: {
|
|
18
|
+
params?: { catchall: string[] | undefined };
|
|
19
|
+
searchParams?: Record<string, string | string[]>;
|
|
20
|
+
}`)}) {
|
|
21
|
+
const plasmicComponentData = await fetchPlasmicComponentData(params?.catchall);
|
|
22
|
+
if (!plasmicComponentData) {
|
|
23
|
+
notFound();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { prefetchedData } = plasmicComponentData;
|
|
27
|
+
if (prefetchedData.entryCompMetas.length === 0) {
|
|
28
|
+
notFound();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const pageMeta = prefetchedData.entryCompMetas[0];
|
|
32
|
+
return (
|
|
33
|
+
<ClientPlasmicRootProvider
|
|
34
|
+
prefetchedData={prefetchedData}
|
|
35
|
+
pageParams={pageMeta.params}
|
|
36
|
+
pageQuery={searchParams}
|
|
37
|
+
>
|
|
38
|
+
<PlasmicComponent
|
|
39
|
+
component={pageMeta.displayName}
|
|
40
|
+
/>
|
|
41
|
+
</ClientPlasmicRootProvider>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function fetchPlasmicComponentData(catchall${(0, file_utils_1.ifTs)(jsOrTs, ": string[] | undefined")}) {
|
|
46
|
+
const plasmicPath = "/" + (catchall ? catchall.join("/") : "");
|
|
47
|
+
const prefetchedData = await PLASMIC.maybeFetchComponentData(plasmicPath);
|
|
48
|
+
if (!prefetchedData) {
|
|
49
|
+
notFound();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return { prefetchedData };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function generateStaticParams() {
|
|
56
|
+
const pageModules = await PLASMIC.fetchPages();
|
|
57
|
+
return pageModules.map((mod) => {
|
|
58
|
+
const catchall =
|
|
59
|
+
mod.path === "/" ? undefined : mod.path.substring(1).split("/");
|
|
60
|
+
return {
|
|
61
|
+
catchall,
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
exports.makeCatchallPage_app_loader = makeCatchallPage_app_loader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makePlasmicHostPage_app_loader(): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePlasmicHostPage_app_loader = void 0;
|
|
4
|
+
function makePlasmicHostPage_app_loader() {
|
|
5
|
+
return `import { PlasmicCanvasHost } from "@plasmicapp/loader-nextjs";
|
|
6
|
+
import "plasmic-init-client";
|
|
7
|
+
|
|
8
|
+
export default function PlasmicHost() {
|
|
9
|
+
return <PlasmicCanvasHost />;
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
}
|
|
13
|
+
exports.makePlasmicHostPage_app_loader = makePlasmicHostPage_app_loader;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePlasmicInitClient_app_loader = void 0;
|
|
4
|
+
const file_utils_1 = require("../../../utils/file-utils");
|
|
5
|
+
function makePlasmicInitClient_app_loader(jsOrTs) {
|
|
6
|
+
return `"use client";
|
|
7
|
+
|
|
8
|
+
import { PlasmicRootProvider } from "@plasmicapp/loader-nextjs";
|
|
9
|
+
import { PLASMIC } from "plasmic-init";
|
|
10
|
+
|
|
11
|
+
// You can register any code components that you want to use here; see
|
|
12
|
+
// https://docs.plasmic.app/learn/code-components-ref/
|
|
13
|
+
// And configure your Plasmic project to use the host url pointing at
|
|
14
|
+
// the /plasmic-host page of your nextjs app (for example,
|
|
15
|
+
// http://localhost:3000/plasmic-host). See
|
|
16
|
+
// https://docs.plasmic.app/learn/app-hosting/#set-a-plasmic-project-to-use-your-app-host
|
|
17
|
+
|
|
18
|
+
// PLASMIC.registerComponent(...);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* ClientPlasmicRootProvider is a Client Component that passes in the loader for you.
|
|
22
|
+
*
|
|
23
|
+
* Why? Props passed from Server to Client Components must be serializable.
|
|
24
|
+
* https://beta.nextjs.org/docs/rendering/server-and-client-components#passing-props-from-server-to-client-components-serialization
|
|
25
|
+
* However, PlasmicRootProvider requires a loader, but the loader is NOT serializable.
|
|
26
|
+
*
|
|
27
|
+
* In a Server Component like app/<your-path>/path.tsx, rendering the following would not work:
|
|
28
|
+
*
|
|
29
|
+
* \`\`\`tsx
|
|
30
|
+
* import { PLASMIC } from "plasmic-init";
|
|
31
|
+
* import { PlasmicRootProvider } from "plasmicapp/loader-nextjs";
|
|
32
|
+
* export default function MyPage() {
|
|
33
|
+
* const prefetchedData = await PLASMIC.fetchComponentData("YourPage");
|
|
34
|
+
* return (
|
|
35
|
+
* <PlasmicRootProvider
|
|
36
|
+
* loader={PLASMIC} // ERROR: loader is not serializable
|
|
37
|
+
* prefetchedData={prefetchedData}
|
|
38
|
+
* >
|
|
39
|
+
* {yourContent()}
|
|
40
|
+
* </PlasmicRootProvider>;
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
* \`\`\`
|
|
44
|
+
*
|
|
45
|
+
* Therefore, we define ClientPlasmicRootProvider as a Client Component (this file is marked "use client").
|
|
46
|
+
* ClientPlasmicRootProvider wraps the PlasmicRootProvider and passes in the loader for you,
|
|
47
|
+
* while allowing your Server Component to pass in prefetched data and other serializable props:
|
|
48
|
+
*
|
|
49
|
+
* \`\`\`tsx
|
|
50
|
+
* import { PLASMIC } from "plasmic-init";
|
|
51
|
+
* import { ClientPlasmicRootProvider } from "plasmic-init-client"; // changed
|
|
52
|
+
* export default function MyPage() {
|
|
53
|
+
* const prefetchedData = await PLASMIC.fetchComponentData("YourPage");
|
|
54
|
+
* return (
|
|
55
|
+
* <ClientPlasmicRootProvider // don't pass in loader
|
|
56
|
+
* prefetchedData={prefetchedData}
|
|
57
|
+
* >
|
|
58
|
+
* {yourContent()}
|
|
59
|
+
* </ClientPlasmicRootProvider>;
|
|
60
|
+
* );
|
|
61
|
+
* }
|
|
62
|
+
* \`\`\`
|
|
63
|
+
*/
|
|
64
|
+
export function ClientPlasmicRootProvider(
|
|
65
|
+
props${(0, file_utils_1.ifTs)(jsOrTs, ': Omit<React.ComponentProps<typeof PlasmicRootProvider>, "loader">')}
|
|
66
|
+
) {
|
|
67
|
+
return (
|
|
68
|
+
<PlasmicRootProvider loader={PLASMIC} {...props}></PlasmicRootProvider>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
exports.makePlasmicInitClient_app_loader = makePlasmicInitClient_app_loader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makePlasmicInit_app_loader(projectId: string, projectApiToken: string): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePlasmicInit_app_loader = void 0;
|
|
4
|
+
function makePlasmicInit_app_loader(projectId, projectApiToken) {
|
|
5
|
+
return `import { initPlasmicLoader } from "@plasmicapp/loader-nextjs/react-server-conditional";
|
|
6
|
+
|
|
7
|
+
export const PLASMIC = initPlasmicLoader({
|
|
8
|
+
projects: [
|
|
9
|
+
{
|
|
10
|
+
id: "${projectId}",
|
|
11
|
+
token: "${projectApiToken}",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
|
|
15
|
+
// By default Plasmic will use the last published version of your project.
|
|
16
|
+
// For development, you can set preview to true, which will use the unpublished
|
|
17
|
+
// project, allowing you to see your designs without publishing. Please
|
|
18
|
+
// only use this for development, as this is significantly slower.
|
|
19
|
+
preview: false,
|
|
20
|
+
});
|
|
21
|
+
`;
|
|
22
|
+
}
|
|
23
|
+
exports.makePlasmicInit_app_loader = makePlasmicInit_app_loader;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeCustomApp_pages_codegen = void 0;
|
|
4
|
+
const file_utils_1 = require("../../../utils/file-utils");
|
|
5
|
+
function makeCustomApp_pages_codegen(jsOrTs) {
|
|
6
|
+
return `import 'styles/globals.css'
|
|
7
|
+
import { PlasmicRootProvider } from "@plasmicapp/react-web";${(0, file_utils_1.ifTs)(jsOrTs, `
|
|
8
|
+
import type { AppProps } from "next/app";`)}
|
|
9
|
+
import Head from "next/head";
|
|
10
|
+
|
|
11
|
+
export default function MyApp({ Component, pageProps }${(0, file_utils_1.ifTs)(jsOrTs, `: AppProps`)}) {
|
|
12
|
+
return (
|
|
13
|
+
<PlasmicRootProvider Head={Head}>
|
|
14
|
+
<Component {...pageProps} />
|
|
15
|
+
</PlasmicRootProvider>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
exports.makeCustomApp_pages_codegen = makeCustomApp_pages_codegen;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makePlasmicHostPage_pages_codegen(): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePlasmicHostPage_pages_codegen = void 0;
|
|
4
|
+
function makePlasmicHostPage_pages_codegen() {
|
|
5
|
+
return `import * as React from 'react';
|
|
6
|
+
import { PlasmicCanvasHost, registerComponent } from '@plasmicapp/host';
|
|
7
|
+
|
|
8
|
+
// You can register any code components that you want to use here; see
|
|
9
|
+
// https://docs.plasmic.app/learn/code-components-ref/
|
|
10
|
+
// And configure your Plasmic project to use the host url pointing at
|
|
11
|
+
// the /plasmic-host page of your nextjs app (for example,
|
|
12
|
+
// http://localhost:3000/plasmic-host). See
|
|
13
|
+
// https://docs.plasmic.app/learn/app-hosting/#set-a-plasmic-project-to-use-your-app-host
|
|
14
|
+
|
|
15
|
+
// registerComponent(...)
|
|
16
|
+
|
|
17
|
+
export default function PlasmicHost() {
|
|
18
|
+
return <PlasmicCanvasHost />;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
22
|
+
exports.makePlasmicHostPage_pages_codegen = makePlasmicHostPage_pages_codegen;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeCatchallPage_pages_loader = void 0;
|
|
4
|
+
const file_utils_1 = require("../../../utils/file-utils");
|
|
5
|
+
function makeCatchallPage_pages_loader(jsOrTs) {
|
|
6
|
+
return `import * as React from "react";
|
|
7
|
+
import {
|
|
8
|
+
PlasmicComponent,
|
|
9
|
+
extractPlasmicQueryData,
|
|
10
|
+
ComponentRenderData,
|
|
11
|
+
PlasmicRootProvider,
|
|
12
|
+
} from "@plasmicapp/loader-nextjs";
|
|
13
|
+
${(0, file_utils_1.ifTs)(jsOrTs, `import type { GetStaticPaths, GetStaticProps } from "next";\n`)}
|
|
14
|
+
import Error from "next/error";
|
|
15
|
+
import { useRouter } from "next/router";
|
|
16
|
+
import { PLASMIC } from "plasmic-init";
|
|
17
|
+
|
|
18
|
+
export default function PlasmicLoaderPage(props${(0, file_utils_1.ifTs)(jsOrTs, `: {
|
|
19
|
+
plasmicData?: ComponentRenderData;
|
|
20
|
+
queryCache?: Record<string, any>;
|
|
21
|
+
}`)}) {
|
|
22
|
+
const { plasmicData, queryCache } = props;
|
|
23
|
+
const router = useRouter();
|
|
24
|
+
if (!plasmicData || plasmicData.entryCompMetas.length === 0) {
|
|
25
|
+
return <Error statusCode={404} />;
|
|
26
|
+
}
|
|
27
|
+
const pageMeta = plasmicData.entryCompMetas[0];
|
|
28
|
+
return (
|
|
29
|
+
<PlasmicRootProvider
|
|
30
|
+
loader={PLASMIC}
|
|
31
|
+
prefetchedData={plasmicData}
|
|
32
|
+
prefetchedQueryData={queryCache}
|
|
33
|
+
pageParams={pageMeta.params}
|
|
34
|
+
pageQuery={router.query}
|
|
35
|
+
>
|
|
36
|
+
<PlasmicComponent component={pageMeta.displayName} />
|
|
37
|
+
</PlasmicRootProvider>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const getStaticProps${(0, file_utils_1.ifTs)(jsOrTs, `: GetStaticProps`)} = async (context) => {
|
|
42
|
+
const { catchall } = context.params ?? {};
|
|
43
|
+
const plasmicPath = typeof catchall === 'string' ? catchall : Array.isArray(catchall) ? \`/\${catchall.join('/')}\` : '/';
|
|
44
|
+
const plasmicData = await PLASMIC.maybeFetchComponentData(plasmicPath);
|
|
45
|
+
if (!plasmicData) {
|
|
46
|
+
// non-Plasmic catch-all
|
|
47
|
+
return { props: {} };
|
|
48
|
+
}
|
|
49
|
+
const pageMeta = plasmicData.entryCompMetas[0];
|
|
50
|
+
// Cache the necessary data fetched for the page
|
|
51
|
+
const queryCache = await extractPlasmicQueryData(
|
|
52
|
+
<PlasmicRootProvider
|
|
53
|
+
loader={PLASMIC}
|
|
54
|
+
prefetchedData={plasmicData}
|
|
55
|
+
pageParams={pageMeta.params}
|
|
56
|
+
>
|
|
57
|
+
<PlasmicComponent component={pageMeta.displayName} />
|
|
58
|
+
</PlasmicRootProvider>
|
|
59
|
+
);
|
|
60
|
+
// Use revalidate if you want incremental static regeneration
|
|
61
|
+
return { props: { plasmicData, queryCache }, revalidate: 60 };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const getStaticPaths${(0, file_utils_1.ifTs)(jsOrTs, `: GetStaticPaths`)} = async () => {
|
|
65
|
+
const pageModules = await PLASMIC.fetchPages();
|
|
66
|
+
return {
|
|
67
|
+
paths: pageModules.map((mod) => ({
|
|
68
|
+
params: {
|
|
69
|
+
catchall: mod.path.substring(1).split("/"),
|
|
70
|
+
},
|
|
71
|
+
})),
|
|
72
|
+
fallback: "blocking",
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
exports.makeCatchallPage_pages_loader = makeCatchallPage_pages_loader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makePlasmicHostPage_pages_loader(): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePlasmicHostPage_pages_loader = void 0;
|
|
4
|
+
function makePlasmicHostPage_pages_loader() {
|
|
5
|
+
return `import * as React from 'react';
|
|
6
|
+
import { PlasmicCanvasHost } from '@plasmicapp/loader-nextjs';
|
|
7
|
+
import { PLASMIC } from 'plasmic-init';
|
|
8
|
+
|
|
9
|
+
export default function PlasmicHost() {
|
|
10
|
+
return PLASMIC && <PlasmicCanvasHost />;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
}
|
|
14
|
+
exports.makePlasmicHostPage_pages_loader = makePlasmicHostPage_pages_loader;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makePlasmicInit_pages_loader(projectId: string, projectApiToken: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makePlasmicInit_pages_loader = void 0;
|
|
4
|
+
function makePlasmicInit_pages_loader(projectId, projectApiToken) {
|
|
5
|
+
return `import { initPlasmicLoader } from "@plasmicapp/loader-nextjs";
|
|
6
|
+
|
|
7
|
+
export const PLASMIC = initPlasmicLoader({
|
|
8
|
+
projects: [
|
|
9
|
+
{
|
|
10
|
+
id: "${projectId}",
|
|
11
|
+
token: "${projectApiToken}",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
|
|
15
|
+
// By default Plasmic will use the last published version of your project.
|
|
16
|
+
// For development, you can set preview to true, which will use the unpublished
|
|
17
|
+
// project, allowing you to see your designs without publishing. Please
|
|
18
|
+
// only use this for development, as this is significantly slower.
|
|
19
|
+
preview: false,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// You can register any code components that you want to use here; see
|
|
23
|
+
// https://docs.plasmic.app/learn/code-components-ref/
|
|
24
|
+
// And configure your Plasmic project to use the host url pointing at
|
|
25
|
+
// the /plasmic-host page of your nextjs app (for example,
|
|
26
|
+
// http://localhost:3000/plasmic-host). See
|
|
27
|
+
// https://docs.plasmic.app/learn/app-hosting/#set-a-plasmic-project-to-use-your-app-host
|
|
28
|
+
|
|
29
|
+
// PLASMIC.registerComponent(...);
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
exports.makePlasmicInit_pages_loader = makePlasmicInit_pages_loader;
|
|
@@ -12,18 +12,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.reactStrategy = void 0;
|
|
15
16
|
const fs_1 = __importDefault(require("fs"));
|
|
16
17
|
const path_1 = __importDefault(require("path"));
|
|
17
18
|
const cmd_utils_1 = require("../utils/cmd-utils");
|
|
19
|
+
const codegen_1 = require("../utils/codegen");
|
|
18
20
|
const file_utils_1 = require("../utils/file-utils");
|
|
19
21
|
const npm_utils_1 = require("../utils/npm-utils");
|
|
20
|
-
|
|
21
|
-
const reactStrategy = {
|
|
22
|
+
exports.reactStrategy = {
|
|
22
23
|
create: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const { projectPath,
|
|
24
|
+
const { projectPath, jsOrTs } = args;
|
|
24
25
|
let { template } = args;
|
|
25
26
|
const createCommand = `npx create-react-app@latest ${projectPath}`;
|
|
26
|
-
if (!template &&
|
|
27
|
+
if (!template && jsOrTs === "ts") {
|
|
27
28
|
template = "typescript";
|
|
28
29
|
}
|
|
29
30
|
const templateArg = template ? ` --template ${template}` : "";
|
|
@@ -36,18 +37,18 @@ const reactStrategy = {
|
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
|
-
return yield (0,
|
|
40
|
+
return yield (0, codegen_1.installCodegenDeps)({ projectPath });
|
|
40
41
|
}
|
|
41
42
|
}),
|
|
42
43
|
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
44
|
// No config to overwrite
|
|
44
45
|
}),
|
|
45
|
-
generateFiles: ({ scheme, projectApiToken, projectId, projectPath,
|
|
46
|
+
generateFiles: ({ scheme, projectApiToken, projectId, projectPath, jsOrTs, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
47
|
if (scheme === "loader") {
|
|
47
48
|
// Nothing to do
|
|
48
49
|
}
|
|
49
50
|
else {
|
|
50
|
-
yield (0,
|
|
51
|
+
yield (0, codegen_1.runCodegenSync)({
|
|
51
52
|
projectId,
|
|
52
53
|
projectApiToken,
|
|
53
54
|
projectPath,
|
|
@@ -55,8 +56,8 @@ const reactStrategy = {
|
|
|
55
56
|
// Overwrite the App.tsx
|
|
56
57
|
yield (0, file_utils_1.overwriteIndex)(projectPath, "react", scheme);
|
|
57
58
|
}
|
|
58
|
-
// Deactivate React.StrictMode from index.tsx
|
|
59
|
-
const indexFileName = path_1.default.join(projectPath, "src", `index.${
|
|
59
|
+
// Deactivate React.StrictMode from index.js or index.tsx
|
|
60
|
+
const indexFileName = path_1.default.join(projectPath, "src", `index.${jsOrTs === "js" ? "js" : "tsx"}`);
|
|
60
61
|
let indexFile = fs_1.default.readFileSync(indexFileName).toString();
|
|
61
62
|
indexFile = indexFile.replace("<React.StrictMode>", "");
|
|
62
63
|
indexFile = indexFile.replace("</React.StrictMode>", "");
|
|
@@ -68,4 +69,3 @@ const reactStrategy = {
|
|
|
68
69
|
yield (0, cmd_utils_1.spawnOrFail)(`${npmRunCmd} build`, projectPath);
|
|
69
70
|
}),
|
|
70
71
|
};
|
|
71
|
-
exports.default = reactStrategy;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PlatformType } from "../
|
|
2
|
-
export declare
|
|
1
|
+
import { PlatformType } from "../utils/types";
|
|
2
|
+
export declare function README(platform: PlatformType, buildCommand: string): string;
|
package/dist/templates/readme.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.README = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
This is a ${(0,
|
|
4
|
+
const types_1 = require("../utils/types");
|
|
5
|
+
function README(platform, buildCommand) {
|
|
6
|
+
return `This is a ${(0, types_1.platformTypeToString)(platform)} project bootstrapped with [\`create-plasmic-app\`](https://www.npmjs.com/package/create-plasmic-app).
|
|
7
7
|
|
|
8
8
|
## Getting Started
|
|
9
9
|
|
|
@@ -28,5 +28,6 @@ To learn more about Plasmic, take a look at the following resources:
|
|
|
28
28
|
- [Plasmic Slack Community](https://www.plasmic.app/slack)
|
|
29
29
|
|
|
30
30
|
You can check out [the Plasmic GitHub repository](https://github.com/plasmicapp/plasmic) - your feedback and contributions are welcome!
|
|
31
|
-
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
32
33
|
exports.README = README;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PLASMIC_LOGO = "
|
|
2
|
-
export declare
|
|
1
|
+
export declare const PLASMIC_LOGO = "function PlasmicLogo() {\n return (\n <svg\n width={40}\n height={40}\n viewBox=\"0 0 40 40\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M34 26h-2v-1c0-6.627-5.373-12-12-12S8 18.374 8 25v1H6a1 1 0 01-1-1c0-8.284 6.716-15 15-15 8.284 0 15 6.716 15 15a1 1 0 01-1 1z\"\n fill=\"url(#paint0_linear)\"\n />\n <path\n d=\"M27 25a7 7 0 00-14 0v1h2a1 1 0 001-1 4 4 0 018 0 1 1 0 001 1h2v-1z\"\n fill=\"url(#paint1_linear)\"\n />\n <path\n d=\"M30.999 25C30.999 18.925 26.075 14 20 14S9.001 18.926 9.001 25H9v1h3v-1a8 8 0 0116 0v1h3v-1h-.001z\"\n fill=\"url(#paint2_linear)\"\n />\n <defs>\n <linearGradient\n id=\"paint0_linear\"\n x1={5}\n y1={26}\n x2={35}\n y2={26}\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop stopColor=\"#1877F2\" />\n <stop offset={1} stopColor=\"#04A4F4\" />\n </linearGradient>\n <linearGradient\n id=\"paint1_linear\"\n x1={13}\n y1={26}\n x2={27}\n y2={26}\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop stopColor=\"#F02849\" />\n <stop offset={1} stopColor=\"#F5533D\" />\n </linearGradient>\n <linearGradient\n id=\"paint2_linear\"\n x1={9}\n y1={26}\n x2={31}\n y2={26}\n gradientUnits=\"userSpaceOnUse\"\n >\n <stop stopColor=\"#45BD62\" />\n <stop offset={1} stopColor=\"#2ABBA7\" />\n </linearGradient>\n </defs>\n </svg>\n );\n}\n";
|
|
2
|
+
export declare function WELCOME_PAGE(hasPages: boolean, platform: string, pageSection: string): string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WELCOME_PAGE = exports.PLASMIC_LOGO = void 0;
|
|
4
|
-
exports.PLASMIC_LOGO = `
|
|
5
|
-
function PlasmicLogo() {
|
|
4
|
+
exports.PLASMIC_LOGO = `function PlasmicLogo() {
|
|
6
5
|
return (
|
|
7
6
|
<svg
|
|
8
7
|
width={40}
|
|
@@ -64,8 +63,8 @@ function PlasmicLogo() {
|
|
|
64
63
|
);
|
|
65
64
|
}
|
|
66
65
|
`;
|
|
67
|
-
|
|
68
|
-
import React from "react";
|
|
66
|
+
function WELCOME_PAGE(hasPages, platform, pageSection) {
|
|
67
|
+
return `import React from "react";
|
|
69
68
|
${hasPages && platform === "nextjs" ? `import Link from "next/link";` : ""}
|
|
70
69
|
${exports.PLASMIC_LOGO}
|
|
71
70
|
|
|
@@ -95,5 +94,6 @@ function Index() {
|
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
export default Index;
|
|
98
|
-
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
99
|
exports.WELCOME_PAGE = WELCOME_PAGE;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlatformType } from "../
|
|
1
|
+
import { JsOrTs, PlatformType } from "../utils/types";
|
|
2
2
|
/**
|
|
3
3
|
* Runs the search pattern through `glob` and deletes all resulting files
|
|
4
4
|
* @param searchPattern - glob search query
|
|
@@ -24,4 +24,4 @@ export declare function overwriteIndex(projectPath: string, platform: string, sc
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function overwriteReadme(projectPath: string, platform: PlatformType, buildCommand: string): Promise<void>;
|
|
26
26
|
export declare function ensureTsconfig(projectPath: string): Promise<void>;
|
|
27
|
-
export declare function ifTs(ts:
|
|
27
|
+
export declare function ifTs(ts: JsOrTs, str: string): string;
|
package/dist/utils/file-utils.js
CHANGED
|
@@ -40,7 +40,7 @@ const fs_1 = require("fs");
|
|
|
40
40
|
const glob_1 = __importDefault(require("glob"));
|
|
41
41
|
const lodash_1 = __importDefault(require("lodash"));
|
|
42
42
|
const path = __importStar(require("upath"));
|
|
43
|
-
const
|
|
43
|
+
const template_1 = require("../gatsby/template");
|
|
44
44
|
const readme_1 = require("../templates/readme");
|
|
45
45
|
const welcomePage_1 = require("../templates/welcomePage");
|
|
46
46
|
const lang_utils_1 = require("./lang-utils");
|
|
@@ -124,7 +124,7 @@ function overwriteIndex(projectPath, platform, scheme) {
|
|
|
124
124
|
// Create a very basic 404 page - `gatsby build` fails without it.
|
|
125
125
|
// We've deleted the components that the default 404 page depended
|
|
126
126
|
// on, so
|
|
127
|
-
yield fs_1.promises.writeFile(path.join(projectPath, "src/pages/404.js"),
|
|
127
|
+
yield fs_1.promises.writeFile(path.join(projectPath, "src/pages/404.js"), template_1.GATSBY_404);
|
|
128
128
|
}
|
|
129
129
|
// We're done if we can already render an index page
|
|
130
130
|
if ((isNextjs || isGatsby) &&
|
|
@@ -253,6 +253,6 @@ function ensureTsconfig(projectPath) {
|
|
|
253
253
|
}
|
|
254
254
|
exports.ensureTsconfig = ensureTsconfig;
|
|
255
255
|
function ifTs(ts, str) {
|
|
256
|
-
return ts ? str : "";
|
|
256
|
+
return ts === "ts" ? str : "";
|
|
257
257
|
}
|
|
258
258
|
exports.ifTs = ifTs;
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface CreateArgs {
|
|
1
|
+
import { JsOrTs, PlatformOptions, SchemeType } from "./types";
|
|
2
|
+
export interface CreateArgs {
|
|
3
3
|
projectPath: string;
|
|
4
4
|
template?: string;
|
|
5
|
-
|
|
5
|
+
jsOrTs: JsOrTs;
|
|
6
|
+
platformOptions: PlatformOptions;
|
|
6
7
|
}
|
|
7
|
-
interface ConfigArgs {
|
|
8
|
+
export interface ConfigArgs {
|
|
8
9
|
projectId: string;
|
|
9
10
|
projectPath: string;
|
|
10
|
-
|
|
11
|
-
scheme:
|
|
11
|
+
jsOrTs: JsOrTs;
|
|
12
|
+
scheme: SchemeType;
|
|
12
13
|
projectApiToken: string | undefined;
|
|
14
|
+
platformOptions: PlatformOptions;
|
|
13
15
|
}
|
|
14
|
-
interface GenerateFilesArgs {
|
|
16
|
+
export interface GenerateFilesArgs {
|
|
15
17
|
projectPath: string;
|
|
16
|
-
|
|
17
|
-
scheme:
|
|
18
|
+
jsOrTs: JsOrTs;
|
|
19
|
+
scheme: SchemeType;
|
|
18
20
|
projectId: string;
|
|
19
21
|
projectApiToken: string | undefined;
|
|
22
|
+
platformOptions: PlatformOptions;
|
|
20
23
|
}
|
|
21
|
-
interface BuildArgs {
|
|
24
|
+
export interface BuildArgs {
|
|
22
25
|
projectPath: string;
|
|
23
26
|
npmRunCmd: string;
|
|
24
27
|
}
|
|
25
|
-
interface InstallArgs {
|
|
26
|
-
scheme:
|
|
28
|
+
export interface InstallArgs {
|
|
29
|
+
scheme: SchemeType;
|
|
27
30
|
projectPath: string;
|
|
28
|
-
|
|
31
|
+
jsOrTs: JsOrTs;
|
|
29
32
|
}
|
|
30
33
|
export interface CPAStrategy {
|
|
31
34
|
create: (args: CreateArgs) => Promise<void>;
|
|
@@ -34,4 +37,3 @@ export interface CPAStrategy {
|
|
|
34
37
|
generateFiles: (args: GenerateFilesArgs) => Promise<void>;
|
|
35
38
|
build: (args: BuildArgs) => Promise<void>;
|
|
36
39
|
}
|
|
37
|
-
export {};
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type JsOrTs = "js" | "ts";
|
|
2
|
+
export type PlatformType = "nextjs" | "gatsby" | "react";
|
|
3
|
+
export type PlatformOptions = {
|
|
4
|
+
nextjs?: {
|
|
5
|
+
appDir: boolean;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export type SchemeType = "codegen" | "loader";
|
|
9
|
+
export declare function platformTypeToString(s: PlatformType): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.platformTypeToString = void 0;
|
|
4
|
+
function platformTypeToString(s) {
|
|
5
|
+
return s === "nextjs" ? "Next.js" : s === "gatsby" ? "Gatsby" : "React";
|
|
6
|
+
}
|
|
7
|
+
exports.platformTypeToString = platformTypeToString;
|