@kaynooo/cli-docker 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-docker",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.8.0",
5
5
  "description": "dc, dx, dlog and sf: docker compose on the stack found here, including one only its containers tell of, a compose service's shell, logs, restart, stop or rebuild, every service's health and recent errors in one call, and a Symfony console command picked and run.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "sf": "$npm_execpath src/sf-cli.ts"
38
38
  },
39
39
  "devDependencies": {
40
- "@kaynooo/cli-env": "0.10.0",
41
- "@kaynooo/cli-kit": "0.21.1"
40
+ "@kaynooo/cli-env": "0.12.0",
41
+ "@kaynooo/cli-kit": "0.26.0"
42
42
  }
43
43
  }
package/src/dc.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Labels, Stack } from './stack'
2
2
  import process from 'node:process'
3
- import { paint } from '@kaynooo/cli-kit'
3
+ import { isInteractive, paint } from '@kaynooo/cli-kit'
4
4
  import { nearestStack, recordedNearby, stackAt, stackOf } from './stack'
5
5
 
6
6
  // The words a compose command starts with, which never name a stack, so the containers are not listed to check.
@@ -39,7 +39,7 @@ export async function target(args: string[]): Promise<Target> {
39
39
  async function choose(recorded: Labels[]): Promise<Labels | undefined> {
40
40
  const picker = Bun.which('pick')
41
41
 
42
- if (picker === null || !process.stdin.isTTY)
42
+ if (picker === null || !isInteractive())
43
43
  return undefined
44
44
 
45
45
  const proc = Bun.spawn([picker, '--prompt', 'dc> '], { stdin: new Blob([recorded.map(stack => stack.project).join('\n')]), stdout: 'pipe', stderr: 'inherit' })
package/src/dx.ts CHANGED
@@ -3,7 +3,7 @@ import type { Action, Service } from './stack'
3
3
  import process from 'node:process'
4
4
  import { loadKnown } from '@kaynooo/cli-env/files'
5
5
  import { Redactor } from '@kaynooo/cli-env/redactor'
6
- import { closest, fail, jsonOption, paint, parse, printJson, wholeNumber } from '@kaynooo/cli-kit'
6
+ import { closest, fail, isInteractive, jsonOption, paint, parse, printJson, wholeNumber } from '@kaynooo/cli-kit'
7
7
  import { byRecency, record, runs } from '@kaynooo/cli-kit/picker'
8
8
  import { KEY_LABELS, KEYS, pickService } from './picker'
9
9
  import { ACTIONS, allServices, commandFor, defaultAction, key, LOGS_TAIL, logsOf, serviceNamed, stateColor } from './stack'
@@ -139,7 +139,7 @@ export async function dx(args: string[]): Promise<number> {
139
139
  let action: Action | undefined
140
140
 
141
141
  if (named === undefined) {
142
- const interactive = process.stdin.isTTY && process.stderr.isTTY && parsed.values.json !== true
142
+ const interactive = isInteractive() && parsed.values.json !== true
143
143
 
144
144
  if (!interactive) {
145
145
  if (emit)
package/src/sf.ts CHANGED
@@ -4,7 +4,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
4
4
  import { homedir } from 'node:os'
5
5
  import { dirname, join, resolve } from 'node:path'
6
6
  import process from 'node:process'
7
- import { fail, paint, parse, printJson } from '@kaynooo/cli-kit'
7
+ import { fail, isInteractive, paint, parse, printJson } from '@kaynooo/cli-kit'
8
8
  import { byRecency, emit, list, pick, record, runs, table } from '@kaynooo/cli-kit/picker'
9
9
  import { input } from '@kaynooo/cli-kit/prompt'
10
10
  import { children, from, nearestStack, services, up } from './stack'
@@ -234,7 +234,7 @@ export async function answered(command: Arg[], ask: (name: string) => Promise<st
234
234
  }
235
235
 
236
236
  function interactive(): boolean {
237
- return process.stdin.isTTY && process.stderr.isTTY
237
+ return isInteractive()
238
238
  }
239
239
 
240
240
  /** What `--emit` prints for tmux, or, standalone, the command run once its prompts are answered. */
package/src/stack.ts CHANGED
@@ -3,7 +3,7 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs'
3
3
  import { dirname, join, relative, resolve } from 'node:path'
4
4
  import { loadKnown } from '@kaynooo/cli-env/files'
5
5
  import { Redactor } from '@kaynooo/cli-env/redactor'
6
- import { captureOutput, composeError } from '@kaynooo/cli-kit'
6
+ import { captureOutput, composeError, SKIPPED_FOLDERS } from '@kaynooo/cli-kit'
7
7
 
8
8
  /** How to reach one compose project: the command a user runs, and the one this package lists it with. */
9
9
  export interface Stack {
@@ -54,7 +54,6 @@ export interface Container {
54
54
  const LABEL_FORMAT = ['project', 'project.config_files', 'project.environment_file', 'project.working_dir'].map(label => `{{.Label "com.docker.compose.${label}"}}`).join('\t')
55
55
  const COMPOSE_FILE_VAR = /^\s*(?:export\s+)?COMPOSE_FILE\s*=\s*\S/m
56
56
  const COMPOSE_FILES = ['compose.yaml', 'compose.yml', 'docker-compose.yaml', 'docker-compose.yml']
57
- const SKIPPED = new Set(['node_modules', 'vendor', 'dist', 'build', 'target', 'venv', '__pycache__'])
58
57
 
59
58
  export const ACTIONS: Action[] = ['shell', 'logs', 'restart', 'up', 'stop', 'build']
60
59
 
@@ -66,7 +65,7 @@ export function from(dir: string, command: string[]): string[] {
66
65
  /** The direct child folders, hidden and built ones aside. */
67
66
  export function children(dir = '.'): string[] {
68
67
  return readdirSync(dir, { withFileTypes: true })
69
- .filter(child => child.isDirectory() && !child.name.startsWith('.') && !SKIPPED.has(child.name))
68
+ .filter(child => child.isDirectory() && !child.name.startsWith('.') && !SKIPPED_FOLDERS.has(child.name))
70
69
  .map(child => child.name)
71
70
  .sort()
72
71
  }