web-ext 6.7.0 → 7.1.0
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/README.md +17 -8
- package/bin/web-ext.js +13 -0
- package/index.js +12 -0
- package/lib/cmd/build.js +226 -0
- package/lib/cmd/build.js.map +1 -0
- package/lib/cmd/docs.js +16 -0
- package/lib/cmd/docs.js.map +1 -0
- package/lib/cmd/index.js +47 -0
- package/lib/cmd/index.js.map +1 -0
- package/lib/cmd/lint.js +50 -0
- package/lib/cmd/lint.js.map +1 -0
- package/lib/cmd/run.js +199 -0
- package/lib/cmd/run.js.map +1 -0
- package/lib/cmd/sign.js +140 -0
- package/lib/cmd/sign.js.map +1 -0
- package/lib/config.js +144 -0
- package/lib/config.js.map +1 -0
- package/{src → lib}/errors.js +26 -35
- package/lib/errors.js.map +1 -0
- package/lib/extension-runners/base.js +2 -0
- package/lib/extension-runners/base.js.map +1 -0
- package/{src → lib}/extension-runners/chromium.js +121 -178
- package/lib/extension-runners/chromium.js.map +1 -0
- package/{src → lib}/extension-runners/firefox-android.js +168 -326
- package/lib/extension-runners/firefox-android.js.map +1 -0
- package/{src → lib}/extension-runners/firefox-desktop.js +73 -114
- package/lib/extension-runners/firefox-desktop.js.map +1 -0
- package/lib/extension-runners/index.js +311 -0
- package/lib/extension-runners/index.js.map +1 -0
- package/lib/firefox/index.js +362 -0
- package/lib/firefox/index.js.map +1 -0
- package/lib/firefox/package-identifiers.js +5 -0
- package/lib/firefox/package-identifiers.js.map +1 -0
- package/{src → lib}/firefox/preferences.js +27 -70
- package/lib/firefox/preferences.js.map +1 -0
- package/{src → lib}/firefox/rdp-client.js +98 -105
- package/lib/firefox/rdp-client.js.map +1 -0
- package/{src → lib}/firefox/remote.js +55 -129
- package/lib/firefox/remote.js.map +1 -0
- package/lib/main.js +9 -0
- package/lib/main.js.map +1 -0
- package/lib/program.js +663 -0
- package/lib/program.js.map +1 -0
- package/lib/util/adb.js +322 -0
- package/lib/util/adb.js.map +1 -0
- package/lib/util/artifacts.js +52 -0
- package/lib/util/artifacts.js.map +1 -0
- package/lib/util/desktop-notifier.js +27 -0
- package/lib/util/desktop-notifier.js.map +1 -0
- package/{src → lib}/util/file-exists.js +7 -14
- package/lib/util/file-exists.js.map +1 -0
- package/{src → lib}/util/file-filter.js +31 -59
- package/lib/util/file-filter.js.map +1 -0
- package/lib/util/is-directory.js +20 -0
- package/lib/util/is-directory.js.map +1 -0
- package/lib/util/logger.js +79 -0
- package/lib/util/logger.js.map +1 -0
- package/{src → lib}/util/manifest.js +18 -50
- package/lib/util/manifest.js.map +1 -0
- package/{src → lib}/util/promisify.js +6 -9
- package/lib/util/promisify.js.map +1 -0
- package/{src → lib}/util/stdin.js +3 -7
- package/lib/util/stdin.js.map +1 -0
- package/{src → lib}/util/temp-dir.js +47 -52
- package/lib/util/temp-dir.js.map +1 -0
- package/lib/util/updates.js +16 -0
- package/lib/util/updates.js.map +1 -0
- package/lib/watcher.js +78 -0
- package/lib/watcher.js.map +1 -0
- package/package.json +50 -52
- package/CODE_OF_CONDUCT.md +0 -10
- package/bin/web-ext +0 -7
- package/dist/web-ext.js +0 -2
- package/index.mjs +0 -13
- package/src/cmd/build.js +0 -319
- package/src/cmd/docs.js +0 -33
- package/src/cmd/index.js +0 -57
- package/src/cmd/lint.js +0 -102
- package/src/cmd/run.js +0 -266
- package/src/cmd/sign.js +0 -198
- package/src/config.js +0 -187
- package/src/extension-runners/base.js +0 -40
- package/src/extension-runners/index.js +0 -381
- package/src/firefox/index.js +0 -541
- package/src/firefox/package-identifiers.js +0 -14
- package/src/main.js +0 -19
- package/src/program.js +0 -765
- package/src/util/adb.js +0 -433
- package/src/util/artifacts.js +0 -69
- package/src/util/desktop-notifier.js +0 -41
- package/src/util/is-directory.js +0 -23
- package/src/util/logger.js +0 -131
- package/src/util/updates.js +0 -21
- package/src/watcher.js +0 -114
package/src/cmd/build.js
DELETED
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import {createWriteStream} from 'fs';
|
|
4
|
-
|
|
5
|
-
import {fs} from 'mz';
|
|
6
|
-
import parseJSON from 'parse-json';
|
|
7
|
-
import stripBom from 'strip-bom';
|
|
8
|
-
import stripJsonComments from 'strip-json-comments';
|
|
9
|
-
import defaultEventToPromise from 'event-to-promise';
|
|
10
|
-
import zipDir from 'zip-dir';
|
|
11
|
-
|
|
12
|
-
import defaultSourceWatcher from '../watcher';
|
|
13
|
-
import getValidatedManifest, {getManifestId} from '../util/manifest';
|
|
14
|
-
import {prepareArtifactsDir} from '../util/artifacts';
|
|
15
|
-
import {createLogger} from '../util/logger';
|
|
16
|
-
import {UsageError, isErrorWithCode} from '../errors';
|
|
17
|
-
import {
|
|
18
|
-
createFileFilter as defaultFileFilterCreator,
|
|
19
|
-
FileFilter,
|
|
20
|
-
} from '../util/file-filter';
|
|
21
|
-
// Import flow types.
|
|
22
|
-
import type {OnSourceChangeFn} from '../watcher';
|
|
23
|
-
import type {ExtensionManifest} from '../util/manifest';
|
|
24
|
-
import type {FileFilterCreatorFn} from '../util/file-filter';
|
|
25
|
-
|
|
26
|
-
const log = createLogger(__filename);
|
|
27
|
-
const DEFAULT_FILENAME_TEMPLATE = '{name}-{version}.zip';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export function safeFileName(name: string): string {
|
|
31
|
-
return name.toLowerCase().replace(/[^a-z0-9.-]+/g, '_');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// defaultPackageCreator types and implementation.
|
|
36
|
-
|
|
37
|
-
export type ExtensionBuildResult = {|
|
|
38
|
-
extensionPath: string,
|
|
39
|
-
|};
|
|
40
|
-
|
|
41
|
-
export type PackageCreatorParams = {|
|
|
42
|
-
manifestData?: ExtensionManifest,
|
|
43
|
-
sourceDir: string,
|
|
44
|
-
fileFilter: FileFilter,
|
|
45
|
-
artifactsDir: string,
|
|
46
|
-
overwriteDest: boolean,
|
|
47
|
-
showReadyMessage: boolean,
|
|
48
|
-
filename?: string,
|
|
49
|
-
|};
|
|
50
|
-
|
|
51
|
-
export type LocalizedNameParams = {|
|
|
52
|
-
messageFile: string,
|
|
53
|
-
manifestData: ExtensionManifest,
|
|
54
|
-
|}
|
|
55
|
-
|
|
56
|
-
export type PackageCreatorOptions = {|
|
|
57
|
-
eventToPromise: typeof defaultEventToPromise,
|
|
58
|
-
|};
|
|
59
|
-
|
|
60
|
-
// This defines the _locales/messages.json type. See:
|
|
61
|
-
// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Internationalization#Providing_localized_strings_in__locales
|
|
62
|
-
type LocalizedMessageData = {|
|
|
63
|
-
[messageName: string]: {|
|
|
64
|
-
description: string,
|
|
65
|
-
message: string,
|
|
66
|
-
|},
|
|
67
|
-
|}
|
|
68
|
-
|
|
69
|
-
export async function getDefaultLocalizedName(
|
|
70
|
-
{messageFile, manifestData}: LocalizedNameParams
|
|
71
|
-
): Promise<string> {
|
|
72
|
-
|
|
73
|
-
let messageData: LocalizedMessageData;
|
|
74
|
-
let messageContents: string | Buffer;
|
|
75
|
-
let extensionName: string = manifestData.name;
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
messageContents = await fs.readFile(messageFile, {encoding: 'utf-8'});
|
|
79
|
-
} catch (error) {
|
|
80
|
-
throw new UsageError(
|
|
81
|
-
`Error reading messages.json file at ${messageFile}: ${error}`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
messageContents = stripBom(messageContents);
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
messageData = parseJSON(stripJsonComments(messageContents));
|
|
88
|
-
} catch (error) {
|
|
89
|
-
throw new UsageError(
|
|
90
|
-
`Error parsing messages.json file at ${messageFile}: ${error}`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
extensionName = manifestData.name.replace(
|
|
94
|
-
/__MSG_([A-Za-z0-9@_]+?)__/g,
|
|
95
|
-
(match, messageName) => {
|
|
96
|
-
if (!(messageData[messageName]
|
|
97
|
-
&& messageData[messageName].message)) {
|
|
98
|
-
const error = new UsageError(
|
|
99
|
-
`The locale file ${messageFile} ` +
|
|
100
|
-
`is missing key: ${messageName}`);
|
|
101
|
-
throw error;
|
|
102
|
-
} else {
|
|
103
|
-
return messageData[messageName].message;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
return Promise.resolve(extensionName);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// https://stackoverflow.com/a/22129960
|
|
110
|
-
export function getStringPropertyValue(
|
|
111
|
-
prop: string,
|
|
112
|
-
obj: Object,
|
|
113
|
-
): string {
|
|
114
|
-
const properties = prop.split('.');
|
|
115
|
-
const value = properties.reduce((prev, curr) => prev && prev[curr], obj);
|
|
116
|
-
if (!['string', 'number'].includes(typeof value)) {
|
|
117
|
-
throw new UsageError(
|
|
118
|
-
`Manifest key "${prop}" is missing or has an invalid type: ${value}`
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
const stringValue = `${value}`;
|
|
122
|
-
if (!stringValue.length) {
|
|
123
|
-
throw new UsageError(`Manifest key "${prop}" value is an empty string`);
|
|
124
|
-
}
|
|
125
|
-
return stringValue;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function getPackageNameFromTemplate(
|
|
129
|
-
filenameTemplate: string,
|
|
130
|
-
manifestData: ExtensionManifest
|
|
131
|
-
): string {
|
|
132
|
-
const packageName = filenameTemplate.replace(
|
|
133
|
-
/{([A-Za-z0-9._]+?)}/g,
|
|
134
|
-
(match, manifestProperty) => {
|
|
135
|
-
return safeFileName(
|
|
136
|
-
getStringPropertyValue(manifestProperty, manifestData));
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
// Validate the resulting packageName string, after interpolating the manifest property
|
|
141
|
-
// specified in the template string.
|
|
142
|
-
const parsed = path.parse(packageName);
|
|
143
|
-
if (parsed.dir) {
|
|
144
|
-
throw new UsageError(
|
|
145
|
-
`Invalid filename template "${filenameTemplate}". ` +
|
|
146
|
-
`Filename "${packageName}" should not contain a path`
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
if (!['.zip', '.xpi'].includes(parsed.ext)) {
|
|
150
|
-
throw new UsageError(
|
|
151
|
-
`Invalid filename template "${filenameTemplate}". ` +
|
|
152
|
-
`Filename "${packageName}" should have a zip or xpi extension`
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return packageName;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export type PackageCreatorFn =
|
|
160
|
-
(params: PackageCreatorParams) => Promise<ExtensionBuildResult>;
|
|
161
|
-
|
|
162
|
-
export async function defaultPackageCreator(
|
|
163
|
-
{
|
|
164
|
-
manifestData,
|
|
165
|
-
sourceDir,
|
|
166
|
-
fileFilter,
|
|
167
|
-
artifactsDir,
|
|
168
|
-
overwriteDest,
|
|
169
|
-
showReadyMessage,
|
|
170
|
-
filename = DEFAULT_FILENAME_TEMPLATE,
|
|
171
|
-
}: PackageCreatorParams,
|
|
172
|
-
{
|
|
173
|
-
eventToPromise = defaultEventToPromise,
|
|
174
|
-
}: PackageCreatorOptions = {}
|
|
175
|
-
): Promise<ExtensionBuildResult> {
|
|
176
|
-
let id;
|
|
177
|
-
if (manifestData) {
|
|
178
|
-
id = getManifestId(manifestData);
|
|
179
|
-
log.debug(`Using manifest id=${id || '[not specified]'}`);
|
|
180
|
-
} else {
|
|
181
|
-
manifestData = await getValidatedManifest(sourceDir);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const buffer = await zipDir(sourceDir, {
|
|
185
|
-
filter: (...args) => fileFilter.wantFile(...args),
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
let filenameTemplate = filename;
|
|
189
|
-
|
|
190
|
-
let {default_locale} = manifestData;
|
|
191
|
-
if (default_locale) {
|
|
192
|
-
default_locale = default_locale.replace(/-/g, '_');
|
|
193
|
-
const messageFile = path.join(
|
|
194
|
-
sourceDir, '_locales',
|
|
195
|
-
default_locale, 'messages.json'
|
|
196
|
-
);
|
|
197
|
-
log.debug('Manifest declared default_locale, localizing extension name');
|
|
198
|
-
const extensionName = await getDefaultLocalizedName({
|
|
199
|
-
messageFile, manifestData,
|
|
200
|
-
});
|
|
201
|
-
// allow for a localized `{name}`, without mutating `manifestData`
|
|
202
|
-
filenameTemplate = filenameTemplate.replace(/{name}/g, extensionName);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const packageName = safeFileName(
|
|
206
|
-
getPackageNameFromTemplate(filenameTemplate, manifestData)
|
|
207
|
-
);
|
|
208
|
-
const extensionPath = path.join(artifactsDir, packageName);
|
|
209
|
-
|
|
210
|
-
// Added 'wx' flags to avoid overwriting of existing package.
|
|
211
|
-
const stream = createWriteStream(extensionPath, {flags: 'wx'});
|
|
212
|
-
|
|
213
|
-
stream.write(buffer, () => {
|
|
214
|
-
stream.end();
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
try {
|
|
218
|
-
await eventToPromise(stream, 'close');
|
|
219
|
-
} catch (error) {
|
|
220
|
-
if (!isErrorWithCode('EEXIST', error)) {
|
|
221
|
-
throw error;
|
|
222
|
-
}
|
|
223
|
-
if (!overwriteDest) {
|
|
224
|
-
throw new UsageError(
|
|
225
|
-
`Extension exists at the destination path: ${extensionPath}\n` +
|
|
226
|
-
'Use --overwrite-dest to enable overwriting.');
|
|
227
|
-
}
|
|
228
|
-
log.info(`Destination exists, overwriting: ${extensionPath}`);
|
|
229
|
-
const overwriteStream = createWriteStream(extensionPath);
|
|
230
|
-
overwriteStream.write(buffer, () => {
|
|
231
|
-
overwriteStream.end();
|
|
232
|
-
});
|
|
233
|
-
await eventToPromise(overwriteStream, 'close');
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (showReadyMessage) {
|
|
237
|
-
log.info(`Your web extension is ready: ${extensionPath}`);
|
|
238
|
-
}
|
|
239
|
-
return {extensionPath};
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
// Build command types and implementation.
|
|
244
|
-
|
|
245
|
-
export type BuildCmdParams = {|
|
|
246
|
-
sourceDir: string,
|
|
247
|
-
artifactsDir: string,
|
|
248
|
-
asNeeded?: boolean,
|
|
249
|
-
overwriteDest?: boolean,
|
|
250
|
-
ignoreFiles?: Array<string>,
|
|
251
|
-
filename?: string,
|
|
252
|
-
|};
|
|
253
|
-
|
|
254
|
-
export type BuildCmdOptions = {|
|
|
255
|
-
manifestData?: ExtensionManifest,
|
|
256
|
-
fileFilter?: FileFilter,
|
|
257
|
-
onSourceChange?: OnSourceChangeFn,
|
|
258
|
-
packageCreator?: PackageCreatorFn,
|
|
259
|
-
showReadyMessage?: boolean,
|
|
260
|
-
createFileFilter?: FileFilterCreatorFn,
|
|
261
|
-
shouldExitProgram?: boolean,
|
|
262
|
-
|};
|
|
263
|
-
|
|
264
|
-
export default async function build(
|
|
265
|
-
{
|
|
266
|
-
sourceDir,
|
|
267
|
-
artifactsDir,
|
|
268
|
-
asNeeded = false,
|
|
269
|
-
overwriteDest = false,
|
|
270
|
-
ignoreFiles = [],
|
|
271
|
-
filename = DEFAULT_FILENAME_TEMPLATE,
|
|
272
|
-
}: BuildCmdParams,
|
|
273
|
-
{
|
|
274
|
-
manifestData,
|
|
275
|
-
createFileFilter = defaultFileFilterCreator,
|
|
276
|
-
fileFilter = createFileFilter({
|
|
277
|
-
sourceDir,
|
|
278
|
-
artifactsDir,
|
|
279
|
-
ignoreFiles,
|
|
280
|
-
}),
|
|
281
|
-
onSourceChange = defaultSourceWatcher,
|
|
282
|
-
packageCreator = defaultPackageCreator,
|
|
283
|
-
showReadyMessage = true,
|
|
284
|
-
}: BuildCmdOptions = {}
|
|
285
|
-
): Promise<ExtensionBuildResult> {
|
|
286
|
-
|
|
287
|
-
const rebuildAsNeeded = asNeeded; // alias for `build --as-needed`
|
|
288
|
-
log.info(`Building web extension from ${sourceDir}`);
|
|
289
|
-
|
|
290
|
-
const createPackage = () => packageCreator({
|
|
291
|
-
manifestData,
|
|
292
|
-
sourceDir,
|
|
293
|
-
fileFilter,
|
|
294
|
-
artifactsDir,
|
|
295
|
-
overwriteDest,
|
|
296
|
-
showReadyMessage,
|
|
297
|
-
filename,
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
await prepareArtifactsDir(artifactsDir);
|
|
301
|
-
const result = await createPackage();
|
|
302
|
-
|
|
303
|
-
if (rebuildAsNeeded) {
|
|
304
|
-
log.info('Rebuilding when files change...');
|
|
305
|
-
onSourceChange({
|
|
306
|
-
sourceDir,
|
|
307
|
-
artifactsDir,
|
|
308
|
-
onChange: () => {
|
|
309
|
-
return createPackage().catch((error) => {
|
|
310
|
-
log.error(error.stack);
|
|
311
|
-
throw error;
|
|
312
|
-
});
|
|
313
|
-
},
|
|
314
|
-
shouldWatchFile: (...args) => fileFilter.wantFile(...args),
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return result;
|
|
319
|
-
}
|
package/src/cmd/docs.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
import open from 'open';
|
|
3
|
-
|
|
4
|
-
import {createLogger} from '../util/logger';
|
|
5
|
-
|
|
6
|
-
const log = createLogger(__filename);
|
|
7
|
-
|
|
8
|
-
export type DocsParams = {
|
|
9
|
-
noInput?: boolean,
|
|
10
|
-
shouldExitProgram?: boolean,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type DocsOptions = {
|
|
14
|
-
openUrl?: typeof open,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line max-len
|
|
18
|
-
export const url = 'https://extensionworkshop.com/documentation/develop/getting-started-with-web-ext/';
|
|
19
|
-
|
|
20
|
-
export default function docs(
|
|
21
|
-
params: DocsParams, {openUrl = open}: DocsOptions = {}
|
|
22
|
-
): Promise<void> {
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
openUrl(url, (error) => {
|
|
25
|
-
if (error) {
|
|
26
|
-
log.debug(`Encountered an error while opening URL ${url}`, error);
|
|
27
|
-
reject(error);
|
|
28
|
-
} else {
|
|
29
|
-
resolve();
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
package/src/cmd/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
BuildCmdParams, BuildCmdOptions, ExtensionBuildResult,
|
|
5
|
-
} from './build';
|
|
6
|
-
import type {LintCmdParams, LintCmdOptions} from './lint';
|
|
7
|
-
import type {CmdRunParams, CmdRunOptions} from './run';
|
|
8
|
-
import type {MultiExtensionRunner} from '../extension-runners';
|
|
9
|
-
import type {SignParams, SignOptions, SignResult} from './sign';
|
|
10
|
-
import type {DocsParams, DocsOptions} from './docs';
|
|
11
|
-
|
|
12
|
-
// This module exports entry points for all supported commands. For performance
|
|
13
|
-
// reasons (faster start-up), the implementations are not statically imported
|
|
14
|
-
// at the top of the file, but lazily loaded in the (exported) functions.
|
|
15
|
-
// The latter would slow down start-up by several seconds, as seen in #1302 .
|
|
16
|
-
|
|
17
|
-
async function build(
|
|
18
|
-
params: BuildCmdParams, options: BuildCmdOptions
|
|
19
|
-
): Promise<ExtensionBuildResult> {
|
|
20
|
-
// TODO: use async import instead of require - https://github.com/mozilla/web-ext/issues/1306
|
|
21
|
-
const {default: runCommand} = require('./build');
|
|
22
|
-
return runCommand(params, options);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function lint(
|
|
26
|
-
params: LintCmdParams, options: LintCmdOptions
|
|
27
|
-
): Promise<void> {
|
|
28
|
-
// TODO: use async import instead of require - https://github.com/mozilla/web-ext/issues/1306
|
|
29
|
-
const {default: runCommand} = require('./lint');
|
|
30
|
-
return runCommand(params, options);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function run(
|
|
34
|
-
params: CmdRunParams, options: CmdRunOptions
|
|
35
|
-
): Promise<MultiExtensionRunner> {
|
|
36
|
-
// TODO: use async import instead of require - https://github.com/mozilla/web-ext/issues/1306
|
|
37
|
-
const {default: runCommand} = require('./run');
|
|
38
|
-
return runCommand(params, options);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function sign(
|
|
42
|
-
params: SignParams, options: SignOptions
|
|
43
|
-
): Promise<SignResult> {
|
|
44
|
-
// TODO: use async import instead of require - https://github.com/mozilla/web-ext/issues/1306
|
|
45
|
-
const {default: runCommand} = require('./sign');
|
|
46
|
-
return runCommand(params, options);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function docs(
|
|
50
|
-
params: DocsParams, options: DocsOptions
|
|
51
|
-
): Promise<void> {
|
|
52
|
-
// TODO: use async import instead of require - https://github.com/mozilla/web-ext/issues/1306
|
|
53
|
-
const {default: runCommand} = require('./docs');
|
|
54
|
-
return runCommand(params, options);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default {build, lint, run, sign, docs};
|
package/src/cmd/lint.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
import {createInstance as defaultLinterCreator} from 'addons-linter';
|
|
3
|
-
|
|
4
|
-
import {createLogger} from '../util/logger';
|
|
5
|
-
import {
|
|
6
|
-
createFileFilter as defaultFileFilterCreator,
|
|
7
|
-
} from '../util/file-filter';
|
|
8
|
-
// import flow types
|
|
9
|
-
import type {FileFilterCreatorFn} from '../util/file-filter';
|
|
10
|
-
|
|
11
|
-
const log = createLogger(__filename);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// Define the needed 'addons-linter' module flow types.
|
|
15
|
-
|
|
16
|
-
export type LinterOutputType = 'text' | 'json';
|
|
17
|
-
|
|
18
|
-
export type LinterCreatorParams = {|
|
|
19
|
-
config: {|
|
|
20
|
-
logLevel: 'debug' | 'fatal',
|
|
21
|
-
stack: boolean,
|
|
22
|
-
pretty?: boolean,
|
|
23
|
-
warningsAsErrors?: boolean,
|
|
24
|
-
metadata?: boolean,
|
|
25
|
-
output?: LinterOutputType,
|
|
26
|
-
boring?: boolean,
|
|
27
|
-
selfHosted?: boolean,
|
|
28
|
-
shouldScanFile: (fileName: string) => boolean,
|
|
29
|
-
_: Array<string>,
|
|
30
|
-
|},
|
|
31
|
-
runAsBinary: boolean,
|
|
32
|
-
|};
|
|
33
|
-
|
|
34
|
-
export type Linter = {|
|
|
35
|
-
run: () => Promise<void>,
|
|
36
|
-
|};
|
|
37
|
-
|
|
38
|
-
export type LinterCreatorFn = (params: LinterCreatorParams) => Linter;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Lint command types and implementation.
|
|
42
|
-
|
|
43
|
-
export type LintCmdParams = {|
|
|
44
|
-
artifactsDir?: string,
|
|
45
|
-
boring?: boolean,
|
|
46
|
-
ignoreFiles?: Array<string>,
|
|
47
|
-
metadata?: boolean,
|
|
48
|
-
output?: LinterOutputType,
|
|
49
|
-
pretty?: boolean,
|
|
50
|
-
selfHosted?: boolean,
|
|
51
|
-
sourceDir: string,
|
|
52
|
-
verbose?: boolean,
|
|
53
|
-
warningsAsErrors?: boolean,
|
|
54
|
-
|};
|
|
55
|
-
|
|
56
|
-
export type LintCmdOptions = {|
|
|
57
|
-
createLinter?: LinterCreatorFn,
|
|
58
|
-
createFileFilter?: FileFilterCreatorFn,
|
|
59
|
-
shouldExitProgram?: boolean,
|
|
60
|
-
|};
|
|
61
|
-
|
|
62
|
-
export default function lint(
|
|
63
|
-
{
|
|
64
|
-
artifactsDir,
|
|
65
|
-
boring,
|
|
66
|
-
ignoreFiles,
|
|
67
|
-
metadata,
|
|
68
|
-
output,
|
|
69
|
-
pretty,
|
|
70
|
-
sourceDir,
|
|
71
|
-
selfHosted,
|
|
72
|
-
verbose,
|
|
73
|
-
warningsAsErrors,
|
|
74
|
-
}: LintCmdParams,
|
|
75
|
-
{
|
|
76
|
-
createLinter = defaultLinterCreator,
|
|
77
|
-
createFileFilter = defaultFileFilterCreator,
|
|
78
|
-
shouldExitProgram = true,
|
|
79
|
-
}: LintCmdOptions = {}
|
|
80
|
-
): Promise<void> {
|
|
81
|
-
const fileFilter = createFileFilter({sourceDir, ignoreFiles, artifactsDir});
|
|
82
|
-
|
|
83
|
-
log.debug(`Running addons-linter on ${sourceDir}`);
|
|
84
|
-
const linter = createLinter({
|
|
85
|
-
config: {
|
|
86
|
-
logLevel: verbose ? 'debug' : 'fatal',
|
|
87
|
-
stack: Boolean(verbose),
|
|
88
|
-
pretty,
|
|
89
|
-
warningsAsErrors,
|
|
90
|
-
metadata,
|
|
91
|
-
output,
|
|
92
|
-
boring,
|
|
93
|
-
selfHosted,
|
|
94
|
-
shouldScanFile: (fileName) => fileFilter.wantFile(fileName),
|
|
95
|
-
// This mimics the first command line argument from yargs,
|
|
96
|
-
// which should be the directory to the extension.
|
|
97
|
-
_: [sourceDir],
|
|
98
|
-
},
|
|
99
|
-
runAsBinary: shouldExitProgram,
|
|
100
|
-
});
|
|
101
|
-
return linter.run();
|
|
102
|
-
}
|