thinkncollab-cli 0.0.9 β†’ 0.0.10

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.
Files changed (3) hide show
  1. package/Readme.md +302 -3
  2. package/bin/index.js +20 -1
  3. package/package.json +1 -1
package/Readme.md CHANGED
@@ -1,11 +1,310 @@
1
- "tnc-cli login" for login to get access for CLI to push files
1
+ # 🧠 ThinkNCollab CLI
2
2
 
3
- "tnc-cli push --room <roomId> <file-or-folder-path>" to push from the root directory.
3
+ A powerful command-line interface for seamless collaboration with **ThinkNCollab** β€” push files, manage rooms, and collaborate directly from your terminal.
4
4
 
5
- .ignoretnc files for ignorng the files...
5
+ ---
6
6
 
7
+ ## πŸš€ Quick Start
7
8
 
9
+ ```bash
10
+ # Install the CLI globally
11
+ npm install -g @thinkncollab/tnc-cli
8
12
 
13
+ # Login to your ThinkNCollab account
14
+ tnc-cli login
9
15
 
16
+ # Push files to a room
17
+ tnc-cli push --room 64a1b2c3d4e5f6a1b2c3d4e5 ./project-files/
18
+ ```
10
19
 
20
+ ---
11
21
 
22
+ ## πŸ” Authentication
23
+
24
+ ### **Login Command**
25
+
26
+ Authenticate with your ThinkNCollab account to enable CLI access:
27
+
28
+ ```bash
29
+ tnc-cli login
30
+ ```
31
+
32
+ ### **What Happens During Login**
33
+
34
+ - Opens a secure browser window to ThinkNCollab’s authentication page
35
+ - Completes OAuth2 authentication flow
36
+ - Creates an encrypted `.tncrc` configuration file in your home directory
37
+ - Stores secure tokens for future CLI sessions
38
+
39
+ ### **Manual Authentication**
40
+
41
+ ```bash
42
+ tnc-cli login --token YOUR_AUTH_TOKEN
43
+ ```
44
+
45
+ ### **Verify Authentication**
46
+
47
+ ```bash
48
+ tnc-cli whoami
49
+ ```
50
+
51
+ ### **Logout**
52
+
53
+ Clear stored credentials:
54
+
55
+ ```bash
56
+ tnc-cli logout
57
+ ```
58
+
59
+ ---
60
+
61
+ ## πŸ“¦ File Operations
62
+
63
+ ### **Push Command**
64
+
65
+ Push files or directories to ThinkNCollab rooms:
66
+
67
+ ```bash
68
+ tnc-cli push --room <roomId> <path>
69
+ ```
70
+
71
+ #### **Syntax**
72
+
73
+ ```bash
74
+ tnc-cli push --room ROOM_ID PATH [ADDITIONAL_PATHS...]
75
+ ```
76
+
77
+ #### **Examples**
78
+
79
+ | Action | Command |
80
+ |--------|----------|
81
+ | Push a single file | `tnc-cli push --room 64a1b2c3d4e5f6a1b2c3d4e5 document.pdf` |
82
+ | Push entire folder | `tnc-cli push --room 64a1b2c3d4e5f6a1b2c3d4e5 ./src/` |
83
+ | Push multiple items | `tnc-cli push --room 64a1b2c3d4e5f6a1b2c3d4e5 file1.js assets/ components/` |
84
+ | Push current directory | `tnc-cli push --room 64a1b2c3d4e5f6a1b2c3d4e5 .` |
85
+
86
+ #### **Options**
87
+
88
+ | Option | Short | Description |
89
+ |---------|--------|-------------|
90
+ | `--room` | `-r` | **Required:** Target room ID |
91
+ | `--message` | `-m` | Commit message describing changes |
92
+ | `--force` | `-f` | Force push (overwrite conflicts) |
93
+ | `--dry-run` | β€” | Preview files before pushing |
94
+ | `--exclude` | β€” | Additional patterns to exclude |
95
+
96
+ ---
97
+
98
+ ## 🧩 Room Management
99
+
100
+ | Command | Description |
101
+ |----------|--------------|
102
+ | `tnc-cli rooms list` | List accessible rooms |
103
+ | `tnc-cli rooms info <id>` | Show details for a specific room |
104
+
105
+ ---
106
+
107
+ ## 🚫 File Ignoring
108
+
109
+ Use a `.ignoretnc` file in your project root to exclude files/folders during push.
110
+
111
+ ### **Example `.ignoretnc`**
112
+
113
+ ```text
114
+ # Dependencies
115
+ node_modules/
116
+ vendor/
117
+ bower_components/
118
+
119
+ # Build outputs
120
+ /dist
121
+ /build
122
+ /.next
123
+ /out
124
+
125
+ # Environment
126
+ .env
127
+ .env.local
128
+ .env.production
129
+ .env.development
130
+
131
+ # Logs
132
+ *.log
133
+ npm-debug.log*
134
+ yarn-debug.log*
135
+
136
+ # Temporary / OS
137
+ *.tmp
138
+ .DS_Store
139
+ Thumbs.db
140
+
141
+ # IDE
142
+ .vscode/
143
+ .idea/
144
+
145
+ # Test
146
+ *.test.js
147
+ *.spec.js
148
+ /coverage/
149
+
150
+ # Large assets
151
+ *.psd
152
+ *.ai
153
+ *.sketch
154
+ ```
155
+
156
+ ### **Pattern Rules**
157
+
158
+ | Type | Example | Description |
159
+ |------|----------|-------------|
160
+ | Directory | `dist/` | Ignore whole directory |
161
+ | File Extension | `*.log` | Ignore all `.log` files |
162
+ | Specific File | `secret.env` | Ignore single file |
163
+ | Wildcard | `test-*.js` | Match name patterns |
164
+ | Negation | `!keep.js` | Include despite other rules |
165
+ | Comment | `# comment` | Ignored by parser |
166
+
167
+ ---
168
+
169
+ ## βš™οΈ Configuration
170
+
171
+ After login, an encrypted `.tncrc` file is created in your home directory.
172
+
173
+ ### **Example `.tncrc`**
174
+
175
+ ```json
176
+ {
177
+ "user": {
178
+ "id": "encrypted_user_id",
179
+ "email": "encrypted_email",
180
+ "name": "encrypted_display_name"
181
+ },
182
+ "auth": {
183
+ "token": "encrypted_jwt_token",
184
+ "refreshToken": "encrypted_refresh_token",
185
+ "expires": "2025-12-31T23:59:59Z"
186
+ },
187
+ "workspace": {
188
+ "id": "encrypted_workspace_id",
189
+ "name": "encrypted_workspace_name"
190
+ },
191
+ "settings": {
192
+ "defaultRoom": "optional_default_room_id",
193
+ "autoSync": false
194
+ }
195
+ }
196
+ ```
197
+
198
+ ### **Environment Variables**
199
+
200
+ ```bash
201
+ export TNC_API_TOKEN="your_api_token"
202
+ export TNC_API_URL="https://api.thinkncollab.com"
203
+ export TNC_DEFAULT_ROOM="your_default_room_id"
204
+ ```
205
+
206
+ ---
207
+
208
+ ## ⚑ Advanced Usage
209
+
210
+ ### **Batch Push**
211
+
212
+ ```bash
213
+ tnc-cli push --room room1,room2,room3 ./shared-assets/
214
+ ```
215
+
216
+ ### **CI/CD Integration**
217
+
218
+ ```bash
219
+ tnc-cli login --token $TNC_DEPLOY_TOKEN
220
+ tnc-cli push --room $PRODUCTION_ROOM ./dist/ --message "Build ${CI_COMMIT_SHA}"
221
+ ```
222
+
223
+ ### **Watch for Changes (Experimental)**
224
+
225
+ ```bash
226
+ tnc-cli watch --room 64a1b2c3d4e5f6a1b2c3d4e5 ./src/
227
+ ```
228
+
229
+ ---
230
+
231
+ ## 🧰 Troubleshooting
232
+
233
+ ### **Authentication Issues**
234
+
235
+ ```bash
236
+ tnc-cli logout
237
+ tnc-cli login
238
+ ```
239
+
240
+ - Ensure valid token and room access
241
+ - Token may need refresh or rotation
242
+
243
+ ### **Permission Errors**
244
+
245
+ - Confirm write access to target room
246
+ - Check if the room ID is active
247
+
248
+ ### **File Size Limits**
249
+
250
+ | Type | Limit |
251
+ |------|--------|
252
+ | Individual File | 100 MB |
253
+ | Total Push | 1 GB |
254
+
255
+ ### **Debug Mode**
256
+
257
+ Enable detailed logs:
258
+
259
+ ```bash
260
+ tnc-cli --debug push --room 64a1b2c3d4e5f6a1b2c3d4e5 ./path/
261
+ ```
262
+
263
+ ---
264
+
265
+ ## πŸ”’ Security Guidelines
266
+
267
+ - **Never share** your `.tncrc` file β€” it stores encrypted tokens
268
+ - **Never commit** `.tncrc` to Git or any version control
269
+ - Use `.ignoretnc` to exclude sensitive files
270
+ - Rotate API tokens regularly
271
+ - Validate room access before pushing confidential data
272
+
273
+ ---
274
+
275
+ ## πŸ’‘ Best Practices
276
+
277
+ - Use environment variables for automated environments
278
+ - Review `.ignoretnc` before each push
279
+ - Run `--dry-run` to preview changes
280
+ - Monitor push logs for unexpected files
281
+
282
+ ---
283
+
284
+ ## 🧭 Command Reference
285
+
286
+ | Command | Description |
287
+ |----------|-------------|
288
+ | `tnc-cli login` | Authenticate with ThinkNCollab |
289
+ | `tnc-cli logout` | Clear credentials |
290
+ | `tnc-cli whoami` | Show current user info |
291
+ | `tnc-cli push --room <id> <path>` | Push files/folders to a room |
292
+ | `tnc-cli rooms list` | List all accessible rooms |
293
+ | `tnc-cli rooms info <id>` | Show room details |
294
+ | `tnc-cli --version` | Show CLI version |
295
+ | `tnc-cli --help` | Show help information |
296
+
297
+ ---
298
+
299
+ ## 🧩 Resources & Support
300
+
301
+ - πŸ“˜ **Documentation:** [docs.thinkncollab.com/cli](https://docs.thinkncollab.com/cli)
302
+ - πŸ™ **GitHub Issues:** [ThinkNCollab Repository](https://github.com/thinkncollab)
303
+ - βœ‰οΈ **Email:** support@thinkncollab.com
304
+ - πŸ’¬ **Community:** Join our [ThinkNCollab Discord](https://discord.gg/thinkncollab)
305
+
306
+ ---
307
+
308
+ ## πŸ“„ License
309
+
310
+ MIT License – see `LICENSE` file for details.
package/bin/index.js CHANGED
@@ -10,6 +10,21 @@ import FormData from "form-data";
10
10
  const RC_FILE = path.join(os.homedir(), ".tncrc");
11
11
  const BASE_URL = "https://thinkncollab.com/rooms";
12
12
 
13
+ // LOGOUT
14
+ async function logout() {
15
+ try {
16
+ if (fs.existsSync(RC_FILE)) {
17
+ // Remove the .tncrc file safely
18
+ await fs.promises.rm(RC_FILE, { force: true });
19
+ console.log("βœ… Logged out successfully. Local credentials removed.");
20
+ } else {
21
+ console.log("ℹ️ No active session found.");
22
+ }
23
+ } catch (err) {
24
+ console.error("❌ Error during logout:", err.message);
25
+ }
26
+ }
27
+
13
28
  /** ========== LOGIN ========== **/
14
29
  async function login() {
15
30
  const answers = await inquirer.prompt([
@@ -216,10 +231,14 @@ switch (args[0]) {
216
231
  push(roomId, targetPath);
217
232
  break;
218
233
  }
234
+ case "logout": {
235
+ logout();
236
+ break;
237
+ }
219
238
 
220
239
  default:
221
240
  console.log("βœ… TNC CLI ready!");
222
241
  console.log("Commands:");
223
242
  console.log(" tnc login");
224
243
  console.log(" tnc push --room <roomId> <path>");
225
- }
244
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thinkncollab-cli",
3
3
  "author": "Raman Singh",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "description": "CLI tool for ThinkNCollab",
6
6
  "main": "index.js",
7
7
  "bin": {