@stricli/create-app
Advanced tools
| var i={name:"@stricli/create-app",version:"1.1.1",description:"Generate a new Stricli application",license:"Apache-2.0",repository:{type:"git",url:"https://github.com/bloomberg/stricli/tree/main/packages/create-app"},author:"Michael Molisani <mmolisani@bloomberg.net>",files:["dist"],type:"module",bin:{"create-app":"dist/cli.js"},engines:{node:">=18.x"},scripts:{format:"prettier --config ../../.prettierrc -w .","format:check":"prettier --config ../../.prettierrc -c .",lint:"eslint src","lint:fix":"eslint src tests --fix",typecheck:"tsc -p tsconfig.json --noEmit",test:"mocha","test:clear-baseline":"node scripts/clear_baseline","test:accept-baseline":"node scripts/accept_baseline",coverage:"c8 npm test",build:"tsup",prepublishOnly:"npm run build"},mocha:{import:"tsx/esm",spec:"tests/**/*.spec.ts"},c8:{reporter:["text","lcovonly"],"check-coverage":!0,"skip-full":!0},tsup:{entry:["src/bin/cli.ts"],format:["esm"],tsconfig:"src/tsconfig.json",clean:!0,splitting:!0,minify:!0},dependencies:{"@stricli/auto-complete":"^1.1.1","@stricli/core":"^1.1.1"},devDependencies:{"@types/chai":"^4.3.16","@types/mocha":"^10.0.6","@types/node":"^18.19.33","@types/sinon":"^17.0.3","@typescript-eslint/eslint-plugin":"^8.2.0","@typescript-eslint/parser":"^8.2.0",c8:"^9.1.0",chai:"^5.1.1",eslint:"^8.57.0","eslint-plugin-prettier":"^5.1.3","fs-extra":"^11.2.0",memfs:"^4.9.2",mocha:"^10.4.0",prettier:"^3.2.5",sinon:"^18.0.0",tsup:"^6.7.0",tsx:"^4.8.2","type-fest":"^3.5.4",typescript:"5.6.x"}};export{i as a}; |
| import{a as c}from"./chunk-AOTHCOEO.js";var b=`# Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| lerna-debug.log* | ||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
| # Coverage directory used by tools like istanbul | ||
| coverage | ||
| *.lcov | ||
| # nyc test coverage | ||
| .nyc_output | ||
| # Dependency directories | ||
| node_modules/ | ||
| jspm_packages/ | ||
| *.tsbuildinfo | ||
| dist | ||
| `,C=`import type { CommandContext } from "@stricli/core"; | ||
| export interface LocalContext extends CommandContext { | ||
| readonly process: NodeJS.Process; | ||
| // ... | ||
| } | ||
| export function buildContext(process: NodeJS.Process): LocalContext { | ||
| return { | ||
| process, | ||
| }; | ||
| } | ||
| `,x=`import type { CommandContext } from "@stricli/core"; | ||
| import type { StricliAutoCompleteContext } from "@stricli/auto-complete"; | ||
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
| export interface LocalContext extends CommandContext, StricliAutoCompleteContext { | ||
| readonly process: NodeJS.Process; | ||
| // ... | ||
| } | ||
| export function buildContext(process: NodeJS.Process): LocalContext { | ||
| return { | ||
| process, | ||
| os, | ||
| fs, | ||
| path, | ||
| }; | ||
| } | ||
| `,g=`import type { LocalContext } from "./context"; | ||
| interface CommandFlags { | ||
| readonly count: number; | ||
| } | ||
| export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise<void> { | ||
| this.process.stdout.write(\`Hello \${name}!\\n\`.repeat(flags.count)); | ||
| } | ||
| `,y=`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, | ||
| }, | ||
| ], | ||
| }, | ||
| flags: { | ||
| count: { | ||
| kind: "parsed", | ||
| brief: "Number of times to say hello", | ||
| parse: numberParser, | ||
| }, | ||
| }, | ||
| }, | ||
| docs: { | ||
| brief: description, | ||
| }, | ||
| }); | ||
| export const app = buildApplication(command, { | ||
| name, | ||
| versionInfo: { | ||
| currentVersion: version, | ||
| }, | ||
| }); | ||
| `,v=`import type { LocalContext } from "../../context"; | ||
| interface SubdirCommandFlags { | ||
| // ... | ||
| } | ||
| export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise<void> { | ||
| // ... | ||
| } | ||
| `,h=`import { buildCommand } from "@stricli/core"; | ||
| export const subdirCommand = buildCommand({ | ||
| loader: async () => import("./impl"), | ||
| parameters: { | ||
| positional: { | ||
| kind: "tuple", | ||
| parameters: [], | ||
| }, | ||
| }, | ||
| docs: { | ||
| brief: "Command in subdirectory", | ||
| }, | ||
| }); | ||
| `,P=`import type { LocalContext } from "../../context"; | ||
| interface FooCommandFlags { | ||
| // ... | ||
| } | ||
| export async function foo(this: LocalContext, flags: FooCommandFlags): Promise<void> { | ||
| // ... | ||
| } | ||
| interface BarCommandFlags { | ||
| // ... | ||
| } | ||
| export async function bar(this: LocalContext, flags: BarCommandFlags): Promise<void> { | ||
| // ... | ||
| } | ||
| `,T=`import { buildCommand, buildRouteMap } from "@stricli/core"; | ||
| export const fooCommand = buildCommand({ | ||
| loader: async () => { | ||
| const { foo } = await import("./impl"); | ||
| return foo; | ||
| }, | ||
| parameters: { | ||
| positional: { | ||
| kind: "tuple", | ||
| parameters: [], | ||
| }, | ||
| }, | ||
| docs: { | ||
| brief: "Nested foo command", | ||
| }, | ||
| }); | ||
| export const barCommand = buildCommand({ | ||
| loader: async () => { | ||
| const { bar } = await import("./impl"); | ||
| return bar; | ||
| }, | ||
| parameters: { | ||
| positional: { | ||
| kind: "tuple", | ||
| parameters: [], | ||
| }, | ||
| }, | ||
| docs: { | ||
| brief: "Nested bar command", | ||
| }, | ||
| }); | ||
| export const nestedRoutes = buildRouteMap({ | ||
| routes: { | ||
| foo: fooCommand, | ||
| bar: barCommand, | ||
| }, | ||
| docs: { | ||
| brief: "Nested commands", | ||
| }, | ||
| }); | ||
| `,w=`import { buildApplication, buildRouteMap } from "@stricli/core"; | ||
| import { name, version, description } from "../package.json"; | ||
| import { subdirCommand } from "./commands/subdir/command"; | ||
| import { nestedRoutes } from "./commands/nested/commands"; | ||
| const routes = buildRouteMap({ | ||
| routes: { | ||
| subdir: subdirCommand, | ||
| nested: nestedRoutes, | ||
| }, | ||
| docs: { | ||
| brief: description, | ||
| }, | ||
| }); | ||
| export const app = buildApplication(routes, { | ||
| name, | ||
| versionInfo: { | ||
| currentVersion: version, | ||
| }, | ||
| }); | ||
| `;function N(e,t){return`import { buildApplication, buildRouteMap } from "@stricli/core"; | ||
| import { buildInstallCommand, buildUninstallCommand } from "@stricli/auto-complete"; | ||
| import { name, version, description } from "../package.json"; | ||
| import { subdirCommand } from "./commands/subdir/command"; | ||
| import { nestedRoutes } from "./commands/nested/commands"; | ||
| const routes = buildRouteMap({ | ||
| routes: { | ||
| subdir: subdirCommand, | ||
| nested: nestedRoutes, | ||
| install: buildInstallCommand("${e}", { bash: "${t}" }), | ||
| uninstall: buildUninstallCommand("${e}", { bash: true }), | ||
| }, | ||
| docs: { | ||
| brief: description, | ||
| hideRoute: { | ||
| install: true, | ||
| uninstall: true, | ||
| }, | ||
| }, | ||
| }); | ||
| export const app = buildApplication(routes, { | ||
| name, | ||
| versionInfo: { | ||
| currentVersion: version, | ||
| }, | ||
| }); | ||
| `}var k=`#!/usr/bin/env node | ||
| import { run } from "@stricli/core"; | ||
| import { buildContext } from "../context"; | ||
| import { app } from "../app"; | ||
| await run(app, process.argv.slice(2), buildContext(process)); | ||
| `,S=`#!/usr/bin/env node | ||
| import { run } from "@stricli/core"; | ||
| import { buildContext } from "../context"; | ||
| import { app } from "../app"; | ||
| void run(app, process.argv.slice(2), buildContext(process)); | ||
| `,j=`#!/usr/bin/env node | ||
| import { proposeCompletions } from "@stricli/core"; | ||
| import { buildContext } from "../context"; | ||
| import { app } from "../app"; | ||
| const inputs = process.argv.slice(3); | ||
| if (process.env["COMP_LINE"]?.endsWith(" ")) { | ||
| 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 | ||
| } | ||
| `,A=`#!/usr/bin/env node | ||
| import { proposeCompletions } from "@stricli/core"; | ||
| import { buildContext } from "../context"; | ||
| import { app } from "../app"; | ||
| const inputs = process.argv.slice(3); | ||
| if (process.env["COMP_LINE"]?.endsWith(" ")) { | ||
| inputs.push(""); | ||
| } | ||
| void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { | ||
| for (const { completion } of completions) { | ||
| process.stdout.write(\`\${completion}\\n\`); | ||
| } | ||
| }, () => { | ||
| // ignore | ||
| }); | ||
| `;import V from"node:child_process";function J(e){if(e.env.NPM_CONFIG_REGISTRY)return e.env.NPM_CONFIG_REGISTRY;if(e.env.NPM_EXECPATH)return V.execFileSync(e.execPath,[e.env.NPM_EXECPATH,"config","get","registry"],{encoding:"utf-8"}).trim()}async function M(e,t){let n=e+(e.endsWith("/")?t:`/${t}`),o=await(await fetch(n)).json();if(typeof o=="object"&&o&&"versions"in o&&typeof o.versions=="object")return Object.keys(o.versions??{})}var _=22;async function R(e){let t=Number(e.versions.node.split(".")[0]),n;if(t>_){let i=J(e),o=i&&await M(i,"@types/node");if(o?.includes(e.versions.node))n=`^${e.versions.node}`;else if(o){let s=new Set(o.map(r=>Number(r.split(".")[0])));if(s.has(t))n=`${t}.x`;else{let r=[...s].filter(a=>a%2===0).toSorted().at(-1);r&&(n=`${r}.x`,e.stderr.write(`No version of @types/node found with major ${t}, falling back to ${n} | ||
| `),e.stderr.write("Rerun this command with the hidden flag --node-version to manually specify the Node.js major version"))}}}else n=`${t}.x`;return n||(n=`${t}.x`,e.stderr.write(`Unable to determine version of @types/node for ${e.versions.node}, assuming ${n} | ||
| `),e.stderr.write("Rerun this command with the hidden flag --node-version to manually specify the Node.js major version")),{engine:`>=${t}`,types:n}}var p={compilerOptions:{noEmit:!0,rootDir:"..",types:["node"],resolveJsonModule:!0,target:"esnext",module:"esnext",moduleResolution:"bundler",lib:["esnext"],skipLibCheck:!0,strict:!0,isolatedModules:!0,forceConsistentCasingInFileNames:!0,noImplicitOverride:!0,noPropertyAccessFromIndexSignature:!0,noUncheckedIndexedAccess:!0,verbatimModuleSyntax:!0},exclude:[],include:["**/*"]};function O(e){return`__${e}_bash_complete`}function E(e,t,n){return{...e,version:"0.0.0",files:["dist"],bin:{[t]:"dist/cli.js"},engines:{node:n.engine},scripts:{prebuild:"tsc -p src/tsconfig.json",build:"tsup",prepublishOnly:"npm run build"},tsup:{entry:["src/bin/cli.ts"],format:[e.type==="commonjs"?"cjs":"esm"],tsconfig:"src/tsconfig.json",clean:!0,splitting:!0,minify:!0},dependencies:{"@stricli/core":c.dependencies["@stricli/core"]},devDependencies:{"@types/node":n.types,tsup:c.devDependencies.tsup,typescript:c.devDependencies.typescript}}}function B(e,t){return{...e,dependencies:{...e.dependencies,"@stricli/auto-complete":c.dependencies["@stricli/auto-complete"]},bin:{...e.bin,[t]:"dist/bash-complete.js"},tsup:{...e.tsup,entry:[...e.tsup?.entry??[],"src/bin/bash-complete.ts"]}}}function I(e,t){return{...e,scripts:{...e.scripts,postinstall:t}}}async function Q(e,t){let{fs:n,path:i}=this;await n.promises.mkdir(t,{recursive:!0});let o=async(u,f)=>{let $=i.join(t,u);await n.promises.writeFile($,f)},s=async u=>{let f=i.join(t,u);await n.promises.mkdir(f,{recursive:!0})};await s("src");let r=e.name??i.basename(t),a=e.command??r,d;e.nodeVersion?d={engine:`>=${e.nodeVersion}`,types:`${e.nodeVersion}.x`}:d=await R(this.process);let m=E({name:r,author:e.author,description:e.description,license:e.license,type:e.type},a,d),l=O(a);e.autoComplete?(m=B(m,l),e.template==="multi"?m=I(m,`${a} install`):m=I(m,`npx @stricli/auto-complete@latest install ${a} --bash ${l}`),await o("src/context.ts",x)):await o("src/context.ts",C),await o("package.json",JSON.stringify(m,void 0,4)),await o(".gitignore",b);let L={compilerOptions:p.compilerOptions,include:p.include,exclude:p.exclude};await o("src/tsconfig.json",JSON.stringify(L,void 0,4)),e.template==="single"?(await o("src/impl.ts",g),await o("src/app.ts",y)):(await s("src/commands/subdir"),await o("src/commands/subdir/impl.ts",v),await o("src/commands/subdir/command.ts",h),await s("src/commands/nested"),await o("src/commands/nested/impl.ts",P),await o("src/commands/nested/commands.ts",T),e.autoComplete?await o("src/app.ts",N(a,l)):await o("src/app.ts",w)),await s("src/bin"),await o("src/bin/cli.ts",e.type==="module"?k:S),e.autoComplete&&await o("src/bin/bash-complete.ts",e.type==="module"?j:A)}export{Q as default}; |
+1
-1
| #!/usr/bin/env node | ||
| import{a as e}from"./chunk-KM6MPGDF.js";import{run as l}from"@stricli/core";import i from"node:fs";import a from"node:os";import n from"node:path";function r(o){return{process:o,os:a,fs:i,path:n}}import{buildApplication as s,buildCommand as p,numberParser as m}from"@stricli/core";var d=p({loader:async()=>import("./impl-WMK7M73K.js"),parameters:{positional:{kind:"tuple",parameters:[{brief:"Target path of new package directory",parse(o){return this.path.join(this.process.cwd(),o)},placeholder:"path"}]},flags:{type:{kind:"enum",brief:"Package type, controls output format of JS files",values:["commonjs","module"],default:"module"},template:{kind:"enum",brief:"Application template to generate",values:["single","multi"],default:"multi"},autoComplete:{kind:"boolean",brief:"Include auto complete postinstall script",default:!0},name:{kind:"parsed",brief:"Package name, if different from directory",parse:String,optional:!0},command:{kind:"parsed",brief:"Intended bin command, if different from name",parse:String,optional:!0},description:{kind:"parsed",brief:"Package description",parse:String,default:"Stricli command line application"},license:{kind:"parsed",brief:"Package license",parse:String,default:"MIT"},author:{kind:"parsed",brief:"Package author",parse:String,default:""},nodeVersion:{kind:"parsed",brief:"Node.js major version to use for engines.node minimum and @types/node, bypasses version discovery logic",parse:m,optional:!0,hidden:!0}},aliases:{n:"name",d:"description"}},docs:{brief:e.description}}),t=s(d,{name:e.name,versionInfo:{currentVersion:e.version},scanner:{caseStyle:"allow-kebab-for-camel"},documentation:{useAliasInUsageLine:!0}});await l(t,process.argv.slice(2),r(process)); | ||
| import{a as e}from"./chunk-AOTHCOEO.js";import{run as l}from"@stricli/core";import i from"node:fs";import a from"node:os";import n from"node:path";function r(o){return{process:o,os:a,fs:i,path:n}}import{buildApplication as s,buildCommand as p,numberParser as m}from"@stricli/core";var d=p({loader:async()=>import("./impl-RJSUFLNJ.js"),parameters:{positional:{kind:"tuple",parameters:[{brief:"Target path of new package directory",parse(o){return this.path.join(this.process.cwd(),o)},placeholder:"path"}]},flags:{type:{kind:"enum",brief:"Package type, controls output format of JS files",values:["commonjs","module"],default:"module"},template:{kind:"enum",brief:"Application template to generate",values:["single","multi"],default:"multi"},autoComplete:{kind:"boolean",brief:"Include auto complete postinstall script",default:!0},name:{kind:"parsed",brief:"Package name, if different from directory",parse:String,optional:!0},command:{kind:"parsed",brief:"Intended bin command, if different from name",parse:String,optional:!0},description:{kind:"parsed",brief:"Package description",parse:String,default:"Stricli command line application"},license:{kind:"parsed",brief:"Package license",parse:String,default:"MIT"},author:{kind:"parsed",brief:"Package author",parse:String,default:""},nodeVersion:{kind:"parsed",brief:"Node.js major version to use for engines.node minimum and @types/node, bypasses version discovery logic",parse:m,optional:!0,hidden:!0}},aliases:{n:"name",d:"description"}},docs:{brief:e.description}}),t=s(d,{name:e.name,versionInfo:{currentVersion:e.version},scanner:{caseStyle:"allow-kebab-for-camel"},documentation:{useAliasInUsageLine:!0}});await l(t,process.argv.slice(2),r(process)); |
+3
-3
| { | ||
| "name": "@stricli/create-app", | ||
| "version": "1.1.0", | ||
| "version": "1.1.1", | ||
| "description": "Generate a new Stricli application", | ||
@@ -59,4 +59,4 @@ "license": "Apache-2.0", | ||
| "dependencies": { | ||
| "@stricli/auto-complete": "^1.1.0", | ||
| "@stricli/core": "^1.1.0" | ||
| "@stricli/auto-complete": "^1.1.1", | ||
| "@stricli/core": "^1.1.1" | ||
| }, | ||
@@ -63,0 +63,0 @@ "devDependencies": { |
| var i={name:"@stricli/create-app",version:"1.1.0",description:"Generate a new Stricli application",license:"Apache-2.0",repository:{type:"git",url:"https://github.com/bloomberg/stricli/tree/main/packages/create-app"},author:"Michael Molisani <mmolisani@bloomberg.net>",files:["dist"],type:"module",bin:{"create-app":"dist/cli.js"},engines:{node:">=18.x"},scripts:{format:"prettier --config ../../.prettierrc -w .","format:check":"prettier --config ../../.prettierrc -c .",lint:"eslint src","lint:fix":"eslint src tests --fix",typecheck:"tsc -p tsconfig.json --noEmit",test:"mocha","test:clear-baseline":"node scripts/clear_baseline","test:accept-baseline":"node scripts/accept_baseline",coverage:"c8 npm test",build:"tsup",prepublishOnly:"npm run build"},mocha:{import:"tsx/esm",spec:"tests/**/*.spec.ts"},c8:{reporter:["text","lcovonly"],"check-coverage":!0,"skip-full":!0},tsup:{entry:["src/bin/cli.ts"],format:["esm"],tsconfig:"src/tsconfig.json",clean:!0,splitting:!0,minify:!0},dependencies:{"@stricli/auto-complete":"^1.1.0","@stricli/core":"^1.1.0"},devDependencies:{"@types/chai":"^4.3.16","@types/mocha":"^10.0.6","@types/node":"^18.19.33","@types/sinon":"^17.0.3","@typescript-eslint/eslint-plugin":"^8.2.0","@typescript-eslint/parser":"^8.2.0",c8:"^9.1.0",chai:"^5.1.1",eslint:"^8.57.0","eslint-plugin-prettier":"^5.1.3","fs-extra":"^11.2.0",memfs:"^4.9.2",mocha:"^10.4.0",prettier:"^3.2.5",sinon:"^18.0.0",tsup:"^6.7.0",tsx:"^4.8.2","type-fest":"^3.5.4",typescript:"5.6.x"}};export{i as a}; |
| import{a as c}from"./chunk-KM6MPGDF.js";var b=`# Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| lerna-debug.log* | ||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
| # Coverage directory used by tools like istanbul | ||
| coverage | ||
| *.lcov | ||
| # nyc test coverage | ||
| .nyc_output | ||
| # Dependency directories | ||
| node_modules/ | ||
| jspm_packages/ | ||
| *.tsbuildinfo | ||
| dist | ||
| `,C=`import type { CommandContext } from "@stricli/core"; | ||
| export interface LocalContext extends CommandContext { | ||
| readonly process: NodeJS.Process; | ||
| // ... | ||
| } | ||
| export function buildContext(process: NodeJS.Process): LocalContext { | ||
| return { | ||
| process, | ||
| }; | ||
| } | ||
| `,x=`import type { CommandContext } from "@stricli/core"; | ||
| import type { StricliAutoCompleteContext } from "@stricli/auto-complete"; | ||
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
| export interface LocalContext extends CommandContext, StricliAutoCompleteContext { | ||
| readonly process: NodeJS.Process; | ||
| // ... | ||
| } | ||
| export function buildContext(process: NodeJS.Process): LocalContext { | ||
| return { | ||
| process, | ||
| os, | ||
| fs, | ||
| path, | ||
| }; | ||
| } | ||
| `,g=`import type { LocalContext } from "./context"; | ||
| interface CommandFlags { | ||
| readonly count: number; | ||
| } | ||
| export default async function(this: LocalContext, flags: CommandFlags, name: string): Promise<void> { | ||
| this.process.stdout.write(\`Hello \${name}!\\n\`.repeat(flags.count)); | ||
| } | ||
| `,y=`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, | ||
| }, | ||
| ], | ||
| }, | ||
| flags: { | ||
| count: { | ||
| kind: "parsed", | ||
| brief: "Number of times to say hello", | ||
| parse: numberParser, | ||
| }, | ||
| }, | ||
| }, | ||
| docs: { | ||
| brief: description, | ||
| }, | ||
| }); | ||
| export const app = buildApplication(command, { | ||
| name, | ||
| versionInfo: { | ||
| currentVersion: version, | ||
| }, | ||
| }); | ||
| `,v=`import type { LocalContext } from "../../context"; | ||
| interface SubdirCommandFlags { | ||
| // ... | ||
| } | ||
| export default async function(this: LocalContext, flags: SubdirCommandFlags): Promise<void> { | ||
| // ... | ||
| } | ||
| `,h=`import { buildCommand } from "@stricli/core"; | ||
| export const subdirCommand = buildCommand({ | ||
| loader: async () => import("./impl"), | ||
| parameters: { | ||
| positional: { | ||
| kind: "tuple", | ||
| parameters: [], | ||
| }, | ||
| }, | ||
| docs: { | ||
| brief: "Command in subdirectory", | ||
| }, | ||
| }); | ||
| `,P=`import type { LocalContext } from "../../context"; | ||
| interface FooCommandFlags { | ||
| // ... | ||
| } | ||
| export async function foo(this: LocalContext, flags: FooCommandFlags): Promise<void> { | ||
| // ... | ||
| } | ||
| interface BarCommandFlags { | ||
| // ... | ||
| } | ||
| export async function bar(this: LocalContext, flags: BarCommandFlags): Promise<void> { | ||
| // ... | ||
| } | ||
| `,T=`import { buildCommand, buildRouteMap } from "@stricli/core"; | ||
| export const fooCommand = buildCommand({ | ||
| loader: async () => { | ||
| const { foo } = await import("./impl"); | ||
| return foo; | ||
| }, | ||
| parameters: { | ||
| positional: { | ||
| kind: "tuple", | ||
| parameters: [], | ||
| }, | ||
| }, | ||
| docs: { | ||
| brief: "Nested foo command", | ||
| }, | ||
| }); | ||
| export const barCommand = buildCommand({ | ||
| loader: async () => { | ||
| const { bar } = await import("./impl"); | ||
| return bar; | ||
| }, | ||
| parameters: { | ||
| positional: { | ||
| kind: "tuple", | ||
| parameters: [], | ||
| }, | ||
| }, | ||
| docs: { | ||
| brief: "Nested bar command", | ||
| }, | ||
| }); | ||
| export const nestedRoutes = buildRouteMap({ | ||
| routes: { | ||
| foo: fooCommand, | ||
| bar: barCommand, | ||
| }, | ||
| docs: { | ||
| brief: "Nested commands", | ||
| }, | ||
| }); | ||
| `,w=`import { buildApplication, buildRouteMap } from "@stricli/core"; | ||
| import { name, version, description } from "../package.json"; | ||
| import { subdirCommand } from "./commands/subdir/command"; | ||
| import { nestedRoutes } from "./commands/nested/commands"; | ||
| const routes = buildRouteMap({ | ||
| routes: { | ||
| subdir: subdirCommand, | ||
| nested: nestedRoutes, | ||
| }, | ||
| docs: { | ||
| brief: description, | ||
| }, | ||
| }); | ||
| export const app = buildApplication(routes, { | ||
| name, | ||
| versionInfo: { | ||
| currentVersion: version, | ||
| }, | ||
| }); | ||
| `;function N(e,t){return`import { buildApplication, buildRouteMap } from "@stricli/core"; | ||
| import { buildInstallCommand, buildUninstallCommand } from "@stricli/auto-complete"; | ||
| import { name, version, description } from "../package.json"; | ||
| import { subdirCommand } from "./commands/subdir/command"; | ||
| import { nestedRoutes } from "./commands/nested/commands"; | ||
| const routes = buildRouteMap({ | ||
| routes: { | ||
| subdir: subdirCommand, | ||
| nested: nestedRoutes, | ||
| install: buildInstallCommand("${e}", { bash: "${t}" }), | ||
| uninstall: buildUninstallCommand("${e}", { bash: true }), | ||
| }, | ||
| docs: { | ||
| brief: description, | ||
| hideRoute: { | ||
| install: true, | ||
| uninstall: true, | ||
| }, | ||
| }, | ||
| }); | ||
| export const app = buildApplication(routes, { | ||
| name, | ||
| versionInfo: { | ||
| currentVersion: version, | ||
| }, | ||
| }); | ||
| `}var k=`#!/usr/bin/env node | ||
| import { run } from "@stricli/core"; | ||
| import { buildContext } from "../context"; | ||
| import { app } from "../app"; | ||
| await run(app, process.argv.slice(2), buildContext(process)); | ||
| `,S=`#!/usr/bin/env node | ||
| import { run } from "@stricli/core"; | ||
| import { buildContext } from "../context"; | ||
| import { app } from "../app"; | ||
| void run(app, process.argv.slice(2), buildContext(process)); | ||
| `,j=`#!/usr/bin/env node | ||
| import { proposeCompletions } from "@stricli/core"; | ||
| import { buildContext } from "../context"; | ||
| import { app } from "../app"; | ||
| const inputs = process.argv.slice(3); | ||
| if (process.env["COMP_LINE"]?.endsWith(" ")) { | ||
| 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 | ||
| } | ||
| `,A=`#!/usr/bin/env node | ||
| import { proposeCompletions } from "@stricli/core"; | ||
| import { buildContext } from "../context"; | ||
| import { app } from "../app"; | ||
| const inputs = process.argv.slice(3); | ||
| if (process.env["COMP_LINE"]?.endsWith(" ")) { | ||
| inputs.push(""); | ||
| } | ||
| void proposeCompletions(app, inputs, buildContext(process)).then((completions) => { | ||
| for (const { completion } of completions) { | ||
| process.stdout.write(\`\${completion}\\n\`); | ||
| } | ||
| }, () => { | ||
| // ignore | ||
| }); | ||
| `;import V from"node:child_process";function J(e){if(e.env.NPM_CONFIG_REGISTRY)return e.env.NPM_CONFIG_REGISTRY;if(e.env.NPM_EXECPATH)return V.execFileSync(e.execPath,[e.env.NPM_EXECPATH,"config","get","registry"],{encoding:"utf-8"}).trim()}async function M(e,t){let n=e+(e.endsWith("/")?t:`/${t}`),o=await(await fetch(n)).json();if(typeof o=="object"&&o&&"versions"in o&&typeof o.versions=="object")return Object.keys(o.versions??{})}var _=22;async function R(e){let t=Number(e.versions.node.split(".")[0]),n;if(t>_){let i=J(e),o=i&&await M(i,"@types/node");if(o?.includes(e.versions.node))n=`^${e.versions.node}`;else if(o){let s=new Set(o.map(r=>Number(r.split(".")[0])));if(s.has(t))n=`${t}.x`;else{let r=[...s].filter(a=>a%2===0).toSorted().at(-1);r&&(n=`${r}.x`,e.stderr.write(`No version of @types/node found with major ${t}, falling back to ${n} | ||
| `),e.stderr.write("Rerun this command with the hidden flag --node-version to manually specify the Node.js major version"))}}}else n=`${t}.x`;return n||(n=`${t}.x`,e.stderr.write(`Unable to determine version of @types/node for ${e.versions.node}, assuming ${n} | ||
| `),e.stderr.write("Rerun this command with the hidden flag --node-version to manually specify the Node.js major version")),{engine:`>=${t}`,types:n}}var p={compilerOptions:{noEmit:!0,rootDir:"..",types:["node"],resolveJsonModule:!0,target:"esnext",module:"esnext",moduleResolution:"bundler",lib:["esnext"],skipLibCheck:!0,strict:!0,isolatedModules:!0,forceConsistentCasingInFileNames:!0,noImplicitOverride:!0,noPropertyAccessFromIndexSignature:!0,noUncheckedIndexedAccess:!0,verbatimModuleSyntax:!0},exclude:[],include:["**/*"]};function O(e){return`__${e}_bash_complete`}function E(e,t,n){return{...e,version:"0.0.0",files:["dist"],bin:{[t]:"dist/cli.js"},engines:{node:n.engine},scripts:{prebuild:"tsc -p src/tsconfig.json",build:"tsup",prepublishOnly:"npm run build"},tsup:{entry:["src/bin/cli.ts"],format:[e.type==="commonjs"?"cjs":"esm"],tsconfig:"src/tsconfig.json",clean:!0,splitting:!0,minify:!0},dependencies:{"@stricli/core":c.dependencies["@stricli/core"]},devDependencies:{"@types/node":n.types,tsup:c.devDependencies.tsup,typescript:c.devDependencies.typescript}}}function B(e,t){return{...e,dependencies:{...e.dependencies,"@stricli/auto-complete":c.dependencies["@stricli/auto-complete"]},bin:{...e.bin,[t]:"dist/bash-complete.js"},tsup:{...e.tsup,entry:[...e.tsup?.entry??[],"src/bin/bash-complete.ts"]}}}function I(e,t){return{...e,scripts:{...e.scripts,postinstall:t}}}async function Q(e,t){let{fs:n,path:i}=this;await n.promises.mkdir(t,{recursive:!0});let o=async(u,f)=>{let $=i.join(t,u);await n.promises.writeFile($,f)},s=async u=>{let f=i.join(t,u);await n.promises.mkdir(f,{recursive:!0})};await s("src");let r=e.name??i.basename(t),a=e.command??r,d;e.nodeVersion?d={engine:`>=${e.nodeVersion}`,types:`${e.nodeVersion}.x`}:d=await R(this.process);let m=E({name:r,author:e.author,description:e.description,license:e.license,type:e.type},a,d),l=O(a);e.autoComplete?(m=B(m,l),e.template==="multi"?m=I(m,`${a} install`):m=I(m,`npx @stricli/auto-complete@latest install ${a} ${l}`),await o("src/context.ts",x)):await o("src/context.ts",C),await o("package.json",JSON.stringify(m,void 0,4)),await o(".gitignore",b);let L={compilerOptions:p.compilerOptions,include:p.include,exclude:p.exclude};await o("src/tsconfig.json",JSON.stringify(L,void 0,4)),e.template==="single"?(await o("src/impl.ts",g),await o("src/app.ts",y)):(await s("src/commands/subdir"),await o("src/commands/subdir/impl.ts",v),await o("src/commands/subdir/command.ts",h),await s("src/commands/nested"),await o("src/commands/nested/impl.ts",P),await o("src/commands/nested/commands.ts",T),e.autoComplete?await o("src/app.ts",N(a,l)):await o("src/app.ts",w)),await s("src/bin"),await o("src/bin/cli.ts",e.type==="module"?k:S),e.autoComplete&&await o("src/bin/bash-complete.ts",e.type==="module"?j:A)}export{Q as default}; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
16862
0.04%Updated