@toptal/davinci-monorepo 12.0.2-alpha-top-support-npm-7e29d4f4.5 → 12.0.2-alpha-top-support-npm-62a0d26c.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import cliEngine from '@toptal/davinci-cli-shared'
4
+
4
5
  import { commands } from '../src/index.js'
5
6
 
6
7
  cliEngine.loadCommands(commands, 'davinci-monorepo')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-monorepo",
3
- "version": "12.0.2-alpha-top-support-npm-7e29d4f4.5+7e29d4f4",
3
+ "version": "12.0.2-alpha-top-support-npm-62a0d26c.7+62a0d26c",
4
4
  "keywords": [
5
5
  "lint"
6
6
  ],
@@ -25,9 +25,10 @@
25
25
  "test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' yarn jest"
26
26
  },
27
27
  "dependencies": {
28
+ "@manypkg/find-root": "^3.0.0",
28
29
  "@nodelib/fs.walk": "^1.2.6",
29
30
  "@oclif/core": "^1.16.1",
30
- "@toptal/davinci-cli-shared": "2.5.2-alpha-top-support-npm-7e29d4f4.53+7e29d4f4",
31
+ "@toptal/davinci-cli-shared": "2.5.2-alpha-top-support-npm-62a0d26c.55+62a0d26c",
31
32
  "chalk": "^4.1.2",
32
33
  "codeowners": "5.1.1",
33
34
  "dependency-cruiser": "^16.3.0",
@@ -51,5 +52,5 @@
51
52
  "publishConfig": {
52
53
  "access": "public"
53
54
  },
54
- "gitHead": "7e29d4f4d372103ff0ca43382fc4a137b0a9df91"
55
+ "gitHead": "62a0d26c9f0d3e74903894448f28902f7d476686"
55
56
  }
@@ -1,4 +1,4 @@
1
- import getWorkspaceRoot from 'find-yarn-workspace-root'
1
+ import { findWorkspaceRoot as getWorkspaceRoot } from '../../../../utils/find-workspace-root.js'
2
2
 
3
3
  /**
4
4
  * @param {string} cwd
@@ -1,9 +1,9 @@
1
1
  import path from 'path'
2
2
  import { print } from '@toptal/davinci-cli-shared'
3
- import getWorkspaceRoot from 'find-yarn-workspace-root'
4
3
  import { readFile, writeFile } from 'fs/promises'
5
4
  import { existsSync } from 'fs'
6
5
 
6
+ import { findWorkspaceRoot as getWorkspaceRoot } from '../../utils/find-workspace-root.js'
7
7
  import { CYPRESS_COVERAGE_PATH, JEST_COVERAGE_PATH } from './config.js'
8
8
  import { sanitizeTeamName } from './services/sanitize-team-name/sanitize-team-name.js'
9
9
  import { getUniqueTeams } from './services/get-unique-teams/get-unique-teams.js'
package/src/index.js CHANGED
@@ -7,11 +7,17 @@ import { hostsCommandFactory } from './commands/hosts/index.js'
7
7
  import { createUpdatePicassoCommand } from './commands/update-picasso.js'
8
8
  import checkIfMonorepo from './utils/check-if-monorepo.js'
9
9
  import { getPackages, getPackagesLocations } from './utils/get-packages.js'
10
+ import {
11
+ findWorkspaceRoot,
12
+ getWorkspaceRoot,
13
+ } from './utils/find-workspace-root.js'
10
14
 
11
15
  export const utils = {
12
16
  checkIfMonorepo,
13
17
  getPackages,
14
18
  getPackagesLocations,
19
+ findWorkspaceRoot,
20
+ getWorkspaceRoot,
15
21
  }
16
22
 
17
23
  export const commands = [
@@ -0,0 +1,26 @@
1
+ import { findRootSync } from '@manypkg/find-root'
2
+
3
+ /**
4
+ * Find the root directory of a workspace/monorepo.
5
+ * Works with any package manager: yarn, npm, pnpm, lerna, rush.
6
+ *
7
+ * @param {string} [cwd=process.cwd()] - The directory to start searching from
8
+ * @returns {string|null} - The absolute path to workspace root or null if not in a workspace
9
+ */
10
+ export const findWorkspaceRoot = (cwd = process.cwd()) => {
11
+ try {
12
+ const result = findRootSync(cwd)
13
+
14
+ return result.rootDir
15
+ } catch {
16
+ // If not in a workspace, return null (same behavior as find-yarn-workspace-root)
17
+ return null
18
+ }
19
+ }
20
+
21
+ /**
22
+ * @deprecated Use findWorkspaceRoot instead
23
+ */
24
+ export const getWorkspaceRoot = findWorkspaceRoot
25
+
26
+ export default findWorkspaceRoot
@@ -0,0 +1,34 @@
1
+ import { describe, it, expect } from '@jest/globals'
2
+ import path from 'path'
3
+ import { fileURLToPath } from 'url'
4
+
5
+ import { findWorkspaceRoot, getWorkspaceRoot } from './find-workspace-root.js'
6
+
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
8
+
9
+ describe('findWorkspaceRoot', () => {
10
+ it('should find workspace root', () => {
11
+ const root = findWorkspaceRoot()
12
+
13
+ // Should return a path (not null) since we're running from a workspace
14
+ expect(root).toBeTruthy()
15
+ expect(typeof root).toBe('string')
16
+
17
+ // Should be absolute path
18
+ expect(root.startsWith('/')).toBe(true)
19
+ })
20
+
21
+ it('should work with getWorkspaceRoot alias', () => {
22
+ const root1 = findWorkspaceRoot()
23
+ const root2 = getWorkspaceRoot()
24
+
25
+ expect(root1).toBe(root2)
26
+ })
27
+
28
+ it('should return same result for different starting directories', () => {
29
+ const rootFromCwd = findWorkspaceRoot()
30
+ const rootFromPackage = findWorkspaceRoot(__dirname)
31
+
32
+ expect(rootFromCwd).toBe(rootFromPackage)
33
+ })
34
+ })
@@ -1,9 +1,9 @@
1
- import getWorkspaceRoot from 'find-yarn-workspace-root'
2
1
  import { execSync } from 'child_process'
3
2
 
3
+ import { findWorkspaceRoot } from './find-workspace-root.js'
4
4
  import logger from './logger.js'
5
5
 
6
- const workspaceRoot = getWorkspaceRoot()
6
+ const workspaceRoot = findWorkspaceRoot()
7
7
 
8
8
  const hasStashedChanges = () => {
9
9
  try {