Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .eslintrc.json

This file was deleted.

7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Enforce LF for all text files — prevents the CRLF spurious-diff problem
* text=auto eol=lf

# Binary assets
*.png binary
*.gif binary
*.vsix binary
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Build output
out
dist
*.tsbuildinfo

# Dependencies
node_modules

# VS Code extension testing & packaging
.vscode-test/
*.vsix

# Logs
*.log
npm-debug.log*

# OS
.DS_Store
Thumbs.db
25 changes: 25 additions & 0 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineConfig } from '@vscode/test-cli';
import os from 'node:os';
import path from 'node:path';

// VS Code's default user-data-dir lives inside the project (.vscode-test/user-data). On deep project
// paths that pushes the Extension Host IPC socket past macOS's ~103-char unix-socket limit
// (listen EINVAL: ...-main.sock). Relocate it to a short temp path so `npm test` runs anywhere.
const userDataDir = path.join(os.tmpdir(), 'irt-vscode-test');

export default defineConfig({
tests: [
{
files: 'out/test/**/*.test.js',
mocha: {
ui: 'bdd',
},
launchArgs: [ '--user-data-dir', userDataDir ],
},
],
coverage: {
includeAll: true,
exclude: [ '**/test/**', '**/*.test.*' ],
reporter: [ 'text', 'html' ],
},
});
8 changes: 3 additions & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
]
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers", "ms-vscode.extension-test-runner"]
}
17 changes: 1 addition & 16 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,11 @@
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
Expand Down
20 changes: 11 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
"files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
},
"search.exclude": {
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
52 changes: 48 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,61 @@
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"label": "watch",
"dependsOn": [
"npm: watch:tsc",
"npm: watch:esbuild"
],
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"script": "watch:esbuild",
"group": "build",
"problemMatcher": "$esbuild-watch",
"isBackground": true,
"label": "npm: watch:esbuild",
"presentation": {
"group": "watch",
"reveal": "never"
}
},
{
"type": "npm",
"script": "watch:tsc",
"group": "build",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"label": "npm: watch:tsc",
"presentation": {
"group": "watch",
"reveal": "never"
}
},
{
"type": "npm",
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build"
},
{
"label": "tasks: watch-tests",
"dependsOn": [
"npm: watch",
"npm: watch-tests"
],
"problemMatcher": []
}
]
}
16 changes: 13 additions & 3 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
.vscode/**
.vscode-test/**
out/test/**
out/**
node_modules/**
src/**
.gitignore
vsc-extension-quickstart.md
.gitattributes
esbuild.js
**/tsconfig.json
**/.eslintrc.json
**/eslint.config.mjs
**/*.map
**/*.ts
**/.vscode-test.*
package-lock.json
CLAUDE.md
.claude/**
**/.DS_Store
icon-preview.html
images/icon-source.png
images/icon@256.png
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## v1.0.0 (2026-06-28)

The first stable release — a ground-up relaunch as **Random & Fake Data Generator**.

### Features

