Skip to content

Commit

Permalink
Merge pull request #12 from alovajs/release/v1.2.x
Browse files Browse the repository at this point in the history
feat: specify custom axios instance
  • Loading branch information
JOU-amjs authored Oct 26, 2023
2 parents 3fc7ab0 + 28659ed commit 364827e
Show file tree
Hide file tree
Showing 20 changed files with 222 additions and 186 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
service_name: travis-pro
service_name: github-action
repo_token: lUvcBvK6t0T7L2PClgL8aq931DRj8q6F7
8 changes: 2 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
root = true

[{*.js,*.css,*.html}]
[*]
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
charset = utf-8
insert_final_newline = true

[{package.json,.*rc,*.yml}]
indent_style = space
indent_size = 2
4 changes: 3 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
env: {
browser: true,
es2021: true
es2021: true,
node: true
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
overrides: [],
Expand All @@ -20,6 +21,7 @@ module.exports = {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'no-empty': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/triple-slash-reference': 'off'
}
};
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# Auto detect text files and perform LF normalization
* text=auto
* text eol=lf
4 changes: 1 addition & 3 deletions config/rollup.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* @LastEditors: JOU(wx: huzhen555)
* @LastEditTime: 2023-05-08 23:00:03
*/
var typescript = require('rollup-plugin-typescript2');
var { readFileSync } = require('fs');

const typescript = require('rollup-plugin-typescript2');
const getCompiler = (
opt = {
// objectHashIgnoreUnknownHack: true,
Expand Down
50 changes: 25 additions & 25 deletions config/rollup.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
*/
// rollup.config.js
// commonjs
var config = require('./rollup.cjs');
var module = process.argv.pop().replace('--', '') || 'core';
var paths = config.compilePath;
var moduleType = 'cjs';
const config = require('./rollup.cjs');
const module = process.argv.pop().replace('--', '') || 'core';
const paths = config.compilePath;
const moduleType = 'cjs';

module.exports = {
input: paths.input,
output: {
name: paths.packageName,
file: paths.output(moduleType),
format: 'cjs',
// When export and export default are not used at the same time, set legacy to true.
// legacy: true,
banner: config.banner,
},
external: config.external,
plugins: [
config.getCompiler({
tsconfigOverride: {
compilerOptions: {
declaration: true,
module: 'ES2015'
}
},
useTsconfigDeclarationDir: true
})
]
input: paths.input,
output: {
name: paths.packageName,
file: paths.output(moduleType),
format: 'cjs',
// When export and export default are not used at the same time, set legacy to true.
// legacy: true,
banner: config.banner
},
external: config.external,
plugins: [
config.getCompiler({
tsconfigOverride: {
compilerOptions: {
declaration: true,
module: 'ES2015'
}
},
useTsconfigDeclarationDir: true
})
]
};
9 changes: 4 additions & 5 deletions config/rollup.config.esm.cjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// rollup.config.js
// ES output
var { nodeResolve } = require('@rollup/plugin-node-resolve');
var config = require('./rollup.cjs');
var paths = config.compilePath;
var moduleType = 'esm';

const { nodeResolve } = require('@rollup/plugin-node-resolve');
const config = require('./rollup.cjs');
const paths = config.compilePath;
const moduleType = 'esm';
const globals = {};
// 将externals中的内容放到globals对象中
config.external.forEach(key => (globals[key] = key));
Expand Down
20 changes: 10 additions & 10 deletions config/rollup.config.umd.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
*/
// rollup.config.js
// umd
var { nodeResolve } = require('@rollup/plugin-node-resolve');
var commonjs = require('@rollup/plugin-commonjs');
var { terser } = require('rollup-plugin-terser');
var replace = require('@rollup/plugin-replace');
var json = require('@rollup/plugin-json');
var config = require('./rollup.cjs');
var prod = process.env.NODE_ENV === 'production';
var paths = config.compilePath;
var moduleType = prod ? 'umd.min' : 'umd';

const { nodeResolve } = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const { terser } = require('rollup-plugin-terser');
const replace = require('@rollup/plugin-replace');
const json = require('@rollup/plugin-json');
const config = require('./rollup.cjs');
const prod = process.env.NODE_ENV === 'production';
const paths = config.compilePath;
const moduleType = prod ? 'umd.min' : 'umd';
const globals = {};
// 将externals中的内容放到globals对象中
config.external.forEach(key => (globals[key] = key));

module.exports = {
input: paths.input,
output: {
Expand Down
37 changes: 4 additions & 33 deletions jest.config.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,7 @@ export default {
// The test environment that will be used for testing
// testEnvironment: 'node',

testMatch: [
'**/?(*.)+(spec|test).[tj]s?(x)'
// '**/test/requestAdapter.spec.ts(x)?'
// '**/test/mockResponse.spec.ts(x)?'
],
testMatch: ['**/test/server/**/*.[jt]s?(x)'],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: [
Expand All @@ -163,37 +159,12 @@ export default {

// A map from regular expressions to paths to transformers
transform: {
'\\.(j|t)sx?$': [
'ts-jest',
// mock import.meta, see https://www.npmjs.com/package/ts-jest-mock-import-meta
{
diagnostics: {
ignoreCodes: [1343]
},
astTransformers: {
// 转换import.meta
before: [
{
path: 'node_modules/ts-jest-mock-import-meta',
options: {
metaObjectReplacement: {
url: 'https://xxx',
env: {
PROD: false,
DEV: true
},
status: 2
}
}
}
]
}
}
]
'\\.(j|t)sx?$': 'ts-jest'
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
transformIgnorePatterns: ['/node_modules/(?!alova)']
// must "allowJs": true in tsconfig.json
transformIgnorePatterns: ['/node_modules/(?!(alova|@alova/mock))']

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
Expand Down
36 changes: 3 additions & 33 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,7 @@ export default {
// The test environment that will be used for testing
testEnvironment: 'jsdom',

testMatch: [
'**/?(*.)+(spec|test).[tj]s?(x)'
// '**/test/requestAdapter.spec.ts(x)?'
// '**/test/mockResponse.spec.ts(x)?'
],
testMatch: ['**/test/browser/**/*.[jt]s?(x)'],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: [
Expand All @@ -163,37 +159,11 @@ export default {

// A map from regular expressions to paths to transformers
transform: {
'\\.(j|t)sx?$': [
'ts-jest',
// mock import.meta, see https://www.npmjs.com/package/ts-jest-mock-import-meta
{
diagnostics: {
ignoreCodes: [1343]
},
astTransformers: {
// 转换import.meta
before: [
{
path: 'node_modules/ts-jest-mock-import-meta',
options: {
metaObjectReplacement: {
url: 'https://xxx',
env: {
PROD: false,
DEV: true
},
status: 2
}
}
}
]
}
}
]
'\\.(j|t)sx?$': 'ts-jest'
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
transformIgnorePatterns: ['/node_modules/(?!alova)']
transformIgnorePatterns: ['/node_modules/(?!(alova|@alova/mock))']

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"typings/*.d.ts"
],
"devDependencies": {
"@alova/mock": "^1.2.1",
"@alova/mock": "^1.5.0",
"@babel/core": "^7.18.2",
"@babel/preset-env": "^7.18.2",
"@commitlint/config-conventional": "^17.4.4",
Expand All @@ -70,7 +70,7 @@
"@types/jest": "^29.4.0",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"alova": "^2.3.1",
"alova": "^2.13.1",
"axios": "^1.3.4",
"babel-jest": "^29.2.2",
"commitizen": "^4.3.0",
Expand Down
Loading

0 comments on commit 364827e

Please sign in to comment.