create-plasmic-app 0.0.106 → 0.0.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cpa-out/tanstack-codegen-ts/tsconfig.json +1 -1
- package/dist/index.js +19 -19
- package/dist/tanstack/tanstack.js +9 -7
- package/dist/tanstack/templates/file-router/root.d.ts +1 -2
- package/dist/tanstack/templates/file-router/root.js +1 -1
- package/package.json +2 -2
- package/run-cpa.ts +7 -5
- package/src/index.ts +27 -21
- package/src/tanstack/tanstack.ts +20 -11
- package/src/tanstack/templates/file-router/root.ts +1 -3
package/dist/index.js
CHANGED
|
@@ -151,25 +151,6 @@ function run() {
|
|
|
151
151
|
});
|
|
152
152
|
// Absolute path to the new project
|
|
153
153
|
resolvedProjectPath = path.resolve(projectName);
|
|
154
|
-
// Prompt for Typescript
|
|
155
|
-
const jsOrTs = (yield maybePrompt({
|
|
156
|
-
name: "typescript",
|
|
157
|
-
message: "What language do you want to use?",
|
|
158
|
-
type: "list",
|
|
159
|
-
choices: () => [
|
|
160
|
-
{
|
|
161
|
-
name: "TypeScript",
|
|
162
|
-
value: true,
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
name: "JavaScript",
|
|
166
|
-
value: false,
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
default: true,
|
|
170
|
-
}))
|
|
171
|
-
? "ts"
|
|
172
|
-
: "js";
|
|
173
154
|
// Prompt for the platform
|
|
174
155
|
const platform = yield maybePrompt({
|
|
175
156
|
name: "platform",
|
|
@@ -198,6 +179,25 @@ function run() {
|
|
|
198
179
|
],
|
|
199
180
|
default: "nextjs",
|
|
200
181
|
});
|
|
182
|
+
// Prompt for Typescript
|
|
183
|
+
const jsOrTs = platform === "tanstack"
|
|
184
|
+
? "ts"
|
|
185
|
+
: yield maybePrompt({
|
|
186
|
+
name: "typescript",
|
|
187
|
+
message: "What language do you want to use?",
|
|
188
|
+
type: "list",
|
|
189
|
+
choices: () => [
|
|
190
|
+
{
|
|
191
|
+
name: "TypeScript",
|
|
192
|
+
value: "ts",
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "JavaScript",
|
|
196
|
+
value: "js",
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
default: "ts",
|
|
200
|
+
});
|
|
201
201
|
// Scheme to use for Plasmic integration
|
|
202
202
|
// - loader only available for gatsby/next.js
|
|
203
203
|
const scheme = platform === "nextjs" || platform === "gatsby"
|
|
@@ -50,13 +50,15 @@ exports.tanstackStrategy = {
|
|
|
50
50
|
}
|
|
51
51
|
}),
|
|
52
52
|
overwriteConfig: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
const { projectPath
|
|
53
|
+
const { projectPath } = args;
|
|
54
54
|
/* We need to provide @plasmicapp/* packages in noExternal ssr packages for
|
|
55
55
|
* them to work properly during ssr phase.
|
|
56
56
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "vite.config.ts"), (0, config_1.makeCustomViteConfig_file_router_codegen)());
|
|
58
|
+
// Disable verbatimModuleSyntax in tsconfig.json
|
|
59
|
+
const tsconfigPath = path_1.default.join(projectPath, "tsconfig.json");
|
|
60
|
+
const tsconfigContent = yield fs_1.promises.readFile(tsconfigPath, "utf8");
|
|
61
|
+
yield fs_1.promises.writeFile(tsconfigPath, tsconfigContent.replace(`"verbatimModuleSyntax": true`, `"verbatimModuleSyntax": false`));
|
|
60
62
|
}),
|
|
61
63
|
generateFiles: (args) => {
|
|
62
64
|
return generateFilesFileRouterTemplate(args);
|
|
@@ -68,7 +70,7 @@ exports.tanstackStrategy = {
|
|
|
68
70
|
};
|
|
69
71
|
function generateFilesFileRouterTemplate(args) {
|
|
70
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const { projectPath, scheme,
|
|
73
|
+
const { projectPath, scheme, projectId, projectApiToken } = args;
|
|
72
74
|
// Delete existing pages
|
|
73
75
|
(0, file_utils_1.deleteGlob)(path_1.default.join(projectPath, "src/routes", "*.*"));
|
|
74
76
|
if (scheme === "loader") {
|
|
@@ -76,9 +78,9 @@ function generateFilesFileRouterTemplate(args) {
|
|
|
76
78
|
}
|
|
77
79
|
else {
|
|
78
80
|
// ./src/routes/__root.tsx
|
|
79
|
-
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "src/routes",
|
|
81
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "src/routes", "__root.tsx"), (0, root_1.makeCustomRoot_file_router_codegen)());
|
|
80
82
|
// ./src/routes/plasmic-host.tsx
|
|
81
|
-
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "src/routes",
|
|
83
|
+
yield fs_1.promises.writeFile(path_1.default.join(projectPath, "src/routes", "plasmic-host.tsx"), (0, plasmic_host_1.makePlasmicHostPage_fileRouter_codegen)());
|
|
82
84
|
// This should generate
|
|
83
85
|
// ./plasmic.json
|
|
84
86
|
// ./routes/index.tsx
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function makeCustomRoot_file_router_codegen(_jsOrTs: JsOrTs): string;
|
|
1
|
+
export declare function makeCustomRoot_file_router_codegen(): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeCustomRoot_file_router_codegen = void 0;
|
|
4
|
-
function makeCustomRoot_file_router_codegen(
|
|
4
|
+
function makeCustomRoot_file_router_codegen() {
|
|
5
5
|
return `import { createRootRoute, HeadContent, Outlet, Scripts } from '@tanstack/react-router'
|
|
6
6
|
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
|
|
7
7
|
import { PlasmicRootProvider } from "@plasmicapp/react-web"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-plasmic-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.107",
|
|
4
4
|
"description": "Create Plasmic-powered React apps",
|
|
5
5
|
"main": "./dist/lib.js",
|
|
6
6
|
"types": "./dist/lib.d.ts",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"validate-npm-package-name": "^3.0.0",
|
|
47
47
|
"yargs": "^16.2.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "7eba0fb9492e4b1907a42537163ba9d1e91f8482"
|
|
50
50
|
}
|
package/run-cpa.ts
CHANGED
|
@@ -31,11 +31,13 @@ async function run() {
|
|
|
31
31
|
typescript,
|
|
32
32
|
});
|
|
33
33
|
if (scheme === "codegen") {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (typescript) {
|
|
35
|
+
allArgSets.push({
|
|
36
|
+
platform: "tanstack",
|
|
37
|
+
scheme,
|
|
38
|
+
typescript,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
39
41
|
|
|
40
42
|
allArgSets.push({
|
|
41
43
|
platform: "react",
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,12 @@ import yargs from "yargs";
|
|
|
8
8
|
import * as cpa from "./lib";
|
|
9
9
|
import { ensure } from "./utils/lang-utils";
|
|
10
10
|
import { checkEngineStrict, updateNotify } from "./utils/npm-utils";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
JsOrTs,
|
|
13
|
+
PlatformOptions,
|
|
14
|
+
PlatformType,
|
|
15
|
+
SchemeType,
|
|
16
|
+
} from "./utils/types";
|
|
12
17
|
|
|
13
18
|
if (process.env.CPA_DEBUG_CHDIR) {
|
|
14
19
|
process.chdir(process.env.CPA_DEBUG_CHDIR);
|
|
@@ -138,26 +143,6 @@ async function run(): Promise<void> {
|
|
|
138
143
|
// Absolute path to the new project
|
|
139
144
|
resolvedProjectPath = path.resolve(projectName);
|
|
140
145
|
|
|
141
|
-
// Prompt for Typescript
|
|
142
|
-
const jsOrTs = (await maybePrompt({
|
|
143
|
-
name: "typescript",
|
|
144
|
-
message: "What language do you want to use?",
|
|
145
|
-
type: "list",
|
|
146
|
-
choices: () => [
|
|
147
|
-
{
|
|
148
|
-
name: "TypeScript",
|
|
149
|
-
value: true,
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
name: "JavaScript",
|
|
153
|
-
value: false,
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
default: true,
|
|
157
|
-
}))
|
|
158
|
-
? "ts"
|
|
159
|
-
: "js";
|
|
160
|
-
|
|
161
146
|
// Prompt for the platform
|
|
162
147
|
const platform = await maybePrompt<PlatformType>({
|
|
163
148
|
name: "platform",
|
|
@@ -187,6 +172,27 @@ async function run(): Promise<void> {
|
|
|
187
172
|
default: "nextjs",
|
|
188
173
|
});
|
|
189
174
|
|
|
175
|
+
// Prompt for Typescript
|
|
176
|
+
const jsOrTs: JsOrTs =
|
|
177
|
+
platform === "tanstack"
|
|
178
|
+
? "ts"
|
|
179
|
+
: await maybePrompt({
|
|
180
|
+
name: "typescript",
|
|
181
|
+
message: "What language do you want to use?",
|
|
182
|
+
type: "list",
|
|
183
|
+
choices: () => [
|
|
184
|
+
{
|
|
185
|
+
name: "TypeScript",
|
|
186
|
+
value: "ts",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "JavaScript",
|
|
190
|
+
value: "js",
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
default: "ts",
|
|
194
|
+
});
|
|
195
|
+
|
|
190
196
|
// Scheme to use for Plasmic integration
|
|
191
197
|
// - loader only available for gatsby/next.js
|
|
192
198
|
const scheme: SchemeType =
|
package/src/tanstack/tanstack.ts
CHANGED
|
@@ -43,17 +43,26 @@ export const tanstackStrategy: CPAStrategy = {
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
overwriteConfig: async (args) => {
|
|
46
|
-
const { projectPath
|
|
46
|
+
const { projectPath } = args;
|
|
47
47
|
|
|
48
48
|
/* We need to provide @plasmicapp/* packages in noExternal ssr packages for
|
|
49
49
|
* them to work properly during ssr phase.
|
|
50
50
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
await fs.writeFile(
|
|
52
|
+
path.join(projectPath, "vite.config.ts"),
|
|
53
|
+
makeCustomViteConfig_file_router_codegen()
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Disable verbatimModuleSyntax in tsconfig.json
|
|
57
|
+
const tsconfigPath = path.join(projectPath, "tsconfig.json");
|
|
58
|
+
const tsconfigContent = await fs.readFile(tsconfigPath, "utf8");
|
|
59
|
+
await fs.writeFile(
|
|
60
|
+
tsconfigPath,
|
|
61
|
+
tsconfigContent.replace(
|
|
62
|
+
`"verbatimModuleSyntax": true`,
|
|
63
|
+
`"verbatimModuleSyntax": false`
|
|
64
|
+
)
|
|
65
|
+
);
|
|
57
66
|
},
|
|
58
67
|
generateFiles: (args) => {
|
|
59
68
|
return generateFilesFileRouterTemplate(args);
|
|
@@ -65,7 +74,7 @@ export const tanstackStrategy: CPAStrategy = {
|
|
|
65
74
|
};
|
|
66
75
|
|
|
67
76
|
async function generateFilesFileRouterTemplate(args: GenerateFilesArgs) {
|
|
68
|
-
const { projectPath, scheme,
|
|
77
|
+
const { projectPath, scheme, projectId, projectApiToken } = args;
|
|
69
78
|
|
|
70
79
|
// Delete existing pages
|
|
71
80
|
deleteGlob(path.join(projectPath, "src/routes", "*.*"));
|
|
@@ -77,13 +86,13 @@ async function generateFilesFileRouterTemplate(args: GenerateFilesArgs) {
|
|
|
77
86
|
} else {
|
|
78
87
|
// ./src/routes/__root.tsx
|
|
79
88
|
await fs.writeFile(
|
|
80
|
-
path.join(projectPath, "src/routes",
|
|
81
|
-
makeCustomRoot_file_router_codegen(
|
|
89
|
+
path.join(projectPath, "src/routes", "__root.tsx"),
|
|
90
|
+
makeCustomRoot_file_router_codegen()
|
|
82
91
|
);
|
|
83
92
|
|
|
84
93
|
// ./src/routes/plasmic-host.tsx
|
|
85
94
|
await fs.writeFile(
|
|
86
|
-
path.join(projectPath, "src/routes",
|
|
95
|
+
path.join(projectPath, "src/routes", "plasmic-host.tsx"),
|
|
87
96
|
makePlasmicHostPage_fileRouter_codegen()
|
|
88
97
|
);
|
|
89
98
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function makeCustomRoot_file_router_codegen(_jsOrTs: JsOrTs): string {
|
|
1
|
+
export function makeCustomRoot_file_router_codegen(): string {
|
|
4
2
|
return `import { createRootRoute, HeadContent, Outlet, Scripts } from '@tanstack/react-router'
|
|
5
3
|
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
|
|
6
4
|
import { PlasmicRootProvider } from "@plasmicapp/react-web"
|