-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up build scripts #12305
Merged
Merged
Clean up build scripts #12305
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
261622e
move from `ts-node` to `node --experimental-strip-types`, create `bui…
phryneas 96181a5
remove `engines` field, specify `devEngines`
phryneas ed17d0a
adjust node version for CI
phryneas 89d4bb7
fix up some more syntax
phryneas a3c6ff1
prettier
phryneas 1b80b4e
adjust precheck, bump minimal lockfile version to 3
phryneas f8152b3
convert jest config to esm
phryneas 85a4a13
move `entryPoints` to TS, make it work in mjs and jest
phryneas 4067869
run rollup with ts config
phryneas 3d6686c
update a few more node calls
phryneas ab50228
some more typings
phryneas 05bfd25
move all scripts to function invocation
phryneas aee764a
migrate `prepareChangestsRelease` too
phryneas cf3bae4
remove scripts that are not called manually
phryneas a25730c
convert `prepareDist` to TS
phryneas f02eb4b
migrate `precheck.js`
phryneas c00f3cd
`version.js->ts`
phryneas 795a432
use jest ts config
phryneas c75c83e
prettier
phryneas ad9a12d
dirname.cjs->cts
phryneas b05822e
Merge remote-tracking branch 'origin/release-4.0' into pr/build-changes
phryneas fa398ba
dirname-related import fixes
phryneas c68ae2c
fix up new knip issues
phryneas 62792ef
delete `devEngines` instead of `engines` field
phryneas 6f3a7e6
require node 23.6 instead of 22.6
phryneas 2b77df6
Merge remote-tracking branch 'origin/release-4.0' into pr/build-changes
phryneas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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,63 @@ | ||
import { $ } from "zx"; | ||
import { join } from "node:path"; | ||
import { parseArgs } from "node:util"; | ||
|
||
import { inlineInheritDoc } from "./inlineInheritDoc.ts"; | ||
import { updateVersion, verifyVersion } from "./version.ts"; | ||
import { processInvariants } from "./processInvariants.ts"; | ||
import { rewriteSourceMaps } from "./rewriteSourceMaps.ts"; | ||
import { rollup } from "./rollup.ts"; | ||
import { prepareDist } from "./prepareDist.ts"; | ||
import { postprocessDist } from "./postprocessDist.ts"; | ||
import { prepareChangesetsRelease } from "./prepareChangesetsRelease.ts"; | ||
|
||
$.cwd = join(import.meta.dirname, ".."); | ||
$.verbose = true; | ||
|
||
const buildSteps = { | ||
typescript: () => $`npx tsc`, | ||
updateVersion, | ||
inlineInheritDoc, | ||
processInvariants, | ||
rewriteSourceMaps, | ||
rollup, | ||
prepareDist, | ||
postprocessDist, | ||
verifyVersion, | ||
}; | ||
const additionalSteps = { | ||
prepareChangesetsRelease, | ||
}; | ||
|
||
const args = parseArgs({ | ||
options: { | ||
step: { | ||
type: "string", | ||
multiple: true, | ||
default: ["build"], | ||
}, | ||
}, | ||
}); | ||
|
||
const allSteps = Object.assign({}, buildSteps, additionalSteps); | ||
|
||
const runSteps = args.values.step.flatMap((step) => | ||
step === "build" ? Object.keys(buildSteps) : [step] | ||
); | ||
|
||
const wrongSteps = runSteps.filter((step) => !(step in allSteps)); | ||
if (wrongSteps.length) { | ||
throw new Error( | ||
`Unknown steps: ${wrongSteps.join(", ")}. Valid steps are ${Object.keys( | ||
allSteps | ||
).join(", ")}` | ||
); | ||
} | ||
|
||
console.log("Running build steps: %s", runSteps.join(", ")); | ||
|
||
for (const step of runSteps) { | ||
console.log("--- Step %s: running ---", step); | ||
await allSteps[step](); | ||
console.log("--- Step %s: done ---", step); | ||
} |
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,4 @@ | ||
// workaround for `entryPoints.ts` that needs access to the current directory, | ||
// but cannot use `import.meta` as the file is required by Jest, which transpiles | ||
// the file to CommonJS - ending up with "SyntaxError: Cannot use 'import.meta' outside a module" | ||
module.exports = __dirname; |
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,2 @@ | ||
declare const __dirname: string; | ||
export default __dirname; |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling this with
--step=build
is a shorthand for the normal build steps - that makes it possible to call it with--step=build --step=prepareChangesetsRelease
instead of being forced to use a much longer command.