create-plasmic-app 0.0.66 → 0.0.68
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/.tool-versions +1 -0
- package/cpa-out/gatsby-codegen-js/package.json +2 -2
- package/cpa-out/gatsby-codegen-js/plasmic.json +54 -3
- package/cpa-out/gatsby-codegen-js/src/components/Button.jsx +13 -0
- package/cpa-out/gatsby-codegen-js/src/components/RandomDynamicPageButton.jsx +24 -0
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicButton.jsx +631 -0
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +176 -0
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +15 -3
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.jsx +162 -0
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Checksvg.jsx +39 -0
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.jsx +37 -0
- package/cpa-out/gatsby-codegen-js/src/pages/dynamic/[slug].jsx +39 -0
- package/cpa-out/gatsby-codegen-ts/package.json +2 -2
- package/cpa-out/gatsby-codegen-ts/plasmic.json +54 -3
- package/cpa-out/gatsby-codegen-ts/src/components/Button.tsx +36 -0
- package/cpa-out/gatsby-codegen-ts/src/components/RandomDynamicPageButton.tsx +44 -0
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicButton.tsx +736 -0
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +262 -0
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +1 -0
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +18 -5
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx +246 -0
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Checksvg.tsx +44 -0
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.tsx +41 -0
- package/cpa-out/gatsby-codegen-ts/src/pages/dynamic/[slug].tsx +41 -0
- package/cpa-out/gatsby-loader-js/package.json +3 -3
- package/cpa-out/gatsby-loader-ts/package.json +7 -7
- package/cpa-out/nextjs-app-loader-js/package.json +4 -4
- package/cpa-out/nextjs-app-loader-ts/package.json +6 -6
- package/cpa-out/nextjs-pages-codegen-js/components/Button.jsx +13 -0
- package/cpa-out/nextjs-pages-codegen-js/components/RandomDynamicPageButton.jsx +24 -0
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicButton.jsx +640 -0
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +184 -0
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +15 -3
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.jsx +170 -0
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Checksvg.jsx +39 -0
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.jsx +37 -0
- package/cpa-out/nextjs-pages-codegen-js/package.json +2 -2
- package/cpa-out/nextjs-pages-codegen-js/pages/dynamic/[slug].jsx +35 -0
- package/cpa-out/nextjs-pages-codegen-js/plasmic.json +54 -3
- package/cpa-out/nextjs-pages-codegen-ts/components/Button.tsx +36 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/RandomDynamicPageButton.tsx +44 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicButton.tsx +742 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +264 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +1 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +18 -5
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx +252 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Checksvg.tsx +44 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.tsx +41 -0
- package/cpa-out/nextjs-pages-codegen-ts/package.json +4 -4
- package/cpa-out/nextjs-pages-codegen-ts/pages/dynamic/[slug].tsx +37 -0
- package/cpa-out/nextjs-pages-codegen-ts/plasmic.json +54 -3
- package/cpa-out/nextjs-pages-loader-js/package.json +4 -4
- package/cpa-out/nextjs-pages-loader-ts/package.json +6 -6
- package/cpa-out/react-codegen-js/package.json +2 -2
- package/cpa-out/react-codegen-js/plasmic.json +54 -3
- package/cpa-out/react-codegen-js/src/components/Button.jsx +13 -0
- package/cpa-out/react-codegen-js/src/components/DynamicPage.jsx +26 -0
- package/cpa-out/react-codegen-js/src/components/RandomDynamicPageButton.jsx +24 -0
- package/cpa-out/react-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicButton.jsx +625 -0
- package/cpa-out/react-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +166 -0
- package/cpa-out/react-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +15 -3
- package/cpa-out/react-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.jsx +161 -0
- package/cpa-out/react-codegen-js/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Checksvg.jsx +39 -0
- package/cpa-out/react-codegen-js/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.jsx +37 -0
- package/cpa-out/react-codegen-ts/package.json +2 -2
- package/cpa-out/react-codegen-ts/plasmic.json +54 -3
- package/cpa-out/react-codegen-ts/src/components/Button.tsx +36 -0
- package/cpa-out/react-codegen-ts/src/components/DynamicPage.tsx +45 -0
- package/cpa-out/react-codegen-ts/src/components/RandomDynamicPageButton.tsx +44 -0
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicButton.tsx +725 -0
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +248 -0
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +1 -0
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +18 -5
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx +240 -0
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Checksvg.tsx +44 -0
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.tsx +41 -0
- package/cpa-out/react-loader-js/package.json +2 -3
- package/cpa-out/react-loader-js/plasmic.json +54 -3
- package/cpa-out/react-loader-js/src/components/Button.jsx +13 -0
- package/cpa-out/react-loader-js/src/components/DynamicPage.jsx +26 -0
- package/cpa-out/react-loader-js/src/components/RandomDynamicPageButton.jsx +24 -0
- package/cpa-out/react-loader-js/src/components/plasmic/create_plasmic_app/PlasmicButton.jsx +625 -0
- package/cpa-out/react-loader-js/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +166 -0
- package/cpa-out/react-loader-js/src/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +18 -4
- package/cpa-out/react-loader-js/src/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.jsx +161 -0
- package/cpa-out/react-loader-js/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Checksvg.jsx +39 -0
- package/cpa-out/react-loader-js/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.jsx +37 -0
- package/cpa-out/react-loader-ts/package.json +2 -3
- package/cpa-out/react-loader-ts/plasmic.json +54 -3
- package/cpa-out/react-loader-ts/src/components/Button.tsx +36 -0
- package/cpa-out/react-loader-ts/src/components/DynamicPage.tsx +45 -0
- package/cpa-out/react-loader-ts/src/components/RandomDynamicPageButton.tsx +44 -0
- package/cpa-out/react-loader-ts/src/components/plasmic/create_plasmic_app/PlasmicButton.tsx +725 -0
- package/cpa-out/react-loader-ts/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +248 -0
- package/cpa-out/react-loader-ts/src/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +1 -0
- package/cpa-out/react-loader-ts/src/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +21 -7
- package/cpa-out/react-loader-ts/src/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx +240 -0
- package/cpa-out/react-loader-ts/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Checksvg.tsx +44 -0
- package/cpa-out/react-loader-ts/src/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.tsx +41 -0
- package/dist/gatsby/gatsby.js +16 -2
- package/dist/nextjs/nextjs.js +11 -7
- package/dist/react/react.js +17 -5
- package/dist/utils/file-utils.d.ts +15 -9
- package/dist/utils/file-utils.js +4 -59
- package/package.json +2 -2
- package/src/gatsby/gatsby.ts +32 -3
- package/src/nextjs/nextjs.ts +19 -5
- package/src/react/react.ts +28 -6
- package/src/utils/file-utils.ts +5 -88
- /package/cpa-out/gatsby-codegen-js/src/pages/{404.js → 404.jsx} +0 -0
- /package/cpa-out/gatsby-codegen-ts/src/pages/{404.js → 404.tsx} +0 -0
package/dist/gatsby/gatsby.js
CHANGED
|
@@ -44,6 +44,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.gatsbyStrategy = exports.GATSBY_TEMPLATES = void 0;
|
|
46
46
|
const fs_1 = require("fs");
|
|
47
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
47
48
|
const path_1 = __importDefault(require("path"));
|
|
48
49
|
const readline = __importStar(require("readline"));
|
|
49
50
|
const cmd_utils_1 = require("../utils/cmd-utils");
|
|
@@ -179,8 +180,21 @@ exports.gatsbyStrategy = {
|
|
|
179
180
|
projectApiToken,
|
|
180
181
|
projectPath,
|
|
181
182
|
});
|
|
182
|
-
//
|
|
183
|
-
yield (0, file_utils_1.
|
|
183
|
+
// Special case: remove all Gatsby components (due to conflicting file names)
|
|
184
|
+
const config = yield (0, file_utils_1.getPlasmicConfig)(projectPath, "gatsby", scheme);
|
|
185
|
+
const plasmicFiles = lodash_1.default.map(lodash_1.default.flatMap(config.projects, (p) => p.components), (c) => c.importSpec.modulePath);
|
|
186
|
+
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "src/@(pages|components)/*.*"), [
|
|
187
|
+
// Files to ignore
|
|
188
|
+
...plasmicFiles.map((f) => path_1.default.basename(f)),
|
|
189
|
+
]);
|
|
190
|
+
// Create a very basic 404 page - `gatsby build` fails without it.
|
|
191
|
+
// We've deleted the components that the default 404 page depended
|
|
192
|
+
// on, so
|
|
193
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/pages/404.${jsOrTs}x`), template_1.GATSBY_404);
|
|
194
|
+
// Make an index page if the project didn't have one.
|
|
195
|
+
if (!plasmicFiles.find((f) => f.includes("/index."))) {
|
|
196
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/pages/index.${jsOrTs}x`), (0, file_utils_1.generateWelcomePage)(config, "gatsby"));
|
|
197
|
+
}
|
|
184
198
|
// Overwrite the wrapper files to wrap PlasmicRootProvider
|
|
185
199
|
const wrapperContent = (0, template_1.wrapAppRootForCodegen)();
|
|
186
200
|
const browserFilePath = path_1.default.join(projectPath, `gatsby-browser.${jsOrTs}x`);
|
package/dist/nextjs/nextjs.js
CHANGED
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.nextjsStrategy = void 0;
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
17
18
|
const path_1 = __importDefault(require("path"));
|
|
18
19
|
const cmd_utils_1 = require("../utils/cmd-utils");
|
|
19
20
|
const codegen_1 = require("../utils/codegen");
|
|
@@ -21,12 +22,12 @@ const file_utils_1 = require("../utils/file-utils");
|
|
|
21
22
|
const lang_utils_1 = require("../utils/lang-utils");
|
|
22
23
|
const npm_utils_1 = require("../utils/npm-utils");
|
|
23
24
|
const catchall_page_1 = require("./templates/app-loader/catchall-page");
|
|
25
|
+
const plasmic_host_1 = require("./templates/app-loader/plasmic-host");
|
|
24
26
|
const plasmic_init_1 = require("./templates/app-loader/plasmic-init");
|
|
25
27
|
const plasmic_init_client_1 = require("./templates/app-loader/plasmic-init-client");
|
|
26
28
|
const app_1 = require("./templates/pages-codegen/app");
|
|
27
|
-
const
|
|
29
|
+
const plasmic_host_2 = require("./templates/pages-codegen/plasmic-host");
|
|
28
30
|
const catchall_page_2 = require("./templates/pages-loader/catchall-page");
|
|
29
|
-
const plasmic_host_2 = require("./templates/app-loader/plasmic-host");
|
|
30
31
|
const plasmic_host_3 = require("./templates/pages-loader/plasmic-host");
|
|
31
32
|
const plasmic_init_2 = require("./templates/pages-loader/plasmic-init");
|
|
32
33
|
exports.nextjsStrategy = {
|
|
@@ -114,7 +115,7 @@ function generateFilesAppDir(args) {
|
|
|
114
115
|
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
116
|
// ./app/plasmic-host/page.tsx
|
|
116
117
|
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,
|
|
118
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "plasmic-host", `page.${jsOrTs}x`), (0, plasmic_host_1.makePlasmicHostPage_app_loader)());
|
|
118
119
|
// ./app/[[...catchall]]/page.tsx
|
|
119
120
|
yield fs_1.promises.mkdir(path_1.default.join(projectPath, "app", "[[...catchall]]"));
|
|
120
121
|
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "[[...catchall]]", `page.${jsOrTs}x`), (0, catchall_page_1.makeCatchallPage_app_loader)(jsOrTs));
|
|
@@ -137,7 +138,7 @@ function generateFilesPagesDir(args) {
|
|
|
137
138
|
// ./pages/_app.tsx
|
|
138
139
|
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `_app.${jsOrTs}x`), (0, app_1.makeCustomApp_pages_codegen)(jsOrTs));
|
|
139
140
|
// ./pages/plasmic-host.tsx
|
|
140
|
-
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `plasmic-host.${jsOrTs}x`), (0,
|
|
141
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `plasmic-host.${jsOrTs}x`), (0, plasmic_host_2.makePlasmicHostPage_pages_codegen)());
|
|
141
142
|
// This should generate
|
|
142
143
|
// ./plasmic.json
|
|
143
144
|
// ./pages/index.tsx
|
|
@@ -147,9 +148,12 @@ function generateFilesPagesDir(args) {
|
|
|
147
148
|
projectApiToken,
|
|
148
149
|
projectPath,
|
|
149
150
|
});
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
// Make an index page if the project didn't have one.
|
|
152
|
+
const config = yield (0, file_utils_1.getPlasmicConfig)(projectPath, "nextjs", scheme);
|
|
153
|
+
const plasmicFiles = lodash_1.default.map(lodash_1.default.flatMap(config.projects, (p) => p.components), (c) => c.importSpec.modulePath);
|
|
154
|
+
if (!plasmicFiles.find((f) => f.includes("/index."))) {
|
|
155
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `index.${jsOrTs}x`), (0, file_utils_1.generateWelcomePage)(config, "nextjs"));
|
|
156
|
+
}
|
|
153
157
|
}
|
|
154
158
|
});
|
|
155
159
|
}
|
package/dist/react/react.js
CHANGED
|
@@ -13,11 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.reactStrategy = void 0;
|
|
16
|
-
const fs_1 =
|
|
16
|
+
const fs_1 = require("fs");
|
|
17
|
+
const glob_1 = __importDefault(require("glob"));
|
|
17
18
|
const path_1 = __importDefault(require("path"));
|
|
18
19
|
const cmd_utils_1 = require("../utils/cmd-utils");
|
|
19
20
|
const codegen_1 = require("../utils/codegen");
|
|
20
21
|
const file_utils_1 = require("../utils/file-utils");
|
|
22
|
+
const lang_utils_1 = require("../utils/lang-utils");
|
|
21
23
|
const npm_utils_1 = require("../utils/npm-utils");
|
|
22
24
|
exports.reactStrategy = {
|
|
23
25
|
create: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -48,20 +50,30 @@ exports.reactStrategy = {
|
|
|
48
50
|
// Nothing to do
|
|
49
51
|
}
|
|
50
52
|
else {
|
|
53
|
+
// Delete existing entry point App.tsx and related test
|
|
54
|
+
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "src", "App*"));
|
|
51
55
|
yield (0, codegen_1.runCodegenSync)({
|
|
52
56
|
projectId,
|
|
53
57
|
projectApiToken,
|
|
54
58
|
projectPath,
|
|
55
59
|
});
|
|
56
|
-
//
|
|
57
|
-
yield (0, file_utils_1.
|
|
60
|
+
// Pick a page for the entry point App.tsx page
|
|
61
|
+
const config = yield (0, file_utils_1.getPlasmicConfig)(projectPath, "react", scheme);
|
|
62
|
+
const pagesDir = path_1.default.join(projectPath, (0, lang_utils_1.ensureString)(config.srcDir));
|
|
63
|
+
const homeFilePossibilities = glob_1.default.sync(path_1.default.join(pagesDir, "**", "@(index|Home|home|Homepage).*"));
|
|
64
|
+
// Overwrite App.tsx
|
|
65
|
+
const indexPath = path_1.default.join(projectPath, "src", `App.${jsOrTs}x`);
|
|
66
|
+
const content = homeFilePossibilities.length > 0
|
|
67
|
+
? (0, file_utils_1.generateHomePage)(homeFilePossibilities[0], indexPath)
|
|
68
|
+
: (0, file_utils_1.generateWelcomePage)(config, "react");
|
|
69
|
+
yield fs_1.promises.writeFile(indexPath, content);
|
|
58
70
|
}
|
|
59
71
|
// Deactivate React.StrictMode from index.js or index.tsx
|
|
60
72
|
const indexFileName = path_1.default.join(projectPath, "src", `index.${jsOrTs === "js" ? "js" : "tsx"}`);
|
|
61
|
-
let indexFile = fs_1.
|
|
73
|
+
let indexFile = (yield fs_1.promises.readFile(indexFileName)).toString();
|
|
62
74
|
indexFile = indexFile.replace("<React.StrictMode>", "");
|
|
63
75
|
indexFile = indexFile.replace("</React.StrictMode>", "");
|
|
64
|
-
fs_1.
|
|
76
|
+
yield fs_1.promises.writeFile(indexFileName, indexFile);
|
|
65
77
|
return;
|
|
66
78
|
}),
|
|
67
79
|
build: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -7,15 +7,6 @@ import { JsOrTs, PlatformType } from "../utils/types";
|
|
|
7
7
|
export declare function deleteGlob(searchPattern: string, skipPatterns?: string[]): void;
|
|
8
8
|
export declare function stripExtension(filename: string, removeComposedPath?: boolean): string;
|
|
9
9
|
export declare function writePlasmicLoaderJson(projectDir: string, projectId: string, projectApiToken: string): Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* - [nextjs|gatsby, loader, '/' page exists] - remove index file
|
|
12
|
-
* - [nextjs|gatsby, loader, '/' Page DNE] - replace index file with Welcome page
|
|
13
|
-
* - [nextjs|gatsby, codegen, '/' page exists] - remove Next.js/Gatsby index file, preserve Plasmic index
|
|
14
|
-
* - [nextjs|gatsby, codegen, '/' page DNE] - replace index file with Welcome page
|
|
15
|
-
* - [react, codegen ] - replace App file with '/', Home, or Welcome page
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
export declare function overwriteIndex(projectPath: string, platform: string, scheme: string): Promise<void>;
|
|
19
10
|
/**
|
|
20
11
|
* Overwrite the README file
|
|
21
12
|
* @param projectPath
|
|
@@ -23,5 +14,20 @@ export declare function overwriteIndex(projectPath: string, platform: string, sc
|
|
|
23
14
|
* @param buildCommand
|
|
24
15
|
*/
|
|
25
16
|
export declare function overwriteReadme(projectPath: string, platform: PlatformType, buildCommand: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Generate a file to render the component
|
|
19
|
+
* @param componentAbsPath - absolute path to component to render
|
|
20
|
+
* @param indexAbsPath - absolute path of index file to write
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateHomePage(componentAbsPath: string, indexAbsPath: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Generate a Welcome page based on a PlasmicConfig
|
|
26
|
+
* @param config - PlasmicConfig
|
|
27
|
+
* @param noPages - don't render links to pages
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
export declare function generateWelcomePage(config: any, platform: string): string;
|
|
31
|
+
export declare function getPlasmicConfig(projectPath: string, platform: PlatformType, scheme: string): Promise<any>;
|
|
26
32
|
export declare function ensureTsconfig(projectPath: string): Promise<void>;
|
|
27
33
|
export declare function ifTs(ts: JsOrTs, str: string): string;
|
package/dist/utils/file-utils.js
CHANGED
|
@@ -35,12 +35,11 @@ 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.ifTs = exports.ensureTsconfig = exports.
|
|
38
|
+
exports.ifTs = exports.ensureTsconfig = exports.getPlasmicConfig = exports.generateWelcomePage = exports.generateHomePage = exports.overwriteReadme = exports.writePlasmicLoaderJson = exports.stripExtension = exports.deleteGlob = void 0;
|
|
39
39
|
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 template_1 = require("../gatsby/template");
|
|
44
43
|
const readme_1 = require("../templates/readme");
|
|
45
44
|
const welcomePage_1 = require("../templates/welcomePage");
|
|
46
45
|
const lang_utils_1 = require("./lang-utils");
|
|
@@ -82,63 +81,6 @@ function writePlasmicLoaderJson(projectDir, projectId, projectApiToken) {
|
|
|
82
81
|
});
|
|
83
82
|
}
|
|
84
83
|
exports.writePlasmicLoaderJson = writePlasmicLoaderJson;
|
|
85
|
-
/**
|
|
86
|
-
* - [nextjs|gatsby, loader, '/' page exists] - remove index file
|
|
87
|
-
* - [nextjs|gatsby, loader, '/' Page DNE] - replace index file with Welcome page
|
|
88
|
-
* - [nextjs|gatsby, codegen, '/' page exists] - remove Next.js/Gatsby index file, preserve Plasmic index
|
|
89
|
-
* - [nextjs|gatsby, codegen, '/' page DNE] - replace index file with Welcome page
|
|
90
|
-
* - [react, codegen ] - replace App file with '/', Home, or Welcome page
|
|
91
|
-
* @returns
|
|
92
|
-
*/
|
|
93
|
-
function overwriteIndex(projectPath, platform, scheme) {
|
|
94
|
-
var _a;
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const isNextjs = platform === "nextjs";
|
|
97
|
-
const isGatsby = platform === "gatsby";
|
|
98
|
-
const isCra = platform === "react";
|
|
99
|
-
const config = yield getPlasmicConfig(projectPath, platform, scheme);
|
|
100
|
-
const plasmicFiles = lodash_1.default.map(lodash_1.default.flatMap(config.projects, (p) => p.components), (c) => c.importSpec.modulePath);
|
|
101
|
-
const isTypescript = ((_a = config === null || config === void 0 ? void 0 : config.code) === null || _a === void 0 ? void 0 : _a.lang) === "ts";
|
|
102
|
-
const pagesDir = (0, lang_utils_1.ensure)(isNextjs
|
|
103
|
-
? path.join(projectPath, "pages/")
|
|
104
|
-
: isGatsby
|
|
105
|
-
? path.join(projectPath, "src/pages/")
|
|
106
|
-
: isCra
|
|
107
|
-
? path.join(projectPath, "src/")
|
|
108
|
-
: undefined);
|
|
109
|
-
const indexBasename = isCra ? `App` : `index`;
|
|
110
|
-
const extension = isTypescript ? "tsx" : "jsx";
|
|
111
|
-
const indexAbsPath = path.join(pagesDir, `${indexBasename}.${extension}`);
|
|
112
|
-
// Delete existing index files
|
|
113
|
-
// - Skipping any Plasmic-managed files
|
|
114
|
-
// - Note: this only compares basenames, so it may have false positives
|
|
115
|
-
deleteGlob(path.join(pagesDir, `${indexBasename}.*`), plasmicFiles.map((f) => path.basename(f)));
|
|
116
|
-
// Special case: remove all Gatsby components (due to conflicting file names)
|
|
117
|
-
// TODO: find a better way to handle this issue
|
|
118
|
-
if (platform === "gatsby") {
|
|
119
|
-
// Delete the index file
|
|
120
|
-
deleteGlob(path.join(projectPath, "src/@(pages|components)/*.*"), [
|
|
121
|
-
// Files to ignore
|
|
122
|
-
...plasmicFiles.map((f) => path.basename(f)),
|
|
123
|
-
]);
|
|
124
|
-
// Create a very basic 404 page - `gatsby build` fails without it.
|
|
125
|
-
// We've deleted the components that the default 404 page depended
|
|
126
|
-
// on, so
|
|
127
|
-
yield fs_1.promises.writeFile(path.join(projectPath, "src/pages/404.js"), template_1.GATSBY_404);
|
|
128
|
-
}
|
|
129
|
-
// We're done if we can already render an index page
|
|
130
|
-
if ((isNextjs || isGatsby) &&
|
|
131
|
-
plasmicFiles.find((f) => f.includes("/index."))) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const homeFilePossibilities = glob_1.default.sync(path.join(projectPath, (0, lang_utils_1.ensureString)(config.srcDir), "**", "@(index|Home|home|Homepage).*"));
|
|
135
|
-
const content = isCra && homeFilePossibilities.length > 0
|
|
136
|
-
? generateHomePage(homeFilePossibilities[0], indexAbsPath)
|
|
137
|
-
: generateWelcomePage(config, platform);
|
|
138
|
-
yield fs_1.promises.writeFile(indexAbsPath, content);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
exports.overwriteIndex = overwriteIndex;
|
|
142
84
|
/**
|
|
143
85
|
* Overwrite the README file
|
|
144
86
|
* @param projectPath
|
|
@@ -175,6 +117,7 @@ export default App;
|
|
|
175
117
|
`;
|
|
176
118
|
return appjsContents;
|
|
177
119
|
}
|
|
120
|
+
exports.generateHomePage = generateHomePage;
|
|
178
121
|
/**
|
|
179
122
|
* Generate a Welcome page based on a PlasmicConfig
|
|
180
123
|
* @param config - PlasmicConfig
|
|
@@ -218,6 +161,7 @@ function generateWelcomePage(config, platform) {
|
|
|
218
161
|
const content = (0, welcomePage_1.WELCOME_PAGE)(hasPages, platform, hasPages ? getPageSection() : "");
|
|
219
162
|
return content;
|
|
220
163
|
}
|
|
164
|
+
exports.generateWelcomePage = generateWelcomePage;
|
|
221
165
|
function getPlasmicConfig(projectPath, platform, scheme) {
|
|
222
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
223
167
|
const isNextjs = platform === "nextjs";
|
|
@@ -235,6 +179,7 @@ function getPlasmicConfig(projectPath, platform, scheme) {
|
|
|
235
179
|
return JSON.parse(configStr.toString());
|
|
236
180
|
});
|
|
237
181
|
}
|
|
182
|
+
exports.getPlasmicConfig = getPlasmicConfig;
|
|
238
183
|
// Create tsconfig.json if it doesn't exist
|
|
239
184
|
// this will force Plasmic to recognize Typescript
|
|
240
185
|
function ensureTsconfig(projectPath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-plasmic-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.68",
|
|
4
4
|
"description": "Create Plasmic-powered React apps",
|
|
5
5
|
"main": "./dist/lib.js",
|
|
6
6
|
"types": "./dist/lib.d.ts",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"validate-npm-package-name": "^3.0.0",
|
|
56
56
|
"yargs": "^16.2.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "1d9e46447dea9fe47ae76c2e1a39e14dcab687e6"
|
|
59
59
|
}
|
package/src/gatsby/gatsby.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { createReadStream, existsSync, promises as fs } from "fs";
|
|
2
|
+
import L from "lodash";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import * as readline from "readline";
|
|
4
5
|
import { spawnOrFail } from "../utils/cmd-utils";
|
|
5
6
|
import { installCodegenDeps, runCodegenSync } from "../utils/codegen";
|
|
6
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
deleteGlob,
|
|
9
|
+
generateWelcomePage,
|
|
10
|
+
getPlasmicConfig,
|
|
11
|
+
ifTs,
|
|
12
|
+
} from "../utils/file-utils";
|
|
7
13
|
import { ensure } from "../utils/lang-utils";
|
|
8
14
|
import { installUpgrade } from "../utils/npm-utils";
|
|
9
15
|
import { CPAStrategy } from "../utils/strategy";
|
|
@@ -165,8 +171,31 @@ export const gatsbyStrategy: CPAStrategy = {
|
|
|
165
171
|
projectPath,
|
|
166
172
|
});
|
|
167
173
|
|
|
168
|
-
//
|
|
169
|
-
await
|
|
174
|
+
// Special case: remove all Gatsby components (due to conflicting file names)
|
|
175
|
+
const config = await getPlasmicConfig(projectPath, "gatsby", scheme);
|
|
176
|
+
const plasmicFiles = L.map(
|
|
177
|
+
L.flatMap(config.projects, (p) => p.components),
|
|
178
|
+
(c) => c.importSpec.modulePath
|
|
179
|
+
);
|
|
180
|
+
deleteGlob(path.join(projectPath, "src/@(pages|components)/*.*"), [
|
|
181
|
+
// Files to ignore
|
|
182
|
+
...plasmicFiles.map((f) => path.basename(f)),
|
|
183
|
+
]);
|
|
184
|
+
// Create a very basic 404 page - `gatsby build` fails without it.
|
|
185
|
+
// We've deleted the components that the default 404 page depended
|
|
186
|
+
// on, so
|
|
187
|
+
await fs.writeFile(
|
|
188
|
+
path.join(projectPath, `src/pages/404.${jsOrTs}x`),
|
|
189
|
+
GATSBY_404
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
// Make an index page if the project didn't have one.
|
|
193
|
+
if (!plasmicFiles.find((f) => f.includes("/index."))) {
|
|
194
|
+
await fs.writeFile(
|
|
195
|
+
path.join(projectPath, `src/pages/index.${jsOrTs}x`),
|
|
196
|
+
generateWelcomePage(config, "gatsby")
|
|
197
|
+
);
|
|
198
|
+
}
|
|
170
199
|
|
|
171
200
|
// Overwrite the wrapper files to wrap PlasmicRootProvider
|
|
172
201
|
const wrapperContent = wrapAppRootForCodegen();
|
package/src/nextjs/nextjs.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { promises as fs } from "fs";
|
|
2
|
+
import L from "lodash";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import { spawnOrFail } from "../utils/cmd-utils";
|
|
4
5
|
import { installCodegenDeps, runCodegenSync } from "../utils/codegen";
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
deleteGlob,
|
|
8
|
+
generateWelcomePage,
|
|
9
|
+
getPlasmicConfig,
|
|
10
|
+
} from "../utils/file-utils";
|
|
6
11
|
import { ensure } from "../utils/lang-utils";
|
|
7
12
|
import { installUpgrade } from "../utils/npm-utils";
|
|
8
13
|
import { CPAStrategy, GenerateFilesArgs } from "../utils/strategy";
|
|
9
14
|
import { makeCatchallPage_app_loader } from "./templates/app-loader/catchall-page";
|
|
15
|
+
import { makePlasmicHostPage_app_loader } from "./templates/app-loader/plasmic-host";
|
|
10
16
|
import { makePlasmicInit_app_loader } from "./templates/app-loader/plasmic-init";
|
|
11
17
|
import { makePlasmicInitClient_app_loader } from "./templates/app-loader/plasmic-init-client";
|
|
12
18
|
import { makeCustomApp_pages_codegen } from "./templates/pages-codegen/app";
|
|
13
19
|
import { makePlasmicHostPage_pages_codegen } from "./templates/pages-codegen/plasmic-host";
|
|
14
20
|
import { makeCatchallPage_pages_loader } from "./templates/pages-loader/catchall-page";
|
|
15
|
-
import { makePlasmicHostPage_app_loader } from "./templates/app-loader/plasmic-host";
|
|
16
21
|
import { makePlasmicHostPage_pages_loader } from "./templates/pages-loader/plasmic-host";
|
|
17
22
|
import { makePlasmicInit_pages_loader } from "./templates/pages-loader/plasmic-init";
|
|
18
23
|
|
|
@@ -173,8 +178,17 @@ async function generateFilesPagesDir(args: GenerateFilesArgs) {
|
|
|
173
178
|
projectPath,
|
|
174
179
|
});
|
|
175
180
|
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
|
|
181
|
+
// Make an index page if the project didn't have one.
|
|
182
|
+
const config = await getPlasmicConfig(projectPath, "nextjs", scheme);
|
|
183
|
+
const plasmicFiles = L.map(
|
|
184
|
+
L.flatMap(config.projects, (p) => p.components),
|
|
185
|
+
(c) => c.importSpec.modulePath
|
|
186
|
+
);
|
|
187
|
+
if (!plasmicFiles.find((f) => f.includes("/index."))) {
|
|
188
|
+
await fs.writeFile(
|
|
189
|
+
path.join(projectPath, "pages", `index.${jsOrTs}x`),
|
|
190
|
+
generateWelcomePage(config, "nextjs")
|
|
191
|
+
);
|
|
192
|
+
}
|
|
179
193
|
}
|
|
180
194
|
}
|
package/src/react/react.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import fs from "fs";
|
|
1
|
+
import { promises as fs } from "fs";
|
|
2
|
+
import glob from "glob";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import { spawnOrFail } from "../utils/cmd-utils";
|
|
4
5
|
import { installCodegenDeps, runCodegenSync } from "../utils/codegen";
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
deleteGlob,
|
|
8
|
+
generateHomePage,
|
|
9
|
+
generateWelcomePage,
|
|
10
|
+
getPlasmicConfig,
|
|
11
|
+
} from "../utils/file-utils";
|
|
12
|
+
import { ensureString } from "../utils/lang-utils";
|
|
6
13
|
import { installUpgrade } from "../utils/npm-utils";
|
|
7
14
|
import { CPAStrategy } from "../utils/strategy";
|
|
8
15
|
|
|
@@ -41,14 +48,29 @@ export const reactStrategy: CPAStrategy = {
|
|
|
41
48
|
if (scheme === "loader") {
|
|
42
49
|
// Nothing to do
|
|
43
50
|
} else {
|
|
51
|
+
// Delete existing entry point App.tsx and related test
|
|
52
|
+
deleteGlob(path.join(projectPath, "src", "App*"));
|
|
53
|
+
|
|
44
54
|
await runCodegenSync({
|
|
45
55
|
projectId,
|
|
46
56
|
projectApiToken,
|
|
47
57
|
projectPath,
|
|
48
58
|
});
|
|
49
59
|
|
|
50
|
-
//
|
|
51
|
-
await
|
|
60
|
+
// Pick a page for the entry point App.tsx page
|
|
61
|
+
const config = await getPlasmicConfig(projectPath, "react", scheme);
|
|
62
|
+
const pagesDir = path.join(projectPath, ensureString(config.srcDir));
|
|
63
|
+
const homeFilePossibilities = glob.sync(
|
|
64
|
+
path.join(pagesDir, "**", "@(index|Home|home|Homepage).*")
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// Overwrite App.tsx
|
|
68
|
+
const indexPath = path.join(projectPath, "src", `App.${jsOrTs}x`);
|
|
69
|
+
const content =
|
|
70
|
+
homeFilePossibilities.length > 0
|
|
71
|
+
? generateHomePage(homeFilePossibilities[0], indexPath)
|
|
72
|
+
: generateWelcomePage(config, "react");
|
|
73
|
+
await fs.writeFile(indexPath, content);
|
|
52
74
|
}
|
|
53
75
|
|
|
54
76
|
// Deactivate React.StrictMode from index.js or index.tsx
|
|
@@ -57,10 +79,10 @@ export const reactStrategy: CPAStrategy = {
|
|
|
57
79
|
"src",
|
|
58
80
|
`index.${jsOrTs === "js" ? "js" : "tsx"}`
|
|
59
81
|
);
|
|
60
|
-
let indexFile = fs.
|
|
82
|
+
let indexFile = (await fs.readFile(indexFileName)).toString();
|
|
61
83
|
indexFile = indexFile.replace("<React.StrictMode>", "");
|
|
62
84
|
indexFile = indexFile.replace("</React.StrictMode>", "");
|
|
63
|
-
fs.
|
|
85
|
+
await fs.writeFile(indexFileName, indexFile);
|
|
64
86
|
|
|
65
87
|
return;
|
|
66
88
|
},
|
package/src/utils/file-utils.ts
CHANGED
|
@@ -2,11 +2,10 @@ import { existsSync, promises as fs, unlinkSync } from "fs";
|
|
|
2
2
|
import glob from "glob";
|
|
3
3
|
import L from "lodash";
|
|
4
4
|
import * as path from "upath";
|
|
5
|
-
import { GATSBY_404 } from "../gatsby/template";
|
|
6
5
|
import { README } from "../templates/readme";
|
|
7
6
|
import { WELCOME_PAGE } from "../templates/welcomePage";
|
|
8
7
|
import { JsOrTs, PlatformType } from "../utils/types";
|
|
9
|
-
import { ensure
|
|
8
|
+
import { ensure } from "./lang-utils";
|
|
10
9
|
import { installUpgrade } from "./npm-utils";
|
|
11
10
|
|
|
12
11
|
/**
|
|
@@ -57,88 +56,6 @@ export async function writePlasmicLoaderJson(
|
|
|
57
56
|
await fs.writeFile(plasmicLoaderJson, JSON.stringify(content));
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
/**
|
|
61
|
-
* - [nextjs|gatsby, loader, '/' page exists] - remove index file
|
|
62
|
-
* - [nextjs|gatsby, loader, '/' Page DNE] - replace index file with Welcome page
|
|
63
|
-
* - [nextjs|gatsby, codegen, '/' page exists] - remove Next.js/Gatsby index file, preserve Plasmic index
|
|
64
|
-
* - [nextjs|gatsby, codegen, '/' page DNE] - replace index file with Welcome page
|
|
65
|
-
* - [react, codegen ] - replace App file with '/', Home, or Welcome page
|
|
66
|
-
* @returns
|
|
67
|
-
*/
|
|
68
|
-
export async function overwriteIndex(
|
|
69
|
-
projectPath: string,
|
|
70
|
-
platform: string,
|
|
71
|
-
scheme: string
|
|
72
|
-
): Promise<void> {
|
|
73
|
-
const isNextjs = platform === "nextjs";
|
|
74
|
-
const isGatsby = platform === "gatsby";
|
|
75
|
-
const isCra = platform === "react";
|
|
76
|
-
|
|
77
|
-
const config = await getPlasmicConfig(projectPath, platform, scheme);
|
|
78
|
-
const plasmicFiles = L.map(
|
|
79
|
-
L.flatMap(config.projects, (p) => p.components),
|
|
80
|
-
(c) => c.importSpec.modulePath
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const isTypescript = config?.code?.lang === "ts";
|
|
84
|
-
const pagesDir = ensure(
|
|
85
|
-
isNextjs
|
|
86
|
-
? path.join(projectPath, "pages/")
|
|
87
|
-
: isGatsby
|
|
88
|
-
? path.join(projectPath, "src/pages/")
|
|
89
|
-
: isCra
|
|
90
|
-
? path.join(projectPath, "src/")
|
|
91
|
-
: undefined
|
|
92
|
-
);
|
|
93
|
-
const indexBasename = isCra ? `App` : `index`;
|
|
94
|
-
const extension = isTypescript ? "tsx" : "jsx";
|
|
95
|
-
const indexAbsPath = path.join(pagesDir, `${indexBasename}.${extension}`);
|
|
96
|
-
|
|
97
|
-
// Delete existing index files
|
|
98
|
-
// - Skipping any Plasmic-managed files
|
|
99
|
-
// - Note: this only compares basenames, so it may have false positives
|
|
100
|
-
deleteGlob(
|
|
101
|
-
path.join(pagesDir, `${indexBasename}.*`),
|
|
102
|
-
plasmicFiles.map((f) => path.basename(f))
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
// Special case: remove all Gatsby components (due to conflicting file names)
|
|
106
|
-
// TODO: find a better way to handle this issue
|
|
107
|
-
if (platform === "gatsby") {
|
|
108
|
-
// Delete the index file
|
|
109
|
-
deleteGlob(path.join(projectPath, "src/@(pages|components)/*.*"), [
|
|
110
|
-
// Files to ignore
|
|
111
|
-
...plasmicFiles.map((f) => path.basename(f)),
|
|
112
|
-
]);
|
|
113
|
-
// Create a very basic 404 page - `gatsby build` fails without it.
|
|
114
|
-
// We've deleted the components that the default 404 page depended
|
|
115
|
-
// on, so
|
|
116
|
-
await fs.writeFile(path.join(projectPath, "src/pages/404.js"), GATSBY_404);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// We're done if we can already render an index page
|
|
120
|
-
if (
|
|
121
|
-
(isNextjs || isGatsby) &&
|
|
122
|
-
plasmicFiles.find((f) => f.includes("/index."))
|
|
123
|
-
) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const homeFilePossibilities = glob.sync(
|
|
128
|
-
path.join(
|
|
129
|
-
projectPath,
|
|
130
|
-
ensureString(config.srcDir),
|
|
131
|
-
"**",
|
|
132
|
-
"@(index|Home|home|Homepage).*"
|
|
133
|
-
)
|
|
134
|
-
);
|
|
135
|
-
const content =
|
|
136
|
-
isCra && homeFilePossibilities.length > 0
|
|
137
|
-
? generateHomePage(homeFilePossibilities[0], indexAbsPath)
|
|
138
|
-
: generateWelcomePage(config, platform);
|
|
139
|
-
await fs.writeFile(indexAbsPath, content);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
59
|
/**
|
|
143
60
|
* Overwrite the README file
|
|
144
61
|
* @param projectPath
|
|
@@ -161,7 +78,7 @@ export async function overwriteReadme(
|
|
|
161
78
|
* @param indexAbsPath - absolute path of index file to write
|
|
162
79
|
* @returns
|
|
163
80
|
*/
|
|
164
|
-
function generateHomePage(
|
|
81
|
+
export function generateHomePage(
|
|
165
82
|
componentAbsPath: string,
|
|
166
83
|
indexAbsPath: string
|
|
167
84
|
): string {
|
|
@@ -190,7 +107,7 @@ export default App;
|
|
|
190
107
|
* @param noPages - don't render links to pages
|
|
191
108
|
* @returns
|
|
192
109
|
*/
|
|
193
|
-
function generateWelcomePage(config: any, platform: string): string {
|
|
110
|
+
export function generateWelcomePage(config: any, platform: string): string {
|
|
194
111
|
let hasPages = false;
|
|
195
112
|
let pageComponents: any[];
|
|
196
113
|
let pagesDir: string;
|
|
@@ -233,9 +150,9 @@ function generateWelcomePage(config: any, platform: string): string {
|
|
|
233
150
|
return content;
|
|
234
151
|
}
|
|
235
152
|
|
|
236
|
-
async function getPlasmicConfig(
|
|
153
|
+
export async function getPlasmicConfig(
|
|
237
154
|
projectPath: string,
|
|
238
|
-
platform:
|
|
155
|
+
platform: PlatformType,
|
|
239
156
|
scheme: string
|
|
240
157
|
) {
|
|
241
158
|
const isNextjs = platform === "nextjs";
|
|
File without changes
|
|
File without changes
|