Extend with desktop platform
This commit is contained in:
parent
40391cab57
commit
9edffebee0
|
@ -105,6 +105,9 @@ platformMeta =
|
||||||
'wpf':
|
'wpf':
|
||||||
name: "WPF"
|
name: "WPF"
|
||||||
sources: ["core.cljs"]
|
sources: ["core.cljs"]
|
||||||
|
'desktop':
|
||||||
|
name: 'desktop'
|
||||||
|
sources: ["core.cljs"]
|
||||||
|
|
||||||
log = (s, color = 'green') ->
|
log = (s, color = 'green') ->
|
||||||
console.log chalk[color] s
|
console.log chalk[color] s
|
||||||
|
@ -501,6 +504,9 @@ generateReactNativeProject = (projName) ->
|
||||||
mainApplicationPath = "android/app/src/main/java/com/#{projName.toLowerCase()}/MainApplication.java"
|
mainApplicationPath = "android/app/src/main/java/com/#{projName.toLowerCase()}/MainApplication.java"
|
||||||
edit mainApplicationPath, [[/@Override\s+.*getJSMainModuleName.*\s+.*\s+}/g, ""]]
|
edit mainApplicationPath, [[/@Override\s+.*getJSMainModuleName.*\s+.*\s+}/g, ""]]
|
||||||
|
|
||||||
|
generateDesktopProject = (projName) ->
|
||||||
|
log 'Not implemented: Creating React Native Desktop project.'
|
||||||
|
|
||||||
generateWindowsProject = (projName) ->
|
generateWindowsProject = (projName) ->
|
||||||
log 'Creating React Native windows project.'
|
log 'Creating React Native windows project.'
|
||||||
exec "node -e \"require('react-native-windows/local-cli/generate-windows')('.', '#{projName}', '#{projName}')\""
|
exec "node -e \"require('react-native-windows/local-cli/generate-windows')('.', '#{projName}', '#{projName}')\""
|
||||||
|
@ -570,6 +576,9 @@ init = (interfaceName, projName, platforms) ->
|
||||||
if 'windows' in platforms || 'wpf' in platforms
|
if 'windows' in platforms || 'wpf' in platforms
|
||||||
pkg.dependencies['react-native-windows'] = rnWinVersion
|
pkg.dependencies['react-native-windows'] = rnWinVersion
|
||||||
|
|
||||||
|
if 'desktop' in platforms
|
||||||
|
log 'TODO: Inject dependencies on react-native-desktop instead of react-native'
|
||||||
|
|
||||||
fs.writeFileSync 'package.json', JSON.stringify pkg, null, 2
|
fs.writeFileSync 'package.json', JSON.stringify pkg, null, 2
|
||||||
|
|
||||||
installDeps()
|
installDeps()
|
||||||
|
@ -584,6 +593,9 @@ init = (interfaceName, projName, platforms) ->
|
||||||
if 'wpf' in platforms
|
if 'wpf' in platforms
|
||||||
generateWpfProject(projName)
|
generateWpfProject(projName)
|
||||||
|
|
||||||
|
if 'desktop' in platforms
|
||||||
|
generateDesktopProject(projName)
|
||||||
|
|
||||||
updateGitIgnore(platforms)
|
updateGitIgnore(platforms)
|
||||||
|
|
||||||
config = generateConfig(interfaceName, platforms, projName)
|
config = generateConfig(interfaceName, platforms, projName)
|
||||||
|
@ -814,6 +826,9 @@ doUpgrade = (config) ->
|
||||||
android:
|
android:
|
||||||
host: "localhost"
|
host: "localhost"
|
||||||
modules: []
|
modules: []
|
||||||
|
desktop:
|
||||||
|
host: "localhost"
|
||||||
|
modules: []
|
||||||
|
|
||||||
if config.iosHost?
|
if config.iosHost?
|
||||||
config.platforms.ios.host = config.iosHost
|
config.platforms.ios.host = config.iosHost
|
||||||
|
@ -823,6 +838,10 @@ doUpgrade = (config) ->
|
||||||
config.platforms.android.host = config.androidHost
|
config.platforms.android.host = config.androidHost
|
||||||
delete config.androidHost
|
delete config.androidHost
|
||||||
|
|
||||||
|
if config.desktopHost?
|
||||||
|
config.platforms.desktop.host = config.desktopHost
|
||||||
|
delete config.desktopHost
|
||||||
|
|
||||||
if config.modulesPlatform?
|
if config.modulesPlatform?
|
||||||
if config.modulesPlatform.ios?
|
if config.modulesPlatform.ios?
|
||||||
config.platforms.ios.modules = config.platforms.ios.modules.concat(config.modulesPlatform.ios)
|
config.platforms.ios.modules = config.platforms.ios.modules.concat(config.modulesPlatform.ios)
|
||||||
|
@ -830,6 +849,9 @@ doUpgrade = (config) ->
|
||||||
if config.modulesPlatform.android?
|
if config.modulesPlatform.android?
|
||||||
config.platforms.android.modules = config.platforms.android.modules.concat(config.modulesPlatform.android)
|
config.platforms.android.modules = config.platforms.android.modules.concat(config.modulesPlatform.android)
|
||||||
|
|
||||||
|
if config.modulesPlatform.desktop?
|
||||||
|
config.platforms.desktop.modules = config.platforms.desktop.modules.concat(config.modulesPlatform.desktop)
|
||||||
|
|
||||||
delete config.modulesPlatform
|
delete config.modulesPlatform
|
||||||
|
|
||||||
writeConfig(config)
|
writeConfig(config)
|
||||||
|
@ -916,6 +938,7 @@ cli.command 'init <name>'
|
||||||
.option "-i, --interface [#{interfaceNames.join ' '}]", 'specify React interface', defaultInterface
|
.option "-i, --interface [#{interfaceNames.join ' '}]", 'specify React interface', defaultInterface
|
||||||
.option '-u, --uwp', 'create project for UWP app'
|
.option '-u, --uwp', 'create project for UWP app'
|
||||||
.option '-w, --wpf', 'create project for WPF app'
|
.option '-w, --wpf', 'create project for WPF app'
|
||||||
|
.option '-d, --desktop', 'create project for desktop app'
|
||||||
.action (name, cmd) ->
|
.action (name, cmd) ->
|
||||||
if typeof name isnt 'string'
|
if typeof name isnt 'string'
|
||||||
logErr '''
|
logErr '''
|
||||||
|
@ -930,6 +953,8 @@ cli.command 'init <name>'
|
||||||
platforms.push 'windows'
|
platforms.push 'windows'
|
||||||
if cmd.wpf?
|
if cmd.wpf?
|
||||||
platforms.push 'wpf'
|
platforms.push 'wpf'
|
||||||
|
if cmd.desktop?
|
||||||
|
platforms.push 'desktop'
|
||||||
ensureFreePort -> init(cmd.interface, name, platforms)
|
ensureFreePort -> init(cmd.interface, name, platforms)
|
||||||
|
|
||||||
cli.command 'upgrade'
|
cli.command 'upgrade'
|
||||||
|
@ -938,7 +963,7 @@ cli.command 'upgrade'
|
||||||
doUpgrade readConfig()
|
doUpgrade readConfig()
|
||||||
|
|
||||||
cli.command 'add-platform <platform>'
|
cli.command 'add-platform <platform>'
|
||||||
.description 'adds additional app platform: \'windows\' - UWP app, \'wpf\' - WPF app'
|
.description 'adds additional app platform: \'windows\' - UWP app, \'wpf\' - WPF app, \'desktop\' - desktop app'
|
||||||
.action (platform) ->
|
.action (platform) ->
|
||||||
addPlatform(platform)
|
addPlatform(platform)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue