@@ -13,23 +13,22 @@ const stringUtils = require('../utility/string');
1313const typescriptUtils = require ( '../utility/typescript-extension' ) ;
1414const removeFile = require ( '../utility/file-operations' ) . remove ;
1515const latestVersions = require ( '../utility/latest-versions' ) ;
16- const { extractToolingVersion } = require ( '../utility/extract-tooling-version' ) ;
1716const defaultStyles = [
1817 'devextreme/dist/css/dx.light.css'
1918] ;
2019
2120const getExtension = ( appPath ) => {
22- return fs . existsSync ( path . join ( appPath , 'src' , 'App.tsx' ) ) ? '.tsx' : '.js ' ;
21+ return fs . existsSync ( path . join ( appPath , 'src' , 'App.tsx' ) ) ? '.tsx' : '.jsx ' ;
2322} ;
2423
2524const pathToPagesIndex = ( ) => {
2625 const extension = getExtension ( process . cwd ( ) ) ;
2726 return path . join ( process . cwd ( ) , 'src' , 'pages' , `index${ extension } ` ) ;
2827} ;
2928
30- const preparePackageJsonForTemplate = ( appPath , appName , isTypeScript ) => {
29+ const preparePackageJsonForTemplate = ( appPath , appName ) => {
3130 const dependencies = [
32- { name : 'sass' , version : '^1.34 .1' } ,
31+ { name : 'sass-embedded ' , version : '^1.85 .1' } ,
3332 { name : 'devextreme-cli' , version : latestVersions [ 'devextreme-cli' ] , dev : true } ,
3433 { name : 'react-router-dom' , version : '^6.3.0' } ,
3534 ] ;
@@ -60,27 +59,25 @@ const create = async(appName, options) => {
6059 layout : stringUtils . classify ( layoutType ) ,
6160 isTypeScript : typescriptUtils . isTypeScript ( templateType )
6261 } ) ;
63- const toolingVersion = extractToolingVersion ( options ) ;
64- const commandArguments = [ `-p=create-react-app${ toolingVersion } ` , 'create-react-app' , appName ] ;
6562
66- const templateSuffix = templateOptions . isTypeScript ? '-typescript' : '' ;
67- const templatePath = path . resolve ( __dirname , `../templates/cra-template${ templateSuffix } ` ) ;
63+ const commandArguments = [ `-p=create-vite@${ latestVersions [ 'create-vite' ] } ` , 'create-vite' , appName ] ;
6864
69- commandArguments . push ( `--template file: ${ templatePath } ` ) ;
65+ commandArguments . push ( `--template react ${ templateOptions . isTypeScript ? '-ts' : '' } ` ) ;
7066
7167 await runCommand ( 'npx' , commandArguments ) ;
7268
7369 const appPath = path . join ( process . cwd ( ) , appName ) ;
7470
7571 modifyIndexHtml ( appPath , templateOptions . project ) ;
72+
7673 addTemplate ( appPath , appName , templateOptions ) ;
7774} ;
7875
7976const modifyIndexHtml = ( appPath , appName ) => {
80- const indexHtmlPath = path . join ( appPath , 'public' , ' index.html') ;
77+ const indexHtmlPath = path . join ( appPath , 'index.html' ) ;
8178
8279 let htmlContent = fs . readFileSync ( indexHtmlPath ) . toString ( ) ;
83- htmlContent = htmlContent . replace ( / < t i t l e > ( \w + \s * ) + < \/ t i t l e > / , `<title>${ appName } <\/title>` ) ;
80+ htmlContent = htmlContent . replace ( / < t i t l e > [ ^ < ] + < \/ t i t l e > / , `<title>${ appName } <\/title>` ) ;
8481 htmlContent = htmlContent . replace ( '<body>' , '<body class="dx-viewport">' ) ;
8582
8683 fs . writeFileSync ( indexHtmlPath , htmlContent ) ;
@@ -97,7 +94,6 @@ const addTemplate = (appPath, appName, templateOptions) => {
9794 ) ;
9895
9996 const manifestPath = path . join ( appPath , 'public' , 'manifest.json' ) ;
100- const indexPath = path . join ( appPath , 'src' , templateOptions . isTypeScript ? 'index.tsx' : 'index.js' ) ;
10197
10298 const styles = [
10399 './themes/generated/theme.additional.css' ,
@@ -108,15 +104,15 @@ const addTemplate = (appPath, appName, templateOptions) => {
108104 ] ;
109105
110106 templateCreator . moveTemplateFilesToProject ( applicationTemplatePath , appPath , templateOptions , getCorrectPath ) ;
111- removeFile ( path . join ( appPath , 'src' , 'App.css' ) ) ;
112- ! templateOptions . isTypeScript && removeFile ( path . join ( appPath , 'src' , 'types.js' ) ) ;
107+
108+ ! templateOptions . isTypeScript && removeFile ( path . join ( appPath , 'src' , 'types.jsx' ) ) ;
109+
113110 if ( ! templateOptions . empty ) {
114111 addSamplePages ( appPath , templateOptions ) ;
115112 }
116113
117114 preparePackageJsonForTemplate ( appPath , appName , templateOptions . isTypeScript ) ;
118115 updateJsonPropName ( manifestPath , appName ) ;
119- addPolyfills ( packageJsonUtils . getPackageJsonPath ( ) , indexPath ) ;
120116 install ( { } , appPath , styles ) ;
121117} ;
122118
@@ -130,15 +126,6 @@ const install = (options, appPath, styles) => {
130126 packageManager . runInstall ( { cwd : appPath } ) ;
131127} ;
132128
133- const addPolyfills = ( packagePath , indexPath ) => {
134- const packages = [
135- { name : 'react-app-polyfill' , version : '^1.0.0' }
136- ] ;
137-
138- packageJsonUtils . addDependencies ( packagePath , packages ) ;
139- moduleUtils . insertImport ( indexPath , './polyfills' ) ;
140- } ;
141-
142129const addStylesToApp = ( filePath , styles ) => {
143130 styles . forEach ( style => {
144131 moduleUtils . insertImport ( filePath , style ) ;
0 commit comments