Skip to content

Commit bdb919f

Browse files
authored
Update CLI to v5 templates (#2934)
1 parent a692154 commit bdb919f

File tree

4 files changed

+13
-66
lines changed

4 files changed

+13
-66
lines changed

.changeset/chilly-eels-yell.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@thirdweb-dev/cli": patch
3+
"thirdweb": patch
4+
---
5+
6+
Updates the CLI `create` command to use the v5 templates for Next.js and Vite
7+
8+
Other templates will be updated in the future from within their existing repositories
9+
10+
Removes React Native starters from the CLI menu
11+
Removes JS template support from the CLI

legacy_packages/cli/src/cli/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,12 @@ const main = async () => {
250250
)
251251
.option("--app", "Create a web3 app.")
252252
.option("--contract", "Create a web3 contract project")
253-
.option("--ts, --typescript", "Initialize as a TypeScript project.")
254-
.option("--js, --javascript", "Initialize as a JavaScript project.")
255253
.option("--forge", "Initialize as a Forge project.")
256254
.option("--hardhat", "Initialize as a Hardhat project.")
257255
.option("--extension", "Create a smart contract extension.")
258256
.option("--react", "Initialize as a Create React App project.")
259257
.option("--next", "Initialize as a Next.js project.")
260258
.option("--vite", "Initialize as a Vite project.")
261-
.option("--reactNative", "Initialize as a React Native project.")
262259
.option("--express", "Initialize as a Express project.")
263260
.option("--node", "Initialize as a Node project.")
264261
.option("--pwaVite", "Initialize as a PWA project.")

legacy_packages/cli/src/create/command.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ let contractName: string = "";
1616
let projectPath: string = "";
1717
let projectType: string = "";
1818
let framework: string = "";
19-
let language: string = "";
2019
let baseContract: string = "";
2120
let chain: string = "";
2221
let createExtension: boolean = false;
@@ -47,55 +46,41 @@ export async function twCreate(
4746
if (!projectType && Object.keys(options).length > 0) {
4847
if (options.react) {
4948
projectType = "app";
50-
language = "typescript";
5149
framework = "cra";
5250
}
5351

5452
if (options.next) {
5553
projectType = "app";
56-
language = "typescript";
5754
framework = "next";
5855
}
5956

6057
if (options.vite) {
6158
projectType = "app";
62-
language = "typescript";
6359
framework = "vite";
6460
}
6561

6662
if (options.node) {
6763
projectType = "app";
68-
language = "typescript";
6964
framework = "node";
7065
}
7166

7267
if (options.express) {
7368
projectType = "app";
74-
language = "typescript";
7569
framework = "express";
7670
}
7771

7872
if (options.pwaVite) {
7973
projectType = "app";
80-
language = "typescript";
8174
framework = "pwa-vite";
8275
}
8376

8477
if (options.reactNative) {
8578
projectType = "app";
86-
language = "typescript";
8779
framework = "react-native";
8880
}
8981
}
9082

9183
if (projectType === "app") {
92-
if (options.typescript) {
93-
language = "typescript";
94-
}
95-
if (options.javascript) {
96-
language = "javascript";
97-
}
98-
9984
if (options.next) {
10085
framework = "next";
10186
}
@@ -111,9 +96,6 @@ export async function twCreate(
11196
if (options.express) {
11297
framework = "express";
11398
}
114-
if (options.reactNative) {
115-
framework = "react-native";
116-
}
11799
if (options.pwaVite) {
118100
framework = "pwa-vite";
119101
}
@@ -261,7 +243,6 @@ export async function twCreate(
261243
{ title: "Create React App", value: "cra" },
262244
{ title: "Vite", value: "vite" },
263245
{ title: "PWA Vite", value: "pwa-vite" },
264-
{ title: "React Native", value: "react-native" },
265246
{ title: "Node.js", value: "node" },
266247
{ title: "Express", value: "express" },
267248
],
@@ -272,40 +253,6 @@ export async function twCreate(
272253
}
273254
}
274255

275-
if (projectType === "app" && !language) {
276-
if (framework === "react-native") {
277-
const res = await prompts({
278-
type: "select",
279-
name: "project",
280-
message: CREATE_MESSAGES.reactNative,
281-
choices: [
282-
{ title: "Expo Project", value: "expo" },
283-
{ title: "React Native CLI", value: "typescript" },
284-
],
285-
});
286-
287-
if (typeof res.project === "string") {
288-
language = res.project.trim();
289-
}
290-
} else if (framework === "pwa-vite" || framework === "pwa-next") {
291-
language = "typescript";
292-
} else {
293-
const res = await prompts({
294-
type: "select",
295-
name: "language",
296-
message: CREATE_MESSAGES.language,
297-
choices: [
298-
{ title: "JavaScript", value: "javascript" },
299-
{ title: "TypeScript", value: "typescript" },
300-
],
301-
});
302-
303-
if (typeof res.language === "string") {
304-
language = res.language.trim();
305-
}
306-
}
307-
}
308-
309256
if (
310257
(projectType === "contract" || projectType === "extension") &&
311258
framework !== "forge" &&
@@ -330,11 +277,6 @@ export async function twCreate(
330277
console.log("Please specify a framework");
331278
process.exit(1);
332279
}
333-
334-
if (!language) {
335-
// Default = JavaScript
336-
language = "javascript";
337-
}
338280
}
339281
}
340282

@@ -483,7 +425,6 @@ export async function twCreate(
483425
appPath: projectPath,
484426
packageManager,
485427
framework,
486-
language,
487428
template,
488429
});
489430
} else {

legacy_packages/cli/src/create/helpers/create-app.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ export async function createApp({
2222
appPath,
2323
packageManager,
2424
framework,
25-
language,
2625
template,
2726
}: {
2827
appPath: string;
2928
packageManager: PackageManager;
3029
framework?: string;
31-
language?: string;
3230
template?: string;
3331
}): Promise<void> {
3432
let frameworkPath = "";
@@ -45,7 +43,7 @@ export async function createApp({
4543
process.exit(1);
4644
}
4745
} else if (framework) {
48-
frameworkPath = `${framework}-${language || "javascript"}-starter`;
46+
frameworkPath = `${framework}-starter`;
4947
const found = await hasTemplate(frameworkPath);
5048

5149
if (!found) {
@@ -63,7 +61,7 @@ export async function createApp({
6361
function isReactNativeCLI() {
6462
return (
6563
isReactNative &&
66-
(language === "typescript" || (template && !template.includes("expo")))
64+
(template && !template.includes("expo"))
6765
);
6866
}
6967

0 commit comments

Comments
 (0)