create-plasmic-app 0.0.167 → 0.0.169
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 -4
- package/cpa-out/gatsby-codegen-js/package.json +3 -2
- package/cpa-out/gatsby-codegen-js/plasmic.json +5 -8
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicButton.jsx +12 -12
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +18 -18
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +12 -16
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.jsx +1 -0
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicStyleTokensProvider.jsx +2 -2
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/{plasmic.module.css → plasmic.css} +89 -73
- package/cpa-out/gatsby-codegen-js/src/components/plasmic/{plasmic__default_style.module.css → plasmic__default_style.css} +16 -0
- package/cpa-out/gatsby-codegen-ts/package.json +3 -2
- package/cpa-out/gatsby-codegen-ts/plasmic.json +5 -8
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicButton.tsx +12 -12
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +18 -18
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +12 -16
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx +1 -1
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicStyleTokensProvider.tsx +2 -2
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/{plasmic.module.css → plasmic.css} +89 -73
- package/cpa-out/gatsby-codegen-ts/src/components/plasmic/{plasmic__default_style.module.css → plasmic__default_style.css} +16 -0
- package/cpa-out/gatsby-loader-js/package.json +1 -1
- package/cpa-out/gatsby-loader-ts/package.json +1 -1
- package/cpa-out/nextjs-app-codegen-js/app/dynamic/[slug]/page.jsx +5 -5
- package/cpa-out/nextjs-app-codegen-js/app/robots.js +24 -0
- package/cpa-out/nextjs-app-codegen-js/app/sitemap.js +38 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +2 -2
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPageServer.jsx +2 -2
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/plasmic.css +16 -0
- package/cpa-out/nextjs-app-codegen-js/components/plasmic/plasmic__default_style.css +16 -0
- package/cpa-out/nextjs-app-codegen-js/package.json +7 -6
- package/cpa-out/nextjs-app-codegen-js/plasmic.json +3 -6
- package/cpa-out/nextjs-app-codegen-ts/app/dynamic/[slug]/page.tsx +8 -11
- package/cpa-out/nextjs-app-codegen-ts/app/page.tsx +4 -4
- package/cpa-out/nextjs-app-codegen-ts/app/robots.ts +25 -0
- package/cpa-out/nextjs-app-codegen-ts/app/sitemap.ts +41 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +2 -2
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPageServer.tsx +7 -13
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepageServer.tsx +5 -11
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/plasmic.css +16 -0
- package/cpa-out/nextjs-app-codegen-ts/components/plasmic/plasmic__default_style.css +16 -0
- package/cpa-out/nextjs-app-codegen-ts/package.json +7 -6
- package/cpa-out/nextjs-app-codegen-ts/plasmic.json +3 -6
- package/cpa-out/nextjs-app-loader-js/app/robots.js +24 -0
- package/cpa-out/nextjs-app-loader-js/app/sitemap.js +29 -0
- package/cpa-out/nextjs-app-loader-js/package.json +5 -5
- package/cpa-out/nextjs-app-loader-ts/app/layout.tsx +1 -5
- package/cpa-out/nextjs-app-loader-ts/app/robots.ts +25 -0
- package/cpa-out/nextjs-app-loader-ts/app/sitemap.ts +30 -0
- package/cpa-out/nextjs-app-loader-ts/package.json +5 -5
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +2 -2
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/plasmic.css +16 -0
- package/cpa-out/nextjs-pages-codegen-js/components/plasmic/plasmic__default_style.css +16 -0
- package/cpa-out/nextjs-pages-codegen-js/package.json +7 -6
- package/cpa-out/nextjs-pages-codegen-js/pages/robots.txt.js +25 -0
- package/cpa-out/nextjs-pages-codegen-js/pages/sitemap.xml.js +53 -0
- package/cpa-out/nextjs-pages-codegen-js/plasmic.json +3 -6
- package/cpa-out/nextjs-pages-codegen-js/styles/Home.module.css +8 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +2 -2
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/plasmic.css +16 -0
- package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/plasmic__default_style.css +16 -0
- package/cpa-out/nextjs-pages-codegen-ts/package.json +7 -6
- package/cpa-out/nextjs-pages-codegen-ts/pages/robots.txt.ts +27 -0
- package/cpa-out/nextjs-pages-codegen-ts/pages/sitemap.xml.ts +56 -0
- package/cpa-out/nextjs-pages-codegen-ts/plasmic.json +3 -6
- package/cpa-out/nextjs-pages-codegen-ts/styles/Home.module.css +8 -0
- package/cpa-out/nextjs-pages-loader-js/package.json +5 -5
- package/cpa-out/nextjs-pages-loader-js/pages/robots.txt.js +25 -0
- package/cpa-out/nextjs-pages-loader-js/pages/sitemap.xml.js +46 -0
- package/cpa-out/nextjs-pages-loader-js/styles/Home.module.css +8 -0
- package/cpa-out/nextjs-pages-loader-ts/package.json +5 -5
- package/cpa-out/nextjs-pages-loader-ts/pages/robots.txt.ts +27 -0
- package/cpa-out/nextjs-pages-loader-ts/pages/sitemap.xml.ts +47 -0
- package/cpa-out/nextjs-pages-loader-ts/styles/Home.module.css +8 -0
- package/cpa-out/react-codegen-js/package.json +3 -2
- package/cpa-out/react-codegen-js/plasmic.json +3 -6
- package/cpa-out/react-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +2 -2
- package/cpa-out/react-codegen-js/src/components/plasmic/create_plasmic_app/plasmic.css +16 -0
- package/cpa-out/react-codegen-js/src/components/plasmic/plasmic__default_style.css +16 -0
- package/cpa-out/react-codegen-ts/package.json +3 -2
- package/cpa-out/react-codegen-ts/plasmic.json +3 -6
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +2 -2
- package/cpa-out/react-codegen-ts/src/components/plasmic/create_plasmic_app/plasmic.css +16 -0
- package/cpa-out/react-codegen-ts/src/components/plasmic/plasmic__default_style.css +16 -0
- package/cpa-out/tanstack-codegen-ts/package.json +8 -13
- package/cpa-out/tanstack-codegen-ts/plasmic.json +3 -6
- package/cpa-out/tanstack-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +3 -3
- package/cpa-out/tanstack-codegen-ts/src/components/plasmic/plasmic__default_style.css +16 -0
- package/cpa-out/tanstack-codegen-ts/src/routeTree.gen.ts +13 -13
- package/cpa-out/tanstack-codegen-ts/src/routes/dynamic/$slug/index.tsx +2 -2
- package/dist/gatsby/gatsby.js +23 -17
- package/dist/index.js +6 -0
- package/dist/lib.d.ts +2 -1
- package/dist/lib.js +9 -4
- package/dist/nextjs/nextjs.js +30 -6
- package/dist/nextjs/templates/app-seo.d.ts +4 -0
- package/dist/nextjs/templates/app-seo.js +92 -0
- package/dist/nextjs/templates/pages-seo.d.ts +4 -0
- package/dist/nextjs/templates/pages-seo.js +121 -0
- package/dist/react/react.js +9 -4
- package/dist/tanstack/tanstack.js +12 -5
- package/dist/utils/codegen.d.ts +3 -0
- package/dist/utils/codegen.js +17 -4
- package/dist/utils/file-utils.d.ts +2 -2
- package/dist/utils/file-utils.js +2 -1
- package/dist/utils/npm-utils.d.ts +24 -9
- package/dist/utils/npm-utils.js +66 -21
- package/dist/utils/strategy.d.ts +5 -1
- package/dist/utils/types.d.ts +1 -0
- package/package.json +2 -4
- package/run-cpa.ts +17 -6
- package/src/gatsby/gatsby.ts +40 -22
- package/src/index.ts +9 -0
- package/src/lib.ts +18 -6
- package/src/nextjs/nextjs.ts +85 -7
- package/src/nextjs/templates/app-seo.ts +104 -0
- package/src/nextjs/templates/pages-seo.ts +131 -0
- package/src/react/react.ts +11 -4
- package/src/tanstack/tanstack.ts +19 -6
- package/src/utils/codegen.ts +28 -6
- package/src/utils/file-utils.ts +6 -2
- package/src/utils/npm-utils.ts +76 -23
- package/src/utils/strategy.ts +10 -1
- package/src/utils/types.ts +1 -0
package/dist/nextjs/nextjs.js
CHANGED
|
@@ -28,35 +28,45 @@ const catchall_page_1 = require("./templates/app-loader/catchall-page");
|
|
|
28
28
|
const plasmic_host_2 = require("./templates/app-loader/plasmic-host");
|
|
29
29
|
const plasmic_init_1 = require("./templates/app-loader/plasmic-init");
|
|
30
30
|
const plasmic_init_client_2 = require("./templates/app-loader/plasmic-init-client");
|
|
31
|
+
const app_seo_1 = require("./templates/app-seo");
|
|
31
32
|
const app_1 = require("./templates/pages-codegen/app");
|
|
32
33
|
const plasmic_host_3 = require("./templates/pages-codegen/plasmic-host");
|
|
33
34
|
const catchall_page_2 = require("./templates/pages-loader/catchall-page");
|
|
34
35
|
const plasmic_host_4 = require("./templates/pages-loader/plasmic-host");
|
|
35
36
|
const plasmic_init_2 = require("./templates/pages-loader/plasmic-init");
|
|
37
|
+
const pages_seo_1 = require("./templates/pages-seo");
|
|
36
38
|
exports.nextjsStrategy = {
|
|
37
39
|
create: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
40
|
var _a;
|
|
39
|
-
const { projectPath, template, jsOrTs, platformOptions } = args;
|
|
41
|
+
const { projectPath, template, jsOrTs, platformOptions, packageManager } = args;
|
|
40
42
|
const typescriptArg = `--${jsOrTs}`;
|
|
41
43
|
const experimentalAppArg = ((_a = platformOptions.nextjs) === null || _a === void 0 ? void 0 : _a.appDir)
|
|
42
44
|
? "--app"
|
|
43
45
|
: "--no-app";
|
|
44
46
|
const templateArg = template ? ` --example ${template}` : "";
|
|
47
|
+
const isYarnBerry = packageManager === "yarn2";
|
|
45
48
|
// NOTE: Not using create-next-app@latest to keep major version bumps deliberate
|
|
46
49
|
const createCommand = `npx create-next-app@16 ${projectPath} ${typescriptArg} ${experimentalAppArg} ${templateArg}` +
|
|
47
|
-
` --eslint --no-src-dir --import-alias "@/*" --no-tailwind
|
|
50
|
+
` --use-${(0, npm_utils_1.packageManagerCommand)(packageManager)} --eslint --no-src-dir --import-alias "@/*" --no-tailwind` +
|
|
51
|
+
// Berry must install into the project we set up below, not the default PnP one
|
|
52
|
+
(isYarnBerry ? " --skip-install" : "");
|
|
48
53
|
// Default Next.js starter already supports Typescript
|
|
49
54
|
// See where we `touch tsconfig.json` later on
|
|
50
55
|
yield (0, cmd_utils_1.spawnOrFail)(createCommand);
|
|
56
|
+
if (isYarnBerry) {
|
|
57
|
+
yield (0, npm_utils_1.initYarnBerryProject)(projectPath);
|
|
58
|
+
yield (0, cmd_utils_1.spawnOrFail)("yarn install", projectPath);
|
|
59
|
+
}
|
|
51
60
|
}),
|
|
52
|
-
installDeps: ({ scheme, projectPath }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
installDeps: ({ scheme, projectPath, packageManager }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
62
|
if (scheme === "loader") {
|
|
54
63
|
return yield (0, npm_utils_1.installUpgrade)("@plasmicapp/loader-nextjs", {
|
|
55
64
|
workingDir: projectPath,
|
|
65
|
+
packageManager,
|
|
56
66
|
});
|
|
57
67
|
}
|
|
58
68
|
else {
|
|
59
|
-
return yield (0, codegen_1.installCodegenDeps)({ projectPath });
|
|
69
|
+
return yield (0, codegen_1.installCodegenDeps)({ projectPath, packageManager });
|
|
60
70
|
}
|
|
61
71
|
}),
|
|
62
72
|
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -121,9 +131,11 @@ a {
|
|
|
121
131
|
}
|
|
122
132
|
function generateFilesAppDir(args) {
|
|
123
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
const { projectPath, scheme, jsOrTs, projectId, projectApiToken } = args;
|
|
134
|
+
const { projectPath, scheme, jsOrTs, projectId, projectApiToken, packageManager, } = args;
|
|
125
135
|
// Delete existing pages
|
|
126
136
|
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "app", "page.*"));
|
|
137
|
+
// ./app/robots.ts
|
|
138
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", `robots.${jsOrTs}`), (0, app_seo_1.makeRobots_app)(jsOrTs));
|
|
127
139
|
if (scheme === "loader") {
|
|
128
140
|
// ./plasmic-init.ts
|
|
129
141
|
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")));
|
|
@@ -135,6 +147,8 @@ function generateFilesAppDir(args) {
|
|
|
135
147
|
// ./app/[[...catchall]]/page.tsx
|
|
136
148
|
yield fs_1.promises.mkdir(path_1.default.join(projectPath, "app", "[[...catchall]]"));
|
|
137
149
|
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", "[[...catchall]]", `page.${jsOrTs}x`), (0, catchall_page_1.makeCatchallPage_app_loader)(jsOrTs));
|
|
150
|
+
// ./app/sitemap.ts
|
|
151
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", `sitemap.${jsOrTs}`), (0, app_seo_1.makeSitemap_app_loader)(jsOrTs));
|
|
138
152
|
}
|
|
139
153
|
else {
|
|
140
154
|
// ./plasmic-init-client.tsx
|
|
@@ -150,7 +164,10 @@ function generateFilesAppDir(args) {
|
|
|
150
164
|
projectId,
|
|
151
165
|
projectApiToken,
|
|
152
166
|
projectPath,
|
|
167
|
+
packageManager,
|
|
153
168
|
});
|
|
169
|
+
// ./app/sitemap.ts
|
|
170
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", `sitemap.${jsOrTs}`), (0, app_seo_1.makeSitemap_app_codegen)(jsOrTs));
|
|
154
171
|
// Read plasmic.json so we can wire each top-level project's plasmic.css
|
|
155
172
|
// import directly into the root layout template.
|
|
156
173
|
const config = yield (0, file_utils_1.getPlasmicConfig)(projectPath, "nextjs", scheme);
|
|
@@ -174,9 +191,11 @@ function generateFilesAppDir(args) {
|
|
|
174
191
|
}
|
|
175
192
|
function generateFilesPagesDir(args) {
|
|
176
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
const { projectPath, scheme, jsOrTs, projectId, projectApiToken } = args;
|
|
194
|
+
const { projectPath, scheme, jsOrTs, projectId, projectApiToken, packageManager, } = args;
|
|
178
195
|
// Delete existing pages
|
|
179
196
|
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "pages", "*.*"));
|
|
197
|
+
// ./pages/robots.txt.ts
|
|
198
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `robots.txt.${jsOrTs}`), (0, pages_seo_1.makeRobots_pages)(jsOrTs));
|
|
180
199
|
if (scheme === "loader") {
|
|
181
200
|
// ./plasmic-init.ts
|
|
182
201
|
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, "Missing projectApiToken")));
|
|
@@ -184,6 +203,8 @@ function generateFilesPagesDir(args) {
|
|
|
184
203
|
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `plasmic-host.${jsOrTs}x`), (0, plasmic_host_4.makePlasmicHostPage_pages_loader)());
|
|
185
204
|
// ./pages/[[...catchall]].tsx
|
|
186
205
|
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `[[...catchall]].${jsOrTs}x`), (0, catchall_page_2.makeCatchallPage_pages_loader)(jsOrTs));
|
|
206
|
+
// ./pages/sitemap.xml.ts
|
|
207
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `sitemap.xml.${jsOrTs}`), (0, pages_seo_1.makeSitemap_pages_loader)(jsOrTs));
|
|
187
208
|
}
|
|
188
209
|
else {
|
|
189
210
|
// ./pages/plasmic-host.tsx
|
|
@@ -196,7 +217,10 @@ function generateFilesPagesDir(args) {
|
|
|
196
217
|
projectId,
|
|
197
218
|
projectApiToken,
|
|
198
219
|
projectPath,
|
|
220
|
+
packageManager,
|
|
199
221
|
});
|
|
222
|
+
// ./pages/sitemap.xml.ts
|
|
223
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `sitemap.xml.${jsOrTs}`), (0, pages_seo_1.makeSitemap_pages_codegen)(jsOrTs));
|
|
200
224
|
// Read plasmic.json so we can wire each top-level project's plasmic.css
|
|
201
225
|
// import directly into the _app template.
|
|
202
226
|
const config = yield (0, file_utils_1.getPlasmicConfig)(projectPath, "nextjs", scheme);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeRobots_app = exports.makeSitemap_app_codegen = exports.makeSitemap_app_loader = void 0;
|
|
4
|
+
const file_utils_1 = require("../../utils/file-utils");
|
|
5
|
+
const getSiteUrl = `// Set NEXT_PUBLIC_SITE_URL to pin the origin and keep this route static;
|
|
6
|
+
// otherwise it is derived per-request, which opts the route out of prerendering.
|
|
7
|
+
async function getSiteUrl() {
|
|
8
|
+
if (process.env.NEXT_PUBLIC_SITE_URL) {
|
|
9
|
+
return process.env.NEXT_PUBLIC_SITE_URL;
|
|
10
|
+
}
|
|
11
|
+
if (process.env.VERCEL_PROJECT_PRODUCTION_URL) {
|
|
12
|
+
return \`https://\${process.env.VERCEL_PROJECT_PRODUCTION_URL}\`;
|
|
13
|
+
}
|
|
14
|
+
const h = await headers();
|
|
15
|
+
const proto = h.get("x-forwarded-proto") ?? "http";
|
|
16
|
+
return \`\${proto}://\${h.get("x-forwarded-host") ?? h.get("host")}\`;
|
|
17
|
+
}`;
|
|
18
|
+
function makeHeader(jsOrTs) {
|
|
19
|
+
return `${(0, file_utils_1.ifTs)(jsOrTs, `import type { MetadataRoute } from "next";\n`)}import { headers } from "next/headers";\n`;
|
|
20
|
+
}
|
|
21
|
+
function makeSignature(jsOrTs) {
|
|
22
|
+
return `export default async function sitemap()${(0, file_utils_1.ifTs)(jsOrTs, ": Promise<MetadataRoute.Sitemap>")} {`;
|
|
23
|
+
}
|
|
24
|
+
function makeSitemap_app_loader(jsOrTs) {
|
|
25
|
+
return `import { PLASMIC } from "@/plasmic-init";
|
|
26
|
+
${makeHeader(jsOrTs)}
|
|
27
|
+
export const revalidate = 60;
|
|
28
|
+
|
|
29
|
+
${getSiteUrl}
|
|
30
|
+
|
|
31
|
+
${makeSignature(jsOrTs)}
|
|
32
|
+
const siteUrl = await getSiteUrl();
|
|
33
|
+
|
|
34
|
+
// fetchPages() drops pages whose path takes a param, e.g. "/blog/[slug]".
|
|
35
|
+
const pages = await PLASMIC.fetchPages();
|
|
36
|
+
|
|
37
|
+
return pages.map((page) => ({
|
|
38
|
+
url: new URL(page.path, siteUrl).toString(),
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
exports.makeSitemap_app_loader = makeSitemap_app_loader;
|
|
44
|
+
function makeSitemap_app_codegen(jsOrTs) {
|
|
45
|
+
const projects = jsOrTs === "ts"
|
|
46
|
+
? `(plasmicJson.projects as {
|
|
47
|
+
components: { componentType: string; path?: string }[];
|
|
48
|
+
}[])`
|
|
49
|
+
: "plasmicJson.projects";
|
|
50
|
+
return `${makeHeader(jsOrTs)}import plasmicJson from "../plasmic.json";
|
|
51
|
+
|
|
52
|
+
${getSiteUrl}
|
|
53
|
+
|
|
54
|
+
${makeSignature(jsOrTs)}
|
|
55
|
+
const siteUrl = await getSiteUrl();
|
|
56
|
+
|
|
57
|
+
return ${projects}
|
|
58
|
+
.flatMap((project) => project.components)
|
|
59
|
+
.flatMap((component) =>
|
|
60
|
+
component.componentType === "page" &&
|
|
61
|
+
component.path &&
|
|
62
|
+
!component.path.includes("[")
|
|
63
|
+
? [
|
|
64
|
+
{
|
|
65
|
+
// next.config sets trailingSlash.
|
|
66
|
+
url: new URL(
|
|
67
|
+
component.path.replace(/\\/?$/, "/"),
|
|
68
|
+
siteUrl
|
|
69
|
+
).toString(),
|
|
70
|
+
},
|
|
71
|
+
]
|
|
72
|
+
: []
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
exports.makeSitemap_app_codegen = makeSitemap_app_codegen;
|
|
78
|
+
function makeRobots_app(jsOrTs) {
|
|
79
|
+
return `${makeHeader(jsOrTs)}
|
|
80
|
+
${getSiteUrl}
|
|
81
|
+
|
|
82
|
+
export default async function robots()${(0, file_utils_1.ifTs)(jsOrTs, ": Promise<MetadataRoute.Robots>")} {
|
|
83
|
+
const siteUrl = await getSiteUrl();
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
rules: { userAgent: "*", allow: "/" },
|
|
87
|
+
sitemap: new URL("/sitemap.xml", siteUrl).toString(),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
exports.makeRobots_app = makeRobots_app;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeRobots_pages = exports.makeSitemap_pages_codegen = exports.makeSitemap_pages_loader = void 0;
|
|
4
|
+
const file_utils_1 = require("../../utils/file-utils");
|
|
5
|
+
const siteUrl = ` // Set NEXT_PUBLIC_SITE_URL to pin the origin;
|
|
6
|
+
// otherwise it is derived per-request from the request headers.
|
|
7
|
+
const siteUrl =
|
|
8
|
+
process.env.NEXT_PUBLIC_SITE_URL ??
|
|
9
|
+
(process.env.VERCEL_PROJECT_PRODUCTION_URL
|
|
10
|
+
? \`https://\${process.env.VERCEL_PROJECT_PRODUCTION_URL}\`
|
|
11
|
+
: \`\${req.headers["x-forwarded-proto"] ?? "http"}://\${
|
|
12
|
+
req.headers["x-forwarded-host"] ?? req.headers.host
|
|
13
|
+
}\`);`;
|
|
14
|
+
function makeHeader(jsOrTs) {
|
|
15
|
+
return (0, file_utils_1.ifTs)(jsOrTs, `import type { GetServerSideProps } from "next";\n`);
|
|
16
|
+
}
|
|
17
|
+
function makeSignature(jsOrTs) {
|
|
18
|
+
return `export const getServerSideProps${(0, file_utils_1.ifTs)(jsOrTs, ": GetServerSideProps")} = async ({ req, res }) => {`;
|
|
19
|
+
}
|
|
20
|
+
function makeSitemapXml(jsOrTs) {
|
|
21
|
+
return `function escapeXml(str${(0, file_utils_1.ifTs)(jsOrTs, ": string")}) {
|
|
22
|
+
return str
|
|
23
|
+
.replace(/&/g, "&")
|
|
24
|
+
.replace(/</g, "<")
|
|
25
|
+
.replace(/>/g, ">")
|
|
26
|
+
.replace(/"/g, """)
|
|
27
|
+
.replace(/'/g, "'");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function makeSitemapXml(urls${(0, file_utils_1.ifTs)(jsOrTs, ": string[]")}) {
|
|
31
|
+
const entries = urls.map(
|
|
32
|
+
(url) => \` <url><loc>\${escapeXml(url)}</loc></url>\`
|
|
33
|
+
);
|
|
34
|
+
return \`<?xml version="1.0" encoding="UTF-8"?>
|
|
35
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
36
|
+
\${entries.join("\\n")}
|
|
37
|
+
</urlset>
|
|
38
|
+
\`;
|
|
39
|
+
}`;
|
|
40
|
+
}
|
|
41
|
+
function makeSitemap_pages_loader(jsOrTs) {
|
|
42
|
+
return `import { PLASMIC } from "@/plasmic-init";
|
|
43
|
+
${makeHeader(jsOrTs)}
|
|
44
|
+
${makeSitemapXml(jsOrTs)}
|
|
45
|
+
|
|
46
|
+
${makeSignature(jsOrTs)}
|
|
47
|
+
${siteUrl}
|
|
48
|
+
|
|
49
|
+
// fetchPages() drops pages whose path takes a param, e.g. "/blog/[slug]".
|
|
50
|
+
const pages = await PLASMIC.fetchPages();
|
|
51
|
+
const urls = pages.map((page) => new URL(page.path, siteUrl).toString());
|
|
52
|
+
|
|
53
|
+
res.setHeader("Content-Type", "application/xml; charset=utf-8");
|
|
54
|
+
res.write(makeSitemapXml(urls));
|
|
55
|
+
res.end();
|
|
56
|
+
return { props: {} };
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default function Sitemap() {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
exports.makeSitemap_pages_loader = makeSitemap_pages_loader;
|
|
65
|
+
function makeSitemap_pages_codegen(jsOrTs) {
|
|
66
|
+
const projects = jsOrTs === "ts"
|
|
67
|
+
? `(plasmicJson.projects as {
|
|
68
|
+
components: { componentType: string; path?: string }[];
|
|
69
|
+
}[])`
|
|
70
|
+
: "plasmicJson.projects";
|
|
71
|
+
return `${makeHeader(jsOrTs)}import plasmicJson from "../plasmic.json";
|
|
72
|
+
|
|
73
|
+
${makeSitemapXml(jsOrTs)}
|
|
74
|
+
|
|
75
|
+
${makeSignature(jsOrTs)}
|
|
76
|
+
${siteUrl}
|
|
77
|
+
|
|
78
|
+
const urls = ${projects}
|
|
79
|
+
.flatMap((project) => project.components)
|
|
80
|
+
.flatMap((component) =>
|
|
81
|
+
component.componentType === "page" &&
|
|
82
|
+
component.path &&
|
|
83
|
+
!component.path.includes("[")
|
|
84
|
+
? // next.config sets trailingSlash.
|
|
85
|
+
[new URL(component.path.replace(/\\/?$/, "/"), siteUrl).toString()]
|
|
86
|
+
: []
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
res.setHeader("Content-Type", "application/xml; charset=utf-8");
|
|
90
|
+
res.write(makeSitemapXml(urls));
|
|
91
|
+
res.end();
|
|
92
|
+
return { props: {} };
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default function Sitemap() {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
exports.makeSitemap_pages_codegen = makeSitemap_pages_codegen;
|
|
101
|
+
function makeRobots_pages(jsOrTs) {
|
|
102
|
+
return `${(0, file_utils_1.ifTs)(jsOrTs, `import type { GetServerSideProps } from "next";\n\n`)}${makeSignature(jsOrTs)}
|
|
103
|
+
${siteUrl}
|
|
104
|
+
|
|
105
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
106
|
+
res.write(
|
|
107
|
+
\`User-agent: *\\nAllow: /\\n\\nSitemap: \${new URL(
|
|
108
|
+
"/sitemap.xml",
|
|
109
|
+
siteUrl
|
|
110
|
+
).toString()}\\n\`
|
|
111
|
+
);
|
|
112
|
+
res.end();
|
|
113
|
+
return { props: {} };
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default function Robots() {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
exports.makeRobots_pages = makeRobots_pages;
|
package/dist/react/react.js
CHANGED
|
@@ -22,7 +22,7 @@ const file_utils_1 = require("../utils/file-utils");
|
|
|
22
22
|
const npm_utils_1 = require("../utils/npm-utils");
|
|
23
23
|
exports.reactStrategy = {
|
|
24
24
|
create: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
const { projectPath, jsOrTs } = args;
|
|
25
|
+
const { projectPath, jsOrTs, packageManager } = args;
|
|
26
26
|
let { template } = args;
|
|
27
27
|
/* create-vite package checks if the targetDir doesn't exist then it creates the targetDir in the
|
|
28
28
|
current directory instead of the targetDir path. For example,
|
|
@@ -47,15 +47,19 @@ exports.reactStrategy = {
|
|
|
47
47
|
}
|
|
48
48
|
const templateArg = template ? ` --template ${template}` : "";
|
|
49
49
|
yield (0, cmd_utils_1.spawnOrFail)(`${createCommand}${templateArg}`);
|
|
50
|
+
if (packageManager === "yarn2") {
|
|
51
|
+
yield (0, npm_utils_1.initYarnBerryProject)(fullProjectPath);
|
|
52
|
+
}
|
|
50
53
|
}),
|
|
51
|
-
installDeps: ({ projectPath, scheme }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
installDeps: ({ projectPath, scheme, packageManager }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
55
|
if (scheme === "loader") {
|
|
53
56
|
return yield (0, npm_utils_1.installUpgrade)("@plasmicapp/loader-react", {
|
|
54
57
|
workingDir: projectPath,
|
|
58
|
+
packageManager,
|
|
55
59
|
});
|
|
56
60
|
}
|
|
57
61
|
else {
|
|
58
|
-
return yield (0, codegen_1.installCodegenDeps)({ projectPath });
|
|
62
|
+
return yield (0, codegen_1.installCodegenDeps)({ projectPath, packageManager });
|
|
59
63
|
}
|
|
60
64
|
}),
|
|
61
65
|
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -73,7 +77,7 @@ exports.reactStrategy = {
|
|
|
73
77
|
yield fs_1.promises.writeFile(tsconfigPath, tsconfigContent);
|
|
74
78
|
}
|
|
75
79
|
}),
|
|
76
|
-
generateFiles: ({ scheme, projectApiToken, projectId, projectPath, jsOrTs, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
generateFiles: ({ scheme, projectApiToken, projectId, projectPath, jsOrTs, packageManager, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
81
|
if (scheme === "loader") {
|
|
78
82
|
// Nothing to do
|
|
79
83
|
}
|
|
@@ -84,6 +88,7 @@ exports.reactStrategy = {
|
|
|
84
88
|
projectId,
|
|
85
89
|
projectApiToken,
|
|
86
90
|
projectPath,
|
|
91
|
+
packageManager,
|
|
87
92
|
});
|
|
88
93
|
// Pick a page for the entry point App.tsx page
|
|
89
94
|
const config = yield (0, file_utils_1.getPlasmicConfig)(projectPath, "react", scheme);
|
|
@@ -23,7 +23,7 @@ const plasmic_host_1 = require("./templates/file-router/plasmic-host");
|
|
|
23
23
|
const root_1 = require("./templates/file-router/root");
|
|
24
24
|
exports.tanstackStrategy = {
|
|
25
25
|
create: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
const { projectPath, template } = args;
|
|
26
|
+
const { projectPath, template, packageManager } = args;
|
|
27
27
|
if (template) {
|
|
28
28
|
console.warn(`Warning: Ignoring template '${template}' (argument is not supported by TanStack).`);
|
|
29
29
|
}
|
|
@@ -46,24 +46,30 @@ exports.tanstackStrategy = {
|
|
|
46
46
|
"--framework React",
|
|
47
47
|
"--router-only",
|
|
48
48
|
"--no-toolchain",
|
|
49
|
-
|
|
49
|
+
`--package-manager ${(0, npm_utils_1.packageManagerCommand)(packageManager)}`,
|
|
50
50
|
"--git",
|
|
51
51
|
"--no-intent",
|
|
52
52
|
"--no-examples",
|
|
53
53
|
"--yes",
|
|
54
|
+
// Berry must install into the project we set up below, not the default PnP one
|
|
55
|
+
...(packageManager === "yarn2" ? ["--no-install"] : []),
|
|
54
56
|
].join(" ");
|
|
55
57
|
yield (0, cmd_utils_1.spawnOrFail)(createCommand);
|
|
58
|
+
if (packageManager === "yarn2") {
|
|
59
|
+
yield (0, npm_utils_1.initYarnBerryProject)(fullProjectPath);
|
|
60
|
+
}
|
|
56
61
|
// Install peer-dep of @tanstack/react-router-with-query
|
|
57
62
|
yield (0, npm_utils_1.installUpgrade)("@tanstack/react-query", {
|
|
58
63
|
workingDir: projectPath,
|
|
64
|
+
packageManager,
|
|
59
65
|
});
|
|
60
66
|
}),
|
|
61
|
-
installDeps: ({ scheme, projectPath }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
installDeps: ({ scheme, projectPath, packageManager }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
68
|
if (scheme === "loader") {
|
|
63
69
|
throw new Error("Plasmic loader scheme is not supported for TanStack platform. Please use the codegen scheme instead.");
|
|
64
70
|
}
|
|
65
71
|
else {
|
|
66
|
-
return yield (0, codegen_1.installCodegenDeps)({ projectPath });
|
|
72
|
+
return yield (0, codegen_1.installCodegenDeps)({ projectPath, packageManager });
|
|
67
73
|
}
|
|
68
74
|
}),
|
|
69
75
|
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -96,7 +102,7 @@ exports.tanstackStrategy = {
|
|
|
96
102
|
};
|
|
97
103
|
function generateFilesFileRouterTemplate(args) {
|
|
98
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
const { projectPath, scheme, projectId, projectApiToken } = args;
|
|
105
|
+
const { projectPath, scheme, projectId, projectApiToken, packageManager } = args;
|
|
100
106
|
// Delete existing pages
|
|
101
107
|
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "src/routes", "*.*"));
|
|
102
108
|
if (scheme === "loader") {
|
|
@@ -115,6 +121,7 @@ function generateFilesFileRouterTemplate(args) {
|
|
|
115
121
|
projectId,
|
|
116
122
|
projectApiToken,
|
|
117
123
|
projectPath,
|
|
124
|
+
packageManager,
|
|
118
125
|
});
|
|
119
126
|
}
|
|
120
127
|
});
|
package/dist/utils/codegen.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { PackageManagerType } from "../utils/types";
|
|
1
2
|
export declare function installCodegenDeps(opts: {
|
|
2
3
|
projectPath: string;
|
|
4
|
+
packageManager: PackageManagerType;
|
|
3
5
|
}): Promise<boolean>;
|
|
4
6
|
export declare function runCodegenSync(opts: {
|
|
5
7
|
projectId: string;
|
|
6
8
|
projectApiToken: string | undefined;
|
|
7
9
|
projectPath: string;
|
|
10
|
+
packageManager: PackageManagerType;
|
|
8
11
|
}): Promise<void>;
|
package/dist/utils/codegen.js
CHANGED
|
@@ -8,26 +8,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.runCodegenSync = exports.installCodegenDeps = void 0;
|
|
16
|
+
const fs_1 = require("fs");
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
13
18
|
const lib_1 = require("../lib");
|
|
14
19
|
const cmd_utils_1 = require("../utils/cmd-utils");
|
|
15
20
|
const npm_utils_1 = require("../utils/npm-utils");
|
|
16
21
|
function installCodegenDeps(opts) {
|
|
17
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const { projectPath } = opts;
|
|
19
|
-
|
|
23
|
+
const { projectPath, packageManager } = opts;
|
|
24
|
+
// Generated pages import @plasmicapp/host directly
|
|
25
|
+
return yield (0, npm_utils_1.installUpgrade)("@plasmicapp/cli @plasmicapp/host", {
|
|
26
|
+
workingDir: projectPath,
|
|
27
|
+
packageManager,
|
|
28
|
+
});
|
|
20
29
|
});
|
|
21
30
|
}
|
|
22
31
|
exports.installCodegenDeps = installCodegenDeps;
|
|
23
32
|
function runCodegenSync(opts) {
|
|
24
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const { projectId, projectApiToken, projectPath } = opts;
|
|
34
|
+
const { projectId, projectApiToken, projectPath, packageManager } = opts;
|
|
26
35
|
(0, lib_1.banner)("SYNCING PLASMIC COMPONENTS");
|
|
27
36
|
const project = projectApiToken
|
|
28
37
|
? `${projectId}:${projectApiToken}`
|
|
29
38
|
: projectId;
|
|
30
|
-
yield (0, cmd_utils_1.spawnOrFail)(
|
|
39
|
+
yield (0, cmd_utils_1.spawnOrFail)(`${(0, npm_utils_1.packageManagerExec)(packageManager)} plasmic sync --yes -p ${project}`, projectPath);
|
|
40
|
+
// Pin the package manager, so syncs don't have to guess from lockfiles
|
|
41
|
+
const configPath = path_1.default.join(projectPath, "plasmic.json");
|
|
42
|
+
const config = JSON.parse(yield fs_1.promises.readFile(configPath, "utf8"));
|
|
43
|
+
yield fs_1.promises.writeFile(configPath, JSON.stringify(Object.assign(Object.assign({}, config), { packageManager }), undefined, 2) + "\n");
|
|
31
44
|
});
|
|
32
45
|
}
|
|
33
46
|
exports.runCodegenSync = runCodegenSync;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PlasmicConfig } from "@plasmicapp/cli/dist/utils/config-utils";
|
|
2
|
-
import { JsOrTs, PlatformType } from "./types";
|
|
2
|
+
import { JsOrTs, PackageManagerType, PlatformType } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Runs the search pattern through `glob` and deletes all resulting files
|
|
5
5
|
* @param searchPattern - glob search query
|
|
@@ -30,5 +30,5 @@ export declare function generateHomePage(componentAbsPath: string, indexAbsPath:
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function generateWelcomePage(config: PlasmicConfig, platform: string): string;
|
|
32
32
|
export declare function getPlasmicConfig(projectPath: string, platform: PlatformType, scheme: string): Promise<PlasmicConfig>;
|
|
33
|
-
export declare function ensureTsconfig(projectPath: string): Promise<void>;
|
|
33
|
+
export declare function ensureTsconfig(projectPath: string, packageManager: PackageManagerType): Promise<void>;
|
|
34
34
|
export declare function ifTs(ts: JsOrTs, str: string): string;
|
package/dist/utils/file-utils.js
CHANGED
|
@@ -200,13 +200,14 @@ function getPlasmicConfig(projectPath, platform, scheme) {
|
|
|
200
200
|
exports.getPlasmicConfig = getPlasmicConfig;
|
|
201
201
|
// Create tsconfig.json if it doesn't exist
|
|
202
202
|
// this will force Plasmic to recognize Typescript
|
|
203
|
-
function ensureTsconfig(projectPath) {
|
|
203
|
+
function ensureTsconfig(projectPath, packageManager) {
|
|
204
204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
205
205
|
const tsconfigPath = path.join(projectPath, "tsconfig.json");
|
|
206
206
|
if (!(0, fs_1.existsSync)(tsconfigPath)) {
|
|
207
207
|
yield fs_1.promises.writeFile(tsconfigPath, "");
|
|
208
208
|
const installTsResult = yield (0, npm_utils_1.installUpgrade)("typescript @types/react", {
|
|
209
209
|
workingDir: projectPath,
|
|
210
|
+
packageManager,
|
|
210
211
|
});
|
|
211
212
|
if (!installTsResult) {
|
|
212
213
|
throw new Error("Failed to install Typescript");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PackageManagerType } from "./types";
|
|
1
2
|
/**
|
|
2
3
|
* Call this to check if there's an update available
|
|
3
4
|
* and display to the user
|
|
@@ -15,20 +16,34 @@ export declare function checkEngineStrict(): boolean;
|
|
|
15
16
|
* @returns boolean - true if success, false if fail
|
|
16
17
|
*/
|
|
17
18
|
export declare function spawn(cmd: string, workingDir?: string): Promise<boolean>;
|
|
19
|
+
interface InstallOpts {
|
|
20
|
+
global?: boolean;
|
|
21
|
+
dev?: boolean;
|
|
22
|
+
workingDir?: string;
|
|
23
|
+
packageManager: PackageManagerType;
|
|
24
|
+
}
|
|
18
25
|
/**
|
|
19
26
|
* Install a package using either `npm` or `yarn`
|
|
20
27
|
* @param pkg - package name
|
|
21
28
|
* @param opts
|
|
22
29
|
* @returns
|
|
23
30
|
*/
|
|
24
|
-
export declare function installUpgrade(pkg: string, opts
|
|
25
|
-
global?: boolean;
|
|
26
|
-
dev?: boolean;
|
|
27
|
-
workingDir?: string;
|
|
28
|
-
}): Promise<boolean>;
|
|
31
|
+
export declare function installUpgrade(pkg: string, opts: InstallOpts): Promise<boolean>;
|
|
29
32
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
+
* The package manager to install with: the one requested, else the one we were run
|
|
34
|
+
* with. `npx` overwrites npm_config_user_agent, so this must be read before spawning
|
|
35
|
+
* nested create commands.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolvePackageManager(requested?: PackageManagerType): PackageManagerType;
|
|
38
|
+
/** Scaffolders and run scripts only know the `yarn` command. */
|
|
39
|
+
export declare function packageManagerCommand(mgr: PackageManagerType): "npm" | "yarn" | "pnpm";
|
|
40
|
+
/** Run a locally installed bin. `npx` can't see Yarn Berry's PnP installs. */
|
|
41
|
+
export declare function packageManagerExec(mgr: PackageManagerType): string;
|
|
42
|
+
/**
|
|
43
|
+
* Make a freshly scaffolded app its own Yarn Berry project. Without a lockfile Berry
|
|
44
|
+
* claims the app for the nearest ancestor project, and its default PnP linker can't
|
|
45
|
+
* load CommonJS from Node 24's ESM resolver (EBADF), which breaks every framework we
|
|
46
|
+
* scaffold. Must run before anything invokes yarn in `projectPath`.
|
|
33
47
|
*/
|
|
34
|
-
export declare function
|
|
48
|
+
export declare function initYarnBerryProject(projectPath: string): Promise<void>;
|
|
49
|
+
export {};
|