Skip to content

Commit

Permalink
Merge pull request #35 from collective/disabledPackagesAware
Browse files Browse the repository at this point in the history
Disabled packages aware
  • Loading branch information
ebrehault authored Jun 5, 2023
2 parents 12b1cd2 + 1ac99f7 commit 8a16064
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"singleQuote": true,
"useTabs": false,
"tabWidth": 2,
"bracketSpacing": true
"bracketSpacing": true,
"trailingComma": "all"
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ Properties:
- `url`: Mandatory. Git repository remote URL.
- `branch`: Optional. Branch name, defaults to the remote's default branch. Ignored if `tag` is defined.
- `tag`: Optional. Tag name.
- `develop`: Optional. Boolean, can be toggled on/off to activate/deactivate a package. Default is true.
- `develop`: Optional. Boolean, can be toggled on/off to activate/deactivate a package. If activated, then deactivated afterwards, the package gets removed from `jsconfig` maintaining the synchronization with `mrs.developer.json`. Default is `true`.

## Usage with React
## Usage with (non-TypeScript) React

Create a minimal `jsconfig.json` file in the project root (see https://code.visualstudio.com/docs/languages/jsconfig):

Expand Down
14 changes: 14 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,19 @@ async function develop(options) {
}
}

function disabledPackages(options) {
const mrsDeveloperJSON = JSON.parse(
fs.readFileSync(path.join(options.root || '.', 'mrs.developer.json')),
);

return Object.entries(mrsDeveloperJSON || {})
.filter(([name, config]) => config.develop === false)
.reduce((acc, [name, config]) => {
acc.push(config.package || name);
return acc;
}, []);
}

function writeConfigFile(paths, options, developedPackages) {
// update paths in configFile
const defaultConfigFile = fs.existsSync('./tsconfig.base.json')
Expand All @@ -336,6 +349,7 @@ function writeConfigFile(paths, options, developedPackages) {
: `src/${DEVELOP_DIRECTORY}`,
),
)
.filter(([pkg, path]) => !disabledPackages(options).includes(pkg))
.reduce((acc, [pkg, path]) => {
acc[pkg] = path;
return acc;
Expand Down

0 comments on commit 8a16064

Please sign in to comment.