Skip to content

Commit

Permalink
🚀 v1.0.0 版本发布
Browse files Browse the repository at this point in the history
  • Loading branch information
sifan committed Dec 15, 2020
0 parents commit f09fa26
Show file tree
Hide file tree
Showing 20 changed files with 11,943 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 指定作用文件格式
[*.{js,jsx,ts,tsx,vue}]
# 缩进的类型 [space | tab]
indent_style = space
# 缩进的大小
# tab_width: 设置整数用于指定替代tab的列数。默认值就是indent_size的值,一般无需指定。
indent_size = 2
# 定义换行符 [lf | cr | crlf]
end_of_line = lf
# 是否除去换行行首的任意空白字符
trim_trailing_whitespace = false
# 文件是否以一个空白行结尾 [true | false]
insert_final_newline = false
max_line_length = 100
# 表明这是最顶层的配置文件,这样才会停止继续向上查找 .editorconfig 文件;
# 查找的 .editorconfig 文件是从顶层开始读取的,类似变量作用域的效果,内部
# 的 .editorconfig 文件属性优先级更高
root = true
# 编码格式。支持latin1、utf-8、utf-8-bom、utf-16be和utf-16le,不建议使用uft-8-bom。
charset = utf-8

6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
src/assets/
src/mock
public
*.d.ts
build
tsconfig.json
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'eslint:recommended',
'@vue/typescript/recommended'
],
parserOptions: {
ecmaVersion: 2020
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
"no-use-before-define": [2, { "functions": false }]
}
}
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
node_modules

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
45 changes: 45 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@


const { src, dest, series } = require('gulp');
const clean = require('gulp-clean');
const path = require('path');
const foldPath = 'packages/date-week-range';
const jsonEditor = require("gulp-json-editor");
const { Reflect } = require('core-js');
const merge = require('merge')

function copy (name) {
return function copy() {
clear(name);

return src(name)
.pipe(dest(foldPath));
}
}

function clear(name) {
return src(path.resolve(foldPath, name), {
allowEmpty: true
}).pipe(clean({
force: true
}));
}

function package() {
return src("package.json")
.pipe(jsonEditor(function(json) {
const existJson = {
scripts: {
test: 'echo "Error: no test specified" && exit 1'
}
};
const tmpJson = merge(json, existJson);

Reflect.deleteProperty(tmpJson, 'devDependencies');
Reflect.deleteProperty(tmpJson, 'dependencies');

return tmpJson;
})).pipe(dest(foldPath));
}

exports.default = series(copy('LICENSE'), copy('README.md'), package)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 sifan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# vue3-count-to

> 基于 vue-count-to 升级改造
## 目的

- 由于原有作者好像没打算升级版本,故而自己升级维护一下。

## 兼容

- 当前版本同时兼容 vue2、vue3,亦能在ts下使用

## 安装 && 引入

> * 安装
``` bash
npm install vue3-count-to --save
```
> * 全局注册
```javascript
import countTo from 'vue3-count-to';
```

使用 Vue 2:

```javascript
Vue.use(countTo);
```

使用 Vue 3:

```javascript
import { createApp } from 'vue';

const app = createApp(...);

app.use(countTo);
```

局部引入

```javascript
<template>
<countTo></countTo>
</template>

<script>
import countTo from 'vue3-count-to';

export default {
components: {
countTo
}
}
</script>
```

> * 浏览器使用
```html
<script src="https://unpkg.com/vue"></script>
<!-- or -->
<script src="https://unpkg.com/vue@next"></script>
<script src="https://unpkg.com/vue3-count-to"></script>
```
## 文档

参看 [vue-count-to](https://github.com/PanJiaChen/vue-countTo) 文档。
14 changes: 14 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
presets: [
[
'@babel/env',
{
modules: false,
},
],
],
plugins: [
'@vue/babel-plugin-jsx',
'@babel/transform-runtime',
]
}
79 changes: 79 additions & 0 deletions build/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"use strict";

const ora = require("ora");
const rm = require("rimraf");
const path = require("path");
const chalk = require("chalk");
const webpack = require("webpack");
const webpackConfig = require("./webpack.conf.js");
const merge = require("webpack-merge");
const config = require("./config");

let isModern = false;
let isOnly = false;

process.argv.forEach(item => {
if (item.includes("modern")) {
isModern = true;
}

if (item.includes("only")) {
isOnly = true;
}
});

let spinner;

function logStart(str = "") {
spinner = ora(`Building ${str}bundle for production...`);

spinner.start();
}

function build(webpackConfig, str) {
return new Promise(function (resolve, reject) {
logStart(str);

webpack(webpackConfig, function (err, stats) {
spinner.stop();
if (err) {
process.exit(1);

throw err;
}

if (stats.hasErrors()) {
console.log(stats.toString({
colors: true
}));

console.log(chalk.red("\nBuild failed with errors.\n"));

process.exit(1);
}

resolve();
});
});
}

(async function () {
rm(
config.output.path,
async err => {
if (err) {
spinner.stop();

process.exit(1);
throw err;
}
let startTime = Date.now();

await build(webpackConfig);

console.log(
chalk.green("Build complete in " + (Date.now() - startTime) + "ms.\n")
);
}
);
})();
45 changes: 45 additions & 0 deletions build/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const path = require('path');
const { genTranspileDepRegex } = require("./utils");
const nodeExternals = require('webpack-node-externals');

exports.alias = {
packages: path.resolve(__dirname, '../packages'),
};

exports.vue = {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
};

exports.externals = [{ vue: 'vue' }, nodeExternals()];

exports.jsexclude = function (filepath){
const transpileDependencies = ['element-ui/src', 'element-ui/packages'];
const transpileDepRegex = genTranspileDepRegex(transpileDependencies);

// always transpile js in vue files
if (/\.vue\.jsx?$/.test(filepath)) {
return false
}

// only include @babel/runtime when the @vue/babel-preset-app preset is used
if (
process.env.VUE_CLI_TRANSPILE_BABEL_RUNTIME &&
filepath.includes(path.join('@babel', 'runtime'))
) {
return false
}

// check if this is something the user explicitly wants to transpile
if (transpileDepRegex && transpileDepRegex.test(filepath)) {
return false
}
// Don't transpile node_modules
return /node_modules/.test(filepath)
}

exports.output = {
path: path.resolve(process.cwd(), './dist')
}
19 changes: 19 additions & 0 deletions build/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const path = require("path");

exports.isWindows = process.platform === 'win32';

function genTranspileDepRegex (transpileDependencies) {
const deps = transpileDependencies.map(dep => {
if (typeof dep === 'string') {
const depPath = path.join('node_modules', dep, '/')
return exports.isWindows
? depPath.replace(/\\/g, '\\\\') // double escape for windows style path
: depPath
} else if (dep instanceof RegExp) {
return dep.source
}
})
return deps.length ? new RegExp(deps.join('|')) : null
}

exports.genTranspileDepRegex = genTranspileDepRegex;
Loading

0 comments on commit f09fa26

Please sign in to comment.