-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from CrowdStrike/turbo_try2
Setup turborepo, second try
- Loading branch information
Showing
15 changed files
with
302 additions
and
136 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ dist/ | |
node_modules/ | ||
|
||
# misc | ||
.turbo/ | ||
/.env* | ||
/.pnp* | ||
/.pnpm-debug.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import syncPnpm from '../index.js'; | ||
|
||
await syncPnpm(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { join, dirname } from 'node:path'; | ||
import { createRequire } from 'node:module'; | ||
|
||
import { getPackages } from '@manypkg/get-packages'; | ||
import { findRoot } from '@manypkg/find-root'; | ||
import { readJson, pathExists } from 'fs-extra/esm'; | ||
import { hardLinkDir } from '@pnpm/fs.hard-link-dir'; | ||
import resolvePackagePath from 'resolve-package-path'; | ||
|
||
const require = createRequire(import.meta.url); | ||
|
||
const syncDir = './dist'; | ||
|
||
export default async function syncPnpm(dir = process.cwd()) { | ||
const root = await findRoot(dir); | ||
const ownPackageJson = await readJson(join(dir, 'package.json')); | ||
const ownDependencies = [ | ||
...Object.keys(ownPackageJson.dependencies ?? {}), | ||
...Object.keys(ownPackageJson.devDependencies ?? {}), | ||
]; | ||
|
||
const localPackages = (await getPackages(root.rootDir)).packages; | ||
|
||
const packagesToSync = localPackages.filter( | ||
(p) => | ||
p.packageJson.name !== 'sync-pnpm' && | ||
ownDependencies.includes(p.packageJson.name) | ||
); | ||
|
||
for (const pkg of packagesToSync) { | ||
const syncFrom = join(pkg.dir, syncDir); | ||
const resolvedPackagePath = dirname( | ||
resolvePackagePath(pkg.packageJson.name, dir) | ||
); | ||
const syncTo = join(resolvedPackagePath, syncDir); | ||
|
||
if (await pathExists(syncFrom)) { | ||
await hardLinkDir(syncFrom, [syncTo]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "sync-pnpm", | ||
"version": "0.0.0", | ||
"private": true, | ||
"description": "Sync build artifacts of workspace packages to pnpm injected/hard linked copies", | ||
"repository": "", | ||
"license": "MIT", | ||
"author": "", | ||
"main": "index.js", | ||
"bin": "bin/sync-pnpm.js", | ||
"type": "module", | ||
"dependencies": { | ||
"@manypkg/find-root": "^2.1.0", | ||
"@manypkg/get-packages": "^2.1.0", | ||
"@pnpm/fs.hard-link-dir": "^1.0.3", | ||
"fs-extra": "^11.1.0", | ||
"resolve-package-path": "^4.0.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.