Skip to content

Commit

Permalink
feat: use mocha to test the CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Apr 3, 2023
1 parent ef456b8 commit 6ee4f93
Show file tree
Hide file tree
Showing 30 changed files with 3,191 additions and 3,092 deletions.
16 changes: 16 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"require": [
"ts-node/register",
"./test/helpers/oclif.js",
"./test/helpers/stub-axios.js"
],
"watch-extensions": [
"ts"
],
"spec": [
"test/**/*.cli-test.ts"
],
"recursive": true,
"reporter": "spec",
"timeout": 60000
}
4 changes: 2 additions & 2 deletions hygen-template/artifact/new/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const { basename } = require('path');
const { promises: fsp } = require('fs');
const _ = require('lodash');

const { loadConfig } = require('../../../build/utils/config');
const internal = require('../../../build/internal');

module.exports = {
prompt: ({ prompter: inquirer }) => {
const config = loadConfig(process.cwd(), './surgio.conf.js');
const config = internal.config.loadConfig(process.cwd());

return inquirer.prompt([
{
Expand Down
3 changes: 2 additions & 1 deletion hygen-template/provider/new/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const { SupportProviderEnum } = require('../../../build/types');
const { types } = require('../../../build/internal');
const { SupportProviderEnum } = types;

module.exports = {
prompt: ({ prompter: inquirer }) => {
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./build/index.js');
1 change: 1 addition & 0 deletions internal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./build/internal.js');
73 changes: 44 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@
"name": "surgio",
"description": "Generating rules for Surge, Clash, Quantumult like a PRO",
"version": "2.25.0",
"main": "build/index.js",
"typings": "build/index.d.ts",
"main": "./build/index.js",
"typings": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"require": "./build/index.js"
},
"./internal": {
"types": "./build/internal.d.ts",
"require": "./build/internal.js"
}
},
"bin": {
"surgio": "bin/run"
},
Expand All @@ -20,9 +30,10 @@
},
"homepage": "https://surgio.royli.dev",
"scripts": {
"test": "run-s test:*",
"test": "run-s build test:*",
"test:lint": "eslint -c .eslintrc.js --ext .js,.ts .",
"test:unit": "run-s build && ava",
"test:unit": "ava",
"test:cli": "mocha",
"coverage": "cross-env TS_NODE_FILES=true nyc ava",
"clean": "rimraf build",
"build": "run-s clean && tsc -p tsconfig.build.json",
Expand Down Expand Up @@ -54,13 +65,13 @@
},
"dependencies": {
"@brillout/import": "^0.2.2",
"@oclif/core": "^2.6.5",
"@oclif/plugin-help": "^5.2.8",
"@oclif/core": "^2.8.0",
"@oclif/plugin-help": "^5.2.9",
"@oclif/plugin-plugins": "^2.4.3",
"@royli/hygen": "^6.2.0",
"@surgio/eslint-config-surgio": "^1.0.5",
"@surgio/logger": "^1.2.1",
"@types/eslint": "^8.21.3",
"@types/eslint": "^8.37.0",
"agentkeepalive": "^4.3.0",
"ali-oss": "^6.17.1",
"bluebird": "^3.7.2",
Expand All @@ -73,10 +84,10 @@
"detect-newline": "^3.1.0",
"dotenv": "^16.0.3",
"emoji-regex": "^10.2.1",
"eslint": "^8.36.0",
"eslint": "^8.37.0",
"espree": "^7.3.1",
"execa": "^4.1.0",
"filesize": "^10.0.6",
"filesize": "^10.0.7",
"fs-extra": "^11.1.1",
"got": "^11.8.6",
"hpagent": "^1.2.0",
Expand All @@ -89,35 +100,37 @@
"node-cache": "^5.1.2",
"node-dir": "^0.1.17",
"nunjucks": "^3.2.3",
"ora": "^6.2.0",
"ora": "^5.4.1",
"query-string": "^7.1.3",
"rimraf": "^4.4.0",
"rimraf": "^4.4.1",
"source-map-support": "^0.5.21",
"type-fest": "^3.6.1",
"update-notifier": "^6.0.2",
"type-fest": "^3.7.2",
"update-notifier": "^5.1.0",
"urlsafe-base64": "^1.0.0",
"yaml": "^2.2.1"
},
"devDependencies": {
"@algolia/client-search": "^4.15.0",
"@commitlint/cli": "^17.4.4",
"@algolia/client-search": "^4.16.0",
"@commitlint/cli": "^17.5.1",
"@commitlint/config-angular": "^17.4.4",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@swc/core": "^1.3.42",
"@oclif/test": "^2.3.14",
"@types/bluebird": "^3.5.38",
"@types/bytes": "^3.1.1",
"@types/chai": "^4.3.4",
"@types/debug": "^4.1.7",
"@types/fs-extra": "^11.0.1",
"@types/hapi__joi": "^17.1.9",
"@types/inquirer": "^8.2.6",
"@types/ioredis-mock": "^8.2.1",
"@types/lodash": "^4.14.191",
"@types/node": "^16",
"@types/lodash": "^4.14.192",
"@types/mocha": "^10.0.1",
"@types/node": "^16.18.23",
"@types/nunjucks": "^3.2.2",
"@types/sinon": "^10.0.13",
"@types/urlsafe-base64": "^1.0.28",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"@vuepress/client": "2.0.0-beta.61",
"@vuepress/plugin-docsearch": "2.0.0-beta.61",
"@vuepress/plugin-google-analytics": "2.0.0-beta.61",
Expand All @@ -126,24 +139,26 @@
"@vuepress/utils": "2.0.0-beta.61",
"ava": "^5.2.0",
"benchmark": "^2.1.4",
"coffee": "^5.5.0",
"chai": "^4.3.7",
"chai-jest-snapshot": "^2.0.0",
"conventional-changelog-cli": "^2.2.2",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"ini": "^3.0.1",
"ioredis-mock": "^8.2.6",
"ioredis-mock": "^8.4.0",
"lint-staged": "^13.2.0",
"mocha": "^10.2.0",
"nock": "^13.3.0",
"np": "^6.5.0",
"npm-debug-log-cleaner": "^1.0.3",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"prettier": "^2.8.6",
"sass": "^1.59.3",
"sinon": "^15.0.2",
"prettier": "^2.8.7",
"sass": "^1.60.0",
"sinon": "^15.0.3",
"ts-node": "^10.9.1",
"typescript": "^5.0.2",
"typescript": "^5.0.3",
"vue": "^3.2.47",
"vuepress": "2.0.0-beta.61",
"vuepress-plugin-sitemap2": "2.0.0-beta.197"
Expand All @@ -156,12 +171,12 @@
"js"
],
"files": [
"test/**/*.test.ts",
"lib/**/*.test.ts"
"./test/**/*.test.ts",
"./src/**/*.test.ts"
],
"require": [
"ts-node/register",
"./test/stub-axios.js"
"./test/helpers/stub-axios.js"
]
},
"nyc": {
Expand Down
Loading

0 comments on commit 6ee4f93

Please sign in to comment.