Skip to content

Commit

Permalink
feat: support create-expo-app
Browse files Browse the repository at this point in the history
  • Loading branch information
yrming committed Jan 10, 2024
1 parent 30efe72 commit b26fdfe
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 3 deletions.
19 changes: 18 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"publisher": "YRM",
"name": "starter-templates",
"displayName": "Starters",
"version": "0.11.0",
"version": "0.12.0",
"description": "Kickstart your project with a starter in VSCode",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -265,6 +265,23 @@
"scope": "window"
}
}
},
{
"title": "Create Expo App(Official)",
"order": 7,
"properties": {
"starters.createExpoApp.whichTemplate": {
"enum": [
"expo-template-blank",
"expo-template-blank-typescript",
"expo-template-tabs",
"expo-template-bare-minimum"
],
"default": "expo-template-blank-typescript",
"description": "Which template do you want to use?",
"scope": "window"
}
}
}
]
},
Expand Down
53 changes: 51 additions & 2 deletions src/commands/starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export class StarterCommands extends BaseCommands {
case 'nest-cli':
await this.handleCreateNest(projectName)
break

case 'create-expo-app':
await this.handleCreateExpoApp(projectPath!)
break
default:
break
}
Expand All @@ -114,7 +116,6 @@ export class StarterCommands extends BaseCommands {
private async handleCommonActions(projectPath: string) {
if (config.globalNeedsGitInit)
await $`git init ${projectPath!}`

if (config.globalNeedsInstall) {
await window.withProgress({
location: ProgressLocation.Notification,
Expand All @@ -133,12 +134,17 @@ export class StarterCommands extends BaseCommands {
})
}
catch (error) {
console.log(error)
window.showWarningMessage('Failed to install dependencies!')
}
})
}
}

private async handleCreateExpoApp(projectPath: string) {
await degit(`expo/expo/templates/${config.createExpoAppWhichAppTemplate}`).clone(`${projectPath}`)
}

private async handleCreateNest(projectName: string) {
const args = []
args.push('--package-manager')
Expand Down Expand Up @@ -468,6 +474,10 @@ export class StarterCommands extends BaseCommands {
detail: 'WebExtension Vite Starter Template',
template: { id: 'vitesse-webext', defaultProjectName: 'webext-vitesse-project' },
},
{
kind: QuickPickItemKind.Separator,
label: 'Nest',
},
{
label: 'Nest CLI(Official)',
iconPath: {
Expand All @@ -477,6 +487,19 @@ export class StarterCommands extends BaseCommands {
detail: 'CLI tool for Nest applications',
template: { id: 'nest-cli', defaultProjectName: 'nest-project' },
},
{
kind: QuickPickItemKind.Separator,
label: 'Expo',
},
{
label: 'Create Expo App(Official)',
iconPath: {
dark: Uri.file(this.context.asAbsolutePath('resources/expo.png')),
light: Uri.file(this.context.asAbsolutePath('resources/expo.png')),
},
detail: 'The fastest way to create universal React apps',
template: { id: 'create-expo-app', defaultProjectName: 'expo-project' },
},
]
return templates
}
Expand Down Expand Up @@ -563,6 +586,8 @@ export class StarterCommands extends BaseCommands {
return [...this.getCurrentCreateSettingsOfCreateSolid(), ...this.getGlobalSettings()]
case 'nest-cli':
return [...this.getCurrentCreateSettingsOfCreateNest(), ...this.getGlobalSettings()]
case 'create-expo-app':
return [...this.getCurrentCreateSettingsOfCreateExpoApp(), ...this.getGlobalSettings()]
default:
return this.getGlobalSettings()
}
Expand Down Expand Up @@ -815,6 +840,30 @@ export class StarterCommands extends BaseCommands {
return createSvelteSettings
}

private getCurrentCreateSettingsOfCreateExpoApp() {
const createExpoSettings: PickableSetting[] = [
{
kind: QuickPickItemKind.Separator,
label: 'Create Expo App',
},
{
currentValue: config.createExpoAppWhichAppTemplate || 'expo-template-blank-typescript',
description: config.createExpoAppWhichAppTemplate || 'expo-template-blank-typescript',
detail: '',
enumValues: [
'expo-template-blank',
'expo-template-blank-typescript',
'expo-template-tabs',
'expo-template-bare-minimum'
],
label: 'Which template do you want to use?',
setValue: (newValue: 'expo-template-blank' | 'expo-template-blank-typescript' | 'expo-template-tabs' | 'expo-template-bare-minimum') => config.setCreateExpoAppWhichAppTemplate(newValue),
settingKind: 'ENUM',
},
]
return createExpoSettings
}

private getCurrentCreateSettingsOfCreateSolid() {
const createSolidSettings: PickableSetting[] = [
{
Expand Down
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class Config {
get createSolidNeedsSsr(): boolean { return this.getConfig<boolean>('createSolid.needsSsr', true) }
// create nest
get createNestNeedsTypeScript(): boolean { return this.getConfig<boolean>('createNest.needsTypeScript', true) }
// create expo app
get createExpoAppWhichAppTemplate(): 'expo-template-blank' | 'expo-template-blank-typescript' | 'expo-template-tabs' | 'expo-template-bare-minimum' { return this.getConfig<'expo-template-blank' | 'expo-template-blank-typescript' | 'expo-template-tabs' | 'expo-template-bare-minimum'>('createExpoApp.whichTemplate', 'expo-template-blank-typescript') }
// global settings
get globalNeedsGitInit(): boolean { return this.getConfig<boolean>('globalSettings.needsGitInit', true) }
get globalNeedsInstall(): boolean { return this.getConfig<boolean>('globalSettings.needsInstall', true) }
Expand Down Expand Up @@ -103,6 +105,8 @@ class Config {
public setCreateSolidNeedsSsr(value: boolean): Promise<void> { return this.setConfig<boolean>('createSolid.needsSsr', value, ConfigurationTarget.Global) }
// create nest
public setCreateNestNeedsTypeScript(value: boolean): Promise<void> { return this.setConfig<boolean>('createNest.needsTypeScript', value, ConfigurationTarget.Global) }
// create expo app
public setCreateExpoAppWhichAppTemplate(value: 'expo-template-blank' | 'expo-template-blank-typescript' | 'expo-template-tabs' | 'expo-template-bare-minimum'): Promise<void> { return this.setConfig('createExpoApp.whichTemplate', value, ConfigurationTarget.Global) }
// global settings
public setGlobalNeedsGitInit(value: boolean): Promise<void> { return this.setConfig('globalSettings.needsGitInit', value, ConfigurationTarget.Global) }
public setGlobalNeedsInstall(value: boolean): Promise<void> { return this.setConfig('globalSettings.needsInstall', value, ConfigurationTarget.Global) }
Expand Down

0 comments on commit b26fdfe

Please sign in to comment.