or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

android-development.mdbuild-system.mdextension-runners.mdindex.mdlinting-system.mdlogging-system.mdmain-api.mdsigning-publishing.md

main-api.mddocs/

0

# Main API

1

2

Core programmatic interface for web-ext providing access to CLI functionality and individual commands.

3

4

## Capabilities

5

6

### Main Entry Point

7

8

Primary function for running web-ext programmatically, equivalent to using the CLI.

9

10

```javascript { .api }

11

/**

12

* Main entry point for web-ext CLI functionality

13

* @param absolutePackageDir - Absolute path to the package directory

14

* @param options - Optional configuration for execution

15

* @returns Promise that resolves when execution completes

16

*/

17

function main(absolutePackageDir: string, options?: MainOptions): Promise<void>;

18

19

interface MainOptions {

20

getVersion?: (absolutePackageDir: string) => Promise<string>;

21

commands?: CommandsObject;

22

argv?: string[];

23

runOptions?: RunOptions;

24

}

25

```

26

27

**Usage Example:**

28

29

```javascript

30

import webExt from "web-ext";

31

32

// Run with default settings (uses process.argv)

33

await webExt.main(process.cwd());

34

35

// Run with custom arguments

36

await webExt.main('/path/to/extension', {

37

argv: ['build', '--source-dir', './src']

38

});

39

```

40

41

### Commands Object

42

43

Direct access to individual command implementations without CLI argument parsing.

44

45

```javascript { .api }

46

interface CommandsObject {

47

build: (params: BuildParams, options?: BuildOptions) => Promise<BuildResult>;

48

run: (params: RunParams, options?: RunOptions) => Promise<void>;

49

lint: (params: LintParams, options?: LintOptions) => Promise<void>;

50

sign: (params: SignParams, options?: SignOptions) => Promise<SignResult>;

51

docs: (params: DocsParams, options?: DocsOptions) => Promise<void>;

52

dumpConfig: (params: DumpConfigParams, options?: DumpConfigOptions) => Promise<void>;

53

}

54

```

55

56

**Usage Example:**

57

58

```javascript

59

import { cmd } from "web-ext";

60

61

// Build extension

62

const result = await cmd.build({

63

sourceDir: './my-extension',

64

artifactsDir: './web-ext-artifacts',

65

overwriteDest: true

66

});

67

68

console.log('Extension built at:', result.extensionPath);

69

70

// Run extension in Firefox

71

await cmd.run({

72

sourceDir: './my-extension',

73

target: ['firefox-desktop'],

74

firefox: 'firefox',

75

startUrl: ['https://example.com']

76

});

77

```

78

79

80

## Types

81

82

```javascript { .api }

83

interface RunOptions {

84

shouldExitProgram?: boolean;

85

checkForUpdates?: Function;

86

systemProcess?: NodeJS.Process;

87

logStream?: any;

88

}

89

90

interface BuildResult {

91

extensionPath: string;

92

}

93

94

interface SignResult {

95

success: boolean;

96

id?: string;

97

downloadedFiles?: string[];

98

}

99

```

100

101