-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Step
committed
Mar 14, 2021
1 parent
49f7543
commit 25ae832
Showing
6 changed files
with
110 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Check and Publish Package | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
env: | ||
USERPASS: ${{secrets.USERPASS}} | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
- run: npm ci | ||
- run: npm test | ||
|
||
publish-npm: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
# moy-nalog | ||
Обёртка для API сервиса lknpd.nalog.ru | ||
# Отправка чеков в налоговую | ||
Неофициальная обёртка для API сервиса lknpd.nalog.ru | ||
|
||
Пригодится для автоматизации отправки информации о доходах самозанятых. | ||
|
||
|
||
## Использование | ||
|
||
... | ||
|
||
|
||
[Подробное описание методов класса](/blob/main/docs/nalogAPIClass.md) | ||
|
||
|
||
## Разработка | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const NalogAPI = require('../index.js') | ||
|
||
if (!process.env.USERPASS) { | ||
process.exit(1) | ||
} | ||
|
||
const [USER, PASS] = process.env.USERPASS.split(':') | ||
|
||
const tests = { | ||
'Логин и пароль - обязательны при autologin': async () => { | ||
try { | ||
// eslint-disable-next-line no-unused-vars | ||
const ok = new NalogAPI({ password: PASS }) | ||
} catch (err) { | ||
return true | ||
} | ||
}, | ||
|
||
'Проверка авто-логина': async () => { | ||
const MyNalog = new NalogAPI({ login: USER, password: PASS }) | ||
const profile = await MyNalog.userInfo() | ||
|
||
if (!profile || !profile.id) { | ||
console.error(profile) | ||
throw new Error('Ошибка получения информации о пользователе') | ||
} | ||
return true | ||
}, | ||
|
||
'Самостоятельный логин': async () => { | ||
const MyNalog = new NalogAPI({ autologin: false }) | ||
if (MyNalog.authPromise) { throw new Error('сработал автологин') } | ||
const resp = await MyNalog.auth(USER, PASS) | ||
if (!resp || !resp.refreshToken) { | ||
console.error(resp) | ||
throw new Error('Ошибка логина') | ||
} | ||
return true | ||
} | ||
}; | ||
|
||
(async () => { | ||
for (const testName in tests) { | ||
const result = await tests[testName]() | ||
if (result) { | ||
console.info(`[OK] - ${testName}`) | ||
} else { | ||
console.error(`[FAIL] - ${testName}`, result) | ||
process.exit(1) | ||
} | ||
} | ||
})() |