Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 6f77738

Browse files
authored
Create devtools-environment (#1063)
1 parent 4d4d3fc commit 6f77738

File tree

12 files changed

+103
-77
lines changed

12 files changed

+103
-77
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
|:----:|:---:|
55
| [![devtools-launchpad-version]][devtools-launchpad-pkg] | [devtools-launchpad] |
66
| [![devtools-config-version]][devtools-config-pkg] | [devtools-config] |
7+
| [![devtools-environment-version]][devtools-environment-pkg] | [devtools-environment] |
78
| [![devtools-connection-version]][devtools-connection-pkg] | [devtools-connection] |
89
| [![devtools-contextmenu-version]][devtools-contextmenu-pkg] | [devtools-contextmenu] |
910
| [![devtools-modules-version]][devtools-modules-pkg] | [devtools-modules] |
@@ -41,6 +42,10 @@ the dependency in the launchpad.
4142
[devtools-config-pkg]:https://npmjs.org/package/devtools-config
4243
[devtools-config]:./packages/devtools-config/#readme
4344

45+
[devtools-environment-version]:https://img.shields.io/npm/v/devtools-environment.svg
46+
[devtools-environment-pkg]:https://npmjs.org/package/devtools-environment
47+
[devtools-environment]:./packages/devtools-environment/#readme
48+
4449
[devtools-modules-version]:https://img.shields.io/npm/v/devtools-modules.svg
4550
[devtools-modules-pkg]:https://npmjs.org/package/devtools-modules
4651
[devtools-modules]:./packages/devtools-modules/#readme

packages/devtools-config/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
All default config values are in [`config/development.json`](./development.json), to override these values you need to [create a local config file](#create-a-local-config-file).
66

77
* *logging*
8-
* `client` Enables logging the Firefox protocol in the devtools console of the debugger
98
* `firefoxProxy` Enables logging the Firefox protocol in the terminal running `npm start`
10-
* `actions` Enables logging the redux actions
11-
* *features* debugger related features
12-
* `tabs` Enables source view tabs in the editor (CodeMirror)
13-
* `sourceMaps` Enables source map loading when available
14-
* `watchExpressions` Enables accordion component for working with watch expressions
159
* *chrome* Chrome browser related flags
1610
* `debug` Enables listening for remotely debuggable Chrome browsers
1711
* `port` web socket port specified when launching Chrome from the command line

packages/devtools-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "devtools-config",
3-
"version": "0.0.15",
3+
"version": "0.0.16",
44
"description": "Devtools Local Configuration System",
55
"main": "index.js",
66
"directories": {

packages/devtools-config/src/feature.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ const fs = require("fs");
77
const path = require("path");
88

99
let config;
10-
11-
const flag = require("./test-flag");
12-
13-
function isBrowser() {
14-
return typeof window == "object" && typeof module == "undefined";
15-
}
16-
1710
/**
1811
* Gets a config value for a given key
1912
* e.g "chrome.webSocketPort"
@@ -26,44 +19,6 @@ function setValue(key, value) {
2619
return put(config, key, value);
2720
}
2821

29-
function isEnabled(key) {
30-
return config.features && typeof config.features[key] == "object"
31-
? config.features[key].enabled
32-
: config.features[key];
33-
}
34-
35-
function isDevelopment() {
36-
if (isBrowser()) {
37-
if (process.env.NODE_ENV === "production") {
38-
return false;
39-
}
40-
const href = window.location ? window.location.href : "";
41-
return href.match(/^file:/) || href.match(/localhost:/);
42-
}
43-
44-
if (isFirefoxPanel()) {
45-
// Default to production if compiling for the Firefox panel
46-
return process.env.NODE_ENV === "development";
47-
}
48-
return process.env.NODE_ENV !== "production";
49-
}
50-
51-
function isTesting() {
52-
return flag.testing;
53-
}
54-
55-
function isFirefoxPanel() {
56-
return process.env.TARGET == "firefox-panel";
57-
}
58-
59-
function isApplication() {
60-
return process.env.TARGET == "application";
61-
}
62-
63-
function isFirefox() {
64-
return /firefox/i.test(navigator.userAgent);
65-
}
66-
6722
function setConfig(value) {
6823
config = value;
6924
}
@@ -80,14 +35,8 @@ function updateLocalConfig(relativePath) {
8035
}
8136

8237
module.exports = {
83-
isEnabled,
8438
getValue,
8539
setValue,
86-
isDevelopment,
87-
isTesting,
88-
isFirefoxPanel,
89-
isApplication,
90-
isFirefox,
9140
getConfig,
9241
setConfig,
9342
updateLocalConfig,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Environment
2+
3+
[![Npm version](https://img.shields.io/npm/v/devtools-environment.svg)](https://npmjs.org/package/devtools-environment)
4+
5+
* `isFirefox` is the tool is running in firefox
6+
* `isFirefoxPanel` - is the tool running in the firefox panel (toolbox)
7+
* `isDevelopment` - is the tool running in the launchpad
8+
* `isTesting` - is the tool running in a mochitest environment
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
4+
5+
const flag = require("./test-flag");
6+
7+
function isBrowser() {
8+
return typeof window == "object";
9+
}
10+
11+
function isNode() {
12+
return process && process.release && process.release.name == 'node'
13+
}
14+
15+
export function isDevelopment() {
16+
if (!isNode() && isBrowser()) {
17+
const href = window.location ? window.location.href : "";
18+
return href.match(/^file:/) || href.match(/localhost:/);
19+
}
20+
21+
return process.env.NODE_ENV != "production";
22+
}
23+
24+
export function isTesting() {
25+
return flag.testing;
26+
}
27+
28+
export function isFirefoxPanel() {
29+
return !isDevelopment();
30+
}
31+
32+
export function isFirefox() {
33+
return /firefox/i.test(navigator.userAgent);
34+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "devtools-environment",
3+
"version": "0.0.4",
4+
"description": "Devtools Environment Check",
5+
"main": "index.js",
6+
"scripts": {},
7+
"author": "",
8+
"license": "MPL-2.0"
9+
}
File renamed without changes.

packages/devtools-launchpad/configs/development.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
"dir": "ltr",
88
"defaultURL": "https://devtools-html.github.io/debugger-examples/",
99
"logging": {
10-
"client": false,
11-
"firefoxProxy": false,
12-
"actions": false
10+
"firefoxProxy": false
1311
},
1412
"development": {
1513
"serverPort": 8000,

packages/devtools-launchpad/package.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
"name": "devtools-launchpad",
33
"version": "0.0.123",
44
"license": "MPL-2.0",
5-
"description":
6-
"The Launchpad makes it easy to build a developer tool for Firefox, Chrome, and Node.",
5+
"description": "The Launchpad makes it easy to build a developer tool for Firefox, Chrome, and Node.",
76
"repository": {
87
"url": "git://github.com/devtools-html/devtools-core.git",
98
"type": "git"
109
},
1110
"bugs": {
1211
"url": "https://github.com/devtools-html/devtools-core/issues"
1312
},
14-
"homepage":
15-
"https://github.com/devtools-html/devtools-core/tree/master/packages/devtools-launchpad#readme",
13+
"homepage": "https://github.com/devtools-html/devtools-core/tree/master/packages/devtools-launchpad#readme",
1614
"scripts": {
1715
"storybook": "start-storybook -p 6006",
1816
"build-storybook": "build-storybook",
@@ -52,9 +50,10 @@
5250
"co": "=4.6.0",
5351
"css-loader": "^0.26.1",
5452
"debug": "^3.1.0",
55-
"devtools-config": "^0.0.15",
53+
"devtools-config": "^0.0.16",
5654
"devtools-connection": "^0.0.9",
5755
"devtools-contextmenu": "^0.0.8",
56+
"devtools-environment": "^0.0.4",
5857
"devtools-mc-assets": "^0.0.5",
5958
"devtools-modules": "^0.0.37",
6059
"devtools-sprintf-js": "^1.0.3",
@@ -80,7 +79,7 @@
8079
"ps-node": "^0.1.4",
8180
"raw-loader": "^0.5.1",
8281
"react": "^16.2.0",
83-
"react-dom":"^16.2.0",
82+
"react-dom": "^16.2.0",
8483
"react-dom-factories": "^1.0.2",
8584
"react-immutable-proptypes": "^2.1.0",
8685
"react-redux": "^5.0.6",
@@ -121,8 +120,14 @@
121120
],
122121
"jest": {
123122
"rootDir": "src",
124-
"testMatch": ["**/tests/**/*.js"],
125-
"testPathIgnorePatterns": ["/node_modules/"],
126-
"transformIgnorePatterns": ["node_modules/(?!devtools-)"]
123+
"testMatch": [
124+
"**/tests/**/*.js"
125+
],
126+
"testPathIgnorePatterns": [
127+
"/node_modules/"
128+
],
129+
"transformIgnorePatterns": [
130+
"node_modules/(?!devtools-)"
131+
]
127132
}
128133
}

0 commit comments

Comments
 (0)