-
Notifications
You must be signed in to change notification settings - Fork 1k
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
refactor(api): Add conditional exports to package.json #11307
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
69f0c01
replace files with exports
Josh-Walker-GM 227194d
custom attw script in framework tools
Josh-Walker-GM 170c136
add changelog
Josh-Walker-GM b452c3a
correct usage output
Josh-Walker-GM 7b91055
Merge branch 'main' into jgmw/api-add-conditional-exports
Josh-Walker-GM 6529fe1
address node10 module resolution issue
Josh-Walker-GM c3a14f8
add normalise paths
Josh-Walker-GM 9d455c9
rework
Josh-Walker-GM 8c3d69d
change output
Josh-Walker-GM affbf06
Merge branch 'main' into jgmw/api-add-conditional-exports
Josh-Walker-GM 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- refactor(api): Add conditional exports to package.json (#11307) by @Josh-Walker-GM | ||
|
||
This change restricts the available imports from this package. You can no longer freely import from within the dist like `@redwoodjs/api/dist/...`. If you were doing so please consult the `@redwoodjs/api` `package.json` file to see what exports are now available. |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { execSync } from 'node:child_process' | ||
import fs from 'node:fs/promises' | ||
import { createRequire } from 'node:module' | ||
import path from 'node:path' | ||
|
||
interface Problem { | ||
kind: string | ||
entrypoint?: string | ||
resolutionKind?: string | ||
} | ||
|
||
export async function attw(): Promise<Problem[]> { | ||
// We can't rely on directly running the attw binary because it's not | ||
// a direct dependency of the package that will ultimately use this. | ||
// Instead, we have to do a little work to find the attw binary and run it. | ||
const require = createRequire(import.meta.url) | ||
const pathToAttw = require.resolve('@arethetypeswrong/cli/package.json') | ||
const attwPackageJson = require(pathToAttw) | ||
const relativeBinPath = attwPackageJson.bin.attw | ||
const attwBinPath = path.normalize( | ||
path.resolve(path.dirname(pathToAttw), relativeBinPath), | ||
) | ||
|
||
// Run attw via it's CLI | ||
const outputFile = '.attw.json' | ||
try { | ||
execSync(`node ${attwBinPath} -P -f json > ${outputFile}`) | ||
|
||
} catch { | ||
// We don't care about non-zero exit codes | ||
} | ||
|
||
// Read the resulting JSON file | ||
const output = await fs.readFile(outputFile, 'utf8') | ||
await fs.unlink(outputFile) | ||
const json = JSON.parse(output) | ||
|
||
// If no errors were found then return early | ||
if (!json.analysis.problems || json.analysis.problems.length === 0) { | ||
return [] | ||
} | ||
|
||
// We don't care about node10 errors | ||
const problems: Problem[] = json.analysis.problems.filter( | ||
(problem: Problem) => problem.resolutionKind !== 'node10', | ||
) | ||
|
||
return problems | ||
} |
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,21 @@ | ||
import process from 'node:process' | ||
|
||
import { attw } from '../attw.js' | ||
|
||
async function main() { | ||
console.log(`Running attw against: ${process.cwd()}`) | ||
|
||
const problems = await attw() | ||
if (problems.length > 0) { | ||
console.error('Problems found:') | ||
for (const problem of problems) { | ||
console.error(problem) | ||
} | ||
process.exit(1) | ||
} | ||
|
||
console.log('No problems found') | ||
process.exit(0) | ||
} | ||
|
||
main() |
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
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.
Reminder to self