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.
Files changed (53) hide show
  1. package/cpa-out/nextjs-app-codegen-js/app/dynamic/[slug]/page-client.jsx +7 -0
  2. package/cpa-out/nextjs-app-codegen-js/app/dynamic/[slug]/page.jsx +45 -0
  3. package/cpa-out/nextjs-app-codegen-js/app/layout.js +28 -0
  4. package/cpa-out/nextjs-app-codegen-js/app/layout.jsx +17 -0
  5. package/cpa-out/nextjs-app-codegen-js/app/page-client.jsx +7 -0
  6. package/cpa-out/nextjs-app-codegen-js/app/page.jsx +45 -0
  7. package/cpa-out/nextjs-app-codegen-js/app/plasmic-host/page.jsx +15 -0
  8. package/cpa-out/nextjs-app-codegen-js/components/Button.jsx +11 -0
  9. package/cpa-out/nextjs-app-codegen-js/components/RandomDynamicPageButton.jsx +24 -0
  10. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicButton.jsx +595 -0
  11. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +216 -0
  12. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPageServer.jsx +56 -0
  13. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.jsx +26 -0
  14. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +251 -0
  15. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepageServer.jsx +56 -0
  16. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.jsx +159 -0
  17. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicStyleTokensProvider.jsx +15 -0
  18. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/icons/PlasmicIcon__CheckSvg.jsx +39 -0
  19. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.jsx +37 -0
  20. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/plasmic.jsx +11 -0
  21. package/cpa-out/nextjs-app-codegen-js/package.json +22 -0
  22. package/cpa-out/nextjs-app-codegen-js/plasmic.json +148 -0
  23. package/cpa-out/nextjs-app-codegen-ts/app/dynamic/[slug]/page-client.tsx +11 -0
  24. package/cpa-out/nextjs-app-codegen-ts/app/dynamic/[slug]/page.tsx +57 -0
  25. package/cpa-out/nextjs-app-codegen-ts/app/layout.tsx +19 -0
  26. package/cpa-out/nextjs-app-codegen-ts/app/page-client.tsx +11 -0
  27. package/cpa-out/nextjs-app-codegen-ts/app/page.tsx +54 -0
  28. package/cpa-out/nextjs-app-codegen-ts/app/plasmic-host/page.tsx +15 -0
  29. package/cpa-out/nextjs-app-codegen-ts/components/Button.tsx +35 -0
  30. package/cpa-out/nextjs-app-codegen-ts/components/RandomDynamicPageButton.tsx +44 -0
  31. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicButton.tsx +776 -0
  32. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +329 -0
  33. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPageServer.tsx +77 -0
  34. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +30 -0
  35. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +366 -0
  36. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepageServer.tsx +75 -0
  37. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx +274 -0
  38. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicStyleTokensProvider.tsx +19 -0
  39. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/icons/PlasmicIcon__CheckSvg.tsx +44 -0
  40. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.tsx +41 -0
  41. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/plasmic.tsx +14 -0
  42. package/cpa-out/nextjs-app-codegen-ts/package.json +26 -0
  43. package/cpa-out/nextjs-app-codegen-ts/plasmic.json +148 -0
  44. package/cpa-out/nextjs-app-codegen-ts/tsconfig.json +26 -0
  45. package/dist/index.js +31 -28
  46. package/dist/nextjs/nextjs.js +37 -11
  47. package/dist/nextjs/templates/app-codegen/layout.d.ts +2 -0
  48. package/dist/nextjs/templates/app-codegen/layout.js +27 -0
  49. package/package.json +2 -2
  50. package/run-cpa.ts +8 -9
  51. package/src/index.ts +31 -34
  52. package/src/nextjs/nextjs.ts +67 -28
  53. package/src/nextjs/templates/app-codegen/layout.ts +28 -0
