diff --git a/package.json b/package.json index f0ce7f5cf8..79a02a4b50 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,12 @@ "react-dom": "^18.3.1" }, "devDependencies": { - "@graphcommerce/cli": "9.0.0-canary.107", + "@graphcommerce/cli": "workspace:^", + "@graphcommerce/eslint-config-pwa": "workspace:^", + "@graphcommerce/hygraph-cli": "workspace:^", + "@graphcommerce/next-config": "workspace:^", + "@graphcommerce/prettier-config-pwa": "workspace:^", + "@graphcommerce/typescript-config-pwa": "workspace:^", "@graphql-codegen/testing": "3.0.4", "@playwright/test": "1.49.0", "@testing-library/dom": "^10.4.0", diff --git a/packages/cli/dist/bin/is-monorepo.js b/packages/cli/dist/bin/is-monorepo.js index 1f52b72dfb..f371583116 100755 --- a/packages/cli/dist/bin/is-monorepo.js +++ b/packages/cli/dist/bin/is-monorepo.js @@ -1,6 +1,5 @@ #!/usr/bin/env node import { spawn } from 'node:child_process'; -import 'node:fs'; import path from 'node:path'; import { findParentPath } from '@graphcommerce/next-config'; import { detect } from 'detect-package-manager'; diff --git a/packages/cli/src/bin/is-monorepo.ts b/packages/cli/src/bin/is-monorepo.ts index 5521ce3a63..c07f9b38db 100755 --- a/packages/cli/src/bin/is-monorepo.ts +++ b/packages/cli/src/bin/is-monorepo.ts @@ -1,9 +1,8 @@ #!/usr/bin/env node import type { ChildProcess } from 'node:child_process' import { spawn } from 'node:child_process' -import fs from 'node:fs' import path from 'node:path' -import { findParentPath, isMonorepo } from '@graphcommerce/next-config' +import { findParentPath } from '@graphcommerce/next-config' import { detect } from 'detect-package-manager' const debug = process.env.DEBUG === '1' @@ -11,28 +10,6 @@ const debug = process.env.DEBUG === '1' const log = (message: string) => debug && console.log(`is-monorepo: ${message}`) const logError = (message: string) => console.error(`is-monorepo: ${message}`) -/** Find the nearest parent directory containing a @graphcommerce/* package */ -function findRootDir(startDir: string): string | null { - // Start from the parent directory to find a parent @graphcommerce package - let currentDir = path.dirname(startDir) - log(`Looking for parent packages starting from: ${currentDir}`) - - while (currentDir !== path.parse(currentDir).root) { - try { - const packageJson = JSON.parse(fs.readFileSync(path.join(currentDir, 'package.json'), 'utf8')) - if (packageJson.name.startsWith('@graphcommerce/')) { - log(`Found root directory at: ${currentDir}`) - return currentDir - } - } catch { - // Continue if package.json doesn't exist or can't be parsed - } - currentDir = path.dirname(currentDir) - } - - return null -} - /** * Executes a command depending if we're running in a monorepo or not. Usage: is-monorepo '[pkgrun] * run my-script' '[pkgrun] run my-other-script' @@ -43,7 +20,6 @@ function findRootDir(startDir: string): string | null { * - Npm -> 'npm run' */ async function main() { - // const isMono = isMonorepo() const parentPath = findParentPath(process.cwd()) const command = parentPath ? process.argv.slice(2)[0] : process.argv.slice(2)[1] diff --git a/packagesDev/next-config/dist/commands/copyFiles.js b/packagesDev/next-config/dist/commands/copyFiles.js index 55b1d0679f..e69084408b 100644 --- a/packagesDev/next-config/dist/commands/copyFiles.js +++ b/packagesDev/next-config/dist/commands/copyFiles.js @@ -192,7 +192,7 @@ Found in packages: Source: ${sourcePath}`); process.exit(1); } - console.log(`Creating new file: ${file}`); + console.log(`Creating new file: ${file}\nSource: ${sourcePath}`); debug('File does not exist yet'); } // Skip if content is identical (including magic comment) diff --git a/packagesDev/next-config/dist/utils/isMonorepo.js b/packagesDev/next-config/dist/utils/isMonorepo.js index 900659d288..a3b60b8a30 100644 --- a/packagesDev/next-config/dist/utils/isMonorepo.js +++ b/packagesDev/next-config/dist/utils/isMonorepo.js @@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isMonorepo = isMonorepo; exports.findParentPath = findParentPath; const node_fs_1 = __importDefault(require("node:fs")); const node_path_1 = __importDefault(require("node:path")); @@ -20,33 +19,6 @@ function findPackageJson(directory) { return null; } } -/** - * Determines if we're running in a monorepo context and how to handle postinstall scripts. - * - * If there is a parent `@graphcommerce/*` package, we're in a monorepo. - */ -function isMonorepo() { - let currentDir = process.cwd(); - log(`Starting directory: ${currentDir}`); - // Start from the parent directory to find a parent @graphcommerce package - currentDir = node_path_1.default.dirname(currentDir); - log(`Looking for parent packages starting from: ${currentDir}`); - // Keep going up until we find a root package or hit the filesystem root - while (currentDir !== node_path_1.default.parse(currentDir).root) { - const packageJson = findPackageJson(currentDir); - if (packageJson) { - log(`Found package.json in: ${currentDir}`); - log(`Package name: ${packageJson.name}`); - if (packageJson.name.startsWith('@graphcommerce/')) { - log('isMonorepo result: true (found parent @graphcommerce package)'); - return true; - } - } - currentDir = node_path_1.default.dirname(currentDir); - } - log('isMonorepo result: false (no parent @graphcommerce package found)'); - return false; -} /** * Finds the path of the parent @graphcommerce package if it exists Returns null if no parent * package is found diff --git a/packagesDev/next-config/src/utils/isMonorepo.ts b/packagesDev/next-config/src/utils/isMonorepo.ts index 17f7d2e571..b5e27e4134 100644 --- a/packagesDev/next-config/src/utils/isMonorepo.ts +++ b/packagesDev/next-config/src/utils/isMonorepo.ts @@ -15,40 +15,6 @@ function findPackageJson(directory: string): { name: string } | null { } } -/** - * Determines if we're running in a monorepo context and how to handle postinstall scripts. - * - * If there is a parent `@graphcommerce/*` package, we're in a monorepo. - */ -export function isMonorepo() { - let currentDir = process.cwd() - log(`Starting directory: ${currentDir}`) - - // Start from the parent directory to find a parent @graphcommerce package - currentDir = path.dirname(currentDir) - log(`Looking for parent packages starting from: ${currentDir}`) - - // Keep going up until we find a root package or hit the filesystem root - while (currentDir !== path.parse(currentDir).root) { - const packageJson = findPackageJson(currentDir) - - if (packageJson) { - log(`Found package.json in: ${currentDir}`) - log(`Package name: ${packageJson.name}`) - - if (packageJson.name.startsWith('@graphcommerce/')) { - log('isMonorepo result: true (found parent @graphcommerce package)') - return true - } - } - - currentDir = path.dirname(currentDir) - } - - log('isMonorepo result: false (no parent @graphcommerce package found)') - return false -} - /** * Finds the path of the parent @graphcommerce package if it exists Returns null if no parent * package is found