Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Force consistent capitalization of Polymer/ PolymerElements and PolymerLabs in bower.json #48

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions cleanup-passes/bower.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ async function cleanupBower(element: ElementRepo): Promise<void> {
return; // no bower to cleanup
}

const fixedCaps = consistentlyCapitalizeDeps(bowerConfig);
if (fixedCaps) {
writeToBower(bowerPath, bowerConfig);
await makeCommit(element, ['bower.json'], 'Use consistent capitalization in bower references of Polymer/, PolymerLabs/, and PolymerElements/');
}

// Clean up nonexistant bower file
if (!bowerConfig['main'] || bowerConfig['main'].length === 0) {
const elemFile = path.basename(element.dir) + '.html';
Expand Down Expand Up @@ -87,6 +93,38 @@ async function cleanupBower(element: ElementRepo): Promise<void> {
}
}

type BowerConfig = {
dependencies?: {[dirname: string]: string};
devDependencies?: {[dirname: string]: string};
}

function consistentlyCapitalizeDeps(bowerConfig: BowerConfig) {
function consistentlyCapitalizeDependenciesObject(deps?: {[dirname: string]: string}) {
let madeChange = false;
if (!deps) {
return false;
}
for (const key in deps) {
const value = deps[key];
const newValue = value
.replace(/^polymerelements\//i, 'PolymerElements/')
.replace(/^polymer\//i, 'Polymer/')
.replace(/^polymerlabs\//i, 'PolymerLabs/');
deps[key] = newValue;
madeChange = madeChange || value !== newValue;
}
return madeChange;
}


let madeChange = consistentlyCapitalizeDependenciesObject(
bowerConfig.dependencies);
madeChange = consistentlyCapitalizeDependenciesObject(
bowerConfig.devDependencies) || madeChange;

return madeChange;
}

register({
name: 'bower',
pass: cleanupBower,
Expand Down
2 changes: 1 addition & 1 deletion cleanup-passes/travis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,5 @@ async function cleanupTravisConfig(element: ElementRepo): Promise<void> {
register({
name: 'travis',
pass: cleanupTravisConfig,
runsByDefault: true,
runsByDefault: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems unrelated. Intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional. We never landed all of the travis fixups, which still need some hand-fixing afaik

});