-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leon Si
committed
Sep 28, 2023
1 parent
3b2eb3f
commit fe4c75d
Showing
5 changed files
with
235 additions
and
9 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,20 +1,26 @@ | ||
{ | ||
"name": "@-/patching", | ||
"type": "module", | ||
"type": "module", | ||
"dependencies": { | ||
"pathe": "^1.1.1", | ||
"replace-in-file": "^7.0.1", | ||
"tmp-promise": "^3.0.3", | ||
"@rollup/plugin-commonjs": "^25.0.4", | ||
"@rollup/plugin-node-resolve": "^15.2.1", | ||
"@ts-monorepo/get-monorepo-packages": "^1.0.0", | ||
"acorn": "^8.10.0", | ||
"desm": "^1.3.0", | ||
"escape-string-regexp": "^5.0.0", | ||
"estree-walker": "^3.0.3", | ||
"execa": "^8.0.1", | ||
"map-obj": "^5.0.2", | ||
"execa": "^8.0.1", | ||
"glob": "^10.3.10", | ||
"map-obj": "^5.0.2", | ||
"outdent": "^0.8.0", | ||
"tilde-imports": "^3.1.0", | ||
"tilde-imports": "^3.1.0", | ||
"rollup": "^3.29.3", | ||
"rollup-plugin-esbuild": "^6.0.1" | ||
}, | ||
"devDependencies": { | ||
"commander": "^11.0.0" | ||
} | ||
} |
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 @@ | ||
#!/usr/bin/env -S pnpm exec tsx | ||
|
||
import { program } from "commander"; | ||
|
||
import { patches } from "~/patches/$.ts"; | ||
import { generatePatch } from "~/utils/patch.ts"; | ||
|
||
await program | ||
.requiredOption( | ||
"--monorepo-dir <monorepoDirpath>", | ||
"The path to the monorepo directory" | ||
) | ||
.requiredOption( | ||
"--patches-dir <patchesDirpath>", | ||
"The path to the patches directory" | ||
) | ||
.argument( | ||
"[patch-ids...]", | ||
"The IDs of the patches to generate. If not provided, all patches will be generates." | ||
) | ||
.action( | ||
async ( | ||
patchIds: string[], | ||
options: { patchesDir: string; monorepoDir: string } | ||
) => { | ||
const patchIdsToGenerate = | ||
patchIds.length > 0 ? patchIds : Object.keys(patches); | ||
|
||
for (const patchId of patchIdsToGenerate) { | ||
console.info(`Generating patch "${patchId}"...`); | ||
// eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unnecessary-condition -- We need to apply patches synchronously to prevent race conditions for updating files | ||
await generatePatch({ | ||
patchId: patchId as keyof typeof patches, | ||
monorepoDirpath: options.monorepoDir, | ||
patchesDirpath: options.patchesDir, | ||
}); | ||
console.info(`Successfully generated patch "${patchId}"!`); | ||
} | ||
} | ||
) | ||
.parseAsync(); |
2 changes: 2 additions & 0 deletions
2
packages/patching/src/patches/typescript/create-get-package-path.cjs
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
Oops, something went wrong.