- Switched the random engine to [`@faker-js/faker`](https://fakerjs.dev) (single locale) for realistic, coherent data.
- Expanded the catalog to ~24 data types — names, email, username, phone, UUID, hash, numbers, boolean, dates, country/city/address, IP/MAC/URL, color, password, words/sentences/lorem, and more.
- **Multi-cursor fill** — insert a different value at every cursor in one step.
- New **Insert Random: Pick…** command — choose any type from a searchable, grouped menu.
- **Clipboard insert type** — set `insertType` to `Clipboard` to copy a generated value to the clipboard instead of inserting it (no editor needed; resolves #4).
- New settings: `insertRandomText.uniquePerCursor`, `insertRandomText.seed` (reproducible output), `insertRandomText.bulkCount`, `insertRandomText.outputFormat` (`plain` / `jsonArray` / `quotedList`), and an opt-in editor context-menu submenu (`insertRandomText.contextMenu.enabled`).

### Fixes

- Lorem is now genuinely randomized (previously a fixed substring of one hardcoded string).
- Random string is alphanumeric, so it no longer breaks quote-wrapping.
- Removed the global notification-clearing side effect and a duplicate-draw bug in the animal command.

### Changes

- Removed the unused `loremSize`, `hashSize`, and `disableNotifs` settings.
- Existing `extension.insertRandom*` commands continue to work unchanged.
- Modernized the build (esbuild bundle; now requires VS Code 1.97+).

## v0.1.3 (2020-7-25)

### Changes
Expand Down
67 changes: 67 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## What this is

VS Code extension (display name **"Random & Fake Data Generator"**, id `insert-random-text`, publisher `ElecTreeFrying`) that inserts random / fake / mock data — names, emails, addresses, numbers, dates, UUIDs, lorem ipsum, and ~24 types in all — at **every cursor**. Randomness comes from **`@faker-js/faker`** (single-locale `en`).

### Project goals (north star)
1. Grow active installs in the random/mock-data category (near-term: pass the category mid-tier; long-term: challenge the leader). Active installs *subtract* on uninstall, so **retention is the real metric** — every defect fix is rank-defending.
2. Value is the engine: each generator is simultaneously a real feature, a searchable command title, and a Quick Pick entry. Breadth = discoverability + utility.

## Commands

- `npm run compile` — type-check + lint + **esbuild** bundle (`src/extension.ts` → `dist/extension.js`)
- `npm run watch` — incremental dev build; `watch:esbuild` + `watch:tsc` in parallel (`npm-run-all`). Default build task (auto-runs on F5 via `preLaunchTask`).
- `npm run check-types` — `tsc --noEmit` (esbuild does the actual transpile)
- `npm run lint` — `eslint src` (flat config, `eslint.config.mjs`)
- `npm run package` — production build: `check-types && lint && esbuild --production`. `vscode:prepublish` runs this.
- `npx @vscode/vsce package` — build the `.vsix` (runs prepublish first). Keep the packaged `.vsix` ≤ ~1.5 MB.

`main` is `./dist/extension.js` (esbuild bundle, **faker inlined**). `dist/` and `out/` are gitignored — build before running. **esbuild's entry is `src/extension.ts`, so that file must keep its name/location** (the entry is configured in `esbuild.js`, which is out of the usual edit scope).

### Verification (there is no test suite right now)
All tests were removed at the owner's request; **do not (re)introduce tests unless asked.** When they return, they belong in a dedicated **`/test`** directory (matching the sibling `auto-import-relative-path` layout) — never as loose `.spec.ts` files in `src/`. The `test` / `compile-tests` / `test:coverage` scripts and `.vscode-test.mjs` remain as scaffolding. Until then, verify with `check-types` + `lint` + `node esbuild.js --production` + `npx @vscode/vsce package`; for pure logic (`catalog` / `formatter`), a throwaway esbuild-bundled `node` script is the quick sanity check.

### Running / debugging
Press F5 → **"Run Extension"** opens an Extension Development Host with the extension loaded (the `preLaunchTask` builds first).

## Architecture

Five single-responsibility modules. Generation is `vscode`-free and lives apart from the editor glue, so the logic that matters is decoupled from the API surface:

- **`src/engine.ts`** — faker lifecycle: `load()` (lazy, idempotent), the `faker()` accessor, and `seed()`. Encapsulates the ESM/dynamic-import detail (see Gotchas). No `vscode` import.
- **`src/catalog.ts`** — the **generator registry**: the `Generator` interface and the readonly `generators` array (each `{ id, label, group, hidden?, generate() }`), plus `getGenerator(id)`. Single source of truth — drives generation, the commands, and the Quick Pick. No `vscode` import.
- **`src/formatter.ts`** — **pure** rendering: `buildBlocks(cursorCount, generator, options)` returns one block per cursor; `formatBlock` applies `bulkCount` + `outputFormat` (`plain` / `jsonArray` / `quotedList`) + quote/newline wrapping. No `vscode` import → trivially checkable.
- **`src/configuration.ts`** — `Configuration` reads workspace settings into a typed `Settings` via `read()`; `ConfigKey` holds the package.json key constants; the two enum settings are normalized to booleans here. Depends only on a narrow `WorkspaceLike` seam, not `vscode`.
- **`src/extension.ts`** — thin activation entry. `COMMAND_TO_GENERATOR` maps every command id → a generator id; `activate()` registers them all through one `insertGenerated(id)`, plus the `insertRandomText.pick` Quick Pick. `insertGenerated`: `load()` faker → `applySeed()` → read cached `settings` → `buildBlocks` over `editor.selections` (Cursor mode = multi-cursor fill; Top mode = one block at line 1).

### Config flow (the key cross-file mechanism)
`extension.ts` holds a single module-level `settings: Settings`. On activate, `watchConfiguration()` snapshots it via `Configuration.read()`, then re-snapshots on any relevant `onDidChangeConfiguration`. Commands read this **cached** `settings`, never re-reading at invocation. Anything bypassing `watchConfiguration` sees stale config.

### Commands & settings model
- **Two command namespaces.** The original 14 `extension.insertRandom*` ids are kept for **back-compat** (existing keybindings); every new type uses a namespaced `insertRandomText.<id>` id. Both register via `COMMAND_TO_GENERATOR`.
- **Settings are split.** The 4 remaining legacy keys stay **flat & non-namespaced** (`quoteStyle`, `insertType`, `withQuote`, `withNewLine`) for back-compat; **all new keys are namespaced** under `insertRandomText.*` (`uniquePerCursor`, `seed`, `bulkCount`, `outputFormat`, `contextMenu.enabled`). Do **not** migrate the legacy keys.
- **Hidden generators.** The Lorem/Hash Small/Medium/Large back-compat generators carry `hidden: true` so they serve their legacy commands without cluttering the Quick Pick.

### Adding a generator (the common case)
1. `src/catalog.ts` — add a `{ id, label, group, generate }` entry. It appears in the Quick Pick automatically.
2. `package.json` → `contributes.commands` — add `{ "command": "insertRandomText.<id>", "title": "Insert Random: <Label>" }` (direct command + search visibility).
3. `src/extension.ts` — add `'insertRandomText.<id>': '<id>'` to `COMMAND_TO_GENERATOR`.

(activationEvents are auto-generated from `contributes.commands` since VS Code 1.74 — nothing to update there.)

### Config boolean conventions
- `insertType`: `true` = "Cursor" (multi-cursor fill at each selection), `false` = "Top" (one block at line 1 / `0,0`).
- `quoteStyle`: `true` = single quotes, `false` = double (only when `withQuote`).

## Gotchas

- **faker is ESM-only; the bundle is CJS.** `engine.ts` loads the single-locale instance via a **dynamic `import('@faker-js/faker/locale/en')`** inside `load()` — a *static* import trips `TS1479` under `module: Node16`. The faker **type** is imported with `import type { Faker } from '@faker-js/faker' with { 'resolution-mode': 'import' }` (the `TS1542` fix). esbuild inlines the dynamic import into the single CJS bundle. **Always import `/locale/en` — never the faker root** (60+ locales → multi-MB bundle, blows the `.vsix` size gate).
- **Fresh value per call — never a cached getter.** `Generator.generate()` is called once per cursor inside the `editor.selections` loop and must draw a new value each time. (The old code had an "animal double-draw" bug from a getter read twice — the registry shape structurally prevents it; don't reintroduce stored/memoized generator values.) With `seed` set, the sequence is reproducible.
- **Line endings are LF**, enforced by `.gitattributes` (`* text=auto eol=lf`).

## Scope & toolchain
- **Core work lives in `src/**`, `package.json`, `README.md`, `CLAUDE.md`, `CHANGELOG.md`.** Out of scope (later waves): icon assets under `images/`, CI, Open VSX, `tsconfig.json` / `esbuild.js`, re-adding tests.
- TypeScript 5.9 (target `ES2022`, module `Node16`, `strict: false`), ESLint 9 flat config (rules are warnings), esbuild bundling, engine `vscode ^1.97.0`. **Runtime dependency: `@faker-js/faker`** (bundled into `dist/`). Mirrors the sibling `auto-import-relative-path` extension.
Loading