Skip to content

Commit

Permalink
release: v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JOU-amjs committed Oct 30, 2022
1 parent 1590b76 commit 7f031c9
Show file tree
Hide file tree
Showing 27 changed files with 5,686 additions and 15 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": [
["@babel/preset-env", {
"targets": {
"node": "current"
}
}]
]
}
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

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

[{package.json,.*rc,*.yml}]
indent_style = space
indent_size = 2
41 changes: 41 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* @Date: 2020-04-09 11:06:01
* @LastEditors: JOU(wx: huzhen555)
* @LastEditTime: 2020-04-09 11:56:36
*/
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
// "plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-console": "off",
"max-classes-per-file": ["error", 2],
}
};
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### 问题是什么

问题的具体描述,尽量详细

### 环境

- 手机: 小米6
- 系统:安卓7.1.1
- 浏览器:chrome 61
- jslib版本:0.2.0
- 其他版本信息

### 在线例子

如果有请提供在线例子

### 其他

其他信息
42 changes: 42 additions & 0 deletions .github/workflows/main-mock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: build

# 触发条件:在 push或合并请求 到 master 或 realease开头的分支后
on:
push:
branches:
- main
paths:
- packages/mock/**

pull_request:
branches:
- main
paths:
- packages/mock/**

# 任务
jobs:
build:
# 服务器环境:最新版 Ubuntu
runs-on: ubuntu-latest
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16.14.x
registry-url: 'https://registry.npmjs.org'
cache: 'npm'

# 执行测试和打包操作
- run: npm ci
- run: cd ./packages/mock && npm ci
- run: npm run build --if-present

# 这条命令包含了测试和上传覆盖率
# - run: npm run coveralls
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ALOVA_PUBLISH_TOKEN }}
35 changes: 20 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# Build and Release Folders
bin-debug/
bin-release/
[Oo]bj/
[Bb]in/
# dependencies
/node_modules
/packages/*/node_modules

# Other files and folders
.settings/
# testing
/packages/*/coverage

# Executables
*.swf
*.air
*.ipa
*.apk
# production
/packages/*/dist

# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
# should NOT be excluded as they contain compiler settings and other important
# information for Eclipse / Flash Builder.
# misc
.DS_Store
.idea
.coveralls.yml

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Optional eslint cache
.eslintcache
/demo
/design
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.d.ts
!index.d.ts
.rpt2_cache
coverage
node_modules
dist
.nyc_output
demo
design
16 changes: 16 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
printWidth: 120, // 换行字符串阈值
tabWidth: 2, // 设置工具每一个水平缩进的空格数
useTabs: true, // 是否使用tab缩进
semi: true, // 句末是否加分号
singleQuote: true, // 用单引号
trailingComma: 'none', // 最后一个对象元素符加逗号
bracketSpacing: true, // 对象字面量的大括号之间是否有空格
jsxBracketSameLine: true, // jsx > 是否另取一行
insertPragma: false, // 不需要自动在文件开头加入 @prettier
endOfLine: 'lf', // 换行符使用 lf
bracketSameLine: true, // 对象字面量的大括号是否另起一行
arrowParens: 'avoid', // 箭头函数参数是否使用圆括号
vueIndentScriptAndStyle: false, // vue文件中script和style标签的缩进
singleAttributePerLine: true // 单个属性是否单独一行
};
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Unit Test",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"runtimeArgs": [
"run",
"test"
],
"console": "integratedTerminal",
"cwd": "${workspaceRoot}",
"env": {
"NODE_ENV": "test"
}
}
]
}
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"editor.formatOnSave": true, // 保存是格式化
"editor.tabSize": 2, // Tab 的大小2个空格
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.suggestSelection": "recentlyUsedByPrefix", // 自动补全
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll.eslint": true // 修复所有代码
}
}
21 changes: 21 additions & 0 deletions config/rollup.config.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// rollup.config.js
// ES output
var config = require('./rollup.js');
var paths = config.compilePath;
var moduleType = 'esm';

module.exports = {
input: paths.input,
output: {
name: paths.packageName,
file: paths.output(moduleType),
format: 'es',
// 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()
]
};
35 changes: 35 additions & 0 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* @Date: 2020-04-09 11:06:01
* @LastEditors: JOU(wx: huzhen555)
* @LastEditTime: 2022-06-12 09:51:56
*/
// rollup.config.js
// commonjs
var config = require('./rollup.js');
var module = process.argv.pop().replace('--', '') || 'core';
var paths = config.compilePath;
var 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
})
]
};
47 changes: 47 additions & 0 deletions config/rollup.config.umd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* @Date: 2020-04-09 11:06:01
* @LastEditors: JOU(wx: huzhen555)
* @LastEditTime: 2022-06-12 09:51:50
*/
// 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.js');
var prod = process.env.NODE_ENV === 'production';
var paths = config.compilePath;
var moduleType = prod ? 'umd.min' : 'umd';

const globals = {};
// 将externals中的内容放到globals对象中
config.external.forEach(key => globals[key] = key);
module.exports = {
input: paths.input,
output: {
name: paths.packageName,
file: paths.output(moduleType),
format: 'umd',
// When export and export default are not used at the same time, set legacy to true.
// legacy: true,
globals,
banner: config.banner,
},
external: config.external,
plugins: [
nodeResolve({
browser: true,
extensions: ['.ts', '.js', 'tsx', 'jsx']
}),
commonjs(),
config.getCompiler(),
json(), // 可允许import json文件
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
preventAssignment: true,
}),
(prod && terser()),
]
};
51 changes: 51 additions & 0 deletions config/rollup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* @Date: 2020-04-09 11:06:01
* @LastEditors: JOU(wx: huzhen555)
* @LastEditTime: 2022-10-30 00:08:14
*/
var typescript = require('rollup-plugin-typescript2');
var { readFileSync } = require('fs');

const getCompiler = (opt = {
// objectHashIgnoreUnknownHack: true,
// clean: true,
tsconfigOverride: {
compilerOptions: {
module: 'ES2015'
}
}
}) => typescript(opt);
exports.getCompiler = getCompiler;
const compilePaths = {
mock: {
external: ['alova'],
packageName: 'AlovaMock',
input: 'src/index.ts',
output: suffix => `dist/alova-mock.${suffix}.js`,
}
};
exports.external = Object.keys(compilePaths)
.reduce((prev, next) => [
...prev,
...(compilePaths[next].external || [])
], [])
.filter(key => key !== 'core');

const extension = process.env.EXTENSION;
if (!extension) {
console.error('compiling extension error');
process.exit(1);
}

const pkg = JSON.parse(readFileSync('package.json').toString() || '{}');
const version = pkg.version;
const author = pkg.author;
const homepage = pkg.homepage;
exports.banner =
`/**
* ${pkg.name} ${version} (${homepage})
* Copyright ${(new Date).getFullYear()} ${author}. All Rights Reserved
* Licensed under MIT (${homepage}/blob/master/LICENSE)
*/
`;
exports.compilePath = compilePaths[extension];
Loading

0 comments on commit 7f031c9

Please sign in to comment.