yoctomarkdown 0.0.2 → 0.0.3

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.
@@ -0,0 +1,31 @@
1
+ ---
2
+ description: Create a new tagged npm release (patch/minor/major)
3
+ ---
4
+
5
+ Create a new npm release for this repo. The bump type is: $1 (default to "patch" if not provided).
6
+
7
+ Steps to follow exactly:
8
+
9
+ 1. Normalize bump type to one of `patch|minor|major`; if empty, use `patch`.
10
+ 2. Verify git state before doing anything:
11
+ - current branch must be `main`
12
+ - working tree must be clean
13
+ - run `git fetch origin --tags` and ensure `HEAD` equals `origin/main`
14
+ If any check fails, stop and report.
15
+ 3. Run the full repo check suit — stop and report failures.
16
+ 4. Read `package.json` and capture both `name` and current `version`.
17
+ 5. Compute the next semver version by bumping the selected part.
18
+ 6. Guardrails before mutating files:
19
+ - ensure git tag `v<new-version>` does not exist locally or on origin
20
+ - ensure npm version does not already exist: `npm view <package-name>@<new-version> version`
21
+ If either exists, stop and report.
22
+ 7. Update the `version` field in `package.json` to `<new-version>`.
23
+ 8. Run `bun run build`.
24
+ 9. Commit all staged and unstaged changes with message: `chore: release v<new-version>`.
25
+ 10. Create annotated tag: `git tag -a v<new-version> -m "<new-version>\n<small-changelog>"`.
26
+ 11. Push explicitly to main and the exact tag:
27
+ - `git push origin main`
28
+ - `git push origin v<new-version>`
29
+ 12. Post-push verification: run `npm view <package-name>@<new-version> version`.
30
+ - If it already exists, report that publish already happened and do **not** ask user to publish again.
31
+ - If it does not exist, run `npm publish`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yoctomarkdown",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {
@@ -18,7 +18,7 @@
18
18
  "yoctocolors": "^2.1.2"
19
19
  },
20
20
  "bin": {
21
- "yoctomarkdown": "./src/cli.ts"
21
+ "yoctomarkdown": "src/cli.ts"
22
22
  },
23
23
  "scripts": {
24
24
  "typecheck": "tsc --noEmit",
package/src/index.ts CHANGED
@@ -128,6 +128,7 @@ export function createHighlighter(options?: Options): Highlighter {
128
128
  }
129
129
 
130
130
  let hasPartial = false;
131
+ let partialLength = 0;
131
132
 
132
133
  return {
133
134
  write(chunk: string | Uint8Array): string {
@@ -140,7 +141,15 @@ export function createHighlighter(options?: Options): Highlighter {
140
141
 
141
142
  let out = "";
142
143
  if (hasPartial) {
144
+ const columns =
145
+ typeof process !== "undefined" && process.stdout?.columns
146
+ ? process.stdout.columns
147
+ : 80;
148
+ const linesToClear = Math.ceil(partialLength / columns) || 1;
143
149
  out += "\x1b[2K\r";
150
+ if (linesToClear > 1) {
151
+ out += "\x1b[1A\x1b[2K".repeat(linesToClear - 1);
152
+ }
144
153
  }
145
154
 
146
155
  if (lines.length > 0) {
@@ -150,8 +159,10 @@ export function createHighlighter(options?: Options): Highlighter {
150
159
  if (buffer.length > 0) {
151
160
  out += parseLine(buffer, true);
152
161
  hasPartial = true;
162
+ partialLength = buffer.length;
153
163
  } else {
154
164
  hasPartial = false;
165
+ partialLength = 0;
155
166
  }
156
167
 
157
168
  return out;
@@ -160,7 +171,19 @@ export function createHighlighter(options?: Options): Highlighter {
160
171
  if (buffer.length > 0) {
161
172
  const out = parseLine(buffer, false);
162
173
  buffer = "";
163
- return (hasPartial ? "\x1b[2K\r" : "") + out;
174
+ if (hasPartial) {
175
+ const columns =
176
+ typeof process !== "undefined" && process.stdout?.columns
177
+ ? process.stdout.columns
178
+ : 80;
179
+ const linesToClear = Math.ceil(partialLength / columns) || 1;
180
+ let clearSeq = "\x1b[2K\r";
181
+ if (linesToClear > 1) {
182
+ clearSeq += "\x1b[1A\x1b[2K".repeat(linesToClear - 1);
183
+ }
184
+ return clearSeq + out;
185
+ }
186
+ return out;
164
187
  }
165
188
  return "";
166
189
  },
@@ -81,4 +81,34 @@ describe("Programmatic Usage: createHighlighter (Streaming)", () => {
81
81
 
82
82
  expectStreamMatch(res, markdown);
83
83
  });
84
+
85
+ test("should clear multiple lines when wrapped", () => {
86
+ // Mock columns
87
+ const originalColumns = process.stdout.columns;
88
+ Object.defineProperty(process.stdout, "columns", {
89
+ value: 10,
90
+ configurable: true,
91
+ });
92
+
93
+ const highlighter = createHighlighter({ theme: "none" });
94
+ // 25 chars, columns = 10, so it takes 3 visual lines
95
+ const chunk1 = "1234567890123456789012345";
96
+ const chunk2 = "67890\n";
97
+
98
+ let res = highlighter.write(chunk1);
99
+ res += highlighter.write(chunk2);
100
+ res += highlighter.end();
101
+
102
+ // The first chunk is written, then cleared. Since it takes 3 lines,
103
+ // clear sequence should have \x1b[1A\x1b[2K repeated twice.
104
+ expect(res).toContain("\x1b[1A\x1b[2K\x1b[1A\x1b[2K");
105
+
106
+ // Restore
107
+ if (originalColumns !== undefined) {
108
+ Object.defineProperty(process.stdout, "columns", {
109
+ value: originalColumns,
110
+ configurable: true,
111
+ });
112
+ }
113
+ });
84
114
  });