Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit afec264

Browse files
author
Lucas Rojas
committed
Clean comments form platformbase.js
1 parent 5b41ed6 commit afec264

File tree

1 file changed

+3
-64
lines changed

1 file changed

+3
-64
lines changed

lib/platformBase.js

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,9 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
2121
self.packageName = packageName;
2222
self.baseDir = baseDir;
2323
self.log = log;
24-
25-
// default for platform category
2624
self.isPWA = false;
27-
28-
// default for images output
2925
self.imagesSubfolder = 'Images';
3026

31-
// get extended configuration settings if available
3227
if (extendedCfg) {
3328
self.isPWA = extendedCfg.isPWA;
3429
self.targetFolder = extendedCfg.targetFolder;
@@ -75,28 +70,19 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
7570
return Q.resolve().nodeify(callback);
7671
};
7772

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) {
8674
if (!self.baseDir) {
8775
self.warn('Missing base directory for platform: ' + self.id + '.');
8876
return Q.resolve([]).nodeify(callback);
8977
}
9078

91-
// first look for a 'validationRules' directory
9279
var validationRulesDir = path.join(self.baseDir, 'validationRules');
9380
return Q.nfcall(fs.stat, validationRulesDir).then(function (stats) {
9481
if (stats.isDirectory()) {
9582
return manifestTools.loadValidationRules(validationRulesDir, platforms);
9683
}
9784
})
9885
.catch(function () {
99-
// then look for a 'validationRules.js' file
10086
var validationRulesFile = validationRulesDir + '.js';
10187
return Q.nfcall(fs.stat, validationRulesFile).then(function (stats) {
10288
if (stats.isFile()) {
@@ -112,7 +98,7 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
11298

11399
/**
114100
* 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:
116102
* "icons": {
117103
* "30": "/images/smalllogo.png",
118104
* "50": "/images/storelogo.png",
@@ -171,9 +157,6 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
171157
return iconFromGetManifestIcons.fileName || utils.newGuid() + '.png';
172158
};
173159

174-
/**
175-
* Returns the icon uri for an embedded icon in order to set it within the original W3C manifest
176-
*/
177160
self.updateEmbeddedIconUriW3C = function(uri) {
178161
return uri;
179162
};
@@ -192,7 +175,6 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
192175
self.updateEmbeddedIconUri = function(manifest, iconFromGetManifestIcons, uri) {
193176
uri = ('/' + uri).replace('//', '/');
194177

195-
// updates the converted platform manifest
196178
var oldUri = iconFromGetManifestIcons.url || iconFromGetManifestIcons;
197179
if (iconFromGetManifestIcons.url) {
198180
iconFromGetManifestIcons.url = uri;
@@ -204,7 +186,6 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
204186
});
205187
}
206188

207-
// if __w3cManifestInfo is also provided then update it
208189
if (manifest.__w3cManifestInfo && manifest.__w3cManifestInfo.content) {
209190
(manifest.__w3cManifestInfo.content.icons || [ ]).forEach(function(icon) {
210191
if (icon.src === oldUri) {
@@ -278,13 +259,11 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
278259
self.downloadIcons = function (manifest, baseUrl, imagesOutputInfo, callback) {
279260
self.debug('Downloading the ' + self.id + ' icons...');
280261

281-
// defaults for images output folder and manifest icons' path updates
282262
var rootDir = imagesOutputInfo;
283263
var imagesDir = imagesOutputInfo;
284264
var relativePath = '';
285265
var updatePaths = false;
286266

287-
// if the imagesOutputInfo is object with content
288267
if (imagesOutputInfo.rootFolder) {
289268
self.debug('Overriding defaults with custom images info: ' + JSON.stringify(imagesOutputInfo));
290269

@@ -294,7 +273,6 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
294273
updatePaths = imagesOutputInfo.updatePaths;
295274
}
296275

297-
// download the icons specified in the manifest
298276
var iconList = manifest.icons;
299277
return Q.resolve().then(function () {
300278
if (iconList) {
@@ -321,25 +299,19 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
321299
});
322300
});
323301
}
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 () {
326303
delete(manifest.__w3cManifestInfo);
327304

328305
var defaultImagesDir = path.join(self.baseDir, 'assets', 'images');
329306
return fileTools.syncFiles(defaultImagesDir, imagesDir, {
330-
// filter out default images that do not need to be moved over
331307
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')
334308
var size = path.basename(file, path.extname(file));
335309
return !self.getManifestIcon(manifest, size);
336310
}
337311
}).then(function (files) {
338312
files.forEach(function (file) {
339-
// make path relative to imagesDir
340313
var filePath = path.relative(imagesDir, file);
341314

342-
// convention is for file name to specify the icon's size
343315
var size = path.basename(file, path.extname(file));
344316
self.addManifestIcon(manifest, filePath, size);
345317
});
@@ -358,10 +330,6 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
358330
}).nodeify(callback);
359331
};
360332

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-
*/
365333
self.copyDocumentation = function (targetPath, platform, callback) {
366334

367335
if (arguments.length > 1) {
@@ -376,16 +344,11 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
376344
self.info('Copying documentation from \'' + sourcePath + '\' to \'' + targetPath + '\'...');
377345

378346
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
380347
self.warn('Failed to copy the documentation for the \'' + platform + '\' Cordova platform. ' + err.getMessage());
381348
})
382349
.nodeify(callback);
383350
};
384351

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-
*/
389352
self.writeGenerationInfo = function (manifestInfo, targetPath, callback) {
390353
var appModule = packageTools.getPackageInformation();
391354
if (!appModule) {
@@ -421,24 +384,15 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
421384
.nodeify(callback);
422385
};
423386

424-
/**
425-
* Returns bool value indicating if the module is PWA or not
426-
*/
427387
self.isPWAPlatform = function() {
428388
return self.isPWA;
429389
};
430390

431-
/**
432-
* Returns the intermediate output folder
433-
*/
434391
self.getOutputFolder = function(rootDir) {
435392
var targetFolder = self.targetFolder ? self.targetFolder : self.id;
436393
return path.join(rootDir, targetFolder);
437394
};
438395

439-
/**
440-
* Returns the info for image's output generation
441-
*/
442396
self.getOutputImagesInfo = function(rootDir) {
443397
return {
444398
rootFolder: rootDir,
@@ -448,37 +402,22 @@ function PlatformBase (id, name, packageName, baseDir, extendedCfg) {
448402
};
449403
};
450404

451-
/**
452-
* Outputs a debug message to the log.
453-
*/
454405
self.debug = function (message, source) {
455406
self.log.debug(message, source || self.id);
456407
};
457408

458-
/**
459-
* Outputs an informational message to the log.
460-
*/
461409
self.info = function (message, source) {
462410
self.log.info(message, source || self.id);
463411
};
464412

465-
/**
466-
* Outputs a warning message to the log.
467-
*/
468413
self.warn = function (message, source) {
469414
self.log.warn(message, source || self.id);
470415
};
471416

472-
/**
473-
* Outputs an informational message to the log.
474-
*/
475417
self.error = function (message, source) {
476418
self.log.error(message, source || self.id);
477419
};
478420

479-
/**
480-
* Outputs a message to the log regardless of the configured logging level.
481-
*/
482421
self.write = function (message, source) {
483422
self.log.write(message, source || self.id);
484423
};

0 commit comments

Comments
 (0)