@link-assistant/web-capture 1.1.2 → 1.4.2

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 (55) hide show
  1. package/CHANGELOG.md +17 -14
  2. package/README.md +256 -146
  3. package/bin/web-capture.js +403 -6
  4. package/package.json +11 -4
  5. package/src/animation.js +283 -0
  6. package/src/archive.js +212 -0
  7. package/src/batch.js +180 -0
  8. package/src/browser.js +150 -111
  9. package/src/docx.js +182 -0
  10. package/src/figures.js +208 -0
  11. package/src/gdocs.js +333 -0
  12. package/src/image.js +65 -8
  13. package/src/index.js +15 -0
  14. package/src/latex.js +127 -0
  15. package/src/lib.js +226 -1
  16. package/src/localize-images.js +202 -0
  17. package/src/metadata.js +333 -0
  18. package/src/pdf.js +76 -0
  19. package/src/popups.js +171 -0
  20. package/src/postprocess.js +265 -0
  21. package/src/retry.js +48 -0
  22. package/src/themed-image.js +167 -0
  23. package/src/verify.js +312 -0
  24. package/tests/e2e/docker.test.js +51 -12
  25. package/tests/e2e/process.test.js +34 -10
  26. package/tests/fixtures/habr-articles.js +45 -0
  27. package/tests/integration/api-endpoints.test.js +231 -0
  28. package/tests/integration/habr-article.test.js +337 -0
  29. package/tests/mock/index.test.js +5 -3
  30. package/tests/unit/animation.test.js +33 -0
  31. package/tests/unit/batch.test.js +114 -0
  32. package/tests/unit/browser.test.js +38 -2
  33. package/tests/unit/figures.test.js +74 -0
  34. package/tests/unit/gdocs.test.js +203 -0
  35. package/tests/unit/latex.test.js +123 -0
  36. package/tests/unit/localize-images.test.js +78 -0
  37. package/tests/unit/metadata.test.js +140 -0
  38. package/tests/unit/postprocess.test.js +108 -0
  39. package/tests/unit/retry.test.js +111 -0
  40. package/tests/unit/verify.test.js +182 -0
  41. package/.github/workflows/release.yml +0 -294
  42. package/ARCHITECTURE.md +0 -982
  43. package/LICENSE +0 -24
  44. package/apply.sh +0 -166
  45. package/docs/market-analysis-2025-05-13.md +0 -64
  46. package/scripts/changeset-version.mjs +0 -38
  47. package/scripts/create-github-release.mjs +0 -93
  48. package/scripts/create-manual-changeset.mjs +0 -88
  49. package/scripts/format-github-release.mjs +0 -83
  50. package/scripts/format-release-notes.mjs +0 -218
  51. package/scripts/instant-version-bump.mjs +0 -121
  52. package/scripts/publish-to-npm.mjs +0 -128
  53. package/scripts/setup-npm.mjs +0 -37
  54. package/scripts/validate-changeset.mjs +0 -106
  55. package/scripts/version-and-commit.mjs +0 -237
