Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/project-roots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as path from 'path';
import { logError, logInfo } from './utils/logger';
import { URI } from 'vscode-uri';
import { isGlimmerXProject, isELSAddonRoot, isRootStartingWithFilePath, safeWalkAsync, asyncGetPackageJSON } from './utils/layout-helpers';
import { isGlimmerXProject, isELSAddonRoot, isRootStartingWithFilePath, safeWalkAsync, asyncGetPackageJSON, asyncGetJSON } from './utils/layout-helpers';

import Server from './server';

Expand Down Expand Up @@ -80,6 +80,16 @@ export default class ProjectRoots {
this.ignoredProjects = ignoredProjects;
}

/**
* Returns true If the project is a parent project of an ember project.
* @param root string
*/
async isParentProject(root: string): Promise<boolean> {
const info = await asyncGetJSON(path.join(root, 'package.json'));

return !!info?.['ember-addon']?.projectRoot;
}

async findProjectsInsideRoot(workspaceRoot: string) {
const roots = await safeWalkAsync(workspaceRoot, {
directories: false,
Expand All @@ -93,7 +103,7 @@ export default class ProjectRoots {

if (filePath.endsWith('package.json')) {
try {
if (await isGlimmerXProject(fullPath)) {
if ((await isGlimmerXProject(fullPath)) || (await this.isParentProject(fullPath))) {
await this.onProjectAdd(fullPath);
}
} catch (e) {
Expand Down
14 changes: 13 additions & 1 deletion src/utils/layout-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export interface PackageInfo {
peerDependencies?: StringConfig;
devDependencies?: StringConfig;
dependencies?: StringConfig;
workspaces?: string;
'ember-addon'?: {
projectRoot?: string;
version?: number;
paths?: string[];
before?: string | string[];
Expand Down Expand Up @@ -274,7 +276,17 @@ export async function isGlimmerXProject(root: string) {
}

export async function getProjectAddonsRoots(root: string, resolvedItems: string[] = [], packageFolderName = 'node_modules') {
const pack = await asyncGetPackageJSON(root);
let pack = await asyncGetPackageJSON(root);
const maybeExtraRoot = pack['ember-addon']?.projectRoot;

if (maybeExtraRoot) {
// in case there is a different project root from the current one, then use that to get the dependencies.
if (!isEmberAddon(pack) && maybeExtraRoot) {
const newRoot = path.join(root, maybeExtraRoot);

pack = await asyncGetPackageJSON(newRoot);
}
}

if (resolvedItems.length) {
if (!isEmberAddon(pack)) {
Expand Down