pointfree-docs 0.1.0 → 0.2.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.
package/dist/lib/repos.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import { simpleGit } from "simple-git";
5
5
  import { existsSync, mkdirSync } from "fs";
6
6
  import { join } from "path";
7
- import { PATHS } from "../config.js";
7
+ import { PATHS, EXAMPLES_CONFIG, EPISODES_CONFIG } from "../config.js";
8
8
  /**
9
9
  * Clone a library repository (sparse checkout, docs only)
10
10
  */
@@ -34,6 +34,58 @@ export async function cloneLibrary(lib) {
34
34
  await repoGit.raw(["sparse-checkout", "set", ...lib.docsPaths]);
35
35
  console.log(` ✓ Cloned ${lib.shortName}`);
36
36
  }
37
+ /**
38
+ * Clone TCA examples (CaseStudies, SyncUps, etc.)
39
+ */
40
+ export async function cloneExamples() {
41
+ const repoDir = join(PATHS.reposDir, EXAMPLES_CONFIG.name);
42
+ // Ensure repos directory exists
43
+ if (!existsSync(PATHS.reposDir)) {
44
+ mkdirSync(PATHS.reposDir, { recursive: true });
45
+ }
46
+ if (existsSync(repoDir)) {
47
+ console.log(` Repository already exists: ${EXAMPLES_CONFIG.name}`);
48
+ return;
49
+ }
50
+ console.log(` Cloning ${EXAMPLES_CONFIG.repo} (examples)...`);
51
+ const git = simpleGit();
52
+ // Sparse checkout: only download examples directories
53
+ await git.clone(`https://github.com/${EXAMPLES_CONFIG.repo}.git`, repoDir, [
54
+ "--depth",
55
+ "1",
56
+ "--filter=blob:none",
57
+ "--sparse",
58
+ ]);
59
+ const repoGit = simpleGit(repoDir);
60
+ // Set up sparse checkout to only get the examples folders
61
+ await repoGit.raw(["sparse-checkout", "init", "--cone"]);
62
+ await repoGit.raw(["sparse-checkout", "set", ...EXAMPLES_CONFIG.paths]);
63
+ console.log(` ✓ Cloned examples`);
64
+ }
65
+ /**
66
+ * Clone episode code samples
67
+ */
68
+ export async function cloneEpisodes() {
69
+ const repoDir = join(PATHS.reposDir, EPISODES_CONFIG.name);
70
+ // Ensure repos directory exists
71
+ if (!existsSync(PATHS.reposDir)) {
72
+ mkdirSync(PATHS.reposDir, { recursive: true });
73
+ }
74
+ if (existsSync(repoDir)) {
75
+ console.log(` Repository already exists: ${EPISODES_CONFIG.name}`);
76
+ return;
77
+ }
78
+ console.log(` Cloning ${EPISODES_CONFIG.repo} (episodes)...`);
79
+ console.log(` ⚠ Note: This may take a while (350+ episodes)...`);
80
+ const git = simpleGit();
81
+ // Full clone with depth 1 and blob filter for efficiency
82
+ await git.clone(`https://github.com/${EPISODES_CONFIG.repo}.git`, repoDir, [
83
+ "--depth",
84
+ "1",
85
+ "--filter=blob:none",
86
+ ]);
87
+ console.log(` ✓ Cloned episodes`);
88
+ }
37
89
  /**
38
90
  * Update a library repository
39
91
  */
@@ -61,12 +113,78 @@ export async function updateLibrary(lib) {
61
113
  return false;
62
114
  }
63
115
  }
116
+ /**
117
+ * Update examples repository
118
+ */
119
+ export async function updateExamples() {
120
+ const repoDir = join(PATHS.reposDir, EXAMPLES_CONFIG.name);
121
+ if (!existsSync(repoDir)) {
122
+ console.log(` Examples not found. Run 'pf-docs init --examples' first.`);
123
+ return false;
124
+ }
125
+ console.log(` Updating examples...`);
126
+ const git = simpleGit(repoDir);
127
+ try {
128
+ const pullResult = await git.pull();
129
+ if (pullResult.summary.changes > 0) {
130
+ console.log(` ✓ Updated examples (${pullResult.summary.changes} changes)`);
131
+ return true;
132
+ }
133
+ else {
134
+ console.log(` ✓ Examples are up to date`);
135
+ return false;
136
+ }
137
+ }
138
+ catch (error) {
139
+ console.error(` ✗ Failed to update examples:`, error);
140
+ return false;
141
+ }
142
+ }
143
+ /**
144
+ * Update episodes repository
145
+ */
146
+ export async function updateEpisodes() {
147
+ const repoDir = join(PATHS.reposDir, EPISODES_CONFIG.name);
148
+ if (!existsSync(repoDir)) {
149
+ console.log(` Episodes not found. Run 'pf-docs init --episodes' first.`);
150
+ return false;
151
+ }
152
+ console.log(` Updating episodes...`);
153
+ const git = simpleGit(repoDir);
154
+ try {
155
+ const pullResult = await git.pull();
156
+ if (pullResult.summary.changes > 0) {
157
+ console.log(` ✓ Updated episodes (${pullResult.summary.changes} changes)`);
158
+ return true;
159
+ }
160
+ else {
161
+ console.log(` ✓ Episodes are up to date`);
162
+ return false;
163
+ }
164
+ }
165
+ catch (error) {
166
+ console.error(` ✗ Failed to update episodes:`, error);
167
+ return false;
168
+ }
169
+ }
64
170
  /**
65
171
  * Get all local paths to a library's docs
66
172
  */
67
173
  export function getDocsPaths(lib) {
68
174
  return lib.docsPaths.map((docsPath) => join(PATHS.reposDir, lib.name, docsPath));
69
175
  }
176
+ /**
177
+ * Get all local paths to examples
178
+ */
179
+ export function getExamplesPaths() {
180
+ return EXAMPLES_CONFIG.paths.map((path) => join(PATHS.reposDir, EXAMPLES_CONFIG.name, path));
181
+ }
182
+ /**
183
+ * Get local path to episodes
184
+ */
185
+ export function getEpisodesPath() {
186
+ return join(PATHS.reposDir, EPISODES_CONFIG.name);
187
+ }
70
188
  /**
71
189
  * Check if a library is cloned
72
190
  */
@@ -74,3 +192,17 @@ export function isLibraryCloned(lib) {
74
192
  const repoDir = join(PATHS.reposDir, lib.name);
75
193
  return existsSync(repoDir);
76
194
  }
195
+ /**
196
+ * Check if examples are cloned
197
+ */
198
+ export function areExamplesCloned() {
199
+ const repoDir = join(PATHS.reposDir, EXAMPLES_CONFIG.name);
200
+ return existsSync(repoDir);
201
+ }
202
+ /**
203
+ * Check if episodes are cloned
204
+ */
205
+ export function areEpisodesCloned() {
206
+ const repoDir = join(PATHS.reposDir, EPISODES_CONFIG.name);
207
+ return existsSync(repoDir);
208
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pointfree-docs",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "CLI tool for searching Point-Free library documentation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,10 +33,10 @@
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
35
  "better-sqlite3": "^11.0.0",
36
+ "chalk": "^5.3.0",
36
37
  "commander": "^12.0.0",
37
38
  "glob": "^10.3.0",
38
- "simple-git": "^3.22.0",
39
- "chalk": "^5.3.0"
39
+ "simple-git": "^3.22.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/better-sqlite3": "^7.6.9",