11import {
22 Asset ,
3+ AssetWithContent ,
34 AsyncResult ,
45 DebugIdGenerator ,
56 Err ,
67 Ok ,
8+ RawSourceMap ,
79 ResultPromise ,
810 SourceProcessor ,
911 SymbolUploader ,
@@ -12,9 +14,12 @@ import {
1214 archiveSourceMaps ,
1315 failIfEmpty ,
1416 filter ,
17+ loadSourceMap ,
1518 log ,
1619 map ,
1720 matchSourceMapExtension ,
21+ pass ,
22+ stripSourcesContent ,
1823 uploadArchive ,
1924 writeStream ,
2025} from '@backtrace/sourcemap-tools' ;
@@ -28,18 +33,14 @@ import { CliLogger, createLogger } from '../logger';
2833interface UploadOptions extends GlobalOptions {
2934 readonly url : string ;
3035 readonly path : string [ ] ;
31- readonly 'no -sources' : string ;
36+ readonly 'include -sources' : string ;
3237 readonly insecure : boolean ;
3338 readonly 'dry-run' : boolean ;
3439 readonly force : boolean ;
3540 readonly 'pass-with-no-files' : boolean ;
3641 readonly output : string ;
3742}
3843
39- interface AssetWithDebugId extends Asset {
40- readonly debugId : string ;
41- }
42-
4344export const uploadCmd = new Command < UploadOptions > ( {
4445 name : 'upload' ,
4546 description : 'Uploading of sourcemaps to Backtrace' ,
@@ -61,9 +62,9 @@ export const uploadCmd = new Command<UploadOptions>({
6162 alias : 'p' ,
6263 } )
6364 . option ( {
64- name : 'no -sources' ,
65+ name : 'include -sources' ,
6566 type : Boolean ,
66- description : 'Uploads the sourcemaps without "sourcesContent" key.' ,
67+ description : 'Uploads the sourcemaps with "sourcesContent" key.' ,
6768 defaultValue : false ,
6869 } )
6970 . option ( {
@@ -118,8 +119,8 @@ export const uploadCmd = new Command<UploadOptions>({
118119
119120 const logDebug = log ( logger , 'debug' ) ;
120121 const logTrace = log ( logger , 'trace' ) ;
121- const logTraceAsset = logAsset ( logger , 'trace' ) ;
122122 const logDebugAsset = logAsset ( logger , 'debug' ) ;
123+ const logTraceAsset = logAsset ( logger , 'trace' ) ;
123124
124125 const isAssetProcessedCommand = ( asset : Asset ) =>
125126 AsyncResult . fromValue < Asset , string > ( asset )
@@ -139,17 +140,17 @@ export const uploadCmd = new Command<UploadOptions>({
139140 . then ( filter ( ( f ) => f . result ) )
140141 . then ( map ( ( f ) => f . asset ) ) . inner ;
141142
142- const readDebugIdCommand = ( asset : Asset ) =>
143+ const loadSourceMapCommand = ( asset : Asset ) =>
143144 AsyncResult . fromValue < Asset , string > ( asset )
144- . then ( logTraceAsset ( 'reading debug ID ' ) )
145- . then ( readDebugId ( sourceProcessor ) )
146- . then ( logDebugAsset ( ( res ) => `read debug ID: ${ res . debugId } ` ) )
147- . thenErr ( ( error ) => ` ${ asset . name } : ${ error } ` ) . inner ;
145+ . then ( logTraceAsset ( 'loading sourcemap ' ) )
146+ . then ( loadSourceMap )
147+ . then ( logDebugAsset ( 'loaded sourcemap' ) )
148+ . then ( opts [ 'include-sources' ] ? pass : stripSourcesContent ) . inner ;
148149
149- const createArchiveCommand = ( assets : Asset [ ] ) =>
150- AsyncResult . fromValue < Asset [ ] , string > ( assets )
150+ const createArchiveCommand = ( assets : AssetWithContent < RawSourceMap > [ ] ) =>
151+ AsyncResult . fromValue < AssetWithContent < RawSourceMap > [ ] , string > ( assets )
151152 . then ( logTrace ( 'creating archive' ) )
152- . then ( ( assets ) => archiveSourceMaps ( sourceProcessor ) ( assets . map ( ( a ) => a . path ) ) )
153+ . then ( archiveSourceMaps ( sourceProcessor ) )
153154 . then ( logDebug ( 'archive created' ) ) . inner ;
154155
155156 const saveArchiveCommand = outputPath
@@ -178,7 +179,7 @@ export const uploadCmd = new Command<UploadOptions>({
178179 . then ( map ( logTrace ( ( path ) => `file matching extension: ${ path } ` ) ) )
179180 . then ( map ( toAsset ) )
180181 . then ( opts . force ? Ok : filterProcessedAssetsCommand )
181- . then ( map ( readDebugIdCommand ) )
182+ . then ( map ( loadSourceMapCommand ) )
182183 . then ( logDebug ( ( r ) => `uploading ${ r . length } files` ) )
183184 . then ( map ( logTrace ( ( { path } ) => `file to upload: ${ path } ` ) ) )
184185 . then ( opts [ 'pass-with-no-files' ] ? Ok : failIfEmpty ( 'no files for uploading found' ) )
@@ -200,13 +201,13 @@ function isAssetProcessed(sourceProcessor: SourceProcessor) {
200201 } ;
201202}
202203
203- function readDebugId ( sourceProcessor : SourceProcessor ) {
204- return async function readDebugId ( asset : Asset ) : ResultPromise < AssetWithDebugId , string > {
205- return AsyncResult . equip ( sourceProcessor . getSourceMapFileDebugId ( asset . path ) ) . then < AssetWithDebugId > (
206- ( debugId ) => ( { ...asset , debugId } ) ,
207- ) . inner ;
208- } ;
209- }
204+ // function readDebugId(sourceProcessor: SourceProcessor) {
205+ // return async function readDebugId(asset: Asset): ResultPromise<AssetWithDebugId, string> {
206+ // return AsyncResult.equip(sourceProcessor.getSourceMapFileDebugId(asset.path)).then<AssetWithDebugId>(
207+ // (debugId) => ({ ...asset, debugId }),
208+ // ).inner;
209+ // };
210+ // }
210211
211212function saveArchive ( filePath : string ) {
212213 return async function saveArchive ( stream : Readable ) : ResultPromise < UploadResult , string > {
0 commit comments