Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73ac18d
commit b66176f
Showing
19 changed files
with
438 additions
and
58 deletions.
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
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 |
---|---|---|
|
@@ -23,3 +23,6 @@ coverage | |
|
||
# eslint | ||
.eslintcache | ||
|
||
# release | ||
RELEASELOG.md |
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 @@ | ||
CHANGELOG.md |
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 |
---|---|---|
@@ -1,24 +1,18 @@ | ||
# 2.0.0-beta.0 (2023-04-04) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* 清理 url 前面多余的斜线 ([666a942](https://github.com/zjx0905/axios-miniprogram/commit/666a9427d3c9bfbd96def9e112d5183acdf08d84)) | ||
|
||
|
||
### Features | ||
|
||
* 增强默认参数系列化器 ([0cfb3e1](https://github.com/zjx0905/axios-miniprogram/commit/0cfb3e1ff04b69896ba43ffcb6abba5fb61ad48a)) | ||
* 支持合并自定义配置 ([4409a57](https://github.com/zjx0905/axios-miniprogram/commit/4409a5720ba1e58a4c218ee67f71d5f05beee6a8)), closes [#38](https://github.com/zjx0905/axios-miniprogram/issues/38) | ||
* 支持京东小程序 ([0d1d21f](https://github.com/zjx0905/axios-miniprogram/commit/0d1d21fc66eb202463ef2baaa174b0f60276035e)) | ||
* 支持自定义配置 ([b15b31e](https://github.com/zjx0905/axios-miniprogram/commit/b15b31ee55217f11e08713ce02dd7ab21732fba1)) | ||
|
||
|
||
### BREAKING CHANGES | ||
|
||
* axios.get('url',{obj:{v1:1,v2:2}}) -> fetch: 'url?obj={"val":1,"v2":2}' | ||
变为 | ||
axios.get('url',{obj:{v1:1,v2:2}}) -> fetch: 'url?obj[v1]=1&obj[v2]=2' | ||
|
||
|
||
|
||
变为 | ||
axios.get('url',{obj:{v1:1,v2:2}}) -> fetch: 'url?obj[v1]=1&obj[v2]=2' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,46 @@ | ||
import fs from 'node:fs'; | ||
import consola from 'consola'; | ||
import { exec, getPkgJSON } from './utils'; | ||
import { exec, pkgPath, getPkgJSON } from './utils'; | ||
|
||
const { version } = getPkgJSON(); | ||
const pkg = getPkgJSON(); | ||
|
||
main(); | ||
|
||
function main() { | ||
consola.info('Generate publish pkg'); | ||
generatePublishPkg(); | ||
|
||
let command = 'npm publish --access public'; | ||
|
||
const preid = version.match(/\d-(.+)\.\d$/)?.[1]; | ||
const preid = pkg.version.match(/\d-(.+)\.\d$/)?.[1]; | ||
if (preid) { | ||
command += ` --tag ${preid}`; | ||
} | ||
|
||
consola.info('Publish NPM'); | ||
exec(command); | ||
} | ||
|
||
function generatePublishPkg() { | ||
const publishPkg = {}; | ||
|
||
[ | ||
'name', | ||
'version', | ||
'description', | ||
'main', | ||
'module', | ||
'types', | ||
'files', | ||
'repository', | ||
'keywords', | ||
'author', | ||
'bugs', | ||
'homepage', | ||
'license', | ||
].forEach((key) => { | ||
publishPkg[key] = pkg[key]; | ||
}); | ||
|
||
fs.writeFileSync(pkgPath, JSON.stringify(publishPkg, null, 2) + '\n'); | ||
} |
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,28 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import readline from 'node:readline'; | ||
import { __dirname, getPkgJSON } from './utils'; | ||
|
||
const changelogPath = path.resolve(__dirname, 'CHANGELOG.md'); | ||
const releaselogPath = path.resolve(__dirname, 'RELEASELOG.md'); | ||
const { version } = getPkgJSON(); | ||
const versionRE = new RegExp(`^# \\[?${version}\\]?`); | ||
|
||
main(); | ||
|
||
async function main() { | ||
const changelog = readline.createInterface({ | ||
input: fs.createReadStream(changelogPath), | ||
crlfDelay: Infinity, | ||
}); | ||
|
||
let releaselog = ''; | ||
for await (const line of changelog) { | ||
if (line.startsWith('# ') && !versionRE.test(line)) { | ||
break; | ||
} | ||
releaselog += `${line}\n`; | ||
} | ||
|
||
fs.writeFileSync(releaselogPath, releaselog); | ||
} |
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
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,55 @@ | ||
import { describe, test, expect, beforeEach, afterEach, vi } from 'vitest'; | ||
import { getAdapterDefault } from 'src/adapter'; | ||
|
||
const platforms = [ | ||
'uni', | ||
'wx', | ||
'my', | ||
'swan', | ||
'tt', | ||
'qq', | ||
'qh', | ||
'ks', | ||
'dd', | ||
'jd', | ||
'unknown', | ||
]; | ||
|
||
describe.each(platforms)('src/adapter.ts', (p) => { | ||
beforeEach(() => { | ||
vi.stubGlobal(p, { | ||
request: vi.fn(), | ||
uploadFile: vi.fn(), | ||
downloadFile: vi.fn(), | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
vi.unstubAllGlobals(); | ||
}); | ||
|
||
test('应该可以获取到默认的平台适配器', () => { | ||
const a = getAdapterDefault(); | ||
if (p !== 'unknown') { | ||
expect(a).toBeTypeOf('function'); | ||
(expect(a).property('name') as any).toBe('adapter'); | ||
} else { | ||
// unknown 未知平台 | ||
expect(a).toBeUndefined(); | ||
} | ||
}); | ||
}); | ||
|
||
describe.each(platforms)('src/adapter.ts', (p) => { | ||
beforeEach(() => { | ||
vi.stubGlobal(p, {}); | ||
}); | ||
|
||
afterEach(() => { | ||
vi.unstubAllGlobals(); | ||
}); | ||
|
||
test('应该获取不到默认的平台适配器', () => { | ||
expect(getAdapterDefault()).toBeUndefined(); | ||
}); | ||
}); |
Oops, something went wrong.