yukichant 2.2.1 → 3.0.2

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.
@@ -0,0 +1,26 @@
1
+ name: Node CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ build:
10
+ name: build
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ node-version: [ 12.x, 14.x, 16.x ]
16
+
17
+ steps:
18
+ - run: node -v
19
+ - uses: actions/checkout@v2
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v2
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ - run: node -v
25
+ - run: npm ci
26
+ - run: npm test
@@ -0,0 +1,36 @@
1
+ name: npm-publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ publish:
10
+ if: startsWith(github.ref, 'refs/tags/v')
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v2
15
+
16
+ - name: Use Node.js And Setup .npmrc
17
+ uses: actions/setup-node@v2
18
+ with:
19
+ node-version: '12.x'
20
+ registry-url: 'https://registry.npmjs.org'
21
+ always-auth : true
22
+ env :
23
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
24
+
25
+ - name: Can Publish
26
+ run : npx can-npm-publish --verbose
27
+ env :
28
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29
+
30
+ - name: Install
31
+ run : npm install
32
+
33
+ - name: Publish
34
+ run : npm publish --access=public
35
+ env :
36
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # yukichant
2
2
 
3
- [![Build Status](https://travis-ci.org/amanoese/yukichant.svg?branch=master)](https://travis-ci.org/amanoese/yukichant)
3
+ [![Actions Status](https://github.com/amanoese/yukichant/workflows/Node%20CI/badge.svg)](https://github.com/amanoese/yukichant/actions)
4
4
  [![npm version](http://img.shields.io/npm/v/yukichant.svg)](https://npmjs.org/package/yukichant)
5
5
 
6
6
  yukichantは、テキストデータを詠唱呪文に変換するコマンドです。
@@ -129,8 +129,7 @@ module.exports = {
129
129
  // snapshotSerializers: [],
130
130
 
131
131
  // The test environment that will be used for testing
132
- testEnvironment: "node",
133
-
132
+ testEnvironment: 'jest-environment-node',
134
133
  // Options that will be passed to the testEnvironment
135
134
  // testEnvironmentOptions: {},
136
135
 
@@ -165,6 +164,7 @@ module.exports = {
165
164
 
166
165
  // A map from regular expressions to paths to transformers
167
166
  // transform: null,
167
+ transform: {}
168
168
 
169
169
  // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
170
170
  // transformIgnorePatterns: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yukichant",
3
- "version": "2.2.1",
3
+ "version": "3.0.2",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "amanoese/yukichant",
@@ -12,22 +12,22 @@
12
12
  "scripts": {
13
13
  "dev": "src/cli.js",
14
14
  "json-generate": "raw_data/json_generator",
15
- "test": "jest",
15
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
16
16
  "deploy": "npm version patch && git push origin $(git describe --tags --abbrev=0)"
17
17
  },
18
18
  "devDependencies": {
19
- "jest": "^24.8.0",
20
- "jest-extended": "^0.11.2"
19
+ "jest": "^27.4.7",
20
+ "jest-extended": "^1.2.0"
21
21
  },
22
22
  "dependencies": {
23
- "caporal": "^1.3.0",
24
- "core-js": "^3.2.0",
25
- "get-stdin": "^7.0.0",
26
- "util": "^0.12.1"
23
+ "commander": "^8.3.0",
24
+ "get-stdin": "^9.0.0"
27
25
  },
28
26
  "keywords": [
29
27
  "cli",
30
28
  "terminal",
31
29
  "unicode"
32
- ]
30
+ ],
31
+ "type": "module",
32
+ "node": ">=12.22.8"
33
33
  }
package/src/cli.js CHANGED
@@ -1,17 +1,22 @@
1
1
  #!/usr/bin/env node
2
- const prog = require('caporal')
3
- const getStdin = require('get-stdin')
4
- const chant = require('./index.js')
2
+ import getStdin from 'get-stdin'
3
+ import chant from './index.js'
4
+ import fs from 'fs'
5
+ import path from 'path'
6
+ const dirname = path.dirname(new URL(import.meta.url).pathname)
7
+ const { version } = JSON.parse(fs.readFileSync(`${dirname}/../package.json`));
5
8
 
6
- prog
9
+ import { Command } from 'commander/esm.mjs';
10
+ const program = new Command();
11
+
12
+ program
7
13
  .name('yukichant')
8
14
  .description('yukichant is convert text to magic spell.')
9
- .bin('chant')
10
- .version(require('../package.json').version)
11
- .argument('[text]','input text',null,'')
15
+ .version(version)
16
+ .argument('[text]','input text','')
12
17
  .option('-d','decode flag')
13
- .action(async (args,option)=>{
14
- let inputText = args.text || (await getStdin())
18
+ .action(async (text,option)=>{
19
+ let inputText = text || (await getStdin())
15
20
  if (inputText == '') {
16
21
  console.log(chant.generate())
17
22
  } else if (option.d){
@@ -20,5 +25,4 @@ prog
20
25
  console.log(chant.encode(inputText))
21
26
  }
22
27
  })
23
-
24
- prog.parse(process.argv)
28
+ .parse(process.argv);
package/src/index.js CHANGED
@@ -1,9 +1,9 @@
1
- require('core-js')
2
- const util = require('util')
3
- const simpleEnigma = require('./machine-encrypt')
4
-
5
- const meisi = require('../data/meisi.json')
6
- const dousi = require('../data/dousi.json')
1
+ import simpleEnigma from './machine-encrypt.js'
2
+ import fs from 'fs'
3
+ import path from 'path'
4
+ const dirname = path.dirname(new URL(import.meta.url).pathname)
5
+ const meisi = JSON.parse(fs.readFileSync(`${dirname}/../data/meisi.json`, 'utf8'));
6
+ const dousi = JSON.parse(fs.readFileSync(`${dirname}/../data/dousi.json`, 'utf8'));
7
7
 
8
8
 
9
9
  let default_encoder = (uint8text,{ meisi, dousi }) => {
@@ -83,7 +83,7 @@ let default_decoder = (encodeText,{ meisi, dousi }) => {
83
83
  return Uint8Array.from(textCode)
84
84
  }
85
85
 
86
- module.exports = {
86
+ export default {
87
87
  data : {
88
88
  meisi,
89
89
  dousi
@@ -94,11 +94,11 @@ module.exports = {
94
94
  return generater(uint8text,data)
95
95
  },
96
96
  encode( text, data = this.data, encoder = default_encoder ){
97
- let uint8text = (TextEncoder ? new TextEncoder() : new util.TextEncoder()).encode(text)
97
+ let uint8text = (new TextEncoder()).encode(text)
98
98
  return encoder(uint8text,data)
99
99
  },
100
100
  decode( text, data = this.data, decoder = default_decoder ){
101
101
  let uint8text = decoder(text,data)
102
- return (TextDecoder ? new TextDecoder() : new util.TextDecoder()).decode(uint8text)
102
+ return (new TextDecoder()).decode(uint8text)
103
103
  }
104
104
  }
@@ -14,11 +14,12 @@ let encrypt = (uint8array,roter,refrector) => {
14
14
  return [fase_3, ...(uint8array.length <= 1 ? [] : encrypt(uint8array.slice(1),nextRotor,refrector)) ]
15
15
  }
16
16
 
17
- module.exports = {
17
+ export default {
18
18
  default_roter,
19
19
  refrector,
20
20
  encrypt,
21
- uint8ArrayEncrypt(uint8array){
22
- return this.encrypt(uint8array,this.default_roter,this.refrector)
21
+ uint8ArrayEncrypt(uint8array) {
22
+ return this.encrypt(uint8array,this.default_roter,this.refrector);
23
23
  }
24
24
  }
25
+
@@ -0,0 +1,13 @@
1
+ const message = `Usage: yukichant [options] [text]
2
+
3
+ yukichant is convert text to magic spell.
4
+
5
+ Arguments:
6
+ text input text (default: "")
7
+
8
+ Options:
9
+ -V, --version output the version number
10
+ -d decode flag
11
+ -h, --help display help for command
12
+ `
13
+ export default message