@naganpm/fetch-prompts 1.0.1 → 1.0.4

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 +52 -34
  2. package/bin/index.js +4 -4
  3. package/package.json +5 -2
package/README.md CHANGED
@@ -1,18 +1,59 @@
1
- # fetch-angular-prompts
1
+ # fetch-prompts
2
2
 
3
- Fetch Angular routing prompts from your GitLab repository.
3
+ Fetch prompts from a private GitLab repository.
4
4
 
5
- ## Setup
5
+ ## Quick Start
6
6
 
7
- 1. **Edit `bin/index.js`** and update the configuration:
7
+ **This package fetches from a private GitLab repository.** Users need:
8
+ 1. Access to the GitLab repo (ask owner to add you as member)
9
+ 2. A GitLab personal access token
10
+
11
+ ### Step 1: Get Added to GitLab Repo
12
+ Ask the repo owner to add you at:
13
+ https://gitlab.com/npm-packages713505/prompt-manager/-/project_members
14
+
15
+ ### Step 2: Create GitLab Token
16
+ 1. Go to: https://gitlab.com/-/profile/personal_access_tokens
17
+ 2. Create token with scopes: `read_api`, `read_repository`
18
+ 3. Copy your token (starts with `glpat-`)
19
+
20
+ ### Step 3: Run the Package
21
+ ```bash
22
+ GITLAB_TOKEN=glpat-your-token-here npx -y @naganpm/fetch-prompts
23
+ ```
24
+
25
+ Or export it first:
26
+ ```bash
27
+ export GITLAB_TOKEN=glpat-your-token-here
28
+ npx -y @naganpm/fetch-prompts
29
+ ```
30
+
31
+ This downloads all `.md` prompt files from the GitLab repo into a local `prompts/` folder.
32
+
33
+ ## For Repo Owner: Adding Users
34
+
35
+ To grant someone access to fetch prompts:
36
+
37
+ 1. Go to: https://gitlab.com/npm-packages713505/prompt-manager/-/project_members
38
+ 2. Click **"Invite members"**
39
+ 3. Add their GitLab username or email
40
+ 4. Set role to **"Reporter"** (read-only access)
41
+ 5. Click **"Invite"**
42
+
43
+ They can then create their own token and use the `npx` command above.
44
+
45
+ ## Setup (For Development)
46
+
47
+ If you want to fork/modify this package:
48
+
49
+ 1. **Edit `bin/index.js`** to point to your GitLab repo:
8
50
  ```js
9
- const GITLAB_PROJECT = 'youruser/yourproject'; // Your GitLab project path
10
- const GITLAB_BRANCH = 'main'; // Your branch name
11
- const PROMPTS_PATH = 'prompts'; // Folder containing .md files
12
- const GITLAB_HOST = 'gitlab.com'; // Or your GitLab instance
51
+ const GITLAB_PROJECT = 'your-group/your-project';
52
+ const GITLAB_BRANCH = 'main';
53
+ const PROMPTS_PATH = 'prompts';
13
54
  ```
14
55
 
15
- 2. **For private repos**, create a `.env` file in the package root:
56
+ 2. **Create `.env`** for local testing:
16
57
  ```bash
17
58
  # Copy the example
18
59
  cp .env.example .env
@@ -32,30 +73,7 @@ Fetch Angular routing prompts from your GitLab repository.
32
73
  └── other-prompt.md
33
74
  ```
34
75
 
35
- ## Usage
36
-
37
- After publishing to npm:
38
- ```bash
39
- npx -y fetch-angular-prompts
40
- ```
41
-
42
- This creates a `prompts/` folder in the current directory with all `.md` files from your GitLab repo.
43
-
44
- ## Publishing
45
-
46
- ### To npm:
47
- ```bash
48
- npm login
49
- npm publish
50
- ```
51
-
52
- ### Or use from GitHub:
53
- Push this package to GitHub, then users can run:
54
- ```bash
55
- npx github:youruser/your-repo
56
- ```
57
-
58
- ## Local Testing
76
+ 3. **Test locally:**
59
77
 
60
78
  ```bash
61
79
  # Install dependencies
@@ -70,7 +88,7 @@ cp .env.example .env
70
88
 
71
89
  # Test locally
72
90
  npm link
73
- npx -y fetch-angular-prompts
91
+ npx -y @naganpm/fetch-prompts
74
92
 
75
93
  # Or run directly
76
94
  node bin/index.js
package/bin/index.js CHANGED
@@ -12,7 +12,7 @@ if (fs.existsSync(envPath)) {
12
12
  }
13
13
 
14
14
  // Configuration - update these with your GitLab details
15
- const GITLAB_PROJECT = 'nagavadlapudi/prompt-manager'; // e.g., 'john/angular-prompts'
15
+ const GITLAB_PROJECT = 'npm-packages713505/prompt-manager'; // group/project
16
16
  const GITLAB_BRANCH = 'main'; // or 'master'
17
17
  const PROMPTS_PATH = 'prompts'; // folder in your GitLab repo
18
18
  const GITLAB_HOST = 'gitlab.com'; // or your self-hosted GitLab domain
@@ -91,12 +91,12 @@ async function fetchPrompts() {
91
91
  }
92
92
 
93
93
  for (const file of mdFiles) {
94
- // GitLab raw file URL
95
- const rawUrl = `https://${GITLAB_HOST}/${GITLAB_PROJECT}/-/raw/${GITLAB_BRANCH}/${PROMPTS_PATH}/${file.name}`;
94
+ // Use GitLab API to get file content (works with PRIVATE-TOKEN)
95
+ const fileApiUrl = `https://${GITLAB_HOST}/api/v4/projects/${encodeURIComponent(GITLAB_PROJECT)}/repository/files/${encodeURIComponent(`${PROMPTS_PATH}/${file.name}`)}/raw?ref=${GITLAB_BRANCH}`;
96
96
  const destPath = path.join(process.cwd(), 'prompts', file.name);
97
97
 
98
98
  console.log(`Downloading ${file.name}...`);
99
- await downloadFile(rawUrl, destPath, GITLAB_TOKEN);
99
+ await downloadFile(fileApiUrl, destPath, GITLAB_TOKEN);
100
100
  }
101
101
 
102
102
  console.log(`\n✓ Downloaded ${mdFiles.length} prompt(s) to ./prompts/`);
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@naganpm/fetch-prompts",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "Fetch prompts from GitLab repository",
5
5
  "bin": {
6
6
  "fetch-prompts": "bin/index.js"
7
7
  },
8
- "keywords": ["prompts", "gitlab"],
8
+ "keywords": [
9
+ "prompts",
10
+ "gitlab"
11
+ ],
9
12
  "license": "MIT",
10
13
  "engines": {
11
14
  "node": ">=14"