[lit-labs/cli]: Customize Generated Package Name
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 21.8k
- Forks
- 1.1k
- Avg merge
- 18h 25m
- Merged PRs (30d)
- 2
Description
Should this be an RFC?
- This is not a substantial change
Which package is this a feature request for?
Other/unknown (please mention in description)
Description
Currently, the run function in the @lit-labs/cli generator automatically uses the package name from the package.json of the input packages. This process lacks flexibility as it does not provide an option to specify a custom package name for the generated packages. Adding an option to specify a package name will enhance the utility and flexibility of the tool, especially in scenarios where the same package is being used across multiple frameworks with different naming conventions or requirements.
Detailed Description:
The run function accepts several parameters such as packages, frameworks, manifest, outDir, and exclude. However, it does not provide an option to specify a custom name for the generated packages. This limitation forces users to manually rename packages post-generation or adjust their workflows to accommodate the tool's constraints.
Here is the specific section of the code that needs enhancement:
const options = {
package: pkg,
};
const results = await Promise.allSettled(
generators.map(async (generator) => {
await writeFileTree(out, await generator.generate(options, console));
})
);
To address this, an additional parameter should be introduced to the run function, allowing users to specify a custom package name.
Alternatives and Workarounds
Current Workarounds:
- Manual Renaming: After the package is generated, users manually rename the package. This is not efficient and can lead to errors, especially in automated workflows.
- Scripted Rename: Users can write scripts to rename packages post-generation, but this adds unnecessary complexity to the build process.
Proposed Alternative:
Modify the run function to accept an optional packageName parameter. This parameter, if provided, will override the default name taken from package.json. The updated function signature would look like this:
export const run = async (
{
cli,
packages,
frameworks: frameworkNames,
manifest,
outDir,
packageName,
exclude,
}: {
packages: string[];
frameworks: string[];
manifest: boolean;
outDir: string;
packageName?: string;
exclude?: string[];
cli: LitCli;
},
console: Console
) => {
// existing code...
const options = {
package: pkg,
packageName: packageName ?? pkg.packageJson.name,
};
// existing code...
};
Usage:
lit labs gen --framework=react --package-name=custom-package
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the run function in the @lit-labs/cli generator and trace how its options reach generator.generate. Check how the CLI parses generator arguments, then add the optional package-name flow so generated packages use the custom name when supplied and retain the package.json name by default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100