create-plasmic-app 0.0.133 → 0.0.134
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/cpa-out/nextjs-app-codegen-js/app/dynamic/[slug]/page-client.jsx +7 -0
- package/cpa-out/nextjs-app-codegen-js/app/dynamic/[slug]/page.jsx +45 -0
- package/cpa-out/nextjs-app-codegen-js/app/layout.js +28 -0
- package/cpa-out/nextjs-app-codegen-js/app/layout.jsx +17 -0
- package/cpa-out/nextjs-app-codegen-js/app/page-client.jsx +7 -0
- package/cpa-out/nextjs-app-codegen-js/app/page.jsx +45 -0
- package/cpa-out/nextjs-app-codegen-js/app/plasmic-host/page.jsx +15 -0
- package/cpa-out/nextjs-app-codegen-js/components/Button.jsx +11 -0
- package/cpa-out/nextjs-app-codegen-js/components/RandomDynamicPageButton.jsx +24 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicButton.jsx +595 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +216 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPageServer.jsx +56 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.jsx +26 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +251 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepageServer.jsx +56 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.jsx +159 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicStyleTokensProvider.jsx +15 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/icons/PlasmicIcon__CheckSvg.jsx +39 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.jsx +37 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/plasmic.jsx +11 -0
- package/cpa-out/nextjs-app-codegen-js/package.json +22 -0
- package/cpa-out/nextjs-app-codegen-js/plasmic.json +148 -0
- package/cpa-out/nextjs-app-codegen-ts/app/dynamic/[slug]/page-client.tsx +11 -0
- package/cpa-out/nextjs-app-codegen-ts/app/dynamic/[slug]/page.tsx +57 -0
- package/cpa-out/nextjs-app-codegen-ts/app/layout.tsx +19 -0
- package/cpa-out/nextjs-app-codegen-ts/app/page-client.tsx +11 -0
- package/cpa-out/nextjs-app-codegen-ts/app/page.tsx +54 -0
- package/cpa-out/nextjs-app-codegen-ts/app/plasmic-host/page.tsx +15 -0
- package/cpa-out/nextjs-app-codegen-ts/components/Button.tsx +35 -0
- package/cpa-out/nextjs-app-codegen-ts/components/RandomDynamicPageButton.tsx +44 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicButton.tsx +776 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +329 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPageServer.tsx +77 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +30 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +366 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepageServer.tsx +75 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx +274 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicStyleTokensProvider.tsx +19 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/icons/PlasmicIcon__CheckSvg.tsx +44 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.tsx +41 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/plasmic.tsx +14 -0
- package/cpa-out/nextjs-app-codegen-ts/package.json +26 -0
- package/cpa-out/nextjs-app-codegen-ts/plasmic.json +148 -0
- package/cpa-out/nextjs-app-codegen-ts/tsconfig.json +26 -0
- package/dist/index.js +31 -28
- package/dist/nextjs/nextjs.js +37 -11
- package/dist/nextjs/templates/app-codegen/layout.d.ts +2 -0
- package/dist/nextjs/templates/app-codegen/layout.js +27 -0
- package/package.json +2 -2
- package/run-cpa.ts +8 -9
- package/src/index.ts +31 -34
- package/src/nextjs/nextjs.ts +67 -28
- package/src/nextjs/templates/app-codegen/layout.ts +28 -0
package/src/nextjs/nextjs.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { ensure } from "../utils/lang-utils";
|
|
12
12
|
import { installUpgrade } from "../utils/npm-utils";
|
|
13
13
|
import { CPAStrategy, GenerateFilesArgs } from "../utils/strategy";
|
|
14
|
+
import { makeLayout_app_codegen } from "./templates/app-codegen/layout";
|
|
14
15
|
import { makeCatchallPage_app_loader } from "./templates/app-loader/catchall-page";
|
|
15
16
|
import { makePlasmicHostPage_app_loader } from "./templates/app-loader/plasmic-host";
|
|
16
17
|
import { makePlasmicInit_app_loader } from "./templates/app-loader/plasmic-init";
|
|
@@ -81,39 +82,77 @@ export default nextConfig;`
|
|
|
81
82
|
};
|
|
82
83
|
|
|
83
84
|
async function generateFilesAppDir(args: GenerateFilesArgs) {
|
|
84
|
-
const { projectPath, jsOrTs, projectId, projectApiToken } = args;
|
|
85
|
+
const { projectPath, scheme, jsOrTs, projectId, projectApiToken } = args;
|
|
85
86
|
|
|
86
87
|
// Delete existing pages
|
|
87
88
|
deleteGlob(path.join(projectPath, "app", "page.*"));
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
if (scheme === "loader") {
|
|
91
|
+
// ./plasmic-init.ts
|
|
92
|
+
await fs.writeFile(
|
|
93
|
+
path.join(projectPath, `plasmic-init.${jsOrTs}`),
|
|
94
|
+
makePlasmicInit_app_loader(
|
|
95
|
+
projectId,
|
|
96
|
+
ensure(projectApiToken, "Missing projectApiToken")
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
// ./plasmic-init-client.ts
|
|
101
|
+
await fs.writeFile(
|
|
102
|
+
path.join(projectPath, `plasmic-init-client.${jsOrTs}x`),
|
|
103
|
+
makePlasmicInitClient_app_loader(jsOrTs)
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// ./app/plasmic-host/page.tsx
|
|
107
|
+
await fs.mkdir(path.join(projectPath, "app", "plasmic-host"));
|
|
108
|
+
await fs.writeFile(
|
|
109
|
+
path.join(projectPath, "app", "plasmic-host", `page.${jsOrTs}x`),
|
|
110
|
+
makePlasmicHostPage_app_loader()
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// ./app/[[...catchall]]/page.tsx
|
|
114
|
+
await fs.mkdir(path.join(projectPath, "app", "[[...catchall]]"));
|
|
115
|
+
await fs.writeFile(
|
|
116
|
+
path.join(projectPath, "app", "[[...catchall]]", `page.${jsOrTs}x`),
|
|
117
|
+
makeCatchallPage_app_loader(jsOrTs)
|
|
118
|
+
);
|
|
119
|
+
} else {
|
|
120
|
+
// ./app/layout.tsx
|
|
121
|
+
await fs.writeFile(
|
|
122
|
+
path.join(projectPath, "app", `layout.${jsOrTs}x`),
|
|
123
|
+
makeLayout_app_codegen(jsOrTs)
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// ./app/plasmic-host/page.tsx
|
|
127
|
+
await fs.mkdir(path.join(projectPath, "app", "plasmic-host"));
|
|
128
|
+
await fs.writeFile(
|
|
129
|
+
path.join(projectPath, "app", "plasmic-host", `page.${jsOrTs}x`),
|
|
130
|
+
makePlasmicHostPage_pages_codegen() // plasmic-host page contents are the same as the pages router
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// This should generate
|
|
134
|
+
// ./plasmic.json
|
|
135
|
+
// ./app/page.tsx
|
|
136
|
+
// ./components/plasmic/**
|
|
137
|
+
await runCodegenSync({
|
|
93
138
|
projectId,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// ./app/[[...catchall]]/page.tsx
|
|
112
|
-
await fs.mkdir(path.join(projectPath, "app", "[[...catchall]]"));
|
|
113
|
-
await fs.writeFile(
|
|
114
|
-
path.join(projectPath, "app", "[[...catchall]]", `page.${jsOrTs}x`),
|
|
115
|
-
makeCatchallPage_app_loader(jsOrTs)
|
|
116
|
-
);
|
|
139
|
+
projectApiToken,
|
|
140
|
+
projectPath,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Make an index (/) page if the project didn't have one.
|
|
144
|
+
const config = await getPlasmicConfig(projectPath, "nextjs", scheme);
|
|
145
|
+
const plasmicFiles = L.map(
|
|
146
|
+
L.flatMap(config.projects, (p) => p.components),
|
|
147
|
+
(c) => c.importSpec.modulePath
|
|
148
|
+
);
|
|
149
|
+
if (!plasmicFiles.find((f) => f.includes("app/page."))) {
|
|
150
|
+
await fs.writeFile(
|
|
151
|
+
path.join(projectPath, "app", `page.${jsOrTs}x`),
|
|
152
|
+
generateWelcomePage(config, "nextjs")
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
117
156
|
}
|
|
118
157
|
|
|
119
158
|
async function generateFilesPagesDir(args: GenerateFilesArgs) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ifTs } from "../../../utils/file-utils";
|
|
2
|
+
import { JsOrTs } from "../../../utils/types";
|
|
3
|
+
|
|
4
|
+
export function makeLayout_app_codegen(jsOrTs: JsOrTs): string {
|
|
5
|
+
return `import '@/app/globals.css'
|
|
6
|
+
import { PlasmicRootProvider } from "@plasmicapp/react-web";
|
|
7
|
+
import Link from "next/link";
|
|
8
|
+
|
|
9
|
+
export default function RootLayout({
|
|
10
|
+
children,
|
|
11
|
+
}${ifTs(
|
|
12
|
+
jsOrTs,
|
|
13
|
+
`: Readonly<{
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}>`
|
|
16
|
+
)}) {
|
|
17
|
+
return (
|
|
18
|
+
<html lang="en">
|
|
19
|
+
<body>
|
|
20
|
+
<PlasmicRootProvider Link={Link}>
|
|
21
|
+
{children}
|
|
22
|
+
</PlasmicRootProvider>
|
|
23
|
+
</body>
|
|
24
|
+
</html>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
}
|