-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deps): dynamic renaming of dependency elements with version #127
- Loading branch information
1 parent
b393085
commit 7eb76f7
Showing
11 changed files
with
145 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license | ||
// See LICENSE in the project root for license information. | ||
|
||
// --------------------------------------------------------------------- | ||
|
||
import { literal, unsafeStatic } from 'lit/static-html.js'; | ||
|
||
export class AuroDependencyVersioning { | ||
|
||
/** | ||
* Generates a unique string to be used for child auro element naming. | ||
* @private | ||
* @param {string} baseName - Defines the first part of the unique element name. | ||
* @param {string} version - Version of the component that will be appended to the baseName. | ||
* @returns {string} - Unique string to be used for naming. | ||
*/ | ||
generateElementName(baseName, version) { | ||
let result = baseName; | ||
|
||
result += '-'; | ||
result += version.replace(/[.]/g, '_'); | ||
|
||
return result; | ||
} | ||
|
||
/** | ||
* Generates a unique string to be used for child auro element naming. | ||
* @param {string} baseName - Defines the first part of the unique element name. | ||
* @param {string} version - Version of the component that will be appended to the baseName. | ||
* @returns {string} - Unique string to be used for naming. | ||
*/ | ||
generateTag(baseName, version, tagClass) { | ||
const elementName = this.generateElementName(baseName, version); | ||
const tag = literal`${unsafeStatic(elementName)}`; | ||
|
||
if (!customElements.get(elementName)) { | ||
customElements.define(elementName, class extends tagClass {}); | ||
} | ||
|
||
return tag; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license | ||
// See LICENSE in the project root for license information. | ||
|
||
// --------------------------------------------------------------------- | ||
|
||
const versionWriter = require("./versionWriter"); | ||
|
||
versionWriter.writeDepVersionFile('@aurodesignsystem/auro-dropdown'); | ||
versionWriter.writeDepVersionFile('@aurodesignsystem/auro-input'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license | ||
// See LICENSE in the project root for license information. | ||
|
||
// --------------------------------------------------------------------- | ||
|
||
function writeDepVersionFile(pkg) { | ||
console.warn('writeDepVersionFile', pkg); | ||
|
||
const fs = require('fs'); | ||
|
||
const path = '../node_modules/' + pkg + '/package.json'; | ||
const json = require(path); | ||
const version = json.version; | ||
const elemSubName = pkg.substring(pkg.indexOf('auro-') + 5); | ||
const versionFilePath = './src/' + elemSubName + 'Version.js'; | ||
|
||
fs.writeFileSync(versionFilePath, `export default '${version}'`); | ||
}; | ||
|
||
// add the code below | ||
module.exports = { writeDepVersionFile }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default '2.9.9' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default '2.14.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.