@appium/docutils 0.4.12 → 1.0.1
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/base-mkdocs.yml +45 -5
- package/build/lib/builder/deploy.d.ts +4 -4
- package/build/lib/builder/deploy.d.ts.map +1 -1
- package/build/lib/builder/deploy.js +5 -4
- package/build/lib/builder/deploy.js.map +1 -1
- package/build/lib/builder/index.d.ts +0 -2
- package/build/lib/builder/index.d.ts.map +1 -1
- package/build/lib/builder/index.js +0 -2
- package/build/lib/builder/index.js.map +1 -1
- package/build/lib/builder/site.d.ts +2 -2
- package/build/lib/builder/site.js +2 -2
- package/build/lib/cli/command/build.d.ts +8 -45
- package/build/lib/cli/command/build.d.ts.map +1 -1
- package/build/lib/cli/command/build.js +11 -56
- package/build/lib/cli/command/build.js.map +1 -1
- package/build/lib/cli/command/init.d.ts +0 -27
- package/build/lib/cli/command/init.d.ts.map +1 -1
- package/build/lib/cli/command/init.js +0 -27
- package/build/lib/cli/command/init.js.map +1 -1
- package/build/lib/cli/command/validate.d.ts +0 -24
- package/build/lib/cli/command/validate.d.ts.map +1 -1
- package/build/lib/cli/command/validate.js +2 -26
- package/build/lib/cli/command/validate.js.map +1 -1
- package/build/lib/constants.d.ts +3 -14
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +4 -15
- package/build/lib/constants.js.map +1 -1
- package/build/lib/fs.d.ts +0 -29
- package/build/lib/fs.d.ts.map +1 -1
- package/build/lib/fs.js +4 -57
- package/build/lib/fs.js.map +1 -1
- package/build/lib/index.d.ts +0 -1
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +0 -1
- package/build/lib/index.js.map +1 -1
- package/build/lib/init.d.ts +7 -131
- package/build/lib/init.d.ts.map +1 -1
- package/build/lib/init.js +2 -55
- package/build/lib/init.js.map +1 -1
- package/build/lib/model.d.ts +0 -11
- package/build/lib/model.d.ts.map +1 -1
- package/build/lib/validate.d.ts +2 -30
- package/build/lib/validate.d.ts.map +1 -1
- package/build/lib/validate.js +2 -93
- package/build/lib/validate.js.map +1 -1
- package/lib/builder/deploy.ts +17 -15
- package/lib/builder/index.ts +0 -2
- package/lib/builder/site.ts +6 -6
- package/lib/cli/command/build.ts +12 -59
- package/lib/cli/command/init.ts +0 -27
- package/lib/cli/command/validate.ts +3 -27
- package/lib/constants.ts +4 -17
- package/lib/fs.ts +16 -84
- package/lib/index.ts +0 -1
- package/lib/init.ts +9 -106
- package/lib/model.ts +0 -14
- package/lib/validate.ts +23 -172
- package/package.json +7 -13
- package/requirements.txt +4 -3
- package/tsconfig.json +1 -0
- package/build/lib/builder/nav.d.ts +0 -81
- package/build/lib/builder/nav.d.ts.map +0 -1
- package/build/lib/builder/nav.js +0 -288
- package/build/lib/builder/nav.js.map +0 -1
- package/build/lib/builder/reference.d.ts +0 -57
- package/build/lib/builder/reference.d.ts.map +0 -1
- package/build/lib/builder/reference.js +0 -111
- package/build/lib/builder/reference.js.map +0 -1
- package/build/lib/mike.d.ts +0 -81
- package/build/lib/mike.d.ts.map +0 -1
- package/build/lib/mike.js +0 -146
- package/build/lib/mike.js.map +0 -1
- package/lib/builder/nav.ts +0 -402
- package/lib/builder/reference.ts +0 -171
- package/lib/mike.js +0 -153
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Handles updating/adding the `nav` property of `mkdocs.yml`, based on the output of `typedoc`;
|
|
3
|
-
* specifically, the command documentation generated by `@appium/typedoc-plugin-appium`.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
import { MkDocsYmlNav } from '../model';
|
|
8
|
-
/**
|
|
9
|
-
* Because the `nav` property of `mkdocs.yml` is both a recursive type and a kind of awful one, it's
|
|
10
|
-
* easier to work with it if we rewrite the data into a flat array of objects. We keep a `keypath`
|
|
11
|
-
* prop which represents the deep/nested location within the `nav` object.
|
|
12
|
-
*
|
|
13
|
-
* @privateRemarks This function is not recursive; instead it loops over a queue of items to process
|
|
14
|
-
* data, and we append to that queue while processing if needed.
|
|
15
|
-
* @param nav Contents of the `nav` prop of `mkdocs.yml`
|
|
16
|
-
* @returns A list of objects, each with a `keypath` property and a `fileOrUrl` property (and maybe
|
|
17
|
-
* a `name` property)
|
|
18
|
-
*/
|
|
19
|
-
export declare function parseNav(nav: MkDocsYmlNav): ParsedNavData[];
|
|
20
|
-
/**
|
|
21
|
-
* Update the `nav` property of `mkdocs.yml` with a list of "command" files generated by TypeDoc via
|
|
22
|
-
* `@appium/typedoc-plugin-appium`.
|
|
23
|
-
*
|
|
24
|
-
* To be clear, this function **modifies the MkDocs config file (`mkdocs.yml`) in place**; it is
|
|
25
|
-
* typically under version control, so if this function makes any changes, you'll want to commit them.
|
|
26
|
-
* @param opts - Options
|
|
27
|
-
* @todo implement `dryRun` option
|
|
28
|
-
*/
|
|
29
|
-
export declare function updateNav({ cwd, mkdocsYml: mkDocsYmlPath, typedocJson: typeDocJsonPath, all, }?: UpdateNavOpts): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Options for {@linkcode updateNav}
|
|
32
|
-
*/
|
|
33
|
-
export interface UpdateNavOpts {
|
|
34
|
-
/**
|
|
35
|
-
* Current working directory
|
|
36
|
-
*/
|
|
37
|
-
cwd?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Path to `mkdocs.yml`
|
|
40
|
-
*/
|
|
41
|
-
mkdocsYml?: string;
|
|
42
|
-
/**
|
|
43
|
-
* Path to `package.json`
|
|
44
|
-
*/
|
|
45
|
-
packageJson?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Path to `typedoc.json`
|
|
48
|
-
*/
|
|
49
|
-
typedocJson?: string;
|
|
50
|
-
/**
|
|
51
|
-
* If `true`, do not write any files
|
|
52
|
-
* @remarks Not yet implemented
|
|
53
|
-
*/
|
|
54
|
-
dryRun?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* If `true`, add _all_ reference documentation to the navigation config (not just commands)
|
|
57
|
-
*/
|
|
58
|
-
all?: boolean;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Used internally by {@linkcode updatedNav}
|
|
62
|
-
* @see {@linkcode parseNav}
|
|
63
|
-
*/
|
|
64
|
-
interface ParsedNavData {
|
|
65
|
-
/**
|
|
66
|
-
* Keypath within `nav` for some file or URL
|
|
67
|
-
*/
|
|
68
|
-
keypath: string;
|
|
69
|
-
/**
|
|
70
|
-
* A filepath (usually) or a URL.
|
|
71
|
-
* This is considered the "index" of the data, and should be unique within its parent. If it's not
|
|
72
|
-
* unique, then it will probably end up that way after updating...
|
|
73
|
-
*/
|
|
74
|
-
fileOrUrl: string;
|
|
75
|
-
/**
|
|
76
|
-
* If this file or url has a proper name, this would be it. Most don't.
|
|
77
|
-
*/
|
|
78
|
-
name?: string;
|
|
79
|
-
}
|
|
80
|
-
export {};
|
|
81
|
-
//# sourceMappingURL=nav.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nav.d.ts","sourceRoot":"","sources":["../../../lib/builder/nav.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuBH,OAAO,EAAY,YAAY,EAAC,MAAM,UAAU,CAAC;AA4BjD;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,YAAY,GAAG,aAAa,EAAE,CAgC3D;AAmJD;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,EAC9B,GAAmB,EACnB,SAAS,EAAE,aAAa,EACxB,WAAW,EAAE,eAAe,EAC5B,GAAW,GACZ,GAAE,aAAkB,iBAwFpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;GAGG;AACH,UAAU,aAAa;IACrB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
package/build/lib/builder/nav.js
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Handles updating/adding the `nav` property of `mkdocs.yml`, based on the output of `typedoc`;
|
|
4
|
-
* specifically, the command documentation generated by `@appium/typedoc-plugin-appium`.
|
|
5
|
-
*
|
|
6
|
-
* @module
|
|
7
|
-
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.updateNav = exports.parseNav = void 0;
|
|
13
|
-
const support_1 = require("@appium/support");
|
|
14
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
15
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
-
const constants_1 = require("../constants");
|
|
17
|
-
const error_1 = require("../error");
|
|
18
|
-
const fs_1 = require("../fs");
|
|
19
|
-
const logger_1 = require("../logger");
|
|
20
|
-
const util_1 = require("../util");
|
|
21
|
-
const log = (0, logger_1.getLogger)('builder:nav');
|
|
22
|
-
/**
|
|
23
|
-
* Gets a list of `.md` files relative to `docs_dir`
|
|
24
|
-
* @param targetDir Directory ostensibly containing Markdown files; must be absolute
|
|
25
|
-
* @param mkDocsDocsDir The path to the `docs_dir` in the `mkdocs.yml` file; must be absolute
|
|
26
|
-
* @returns List of Markdown files relative to the `docs_dir` in the `mkdocs.yml` file
|
|
27
|
-
*/
|
|
28
|
-
async function findRelativeMarkdownFiles(targetDir, mkDocsDocsDir) {
|
|
29
|
-
if (!node_path_1.default.isAbsolute(targetDir)) {
|
|
30
|
-
throw new error_1.DocutilsError(`Expected absolute path, got '${targetDir}'`);
|
|
31
|
-
}
|
|
32
|
-
if (!node_path_1.default.isAbsolute(mkDocsDocsDir)) {
|
|
33
|
-
throw new error_1.DocutilsError(`Expected absolute path, got '${mkDocsDocsDir}'`);
|
|
34
|
-
}
|
|
35
|
-
const relDir = node_path_1.default.relative(mkDocsDocsDir, targetDir);
|
|
36
|
-
const dirEnts = await support_1.fs.readdir(targetDir, { withFileTypes: true });
|
|
37
|
-
return dirEnts
|
|
38
|
-
.filter((ent) => ent.isFile() && ent.name.endsWith('.md'))
|
|
39
|
-
.map((ent) => node_path_1.default.join(relDir, ent.name));
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Because the `nav` property of `mkdocs.yml` is both a recursive type and a kind of awful one, it's
|
|
43
|
-
* easier to work with it if we rewrite the data into a flat array of objects. We keep a `keypath`
|
|
44
|
-
* prop which represents the deep/nested location within the `nav` object.
|
|
45
|
-
*
|
|
46
|
-
* @privateRemarks This function is not recursive; instead it loops over a queue of items to process
|
|
47
|
-
* data, and we append to that queue while processing if needed.
|
|
48
|
-
* @param nav Contents of the `nav` prop of `mkdocs.yml`
|
|
49
|
-
* @returns A list of objects, each with a `keypath` property and a `fileOrUrl` property (and maybe
|
|
50
|
-
* a `name` property)
|
|
51
|
-
*/
|
|
52
|
-
function parseNav(nav) {
|
|
53
|
-
let parsedNav = [];
|
|
54
|
-
const entries = Object.entries(nav);
|
|
55
|
-
const queue = [{ entries, keypath: '' }];
|
|
56
|
-
while (queue.length) {
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
58
|
-
const { entries, keypath } = queue.shift();
|
|
59
|
-
for (const [key, item] of entries) {
|
|
60
|
-
if (lodash_1.default.isString(item)) {
|
|
61
|
-
const navData = {
|
|
62
|
-
keypath: keypath ? `${keypath}.${key}` : key,
|
|
63
|
-
fileOrUrl: item,
|
|
64
|
-
};
|
|
65
|
-
// if the key is not convertible to a number, it's a name
|
|
66
|
-
// which was manually put there by somebody.
|
|
67
|
-
if (Number.isNaN(Number(key))) {
|
|
68
|
-
navData.name = key;
|
|
69
|
-
}
|
|
70
|
-
parsedNav = [...parsedNav, navData];
|
|
71
|
-
}
|
|
72
|
-
else if (lodash_1.default.isObject(item)) {
|
|
73
|
-
const subEntries = Object.entries(item);
|
|
74
|
-
queue.push({ entries: subEntries, keypath: keypath ? `${keypath}.${key}` : key });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return parsedNav;
|
|
79
|
-
}
|
|
80
|
-
exports.parseNav = parseNav;
|
|
81
|
-
/**
|
|
82
|
-
* Finds all items within the list of parsed nav data which correpsond to the header.
|
|
83
|
-
*
|
|
84
|
-
* This is imperfect, as it's possible for the header string to appear in multiple places in the
|
|
85
|
-
* nav, but let's just ignore that until we can't.
|
|
86
|
-
* @param navData Some parsed nav data
|
|
87
|
-
* @param header Header name
|
|
88
|
-
*/
|
|
89
|
-
function filterHeaderItems(navData, header) {
|
|
90
|
-
return lodash_1.default.filter(navData, (item) => lodash_1.default.toPath(item.keypath).includes(header));
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Given a root header keypath (like a prefix), a numeric offset, and some parsed nav data, compute
|
|
94
|
-
* a keypath
|
|
95
|
-
*
|
|
96
|
-
* @param rootHeaderKeypath Root keypath as determined by {@linkcode getRootHeaderKeypath}
|
|
97
|
-
* @param offset Numeric offset within the array of items for the header
|
|
98
|
-
* @param data Any parsed nav data found. For new items, this will be `undefined`. If not new, it
|
|
99
|
-
* may or may not have a `name` prop, and if it does, we want to retain it.
|
|
100
|
-
* @returns Complete keypath for a nav item beginning with the root keypath
|
|
101
|
-
*/
|
|
102
|
-
function getKeypathForHeaderItem(rootHeaderKeypath, offset, data) {
|
|
103
|
-
return data?.name
|
|
104
|
-
? `${rootHeaderKeypath}.${offset}.${data.name}`
|
|
105
|
-
: `${rootHeaderKeypath}.${offset}`;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Compares two sets of nav data and determines if they are different.
|
|
109
|
-
*
|
|
110
|
-
* This does not compare the entire `nav` object with a new one; it works per-header
|
|
111
|
-
* @param newNavData Nav data as computed by {@linkcode getNavItemsForDir} corresponding to a
|
|
112
|
-
* particular header
|
|
113
|
-
* @param navData Subset of original nav data as parsed by {@linkcode parseNav}, corresponding to
|
|
114
|
-
* the same header
|
|
115
|
-
*/
|
|
116
|
-
function navDataDidChange(newNavData, navData) {
|
|
117
|
-
// the result should be the items from newNavData which either don't appear in
|
|
118
|
-
// navdata, or the items which do appear in navData but have a different fileOrUrl
|
|
119
|
-
const matchedKeypaths = lodash_1.default.intersectionBy(newNavData, navData, 'keypath');
|
|
120
|
-
const diff = lodash_1.default.xorBy(newNavData, matchedKeypaths, 'fileOrUrl');
|
|
121
|
-
return !lodash_1.default.isEmpty(diff);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Find the "root" keypath for a particular header
|
|
125
|
-
*
|
|
126
|
-
* @param headerItems Some subset of the nav data having keypaths corresponding to `header`
|
|
127
|
-
* @param header Header string
|
|
128
|
-
* @returns The keypath up to the header string, inclusive
|
|
129
|
-
*/
|
|
130
|
-
function getRootHeaderKeypath(headerItems, header) {
|
|
131
|
-
// these are the parts of the keypath of the first item, which will contain the header string. it
|
|
132
|
-
// dosn't matter whether we pick the first one or any one; they will all contain the same root
|
|
133
|
-
// keypath by definition.
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
135
|
-
const rootHeaderKeypathParts = lodash_1.default.toPath(lodash_1.default.first(headerItems).keypath);
|
|
136
|
-
// this is the keypath up to the header string, inclusive.
|
|
137
|
-
// we append indices or names to this keypath
|
|
138
|
-
return rootHeaderKeypathParts.slice(0, rootHeaderKeypathParts.indexOf(header) + 1).join('.');
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* This examines the `navData` looking for items matching the header string (which _may_ be defined
|
|
142
|
-
* by `dir`; if `all` is true, we just use the default header, because we will be returning a whole
|
|
143
|
-
* lot of headers).
|
|
144
|
-
*
|
|
145
|
-
* @param dir Abs path to directory containing markdown files generated by TypeDoc
|
|
146
|
-
* @param mkDocsDocsDir Configured `docs_dir` or via options
|
|
147
|
-
* @param navData Nav data parsed by {@linkcode parseNav}
|
|
148
|
-
* @param all If `true`, process all markdown files, not just commands
|
|
149
|
-
*/
|
|
150
|
-
async function getNavItemsForDir(dir, mkDocsDocsDir, navData, nav, all = false) {
|
|
151
|
-
let dataChanged = false;
|
|
152
|
-
const newNavHeaderItems = [];
|
|
153
|
-
const referenceOutputFilepaths = await findRelativeMarkdownFiles(dir, mkDocsDocsDir);
|
|
154
|
-
if (!referenceOutputFilepaths.length) {
|
|
155
|
-
log.warn('No markdown files found in %s; did TypeDoc run?', dir);
|
|
156
|
-
return { data: [], changed: false };
|
|
157
|
-
}
|
|
158
|
-
const navHeader = all ? lodash_1.default.startCase(node_path_1.default.basename(dir)) : constants_1.DEFAULT_NAV_HEADER;
|
|
159
|
-
const navHeaderItems = filterHeaderItems(navData, navHeader);
|
|
160
|
-
// if we found items with this header already, we are going
|
|
161
|
-
// to replace them all wholesale
|
|
162
|
-
if (navHeaderItems.length) {
|
|
163
|
-
log.debug('Found %d item(s) in header %s', navHeaderItems.length, navHeader);
|
|
164
|
-
// we append indices or names to this keypath
|
|
165
|
-
const rootHeaderKeypath = getRootHeaderKeypath(navHeaderItems, navHeader);
|
|
166
|
-
for (const fileOrUrl of referenceOutputFilepaths) {
|
|
167
|
-
const offset = navHeaderItems.findIndex((item) => item.fileOrUrl === fileOrUrl);
|
|
168
|
-
const newOffset = offset >= 0 ? offset : navHeaderItems.length;
|
|
169
|
-
const data = navHeaderItems[offset];
|
|
170
|
-
const keypath = getKeypathForHeaderItem(rootHeaderKeypath, newOffset, data);
|
|
171
|
-
newNavHeaderItems.push({ keypath, fileOrUrl });
|
|
172
|
-
}
|
|
173
|
-
// look for any differences between what we have and what's in the file
|
|
174
|
-
if (navDataDidChange(newNavHeaderItems, navHeaderItems)) {
|
|
175
|
-
log.debug('Will write new nav data for header %s: %O', navHeader, newNavHeaderItems);
|
|
176
|
-
dataChanged = true;
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
log.debug('No changes for header %s', navHeader);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
log.debug('No items found in header %s', navHeader);
|
|
184
|
-
const navOffset = nav.length;
|
|
185
|
-
for (const [idx, newRefFilepath] of referenceOutputFilepaths.entries()) {
|
|
186
|
-
newNavHeaderItems.push({
|
|
187
|
-
keypath: `${navOffset}.${navHeader}.${idx}`,
|
|
188
|
-
fileOrUrl: newRefFilepath,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
log.debug('Will create nav data for header %s', navHeader);
|
|
192
|
-
dataChanged = true;
|
|
193
|
-
}
|
|
194
|
-
return { data: newNavHeaderItems, changed: dataChanged };
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Applies the changes in `newData` to the `mkDocsYml` object.
|
|
198
|
-
*
|
|
199
|
-
* **This function mutates `mkDocsYml`.**
|
|
200
|
-
* @param newData New nav data
|
|
201
|
-
* @param mkDocsYml Original `mkdocs.yml`
|
|
202
|
-
*/
|
|
203
|
-
function applyNavData(newData, mkDocsYml) {
|
|
204
|
-
for (const { keypath, fileOrUrl } of newData) {
|
|
205
|
-
lodash_1.default.set(mkDocsYml, `nav.${keypath}`, fileOrUrl);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Update the `nav` property of `mkdocs.yml` with a list of "command" files generated by TypeDoc via
|
|
210
|
-
* `@appium/typedoc-plugin-appium`.
|
|
211
|
-
*
|
|
212
|
-
* To be clear, this function **modifies the MkDocs config file (`mkdocs.yml`) in place**; it is
|
|
213
|
-
* typically under version control, so if this function makes any changes, you'll want to commit them.
|
|
214
|
-
* @param opts - Options
|
|
215
|
-
* @todo implement `dryRun` option
|
|
216
|
-
*/
|
|
217
|
-
async function updateNav({ cwd = process.cwd(), mkdocsYml: mkDocsYmlPath, typedocJson: typeDocJsonPath, all = false, } = {}) {
|
|
218
|
-
// we need `mkdocs.yml` to update
|
|
219
|
-
// and we need `typedoc.json` to know where to look for the command docs
|
|
220
|
-
[mkDocsYmlPath, typeDocJsonPath] = await Promise.all([
|
|
221
|
-
mkDocsYmlPath ?? (0, fs_1.findMkDocsYml)(cwd),
|
|
222
|
-
typeDocJsonPath ?? (0, fs_1.findTypeDocJsonPath)(cwd),
|
|
223
|
-
]);
|
|
224
|
-
if (!mkDocsYmlPath) {
|
|
225
|
-
throw new error_1.DocutilsError(`Could not find ${constants_1.NAME_MKDOCS_YML} from ${cwd}; run "${constants_1.NAME_BIN} init" to create it`);
|
|
226
|
-
}
|
|
227
|
-
if (!typeDocJsonPath) {
|
|
228
|
-
throw new error_1.DocutilsError(`Could not find ${constants_1.NAME_TYPEDOC_JSON} from ${cwd}; run "${constants_1.NAME_BIN} init" to create it`);
|
|
229
|
-
}
|
|
230
|
-
const relativePath = (0, util_1.relative)(cwd);
|
|
231
|
-
const relMkDocsYmlPath = relativePath(mkDocsYmlPath);
|
|
232
|
-
const typeDocJson = (0, fs_1.readTypedocJson)(typeDocJsonPath);
|
|
233
|
-
const mkDocsYml = (await (0, fs_1.readYaml)(mkDocsYmlPath));
|
|
234
|
-
/**
|
|
235
|
-
* Absolute path to `typedoc.json`
|
|
236
|
-
*/
|
|
237
|
-
const absTypeDocJsonPath = node_path_1.default.isAbsolute(typeDocJsonPath)
|
|
238
|
-
? typeDocJsonPath
|
|
239
|
-
: node_path_1.default.resolve(cwd, typeDocJsonPath);
|
|
240
|
-
/**
|
|
241
|
-
* Absolute path to TypeDoc's output directory (`out`)
|
|
242
|
-
*/
|
|
243
|
-
const typeDocOutDir = node_path_1.default.resolve(node_path_1.default.dirname(absTypeDocJsonPath), typeDocJson.out ? typeDocJson.out : constants_1.DEFAULT_REL_TYPEDOC_OUT_PATH);
|
|
244
|
-
/**
|
|
245
|
-
* Absolute path to `mkdocs.yml`
|
|
246
|
-
*/
|
|
247
|
-
const absMkdocsYmlPath = node_path_1.default.isAbsolute(mkDocsYmlPath)
|
|
248
|
-
? mkDocsYmlPath
|
|
249
|
-
: node_path_1.default.resolve(cwd, mkDocsYmlPath);
|
|
250
|
-
const { docs_dir: docsDir, nav = [] } = mkDocsYml;
|
|
251
|
-
/**
|
|
252
|
-
* Absolute path to the directory containing MkDocs input docs
|
|
253
|
-
*/
|
|
254
|
-
const mkDocsDocsDir = node_path_1.default.resolve(node_path_1.default.dirname(absMkdocsYmlPath), docsDir ?? 'docs');
|
|
255
|
-
/**
|
|
256
|
-
* @todo
|
|
257
|
-
* `commands` is a dirname configurable via the `commandsDir` option added by
|
|
258
|
-
* `@appium/typedoc-plugin-appium`. this lives in `typedoc.json`, but in order for it to be parsed
|
|
259
|
-
* using TypeDoc's facilities, we have to load plugins before reading `typedoc.json`, which is
|
|
260
|
-
* slow. we will probably have to support this in the future, but for now, we can just hardcode it
|
|
261
|
-
*/
|
|
262
|
-
const dirs = all ? await (0, fs_1.findDirsIn)(typeDocOutDir) : [node_path_1.default.join(typeDocOutDir, 'commands')];
|
|
263
|
-
let shouldWriteMkDocsYml = false;
|
|
264
|
-
const navData = parseNav(nav);
|
|
265
|
-
// this is the thing which will be assigned to the `nav` prop
|
|
266
|
-
// and thus written to `mkdocs.yml` if there were any changes.
|
|
267
|
-
// we don't need the `name` prop, since the name is already present in the keypath.
|
|
268
|
-
const newData = [];
|
|
269
|
-
for await (const dir of dirs) {
|
|
270
|
-
const { data, changed } = await getNavItemsForDir(dir, mkDocsDocsDir, navData, nav, all);
|
|
271
|
-
if (changed) {
|
|
272
|
-
shouldWriteMkDocsYml = true;
|
|
273
|
-
}
|
|
274
|
-
newData.push(...data);
|
|
275
|
-
}
|
|
276
|
-
if (shouldWriteMkDocsYml) {
|
|
277
|
-
applyNavData(newData, mkDocsYml);
|
|
278
|
-
const yaml = (0, fs_1.stringifyYaml)(mkDocsYml);
|
|
279
|
-
log.debug('Writing to %s:\n%s', mkDocsYmlPath, yaml);
|
|
280
|
-
await (0, fs_1.safeWriteFile)(mkDocsYmlPath, yaml, true);
|
|
281
|
-
log.success('Updated MkDocs navigation config for reference docs; please run "git add -A %s" and commit this change', relMkDocsYmlPath);
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
log.info('No changes needed for MkDocs config at %s', relMkDocsYmlPath);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
exports.updateNav = updateNav;
|
|
288
|
-
//# sourceMappingURL=nav.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nav.js","sourceRoot":"","sources":["../../../lib/builder/nav.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,6CAAmC;AACnC,oDAAuB;AACvB,0DAA6B;AAC7B,4CAMsB;AACtB,oCAAuC;AACvC,8BAQe;AACf,sCAAoC;AAEpC,kCAAiC;AAEjC,MAAM,GAAG,GAAG,IAAA,kBAAS,EAAC,aAAa,CAAC,CAAC;AAErC;;;;;GAKG;AACH,KAAK,UAAU,yBAAyB,CACtC,SAAiB,EACjB,aAAqB;IAErB,IAAI,CAAC,mBAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC/B,MAAM,IAAI,qBAAa,CAAC,gCAAgC,SAAS,GAAG,CAAC,CAAC;KACvE;IACD,IAAI,CAAC,mBAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;QACnC,MAAM,IAAI,qBAAa,CAAC,gCAAgC,aAAa,GAAG,CAAC,CAAC;KAC3E;IACD,MAAM,MAAM,GAAG,mBAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,MAAM,YAAE,CAAC,OAAO,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,GAAG,IAAI,IAAI,EAAE;QAC5B,MAAM,EAAC,IAAI,EAAE,OAAO,EAAC,GAAG,MAAM,iBAAiB,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACvF,IAAI,OAAO,EAAE;YACX,oBAAoB,GAAG,IAAI,CAAC;SAC7B;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;KACvB;IAED,IAAI,oBAAoB,EAAE;QACxB,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACjC,MAAM,IAAI,GAAG,IAAA,kBAAa,EAAC,SAAS,CAAC,CAAC;QACtC,GAAG,CAAC,KAAK,CAAC,oBAAoB,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;QACrD,MAAM,IAAA,kBAAa,EAAC,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC/C,GAAG,CAAC,OAAO,CACT,wGAAwG,EACxG,gBAAgB,CACjB,CAAC;KACH;SAAM;QACL,GAAG,CAAC,IAAI,CAAC,2CAA2C,EAAE,gBAAgB,CAAC,CAAC;KACzE;AACH,CAAC;AA7FD,8BA6FC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds reference documentation via TypeDoc. The output is _markdown_, intended to be imported into MkDocs.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Executes TypeDoc _in the current process_
|
|
8
|
-
*
|
|
9
|
-
* You will probably want to run `updateNav()` after this.
|
|
10
|
-
*
|
|
11
|
-
* @privateRemarks Monkeypatches TypeDoc's homebrew "glob" implementation because it is broken
|
|
12
|
-
* @parma typeDocJsonPath - Path to `typedoc.json`
|
|
13
|
-
* @param opts - TypeDoc options
|
|
14
|
-
*/
|
|
15
|
-
export declare function runTypedoc(typeDocJsonPath: string, opts: Record<string, string>): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Options for {@linkcode buildReferenceDocs}
|
|
18
|
-
*/
|
|
19
|
-
export interface BuildReferenceOptions {
|
|
20
|
-
/**
|
|
21
|
-
* Path to `typedoc.json`
|
|
22
|
-
*/
|
|
23
|
-
typedocJson?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Current working directory
|
|
26
|
-
*/
|
|
27
|
-
cwd?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Path to `package.json`
|
|
30
|
-
*/
|
|
31
|
-
packageJson?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Path to `tsconfig.json`
|
|
34
|
-
*/
|
|
35
|
-
tsconfigJson?: string;
|
|
36
|
-
/**
|
|
37
|
-
* "Title" for generated docs; this corresponds to {@linkcode typedoc.TypeDocOptionMap.name}
|
|
38
|
-
*/
|
|
39
|
-
title?: string;
|
|
40
|
-
/**
|
|
41
|
-
* This is here because we pass it thru to TypeDoc
|
|
42
|
-
*/
|
|
43
|
-
logLevel?: LogLevelName;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Log level names as supported by this package
|
|
47
|
-
*
|
|
48
|
-
* Used to convert our log level to TypeDoc's
|
|
49
|
-
*/
|
|
50
|
-
type LogLevelName = 'debug' | 'info' | 'error' | 'warn';
|
|
51
|
-
/**
|
|
52
|
-
* Build reference documentation via TypeDoc
|
|
53
|
-
* @param opts - Options
|
|
54
|
-
*/
|
|
55
|
-
export declare function buildReferenceDocs({ typedocJson: typeDocJsonPath, cwd, tsconfigJson: tsconfig, logLevel, title, }?: BuildReferenceOptions): Promise<void>;
|
|
56
|
-
export {};
|
|
57
|
-
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../lib/builder/reference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmBH;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,iBAmBrF;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED;;;;GAIG;AACH,KAAK,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAexD;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,WAAW,EAAE,eAAe,EAC5B,GAAmB,EACnB,YAAY,EAAE,QAAQ,EACtB,QAA4B,EAC5B,KAAK,GACN,GAAE,qBAA0B,iBAyD5B"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Builds reference documentation via TypeDoc. The output is _markdown_, intended to be imported into MkDocs.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.buildReferenceDocs = exports.runTypedoc = void 0;
|
|
12
|
-
const support_1 = require("@appium/support");
|
|
13
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
14
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
-
const typedoc_1 = require("typedoc");
|
|
16
|
-
const constants_1 = require("../constants");
|
|
17
|
-
const error_1 = require("../error");
|
|
18
|
-
const fs_1 = require("../fs");
|
|
19
|
-
const logger_1 = require("../logger");
|
|
20
|
-
const util_1 = require("../util");
|
|
21
|
-
const log = (0, logger_1.getLogger)('builder:reference');
|
|
22
|
-
/**
|
|
23
|
-
* Executes TypeDoc _in the current process_
|
|
24
|
-
*
|
|
25
|
-
* You will probably want to run `updateNav()` after this.
|
|
26
|
-
*
|
|
27
|
-
* @privateRemarks Monkeypatches TypeDoc's homebrew "glob" implementation because it is broken
|
|
28
|
-
* @parma typeDocJsonPath - Path to `typedoc.json`
|
|
29
|
-
* @param opts - TypeDoc options
|
|
30
|
-
*/
|
|
31
|
-
async function runTypedoc(typeDocJsonPath, opts) {
|
|
32
|
-
const args = (0, util_1.argify)(opts);
|
|
33
|
-
log.debug('TypeDoc args:', args);
|
|
34
|
-
const app = new typedoc_1.Application();
|
|
35
|
-
app.options.setValue('plugin', [
|
|
36
|
-
'typedoc-plugin-markdown',
|
|
37
|
-
'typedoc-plugin-resolve-crossmodule-references',
|
|
38
|
-
'@appium/typedoc-plugin-appium',
|
|
39
|
-
]);
|
|
40
|
-
app.options.addReader(new typedoc_1.TypeDocReader());
|
|
41
|
-
app.options.addReader(new typedoc_1.ArgumentsReader(100, args));
|
|
42
|
-
app.bootstrap({ options: node_path_1.default.dirname(typeDocJsonPath) });
|
|
43
|
-
const out = app.options.getValue('out');
|
|
44
|
-
const project = app.convert();
|
|
45
|
-
if (project) {
|
|
46
|
-
return await app.generateDocs(project, out);
|
|
47
|
-
}
|
|
48
|
-
throw new error_1.DocutilsError('TypeDoc found nothing to document. Is your package empty?');
|
|
49
|
-
}
|
|
50
|
-
exports.runTypedoc = runTypedoc;
|
|
51
|
-
/**
|
|
52
|
-
* Mapping of whatever our log level is to whatever TypeDoc's should be.
|
|
53
|
-
*
|
|
54
|
-
* TypeDoc's "info" is too verbose for our needs, and it's our default, so
|
|
55
|
-
* we map it to "warn".
|
|
56
|
-
*/
|
|
57
|
-
const TypeDocLogLevelMap = {
|
|
58
|
-
debug: 'Verbose',
|
|
59
|
-
info: 'Warn',
|
|
60
|
-
warn: 'Warn',
|
|
61
|
-
error: 'Error',
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Build reference documentation via TypeDoc
|
|
65
|
-
* @param opts - Options
|
|
66
|
-
*/
|
|
67
|
-
async function buildReferenceDocs({ typedocJson: typeDocJsonPath, cwd = process.cwd(), tsconfigJson: tsconfig, logLevel = constants_1.DEFAULT_LOG_LEVEL, title, } = {}) {
|
|
68
|
-
const stop = (0, util_1.stopwatch)('buildReferenceDocs');
|
|
69
|
-
typeDocJsonPath = typeDocJsonPath
|
|
70
|
-
? node_path_1.default.resolve(cwd, typeDocJsonPath)
|
|
71
|
-
: await (0, fs_1.findTypeDocJsonPath)(cwd);
|
|
72
|
-
if (!typeDocJsonPath) {
|
|
73
|
-
throw new error_1.DocutilsError(`Could not find ${constants_1.NAME_TYPEDOC_JSON} from ${cwd}; run "${constants_1.NAME_BIN}" to create it`);
|
|
74
|
-
}
|
|
75
|
-
const pkgRoot = support_1.fs.findRoot(cwd);
|
|
76
|
-
const relativePath = (0, util_1.relative)(cwd);
|
|
77
|
-
const relativeTypeDocJsonPath = relativePath(typeDocJsonPath);
|
|
78
|
-
log.debug(`Using ${relativeTypeDocJsonPath} as typedoc.json`);
|
|
79
|
-
let typeDocJson;
|
|
80
|
-
// we only need typedoc.json to make sure we have a custom "out" path.
|
|
81
|
-
try {
|
|
82
|
-
typeDocJson = (0, fs_1.readTypedocJson)(typeDocJsonPath);
|
|
83
|
-
log.debug('Contents of %s: %O', relativeTypeDocJsonPath, typeDocJson);
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
log.error(err);
|
|
87
|
-
throw new error_1.DocutilsError(`Could not read ${relativeTypeDocJsonPath}; run "${constants_1.NAME_BIN} init" to create it`);
|
|
88
|
-
}
|
|
89
|
-
// if for some reason "out" is not in typedoc.json, we want to use our default path.
|
|
90
|
-
// otherwise, typedoc's default behavior is to write to the "docs" dir, which is the same dir that
|
|
91
|
-
// we use (by default) as a source dir for the mkdocs site--which might contain files under vcs.
|
|
92
|
-
let out;
|
|
93
|
-
if (typeDocJson.out) {
|
|
94
|
-
log.debug(`Found "out" option in ${constants_1.NAME_TYPEDOC_JSON}: ${typeDocJson.out}`);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
out = node_path_1.default.relative(node_path_1.default.dirname(typeDocJsonPath), node_path_1.default.join(pkgRoot, constants_1.DEFAULT_REL_TYPEDOC_OUT_PATH));
|
|
98
|
-
log.debug('Setting "out" option to %s', out);
|
|
99
|
-
}
|
|
100
|
-
const extraTypedocOpts = lodash_1.default.pickBy({ tsconfig, name: title, out, logLevel: TypeDocLogLevelMap[logLevel] }, Boolean);
|
|
101
|
-
try {
|
|
102
|
-
await runTypedoc(typeDocJsonPath, extraTypedocOpts);
|
|
103
|
-
const finalOut = (typeDocJson.out ?? out);
|
|
104
|
-
log.success('Reference docs built at %s (%dms)', node_path_1.default.isAbsolute(finalOut) ? relativePath(finalOut) : finalOut, stop());
|
|
105
|
-
}
|
|
106
|
-
catch (err) {
|
|
107
|
-
log.error(err);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
exports.buildReferenceDocs = buildReferenceDocs;
|
|
111
|
-
//# sourceMappingURL=reference.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../../lib/builder/reference.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,6CAAmC;AACnC,oDAAuB;AACvB,0DAA6B;AAC7B,qCAAoF;AACpF,4CAKsB;AACtB,oCAAuC;AACvC,8BAA2D;AAC3D,sCAAoC;AACpC,kCAAoD;AAEpD,MAAM,GAAG,GAAG,IAAA,kBAAS,EAAC,mBAAmB,CAAC,CAAC;AAE3C;;;;;;;;GAQG;AACI,KAAK,UAAU,UAAU,CAAC,eAAuB,EAAE,IAA4B;IACpF,MAAM,IAAI,GAAG,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC;IAC1B,GAAG,CAAC,K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,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;KAC9C;IAED,MAAM,gBAAgB,GAAG,gBAAC,CAAC,MAAM,CAC/B,EAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAC,EACpE,OAAO,CACkB,CAAC;IAE5B,IAAI;QACF,MAAM,UAAU,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,CAAW,CAAC;QACpD,GAAG,CAAC,OAAO,CACT,mCAAmC,EACnC,mBAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,EAC7D,IAAI,EAAE,CACP,CAAC;KACH;IAAC,OAAO,GAAG,EAAE;QACZ,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAChB;AACH,CAAC;AA/DD,gDA+DC"}
|
package/build/lib/mike.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated Use the `deploy` export from `@appium/docutils`
|
|
3
|
-
*/
|
|
4
|
-
export class Mike {
|
|
5
|
-
constructor(opts: MikeOpts);
|
|
6
|
-
/** @type {string} */ remote: string;
|
|
7
|
-
/** @type {string} */ branch: string;
|
|
8
|
-
/** @type {string?} */ prefix: string | null;
|
|
9
|
-
/** @type {string} */ configFile: string;
|
|
10
|
-
/** @type {boolean} */ _mikeVerified: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Throw an error if the 'mike' binary cannot be found
|
|
13
|
-
*
|
|
14
|
-
* @throws {Error}
|
|
15
|
-
*/
|
|
16
|
-
verifyMike(): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Get an array of args based on the class members that can be used with Mike-related subprocess
|
|
19
|
-
* execution
|
|
20
|
-
*
|
|
21
|
-
* @param {string} cmdName - the name of the mike command to run
|
|
22
|
-
* @param {string[]} cmdArgs - an array of command-specific arguments
|
|
23
|
-
*
|
|
24
|
-
* @returns {string[]}
|
|
25
|
-
*/
|
|
26
|
-
getMikeArgs(cmdName: string, cmdArgs: string[]): string[];
|
|
27
|
-
/**
|
|
28
|
-
* Exec mike as a subprocess
|
|
29
|
-
*
|
|
30
|
-
* @param {string} mikeCmd - the mike command to run
|
|
31
|
-
* @param {string[]} [mikeArgs=[]] - the arguments to pass to the mike command
|
|
32
|
-
* @param {boolean?} [verify=true] - whether to verify mike exists first
|
|
33
|
-
*
|
|
34
|
-
* @returns {Promise<import('teen_process').ExecResult<string>>}
|
|
35
|
-
*/
|
|
36
|
-
exec(mikeCmd: string, mikeArgs?: string[] | undefined, verify?: boolean | null | undefined): Promise<import('teen_process').ExecResult<string>>;
|
|
37
|
-
/**
|
|
38
|
-
* Return the list of mike deploys
|
|
39
|
-
*
|
|
40
|
-
* @returns {string[]}
|
|
41
|
-
*/
|
|
42
|
-
list(): string[];
|
|
43
|
-
/**
|
|
44
|
-
* Set the default version or alias
|
|
45
|
-
*
|
|
46
|
-
* @param {string} alias - the version or alias
|
|
47
|
-
*/
|
|
48
|
-
setDefault(alias: string): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* Deploy docs to the branch
|
|
51
|
-
*
|
|
52
|
-
* @param {MikeDeployOpts} opts - the deploy options
|
|
53
|
-
*/
|
|
54
|
-
deploy(opts: any): Promise<void>;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* - options for instantiating a Mike object
|
|
58
|
-
*/
|
|
59
|
-
export type MikeOpts = {
|
|
60
|
-
/**
|
|
61
|
-
* - the git remote to push docs to
|
|
62
|
-
*/
|
|
63
|
-
remote?: string | undefined;
|
|
64
|
-
/**
|
|
65
|
-
* - the git branch to push docs to
|
|
66
|
-
*/
|
|
67
|
-
branch?: string | undefined;
|
|
68
|
-
/**
|
|
69
|
-
* - the path prefix on the branch if any
|
|
70
|
-
*/
|
|
71
|
-
prefix: string | null;
|
|
72
|
-
/**
|
|
73
|
-
* - the mkdocs config file to use
|
|
74
|
-
*/
|
|
75
|
-
configFile: string;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* - options for deploying docs with Mike
|
|
79
|
-
*/
|
|
80
|
-
export type MikeDeployOpts = any;
|
|
81
|
-
//# sourceMappingURL=mike.d.ts.map
|
package/build/lib/mike.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mike.d.ts","sourceRoot":"","sources":["../../lib/mike.js"],"names":[],"mappings":"AAaA;;GAEG;AACH;IAOE,kBAAsB,QAAQ,EAK7B;IAXD,qBAAqB,CAAC,QAAX,MAAM,CAAY;IAC7B,qBAAqB,CAAC,QAAX,MAAM,CAAY;IAC7B,sBAAsB,CAAC,QAAZ,MAAM,QAAa;IAC9B,qBAAqB,CAAC,YAAX,MAAM,CAAgB;IACjC,sBAAsB,CAAC,eAAZ,OAAO,CAA2B;IAS7C;;;;OAIG;IACH,4BAaC;IAED;;;;;;;;OAQG;IACH,qBALW,MAAM,WACN,MAAM,EAAE,GAEN,MAAM,EAAE,CAepB;IAED;;;;;;;;OAQG;IACH,cANW,MAAM,yEAIJ,QAAQ,OAAO,cAAc,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAS9D;IAED;;;;OAIG;IACH,QAFa,MAAM,EAAE,CAQpB;IAED;;;;OAIG;IACH,kBAFW,MAAM,iBAIhB;IAED;;;;OAIG;IACH,iCAeC;CACF;;;;;;;;;;;;;;;;YAMa,MAAM;;;;gBACN,MAAM"}
|