Switch to Neutrino 9 RC3
This commit is contained in:
Родитель
82f085a03e
Коммит
f12f1a040b
|
@ -1,5 +1,3 @@
|
|||
const { Neutrino } = require('neutrino');
|
||||
const neutrino = require('neutrino');
|
||||
|
||||
module.exports = Neutrino({ root: __dirname })
|
||||
.use('.neutrinorc.js')
|
||||
.call('eslintrc');
|
||||
module.exports = neutrino().eslintrc();
|
|
@ -0,0 +1,5 @@
|
|||
const neutrino = require('neutrino');
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'test';
|
||||
|
||||
module.exports = neutrino().mocha();
|
|
@ -1,49 +1,41 @@
|
|||
const airbnbBase = require('@neutrinojs/airbnb-base');
|
||||
const node = require('@neutrinojs/node');
|
||||
const mocha = require('@neutrinojs/mocha');
|
||||
|
||||
module.exports = {
|
||||
options: {
|
||||
mains: {
|
||||
index: 'index',
|
||||
nimbledroid: 'scripts/fetchNimbledroidData.js',
|
||||
}
|
||||
},
|
||||
root: __dirname,
|
||||
},
|
||||
use: [
|
||||
[
|
||||
'@neutrinojs/airbnb-base',
|
||||
{
|
||||
eslint: {
|
||||
rules: {
|
||||
"no-console": 0,
|
||||
"no-await-in-loop": 0,
|
||||
"no-param-reassign": 0,
|
||||
"no-return-assign": 0,
|
||||
"guard-for-in": 0,
|
||||
"no-restricted-syntax": 0,
|
||||
"no-loop-func": 0,
|
||||
"import/prefer-default-export": 0,
|
||||
"no-mixed-operators": 0,
|
||||
"no-unused-vars": 0,
|
||||
"prefer-destructuring": 0
|
||||
}
|
||||
airbnbBase({
|
||||
eslint: {
|
||||
rules: {
|
||||
"no-console": 0,
|
||||
"no-await-in-loop": 0,
|
||||
"no-param-reassign": 0,
|
||||
"no-return-assign": 0,
|
||||
"guard-for-in": 0,
|
||||
"no-restricted-syntax": 0,
|
||||
"no-loop-func": 0,
|
||||
"import/prefer-default-export": 0,
|
||||
"no-mixed-operators": 0,
|
||||
"no-unused-vars": 0,
|
||||
"prefer-destructuring": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'@neutrinojs/node',
|
||||
{
|
||||
// https://github.com/mozilla-neutrino/neutrino-dev/issues/984#issuecomment-402799699
|
||||
// fast-sync is giving trouble but we don't need it
|
||||
polyfills: {
|
||||
async: false,
|
||||
},
|
||||
html: {
|
||||
title: 'Firefox health backend'
|
||||
},
|
||||
}
|
||||
],
|
||||
[
|
||||
'@neutrinojs/mocha', {
|
||||
exit: true,
|
||||
recursive: true,
|
||||
}
|
||||
],
|
||||
}),
|
||||
node({
|
||||
html: {
|
||||
title: 'Firefox health backend'
|
||||
},
|
||||
}),
|
||||
mocha({
|
||||
exit: true,
|
||||
recursive: true,
|
||||
}),
|
||||
]
|
||||
};
|
||||
|
|
12
README.md
12
README.md
|
@ -8,17 +8,21 @@ For the frontend code visit the [Firefox health dashboard](https://github.com/mo
|
|||
## Requirements
|
||||
|
||||
* Node
|
||||
* Yarn (recommended)
|
||||
* Yarn
|
||||
* Docker OR redis
|
||||
|
||||
## Setting project up
|
||||
|
||||
In your console:
|
||||
```
|
||||
|
||||
```shell
|
||||
docker run -p 6379:6379 -d redis
|
||||
yarn // To get the dependencies installed
|
||||
yarn start // To start the server
|
||||
```
|
||||
|
||||
### Enable access to Nimbledroid's data
|
||||
|
||||
Nimbledroid provides us with performance data for various sites on Android.
|
||||
If you want to make changes to the Nimbledroid APIs on the backend you will need
|
||||
to have access to our corporate Nimbledroid account.
|
||||
|
@ -28,7 +32,7 @@ Once you have access you can fetch your personal key (keep private) under your
|
|||
|
||||
Once you have it you can start the backend like this:
|
||||
|
||||
```
|
||||
```shell
|
||||
export NIMBLEDROID_API_KEY=<API key>
|
||||
export NIMBLEDROID_EMAIL=<your email address>
|
||||
export REDIS_URL=redis://localhost:6379
|
||||
|
@ -82,4 +86,4 @@ If everything works, load the Nimbledroid APKs directly and inspect the output.
|
|||
|
||||
## Attributions
|
||||
|
||||
- heartbeat icon by Creative Stall from the Noun Project
|
||||
* heartbeat icon by Creative Stall from the Noun Project
|
||||
|
|
37
package.json
37
package.json
|
@ -4,22 +4,22 @@
|
|||
"description": "Firefox Health backend",
|
||||
"main": "build/index.js",
|
||||
"scripts": {
|
||||
"test:src": "neutrino test",
|
||||
"test:lint": "neutrino lint",
|
||||
"coverage": "nyc neutrino test && nyc report --reporter=text-lcov | coveralls",
|
||||
"test:src": "mocha",
|
||||
"test:lint": "eslint --cache --format codeframe --ext mjs,jsx,js src test",
|
||||
"coverage": "nyc yarn test:src && nyc report --reporter=text-lcov | coveralls",
|
||||
"test": "npm-run-all --parallel test:*",
|
||||
"watch": "neutrino test --watch",
|
||||
"build": "neutrino build",
|
||||
"start": "neutrino start",
|
||||
"start:prod": "neutrino build && node .",
|
||||
"start:debugger": "neutrino build && node --inspect .",
|
||||
"watch": "mocha test --watch",
|
||||
"build": "webpack --mode production",
|
||||
"start": "webpack --watch --mode development",
|
||||
"start:prod": "yarn build && node .",
|
||||
"start:debugger": "yarn build && node --inspect .",
|
||||
"precommit": "lint-staged",
|
||||
"heroku-postbuild": "npm run build",
|
||||
"fetchNimbledroidData": "neutrino build && node build/nimbledroid.js"
|
||||
"heroku-postbuild": "yarn build",
|
||||
"fetchNimbledroidData": "yarn build && node build/nimbledroid.js"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"neutrino lint"
|
||||
"yarn test:lint"
|
||||
]
|
||||
},
|
||||
"author": "Harald Kirschner <npm@digitarald.com> (http://digitarald.de/)",
|
||||
|
@ -40,18 +40,23 @@
|
|||
"simple-statistics": "^5.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@neutrinojs/airbnb-base": "^8.3.0",
|
||||
"@neutrinojs/mocha": "^8.3.0",
|
||||
"@neutrinojs/node": "^8.3.0",
|
||||
"@neutrinojs/airbnb-base": "9.0.0-rc.3",
|
||||
"@neutrinojs/mocha": "9.0.0-rc.3",
|
||||
"@neutrinojs/node": "9.0.0-rc.3",
|
||||
"coveralls": "^3.0.0",
|
||||
"eslint": "^5",
|
||||
"fetch-mock": "^6.5.0",
|
||||
"husky": "^0.14.3",
|
||||
"lint-staged": "^7.0.5",
|
||||
"mocha": "^6.0.0",
|
||||
"mocha-lcov-reporter": "^1.3.0",
|
||||
"neutrino": "^8.3.0",
|
||||
"neutrino": "9.0.0-rc.3",
|
||||
"npm-run-all": "^4.1.3",
|
||||
"nyc": "^11.1.0",
|
||||
"source-map-support": "^0.5.3",
|
||||
"supertest": "^3.0.0"
|
||||
"supertest": "^3.0.0",
|
||||
"webpack": "^4",
|
||||
"webpack-cli": "^3",
|
||||
"webpack-dev-server": "^3"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,15 +11,15 @@ router
|
|||
if (!process.env.NIMBLEDROID_API_KEY || !process.env.NIMBLEDROID_EMAIL) {
|
||||
ctx.throw(
|
||||
400,
|
||||
'You need to set Nimbledroid authentication for this endpoint to work. ' +
|
||||
`More info in ${README_URL}`,
|
||||
'You need to set Nimbledroid authentication for this endpoint to work. '
|
||||
+ `More info in ${README_URL}`,
|
||||
);
|
||||
}
|
||||
if (!process.env.REDIS_URL) {
|
||||
ctx.throw(
|
||||
400,
|
||||
'You need to run Redis for this endpoint to work. ' +
|
||||
`More info in ${README_URL}`,
|
||||
'You need to run Redis for this endpoint to work. '
|
||||
+ `More info in ${README_URL}`,
|
||||
);
|
||||
}
|
||||
const { product } = ctx.request.query;
|
||||
|
|
|
@ -43,7 +43,7 @@ export async function getEvolution(query) {
|
|||
key,
|
||||
evolution: evolutionMap[key].sanitized(),
|
||||
}));
|
||||
} else if (evolutionMap['']) {
|
||||
} if (evolutionMap['']) {
|
||||
return evolutionMap[''].sanitized();
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -7,9 +7,9 @@ const infoLog = debug('script:info');
|
|||
const errorLog = debug('script:error');
|
||||
|
||||
if (
|
||||
!process.env.REDIS_URL ||
|
||||
!process.env.NIMBLEDROID_API_KEY ||
|
||||
!process.env.NIMBLEDROID_EMAIL
|
||||
!process.env.REDIS_URL
|
||||
|| !process.env.NIMBLEDROID_API_KEY
|
||||
|| !process.env.NIMBLEDROID_EMAIL
|
||||
) {
|
||||
throw Error('You need to set NIMBLEDROID_EMAIL, NIMBLEDROID_API_KEY and REDIS_URL');
|
||||
}
|
||||
|
@ -47,12 +47,10 @@ const storeProfilingRunIfMissing = async (profilingRunData) => {
|
|||
};
|
||||
|
||||
const storeDataInRedis = async (data) => {
|
||||
await Promise.all(Object.keys(data).map(index =>
|
||||
storeProfilingRunIfMissing(data[index])));
|
||||
await Promise.all(Object.keys(data).map(index => storeProfilingRunIfMissing(data[index])));
|
||||
};
|
||||
|
||||
const fetchData = async productName =>
|
||||
nimbledroidClient.getNimbledroidData(productName);
|
||||
const fetchData = async productName => nimbledroidClient.getNimbledroidData(productName);
|
||||
|
||||
const main = async () => {
|
||||
let errorCode = -1;
|
||||
|
|
|
@ -47,8 +47,7 @@ const processedData = (data, packageId) => {
|
|||
|
||||
const queryNimbledroidData = async (product) => {
|
||||
const cachedKeys = await client.keys(`cache:*nimble*${product}/apks/*`);
|
||||
const data = await Promise.all(cachedKeys.map(async key =>
|
||||
JSON.parse(await client.get(key))));
|
||||
const data = await Promise.all(cachedKeys.map(async key => JSON.parse(await client.get(key))));
|
||||
if (data.length === 0) {
|
||||
throw Error('The script that fetches data should have run before hitting the API.');
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// Whilst the configuration object can be modified here, the recommended way of making
|
||||
// changes is via the presets' options or Neutrino's API in `.neutrinorc.js` instead.
|
||||
// Neutrino's inspect feature can be used to view/export the generated configuration.
|
||||
const neutrino = require('neutrino');
|
||||
|
||||
module.exports = neutrino().webpack();
|
4732
yarn.lock
4732
yarn.lock
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче