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
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.wrapAppRootForCodegen = exports.makeGatsbyPlasmicInit = exports.GATSBY_SSR_CONFIG = exports.makeGatsbyHostPage = exports.GATSBY_PLUGIN_CONFIG = exports.GATSBY_404 = exports.makeGatsbyDefaultPage = void 0;
|
|
4
4
|
const file_utils_1 = require("../utils/file-utils");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return `
|
|
8
|
-
import React from "react";
|
|
5
|
+
function makeGatsbyDefaultPage(jsOrTs) {
|
|
6
|
+
return `import React from "react";
|
|
9
7
|
import Helmet from "react-helmet";
|
|
10
8
|
import {
|
|
11
9
|
PlasmicComponent,
|
|
12
|
-
PlasmicRootProvider,${(0, file_utils_1.ifTs)(
|
|
10
|
+
PlasmicRootProvider,${(0, file_utils_1.ifTs)(jsOrTs, `
|
|
13
11
|
InitOptions,
|
|
14
12
|
ComponentRenderData,`)}
|
|
15
13
|
} from "@plasmicapp/loader-gatsby";
|
|
16
|
-
import { graphql${(0, file_utils_1.ifTs)(
|
|
14
|
+
import { graphql${(0, file_utils_1.ifTs)(jsOrTs, ", PageProps")} } from "gatsby";
|
|
17
15
|
import { initPlasmicLoaderWithRegistrations } from "../plasmic-init";
|
|
18
16
|
|
|
19
17
|
export const query = graphql\`
|
|
@@ -23,14 +21,14 @@ export const query = graphql\`
|
|
|
23
21
|
}
|
|
24
22
|
\`;
|
|
25
23
|
|
|
26
|
-
${(0, file_utils_1.ifTs)(
|
|
24
|
+
${(0, file_utils_1.ifTs)(jsOrTs, `interface PlasmicGatsbyPageProps extends PageProps {
|
|
27
25
|
data: {
|
|
28
26
|
plasmicOptions: InitOptions
|
|
29
27
|
plasmicComponents: ComponentRenderData
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
`)}
|
|
33
|
-
const PlasmicGatsbyPage = ({ data, location }${(0, file_utils_1.ifTs)(
|
|
31
|
+
const PlasmicGatsbyPage = ({ data, location }${(0, file_utils_1.ifTs)(jsOrTs, ": PlasmicGatsbyPageProps")}) => {
|
|
34
32
|
const {
|
|
35
33
|
plasmicComponents,
|
|
36
34
|
plasmicOptions,
|
|
@@ -57,17 +55,16 @@ const PlasmicGatsbyPage = ({ data, location }${(0, file_utils_1.ifTs)(ts, ": Pla
|
|
|
57
55
|
};
|
|
58
56
|
|
|
59
57
|
export default PlasmicGatsbyPage;
|
|
60
|
-
|
|
61
|
-
}
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
62
60
|
exports.makeGatsbyDefaultPage = makeGatsbyDefaultPage;
|
|
63
|
-
exports.GATSBY_404 = `
|
|
64
|
-
const NotFound = () => {
|
|
61
|
+
exports.GATSBY_404 = `const NotFound = () => {
|
|
65
62
|
return "Not Found";
|
|
66
63
|
};
|
|
67
64
|
export default NotFound;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{
|
|
65
|
+
`;
|
|
66
|
+
function GATSBY_PLUGIN_CONFIG(projectId, projectApiToken, jsOrTs) {
|
|
67
|
+
return `{
|
|
71
68
|
resolve: "@plasmicapp/loader-gatsby",
|
|
72
69
|
options: {
|
|
73
70
|
projects: [
|
|
@@ -77,21 +74,21 @@ const GATSBY_PLUGIN_CONFIG = (projectId, projectApiToken, useTypescript) => `
|
|
|
77
74
|
},
|
|
78
75
|
], // An array of project ids.
|
|
79
76
|
preview: false,
|
|
80
|
-
defaultPlasmicPage: ${
|
|
77
|
+
defaultPlasmicPage: ${jsOrTs === "ts" ? "path" : "require"}.resolve("./src/templates/defaultPlasmicPage.${jsOrTs}x"),
|
|
81
78
|
},
|
|
82
79
|
},
|
|
83
80
|
{
|
|
84
81
|
resolve: "gatsby-plugin-react-helmet",
|
|
85
82
|
}
|
|
86
83
|
`;
|
|
84
|
+
}
|
|
87
85
|
exports.GATSBY_PLUGIN_CONFIG = GATSBY_PLUGIN_CONFIG;
|
|
88
|
-
|
|
89
|
-
const {
|
|
86
|
+
function makeGatsbyHostPage(opts) {
|
|
87
|
+
const { jsOrTs, scheme } = opts;
|
|
90
88
|
if (scheme === "loader") {
|
|
91
|
-
return `
|
|
92
|
-
import * as React from "react"
|
|
89
|
+
return `import * as React from "react"
|
|
93
90
|
import {
|
|
94
|
-
PlasmicCanvasHost${(0, file_utils_1.ifTs)(
|
|
91
|
+
PlasmicCanvasHost${(0, file_utils_1.ifTs)(jsOrTs, `, InitOptions`)}
|
|
95
92
|
} from "@plasmicapp/loader-gatsby"
|
|
96
93
|
import { graphql } from "gatsby"
|
|
97
94
|
import { initPlasmicLoaderWithRegistrations } from "../plasmic-init"
|
|
@@ -102,22 +99,21 @@ export const query = graphql\`
|
|
|
102
99
|
}
|
|
103
100
|
\`
|
|
104
101
|
|
|
105
|
-
${(0, file_utils_1.ifTs)(
|
|
102
|
+
${(0, file_utils_1.ifTs)(jsOrTs, `interface HostProps {
|
|
106
103
|
data: {
|
|
107
104
|
plasmicOptions: InitOptions;
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
107
|
`)}
|
|
111
|
-
export default function Host({ data }${(0, file_utils_1.ifTs)(
|
|
108
|
+
export default function Host({ data }${(0, file_utils_1.ifTs)(jsOrTs, ": HostProps")}) {
|
|
112
109
|
const { plasmicOptions } = data
|
|
113
110
|
initPlasmicLoaderWithRegistrations(plasmicOptions)
|
|
114
111
|
return <PlasmicCanvasHost />
|
|
115
112
|
}
|
|
116
|
-
|
|
113
|
+
`;
|
|
117
114
|
}
|
|
118
115
|
else {
|
|
119
|
-
return `
|
|
120
|
-
import * as React from "react"
|
|
116
|
+
return `import * as React from "react"
|
|
121
117
|
import { PlasmicCanvasHost, registerComponent } from "@plasmicapp/host";
|
|
122
118
|
|
|
123
119
|
// You can register any code components that you want to use here; see
|
|
@@ -134,12 +130,11 @@ export default function PlasmicHost() {
|
|
|
134
130
|
<PlasmicCanvasHost />
|
|
135
131
|
);
|
|
136
132
|
}
|
|
137
|
-
|
|
133
|
+
`;
|
|
138
134
|
}
|
|
139
|
-
}
|
|
135
|
+
}
|
|
140
136
|
exports.makeGatsbyHostPage = makeGatsbyHostPage;
|
|
141
|
-
exports.GATSBY_SSR_CONFIG =
|
|
142
|
-
/**
|
|
137
|
+
exports.GATSBY_SSR_CONFIG = `/**
|
|
143
138
|
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
|
|
144
139
|
*
|
|
145
140
|
* See: https://www.gatsbyjs.com/docs/ssr-apis/
|
|
@@ -183,16 +178,14 @@ exports.onRenderBody = ({ pathname, setHeadComponents }) => {
|
|
|
183
178
|
setHeadComponents(HeadComponents)
|
|
184
179
|
}
|
|
185
180
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
import {
|
|
191
|
-
initPlasmicLoader,${(0, file_utils_1.ifTs)(ts, `
|
|
181
|
+
`;
|
|
182
|
+
function makeGatsbyPlasmicInit(jsOrTs) {
|
|
183
|
+
return `import {
|
|
184
|
+
initPlasmicLoader,${(0, file_utils_1.ifTs)(jsOrTs, `
|
|
192
185
|
InitOptions,`)}
|
|
193
186
|
} from "@plasmicapp/loader-gatsby";
|
|
194
187
|
|
|
195
|
-
export function initPlasmicLoaderWithRegistrations(plasmicOptions${(0, file_utils_1.ifTs)(
|
|
188
|
+
export function initPlasmicLoaderWithRegistrations(plasmicOptions${(0, file_utils_1.ifTs)(jsOrTs, ": InitOptions")}) {
|
|
196
189
|
const PLASMIC = initPlasmicLoader(plasmicOptions);
|
|
197
190
|
|
|
198
191
|
// You can register any code components that you want to use here; see
|
|
@@ -206,12 +199,11 @@ export function initPlasmicLoaderWithRegistrations(plasmicOptions${(0, file_util
|
|
|
206
199
|
|
|
207
200
|
return PLASMIC;
|
|
208
201
|
}
|
|
209
|
-
|
|
210
|
-
}
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
211
204
|
exports.makeGatsbyPlasmicInit = makeGatsbyPlasmicInit;
|
|
212
205
|
function wrapAppRootForCodegen() {
|
|
213
|
-
return `
|
|
214
|
-
import React from "react";
|
|
206
|
+
return `import React from "react";
|
|
215
207
|
import { PlasmicRootProvider } from "@plasmicapp/react-web";
|
|
216
208
|
import Helmet from "react-helmet";
|
|
217
209
|
|
|
@@ -222,6 +214,6 @@ export const wrapRootElement = ({ element }) => {
|
|
|
222
214
|
</PlasmicRootProvider>
|
|
223
215
|
);
|
|
224
216
|
}
|
|
225
|
-
|
|
217
|
+
`;
|
|
226
218
|
}
|
|
227
219
|
exports.wrapAppRootForCodegen = wrapAppRootForCodegen;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export
|
|
2
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -52,39 +52,41 @@ if (process.env.CPA_DEBUG_CHDIR) {
|
|
|
52
52
|
const createPlasmicAppVersion = (0, npm_utils_1.updateNotify)();
|
|
53
53
|
// Specify command-line args
|
|
54
54
|
const argv = yargs_1.default
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
.command("$0 [projectName]", "Create a Plasmic app with Next.js, Gatsby, or Create React App", (yargs) => {
|
|
56
|
+
yargs
|
|
57
|
+
.usage("Usage: $0 [projectName] [options]")
|
|
58
|
+
.positional("projectName", {
|
|
59
|
+
describe: "Project and NPM package name",
|
|
60
|
+
string: true,
|
|
61
|
+
});
|
|
62
|
+
})
|
|
59
63
|
.option("platform", {
|
|
60
64
|
describe: "Target platform",
|
|
61
65
|
choices: ["", "nextjs", "gatsby", "react"],
|
|
62
|
-
default: "",
|
|
63
66
|
})
|
|
64
67
|
.option("scheme", {
|
|
65
68
|
describe: "Plasmic integration scheme",
|
|
66
69
|
choices: ["", "codegen", "loader"],
|
|
67
|
-
default: "",
|
|
68
70
|
})
|
|
69
71
|
.option("projectId", {
|
|
70
72
|
describe: "Plasmic project ID",
|
|
71
73
|
string: true,
|
|
72
|
-
default: "",
|
|
73
74
|
})
|
|
74
75
|
.option("projectApiToken", {
|
|
75
76
|
describe: "Plasmic project API token (optional, to bypass standard auth)",
|
|
76
77
|
string: true,
|
|
77
|
-
default: "",
|
|
78
78
|
})
|
|
79
79
|
.option("template", {
|
|
80
80
|
describe: "Specify a template for the created project",
|
|
81
81
|
string: true,
|
|
82
|
-
default: "",
|
|
83
82
|
})
|
|
84
83
|
.option("typescript", {
|
|
85
|
-
describe: "Use
|
|
84
|
+
describe: "Use Typescript?",
|
|
85
|
+
boolean: true,
|
|
86
|
+
})
|
|
87
|
+
.option("appDir", {
|
|
88
|
+
describe: "(Next.js) Use app directory (experimental)?",
|
|
86
89
|
boolean: true,
|
|
87
|
-
default: "",
|
|
88
90
|
})
|
|
89
91
|
.strict()
|
|
90
92
|
.help("h")
|
|
@@ -109,7 +111,10 @@ function maybePrompt(question, checkCliAnswer = true) {
|
|
|
109
111
|
const message = (0, lang_utils_1.ensure)(question.message);
|
|
110
112
|
if (checkCliAnswer) {
|
|
111
113
|
const cliAnswer = argv[name];
|
|
112
|
-
if (cliAnswer !== null &&
|
|
114
|
+
if (cliAnswer !== null &&
|
|
115
|
+
cliAnswer !== undefined &&
|
|
116
|
+
cliAnswer !== "" &&
|
|
117
|
+
(!question.validate || question.validate(cliAnswer))) {
|
|
113
118
|
console.log(`${message}: ${cliAnswer} (specified in CLI arg)`);
|
|
114
119
|
return cliAnswer; // assume it's the correct type
|
|
115
120
|
}
|
|
@@ -119,7 +124,7 @@ function maybePrompt(question, checkCliAnswer = true) {
|
|
|
119
124
|
});
|
|
120
125
|
}
|
|
121
126
|
// Keeping these as globals to easily share with our `crash` function
|
|
122
|
-
|
|
127
|
+
const projectName = argv._.length > 0 ? argv._[0] + "" : undefined;
|
|
123
128
|
let resolvedProjectPath;
|
|
124
129
|
/**
|
|
125
130
|
* Main function
|
|
@@ -129,18 +134,17 @@ function run() {
|
|
|
129
134
|
/**
|
|
130
135
|
* PROMPT USER
|
|
131
136
|
*/
|
|
132
|
-
// User-specified project
|
|
133
|
-
|
|
134
|
-
projectName
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
137
|
+
// User-specified project name
|
|
138
|
+
const projectName = yield maybePrompt({
|
|
139
|
+
name: "projectName",
|
|
140
|
+
message: "What is your project named?",
|
|
141
|
+
default: "my-app",
|
|
142
|
+
validate: cpa.checkValidName,
|
|
143
|
+
});
|
|
140
144
|
// Absolute path to the new project
|
|
141
145
|
resolvedProjectPath = path.resolve(projectName);
|
|
142
146
|
// Prompt for Typescript
|
|
143
|
-
const
|
|
147
|
+
const jsOrTs = (yield maybePrompt({
|
|
144
148
|
name: "typescript",
|
|
145
149
|
message: "What language do you want to use?",
|
|
146
150
|
type: "list",
|
|
@@ -155,9 +159,11 @@ function run() {
|
|
|
155
159
|
},
|
|
156
160
|
],
|
|
157
161
|
default: true,
|
|
158
|
-
})
|
|
162
|
+
}))
|
|
163
|
+
? "ts"
|
|
164
|
+
: "js";
|
|
159
165
|
// Prompt for the platform
|
|
160
|
-
const platform =
|
|
166
|
+
const platform = yield maybePrompt({
|
|
161
167
|
name: "platform",
|
|
162
168
|
message: "What React framework do you want to use?",
|
|
163
169
|
type: "list",
|
|
@@ -176,7 +182,7 @@ function run() {
|
|
|
176
182
|
},
|
|
177
183
|
],
|
|
178
184
|
default: "nextjs",
|
|
179
|
-
})
|
|
185
|
+
});
|
|
180
186
|
// Scheme to use for Plasmic integration
|
|
181
187
|
// - loader only available for gatsby/next.js
|
|
182
188
|
const scheme = platform === "nextjs" || platform === "gatsby"
|
|
@@ -199,6 +205,30 @@ function run() {
|
|
|
199
205
|
default: "loader",
|
|
200
206
|
})
|
|
201
207
|
: "codegen";
|
|
208
|
+
// TODO: Support nextjs + codegen
|
|
209
|
+
const platformOptions = {};
|
|
210
|
+
if (platform === "nextjs" && scheme === "loader") {
|
|
211
|
+
platformOptions.nextjs = {
|
|
212
|
+
appDir: yield maybePrompt({
|
|
213
|
+
name: "appDir",
|
|
214
|
+
message: "Do you want to use the app/ directory and React Server Components? (see https://beta.nextjs.org/docs/app-directory-roadmap)",
|
|
215
|
+
type: "list",
|
|
216
|
+
choices: () => [
|
|
217
|
+
{
|
|
218
|
+
name: "No, use pages/ directory",
|
|
219
|
+
short: "No",
|
|
220
|
+
value: false,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "Yes, use app/ directory (experimental)",
|
|
224
|
+
short: "Yes",
|
|
225
|
+
value: true,
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
default: false,
|
|
229
|
+
}),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
202
232
|
// Get the projectId
|
|
203
233
|
console.log();
|
|
204
234
|
let projectId;
|
|
@@ -225,7 +255,6 @@ What is the URL of your project?`,
|
|
|
225
255
|
}
|
|
226
256
|
// RUN IT
|
|
227
257
|
console.log();
|
|
228
|
-
(0, lang_utils_1.assert)(platform === "nextjs" || platform === "gatsby" || platform === "react", "platform must be one of ['nextjs', 'gatsby', 'react']");
|
|
229
258
|
const template = argv["template"];
|
|
230
259
|
const projectApiToken = argv["projectApiToken"];
|
|
231
260
|
// Set the metadata environment variable to tag the future Segment codegen event
|
|
@@ -236,8 +265,9 @@ What is the URL of your project?`,
|
|
|
236
265
|
resolvedProjectPath,
|
|
237
266
|
projectId,
|
|
238
267
|
platform,
|
|
268
|
+
platformOptions,
|
|
239
269
|
scheme,
|
|
240
|
-
|
|
270
|
+
jsOrTs,
|
|
241
271
|
projectApiToken,
|
|
242
272
|
template,
|
|
243
273
|
});
|
package/dist/lib.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { setMetadataEnv } from "@plasmicapp/cli";
|
|
2
|
-
|
|
3
|
-
export type SchemeType = "codegen" | "loader";
|
|
4
|
-
export declare function toString(s: PlatformType): string;
|
|
2
|
+
import { JsOrTs, PlatformOptions, PlatformType, SchemeType } from "./utils/types";
|
|
5
3
|
export interface CreatePlasmicAppArgs {
|
|
6
4
|
resolvedProjectPath: string;
|
|
7
5
|
projectId: string;
|
|
8
6
|
platform: PlatformType;
|
|
7
|
+
platformOptions: PlatformOptions;
|
|
9
8
|
scheme: SchemeType;
|
|
10
|
-
|
|
9
|
+
jsOrTs: JsOrTs;
|
|
11
10
|
projectApiToken?: string;
|
|
12
11
|
template?: string;
|
|
13
12
|
}
|
package/dist/lib.js
CHANGED
|
@@ -35,21 +35,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.setMetadata = exports.banner = exports.checkValidName = exports.create =
|
|
38
|
+
exports.setMetadata = exports.banner = exports.checkValidName = exports.create = void 0;
|
|
39
39
|
const cli_1 = require("@plasmicapp/cli");
|
|
40
40
|
const chalk_1 = __importDefault(require("chalk"));
|
|
41
41
|
const path = __importStar(require("upath"));
|
|
42
42
|
const validate_npm_package_name_1 = __importDefault(require("validate-npm-package-name"));
|
|
43
|
-
const strategies_1 = require("./strategies");
|
|
44
43
|
const file_utils_1 = require("./utils/file-utils");
|
|
45
44
|
const npm_utils_1 = require("./utils/npm-utils");
|
|
46
|
-
function
|
|
47
|
-
return
|
|
45
|
+
function getCPAStrategy(platform) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
switch (platform) {
|
|
48
|
+
case "nextjs":
|
|
49
|
+
return (yield Promise.resolve().then(() => __importStar(require("./nextjs/nextjs")))).nextjsStrategy;
|
|
50
|
+
case "gatsby":
|
|
51
|
+
return (yield Promise.resolve().then(() => __importStar(require("./gatsby/gatsby")))).gatsbyStrategy;
|
|
52
|
+
case "react":
|
|
53
|
+
return (yield Promise.resolve().then(() => __importStar(require("./react/react")))).reactStrategy;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
48
56
|
}
|
|
49
|
-
exports.toString = toString;
|
|
50
57
|
function create(args) {
|
|
51
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const { resolvedProjectPath, projectId, platform, scheme,
|
|
59
|
+
const { resolvedProjectPath, projectId, platform, platformOptions, scheme, jsOrTs, template, } = args;
|
|
53
60
|
let { projectApiToken } = args;
|
|
54
61
|
console.log("Let's get started! Here's what we'll do: ");
|
|
55
62
|
console.log("1. Authenticate with Plasmic");
|
|
@@ -81,17 +88,18 @@ function create(args) {
|
|
|
81
88
|
if (!["codegen", "loader"].includes(scheme)) {
|
|
82
89
|
throw new Error(`Unrecognized Plasmic scheme: ${scheme}`);
|
|
83
90
|
}
|
|
84
|
-
const cpaStrategy =
|
|
91
|
+
const cpaStrategy = yield getCPAStrategy(platform);
|
|
85
92
|
// Create project using strategy for platform
|
|
86
93
|
yield cpaStrategy.create({
|
|
87
94
|
projectPath: resolvedProjectPath,
|
|
88
|
-
|
|
95
|
+
jsOrTs,
|
|
89
96
|
template,
|
|
97
|
+
platformOptions,
|
|
90
98
|
});
|
|
91
99
|
// Ensure that we have a empty tsconfig and @types packages.
|
|
92
100
|
// Gatsby and Next.js by default support typescript handling internally
|
|
93
101
|
// tsconfig so we don't have to ensure it.
|
|
94
|
-
if (
|
|
102
|
+
if (jsOrTs === "ts" && platform === "react") {
|
|
95
103
|
yield (0, file_utils_1.ensureTsconfig)(resolvedProjectPath);
|
|
96
104
|
}
|
|
97
105
|
// Make sure we have an api token for loader
|
|
@@ -106,7 +114,7 @@ function create(args) {
|
|
|
106
114
|
const installResult = yield cpaStrategy.installDeps({
|
|
107
115
|
scheme,
|
|
108
116
|
projectPath: resolvedProjectPath,
|
|
109
|
-
|
|
117
|
+
jsOrTs,
|
|
110
118
|
});
|
|
111
119
|
if (!installResult) {
|
|
112
120
|
throw new Error("Failed to install the Plasmic dependency");
|
|
@@ -116,16 +124,18 @@ function create(args) {
|
|
|
116
124
|
projectId,
|
|
117
125
|
projectPath: resolvedProjectPath,
|
|
118
126
|
projectApiToken,
|
|
119
|
-
|
|
127
|
+
jsOrTs,
|
|
120
128
|
scheme,
|
|
129
|
+
platformOptions,
|
|
121
130
|
});
|
|
122
131
|
// Generate files
|
|
123
132
|
yield cpaStrategy.generateFiles({
|
|
124
133
|
projectPath: resolvedProjectPath,
|
|
125
|
-
|
|
134
|
+
jsOrTs,
|
|
126
135
|
scheme,
|
|
127
136
|
projectId,
|
|
128
137
|
projectApiToken,
|
|
138
|
+
platformOptions,
|
|
129
139
|
});
|
|
130
140
|
/**
|
|
131
141
|
* INSTRUCT USER ON NEXT STEPS
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.nextjsStrategy = void 0;
|
|
16
|
+
const fs_1 = require("fs");
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const cmd_utils_1 = require("../utils/cmd-utils");
|
|
19
|
+
const codegen_1 = require("../utils/codegen");
|
|
20
|
+
const file_utils_1 = require("../utils/file-utils");
|
|
21
|
+
const lang_utils_1 = require("../utils/lang-utils");
|
|
22
|
+
const npm_utils_1 = require("../utils/npm-utils");
|
|
23
|
+
const catchall_page_1 = require("./templates/app-loader/catchall-page");
|
|
24
|
+
const plasmic_init_1 = require("./templates/app-loader/plasmic-init");
|
|
25
|
+
const plasmic_init_client_1 = require("./templates/app-loader/plasmic-init-client");
|
|
26
|
+
const app_1 = require("./templates/pages-codegen/app");
|
|
27
|
+
const plasmic_host_1 = require("./templates/pages-codegen/plasmic-host");
|
|
28
|
+
const catchall_page_2 = require("./templates/pages-loader/catchall-page");
|
|
29
|
+
const plasmic_host_2 = require("./templates/app-loader/plasmic-host");
|
|
30
|
+
const plasmic_host_3 = require("./templates/pages-loader/plasmic-host");
|
|
31
|
+
const plasmic_init_2 = require("./templates/pages-loader/plasmic-init");
|
|
32
|
+
exports.nextjsStrategy = {
|
|
33
|
+
create: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
var _a;
|
|
35
|
+
const { projectPath, template, jsOrTs, platformOptions } = args;
|
|
36
|
+
const typescriptArg = `--${jsOrTs}`;
|
|
37
|
+
const experimentalAppArg = ((_a = platformOptions.nextjs) === null || _a === void 0 ? void 0 : _a.appDir)
|
|
38
|
+
? "--experimental-app"
|
|
39
|
+
: "--no-experimental-app";
|
|
40
|
+
const templateArg = template ? ` --template ${template}` : "";
|
|
41
|
+
const createCommand = `npx create-next-app@latest ${typescriptArg} ${experimentalAppArg} ${templateArg}` +
|
|
42
|
+
` --eslint --no-src-dir --import-alias "@/*" ${projectPath}`;
|
|
43
|
+
// Default Next.js starter already supports Typescript
|
|
44
|
+
// See where we `touch tsconfig.json` later on
|
|
45
|
+
yield (0, cmd_utils_1.spawnOrFail)(createCommand);
|
|
46
|
+
}),
|
|
47
|
+
installDeps: ({ scheme, projectPath }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
if (scheme === "loader") {
|
|
49
|
+
return yield (0, npm_utils_1.installUpgrade)("@plasmicapp/loader-nextjs", {
|
|
50
|
+
workingDir: projectPath,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return yield (0, codegen_1.installCodegenDeps)({ projectPath });
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
var _b;
|
|
59
|
+
const { projectPath, scheme, platformOptions } = args;
|
|
60
|
+
const nextjsConfigFile = path_1.default.join(projectPath, "next.config.js");
|
|
61
|
+
const appDirOption = ((_b = platformOptions.nextjs) === null || _b === void 0 ? void 0 : _b.appDir)
|
|
62
|
+
? `
|
|
63
|
+
experimental: {
|
|
64
|
+
appDir: true,
|
|
65
|
+
}`
|
|
66
|
+
: "";
|
|
67
|
+
if (scheme === "codegen") {
|
|
68
|
+
yield fs_1.promises.writeFile(nextjsConfigFile, `
|
|
69
|
+
/** @type {import('next').NextConfig} */
|
|
70
|
+
const nextConfig = {
|
|
71
|
+
eslint: {
|
|
72
|
+
ignoreDuringBuilds: true,
|
|
73
|
+
},
|
|
74
|
+
trailingSlash: true,${appDirOption}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
module.exports = nextConfig;`);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
yield fs_1.promises.writeFile(nextjsConfigFile, `
|
|
81
|
+
/** @type {import('next').NextConfig} */
|
|
82
|
+
const nextConfig = {
|
|
83
|
+
// Turn off React StrictMode for now, as react-aria (used by Plasmic)
|
|
84
|
+
// has some troubles with it. See
|
|
85
|
+
// https://github.com/adobe/react-spectrum/labels/strict%20mode
|
|
86
|
+
reactStrictMode: false,${appDirOption}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
module.exports = nextConfig;`);
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
generateFiles: (args) => {
|
|
93
|
+
var _a;
|
|
94
|
+
if ((_a = args.platformOptions.nextjs) === null || _a === void 0 ? void 0 : _a.appDir) {
|
|
95
|
+
return generateFilesAppDir(args);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return generateFilesPagesDir(args);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
build: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
const { npmRunCmd, projectPath } = args;
|
|
103
|
+
yield (0, cmd_utils_1.spawnOrFail)(`${npmRunCmd} build`, projectPath);
|
|
104
|
+
}),
|
|
105
|
+
};
|
|
106
|
+
function generateFilesAppDir(args) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const { projectPath, jsOrTs, projectId, projectApiToken } = args;
|
|
109
|
+
// Delete existing pages
|
|
110
|
+
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "app", "page.*"));
|
|
111
|
+
// ./plasmic-init.ts
|
|
112
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `plasmic-init.${jsOrTs}`), (0, plasmic_init_1.makePlasmicInit_app_loader)(projectId, (0, lang_utils_1.ensure)(projectApiToken)));
|
|
113
|
+
// ./plasmic-init-client.ts
|
|
114
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `plasmic-init-client.${jsOrTs}x`), (0, plasmic_init_client_1.makePlasmicInitClient_app_loader)(jsOrTs));
|
|
115
|
+
// ./app/plasmic-host/page.tsx
|
|
116
|
+
yield fs_1.promises.mkdir(path_1.default.join(projectPath, "app", "plasmic-host"));
|
|
117
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "plasmic-host", `page.${jsOrTs}x`), (0, plasmic_host_2.makePlasmicHostPage_app_loader)());
|
|
118
|
+
// ./app/[[...catchall]]/page.tsx
|
|
119
|
+
yield fs_1.promises.mkdir(path_1.default.join(projectPath, "app", "[[...catchall]]"));
|
|
120
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "[[...catchall]]", `page.${jsOrTs}x`), (0, catchall_page_1.makeCatchallPage_app_loader)(jsOrTs));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function generateFilesPagesDir(args) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
const { projectPath, scheme, jsOrTs, projectId, projectApiToken } = args;
|
|
126
|
+
// Delete existing pages
|
|
127
|
+
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "pages", "*.*"));
|
|
128
|
+
if (scheme === "loader") {
|
|
129
|
+
// ./plasmic-init.ts
|
|
130
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `plasmic-init.${jsOrTs}`), (0, plasmic_init_2.makePlasmicInit_pages_loader)(projectId, (0, lang_utils_1.ensure)(projectApiToken)));
|
|
131
|
+
// ./pages/plasmic-host.tsx
|
|
132
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `plasmic-host.${jsOrTs}x`), (0, plasmic_host_3.makePlasmicHostPage_pages_loader)());
|
|
133
|
+
// ./pages/[[...catchall]].tsx
|
|
134
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `[[...catchall]].${jsOrTs}x`), (0, catchall_page_2.makeCatchallPage_pages_loader)(jsOrTs));
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// ./pages/_app.tsx
|
|
138
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `_app.${jsOrTs}x`), (0, app_1.makeCustomApp_pages_codegen)(jsOrTs));
|
|
139
|
+
// ./pages/plasmic-host.tsx
|
|
140
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `plasmic-host.${jsOrTs}x`), (0, plasmic_host_1.makePlasmicHostPage_pages_codegen)());
|
|
141
|
+
// This should generate
|
|
142
|
+
// ./plasmic.json
|
|
143
|
+
// ./pages/index.tsx
|
|
144
|
+
// ./components/plasmic/**
|
|
145
|
+
yield (0, codegen_1.runCodegenSync)({
|
|
146
|
+
projectId,
|
|
147
|
+
projectApiToken,
|
|
148
|
+
projectPath,
|
|
149
|
+
});
|
|
150
|
+
// This should overwrite
|
|
151
|
+
// ./pages/index.tsx
|
|
152
|
+
yield (0, file_utils_1.overwriteIndex)(projectPath, "nextjs", scheme);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|