mirror of
https://github.com/any86/any-rule.git
synced 2025-07-14 15:38:58 +08:00
feat:改为使用webpack打包,减少体积
This commit is contained in:
parent
5108c46811
commit
87466146d2
@ -1,39 +0,0 @@
|
|||||||
# Javascript Node CircleCI 2.0 configuration file
|
|
||||||
#
|
|
||||||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
|
|
||||||
#
|
|
||||||
version: 2
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
docker:
|
|
||||||
# specify the version you desire here
|
|
||||||
- image: circleci/node:8.9.4
|
|
||||||
|
|
||||||
# Specify service dependencies here if necessary
|
|
||||||
# CircleCI maintains a library of pre-built images
|
|
||||||
# documented at https://circleci.com/docs/2.0/circleci-images/
|
|
||||||
# - image: circleci/mongo:3.4.4
|
|
||||||
|
|
||||||
working_directory: ~/repo
|
|
||||||
|
|
||||||
parallelism: 1
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
|
|
||||||
# - restore_cache:
|
|
||||||
# key: dependency-cache-{{ checksum "package.json" }}
|
|
||||||
|
|
||||||
# - run: yarn install
|
|
||||||
# - run: yarn add codecov
|
|
||||||
- run: yarn add chalk
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# - save_cache:
|
|
||||||
# key: dependency-cache-{{ checksum "package.json" }}
|
|
||||||
# paths:
|
|
||||||
# - ./node_modules
|
|
||||||
# run tests!
|
|
||||||
- run: yarn test:rules
|
|
||||||
# - run: ./node_modules/.bin/codecov
|
|
@ -1,10 +1,14 @@
|
|||||||
.vscode/**
|
.vscode/**
|
||||||
.vscode-test/**
|
.vscode-test/**
|
||||||
out/test/**
|
.github/**
|
||||||
|
out/**
|
||||||
src/**
|
src/**
|
||||||
|
node_modules
|
||||||
.gitignore
|
.gitignore
|
||||||
vsc-extension-quickstart.md
|
vsc-extension-quickstart.md
|
||||||
|
**/webpack.config.js
|
||||||
**/tsconfig.json
|
**/tsconfig.json
|
||||||
**/tslint.json
|
**/tslint.json
|
||||||
|
**/*.lock
|
||||||
**/*.map
|
**/*.map
|
||||||
**/*.ts
|
**/*.ts
|
@ -1,6 +1,11 @@
|
|||||||
# 更新日志
|
# 更新日志
|
||||||
🚀 提交问题: https://github.com/any86/any-rule/issues/new
|
🚀 提交问题: https://github.com/any86/any-rule/issues/new
|
||||||
|
|
||||||
|
- 0.1.0
|
||||||
|
- [x] 重新设计交互方式
|
||||||
|
- [x] 支持拼音、关键词以及模糊查询
|
||||||
|
- [x] 支持在线更新规则
|
||||||
|
|
||||||
- 0.0.13
|
- 0.0.13
|
||||||
- [x] 给"统一社会信用代码"增加^$标记
|
- [x] 给"统一社会信用代码"增加^$标记
|
||||||
- [x] 修复图片/视频连接匹配不严谨
|
- [x] 修复图片/视频连接匹配不严谨
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
const chalk = require('chalk');
|
|
||||||
const RULES = require('../packages/www/src/RULES');
|
|
||||||
let failGroup = [];
|
|
||||||
|
|
||||||
|
|
||||||
RULES.forEach(RULE => {
|
|
||||||
testOne(RULE);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function testOne(one) {
|
|
||||||
const {
|
|
||||||
rule,
|
|
||||||
examples,
|
|
||||||
title,
|
|
||||||
counterExamples
|
|
||||||
} = one;
|
|
||||||
examples.forEach(example => {
|
|
||||||
const isSuccess = rule.test(example);
|
|
||||||
if (isSuccess) {
|
|
||||||
console.log(chalk.green(`成功: ${title}, 用例: ${example}`));
|
|
||||||
} else {
|
|
||||||
failGroup.push({title, example, is:'正例'});
|
|
||||||
|
|
||||||
console.log(chalk.red(`失败: ${title}, 用例: ${example}`));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (counterExamples) {
|
|
||||||
counterExamples.forEach(example => {
|
|
||||||
const isFail = !rule.test(example);
|
|
||||||
if (isFail) {
|
|
||||||
console.log(chalk.green(`反例成功(counterExamples): ${title}`));
|
|
||||||
} else {
|
|
||||||
failGroup.push({title, example, is: '反例'});
|
|
||||||
console.log(chalk.red(`反例失败(counterExamples): ${title}, 用例: ${example}`));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(0 === failGroup.length) {
|
|
||||||
console.log(chalk.green('\r\n🚀 全部测试通过!'))
|
|
||||||
} else {
|
|
||||||
console.log(chalk.red('='.repeat(30) + '🔥 未通过测试' + '='.repeat(30)));
|
|
||||||
|
|
||||||
// 失败列表
|
|
||||||
failGroup.forEach(item=>{
|
|
||||||
const str = `${item.title}[${item.is}]: ${item.example}`;
|
|
||||||
console.log(chalk.red(str));
|
|
||||||
});
|
|
||||||
}
|
|
9
dist/extension.js
vendored
Normal file
9
dist/extension.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/extension.js.map
vendored
Normal file
1
dist/extension.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
13
package.json
13
package.json
@ -24,7 +24,7 @@
|
|||||||
"onCommand:extension.support",
|
"onCommand:extension.support",
|
||||||
"*"
|
"*"
|
||||||
],
|
],
|
||||||
"main": "./out/extension.js",
|
"main": "./dist/extension.js",
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
@ -58,7 +58,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"vscode:prepublish": "yarn run compile",
|
"vscode:prepublish": "webpack --mode production",
|
||||||
|
"webpack": "webpack --mode development",
|
||||||
|
"webpack-dev": "webpack --mode development --watch",
|
||||||
"compile": "tsc -p ./",
|
"compile": "tsc -p ./",
|
||||||
"watch": "tsc -watch -p ./",
|
"watch": "tsc -watch -p ./",
|
||||||
"pretest": "yarn run compile",
|
"pretest": "yarn run compile",
|
||||||
@ -75,8 +77,11 @@
|
|||||||
"@types/vscode": "^1.41.0",
|
"@types/vscode": "^1.41.0",
|
||||||
"glob": "^7.1.5",
|
"glob": "^7.1.5",
|
||||||
"mocha": "^6.2.2",
|
"mocha": "^6.2.2",
|
||||||
|
"ts-loader": "^6.2.1",
|
||||||
"tslint": "^5.20.0",
|
"tslint": "^5.20.0",
|
||||||
"typescript": "^3.6.4",
|
"typescript": "^3.6.4",
|
||||||
"vscode-test": "^1.2.2"
|
"vscode-test": "^1.2.2",
|
||||||
|
"webpack": "^4.41.5",
|
||||||
|
"webpack-cli": "^3.3.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,19 +0,0 @@
|
|||||||
const RULES = require('../packages/www/src/RULES.js');
|
|
||||||
const pkg = require('../package.json');
|
|
||||||
const fs = require('fs');
|
|
||||||
const chalk = require('chalk');
|
|
||||||
|
|
||||||
pkg.contributes.commands = [];
|
|
||||||
pkg.activationEvents = [];
|
|
||||||
RULES.forEach((rule, index) => {
|
|
||||||
pkg.contributes.commands.push({
|
|
||||||
command: 'extension.rule' + index,
|
|
||||||
title: `zz: ${rule.title}`
|
|
||||||
});
|
|
||||||
|
|
||||||
pkg.activationEvents.push('onCommand:extension.rule'+index);
|
|
||||||
})
|
|
||||||
|
|
||||||
// console.log(JSON.stringify(pkg));
|
|
||||||
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 4), 'utf8');
|
|
||||||
console.log(chalk.green('🚀 pkg文件修改完毕, 请等待生成vsc包...'));
|
|
@ -1,55 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const chalk = require('chalk');
|
|
||||||
const json = require('../packages/www/src/RULES');
|
|
||||||
const VSC_URL = 'https://marketplace.visualstudio.com/items?itemName=russell.any-rule'
|
|
||||||
const badges = [
|
|
||||||
// ``,
|
|
||||||
|
|
||||||
``,
|
|
||||||
|
|
||||||
|
|
||||||
`[](https://marketplace.visualstudio.com/items?itemName=russell.any-rule)`,
|
|
||||||
|
|
||||||
`[](https://marketplace.visualstudio.com/items?itemName=russell.any-rule)`,
|
|
||||||
|
|
||||||
`[](https://marketplace.visualstudio.com/items?itemName=russell.any-rule)`,
|
|
||||||
|
|
||||||
``,
|
|
||||||
|
|
||||||
`[](https://circleci.com/gh/any86/any-rule)`
|
|
||||||
];
|
|
||||||
|
|
||||||
let content = `# 正则大全 ${badges.join(' ')}
|
|
||||||
|
|
||||||
支持**图形界面** / **vscode插件**2种查询方式.
|
|
||||||
|
|
||||||
## :rocket:图形界面
|
|
||||||
https://any86.github.io/any-rule/
|
|
||||||
|
|
||||||
## 🍭vscode插件
|
|
||||||
1. 安装vscode中插件搜索框输入**any-rule**
|
|
||||||
2. 安装完毕后按**F1**(或者ctrl+shift+p).
|
|
||||||
3. 输入"**zz**"可以看到正则列表.
|
|
||||||
4. 或者**输入关键词**, 比如"手机".
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## :fire:关于PR
|
|
||||||
欢迎大家PR, 步骤如下:
|
|
||||||
1. **正则**请在**packages/www/src/RULES.js**中添加.
|
|
||||||
2. 运行\`npm run test:rules\`进行测试.
|
|
||||||
3. 运行\`npm run build:md\`更新**README.md**.
|
|
||||||
4. 请务必提交到**develop**分支.
|
|
||||||
|
|
||||||
在此感谢大家对**any-rule**做出的贡献!
|
|
||||||
|
|
||||||
## 🍔正则
|
|
||||||
`;
|
|
||||||
|
|
||||||
json.forEach(({title, rule})=>{
|
|
||||||
content+= `\r\n### ${title}\r\n`;
|
|
||||||
content+= `\`\`\`javascript\r\n`;
|
|
||||||
content+= `${rule}\r\n\`\`\`\r\n`;
|
|
||||||
});
|
|
||||||
fs.writeFileSync('./README.md',content,'utf-8');
|
|
||||||
console.log(chalk.green('生成完毕'));
|
|
42
webpack.config.js
Normal file
42
webpack.config.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
/**@type {import('webpack').Configuration}*/
|
||||||
|
const config = {
|
||||||
|
target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
|
||||||
|
|
||||||
|
entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
|
||||||
|
output: {
|
||||||
|
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
|
||||||
|
path: path.resolve(__dirname, 'dist'),
|
||||||
|
filename: 'extension.js',
|
||||||
|
libraryTarget: 'commonjs2',
|
||||||
|
devtoolModuleFilenameTemplate: '../[resource-path]'
|
||||||
|
},
|
||||||
|
devtool: 'source-map',
|
||||||
|
externals: {
|
||||||
|
vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
|
||||||
|
extensions: ['.ts', '.js']
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.ts$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'ts-loader'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = config;
|
Loading…
x
Reference in New Issue
Block a user