web-ext 7.2.0 → 7.3.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/README.md +2 -2
- package/lib/cmd/build.js +18 -36
- package/lib/cmd/build.js.map +1 -1
- package/lib/cmd/docs.js +1 -0
- package/lib/cmd/docs.js.map +1 -1
- package/lib/cmd/index.js +3 -5
- package/lib/cmd/index.js.map +1 -1
- package/lib/cmd/lint.js +28 -17
- package/lib/cmd/lint.js.map +1 -1
- package/lib/cmd/run.js +19 -23
- package/lib/cmd/run.js.map +1 -1
- package/lib/cmd/sign.js +80 -47
- package/lib/cmd/sign.js.map +1 -1
- package/lib/config.js +18 -29
- package/lib/config.js.map +1 -1
- package/lib/errors.js +8 -18
- package/lib/errors.js.map +1 -1
- package/lib/extension-runners/base.js +2 -0
- package/lib/extension-runners/base.js.map +1 -1
- package/lib/extension-runners/chromium.js +36 -62
- package/lib/extension-runners/chromium.js.map +1 -1
- package/lib/extension-runners/firefox-android.js +65 -102
- package/lib/extension-runners/firefox-android.js.map +1 -1
- package/lib/extension-runners/firefox-desktop.js +29 -42
- package/lib/extension-runners/firefox-desktop.js.map +1 -1
- package/lib/extension-runners/index.js +33 -46
- package/lib/extension-runners/index.js.map +1 -1
- package/lib/firefox/index.js +59 -52
- package/lib/firefox/index.js.map +1 -1
- package/lib/firefox/package-identifiers.js +2 -0
- package/lib/firefox/package-identifiers.js.map +1 -1
- package/lib/firefox/preferences.js +14 -15
- package/lib/firefox/preferences.js.map +1 -1
- package/lib/firefox/rdp-client.js +16 -64
- package/lib/firefox/rdp-client.js.map +1 -1
- package/lib/firefox/remote.js +15 -30
- package/lib/firefox/remote.js.map +1 -1
- package/lib/main.js +4 -2
- package/lib/main.js.map +1 -1
- package/lib/program.js +74 -76
- package/lib/program.js.map +1 -1
- package/lib/util/adb.js +33 -63
- package/lib/util/adb.js.map +1 -1
- package/lib/util/artifacts.js +3 -5
- package/lib/util/artifacts.js.map +1 -1
- package/lib/util/desktop-notifier.js +1 -0
- package/lib/util/desktop-notifier.js.map +1 -1
- package/lib/util/file-exists.js +1 -2
- package/lib/util/file-exists.js.map +1 -1
- package/lib/util/file-filter.js +17 -19
- package/lib/util/file-filter.js.map +1 -1
- package/lib/util/is-directory.js +2 -1
- package/lib/util/is-directory.js.map +1 -1
- package/lib/util/logger.js +7 -12
- package/lib/util/logger.js.map +1 -1
- package/lib/util/manifest.js +6 -13
- package/lib/util/manifest.js.map +1 -1
- package/lib/util/promisify.js +7 -3
- package/lib/util/promisify.js.map +1 -1
- package/lib/util/stdin.js +2 -0
- package/lib/util/stdin.js.map +1 -1
- package/lib/util/submit-addon.js +288 -0
- package/lib/util/submit-addon.js.map +1 -0
- package/lib/util/temp-dir.js +8 -18
- package/lib/util/temp-dir.js.map +1 -1
- package/lib/util/updates.js +1 -1
- package/lib/util/updates.js.map +1 -1
- package/lib/watcher.js +14 -9
- package/lib/watcher.js.map +1 -1
- package/package.json +16 -14
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ webExt.cmd.run({
|
|
|
149
149
|
If you would like to run an extension on Firefox for Android:
|
|
150
150
|
|
|
151
151
|
```js
|
|
152
|
-
import adbUtils from "web-ext/util/adb";
|
|
152
|
+
import * as adbUtils from "web-ext/util/adb";
|
|
153
153
|
|
|
154
154
|
// Path to adb binary (optional parameter, auto-detected if missing)
|
|
155
155
|
const adbBin = "/path/to/adb";
|
|
@@ -173,7 +173,7 @@ webExt.cmd.run({
|
|
|
173
173
|
If you would like to control logging, you can access the logger object. Here is an example of turning on verbose logging:
|
|
174
174
|
|
|
175
175
|
```js
|
|
176
|
-
import webExtLogger from "web-ext/util/logger";
|
|
176
|
+
import * as webExtLogger from "web-ext/util/logger";
|
|
177
177
|
|
|
178
178
|
webExtLogger.consoleStream.makeVerbose();
|
|
179
179
|
webExt.cmd.run({sourceDir: './src'}, {shouldExitProgram: false});
|
package/lib/cmd/build.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
import path from 'path';
|
|
2
3
|
import { createWriteStream } from 'fs';
|
|
3
4
|
import { fs } from 'mz';
|
|
@@ -10,13 +11,16 @@ import getValidatedManifest, { getManifestId } from '../util/manifest.js';
|
|
|
10
11
|
import { prepareArtifactsDir } from '../util/artifacts.js';
|
|
11
12
|
import { createLogger } from '../util/logger.js';
|
|
12
13
|
import { UsageError, isErrorWithCode } from '../errors.js';
|
|
13
|
-
import { createFileFilter as defaultFileFilterCreator, FileFilter } from '../util/file-filter.js';
|
|
14
|
+
import { createFileFilter as defaultFileFilterCreator, FileFilter } from '../util/file-filter.js';
|
|
15
|
+
// Import flow types.
|
|
14
16
|
|
|
15
17
|
const log = createLogger(import.meta.url);
|
|
16
18
|
const DEFAULT_FILENAME_TEMPLATE = '{name}-{version}.zip';
|
|
17
19
|
export function safeFileName(name) {
|
|
18
20
|
return name.toLowerCase().replace(/[^a-z0-9.-]+/g, '_');
|
|
19
|
-
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// defaultPackageCreator types and implementation.
|
|
20
24
|
|
|
21
25
|
export async function getDefaultLocalizedName({
|
|
22
26
|
messageFile,
|
|
@@ -25,7 +29,6 @@ export async function getDefaultLocalizedName({
|
|
|
25
29
|
let messageData;
|
|
26
30
|
let messageContents;
|
|
27
31
|
let extensionName = manifestData.name;
|
|
28
|
-
|
|
29
32
|
try {
|
|
30
33
|
messageContents = await fs.readFile(messageFile, {
|
|
31
34
|
encoding: 'utf-8'
|
|
@@ -33,18 +36,15 @@ export async function getDefaultLocalizedName({
|
|
|
33
36
|
} catch (error) {
|
|
34
37
|
throw new UsageError(`Error reading messages.json file at ${messageFile}: ${error}`);
|
|
35
38
|
}
|
|
36
|
-
|
|
37
39
|
messageContents = stripBom(messageContents);
|
|
38
40
|
const {
|
|
39
41
|
default: stripJsonComments
|
|
40
42
|
} = await import('strip-json-comments');
|
|
41
|
-
|
|
42
43
|
try {
|
|
43
44
|
messageData = parseJSON(stripJsonComments(messageContents));
|
|
44
45
|
} catch (error) {
|
|
45
46
|
throw new UsageError(`Error parsing messages.json file at ${messageFile}: ${error}`);
|
|
46
47
|
}
|
|
47
|
-
|
|
48
48
|
extensionName = manifestData.name.replace(/__MSG_([A-Za-z0-9@_]+?)__/g, (match, messageName) => {
|
|
49
49
|
if (!(messageData[messageName] && messageData[messageName].message)) {
|
|
50
50
|
const error = new UsageError(`The locale file ${messageFile} ` + `is missing key: ${messageName}`);
|
|
@@ -54,44 +54,37 @@ export async function getDefaultLocalizedName({
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
return Promise.resolve(extensionName);
|
|
57
|
-
}
|
|
57
|
+
}
|
|
58
58
|
|
|
59
|
+
// https://stackoverflow.com/a/22129960
|
|
59
60
|
export function getStringPropertyValue(prop, obj) {
|
|
60
61
|
const properties = prop.split('.');
|
|
61
62
|
const value = properties.reduce((prev, curr) => prev && prev[curr], obj);
|
|
62
|
-
|
|
63
63
|
if (!['string', 'number'].includes(typeof value)) {
|
|
64
64
|
throw new UsageError(`Manifest key "${prop}" is missing or has an invalid type: ${value}`);
|
|
65
65
|
}
|
|
66
|
-
|
|
67
66
|
const stringValue = `${value}`;
|
|
68
|
-
|
|
69
67
|
if (!stringValue.length) {
|
|
70
68
|
throw new UsageError(`Manifest key "${prop}" value is an empty string`);
|
|
71
69
|
}
|
|
72
|
-
|
|
73
70
|
return stringValue;
|
|
74
71
|
}
|
|
75
|
-
|
|
76
72
|
function getPackageNameFromTemplate(filenameTemplate, manifestData) {
|
|
77
73
|
const packageName = filenameTemplate.replace(/{([A-Za-z0-9._]+?)}/g, (match, manifestProperty) => {
|
|
78
74
|
return safeFileName(getStringPropertyValue(manifestProperty, manifestData));
|
|
79
|
-
});
|
|
80
|
-
// specified in the template string.
|
|
75
|
+
});
|
|
81
76
|
|
|
77
|
+
// Validate the resulting packageName string, after interpolating the manifest property
|
|
78
|
+
// specified in the template string.
|
|
82
79
|
const parsed = path.parse(packageName);
|
|
83
|
-
|
|
84
80
|
if (parsed.dir) {
|
|
85
81
|
throw new UsageError(`Invalid filename template "${filenameTemplate}". ` + `Filename "${packageName}" should not contain a path`);
|
|
86
82
|
}
|
|
87
|
-
|
|
88
83
|
if (!['.zip', '.xpi'].includes(parsed.ext)) {
|
|
89
84
|
throw new UsageError(`Invalid filename template "${filenameTemplate}". ` + `Filename "${packageName}" should have a zip or xpi extension`);
|
|
90
85
|
}
|
|
91
|
-
|
|
92
86
|
return packageName;
|
|
93
87
|
}
|
|
94
|
-
|
|
95
88
|
export async function defaultPackageCreator({
|
|
96
89
|
manifestData,
|
|
97
90
|
sourceDir,
|
|
@@ -104,14 +97,12 @@ export async function defaultPackageCreator({
|
|
|
104
97
|
fromEvent = defaultFromEvent
|
|
105
98
|
} = {}) {
|
|
106
99
|
let id;
|
|
107
|
-
|
|
108
100
|
if (manifestData) {
|
|
109
101
|
id = getManifestId(manifestData);
|
|
110
102
|
log.debug(`Using manifest id=${id || '[not specified]'}`);
|
|
111
103
|
} else {
|
|
112
104
|
manifestData = await getValidatedManifest(sourceDir);
|
|
113
105
|
}
|
|
114
|
-
|
|
115
106
|
const buffer = await zipDir(sourceDir, {
|
|
116
107
|
filter: (...args) => fileFilter.wantFile(...args)
|
|
117
108
|
});
|
|
@@ -119,7 +110,6 @@ export async function defaultPackageCreator({
|
|
|
119
110
|
let {
|
|
120
111
|
default_locale
|
|
121
112
|
} = manifestData;
|
|
122
|
-
|
|
123
113
|
if (default_locale) {
|
|
124
114
|
default_locale = default_locale.replace(/-/g, '_');
|
|
125
115
|
const messageFile = path.join(sourceDir, '_locales', default_locale, 'messages.json');
|
|
@@ -127,32 +117,29 @@ export async function defaultPackageCreator({
|
|
|
127
117
|
const extensionName = await getDefaultLocalizedName({
|
|
128
118
|
messageFile,
|
|
129
119
|
manifestData
|
|
130
|
-
});
|
|
131
|
-
|
|
120
|
+
});
|
|
121
|
+
// allow for a localized `{name}`, without mutating `manifestData`
|
|
132
122
|
filenameTemplate = filenameTemplate.replace(/{name}/g, extensionName);
|
|
133
123
|
}
|
|
134
|
-
|
|
135
124
|
const packageName = safeFileName(getPackageNameFromTemplate(filenameTemplate, manifestData));
|
|
136
|
-
const extensionPath = path.join(artifactsDir, packageName);
|
|
125
|
+
const extensionPath = path.join(artifactsDir, packageName);
|
|
137
126
|
|
|
127
|
+
// Added 'wx' flags to avoid overwriting of existing package.
|
|
138
128
|
const stream = createWriteStream(extensionPath, {
|
|
139
129
|
flags: 'wx'
|
|
140
130
|
});
|
|
141
131
|
stream.write(buffer, () => {
|
|
142
132
|
stream.end();
|
|
143
133
|
});
|
|
144
|
-
|
|
145
134
|
try {
|
|
146
135
|
await fromEvent(stream, 'close');
|
|
147
136
|
} catch (error) {
|
|
148
137
|
if (!isErrorWithCode('EEXIST', error)) {
|
|
149
138
|
throw error;
|
|
150
139
|
}
|
|
151
|
-
|
|
152
140
|
if (!overwriteDest) {
|
|
153
141
|
throw new UsageError(`Extension exists at the destination path: ${extensionPath}\n` + 'Use --overwrite-dest to enable overwriting.');
|
|
154
142
|
}
|
|
155
|
-
|
|
156
143
|
log.info(`Destination exists, overwriting: ${extensionPath}`);
|
|
157
144
|
const overwriteStream = createWriteStream(extensionPath);
|
|
158
145
|
overwriteStream.write(buffer, () => {
|
|
@@ -160,15 +147,15 @@ export async function defaultPackageCreator({
|
|
|
160
147
|
});
|
|
161
148
|
await fromEvent(overwriteStream, 'close');
|
|
162
149
|
}
|
|
163
|
-
|
|
164
150
|
if (showReadyMessage) {
|
|
165
151
|
log.info(`Your web extension is ready: ${extensionPath}`);
|
|
166
152
|
}
|
|
167
|
-
|
|
168
153
|
return {
|
|
169
154
|
extensionPath
|
|
170
155
|
};
|
|
171
|
-
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Build command types and implementation.
|
|
172
159
|
|
|
173
160
|
export default async function build({
|
|
174
161
|
sourceDir,
|
|
@@ -190,9 +177,7 @@ export default async function build({
|
|
|
190
177
|
showReadyMessage = true
|
|
191
178
|
} = {}) {
|
|
192
179
|
const rebuildAsNeeded = asNeeded; // alias for `build --as-needed`
|
|
193
|
-
|
|
194
180
|
log.info(`Building web extension from ${sourceDir}`);
|
|
195
|
-
|
|
196
181
|
const createPackage = () => packageCreator({
|
|
197
182
|
manifestData,
|
|
198
183
|
sourceDir,
|
|
@@ -202,10 +187,8 @@ export default async function build({
|
|
|
202
187
|
showReadyMessage,
|
|
203
188
|
filename
|
|
204
189
|
});
|
|
205
|
-
|
|
206
190
|
await prepareArtifactsDir(artifactsDir);
|
|
207
191
|
const result = await createPackage();
|
|
208
|
-
|
|
209
192
|
if (rebuildAsNeeded) {
|
|
210
193
|
log.info('Rebuilding when files change...');
|
|
211
194
|
onSourceChange({
|
|
@@ -220,7 +203,6 @@ export default async function build({
|
|
|
220
203
|
shouldWatchFile: (...args) => fileFilter.wantFile(...args)
|
|
221
204
|
});
|
|
222
205
|
}
|
|
223
|
-
|
|
224
206
|
return result;
|
|
225
207
|
}
|
|
226
208
|
//# sourceMappingURL=build.js.map
|
package/lib/cmd/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","names":["path","createWriteStream","fs","parseJSON","stripBom","defaultFromEvent","zipDir","defaultSourceWatcher","getValidatedManifest","getManifestId","prepareArtifactsDir","createLogger","UsageError","isErrorWithCode","createFileFilter","defaultFileFilterCreator","FileFilter","log","import","meta","url","DEFAULT_FILENAME_TEMPLATE","safeFileName","name","toLowerCase","replace","getDefaultLocalizedName","messageFile","manifestData","messageData","messageContents","extensionName","readFile","encoding","error","default","stripJsonComments","match","messageName","message","Promise","resolve","getStringPropertyValue","prop","obj","properties","split","value","reduce","prev","curr","includes","stringValue","length","getPackageNameFromTemplate","filenameTemplate","packageName","manifestProperty","parsed","parse","dir","ext","defaultPackageCreator","sourceDir","fileFilter","artifactsDir","overwriteDest","showReadyMessage","filename","fromEvent","id","debug","buffer","filter","args","wantFile","default_locale","join","extensionPath","stream","flags","write","end","info","overwriteStream","build","asNeeded","ignoreFiles","onSourceChange","packageCreator","rebuildAsNeeded","createPackage","result","onChange","catch","stack","shouldWatchFile"],"sources":["../../src/cmd/build.js"],"sourcesContent":["/* @flow */\nimport path from 'path';\nimport {createWriteStream} from 'fs';\n\nimport {fs} from 'mz';\nimport parseJSON from 'parse-json';\nimport stripBom from 'strip-bom';\nimport defaultFromEvent from 'promise-toolbox/fromEvent';\nimport zipDir from 'zip-dir';\n\nimport defaultSourceWatcher from '../watcher.js';\nimport getValidatedManifest, {getManifestId} from '../util/manifest.js';\nimport {prepareArtifactsDir} from '../util/artifacts.js';\nimport {createLogger} from '../util/logger.js';\nimport {UsageError, isErrorWithCode} from '../errors.js';\nimport {\n createFileFilter as defaultFileFilterCreator,\n FileFilter,\n} from '../util/file-filter.js';\n// Import flow types.\nimport type {OnSourceChangeFn} from '../watcher.js';\nimport type {ExtensionManifest} from '../util/manifest.js';\nimport type {FileFilterCreatorFn} from '../util/file-filter.js';\n\nconst log = createLogger(import.meta.url);\nconst DEFAULT_FILENAME_TEMPLATE = '{name}-{version}.zip';\n\nexport function safeFileName(name: string): string {\n return name.toLowerCase().replace(/[^a-z0-9.-]+/g, '_');\n}\n\n\n// defaultPackageCreator types and implementation.\n\nexport type ExtensionBuildResult = {|\n extensionPath: string,\n|};\n\nexport type PackageCreatorParams = {|\n manifestData?: ExtensionManifest,\n sourceDir: string,\n fileFilter: FileFilter,\n artifactsDir: string,\n overwriteDest: boolean,\n showReadyMessage: boolean,\n filename?: string,\n|};\n\nexport type LocalizedNameParams = {|\n messageFile: string,\n manifestData: ExtensionManifest,\n|}\n\nexport type PackageCreatorOptions = {\n fromEvent: typeof defaultFromEvent,\n};\n\n// This defines the _locales/messages.json type. See:\n// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Internationalization#Providing_localized_strings_in__locales\ntype LocalizedMessageData = {|\n [messageName: string]: {|\n description: string,\n message: string,\n |},\n|}\n\nexport async function getDefaultLocalizedName(\n {messageFile, manifestData}: LocalizedNameParams\n): Promise<string> {\n\n let messageData: LocalizedMessageData;\n let messageContents: string | Buffer;\n let extensionName: string = manifestData.name;\n\n try {\n messageContents = await fs.readFile(messageFile, {encoding: 'utf-8'});\n } catch (error) {\n throw new UsageError(\n `Error reading messages.json file at ${messageFile}: ${error}`);\n }\n\n messageContents = stripBom(messageContents);\n\n const {default: stripJsonComments } = await import('strip-json-comments');\n try {\n messageData = parseJSON(stripJsonComments(messageContents));\n } catch (error) {\n throw new UsageError(\n `Error parsing messages.json file at ${messageFile}: ${error}`);\n }\n\n extensionName = manifestData.name.replace(\n /__MSG_([A-Za-z0-9@_]+?)__/g,\n (match, messageName) => {\n if (!(messageData[messageName]\n && messageData[messageName].message)) {\n const error = new UsageError(\n `The locale file ${messageFile} ` +\n `is missing key: ${messageName}`);\n throw error;\n } else {\n return messageData[messageName].message;\n }\n });\n return Promise.resolve(extensionName);\n}\n\n// https://stackoverflow.com/a/22129960\nexport function getStringPropertyValue(\n prop: string,\n obj: Object,\n): string {\n const properties = prop.split('.');\n const value = properties.reduce((prev, curr) => prev && prev[curr], obj);\n if (!['string', 'number'].includes(typeof value)) {\n throw new UsageError(\n `Manifest key \"${prop}\" is missing or has an invalid type: ${value}`\n );\n }\n const stringValue = `${value}`;\n if (!stringValue.length) {\n throw new UsageError(`Manifest key \"${prop}\" value is an empty string`);\n }\n return stringValue;\n}\n\nfunction getPackageNameFromTemplate(\n filenameTemplate: string,\n manifestData: ExtensionManifest\n): string {\n const packageName = filenameTemplate.replace(\n /{([A-Za-z0-9._]+?)}/g,\n (match, manifestProperty) => {\n return safeFileName(\n getStringPropertyValue(manifestProperty, manifestData));\n }\n );\n\n // Validate the resulting packageName string, after interpolating the manifest property\n // specified in the template string.\n const parsed = path.parse(packageName);\n if (parsed.dir) {\n throw new UsageError(\n `Invalid filename template \"${filenameTemplate}\". ` +\n `Filename \"${packageName}\" should not contain a path`\n );\n }\n if (!['.zip', '.xpi'].includes(parsed.ext)) {\n throw new UsageError(\n `Invalid filename template \"${filenameTemplate}\". ` +\n `Filename \"${packageName}\" should have a zip or xpi extension`\n );\n }\n\n return packageName;\n}\n\nexport type PackageCreatorFn =\n (params: PackageCreatorParams) => Promise<ExtensionBuildResult>;\n\nexport async function defaultPackageCreator(\n {\n manifestData,\n sourceDir,\n fileFilter,\n artifactsDir,\n overwriteDest,\n showReadyMessage,\n filename = DEFAULT_FILENAME_TEMPLATE,\n }: PackageCreatorParams,\n {\n fromEvent = defaultFromEvent,\n }: PackageCreatorOptions = {}\n): Promise<ExtensionBuildResult> {\n let id;\n if (manifestData) {\n id = getManifestId(manifestData);\n log.debug(`Using manifest id=${id || '[not specified]'}`);\n } else {\n manifestData = await getValidatedManifest(sourceDir);\n }\n\n const buffer = await zipDir(sourceDir, {\n filter: (...args) => fileFilter.wantFile(...args),\n });\n\n let filenameTemplate = filename;\n\n let {default_locale} = manifestData;\n if (default_locale) {\n default_locale = default_locale.replace(/-/g, '_');\n const messageFile = path.join(\n sourceDir, '_locales',\n default_locale, 'messages.json'\n );\n log.debug('Manifest declared default_locale, localizing extension name');\n const extensionName = await getDefaultLocalizedName({\n messageFile, manifestData,\n });\n // allow for a localized `{name}`, without mutating `manifestData`\n filenameTemplate = filenameTemplate.replace(/{name}/g, extensionName);\n }\n\n const packageName = safeFileName(\n getPackageNameFromTemplate(filenameTemplate, manifestData)\n );\n const extensionPath = path.join(artifactsDir, packageName);\n\n // Added 'wx' flags to avoid overwriting of existing package.\n const stream = createWriteStream(extensionPath, {flags: 'wx'});\n\n stream.write(buffer, () => {\n stream.end();\n });\n\n try {\n await fromEvent(stream, 'close');\n } catch (error) {\n if (!isErrorWithCode('EEXIST', error)) {\n throw error;\n }\n if (!overwriteDest) {\n throw new UsageError(\n `Extension exists at the destination path: ${extensionPath}\\n` +\n 'Use --overwrite-dest to enable overwriting.');\n }\n log.info(`Destination exists, overwriting: ${extensionPath}`);\n const overwriteStream = createWriteStream(extensionPath);\n overwriteStream.write(buffer, () => {\n overwriteStream.end();\n });\n await fromEvent(overwriteStream, 'close');\n }\n\n if (showReadyMessage) {\n log.info(`Your web extension is ready: ${extensionPath}`);\n }\n return {extensionPath};\n}\n\n\n// Build command types and implementation.\n\nexport type BuildCmdParams = {|\n sourceDir: string,\n artifactsDir: string,\n asNeeded?: boolean,\n overwriteDest?: boolean,\n ignoreFiles?: Array<string>,\n filename?: string,\n|};\n\nexport type BuildCmdOptions = {\n manifestData?: ExtensionManifest,\n fileFilter?: FileFilter,\n onSourceChange?: OnSourceChangeFn,\n packageCreator?: PackageCreatorFn,\n showReadyMessage?: boolean,\n createFileFilter?: FileFilterCreatorFn,\n shouldExitProgram?: boolean,\n};\n\nexport default async function build(\n {\n sourceDir,\n artifactsDir,\n asNeeded = false,\n overwriteDest = false,\n ignoreFiles = [],\n filename = DEFAULT_FILENAME_TEMPLATE,\n }: BuildCmdParams,\n {\n manifestData,\n createFileFilter = defaultFileFilterCreator,\n fileFilter = createFileFilter({\n sourceDir,\n artifactsDir,\n ignoreFiles,\n }),\n onSourceChange = defaultSourceWatcher,\n packageCreator = defaultPackageCreator,\n showReadyMessage = true,\n }: BuildCmdOptions = {}\n): Promise<ExtensionBuildResult> {\n\n const rebuildAsNeeded = asNeeded; // alias for `build --as-needed`\n log.info(`Building web extension from ${sourceDir}`);\n\n const createPackage = () => packageCreator({\n manifestData,\n sourceDir,\n fileFilter,\n artifactsDir,\n overwriteDest,\n showReadyMessage,\n filename,\n });\n\n await prepareArtifactsDir(artifactsDir);\n const result = await createPackage();\n\n if (rebuildAsNeeded) {\n log.info('Rebuilding when files change...');\n onSourceChange({\n sourceDir,\n artifactsDir,\n onChange: () => {\n return createPackage().catch((error) => {\n log.error(error.stack);\n throw error;\n });\n },\n shouldWatchFile: (...args) => fileFilter.wantFile(...args),\n });\n }\n\n return result;\n}\n"],"mappings":"AACA,OAAOA,IAAP,MAAiB,MAAjB;AACA,SAAQC,iBAAR,QAAgC,IAAhC;AAEA,SAAQC,EAAR,QAAiB,IAAjB;AACA,OAAO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IAAID,eAAJ,EAAqB;IACnBzE,GAAG,CAACkE,IAAJ,CAAS,iCAAT;IACAK,cAAc,CAAC;MACbzB,SADa;MAEbE,YAFa;MAGb4B,QAAQ,EAAE,MAAM;QACd,OAAOF,aAAa,GAAGG,KAAhB,CAAuB5D,KAAD,IAAW;UACtCjB,GAAG,CAACiB,KAAJ,CAAUA,KAAK,CAAC6D,KAAhB;UACA,MAAM7D,KAAN;QACD,CAHM,CAAP;MAID,CARY;MASb8D,eAAe,EAAE,CAAC,GAAGtB,IAAJ,KAAaV,UAAU,CAACW,QAAX,CAAoB,GAAGD,IAAvB;IATjB,CAAD,CAAd;EAWD;;EAED,OAAOkB,MAAP;AACD"}
|
|
1
|
+
{"version":3,"file":"build.js","names":["path","createWriteStream","fs","parseJSON","stripBom","defaultFromEvent","zipDir","defaultSourceWatcher","getValidatedManifest","getManifestId","prepareArtifactsDir","createLogger","UsageError","isErrorWithCode","createFileFilter","defaultFileFilterCreator","FileFilter","log","import","meta","url","DEFAULT_FILENAME_TEMPLATE","safeFileName","name","toLowerCase","replace","getDefaultLocalizedName","messageFile","manifestData","messageData","messageContents","extensionName","readFile","encoding","error","default","stripJsonComments","match","messageName","message","Promise","resolve","getStringPropertyValue","prop","obj","properties","split","value","reduce","prev","curr","includes","stringValue","length","getPackageNameFromTemplate","filenameTemplate","packageName","manifestProperty","parsed","parse","dir","ext","defaultPackageCreator","sourceDir","fileFilter","artifactsDir","overwriteDest","showReadyMessage","filename","fromEvent","id","debug","buffer","filter","args","wantFile","default_locale","join","extensionPath","stream","flags","write","end","info","overwriteStream","build","asNeeded","ignoreFiles","onSourceChange","packageCreator","rebuildAsNeeded","createPackage","result","onChange","catch","stack","shouldWatchFile"],"sources":["../../src/cmd/build.js"],"sourcesContent":["/* @flow */\nimport path from 'path';\nimport {createWriteStream} from 'fs';\n\nimport {fs} from 'mz';\nimport parseJSON from 'parse-json';\nimport stripBom from 'strip-bom';\nimport defaultFromEvent from 'promise-toolbox/fromEvent';\nimport zipDir from 'zip-dir';\n\nimport defaultSourceWatcher from '../watcher.js';\nimport getValidatedManifest, {getManifestId} from '../util/manifest.js';\nimport {prepareArtifactsDir} from '../util/artifacts.js';\nimport {createLogger} from '../util/logger.js';\nimport {UsageError, isErrorWithCode} from '../errors.js';\nimport {\n createFileFilter as defaultFileFilterCreator,\n FileFilter,\n} from '../util/file-filter.js';\n// Import flow types.\nimport type {OnSourceChangeFn} from '../watcher.js';\nimport type {ExtensionManifest} from '../util/manifest.js';\nimport type {FileFilterCreatorFn} from '../util/file-filter.js';\n\nconst log = createLogger(import.meta.url);\nconst DEFAULT_FILENAME_TEMPLATE = '{name}-{version}.zip';\n\nexport function safeFileName(name: string): string {\n return name.toLowerCase().replace(/[^a-z0-9.-]+/g, '_');\n}\n\n\n// defaultPackageCreator types and implementation.\n\nexport type ExtensionBuildResult = {|\n extensionPath: string,\n|};\n\nexport type PackageCreatorParams = {|\n manifestData?: ExtensionManifest,\n sourceDir: string,\n fileFilter: FileFilter,\n artifactsDir: string,\n overwriteDest: boolean,\n showReadyMessage: boolean,\n filename?: string,\n|};\n\nexport type LocalizedNameParams = {|\n messageFile: string,\n manifestData: ExtensionManifest,\n|}\n\nexport type PackageCreatorOptions = {\n fromEvent: typeof defaultFromEvent,\n};\n\n// This defines the _locales/messages.json type. See:\n// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Internationalization#Providing_localized_strings_in__locales\ntype LocalizedMessageData = {|\n [messageName: string]: {|\n description: string,\n message: string,\n |},\n|}\n\nexport async function getDefaultLocalizedName(\n {messageFile, manifestData}: LocalizedNameParams\n): Promise<string> {\n\n let messageData: LocalizedMessageData;\n let messageContents: string | Buffer;\n let extensionName: string = manifestData.name;\n\n try {\n messageContents = await fs.readFile(messageFile, {encoding: 'utf-8'});\n } catch (error) {\n throw new UsageError(\n `Error reading messages.json file at ${messageFile}: ${error}`);\n }\n\n messageContents = stripBom(messageContents);\n\n const {default: stripJsonComments } = await import('strip-json-comments');\n try {\n messageData = parseJSON(stripJsonComments(messageContents));\n } catch (error) {\n throw new UsageError(\n `Error parsing messages.json file at ${messageFile}: ${error}`);\n }\n\n extensionName = manifestData.name.replace(\n /__MSG_([A-Za-z0-9@_]+?)__/g,\n (match, messageName) => {\n if (!(messageData[messageName]\n && messageData[messageName].message)) {\n const error = new UsageError(\n `The locale file ${messageFile} ` +\n `is missing key: ${messageName}`);\n throw error;\n } else {\n return messageData[messageName].message;\n }\n });\n return Promise.resolve(extensionName);\n}\n\n// https://stackoverflow.com/a/22129960\nexport function getStringPropertyValue(\n prop: string,\n obj: Object,\n): string {\n const properties = prop.split('.');\n const value = properties.reduce((prev, curr) => prev && prev[curr], obj);\n if (!['string', 'number'].includes(typeof value)) {\n throw new UsageError(\n `Manifest key \"${prop}\" is missing or has an invalid type: ${value}`\n );\n }\n const stringValue = `${value}`;\n if (!stringValue.length) {\n throw new UsageError(`Manifest key \"${prop}\" value is an empty string`);\n }\n return stringValue;\n}\n\nfunction getPackageNameFromTemplate(\n filenameTemplate: string,\n manifestData: ExtensionManifest\n): string {\n const packageName = filenameTemplate.replace(\n /{([A-Za-z0-9._]+?)}/g,\n (match, manifestProperty) => {\n return safeFileName(\n getStringPropertyValue(manifestProperty, manifestData));\n }\n );\n\n // Validate the resulting packageName string, after interpolating the manifest property\n // specified in the template string.\n const parsed = path.parse(packageName);\n if (parsed.dir) {\n throw new UsageError(\n `Invalid filename template \"${filenameTemplate}\". ` +\n `Filename \"${packageName}\" should not contain a path`\n );\n }\n if (!['.zip', '.xpi'].includes(parsed.ext)) {\n throw new UsageError(\n `Invalid filename template \"${filenameTemplate}\". ` +\n `Filename \"${packageName}\" should have a zip or xpi extension`\n );\n }\n\n return packageName;\n}\n\nexport type PackageCreatorFn =\n (params: PackageCreatorParams) => Promise<ExtensionBuildResult>;\n\nexport async function defaultPackageCreator(\n {\n manifestData,\n sourceDir,\n fileFilter,\n artifactsDir,\n overwriteDest,\n showReadyMessage,\n filename = DEFAULT_FILENAME_TEMPLATE,\n }: PackageCreatorParams,\n {\n fromEvent = defaultFromEvent,\n }: PackageCreatorOptions = {}\n): Promise<ExtensionBuildResult> {\n let id;\n if (manifestData) {\n id = getManifestId(manifestData);\n log.debug(`Using manifest id=${id || '[not specified]'}`);\n } else {\n manifestData = await getValidatedManifest(sourceDir);\n }\n\n const buffer = await zipDir(sourceDir, {\n filter: (...args) => fileFilter.wantFile(...args),\n });\n\n let filenameTemplate = filename;\n\n let {default_locale} = manifestData;\n if (default_locale) {\n default_locale = default_locale.replace(/-/g, '_');\n const messageFile = path.join(\n sourceDir, '_locales',\n default_locale, 'messages.json'\n );\n log.debug('Manifest declared default_locale, localizing extension name');\n const extensionName = await getDefaultLocalizedName({\n messageFile, manifestData,\n });\n // allow for a localized `{name}`, without mutating `manifestData`\n filenameTemplate = filenameTemplate.replace(/{name}/g, extensionName);\n }\n\n const packageName = safeFileName(\n getPackageNameFromTemplate(filenameTemplate, manifestData)\n );\n const extensionPath = path.join(artifactsDir, packageName);\n\n // Added 'wx' flags to avoid overwriting of existing package.\n const stream = createWriteStream(extensionPath, {flags: 'wx'});\n\n stream.write(buffer, () => {\n stream.end();\n });\n\n try {\n await fromEvent(stream, 'close');\n } catch (error) {\n if (!isErrorWithCode('EEXIST', error)) {\n throw error;\n }\n if (!overwriteDest) {\n throw new UsageError(\n `Extension exists at the destination path: ${extensionPath}\\n` +\n 'Use --overwrite-dest to enable overwriting.');\n }\n log.info(`Destination exists, overwriting: ${extensionPath}`);\n const overwriteStream = createWriteStream(extensionPath);\n overwriteStream.write(buffer, () => {\n overwriteStream.end();\n });\n await fromEvent(overwriteStream, 'close');\n }\n\n if (showReadyMessage) {\n log.info(`Your web extension is ready: ${extensionPath}`);\n }\n return {extensionPath};\n}\n\n\n// Build command types and implementation.\n\nexport type BuildCmdParams = {|\n sourceDir: string,\n artifactsDir: string,\n asNeeded?: boolean,\n overwriteDest?: boolean,\n ignoreFiles?: Array<string>,\n filename?: string,\n|};\n\nexport type BuildCmdOptions = {\n manifestData?: ExtensionManifest,\n fileFilter?: FileFilter,\n onSourceChange?: OnSourceChangeFn,\n packageCreator?: PackageCreatorFn,\n showReadyMessage?: boolean,\n createFileFilter?: FileFilterCreatorFn,\n shouldExitProgram?: boolean,\n};\n\nexport default async function build(\n {\n sourceDir,\n artifactsDir,\n asNeeded = false,\n overwriteDest = false,\n ignoreFiles = [],\n filename = DEFAULT_FILENAME_TEMPLATE,\n }: BuildCmdParams,\n {\n manifestData,\n createFileFilter = defaultFileFilterCreator,\n fileFilter = createFileFilter({\n sourceDir,\n artifactsDir,\n ignoreFiles,\n }),\n onSourceChange = defaultSourceWatcher,\n packageCreator = defaultPackageCreator,\n showReadyMessage = true,\n }: BuildCmdOptions = {}\n): Promise<ExtensionBuildResult> {\n\n const rebuildAsNeeded = asNeeded; // alias for `build --as-needed`\n log.info(`Building web extension from ${sourceDir}`);\n\n const createPackage = () => packageCreator({\n manifestData,\n sourceDir,\n fileFilter,\n artifactsDir,\n overwriteDest,\n showReadyMessage,\n filename,\n });\n\n await prepareArtifactsDir(artifactsDir);\n const result = await createPackage();\n\n if (rebuildAsNeeded) {\n log.info('Rebuilding when files change...');\n onSourceChange({\n sourceDir,\n artifactsDir,\n onChange: () => {\n return createPackage().catch((error) => {\n log.error(error.stack);\n throw error;\n });\n },\n shouldWatchFile: (...args) => fileFilter.wantFile(...args),\n });\n }\n\n return result;\n}\n"],"mappings":";AACA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAAQC,iBAAiB,QAAO,IAAI;AAEpC,SAAQC,EAAE,QAAO,IAAI;AACrB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,QAAQ,MAAM,WAAW;AAChC,OAAOC,gBAAgB,MAAM,2BAA2B;AACxD,OAAOC,MAAM,MAAM,SAAS;AAE5B,OAAOC,oBAAoB,MAAM,eAAe;AAChD,OAAOC,oBAAoB,IAAGC,aAAa,QAAO,qBAAqB;AACvE,SAAQC,mBAAmB,QAAO,sBAAsB;AACxD,SAAQC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AC,CAAC;MACJ,CAAC;MACD8D,eAAe,EAAE,CAAC,GAAGtB,IAAI,KAAKV,UAAU,CAACW,QAAQ,CAAC,GAAGD,IAAI;IAC3D,CAAC,CAAC;EACJ;EAEA,OAAOkB,MAAM;AACf"}
|
package/lib/cmd/docs.js
CHANGED
package/lib/cmd/docs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.js","names":["open","createLogger","log","import","meta","url","docs","params","openUrl","error","debug"],"sources":["../../src/cmd/docs.js"],"sourcesContent":["/* @flow */\nimport open from 'open';\n\nimport {createLogger} from '../util/logger.js';\n\nconst log = createLogger(import.meta.url);\n\nexport type DocsParams = {\n noInput?: boolean,\n shouldExitProgram?: boolean,\n}\n\nexport type DocsOptions = {\n openUrl?: typeof open,\n}\n\n// eslint-disable-next-line max-len\nexport const url = 'https://extensionworkshop.com/documentation/develop/getting-started-with-web-ext/';\n\nexport default async function docs(\n params: DocsParams, {openUrl = open}: DocsOptions = {}\n): Promise<void> {\n try {\n await openUrl(url);\n } catch (error) {\n log.debug(`Encountered an error while opening URL ${url}`, error);\n throw error;\n }\n}\n"],"mappings":"AACA,OAAOA,
|
|
1
|
+
{"version":3,"file":"docs.js","names":["open","createLogger","log","import","meta","url","docs","params","openUrl","error","debug"],"sources":["../../src/cmd/docs.js"],"sourcesContent":["/* @flow */\nimport open from 'open';\n\nimport {createLogger} from '../util/logger.js';\n\nconst log = createLogger(import.meta.url);\n\nexport type DocsParams = {\n noInput?: boolean,\n shouldExitProgram?: boolean,\n}\n\nexport type DocsOptions = {\n openUrl?: typeof open,\n}\n\n// eslint-disable-next-line max-len\nexport const url = 'https://extensionworkshop.com/documentation/develop/getting-started-with-web-ext/';\n\nexport default async function docs(\n params: DocsParams, {openUrl = open}: DocsOptions = {}\n): Promise<void> {\n try {\n await openUrl(url);\n } catch (error) {\n log.debug(`Encountered an error while opening URL ${url}`, error);\n throw error;\n }\n}\n"],"mappings":";AACA,OAAOA,IAAI,MAAM,MAAM;AAEvB,SAAQC,YAAY,QAAO,mBAAmB;AAE9C,MAAMC,GAAG,GAAGD,YAAY,CAACE,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;AAWzC;AACA,OAAO,MAAMA,GAAG,GAAG,mFAAmF;AAEtG,eAAe,eAAeC,IAAI,CAChCC,MAAkB,EAAE;EAACC,OAAO,GAAGR;AAAiB,CAAC,GAAG,CAAC,CAAC,EACvC;EACf,IAAI;IACF,MAAMQ,OAAO,CAACH,GAAG,CAAC;EACpB,CAAC,CAAC,OAAOI,KAAK,EAAE;IACdP,GAAG,CAACQ,KAAK,CAAE,0CAAyCL,GAAI,EAAC,EAAEI,KAAK,CAAC;IACjE,MAAMA,KAAK;EACb;AACF"}
|
package/lib/cmd/index.js
CHANGED
|
@@ -1,42 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
1
3
|
// This module exports entry points for all supported commands. For performance
|
|
2
4
|
// reasons (faster start-up), the implementations are not statically imported
|
|
3
5
|
// at the top of the file, but lazily loaded in the (exported) functions.
|
|
4
6
|
// The latter would slow down start-up by several seconds, as seen in #1302 .
|
|
7
|
+
|
|
5
8
|
async function build(params, options) {
|
|
6
9
|
const {
|
|
7
10
|
default: runCommand
|
|
8
11
|
} = await import('./build.js');
|
|
9
12
|
return runCommand(params, options);
|
|
10
13
|
}
|
|
11
|
-
|
|
12
14
|
async function lint(params, options) {
|
|
13
15
|
const {
|
|
14
16
|
default: runCommand
|
|
15
17
|
} = await import('./lint.js');
|
|
16
18
|
return runCommand(params, options);
|
|
17
19
|
}
|
|
18
|
-
|
|
19
20
|
async function run(params, options) {
|
|
20
21
|
const {
|
|
21
22
|
default: runCommand
|
|
22
23
|
} = await import('./run.js');
|
|
23
24
|
return runCommand(params, options);
|
|
24
25
|
}
|
|
25
|
-
|
|
26
26
|
async function sign(params, options) {
|
|
27
27
|
const {
|
|
28
28
|
default: runCommand
|
|
29
29
|
} = await import('./sign.js');
|
|
30
30
|
return runCommand(params, options);
|
|
31
31
|
}
|
|
32
|
-
|
|
33
32
|
async function docs(params, options) {
|
|
34
33
|
const {
|
|
35
34
|
default: runCommand
|
|
36
35
|
} = await import('./docs.js');
|
|
37
36
|
return runCommand(params, options);
|
|
38
37
|
}
|
|
39
|
-
|
|
40
38
|
export default {
|
|
41
39
|
build,
|
|
42
40
|
lint,
|
package/lib/cmd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["build","params","options","default","runCommand","lint","run","sign","docs"],"sources":["../../src/cmd/index.js"],"sourcesContent":["/* @flow */\n\nimport type {\n BuildCmdParams, BuildCmdOptions, ExtensionBuildResult,\n} from './build.js';\nimport type {LintCmdParams, LintCmdOptions} from './lint.js';\nimport type {CmdRunParams, CmdRunOptions} from './run.js';\nimport type {MultiExtensionRunner} from '../extension-runners/index.js';\nimport type {SignParams, SignOptions, SignResult} from './sign.js';\nimport type {DocsParams, DocsOptions} from './docs.js';\n\n// This module exports entry points for all supported commands. For performance\n// reasons (faster start-up), the implementations are not statically imported\n// at the top of the file, but lazily loaded in the (exported) functions.\n// The latter would slow down start-up by several seconds, as seen in #1302 .\n\nasync function build(\n params: BuildCmdParams, options: BuildCmdOptions\n): Promise<ExtensionBuildResult> {\n const {default: runCommand} = await import('./build.js');\n return runCommand(params, options);\n}\n\nasync function lint(\n params: LintCmdParams, options: LintCmdOptions\n): Promise<void> {\n const {default: runCommand} = await import('./lint.js');\n return runCommand(params, options);\n}\n\nasync function run(\n params: CmdRunParams, options: CmdRunOptions\n): Promise<MultiExtensionRunner> {\n const {default: runCommand} = await import('./run.js');\n return runCommand(params, options);\n}\n\nasync function sign(\n params: SignParams, options: SignOptions\n): Promise<SignResult> {\n const {default: runCommand} = await import('./sign.js');\n return runCommand(params, options);\n}\n\nasync function docs(\n params: DocsParams, options: DocsOptions\n): Promise<void> {\n const {default: runCommand} = await import('./docs.js');\n return runCommand(params, options);\n}\n\nexport default {build, lint, run, sign, docs};\n"],"mappings":"AAWA;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"file":"index.js","names":["build","params","options","default","runCommand","lint","run","sign","docs"],"sources":["../../src/cmd/index.js"],"sourcesContent":["/* @flow */\n\nimport type {\n BuildCmdParams, BuildCmdOptions, ExtensionBuildResult,\n} from './build.js';\nimport type {LintCmdParams, LintCmdOptions} from './lint.js';\nimport type {CmdRunParams, CmdRunOptions} from './run.js';\nimport type {MultiExtensionRunner} from '../extension-runners/index.js';\nimport type {SignParams, SignOptions, SignResult} from './sign.js';\nimport type {DocsParams, DocsOptions} from './docs.js';\n\n// This module exports entry points for all supported commands. For performance\n// reasons (faster start-up), the implementations are not statically imported\n// at the top of the file, but lazily loaded in the (exported) functions.\n// The latter would slow down start-up by several seconds, as seen in #1302 .\n\nasync function build(\n params: BuildCmdParams, options: BuildCmdOptions\n): Promise<ExtensionBuildResult> {\n const {default: runCommand} = await import('./build.js');\n return runCommand(params, options);\n}\n\nasync function lint(\n params: LintCmdParams, options: LintCmdOptions\n): Promise<void> {\n const {default: runCommand} = await import('./lint.js');\n return runCommand(params, options);\n}\n\nasync function run(\n params: CmdRunParams, options: CmdRunOptions\n): Promise<MultiExtensionRunner> {\n const {default: runCommand} = await import('./run.js');\n return runCommand(params, options);\n}\n\nasync function sign(\n params: SignParams, options: SignOptions\n): Promise<SignResult> {\n const {default: runCommand} = await import('./sign.js');\n return runCommand(params, options);\n}\n\nasync function docs(\n params: DocsParams, options: DocsOptions\n): Promise<void> {\n const {default: runCommand} = await import('./docs.js');\n return runCommand(params, options);\n}\n\nexport default {build, lint, run, sign, docs};\n"],"mappings":";;AAWA;AACA;AACA;AACA;;AAEA,eAAeA,KAAK,CAClBC,MAAsB,EAAEC,OAAwB,EACjB;EAC/B,MAAM;IAACC,OAAO,EAAEC;EAAU,CAAC,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;EACxD,OAAOA,UAAU,CAACH,MAAM,EAAEC,OAAO,CAAC;AACpC;AAEA,eAAeG,IAAI,CACjBJ,MAAqB,EAAEC,OAAuB,EAC/B;EACf,MAAM;IAACC,OAAO,EAAEC;EAAU,CAAC,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;EACvD,OAAOA,UAAU,CAACH,MAAM,EAAEC,OAAO,CAAC;AACpC;AAEA,eAAeI,GAAG,CAChBL,MAAoB,EAAEC,OAAsB,EACb;EAC/B,MAAM;IAACC,OAAO,EAAEC;EAAU,CAAC,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC;EACtD,OAAOA,UAAU,CAACH,MAAM,EAAEC,OAAO,CAAC;AACpC;AAEA,eAAeK,IAAI,CACjBN,MAAkB,EAAEC,OAAoB,EACnB;EACrB,MAAM;IAACC,OAAO,EAAEC;EAAU,CAAC,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;EACvD,OAAOA,UAAU,CAACH,MAAM,EAAEC,OAAO,CAAC;AACpC;AAEA,eAAeM,IAAI,CACjBP,MAAkB,EAAEC,OAAoB,EACzB;EACf,MAAM;IAACC,OAAO,EAAEC;EAAU,CAAC,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;EACvD,OAAOA,UAAU,CAACH,MAAM,EAAEC,OAAO,CAAC;AACpC;AAEA,eAAe;EAACF,KAAK;EAAEK,IAAI;EAAEC,GAAG;EAAEC,IAAI;EAAEC;AAAI,CAAC"}
|
package/lib/cmd/lint.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
|
|
1
2
|
import { createInstance as defaultLinterCreator } from 'addons-linter';
|
|
2
3
|
import { createLogger } from '../util/logger.js';
|
|
3
|
-
import { createFileFilter as defaultFileFilterCreator } from '../util/file-filter.js';
|
|
4
|
+
import { createFileFilter as defaultFileFilterCreator } from '../util/file-filter.js';
|
|
5
|
+
// import flow types
|
|
6
|
+
|
|
7
|
+
const log = createLogger(import.meta.url);
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
// Define the needed 'addons-linter' module flow types.
|
|
6
10
|
|
|
7
11
|
export default function lint({
|
|
8
12
|
artifactsDir,
|
|
9
13
|
boring,
|
|
14
|
+
firefoxPreview = [],
|
|
10
15
|
ignoreFiles,
|
|
11
16
|
metadata,
|
|
12
17
|
output,
|
|
@@ -26,23 +31,29 @@ export default function lint({
|
|
|
26
31
|
ignoreFiles,
|
|
27
32
|
artifactsDir
|
|
28
33
|
});
|
|
34
|
+
const config = {
|
|
35
|
+
logLevel: verbose ? 'debug' : 'fatal',
|
|
36
|
+
stack: Boolean(verbose),
|
|
37
|
+
pretty,
|
|
38
|
+
privileged,
|
|
39
|
+
warningsAsErrors,
|
|
40
|
+
metadata,
|
|
41
|
+
output,
|
|
42
|
+
boring,
|
|
43
|
+
selfHosted,
|
|
44
|
+
shouldScanFile: fileName => fileFilter.wantFile(fileName),
|
|
45
|
+
minManifestVersion: 2,
|
|
46
|
+
maxManifestVersion: 2,
|
|
47
|
+
// This mimics the first command line argument from yargs, which should be
|
|
48
|
+
// the directory to the extension.
|
|
49
|
+
_: [sourceDir]
|
|
50
|
+
};
|
|
51
|
+
if (firefoxPreview.includes('mv3')) {
|
|
52
|
+
config.maxManifestVersion = 3;
|
|
53
|
+
}
|
|
29
54
|
log.debug(`Running addons-linter on ${sourceDir}`);
|
|
30
55
|
const linter = createLinter({
|
|
31
|
-
config
|
|
32
|
-
logLevel: verbose ? 'debug' : 'fatal',
|
|
33
|
-
stack: Boolean(verbose),
|
|
34
|
-
pretty,
|
|
35
|
-
privileged,
|
|
36
|
-
warningsAsErrors,
|
|
37
|
-
metadata,
|
|
38
|
-
output,
|
|
39
|
-
boring,
|
|
40
|
-
selfHosted,
|
|
41
|
-
shouldScanFile: fileName => fileFilter.wantFile(fileName),
|
|
42
|
-
// This mimics the first command line argument from yargs,
|
|
43
|
-
// which should be the directory to the extension.
|
|
44
|
-
_: [sourceDir]
|
|
45
|
-
},
|
|
56
|
+
config,
|
|
46
57
|
runAsBinary: shouldExitProgram
|
|
47
58
|
});
|
|
48
59
|
return linter.run();
|
package/lib/cmd/lint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.js","names":["createInstance","defaultLinterCreator","createLogger","createFileFilter","defaultFileFilterCreator","log","import","meta","url","lint","artifactsDir","boring","ignoreFiles","metadata","output","pretty","privileged","sourceDir","selfHosted","verbose","warningsAsErrors","createLinter","shouldExitProgram","fileFilter","
|
|
1
|
+
{"version":3,"file":"lint.js","names":["createInstance","defaultLinterCreator","createLogger","createFileFilter","defaultFileFilterCreator","log","import","meta","url","lint","artifactsDir","boring","firefoxPreview","ignoreFiles","metadata","output","pretty","privileged","sourceDir","selfHosted","verbose","warningsAsErrors","createLinter","shouldExitProgram","fileFilter","config","logLevel","stack","Boolean","shouldScanFile","fileName","wantFile","minManifestVersion","maxManifestVersion","_","includes","debug","linter","runAsBinary","run"],"sources":["../../src/cmd/lint.js"],"sourcesContent":["/* @flow */\nimport {createInstance as defaultLinterCreator} from 'addons-linter';\n\nimport {createLogger} from '../util/logger.js';\nimport {\n createFileFilter as defaultFileFilterCreator,\n} from '../util/file-filter.js';\n// import flow types\nimport type {FileFilterCreatorFn} from '../util/file-filter.js';\n\nconst log = createLogger(import.meta.url);\n\n\n// Define the needed 'addons-linter' module flow types.\n\nexport type LinterOutputType = 'text' | 'json';\n\nexport type LinterCreatorParams = {|\n config: {|\n logLevel: 'debug' | 'fatal',\n stack: boolean,\n pretty?: boolean,\n warningsAsErrors?: boolean,\n metadata?: boolean,\n minManifestVersion?: number,\n maxManifestVersion?: number,\n output?: LinterOutputType,\n privileged?: boolean,\n boring?: boolean,\n selfHosted?: boolean,\n shouldScanFile: (fileName: string) => boolean,\n _: Array<string>,\n |},\n runAsBinary: boolean,\n|};\n\nexport type Linter = {|\n run: () => Promise<void>,\n|};\n\nexport type LinterCreatorFn = (params: LinterCreatorParams) => Linter;\n\n\n// Lint command types and implementation.\n\nexport type LintCmdParams = {|\n artifactsDir?: string,\n boring?: boolean,\n firefoxPreview: Array<string>,\n ignoreFiles?: Array<string>,\n metadata?: boolean,\n output?: LinterOutputType,\n pretty?: boolean,\n privileged?: boolean,\n selfHosted?: boolean,\n sourceDir: string,\n verbose?: boolean,\n warningsAsErrors?: boolean,\n|};\n\nexport type LintCmdOptions = {\n createLinter?: LinterCreatorFn,\n createFileFilter?: FileFilterCreatorFn,\n shouldExitProgram?: boolean,\n};\n\nexport default function lint(\n {\n artifactsDir,\n boring,\n firefoxPreview = [],\n ignoreFiles,\n metadata,\n output,\n pretty,\n privileged,\n sourceDir,\n selfHosted,\n verbose,\n warningsAsErrors,\n }: LintCmdParams,\n {\n createLinter = defaultLinterCreator,\n createFileFilter = defaultFileFilterCreator,\n shouldExitProgram = true,\n }: LintCmdOptions = {}\n): Promise<void> {\n const fileFilter = createFileFilter({sourceDir, ignoreFiles, artifactsDir});\n\n const config = {\n logLevel: verbose ? 'debug' : 'fatal',\n stack: Boolean(verbose),\n pretty,\n privileged,\n warningsAsErrors,\n metadata,\n output,\n boring,\n selfHosted,\n shouldScanFile: (fileName) => fileFilter.wantFile(fileName),\n minManifestVersion: 2,\n maxManifestVersion: 2,\n // This mimics the first command line argument from yargs, which should be\n // the directory to the extension.\n _: [sourceDir],\n };\n\n if (firefoxPreview.includes('mv3')) {\n config.maxManifestVersion = 3;\n }\n\n log.debug(`Running addons-linter on ${sourceDir}`);\n const linter = createLinter({ config, runAsBinary: shouldExitProgram });\n return linter.run();\n}\n"],"mappings":";AACA,SAAQA,cAAc,IAAIC,oBAAoB,QAAO,eAAe;AAEpE,SAAQC,YAAY,QAAO,mBAAmB;AAC9C,SACEC,gBAAgB,IAAIC,wBAAwB,QACvC,wBAAwB;AAC/B;;AAGA,MAAMC,GAAG,GAAGH,YAAY,CAACI,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC;;AAGzC;;AAqDA,eAAe,SAASC,IAAI,CAC1B;EACEC,YAAY;EACZC,MAAM;EACNC,cAAc,GAAG,EAAE;EACnBC,WAAW;EACXC,QAAQ;EACRC,MAAM;EACNC,MAAM;EACNC,UAAU;EACVC,SAAS;EACTC,UAAU;EACVC,OAAO;EACPC;AACa,CAAC,EAChB;EACEC,YAAY,GAAGrB,oBAAoB;EACnCE,gBAAgB,GAAGC,wBAAwB;EAC3CmB,iBAAiB,GAAG;AACN,CAAC,GAAG,CAAC,CAAC,EACP;EACf,MAAMC,UAAU,GAAGrB,gBAAgB,CAAC;IAACe,SAAS;IAAEL,WAAW;IAAEH;EAAY,CAAC,CAAC;EAE3E,MAAMe,MAAM,GAAG;IACbC,QAAQ,EAAEN,OAAO,GAAG,OAAO,GAAG,OAAO;IACrCO,KAAK,EAAEC,OAAO,CAACR,OAAO,CAAC;IACvBJ,MAAM;IACNC,UAAU;IACVI,gBAAgB;IAChBP,QAAQ;IACRC,MAAM;IACNJ,MAAM;IACNQ,UAAU;IACVU,cAAc,EAAGC,QAAQ,IAAKN,UAAU,CAACO,QAAQ,CAACD,QAAQ,CAAC;IAC3DE,kBAAkB,EAAE,CAAC;IACrBC,kBAAkB,EAAE,CAAC;IACrB;IACA;IACAC,CAAC,EAAE,CAAChB,SAAS;EACf,CAAC;EAED,IAAIN,cAAc,CAACuB,QAAQ,CAAC,KAAK,CAAC,EAAE;IAClCV,MAAM,CAACQ,kBAAkB,GAAG,CAAC;EAC/B;EAEA5B,GAAG,CAAC+B,KAAK,CAAE,4BAA2BlB,SAAU,EAAC,CAAC;EAClD,MAAMmB,MAAM,GAAGf,YAAY,CAAC;IAAEG,MAAM;IAAEa,WAAW,EAAEf;EAAkB,CAAC,CAAC;EACvE,OAAOc,MAAM,CAACE,GAAG,EAAE;AACrB"}
|
package/lib/cmd/run.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
import { fs } from 'mz';
|
|
2
3
|
import defaultBuildExtension from './build.js';
|
|
3
4
|
import { showDesktopNotification as defaultDesktopNotifications } from '../util/desktop-notifier.js';
|
|
@@ -6,13 +7,17 @@ import { connectWithMaxRetries as defaultFirefoxClient } from '../firefox/remote
|
|
|
6
7
|
import { createLogger } from '../util/logger.js';
|
|
7
8
|
import defaultGetValidatedManifest from '../util/manifest.js';
|
|
8
9
|
import { UsageError } from '../errors.js';
|
|
9
|
-
import { createExtensionRunner, defaultReloadStrategy, MultiExtensionRunner as DefaultMultiExtensionRunner } from '../extension-runners/index.js';
|
|
10
|
+
import { createExtensionRunner, defaultReloadStrategy, MultiExtensionRunner as DefaultMultiExtensionRunner } from '../extension-runners/index.js';
|
|
11
|
+
// Import objects that are only used as Flow types.
|
|
12
|
+
|
|
13
|
+
const log = createLogger(import.meta.url);
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
// Run command types and implementation.
|
|
12
16
|
|
|
13
17
|
export default async function run({
|
|
14
18
|
artifactsDir,
|
|
15
19
|
browserConsole = false,
|
|
20
|
+
devtools = false,
|
|
16
21
|
pref,
|
|
17
22
|
firefox,
|
|
18
23
|
firefoxProfile,
|
|
@@ -51,36 +56,30 @@ export default async function run({
|
|
|
51
56
|
getValidatedManifest = defaultGetValidatedManifest
|
|
52
57
|
} = {}) {
|
|
53
58
|
log.info(`Running web extension from ${sourceDir}`);
|
|
54
|
-
|
|
55
59
|
if (preInstall) {
|
|
56
60
|
log.info('Disabled auto-reloading because it\'s not possible with ' + '--pre-install');
|
|
57
61
|
noReload = true;
|
|
58
62
|
}
|
|
59
|
-
|
|
60
63
|
if (watchFile != null && (!Array.isArray(watchFile) || !watchFile.every(el => typeof el === 'string'))) {
|
|
61
64
|
throw new UsageError('Unexpected watchFile type');
|
|
62
|
-
}
|
|
63
|
-
// object containing one or more preferences.
|
|
64
|
-
|
|
65
|
+
}
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
// Create an alias for --pref since it has been transformed into an
|
|
68
|
+
// object containing one or more preferences.
|
|
69
|
+
const customPrefs = {
|
|
70
|
+
...pref
|
|
67
71
|
};
|
|
68
|
-
|
|
69
72
|
if (firefoxPreview.includes('mv3')) {
|
|
70
73
|
log.info('Configuring Firefox preferences for Manifest V3');
|
|
71
74
|
customPrefs['extensions.manifestV3.enabled'] = true;
|
|
72
75
|
}
|
|
73
|
-
|
|
74
76
|
const manifestData = await getValidatedManifest(sourceDir);
|
|
75
77
|
const profileDir = firefoxProfile || chromiumProfile;
|
|
76
|
-
|
|
77
78
|
if (profileCreateIfMissing) {
|
|
78
79
|
if (!profileDir) {
|
|
79
80
|
throw new UsageError('--profile-create-if-missing requires ' + '--firefox-profile or --chromium-profile');
|
|
80
81
|
}
|
|
81
|
-
|
|
82
82
|
const isDir = fs.existsSync(profileDir);
|
|
83
|
-
|
|
84
83
|
if (isDir) {
|
|
85
84
|
log.info(`Profile directory ${profileDir} already exists`);
|
|
86
85
|
} else {
|
|
@@ -88,7 +87,6 @@ export default async function run({
|
|
|
88
87
|
await fs.mkdir(profileDir);
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
|
-
|
|
92
90
|
const runners = [];
|
|
93
91
|
const commonRunnerParams = {
|
|
94
92
|
// Common options.
|
|
@@ -101,14 +99,15 @@ export default async function run({
|
|
|
101
99
|
args,
|
|
102
100
|
desktopNotifications
|
|
103
101
|
};
|
|
104
|
-
|
|
105
102
|
if (!target || target.length === 0 || target.includes('firefox-desktop')) {
|
|
106
|
-
const firefoxDesktopRunnerParams = {
|
|
103
|
+
const firefoxDesktopRunnerParams = {
|
|
104
|
+
...commonRunnerParams,
|
|
107
105
|
// Firefox specific CLI options.
|
|
108
106
|
firefoxBinary: firefox,
|
|
109
107
|
profilePath: firefoxProfile,
|
|
110
108
|
customPrefs,
|
|
111
109
|
browserConsole,
|
|
110
|
+
devtools,
|
|
112
111
|
preInstall,
|
|
113
112
|
// Firefox runner injected dependencies.
|
|
114
113
|
firefoxApp,
|
|
@@ -120,9 +119,9 @@ export default async function run({
|
|
|
120
119
|
});
|
|
121
120
|
runners.push(firefoxDesktopRunner);
|
|
122
121
|
}
|
|
123
|
-
|
|
124
122
|
if (target && target.includes('firefox-android')) {
|
|
125
|
-
const firefoxAndroidRunnerParams = {
|
|
123
|
+
const firefoxAndroidRunnerParams = {
|
|
124
|
+
...commonRunnerParams,
|
|
126
125
|
// Firefox specific CLI options.
|
|
127
126
|
profilePath: firefoxProfile,
|
|
128
127
|
customPrefs,
|
|
@@ -160,9 +159,9 @@ export default async function run({
|
|
|
160
159
|
});
|
|
161
160
|
runners.push(firefoxAndroidRunner);
|
|
162
161
|
}
|
|
163
|
-
|
|
164
162
|
if (target && target.includes('chromium')) {
|
|
165
|
-
const chromiumRunnerParams = {
|
|
163
|
+
const chromiumRunnerParams = {
|
|
164
|
+
...commonRunnerParams,
|
|
166
165
|
chromiumBinary,
|
|
167
166
|
chromiumProfile
|
|
168
167
|
};
|
|
@@ -172,13 +171,11 @@ export default async function run({
|
|
|
172
171
|
});
|
|
173
172
|
runners.push(chromiumRunner);
|
|
174
173
|
}
|
|
175
|
-
|
|
176
174
|
const extensionRunner = new MultiExtensionRunner({
|
|
177
175
|
desktopNotifications,
|
|
178
176
|
runners
|
|
179
177
|
});
|
|
180
178
|
await extensionRunner.run();
|
|
181
|
-
|
|
182
179
|
if (noReload) {
|
|
183
180
|
log.info('Automatic extension reloading has been disabled');
|
|
184
181
|
} else {
|
|
@@ -193,7 +190,6 @@ export default async function run({
|
|
|
193
190
|
noInput
|
|
194
191
|
});
|
|
195
192
|
}
|
|
196
|
-
|
|
197
193
|
return extensionRunner;
|
|
198
194
|
}
|
|
199
195
|
//# sourceMappingURL=run.js.map
|