mirror of
https://github.com/appium/appium.git
synced 2026-05-08 11:59:29 -05:00
chore: lint all the typescript
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import {Constraints, ISessionCommands, MultiSessionData} from '@appium/types';
|
||||
import _ from 'lodash';
|
||||
import {BaseDriver} from '../driver';
|
||||
import {mixin} from './mixin';
|
||||
|
||||
@@ -9,7 +8,7 @@ declare module '../driver' {
|
||||
|
||||
const SessionCommands: ISessionCommands = {
|
||||
async getSessions<C extends Constraints>(this: BaseDriver<C>) {
|
||||
let ret: MultiSessionData[] = [];
|
||||
const ret: MultiSessionData[] = [];
|
||||
|
||||
if (this.sessionId) {
|
||||
ret.push({
|
||||
|
||||
@@ -107,7 +107,7 @@ const TimeoutCommands: ITimeoutCommands = {
|
||||
this.log.debug(`Set implicit wait to ${ms}ms`);
|
||||
if (this.managedDrivers && this.managedDrivers.length) {
|
||||
this.log.debug('Setting implicit wait on managed drivers');
|
||||
for (let driver of this.managedDrivers) {
|
||||
for (const driver of this.managedDrivers) {
|
||||
if (_.isFunction(driver.setImplicitWait)) {
|
||||
driver.setImplicitWait(ms);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ const TimeoutCommands: ITimeoutCommands = {
|
||||
this.log.debug(`Set new command timeout to ${ms}ms`);
|
||||
if (this.managedDrivers && this.managedDrivers.length) {
|
||||
this.log.debug('Setting new command timeout on managed drivers');
|
||||
for (let driver of this.managedDrivers) {
|
||||
for (const driver of this.managedDrivers) {
|
||||
if (_.isFunction(driver.setNewCommandTimeout)) {
|
||||
driver.setNewCommandTimeout(ms);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ const TimeoutCommands: ITimeoutCommands = {
|
||||
|
||||
async implicitWaitForCondition(condFn) {
|
||||
this.log.debug(`Waiting up to ${this.implicitWaitMs} ms for condition`);
|
||||
let wrappedCondFn = async (...args: any[]) => {
|
||||
const wrappedCondFn = async (...args: any[]) => {
|
||||
// reset command timeout
|
||||
await this.clearNewCommandTimeout();
|
||||
|
||||
@@ -144,7 +144,7 @@ const TimeoutCommands: ITimeoutCommands = {
|
||||
},
|
||||
|
||||
parseTimeoutArgument<C extends Constraints>(this: BaseDriver<C>, ms: number | string) {
|
||||
let duration = parseInt(String(ms), 10);
|
||||
const duration = parseInt(String(ms), 10);
|
||||
if (_.isNaN(duration) || duration < MIN_TIMEOUT) {
|
||||
throw new errors.UnknownError(`Invalid timeout value '${ms}'`);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ async function getNavItemsForDir(
|
||||
const rootHeaderKeypath = getRootHeaderKeypath(navHeaderItems, navHeader);
|
||||
|
||||
for (const fileOrUrl of referenceOutputFilepaths) {
|
||||
let offset = navHeaderItems.findIndex((item) => item.fileOrUrl === fileOrUrl);
|
||||
const offset = navHeaderItems.findIndex((item) => item.fileOrUrl === fileOrUrl);
|
||||
const newOffset = offset >= 0 ? offset : navHeaderItems.length;
|
||||
const data = navHeaderItems[offset];
|
||||
log.warn(rootHeaderKeypath, newOffset, data);
|
||||
@@ -214,7 +214,7 @@ async function getNavItemsForDir(
|
||||
}
|
||||
} else {
|
||||
log.debug('No items found in header %s', navHeader);
|
||||
let navOffset = nav.length;
|
||||
const navOffset = nav.length;
|
||||
for (const [idx, newRefFilepath] of referenceOutputFilepaths.entries()) {
|
||||
newNavHeaderItems.push({
|
||||
keypath: `${navOffset}.${navHeader}.${idx}`,
|
||||
@@ -254,7 +254,6 @@ export async function updateNav({
|
||||
mkdocsYml: mkDocsYmlPath,
|
||||
typedocJson: typeDocJsonPath,
|
||||
all = false,
|
||||
dryRun = false,
|
||||
}: UpdateNavOpts = {}) {
|
||||
// we need `mkdocs.yml` to update
|
||||
// and we need `typedoc.json` to know where to look for the command docs
|
||||
|
||||
@@ -159,7 +159,7 @@ export async function buildReferenceDocs({
|
||||
|
||||
try {
|
||||
await runTypedoc(typeDocJsonPath, extraTypedocOpts);
|
||||
let finalOut = (typeDocJson.out ?? out) as string;
|
||||
const finalOut = (typeDocJson.out ?? out) as string;
|
||||
log.success(
|
||||
'Reference docs built at %s (%dms)',
|
||||
path.isAbsolute(finalOut) ? relativePath(finalOut) : finalOut,
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
*/
|
||||
|
||||
import path from 'node:path';
|
||||
import _ from 'lodash';
|
||||
import type {CommandModule, InferredOptionTypes, Options} from 'yargs';
|
||||
import {buildReferenceDocs, buildSite, deploy, updateNav} from '../../builder';
|
||||
import {NAME_BIN} from '../../constants';
|
||||
import {checkMissingPaths} from '../check';
|
||||
import logger from '../../logger';
|
||||
import {stopwatch} from '../../util';
|
||||
import {checkMissingPaths} from '../check';
|
||||
|
||||
const log = logger.withTag('build');
|
||||
|
||||
@@ -242,4 +241,4 @@ export default {
|
||||
}
|
||||
log.success('Done! (total: %dms)', stop());
|
||||
},
|
||||
} as CommandModule<{}, BuildOptions>;
|
||||
} as CommandModule<object, BuildOptions>;
|
||||
|
||||
@@ -178,4 +178,4 @@ export default {
|
||||
await init({...args, overwrite: args.force, cwd: args.dir});
|
||||
log.success('Done (%dms)', done());
|
||||
},
|
||||
} as CommandModule<{}, InitOptions>;
|
||||
} as CommandModule<object, InitOptions>;
|
||||
|
||||
@@ -126,4 +126,4 @@ export default {
|
||||
);
|
||||
}
|
||||
},
|
||||
} as CommandModule<{}, ValidateOptions>;
|
||||
} as CommandModule<object, ValidateOptions>;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
/* eslint-disable no-console */
|
||||
|
||||
/**
|
||||
* Main CLI entry point for `@appium/docutils`
|
||||
@@ -99,7 +100,7 @@ export async function main(argv = hideBin(process.argv)) {
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
// eslint-disable-next-line promise/prefer-await-to-then
|
||||
// eslint-disable-next-line promise/prefer-await-to-then, promise/prefer-await-to-callbacks
|
||||
main().catch((err) => {
|
||||
log.error('Caught otherwise-unhandled rejection (this is probably a bug):', err);
|
||||
});
|
||||
|
||||
@@ -239,14 +239,14 @@ export const whichMike = _.partial(cachedWhich, NAME_MIKE);
|
||||
*/
|
||||
export const readMkDocsYml = _.memoize(
|
||||
async (filepath: string, cwd = process.cwd()): Promise<MkDocsYml> => {
|
||||
let mkDocsYml = <MkDocsYml>await readYaml(filepath);
|
||||
let mkDocsYml = (await readYaml(filepath)) as MkDocsYml;
|
||||
if (mkDocsYml.site_dir) {
|
||||
mkDocsYml.site_dir = path.resolve(cwd, path.dirname(filepath), mkDocsYml.site_dir);
|
||||
}
|
||||
if (mkDocsYml.INHERIT) {
|
||||
let inheritPath: string | undefined = path.resolve(path.dirname(filepath), mkDocsYml.INHERIT);
|
||||
while (inheritPath) {
|
||||
const inheritYml = <MkDocsYml>await readYaml(inheritPath);
|
||||
const inheritYml = (await readYaml(inheritPath)) as MkDocsYml;
|
||||
if (inheritYml.site_dir) {
|
||||
inheritYml.site_dir = path.resolve(path.dirname(inheritPath), inheritYml.site_dir);
|
||||
log.debug('Resolved site_dir to %s', inheritYml.site_dir);
|
||||
|
||||
@@ -126,7 +126,9 @@ export const initMkDocs = createScaffoldTask<InitMkDocsOptions, MkDocsYml>(
|
||||
if (repoUrl && !repoName) {
|
||||
let {pathname} = new URL(repoUrl);
|
||||
pathname = pathname.slice(1);
|
||||
let [owner, repo] = pathname.split('/');
|
||||
const pathparts = pathname.split('/');
|
||||
const owner = pathparts[0];
|
||||
let repo = pathparts[1];
|
||||
repo = repo.replace(/\.git$/, '');
|
||||
repoName = [owner, repo].join('/');
|
||||
if (repoName) {
|
||||
@@ -262,7 +264,7 @@ export async function init({
|
||||
}
|
||||
}
|
||||
|
||||
export interface InitTypeDocOptions extends ScaffoldTaskOptions {}
|
||||
export type InitTypeDocOptions = ScaffoldTaskOptions;
|
||||
export interface InitTsConfigOptions extends ScaffoldTaskOptions {
|
||||
/**
|
||||
* List of source files (globs supported); typically `src` or `lib`
|
||||
|
||||
@@ -285,7 +285,7 @@ export class DocutilsValidator extends EventEmitter {
|
||||
return this.requirementsTxt;
|
||||
}
|
||||
|
||||
let requiredPackages: PipPackage[] = [];
|
||||
const requiredPackages: PipPackage[] = [];
|
||||
|
||||
try {
|
||||
let requirementsTxt = await fs.readFile(REQUIREMENTS_TXT_PATH, 'utf8');
|
||||
@@ -534,7 +534,7 @@ export class DocutilsValidator extends EventEmitter {
|
||||
}
|
||||
|
||||
if (rawTypeDocVersion) {
|
||||
let match = rawTypeDocVersion.match(TYPEDOC_VERSION_REGEX);
|
||||
const match = rawTypeDocVersion.match(TYPEDOC_VERSION_REGEX);
|
||||
if (match) {
|
||||
typeDocVersion = match[1];
|
||||
} else {
|
||||
@@ -622,7 +622,7 @@ export class DocutilsValidator extends EventEmitter {
|
||||
return this.fail(`Could not find TypeScript compiler ("tsc") from ${pkgDir}`);
|
||||
}
|
||||
|
||||
let match = rawTypeScriptVersion.match(TYPESCRIPT_VERSION_REGEX);
|
||||
const match = rawTypeScriptVersion.match(TYPESCRIPT_VERSION_REGEX);
|
||||
if (match) {
|
||||
typeScriptVersion = match[1];
|
||||
} else {
|
||||
|
||||
@@ -16,8 +16,8 @@ declare module '../driver' {
|
||||
|
||||
const ContextsMixin: FakeDriverContextsMixin = {
|
||||
getRawContexts(this: FakeDriver) {
|
||||
let contexts = {NATIVE_APP: null, PROXY: null};
|
||||
let wvs = this.appModel.getWebviews() ?? [];
|
||||
const contexts = {NATIVE_APP: null, PROXY: null};
|
||||
const wvs = this.appModel.getWebviews() ?? [];
|
||||
for (let i = 1; i < wvs.length + 1; i++) {
|
||||
contexts[`WEBVIEW_${i}`] = wvs[i - 1];
|
||||
}
|
||||
@@ -47,7 +47,7 @@ const ContextsMixin: FakeDriverContextsMixin = {
|
||||
* @param context - name of the context
|
||||
*/
|
||||
async setContext(this: FakeDriver, context: string) {
|
||||
let contexts = this.getRawContexts();
|
||||
const contexts = this.getRawContexts();
|
||||
if (context in contexts) {
|
||||
this.curContext = context;
|
||||
if (context === 'NATIVE_APP') {
|
||||
@@ -72,7 +72,7 @@ const ContextsMixin: FakeDriverContextsMixin = {
|
||||
if (frameId === null) {
|
||||
this.appModel.deactivateFrame();
|
||||
} else {
|
||||
let nodes = this.appModel.xpathQuery(`//iframe[@id="${frameId}"]`);
|
||||
const nodes = this.appModel.xpathQuery(`//iframe[@id="${frameId}"]`);
|
||||
if (!nodes.length) {
|
||||
throw new errors.NoSuchFrameError();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ declare module '../driver' {
|
||||
|
||||
const ElementsMixin: FakeDriverElementsMixin = {
|
||||
getElements(this: FakeDriver, elementIds: string[]) {
|
||||
for (let elId of elementIds) {
|
||||
for (const elId of elementIds) {
|
||||
if (!_.has(this.elMap, elId)) {
|
||||
throw new errors.StaleElementReferenceError();
|
||||
}
|
||||
@@ -45,22 +45,22 @@ const ElementsMixin: FakeDriverElementsMixin = {
|
||||
},
|
||||
|
||||
async getName(this: FakeDriver, elementId: string) {
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return el.tagName;
|
||||
},
|
||||
|
||||
async elementDisplayed(this: FakeDriver, elementId: string) {
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return el.isVisible();
|
||||
},
|
||||
|
||||
async elementEnabled(this: FakeDriver, elementId: string) {
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return el.isEnabled();
|
||||
},
|
||||
|
||||
async elementSelected(this: FakeDriver, elementId: string) {
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return el.isSelected();
|
||||
},
|
||||
|
||||
@@ -69,7 +69,7 @@ const ElementsMixin: FakeDriverElementsMixin = {
|
||||
if (keys instanceof Array) {
|
||||
value = keys.join('');
|
||||
}
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
if (el.type !== 'MockInputField') {
|
||||
throw new errors.InvalidElementStateError();
|
||||
}
|
||||
@@ -77,7 +77,7 @@ const ElementsMixin: FakeDriverElementsMixin = {
|
||||
},
|
||||
|
||||
async getText(this: FakeDriver, elementId: string) {
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return el.getAttr('value');
|
||||
},
|
||||
|
||||
@@ -90,7 +90,7 @@ const ElementsMixin: FakeDriverElementsMixin = {
|
||||
*/
|
||||
async click(this: FakeDriver, elementId: string) {
|
||||
this.assertNoAlert();
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
if (!el.isVisible()) {
|
||||
throw new errors.InvalidElementStateError();
|
||||
}
|
||||
@@ -99,29 +99,29 @@ const ElementsMixin: FakeDriverElementsMixin = {
|
||||
},
|
||||
|
||||
async getAttribute(this: FakeDriver, attr: string, elementId: string) {
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return el.getAttr(attr);
|
||||
},
|
||||
|
||||
async getElementRect(this: FakeDriver, elementId: string) {
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return el.getElementRect();
|
||||
},
|
||||
|
||||
async getSize(this: FakeDriver, elementId: string) {
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return el.getSize();
|
||||
},
|
||||
|
||||
async equalsElement(this: FakeDriver, elementIdA: string, elementIdB: string) {
|
||||
let el1 = this.getElement(elementIdA);
|
||||
let el2 = this.getElement(elementIdB);
|
||||
const el1 = this.getElement(elementIdA);
|
||||
const el2 = this.getElement(elementIdB);
|
||||
return el1.equals(el2);
|
||||
},
|
||||
|
||||
async getCssProperty(this: FakeDriver, prop: string, elementId: string) {
|
||||
this.assertWebviewContext();
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return el.getCss(prop);
|
||||
},
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ declare module '../driver' {
|
||||
|
||||
const FindMixin: FakeDriverFindMixin = {
|
||||
getExistingElementForNode(this: FakeDriver, node) {
|
||||
for (let [id, el] of _.toPairs(this.elMap)) {
|
||||
for (const [id, el] of _.toPairs(this.elMap)) {
|
||||
if (el.node === node) {
|
||||
return id;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ const FindMixin: FakeDriverFindMixin = {
|
||||
|
||||
wrapNewEl(this: FakeDriver, obj: FakeElement): Element {
|
||||
// first check and see if we already have a ref to this element
|
||||
let existingElId = this.getExistingElementForNode(obj);
|
||||
const existingElId = this.getExistingElementForNode(obj);
|
||||
if (existingElId) {
|
||||
return {ELEMENT: existingElId, [W3C_WEB_ELEMENT_IDENTIFIER]: existingElId};
|
||||
}
|
||||
@@ -63,7 +63,7 @@ const FindMixin: FakeDriverFindMixin = {
|
||||
many: Many,
|
||||
context: Ctx
|
||||
): Promise<Many extends true ? Element[] : Element> {
|
||||
let qMap = {
|
||||
const qMap = {
|
||||
xpath: 'xpathQuery',
|
||||
id: 'idQuery',
|
||||
'accessibility id': 'idQuery',
|
||||
@@ -78,13 +78,13 @@ const FindMixin: FakeDriverFindMixin = {
|
||||
if (selector === 'badsel') {
|
||||
throw new errors.InvalidSelectorError();
|
||||
}
|
||||
let els = this.appModel[qMap[strategy]](selector, context);
|
||||
const els = this.appModel[qMap[strategy]](selector, context);
|
||||
|
||||
let retval: Element | Element[];
|
||||
if (els.length) {
|
||||
if (many) {
|
||||
let allEls: Element[] = [];
|
||||
for (let el of els) {
|
||||
const allEls: Element[] = [];
|
||||
for (const el of els) {
|
||||
allEls.push(this.wrapNewEl(el));
|
||||
}
|
||||
retval = allEls;
|
||||
@@ -119,7 +119,7 @@ const FindMixin: FakeDriverFindMixin = {
|
||||
selector: string,
|
||||
elementId: string
|
||||
) {
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return this.findElOrEls(strategy, selector, false, el.xmlFragment);
|
||||
},
|
||||
|
||||
@@ -129,7 +129,7 @@ const FindMixin: FakeDriverFindMixin = {
|
||||
selector: string,
|
||||
elementId: string
|
||||
) {
|
||||
let el = this.getElement(elementId);
|
||||
const el = this.getElement(elementId);
|
||||
return this.findElOrEls(strategy, selector, true, el.xmlFragment);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {ActionSequence, Location, Rect, Size} from '@appium/types';
|
||||
import {errors} from 'appium/driver';
|
||||
import {ActionSequence, Location, Rect, Size, LogDef, Driver, LogDefRecord} from '@appium/types';
|
||||
import {FakeDriver, FakeDriverConstraints, Orientation} from '../driver';
|
||||
import {FakeDriver, Orientation} from '../driver';
|
||||
import {mixin} from './mixin';
|
||||
|
||||
const ORIENTATIONS = new Set(['LANDSCAPE', 'PORTRAIT']);
|
||||
|
||||
@@ -2,6 +2,7 @@ import {Context} from 'typedoc';
|
||||
import {AppiumPluginLogger} from '../logger';
|
||||
|
||||
export abstract class BaseConverter<Result> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
constructor(protected ctx: Context, protected log: AppiumPluginLogger, ...args: any[]) {}
|
||||
|
||||
abstract convert(): Result;
|
||||
|
||||
@@ -154,7 +154,7 @@ export function omitDefaultReflections(
|
||||
project: ProjectReflection,
|
||||
refl: ContainerReflection = project
|
||||
): Set<DeclarationReflection> {
|
||||
let removed = new Set<DeclarationReflection>();
|
||||
const removed = new Set<DeclarationReflection>();
|
||||
for (const childRefl of refl.getChildrenByKind(~(AppiumPluginReflectionKind.Extension as any))) {
|
||||
project.removeReflection(childRefl);
|
||||
removed.add(childRefl);
|
||||
@@ -174,7 +174,7 @@ export function omitBuiltinReflections(
|
||||
project: ProjectReflection,
|
||||
refl: ContainerReflection = project
|
||||
) {
|
||||
let removed = new Set<DeclarationReflection>();
|
||||
const removed = new Set<DeclarationReflection>();
|
||||
|
||||
const extRefls = refl.getChildrenByKind(
|
||||
AppiumPluginReflectionKind.Extension as any
|
||||
|
||||
@@ -63,7 +63,7 @@ const MethodCommentFinders: Readonly<CommentFinder[]> = [
|
||||
({commentSource}) => commentSource !== CommentSource.OtherMethod
|
||||
)
|
||||
.map(({getter, commentSource}) => ({
|
||||
comment: getter({refl: otherRefl, knownBuiltinMethods: knownBuiltinMethods}),
|
||||
comment: getter({refl: otherRefl, knownBuiltinMethods}),
|
||||
commentSource,
|
||||
}))
|
||||
.find(({comment}) => Boolean(comment))?.comment;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {ParameterReflection} from 'typedoc';
|
||||
import {isCallSignatureReflection, isParameterReflection} from '../../guards';
|
||||
import {findCallSignature} from '../../utils';
|
||||
import {CommentSource} from '../types';
|
||||
|
||||
@@ -109,7 +109,7 @@ export function convertExecuteMethodMap({
|
||||
continue;
|
||||
}
|
||||
|
||||
const commentData = deriveComment({refl: methodRefl, comment, knownMethods: knownMethods});
|
||||
const commentData = deriveComment({refl: methodRefl, comment, knownMethods});
|
||||
|
||||
const execMethodData = ExecMethodData.create(ctx, log, command, methodRefl, script, {
|
||||
requiredParams,
|
||||
|
||||
@@ -228,7 +228,7 @@ export function cloneParameterReflection(
|
||||
// so we do not need to worry about combining block/summary comments like with methods.
|
||||
newPRefl.comment = deriveComment({
|
||||
refl: pRefl,
|
||||
knownMethods: knownMethods,
|
||||
knownMethods,
|
||||
comment: pRefl.comment,
|
||||
})?.comment;
|
||||
// there doesn't seem to be a straightforward way to clone flags.
|
||||
@@ -294,7 +294,7 @@ export function createNewParamRefls(
|
||||
sig: SignatureReflection,
|
||||
opts: CreateNewParamReflsOpts = {}
|
||||
): ParameterReflection[] {
|
||||
let {builtinMethods = new Map(), commandParams = [], isOptional, isPluginCommand} = opts;
|
||||
const {builtinMethods = new Map(), commandParams = [], isOptional, isPluginCommand} = opts;
|
||||
if (!sig.parameters?.length) {
|
||||
// this should not happen, I think?
|
||||
return [];
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
ContainerReflection,
|
||||
DeclarationReflection,
|
||||
LiteralType,
|
||||
ParameterReflection,
|
||||
|
||||
@@ -36,7 +36,7 @@ export class BuiltinCommands {
|
||||
* will be invariant; thus we only need to create it once.
|
||||
* @returns A {@linkcode ProjectCommands} object with zero or one entry
|
||||
*/
|
||||
public toProjectCommands = _.once(() => {
|
||||
return new ProjectCommands(this.refl ? [[this.refl.name, this.moduleCmds]] : []);
|
||||
});
|
||||
public toProjectCommands = _.once(
|
||||
() => new ProjectCommands(this.refl ? [[this.refl.name, this.moduleCmds]] : [])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -65,13 +65,12 @@ export class ExtensionReflection extends DeclarationReflection {
|
||||
*
|
||||
* Should **not** be called before the TypeDoc converter has emitted `EVENT_RESOLVE_END`
|
||||
*/
|
||||
static isCompositeProject = _.memoize((project: ProjectReflection) => {
|
||||
return (
|
||||
static isCompositeProject = _.memoize(
|
||||
(project: ProjectReflection) =>
|
||||
project
|
||||
.getChildrenByKind(AppiumPluginReflectionKind.Extension as any)
|
||||
?.filter(({name}) => name !== NAME_BUILTIN_COMMAND_MODULE).length > 1
|
||||
);
|
||||
});
|
||||
);
|
||||
|
||||
/**
|
||||
* This is called by `AppiumTheme`'s `getUrl` method, which causes a particular filename to be used.
|
||||
@@ -87,7 +86,7 @@ export class ExtensionReflection extends DeclarationReflection {
|
||||
}
|
||||
|
||||
let alias: string;
|
||||
let matches = this.name.match(SCOPED_PACKAGE_NAME_REGEX);
|
||||
const matches = this.name.match(SCOPED_PACKAGE_NAME_REGEX);
|
||||
alias = matches ? matches[2] : this.name;
|
||||
alias = alias.replace(/\W/, '-');
|
||||
this.#alias = alias;
|
||||
|
||||
@@ -50,7 +50,9 @@ export class AppiumPluginOptionsReader implements OptionsReader {
|
||||
try {
|
||||
const pkg = require(pkgJsonPath);
|
||||
return pkg?.appium?.driverName ?? pkg?.appium?.pluginName;
|
||||
} catch {}
|
||||
} catch {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,7 @@ function reflectionPath(this: PageEvent<ContainerReflection>) {
|
||||
* @param inclusive Whether to show the count in the output
|
||||
* @returns The pluralized string (if necessary)
|
||||
*/
|
||||
function pluralize(value: string, count: number, inclusive: boolean = false) {
|
||||
function pluralize(value: string, count: number, inclusive = false) {
|
||||
const safeValue = Handlebars.escapeExpression(value);
|
||||
// XXX: Handlebars seems to be passing in a truthy value here, even if the arg is unused in the template! Make double-sure it's a boolean.
|
||||
inclusive = inclusive === true;
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('@appium/typedoc-plugin-appium', function () {
|
||||
});
|
||||
|
||||
describe('convertCommands()', function () {
|
||||
it('should return a non-empty ProjectCommands Map', () => {
|
||||
it('should return a non-empty ProjectCommands Map', function () {
|
||||
expect(convertCommands(ctx, log)).to.be.an.instanceof(ProjectCommands).and.not.to.be.empty;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,13 +100,13 @@ export function initAppForPkgs({
|
||||
tsconfig = ROOT_TSCONFIG,
|
||||
...opts
|
||||
}: SetRequired<Partial<TypeDocOptions>, 'entryPoints'>): Application {
|
||||
let {entryPoints, ...typedocOpts} = opts;
|
||||
let {entryPoints} = opts;
|
||||
entryPoints = entryPoints.map((pkgName) =>
|
||||
path.dirname(require.resolve(`${pkgName}/${NAME_PACKAGE_JSON}`))
|
||||
);
|
||||
// because entryPoints is a list of directories, this must be 'packages'
|
||||
const entryPointStrategy = EntryPointStrategy.Packages;
|
||||
return getTypedocApp({...typedocOpts, entryPoints, entryPointStrategy});
|
||||
return getTypedocApp({...opts, tsconfig, entryPoints, entryPointStrategy});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,7 +83,7 @@ export interface AppiumServerSocket extends Socket {
|
||||
*/
|
||||
export type Class<
|
||||
Proto,
|
||||
StaticMembers extends object = {},
|
||||
StaticMembers extends object = object,
|
||||
Args extends unknown[] = any[]
|
||||
> = _Class<Proto, Args> & StaticMembers;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user