@@ -0,0 +1,19 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ // @ts-nocheck
4
+
5
+ // This code is auto-generated by Plasmic; please do not edit!
6
+ // Plasmic Project: 47tFXWjN2C4NyHFGGpaYQ3
7
+
8
+ import { createUseStyleTokens } from "@plasmicapp/react-web";
9
+
10
+ import { _useGlobalVariants } from "./plasmic"; // plasmic-import: 47tFXWjN2C4NyHFGGpaYQ3/projectModule
11
+
12
+ import projectcss from "./plasmic.module.css"; // plasmic-import: 47tFXWjN2C4NyHFGGpaYQ3/projectcss
13
+
14
+ const data = {
15
+ base: `${projectcss.plasmic_tokens}`,
16
+ varianted: []
17
+ };
18
+
19
+ export const _useStyleTokens = createUseStyleTokens(data, _useGlobalVariants);
@@ -0,0 +1,44 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ // @ts-nocheck
4
+ /* prettier-ignore-start */
5
+ import React from "react";
6
+ import { classNames } from "@plasmicapp/react-web";
7
+
8
+ export type CheckSvgIconProps = React.ComponentProps<"svg"> & {
9
+ title?: string;
10
+ };
11
+
12
+ export function CheckSvgIcon(props: CheckSvgIconProps) {
13
+ const { className, style, title, ...restProps } = props;
14
+ return (
15
+ <svg
16
+ xmlns={"http://www.w3.org/2000/svg"}
17
+ fill={"none"}
18
+ viewBox={"0 0 24 24"}
19
+ height={"1em"}
20
+ width={"1em"}
21
+ style={{
22
+ fill: "currentcolor",
23
+
24
+ ...(style || {})
25
+ }}
26
+ className={classNames("plasmic-default__svg", className)}
27
+ {...restProps}
28
+ >
29
+ {title && <title>{title}</title>}
30
+
31
+ <path
32
+ fillRule={"evenodd"}
33
+ clipRule={"evenodd"}
34
+ d={
35
+ "M18.416 5.876a.75.75 0 01.208 1.04L11.42 17.721a1.75 1.75 0 01-2.871.06l-3.156-4.34a.75.75 0 111.214-.882l3.155 4.339a.25.25 0 00.41-.009l7.204-10.805a.75.75 0 011.04-.208z"
36
+ }
37
+ fill={"currentColor"}
38
+ ></path>
39
+ </svg>
40
+ );
41
+ }
42
+
43
+ export default CheckSvgIcon;
44
+ /* prettier-ignore-end */
@@ -0,0 +1,41 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ // @ts-nocheck
4
+ /* prettier-ignore-start */
5
+ import React from "react";
6
+ import { classNames } from "@plasmicapp/react-web";
7
+
8
+ export type IconIconProps = React.ComponentProps<"svg"> & {
9
+ title?: string;
10
+ };
11
+
12
+ export function IconIcon(props: IconIconProps) {
13
+ const { className, style, title, ...restProps } = props;
14
+ return (
15
+ <svg
16
+ xmlns={"http://www.w3.org/2000/svg"}
17
+ stroke={"currentColor"}
18
+ fill={"currentColor"}
19
+ strokeWidth={"0"}
20
+ viewBox={"0 0 16 16"}
21
+ height={"1em"}
22
+ width={"1em"}
23
+ className={classNames("plasmic-default__svg", className)}
24
+ style={style}
25
+ {...restProps}
26
+ >
27
+ {title && <title>{title}</title>}
28
+
29
+ <path
30
+ fillRule={"evenodd"}
31
+ d={
32
+ "M1 8a.5.5 0 01.5-.5h11.793l-3.147-3.146a.5.5 0 01.708-.708l4 4a.5.5 0 010 .708l-4 4a.5.5 0 01-.708-.708L13.293 8.5H1.5A.5.5 0 011 8z"
33
+ }
34
+ stroke={"none"}
35
+ ></path>
36
+ </svg>
37
+ );
38
+ }
39
+
40
+ export default IconIcon;
41
+ /* prettier-ignore-end */
@@ -0,0 +1,14 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ // @ts-nocheck
4
+
5
+ // This code is auto-generated by Plasmic; please do not edit!
6
+ // Plasmic Project: 47tFXWjN2C4NyHFGGpaYQ3
7
+
8
+ import { createUseGlobalVariants } from "@plasmicapp/react-web";
9
+
10
+ import { useScreenVariants as useScreenVariantsscBjPxgdxdzbv } from "./PlasmicGlobalVariant__Screen"; // plasmic-import: SCBjPXGDXDZBV/globalVariant
11
+
12
+ export const _useGlobalVariants = createUseGlobalVariants({
13
+ screen: useScreenVariantsscBjPxgdxdzbv
14
+ });
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "nextjs-app-codegen-ts",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "next dev",
7
+ "build": "next build",
8
+ "start": "next start",
9
+ "lint": "next lint"
10
+ },
11
+ "dependencies": {
12
+ "@plasmicapp/cli": "^0.1.359",
13
+ "@plasmicapp/react-web": "^0.2.422",
14
+ "next": "14.2.35",
15
+ "react": "^18",
16
+ "react-dom": "^18"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "^20",
20
+ "@types/react": "^18",
21
+ "@types/react-dom": "^18",
22
+ "eslint": "^8",
23
+ "eslint-config-next": "14.2.35",
24
+ "typescript": "^5"
25
+ }
26
+ }
@@ -0,0 +1,148 @@
1
+ {
2
+ "platform": "nextjs",
3
+ "code": {
4
+ "lang": "ts",
5
+ "scheme": "blackbox",
6
+ "reactRuntime": "classic"
7
+ },
8
+ "style": {
9
+ "scheme": "css-modules",
10
+ "defaultStyleCssFilePath": "plasmic/plasmic__default_style.module.css"
11
+ },
12
+ "images": {
13
+ "scheme": "public-files",
14
+ "publicDir": "../public",
15
+ "publicUrlPrefix": "/"
16
+ },
17
+ "tokens": {
18
+ "scheme": "theo",
19
+ "tokensFilePath": "plasmic-tokens.theo.json"
20
+ },
21
+ "srcDir": "components",
22
+ "defaultPlasmicDir": "./plasmic",
23
+ "projects": [
24
+ {
25
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
26
+ "projectApiToken": "7BRFratDxPLMGZHnd2grV5QP6mlHcZ1AK3BJSIeh7xzUlHgWh25XpgXvUaKAqHXFMXQQuzpADqboibF6nqNWQ",
27
+ "projectName": "create-plasmic-app",
28
+ "version": "latest",
29
+ "cssFilePath": "plasmic/create_plasmic_app/plasmic.module.css",
30
+ "components": [
31
+ {
32
+ "id": "6uuAAE1jiCew",
33
+ "name": "Homepage",
34
+ "type": "managed",
35
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
36
+ "renderModuleFilePath": "plasmic/create_plasmic_app/PlasmicHomepage.tsx",
37
+ "importSpec": {
38
+ "modulePath": "../app/page.tsx"
39
+ },
40
+ "cssFilePath": "plasmic/create_plasmic_app/PlasmicHomepage.module.css",
41
+ "scheme": "blackbox",
42
+ "componentType": "page",
43
+ "path": "/",
44
+ "rsc": {
45
+ "serverModulePath": "plasmic/create_plasmic_app/PlasmicHomepageServer.tsx",
46
+ "clientModulePath": "../app/page-client.tsx"
47
+ }
48
+ },
49
+ {
50
+ "id": "AO44A-w7hh",
51
+ "name": "DynamicPage",
52
+ "type": "managed",
53
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
54
+ "renderModuleFilePath": "plasmic/create_plasmic_app/PlasmicDynamicPage.tsx",
55
+ "importSpec": {
56
+ "modulePath": "../app/dynamic/[slug]/page.tsx"
57
+ },
58
+ "cssFilePath": "plasmic/create_plasmic_app/PlasmicDynamicPage.module.css",
59
+ "scheme": "blackbox",
60
+ "componentType": "page",
61
+ "path": "/dynamic/[slug]",
62
+ "rsc": {
63
+ "serverModulePath": "plasmic/create_plasmic_app/PlasmicDynamicPageServer.tsx",
64
+ "clientModulePath": "../app/dynamic/[slug]/page-client.tsx"
65
+ }
66
+ },
67
+ {
68
+ "id": "TQcvW_pSKi3",
69
+ "name": "Button",
70
+ "type": "managed",
71
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
72
+ "renderModuleFilePath": "plasmic/create_plasmic_app/PlasmicButton.tsx",
73
+ "importSpec": {
74
+ "modulePath": "Button.tsx"
75
+ },
76
+ "cssFilePath": "plasmic/create_plasmic_app/PlasmicButton.module.css",
77
+ "scheme": "blackbox",
78
+ "componentType": "component",
79
+ "plumeType": "button"
80
+ },
81
+ {
82
+ "id": "Q23H1_1M_P",
83
+ "name": "RandomDynamicPageButton",
84
+ "type": "managed",
85
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
86
+ "renderModuleFilePath": "plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx",
87
+ "importSpec": {
88
+ "modulePath": "RandomDynamicPageButton.tsx"
89
+ },
90
+ "cssFilePath": "plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.module.css",
91
+ "scheme": "blackbox",
92
+ "componentType": "component"
93
+ }
94
+ ],
95
+ "icons": [
96
+ {
97
+ "id": "gj-_D7n31Ho",
98
+ "name": "CheckSvgIcon",
99
+ "moduleFilePath": "plasmic/create_plasmic_app/icons/PlasmicIcon__CheckSvg.tsx"
100
+ },
101
+ {
102
+ "id": "6PNxx3YMyDQ",
103
+ "name": "IconIcon",
104
+ "moduleFilePath": "plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.tsx"
105
+ }
106
+ ],
107
+ "images": [],
108
+ "indirect": false,
109
+ "globalContextsFilePath": "",
110
+ "splitsProviderFilePath": "",
111
+ "styleTokensProviderFilePath": "plasmic/create_plasmic_app/PlasmicStyleTokensProvider.tsx",
112
+ "dataTokensFilePath": "",
113
+ "projectModuleFilePath": "plasmic/create_plasmic_app/plasmic.tsx",
114
+ "codeComponents": [
115
+ {
116
+ "id": "P6aGdYWZ2R",
117
+ "name": "PlasmicHead",
118
+ "displayName": "hostless-plasmic-head",
119
+ "componentImportPath": "@plasmicapp/react-web"
120
+ },
121
+ {
122
+ "id": "8G2A-uTjGa",
123
+ "name": "Fetcher",
124
+ "displayName": "plasmic-data-source-fetcher",
125
+ "componentImportPath": "@plasmicapp/react-web/lib/data-sources"
126
+ }
127
+ ],
128
+ "customFunctions": []
129
+ }
130
+ ],
131
+ "globalVariants": {
132
+ "variantGroups": [
133
+ {
134
+ "id": "SCBjPXGDXDZBV",
135
+ "name": "Screen",
136
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
137
+ "contextFilePath": "plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx"
138
+ }
139
+ ]
140
+ },
141
+ "wrapPagesWithGlobalContexts": true,
142
+ "preserveJsImportExtensions": false,
143
+ "nextjsConfig": {
144
+ "pagesDir": "../app"
145
+ },
146
+ "cliVersion": "0.1.359",
147
+ "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.359/dist/plasmic.schema.json"
148
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["dom", "dom.iterable", "esnext"],
4
+ "allowJs": true,
5
+ "skipLibCheck": true,
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "esModuleInterop": true,
9
+ "module": "esnext",
10
+ "moduleResolution": "bundler",
11
+ "resolveJsonModule": true,
12
+ "isolatedModules": true,
13
+ "jsx": "preserve",
14
+ "incremental": true,
15
+ "plugins": [
16
+ {
17
+ "name": "next"
18
+ }
19
+ ],
20
+ "paths": {
21
+ "@/*": ["./*"]
22
+ }
23
+ },
24
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
+ "exclude": ["node_modules"]
26
+ }
package/dist/index.js CHANGED
@@ -96,10 +96,6 @@ const argv = yargs_1.default
96
96
  !(argv2.platform === "nextjs" || argv2.platform === "gatsby")) {
97
97
  throw new Error(`Loader scheme may only be used with Next.js or Gatsby`);
98
98
  }
