Commit 4631a4c
packages/cli-tool/src/new.ts
@@ -80,9 +80,7 @@ program
try {
if (cliRootDir) {
projectRootDir = path.resolve(cliRootDir);
- // Verify if the provided rootDir is valid by checking for a known file/dir, e.g., package.json
- // This is a simple check, can be made more robust.
- await fs.access(path.join(projectRootDir, 'package.json'));
+ await fs.access(path.join(projectRootDir, 'astro.config.mjs'));
} else {
projectRootDir = await findMonorepoRoot();
}
packages/cli-tool/src/pub.ts
@@ -1,5 +1,5 @@
import { config as scriptConfig } from './config';
-import { findAvailableFileName, slugify } from './utils';
+import { findAvailableFileName, findMonorepoRoot, slugify } from './utils';
import type { AvailableFileNameInfo } from './utils';
import { L, type Locales } from '@astral-halo/i18n';
import { ExitPromptError } from '@inquirer/core';
@@ -68,8 +68,9 @@ async function updateFrontmatterWithPublishedDate(filePath: string): Promise<voi
}
async function run() {
- const draftsDir = path.resolve(process.cwd(), scriptConfig.draftsDir);
- let postsDir = path.resolve(process.cwd(), scriptConfig.postsDir); // Made postsDir mutable
+ const root = await findMonorepoRoot(process.cwd());
+ const draftsDir = path.resolve(root, scriptConfig.draftsDir);
+ let postsDir = path.resolve(root, scriptConfig.postsDir);
let selectedDraftRelativePath: string | undefined;
packages/cli-tool/src/utils.ts
@@ -137,7 +137,7 @@ export async function findMonorepoRoot(
}
while (true) {
- const workspaceFilePath = path.join(currentDir, 'pnpm-workspace.yaml');
+ const workspaceFilePath = path.join(currentDir, 'astro.config.mjs');
try {
await fs.access(workspaceFilePath);
return currentDir; // Found the file, this is the root
@@ -146,7 +146,7 @@ export async function findMonorepoRoot(
const parentDir = path.dirname(currentDir);
if (parentDir === currentDir) {
// Reached the filesystem root and haven't found the file
- throw new Error("Could not find 'pnpm-workspace.yaml'.");
+ throw new Error("Could not find 'astro.config.mjs'.");
}
currentDir = parentDir;
}