-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat: support format config #238
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,22 +12,22 @@ test('standalone fixtures', async t => { | |
equal(entry.length, 288, 'entry output length should be 288') | ||
|
||
const dts = await readFile('examples/basic/.velite/index.d.ts', 'utf8') | ||
equal(dts.length, 628, 'dts output length should be 628') | ||
equal(dts.length, 636, 'dts output length should be 636') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Missing The expected 🔗 Analysis chainApprove the updated dts output length. The change in the expected length of the To ensure the accuracy of this change, please run the following script to verify the actual length of the generated 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the length of the generated .velite/index.d.ts file
# Test: Check the length of the .velite/index.d.ts file
dts_length=$(wc -c < examples/basic/.velite/index.d.ts)
echo "Actual dts length: $dts_length"
if [ "$dts_length" -eq 636 ]; then
echo "Length matches the expected value."
else
echo "Length does not match the expected value."
fi
Length of output: 375 Script: #!/bin/bash
# Description: Locate all instances of index.d.ts in the repository
fd 'index\.d\.ts$'
Length of output: 20 Script: #!/bin/bash
# Description: Search for all TypeScript declaration files in the repository
fd '\.d\.ts$' --exclude 'node_modules' --exclude 'dist' --exclude 'build'
Length of output: 69 |
||
|
||
const options = await readFile('examples/basic/.velite/options.json', 'utf8') | ||
equal(options.length, 1121, 'options output length should be 1121') | ||
|
||
const categories = await readFile('examples/basic/.velite/categories.json', 'utf8') | ||
equal(categories.length, 880, 'categories output length should be 880') | ||
|
||
const tags = await readFile('examples/basic/.velite/tags.json', 'utf8') | ||
equal(tags.length, 315, 'tags output length should be 315') | ||
|
||
const pages = await readFile('examples/basic/.velite/pages.json', 'utf8') | ||
equal(pages.length, 6182, 'pages output length should be 6182') | ||
|
||
const posts = await readFile('examples/basic/.velite/posts.json', 'utf8') | ||
equal(posts.length, 14165, 'posts output length should be 14165') | ||
|
||
const tags = await readFile('examples/basic/.velite/tags.json', 'utf8') | ||
equal(tags.length, 315, 'tags output length should be 315') | ||
|
||
await rm('examples/basic/.velite', { recursive: true, force: true }) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,22 +11,22 @@ test('integration with nextjs fixtures', async t => { | |
equal(entry.length, 288, 'entry output length should be 288') | ||
|
||
const dts = await readFile('examples/nextjs/.velite/index.d.ts', 'utf8') | ||
equal(dts.length, 628, 'dts output length should be 628') | ||
equal(dts.length, 636, 'dts output length should be 636') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Issue Detected: Missing The test
🔗 Analysis chainLGTM. Verify the content of The expected length for To ensure the change is correct, please verify the content of the 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the content of index.d.ts file
# Expected: The file should contain new type definitions or modifications related to the format configuration
cat examples/nextjs/.velite/index.d.ts
Length of output: 190 Script: #!/bin/bash
# Description: Check if index.d.ts exists and display its contents if it does.
if [ -f examples/nextjs/.velite/index.d.ts ]; then
echo "File exists. Displaying contents:"
cat examples/nextjs/.velite/index.d.ts
else
echo "File examples/nextjs/.velite/index.d.ts does not exist."
fi
Length of output: 168 Script: #!/bin/bash
# Description: Locate the index.d.ts file in the repository and display its contents if found.
index_file=$(fd index.d.ts .)
if [ -n "$index_file" ]; then
echo "Found index.d.ts at: $index_file"
echo "Displaying contents of index.d.ts:"
cat "$index_file"
else
echo "index.d.ts file does not exist in the repository."
fi
Length of output: 157 |
||
|
||
const options = await readFile('examples/nextjs/.velite/options.json', 'utf8') | ||
equal(options.length, 1121, 'options output length should be 1121') | ||
equal(options.length, 775, 'options output length should be 775') | ||
|
||
const categories = await readFile('examples/nextjs/.velite/categories.json', 'utf8') | ||
equal(categories.length, 880, 'categories output length should be 880') | ||
|
||
const tags = await readFile('examples/nextjs/.velite/tags.json', 'utf8') | ||
equal(tags.length, 315, 'tags output length should be 315') | ||
equal(categories.length, 649, 'categories output length should be 649') | ||
|
||
const pages = await readFile('examples/nextjs/.velite/pages.json', 'utf8') | ||
equal(pages.length, 5003, 'pages output length should be 5003') | ||
equal(pages.length, 4942, 'pages output length should be 4942') | ||
|
||
const posts = await readFile('examples/nextjs/.velite/posts.json', 'utf8') | ||
equal(posts.length, 20171, 'posts output length should be 20171') | ||
equal(posts.length, 17991, 'posts output length should be 17991') | ||
|
||
const tags = await readFile('examples/nextjs/.velite/tags.json', 'utf8') | ||
equal(tags.length, 212, 'tags output length should be 212') | ||
|
||
await rm('examples/nextjs/.velite', { recursive: true, force: true }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Add test cases for the new format config in NextJS setup The test doesn't explicitly check for the new format config. Consider adding test cases to verify that both 'esm' and 'cjs' formats are correctly applied when specified in the config.
|
||
}) |
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.
Validate the
format
parameter to ensure robustnessCurrently, the code conditionally handles
'cjs'
and defaults to ES module syntax for other values offormat
. To prevent potential issues with unexpectedformat
values, consider validating theformat
parameter and providing a default or throwing an error for unsupported formats.You could implement a validation mechanism like this:
This ensures that only supported formats are processed and helps catch configuration errors early.