@dephub/write 1.0.0 → 1.0.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2025 Estarlin R
3
+ Copyright (c) 2025-2026 Estarlin R
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
  [![NPM version](https://img.shields.io/npm/v/@dephub/write.svg?style=flat)](https://npmjs.org/package/@dephub/write)
6
6
  [![ESM-only](https://img.shields.io/badge/ESM-only-brightgreen?style=flat)](https://nodejs.org/)
7
- [![Node.js version](https://img.shields.io/badge/node-%3E%3D22.5.0-brightgreen.svg)](https://nodejs.org/)
8
7
 
9
8
  ---
10
9
 
package/dist/cli.js CHANGED
@@ -1,19 +1,23 @@
1
1
  #!/usr/bin/env node
2
- import { cli as o } from "@dephub/cli";
3
- import { error as r, success as s } from "@dephub/log";
4
- import { writeFile as a } from "./core/write.js";
5
- import { name as d, version as c, description as m } from "./utils/pkg.js";
6
- o.name(d.split("/")[1] ?? "write").version(c).description(m).argument("<filepath>", "Path where the file will be written").argument("[content]", "Content to write (if not provided, reads from stdin)").action(async ({ args: n }) => {
7
- const [e, i] = n;
2
+ import { Command as s, CommandError as a } from "@dephub/command";
3
+ import { logger as o } from "@dephub/logger";
4
+ import { writeFile as d } from "./core/write.js";
5
+ import { name as m, version as c, description as p } from "./utils/pkg.js";
6
+ const i = new s().name(m.split("/")[1] ?? "write").version(c).description(p).argument("filePath", "Path where the file will be written").argument("content", "Content to write (if not provided, reads from stdin)").handler(async ({ args: { content: r, filePath: t } }) => {
8
7
  try {
9
- let t = i;
10
- i || (t = await p(), t || (r("No content provided and stdin is empty"), process.exit(1))), await a(e, t), s(`Written to ${e}`);
11
- } catch (t) {
12
- r(`Failed to write to ${e}: ${t.message}`), process.exit(1);
8
+ let e = r;
9
+ r || (e = await f(), e || (o.error("No content provided and stdin is empty"), process.exit(1))), await d(t, e), o.success(`Written to ${t}`);
10
+ } catch (e) {
11
+ o.error(`Failed to write to ${t}: ${e.message}`), process.exit(1);
13
12
  }
13
+ }), f = () => new Promise((r, t) => {
14
+ let e = "";
15
+ process.stdin.setEncoding("utf8"), process.stdin.on("data", (n) => e += n), process.stdin.on("end", () => r(e.trim())), process.stdin.on("error", t), process.stdin.isTTY && setTimeout(() => r(""), 100);
14
16
  });
15
- const p = () => new Promise((n, e) => {
16
- let i = "";
17
- process.stdin.setEncoding("utf8"), process.stdin.on("data", (t) => i += t), process.stdin.on("end", () => n(i.trim())), process.stdin.on("error", e), process.stdin.isTTY && setTimeout(() => n(""), 100);
18
- });
19
- await o.run();
17
+ try {
18
+ await i.run();
19
+ } catch (r) {
20
+ throw r instanceof a && (o.error(`
21
+ Error: ${r.message}
22
+ `), i.help(), process.exit(1)), r;
23
+ }
@@ -1,4 +1,4 @@
1
- const t = "@dephub/write", i = "1.0.0", o = "File writing utility with automatic directory creation for Node.js", e = {
1
+ const t = "@dephub/write", i = "1.0.2", o = "File writing utility with automatic directory creation for Node.js", e = {
2
2
  name: t,
3
3
  version: i,
4
4
  description: o
@@ -1 +1 @@
1
- export declare const version: string, description: string, name: string;
1
+ export declare const description: string, name: string, version: string;
package/dist/utils/pkg.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import o from "../package.json.js";
2
- const { version: e, description: i, name: n } = o ?? {};
2
+ const { description: e, name: i, version: n } = o ?? {};
3
3
  export {
4
- i as description,
5
- n as name,
6
- e as version
4
+ e as description,
5
+ i as name,
6
+ n as version
7
7
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dephub/write",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "description": "File writing utility with automatic directory creation for Node.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "main": "./dist/index.js",
@@ -34,27 +34,38 @@
34
34
  "dist"
35
35
  ],
36
36
  "license": "MIT",
37
- "homepage": "https://github.com/dephubjs/write#readme",
37
+ "homepage": "https://github.com/dephub-js/write#readme",
38
38
  "repository": {
39
39
  "type": "git",
40
- "url": "https://github.com/dephubjs/write.git",
41
- "directory": "packages/write"
40
+ "url": "https://github.com/dephub-js/write.git"
42
41
  },
43
42
  "bugs": {
44
- "url": "https://github.com/dephubjs/write/issues"
43
+ "url": "https://github.com/dephub-js/write/issues"
45
44
  },
46
45
  "publishConfig": {
47
46
  "access": "public"
48
47
  },
49
48
  "dependencies": {
50
- "@dephub/log": "^1.0.0",
51
- "@dephub/cli": "^1.0.0"
49
+ "@dephub/command": "^1.0.1",
50
+ "@dephub/logger": "^1.2.0"
51
+ },
52
+ "devDependencies": {
53
+ "@dephub/eslint-ts": "^1.0.2",
54
+ "@dephub/glob": "^1.0.2",
55
+ "@dephub/path": "^1.0.2",
56
+ "@types/node": "^25.3.3",
57
+ "eslint": "^10.0.2",
58
+ "prettier": "^3.8.1",
59
+ "typescript": "^5.9.3",
60
+ "vite": "^7.3.1",
61
+ "vite-plugin-dts": "^4.5.4"
52
62
  },
53
63
  "scripts": {
54
64
  "release": "pnpm publish",
65
+ "docs": "lineo md 'src/**/*.ts' --outFile code.md --outDir temp",
55
66
  "check-types": "tsc --noEmit --skipLibCheck",
56
- "lint": "lint . --max-warnings 0",
57
- "lint:fix": "lint . --fix",
67
+ "lint": "eslint . --fix --max-warnings 0",
68
+ "fmt": "prettier --write .",
58
69
  "clean": "rm -rf dist",
59
70
  "build": "vite build",
60
71
  "dev": "vite build -w --mode development"