Skip to content

Commit

Permalink
fix for single-repo w/o git (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
theoephraim authored Sep 13, 2024
1 parent 0b73d65 commit 00b3984
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-clocks-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"dmno": patch
---

support workspace root detection in single-repo without git
7 changes: 5 additions & 2 deletions packages/core/src/cli/commands/init.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { tryCatch } from '@dmno/ts-lib';

import gradient from 'gradient-string';
import { PackageManager, findDmnoServices, pathExists } from '../../config-loader/find-services';
import { findDmnoServices, pathExists } from '../../config-loader/find-services';
import { DmnoCommand } from '../lib/dmno-command';

import { formatError, formattedValue, joinAndCompact } from '../lib/formatting';
Expand All @@ -23,6 +23,7 @@ import {
import { initDmnoForService } from '../lib/init-helpers';
import { DISCORD_INVITE_URL, GITHUB_REPO_URL } from '../../lib/constants';
import { CliExitError } from '../lib/cli-error';
import { detectJsPackageManager } from '../../lib/detect-package-manager';

const program = new DmnoCommand('init')
.summary('Sets up dmno')
Expand All @@ -46,7 +47,9 @@ program.action(async (opts: {

const rootPath = workspaceInfo.workspacePackages[0].path;

console.log(kleur.gray(`- Package manager: ${workspaceInfo.packageManager}`));
const packageManager = detectJsPackageManager();

console.log(kleur.gray(`- Package manager: ${packageManager.name}`));
console.log(kleur.gray(`- Workspace root path: ${rootPath}`));
if (workspaceInfo.isMonorepo) {
console.log(kleur.gray(`- Monorepo mode: ENABLED (${workspaceInfo.workspacePackages.length - 1} child packages)`));
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/config-loader/find-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export async function findDmnoServices(includeUnitialized = true): Promise<Scann
const filePath = path.join(cwd, globLocation.file);
if (!await pathExists(filePath)) continue;

// assume first package.json file found is root until we find evidence otherwise
if (globLocation.file === 'package.json' && !dmnoWorkspaceRootPath) {
dmnoWorkspaceRootPath = cwd;
}

debug(`looking for workspace globs in ${filePath} > ${globLocation.path}`);
const fileType = path.extname(filePath);
let fileContents: any;
Expand Down

0 comments on commit 00b3984

Please # to comment.