1ls 0.0.2 → 0.1.0

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,45 @@
1
+ export interface JsonPath {
2
+ path: string;
3
+ value: unknown;
4
+ type: string;
5
+ displayValue: string;
6
+ }
7
+ export type InteractiveMode = "explore" | "build" | "build-arrow-fn";
8
+ export interface ExpressionBuilder {
9
+ basePath: string;
10
+ baseValue: unknown;
11
+ baseType: string;
12
+ expression: string;
13
+ currentMethodIndex: number;
14
+ arrowFnContext: ArrowFnContext | null;
15
+ }
16
+ export interface ArrowFnContext {
17
+ paramName: string;
18
+ paramType: string;
19
+ paramValue: unknown;
20
+ paramPaths: JsonPath[];
21
+ expression: string;
22
+ }
23
+ export interface Method {
24
+ name: string;
25
+ signature: string;
26
+ description: string;
27
+ template?: string;
28
+ category?: string;
29
+ }
30
+ export interface State {
31
+ mode: InteractiveMode;
32
+ paths: JsonPath[];
33
+ matches: FuzzyMatch<JsonPath>[];
34
+ query: string;
35
+ selectedIndex: number;
36
+ builder: ExpressionBuilder | null;
37
+ originalData: unknown;
38
+ methodMatches: FuzzyMatch<Method>[];
39
+ propertyMatches: FuzzyMatch<JsonPath>[];
40
+ }
41
+ export interface FuzzyMatch<T> {
42
+ item: T;
43
+ score: number;
44
+ matches: number[];
45
+ }
@@ -17,6 +17,7 @@ export declare function callMethod(target: unknown, method: string, args: readon
17
17
  export declare class JsonNavigator {
18
18
  evaluate(ast: ASTNode, data: unknown): unknown;
19
19
  private evaluatePropertyAccess;
20
+ private evaluateArg;
20
21
  private evaluateMethodCall;
21
22
  private createFunction;
22
23
  private evaluateFunctionBody;
@@ -0,0 +1,6 @@
1
+ import type { ShortcutMapping } from "../utils/types";
2
+ export declare const VALID_OUTPUT_FORMATS: readonly ["json", "yaml", "csv", "table"];
3
+ export declare const VALID_INPUT_FORMATS: readonly ["json", "yaml", "toml", "csv", "tsv", "lines", "text"];
4
+ export declare const SHORTCUTS: ShortcutMapping[];
5
+ export declare const HELP_TEXT = "1ls - Lightweight JSON CLI with JavaScript syntax\n\nUsage: 1ls [options] [expression]\n\nOptions:\n -h, --help Show this help message\n -v, --version Show version number\n -r, --raw Output raw strings without quotes\n -p, --pretty Pretty print output with indentation\n -c, --compact Output compact JSON (no whitespace)\n -t, --type Show the type of the result\n --format <format> Output format: json, yaml, csv, table\n --input-format, -if Input format: json, yaml, toml, csv, tsv, lines, text\n --detect Show detected input format without processing\n --shortcuts List available expression shortcuts\n\nExpression Syntax:\n . Identity (return entire input)\n .foo Access property 'foo'\n .foo.bar Nested property access\n .[0] Array index access\n .foo[0].bar Combined access\n .map(x => x.name) Transform each element\n .filter(x => x > 5) Filter elements\n .{keys} Get object keys\n .{values} Get object values\n .{length} Get length\n\nExamples:\n echo '{\"name\":\"test\"}' | 1ls .name\n echo '[1,2,3]' | 1ls '.map(x => x * 2)'\n echo '{\"a\":1,\"b\":2}' | 1ls '.{keys}'\n\nShortcuts:\n .mp -> .map .flt -> .filter .rd -> .reduce\n .fnd -> .find .sm -> .some .evr -> .every\n .srt -> .sort .rvs -> .reverse .jn -> .join\n .slc -> .slice .kys -> .{keys} .vls -> .{values}\n .ents -> .{entries} .len -> .{length}\n .lc -> .toLowerCase .uc -> .toUpperCase .trm -> .trim\n .splt -> .split .incl -> .includes\n";
6
+ export declare const SHORTCUTS_TEXT: string;
package/dist/types.d.ts CHANGED
@@ -22,12 +22,14 @@ export interface FormattingOptions {
22
22
  type?: boolean;
23
23
  format?: OutputFormat;
24
24
  inputFormat?: DataFormat;
25
+ detect?: boolean;
25
26
  }
26
27
  export interface CliOptions extends FileOperationOptions, ShorthandOptions, FormattingOptions {
27
28
  expression?: string;
28
29
  readFile?: boolean;
29
30
  help?: boolean;
30
31
  version?: boolean;
32
+ interactive?: boolean;
31
33
  }
32
34
  export declare enum TokenType {
33
35
  DOT = "DOT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "1ls",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "description": "1 line script - Lightweight JSON CLI with JavaScript syntax",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -8,6 +8,10 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "import": "./dist/index.js"
11
+ },
12
+ "./browser": {
13
+ "import": "./dist/browser/index.js",
14
+ "types": "./dist/browser/index.d.ts"
11
15
  }
12
16
  },
13
17
  "bin": {
@@ -19,21 +23,25 @@
19
23
  "files": [
20
24
  "dist"
21
25
  ],
26
+ "workspaces": [
27
+ "app"
28
+ ],
22
29
  "scripts": {
23
- "build": "bun run clean && bun build ./src/cli/index.ts --outdir dist --target bun --minify && tsc --emitDeclarationOnly --outDir dist",
24
- "clean": "rm -rf dist",
25
- "dev": "bun run ./src/cli/index.ts",
26
- "prepublishOnly": "bun run test && bun run build",
30
+ "dev": "turbo dev --filter=1ls-app",
31
+ "dev:cli": "bun run ./src/cli/index.ts",
32
+ "build": "rm -rf dist bin && bun build ./src/cli/index.ts --outdir dist --target bun --minify && bun build ./src/browser/index.ts --outdir dist/browser --target browser --minify --format esm && tsc --emitDeclarationOnly --outDir dist && cp -r src/completions dist/",
33
+ "build:binary:all": "rm -rf dist bin && mkdir -p bin && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/1ls-darwin-arm64 && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-x64 --outfile bin/1ls-darwin-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-x64 --outfile bin/1ls-linux-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-arm64 --outfile bin/1ls-linux-arm64",
34
+ "build:qjs": "bash scripts/build-qjs.sh",
35
+ "build:qjs:bundle": "mkdir -p dist/qjs && bun build ./src/browser/index.ts --outfile dist/qjs/core.js --target browser --minify --format esm",
36
+ "clean": "rm -rf dist bin",
37
+ "prepublishOnly": "bun run build && bun run lint && bun test",
27
38
  "test": "bun test",
28
- "test:unit": "bun test test/unit/",
39
+ "test:coverage": "bun test --coverage --coverage-reporter=lcov",
29
40
  "test:integration": "bun test test/integration/",
30
- "test:integration:docker": "cd test/integration && docker-compose up --build --abort-on-container-exit",
31
- "test:integration:docker:clean": "cd test/integration && docker-compose down -v",
32
- "typecheck": "tsc --noEmit",
33
41
  "lint": "bunx oxlint src/",
34
- "lint:fix": "bunx oxlint src/ --fix",
35
- "format": "bunx prettier --check 'src/**/*.{ts,tsx,js,jsx,json}'",
36
- "format:fix": "bunx prettier --write 'src/**/*.{ts,tsx,js,jsx,json}'"
42
+ "typecheck": "tsc --noEmit",
43
+ "release": "release-it",
44
+ "prepare": "bash scripts/setup-hooks.sh"
37
45
  },
38
46
  "keywords": [
39
47
  "json",
@@ -55,8 +63,27 @@
55
63
  "homepage": "https://github.com/yowainwright/1ls",
56
64
  "devDependencies": {
57
65
  "@types/bun": "latest",
66
+ "react": "^19.1.1",
67
+ "react-dom": "^19.1.1",
68
+ "release-it": "^19.0.5",
58
69
  "turbo": "^2.3.3",
59
70
  "typescript": "5.9.2"
60
71
  },
61
- "packageManager": "bun@1.1.38"
72
+ "packageManager": "bun@1.1.38",
73
+ "release-it": {
74
+ "git": {
75
+ "commitMessage": "chore(release): ${version}",
76
+ "tagName": "v${version}",
77
+ "requireCleanWorkingDir": true,
78
+ "requireUpstream": true
79
+ },
80
+ "github": {
81
+ "release": true,
82
+ "releaseName": "Release ${version}",
83
+ "releaseNotes": "git log --pretty=format:'* %s (%h)' ${latestTag}...HEAD"
84
+ },
85
+ "npm": {
86
+ "publish": true
87
+ }
88
+ }
62
89
  }