create-plasmic-app 0.0.168 → 0.0.170
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/README.md +23 -0
- 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/package.json +1 -0
- package/cpa-out/nextjs-app-codegen-js/plasmic.json +2 -1
- package/cpa-out/nextjs-app-codegen-ts/package.json +1 -0
- package/cpa-out/nextjs-app-codegen-ts/plasmic.json +2 -1
- 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/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/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/styles/Home.module.css +8 -0
- package/cpa-out/nextjs-pages-loader-ts/package.json +5 -5
- 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 +16 -6
- 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 +39 -7
- 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
|
@@ -9,20 +9,20 @@
|
|
|
9
9
|
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
10
10
|
|
|
11
11
|
import { Route as rootRouteImport } from './routes/__root'
|
|
12
|
-
import { Route as PlasmicHostRouteImport } from './routes/plasmic-host'
|
|
13
12
|
import { Route as IndexRouteImport } from './routes/index'
|
|
13
|
+
import { Route as PlasmicHostRouteImport } from './routes/plasmic-host'
|
|
14
14
|
import { Route as DynamicSlugIndexRouteImport } from './routes/dynamic/$slug/index'
|
|
15
15
|
|
|
16
|
-
const PlasmicHostRoute = PlasmicHostRouteImport.update({
|
|
17
|
-
id: '/plasmic-host',
|
|
18
|
-
path: '/plasmic-host',
|
|
19
|
-
getParentRoute: () => rootRouteImport,
|
|
20
|
-
} as any)
|
|
21
16
|
const IndexRoute = IndexRouteImport.update({
|
|
22
17
|
id: '/',
|
|
23
18
|
path: '/',
|
|
24
19
|
getParentRoute: () => rootRouteImport,
|
|
25
20
|
} as any)
|
|
21
|
+
const PlasmicHostRoute = PlasmicHostRouteImport.update({
|
|
22
|
+
id: '/plasmic-host',
|
|
23
|
+
path: '/plasmic-host',
|
|
24
|
+
getParentRoute: () => rootRouteImport,
|
|
25
|
+
} as any)
|
|
26
26
|
const DynamicSlugIndexRoute = DynamicSlugIndexRouteImport.update({
|
|
27
27
|
id: '/dynamic/$slug/',
|
|
28
28
|
path: '/dynamic/$slug/',
|
|
@@ -61,13 +61,6 @@ export interface RootRouteChildren {
|
|
|
61
61
|
|
|
62
62
|
declare module '@tanstack/react-router' {
|
|
63
63
|
interface FileRoutesByPath {
|
|
64
|
-
'/plasmic-host': {
|
|
65
|
-
id: '/plasmic-host'
|
|
66
|
-
path: '/plasmic-host'
|
|
67
|
-
fullPath: '/plasmic-host'
|
|
68
|
-
preLoaderRoute: typeof PlasmicHostRouteImport
|
|
69
|
-
parentRoute: typeof rootRouteImport
|
|
70
|
-
}
|
|
71
64
|
'/': {
|
|
72
65
|
id: '/'
|
|
73
66
|
path: '/'
|
|
@@ -75,6 +68,13 @@ declare module '@tanstack/react-router' {
|
|
|
75
68
|
preLoaderRoute: typeof IndexRouteImport
|
|
76
69
|
parentRoute: typeof rootRouteImport
|
|
77
70
|
}
|
|
71
|
+
'/plasmic-host': {
|
|
72
|
+
id: '/plasmic-host'
|
|
73
|
+
path: '/plasmic-host'
|
|
74
|
+
fullPath: '/plasmic-host'
|
|
75
|
+
preLoaderRoute: typeof PlasmicHostRouteImport
|
|
76
|
+
parentRoute: typeof rootRouteImport
|
|
77
|
+
}
|
|
78
78
|
'/dynamic/$slug/': {
|
|
79
79
|
id: '/dynamic/$slug/'
|
|
80
80
|
path: '/dynamic/$slug'
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
serverQueryTree
|
|
10
10
|
} from "../../../components/plasmic/create_plasmic_app/PlasmicDynamicPage";
|
|
11
11
|
import { createFileRoute } from "@tanstack/react-router";
|
|
12
|
-
import {
|
|
12
|
+
import { executePlasmicQueries } from "@plasmicapp/react-web/lib/data-sources";
|
|
13
13
|
import { PlasmicQueryDataProvider } from "@plasmicapp/react-web/lib/query";
|
|
14
14
|
|
|
15
15
|
export const Route = createFileRoute("/dynamic/$slug/")({
|
|
@@ -28,7 +28,7 @@ export const Route = createFileRoute("/dynamic/$slug/")({
|
|
|
28
28
|
string | string[] | undefined
|
|
29
29
|
>
|
|
30
30
|
};
|
|
31
|
-
const { cache: prefetchedCache } = await
|
|
31
|
+
const { cache: prefetchedCache } = await executePlasmicQueries(
|
|
32
32
|
serverQueryTree,
|
|
33
33
|
{ $props: {}, $ctx }
|
|
34
34
|
);
|
package/dist/gatsby/gatsby.js
CHANGED
|
@@ -28,28 +28,42 @@ exports.GATSBY_TEMPLATES = {
|
|
|
28
28
|
};
|
|
29
29
|
exports.gatsbyStrategy = {
|
|
30
30
|
create: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
const { projectPath, template, jsOrTs } = args;
|
|
31
|
+
const { projectPath, projectId, template, jsOrTs, packageManager } = args;
|
|
32
32
|
if (template) {
|
|
33
33
|
console.log(`Warning: Ignoring template '${template}' (argument is not supported by Gatsby).`);
|
|
34
34
|
}
|
|
35
35
|
const gatsbyTemplate = exports.GATSBY_TEMPLATES[jsOrTs];
|
|
36
36
|
const createCommand = `git clone ${gatsbyTemplate} ${projectPath} --recursive --depth 1 --quiet`;
|
|
37
37
|
yield (0, cmd_utils_1.spawnOrFail)(`${createCommand}`);
|
|
38
|
-
// Remove .
|
|
39
|
-
yield (0, cmd_utils_1.spawnOrFail)(`rm -rf ${projectPath}/.git`);
|
|
40
|
-
|
|
38
|
+
// Remove package-lock.json since the user might be using a different package manager
|
|
39
|
+
yield (0, cmd_utils_1.spawnOrFail)(`rm -rf ${projectPath}/.git ${projectPath}/LICENSE ${projectPath}/package-lock.json`);
|
|
40
|
+
// Rename before installing; Yarn Berry rejects `yarn run` once the lockfile's
|
|
41
|
+
// workspace name no longer matches package.json
|
|
42
|
+
const packageJsonPath = path_1.default.join(projectPath, "package.json");
|
|
43
|
+
const packageJsonObject = JSON.parse(yield fs_1.promises.readFile(packageJsonPath, "utf8"));
|
|
44
|
+
packageJsonObject.name = path_1.default.basename(projectPath);
|
|
45
|
+
packageJsonObject.description = `Plasmic app for ${projectId}`;
|
|
46
|
+
delete packageJsonObject.license;
|
|
47
|
+
delete packageJsonObject.author;
|
|
48
|
+
yield fs_1.promises.writeFile(packageJsonPath, JSON.stringify(packageJsonObject, null, 2));
|
|
49
|
+
if (packageManager === "yarn2") {
|
|
50
|
+
yield (0, npm_utils_1.initYarnBerryProject)(projectPath);
|
|
51
|
+
}
|
|
41
52
|
}),
|
|
42
|
-
installDeps: ({ projectPath, scheme, jsOrTs }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
installDeps: ({ projectPath, scheme, jsOrTs, packageManager }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
54
|
const installedHelmet = yield (0, npm_utils_1.installUpgrade)("react-helmet", {
|
|
44
55
|
workingDir: projectPath,
|
|
56
|
+
packageManager,
|
|
45
57
|
});
|
|
46
58
|
const installedHelmetTypes = jsOrTs === "js" ||
|
|
47
59
|
(yield (0, npm_utils_1.installUpgrade)("@types/react-helmet", {
|
|
48
60
|
workingDir: projectPath,
|
|
49
61
|
dev: true,
|
|
62
|
+
packageManager,
|
|
50
63
|
}));
|
|
51
64
|
const installedHelmetPlugin = yield (0, npm_utils_1.installUpgrade)("gatsby-plugin-react-helmet", {
|
|
52
65
|
workingDir: projectPath,
|
|
66
|
+
packageManager,
|
|
53
67
|
});
|
|
54
68
|
if (!installedHelmet || !installedHelmetPlugin || !installedHelmetTypes) {
|
|
55
69
|
return false;
|
|
@@ -57,24 +71,15 @@ exports.gatsbyStrategy = {
|
|
|
57
71
|
if (scheme === "loader") {
|
|
58
72
|
return yield (0, npm_utils_1.installUpgrade)("@plasmicapp/loader-gatsby", {
|
|
59
73
|
workingDir: projectPath,
|
|
74
|
+
packageManager,
|
|
60
75
|
});
|
|
61
76
|
}
|
|
62
77
|
else {
|
|
63
|
-
return yield (0, codegen_1.installCodegenDeps)({ projectPath });
|
|
78
|
+
return yield (0, codegen_1.installCodegenDeps)({ projectPath, packageManager });
|
|
64
79
|
}
|
|
65
80
|
}),
|
|
66
81
|
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
82
|
const { projectId, projectPath, projectApiToken, jsOrTs, scheme } = args;
|
|
68
|
-
const packageName = path_1.default.basename(projectPath);
|
|
69
|
-
// Update package.json: adding name and description, removing license and author
|
|
70
|
-
const packageJsonPath = path_1.default.join(projectPath, "package.json");
|
|
71
|
-
const packageJson = yield fs_1.promises.readFile(packageJsonPath, "utf8");
|
|
72
|
-
const packageJsonObject = JSON.parse(packageJson);
|
|
73
|
-
packageJsonObject.name = packageName;
|
|
74
|
-
packageJsonObject.description = `Plasmic app for ${projectId}`;
|
|
75
|
-
delete packageJsonObject.license;
|
|
76
|
-
delete packageJsonObject.author;
|
|
77
|
-
yield fs_1.promises.writeFile(packageJsonPath, JSON.stringify(packageJsonObject, null, 2));
|
|
78
83
|
if (scheme === "loader") {
|
|
79
84
|
const gatsbyConfigFile = path_1.default.join(projectPath, `gatsby-config.${jsOrTs}`);
|
|
80
85
|
yield fs_1.promises.writeFile(gatsbyConfigFile, (0, template_1.makeGatsbyConfig)(projectId, (0, lang_utils_1.ensure)(projectApiToken, "Missing projectApiToken"), jsOrTs));
|
|
@@ -83,7 +88,7 @@ exports.gatsbyStrategy = {
|
|
|
83
88
|
generateFiles: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
89
|
// in gatsby we can delete all existing pages/components, since all pages are going
|
|
85
90
|
// to be handled by templates/defaultPlasmicPage
|
|
86
|
-
const { projectId, projectApiToken, projectPath, jsOrTs, scheme } = args;
|
|
91
|
+
const { projectId, projectApiToken, projectPath, jsOrTs, scheme, packageManager, } = args;
|
|
87
92
|
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "src/@(pages|components|templates)/*.*"));
|
|
88
93
|
// Create a very basic 404 page - `gatsby build` fails without it.
|
|
89
94
|
yield fs_1.promises.writeFile(path_1.default.join(projectPath, `src/pages/404.${jsOrTs}`), template_1.GATSBY_404);
|
|
@@ -111,6 +116,7 @@ exports.gatsbyStrategy = {
|
|
|
111
116
|
projectId,
|
|
112
117
|
projectApiToken,
|
|
113
118
|
projectPath,
|
|
119
|
+
packageManager,
|
|
114
120
|
});
|
|
115
121
|
// Special case: remove all Gatsby components (due to conflicting file names)
|
|
116
122
|
const config = yield (0, file_utils_1.getPlasmicConfig)(projectPath, "gatsby", scheme);
|
package/dist/index.js
CHANGED
|
@@ -87,6 +87,10 @@ const argv = yargs_1.default
|
|
|
87
87
|
.option("appDir", {
|
|
88
88
|
describe: "(Next.js) Use app directory?",
|
|
89
89
|
boolean: true,
|
|
90
|
+
})
|
|
91
|
+
.option("packageManager", {
|
|
92
|
+
describe: "Package manager to scaffold and install with",
|
|
93
|
+
choices: ["", "npm", "yarn", "pnpm"],
|
|
90
94
|
})
|
|
91
95
|
.strict()
|
|
92
96
|
.help("h")
|
|
@@ -261,6 +265,7 @@ What is the URL of your project?`,
|
|
|
261
265
|
console.log();
|
|
262
266
|
const template = argv["template"];
|
|
263
267
|
const projectApiToken = argv["projectApiToken"];
|
|
268
|
+
const packageManager = (argv["packageManager"] || undefined);
|
|
264
269
|
// Set the metadata environment variable to tag the future Segment codegen event
|
|
265
270
|
(0, cli_1.setMetadataEnv)({
|
|
266
271
|
source: "create-plasmic-app",
|
|
@@ -274,6 +279,7 @@ What is the URL of your project?`,
|
|
|
274
279
|
jsOrTs,
|
|
275
280
|
projectApiToken,
|
|
276
281
|
template,
|
|
282
|
+
packageManager,
|
|
277
283
|
});
|
|
278
284
|
});
|
|
279
285
|
}
|
package/dist/lib.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setMetadataEnv } from "@plasmicapp/cli";
|
|
2
|
-
import { JsOrTs, PlatformOptions, PlatformType, SchemeType } from "./utils/types";
|
|
2
|
+
import { JsOrTs, PackageManagerType, PlatformOptions, PlatformType, SchemeType } from "./utils/types";
|
|
3
3
|
export interface CreatePlasmicAppArgs {
|
|
4
4
|
resolvedProjectPath: string;
|
|
5
5
|
projectId: string;
|
|
@@ -9,6 +9,7 @@ export interface CreatePlasmicAppArgs {
|
|
|
9
9
|
jsOrTs: JsOrTs;
|
|
10
10
|
projectApiToken?: string;
|
|
11
11
|
template?: string;
|
|
12
|
+
packageManager?: PackageManagerType;
|
|
12
13
|
}
|
|
13
14
|
export declare function create(args: CreatePlasmicAppArgs): Promise<void>;
|
|
14
15
|
export declare function checkValidName(name?: string): boolean;
|
package/dist/lib.js
CHANGED
|
@@ -60,6 +60,7 @@ function create(args) {
|
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
61
|
const { resolvedProjectPath, projectId, platform, platformOptions, scheme, jsOrTs, template, } = args;
|
|
62
62
|
let { projectApiToken } = args;
|
|
63
|
+
const packageManager = (0, npm_utils_1.resolvePackageManager)(args.packageManager);
|
|
63
64
|
console.log("Let's get started! Here's what we'll do: ");
|
|
64
65
|
console.log("1. Authenticate with Plasmic");
|
|
65
66
|
console.log("2. Create a React/Next/Gatsby repo");
|
|
@@ -94,15 +95,17 @@ function create(args) {
|
|
|
94
95
|
// Create project using strategy for platform
|
|
95
96
|
yield cpaStrategy.create({
|
|
96
97
|
projectPath: resolvedProjectPath,
|
|
98
|
+
projectId,
|
|
97
99
|
jsOrTs,
|
|
98
100
|
template,
|
|
99
101
|
platformOptions,
|
|
102
|
+
packageManager,
|
|
100
103
|
});
|
|
101
104
|
// Ensure that we have a empty tsconfig and @types packages.
|
|
102
105
|
// Gatsby and Next.js by default support typescript handling internally
|
|
103
106
|
// tsconfig so we don't have to ensure it.
|
|
104
107
|
if (jsOrTs === "ts" && platform === "react") {
|
|
105
|
-
yield (0, file_utils_1.ensureTsconfig)(resolvedProjectPath);
|
|
108
|
+
yield (0, file_utils_1.ensureTsconfig)(resolvedProjectPath, packageManager);
|
|
106
109
|
}
|
|
107
110
|
// Make sure we have an api token for loader
|
|
108
111
|
if (scheme === "loader" && !projectApiToken) {
|
|
@@ -117,6 +120,7 @@ function create(args) {
|
|
|
117
120
|
scheme,
|
|
118
121
|
projectPath: resolvedProjectPath,
|
|
119
122
|
jsOrTs,
|
|
123
|
+
packageManager,
|
|
120
124
|
});
|
|
121
125
|
if (!installResult) {
|
|
122
126
|
throw new Error("Failed to install the Plasmic dependency");
|
|
@@ -138,12 +142,13 @@ function create(args) {
|
|
|
138
142
|
projectId,
|
|
139
143
|
projectApiToken,
|
|
140
144
|
platformOptions,
|
|
145
|
+
packageManager,
|
|
141
146
|
});
|
|
142
147
|
/**
|
|
143
148
|
* INSTRUCT USER ON NEXT STEPS
|
|
144
149
|
*/
|
|
145
|
-
const
|
|
146
|
-
const npmRunCmd =
|
|
150
|
+
const pmCmd = (0, npm_utils_1.packageManagerCommand)(packageManager);
|
|
151
|
+
const npmRunCmd = pmCmd === "yarn" ? "yarn" : `${pmCmd} run`;
|
|
147
152
|
const command = platform === "nextjs"
|
|
148
153
|
? `${npmRunCmd} dev`
|
|
149
154
|
: platform === "gatsby"
|
|
@@ -169,7 +174,7 @@ function create(args) {
|
|
|
169
174
|
}
|
|
170
175
|
if (scheme === "codegen") {
|
|
171
176
|
console.log("To watch for changes in Plasmic components, in a separate terminal run:");
|
|
172
|
-
console.log(chalk_1.default.bold(
|
|
177
|
+
console.log(chalk_1.default.bold(`${(0, npm_utils_1.packageManagerExec)(packageManager)} plasmic watch`));
|
|
173
178
|
}
|
|
174
179
|
});
|
|
175
180
|
}
|
package/dist/nextjs/nextjs.js
CHANGED
|
@@ -38,27 +38,35 @@ const pages_seo_1 = require("./templates/pages-seo");
|
|
|
38
38
|
exports.nextjsStrategy = {
|
|
39
39
|
create: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
var _a;
|
|
41
|
-
const { projectPath, template, jsOrTs, platformOptions } = args;
|
|
41
|
+
const { projectPath, template, jsOrTs, platformOptions, packageManager } = args;
|
|
42
42
|
const typescriptArg = `--${jsOrTs}`;
|
|
43
43
|
const experimentalAppArg = ((_a = platformOptions.nextjs) === null || _a === void 0 ? void 0 : _a.appDir)
|
|
44
44
|
? "--app"
|
|
45
45
|
: "--no-app";
|
|
46
46
|
const templateArg = template ? ` --example ${template}` : "";
|
|
47
|
+
const isYarnBerry = packageManager === "yarn2";
|
|
47
48
|
// NOTE: Not using create-next-app@latest to keep major version bumps deliberate
|
|
48
49
|
const createCommand = `npx create-next-app@16 ${projectPath} ${typescriptArg} ${experimentalAppArg} ${templateArg}` +
|
|
49
|
-
` --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" : "");
|
|
50
53
|
// Default Next.js starter already supports Typescript
|
|
51
54
|
// See where we `touch tsconfig.json` later on
|
|
52
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
|
+
}
|
|
53
60
|
}),
|
|
54
|
-
installDeps: ({ scheme, projectPath }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
installDeps: ({ scheme, projectPath, packageManager }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
62
|
if (scheme === "loader") {
|
|
56
63
|
return yield (0, npm_utils_1.installUpgrade)("@plasmicapp/loader-nextjs", {
|
|
57
64
|
workingDir: projectPath,
|
|
65
|
+
packageManager,
|
|
58
66
|
});
|
|
59
67
|
}
|
|
60
68
|
else {
|
|
61
|
-
return yield (0, codegen_1.installCodegenDeps)({ projectPath });
|
|
69
|
+
return yield (0, codegen_1.installCodegenDeps)({ projectPath, packageManager });
|
|
62
70
|
}
|
|
63
71
|
}),
|
|
64
72
|
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -123,7 +131,7 @@ a {
|
|
|
123
131
|
}
|
|
124
132
|
function generateFilesAppDir(args) {
|
|
125
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const { projectPath, scheme, jsOrTs, projectId, projectApiToken } = args;
|
|
134
|
+
const { projectPath, scheme, jsOrTs, projectId, projectApiToken, packageManager, } = args;
|
|
127
135
|
// Delete existing pages
|
|
128
136
|
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "app", "page.*"));
|
|
129
137
|
// ./app/robots.ts
|
|
@@ -156,6 +164,7 @@ function generateFilesAppDir(args) {
|
|
|
156
164
|
projectId,
|
|
157
165
|
projectApiToken,
|
|
158
166
|
projectPath,
|
|
167
|
+
packageManager,
|
|
159
168
|
});
|
|
160
169
|
// ./app/sitemap.ts
|
|
161
170
|
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "app", `sitemap.${jsOrTs}`), (0, app_seo_1.makeSitemap_app_codegen)(jsOrTs));
|
|
@@ -182,7 +191,7 @@ function generateFilesAppDir(args) {
|
|
|
182
191
|
}
|
|
183
192
|
function generateFilesPagesDir(args) {
|
|
184
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
const { projectPath, scheme, jsOrTs, projectId, projectApiToken } = args;
|
|
194
|
+
const { projectPath, scheme, jsOrTs, projectId, projectApiToken, packageManager, } = args;
|
|
186
195
|
// Delete existing pages
|
|
187
196
|
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "pages", "*.*"));
|
|
188
197
|
// ./pages/robots.txt.ts
|
|
@@ -208,6 +217,7 @@ function generateFilesPagesDir(args) {
|
|
|
208
217
|
projectId,
|
|
209
218
|
projectApiToken,
|
|
210
219
|
projectPath,
|
|
220
|
+
packageManager,
|
|
211
221
|
});
|
|
212
222
|
// ./pages/sitemap.xml.ts
|
|
213
223
|
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "pages", `sitemap.xml.${jsOrTs}`), (0, pages_seo_1.makeSitemap_pages_codegen)(jsOrTs));
|
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 {};
|