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.
|
|
|
|
*/
|
|
|
|
const capitanoDoc = {
|
|
|
|
title: 'Balena CLI Documentation',
|
|
|
|
introduction: '',
|
|
|
|
categories: [
|
|
|
|
{
|
|
|
|
title: 'API keys',
|
2020-04-22 11:47:12 +00:00
|
|
|
files: ['build/actions-oclif/api-key/generate.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Application',
|
2020-04-22 16:08:11 +00:00
|
|
|
files: [
|
|
|
|
'build/actions-oclif/apps.js',
|
|
|
|
'build/actions-oclif/app/index.js',
|
|
|
|
'build/actions-oclif/app/create.js',
|
|
|
|
'build/actions-oclif/app/rm.js',
|
|
|
|
'build/actions-oclif/app/restart.js',
|
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Authentication',
|
2020-06-23 10:01:31 +00:00
|
|
|
files: [
|
|
|
|
'build/actions-oclif/login.js',
|
|
|
|
'build/actions-oclif/logout.js',
|
|
|
|
'build/actions-oclif/whoami.js',
|
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Device',
|
2019-12-26 22:59:44 +00:00
|
|
|
files: [
|
2020-06-17 13:46:25 +00:00
|
|
|
'build/actions-oclif/device/identify.js',
|
2020-07-02 13:58:07 +00:00
|
|
|
'build/actions-oclif/device/init.js',
|
2020-06-17 13:46:25 +00:00
|
|
|
'build/actions-oclif/device/index.js',
|
|
|
|
'build/actions-oclif/device/move.js',
|
|
|
|
'build/actions-oclif/device/reboot.js',
|
|
|
|
'build/actions-oclif/device/register.js',
|
|
|
|
'build/actions-oclif/device/rename.js',
|
|
|
|
'build/actions-oclif/device/rm.js',
|
|
|
|
'build/actions-oclif/device/shutdown.js',
|
|
|
|
'build/actions-oclif/devices/index.js',
|
2019-12-26 22:59:44 +00:00
|
|
|
'build/actions-oclif/devices/supported.js',
|
2020-06-18 13:36:46 +00:00
|
|
|
'build/actions-oclif/device/os-update.js',
|
2020-06-02 08:01:04 +00:00
|
|
|
'build/actions-oclif/device/public-url.js',
|
2019-12-26 22:59:44 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Environment Variables',
|
2019-04-02 11:26:21 +00:00
|
|
|
files: [
|
2019-09-06 13:43:53 +00:00
|
|
|
'build/actions-oclif/envs.js',
|
2019-04-02 11:26:21 +00:00
|
|
|
'build/actions-oclif/env/add.js',
|
2019-09-06 13:43:53 +00:00
|
|
|
'build/actions-oclif/env/rename.js',
|
2019-08-07 09:28:15 +00:00
|
|
|
'build/actions-oclif/env/rm.js',
|
2019-04-02 11:26:21 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Tags',
|
2020-05-26 09:17:30 +00:00
|
|
|
files: [
|
|
|
|
'build/actions-oclif/tags.js',
|
|
|
|
'build/actions-oclif/tag/rm.js',
|
|
|
|
'build/actions-oclif/tag/set.js',
|
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-24 15:51:07 +00:00
|
|
|
title: 'Help and Version',
|
|
|
|
files: ['build/actions/help.js', 'build/actions-oclif/version.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Keys',
|
2020-04-17 13:19:33 +00:00
|
|
|
files: [
|
|
|
|
'build/actions-oclif/keys.js',
|
|
|
|
'build/actions-oclif/key/index.js',
|
|
|
|
'build/actions-oclif/key/add.js',
|
|
|
|
'build/actions-oclif/key/rm.js',
|
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Logs',
|
2020-07-01 13:52:33 +00:00
|
|
|
files: ['build/actions-oclif/logs.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 22:17:59 +00:00
|
|
|
title: 'Network',
|
|
|
|
files: [
|
2020-03-13 11:32:29 +00:00
|
|
|
'build/actions-oclif/scan.js',
|
2020-06-24 13:24:54 +00:00
|
|
|
'build/actions-oclif/ssh.js',
|
2020-06-29 12:45:32 +00:00
|
|
|
'build/actions-oclif/tunnel.js',
|
2019-06-05 22:17:59 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Notes',
|
2020-03-25 17:07:17 +00:00
|
|
|
files: ['build/actions-oclif/note.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'OS',
|
2020-07-14 13:23:45 +00:00
|
|
|
files: [
|
2020-07-16 10:15:06 +00:00
|
|
|
'build/actions-oclif/os/build-config.js',
|
2020-07-14 13:23:45 +00:00
|
|
|
'build/actions-oclif/os/configure.js',
|
|
|
|
'build/actions-oclif/os/versions.js',
|
2020-07-13 13:07:51 +00:00
|
|
|
'build/actions-oclif/os/download.js',
|
2020-07-15 19:13:18 +00:00
|
|
|
'build/actions-oclif/os/initialize.js',
|
2020-07-14 13:23:45 +00:00
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Config',
|
2020-07-28 12:40:47 +00:00
|
|
|
files: [
|
|
|
|
'build/actions-oclif/config/generate.js',
|
|
|
|
'build/actions-oclif/config/inject.js',
|
|
|
|
'build/actions-oclif/config/read.js',
|
|
|
|
'build/actions-oclif/config/reconfigure.js',
|
|
|
|
'build/actions-oclif/config/write.js',
|
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Preload',
|
|
|
|
files: ['build/actions/preload.js'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Push',
|
|
|
|
files: ['build/actions/push.js'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Settings',
|
2020-03-24 10:44:32 +00:00
|
|
|
files: ['build/actions-oclif/settings.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Local',
|
2020-07-09 13:38:04 +00:00
|
|
|
files: [
|
2020-07-10 11:27:55 +00:00
|
|
|
'build/actions-oclif/local/configure.js',
|
2020-07-09 13:38:04 +00:00
|
|
|
'build/actions-oclif/local/flash.js',
|
|
|
|
],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Deploy',
|
|
|
|
files: ['build/actions/build.js', 'build/actions/deploy.js'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Platform',
|
2020-04-09 14:34:24 +00:00
|
|
|
files: ['build/actions-oclif/join.js', 'build/actions-oclif/leave.js'],
|
2019-04-18 15:49:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Utilities',
|
2020-07-09 11:58:59 +00:00
|
|
|
files: ['build/actions-oclif/util/available-drives.js'],
|
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'),
|
|
|
|
mdParser.getSectionOfTitle('Getting Started'),
|
|
|
|
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
|
|
|
}
|