Skip to content

Commit

Permalink
test: 💍 merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingyun2010 committed Jun 18, 2021
2 parents d7a46b0 + 2e0b2d2 commit ca1c37e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
26 changes: 17 additions & 9 deletions lib/__tests__/crypto.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Encrypt, Decrypt} from '../crypto'
import { Encrypt, Decrypt } from '../crypto';

describe('Encrypt AES', () => {
it('with empty', () => {
Expand All @@ -10,13 +10,17 @@ describe('Encrypt AES', () => {
});

it('valid oject data', () => {
const data = {name: '测试123'}
expect(Encrypt.AES(data, '1234567887654321')).toBe('egm/Mle8irv5rcW8KiYIP1ctnN/sh3k/KwpYvwyhjVg=');
const data = { name: '测试123' };
expect(Encrypt.AES(data, '1234567887654321')).toBe(
'egm/Mle8irv5rcW8KiYIP1ctnN/sh3k/KwpYvwyhjVg=',
);
});

it('valid Array data', () => {
const data = ['1', '2', '测试123']
expect(Encrypt.AES(data, '1234567887654321')).toBe('GHRDr875WQZmG69cTBTvbaDBhT7IjN/lC8l5cfoHz2U=');
const data = ['1', '2', '测试123'];
expect(Encrypt.AES(data, '1234567887654321')).toBe(
'GHRDr875WQZmG69cTBTvbaDBhT7IjN/lC8l5cfoHz2U=',
);
});
});

Expand All @@ -34,12 +38,16 @@ describe('Decrypt AES', () => {
});

it('valid oject data', () => {
const data = {name: '测试123'}
expect(Decrypt.AES('egm/Mle8irv5rcW8KiYIP1ctnN/sh3k/KwpYvwyhjVg=', '1234567887654321')).toBe(JSON.stringify(data));
const data = { name: '测试123' };
expect(Decrypt.AES('egm/Mle8irv5rcW8KiYIP1ctnN/sh3k/KwpYvwyhjVg=', '1234567887654321')).toBe(
JSON.stringify(data),
);
});

it('valid Array data', () => {
const data = ['1', '2', '测试123']
expect(Decrypt.AES('GHRDr875WQZmG69cTBTvbaDBhT7IjN/lC8l5cfoHz2U=', '1234567887654321')).toBe(JSON.stringify(data));
const data = ['1', '2', '测试123'];
expect(Decrypt.AES('GHRDr875WQZmG69cTBTvbaDBhT7IjN/lC8l5cfoHz2U=', '1234567887654321')).toBe(
JSON.stringify(data),
);
});
});
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@
],
"scripts": {
"start": "cross-env NODE_ENV=development PACKAGE=development node scripts/start.js",
"build": "npm run lint && cross-env NODE_ENV=production PACKAGE=production node scripts/build.js",
"build": "cross-env NODE_ENV=production PACKAGE=production node scripts/build.js",
"release": "sh scripts/release.sh",
"clean": "rimraf build",
"ci": "yarn commit",
"commit": "git-cz",
"test": "jest --no-cache",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"prettier": "prettier -c --write '**/*'",
"lint": "npm run lint:ts",
"prettier": "prettier -c --write '**/*.ts'",
"lint": "tsc --build tsconfig.build.json && node node_modules/tslint/bin/tslint -c ./tslint.json -p ./tsconfig.build.json",
"lint-staged": "lint-staged",
"lint:ts": "tsc --build tsconfig.build.json && node node_modules/tslint/bin/tslint -c ./tslint.json -p ./tsconfig.build.json",
"prepublish": "npm run lint && npm run test",
"np": "np --yolo --no-yarn",
"publish": "npm run build && npm run np"
"np": "np --no-cleanup --yolo --no-publish",
"prepublishOnly": "yarn clean && yarn prettier && yarn lint && yarn build && yarn np"
},
"publishConfig": {
"registry": "http://registry.npmjs.org"
},
"husky": {
"hooks": {
"commit-msg": "node scripts/verify-commit-msg.js",
"pre-commit": "lint-staged"
"pre-commit": "lint-staged",
"pre-push": "node scripts/publish-tips.js"
}
},
"lint-staged": {
Expand Down
8 changes: 8 additions & 0 deletions scripts/publish-tips.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const chalk = require('chalk');

console.log();
console.log(
` ${chalk.bgWhite.black(' 请使用')}${chalk.bgRed.black(' npm publish ')}${chalk.bgWhite.black(
'发布代码,会自动检查代码、打包、修改版本号等... ',
)} `,
);
4 changes: 3 additions & 1 deletion scripts/verify-commit-msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const packageJson = require('../package.json');

const commitRE = /^(revert: )?(feat|fix|polish|docs|style|refactor|perf|test|workflow|ci|chore|types|build)(\(.+\))?: .{1,50}/;

if (!commitRE.test(msg) && packageJson.version !== msg) {
console.log(`Commit: ${chalk.bgRed.white(msg)}`);

if (!commitRE.test(msg) && packageJson.version !== msg && !/^v/.test(msg)) {
console.log();
console.error(` ${chalk.bgRed.white(' ERROR ')} 无效的提交信息`);
process.exit(1);
Expand Down

0 comments on commit ca1c37e

Please sign in to comment.