1
- import * as path from "path" ;
2
1
import * as vscode from "vscode" ;
3
- import { transports , format } from "winston" ;
4
- import stripAnsi from "strip-ansi" ;
5
- import { SPLAT } from "triple-beam" ;
6
2
import { ExtensionContext , workspace } from "vscode" ;
7
3
8
4
import { FirebaseProjectMetadata } from "../../src/types/project" ;
@@ -19,16 +15,13 @@ import {
19
15
import { User } from "../../src/types/auth" ;
20
16
import { currentOptions } from "./options" ;
21
17
import { selectProjectInMonospace } from "../../src/monospace" ;
22
- import { setupLoggers , tryStringify } from "../../src/utils" ;
23
- import { pluginLogger } from "./logger-wrapper" ;
24
- import { logger } from '../../src/logger' ;
18
+ import { logSetup , pluginLogger , showOutputChannel } from "./logger-wrapper" ;
25
19
import { discover } from "../../src/frameworks" ;
26
20
import { setEnabled } from "../../src/experiments" ;
27
21
import {
28
22
readAndSendFirebaseConfigs ,
29
23
setupFirebaseJsonAndRcFileSystemWatcher ,
30
- updateFirebaseRCProject ,
31
- getRootFolders
24
+ updateFirebaseRCProject
32
25
} from "./config-files" ;
33
26
import { ServiceAccountUser } from "../common/types" ;
34
27
@@ -37,6 +30,7 @@ export let currentUser: User | ServiceAccountUser;
37
30
// Stores a mapping from user email to list of projects for that user
38
31
let projectsUserMapping = new Map < string , FirebaseProjectMetadata [ ] > ( ) ;
39
32
let channels = null ;
33
+ let currentFramework : string | undefined ;
40
34
41
35
async function fetchUsers ( ) {
42
36
const accounts = await getAccounts ( ) ;
@@ -116,32 +110,8 @@ export async function setupWorkflow(
116
110
if ( useFrameworks ) {
117
111
setEnabled ( 'webframeworks' , true ) ;
118
112
}
119
- /**
120
- * Logging setup for logging to console and to file.
121
- */
122
- // Sets up CLI logger to log to console
123
- process . env . DEBUG = 'true' ;
124
- setupLoggers ( ) ;
125
113
126
- // Only log to file if firebase.debug extension setting is true.
127
- if ( shouldWriteDebug ) {
128
- // Re-implement file logger call from ../../src/bin/firebase.ts to not bring
129
- // in the entire firebase.ts file
130
- const rootFolders = getRootFolders ( ) ;
131
- const filePath = debugLogPath || path . join ( rootFolders [ 0 ] , 'firebase-plugin-debug.log' ) ;
132
- pluginLogger . info ( 'Logging to path' , filePath ) ;
133
- logger . add (
134
- new transports . File ( {
135
- level : "debug" ,
136
- filename : filePath ,
137
- format : format . printf ( ( info ) => {
138
- const segments = [ info . message , ...( info [ SPLAT ] || [ ] ) ]
139
- . map ( tryStringify ) ;
140
- return `[${ info . level } ] ${ stripAnsi ( segments . join ( " " ) ) } ` ;
141
- } ) ,
142
- } )
143
- ) ;
144
- }
114
+ logSetup ( { shouldWriteDebug, debugLogPath } ) ;
145
115
146
116
/**
147
117
* Call pluginLogger with log arguments received from webview.
@@ -227,6 +197,9 @@ export async function setupWorkflow(
227
197
broker . on ( "selectAndInitHostingFolder" , selectAndInitHosting ) ;
228
198
229
199
broker . on ( "hostingDeploy" , async ( { target : deployTarget } ) => {
200
+ showOutputChannel ( ) ;
201
+ pluginLogger . info ( `Starting deployment of project `
202
+ + `${ currentOptions . projectId } to channel: ${ deployTarget } ` ) ;
230
203
const { success, consoleUrl, hostingUrl } = await deployToHosting (
231
204
currentOptions . config ,
232
205
deployTarget
@@ -323,14 +296,14 @@ export async function setupWorkflow(
323
296
}
324
297
325
298
async function selectAndInitHosting ( { projectId, singleAppSupport } ) {
326
- let discoveredFramework ;
299
+ currentFramework = undefined ;
327
300
// Note: discover() takes a few seconds. No need to block users that don't
328
301
// have frameworks support enabled.
329
302
if ( useFrameworks ) {
330
- discoveredFramework = useFrameworks && await discover ( currentOptions . cwd , false ) ;
303
+ currentFramework = useFrameworks && await discover ( currentOptions . cwd , false ) ;
331
304
pluginLogger . debug ( 'Searching for a web framework in this project.' ) ;
332
305
}
333
- if ( discoveredFramework ) {
306
+ if ( currentFramework ) {
334
307
pluginLogger . debug ( 'Detected web framework, launching frameworks init.' ) ;
335
308
await initHosting ( {
336
309
spa : singleAppSupport ,
@@ -358,7 +331,7 @@ export async function setupWorkflow(
358
331
}
359
332
readAndSendFirebaseConfigs ( broker , context ) ;
360
333
broker . send ( "notifyHostingInitDone" ,
361
- { projectId, folderPath : currentOptions . cwd } ) ;
334
+ { projectId, folderPath : currentOptions . cwd , framework : currentFramework } ) ;
362
335
await fetchChannels ( true ) ;
363
336
}
364
337
}
0 commit comments