Skip to content
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

fix: replace statuses with statuses-es for better compact compatibility #53

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/advanced/handling-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ un.get('/user/12345', {
});
```

如果你追求语义化,可以使用导出的和挂载的状态码、[statuses](https://github.com/jshttp/statuses)、[http-status-codes](https://github.com/prettymuchbryce/http-status-codes) 或 [node-http-status](https://github.com/adaltas/node-http-status)。
如果你追求语义化,可以使用导出的和挂载的状态码、[statuses-es](https://github.com/esm-ts/statuses-es)、[http-status-codes](https://github.com/prettymuchbryce/http-status-codes) 或 [node-http-status](https://github.com/adaltas/node-http-status)。

```typescript
import { un, HttpStatusCode } from '@uni-helper/uni-network';
Expand Down
3 changes: 1 addition & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@
"dependencies": {
"@dcloudio/types": "^3.4.8",
"@types/lodash.merge": "^4.6.9",
"@types/statuses": "^2.0.5",
"fast-querystring": "^1.1.2",
"lodash.merge": "^4.6.2",
"statuses": "^2.0.1",
"statuses-es": "^2.0.6",
"vue-demi": "^0.14.8"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/adapters/download.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import statuses from "statuses";
import statuses from "statuses-es";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

Revert import change or update codebase consistently

The change to import statuses-es in packages/core/src/adapters/download.ts is inconsistent with the rest of the codebase and may cause issues. Here are the findings:

  1. The statuses-es package is not listed as a dependency in the package.json file.
  2. There are no usages of statuses-es( in the codebase, but there are three usages of statuses(:
    • packages/core/src/adapters/upload.ts:35
    • packages/core/src/adapters/request.ts:30
    • packages/core/src/adapters/download.ts:37

To resolve this inconsistency, you should either:

  1. Revert the import statement change in packages/core/src/adapters/download.ts back to import statuses from "statuses";
  2. Update the entire codebase to use statuses-es consistently:
    • Add statuses-es to the project dependencies
    • Update all import statements and function calls to use statuses-es
    • Ensure that statuses-es is compatible with the existing statuses usage

Please choose the appropriate action based on the project's goals and requirements.

Analysis chain

Verify compatibility of the new statuses-es module.

The import statement change from "statuses" to "statuses-es" is part of a larger effort to update the project's dependencies and documentation. This change is limited to the import statement and does not alter the overall logic or control flow of the code.

To ensure that the new statuses-es module is a suitable replacement for the original statuses module, please verify the following:

  1. The statuses-es module provides the same or equivalent functionality as the original statuses module.
  2. The statuses-es module is compatible with the project's supported Node.js versions and other dependencies.
  3. The change has been thoroughly tested to ensure that it does not introduce any unexpected behavior or break existing functionality.

You can use the following script to search for usages of the statuses function and ensure that they are compatible with the new statuses-es module:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify compatibility of the `statuses-es` module.

# Test: Search for usages of the `statuses` function.
rg --type typescript -A 5 $'statuses\('

Length of output: 75


Script:

#!/bin/bash
# Description: Verify compatibility of the `statuses-es` module.

# Find TypeScript files
echo "TypeScript files in the repository:"
fd '\.(ts|tsx)$'

# Search for usages of 'statuses(' and 'statuses-es('
echo -e "\nUsages of 'statuses(' in TypeScript files:"
fd '\.(ts|tsx)$' | xargs rg 'statuses\(' -n

echo -e "\nUsages of 'statuses-es(' in TypeScript files:"
fd '\.(ts|tsx)$' | xargs rg 'statuses-es\(' -n

# Check package.json for statuses-es dependency
echo -e "\nChecking package.json for statuses-es dependency:"
jq '.dependencies["statuses-es"] // .devDependencies["statuses-es"] // "Not found"' package.json

# If statuses-es is found, check its version
if jq -e '.dependencies["statuses-es"] // .devDependencies["statuses-es"]' package.json > /dev/null; then
  echo -e "\nComparing statuses-es with original statuses package:"
  jq '{
    "statuses-es": .dependencies["statuses-es"] // .devDependencies["statuses-es"],
    "statuses": .dependencies["statuses"] // .devDependencies["statuses"] // "Not found"
  }' package.json
fi

Length of output: 3006

import type { UnCancelTokenListener } from "../core/UnCancelToken";
import { UnCanceledError } from "../core/UnCanceledError";
import { settle } from "../core/settle";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/adapters/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import statuses from "statuses";
import statuses from "statuses-es";
import type { UnCancelTokenListener } from "../core/UnCancelToken";
import { UnCanceledError } from "../core/UnCanceledError";
import { settle } from "../core/settle";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/adapters/upload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import statuses from "statuses";
import statuses from "statuses-es";
import type { UnCancelTokenListener } from "../core/UnCancelToken";
import { UnCanceledError } from "../core/UnCanceledError";
import { settle } from "../core/settle";
Expand Down
33 changes: 22 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.