Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Commit 52c1cdc

Browse files
committed
Initialize oclif
1 parent 80005ec commit 52c1cdc

17 files changed

+8097
-126
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.md]
11+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/lib

.eslintrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": ["@typescript-eslint"],
3+
"extends": [
4+
"oclif",
5+
"oclif-typescript",
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/eslint-recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"standard-with-typescript"
10+
]
11+
}

.gitignore

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1+
*-debug.log
2+
*-error.log
3+
/.nyc_output
4+
/dist
5+
/lib
6+
/package-lock.json
7+
/tmp
18
node_modules
2-
coverage
3-
.nyc_output
4-
.DS_Store
5-
*.log
6-
.vscode
7-
.idea
8-
dist
9-
compiled
10-
.awcache
11-
.rpt2_cache
12-
.cache/
13-
temp
14-
.env
15-
.parcel-cache/
16-
.temp
17-
.cache

README.md

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,70 @@
11
fluent-vue-cli
2-
=================
2+
==============
33

4-
fluent-vue tool for managing locale messages
4+
fluent-vue CLI to manage translation resources
55

6-
WIP
6+
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7+
[![Version](https://img.shields.io/npm/v/fluent-vue-cli.svg)](https://npmjs.org/package/fluent-vue-cli)
8+
[![Downloads/week](https://img.shields.io/npm/dw/fluent-vue-cli.svg)](https://npmjs.org/package/fluent-vue-cli)
9+
[![License](https://img.shields.io/npm/l/fluent-vue-cli.svg)](https://github.com/Demivan/fluent-vue-cli/blob/master/package.json)
10+
11+
<!-- toc -->
12+
* [Usage](#usage)
13+
* [Commands](#commands)
14+
<!-- tocstop -->
15+
# Usage
16+
<!-- usage -->
17+
```sh-session
18+
$ npm install -g fluent-vue-cli
19+
$ fluent-vue-cli COMMAND
20+
running command...
21+
$ fluent-vue-cli (-v|--version|version)
22+
fluent-vue-cli/0.0.0 linux-x64 node-v16.8.0
23+
$ fluent-vue-cli --help [COMMAND]
24+
USAGE
25+
$ fluent-vue-cli COMMAND
26+
...
27+
```
28+
<!-- usagestop -->
29+
# Commands
30+
<!-- commands -->
31+
* [`fluent-vue-cli hello [FILE]`](#fluent-vue-cli-hello-file)
32+
* [`fluent-vue-cli help [COMMAND]`](#fluent-vue-cli-help-command)
33+
34+
## `fluent-vue-cli hello [FILE]`
35+
36+
describe the command here
37+
38+
```
39+
USAGE
40+
$ fluent-vue-cli hello [FILE]
41+
42+
OPTIONS
43+
-f, --force
44+
-h, --help show CLI help
45+
-n, --name=name name to print
46+
47+
EXAMPLE
48+
$ fluent-vue-cli hello
49+
hello world from ./src/hello.ts!
50+
```
51+
52+
_See code: [src/commands/hello.ts](https://github.com/Demivan/fluent-vue-cli/blob/v0.0.0/src/commands/hello.ts)_
53+
54+
## `fluent-vue-cli help [COMMAND]`
55+
56+
display help for fluent-vue-cli
57+
58+
```
59+
USAGE
60+
$ fluent-vue-cli help [COMMAND]
61+
62+
ARGUMENTS
63+
COMMAND command to show help for
64+
65+
OPTIONS
66+
--all see all commands in CLI
67+
```
68+
69+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.3/src/commands/help.ts)_
70+
<!-- commandsstop -->

__tests__/commands/hello.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import HelloCommand from '../../commands/hello'
2+
3+
describe('hello', () => {
4+
let result: string | undefined;
5+
6+
beforeEach(() => {
7+
result = undefined;
8+
jest
9+
.spyOn(process.stdout, 'write')
10+
.mockImplementation((val: string): boolean => {
11+
result = val
12+
return true
13+
});
14+
});
15+
16+
afterEach(() => jest.restoreAllMocks());
17+
18+
it('runs hello', async () => {
19+
await HelloCommand.run([])
20+
21+
expect(result).toContain('hello world')
22+
})
23+
24+
it('runs hello --name jeff', async () => {
25+
await HelloCommand.run(['hello', '--name', 'jeff'])
26+
27+
expect(result).toContain('hello jeff')
28+
})
29+
})

__tests__/getVueMessages.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { readFile } from 'fs/promises'
1+
import { promises as fs } from 'fs'
22
import { resolve } from 'path'
33

44
import { getVueMessages, MessagesWithLocale } from '../src'
55

66
describe('getVueMessages', () => {
77
it('extracts locale messages from SFC', async () => {
88
// Arrange
9-
const source = await readFile(resolve(__dirname, 'fixtures', './Simple.vue'))
9+
const source = await fs.readFile(resolve(__dirname, 'fixtures', './Simple.vue'))
1010

1111
// Act
1212
const messages = getVueMessages(source.toString())
@@ -30,7 +30,7 @@ Array [
3030

3131
it('extracts multiple SFC blocks', async () => {
3232
// Arrange
33-
const source = await readFile(resolve(__dirname, 'fixtures', './Multiple.vue'))
33+
const source = await fs.readFile(resolve(__dirname, 'fixtures', './Multiple.vue'))
3434

3535
// Act
3636
const messages = getVueMessages(source.toString())

__tests__/mergeVue.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { readFile } from 'fs/promises'
1+
import { promises as fs } from 'fs'
22
import { resolve } from 'path'
33

44
import { mergeVue } from '../src'
55

66
describe('mergeVue', () => {
77
it('adds new key/values', async () => {
88
// Arrange
9-
const source = await readFile(resolve(__dirname, 'fixtures', './Simple.vue'))
9+
const source = await fs.readFile(resolve(__dirname, 'fixtures', './Simple.vue'))
1010
const newTranslation = { hello: 'Hello' }
1111

1212
// Act
@@ -38,7 +38,7 @@ hello = Hello
3838

3939
it('adds new block for new locale', async () => {
4040
// Arrange
41-
const source = await readFile(resolve(__dirname, 'fixtures', './Simple.vue'))
41+
const source = await fs.readFile(resolve(__dirname, 'fixtures', './Simple.vue'))
4242
const newTranslation = { hello: 'Hello' }
4343

4444
// Act

bin/run

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
3+
require('@oclif/command').run()
4+
.then(require('@oclif/command/flush'))
5+
.catch(require('@oclif/errors/handle'))

bin/run.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\run" %*

0 commit comments

Comments
 (0)