New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selecting workspaces in a monorepo #395
Comments
Hi, i would like to use the tool for the same purposes:
example:
so I have workspaces
at the root folder I would like to run command: then ask user to select the workspace where they would like to create a new component and generate a folder for it based on the selected workspace. Probably someone has a receipt or example for this use case? |
I'm also in a monorepo with workspaces, but I'm not actually parsing the paths from the
const fs = require('fs');
const exclude = ['things-to-ignore', '.DS_Store'];
const dirs = fs.readdirSync('./src/apps');
const apps = dirs.reduce((acc, d) => {
if (!exclude.includes(d)) acc.push({ name: d, value: d });
return acc;
}, []);
module.exports = [
{
type: 'input',
name: 'name',
message: 'Package name',
},
{
type: 'multiselect',
name: 'apps',
message: 'Which App to add to?',
limit: 5,
choices: apps,
},
]; For your use case @nareshbhatia you could use a glob to get the directory list for both the |
Thank you for your suggestion, @jamlen. Since I posted this issue, I wrote my own code generation framework that is built from ground up to be monorepo friendly. Would love to see your feedback: https://www.code-shaper.dev/ |
I am writing a generator for a monorepo that uses npm Workspaces. The workspaces are defined in package.json like this:
The actual monorepo layout looks like this. Note that there is 1 app and 3 packages.
What's the best way to prompt the user with a select which populates the choices dynamically with values
['movie-magic', 'config', 'tsconfig', 'ui-lib']
?The approach could be something like this:
workspaces
list from package.json. In the above example, it will be["apps/*", "packages/*"]
.['movie-magic', 'config', 'tsconfig', 'ui-lib']
.Has anyone attempted something like this before? Any pointers?
The text was updated successfully, but these errors were encountered: