catco 0.0.1 → 1.0.1

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/README.md CHANGED
@@ -1,11 +1,51 @@
1
1
  # catco
2
2
 
3
+ Glob copy file contents to ya clipboard. Use it to quickly share many files with an AI code assistant.
4
+
5
+ ## Install
6
+
3
7
  ```
4
8
  npm i -g catco
5
9
  ```
6
10
 
11
+ ## Examples
12
+
7
13
  Tell it what files, and it will concatenate them all and copy them to your clipboard (whitespace minimized) so you can go paste that shit to GPT, Perplexity, Claude, whatever AI to ask for help or whatever.
8
14
 
9
15
  ```
10
- catco foo.ts bar.ts some/directory/*.ts
16
+ catco src/components/**/*.ts
17
+
18
+ catco src/components/**/*.ts src/styles/**/*.css
19
+
20
+ catco src/components/**/*.ts src/styles/**/*.css --ignore *.test.ts
21
+ ```
22
+
23
+ ## Default Ignore Patterns
24
+
25
+ ```
26
+ node_modules
27
+ node_modules/**
28
+ .git
29
+ .git/**
30
+ .github
31
+ .github/**
32
+ dist
33
+ dist/**
34
+ build
35
+ build/**
36
+ coverage
37
+ coverage/**
38
+ .next
39
+ .next/**
40
+ .vercel
41
+ .vercel/**
42
+ .turbo
43
+ .turbo/**
44
+ .DS_Store
45
+ *.log
46
+ npm-debug.log
47
+ yarn-error.log
48
+ pnpm-debug.log
49
+ .env
50
+ .env.*
11
51
  ```
package/dist/index.cjs CHANGED
@@ -1,34 +1,103 @@
1
1
  'use strict';
2
2
 
3
- var globby = require('globby');
4
3
  var fs = require('node:fs');
5
4
  var path = require('node:path');
5
+ var globby = require('globby');
6
6
  var clipboard = require('clipboardy');
7
7
 
8
- function minify(content) {
9
- return content.replace(/\s+/g, " ").replace(/\s*([\{\}\[\]\(\),;:])\s*/g, "$1").replace(/\s*=\s*/g, "=").replace(/\s*>\s*/g, ">").replace(/;\s*/g, ";").replace(/"\s+/g, '"').replace(/\s+"/g, '"').replace(/'\s+/g, "'").replace(/\s+'/g, "'").trim();
10
- }
8
+ const minify = (content) => {
9
+ const minified = content.replace(/\s+/g, " ").replace(/\s*([\{\}\[\]\(\),;:])\s*/g, "$1").replace(/\s*=\s*/g, "=").replace(/\s*>\s*/g, ">").replace(/;\s*/g, ";").replace(/"\s+/g, '"').replace(/\s+"/g, '"').replace(/'\s+/g, "'").replace(/\s+'/g, "'").trim();
10
+ if (!minified) return "(EMPTY FILE)";
11
+ return minified;
12
+ };
11
13
 
