Created
June 17, 2024 17:25
-
-
Save sullemanhossam/613c638bf57a599dcb1c94108a4e5c49 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // example.js | |
| type Target = string; | |
| interface PackageConfig { | |
| targets: Target[]; | |
| alias: string; | |
| pkg: string; | |
| version: string; | |
| } | |
| class PackageToLink { | |
| constructor( | |
| public targets: Target[], | |
| public alias: string, | |
| public pkg: string, | |
| public version: string | |
| ) {} | |
| } | |
| class PackagesToLink { | |
| packages: PackageToLink[]; | |
| constructor(packages: PackageConfig[]) { | |
| this.packages = packages.map((pkg) => new PackageToLink(pkg.targets, pkg.alias, pkg.pkg, pkg.version)); | |
| } | |
| } | |
| // Example usage: | |
| const packages: PackageConfig[] = [ | |
| { targets: ["remoteLibrary"], alias: "heroicons-v1", pkg: "@heroicons/react", version: "1.4.1" }, | |
| { targets: ["remoteLibrary"], alias: "heroicons-v2", pkg: "@heroicons/react", version: "2.1.3" }, | |
| ]; | |
| const packagesToLink = new PackagesToLink(packages); | |
| console.log(packagesToLink); | |
| // const packagesToLink = [ | |
| // { targets: ["remoteLibrary"], alias: "heroicons-v1", pkg: "@heroicons/react", version: "1.4.1" }, | |
| // { targets: ["remoteLibrary"], alias: "heroicons-v2", pkg: "@heroicons/react", version: "2.1.3" }, | |
| // ]; | |
| // if no version i guess latest would be installed | |
| module.exports = { | |
| packagesToLink: packagesToLink, | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment