Skip to content

Commit 029f4d5

Browse files
committed
refactor: style regexp correctly
1 parent c5975d0 commit 029f4d5

10 files changed

Lines changed: 25 additions & 72 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/dist/
2+
/node_modules/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.*
2+
/src/
3+
/tsconfig.json
Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
1-
# Distributable Command
1+
# @examples/distributable-command
22

3-
The core functionality of @qui-cli: quickly convert command line input into both documentation and usable parameters.
4-
5-
To run the command (after building the package):
6-
7-
```sh
8-
> cd path/to/this/package
9-
> ./bin/my-command
10-
```
11-
12-
The command usage can be seen by passing the `--help` or `-h` flag:
13-
14-
```sh
15-
> ./bin/my-command -h
16-
Usage:
17-
my-command -hb --s=<A> --n=<numberValue> [...]
18-
19-
-h --help Show this usage information
20-
-s<A> --stringValue=<A>
21-
A text option
22-
-n<n> --numberValue=<n>
23-
A number option (with a secret default value)
24-
-b --booleanValue A boolean flag
25-
```
26-
27-
Review the [index.ts](./src/index.ts) inlne documentation for basic development usage.
28-
29-
Note that…
30-
31-
1. [package.json](./package.json) includes a `bin` property to export the command itself
32-
2. [my-command](./bin/my-command) names the command (with the file name itself) and is both marked executable and includes the node shebang for shell execution. The file just imports the compiled script from the `dist` directory.
3+
[![npm version](https://badge.fury.io/js/@examples%2fdistributable-command.svg)](https://npmjs.com/package/@examples/distributable-command)
4+
[![Module type: ESM](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://nodejs.org/api/esm.html)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
import '../dist.index.js';

examples/01 Distributable Command/bin/my-command

Lines changed: 0 additions & 2 deletions
This file was deleted.

examples/01 Distributable Command/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "@examples/distributable-command",
33
"version": "0.0.0",
4-
"private": true,
5-
"description": "A distributale command using @qui-cli components",
4+
"description": "",
65
"homepage": "https://github.com/battis/qui-cli/tree/main/examples/01%20Distributable%20Command#readme",
76
"repository": {
87
"type": "git",
@@ -24,7 +23,7 @@
2423
"build:compile": "tsc"
2524
},
2625
"dependencies": {
27-
"@qui-cli/core": "workspace:*"
26+
"@qui-cli/core": "^7.0.0"
2827
},
2928
"devDependencies": {
3029
"@tsconfig/node-lts": "^24.0.0",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as Plugin from '@qui-cli/plugin';
2+
3+
export type Configuration = Plugin.Configuration & {};
4+
5+
export const name = 'distributable-command';
6+
7+
export async function run() {}
Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,6 @@
11
import { Core } from '@qui-cli/core';
2+
import { register } from '@qui-cli/plugin';
3+
import * as DistributableCommand from './DistributableCommand.js';
24

3-
/* Initialize `positionals` and `values` with command line options */
4-
const { values, positionals } =
5-
/* Configure Core to expect a specific set of command line options */
6-
await Core.init({
7-
opt: {
8-
stringValue: {
9-
description: 'A text option',
10-
short: 's',
11-
hint: 'A'
12-
}
13-
},
14-
num: {
15-
numberValue: {
16-
description: 'A number option (with a secret default value)',
17-
short: 'n',
18-
default: 42,
19-
secret: true
20-
}
21-
},
22-
flag: {
23-
booleanValue: {
24-
description: 'A boolean flag',
25-
short: 'b'
26-
}
27-
}
28-
});
29-
30-
/*
31-
* let Core process command line options (including --help which displays
32-
* command usage documentation)
33-
*/
5+
await register(DistributableCommand);
346
await Core.run();
35-
36-
/* body of my-command */
37-
process.stdout.write(JSON.stringify({ values, positionals }));

examples/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# examples
22

33
<dl>
4-
<dt><a href="01 Distributable Command/README.md">@examples/distributable-command</a></dt><dd>A distributale command using @qui-cli components</dd>
54
<dt><a href="dev-env-1password/README.md">@examples/dev-env-1password</a></dt><dd>Integrate 1Password secret references in the enviroment with @qui-cli/env</dd>
65
<dt><a href="dev-plugin/README.md">@examples/dev-plugin</a></dt><dd>Define (and use) a plugin package</dd>
76
<dt><a href="dev-plugin-lifecycle/README.md">@examples/dev-plugin-lifecycle</a></dt><dd>Demonstrate order in which plugin hooks are called (and the state of environment variables at each hook invocation)</dd>

packages/init/src/Init/Plugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import path from 'node:path';
66
import * as Confirm from './Confirm/index.js';
77
import fs from 'node:fs';
88
import { Log } from '@qui-cli/log';
9+
import { Colors } from '@qui-cli/colors';
910

1011
export type Configuration = Plugin.Configuration & {
1112
dirPath?: PathString;
@@ -86,7 +87,7 @@ export function options() {
8687
hint: '/^\\.env(\\.*)?$/i',
8788
default: config.ignore
8889
?.filter((i) => typeof i !== 'string')
89-
.map((r) => `${r}`)
90+
.map((r) => Colors.regexpValue(`${r}`))
9091
}
9192
},
9293
flag: {

0 commit comments

Comments
 (0)