Skip to content

Commit

Permalink
util (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn authored Nov 11, 2022
1 parent c6e2496 commit b109781
Show file tree
Hide file tree
Showing 74 changed files with 275 additions and 366 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# changelog

## 0.65.0

- **break**: depend on `@feltcoop/util` instead of `@feltcoop/felt`
([#355](https://github.com/feltcoop/gro/pull/355))

## 0.64.0

- **break**: upgrade peer dep `@feltcoop/felt@0.42.0`
Expand Down
302 changes: 138 additions & 164 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"node": ">=18.6.0"
},
"dependencies": {
"@feltcoop/util": "^0.1.0",
"@rollup/pluginutils": "^5.0.2",
"@ryanatkn/json-schema-to-typescript": "^11.1.2",
"@types/source-map-support": "^0.5.6",
Expand All @@ -66,7 +67,6 @@
"zod-to-json-schema": "^3.18.1"
},
"peerDependencies": {
"@feltcoop/felt": ">=0.42.0",
"esbuild": ">=0.15.0",
"svelte": ">=3.49.0",
"svelte-preprocess-esbuild": ">=3.0.1"
Expand All @@ -75,7 +75,7 @@
"@feltcoop/eslint-config": "^0.2.1",
"@feltcoop/felt": "^0.42.0",
"@sveltejs/adapter-static": "^1.0.0-next.48",
"@sveltejs/kit": "^1.0.0-next.539",
"@sveltejs/kit": "^1.0.0-next.542",
"@types/estree": "^1.0.0",
"@types/fs-extra": "^9.0.13",
"@types/node": "^18.11.9",
Expand All @@ -85,7 +85,7 @@
"esbuild": "^0.15.13",
"eslint": "^8.27.0",
"eslint-plugin-svelte3": "^4.0.0",
"svelte": "^3.53.0",
"svelte": "^3.53.1",
"svelte-check": "^2.9.2",
"svelte-preprocess-esbuild": "^3.0.1",
"typescript": "^4.8.4",
Expand Down
4 changes: 2 additions & 2 deletions src/adapt/adapt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {toArray} from '@feltcoop/felt/util/array.js';
import type {Timings} from '@feltcoop/felt/util/timings.js';
import {toArray} from '@feltcoop/util';
import type {Timings} from '@feltcoop/util';

import type {TaskContext} from '../task/task.js';
import type {GroConfig} from '../config/config.js';
Expand Down
2 changes: 1 addition & 1 deletion src/adapt/gro-adapter-generic-build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {stripTrailingSlash} from '@feltcoop/felt/util/path.js';
import {stripTrailingSlash} from '@feltcoop/util';

import type {Adapter} from './adapt.js';
import {type HostTarget, copyDist, ensureNojekyll} from './utils.js';
Expand Down
14 changes: 9 additions & 5 deletions src/adapt/gro-adapter-node-library.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import {printSpawnResult, spawn} from '@feltcoop/felt/util/process.js';
import {EMPTY_OBJECT} from '@feltcoop/felt/util/object.js';
import {replaceExtension, stripTrailingSlash} from '@feltcoop/felt/util/path.js';
import {stripStart} from '@feltcoop/felt/util/string.js';
import {
printSpawnResult,
spawn,
EMPTY_OBJECT,
identity,
stripStart,
replaceExtension,
stripTrailingSlash,
} from '@feltcoop/util';
import esbuild from 'esbuild';
import {identity} from '@feltcoop/felt/util/function.js';

import type {Adapter} from './adapt.js';
import {TaskError} from '../task/task.js';
Expand Down
3 changes: 1 addition & 2 deletions src/adapt/gro-adapter-sveltekit-frontend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {EMPTY_OBJECT} from '@feltcoop/felt/util/object.js';
import {stripTrailingSlash} from '@feltcoop/felt/util/path.js';
import {stripTrailingSlash, EMPTY_OBJECT} from '@feltcoop/util';

import type {Adapter} from './adapt.js';
import {ensureNojekyll, move404, type HostTarget} from './utils.js';
Expand Down
4 changes: 2 additions & 2 deletions src/adapt/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {relative, dirname} from 'path';
import type {Logger} from '@feltcoop/felt/util/log.js';
import {stripEnd, stripStart} from '@feltcoop/felt/util/string.js';
import type {Logger} from '@feltcoop/util';
import {stripEnd, stripStart} from '@feltcoop/util';

import type {BuildConfig} from '../build/buildConfig.js';
import type {Filesystem} from '../fs/filesystem.js';
Expand Down
3 changes: 1 addition & 2 deletions src/build.task.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Timings} from '@feltcoop/felt/util/timings.js';
import {printTimings} from '@feltcoop/felt/util/print.js';
import {printTimings, Timings} from '@feltcoop/util';
import {z} from 'zod';

import type {Task} from './task/task.js';
Expand Down
2 changes: 1 addition & 1 deletion src/build/Filer.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {suite} from 'uvu';
import * as assert from 'uvu/assert';
import {replaceExtension} from '@feltcoop/felt/util/path.js';
import {replaceExtension} from '@feltcoop/util';

import {Filer} from './Filer.js';
import {fs as memoryFs, type MemoryFs} from '../fs/memory.js';
Expand Down
15 changes: 10 additions & 5 deletions src/build/Filer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import {resolve, extname, join} from 'path';
import * as lexer from 'es-module-lexer';
import {EventEmitter} from 'events';
import type StrictEventEmitter from 'strict-event-emitter-types';
import {nulls, omitUndefined} from '@feltcoop/felt/util/object.js';
import {UnreachableError} from '@feltcoop/felt/util/error.js';
import {printLogLabel, SystemLogger, type Logger} from '@feltcoop/felt/util/log.js';
import {
nulls,
omitUndefined,
UnreachableError,
printError,
printLogLabel,
SystemLogger,
type Logger,
} from '@feltcoop/util';
import {gray, red, cyan} from 'kleur/colors';
import {printError} from '@feltcoop/felt/util/print.js';
import type {Assignable, PartialExcept} from '@feltcoop/felt/util/types.js';
import type {Assignable, PartialExcept} from '@feltcoop/util';

import type {Filesystem} from '../fs/filesystem.js';
import {createFilerDir, type FilerDir, type FilerDirChangeCallback} from '../build/filerDir.js';
Expand Down
3 changes: 1 addition & 2 deletions src/build/buildConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {resolve} from 'path';
import {toArray} from '@feltcoop/felt/util/array.js';
import {toArray, type Result, type Flavored} from '@feltcoop/util';
import {blue, gray} from 'kleur/colors';
import type {Result, Flavored} from '@feltcoop/felt';

import {paths} from '../paths.js';
import {CONFIG_BUILD_NAME, SYSTEM_BUILD_CONFIG, SYSTEM_BUILD_NAME} from './buildConfigDefaults.js';
Expand Down
2 changes: 1 addition & 1 deletion src/build/buildFile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {UnreachableError} from '@feltcoop/felt/util/error.js';
import {UnreachableError} from '@feltcoop/util';

import type {BaseFilerFile} from './filerFile.js';
import type {SourceMeta} from './sourceMeta.js';
Expand Down
4 changes: 1 addition & 3 deletions src/build/buildSource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {printMs, printTimings} from '@feltcoop/felt/util/print.js';
import type {Logger} from '@feltcoop/felt/util/log.js';
import {createStopwatch, Timings} from '@feltcoop/felt/util/timings.js';
import {printMs, printTimings, type Logger, createStopwatch, Timings} from '@feltcoop/util';
import {gray} from 'kleur/colors';

import {paths, toTypesBuildDir} from '../paths.js';
Expand Down
2 changes: 1 addition & 1 deletion src/build/builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Logger} from '@feltcoop/felt/util/log.js';
import type {Logger} from '@feltcoop/util';

import type {BuildConfig, BuildName} from './buildConfig.js';
import type {EcmaScriptTarget} from './typescriptUtils.js';
Expand Down
2 changes: 1 addition & 1 deletion src/build/filerDir.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {noop} from '@feltcoop/felt/util/function.js';
import {noop} from '@feltcoop/util';

import {watchNodeFs, type WatchNodeFs} from '../fs/watchNodeFs.js';
import type {PathStats} from '../fs/pathData.js';
Expand Down
2 changes: 1 addition & 1 deletion src/build/groBuilderEsbuild.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import esbuild from 'esbuild';
import {replaceExtension} from '@feltcoop/felt/util/path.js';
import {replaceExtension} from '@feltcoop/util';

import {toDefaultEsbuildOptions} from './groBuilderEsbuildUtils.js';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/build/groBuilderNoop.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {UnreachableError} from '@feltcoop/felt/util/error.js';
import {UnreachableError} from '@feltcoop/util';

import {toBuildOutPath} from '../paths.js';
import type {Builder} from './builder.js';
Expand Down
3 changes: 1 addition & 2 deletions src/build/groBuilderSvelte.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as svelte from 'svelte/compiler';
import type {PreprocessorGroup as SveltePreprocessorGroup} from 'svelte/types/compiler/preprocess';
import type {CompileOptions as SvelteCompileOptions} from 'svelte/types/compiler/interfaces';
import {printLogLabel, SystemLogger, type Logger} from '@feltcoop/felt/util/log.js';
import {UnreachableError} from '@feltcoop/felt/util/error.js';
import {UnreachableError, printLogLabel, SystemLogger, type Logger} from '@feltcoop/util';
import {cyan} from 'kleur/colors';

import type {EcmaScriptTarget} from './typescriptUtils.js';
Expand Down
4 changes: 2 additions & 2 deletions src/build/groBuilderSvelteUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type {
} from 'svelte/types/compiler/interfaces';
import type {PreprocessorGroup, Processed} from 'svelte/types/compiler/preprocess';
import * as sveltePreprocessEsbuild from 'svelte-preprocess-esbuild';
import type {Logger} from '@feltcoop/felt/util/log.js';
import type {Logger} from '@feltcoop/util';
import {yellow} from 'kleur/colors';
import {printKeyValue, printMs} from '@feltcoop/felt/util/print.js';
import {printKeyValue, printMs} from '@feltcoop/util';

import {toDefaultEsbuildPreprocessOptions} from './groBuilderEsbuildUtils.js';
import type {EcmaScriptTarget} from './typescriptUtils.js';
Expand Down
2 changes: 1 addition & 1 deletion src/build/postprocess.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {join, extname, relative} from 'path';
import * as lexer from 'es-module-lexer';
import type {Assignable} from '@feltcoop/felt';
import type {Assignable} from '@feltcoop/util';

import {
paths,
Expand Down
4 changes: 1 addition & 3 deletions src/build/rollupPluginGroDiagnostics.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type {Plugin as RollupPlugin} from 'rollup';
import {gray} from 'kleur/colors';
import {SystemLogger} from '@feltcoop/felt/util/log.js';
import {printKeyValue, printMs} from '@feltcoop/felt/util/print.js';
import {createStopwatch} from '@feltcoop/felt/util/timings.js';
import {SystemLogger, printKeyValue, printMs, createStopwatch} from '@feltcoop/util';

import {printPath} from '../paths.js';

Expand Down
3 changes: 1 addition & 2 deletions src/build/sourceFile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {basename, dirname} from 'path';
import {UnreachableError} from '@feltcoop/felt/util/error.js';
import {stripStart} from '@feltcoop/felt/util/string.js';
import {UnreachableError, stripStart} from '@feltcoop/util';

import type {FilerDir} from './filerDir.js';
import {reconstructBuildFiles, type BuildFile} from './buildFile.js';
Expand Down
4 changes: 1 addition & 3 deletions src/build/typescriptUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type {Logger} from '@feltcoop/felt/util/log.js';
import {replaceExtension} from '@feltcoop/felt/util/path.js';
import {spawn} from '@feltcoop/felt/util/process.js';
import {type Logger, spawn, replaceExtension} from '@feltcoop/util';

import type {Filesystem} from '../fs/filesystem.js';
import {
Expand Down
3 changes: 1 addition & 2 deletions src/build/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type {Result} from '@feltcoop/felt';
import {createHash} from 'crypto';
import {resolve} from 'path';
import {replaceExtension} from '@feltcoop/felt/util/path.js';
import {replaceExtension, type Result} from '@feltcoop/util';

import type {BuildConfigInput} from './buildConfig.js';
import type {Filesystem} from '../fs/filesystem.js';
Expand Down
2 changes: 1 addition & 1 deletion src/cert.task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {spawn} from '@feltcoop/felt/util/process.js';
import {spawn} from '@feltcoop/util';
import {z} from 'zod';

import type {Task} from './task/task.js';
Expand Down
2 changes: 1 addition & 1 deletion src/clean.task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {spawn} from '@feltcoop/felt/util/process.js';
import {spawn} from '@feltcoop/util';

import type {Task} from './task/task.js';
import {cleanFs} from './fs/clean.js';
Expand Down
2 changes: 1 addition & 1 deletion src/cli/invoke.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {attachProcessErrorHandlers} from '@feltcoop/felt/util/process.js';
import {attachProcessErrorHandlers} from '@feltcoop/util';

import {invokeTask} from '../task/invokeTask.js';
import {fs as nodeFs} from '../fs/node.js';
Expand Down
9 changes: 5 additions & 4 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import {
printLogLabel,
DEFAULT_LOG_LEVEL,
type Logger,
} from '@feltcoop/felt/util/log.js';
import {omitUndefined} from '@feltcoop/felt/util/object.js';
import type {Assignable, Result} from '@feltcoop/felt';
import {toArray} from '@feltcoop/felt/util/array.js';
omitUndefined,
toArray,
type Assignable,
type Result,
} from '@feltcoop/util';

import {paths, toBuildOutPath, CONFIG_BUILD_PATH, DIST_DIRNAME} from '../paths.js';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/config/gro.config.default.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ENV_LOG_LEVEL, LogLevel} from '@feltcoop/felt/util/log.js';
import {ENV_LOG_LEVEL, LogLevel} from '@feltcoop/util';

import type {GroConfigCreator, GroConfigPartial} from './config.js';
import {
Expand Down
3 changes: 1 addition & 2 deletions src/deploy.task.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {join} from 'path';
import {spawn} from '@feltcoop/felt/util/process.js';
import {printError} from '@feltcoop/felt/util/print.js';
import {printError, spawn} from '@feltcoop/util';
import {green, red} from 'kleur/colors';
import {z} from 'zod';

Expand Down
3 changes: 1 addition & 2 deletions src/dev.task.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {printTimings} from '@feltcoop/felt/util/print.js';
import {Timings} from '@feltcoop/felt/util/timings.js';
import {Timings, printTimings} from '@feltcoop/util';
import {z} from 'zod';

import type {Task} from './task/task.js';
Expand Down
3 changes: 1 addition & 2 deletions src/docs/README.gen.md.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {dirname, relative, basename} from 'path';
import {toPathParts, toPathSegments} from '@feltcoop/felt/util/pathParsing.js';
import {stripStart} from '@feltcoop/felt/util/string.js';
import {stripStart, toPathParts, toPathSegments} from '@feltcoop/util';

import {type Gen, toOutputFileName} from '../gen/gen.js';
import {paths, basePathToSourceId} from '../paths.js';
Expand Down
2 changes: 1 addition & 1 deletion src/docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ there is overhead that e.g. hot paths and simple implementations should avoid.
> see `exactOptionalPropertyTypes` and the note below about it too

```ts
import {omitUndefined} from '@feltcoop/felt/util/object.js';
import {omitUndefined} from '@feltcoop/util';
export interface Options {
a: boolean;
Expand Down
3 changes: 1 addition & 2 deletions src/docs/tasks.gen.md.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {dirname, relative, basename} from 'path';
import {toPathParts, toPathSegments} from '@feltcoop/felt/util/pathParsing.js';
import {stripStart} from '@feltcoop/felt/util/string.js';
import {stripStart, toPathParts, toPathSegments} from '@feltcoop/util';

import {type Gen, toOutputFileName} from '../gen/gen.js';
import {paths, basePathToSourceId} from '../paths.js';
Expand Down
2 changes: 1 addition & 1 deletion src/format.task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {printSpawnResult} from '@feltcoop/felt/util/process.js';
import {printSpawnResult} from '@feltcoop/util';
import {z} from 'zod';

import {TaskError, type Task} from './task/task.js';
Expand Down
4 changes: 2 additions & 2 deletions src/format/formatDirectory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {spawn, type SpawnResult} from '@feltcoop/felt/util/process.js';
import type {Logger} from '@feltcoop/felt/util/log.js';
import {spawn, type SpawnResult} from '@feltcoop/util';
import type {Logger} from '@feltcoop/util';

import {
GITHUB_DIRNAME,
Expand Down
4 changes: 2 additions & 2 deletions src/fs/clean.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {EMPTY_ARRAY} from '@feltcoop/felt/util/array.js';
import type {SystemLogger} from '@feltcoop/felt/util/log.js';
import {EMPTY_ARRAY} from '@feltcoop/util';
import type {SystemLogger} from '@feltcoop/util';

import {toSourceMetaDir} from '../build/sourceMeta.js';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/fs/filesystem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {resolve} from 'path';
import type {Flavored} from '@feltcoop/felt/util/types.js';
import type {Flavored} from '@feltcoop/util';

import type {Encoding} from './encoding.js';
import type {PathStats} from './pathData.js';
Expand Down
2 changes: 1 addition & 1 deletion src/fs/inputPath.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {join, sep, isAbsolute, basename} from 'path';
import {stripEnd, stripStart} from '@feltcoop/felt/util/string.js';
import {stripEnd, stripStart} from '@feltcoop/util';

import {
basePathToSourceId,
Expand Down
3 changes: 1 addition & 2 deletions src/fs/memory.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {suite} from 'uvu';
import * as assert from 'uvu/assert';
import {dirname, resolve} from 'path';
import {stripTrailingSlash} from '@feltcoop/felt/util/path.js';
import {toPathParts} from '@feltcoop/felt/util/pathParsing.js';
import {stripTrailingSlash, toPathParts} from '@feltcoop/util';

import {fs as memoryFs, type MemoryFs} from './memory.js';
import {toFsId} from './filesystem.js';
Expand Down
12 changes: 8 additions & 4 deletions src/fs/memory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {compareSimpleMapEntries, sortMap} from '@feltcoop/felt/util/map.js';
import type {Assignable} from '@feltcoop/felt/util/types.js';
import {toPathParts} from '@feltcoop/felt/util/pathParsing.js';
import {ensureEnd, stripStart} from '@feltcoop/felt/util/string.js';
import {
type Assignable,
toPathParts,
ensureEnd,
stripStart,
compareSimpleMapEntries,
sortMap,
} from '@feltcoop/util';

import {
toFsId,
Expand Down
2 changes: 1 addition & 1 deletion src/fs/mime.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Flavored} from '@feltcoop/felt/util/types.js';
import type {Flavored} from '@feltcoop/util';

// TODO the `extensions` here do not have a leading dot, but elsewhere in Gro they do!

Expand Down
Loading

0 comments on commit b109781

Please sign in to comment.