Skip to content

Commit

Permalink
refactor: use new impl
Browse files Browse the repository at this point in the history
  • Loading branch information
afeiship committed Jun 5, 2022
1 parent 82e7547 commit d2aeb2e
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 61 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Rakefile

.editorconfig
.release-it.json
.prettierrc
9 changes: 9 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
registry=https://registry.npm.taobao.org
disturl=https://npm.taobao.org/dist
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
chromedriver_cdnurl=https://npm.taobao.org/mirrors/chromedriver
operadriver_cdnurl=https://npm.taobao.org/mirrors/operadriver
selenium_cdnurl=https://npm.taobao.org/mirrors/selenium
node_inspector_cdnurl=https://npm.taobao.org/mirrors/node-inspector
fsevents_binary_host_mirror=http://npm.taobao.org/mirrors/fsevents/
package-lock=false
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"trailingComma": "none",
"arrowParens": "always",
"printWidth": 100,
"printWidth": 80,
"bracketSpacing": true,
"jsxBracketSameLine": true,
"tabWidth": 2,
Expand Down
8 changes: 3 additions & 5 deletions .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
},
"hooks": {
"after:init": [
"t2k",
"npm run build"
"t2k"
]
},
"github": {
"release": true
"release": true,
"proxy": "http://127.0.0.1:9090"
}
}


18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,28 @@
[![size][size-image]][size-url]
[![download][download-image]][download-url]

