This commit is contained in:
2024-11-09 01:35:02 -05:00
parent aec5a9673f
commit 112e4f98b7
24 changed files with 7113 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
/dist
+3
View File
@@ -0,0 +1,3 @@
{
"extends": ["oclif", "oclif-typescript", "prettier"]
}
+21
View 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
View 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
View File
@@ -0,0 +1 @@
"@oclif/prettier-config"
+22
View File
@@ -0,0 +1,22 @@
{
"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>/**"],
"runtimeExecutable": "node",
"runtimeArgs": ["--loader", "ts-node/esm", "--no-warnings=ExperimentalWarning"],
"program": "${workspaceFolder}/bin/dev.js",
"args": ["hello", "world"]
}
]
}
+397 -1
View File
@@ -1 +1,397 @@
# jj jj
=================
jj cli
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/jj.svg)](https://npmjs.org/package/jj)
[![Downloads/week](https://img.shields.io/npm/dw/jj.svg)](https://npmjs.org/package/jj)
<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->
# Usage
<!-- usage -->
```sh-session
$ npm install -g jj
$ jj COMMAND
running command...
$ jj (--version)
jj/0.0.0 darwin-arm64 node-v20.16.0
$ jj --help [COMMAND]
USAGE
$ jj COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`jj hello PERSON`](#jj-hello-person)
* [`jj hello world`](#jj-hello-world)
* [`jj help [COMMAND]`](#jj-help-command)
* [`jj plugins`](#jj-plugins)
* [`jj plugins add PLUGIN`](#jj-plugins-add-plugin)
* [`jj plugins:inspect PLUGIN...`](#jj-pluginsinspect-plugin)
* [`jj plugins install PLUGIN`](#jj-plugins-install-plugin)
* [`jj plugins link PATH`](#jj-plugins-link-path)
* [`jj plugins remove [PLUGIN]`](#jj-plugins-remove-plugin)
* [`jj plugins reset`](#jj-plugins-reset)
* [`jj plugins uninstall [PLUGIN]`](#jj-plugins-uninstall-plugin)
* [`jj plugins unlink [PLUGIN]`](#jj-plugins-unlink-plugin)
* [`jj plugins update`](#jj-plugins-update)
## `jj hello PERSON`
Say hello
```
USAGE
$ jj hello PERSON -f <value>
ARGUMENTS
PERSON Person to say hello to
FLAGS
-f, --from=<value> (required) Who is saying hello
DESCRIPTION
Say hello
EXAMPLES
$ jj hello friend --from oclif
hello friend from oclif! (./src/commands/hello/index.ts)
```
_See code: [src/commands/hello/index.ts](https://github.com/jafarijason/jj/jj/blob/v0.0.0/src/commands/hello/index.ts)_
## `jj hello world`
Say hello world
```
USAGE
$ jj hello world
DESCRIPTION
Say hello world
EXAMPLES
$ jj hello world
hello world! (./src/commands/hello/world.ts)
```
_See code: [src/commands/hello/world.ts](https://github.com/jafarijason/jj/jj/blob/v0.0.0/src/commands/hello/world.ts)_
## `jj help [COMMAND]`
Display help for jj.
```
USAGE
$ jj 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 jj.
```
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.16/src/commands/help.ts)_
## `jj plugins`
List installed plugins.
```
USAGE
$ jj plugins [--json] [--core]
FLAGS
--core Show core plugins.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
List installed plugins.
EXAMPLES
$ jj plugins
```
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/index.ts)_
## `jj plugins add PLUGIN`
Installs a plugin into jj.
```
USAGE
$ jj 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 jj.
Uses npm to install plugins.
Installation of a user-installed plugin will override a core plugin.
Use the JJ_NPM_LOG_LEVEL environment variable to set the npm loglevel.
Use the JJ_NPM_REGISTRY environment variable to set the npm registry.
ALIASES
$ jj plugins add
EXAMPLES
Install a plugin from npm registry.
$ jj plugins add myplugin
Install a plugin from a github url.
$ jj plugins add https://github.com/someuser/someplugin
Install a plugin from a github slug.
$ jj plugins add someuser/someplugin
```
## `jj plugins:inspect PLUGIN...`
Displays installation properties of a plugin.
```
USAGE
$ jj 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
$ jj plugins inspect myplugin
```
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/inspect.ts)_
## `jj plugins install PLUGIN`
Installs a plugin into jj.
```
USAGE
$ jj 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 jj.
Uses npm to install plugins.
Installation of a user-installed plugin will override a core plugin.
Use the JJ_NPM_LOG_LEVEL environment variable to set the npm loglevel.
Use the JJ_NPM_REGISTRY environment variable to set the npm registry.
ALIASES
$ jj plugins add
EXAMPLES
Install a plugin from npm registry.
$ jj plugins install myplugin
Install a plugin from a github url.
$ jj plugins install https://github.com/someuser/someplugin
Install a plugin from a github slug.
$ jj plugins install someuser/someplugin
```
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/install.ts)_
## `jj plugins link PATH`
Links a plugin into the CLI for development.
```
USAGE
$ jj 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
$ jj plugins link myplugin
```
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/link.ts)_
## `jj plugins remove [PLUGIN]`
Removes a plugin from the CLI.
```
USAGE
$ jj 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
$ jj plugins unlink
$ jj plugins remove
EXAMPLES
$ jj plugins remove myplugin
```
## `jj plugins reset`
Remove all user-installed and linked plugins.
```
USAGE
$ jj 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.4.15/src/commands/plugins/reset.ts)_
## `jj plugins uninstall [PLUGIN]`
Removes a plugin from the CLI.
```
USAGE
$ jj 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
$ jj plugins unlink
$ jj plugins remove
EXAMPLES
$ jj plugins uninstall myplugin
```
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/uninstall.ts)_
## `jj plugins unlink [PLUGIN]`
Removes a plugin from the CLI.
```
USAGE
$ jj 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
$ jj plugins unlink
$ jj plugins remove
EXAMPLES
$ jj plugins unlink myplugin
```
## `jj plugins update`
Update installed plugins.
```
USAGE
$ jj 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.4.15/src/commands/plugins/update.ts)_
<!-- commandsstop -->
+3
View File
@@ -0,0 +1,3 @@
@echo off
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
Executable
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
// eslint-disable-next-line n/shebang
import {execute} from '@oclif/core'
await execute({development: true, dir: import.meta.url})
+3
View File
@@ -0,0 +1,3 @@
@echo off
node "%~dp0\run" %*
Executable
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env node
import {execute} from '@oclif/core'
await execute({dir: import.meta.url})
+73
View File
@@ -0,0 +1,73 @@
{
"name": "jj",
"description": "jj cli",
"version": "0.0.0",
"author": "Jason Jafari",
"bin": {
"jj": "./bin/run.js"
},
"bugs": "https://github.com/https://github.com/jafarijason/jj/jj/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/https://github.com/jafarijason/jj/jj",
"keywords": [
"oclif"
],
"license": "MIT",
"main": "dist/index.js",
"type": "module",
"oclif": {
"bin": "jj",
"dirname": "jj",
"commands": "./dist/commands",
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-plugins"
],
"topicSeparator": " ",
"topics": {
"hello": {
"description": "Say hello to the world and others"
}
}
},
"repository": "https://github.com/jafarijason/jj/jj",
"scripts": {
"build": "shx rm -rf dist && tsc -b",
"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
View 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
View 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
View File
@@ -0,0 +1 @@
export {run} from '@oclif/core'
+9
View 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
View 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
View File
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig",
"compilerOptions": {
"noEmit": true
},
"references": [
{"path": ".."}
]
}
+15
View File
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"declaration": true,
"module": "Node16",
"outDir": "dist",
"rootDir": "src",
"strict": true,
"target": "es2022",
"moduleResolution": "node16"
},
"include": ["./src/**/*"],
"ts-node": {
"esm": true
}
}
+1
View File
@@ -0,0 +1 @@
{"root":["./src/index.ts","./src/commands/hello/index.ts","./src/commands/hello/world.ts"],"version":"5.6.3"}
+56
View 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
View 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
View 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
+6378
View File
File diff suppressed because it is too large Load Diff