Skip to content

fix: consider lwc dirs nested under package directories #206

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

Merged
merged 4 commits into from
Oct 30, 2024

Conversation

abdulsattar
Copy link
Collaborator

@abdulsattar abdulsattar commented Oct 18, 2024

What does this PR do?

We consider lwc folders under each package directory in this format: <package-directory>/**/lwc.

force-app/main/default/lwc
force-app/main/customer360/lwc
force-app/test/default/lwc
package/lwc

What issues does this PR fix or reference?

@W-16844177@

Fixes #185, #174, #212

@abdulsattar abdulsattar requested a review from a team as a code owner October 18, 2024 23:04
if (!existsSync(sfdxConfig) || !lstatSync(sfdxConfig).isFile()) {
throw new Error(`sfdx-project.json not found in ${rootDir}`);
if (!packageDirectories || !Array.isArray(packageDirectories)) {
throw new Error('No package directories defined.');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give the user a clue about where to define it and a property name or similar. They can search the docs and figure it out. The error message as-is is not actionable.

Suggested change
throw new Error('No package directories defined.');
throw new Error(`No package directories defined in ${projectJson}.`);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to use the API provided by sfdx. It outputs a clean error like this:

Error (MissingDefaultPathError): In sfdx-project.json, be sure to specify which package directory (path) is the default. Example: `[{ "path": "packageDirectory1", "default": true }, { "path": "packageDirectory2" }]`

const s = await lwcDevServer.startLWCServer(logger, path.resolve(__dirname, './__mocks__'), fakeIdentityToken, '');
expect(s).to.equal(server);
});
// it('calling startLWCServer returns an LWCServer', async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't figure out a way to mock dirs for tests :(

@abdulsattar abdulsattar merged commit a066edb into main Oct 30, 2024
11 checks passed
@abdulsattar abdulsattar deleted the abdulsattar/dirs branch October 30, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Only one (main) LWC folder is being watched
2 participants