rclnodejs 1.9.0 → 2.0.0-beta.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.
Files changed (98) hide show
  1. package/.prettierignore +4 -0
  2. package/README.md +2 -2
  3. package/binding.gyp +6 -5
  4. package/lib/action/client.js +5 -4
  5. package/lib/action/uuid.js +1 -1
  6. package/lib/client.js +0 -45
  7. package/lib/distro.js +11 -4
  8. package/lib/interface_loader.js +1 -1
  9. package/lib/message_introspector.js +1 -29
  10. package/lib/message_serialization.js +2 -2
  11. package/lib/native_loader.js +21 -9
  12. package/lib/node.js +2 -2
  13. package/lib/prebuilds.js +47 -0
  14. package/lib/rmw.js +6 -1
  15. package/lib/subscription.js +2 -2
  16. package/package.json +11 -6
  17. package/prebuilds/linux-arm64/humble-jammy-arm64-electron-rclnodejs.node +0 -0
  18. package/prebuilds/linux-arm64/humble-jammy-arm64-node-rclnodejs.node +0 -0
  19. package/prebuilds/linux-arm64/jazzy-noble-arm64-electron-rclnodejs.node +0 -0
  20. package/prebuilds/linux-arm64/jazzy-noble-arm64-node-rclnodejs.node +0 -0
  21. package/prebuilds/linux-arm64/kilted-noble-arm64-electron-rclnodejs.node +0 -0
  22. package/prebuilds/linux-arm64/kilted-noble-arm64-node-rclnodejs.node +0 -0
  23. package/prebuilds/linux-arm64/lyrical-resolute-arm64-electron-rclnodejs.node +0 -0
  24. package/prebuilds/linux-arm64/lyrical-resolute-arm64-node-rclnodejs.node +0 -0
  25. package/prebuilds/linux-x64/humble-jammy-x64-electron-rclnodejs.node +0 -0
  26. package/prebuilds/linux-x64/humble-jammy-x64-node-rclnodejs.node +0 -0
  27. package/prebuilds/linux-x64/jazzy-noble-x64-electron-rclnodejs.node +0 -0
  28. package/prebuilds/linux-x64/jazzy-noble-x64-node-rclnodejs.node +0 -0
  29. package/prebuilds/linux-x64/kilted-noble-x64-electron-rclnodejs.node +0 -0
  30. package/prebuilds/linux-x64/kilted-noble-x64-node-rclnodejs.node +0 -0
  31. package/prebuilds/linux-x64/lyrical-resolute-x64-electron-rclnodejs.node +0 -0
  32. package/prebuilds/linux-x64/lyrical-resolute-x64-node-rclnodejs.node +0 -0
  33. package/rosidl_gen/packages.js +4 -4
  34. package/rosidl_gen/templates/message-template.js +20 -6
  35. package/rosocket/README.md +152 -0
  36. package/rosocket/cli.js +168 -0
  37. package/rosocket/index.js +245 -0
  38. package/scripts/install.js +14 -3
  39. package/scripts/tag_prebuilds.js +26 -9
  40. package/src/rcl_action_client_bindings.cpp +4 -4
  41. package/src/rcl_graph_bindings.cpp +8 -8
  42. package/src/rcl_lifecycle_bindings.cpp +1 -1
  43. package/src/rcl_subscription_bindings.cpp +2 -2
  44. package/src/rcl_utilities.cpp +4 -4
  45. package/src/rcl_utilities.h +2 -2
  46. package/types/distro.d.ts +15 -1
  47. package/prebuilds/linux-arm64/humble-jammy-arm64-rclnodejs.node +0 -0
  48. package/prebuilds/linux-arm64/jazzy-noble-arm64-rclnodejs.node +0 -0
  49. package/prebuilds/linux-arm64/kilted-noble-arm64-rclnodejs.node +0 -0
  50. package/prebuilds/linux-x64/humble-jammy-x64-rclnodejs.node +0 -0
  51. package/prebuilds/linux-x64/jazzy-noble-x64-rclnodejs.node +0 -0
  52. package/prebuilds/linux-x64/kilted-noble-x64-rclnodejs.node +0 -0
  53. package/tools/jsdoc/Makefile +0 -5
  54. package/tools/jsdoc/README.md +0 -96
  55. package/tools/jsdoc/build-index.js +0 -610
  56. package/tools/jsdoc/publish.js +0 -854
  57. package/tools/jsdoc/regenerate-published-docs.js +0 -605
  58. package/tools/jsdoc/static/fonts/OpenSans-Bold-webfont.eot +0 -0
  59. package/tools/jsdoc/static/fonts/OpenSans-Bold-webfont.svg +0 -1830
  60. package/tools/jsdoc/static/fonts/OpenSans-Bold-webfont.woff +0 -0
  61. package/tools/jsdoc/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  62. package/tools/jsdoc/static/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  63. package/tools/jsdoc/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  64. package/tools/jsdoc/static/fonts/OpenSans-Italic-webfont.eot +0 -0
  65. package/tools/jsdoc/static/fonts/OpenSans-Italic-webfont.svg +0 -1830
  66. package/tools/jsdoc/static/fonts/OpenSans-Italic-webfont.woff +0 -0
  67. package/tools/jsdoc/static/fonts/OpenSans-Light-webfont.eot +0 -0
  68. package/tools/jsdoc/static/fonts/OpenSans-Light-webfont.svg +0 -1831
  69. package/tools/jsdoc/static/fonts/OpenSans-Light-webfont.woff +0 -0
  70. package/tools/jsdoc/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  71. package/tools/jsdoc/static/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  72. package/tools/jsdoc/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  73. package/tools/jsdoc/static/fonts/OpenSans-Regular-webfont.eot +0 -0
  74. package/tools/jsdoc/static/fonts/OpenSans-Regular-webfont.svg +0 -1831
  75. package/tools/jsdoc/static/fonts/OpenSans-Regular-webfont.woff +0 -0
  76. package/tools/jsdoc/static/scripts/linenumber.js +0 -25
  77. package/tools/jsdoc/static/scripts/prettify/Apache-License-2.0.txt +0 -202
  78. package/tools/jsdoc/static/scripts/prettify/lang-css.js +0 -36
  79. package/tools/jsdoc/static/scripts/prettify/prettify.js +0 -738
  80. package/tools/jsdoc/static/styles/jsdoc-default.css +0 -1012
  81. package/tools/jsdoc/static/styles/prettify-jsdoc.css +0 -111
  82. package/tools/jsdoc/static/styles/prettify-tomorrow.css +0 -132
  83. package/tools/jsdoc/tmpl/augments.tmpl +0 -10
  84. package/tools/jsdoc/tmpl/container.tmpl +0 -193
  85. package/tools/jsdoc/tmpl/details.tmpl +0 -143
  86. package/tools/jsdoc/tmpl/example.tmpl +0 -2
  87. package/tools/jsdoc/tmpl/examples.tmpl +0 -13
  88. package/tools/jsdoc/tmpl/exceptions.tmpl +0 -17
  89. package/tools/jsdoc/tmpl/layout.tmpl +0 -83
  90. package/tools/jsdoc/tmpl/mainpage.tmpl +0 -163
  91. package/tools/jsdoc/tmpl/members.tmpl +0 -43
  92. package/tools/jsdoc/tmpl/method.tmpl +0 -124
  93. package/tools/jsdoc/tmpl/params.tmpl +0 -133
  94. package/tools/jsdoc/tmpl/properties.tmpl +0 -110
  95. package/tools/jsdoc/tmpl/returns.tmpl +0 -12
  96. package/tools/jsdoc/tmpl/source.tmpl +0 -8
  97. package/tools/jsdoc/tmpl/tutorial.tmpl +0 -19
  98. package/tools/jsdoc/tmpl/type.tmpl +0 -7
