@@ -21,14 +21,9 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
21
21
self . packageName = packageName ;
22
22
self . baseDir = baseDir ;
23
23
self . log = log ;
24
-
25
- // default for platform category
26
24
self . isPWA = false ;
27
-
28
- // default for images output
29
25
self . imagesSubfolder = 'Images' ;
30
26
31
- // get extended configuration settings if available
32
27
if ( extendedCfg ) {
33
28
self . isPWA = extendedCfg . isPWA ;
34
29
self . targetFolder = extendedCfg . targetFolder ;
@@ -75,28 +70,19 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
75
70
return Q . resolve ( ) . nodeify ( callback ) ;
76
71
} ;
77
72
78
- /**
79
- * Loads validation rules from the 'validationRules' folder of the platform project. The
80
- * validation rules ensure the W3C manifest meets the requirements for your platform.
81
- *
82
- * This function is optional. A platform should override it to use a different strategy for
83
- * loading its validation rules.
84
- */
85
- self . getValidationRules = function ( platforms , callback ) {
73
+ self . getValidationRules = function ( platforms , callback ) {
86
74
if ( ! self . baseDir ) {
87
75
self . warn ( 'Missing base directory for platform: ' + self . id + '.' ) ;
88
76
return Q . resolve ( [ ] ) . nodeify ( callback ) ;
89
77
}
90
78
91
- // first look for a 'validationRules' directory
92
79
var validationRulesDir = path . join ( self . baseDir , 'validationRules' ) ;
93
80
return Q . nfcall ( fs . stat , validationRulesDir ) . then ( function ( stats ) {
94
81
if ( stats . isDirectory ( ) ) {
95
82
return manifestTools . loadValidationRules ( validationRulesDir , platforms ) ;
96
83
}
97
84
} )
98
85
. catch ( function ( ) {
99
- // then look for a 'validationRules.js' file
100
86
var validationRulesFile = validationRulesDir + '.js' ;
101
87
return Q . nfcall ( fs . stat , validationRulesFile ) . then ( function ( stats ) {
102
88
if ( stats . isFile ( ) ) {
@@ -112,7 +98,7 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
112
98
113
99
/**
114
100
* Returns an array of icons files as defined in the manifest. The method assumes that all icons
115
- * are are square and defined as properties of an 'icons' member, for example:
101
+ * are square and defined as properties of an 'icons' member, for example:
116
102
* "icons": {
117
103
* "30": "/images/smalllogo.png",
118
104
* "50": "/images/storelogo.png",
@@ -171,9 +157,6 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
171
157
return iconFromGetManifestIcons . fileName || utils . newGuid ( ) + '.png' ;
172
158
} ;
173
159
174
- /**
175
- * Returns the icon uri for an embedded icon in order to set it within the original W3C manifest
176
- */
177
160
self . updateEmbeddedIconUriW3C = function ( uri ) {
178
161
return uri ;
179
162
} ;
@@ -192,7 +175,6 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
192
175
self . updateEmbeddedIconUri = function ( manifest , iconFromGetManifestIcons , uri ) {
193
176
uri = ( '/' + uri ) . replace ( '//' , '/' ) ;
194
177
195
- // updates the converted platform manifest
196
178
var oldUri = iconFromGetManifestIcons . url || iconFromGetManifestIcons ;
197
179
if ( iconFromGetManifestIcons . url ) {
198
180
iconFromGetManifestIcons . url = uri ;
@@ -204,7 +186,6 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
204
186
} ) ;
205
187
}
206
188
207
- // if __w3cManifestInfo is also provided then update it
208
189
if ( manifest . __w3cManifestInfo && manifest . __w3cManifestInfo . content ) {
209
190
( manifest . __w3cManifestInfo . content . icons || [ ] ) . forEach ( function ( icon ) {
210
191
if ( icon . src === oldUri ) {
@@ -278,13 +259,11 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
278
259
self . downloadIcons = function ( manifest , baseUrl , imagesOutputInfo , callback ) {
279
260
self . debug ( 'Downloading the ' + self . id + ' icons...' ) ;
280
261
281
- // defaults for images output folder and manifest icons' path updates
282
262
var rootDir = imagesOutputInfo ;
283
263
var imagesDir = imagesOutputInfo ;
284
264
var relativePath = '' ;
285
265
var updatePaths = false ;
286
266
287
- // if the imagesOutputInfo is object with content
288
267
if ( imagesOutputInfo . rootFolder ) {
289
268
self . debug ( 'Overriding defaults with custom images info: ' + JSON . stringify ( imagesOutputInfo ) ) ;
290
269
@@ -294,7 +273,6 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
294
273
updatePaths = imagesOutputInfo . updatePaths ;
295
274
}
296
275
297
- // download the icons specified in the manifest
298
276
var iconList = manifest . icons ;
299
277
return Q . resolve ( ) . then ( function ( ) {
300
278
if ( iconList ) {
@@ -321,25 +299,19 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
321
299
} ) ;
322
300
} ) ;
323
301
}
324
- } ) . then ( function ( ) { // copy default platform icons to replace any missing icons
325
- // if the platform provided the input w3c manifest then remove it as it's no longer needed
302
+ } ) . then ( function ( ) {
326
303
delete ( manifest . __w3cManifestInfo ) ;
327
304
328
305
var defaultImagesDir = path . join ( self . baseDir , 'assets' , 'images' ) ;
329
306
return fileTools . syncFiles ( defaultImagesDir , imagesDir , {
330
- // filter out default images that do not need to be moved over
331
307
filter : function ( file ) {
332
- // determine the icon dimensions assuming a convention where
333
- // the file name specifies the icon's size (e.g. '50x50.png')
334
308
var size = path . basename ( file , path . extname ( file ) ) ;
335
309
return ! self . getManifestIcon ( manifest , size ) ;
336
310
}
337
311
} ) . then ( function ( files ) {
338
312
files . forEach ( function ( file ) {
339
- // make path relative to imagesDir
340
313
var filePath = path . relative ( imagesDir , file ) ;
341
314
342
- // convention is for file name to specify the icon's size
343
315
var size = path . basename ( file , path . extname ( file ) ) ;
344
316
self . addManifestIcon ( manifest , filePath , size ) ;
345
317
} ) ;
@@ -358,10 +330,6 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
358
330
} ) . nodeify ( callback ) ;
359
331
} ;
360
332
361
- /**
362
- * Copies the documentation to the generated app's folder. All documents must be placed in
363
- * the 'docs' folder of the platform.
364
- */
365
333
self . copyDocumentation = function ( targetPath , platform , callback ) {
366
334
367
335
if ( arguments . length > 1 ) {
@@ -376,16 +344,11 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
376
344
self . info ( 'Copying documentation from \'' + sourcePath + '\' to \'' + targetPath + '\'...' ) ;
377
345
378
346
return fileTools . copyFolder ( sourcePath , targetPath ) . catch ( function ( err ) {
379
- // failure to copy the documentation is not considered fatal, so catch the error and log as a warning
380
347
self . warn ( 'Failed to copy the documentation for the \'' + platform + '\' Cordova platform. ' + err . getMessage ( ) ) ;
381
348
} )
382
349
. nodeify ( callback ) ;
383
350
} ;
384
351
385
- /**
386
- * Writes 'telemetry' information to the generated app's folder, including generation tool version,
387
- * platform package version, generated app URL, and generation date.
388
- */
389
352
self . writeGenerationInfo = function ( manifestInfo , targetPath , callback ) {
390
353
var appModule = packageTools . getPackageInformation ( ) ;
391
354
if ( ! appModule ) {
@@ -421,24 +384,15 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
421
384
. nodeify ( callback ) ;
422
385
} ;
423
386
424
- /**
425
- * Returns bool value indicating if the module is PWA or not
426
- */
427
387
self . isPWAPlatform = function ( ) {
428
388
return self . isPWA ;
429
389
} ;
430
390
431
- /**
432
- * Returns the intermediate output folder
433
- */
434
391
self . getOutputFolder = function ( rootDir ) {
435
392
var targetFolder = self . targetFolder ? self . targetFolder : self . id ;
436
393
return path . join ( rootDir , targetFolder ) ;
437
394
} ;
438
395
439
- /**
440
- * Returns the info for image's output generation
441
- */
442
396
self . getOutputImagesInfo = function ( rootDir ) {
443
397
return {
444
398
rootFolder : rootDir ,
@@ -448,37 +402,22 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
448
402
} ;
449
403
} ;
450
404
451
- /**
452
- * Outputs a debug message to the log.
453
- */
454
405
self . debug = function ( message , source ) {
455
406
self . log . debug ( message , source || self . id ) ;
456
407
} ;
457
408
458
- /**
459
- * Outputs an informational message to the log.
460
- */
461
409
self . info = function ( message , source ) {
462
410
self . log . info ( message , source || self . id ) ;
463
411
} ;
464
412
465
- /**
466
- * Outputs a warning message to the log.
467
- */
468
413
self . warn = function ( message , source ) {
469
414
self . log . warn ( message , source || self . id ) ;
470
415
} ;
471
416
472
- /**
473
- * Outputs an informational message to the log.
474
- */
475
417
self . error = function ( message , source ) {
476
418
self . log . error ( message , source || self . id ) ;
477
419
} ;
478
420
479
- /**
480
- * Outputs a message to the log regardless of the configured logging level.
481
- */
482
421
self . write = function ( message , source ) {
483
422
self . log . write ( message , source || self . id ) ;
484
423
} ;
0 commit comments