![snapshot](https://tva1.sinaimg.cn/large/008eGmZEgy1goaa40g6e1j30m003y3yl.jpg)
![snapshot](https://tva1.sinaimg.cn/large/0081Kckwgy1gk87ynhkbaj30u60asasp.jpg)

## installation
```shell
# 1. install deps(7z)
brew install p7zip
# public
npm i -g @jswork/active-code-cli

# 2. intall acc cmd to global
# private
git clone https://github.com/afeiship/active-code-cli.git
cd active-code-cli
npm link
npm i && npm link
```

## usage
~~~
Usage: acc [options]
Usage: active-code-cli [options]
Options:
-V, --version output the version number
-h, --help display help for command
-V, --version output the version number
-d, --debug only show cmds, but not clean.
-s, --src <string> source filepath. (default: "./src")
-h, --help display help for command
~~~

## license
Expand Down
67 changes: 43 additions & 24 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,63 @@
#!/usr/bin/env node
const { Command } = require('commander');
const chalk = require('chalk');
const cheerio = require('cheerio');
const fetch = require('node-fetch');
const inquirer = require('inquirer');
const clipboardy = require('clipboardy');

// next packages:
require('@jswork/next');
require('@jswork/next-absolute-package');
require('@jswork/next-node-downfile');

// http://idea.medeming.com/jets/
const { version } = nx.absolutePackage();
const program = new Command();
const execSync = require('child_process').execSync;
const TMP_DIR = '/tmp/idea-crack';
// backup urls:
// http://ajihuo.com/a/jihuoma.zip
// http://idea.medeming.com/a/jihuoma.zip
// http://idea.medeming.com/jets/images/jihuoma.zip

// 原始地址: http://idea.medeming.com/idea/
// http://idea.medeming.com/a/jihuoma1.zip
const ZIP_DIR = `http://idea.medeming.com/a/jihuoma1.zip?ts=${Date.now()}`;
const secrets = {
idea: ['https://idea.medeming.com/jetbrains/1119.html', 220529],
pycharm: ['https://idea.medeming.com/pycharm/1045.html', 550529]
};

const DEFAULT_OPTS = {
method: 'post',
headers: {
'content-type': 'application/x-www-form-urlencoded'
}
};

program.version(version);
program.parse(process.argv);

nx.declare({
statics: {
init() {
const app = new this();
app.start();
}
},
const App = nx.declare({
methods: {
init() {},
start() {
execSync([`rm -rf ${TMP_DIR}`, `mkdir -p ${TMP_DIR}`].join('&&'));
nx.nodeDownfile({ url: ZIP_DIR, filename: `${TMP_DIR}/active-code.zip` }).then(() => {
execSync([`cd ${TMP_DIR}/`, '7z e active-code.zip', 'cat *late*.txt | pbcopy'].join('&&'));
console.log(chalk.green('😎 Copyed!'));
});
async get(inTarget) {
const secret = secrets[inTarget];
const html = await fetch(secret[0], {
...DEFAULT_OPTS,
body: `secret_key=${secret[1]}`
}).then((res) => res.text());
const $ = cheerio.load(html);
const text = $('.secret-password blockquote').eq(1).text();
clipboardy.writeSync(text);
},
async start() {
const res = await inquirer.prompt([
{
name: 'type',
type: 'list',
message: 'Select your IDE',
choices: [{ value: 'idea' }, { value: 'pycharm' }]
}
]);

await this.get(res.type);
console.log(chalk.green('😎 Copyed!'));
}
}
});

(async () => {
const app = new App();
await app.start();
})();
5 changes: 4 additions & 1 deletion build/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

const gulp = require('gulp');
const exec = require('child_process').execSync;
const pkg = nx.absolutePackage();
const cmd = nx.getKey(pkg.bin, 'bin/index.js')
const $ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'gulp.*', 'del', '@jswork/gulp-*']
});

const usage = exec('acc -h').toString().trim();
const usage = exec(`${cmd} -h`).toString().trim();


gulp.task('docs', function () {
return gulp
Expand Down
14 changes: 7 additions & 7 deletions docs/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
[![size][size-image]][size-url]
[![download][download-image]][download-url]

![snapshot](https://tva1.sinaimg.cn/large/008eGmZEgy1goaa40g6e1j30m003y3yl.jpg)
![snapshot](https://tva1.sinaimg.cn/large/0081Kckwgy1gk87ynhkbaj30u60asasp.jpg)

## installation
```shell
npm install @jswork/active-code-cli
```
# public
npm i -g @jswork/active-code-cli

## dependencies
```shell
# 7z
brew install p7zip
# private
git clone https://github.com/afeiship/active-code-cli.git
cd active-code-cli
npm i && npm link
```

## usage
Expand Down
4 changes: 4 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
const gulp = require('gulp');
const fs = require('fs');

require("@jswork/next");
require('@jswork/next-absolute-package');
require('@jswork/next-get-key');

//import
fs.readdirSync('./build').map(function (file) {
require('./build/' + file);
Expand Down
37 changes: 22 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"name": "@jswork/active-code-cli",
"version": "1.0.3",
"description": "Get active code and copy it.",
"homepage": "https://github.com/afeiship/active-code-cli",
"homepage": "https://js.work",
"author": {
"name": "afei",
"email": "1290657123@qq.com"
},
"bin": {
"acc": "bin/index.js"
"acc": "bin/index.js",
"active-code-cli": "bin/index.js"
},
"scripts": {
"build": "gulp",
Expand All @@ -17,32 +18,38 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@jswork/next": "^1.0.2",
"@jswork/next": "^1.0.5",
"@jswork/next-absolute-package": "^1.0.1",
"@jswork/next-node-downfile": "^1.0.0",
"@jswork/next-get-key": "^1.0.0",
"chalk": "^4.1.0",
"cheerio": "^1.0.0-rc.11",
"clipboardy": "^2.3.0",
"commander": "^6.2.0",
"globby": "^11.1.0",
"gulp-rename": "^2.0.0",
"inquirer": "^8.2.4",
"node-fetch": "^2.6.7",
"require-dir": "^1.2.0",
"yargs": "^13.2.4"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"del": "^6.0.0",
"gulp": "^4.0.2",
"gulp-load-plugins": "^2.0.5",
"gulp-replace": "^1.0.0",
"prettier": "^2.1.2",
"release-it": "^14.2.1"
"release-it": "^14.14.3"
},
"keywords": [
"crack",
"code",
"cli",
"rubymime",
"idea"
]
"boilerplate",
"cli"
],
"repository": {
"type": "git",
"url": "https://github.com/afeiship/active-code-cli.git"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
}
}

0 comments on commit d2aeb2e

Please sign in to comment.