@@ -1,237 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Version packages and commit to main
5
- * Usage: node scripts/version-and-commit.mjs --mode <changeset|instant> [--bump-type <type>] [--description <desc>]
6
- * changeset: Run changeset version
7
- * instant: Run instant version bump with bump_type (patch|minor|major) and optional description
8
- *
9
- * Uses link-foundation libraries:
10
- * - use-m: Dynamic package loading without package.json dependencies
11
- * - command-stream: Modern shell command execution with streaming support
12
- * - lino-arguments: Unified configuration from CLI args, env vars, and .lenv files
13
- */
14
-
15
- import { readFileSync, appendFileSync, readdirSync } from 'fs';
16
-
17
- // Load use-m dynamically
18
- const { use } = eval(
19
- await (await fetch('https://unpkg.com/use-m/use.js')).text()
20
- );
21
-
22
- // Import link-foundation libraries
23
- const { $ } = await use('command-stream');
24
- const { makeConfig } = await use('lino-arguments');
25
-
26
- // Parse CLI arguments using lino-arguments
27
- const config = makeConfig({
28
- yargs: ({ yargs, getenv }) =>
29
- yargs
30
- .option('mode', {
31
- type: 'string',
32
- default: getenv('MODE', 'changeset'),
33
- describe: 'Version mode: changeset or instant',
34
- choices: ['changeset', 'instant'],
35
- })
36
- .option('bump-type', {
37
- type: 'string',
38
- default: getenv('BUMP_TYPE', ''),
39
- describe: 'Version bump type for instant mode: major, minor, or patch',
40
- })
41
- .option('description', {
42
- type: 'string',
43
- default: getenv('DESCRIPTION', ''),
44
- describe: 'Description for instant version bump',
45
- }),
46
- });
47
-
48
- const { mode, bumpType, description } = config;
49
-
50
- // Debug: Log parsed configuration
51
- console.log('Parsed configuration:', {
52
- mode,
53
- bumpType,
54
- description: description || '(none)',
55
- });
56
-
57
- // Detect if positional arguments were used (common mistake)
58
- const args = process.argv.slice(2);
59
- if (args.length > 0 && !args[0].startsWith('--')) {
60
- console.error('Error: Positional arguments detected!');
61
- console.error('Command line arguments:', args);
62
- console.error('');
63
- console.error(
64
- 'This script requires named arguments (--mode, --bump-type, --description).'
65
- );
66
- console.error('Usage:');
67
- console.error(' Changeset mode:');
68
- console.error(' node scripts/version-and-commit.mjs --mode changeset');
69
- console.error(' Instant mode:');
70
- console.error(
71
- ' node scripts/version-and-commit.mjs --mode instant --bump-type <major|minor|patch> [--description <desc>]'
72
- );
73
- console.error('');
74
- console.error('Examples:');
75
- console.error(
76
- ' node scripts/version-and-commit.mjs --mode instant --bump-type patch --description "Fix bug"'
77
- );
78
- console.error(' node scripts/version-and-commit.mjs --mode changeset');
79
- process.exit(1);
80
- }
81
-
82
- // Validation: Ensure mode is set correctly
83
- if (mode !== 'changeset' && mode !== 'instant') {
84
- console.error(`Invalid mode: "${mode}". Expected "changeset" or "instant".`);
85
- console.error('Command line arguments:', process.argv.slice(2));
86
- process.exit(1);
87
- }
88
-
89
- // Validation: Ensure bump type is provided for instant mode
90
- if (mode === 'instant' && !bumpType) {
91
- console.error('Error: --bump-type is required for instant mode');
92
- console.error(
93
- 'Usage: node scripts/version-and-commit.mjs --mode instant --bump-type <major|minor|patch> [--description <desc>]'
94
- );
95
- process.exit(1);
96
- }
97
-
98
- /**
99
- * Append to GitHub Actions output file
100
- * @param {string} key
101
- * @param {string} value
102
- */
103
- function setOutput(key, value) {
104
- const outputFile = process.env.GITHUB_OUTPUT;
105
- if (outputFile) {
106
- appendFileSync(outputFile, `${key}=${value}\n`);
107
- }
108
- }
109
-
110
- /**
111
- * Count changeset files (excluding README.md)
112
- */
113
- function countChangesets() {
114
- try {
115
- const changesetDir = '.changeset';
116
- const files = readdirSync(changesetDir);
117
- return files.filter((f) => f.endsWith('.md') && f !== 'README.md').length;
118
- } catch {
119
- return 0;
120
- }
121
- }
122
-
123
- /**
124
- * Get package version
125
- * @param {string} source - 'local' or 'remote'
126
- */
127
- async function getVersion(source = 'local') {
128
- if (source === 'remote') {
129
- const result = await $`git show origin/main:package.json`.run({
130
- capture: true,
131
- });
132
- return JSON.parse(result.stdout).version;
133
- }
134
- return JSON.parse(readFileSync('./package.json', 'utf8')).version;
135
- }
136
-
137
- async function main() {
138
- try {
139
- // Configure git
140
- await $`git config user.name "github-actions[bot]"`;
141
- await $`git config user.email "github-actions[bot]@users.noreply.github.com"`;
142
-
143
- // Check if remote main has advanced (handles re-runs after partial success)
144
- console.log('Checking for remote changes...');
145
- await $`git fetch origin main`;
146
-
147
- const localHeadResult = await $`git rev-parse HEAD`.run({ capture: true });
148
- const localHead = localHeadResult.stdout.trim();
149
-
150
- const remoteHeadResult = await $`git rev-parse origin/main`.run({
151
- capture: true,
152
- });
153
- const remoteHead = remoteHeadResult.stdout.trim();
154
-
155
- if (localHead !== remoteHead) {
156
- console.log(
157
- `Remote main has advanced (local: ${localHead}, remote: ${remoteHead})`
158
- );
159
- console.log('This may indicate a previous attempt partially succeeded.');
160
-
161
- // Check if the remote version is already the expected bump
162
- const remoteVersion = await getVersion('remote');
163
- console.log(`Remote version: ${remoteVersion}`);
164
-
165
- // Check if there are changesets to process
166
- const changesetCount = countChangesets();
167
-
168
- if (changesetCount === 0) {
169
- console.log('No changesets to process and remote has advanced.');
170
- console.log(
171
- 'Assuming version bump was already completed in a previous attempt.'
172
- );
173
- setOutput('version_committed', 'false');
174
- setOutput('already_released', 'true');
175
- setOutput('new_version', remoteVersion);
176
- return;
177
- } else {
178
- console.log('Rebasing on remote main to incorporate changes...');
179
- await $`git rebase origin/main`;
180
- }
181
- }
182
-
183
- // Get current version before bump
184
- const oldVersion = await getVersion();
185
- console.log(`Current version: ${oldVersion}`);
186
-
187
- if (mode === 'instant') {
188
- console.log('Running instant version bump...');
189
- // Run instant version bump script
190
- // Rely on command-stream's auto-quoting for proper argument handling
191
- if (description) {
192
- await $`node scripts/instant-version-bump.mjs --bump-type ${bumpType} --description ${description}`;
193
- } else {
194
- await $`node scripts/instant-version-bump.mjs --bump-type ${bumpType}`;
195
- }
196
- } else {
197
- console.log('Running changeset version...');
198
- // Run changeset version to bump versions and update CHANGELOG
199
- await $`npm run changeset:version`;
200
- }
201
-
202
- // Get new version after bump
203
- const newVersion = await getVersion();
204
- console.log(`New version: ${newVersion}`);
205
- setOutput('new_version', newVersion);
206
-
207
- // Check if there are changes to commit
208
- const statusResult = await $`git status --porcelain`.run({ capture: true });
209
- const status = statusResult.stdout.trim();
210
-
211
- if (status) {
212
- console.log('Changes detected, committing...');
213
-
214
- // Stage all changes (package.json, package-lock.json, CHANGELOG.md, deleted changesets)
215
- await $`git add -A`;
216
-
217
- // Commit with version number as message
218
- const commitMessage = newVersion;
219
- const escapedMessage = commitMessage.replace(/"/g, '\\"');
220
- await $`git commit -m "${escapedMessage}"`;
221
-
222
- // Push directly to main
223
- await $`git push origin main`;
224
-
225
- console.log('\u2705 Version bump committed and pushed to main');
226
- setOutput('version_committed', 'true');
227
- } else {
228
- console.log('No changes to commit');
229
- setOutput('version_committed', 'false');
230
- }
231
- } catch (error) {
232
- console.error('Error:', error.message);
233
- process.exit(1);
234
- }
235
- }
236
-
237
- main();