Skip to content

Commit

Permalink
Merge pull request #3563 from cloudfoundry-incubator/add-customize-lo…
Browse files Browse the repository at this point in the history
…gging

Add logging for the customize task
  • Loading branch information
richard-cox authored May 3, 2019
2 parents f6c7a37 + d021974 commit 76f4377
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions build/customize-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@
doShowVersions()
doCustomize(false);
doGenerateIndexHtml(true);
console.log('Finished applying customizations')
cb();
});

// Apply defaults instead of any customizations that are available in custom-src
gulp.task('customize-default', function (cb) {
doCustomize(true);
doGenerateIndexHtml(false);
console.log('Finished applying default customizations')
cb();
});

// Remove all customizations (removes all symlinks as if customize had not been run)
gulp.task('customize-reset', function (cb) {
doCustomize(true, true);
doGenerateIndexHtml(false);
console.log('Finished resetting customizations')
cb();
});

Expand Down Expand Up @@ -112,6 +115,7 @@

if (!reset) {
fs.symlinkSync(srcFile, destFile);
console.log(' + Linking file : ' + srcFile + ' ==> ' + destFile);
}
})

Expand All @@ -133,20 +137,18 @@
}
if (!reset && fs.existsSync(srcFolder)) {
fs.symlinkSync(srcFolder, destFolder);
console.log(' + Linking folder : ' + srcFolder + ' ==> ' + destFolder);
}
});
}

// Copy the correct custom module to either import the supplied custom module or provide an empty module
function doCustomizeCreateModule(forceDefaults, reset, customConfig, baseFolder, customBaseFolder) {
const defaultSrcFolder = path.resolve(__dirname, '../src/frontend/packages/core/misc/custom');
console.log(baseFolder);
const destFile = path.join(baseFolder, 'src/custom-import.module.ts');
const customModuleFile = path.join(baseFolder, 'src/custom/custom.module.ts');
const customRoutingModuleFile = path.join(baseFolder, 'src/custom/custom-routing.module.ts');

console.log(customModuleFile);

// Delete the existing file if it exists
if (fs.existsSync(destFile)) {
fs.unlinkSync(destFile)
Expand All @@ -158,9 +160,15 @@
srcFile = 'custom-src.module.ts_';
if (fs.existsSync(customRoutingModuleFile)) {
srcFile = 'custom-src-routing.module.ts_';
console.log(' + Found custom module with routing');
} else {
console.log(' + Found custom module without routing');
}
} else {
console.log(' + No custom module found - linking empty custom module');
}
fs.copySync(path.join(defaultSrcFolder, srcFile), destFile);
console.log(' + Copying file : ' + path.join(defaultSrcFolder, srcFile) + ' ==> ' + destFile);
}
}

Expand Down Expand Up @@ -208,6 +216,8 @@

// Generate index.html from template
function doGenerateIndexHtml(customize) {

console.log(' + Generating index.html');
// Copy the default
fs.copySync(INDEX_TEMPLATE, INDEX_HTML);

Expand All @@ -223,6 +233,10 @@
}
}

if (metadata.title) {
console.log(' + Overridding title to: "' + metadata.title + '"');
}

// Patch different page title if there is one
var title = metadata.title || 'Stratos';
replace.sync({ files: INDEX_HTML, from: /@@TITLE@@/g, to: title });
Expand All @@ -236,6 +250,7 @@

if (fs.existsSync(GIT_METADATA)) {
gitMetadata = JSON.parse(fs.readFileSync(GIT_METADATA));
console.log(" + Project Metadata: " + JSON.stringify(gitMetadata));
}

// Git Information
Expand Down Expand Up @@ -273,4 +288,4 @@
}
}

})();
})();

0 comments on commit 76f4377

Please sign in to comment.