File tree 3 files changed +22
-10
lines changed
3 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ This is the fork of [vue-cli-plugin-axios](https://www.npmjs.com/package/vue-cli
10
10
11
11
For legacy Vue2 CLI.
12
12
13
- ``` shell
14
- vue add axios-x
13
+ ``` sh
14
+ vue add axios-x
15
15
```
16
16
17
17
## License
Original file line number Diff line number Diff line change @@ -4,21 +4,33 @@ const {
4
4
updateMain,
5
5
} = require ( "./updater" ) ;
6
6
7
+ const {
8
+ get,
9
+ } = require ( "axios" ) ;
10
+
7
11
module . exports = ( api , options ) => {
8
- api . extendPackage ( {
9
- devDependencies : {
10
- axios : "latest" ,
11
- } ,
12
- } ) ;
12
+ // Install latest Axios
13
+ get ( "https://registry.npmjs.org/axios" ) .
14
+ then ( ( { data } ) => {
15
+ const {
16
+ latest : pkgVersion ,
17
+ } = data [ "dist-tags" ] ;
18
+ api . extendPackage ( {
19
+ devDependencies : {
20
+ axios : `${ pkgVersion } ` ,
21
+ } ,
22
+ } ) ;
23
+ } ) ;
13
24
25
+ // Inject config files
14
26
api . render ( {
15
27
"./src/plugins/axios.js" : "./templates/plugins/axios.js" ,
16
28
} , options ) ;
17
29
18
30
19
- // adapted from https://github.com/Akryum/vue-cli-plugin-apollo/blob/master/generator/index.js#L68-L91
31
+ // Adapted from https://github.com/Akryum/vue-cli-plugin-apollo/blob/master/generator/index.js#L68-L91
20
32
api . onCreateComplete ( ( ) => {
21
- // Modify main.js
33
+ // Inject "import axios" into main.js/main.ts
22
34
updateMain ( api , ( src ) => {
23
35
const vueImportIndex = src . findIndex (
24
36
( line ) => line . match ( / ^ i m p o r t V u e / ) ,
Original file line number Diff line number Diff line change 16
16
" plugin"
17
17
],
18
18
"devDependencies" : {
19
- "axios" : " latest " ,
19
+ "axios" : " ^1.7.7 " ,
20
20
"vue" : " ^2.7.16"
21
21
}
22
22
}
You can’t perform that action at this time.
0 commit comments