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" %*

commands/hello.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {Command, flags} from '@oclif/command'
2+
3+
export default class Hello extends Command {
4+
static description = 'describe the command here'
5+
6+
static examples = [
7+
`$ fluent-vue-cli hello
8+
hello world from ./src/hello.ts!
9+
`,
10+
]
11+
12+
static flags = {
13+
help: flags.help({char: 'h'}),
14+
// flag with a value (-n, --name=VALUE)
15+
name: flags.string({char: 'n', description: 'name to print'}),
16+
// flag with no value (-f, --force)
17+
force: flags.boolean({char: 'f'}),
18+
}
19+
20+
static args = [{name: 'file'}]
21+
22+
async run() {
23+
const {args, flags} = this.parse(Hello)
24+
25+
const name = flags.name ?? 'world'
26+
this.log(`hello ${name} from ./src/commands/hello.ts`)
27+
if (args.file && flags.force) {
28+
this.log(`you input --force and --file: ${args.file}`)
29+
}
30+
}
31+
}

jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
globals: {},
4+
coverageDirectory: 'coverage',
5+
collectCoverageFrom: ['src/**/*.ts', 'commands/**/*.ts'],
6+
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
7+
rootDir: __dirname,
8+
testMatch: ['<rootDir>/__tests__/**/*spec.[jt]s?(x)']
9+
}

package.json

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,70 @@
11
{
22
"name": "fluent-vue-cli",
3-
"version": "3.0.0-beta.19",
43
"description": "fluent-vue CLI to manage translation resources",
5-
"keywords": [
6-
"localization",
7-
"internationalization",
8-
"vue",
9-
"Fluent",
10-
"ftl",
11-
"CLI",
12-
"fluent-vue"
13-
],
14-
"sideEffects": false,
15-
"main": "dist/fluent-vue-cli.cjs.js",
16-
"module": "dist/fluent-vue-cli.esm.js",
17-
"types": "dist/fluent-vue-cli.d.ts",
18-
"exports": {
19-
"import": "./dist/fluent-vue-cli.esm.js",
20-
"require": "./dist/fluent-vue-cli.cjs.js"
4+
"version": "0.0.0",
5+
"author": "Ivan Demchuk @Demivan",
6+
"bin": {
7+
"fluent-vue-cli": "./bin/run"
8+
},
9+
"bugs": "https://github.com/Demivan/fluent-vue-cli/issues",
10+
"dependencies": {
11+
"@oclif/command": "^1",
12+
"@oclif/config": "^1",
13+
"@oclif/plugin-help": "^3",
14+
"tslib": "^1"
2115
},
2216
"files": [
23-
"dist",
24-
"README.md"
17+
"/bin",
18+
"/lib",
19+
"/npm-shrinkwrap.json",
20+
"/oclif.manifest.json"
21+
],
22+
"homepage": "https://github.com/Demivan/fluent-vue-cli",
23+
"keywords": [
24+
"oclif"
2525
],
26-
"author": "Ivan Demchuk <ivan.demchuk@gmail.com>",
27-
"repository": {
28-
"type": "git",
29-
"url": "https://github.com/Demivan/fluent-vue"
30-
},
31-
"homepage": "https://fluent-vue.demivan.me/cli",
3226
"license": "MIT",
33-
"dependencies": {
27+
"main": "lib/index.js",
28+
"oclif": {
29+
"commands": "./lib/commands",
30+
"bin": "fluent-vue-cli",
31+
"plugins": [
32+
"@oclif/plugin-help"
33+
]
34+
},
35+
"repository": "Demivan/fluent-vue-cli",
36+
"scripts": {
37+
"postpack": "rm -f oclif.manifest.json",
38+
"posttest": "eslint . --ext .ts --config .eslintrc",
39+
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
40+
"test": "jest --runInBand",
41+
"version": "oclif-dev readme && git add README.md"
42+
},
43+
"types": "lib/index.d.ts",
44+
"devDependencies": {
3445
"@fluent/syntax": "^0.17.0",
3546
"@vue/compiler-dom": "^3.2.6",
36-
"@vue/compiler-sfc": "^3.2.6"
47+
"@vue/compiler-sfc": "^3.2.6",
48+
"@oclif/dev-cli": "^1",
49+
"@oclif/test": "^1",
50+
"@types/jest": "^27.0.1",
51+
"@types/node": "^10.17.60",
52+
"@typescript-eslint/eslint-plugin": "^4.30.0",
53+
"@typescript-eslint/parser": "^4.30.0",
54+
"eslint": "^5.13",
55+
"eslint-config-oclif": "^3.1",
56+
"eslint-config-oclif-typescript": "^0.1",
57+
"eslint-config-standard-with-typescript": "^21.0.1",
58+
"eslint-plugin-import": "^2.24.2",
59+
"eslint-plugin-node": "^11.1.0",
60+
"eslint-plugin-promise": "^5.1.0",
61+
"globby": "^10",
62+
"jest": "^27.1.0",
63+
"ts-jest": "^27.0.5",
64+
"ts-node": "^8",
65+
"typescript": "^3.3"
66+
},
67+
"engines": {
68+
"node": ">=8.0.0"
3769
}
3870
}

0 commit comments

Comments
 (0)