From 92ba4dee07a1c2e3f901b322bee0de4117642d55 Mon Sep 17 00:00:00 2001 From: kirillgroshkov Date: Sun, 13 Aug 2023 21:26:11 +0200 Subject: [PATCH] feat: export `fs2` module Also, remove all `index.ts` files except root, re-export all from root, no more deep-imports. --- scripts/backpressureSimulation.script.ts | 2 +- scripts/colors.script.ts | 4 +- scripts/ndjsonForEach.script.ts | 2 +- scripts/ndjsonMap.script.ts | 2 +- src/bin/del.ts | 2 +- src/bin/generate-build-info.ts | 4 +- src/bin/json2env.ts | 4 +- src/bin/kpy.ts | 2 +- src/bin/secrets-decrypt.ts | 4 +- src/bin/secrets-encrypt.ts | 4 +- src/bin/secrets-gen-key.ts | 4 +- src/bin/slack-this.ts | 2 +- src/colors/colors.test.ts | 3 +- src/colors/colors.ts | 35 +++++++++ src/colors/index.ts | 35 --------- src/fs/del.ts | 2 +- src/fs/fs.test.ts | 2 +- src/fs/fs.util.test.ts | 6 ++ src/fs/fs.util.ts | 83 +++++++++++++------- src/fs/index.ts | 3 - src/fs/json2env.ts | 19 ++++- src/fs/kpy.ts | 2 +- src/index.ts | 5 +- src/leak.test.ts | 4 +- src/script/runScript.test.ts | 2 +- src/script/{index.ts => runScript.ts} | 0 src/secret/secrets-decrypt.util.ts | 2 +- src/secret/secrets-encrypt.util.ts | 2 +- src/stream/ndjson/ndjson.model.ts | 2 +- src/stream/ndjson/pipelineFromNDJsonFile.ts | 2 +- src/stream/ndjson/pipelineToNDJsonFile.ts | 2 +- src/stream/sizeStack.ts | 2 +- src/stream/transform/transformLogProgress.ts | 3 +- src/stream/transform/transformMap.ts | 2 +- src/stream/transform/transformMapSync.ts | 2 +- src/util/git.util.ts | 2 +- 36 files changed, 148 insertions(+), 110 deletions(-) delete mode 100644 src/colors/index.ts delete mode 100644 src/fs/index.ts rename src/script/{index.ts => runScript.ts} (100%) diff --git a/scripts/backpressureSimulation.script.ts b/scripts/backpressureSimulation.script.ts index 915fe1de..40f1d107 100644 --- a/scripts/backpressureSimulation.script.ts +++ b/scripts/backpressureSimulation.script.ts @@ -6,7 +6,7 @@ yarn tsn backpressureSimulation.script.ts import { pDelay, _range } from '@naturalcycles/js-lib' import { Debug, readableFromArray, transformLogProgress, writableForEach, _pipeline } from '../src' -import { runScript } from '../src/script' +import { runScript } from '../src/script/runScript' Debug.enable('*') diff --git a/scripts/colors.script.ts b/scripts/colors.script.ts index 55ec107c..6fd1f53c 100644 --- a/scripts/colors.script.ts +++ b/scripts/colors.script.ts @@ -5,8 +5,8 @@ yarn tsn colors.script.ts */ import { Color, Modifiers } from 'chalk' -import { chalk } from '../src/colors' -import { runScript } from '../src/script' +import { chalk } from '../src/colors/colors' +import { runScript } from '../src/script/runScript' const s = 'Hello World! 1 2 3 4 5ms' diff --git a/scripts/ndjsonForEach.script.ts b/scripts/ndjsonForEach.script.ts index a5f82583..4c3edd90 100644 --- a/scripts/ndjsonForEach.script.ts +++ b/scripts/ndjsonForEach.script.ts @@ -5,7 +5,7 @@ yarn tsn ndjsonForEach.script */ import { ndjsonStreamForEach } from '../src' -import { runScript } from '../src/script' +import { runScript } from '../src/script/runScript' import { tmpDir } from '../src/test/paths.cnst' runScript(async () => { diff --git a/scripts/ndjsonMap.script.ts b/scripts/ndjsonMap.script.ts index 2a92b13b..c521e61a 100644 --- a/scripts/ndjsonMap.script.ts +++ b/scripts/ndjsonMap.script.ts @@ -8,7 +8,7 @@ import { createWriteStream } from 'node:fs' import * as fs from 'node:fs' import { _range } from '@naturalcycles/js-lib' import { readableFromArray, transformToNDJson, _pipeline } from '../src' -import { runScript } from '../src/script' +import { runScript } from '../src/script/runScript' import { ndjsonMap } from '../src' import { tmpDir } from '../src/test/paths.cnst' diff --git a/src/bin/del.ts b/src/bin/del.ts index c0f57571..14d65dde 100644 --- a/src/bin/del.ts +++ b/src/bin/del.ts @@ -2,7 +2,7 @@ import * as yargs from 'yargs' import { delSync } from '../fs/del' -import { runScript } from '../script' +import { runScript } from '../script/runScript' runScript(async () => { const { _: patterns, ...opt } = yargs.demandCommand(1).options({ diff --git a/src/bin/generate-build-info.ts b/src/bin/generate-build-info.ts index 848d82fd..49cca511 100755 --- a/src/bin/generate-build-info.ts +++ b/src/bin/generate-build-info.ts @@ -3,8 +3,8 @@ import * as fs from 'node:fs' import * as path from 'node:path' import * as yargs from 'yargs' -import { appendToBashEnv, appendToGithubEnv, appendToGithubOutput } from '../fs' -import { runScript } from '../script' +import { appendToBashEnv, appendToGithubEnv, appendToGithubOutput } from '../fs/json2env' +import { runScript } from '../script/runScript' import { generateBuildInfo } from '../util/buildInfo.util' runScript(async () => { diff --git a/src/bin/json2env.ts b/src/bin/json2env.ts index bee3a966..47559726 100755 --- a/src/bin/json2env.ts +++ b/src/bin/json2env.ts @@ -1,8 +1,8 @@ #!/usr/bin/env node import * as yargs from 'yargs' -import { json2env } from '../fs' -import { runScript } from '../script' +import { json2env } from '../fs/json2env' +import { runScript } from '../script/runScript' runScript(() => { const { argv } = yargs.demandCommand(1).options({ diff --git a/src/bin/kpy.ts b/src/bin/kpy.ts index d6fa917d..e3beffc7 100644 --- a/src/bin/kpy.ts +++ b/src/bin/kpy.ts @@ -2,7 +2,7 @@ import * as yargs from 'yargs' import { kpySync } from '../fs/kpy' -import { runScript } from '../script' +import { runScript } from '../script/runScript' runScript(() => { const { diff --git a/src/bin/secrets-decrypt.ts b/src/bin/secrets-decrypt.ts index 45d555ac..340462fa 100644 --- a/src/bin/secrets-decrypt.ts +++ b/src/bin/secrets-decrypt.ts @@ -1,8 +1,8 @@ #!/usr/bin/env node import * as yargs from 'yargs' -import { dimGrey } from '../colors' -import { runScript } from '../script' +import { dimGrey } from '../colors/colors' +import { runScript } from '../script/runScript' import { DecryptCLIOptions, secretsDecrypt } from '../secret/secrets-decrypt.util' runScript(() => { diff --git a/src/bin/secrets-encrypt.ts b/src/bin/secrets-encrypt.ts index 053a7c01..949557e7 100644 --- a/src/bin/secrets-encrypt.ts +++ b/src/bin/secrets-encrypt.ts @@ -1,8 +1,8 @@ #!/usr/bin/env node import * as yargs from 'yargs' -import { dimGrey } from '../colors' -import { runScript } from '../script' +import { dimGrey } from '../colors/colors' +import { runScript } from '../script/runScript' import { EncryptCLIOptions, secretsEncrypt } from '../secret/secrets-encrypt.util' runScript(() => { diff --git a/src/bin/secrets-gen-key.ts b/src/bin/secrets-gen-key.ts index 242dfd0a..6966549c 100644 --- a/src/bin/secrets-gen-key.ts +++ b/src/bin/secrets-gen-key.ts @@ -2,8 +2,8 @@ import * as crypto from 'node:crypto' import * as yargs from 'yargs' -import { dimGrey } from '../colors' -import { runScript } from '../script' +import { dimGrey } from '../colors/colors' +import { runScript } from '../script/runScript' runScript(() => { const { sizeBytes } = yargs.option('sizeBytes', { diff --git a/src/bin/slack-this.ts b/src/bin/slack-this.ts index da6fc9a7..7664223c 100644 --- a/src/bin/slack-this.ts +++ b/src/bin/slack-this.ts @@ -2,7 +2,7 @@ import * as yargs from 'yargs' import { SlackService } from '..' -import { runScript } from '../script' +import { runScript } from '../script/runScript' runScript(async () => { const { diff --git a/src/colors/colors.test.ts b/src/colors/colors.test.ts index 83873099..0736a5b0 100644 --- a/src/colors/colors.test.ts +++ b/src/colors/colors.test.ts @@ -1,5 +1,4 @@ -import { hasColors } from './colors' -import { grey } from '.' +import { hasColors, grey } from './colors' test('colors', () => { console.log(grey('sdf')) diff --git a/src/colors/colors.ts b/src/colors/colors.ts index 14cb2362..4473d16a 100644 --- a/src/colors/colors.ts +++ b/src/colors/colors.ts @@ -1,4 +1,7 @@ import * as tty from 'node:tty' +import * as chalk from 'chalk' + +export { chalk } /** * Based on: https://github.com/sindresorhus/yoctocolors/pull/5 @@ -6,3 +9,35 @@ import * as tty from 'node:tty' * @experimental */ export const hasColors = !process.env['NO_COLOR'] && tty.WriteStream.prototype.hasColors() + +// The point of re-exporting is: +// 1. Fix typings to allow to pass `number` (very common case) +// 2. Easier/shorter to import, rather than from 'chalk' +// export type ColorFn = (...args: (string | number)[]) => string + +export const white = chalk.white +export const dimWhite = chalk.dim.white +export const boldWhite = chalk.bold.white +export const inverseWhite = chalk.inverse.white +export const grey = chalk.grey +export const dimGrey = chalk.dim.grey +export const boldGrey = chalk.bold.grey +export const yellow = chalk.yellow +export const dimYellow = chalk.dim.yellow +export const boldYellow = chalk.bold.yellow +export const inverseYellow = chalk.inverse.yellow +export const green = chalk.green +export const dimGreen = chalk.dim.green +export const boldGreen = chalk.bold.green +export const red = chalk.red +export const dimRed = chalk.dim.red +export const boldRed = chalk.bold.red +export const blue = chalk.blue +export const dimBlue = chalk.dim.blue +export const boldBlue = chalk.bold.blue +export const magenta = chalk.magenta +export const dimMagenta = chalk.dim.magenta +export const boldMagenta = chalk.bold.magenta +export const cyan = chalk.cyan +export const dimCyan = chalk.dim.cyan +export const boldCyan = chalk.bold.cyan diff --git a/src/colors/index.ts b/src/colors/index.ts deleted file mode 100644 index f1fb6d58..00000000 --- a/src/colors/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -import * as chalk from 'chalk' - -export { chalk } - -// The point of re-exporting is: -// 1. Fix typings to allow to pass `number` (very common case) -// 2. Easier/shorter to import, rather than from 'chalk' -// export type ColorFn = (...args: (string | number)[]) => string - -export const white = chalk.white -export const dimWhite = chalk.dim.white -export const boldWhite = chalk.bold.white -export const inverseWhite = chalk.inverse.white -export const grey = chalk.grey -export const dimGrey = chalk.dim.grey -export const boldGrey = chalk.bold.grey -export const yellow = chalk.yellow -export const dimYellow = chalk.dim.yellow -export const boldYellow = chalk.bold.yellow -export const inverseYellow = chalk.inverse.yellow -export const green = chalk.green -export const dimGreen = chalk.dim.green -export const boldGreen = chalk.bold.green -export const red = chalk.red -export const dimRed = chalk.dim.red -export const boldRed = chalk.bold.red -export const blue = chalk.blue -export const dimBlue = chalk.dim.blue -export const boldBlue = chalk.bold.blue -export const magenta = chalk.magenta -export const dimMagenta = chalk.dim.magenta -export const boldMagenta = chalk.bold.magenta -export const cyan = chalk.cyan -export const dimCyan = chalk.dim.cyan -export const boldCyan = chalk.bold.cyan diff --git a/src/fs/del.ts b/src/fs/del.ts index 19ed2c07..eb6dffea 100644 --- a/src/fs/del.ts +++ b/src/fs/del.ts @@ -1,7 +1,7 @@ import * as fs from 'node:fs' import * as fsp from 'node:fs/promises' import { pFilter, pMap, _since } from '@naturalcycles/js-lib' -import { dimGrey, yellow } from '../colors' +import { dimGrey, yellow } from '../colors/colors' import { _pathExists, _pathExistsSync, globby } from '../index' export interface DelOptions { diff --git a/src/fs/fs.test.ts b/src/fs/fs.test.ts index 552f3f5a..db4e3931 100644 --- a/src/fs/fs.test.ts +++ b/src/fs/fs.test.ts @@ -1,7 +1,7 @@ import * as fs from 'node:fs' import * as fsp from 'node:fs/promises' import { projectDir, scriptsDir, tmpDir } from '../test/paths.cnst' -import { json2env, kpy, kpySync } from './index' +import { json2env, kpy, kpySync } from '../' beforeEach(() => { jest.spyOn(fs, 'writeFileSync').mockImplementation() diff --git a/src/fs/fs.util.test.ts b/src/fs/fs.util.test.ts index 2cf21f8a..6a6bc7dd 100644 --- a/src/fs/fs.util.test.ts +++ b/src/fs/fs.util.test.ts @@ -1,3 +1,4 @@ +import * as fs from 'node:fs' import { testDir } from '../test/paths.cnst' import { _ensureDir, @@ -10,6 +11,7 @@ import { _readFileSync, _readJson, _readJsonSync, + fs2, } from './fs.util' test('readFile', async () => { @@ -43,3 +45,7 @@ test('readFile', async () => { _ensureFileSync(someFilePath) await _ensureFile(someFilePath) }) + +test('extends native fs', () => { + expect(fs2.createWriteStream).toBe(fs.createWriteStream) +}) diff --git a/src/fs/fs.util.ts b/src/fs/fs.util.ts index 3ddb5f47..8675696c 100644 --- a/src/fs/fs.util.ts +++ b/src/fs/fs.util.ts @@ -19,6 +19,48 @@ import * as fsp from 'node:fs/promises' import * as path from 'node:path' import { _jsonParse } from '@naturalcycles/js-lib' +/** + * fs2 conveniently groups filesystem functions together. + * Supposed to be almost a drop-in replacement for these things together: + * + * 1. node:fs + * 2. node:fs/promises + * 3. fs-extra + */ +export const fs2 = { + // "Omit" is here to workaround this TS error: + // Exported variable 'fs2' has or is using name 'StreamOptions' from external module "fs" but cannot be named. + ...(fs as Omit), + readFile: _readFile, + readFileSync: _readFileSync, + readFileAsBuffer: _readFileAsBuffer, + readFileAsBufferSync: _readFileAsBufferSync, + readJson: _readJson, + readJsonSync: _readJsonSync, + writeFile: _writeFile, + writeFileSync: _writeFileSync, + outputJson: _outputJson, + outputJsonSync: _outputJsonSync, + writeJson: _writeJson, + writeJsonSync: _writeJsonSync, + outputFile: _outputFile, + outputFileSync: _outputFileSync, + pathExists: _pathExists, + pathExistsSync: _pathExistsSync, + ensureDir: _ensureDir, + ensureDirSync: _ensureDirSync, + ensureFile: _ensureFile, + ensureFileSync: _ensureFileSync, + removePath: _removePath, + removePathSync: _removePathSync, + emptyDir: _emptyDir, + emptyDirSync: _emptyDirSync, + copyPath: _copyPath, + copyPathSync: _copyPathSync, + movePath: _movePath, + movePathSync: _movePathSync, +} + export interface JsonOptions { spaces?: number } @@ -30,6 +72,10 @@ export async function _readFile(filePath: string): Promise { return await fsp.readFile(filePath, 'utf8') } +export async function _readFileAsBuffer(filePath: string): Promise { + return await fsp.readFile(filePath) +} + /** * Convenience wrapper that defaults to utf-8 string output. */ @@ -37,26 +83,23 @@ export function _readFileSync(filePath: string): string { return fs.readFileSync(filePath, 'utf8') } +/** + * Convenience wrapper that defaults to utf-8 string output. + */ +export function _readFileAsBufferSync(filePath: string): Buffer { + return fs.readFileSync(filePath) +} + export async function _readJson(filePath: string): Promise { const str = await fsp.readFile(filePath, 'utf8') return _jsonParse(str) } -/** - * @deprecated use _readJson - */ -export const _readJsonFile = _readJson - export function _readJsonSync(filePath: string): T { const str = fs.readFileSync(filePath, 'utf8') return _jsonParse(str) } -/** - * @deprecated use _readJsonSync - */ -export const _readJsonFileSync = _readJsonSync - export async function _writeFile(filePath: string, data: string | Buffer): Promise { await fsp.writeFile(filePath, data) } @@ -88,41 +131,21 @@ export async function _writeJson(filePath: string, data: any, opt?: JsonOptions) await fsp.writeFile(filePath, str) } -/** - * @deprecated use _writeJson - */ -export const _writeJsonFile = _writeJson - export function _writeJsonSync(filePath: string, data: any, opt?: JsonOptions): void { const str = JSON.stringify(data, null, opt?.spaces) fs.writeFileSync(filePath, str) } -/** - * @deprecated use _writeJsonSync - */ -export const _writeJsonFileSync = _writeJsonSync - export async function _outputJson(filePath: string, data: any, opt?: JsonOptions): Promise { const str = JSON.stringify(data, null, opt?.spaces) await _outputFile(filePath, str) } -/** - * @deprecated use _outputJson - */ -export const _outputJsonFile = _outputJson - export function _outputJsonSync(filePath: string, data: any, opt?: JsonOptions): void { const str = JSON.stringify(data, null, opt?.spaces) _outputFileSync(filePath, str) } -/** - * @deprecated use _outputJsonSync - */ -export const _outputJsonFileSync = _outputJsonSync - export async function _pathExists(filePath: string): Promise { try { await fsp.access(filePath) diff --git a/src/fs/index.ts b/src/fs/index.ts deleted file mode 100644 index 439fede5..00000000 --- a/src/fs/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './del' -export * from './json2env' -export * from './kpy' diff --git a/src/fs/json2env.ts b/src/fs/json2env.ts index 202afccd..f529c7b9 100644 --- a/src/fs/json2env.ts +++ b/src/fs/json2env.ts @@ -1,6 +1,6 @@ import * as fs from 'node:fs' import { AnyObject } from '@naturalcycles/js-lib' -import { dimGrey } from '../colors' +import { dimGrey } from '../colors/colors' import { _pathExistsSync, _readJsonSync, _writeFileSync } from './fs.util' export interface Json2EnvOptions { @@ -95,7 +95,7 @@ export function appendToBashEnv(obj: AnyObject, prefix = ''): void { if (BASH_ENV) { const data = objectToShellExport(obj, prefix) fs.appendFileSync(BASH_ENV, data) - console.log(`BASH_ENV file appended (${dimGrey(BASH_ENV)})\n${data}`) + console.log(`BASH_ENV appended:\n${data}`) } } @@ -104,7 +104,7 @@ export function appendToGithubEnv(obj: AnyObject, prefix = ''): void { if (GITHUB_ENV) { const data = objectToGithubActionsEnv(obj, prefix) fs.appendFileSync(GITHUB_ENV, data) - console.log(`GITHUB_ENV file appended (${dimGrey(GITHUB_ENV)})\n${data}`) + console.log(`GITHUB_ENV appended:\n${data}`) } } @@ -113,7 +113,18 @@ export function appendToGithubOutput(obj: AnyObject, prefix = ''): void { if (GITHUB_OUTPUT) { const data = objectToGithubActionsEnv(obj, prefix) fs.appendFileSync(GITHUB_OUTPUT, data) - console.log(`GITHUB_OUTPUT file appended (${dimGrey(GITHUB_OUTPUT)})\n${data}`) + console.log(`GITHUB_OUTPUT appended:\n${data}`) + } +} + +/** + * https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary + */ +export function appendToGithubSummary(str: string): void { + const { GITHUB_STEP_SUMMARY } = process.env + if (GITHUB_STEP_SUMMARY) { + fs.appendFileSync(GITHUB_STEP_SUMMARY, str + '\n') + console.log(`GITHUB_STEP_SUMMARY appended:\n${str}`) } } diff --git a/src/fs/kpy.ts b/src/fs/kpy.ts index 0e12594f..2eef29e9 100644 --- a/src/fs/kpy.ts +++ b/src/fs/kpy.ts @@ -1,6 +1,6 @@ import * as path from 'node:path' import { _since } from '@naturalcycles/js-lib' -import { boldWhite, dimGrey, grey, yellow } from '../colors' +import { boldWhite, dimGrey, grey, yellow } from '../colors/colors' import { _copyPath, _copyPathSync, diff --git a/src/index.ts b/src/index.ts index 0d1ed920..6498ab64 100644 --- a/src/index.ts +++ b/src/index.ts @@ -88,9 +88,12 @@ export * from './validation/joi/joi.model' export * from './validation/joi/joi.shared.schemas' export * from './validation/joi/joi.validation.error' export * from './validation/joi/joi.validation.util' -export * from './script' +export * from './script/runScript' export * from './jwt/jwt.service' export * from './fs/fs.util' +export * from './fs/del' +export * from './fs/json2env' +export * from './fs/kpy' export type { GlobbyOptions, diff --git a/src/leak.test.ts b/src/leak.test.ts index 509559a0..75d3f90b 100644 --- a/src/leak.test.ts +++ b/src/leak.test.ts @@ -1,7 +1,7 @@ test('should not leak', () => { require('.') - require('./script') - require('./colors') + require('./script/runScript') + require('./colors/colors') }) export {} diff --git a/src/script/runScript.test.ts b/src/script/runScript.test.ts index 90c91467..503f3243 100644 --- a/src/script/runScript.test.ts +++ b/src/script/runScript.test.ts @@ -1,6 +1,6 @@ import { _stringifyAny, pDelay, setGlobalStringifyFunction } from '@naturalcycles/js-lib' import { inspectAnyStringifyFn } from '../string/inspectAny' -import { runScript } from '.' +import { runScript } from './runScript' const detectLeaks = process.argv.some(a => a.includes('detectLeaks')) diff --git a/src/script/index.ts b/src/script/runScript.ts similarity index 100% rename from src/script/index.ts rename to src/script/runScript.ts diff --git a/src/secret/secrets-decrypt.util.ts b/src/secret/secrets-decrypt.util.ts index fdac36e9..0531d7ac 100644 --- a/src/secret/secrets-decrypt.util.ts +++ b/src/secret/secrets-decrypt.util.ts @@ -1,7 +1,7 @@ import * as path from 'node:path' import * as fs from 'node:fs' import { _assert } from '@naturalcycles/js-lib' -import { dimGrey, yellow } from '../colors' +import { dimGrey, yellow } from '../colors/colors' import { _readJsonSync, _writeJsonSync, fastGlob } from '../index' import { decryptObject, decryptRandomIVBuffer } from '../security/crypto.util' diff --git a/src/secret/secrets-encrypt.util.ts b/src/secret/secrets-encrypt.util.ts index f236c0ef..75d9220f 100644 --- a/src/secret/secrets-encrypt.util.ts +++ b/src/secret/secrets-encrypt.util.ts @@ -1,7 +1,7 @@ import * as fs from 'node:fs' import * as path from 'node:path' import { _assert } from '@naturalcycles/js-lib' -import { dimGrey, yellow } from '../colors' +import { dimGrey, yellow } from '../colors/colors' import { _readJsonSync, _writeJsonSync, fastGlob } from '../index' import { encryptObject, encryptRandomIVBuffer } from '../security/crypto.util' diff --git a/src/stream/ndjson/ndjson.model.ts b/src/stream/ndjson/ndjson.model.ts index f65142d1..d740461e 100644 --- a/src/stream/ndjson/ndjson.model.ts +++ b/src/stream/ndjson/ndjson.model.ts @@ -1,5 +1,5 @@ import { _hb, _ms } from '@naturalcycles/js-lib' -import { boldWhite, dimWhite } from '../../colors' +import { boldWhite, dimWhite } from '../../colors/colors' export class NDJsonStats { static create(o: Partial = {}): NDJsonStats { diff --git a/src/stream/ndjson/pipelineFromNDJsonFile.ts b/src/stream/ndjson/pipelineFromNDJsonFile.ts index bc0350d6..f73d6c87 100644 --- a/src/stream/ndjson/pipelineFromNDJsonFile.ts +++ b/src/stream/ndjson/pipelineFromNDJsonFile.ts @@ -2,7 +2,7 @@ import { createUnzip, ZlibOptions } from 'node:zlib' import * as fs from 'node:fs' import { _hb } from '@naturalcycles/js-lib' import { transformTap, _pipeline, transformSplit } from '../..' -import { dimWhite, grey } from '../../colors' +import { dimWhite, grey } from '../../colors/colors' import { NDJsonStats } from './ndjson.model' import { transformJsonParse, TransformJsonParseOptions } from './transformJsonParse' diff --git a/src/stream/ndjson/pipelineToNDJsonFile.ts b/src/stream/ndjson/pipelineToNDJsonFile.ts index 4c17da56..4a801816 100644 --- a/src/stream/ndjson/pipelineToNDJsonFile.ts +++ b/src/stream/ndjson/pipelineToNDJsonFile.ts @@ -2,7 +2,7 @@ import { createGzip, ZlibOptions } from 'node:zlib' import * as fs from 'node:fs' import { AppError } from '@naturalcycles/js-lib' import { transformTap, _pipeline, _pathExistsSync, _ensureFileSync } from '../..' -import { grey } from '../../colors' +import { grey } from '../../colors/colors' import { NDJsonStats } from './ndjson.model' import { transformToNDJson, TransformToNDJsonOptions } from './transformToNDJson' diff --git a/src/stream/sizeStack.ts b/src/stream/sizeStack.ts index fd754c55..aac31b1c 100644 --- a/src/stream/sizeStack.ts +++ b/src/stream/sizeStack.ts @@ -1,5 +1,5 @@ import { _hb, CommonLogger, NumberStack } from '@naturalcycles/js-lib' -import { yellow } from '../colors' +import { yellow } from '../colors/colors' import { gzipBuffer } from '../util/zip.util' export class SizeStack extends NumberStack { diff --git a/src/stream/transform/transformLogProgress.ts b/src/stream/transform/transformLogProgress.ts index 9a6e7f5e..8eb0a656 100644 --- a/src/stream/transform/transformLogProgress.ts +++ b/src/stream/transform/transformLogProgress.ts @@ -8,8 +8,7 @@ import { CommonLogger, localTime, } from '@naturalcycles/js-lib' -import { boldWhite, dimGrey, white, yellow } from '../../colors' -import { hasColors } from '../../colors/colors' +import { hasColors, boldWhite, dimGrey, white, yellow } from '../../colors/colors' import { SizeStack } from '../sizeStack' import { TransformOptions, TransformTyped } from '../stream.model' diff --git a/src/stream/transform/transformMap.ts b/src/stream/transform/transformMap.ts index deeca2ed..88839140 100644 --- a/src/stream/transform/transformMap.ts +++ b/src/stream/transform/transformMap.ts @@ -9,7 +9,7 @@ import { SKIP, } from '@naturalcycles/js-lib' import through2Concurrent = require('through2-concurrent') -import { yellow } from '../../colors' +import { yellow } from '../../colors/colors' import { AbortableTransform } from '../pipeline/pipeline' import { TransformTyped } from '../stream.model' import { pipelineClose } from '../stream.util' diff --git a/src/stream/transform/transformMapSync.ts b/src/stream/transform/transformMapSync.ts index 9feaed4f..280f6628 100644 --- a/src/stream/transform/transformMapSync.ts +++ b/src/stream/transform/transformMapSync.ts @@ -7,7 +7,7 @@ import { Predicate, SKIP, } from '@naturalcycles/js-lib' -import { yellow } from '../../colors' +import { yellow } from '../../colors/colors' import { AbortableTransform } from '../pipeline/pipeline' import { TransformTyped } from '../stream.model' import { pipelineClose } from '../stream.util' diff --git a/src/util/git.util.ts b/src/util/git.util.ts index cf769376..b27e0abf 100644 --- a/src/util/git.util.ts +++ b/src/util/git.util.ts @@ -1,7 +1,7 @@ import * as cp from 'node:child_process' import * as path from 'node:path' import type { UnixTimestampNumber } from '@naturalcycles/js-lib' -import { grey } from '../colors' +import { grey } from '../colors/colors' export function getLastGitCommitMsg(): string { return execSync('git log -1 --pretty=%B')