Skip to content

Commit 2685478

Browse files
committed
update dir and file imports to new fsDir and fsFile names
1 parent 0cdf128 commit 2685478

File tree

9 files changed

+127
-122
lines changed

9 files changed

+127
-122
lines changed

packages/fs-cache/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ pnpm add @synstack/fs-cache
4545
Cache directory can be initialized using an `FsDir` instance:
4646

4747
```typescript
48-
import { dir } from "@synstack/fs";
48+
import { fsDir } from "@synstack/fs";
4949

50-
const cacheDir = dir(".cache");
50+
const cacheDir = fsDir(".cache");
5151
const cache = fsCache(cacheDir);
5252
```
5353

packages/fs-cache/src/fs-cache.lib.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { dir } from "@synstack/fs";
1+
import { fsDir } from "@synstack/fs";
22
import assert from "node:assert/strict";
33
import { afterEach, describe, it } from "node:test";
44
import { fsCache } from "./fs-cache.lib.ts";
55

6-
const TMP_DIR = dir(import.meta.dirname).to("tmp");
6+
const TMP_DIR = fsDir(import.meta.dirname).to("tmp");
77

88
describe("FsCache", () => {
99
afterEach(async () => {

packages/fs-cache/src/fs-cache.lib.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { dir, FsDir } from "@synstack/fs";
1+
import { fsDir, FsDir } from "@synstack/fs";
22
import { type OneToN } from "../../shared/src/ts.utils.ts";
33
import { deepEqual } from "./deepEqual.lib.ts";
44

@@ -82,7 +82,7 @@ export class FsCache<
8282
args: TFnArgs,
8383
) {
8484
const relativePath = FsCache.keyToRelativePath(this._config.key, args);
85-
const cacheDir = dir(this._config.cwd);
85+
const cacheDir = fsDir(this._config.cwd);
8686
const file = cacheDir.file(relativePath);
8787

8888
if (!(await file.exists())) {
@@ -105,7 +105,7 @@ export class FsCache<
105105
args: TFnArgs,
106106
): Promise<["miss", null] | ["hit", TValue]> {
107107
const relativePath = FsCache.keyToRelativePath(this._config.key, args);
108-
const cacheDir = dir(this._config.cwd);
108+
const cacheDir = fsDir(this._config.cwd);
109109

110110
if (!(await cacheDir.file(relativePath).exists())) return ["miss", null];
111111

@@ -140,7 +140,7 @@ export class FsCache<
140140
value: any,
141141
) {
142142
const relativePath = FsCache.keyToRelativePath(this._config.key, args);
143-
const file = dir(this._config.cwd).file(relativePath);
143+
const file = fsDir(this._config.cwd).file(relativePath);
144144
return file.write.text(
145145
JSON.stringify(
146146
{

packages/fs/README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ This package provides a strongly-typed, chainable, and immutable API for file sy
99
Turn verbose file operations into chainable, immutable, and strongly-typed commands:
1010

1111
```typescript
12+
import { fsDir } from "@synstack/fs";
13+
1214
// Chain directory and file operations
13-
const srcDir = dir("./src");
15+
const srcDir = fsDir("./src");
1416

1517
// Recursively create directories
1618
await srcDir.to("dist/assets/images").make();
@@ -72,10 +74,10 @@ Create and work with files using the `file()` function:
7274
#### Basic Operations
7375

7476
```typescript
75-
import { file } from "@synstack/fs";
77+
import { fsFile } from "@synstack/fs";
7678

7779
// Create a file instance
78-
const myFile = file("/path/to/file.txt");
80+
const myFile = fsFile("/path/to/file.txt");
7981

8082
// Check file existence
8183
await myFile.exists(); // Promise<boolean>
@@ -97,7 +99,7 @@ myFile.creationDateSync(); // Date
9799
#### Path Operations
98100

99101
```typescript
100-
const myFile = file("/path/to/file.txt");
102+
const myFile = fsFile("/path/to/file.txt");
101103

102104
// Get path information
103105
myFile.path; // "/path/to/file.txt"
@@ -170,10 +172,11 @@ await myFile.write.mode("overwrite").text("content"); // Default behavior
170172
#### Schema Validation
171173

172174
```typescript
175+
import { fsFile } from "@synstack/fs";
173176
import { z } from "zod";
174177

175178
const schema = z.object({ name: z.string() });
176-
const configFile = file("config.json").schema(schema);
179+
const configFile = fsFile("config.json").schema(schema);
177180

178181
// Read with validation
179182
const config = await configFile.read.json();
@@ -188,9 +191,9 @@ Work with directories using the `dir()` function:
188191
#### Basic Operations
189192

190193
```typescript
191-
import { dir } from "@synstack/fs";
194+
import { fsDir } from "@synstack/fs";
192195

193-
const myDir = dir("/path/to/directory");
196+
const myDir = fsDir("/path/to/directory");
194197

195198
// Check existence
196199
await myDir.exists(); // Promise<boolean>
@@ -251,14 +254,14 @@ await myDir.exec`echo "Hello, world!"`;
251254
Work with collections of files using powerful array methods:
252255

253256
```typescript
254-
import { dir, files } from "@synstack/fs";
257+
import { fsDir, fsFiles } from "@synstack/fs";
255258

256259
// Create from directory
257-
const sourceDir = dir("./src");
260+
const sourceDir = fsDir("./src");
258261
const fileArray = await sourceDir.glob("**/*");
259262

260263
// Create from paths
261-
const customArray = files(["/path/to/file1.txt", "/path/to/file2.txt"]);
264+
const customArray = fsFiles(["/path/to/file1.txt", "/path/to/file2.txt"]);
262265

263266
// Filtering
264267
fileArray.filter((file) => file.fileExtension() === ".ts");

packages/fs/src/dir.lib.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class FsDir extends Pipeable<FsDir> {
2323
* @returns The absolute path of the directory as a string
2424
*
2525
* ```typescript
26-
* const srcDir = dir("./src");
26+
* const srcDir = fsDir("./src");
2727
* console.log(srcDir.toString()); // "/absolute/path/to/src"
2828
* ```
2929
*/
@@ -56,7 +56,7 @@ export class FsDir extends Pipeable<FsDir> {
5656
* @returns The absolute path as a string
5757
*
5858
* ```typescript
59-
* const srcDir = dir("./src");
59+
* const srcDir = fsDir("./src");
6060
* console.log(srcDir.path); // "/absolute/path/to/src"
6161
* ```
6262
*/
@@ -95,13 +95,13 @@ export class FsDir extends Pipeable<FsDir> {
9595
*
9696
* ```typescript
9797
* // Create from absolute path
98-
* const rootDir = dir("/path/to/project");
98+
* const rootDir = fsDir("/path/to/project");
9999
*
100100
* // Create from relative path
101-
* const srcDir = dir("./src");
101+
* const srcDir = fsDir("./src");
102102
*
103103
* // Create from existing directory
104-
* const existingDir = dir(dir("/path/to/existing"));
104+
* const existingDir = fsDir(fsDir("/path/to/existing"));
105105
* ```
106106
*/
107107
public static cwd(this: void, arg: FsDir | AnyPath): FsDir;
@@ -118,7 +118,7 @@ export class FsDir extends Pipeable<FsDir> {
118118
* @returns A new FsDir instance representing the combined path
119119
*
120120
* ```typescript
121-
* const projectDir = dir("/path/to/project");
121+
* const projectDir = fsDir("/path/to/project");
122122
*
123123
* // Navigate to subdirectories
124124
* const srcDir = projectDir.toDir("src");
@@ -141,7 +141,7 @@ export class FsDir extends Pipeable<FsDir> {
141141
* @returns A new FsDir instance representing the combined path
142142
*
143143
* ```typescript
144-
* const projectDir = dir("/path/to/project");
144+
* const projectDir = fsDir("/path/to/project");
145145
*
146146
* // Navigate to subdirectories
147147
* const srcDir = projectDir.to("src");
@@ -164,7 +164,7 @@ export class FsDir extends Pipeable<FsDir> {
164164
* @throws If an absolute path is provided
165165
*
166166
* ```typescript
167-
* const srcDir = dir("./src");
167+
* const srcDir = fsDir("./src");
168168
*
169169
* // Access files in the directory
170170
* const configFile = srcDir.toFile("config.json");
@@ -193,7 +193,7 @@ Trying to access a dir file from an absolute paths:
193193
* @throws If an absolute path is provided
194194
*
195195
* ```typescript
196-
* const srcDir = dir("./src");
196+
* const srcDir = fsDir("./src");
197197
*
198198
* // Access files in the directory
199199
* const configFile = srcDir.file("config.json");
@@ -213,7 +213,7 @@ Trying to access a dir file from an absolute paths:
213213
* @returns The directory name without the full path
214214
*
215215
* ```typescript
216-
* const srcDir = dir("/path/to/project/src");
216+
* const srcDir = fsDir("/path/to/project/src");
217217
* console.log(srcDir.name()); // "src"
218218
* ```
219219
*/
@@ -227,7 +227,7 @@ Trying to access a dir file from an absolute paths:
227227
* @returns A promise that resolves to true if the directory exists, false otherwise
228228
*
229229
* ```typescript
230-
* const configDir = dir("./config");
230+
* const configDir = fsDir("./config");
231231
*
232232
* if (await configDir.exists()) {
233233
* // Directory exists, safe to use
@@ -252,7 +252,7 @@ Trying to access a dir file from an absolute paths:
252252
* @returns True if the directory exists, false otherwise
253253
*
254254
* ```typescript
255-
* const configDir = dir("./config");
255+
* const configDir = fsDir("./config");
256256
*
257257
* if (configDir.existsSync()) {
258258
* // Directory exists, safe to use
@@ -279,7 +279,7 @@ Trying to access a dir file from an absolute paths:
279279
* @returns A promise that resolves when the directory is created
280280
*
281281
* ```typescript
282-
* const assetsDir = dir("./dist/assets/images");
282+
* const assetsDir = fsDir("./dist/assets/images");
283283
*
284284
* // Creates all necessary parent directories
285285
* await assetsDir.make();
@@ -295,7 +295,7 @@ Trying to access a dir file from an absolute paths:
295295
* @synchronous
296296
*
297297
* ```typescript
298-
* const assetsDir = dir("./dist/assets/images");
298+
* const assetsDir = fsDir("./dist/assets/images");
299299
*
300300
* // Creates all necessary parent directories immediately
301301
* assetsDir.makeSync();
@@ -336,7 +336,7 @@ Trying to access a dir file from an absolute paths:
336336
* @returns A promise that resolves when the directory is removed
337337
*
338338
* ```typescript
339-
* const tempDir = dir("./temp");
339+
* const tempDir = fsDir("./temp");
340340
*
341341
* // Remove directory and all contents
342342
* await tempDir.rm();
@@ -356,7 +356,7 @@ Trying to access a dir file from an absolute paths:
356356
* @synchronous
357357
*
358358
* ```typescript
359-
* const tempDir = dir("./temp");
359+
* const tempDir = fsDir("./temp");
360360
*
361361
* // Remove directory and all contents immediately
362362
* tempDir.rmSync();
@@ -378,7 +378,7 @@ Trying to access a dir file from an absolute paths:
378378
* @returns A promise that resolves to an FsFileArray containing the matching files
379379
*
380380
* ```typescript
381-
* const srcDir = dir("./src");
381+
* const srcDir = fsDir("./src");
382382
*
383383
* // Find all TypeScript files
384384
* const tsFiles = await srcDir.glob("**\/*.ts");
@@ -406,7 +406,7 @@ Trying to access a dir file from an absolute paths:
406406
* @synchronous
407407
*
408408
* ```typescript
409-
* const srcDir = dir("./src");
409+
* const srcDir = fsDir("./src");
410410
*
411411
* // Find all TypeScript files synchronously
412412
* const tsFiles = srcDir.globSync("**\/*.ts");
@@ -468,7 +468,7 @@ Trying to access a dir file from an absolute paths:
468468
* @returns A promise that resolves to an FsFileArray containing the git-tracked files
469469
*
470470
* ```typescript
471-
* const projectDir = dir("./project");
471+
* const projectDir = fsDir("./project");
472472
*
473473
* // Get all git-tracked files in the directory
474474
* const trackedFiles = await projectDir.gitLs();
@@ -503,13 +503,13 @@ Trying to access a dir file from an absolute paths:
503503
*
504504
* ```typescript
505505
* // Create from absolute path
506-
* const rootDir = dir("/path/to/project");
506+
* const rootDir = fsDir("/path/to/project");
507507
*
508508
* // Create from relative path
509-
* const srcDir = dir("./src");
509+
* const srcDir = fsDir("./src");
510510
*
511511
* // Create from existing directory
512-
* const existingDir = dir(dir("/path/to/existing"));
512+
* const existingDir = fsDir(fsDir("/path/to/existing"));
513513
* ```
514514
*/
515515
export const fsDir = FsDir.cwd;

0 commit comments

Comments
 (0)