99
- if (argv2.appDir &&
100
- !(argv2.platform === "nextjs" && argv2.scheme === "loader")) {
101
- throw new Error(`App dir may only be used with Next.js and loader scheme`);
102
- }
103
99
  return true;
104
100
  }).argv;
105
101
  // Initialize Sentry
@@ -222,31 +218,38 @@ function run() {
222
218
  default: "loader",
223
219
  })
224
220
  : "codegen";
225
- // TODO: Support nextjs + codegen
226
221
  const platformOptions = {};
227
- // Don't show app dir question until we have better support for app dir.
228
- const showAppDirQuestion = false;
229
- if (showAppDirQuestion && platform === "nextjs" && scheme === "loader") {
230
- platformOptions.nextjs = {
231
- appDir: yield maybePrompt({
232
- name: "appDir",
233
- message: "Do you want to use the app/ directory and React Server Components? (see https://beta.nextjs.org/docs/app-directory-roadmap)",
234
- type: "list",
235
- choices: () => [
236
- {
237
- name: "No, use pages/ directory",
238
- short: "No",
239
- value: false,
240
- },
241
- {
242
- name: "Yes, use app/ directory (experimental)",
243
- short: "Yes",
244
- value: true,
245
- },
246
- ],
247
- default: false,
248
- }),
249
- };
222
+ if (platform === "nextjs") {
223
+ // TODO: re-enable when app dir is released
224
+ const showAppDirQuestion = false;
225
+ if (showAppDirQuestion) {
226
+ platformOptions.nextjs = {
227
+ appDir: yield maybePrompt({
228
+ name: "appDir",
229
+ message: "Do you want to use the app/ directory and React Server Components? (see https://nextjs.org/docs/app)",
230
+ type: "list",
231
+ choices: () => [
232
+ {
233
+ name: "Yes, use app/ directory",
234
+ short: "Yes",
235
+ value: true,
236
+ },
237
+ {
238
+ name: "No, use pages/ directory",
239
+ short: "No",
240
+ value: false,
241
+ },
242
+ ],
243
+ default: true,
244
+ }),
245
+ };
246
+ // Respect appDir flag for e2e tests
247
+ }
248
+ else if (argv["appDir"] !== undefined) {
249
+ platformOptions.nextjs = {
250
+ appDir: argv["appDir"],
251
+ };
252
+ }
250
253
  }
251
254
  // Get the projectId
252
255
  console.log();
@@ -21,6 +21,7 @@ const codegen_1 = require("../utils/codegen");
21
21
  const file_utils_1 = require("../utils/file-utils");
22
22
  const lang_utils_1 = require("../utils/lang-utils");
23
23
  const npm_utils_1 = require("../utils/npm-utils");
24
+ const layout_1 = require("./templates/app-codegen/layout");
24
25
  const catchall_page_1 = require("./templates/app-loader/catchall-page");
25
26
  const plasmic_host_1 = require("./templates/app-loader/plasmic-host");
26
27
  const plasmic_init_1 = require("./templates/app-loader/plasmic-init");
@@ -89,19 +90,44 @@ export default nextConfig;`);
89
90
  };
90
91
  function generateFilesAppDir(args) {
91
92
  return __awaiter(this, void 0, void 0, function* () {
92
- const { projectPath, jsOrTs, projectId, projectApiToken } = args;
93
+ const { projectPath, scheme, jsOrTs, projectId, projectApiToken } = args;
93
94
  // Delete existing pages
94
95
  (0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "app", "page.*"));
95
- // ./plasmic-init.ts
96
- 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, "Missing projectApiToken")));
97
- // ./plasmic-init-client.ts
98
- yield fs_1.promises.writeFile(path_1.default.join(projectPath, `plasmic-init-client.${jsOrTs}x`), (0, plasmic_init_client_1.makePlasmicInitClient_app_loader)(jsOrTs));
99
- // ./app/plasmic-host/page.tsx
100
- yield fs_1.promises.mkdir(path_1.default.join(projectPath, "app", "plasmic-host"));
101
- yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "plasmic-host", `page.${jsOrTs}x`), (0, plasmic_host_1.makePlasmicHostPage_app_loader)());
102
- // ./app/[[...catchall]]/page.tsx
103
- yield fs_1.promises.mkdir(path_1.default.join(projectPath, "app", "[[...catchall]]"));
104
- yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "[[...catchall]]", `page.${jsOrTs}x`), (0, catchall_page_1.makeCatchallPage_app_loader)(jsOrTs));
96
+ if (scheme === "loader") {
97
+ // ./plasmic-init.ts
98
+ 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, "Missing projectApiToken")));
99
+ // ./plasmic-init-client.ts
100
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, `plasmic-init-client.${jsOrTs}x`), (0, plasmic_init_client_1.makePlasmicInitClient_app_loader)(jsOrTs));
101
+ // ./app/plasmic-host/page.tsx
102
+ yield fs_1.promises.mkdir(path_1.default.join(projectPath, "app", "plasmic-host"));
103
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "plasmic-host", `page.${jsOrTs}x`), (0, plasmic_host_1.makePlasmicHostPage_app_loader)());
104
+ // ./app/[[...catchall]]/page.tsx
105
+ yield fs_1.promises.mkdir(path_1.default.join(projectPath, "app", "[[...catchall]]"));
106
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "[[...catchall]]", `page.${jsOrTs}x`), (0, catchall_page_1.makeCatchallPage_app_loader)(jsOrTs));
107
+ }
108
+ else {
109
+ // ./app/layout.tsx
110
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", `layout.${jsOrTs}x`), (0, layout_1.makeLayout_app_codegen)(jsOrTs));
111
+ // ./app/plasmic-host/page.tsx
112
+ yield fs_1.promises.mkdir(path_1.default.join(projectPath, "app", "plasmic-host"));
113
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "plasmic-host", `page.${jsOrTs}x`), (0, plasmic_host_2.makePlasmicHostPage_pages_codegen)() // plasmic-host page contents are the same as the pages router
114
+ );
115
+ // This should generate
116
+ // ./plasmic.json
117
+ // ./app/page.tsx
118
+ // ./components/plasmic/**
119
+ yield (0, codegen_1.runCodegenSync)({
120
+ projectId,
121
+ projectApiToken,
122
+ projectPath,
123
+ });
124
+ // Make an index (/) page if the project didn't have one.
125
+ const config = yield (0, file_utils_1.getPlasmicConfig)(projectPath, "nextjs", scheme);
126
+ const plasmicFiles = lodash_1.default.map(lodash_1.default.flatMap(config.projects, (p) => p.components), (c) => c.importSpec.modulePath);
127
+ if (!plasmicFiles.find((f) => f.includes("app/page."))) {
128
+ yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", `page.${jsOrTs}x`), (0, file_utils_1.generateWelcomePage)(config, "nextjs"));
129
+ }
130
+ }
105
131
  });
106
132
  }
107
133
  function generateFilesPagesDir(args) {
@@ -0,0 +1,2 @@
1
+ import { JsOrTs } from "../../../utils/types";
2
+ export declare function makeLayout_app_codegen(jsOrTs: JsOrTs): string;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeLayout_app_codegen = void 0;
4
+ const file_utils_1 = require("../../../utils/file-utils");
5
+ function makeLayout_app_codegen(jsOrTs) {
6
+ return `import '@/app/globals.css'
7
+ import { PlasmicRootProvider } from "@plasmicapp/react-web";
8
+ import Link from "next/link";
9
+
10
+ export default function RootLayout({
11
+ children,
12
+ }${(0, file_utils_1.ifTs)(jsOrTs, `: Readonly<{
13
+ children: React.ReactNode;
14
+ }>`)}) {
15
+ return (
16
+ <html lang="en">
17
+ <body>
18
+ <PlasmicRootProvider Link={Link}>
19
+ {children}
20
+ </PlasmicRootProvider>
21
+ </body>
22
+ </html>
23
+ );
24
+ }
25
+ `;
26
+ }
27
+ exports.makeLayout_app_codegen = makeLayout_app_codegen;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-plasmic-app",
3
- "version": "0.0.133",
3
+ "version": "0.0.134",
4
4
  "description": "Create Plasmic-powered React apps",
5
5
  "main": "./dist/lib.js",
6
6
  "types": "./dist/lib.d.ts",
@@ -47,5 +47,5 @@
47
47
  "validate-npm-package-name": "^3.0.0",
48
48
  "yargs": "^16.2.0"
49
49
  },
50
- "gitHead": "a18cd21936a28b372b3cbdd9f4a4c37b7d055eae"
50
+ "gitHead": "d429f0c262533e0bcc1e2a18675c4e6277580ac6"
51
51
  }
package/run-cpa.ts CHANGED
@@ -30,6 +30,12 @@ async function run() {
30
30
  scheme,
31
31
  typescript,
32
32
  });
33
+ allArgSets.push({
34
+ platform: "nextjs",
35
+ appDir: true,
36
+ scheme,
37
+ typescript,
38
+ });
33
39
  if (scheme === "codegen") {
34
40
  if (typescript) {
35
41
  allArgSets.push({
@@ -46,22 +52,15 @@ async function run() {
46
52
  });
47
53
  }
48
54
  });
49
-
50
- allArgSets.push({
51
- platform: "nextjs",
52
- appDir: true,
53
- scheme: "loader", // TODO: support codegen with appDir
54
- typescript,
55
- });
56
55
  });
57
56
  const allArgSetNames = allArgSets.map(getProjectName).sort();
58
57
 
59
- let yargsCommand = yargs.command(
58
+ const yargsCommand = yargs.command(
60
59
  "$0 [arg-sets..]",
61
60
  `Runs create-plasmic-app with predefined sets of args for you.
62
61
 
63
62
  Valid arg sets:\n\tall\n\t${allArgSetNames.join("\n\t")}`,
64
- (yargs) => yargs
63
+ (yargs2) => yargs2
65
64
  );
66
65
 
67
66
  const cliArgSetNames = yargsCommand.strict().argv["arg-sets"] as
package/src/index.ts CHANGED
@@ -75,15 +75,6 @@ const argv = yargs
75
75
  throw new Error(`Loader scheme may only be used with Next.js or Gatsby`);
76
76
  }
77
77
 
78
- if (
79
- argv2.appDir &&
80
- !(argv2.platform === "nextjs" && argv2.scheme === "loader")
81
- ) {
82
- throw new Error(
83
- `App dir may only be used with Next.js and loader scheme`
84
- );
85
- }
86
-
87
78
  return true;
88
79
  }).argv;
89
80
 
@@ -219,32 +210,38 @@ async function run(): Promise<void> {
219
210
  })
220
211
  : "codegen";
221
212
 
222
- // TODO: Support nextjs + codegen
223
213
  const platformOptions: PlatformOptions = {};
224
- // Don't show app dir question until we have better support for app dir.
225
- const showAppDirQuestion = false;
226
- if (showAppDirQuestion && platform === "nextjs" && scheme === "loader") {
227
- platformOptions.nextjs = {
228
- appDir: await maybePrompt({
229
- name: "appDir",
230
- message:
231
- "Do you want to use the app/ directory and React Server Components? (see https://beta.nextjs.org/docs/app-directory-roadmap)",
232
- type: "list",
233
- choices: () => [
234
- {
235
- name: "No, use pages/ directory",
236
- short: "No",
237
- value: false,
238
- },
239
- {
240
- name: "Yes, use app/ directory (experimental)",
241
- short: "Yes",
242
- value: true,
243
- },
244
- ],
245
- default: false,
246
- }),
247
- };
214
+ if (platform === "nextjs") {
215
+ // TODO: re-enable when app dir is released
216
+ const showAppDirQuestion = false;
217
+ if (showAppDirQuestion) {
218
+ platformOptions.nextjs = {
219
+ appDir: await maybePrompt({
220
+ name: "appDir",
221
+ message:
222
+ "Do you want to use the app/ directory and React Server Components? (see https://nextjs.org/docs/app)",
223
+ type: "list",
224
+ choices: () => [
225
+ {
226
+ name: "Yes, use app/ directory",
227
+ short: "Yes",
228
+ value: true,
229
+ },
230
+ {
231
+ name: "No, use pages/ directory",
232
+ short: "No",
233
+ value: false,
234
+ },
235
+ ],
236
+ default: true,
237
+ }),
238
+ };
239
+ // Respect appDir flag for e2e tests
240
+ } else if (argv["appDir"] !== undefined) {
241
+ platformOptions.nextjs = {
242
+ appDir: argv["appDir"],
243
+ };
244
+ }
248
245
  }
249
246
 
250
247
  // Get the projectId