Skip to content

Instantly share code, notes, and snippets.

@sullemanhossam
Created June 17, 2024 17:25
Show Gist options
  • Select an option

  • Save sullemanhossam/613c638bf57a599dcb1c94108a4e5c49 to your computer and use it in GitHub Desktop.

Select an option

Save sullemanhossam/613c638bf57a599dcb1c94108a4e5c49 to your computer and use it in GitHub Desktop.
// 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