feat: add oclif template
This commit is contained in:
parent
01ce4f0363
commit
09a53e7d05
1
packages/cli/.eslintignore
Normal file
1
packages/cli/.eslintignore
Normal file
@ -0,0 +1 @@
|
||||
/dist
|
3
packages/cli/.eslintrc.json
Normal file
3
packages/cli/.eslintrc.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": ["oclif", "oclif-typescript", "prettier"]
|
||||
}
|
56
packages/cli/.github/workflows/onPushToMain.yml
vendored
Normal file
56
packages/cli/.github/workflows/onPushToMain.yml
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
# test
|
||||
name: version, tag and github release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- name: Check if version already exists
|
||||
id: version-check
|
||||
run: |
|
||||
package_version=$(node -p "require('./package.json').version")
|
||||
exists=$(gh api repos/${{ github.repository }}/releases/tags/v$package_version >/dev/null 2>&1 && echo "true" || echo "")
|
||||
|
||||
if [ -n "$exists" ];
|
||||
then
|
||||
echo "Version v$package_version already exists"
|
||||
echo "::warning file=package.json,line=1::Version v$package_version already exists - no release will be created. If you want to create a new release, please update the version in package.json and push again."
|
||||
echo "skipped=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Version v$package_version does not exist. Creating release..."
|
||||
echo "skipped=false" >> $GITHUB_OUTPUT
|
||||
echo "tag=v$package_version" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
- name: Setup git
|
||||
if: ${{ steps.version-check.outputs.skipped == 'false' }}
|
||||
run: |
|
||||
git config --global user.email ${{ secrets.GH_EMAIL }}
|
||||
git config --global user.name ${{ secrets.GH_USERNAME }}
|
||||
- name: Generate oclif README
|
||||
if: ${{ steps.version-check.outputs.skipped == 'false' }}
|
||||
id: oclif-readme
|
||||
run: |
|
||||
yarn
|
||||
yarn oclif readme
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
git add .
|
||||
git commit -am "chore: update README.md"
|
||||
git push -u origin ${{ github.ref_name }}
|
||||
fi
|
||||
- name: Create Github Release
|
||||
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
|
||||
if: ${{ steps.version-check.outputs.skipped == 'false' }}
|
||||
with:
|
||||
name: ${{ steps.version-check.outputs.tag }}
|
||||
tag: ${{ steps.version-check.outputs.tag }}
|
||||
commit: ${{ github.ref_name }}
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
skipIfReleaseExists: true
|
18
packages/cli/.github/workflows/onRelease.yml
vendored
Normal file
18
packages/cli/.github/workflows/onRelease.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: publish
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: latest
|
||||
- run: yarn
|
||||
- uses: JS-DevTools/npm-publish@19c28f1ef146469e409470805ea4279d47c3d35c
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
23
packages/cli/.github/workflows/test.yml
vendored
Normal file
23
packages/cli/.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
name: tests
|
||||
on:
|
||||
push:
|
||||
branches-ignore: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['ubuntu-latest', 'windows-latest']
|
||||
node_version: [lts/-1, lts/*, latest]
|
||||
fail-fast: false
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node_version }}
|
||||
cache: yarn
|
||||
- run: yarn
|
||||
- run: yarn build
|
||||
- run: yarn test
|
21
packages/cli/.gitignore
vendored
Normal file
21
packages/cli/.gitignore
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
*-debug.log
|
||||
*-error.log
|
||||
**/.DS_Store
|
||||
/.idea
|
||||
/dist
|
||||
/tmp
|
||||
/node_modules
|
||||
oclif.manifest.json
|
||||
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
|
||||
|
15
packages/cli/.mocharc.json
Normal file
15
packages/cli/.mocharc.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"require": [
|
||||
"ts-node/register"
|
||||
],
|
||||
"watch-extensions": [
|
||||
"ts"
|
||||
],
|
||||
"recursive": true,
|
||||
"reporter": "spec",
|
||||
"timeout": 60000,
|
||||
"node-option": [
|
||||
"loader=ts-node/esm",
|
||||
"experimental-specifier-resolution=node"
|
||||
]
|
||||
}
|
1
packages/cli/.prettierrc.json
Normal file
1
packages/cli/.prettierrc.json
Normal file
@ -0,0 +1 @@
|
||||
"@oclif/prettier-config"
|
20
packages/cli/.vscode/launch.json
vendored
Normal file
20
packages/cli/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"name": "Attach",
|
||||
"port": 9229,
|
||||
"skipFiles": ["<node_internals>/**"]
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Execute Command",
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"program": "${workspaceFolder}/bin/dev",
|
||||
"args": ["hello", "world"]
|
||||
}
|
||||
]
|
||||
}
|
396
packages/cli/README.md
Normal file
396
packages/cli/README.md
Normal file
@ -0,0 +1,396 @@
|
||||
@psw-ui/cli
|
||||
=================
|
||||
|
||||
CLI for PSW/UI
|
||||
|
||||
|
||||
[](https://oclif.io)
|
||||
[](https://npmjs.org/package/@psw-ui/cli)
|
||||
[](https://npmjs.org/package/@psw-ui/cli)
|
||||
|
||||
|
||||
<!-- toc -->
|
||||
* [Usage](#usage)
|
||||
* [Commands](#commands)
|
||||
<!-- tocstop -->
|
||||
# Usage
|
||||
<!-- usage -->
|
||||
```sh-session
|
||||
$ npm install -g mycli123
|
||||
$ mycli123 COMMAND
|
||||
running command...
|
||||
$ mycli123 (--version)
|
||||
mycli123/0.0.0 darwin-arm64 node-v20.12.2
|
||||
$ mycli123 --help [COMMAND]
|
||||
USAGE
|
||||
$ mycli123 COMMAND
|
||||
...
|
||||
```
|
||||
<!-- usagestop -->
|
||||
# Commands
|
||||
<!-- commands -->
|
||||
* [`mycli123 hello PERSON`](#mycli123-hello-person)
|
||||
* [`mycli123 hello world`](#mycli123-hello-world)
|
||||
* [`mycli123 help [COMMAND]`](#mycli123-help-command)
|
||||
* [`mycli123 plugins`](#mycli123-plugins)
|
||||
* [`mycli123 plugins add PLUGIN`](#mycli123-plugins-add-plugin)
|
||||
* [`mycli123 plugins:inspect PLUGIN...`](#mycli123-pluginsinspect-plugin)
|
||||
* [`mycli123 plugins install PLUGIN`](#mycli123-plugins-install-plugin)
|
||||
* [`mycli123 plugins link PATH`](#mycli123-plugins-link-path)
|
||||
* [`mycli123 plugins remove [PLUGIN]`](#mycli123-plugins-remove-plugin)
|
||||
* [`mycli123 plugins reset`](#mycli123-plugins-reset)
|
||||
* [`mycli123 plugins uninstall [PLUGIN]`](#mycli123-plugins-uninstall-plugin)
|
||||
* [`mycli123 plugins unlink [PLUGIN]`](#mycli123-plugins-unlink-plugin)
|
||||
* [`mycli123 plugins update`](#mycli123-plugins-update)
|
||||
|
||||
## `mycli123 hello PERSON`
|
||||
|
||||
Say hello
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 hello PERSON -f <value>
|
||||
|
||||
ARGUMENTS
|
||||
PERSON Person to say hello to
|
||||
|
||||
FLAGS
|
||||
-f, --from=<value> (required) Who is saying hello
|
||||
|
||||
DESCRIPTION
|
||||
Say hello
|
||||
|
||||
EXAMPLES
|
||||
$ mycli123 hello friend --from oclif
|
||||
hello friend from oclif! (./src/commands/hello/index.ts)
|
||||
```
|
||||
|
||||
_See code: [src/commands/hello/index.ts](https://github.com/mdonnalley/mycli123/blob/v0.0.0/src/commands/hello/index.ts)_
|
||||
|
||||
## `mycli123 hello world`
|
||||
|
||||
Say hello world
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 hello world
|
||||
|
||||
DESCRIPTION
|
||||
Say hello world
|
||||
|
||||
EXAMPLES
|
||||
$ mycli123 hello world
|
||||
hello world! (./src/commands/hello/world.ts)
|
||||
```
|
||||
|
||||
_See code: [src/commands/hello/world.ts](https://github.com/mdonnalley/mycli123/blob/v0.0.0/src/commands/hello/world.ts)_
|
||||
|
||||
## `mycli123 help [COMMAND]`
|
||||
|
||||
Display help for mycli123.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 help [COMMAND...] [-n]
|
||||
|
||||
ARGUMENTS
|
||||
COMMAND... Command to show help for.
|
||||
|
||||
FLAGS
|
||||
-n, --nested-commands Include all nested commands in the output.
|
||||
|
||||
DESCRIPTION
|
||||
Display help for mycli123.
|
||||
```
|
||||
|
||||
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.21/src/commands/help.ts)_
|
||||
|
||||
## `mycli123 plugins`
|
||||
|
||||
List installed plugins.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 plugins [--json] [--core]
|
||||
|
||||
FLAGS
|
||||
--core Show core plugins.
|
||||
|
||||
GLOBAL FLAGS
|
||||
--json Format output as json.
|
||||
|
||||
DESCRIPTION
|
||||
List installed plugins.
|
||||
|
||||
EXAMPLES
|
||||
$ mycli123 plugins
|
||||
```
|
||||
|
||||
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.16/src/commands/plugins/index.ts)_
|
||||
|
||||
## `mycli123 plugins add PLUGIN`
|
||||
|
||||
Installs a plugin into mycli123.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
|
||||
|
||||
ARGUMENTS
|
||||
PLUGIN... Plugin to install.
|
||||
|
||||
FLAGS
|
||||
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
||||
-h, --help Show CLI help.
|
||||
-s, --silent Silences npm output.
|
||||
-v, --verbose Show verbose npm output.
|
||||
|
||||
GLOBAL FLAGS
|
||||
--json Format output as json.
|
||||
|
||||
DESCRIPTION
|
||||
Installs a plugin into mycli123.
|
||||
|
||||
Uses bundled npm executable to install plugins into /Users/mdonnalley/.local/share/mycli123
|
||||
|
||||
Installation of a user-installed plugin will override a core plugin.
|
||||
|
||||
Use the MYCLI123_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
||||
Use the MYCLI123_NPM_REGISTRY environment variable to set the npm registry.
|
||||
|
||||
ALIASES
|
||||
$ mycli123 plugins add
|
||||
|
||||
EXAMPLES
|
||||
Install a plugin from npm registry.
|
||||
|
||||
$ mycli123 plugins add myplugin
|
||||
|
||||
Install a plugin from a github url.
|
||||
|
||||
$ mycli123 plugins add https://github.com/someuser/someplugin
|
||||
|
||||
Install a plugin from a github slug.
|
||||
|
||||
$ mycli123 plugins add someuser/someplugin
|
||||
```
|
||||
|
||||
## `mycli123 plugins:inspect PLUGIN...`
|
||||
|
||||
Displays installation properties of a plugin.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 plugins inspect PLUGIN...
|
||||
|
||||
ARGUMENTS
|
||||
PLUGIN... [default: .] Plugin to inspect.
|
||||
|
||||
FLAGS
|
||||
-h, --help Show CLI help.
|
||||
-v, --verbose
|
||||
|
||||
GLOBAL FLAGS
|
||||
--json Format output as json.
|
||||
|
||||
DESCRIPTION
|
||||
Displays installation properties of a plugin.
|
||||
|
||||
EXAMPLES
|
||||
$ mycli123 plugins inspect myplugin
|
||||
```
|
||||
|
||||
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.16/src/commands/plugins/inspect.ts)_
|
||||
|
||||
## `mycli123 plugins install PLUGIN`
|
||||
|
||||
Installs a plugin into mycli123.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
|
||||
|
||||
ARGUMENTS
|
||||
PLUGIN... Plugin to install.
|
||||
|
||||
FLAGS
|
||||
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
||||
-h, --help Show CLI help.
|
||||
-s, --silent Silences npm output.
|
||||
-v, --verbose Show verbose npm output.
|
||||
|
||||
GLOBAL FLAGS
|
||||
--json Format output as json.
|
||||
|
||||
DESCRIPTION
|
||||
Installs a plugin into mycli123.
|
||||
|
||||
Uses bundled npm executable to install plugins into /Users/mdonnalley/.local/share/mycli123
|
||||
|
||||
Installation of a user-installed plugin will override a core plugin.
|
||||
|
||||
Use the MYCLI123_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
||||
Use the MYCLI123_NPM_REGISTRY environment variable to set the npm registry.
|
||||
|
||||
ALIASES
|
||||
$ mycli123 plugins add
|
||||
|
||||
EXAMPLES
|
||||
Install a plugin from npm registry.
|
||||
|
||||
$ mycli123 plugins install myplugin
|
||||
|
||||
Install a plugin from a github url.
|
||||
|
||||
$ mycli123 plugins install https://github.com/someuser/someplugin
|
||||
|
||||
Install a plugin from a github slug.
|
||||
|
||||
$ mycli123 plugins install someuser/someplugin
|
||||
```
|
||||
|
||||
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.16/src/commands/plugins/install.ts)_
|
||||
|
||||
## `mycli123 plugins link PATH`
|
||||
|
||||
Links a plugin into the CLI for development.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 plugins link PATH [-h] [--install] [-v]
|
||||
|
||||
ARGUMENTS
|
||||
PATH [default: .] path to plugin
|
||||
|
||||
FLAGS
|
||||
-h, --help Show CLI help.
|
||||
-v, --verbose
|
||||
--[no-]install Install dependencies after linking the plugin.
|
||||
|
||||
DESCRIPTION
|
||||
Links a plugin into the CLI for development.
|
||||
Installation of a linked plugin will override a user-installed or core plugin.
|
||||
|
||||
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
||||
command will override the user-installed or core plugin implementation. This is useful for development work.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
$ mycli123 plugins link myplugin
|
||||
```
|
||||
|
||||
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.16/src/commands/plugins/link.ts)_
|
||||
|
||||
## `mycli123 plugins remove [PLUGIN]`
|
||||
|
||||
Removes a plugin from the CLI.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 plugins remove [PLUGIN...] [-h] [-v]
|
||||
|
||||
ARGUMENTS
|
||||
PLUGIN... plugin to uninstall
|
||||
|
||||
FLAGS
|
||||
-h, --help Show CLI help.
|
||||
-v, --verbose
|
||||
|
||||
DESCRIPTION
|
||||
Removes a plugin from the CLI.
|
||||
|
||||
ALIASES
|
||||
$ mycli123 plugins unlink
|
||||
$ mycli123 plugins remove
|
||||
|
||||
EXAMPLES
|
||||
$ mycli123 plugins remove myplugin
|
||||
```
|
||||
|
||||
## `mycli123 plugins reset`
|
||||
|
||||
Remove all user-installed and linked plugins.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 plugins reset [--hard] [--reinstall]
|
||||
|
||||
FLAGS
|
||||
--hard Delete node_modules and package manager related files in addition to uninstalling plugins.
|
||||
--reinstall Reinstall all plugins after uninstalling.
|
||||
```
|
||||
|
||||
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.16/src/commands/plugins/reset.ts)_
|
||||
|
||||
## `mycli123 plugins uninstall [PLUGIN]`
|
||||
|
||||
Removes a plugin from the CLI.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 plugins uninstall [PLUGIN...] [-h] [-v]
|
||||
|
||||
ARGUMENTS
|
||||
PLUGIN... plugin to uninstall
|
||||
|
||||
FLAGS
|
||||
-h, --help Show CLI help.
|
||||
-v, --verbose
|
||||
|
||||
DESCRIPTION
|
||||
Removes a plugin from the CLI.
|
||||
|
||||
ALIASES
|
||||
$ mycli123 plugins unlink
|
||||
$ mycli123 plugins remove
|
||||
|
||||
EXAMPLES
|
||||
$ mycli123 plugins uninstall myplugin
|
||||
```
|
||||
|
||||
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.16/src/commands/plugins/uninstall.ts)_
|
||||
|
||||
## `mycli123 plugins unlink [PLUGIN]`
|
||||
|
||||
Removes a plugin from the CLI.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 plugins unlink [PLUGIN...] [-h] [-v]
|
||||
|
||||
ARGUMENTS
|
||||
PLUGIN... plugin to uninstall
|
||||
|
||||
FLAGS
|
||||
-h, --help Show CLI help.
|
||||
-v, --verbose
|
||||
|
||||
DESCRIPTION
|
||||
Removes a plugin from the CLI.
|
||||
|
||||
ALIASES
|
||||
$ mycli123 plugins unlink
|
||||
$ mycli123 plugins remove
|
||||
|
||||
EXAMPLES
|
||||
$ mycli123 plugins unlink myplugin
|
||||
```
|
||||
|
||||
## `mycli123 plugins update`
|
||||
|
||||
Update installed plugins.
|
||||
|
||||
```
|
||||
USAGE
|
||||
$ mycli123 plugins update [-h] [-v]
|
||||
|
||||
FLAGS
|
||||
-h, --help Show CLI help.
|
||||
-v, --verbose
|
||||
|
||||
DESCRIPTION
|
||||
Update installed plugins.
|
||||
```
|
||||
|
||||
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.16/src/commands/plugins/update.ts)_
|
||||
<!-- commandsstop -->
|
3
packages/cli/bin/dev.cmd
Normal file
3
packages/cli/bin/dev.cmd
Normal file
@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
|
||||
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
|
6
packages/cli/bin/dev.js
Executable file
6
packages/cli/bin/dev.js
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
|
||||
|
||||
// eslint-disable-next-line n/shebang
|
||||
import {execute} from '@oclif/core'
|
||||
|
||||
await execute({development: true, dir: import.meta.url})
|
3
packages/cli/bin/run.cmd
Normal file
3
packages/cli/bin/run.cmd
Normal file
@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
|
||||
node "%~dp0\run" %*
|
5
packages/cli/bin/run.js
Executable file
5
packages/cli/bin/run.js
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import {execute} from '@oclif/core'
|
||||
|
||||
await execute({dir: import.meta.url})
|
73
packages/cli/package.json
Normal file
73
packages/cli/package.json
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "@psw-ui/cli",
|
||||
"description": "CLI for PSW/UI",
|
||||
"version": "0.0.0",
|
||||
"author": "p-sw",
|
||||
"bin": {
|
||||
"pswui": "./bin/run.js"
|
||||
},
|
||||
"bugs": "https://github.com/p-sw/ui/issues",
|
||||
"dependencies": {
|
||||
"@oclif/core": "^4",
|
||||
"@oclif/plugin-help": "^6",
|
||||
"@oclif/plugin-plugins": "^5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@oclif/prettier-config": "^0.2.1",
|
||||
"@oclif/test": "^4",
|
||||
"@types/chai": "^4",
|
||||
"@types/mocha": "^10",
|
||||
"@types/node": "^18",
|
||||
"chai": "^4",
|
||||
"eslint": "^8",
|
||||
"eslint-config-oclif": "^5",
|
||||
"eslint-config-oclif-typescript": "^3",
|
||||
"eslint-config-prettier": "^9",
|
||||
"mocha": "^10",
|
||||
"oclif": "^4",
|
||||
"shx": "^0.3.3",
|
||||
"ts-node": "^10",
|
||||
"typescript": "^5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"files": [
|
||||
"/bin",
|
||||
"/dist",
|
||||
"/oclif.manifest.json"
|
||||
],
|
||||
"homepage": "https://github.com/p-sw/ui",
|
||||
"keywords": [
|
||||
"oclif"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
"oclif": {
|
||||
"bin": "pswui",
|
||||
"dirname": "pswui",
|
||||
"commands": "./dist/commands",
|
||||
"plugins": [
|
||||
"@oclif/plugin-help",
|
||||
"@oclif/plugin-plugins"
|
||||
],
|
||||
"topicSeparator": " ",
|
||||
"topics": {
|
||||
"hello": {
|
||||
"description": "Say hello to the world and others"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repository": "p-sw/ui",
|
||||
"scripts": {
|
||||
"build": "shx rm -rf dist && tsc",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"postpack": "shx rm -f oclif.manifest.json",
|
||||
"posttest": "yarn lint",
|
||||
"prepack": "oclif manifest && oclif readme",
|
||||
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
||||
"version": "oclif readme && git add README.md"
|
||||
},
|
||||
"types": "dist/index.d.ts"
|
||||
}
|
25
packages/cli/src/commands/hello/index.ts
Normal file
25
packages/cli/src/commands/hello/index.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import {Args, Command, Flags} from '@oclif/core'
|
||||
|
||||
export default class Hello extends Command {
|
||||
static args = {
|
||||
person: Args.string({description: 'Person to say hello to', required: true}),
|
||||
}
|
||||
|
||||
static description = 'Say hello'
|
||||
|
||||
static examples = [
|
||||
`<%= config.bin %> <%= command.id %> friend --from oclif
|
||||
hello friend from oclif! (./src/commands/hello/index.ts)
|
||||
`,
|
||||
]
|
||||
|
||||
static flags = {
|
||||
from: Flags.string({char: 'f', description: 'Who is saying hello', required: true}),
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
const {args, flags} = await this.parse(Hello)
|
||||
|
||||
this.log(`hello ${args.person} from ${flags.from}! (./src/commands/hello/index.ts)`)
|
||||
}
|
||||
}
|
19
packages/cli/src/commands/hello/world.ts
Normal file
19
packages/cli/src/commands/hello/world.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import {Command} from '@oclif/core'
|
||||
|
||||
export default class World extends Command {
|
||||
static args = {}
|
||||
|
||||
static description = 'Say hello world'
|
||||
|
||||
static examples = [
|
||||
`<%= config.bin %> <%= command.id %>
|
||||
hello world! (./src/commands/hello/world.ts)
|
||||
`,
|
||||
]
|
||||
|
||||
static flags = {}
|
||||
|
||||
async run(): Promise<void> {
|
||||
this.log('hello world! (./src/commands/hello/world.ts)')
|
||||
}
|
||||
}
|
1
packages/cli/src/index.ts
Normal file
1
packages/cli/src/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export {run} from '@oclif/core'
|
9
packages/cli/test/commands/hello/index.test.ts
Normal file
9
packages/cli/test/commands/hello/index.test.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import {runCommand} from '@oclif/test'
|
||||
import {expect} from 'chai'
|
||||
|
||||
describe('hello', () => {
|
||||
it('runs hello', async () => {
|
||||
const {stdout} = await runCommand('hello friend --from oclif')
|
||||
expect(stdout).to.contain('hello friend from oclif!')
|
||||
})
|
||||
})
|
9
packages/cli/test/commands/hello/world.test.ts
Normal file
9
packages/cli/test/commands/hello/world.test.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import {runCommand} from '@oclif/test'
|
||||
import {expect} from 'chai'
|
||||
|
||||
describe('hello world', () => {
|
||||
it('runs hello world cmd', async () => {
|
||||
const {stdout} = await runCommand('hello world')
|
||||
expect(stdout).to.contain('hello world!')
|
||||
})
|
||||
})
|
9
packages/cli/test/tsconfig.json
Normal file
9
packages/cli/test/tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../tsconfig",
|
||||
"compilerOptions": {
|
||||
"noEmit": true
|
||||
},
|
||||
"references": [
|
||||
{"path": ".."}
|
||||
]
|
||||
}
|
16
packages/cli/tsconfig.json
Normal file
16
packages/cli/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"module": "Node16",
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"target": "es2022",
|
||||
"moduleResolution": "node16",
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["./src/**/*"],
|
||||
"ts-node": {
|
||||
"esm": true
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user