From 5a7e07612e124c575925129bed869b55006afe7a Mon Sep 17 00:00:00 2001 From: Michael Molisani Date: Thu, 17 Oct 2024 15:00:12 -0400 Subject: [PATCH] fix: update auto-complete template to output completions Signed-off-by: Michael Molisani --- packages/create-app/src/files.ts | 241 +++++++++--------- packages/create-app/src/impl.ts | 4 +- .../without auto-complete.txt | 174 ++++++------- .../package properties/custom bin command.txt | 200 ++++++++------- .../package properties/custom metadata.txt | 200 ++++++++------- .../custom name and bin command.txt | 200 ++++++++------- .../package properties/custom name.txt | 200 ++++++++------- .../commonjs/with default flags.txt | 200 ++++++++------- .../without auto-complete.txt | 174 ++++++------- .../package properties/custom bin command.txt | 199 ++++++++------- .../package properties/custom metadata.txt | 199 ++++++++------- .../custom name and bin command.txt | 199 ++++++++------- .../package properties/custom name.txt | 199 ++++++++------- .../module [default]/with default flags.txt | 199 ++++++++------- .../without auto-complete.txt | 110 ++++---- .../package properties/custom bin command.txt | 126 ++++----- .../package properties/custom metadata.txt | 126 ++++----- .../custom name and bin command.txt | 126 ++++----- .../package properties/custom name.txt | 126 ++++----- .../commonjs/with default flags.txt | 126 ++++----- .../without auto-complete.txt | 110 ++++---- .../package properties/custom bin command.txt | 125 ++++----- .../package properties/custom metadata.txt | 125 ++++----- .../custom name and bin command.txt | 125 ++++----- .../package properties/custom name.txt | 125 ++++----- .../module [default]/with default flags.txt | 125 ++++----- 26 files changed, 2103 insertions(+), 1960 deletions(-) diff --git a/packages/create-app/src/files.ts b/packages/create-app/src/files.ts index 362f1ac..628c59e 100644 --- a/packages/create-app/src/files.ts +++ b/packages/create-app/src/files.ts @@ -34,14 +34,14 @@ export const localContextText = `\ import type { CommandContext } from "@stricli/core"; export interface LocalContext extends CommandContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - }; + return { + process, + }; } `; @@ -53,17 +53,17 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } `; @@ -71,11 +71,11 @@ export const singleCommandImplText = `\ import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(\`Hello \${name}!\\n\`.repeat(flags.count)); + this.process.stdout.write(\`Hello \${name}!\\n\`.repeat(flags.count)); } `; @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); `; @@ -120,11 +120,11 @@ export const multiCommandSubdirImplText = `\ import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } `; @@ -132,16 +132,16 @@ export const multiCommandSubdirCommandText = `\ import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); `; @@ -149,19 +149,19 @@ export const multiCommandNestedImplText = `\ import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } `; @@ -169,45 +169,45 @@ export const multiCommandNestedCommandsText = `\ import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); `; @@ -218,20 +218,20 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - }, - docs: { - brief: description, - }, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + }, + docs: { + brief: description, + }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); `; @@ -244,26 +244,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("${command}", { bash: "${autcCommand}" }), - uninstall: buildUninstallCommand("${command}", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("${command}", { bash: "${autcCommand}" }), + uninstall: buildUninstallCommand("${command}", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); `; } @@ -291,9 +291,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(\`\${completion}\\n\`); + } +} catch { + // ignore +} `; export const binBashCompleteScriptText = `\ @@ -303,7 +310,13 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(\`\${completion}\\n\`); + } +}, () => { + // ignore +}); `; diff --git a/packages/create-app/src/impl.ts b/packages/create-app/src/impl.ts index f95a266..2ebb9e9 100644 --- a/packages/create-app/src/impl.ts +++ b/packages/create-app/src/impl.ts @@ -167,7 +167,7 @@ export default async function (this: LocalContext, flags: CreateProjectFlags, di await writeFile("src/context.ts", localContextText); } - await writeFile("package.json", JSON.stringify(packageJson, void 0, 2)); + await writeFile("package.json", JSON.stringify(packageJson, void 0, 4)); await writeFile(".gitignore", gitignoreText); @@ -176,7 +176,7 @@ export default async function (this: LocalContext, flags: CreateProjectFlags, di include: srcTsconfig.include, exclude: srcTsconfig.exclude, }; - await writeFile("src/tsconfig.json", JSON.stringify(sourceTsconfigJson, void 0, 2)); + await writeFile("src/tsconfig.json", JSON.stringify(sourceTsconfigJson, void 0, 4)); if (flags.template === "single") { await writeFile("src/impl.ts", singleCommandImplText); diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/additional features/without auto-complete.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/additional features/without auto-complete.txt index b9a844d..7123e79 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/additional features/without auto-complete.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/additional features/without auto-complete.txt @@ -82,20 +82,20 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - }, - docs: { - brief: description, - }, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + }, + docs: { + brief: description, + }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/cli.ts @@ -109,133 +109,133 @@ void run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts import type { CommandContext } from "@stricli/core"; export interface LocalContext extends CommandContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - }; + return { + process, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom bin command.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom bin command.txt index ab42f4f..e5de0af 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom bin command.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom bin command.txt @@ -87,26 +87,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("test-cli", { bash: "__test-cli_bash_complete" }), - uninstall: buildUninstallCommand("test-cli", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("test-cli", { bash: "__test-cli_bash_complete" }), + uninstall: buildUninstallCommand("test-cli", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -116,9 +116,15 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(`${completion}\n`); + } +}, () => { + // ignore +}); ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -131,91 +137,91 @@ void run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts @@ -226,45 +232,45 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom metadata.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom metadata.txt index ba7bd54..a1391c5 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom metadata.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom metadata.txt @@ -87,26 +87,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("test", { bash: "__test_bash_complete" }), - uninstall: buildUninstallCommand("test", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("test", { bash: "__test_bash_complete" }), + uninstall: buildUninstallCommand("test", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -116,9 +116,15 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(`${completion}\n`); + } +}, () => { + // ignore +}); ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -131,91 +137,91 @@ void run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts @@ -226,45 +232,45 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom name and bin command.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom name and bin command.txt index 353efad..7bdf364 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom name and bin command.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom name and bin command.txt @@ -87,26 +87,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("test-cli", { bash: "__test-cli_bash_complete" }), - uninstall: buildUninstallCommand("test-cli", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("test-cli", { bash: "__test-cli_bash_complete" }), + uninstall: buildUninstallCommand("test-cli", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -116,9 +116,15 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(`${completion}\n`); + } +}, () => { + // ignore +}); ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -131,91 +137,91 @@ void run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts @@ -226,45 +232,45 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom name.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom name.txt index 16710c9..618c133 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom name.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/package properties/custom name.txt @@ -87,26 +87,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("@org/test-cli", { bash: "__@org/test-cli_bash_complete" }), - uninstall: buildUninstallCommand("@org/test-cli", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("@org/test-cli", { bash: "__@org/test-cli_bash_complete" }), + uninstall: buildUninstallCommand("@org/test-cli", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -116,9 +116,15 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(`${completion}\n`); + } +}, () => { + // ignore +}); ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -131,91 +137,91 @@ void run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts @@ -226,45 +232,45 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/with default flags.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/with default flags.txt index 2a41d31..36a9883 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/with default flags.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/commonjs/with default flags.txt @@ -87,26 +87,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("test", { bash: "__test_bash_complete" }), - uninstall: buildUninstallCommand("test", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("test", { bash: "__test_bash_complete" }), + uninstall: buildUninstallCommand("test", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -116,9 +116,15 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(`${completion}\n`); + } +}, () => { + // ignore +}); ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -131,91 +137,91 @@ void run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts @@ -226,45 +232,45 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/additional features/without auto-complete.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/additional features/without auto-complete.txt index 8c1d87d..a578c40 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/additional features/without auto-complete.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/additional features/without auto-complete.txt @@ -82,20 +82,20 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - }, - docs: { - brief: description, - }, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + }, + docs: { + brief: description, + }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/cli.ts @@ -109,133 +109,133 @@ await run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts import type { CommandContext } from "@stricli/core"; export interface LocalContext extends CommandContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - }; + return { + process, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom bin command.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom bin command.txt index 9c4da3a..982bab7 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom bin command.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom bin command.txt @@ -87,26 +87,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("test-cli", { bash: "__test-cli_bash_complete" }), - uninstall: buildUninstallCommand("test-cli", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("test-cli", { bash: "__test-cli_bash_complete" }), + uninstall: buildUninstallCommand("test-cli", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -116,9 +116,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(`${completion}\n`); + } +} catch { + // ignore +} ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -131,91 +138,91 @@ await run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts @@ -226,45 +233,45 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom metadata.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom metadata.txt index 264edd6..cc7002d 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom metadata.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom metadata.txt @@ -87,26 +87,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("test", { bash: "__test_bash_complete" }), - uninstall: buildUninstallCommand("test", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("test", { bash: "__test_bash_complete" }), + uninstall: buildUninstallCommand("test", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -116,9 +116,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(`${completion}\n`); + } +} catch { + // ignore +} ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -131,91 +138,91 @@ await run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts @@ -226,45 +233,45 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom name and bin command.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom name and bin command.txt index 9c81201..794aa06 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom name and bin command.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom name and bin command.txt @@ -87,26 +87,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("test-cli", { bash: "__test-cli_bash_complete" }), - uninstall: buildUninstallCommand("test-cli", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("test-cli", { bash: "__test-cli_bash_complete" }), + uninstall: buildUninstallCommand("test-cli", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -116,9 +116,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(`${completion}\n`); + } +} catch { + // ignore +} ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -131,91 +138,91 @@ await run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts @@ -226,45 +233,45 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom name.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom name.txt index 7c7a0f0..fb00410 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom name.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/package properties/custom name.txt @@ -87,26 +87,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("@org/test-cli", { bash: "__@org/test-cli_bash_complete" }), - uninstall: buildUninstallCommand("@org/test-cli", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("@org/test-cli", { bash: "__@org/test-cli_bash_complete" }), + uninstall: buildUninstallCommand("@org/test-cli", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -116,9 +116,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(`${completion}\n`); + } +} catch { + // ignore +} ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -131,91 +138,91 @@ await run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts @@ -226,45 +233,45 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/with default flags.txt b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/with default flags.txt index 682e64c..68587ca 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/with default flags.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/multi-command/module [default]/with default flags.txt @@ -87,26 +87,26 @@ import { subdirCommand } from "./commands/subdir/command"; import { nestedRoutes } from "./commands/nested/commands"; const routes = buildRouteMap({ - routes: { - subdir: subdirCommand, - nested: nestedRoutes, - install: buildInstallCommand("test", { bash: "__test_bash_complete" }), - uninstall: buildUninstallCommand("test", { bash: true }), - }, - docs: { - brief: description, - hideRoute: { - install: true, - uninstall: true, + routes: { + subdir: subdirCommand, + nested: nestedRoutes, + install: buildInstallCommand("test", { bash: "__test_bash_complete" }), + uninstall: buildUninstallCommand("test", { bash: true }), + }, + docs: { + brief: description, + hideRoute: { + install: true, + uninstall: true, + }, }, - }, }); export const app = buildApplication(routes, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -116,9 +116,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(`${completion}\n`); + } +} catch { + // ignore +} ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -131,91 +138,91 @@ await run(app, process.argv.slice(2), buildContext(process)); import { buildCommand, buildRouteMap } from "@stricli/core"; export const fooCommand = buildCommand({ - loader: async () => { - const { foo } = await import("./impl"); - return foo; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { foo } = await import("./impl"); + return foo; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested foo command", }, - }, - docs: { - brief: "Nested foo command", - }, }); export const barCommand = buildCommand({ - loader: async () => { - const { bar } = await import("./impl"); - return bar; - }, - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => { + const { bar } = await import("./impl"); + return bar; + }, + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Nested bar command", }, - }, - docs: { - brief: "Nested bar command", - }, }); export const nestedRoutes = buildRouteMap({ - routes: { - foo: fooCommand, - bar: barCommand, - }, - docs: { - brief: "Nested commands", - }, + routes: { + foo: fooCommand, + bar: barCommand, + }, + docs: { + brief: "Nested commands", + }, }); ::::/root/test/src/commands/nested/impl.ts import type { LocalContext } from "../../context"; interface FooCommandFlags { - // ... + // ... } export async function foo(this: LocalContext, flags: FooCommandFlags): Promise { - // ... + // ... } interface BarCommandFlags { - // ... + // ... } export async function bar(this: LocalContext, flags: BarCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/commands/subdir/command.ts import { buildCommand } from "@stricli/core"; export const subdirCommand = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [], + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [], + }, + }, + docs: { + brief: "Command in subdirectory", }, - }, - docs: { - brief: "Command in subdirectory", - }, }); ::::/root/test/src/commands/subdir/impl.ts import type { LocalContext } from "../../context"; interface SubdirCommandFlags { - // ... + // ... } export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise { - // ... + // ... } ::::/root/test/src/context.ts @@ -226,45 +233,45 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/additional features/without auto-complete.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/additional features/without auto-complete.txt index 0d0d530..501f9d0 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/additional features/without auto-complete.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/additional features/without auto-complete.txt @@ -80,35 +80,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/cli.ts @@ -122,53 +122,53 @@ void run(app, process.argv.slice(2), buildContext(process)); import type { CommandContext } from "@stricli/core"; export interface LocalContext extends CommandContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - }; + return { + process, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom bin command.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom bin command.txt index 671c72f..83a7fe3 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom bin command.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom bin command.txt @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -122,9 +122,15 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(`${completion}\n`); + } +}, () => { + // ignore +}); ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -141,56 +147,56 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom metadata.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom metadata.txt index faec70e..b7a7c51 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom metadata.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom metadata.txt @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -122,9 +122,15 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(`${completion}\n`); + } +}, () => { + // ignore +}); ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -141,56 +147,56 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom name and bin command.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom name and bin command.txt index 55a6d78..65729f2 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom name and bin command.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom name and bin command.txt @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -122,9 +122,15 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(`${completion}\n`); + } +}, () => { + // ignore +}); ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -141,56 +147,56 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom name.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom name.txt index 317e568..9c81586 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom name.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/package properties/custom name.txt @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -122,9 +122,15 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(`${completion}\n`); + } +}, () => { + // ignore +}); ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -141,56 +147,56 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/with default flags.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/with default flags.txt index 0864ef7..2873c2d 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/with default flags.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/commonjs/with default flags.txt @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -122,9 +122,15 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } -void proposeCompletions(app, inputs, buildContext(process)); +void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { + for (const { completion } of completions) { + process.stdout.write(`${completion}\n`); + } +}, () => { + // ignore +}); ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -141,56 +147,56 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/additional features/without auto-complete.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/additional features/without auto-complete.txt index 132b8fd..c066be0 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/additional features/without auto-complete.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/additional features/without auto-complete.txt @@ -80,35 +80,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/cli.ts @@ -122,53 +122,53 @@ await run(app, process.argv.slice(2), buildContext(process)); import type { CommandContext } from "@stricli/core"; export interface LocalContext extends CommandContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - }; + return { + process, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom bin command.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom bin command.txt index 0aee201..02f853e 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom bin command.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom bin command.txt @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -122,9 +122,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(`${completion}\n`); + } +} catch { + // ignore +} ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -141,56 +148,56 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom metadata.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom metadata.txt index 2600856..60d0fca 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom metadata.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom metadata.txt @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -122,9 +122,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(`${completion}\n`); + } +} catch { + // ignore +} ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -141,56 +148,56 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom name and bin command.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom name and bin command.txt index 7c37d04..f8db0a9 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom name and bin command.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom name and bin command.txt @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -122,9 +122,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(`${completion}\n`); + } +} catch { + // ignore +} ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -141,56 +148,56 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom name.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom name.txt index 918e38f..b483718 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom name.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/package properties/custom name.txt @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -122,9 +122,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(`${completion}\n`); + } +} catch { + // ignore +} ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -141,56 +148,56 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file diff --git a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/with default flags.txt b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/with default flags.txt index 0e8f3d0..27ceda5 100644 --- a/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/with default flags.txt +++ b/packages/create-app/tests/baselines/reference/app/creates new application/single-command/module [default]/with default flags.txt @@ -84,35 +84,35 @@ import { buildApplication, buildCommand, numberParser } from "@stricli/core"; import { name, version, description } from "../package.json"; const command = buildCommand({ - loader: async () => import("./impl"), - parameters: { - positional: { - kind: "tuple", - parameters: [ - { - brief: "Your name", - parse: String, + loader: async () => import("./impl"), + parameters: { + positional: { + kind: "tuple", + parameters: [ + { + brief: "Your name", + parse: String, + }, + ], + }, + flags: { + count: { + kind: "parsed", + brief: "Number of times to say hello", + parse: numberParser, + }, }, - ], }, - flags: { - count: { - kind: "parsed", - brief: "Number of times to say hello", - parse: numberParser, - }, + docs: { + brief: description, }, - }, - docs: { - brief: description, - }, }); export const app = buildApplication(command, { - name, - versionInfo: { - currentVersion: version, - }, + name, + versionInfo: { + currentVersion: version, + }, }); ::::/root/test/src/bin/bash-complete.ts @@ -122,9 +122,16 @@ import { buildContext } from "../context"; import { app } from "../app"; const inputs = process.argv.slice(3); if (process.env["COMP_LINE"]?.endsWith(" ")) { - inputs.push(""); + inputs.push(""); } await proposeCompletions(app, inputs, buildContext(process)); +try { + for (const { completion } of await proposeCompletions(app, inputs, buildContext(process))) { + process.stdout.write(`${completion}\n`); + } +} catch { + // ignore +} ::::/root/test/src/bin/cli.ts #!/usr/bin/env node @@ -141,56 +148,56 @@ import os from "node:os"; import path from "node:path"; export interface LocalContext extends CommandContext, StricliAutoCompleteContext { - readonly process: NodeJS.Process; - // ... + readonly process: NodeJS.Process; + // ... } export function buildContext(process: NodeJS.Process): LocalContext { - return { - process, - os, - fs, - path, - }; + return { + process, + os, + fs, + path, + }; } ::::/root/test/src/impl.ts import type { LocalContext } from "./context"; interface CommandFlags { - readonly count: number; + readonly count: number; } export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise { - this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); + this.process.stdout.write(`Hello ${name}!\n`.repeat(flags.count)); } ::::/root/test/src/tsconfig.json { - "compilerOptions": { - "noEmit": true, - "rootDir": "..", - "types": [ - "node" - ], - "resolveJsonModule": true, - "target": "esnext", - "module": "esnext", - "moduleResolution": "bundler", - "lib": [ - "esnext" + "compilerOptions": { + "noEmit": true, + "rootDir": "..", + "types": [ + "node" + ], + "resolveJsonModule": true, + "target": "esnext", + "module": "esnext", + "moduleResolution": "bundler", + "lib": [ + "esnext" + ], + "skipLibCheck": true, + "strict": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true + }, + "include": [ + "**/*" ], - "skipLibCheck": true, - "strict": true, - "isolatedModules": true, - "forceConsistentCasingInFileNames": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noUncheckedIndexedAccess": true, - "verbatimModuleSyntax": true - }, - "include": [ - "**/*" - ], - "exclude": [] + "exclude": [] } \ No newline at end of file