@k03mad/dice 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +15 -0
- package/.github/dependabot.yml +14 -0
- package/.github/workflows/lint.yml +20 -0
- package/.github/workflows/publish.yml +34 -0
- package/.husky/pre-commit +1 -0
- package/.nvmrc +1 -0
- package/.vscode/settings.json +3 -0
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/app/png/1.png +0 -0
- package/app/png/2.png +0 -0
- package/app/png/3.png +0 -0
- package/app/png/4.png +0 -0
- package/app/png/5.png +0 -0
- package/app/png/6.png +0 -0
- package/app/run.js +59 -0
- package/eslint.config.js +1 -0
- package/package.json +40 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Lint
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
lint:
|
|
13
|
+
runs-on: ubuntu-22.04
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version-file: '.nvmrc'
|
|
19
|
+
- run: npm run setup
|
|
20
|
+
- run: npm run lint
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
environment: npm
|
|
11
|
+
runs-on: ubuntu-22.04
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
|
|
17
|
+
- uses: tj-actions/changed-files@v44
|
|
18
|
+
id: changed-files
|
|
19
|
+
with:
|
|
20
|
+
files: package.json
|
|
21
|
+
|
|
22
|
+
- if: steps.changed-files.outputs.any_changed == 'true'
|
|
23
|
+
uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version-file: '.nvmrc'
|
|
26
|
+
registry-url: 'https://registry.npmjs.org'
|
|
27
|
+
|
|
28
|
+
- if: steps.changed-files.outputs.any_changed == 'true'
|
|
29
|
+
run: npm run setup
|
|
30
|
+
|
|
31
|
+
- if: steps.changed-files.outputs.any_changed == 'true'
|
|
32
|
+
run: npm publish
|
|
33
|
+
env:
|
|
34
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm run lint
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Kirill Molchanov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/app/png/1.png
ADDED
|
Binary file
|
package/app/png/2.png
ADDED
|
Binary file
|
package/app/png/3.png
ADDED
|
Binary file
|
package/app/png/4.png
ADDED
|
Binary file
|
package/app/png/5.png
ADDED
|
Binary file
|
package/app/png/6.png
ADDED
|
Binary file
|
package/app/run.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {emitKeypressEvents} from 'node:readline';
|
|
4
|
+
|
|
5
|
+
import {log} from '@k03mad/simple-log';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import {globby} from 'globby';
|
|
8
|
+
import _ from 'lodash';
|
|
9
|
+
import image from 'terminal-image';
|
|
10
|
+
|
|
11
|
+
const {green, dim} = chalk;
|
|
12
|
+
|
|
13
|
+
const DICE_PICTURES_PATH = 'app/png';
|
|
14
|
+
const DICE_HEIGHT = '30%';
|
|
15
|
+
|
|
16
|
+
const EXIT_KEY = 'q';
|
|
17
|
+
|
|
18
|
+
const texts = {
|
|
19
|
+
message: green([
|
|
20
|
+
'— enter any digit to generate this count of dices',
|
|
21
|
+
'— press any key to repeat previous generating',
|
|
22
|
+
`— press "CTRL+C" or enter "${EXIT_KEY}" to exit`,
|
|
23
|
+
].join('\n')),
|
|
24
|
+
delimiter: dim('——————————————\n'),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const imgs = await globby(DICE_PICTURES_PATH);
|
|
28
|
+
|
|
29
|
+
emitKeypressEvents(process.stdin);
|
|
30
|
+
|
|
31
|
+
if (process.stdin.isTTY) {
|
|
32
|
+
process.stdin.setRawMode(true);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
log(texts.message);
|
|
36
|
+
|
|
37
|
+
let count = 1;
|
|
38
|
+
|
|
39
|
+
process.stdin.on('keypress', async (str, key) => {
|
|
40
|
+
if (
|
|
41
|
+
(key.ctrl === true && key.name === 'c')
|
|
42
|
+
|| str === EXIT_KEY
|
|
43
|
+
) {
|
|
44
|
+
process.exit();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const inputNum = Number(str);
|
|
48
|
+
|
|
49
|
+
if (inputNum) {
|
|
50
|
+
count = inputNum;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
log(texts.delimiter);
|
|
54
|
+
|
|
55
|
+
for (let i = 0; i < count; i++) {
|
|
56
|
+
const img = await image.file(_.sample(imgs), {height: DICE_HEIGHT});
|
|
57
|
+
log(img);
|
|
58
|
+
}
|
|
59
|
+
});
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default} from '@k03mad/eslint-config';
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@k03mad/dice",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Dice",
|
|
5
|
+
"maintainers": [
|
|
6
|
+
"Kirill Molchanov <k03.mad@gmail.com"
|
|
7
|
+
],
|
|
8
|
+
"bin": {
|
|
9
|
+
"dice": "app/run.js"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/k03mad/dice.git"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@k03mad/simple-log": "2.3.0",
|
|
22
|
+
"chalk": "5.3.0",
|
|
23
|
+
"globby": "14.0.2",
|
|
24
|
+
"lodash": "4.17.21",
|
|
25
|
+
"terminal-image": "3.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@k03mad/eslint-config": "23.0.0",
|
|
29
|
+
"eslint": "8.57.0",
|
|
30
|
+
"husky": "9.1.4"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"lint": "npm run lint:eslint",
|
|
34
|
+
"lint:eslint": "eslint ./ --cache",
|
|
35
|
+
"clean": "rm -rf ./node_modules .eslintcache || true",
|
|
36
|
+
"setup": "npm run clean && npm run setup:pnpm",
|
|
37
|
+
"setup:pnpm": "npm i pnpm -g && pnpm i",
|
|
38
|
+
"prepare": "husky || true"
|
|
39
|
+
}
|
|
40
|
+
}
|