Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
feat: start using sstore 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb committed Feb 21, 2021
1 parent 2d6a454 commit eb666a3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beetcb/cea",
"version": "2.0.4",
"version": "2.0.5",
"description": "campusphere-elegant-auth: login to swms/campusphere at ease",
"main": "dist/index.js",
"bin": "dist/cli.js",
Expand All @@ -27,10 +27,10 @@
},
"license": "ISC",
"dependencies": {
"@beetcb/sstore": "^0.0.3",
"@iarna/toml": "^2.2.5",
"chalk": "^4.1.0",
"cheerio": "^1.0.0-rc.5",
"conf": "^9.0.2",
"inquirer": "^7.3.3",
"node-fetch": "^2.6.1",
"tesseract.js": "^2.1.4",
Expand Down
2 changes: 1 addition & 1 deletion src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function loadConfFromToml(path) {
}

// Useful when we init users/shchool from file/env
conf.load = async function () {
conf.init = async function () {
const env = process.env
const toml = loadConfFromToml('./conf.toml')
const userUlti = new User(conf)
Expand Down
6 changes: 3 additions & 3 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const { User, School, conf } = require('./api')

;(async () => {
await conf.load()
const argv = process.argv[2] || ''
const argv2 = process.argv[3]

Expand All @@ -23,16 +24,15 @@ const { User, School, conf } = require('./api')
case 'rm':
case '--remove': {
if (argv2 === 'all') conf.clear()
conf.delete(argv2)
conf.del(argv2)
break
}
case 'sign': {
require('../TEST/dcampus')
break
}
case 'load': {
await conf.load()
break
await conf.init()
}
}
})()
Expand Down
4 changes: 1 addition & 3 deletions src/cookie.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const Conf = require('conf')
const conf = require('@beetcb/sstore')
const log = require('../interface/colorLog')
const login = require('../crawler/casLogIn')
const { signApp } = require('../campusphere/app')

const conf = new Conf()

// get|store|update cookie synchronizedly, prevent concurrent overlap writes to conf
conf.handleCookie = async () => {
// Return users with curTask
Expand Down

0 comments on commit eb666a3

Please sign in to comment.