aboutsummaryrefslogtreecommitdiff
path: root/files/ru/mozilla/add-ons/sdk/tools
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
commit074785cea106179cb3305637055ab0a009ca74f2 (patch)
treee6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/ru/mozilla/add-ons/sdk/tools
parentda78a9e329e272dedb2400b79a3bdeebff387d47 (diff)
downloadtranslated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz
translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2
translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip
initial commit
Diffstat (limited to 'files/ru/mozilla/add-ons/sdk/tools')
-rw-r--r--files/ru/mozilla/add-ons/sdk/tools/console/index.html110
-rw-r--r--files/ru/mozilla/add-ons/sdk/tools/index.html10
-rw-r--r--files/ru/mozilla/add-ons/sdk/tools/jpm/index.html497
3 files changed, 617 insertions, 0 deletions
diff --git a/files/ru/mozilla/add-ons/sdk/tools/console/index.html b/files/ru/mozilla/add-ons/sdk/tools/console/index.html
new file mode 100644
index 0000000000..d28b31d127
--- /dev/null
+++ b/files/ru/mozilla/add-ons/sdk/tools/console/index.html
@@ -0,0 +1,110 @@
+---
+title: console
+slug: Mozilla/Add-ons/SDK/Tools/console
+translation_of: Archive/Add-ons/Add-on_SDK/Tools/console
+---
+<p><span class="seoSummary">Enables your add-on to log error, warning or informational messages.</span> If you have started Firefox for your add-on from the command line with <code>cfx run</code> or <code>cfx test</code> then these messages appear in the command shell you used. If the add-on has been installed in Firefox, then the messages appear in the <a href="/en-US/docs/Tools/Browser_Console">Browser Console</a>.</p>
+<p>If you're developing your add-on using the <a href="https://addons.mozilla.org/en-US/firefox/addon/autoinstaller/">Extension Auto-installer</a>, then the add-on is installed in Firefox, meaning that messages will appear in the Browser Console. But see the discussion of <a href="/en-US/Add-ons/SDK/Tools/console#Logging_Levels">logging levels</a>: by default, messages logged using <code>log()</code>, <code>info()</code>, <code>trace()</code>, or <code>warn()</code> won't be logged in these situations.</p>
+<h2 id="Console_Methods">Console Methods</h2>
+<p>All console methods except <code>exception()</code> and <code>trace()</code> accept one or more JavaScript objects as arguments and log them to the console. Depending on the console's underlying implementation and user interface, you may be able to examine the properties of non-primitive objects that are logged.</p>
+<h3 id="console.debug(object_object_...)"><code>console.debug(<em>object</em>[, <em>object</em>, ...])</code></h3>
+<p>Logs the arguments to the console, preceded by "debug:" and the name of your add-on:</p>
+<pre class="brush: js">console.debug("This is a debug message");</pre>
+<pre>debug: my-addon: This is a debug message
+</pre>
+<h3 id="console.error(object_object_...)"><code>console.error(<em>object</em>[, <em>object</em>, ...])</code></h3>
+<p>Logs the arguments to the console, preceded by "error:" and the name of your add-on:<code> </code></p>
+<pre class="brush: js">console.error("This is an error message");</pre>
+<pre>error: my-addon: This is an error message
+</pre>
+<h3 id="console.exception(exception)"><code>console.exception(<em>exception</em>)</code></h3>
+<p>Logs the given exception instance as an error, outputting information about the exception's stack traceback if one is available.</p>
+<pre class="brush: js">try {
+ doThing();
+} catch (e) {
+ console.exception(e);
+}
+
+function UserException(message) {
+ this.message = message;
+ this.name = "UserException";
+}
+
+function doThing() {
+ throw new UserException("Thing could not be done!");
+}</pre>
+<pre>error: my-addon: An exception occurred.
+UserException: Thing could not be done!
+</pre>
+<h3 id="console.info(object_object_...)"><code>console.info(<em>object</em>[, <em>object</em>, ...])</code></h3>
+<p>A synonym for <code>console.log()</code>.</p>
+<h3 id="console.log(object_object_...)"><code>console.log(<em>object</em>[, <em>object</em>, ...])</code></h3>
+<p>Logs the arguments to the console, preceded by "info:" and the name of your add-on:</p>
+<pre class="brush: js">console.log("This is an informational message");</pre>
+<pre>info: my-addon: This is an informational message
+</pre>
+<h3 id="console.time(name)"><code>console.time(name)</code></h3>
+<p>Starts a timer with a name specified as an input parameter. Up to 10,000 simultaneous timers can run on a given page.</p>
+<h3 id="console.timeEnd(name)"><code>console.timeEnd(name)</code></h3>
+<p>Stops the specified timer and logs the elapsed time in seconds since its start. See <a href="https://developer.mozilla.org/en-US/docs/Web/API/console#Timers">Timers</a>.</p>
+<h3 id="console.trace()"><code>console.trace()</code></h3>
+<p>Logs a stack trace at the point the function is called.</p>
+<h3 id="console.warn(object_object_...)"><code>console.warn(<em>object</em>[, <em>object</em>, ...])</code></h3>
+<p>Logs the arguments to the console, preceded by "warn:" and the name of your add-on:<code> </code></p>
+<pre class="brush: js"><code>console.warn("This is a warning message");</code></pre>
+<pre>warn: my-addon: This is a warning message
+</pre>
+<h2 id="Logging_Levels">Logging Levels</h2>
+<p>Logging's useful, of course, especially during development. But the more logging there is, the more noise you see in the console output. Especially when debug logging shows up in a production environment, the noise can make it harder, not easier, to debug issues.</p>
+<p>This is the problem that logging levels are designed to fix. The console defines a number of logging levels, from "more verbose" to "less verbose", and a number of different logging functions that correspond to these levels, which are arranged in order of "severity" from informational messages, through warnings, to errors.</p>
+<p>At a given logging level, only calls to the corresponding functions and functions with a higher severity will have any effect.</p>
+<p>For example, if the logging level is set to "info", then calls to <code>info()</code>, <code>log()</code>, <code>warn()</code>, and <code>error()</code> will all result in output being written. But if the logging level is "warn" then only calls to <code>warn()</code> and <code>error()</code> have any effect, and calls to <code>info()</code> and <code>log()</code> are simply discarded.</p>
+<p>This means that the same code can be more verbose in a development environment than in a production environment - you just need to arrange for the appropriate logging level to be set.</p>
+<p>The complete set of logging levels is given in the table below, along with the set of functions that will result in output at each level:</p>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th>Level</th>
+ <th>Will log calls to:</th>
+ </tr>
+ <tr>
+ <td>all</td>
+ <td>Any console method</td>
+ </tr>
+ <tr>
+ <td>debug</td>
+ <td><code>debug(), error(), exception(), info(), log(), time(), timeEnd(), trace(), warn()</code></td>
+ </tr>
+ <tr>
+ <td>info</td>
+ <td><code>error(), exception(), info(), log(), time(), timeEnd(), trace(), warn()</code></td>
+ </tr>
+ <tr>
+ <td>warn</td>
+ <td><code>error(), exception(), warn()</code></td>
+ </tr>
+ <tr>
+ <td>error</td>
+ <td><code>error(), exception()</code></td>
+ </tr>
+ <tr>
+ <td>off</td>
+ <td>Nothing</td>
+ </tr>
+ </tbody>
+</table>
+<h3 id="Setting_the_Logging_Level">Setting the Logging Level</h3>
+<p>The logging level defaults to "error".</p>
+<p>There are two system preferences that can be used to override this default:</p>
+<ul>
+ <li>
+ <p><strong>extensions.sdk.console.logLevel</strong>: if set, this determines the logging level for all installed SDK-based add-ons.</p>
+ </li>
+ <li>
+ <p><strong>extensions.</strong><em>extensionID</em><strong>.sdk.console.logLevel</strong>, where <em>extensionID</em> is an add-on's <a href="/en-US/Add-ons/SDK/Guides/Program_ID">Program ID</a>. If set, this determines the logging level for the specified add-on. This overrides the global preference if both preferences are set.</p>
+ </li>
+</ul>
+<p>Both these preferences can be set programmatically using the <a href="/en-US/Add-ons/SDK/Low-Level_APIs/preferences_service"><code>preferences/service</code></a> API, or manually using <a href="http://kb.mozillazine.org/About:config">about:config</a>. The value for each preference is the desired logging level, given as a string.</p>
+<p>When you run your add-on using <code>cfx run</code> or <code>cfx test</code>, the global <strong>extensions.sdk.console.logLevel</strong> preference is automatically set to "info". This means that calls to <code>console.log()</code> will appear in the console output.</p>
+<p>When you install an add-on into Firefox, the logging level will be "error" by default (that is, unless you have set one of the two preferences). This means that messages written using <code>debug()</code>, <code>log()</code>, <code>info()</code>, <code>trace()</code>, and <code>warn()</code> will not appear in the console.</p>
+<p>This includes add-ons being developed using the <a href="https://addons.mozilla.org/en-US/firefox/addon/autoinstaller/">Extension Auto-installer</a>.</p>
diff --git a/files/ru/mozilla/add-ons/sdk/tools/index.html b/files/ru/mozilla/add-ons/sdk/tools/index.html
new file mode 100644
index 0000000000..b55c672f17
--- /dev/null
+++ b/files/ru/mozilla/add-ons/sdk/tools/index.html
@@ -0,0 +1,10 @@
+---
+title: Tools
+slug: Mozilla/Add-ons/SDK/Tools
+tags:
+ - NeedsTranslation
+ - TopicStub
+translation_of: Archive/Add-ons/Add-on_SDK/Tools
+---
+<p>Articles listed here provide a reference for the SDK's tools:</p>
+<p>{{ LandingPageListSubpages ("/en-US/Add-ons/SDK/Tools", 5) }}</p>
diff --git a/files/ru/mozilla/add-ons/sdk/tools/jpm/index.html b/files/ru/mozilla/add-ons/sdk/tools/jpm/index.html
new file mode 100644
index 0000000000..dbfacde500
--- /dev/null
+++ b/files/ru/mozilla/add-ons/sdk/tools/jpm/index.html
@@ -0,0 +1,497 @@
+---
+title: jpm
+slug: Mozilla/Add-ons/SDK/Tools/jpm
+translation_of: Archive/Add-ons/Add-on_SDK/Tools/jpm
+---
+<div class="note">
+<p>Вы можете использовать <code>jpm</code> для Firefox 38 или более поздних версий.</p>
+
+<p>Данный материал относится только для jpm.</p>
+</div>
+
+<p><span class="seoSummary">Это Node-ориентированная замена устаревшего <a href="/en-US/Add-ons/SDK/Tools/cfx">cfx</a>. Позволяет тестировать, запускать и создавать дополнения для Firefox.</span></p>
+
+<p>Смотри также <a href="/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29">jpm tutorial</a>.</p>
+
+<p>jpm вызывается через:</p>
+
+<pre class="brush: bash">jpm [command] [options]
+</pre>
+
+<p>jpm поддерживает следующие глобальные опции:</p>
+
+<pre class="brush: bash">-h, --help - show a help message and exit
+-V, --version - print the jpm version number
+</pre>
+
+<h2 id="Установка">Установка</h2>
+
+<p>jpm распространяется с помощью менеджера пакетов <a class="external external-icon" href="https://www.npmjs.org/package/jpm">npm</a>, поэтому чтобы установить jpm, вам необходимо предварительно установить менеджер пакетов npm, если вы этого ещё не сделали. npm входит в Node.js, поэтому чтобы установить npm - посетите <a class="external external-icon" href="http://nodejs.org/">nodejs.org</a> и нажмите кнопку INSTALL.</p>
+
+<p>После этого вы можете установить jpm, как и любой другой npm пакет:</p>
+
+<pre>npm install jpm -g</pre>
+
+<p>В зависимости от настроек и операционной системы, вам может потребоваться запустить его с правами администратора (Linux: Debian, Ubuntu, и т.п.):</p>
+
+<pre class="brush: bash">sudo npm install jpm -g</pre>
+
+<p>После установки введите в командной строке:</p>
+
+<pre class="brush: bash">jpm</pre>
+
+<p>Вы должны увидеть краткое описание доступных команд. Обратите внимание, что в отличие от cfx, jpm доступно из любой запущенной командной строки, в случае, если при установке jpm использовался флаг -g.</p>
+
+<h3 id="Проблемы">Проблемы?</h3>
+
+<p>Если у вас возникли проблемы, то обратитесь за помощью. Пользователи SDK и участники проекта готовы обсудить и предложения в <a class="external external-icon" href="http://groups.google.com/group/mozilla-labs-jetpack/topics">project mailing list</a>. Попробуйте поискать там, возможно похожий вопрос уже обсуждался там. Вы также можете обратиться к пользователям SDK в <a class="external external-icon" href="http://mibbit.com/?channel=%23jetpack&amp;server=irc.mozilla.org">#jetpack</a> на <a class="external external-icon" href="http://irc.mozilla.org/">Mozilla's IRC network</a>.</p>
+
+<h2 id="Справочник_команд">Справочник команд</h2>
+
+<p>В jpm доступно шесть команд:</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td style="width: 20%;"><a href="/en-US/Add-ons/SDK/Tools/jpm#jpm_init"><code>jpm init</code></a></td>
+ <td>Создать каркас дополнения в качестве отправной точки для создания вашего дополнения.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/Add-ons/SDK/Tools/jpm#jpm_run"><code>jpm run</code></a></td>
+ <td>Запустить копию Firefox с установленным дополнением.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/Add-ons/SDK/Tools/jpm#jpm_test"><code>jpm test</code></a></td>
+ <td>Запуск тестирования модуля вашего дополнения.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/Add-ons/SDK/Tools/jpm#jpm_xpi"><code>jpm xpi</code></a></td>
+ <td>Упаковать дополнение в <a href="https://developer.mozilla.org/en/XPI">XPI</a> пакет, формат файла установки для дополнений Firefox.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/Add-ons/SDK/Tools/jpm#jpm_post"><code>jpm post</code></a></td>
+ <td>Упаковать дополнение в пакет <a href="https://developer.mozilla.org/en/XPI">XPI</a> и отправить на URL.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/Add-ons/SDK/Tools/jpm#jpm_watchpost"><code>jpm watchpost</code></a></td>
+ <td>Упаковывать дополнение в пакет <a href="https://developer.mozilla.org/en/XPI">XPI</a> и отправлять на URL при каждом изменении файла.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_init">jpm init</h3>
+
+<p>Данная команда инициализирует новое дополнение, с нуля.</p>
+
+<p>Для этого создайте новый каталог, перейдите в него и запустите <code>jpm init</code>.</p>
+
+<pre class="brush: bash">mkdir my-addon
+cd my-addon
+jpm init</pre>
+
+<p>Вам будет предложено указать некоторую информацию о вашем дополнении: данная информация будет использована для создания файла настроек дополнения <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json">package.json</a>.</p>
+
+<ul>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#title">title</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#name">name</a>: По умолчанию это имя каталога, в котором была запущена команда jpm init. За исключнием случаев, когда  заполненно поле <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#id"><code>id</code></a>  в файле package.json, тогда jpm добавит указатель "@" перед именем и использует в качестве него  значение  поля <a href="https://developer.mozilla.org/en-US/Add-ons/Install_Manifests#id"><code>id</code> field in the add-on's install manifest</a>.</li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#version">version</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#description">description</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#main">entry point</a> (which maps to "main" in package.json)</li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#author">author</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#engines">engines</a> (supported applications)</li>
+ <li><a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#license">license</a></li>
+</ul>
+
+<p>Большинство из этих полей имеют значения по умолчанию, который указан в скобках после вопроса. Если вы просто нажмите Enter, то в настройках будет указано значение по умолчанию.</p>
+
+<p>После того как вы укажете значения или выберите значение по умолчанию для этих свойств, вам будет показано полное содержание "package.json" и предложено принять его.</p>
+
+<p>После jpm создаст каркас дополнения в качестве отправной точки для разрабатываемого вами дополнения, со следующей структурой файлов:</p>
+
+<ul class="directory-tree">
+ <li>my-addon
+ <ul>
+ <li>index.js</li>
+ <li>package.json</li>
+ <li>test
+ <ul>
+ <li>test-index.js</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+</ul>
+
+<h3 id="jpm_run">jpm run</h3>
+
+<p>Эта команда запускает новый экземпляр Firefox с подключенным дополнением:</p>
+
+<pre class="brush: bash">jpm run</pre>
+
+<p><code>jpm run</code> принимает следующие значения:</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td style="width: 30%;"><code>-b --binary BINARY</code></td>
+ <td>
+ <p>Use the version of Firefox specified in BINARY. BINARY may be specified as a full path or as a path relative to the current directory.</p>
+
+ <pre class="brush: bash">
+jpm run -b /path/to/Firefox/Nightly</pre>
+ See <a href="/en-US/Add-ons/SDK/Tools/jpm#Selecting_a_browser_version">Selecting a browser version</a>.</td>
+ </tr>
+ <tr>
+ <td><code>--binary-args CMDARGS</code></td>
+ <td>
+ <p>Pass <a href="/en-US/docs/Mozilla/Command_Line_Options">extra arguments</a> to Firefox.</p>
+
+ <p>For example, to pass the <code>-jsconsole</code> argument to Firefox, which will launch the <a href="/en-US/docs/Tools/Browser_Console">Browser Console</a>, try the following:</p>
+
+ <pre class="brush: bash">
+jpm run --binary-args -jsconsole</pre>
+
+ <p>To pass multiple arguments, or arguments containing spaces, quote them:</p>
+
+ <pre class="brush: bash">
+jpm run --binary-args '-url mzl.la -jsconsole'</pre>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--debug</code></td>
+ <td>Run the <a href="/en-US/Add-ons/Add-on_Debugger">add-on debugger</a> attached to the add-on.</td>
+ </tr>
+ <tr>
+ <td><code>-o --overload PATH</code></td>
+ <td>
+ <p>Rather than use the SDK modules built into Firefox, use the modules found at PATH. If <code>-o</code> is specified and PATH is omitted, jpm will look for the JETPACK_ROOT environment variable and use its value as the path.</p>
+
+ <p>See <a href="/en-US/Add-ons/SDK/Tools/jpm#Overloading_the_built-in_modules">Overloading the built-in modules</a> for more information.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-p --profile=<code> PROFILE</code></code></td>
+ <td>
+ <p>By default, jpm uses a clean temporary Firefox <a href="http://support.mozilla.com/en-US/kb/profiles">profile</a> each time you call jpm run. Use the <code>--profile</code> option to instruct jpm to launch Firefox with an existing profile.</p>
+
+ <p>The PROFILE value may be a profile name or the path to the profile.</p>
+
+ <p>See <a href="/en-US/Add-ons/SDK/Tools/jpm#Using_profiles">Using profiles</a> for more information.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-v --verbose</code></td>
+ <td>Verbose operation.</td>
+ </tr>
+ <tr>
+ <td><code>--no-copy</code></td>
+ <td>
+ <div class="warning">Use with caution because <code>jpm run|test</code> changes many preferences, never use with your main profile.</div>
+
+ <div class="note">This only applies when <code>--profile</code> is used.</div>
+ Disables the copying of the profile used, which allows one to reuse a profile.</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_test">jpm test</h3>
+
+<p>Команда запускает тестирование дополнения. Происходит следующее:</p>
+
+<ul>
+ <li>Обзор каталога с именем "test" в корневом каталоге дополнения</li>
+ <li>Открывается каждый файл, имя которого начинается с "test-" в этом каталоге (обратите внимание на дефис после слова "test" в имени jpm файла - в тест будет включён файл вида "test-myCode.js", но исключены файлы вида "test_myCode.js" или "testMyCode.js"</li>
+ <li>Вызываются все функции, извлечённые из файла, имя которого начинается с "test"</li>
+</ul>
+
+<pre class="brush: bash">jpm test
+</pre>
+
+<p>See the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Unit_testing">tutorial on unit testing</a> and the <a href="https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/test_assert">reference documentation for the <code>assert</code> module</a> for more details on this.</p>
+
+<p><code>jpm test</code> accepts the following options:</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td><code>-b --binary BINARY</code></td>
+ <td>
+ <p>Use the version of Firefox specified in BINARY. BINARY may be specified as a full path or as a path relative to the current directory.</p>
+
+ <pre class="brush: bash">
+jpm test -b /path/to/Firefox/Nightly</pre>
+
+ <p>See <a href="/en-US/Add-ons/SDK/Tools/jpm#Selecting_a_browser_version">Selecting a browser version</a>.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--binary-args CMDARGS</code></td>
+ <td>
+ <p>Pass <a href="http://kb.mozillazine.org/Command_line_arguments">extra arguments</a> to Firefox.</p>
+
+ <p>For example, to pass the <code>-jsconsole</code> argument to Firefox, which will launch the <a href="/en-US/docs/Tools/Browser_Console">Browser Console</a>, try the following:</p>
+
+ <pre class="brush: bash">
+jpm test --binary-args -jsconsole</pre>
+
+ <p>To pass multiple arguments, or arguments containing spaces, quote them:</p>
+
+ <pre class="brush: bash">
+jpm test --binary-args '-url mzl.la -jsconsole'</pre>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--debug</code></td>
+ <td>Run the <a href="/en-US/Add-ons/Add-on_Debugger">add-on debugger</a> attached to the add-on.</td>
+ </tr>
+ <tr>
+ <td style="width: 30%;"><code>-f --filter FILE[:TEST]</code></td>
+ <td>
+ <p>Only run tests whose filenames match FILE and optionally match TEST, both regexps.</p>
+
+ <pre class="brush: bash">
+jpm test --filter base64:btoa</pre>
+
+ <p>The above command only runs tests in files whose names contain "base64", and in those files only runs tests whose names contain "btoa".</p>
+ </td>
+ </tr>
+ <tr>
+ <td style="width: 30%;"><code>-o --overload PATH</code></td>
+ <td>
+ <p>Rather than use the SDK modules built into Firefox, use the modules found at PATH. If <code>-o</code> is specified and PATH is omitted, jpm will look for the JETPACK_ROOT environment variable and use its value as the path.</p>
+
+ <p>See <a href="/en-US/Add-ons/SDK/Tools/jpm#Overloading_the_built-in_modules">Overloading the built-in modules</a> for more information.</p>
+ </td>
+ </tr>
+ <tr>
+ <td style="width: 30%;"><code>-p --profile<code> PROFILE</code></code></td>
+ <td>
+ <p>By default, jpm uses a clean temporary Firefox <a href="http://support.mozilla.com/en-US/kb/profiles">profile</a> each time you call jpm run. Use the <code>--profile</code> option to instruct jpm to launch Firefox with an existing profile.</p>
+
+ <p>The PROFILE value may be a profile name or the path to the profile.</p>
+
+ <p>See <a href="/en-US/Add-ons/SDK/Tools/jpm#Using_profiles">Using profiles</a> for more information.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--stop-on-error</code></td>
+ <td>
+ <p>By default jpm test keeps running tests even after tests fail. Specify <code>--stop-on-error</code> to stop running tests after the first failure:</p>
+
+ <pre class="brush: bash">
+jpm test --stop-on-error</pre>
+ </td>
+ </tr>
+ <tr>
+ <td><code>--tbpl</code></td>
+ <td>Print test output in <a href="https://treeherder.mozilla.org/">Treeherder</a> format</td>
+ </tr>
+ <tr>
+ <td><code>--times NUMBER</code></td>
+ <td>
+ <p>Run tests NUMBER of times:</p>
+
+ <pre class="brush: bash">
+jpm test --times 2</pre>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-v --verbose</code></td>
+ <td>Verbose operation.</td>
+ </tr>
+ <tr>
+ <td><code>--no-copy</code></td>
+ <td>
+ <div class="warning">Use with caution because <code>jpm run|test</code> changes many preferences, never use with your main profile.</div>
+
+ <div class="note">This only applies when <code>--profile</code> is used.</div>
+ Disables the copying of the profile used, which allows one to reuse a profile.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_xpi">jpm xpi</h3>
+
+<p>Эта команда собирает дополнение в пакет XPI. Это формат дополнений, которые можно легко установить Mozilla.</p>
+
+<pre class="brush: bash">jpm xpi</pre>
+
+<p>It looks for a file called <code>package.json</code> in the current directory and creates the corresponding XPI file. It ignores any ZIPs or XPIs in the add-on's root, and any test files.</p>
+
+<p>Once you have built an XPI file you can distribute your add-on by submitting it to <a href="http://addons.mozilla.org">addons.mozilla.org</a>.</p>
+
+<p><code>jpm xpi</code> accepts the following option:</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td><code>-v --verbose</code></td>
+ <td>
+ <p>Verbose operation:</p>
+
+ <pre class="brush: bash">
+jpm xpi -v</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_post">jpm post</h3>
+
+<p>This command packages the add-on as an <a href="https://developer.mozilla.org/en/XPI">XPI</a> file, the posts it to some url.</p>
+
+<pre class="brush: bash">jpm post</pre>
+
+<p>It looks for a file called <code>package.json</code> in the current directory and creates a XPI file with which to post to the <code>--post-url</code>.</p>
+
+<p><code>jpm post</code> accepts the following options:</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td><code>--post-url URL</code></td>
+ <td>
+ <p>The url to post the extension to after creating a XPI.</p>
+
+ <pre class="brush: bash">
+jpm post --post-url http://localhost:8888/</pre>
+
+ <p>See <a href="https://www.npmjs.com/package/jpm#using-post-and-watchpost">Using Post and Watchpost</a> for more information.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-v --verbose</code></td>
+ <td>
+ <p>Verbose operation:</p>
+
+ <pre class="brush: bash">
+jpm post --post-url http://localhost:8888/ -v</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="jpm_watchpost">jpm watchpost</h3>
+
+<p>This command packages the add-on as an <a href="https://developer.mozilla.org/en/XPI">XPI</a> file, the posts it to some url whenever a file in the current working directory changes.</p>
+
+<pre class="brush: bash">jpm watchpost</pre>
+
+<p>Creates a XPI whenever a file in the current working directory changes and posts that to the <code>--post-url</code>.</p>
+
+<p><code>jpm watchpost</code> accepts the following options:</p>
+
+<table class="fullwidth-table standard-table">
+ <tbody>
+ <tr>
+ <td><code>--post-url URL</code></td>
+ <td>
+ <p>The url to post the extension to after creating a XPI.</p>
+
+ <pre class="brush: bash">
+jpm watchpost --post-url http://localhost:8888/</pre>
+
+ <p>See <a href="https://www.npmjs.com/package/jpm#using-post-and-watchpost">Using Post and Watchpost</a> for more information.</p>
+ </td>
+ </tr>
+ <tr>
+ <td><code>-v --verbose</code></td>
+ <td>
+ <p>Verbose operation:</p>
+
+ <pre class="brush: bash">
+jpm watchpost --post-url http://localhost:8888/ -v</pre>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Techniques">Techniques</h2>
+
+<h3 id="Selecting_a_browser_version">Selecting a browser version</h3>
+
+<p>By default, <code>jpm run</code> and <code>jpm test</code> will run the release version of Firefox. You can instruct jpm to use a different version in one of two ways:</p>
+
+<ul>
+ <li>
+ <p>you can use the <code>-b</code> or <code>--binary</code> option to instruct jpm to run a different version of Firefox. You can supply a path to a specific binary:</p>
+
+ <pre class="brush: bash">jpm run -b /path/to/Firefox/Nightly</pre>
+
+ <p>As a shorthand for this, you can pass "nightly", "aurora", "beta", or "firefox" and jpm will look in the default location for these Firefox versions:</p>
+
+ <pre class="brush: bash">jpm run -b nightly</pre>
+ </li>
+ <li>
+ <p>you can set the <code>JPM_FIREFOX_BINARY</code> environment variable with the path to the version of Firefox you want to run. When you invoke <code>jpm run</code> or <code>jpm test</code> without the <code>-b</code> option, jpm will first check  <code>JPM_FIREFOX_BINARY</code>, and use this as the path if it is set.</p>
+ </li>
+</ul>
+
+<h3 id="Using_.jpmignore_to_ignore_files">Using <code>.jpmignore</code> to ignore files</h3>
+
+<p>Using <code>.jpmignore</code> is similar to using <code>.gitignore</code> with <code>git</code>, <code>.hgignore</code> with Mercurial, or <code>.npmignore</code> with <code>npm</code>. By using this file you can let <code>jpm</code> know which files you would like it to ignore when building a <code>.xpi</code> file with <code>jpm xpi</code>.</p>
+
+<p>Here is an example:</p>
+
+<pre class="brush: bash"># Ignore .DS_Store files created by mac
+.DS_Store
+
+# Ignore any zip or xpi files
+*.zip
+*.xpi
+</pre>
+
+<p>A <code>.jpmignore</code> file with the above contents would ignore all zip files and <code>.DS_Store</code> files from the xpi generated by <code>jpm xpi</code>.</p>
+
+<h3 id="Using_profiles_2"><a name="Using_profiles">Using profiles</a></h3>
+
+<p>By default, <code>jpm run</code> uses a new profile each time it is executed. This means that any profile-specific data entered from one run of <code>jpm</code> will not, by default, be available in the next run.</p>
+
+<p>This includes, for example, any extra add-ons you installed, or your history, or any data stored using the <a href="/en-US/Add-ons/SDK/High-Level_APIs/simple-storage">simple-storage</a> API.</p>
+
+<p>To make <code>jpm</code> use a specific profile, pass the <code>--profile</code> option, specifying the name of the profile you wish to use, or the path to the profile.</p>
+
+<pre class="brush: bash">jpm run --profile boogaloo
+</pre>
+
+<pre class="brush: bash">jpm run --profile path/to/boogaloo</pre>
+
+<p>If you supply <code>--profile</code> but its argument is not the name of or path to an existing profile, jpm will open the <a href="https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles">profile manager</a>,  enabling you to select and existing profile or create a new one:</p>
+
+<pre class="brush: bash">jpm run --profile i-dont-exist</pre>
+
+<h3 id="Developing_without_browser_restarts">Developing without browser restarts</h3>
+
+<p>Because <code>jpm run</code> restarts the browser each time you invoke it, it can be a little cumbersome if you are making very frequent changes to an add-on. An alternative development model is to use the <a href="https://addons.mozilla.org/en-US/firefox/addon/autoinstaller/" rel="noreferrer">Extension Auto-Installer</a> add-on: this listens for new XPI files on a specified port and installs them automatically. That way you can test new changes without needing to restart the browser:</p>
+
+<ul>
+ <li>make a change to your add-on</li>
+ <li>run <code>jpm post --post-url http://localhost:8888/</code>, to make a xpi and post it.</li>
+</ul>
+
+<p>You could even automate this workflow with a simple script. For example:</p>
+
+<pre class="brush: bash">jpm watchpost --post-url http://localhost:8888/
+</pre>
+
+<p>Note that the logging level defined for the console is different when you use this method, compared to the logging level used when an add-on is run using <code>jpm run</code>. This means that if you want to see output from <a href="/en-US/Add-ons/SDK/Tutorials/Logging" rel="noreferrer"><code>console.log()</code></a> messages, you'll have to tweak a setting. See the documentation on <a href="/en-US/Add-ons/SDK/Tools/console#Logging_Levels" rel="noreferrer">logging levels</a> for the details on this.</p>
+
+<h3 id="Overloading_the_built-in_modules">Overloading the built-in modules</h3>
+
+<p>The SDK modules you use to implement your add-on are built into Firefox. When you run or package an add-on using <code>jpm run</code> or <code>jpm xpi</code>, the add-on will use the versions of the modules in the version of Firefox that hosts it.</p>
+
+<p>As an add-on developer, this is usually what you want. But if you're developing the SDK modules themselves, of course, it isn't. In this case you need to:</p>
+
+<ul>
+ <li>get a local copy of the SDK modules that you want: this usually means checking out the SDK from its <a href="https://github.com/mozilla/addon-sdk" rel="noreferrer">GitHub repo</a></li>
+ <li>set the <code>JETPACK_ROOT</code> environment variable to your local copy</li>
+ <li>pass the <code>-o</code> option to <code>jpm run</code> or <code>jpm xpi</code>:</li>
+</ul>
+
+<pre>jpm run -o
+</pre>
+
+<p>This instructs jpm to use the local copies of the SDK modules, not the ones in Firefox. If you don't want to set the <code>JETPACK_ROOT</code> environment variable, you can pass the location of your copy of the SDK modules along with <code>-o</code>:</p>
+
+<pre>jpm run -o "/path/to/SDK/"</pre>