12
- async function catco(patterns) {
13
- let allContents = "";
14
- for (const pattern of patterns) {
15
- const files = await globby.globby(pattern);
16
- for (const file of files) {
17
- const content = await fs.promises.readFile(file, "utf-8");
18
- const minifiedContent = minify(content);
19
- allContents += `/* FILE: ${path.resolve(file)} */ ${minifiedContent} `;
14
+ const DEFAULT_ANTI_PATTERNS = [
15
+ "node_modules",
16
+ "node_modules/**",
17
+ ".git",
18
+ ".git/**",
19
+ ".github",
20
+ ".github/**",
21
+ "dist",
22
+ "dist/**",
23
+ "build",
24
+ "build/**",
25
+ "coverage",
26
+ "coverage/**",
27
+ ".next",
28
+ ".next/**",
29
+ ".vercel",
30
+ ".vercel/**",
31
+ ".turbo",
32
+ ".turbo/**",
33
+ ".DS_Store",
34
+ "*.log",
35
+ "npm-debug.log",
36
+ "yarn-error.log",
37
+ "pnpm-debug.log",
38
+ ".env",
39
+ ".env.*"
40
+ ];
41
+
42
+ const argv = process.argv.slice(2);
43
+ const getInput = () => {
44
+ let hasIgnorePassed = false;
45
+ const patterns = [];
46
+ const ignorePatterns = [];
47
+ for (const value of argv) {
48
+ if (value === "--ignore") {
49
+ hasIgnorePassed = true;
50
+ continue;
20
51
  }
52
+ if (hasIgnorePassed) ignorePatterns.push(value);
53
+ if (!hasIgnorePassed) patterns.push(value);
21
54
  }
22
- if (allContents) {
23
- await clipboard.write(allContents);
24
- console.log("Contents copied to clipboard!");
25
- } else {
26
- console.log("No matching files found.");
27
- }
28
- }
29
- const args = process.argv.slice(2);
30
- if (args.length === 0) {
31
- console.log("Usage: catco [...patterns]");
55
+ const ignore = ignorePatterns.length ? ignorePatterns : DEFAULT_ANTI_PATTERNS;
56
+ return { patterns, ignore };
57
+ };
58
+ const input = getInput();
59
+
60
+ if (input.patterns.length === 0) {
61
+ console.log("[catco] usage: catco [...patterns]");
62
+ console.log("");
63
+ console.log("Examples:");
64
+ console.log(" catco ./");
65
+ console.log(' catco "./src/**/*.ts"');
66
+ console.log(' catco "./src/**/*.{js,ts}"');
67
+ console.log(' catco "./*.js"');
68
+ console.log(' catco "./src/**/index.ts"');
69
+ console.log(' catco "./src/**/*.test.ts"');
70
+ console.log(' catco "./**/*.md"');
71
+ console.log(' catco "./src/utils/*.ts" "./src/components/*.ts"');
72
+ console.log(' catco "./**/*" "!./node_modules"');
73
+ console.log(' catco "./src/**/*" --exclude="./src/**/*.spec.ts"');
74
+ console.log("");
75
+ console.log("Supports multiple patterns and globs. Use quotes for complex patterns.");
32
76
  process.exit(1);
33
77
  }
34
- catco(args);
78
+ const createOutputContents = (filePath, content) => {
79
+ return `/* FILE: ${path.resolve(filePath)} */ ${content} `;
80
+ };
81
+ const catco = async () => {
82
+ const fileContentsList = [];
83
+ const options = { ignore: input.ignore };
84
+ const filePaths = await globby.globby(input.patterns, options);
85
+ console.log(`[catco] found ${filePaths.length} files.`);
86
+ for (const filePath of filePaths) {
87
+ const content = await fs.promises.readFile(filePath, "utf-8");
88
+ const final = createOutputContents(filePath, content);
89
+ fileContentsList.push(final);
90
+ }
91
+ if (fileContentsList.length) {
92
+ const joined = fileContentsList.join("\n");
93
+ const minified = minify(joined);
94
+ await clipboard.write(minified);
95
+ console.log(`[catco] pre-minified length: ${joined.length}`);
96
+ console.log(`[catco] post-minified length: ${minified.length}`);
97
+ console.log(`[catco] all files contents copied to clipboard!`);
98
+ }
99
+ if (!fileContentsList) {
100
+ console.warn(`[catco] no matching files found for patterns: ${input.patterns}`);
101
+ }
102
+ };
103
+ catco();
@@ -0,0 +1 @@
1
+ #!/usr/bin/env bun
@@ -0,0 +1 @@
1
+ #!/usr/bin/env bun
package/dist/index.js CHANGED
@@ -1,33 +1,102 @@
1
1
  #!/usr/bin/env node
2
- import { globby } from 'globby';
3
2
  import fs from 'node:fs';
4
3
  import path from 'node:path';
4
+ import { globby } from 'globby';
5
5
  import clipboard from 'clipboardy';
6
6
 
7
- function minify(content) {
8
- return content.replace(/\s+/g, " ").replace(/\s*([\{\}\[\]\(\),;:])\s*/g, "$1").replace(/\s*=\s*/g, "=").replace(/\s*>\s*/g, ">").replace(/;\s*/g, ";").replace(/"\s+/g, '"').replace(/\s+"/g, '"').replace(/'\s+/g, "'").replace(/\s+'/g, "'").trim();
9
- }
7
+ const minify = (content) => {
8
+ const minified = content.replace(/\s+/g, " ").replace(/\s*([\{\}\[\]\(\),;:])\s*/g, "$1").replace(/\s*=\s*/g, "=").replace(/\s*>\s*/g, ">").replace(/;\s*/g, ";").replace(/"\s+/g, '"').replace(/\s+"/g, '"').replace(/'\s+/g, "'").replace(/\s+'/g, "'").trim();
9
+ if (!minified) return "(EMPTY FILE)";
10
+ return minified;
11
+ };
10
12
 
11
- async function catco(patterns) {
12
- let allContents = "";
13
- for (const pattern of patterns) {
14
- const files = await globby(pattern);
15
- for (const file of files) {
16
- const content = await fs.promises.readFile(file, "utf-8");
17
- const minifiedContent = minify(content);
18
- allContents += `/* FILE: ${path.resolve(file)} */ ${minifiedContent} `;
13
+ const DEFAULT_ANTI_PATTERNS = [
14
+ "node_modules",
15
+ "node_modules/**",
16
+ ".git",
17
+ ".git/**",
18
+ ".github",
19
+ ".github/**",
20
+ "dist",
21
+ "dist/**",
22
+ "build",
23
+ "build/**",
24
+ "coverage",
25
+ "coverage/**",
26
+ ".next",
27
+ ".next/**",
28
+ ".vercel",
29
+ ".vercel/**",
30
+ ".turbo",
31
+ ".turbo/**",
32
+ ".DS_Store",
33
+ "*.log",
34
+ "npm-debug.log",
35
+ "yarn-error.log",
36
+ "pnpm-debug.log",
37
+ ".env",
38
+ ".env.*"
39
+ ];
40
+
41
+ const argv = process.argv.slice(2);
42
+ const getInput = () => {
43
+ let hasIgnorePassed = false;
44
+ const patterns = [];
45
+ const ignorePatterns = [];
46
+ for (const value of argv) {
47
+ if (value === "--ignore") {
48
+ hasIgnorePassed = true;
49
+ continue;
19
50
  }
51
+ if (hasIgnorePassed) ignorePatterns.push(value);
52
+ if (!hasIgnorePassed) patterns.push(value);
20
53
  }
21
- if (allContents) {
22
- await clipboard.write(allContents);
23
- console.log("Contents copied to clipboard!");
24
- } else {
25
- console.log("No matching files found.");
26
- }
27
- }
28
- const args = process.argv.slice(2);
29
- if (args.length === 0) {
30
- console.log("Usage: catco [...patterns]");
54
+ const ignore = ignorePatterns.length ? ignorePatterns : DEFAULT_ANTI_PATTERNS;
55
+ return { patterns, ignore };
56
+ };
57
+ const input = getInput();
58
+
59
+ if (input.patterns.length === 0) {
60
+ console.log("[catco] usage: catco [...patterns]");
61
+ console.log("");
62
+ console.log("Examples:");
63
+ console.log(" catco ./");
64
+ console.log(' catco "./src/**/*.ts"');
65
+ console.log(' catco "./src/**/*.{js,ts}"');
66
+ console.log(' catco "./*.js"');
67
+ console.log(' catco "./src/**/index.ts"');
68
+ console.log(' catco "./src/**/*.test.ts"');
69
+ console.log(' catco "./**/*.md"');
70
+ console.log(' catco "./src/utils/*.ts" "./src/components/*.ts"');
71
+ console.log(' catco "./**/*" "!./node_modules"');
72
+ console.log(' catco "./src/**/*" --exclude="./src/**/*.spec.ts"');
73
+ console.log("");
74
+ console.log("Supports multiple patterns and globs. Use quotes for complex patterns.");
31
75
  process.exit(1);
32
76
  }
33
- catco(args);
77
+ const createOutputContents = (filePath, content) => {
78
+ return `/* FILE: ${path.resolve(filePath)} */ ${content} `;
79
+ };
80
+ const catco = async () => {
81
+ const fileContentsList = [];
82
+ const options = { ignore: input.ignore };
83
+ const filePaths = await globby(input.patterns, options);
84
+ console.log(`[catco] found ${filePaths.length} files.`);
85
+ for (const filePath of filePaths) {
86
+ const content = await fs.promises.readFile(filePath, "utf-8");
87
+ const final = createOutputContents(filePath, content);
88
+ fileContentsList.push(final);
89
+ }
90
+ if (fileContentsList.length) {
91
+ const joined = fileContentsList.join("\n");
92
+ const minified = minify(joined);
93
+ await clipboard.write(minified);
94
+ console.log(`[catco] pre-minified length: ${joined.length}`);
95
+ console.log(`[catco] post-minified length: ${minified.length}`);
96
+ console.log(`[catco] all files contents copied to clipboard!`);
97
+ }
98
+ if (!fileContentsList) {
99
+ console.warn(`[catco] no matching files found for patterns: ${input.patterns}`);
100
+ }
101
+ };
102
+ catco();
package/dist/index.mjs ADDED
@@ -0,0 +1,101 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { globby } from 'globby';
4
+ import clipboard from 'clipboardy';
5
+
6
+ const minify = (content) => {
7
+ const minified = content.replace(/\s+/g, " ").replace(/\s*([\{\}\[\]\(\),;:])\s*/g, "$1").replace(/\s*=\s*/g, "=").replace(/\s*>\s*/g, ">").replace(/;\s*/g, ";").replace(/"\s+/g, '"').replace(/\s+"/g, '"').replace(/'\s+/g, "'").replace(/\s+'/g, "'").trim();
8
+ if (!minified) return "(EMPTY FILE)";
9
+ return minified;
10
+ };
11
+
12
+ const DEFAULT_ANTI_PATTERNS = [
13
+ "node_modules",
14
+ "node_modules/**",
15
+ ".git",
16
+ ".git/**",
17
+ ".github",
18
+ ".github/**",
19
+ "dist",
20
+ "dist/**",
21
+ "build",
22
+ "build/**",
23
+ "coverage",
24
+ "coverage/**",
25
+ ".next",
26
+ ".next/**",
27
+ ".vercel",
28
+ ".vercel/**",
29
+ ".turbo",
30
+ ".turbo/**",
31
+ ".DS_Store",
32
+ "*.log",
33
+ "npm-debug.log",
34
+ "yarn-error.log",
35
+ "pnpm-debug.log",
36
+ ".env",
37
+ ".env.*"
38
+ ];
39
+
40
+ const argv = process.argv.slice(2);
41
+ const getInput = () => {
42
+ let hasIgnorePassed = false;
43
+ const patterns = [];
44
+ const ignorePatterns = [];
45
+ for (const value of argv) {
46
+ if (value === "--ignore") {
47
+ hasIgnorePassed = true;
48
+ continue;
49
+ }
50
+ if (hasIgnorePassed) ignorePatterns.push(value);
51
+ if (!hasIgnorePassed) patterns.push(value);
52
+ }
53
+ const ignore = ignorePatterns.length ? ignorePatterns : DEFAULT_ANTI_PATTERNS;
54
+ return { patterns, ignore };
55
+ };
56
+ const input = getInput();
57
+
58
+ if (input.patterns.length === 0) {
59
+ console.log("[catco] usage: catco [...patterns]");
60
+ console.log("");
61
+ console.log("Examples:");
62
+ console.log(" catco ./");
63
+ console.log(' catco "./src/**/*.ts"');
64
+ console.log(' catco "./src/**/*.{js,ts}"');
65
+ console.log(' catco "./*.js"');
66
+ console.log(' catco "./src/**/index.ts"');
67
+ console.log(' catco "./src/**/*.test.ts"');
68
+ console.log(' catco "./**/*.md"');
69
+ console.log(' catco "./src/utils/*.ts" "./src/components/*.ts"');
70
+ console.log(' catco "./**/*" "!./node_modules"');
71
+ console.log(' catco "./src/**/*" --exclude="./src/**/*.spec.ts"');
72
+ console.log("");
73
+ console.log("Supports multiple patterns and globs. Use quotes for complex patterns.");
74
+ process.exit(1);
75
+ }
76
+ const createOutputContents = (filePath, content) => {
77
+ return `/* FILE: ${path.resolve(filePath)} */ ${content} `;
78
+ };
79
+ const catco = async () => {
80
+ const fileContentsList = [];
81
+ const options = { ignore: input.ignore };
82
+ const filePaths = await globby(input.patterns, options);
83
+ console.log(`[catco] found ${filePaths.length} files.`);
84
+ for (const filePath of filePaths) {
85
+ const content = await fs.promises.readFile(filePath, "utf-8");
86
+ const final = createOutputContents(filePath, content);
87
+ fileContentsList.push(final);
88
+ }
89
+ if (fileContentsList.length) {
90
+ const joined = fileContentsList.join("\n");
91
+ const minified = minify(joined);
92
+ await clipboard.write(minified);
93
+ console.log(`[catco] pre-minified length: ${joined.length}`);
94
+ console.log(`[catco] post-minified length: ${minified.length}`);
95
+ console.log(`[catco] all files contents copied to clipboard!`);
96
+ }
97
+ if (!fileContentsList) {
98
+ console.warn(`[catco] no matching files found for patterns: ${input.patterns}`);
99
+ }
100
+ };
101
+ catco();
package/package.json CHANGED
@@ -1,53 +1,60 @@
1
1
  {
2
- "name": "catco",
3
- "version": "0.0.1",
4
- "type": "module",
5
- "main": "./dist/index.cjs",
6
- "module": "./dist/index.js",
7
- "description": "",
8
- "exports": {
9
- "import": "./dist/index.js",
10
- "require": "./dist/index.cjs"
11
- },
12
- "scripts": {
13
- "build": "tsx"
14
- },
15
- "files": [
16
- "dist"
17
- ],
18
- "keywords": [
19
- "ai",
20
- "ai-assistant",
21
- "ai-tools",
22
- "gpt",
23
- "copy",
24
- "clipboard",
25
- "claude",
26
- "chatgpt",
27
- "chatgpt4o",
28
- "chatgpt4o-mini"
29
- ],
30
- "bin": {
31
- "catco": "./dist/index.js"
32
- },
33
- "license": "MIT",
34
- "homepage": "https://github.com/tasteee/catco",
35
- "repository": {
36
- "type": "git",
37
- "url": "git+https://github.com/tasteee/catco.git"
38
- },
39
- "bugs": "https://github.com/tasteee/catco/issues",
40
- "author": "tasteink <tasteink@proton.me>",
41
- "devDependencies": {
42
- "tsx": "^4.19.2",
43
- "vitest": "^2.1.3",
44
- "typescript": "^5.6.3"
45
- },
46
- "dependencies": {
47
- "clipboardy": "^4.0.0",
48
- "globby": "^14.0.2"
49
- },
50
- "publishConfig": {
51
- "access": "public"
52
- }
2
+ "name": "catco",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "description": "Glob copy file contents to ya clipboard.",
6
+ "scripts": {
7
+ "build": "pkgroll",
8
+ "start": "tsx src/index.ts ./src/**/*.ts"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "main": "./dist/index.cjs",
14
+ "module": "./dist/index.mjs",
15
+ "exports": {
16
+ "import": {
17
+ "default": "./dist/index.mjs"
18
+ },
19
+ "require": {
20
+ "default": "./dist/index.cjs"
21
+ }
22
+ },
23
+ "bin": {
24
+ "catco": "./dist/index.js"
25
+ },
26
+ "license": "MIT",
27
+ "homepage": "https://github.com/tasteee/catco",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/tasteee/catco.git"
31
+ },
32
+ "bugs": "https://github.com/tasteee/catco/issues",
33
+ "author": "tasteink <rocolcleasure@gmail.com>",
34
+ "devDependencies": {
35
+ "pkgroll": "^2.12.2",
36
+ "prettier": "^3.5.3",
37
+ "tsx": "^4.19.2",
38
+ "typescript": "^5.6.3",
39
+ "vitest": "^2.1.3"
40
+ },
41
+ "dependencies": {
42
+ "clipboardy": "^4.0.0",
43
+ "globby": "^14.0.2"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "keywords": [
49
+ "ai",
50
+ "ai-assistant",
51
+ "ai-tools",
52
+ "gpt",
53
+ "copy",
54
+ "clipboard",
55
+ "claude",
56
+ "chatgpt",
57
+ "chatgpt4o",
58
+ "chatgpt4o-mini"
59
+ ]
53
60
  }