File tree 15 files changed +80
-14
lines changed
packages/create-cloudflare/src/frameworks
15 files changed +80
-14
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,17 @@ import {
9
9
} from "helpers/command" ;
10
10
import { readFile , readJSON , writeFile } from "helpers/files" ;
11
11
import { spinner } from "helpers/interactive" ;
12
+ import { getFrameworkVersion } from "../index" ;
12
13
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
13
14
14
15
const { npx } = detectPackageManager ( ) ;
15
16
16
17
const generate = async ( ctx : PagesGeneratorContext ) => {
18
+ const version = getFrameworkVersion ( ctx ) ;
19
+
17
20
await runFrameworkGenerator (
18
21
ctx ,
19
- `${ npx } @angular/cli@next new ${ ctx . project . name } --standalone`
22
+ `${ npx } @angular/cli@${ version } new ${ ctx . project . name } --standalone`
20
23
) ;
21
24
} ;
22
25
Original file line number Diff line number Diff line change @@ -7,14 +7,17 @@ import {
7
7
runFrameworkGenerator ,
8
8
} from "helpers/command" ;
9
9
import { compatDateFlag } from "helpers/files" ;
10
+ import { getFrameworkVersion } from "../index" ;
10
11
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
11
12
12
13
const { npx } = detectPackageManager ( ) ;
13
14
14
15
const generate = async ( ctx : PagesGeneratorContext ) => {
16
+ const version = getFrameworkVersion ( ctx ) ;
17
+
15
18
await runFrameworkGenerator (
16
19
ctx ,
17
- `${ npx } create-astro@latest ${ ctx . project . name } --no-install`
20
+ `${ npx } create-astro@${ version } ${ ctx . project . name } --no-install`
18
21
) ;
19
22
20
23
logRaw ( "" ) ; // newline
Original file line number Diff line number Diff line change 1
1
import { detectPackageManager , runFrameworkGenerator } from "helpers/command" ;
2
2
import { compatDateFlag } from "helpers/files" ;
3
+ import { getFrameworkVersion } from "../index" ;
3
4
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
4
5
5
6
const { npm } = detectPackageManager ( ) ;
6
7
7
8
const generate = async ( ctx : PagesGeneratorContext ) => {
9
+ const version = getFrameworkVersion ( ctx ) ;
10
+
8
11
await runFrameworkGenerator (
9
12
ctx ,
10
- `${ npm } create docusaurus ${ ctx . project . name } classic`
13
+ `${ npm } create docusaurus@ ${ version } ${ ctx . project . name } classic`
11
14
) ;
12
15
} ;
13
16
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { brandColor, dim } from "helpers/colors";
2
2
import { detectPackageManager , runFrameworkGenerator } from "helpers/command" ;
3
3
import { compatDateFlag } from "helpers/files" ;
4
4
import { confirmInput , textInput } from "helpers/interactive" ;
5
+ import { getFrameworkVersion } from "../index" ;
5
6
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
6
7
7
8
const { npm, npx } = detectPackageManager ( ) ;
@@ -29,9 +30,10 @@ const generate = async (ctx: PagesGeneratorContext) => {
29
30
} ) ;
30
31
}
31
32
33
+ const version = getFrameworkVersion ( ctx ) ;
32
34
await runFrameworkGenerator (
33
35
ctx ,
34
- `${ npx } gatsby new ${ ctx . project . name } ${ templateUrl } `
36
+ `${ npx } gatsby@ ${ version } new ${ ctx . project . name } ${ templateUrl } `
35
37
) ;
36
38
} ;
37
39
Original file line number Diff line number Diff line change 1
1
import { logRaw } from "helpers/cli" ;
2
2
import { detectPackageManager , runFrameworkGenerator } from "helpers/command" ;
3
+ import { getFrameworkVersion } from "../index" ;
3
4
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
4
5
5
6
const { npx } = detectPackageManager ( ) ;
6
7
7
8
const generate = async ( ctx : PagesGeneratorContext ) => {
9
+ const version = getFrameworkVersion ( ctx ) ;
10
+
8
11
await runFrameworkGenerator (
9
12
ctx ,
10
- `${ npx } create-hono@latest ${ ctx . project . name } --template cloudflare-pages`
13
+ `${ npx } create-hono@${ version } ${ ctx . project . name } --template cloudflare-pages`
11
14
) ;
12
15
13
16
logRaw ( "" ) ; // newline
Original file line number Diff line number Diff line change
1
+ import { crash } from "helpers/cli" ;
1
2
import angular from "./angular" ;
2
3
import astro from "./astro" ;
3
4
import docusaurus from "./docusaurus" ;
@@ -10,8 +11,9 @@ import react from "./react";
10
11
import remix from "./remix" ;
11
12
import solid from "./solid" ;
12
13
import svelte from "./svelte" ;
14
+ import versionMap from "./versionMap.json" ;
13
15
import vue from "./vue" ;
14
- import type { FrameworkConfig } from "types" ;
16
+ import type { FrameworkConfig , PagesGeneratorContext } from "types" ;
15
17
16
18
export const FrameworkMap : Record < string , FrameworkConfig > = {
17
19
angular,
@@ -29,6 +31,15 @@ export const FrameworkMap: Record<string, FrameworkConfig> = {
29
31
vue,
30
32
} ;
31
33
34
+ export const getFrameworkVersion = ( ctx : PagesGeneratorContext ) => {
35
+ if ( ! ctx . framework ) {
36
+ return crash ( "Framework not specified." ) ;
37
+ }
38
+
39
+ const framework = ctx . framework . name as keyof typeof versionMap ;
40
+ return versionMap [ framework ] ;
41
+ } ;
42
+
32
43
export const supportedFramework = ( framework : string ) => {
33
44
return Object . keys ( FrameworkMap ) . includes ( framework ) ;
34
45
} ;
Original file line number Diff line number Diff line change @@ -6,15 +6,20 @@ import {
6
6
runFrameworkGenerator ,
7
7
} from "helpers/command" ;
8
8
import { probePaths , usesTypescript , writeFile } from "helpers/files" ;
9
+ import { getFrameworkVersion } from "../index" ;
9
10
import { apiHelloJs , apiHelloTs , nextConfigJs } from "./templates" ;
10
11
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
11
12
12
13
const { npm, npx } = detectPackageManager ( ) ;
13
14
14
15
const generate = async ( ctx : PagesGeneratorContext ) => {
15
16
const projectName = ctx . project . name ;
17
+ const version = getFrameworkVersion ( ctx ) ;
16
18
17
- await runFrameworkGenerator ( ctx , `${ npx } create-next-app ${ projectName } ` ) ;
19
+ await runFrameworkGenerator (
20
+ ctx ,
21
+ `${ npx } create-next-app@${ version } ${ projectName } `
22
+ ) ;
18
23
} ;
19
24
20
25
const configure = async ( ctx : PagesGeneratorContext ) => {
Original file line number Diff line number Diff line change @@ -5,12 +5,18 @@ import {
5
5
runFrameworkGenerator ,
6
6
} from "helpers/command" ;
7
7
import { compatDateFlag } from "helpers/files" ;
8
+ import { getFrameworkVersion } from ".." ;
8
9
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
9
10
10
11
const { npx } = detectPackageManager ( ) ;
11
12
12
13
const generate = async ( ctx : PagesGeneratorContext ) => {
13
- await runFrameworkGenerator ( ctx , `${ npx } nuxi init ${ ctx . project . name } ` ) ;
14
+ const version = getFrameworkVersion ( ctx ) ;
15
+
16
+ await runFrameworkGenerator (
17
+ ctx ,
18
+ `${ npx } nuxi@${ version } init ${ ctx . project . name } `
19
+ ) ;
14
20
15
21
logRaw ( "" ) ; // newline
16
22
} ;
Original file line number Diff line number Diff line change @@ -6,16 +6,19 @@ import {
6
6
runFrameworkGenerator ,
7
7
} from "helpers/command" ;
8
8
import { compatDateFlag } from "helpers/files" ;
9
+ import { getFrameworkVersion } from "../index" ;
9
10
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
10
11
11
12
const { npm, npx } = detectPackageManager ( ) ;
12
13
13
14
const generate = async ( ctx : PagesGeneratorContext ) => {
15
+ const version = getFrameworkVersion ( ctx ) ;
16
+
14
17
// TODO: make this interactive when its possible to specify the project name
15
18
// to create-qwik in interactive mode
16
19
await runFrameworkGenerator (
17
20
ctx ,
18
- `${ npm } create qwik@latest basic ${ ctx . project . name } `
21
+ `${ npm } create qwik@${ version } basic ${ ctx . project . name } `
19
22
) ;
20
23
} ;
21
24
Original file line number Diff line number Diff line change 1
1
import { logRaw } from "helpers/cli" ;
2
2
import { detectPackageManager , runFrameworkGenerator } from "helpers/command" ;
3
3
import { compatDateFlag } from "helpers/files" ;
4
+ import { getFrameworkVersion } from "../index" ;
4
5
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
5
6
6
7
const { npm, npx } = detectPackageManager ( ) ;
7
8
8
9
const generate = async ( ctx : PagesGeneratorContext ) => {
10
+ const version = getFrameworkVersion ( ctx ) ;
11
+
9
12
await runFrameworkGenerator (
10
13
ctx ,
11
- `${ npx } create-react-app ${ ctx . project . name } `
14
+ `${ npx } create-react-app@ ${ version } ${ ctx . project . name } `
12
15
) ;
13
16
14
17
logRaw ( "" ) ;
Original file line number Diff line number Diff line change @@ -3,14 +3,17 @@ import {
3
3
detectPackageManager ,
4
4
runFrameworkGenerator ,
5
5
} from "helpers/command.js" ;
6
+ import { getFrameworkVersion } from "../index" ;
6
7
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
7
8
8
9
const { npm, npx } = detectPackageManager ( ) ;
9
10
10
11
const generate = async ( ctx : PagesGeneratorContext ) => {
12
+ const version = getFrameworkVersion ( ctx ) ;
13
+
11
14
await runFrameworkGenerator (
12
15
ctx ,
13
- `${ npx } create-remix@latest ${ ctx . project . name } --template cloudflare-pages`
16
+ `${ npx } create-remix@${ version } ${ ctx . project . name } --template cloudflare-pages`
14
17
) ;
15
18
16
19
logRaw ( "" ) ; // newline
Original file line number Diff line number Diff line change 7
7
runFrameworkGenerator ,
8
8
} from "helpers/command" ;
9
9
import { compatDateFlag , usesTypescript , writeFile } from "helpers/files" ;
10
+ import { getFrameworkVersion } from "../index" ;
10
11
import { viteConfig } from "./templates" ;
11
12
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
12
13
@@ -18,7 +19,8 @@ const generate = async (ctx: PagesGeneratorContext) => {
18
19
process . chdir ( ctx . project . path ) ;
19
20
20
21
// Run the create-solid command
21
- await runFrameworkGenerator ( ctx , `${ npm } create solid@latest` ) ;
22
+ const version = getFrameworkVersion ( ctx ) ;
23
+ await runFrameworkGenerator ( ctx , `${ npm } create solid@${ version } ` ) ;
22
24
23
25
logRaw ( "" ) ;
24
26
} ;
Original file line number Diff line number Diff line change @@ -8,16 +8,18 @@ import {
8
8
runFrameworkGenerator ,
9
9
} from "helpers/command" ;
10
10
import { compatDateFlag , usesTypescript } from "helpers/files" ;
11
+ import { getFrameworkVersion } from "../index" ;
11
12
import { platformInterface } from "./templates" ;
12
13
import type * as recast from "recast" ;
13
14
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
14
15
15
16
const { npm } = detectPackageManager ( ) ;
16
17
17
18
const generate = async ( ctx : PagesGeneratorContext ) => {
19
+ const version = getFrameworkVersion ( ctx ) ;
18
20
await runFrameworkGenerator (
19
21
ctx ,
20
- `${ npm } create svelte@latest ${ ctx . project . name } `
22
+ `${ npm } create svelte@${ version } ${ ctx . project . name } `
21
23
) ;
22
24
23
25
logRaw ( "" ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "angular" : " next" ,
3
+ "astro" : " 3.1.5" ,
4
+ "docusaurus" : " 2.4.1" ,
5
+ "gatsby" : " 5.10.0" ,
6
+ "hono" : " 0.2.0" ,
7
+ "next" : " 13.3.4" ,
8
+ "nuxt" : " 3.4.2" ,
9
+ "qwik" : " 1.1.2" ,
10
+ "react" : " 5.0.1" ,
11
+ "remix" : " 1.16.0" ,
12
+ "solid" : " 0.2.26" ,
13
+ "svelte" : " 4.2.0" ,
14
+ "vue" : " 3.6.4"
15
+ }
Original file line number Diff line number Diff line change 1
1
import { detectPackageManager , runFrameworkGenerator } from "helpers/command" ;
2
2
import { compatDateFlag } from "helpers/files" ;
3
+ import { getFrameworkVersion } from "../index" ;
3
4
import type { PagesGeneratorContext , FrameworkConfig } from "types" ;
4
5
5
6
const { npm, npx } = detectPackageManager ( ) ;
6
7
7
8
const generate = async ( ctx : PagesGeneratorContext ) => {
9
+ const version = getFrameworkVersion ( ctx ) ;
8
10
await runFrameworkGenerator (
9
11
ctx ,
10
- `${ npx } create-vue@latest ${ ctx . project . name } `
12
+ `${ npx } create-vue@${ version } ${ ctx . project . name } `
11
13
) ;
12
14
} ;
13
15
You can’t perform that action at this time.
0 commit comments