1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add scripts/verify-package-dependencies.js

This commit is contained in:
Nick O'Leary 2018-08-19 00:44:17 +01:00
parent e57d8ba0ef
commit 974ba40f28
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
11 changed files with 1547 additions and 167 deletions

2
.gitignore vendored
View File

@ -18,4 +18,4 @@ public
locales/zz-ZZ
nodes/core/locales/zz-ZZ
!packages/node_modules
packages/node_modules/@node-red/editor/public
packages/node_modules/@node-red/editor-client/public

View File

@ -8,5 +8,3 @@ matrix:
before_script:
- npm install -g istanbul coveralls
- node_js: "8"
- node_js: "6"
- node_js: "4"

View File

@ -303,12 +303,12 @@ module.exports = function(grunt) {
nodemon: {
/* uses .nodemonignore */
dev: {
script: 'red.js',
script: 'packages/node_modules/node-red/red.js',
options: {
args: nodemonArgs,
ext: 'js,html,json',
watch: [
'red','nodes'
'packages/node_modules'
]
}
}
@ -491,6 +491,15 @@ module.exports = function(grunt) {
}
});
grunt.registerTask('verifyPackageDependencies', function() {
var verifyDependencies = require("./scripts/verify-package-dependencies.js");
var failures = verifyDependencies();
if (failures.length > 0) {
failures.forEach(f => grunt.log.error(f));
grunt.fail.fatal("Failed to verify package dependencies");
}
});
grunt.registerTask('setDevEnv',
'Sets NODE_ENV=development so non-minified assets are used',
function () {
@ -499,7 +508,7 @@ module.exports = function(grunt) {
grunt.registerTask('default',
'Builds editor content then runs code style checks and unit tests on all components',
['build','jshint:editor','mocha_istanbul:all']);
['build','verifyPackageDependencies','jshint:editor','mocha_istanbul:all']);
grunt.registerTask('test-core',
'Runs code style check and unit tests on core runtime code',
@ -527,7 +536,7 @@ module.exports = function(grunt) {
grunt.registerTask('release',
'Create distribution zip file',
['build','clean:release','copy:release','chmod:release','compress:release']);
['build','verifyPackageDependencies','clean:release','copy:release','chmod:release','compress:release']);
grunt.registerTask('coverage',
'Run Istanbul code test coverage task',

View File

@ -10,7 +10,7 @@
},
"source": {
"include": [
"./red/runtime-api"
"./packages/node_modules/@node-red/runtime/lib/api"
]
},
"templates": {

1
lib/.gitignore vendored
View File

@ -1 +0,0 @@
*

1586
package-lock.json generated

File diff suppressed because it is too large Load Diff

54
packages/node_modules/node-red/package.json generated vendored Normal file
View File

@ -0,0 +1,54 @@
{
"name": "node-red",
"version": "0.20.0",
"description": "A visual tool for wiring the Internet of Things",
"homepage": "http://nodered.org",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/node-red/node-red.git"
},
"main": "red/red.js",
"scripts": {
"start": "node red.js"
},
"bin": {
"node-red": "./red.js",
"node-red-pi": "bin/node-red-pi"
},
"contributors": [
{
"name": "Nick O'Leary"
},
{
"name": "Dave Conway-Jones"
}
],
"keywords": [
"editor",
"messaging",
"iot",
"flow"
],
"dependencies": {
"@node-red/editor-api": "0.20.0",
"@node-red/runtime": "0.20.0",
"@node-red/util": "0.20.0",
"basic-auth": "2.0.0",
"bcryptjs": "2.4.3",
"express": "4.16.3",
"fs-extra": "5.0.0",
"node-red-node-email": "0.1.*",
"node-red-node-feedparser": "^0.1.12",
"node-red-node-rbe": "0.2.*",
"node-red-node-twitter": "^1.1.0",
"nopt": "4.0.1",
"semver": "5.5.0"
},
"optionalDependencies": {
"bcrypt": "~2.0.0"
},
"engines": {
"node": ">=4"
}
}

View File

@ -24,7 +24,7 @@ catch(e) { bcrypt = require('bcryptjs'); }
var nopt = require("nopt");
var path = require("path");
var fs = require("fs-extra");
var RED = require("./packages/node_modules/node-red/red/red.js");
var RED = require("./red/red.js");
var server;
var app = express();

View File

@ -0,0 +1,46 @@
#!/usr/bin/env node
const path = require("path");
const fs = require("fs");
const should = require("should");
const rootPackage = require(path.join("..","package.json"));
const rootDependencies = rootPackage.dependencies;
const packages = [
"node-red",
"@node-red/editor-api",
"@node-red/editor-client",
"@node-red/nodes",
"@node-red/registry",
"@node-red/runtime",
"@node-red/util"
];
function verifyDependencies() {
let failures = [];
packages.forEach(package => {
let modulePackage = require(path.join("../packages/node_modules",package,"package.json"));
let dependencies = Object.keys(modulePackage.dependencies||{});
dependencies.forEach(module => {
try {
if (!/^@node-red\//.test(module)) {
should.exist(rootDependencies[module],`[${package}] '${module}' missing from root package.json`);
rootDependencies[module].should.eql(modulePackage.dependencies[module],`[${package}] '${module}' version mismatch. Expected '${modulePackage.dependencies[module]}' (got '${rootDependencies[module]}') `);
}
} catch(err) {
failures.push(err.toString());
}
});
})
return failures;
}
if (require.main === module) {
let failures = verifyDependencies();
if (failures.length > 0) {
failures.forEach(f => console.log(` - ${f}`));
process.exit(1);
}
} else {
module.exports = verifyDependencies;
}