@@ -1,605 +0,0 @@
1
- // Copyright (c) 2026 The Robot Web Tools Contributors. All rights reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- 'use strict';
16
-
17
- const childProcess = require('child_process');
18
- const fs = require('fs');
19
- const os = require('os');
20
- const path = require('path');
21
-
22
- const repoRoot = path.resolve(__dirname, '../..');
23
- const buildIndexScript = path.join(__dirname, 'build-index.js');
24
- const defaultOutputRoot = path.join(repoRoot, 'build', 'gh-pages-docs');
25
- const semverDirectoryPattern = /^\d+\.\d+\.\d+$/;
26
- const sharedAssetDirectoryName = '_static';
27
- const sharedAssetFolders = ['fonts', 'scripts', 'styles'];
28
-
29
- function parseArgs(argv) {
30
- const options = {
31
- branch: 'gh-pages',
32
- outputRoot: defaultOutputRoot,
33
- versions: null,
34
- preservePublished: false,
35
- fullRebuild: false,
36
- keepWorktrees: false,
37
- };
38
-
39
- for (let index = 0; index < argv.length; index += 1) {
40
- const arg = argv[index];
41
-
42
- if (arg === '--branch') {
43
- options.branch = argv[index + 1];
44
- index += 1;
45
- } else if (arg === '--out') {
46
- options.outputRoot = path.resolve(argv[index + 1]);
47
- index += 1;
48
- } else if (arg === '--versions') {
49
- options.versions = argv[index + 1]
50
- .split(',')
51
- .map((value) => value.trim())
52
- .filter(Boolean);
53
- index += 1;
54
- } else if (arg === '--preserve-published') {
55
- options.preservePublished = true;
56
- } else if (arg === '--full-rebuild') {
57
- options.fullRebuild = true;
58
- } else if (arg === '--keep-worktrees') {
59
- options.keepWorktrees = true;
60
- } else {
61
- throw new Error(`Unknown argument: ${arg}`);
62
- }
63
- }
64
-
65
- return options;
66
- }
67
-
68
- function runCommand(command, args, options = {}) {
69
- try {
70
- return childProcess.execFileSync(command, args, {
71
- cwd: options.cwd || repoRoot,
72
- encoding: 'utf8',
73
- env: options.env || process.env,
74
- stdio: ['ignore', 'pipe', 'pipe'],
75
- });
76
- } catch (error) {
77
- const stderr = error.stderr ? String(error.stderr).trim() : '';
78
- const stdout = error.stdout ? String(error.stdout).trim() : '';
79
- const details = [stderr, stdout].filter(Boolean).join('\n');
80
-
81
- throw new Error(
82
- details
83
- ? `${command} ${args.join(' ')}\n${details}`
84
- : `${command} ${args.join(' ')} failed`
85
- );
86
- }
87
- }
88
-
89
- function compareVersionsAsc(left, right) {
90
- const leftParts = left.split('.').map(Number);
91
- const rightParts = right.split('.').map(Number);
92
- const maxLength = Math.max(leftParts.length, rightParts.length);
93
-
94
- for (let index = 0; index < maxLength; index += 1) {
95
- const leftValue = leftParts[index] || 0;
96
- const rightValue = rightParts[index] || 0;
97
-
98
- if (leftValue !== rightValue) {
99
- return leftValue - rightValue;
100
- }
101
- }
102
-
103
- return 0;
104
- }
105
-
106
- function getPublishedVersions(branch) {
107
- const output = runCommand('git', [
108
- 'ls-tree',
109
- '--name-only',
110
- `${branch}:docs`,
111
- ]);
112
-
113
- return output
114
- .split(/\r?\n/)
115
- .map((entry) => entry.trim())
116
- .filter((entry) => semverDirectoryPattern.test(entry))
117
- .sort(compareVersionsAsc);
118
- }
119
-
120
- function getTaggedReleaseVersions() {
121
- return runCommand('git', ['tag', '--list'])
122
- .split(/\r?\n/)
123
- .map((entry) => entry.trim())
124
- .filter((entry) => semverDirectoryPattern.test(entry))
125
- .sort(compareVersionsAsc);
126
- }
127
-
128
- function getCurrentWorkspaceVersion() {
129
- const packageInfo = JSON.parse(
130
- fs.readFileSync(path.join(repoRoot, 'package.json'), 'utf8')
131
- );
132
-
133
- if (!semverDirectoryPattern.test(packageInfo.version)) {
134
- throw new Error(
135
- `Current package.json version is not a release semver: ${packageInfo.version}`
136
- );
137
- }
138
-
139
- return packageInfo.version;
140
- }
141
-
142
- function assertTagsExist(versions) {
143
- const tags = new Set(getTaggedReleaseVersions());
144
-
145
- const missing = versions.filter((version) => !tags.has(version));
146
-
147
- if (missing.length) {
148
- throw new Error(
149
- `Missing Git tags for requested versions: ${missing.join(', ')}`
150
- );
151
- }
152
- }
153
-
154
- function ensureCleanOutput(outputRoot) {
155
- fs.rmSync(outputRoot, { recursive: true, force: true });
156
- fs.mkdirSync(path.join(outputRoot, 'docs'), { recursive: true });
157
- }
158
-
159
- function getGeneratedVersions(outputRoot) {
160
- const docsRoot = path.join(outputRoot, 'docs');
161
-
162
- if (!fs.existsSync(docsRoot)) {
163
- return [];
164
- }
165
-
166
- return fs
167
- .readdirSync(docsRoot, { withFileTypes: true })
168
- .filter(
169
- (entry) => entry.isDirectory() && semverDirectoryPattern.test(entry.name)
170
- )
171
- .map((entry) => entry.name)
172
- .sort(compareVersionsAsc);
173
- }
174
-
175
- function writeBranchFile(branch, sourcePath, destinationPath) {
176
- try {
177
- const contents = runCommand('git', ['show', `${branch}:${sourcePath}`]);
178
- fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
179
- fs.writeFileSync(destinationPath, contents, 'utf8');
180
- } catch (error) {
181
- if (sourcePath === '.nojekyll') {
182
- fs.writeFileSync(destinationPath, '', 'utf8');
183
- return;
184
- }
185
-
186
- throw error;
187
- }
188
- }
189
-
190
- function appendJsFiles(directoryPath, inputs) {
191
- if (!fs.existsSync(directoryPath)) {
192
- return;
193
- }
194
-
195
- fs.readdirSync(directoryPath, { withFileTypes: true })
196
- .filter((entry) => entry.isFile() && entry.name.endsWith('.js'))
197
- .sort((left, right) => left.name.localeCompare(right.name))
198
- .forEach((entry) => {
199
- inputs.push(path.join(directoryPath, entry.name));
200
- });
201
- }
202
-
203
- function getJsdocInputs(sourceRoot) {
204
- const inputs = [];
205
- const indexPath = path.join(sourceRoot, 'index.js');
206
-
207
- if (fs.existsSync(indexPath)) {
208
- inputs.push(indexPath);
209
- }
210
-
211
- appendJsFiles(path.join(sourceRoot, 'lib'), inputs);
212
- appendJsFiles(path.join(sourceRoot, 'lib', 'action'), inputs);
213
-
214
- if (!inputs.length) {
215
- throw new Error(`No JSDoc input files found for ${sourceRoot}`);
216
- }
217
-
218
- return inputs;
219
- }
220
-
221
- function sanitizePathSegment(value) {
222
- return value.replace(/[^a-zA-Z0-9._-]/g, '_');
223
- }
224
-
225
- function addWorktree(ref, tempRoot, directoryName = ref) {
226
- const worktreePath = path.join(tempRoot, sanitizePathSegment(directoryName));
227
-
228
- runCommand('git', [
229
- 'worktree',
230
- 'add',
231
- '--detach',
232
- '--force',
233
- worktreePath,
234
- ref,
235
- ]);
236
-
237
- return worktreePath;
238
- }
239
-
240
- function removeWorktree(worktreePath, keepWorktrees) {
241
- if (keepWorktrees) {
242
- return;
243
- }
244
-
245
- try {
246
- runCommand('git', ['worktree', 'remove', '--force', worktreePath]);
247
- } catch {
248
- fs.rmSync(worktreePath, { recursive: true, force: true });
249
- }
250
- }
251
-
252
- function writeIndexPackage(packageJsonPath, outputRoot) {
253
- const packageInfo = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
254
- const trimmedPackageInfo = {
255
- name: packageInfo.name,
256
- version: packageInfo.version,
257
- repository: packageInfo.repository,
258
- };
259
- const destinationPath = path.join(outputRoot, '_index-package.json');
260
-
261
- fs.writeFileSync(
262
- destinationPath,
263
- `${JSON.stringify(trimmedPackageInfo, null, 2)}\n`,
264
- 'utf8'
265
- );
266
-
267
- return destinationPath;
268
- }
269
-
270
- function copyIfExists(sourcePath, destinationPath) {
271
- if (!fs.existsSync(sourcePath)) {
272
- return;
273
- }
274
-
275
- fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
276
- fs.cpSync(sourcePath, destinationPath, { recursive: true, force: true });
277
- }
278
-
279
- function copyDirectoryContents(sourceDir, destinationDir) {
280
- if (!fs.existsSync(sourceDir)) {
281
- return;
282
- }
283
-
284
- fs.mkdirSync(destinationDir, { recursive: true });
285
-
286
- fs.readdirSync(sourceDir, { withFileTypes: true }).forEach((entry) => {
287
- fs.cpSync(
288
- path.join(sourceDir, entry.name),
289
- path.join(destinationDir, entry.name),
290
- { recursive: true, force: true }
291
- );
292
- });
293
- }
294
-
295
- function copyPublishedSnapshot(branch, outputRoot, tempRoot, keepWorktrees) {
296
- const worktreePath = addWorktree(branch, tempRoot, `branch-${branch}`);
297
- const rootFiles = ['.nojekyll', 'README.md', '_index-package.json'];
298
-
299
- try {
300
- copyDirectoryContents(
301
- path.join(worktreePath, 'docs'),
302
- path.join(outputRoot, 'docs')
303
- );
304
-
305
- rootFiles.forEach((fileName) => {
306
- copyIfExists(
307
- path.join(worktreePath, fileName),
308
- path.join(outputRoot, fileName)
309
- );
310
- });
311
- } finally {
312
- removeWorktree(worktreePath, keepWorktrees);
313
- }
314
- }
315
-
316
- function buildVersionDocs(version, outputDocsRoot, tempRoot, keepWorktrees) {
317
- const worktreePath = addWorktree(version, tempRoot, version);
318
-
319
- try {
320
- const inputs = getJsdocInputs(worktreePath);
321
-
322
- runCommand(
323
- 'npx',
324
- [
325
- 'jsdoc',
326
- '--package',
327
- path.join(worktreePath, 'package.json'),
328
- ...inputs,
329
- '-t',
330
- __dirname,
331
- '-d',
332
- outputDocsRoot,
333
- ],
334
- { cwd: repoRoot }
335
- );
336
-
337
- return {
338
- worktreePath,
339
- packageJsonPath: path.join(worktreePath, 'package.json'),
340
- };
341
- } catch (error) {
342
- removeWorktree(worktreePath, keepWorktrees);
343
- throw error;
344
- }
345
- }
346
-
347
- function buildDocsFromSourceRoot(sourceRoot, outputDocsRoot) {
348
- const inputs = getJsdocInputs(sourceRoot);
349
-
350
- runCommand(
351
- 'npx',
352
- [
353
- 'jsdoc',
354
- '--package',
355
- path.join(sourceRoot, 'package.json'),
356
- ...inputs,
357
- '-t',
358
- __dirname,
359
- '-d',
360
- outputDocsRoot,
361
- ],
362
- { cwd: repoRoot }
363
- );
364
-
365
- return {
366
- packageJsonPath: path.join(sourceRoot, 'package.json'),
367
- };
368
- }
369
-
370
- function buildDocsIndex(outputRoot, packageJsonPath) {
371
- runCommand('node', [buildIndexScript], {
372
- cwd: repoRoot,
373
- env: {
374
- ...process.env,
375
- RCLNODEJS_DOCS_ROOT: path.join(outputRoot, 'docs'),
376
- RCLNODEJS_DOCS_INDEX_PATH: path.join(outputRoot, 'docs', 'index.html'),
377
- RCLNODEJS_LOCAL_INDEX_PATH: '',
378
- RCLNODEJS_PACKAGE_JSON_PATH: packageJsonPath,
379
- RCLNODEJS_GIT_CWD: repoRoot,
380
- },
381
- });
382
- }
383
-
384
- function removeTemporaryPublishArtifacts(outputRoot) {
385
- ['README.md', '_index-package.json'].forEach((fileName) => {
386
- fs.rmSync(path.join(outputRoot, fileName), { force: true });
387
- });
388
- }
389
-
390
- function rewriteVersionHtmlToSharedAssets(versionRoot) {
391
- fs.readdirSync(versionRoot, { withFileTypes: true })
392
- .filter((entry) => entry.isFile() && entry.name.endsWith('.html'))
393
- .forEach((entry) => {
394
- const filePath = path.join(versionRoot, entry.name);
395
- const original = fs.readFileSync(filePath, 'utf8');
396
- const rewritten = original.replace(
397
- /(href|src)="(styles|scripts)\//g,
398
- '$1="../_static/$2/'
399
- );
400
-
401
- if (rewritten !== original) {
402
- fs.writeFileSync(filePath, rewritten, 'utf8');
403
- }
404
- });
405
- }
406
-
407
- function hoistSharedAssets(outputRoot) {
408
- const docsRoot = path.join(outputRoot, 'docs');
409
- const versions = getGeneratedVersions(outputRoot);
410
-
411
- if (!versions.length) {
412
- return;
413
- }
414
-
415
- const sourceVersion = versions[versions.length - 1];
416
- const sourceVersionRoot = path.join(docsRoot, sourceVersion);
417
- const sharedRoot = path.join(docsRoot, sharedAssetDirectoryName);
418
-
419
- fs.mkdirSync(sharedRoot, { recursive: true });
420
-
421
- sharedAssetFolders.forEach((folderName) => {
422
- fs.cpSync(
423
- path.join(sourceVersionRoot, folderName),
424
- path.join(sharedRoot, folderName),
425
- { recursive: true, force: true }
426
- );
427
- });
428
-
429
- versions.forEach((version) => {
430
- const versionRoot = path.join(docsRoot, version);
431
-
432
- rewriteVersionHtmlToSharedAssets(versionRoot);
433
-
434
- sharedAssetFolders.forEach((folderName) => {
435
- fs.rmSync(path.join(versionRoot, folderName), {
436
- recursive: true,
437
- force: true,
438
- });
439
- });
440
- });
441
- }
442
-
443
- function ensureSharedAssetsForVersion(outputRoot, version) {
444
- const docsRoot = path.join(outputRoot, 'docs');
445
- const versionRoot = path.join(docsRoot, version);
446
- const sharedRoot = path.join(docsRoot, sharedAssetDirectoryName);
447
-
448
- if (!fs.existsSync(versionRoot)) {
449
- return;
450
- }
451
-
452
- fs.mkdirSync(sharedRoot, { recursive: true });
453
-
454
- sharedAssetFolders.forEach((folderName) => {
455
- const sourcePath = path.join(versionRoot, folderName);
456
-
457
- if (!fs.existsSync(sourcePath)) {
458
- return;
459
- }
460
-
461
- fs.cpSync(sourcePath, path.join(sharedRoot, folderName), {
462
- recursive: true,
463
- force: true,
464
- });
465
- });
466
-
467
- rewriteVersionHtmlToSharedAssets(versionRoot);
468
-
469
- sharedAssetFolders.forEach((folderName) => {
470
- fs.rmSync(path.join(versionRoot, folderName), {
471
- recursive: true,
472
- force: true,
473
- });
474
- });
475
- }
476
-
477
- function main() {
478
- const options = parseArgs(process.argv.slice(2));
479
-
480
- if (options.preservePublished && options.fullRebuild) {
481
- throw new Error(
482
- 'Use either --preserve-published or --full-rebuild, not both.'
483
- );
484
- }
485
-
486
- const publishedVersions = options.versions
487
- ? options.versions
488
- : getPublishedVersions(options.branch);
489
- const currentVersion = getCurrentWorkspaceVersion();
490
- const versions = Array.from(
491
- new Set(publishedVersions.concat(currentVersion))
492
- ).sort(compareVersionsAsc);
493
-
494
- if (!versions.length) {
495
- throw new Error(`No published versions found in ${options.branch}:docs`);
496
- }
497
-
498
- assertTagsExist(
499
- publishedVersions.filter((version) => version !== currentVersion)
500
- );
501
- ensureCleanOutput(options.outputRoot);
502
-
503
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'rclnodejs-jsdoc-'));
504
- const latestVersion = versions[versions.length - 1];
505
- let latestPackageJsonPath = null;
506
-
507
- try {
508
- if (options.preservePublished) {
509
- copyPublishedSnapshot(
510
- options.branch,
511
- options.outputRoot,
512
- tempRoot,
513
- options.keepWorktrees
514
- );
515
- console.log(
516
- `Preserved ${publishedVersions.length} published versions from ${options.branch}.`
517
- );
518
- } else {
519
- writeBranchFile(
520
- options.branch,
521
- '.nojekyll',
522
- path.join(options.outputRoot, '.nojekyll')
523
- );
524
- writeBranchFile(
525
- options.branch,
526
- 'README.md',
527
- path.join(options.outputRoot, 'README.md')
528
- );
529
- }
530
-
531
- console.log(`Regenerating ${versions.length} documentation versions.`);
532
-
533
- if (!options.preservePublished || options.fullRebuild) {
534
- publishedVersions.forEach((version) => {
535
- if (version === currentVersion) {
536
- return;
537
- }
538
-
539
- console.log(`- ${version}`);
540
-
541
- const buildResult = buildVersionDocs(
542
- version,
543
- path.join(options.outputRoot, 'docs'),
544
- tempRoot,
545
- options.keepWorktrees
546
- );
547
-
548
- if (version === latestVersion) {
549
- latestPackageJsonPath = writeIndexPackage(
550
- buildResult.packageJsonPath,
551
- options.outputRoot
552
- );
553
- }
554
-
555
- removeWorktree(buildResult.worktreePath, options.keepWorktrees);
556
- });
557
- }
558
-
559
- if (options.preservePublished && !options.fullRebuild) {
560
- const existingIndexPackagePath = path.join(
561
- options.outputRoot,
562
- '_index-package.json'
563
- );
564
-
565
- if (fs.existsSync(existingIndexPackagePath)) {
566
- latestPackageJsonPath = existingIndexPackagePath;
567
- }
568
- }
569
-
570
- console.log(`- ${currentVersion} (current workspace)`);
571
-
572
- const buildResult = buildDocsFromSourceRoot(
573
- repoRoot,
574
- path.join(options.outputRoot, 'docs')
575
- );
576
-
577
- if (currentVersion === latestVersion) {
578
- latestPackageJsonPath = writeIndexPackage(
579
- buildResult.packageJsonPath,
580
- options.outputRoot
581
- );
582
- }
583
-
584
- buildDocsIndex(
585
- options.outputRoot,
586
- latestPackageJsonPath || path.join(repoRoot, 'package.json')
587
- );
588
-
589
- if (options.preservePublished && !options.fullRebuild) {
590
- ensureSharedAssetsForVersion(options.outputRoot, currentVersion);
591
- } else {
592
- hoistSharedAssets(options.outputRoot);
593
- }
594
-
595
- removeTemporaryPublishArtifacts(options.outputRoot);
596
-
597
- console.log(`Published docs tree ready at ${options.outputRoot}`);
598
- } finally {
599
- if (!options.keepWorktrees) {
600
- fs.rmSync(tempRoot, { recursive: true, force: true });
601
- }
602
- }
603
- }
604
-
605
- main();