2019-04-18 15:49:17 +00:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright 2019 Balena Ltd.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import * as path from 'path';
|
|
|
|
import { MarkdownFileParser } from './utils';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the skeleton of CLI documentation/reference web page at:
|
|
|
|
* https://www.balena.io/docs/reference/cli/
|
|
|
|
*
|
|
|
|
* The `getCapitanoDoc` function in this module parses README.md and adds
|
|
|
|
* some content to this object.
|
2023-11-03 14:55:29 +00:00
|
|
|
*
|
|
|
|
* IMPORTANT
|
|
|
|
*
|
|
|
|
* Only build files listed here will be documented by Capitano
|
|
|
|
* Make sure to add your files in alphabetical order
|
|
|
|
*
|
|
|
|
* Resources with plural names needs to have 2 sections if they have commands like:
|
|
|
|
* "fleet, fleets" or "device, devices" or "tag, tags"
|
|
|
|
*
|
2019-04-18 15:49:17 +00:00
|
|
|
*/
|
|
|
|
const capitanoDoc = {
|
2020-10-20 21:11:17 +00:00
|
|
|
title: 'balena CLI Documentation',
|
2019-04-18 15:49:17 +00:00
|
|
|
introduction: '',
|
|
|
|
categories: [
|
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'API Key',
|
|
|
|
files: ['build/commands/api-keys/index.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'API Keys',
|
2020-04-22 16:08:11 +00:00
|
|
|
files: [
|
2023-11-03 14:55:29 +00:00
|
|
|
'build/commands/api-key/generate.js',
|
|
|
|
'build/commands/api-key/revoke.js',
|
2020-04-22 16:08:11 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
2023-11-03 14:55:29 +00:00
|
|
|
{
|
|
|
|
title: 'App',
|
|
|
|
files: ['build/commands/app/create.js'],
|
|
|
|
},
|
2019-04-18 15:49:17 +00:00
|
|
|
{
|
|
|
|
title: 'Authentication',
|
2020-06-23 10:01:31 +00:00
|
|
|
files: [
|
2020-10-02 11:42:23 +00:00
|
|
|
'build/commands/login.js',
|
|
|
|
'build/commands/logout.js',
|
|
|
|
'build/commands/whoami.js',
|
2020-06-23 10:01:31 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
2023-11-03 14:55:29 +00:00
|
|
|
{
|
|
|
|
title: 'Block',
|
|
|
|
files: ['build/commands/app/create.js'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Config',
|
|
|
|
files: [
|
|
|
|
'build/commands/config/generate.js',
|
|
|
|
'build/commands/config/inject.js',
|
|
|
|
'build/commands/config/read.js',
|
|
|
|
'build/commands/config/reconfigure.js',
|
|
|
|
'build/commands/config/write.js',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Deploy',
|
|
|
|
files: ['build/commands/build.js', 'build/commands/deploy.js'],
|
|
|
|
},
|
2019-04-18 15:49:17 +00:00
|
|
|
{
|
|
|
|
title: 'Device',
|
2019-12-26 22:59:44 +00:00
|
|
|
files: [
|
2021-02-23 22:10:52 +00:00
|
|
|
'build/commands/device/deactivate.js',
|
2020-10-02 11:42:23 +00:00
|
|
|
'build/commands/device/identify.js',
|
2023-11-03 14:55:29 +00:00
|
|
|
'build/commands/device/index.js',
|
2020-10-02 11:42:23 +00:00
|
|
|
'build/commands/device/init.js',
|
2021-02-23 22:10:52 +00:00
|
|
|
'build/commands/device/local-mode.js',
|
2020-10-02 11:42:23 +00:00
|
|
|
'build/commands/device/move.js',
|
2020-10-14 09:13:47 +00:00
|
|
|
'build/commands/device/os-update.js',
|
2023-11-03 14:55:29 +00:00
|
|
|
'build/commands/device/pin.js',
|
2020-10-14 09:13:47 +00:00
|
|
|
'build/commands/device/public-url.js',
|
|
|
|
'build/commands/device/purge.js',
|
2020-10-02 11:42:23 +00:00
|
|
|
'build/commands/device/reboot.js',
|
|
|
|
'build/commands/device/register.js',
|
|
|
|
'build/commands/device/rename.js',
|
|
|
|
'build/commands/device/restart.js',
|
2020-10-14 09:13:47 +00:00
|
|
|
'build/commands/device/rm.js',
|
2020-10-02 11:42:23 +00:00
|
|
|
'build/commands/device/shutdown.js',
|
2023-11-03 14:55:29 +00:00
|
|
|
'build/commands/device/track-fleet.js',
|
2023-11-04 14:38:30 +00:00
|
|
|
'build/commands/device/start-service.js',
|
|
|
|
'build/commands/device/stop-service.js',
|
2019-12-26 22:59:44 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
2021-09-29 14:05:41 +00:00
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'Devices',
|
2021-09-29 14:05:41 +00:00
|
|
|
files: [
|
2023-11-03 14:55:29 +00:00
|
|
|
'build/commands/devices/index.js',
|
|
|
|
'build/commands/devices/supported.js',
|
2021-09-29 14:05:41 +00:00
|
|
|
],
|
|
|
|
},
|
2019-04-18 15:49:17 +00:00
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'Environment Variable',
|
2019-04-02 11:26:21 +00:00
|
|
|
files: [
|
2020-10-02 11:42:23 +00:00
|
|
|
'build/commands/env/add.js',
|
|
|
|
'build/commands/env/rename.js',
|
|
|
|
'build/commands/env/rm.js',
|
2019-04-02 11:26:21 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'Environment Variables',
|
|
|
|
files: ['build/commands/envs.js'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Fleet',
|
2020-05-26 09:17:30 +00:00
|
|
|
files: [
|
2023-11-03 14:55:29 +00:00
|
|
|
'build/commands/fleet/create.js',
|
|
|
|
'build/commands/fleet/index.js',
|
|
|
|
'build/commands/fleet/pin.js',
|
|
|
|
'build/commands/fleet/purge.js',
|
|
|
|
'build/commands/fleet/rename.js',
|
|
|
|
'build/commands/fleet/restart.js',
|
|
|
|
'build/commands/fleet/rm.js',
|
|
|
|
'build/commands/fleet/track-latest.js',
|
2020-05-26 09:17:30 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
2023-11-03 14:55:29 +00:00
|
|
|
{
|
|
|
|
title: 'Fleets',
|
|
|
|
files: ['build/commands/fleets.js'],
|
|
|
|
},
|
2019-04-18 15:49:17 +00:00
|
|
|
{
|
2019-06-24 15:51:07 +00:00
|
|
|
title: 'Help and Version',
|
2020-10-02 11:42:23 +00:00
|
|
|
files: ['help', 'build/commands/version.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'Local',
|
2020-04-17 13:19:33 +00:00
|
|
|
files: [
|
2023-11-03 14:55:29 +00:00
|
|
|
'build/commands/local/configure.js',
|
|
|
|
'build/commands/local/flash.js',
|
2020-04-17 13:19:33 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Logs',
|
2020-10-02 11:42:23 +00:00
|
|
|
files: ['build/commands/logs.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 22:17:59 +00:00
|
|
|
title: 'Network',
|
|
|
|
files: [
|
2020-10-02 11:42:23 +00:00
|
|
|
'build/commands/scan.js',
|
|
|
|
'build/commands/ssh.js',
|
|
|
|
'build/commands/tunnel.js',
|
2019-06-05 22:17:59 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Notes',
|
2020-10-02 11:42:23 +00:00
|
|
|
files: ['build/commands/note.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
2023-11-03 14:55:29 +00:00
|
|
|
{
|
|
|
|
title: 'Organizations',
|
|
|
|
files: ['build/commands/orgs.js'],
|
|
|
|
},
|
2019-04-18 15:49:17 +00:00
|
|
|
{
|
|
|
|
title: 'OS',
|
2020-07-14 13:23:45 +00:00
|
|
|
files: [
|
2020-10-02 11:42:23 +00:00
|
|
|
'build/commands/os/build-config.js',
|
|
|
|
'build/commands/os/configure.js',
|
|
|
|
'build/commands/os/download.js',
|
|
|
|
'build/commands/os/initialize.js',
|
2023-11-03 14:55:29 +00:00
|
|
|
'build/commands/os/versions.js',
|
2020-07-28 12:40:47 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Preload',
|
2020-10-02 11:42:23 +00:00
|
|
|
files: ['build/commands/preload.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Push',
|
2020-10-02 11:42:23 +00:00
|
|
|
files: ['build/commands/push.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
2023-11-03 14:55:29 +00:00
|
|
|
{
|
|
|
|
title: 'Platform',
|
|
|
|
files: ['build/commands/join.js', 'build/commands/leave.js'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Release',
|
|
|
|
files: [
|
|
|
|
'build/commands/release/finalize.js',
|
|
|
|
'build/commands/release/index.js',
|
|
|
|
'build/commands/release/invalidate.js',
|
|
|
|
'build/commands/release/validate.js',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Releases',
|
|
|
|
files: ['build/commands/releases.js'],
|
|
|
|
},
|
2019-04-18 15:49:17 +00:00
|
|
|
{
|
|
|
|
title: 'Settings',
|
2020-10-02 11:42:23 +00:00
|
|
|
files: ['build/commands/settings.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'Support',
|
|
|
|
files: ['build/commands/support.js'],
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
title: 'SSH Key',
|
2020-07-09 13:38:04 +00:00
|
|
|
files: [
|
2023-11-03 14:55:29 +00:00
|
|
|
'build/commands/key/add.js',
|
|
|
|
'build/commands/key/index.js',
|
|
|
|
'build/commands/key/rm.js',
|
2020-07-09 13:38:04 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'SSH Keys',
|
|
|
|
files: ['build/commands/keys.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'Tags',
|
|
|
|
files: ['build/commands/tag/rm.js', 'build/commands/tag/set.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'Tags',
|
|
|
|
files: ['build/commands/tags.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
2020-09-25 09:00:18 +00:00
|
|
|
{
|
2023-11-03 14:55:29 +00:00
|
|
|
title: 'Utilities',
|
|
|
|
files: ['build/commands/util/available-drives.js'],
|
2020-09-25 09:00:18 +00:00
|
|
|
},
|
2019-04-18 15:49:17 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modify and return the `capitanoDoc` object above in order to render the
|
|
|
|
* CLI documentation/reference web page at:
|
|
|
|
* https://www.balena.io/docs/reference/cli/
|
|
|
|
*
|
|
|
|
* This function parses the README.md file to extract relevant sections
|
|
|
|
* for the documentation web page.
|
|
|
|
*/
|
|
|
|
export async function getCapitanoDoc(): Promise<typeof capitanoDoc> {
|
|
|
|
const readmePath = path.join(__dirname, '..', '..', 'README.md');
|
|
|
|
const mdParser = new MarkdownFileParser(readmePath);
|
2019-04-29 15:33:09 +00:00
|
|
|
const sections: string[] = await Promise.all([
|
2019-04-18 15:49:17 +00:00
|
|
|
mdParser.getSectionOfTitle('About').then((sectionLines: string) => {
|
|
|
|
// delete the title of the 'About' section for the web page
|
|
|
|
const match = /^(#+)\s+.+?\n\s*([^]*)/.exec(sectionLines);
|
|
|
|
if (!match || match.length < 3) {
|
|
|
|
throw new Error(`Error parsing section title`);
|
|
|
|
}
|
|
|
|
// match[1] has the title, match[2] has the rest
|
|
|
|
return match && match[2];
|
|
|
|
}),
|
|
|
|
mdParser.getSectionOfTitle('Installation'),
|
2020-09-18 14:35:36 +00:00
|
|
|
mdParser.getSectionOfTitle('Choosing a shell (command prompt/terminal)'),
|
|
|
|
mdParser.getSectionOfTitle('Logging in'),
|
|
|
|
mdParser.getSectionOfTitle('Proxy support'),
|
2019-04-18 15:49:17 +00:00
|
|
|
mdParser.getSectionOfTitle('Support, FAQ and troubleshooting'),
|
2020-05-11 08:12:27 +00:00
|
|
|
mdParser.getSectionOfTitle('Deprecation policy'),
|
2019-04-29 15:33:09 +00:00
|
|
|
]);
|
|
|
|
capitanoDoc.introduction = sections.join('\n');
|
|
|
|
return capitanoDoc;
|
2019-04-18 15:49:17 +00:00
|
|
|
}
|