diff --git a/package.json b/package.json index 198e11e..f51586d 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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" + } + } } ] }, diff --git a/src/commands/starter.ts b/src/commands/starter.ts index 3c47cea..57b450c 100644 --- a/src/commands/starter.ts +++ b/src/commands/starter.ts @@ -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 } @@ -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, @@ -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') @@ -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: { @@ -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 } @@ -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() } @@ -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[] = [ { diff --git a/src/config.ts b/src/config.ts index 98226c5..6a072b1 100644 --- a/src/config.ts +++ b/src/config.ts @@ -68,6 +68,8 @@ class Config { get createSolidNeedsSsr(): boolean { return this.getConfig('createSolid.needsSsr', true) } // create nest get createNestNeedsTypeScript(): boolean { return this.getConfig('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('globalSettings.needsGitInit', true) } get globalNeedsInstall(): boolean { return this.getConfig('globalSettings.needsInstall', true) } @@ -103,6 +105,8 @@ class Config { public setCreateSolidNeedsSsr(value: boolean): Promise { return this.setConfig('createSolid.needsSsr', value, ConfigurationTarget.Global) } // create nest public setCreateNestNeedsTypeScript(value: boolean): Promise { return this.setConfig('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 { return this.setConfig('createExpoApp.whichTemplate', value, ConfigurationTarget.Global) } // global settings public setGlobalNeedsGitInit(value: boolean): Promise { return this.setConfig('globalSettings.needsGitInit', value, ConfigurationTarget.Global) } public setGlobalNeedsInstall(value: boolean): Promise { return this.setConfig('globalSettings.needsInstall', value, ConfigurationTarget.Global) }