Skip to content

Commit

Permalink
Changed dependency to webgme-engine. Fixes#216 (#215)
Browse files Browse the repository at this point in the history
* WIP use webgme-engine as dep, tests are running but some failing

* WIP comment out no longer applicable test

* WIP Add back test and fix it

* Bump version to 2.4.1-beta1

* WIP Add webgme as a dev-dep for testing generated files

* WIP added test for missing seed file

* WIP fixed test seed path

* WIP don't remove non-existent dir on failed new seed

* WIP log output/error with build script

* WIP renamed non-existent file

* WIP fixed conflicting seed name

* WIP v0.12.7 support
  • Loading branch information
Patrik Meijer authored and brollb committed Oct 9, 2017
1 parent 0b9d499 commit fa7bb87
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ build/Release
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
tmp/

# IDE stuff
.idea
4 changes: 3 additions & 1 deletion bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ var spawnSync = require('child_process').spawnSync,
srcRoot = path.join(root, from);

// Compile back to ES5
spawnSync('node', [babelPath, from, '-d', to]);
var res = spawnSync('node', [babelPath, from, '-d', to]);
console.log(res.stdout.toString());
console.error(res.stderr.toString());

// Copy the non-js files
deeplist(srcRoot)
Expand Down
4 changes: 3 additions & 1 deletion bin/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ var spawnSync = require('child_process').spawnSync,
path = require('path');

// Run the build on the src
spawnSync('node', [path.join(__dirname, 'build.js'), 'src', 'lib']);
var res = spawnSync('node', [path.join(__dirname, 'build.js'), 'src', 'lib']);
console.log(res.stdout.toString());
console.error(res.stderr.toString());

// Print message about the argument completion
console.log('Note: Autocomplete for bash can be enabled with:\n\n' +
Expand Down
2 changes: 1 addition & 1 deletion bin/webgme-info
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var pkgJson = require(dirname + '/../package.json'),
versions.cli = pkgJson.version;

// cli tool's webgme
pkgJson = require(dirname + '/../node_modules/webgme/package.json');
pkgJson = require(dirname + '/../node_modules/webgme-engine/package.json');
versions['cli-webgme'] = pkgJson.version;

// webgme in given project
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webgme-cli",
"version": "2.4.0",
"version": "2.4.1-beta1",
"description": "Command line interface for managing WebGME apps",
"main": "index.js",
"bin": {
Expand Down Expand Up @@ -46,7 +46,7 @@
"ramda": "^0.15.1",
"requirejs": "^2.1.18",
"rimraf": "^2.4.0",
"webgme": "^2.0.0"
"webgme-engine": "^2.0.0"
},
"devDependencies": {
"chai": "^3.0.0",
Expand All @@ -55,6 +55,7 @@
"istanbul": "^0.3.17",
"mocha": "^2.2.5",
"sinon": "^1.15.4",
"sinon-chai": "^2.8.0"
"sinon-chai": "^2.8.0",
"webgme": "^2.0.0"
}
}
2 changes: 1 addition & 1 deletion src/AddonManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var _ = require('lodash'),
AddonGenerator = require('./shim/AddonGenerator'),
Enableable = require('./mixins/Enableable/Enableable'),
PluginHelpers = require('./shim/PluginHelpers'),
metadata = require('webgme/src/plugin/coreplugins/AddOnGenerator/metadata.json'),
metadata = require('webgme-engine/src/plugin/coreplugins/AddOnGenerator/metadata.json'),
RAW_CONFIG = metadata.configStructure;

var AddonManager = function(logger) {
Expand Down
4 changes: 2 additions & 2 deletions src/BaseManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ BaseManager.prototype.start = function (options, callback) {
};

BaseManager.prototype._start = function (root, callback) {
var webgmePath = path.join(root, 'node_modules', 'webgme');
var webgmePath = path.join(root, 'node_modules', 'webgme-engine');
npm.load({}, err => {
if (err) {
return callback(err);
Expand Down Expand Up @@ -132,7 +132,7 @@ BaseManager.prototype._createPkgJson = function(project, name) {
toolJsonPath = path.join(__dirname, '..', 'package.json'),
toolJson = require(toolJsonPath),
pkgContent = {
webgmeVersion: toolJson.dependencies.webgme,
webgmeVersion: toolJson.dependencies['webgme-engine'],
name: name
},
outputPkgJson = path.join(project, 'package.json'),
Expand Down
2 changes: 1 addition & 1 deletion src/DecoratorManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var _ = require('lodash'),
DecoratorGenerator = require('./shim/DecoratorGenerator'),
Enableable = require('./mixins/Enableable/Enableable'),
PluginHelpers = require('./shim/PluginHelpers'),
metadata = require('webgme/src/plugin/coreplugins/DecoratorGenerator/metadata.json'),
metadata = require('webgme-engine/src/plugin/coreplugins/DecoratorGenerator/metadata.json'),
RAW_CONFIG = metadata.configStructure;

var DecoratorManager = function(logger) {
Expand Down
2 changes: 1 addition & 1 deletion src/PluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var _ = require('lodash'),
ComponentManager = require('./ComponentManager'),
PluginGenerator = require('./shim/PluginGenerator'),
PluginHelpers = require('./shim/PluginHelpers'),
metadata = require('webgme/src/plugin/coreplugins/PluginGenerator/metadata.json'),
metadata = require('webgme-engine/src/plugin/coreplugins/PluginGenerator/metadata.json'),
RAW_CONFIG = metadata.configStructure;

var PluginManager = function(logger) {
Expand Down
2 changes: 1 addition & 1 deletion src/RouterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var _ = require('lodash'),
ComponentManager = require('./ComponentManager'),
RouterGenerator = require('./shim/RouterGenerator'),
PluginHelpers = require('./shim/PluginHelpers'),
metadata = require('webgme/src/plugin/coreplugins/RestRouterGenerator/metadata.json'),
metadata = require('webgme-engine/src/plugin/coreplugins/RestRouterGenerator/metadata.json'),
RAW_CONFIG = metadata.configStructure;

var RouterManager = function(logger) {
Expand Down
9 changes: 6 additions & 3 deletions src/SeedManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,24 @@ SeedManager.prototype.new = function(args, callback) {
if (!exists(sourceFile)) {
var error = 'Seed file does not exist.';
this._logger.error(error);
fse.rmdirSync(fileDir);
return callback(error);
}

return fse.copy(sourceFile, filePath, err => {
if (err) {
fse.rmdirSync(fileDir);
this._logger.error(err);
if (exists(fileDir)) {
fse.rmdirSync(fileDir);
}
return callback(err);
}
this._saveSeed(name, filePath, callback);
});
}
// This is lazily loaded because the load takes a couple seconds. This
// causes a delay for calling 'new' but no other commands
if (!this._exportProject) {
var exportCli = require('webgme/src/bin/export');
var exportCli = require('webgme-engine/src/bin/export');
this._exportProject = function (parameters, callback) {
var args = [
'node', 'export.js',
Expand Down
6 changes: 3 additions & 3 deletions src/mixins/Enableable/runPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ main = function (argv, callback) {
};

runPlugin = function(gmeConfig, pluginConfig, projectOptions, callback) {
var webgme = require('webgme'),
PluginCliManager = require('webgme/src/plugin/climanager'),
Project = require('webgme/src/server/storage/userproject'),
var webgme = require('webgme-engine'),
PluginCliManager = webgme.PluginCliManager,
Project = require('webgme-engine/src/server/storage/userproject'),
logger = webgme.Logger.create('gme:bin:import', gmeConfig.bin.log);
var storage,
project;
Expand Down
18 changes: 9 additions & 9 deletions src/res/package.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"scripts": {
"start": "node app.js",
"test": "node ./node_modules/mocha/bin/mocha --recursive test",
"apply": "node ./node_modules/webgme/src/bin/apply.js",
"diff": "node ./node_modules/webgme/src/bin/diff.js",
"export": "node ./node_modules/webgme/src/bin/export.js",
"import": "node ./node_modules/webgme/src/bin/import.js",
"merge": "node ./node_modules/webgme/src/bin/merge.js",
"plugin": "node ./node_modules/webgme/src/bin/run_plugin.js",
"pluginHook": "node ./node_modules/webgme/src/bin/plugin_hook.js",
"users": "node ./node_modules/webgme/src/bin/usermanager.js",
"clean_up": "node ./node_modules/webgme/src/bin/clean_up.js"
"apply": "node ./node_modules/webgme-engine/src/bin/apply.js",
"diff": "node ./node_modules/webgme-engine/src/bin/diff.js",
"export": "node ./node_modules/webgme-engine/src/bin/export.js",
"import": "node ./node_modules/webgme-engine/src/bin/import.js",
"merge": "node ./node_modules/webgme-engine/src/bin/merge.js",
"plugin": "node ./node_modules/webgme-engine/src/bin/run_plugin.js",
"pluginHook": "node ./node_modules/webgme-engine/src/bin/plugin_hook.js",
"users": "node ./node_modules/webgme-engine/src/bin/usermanager.js",
"clean_up": "node ./node_modules/webgme-engine/src/bin/clean_up.js"
},
"version": "1.0.0",
"peerDependencies": {
Expand Down
20 changes: 10 additions & 10 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,16 @@ var loadPaths = function(requirejs) {
nodeRequire: require,
baseUrl: __dirname,
paths: {
text: __dirname+'/../node_modules/webgme/src/client/lib/require/require-text/text',
coreplugins: __dirname+'/../node_modules/webgme/src/plugin/coreplugins',
plugin: __dirname + '/../node_modules/webgme/src/plugin',
common: __dirname + '/../node_modules/webgme/src/common',

'plugin/PluginGenerator/PluginGenerator': __dirname + '/../node_modules/webgme/src/plugin/coreplugins/PluginGenerator/',
'plugin/AddOnGenerator/AddOnGenerator': __dirname + '/../node_modules/webgme/src/plugin/coreplugins/AddOnGenerator/',
'plugin/DecoratorGenerator/DecoratorGenerator': __dirname + '/../node_modules/webgme/src/plugin/coreplugins/DecoratorGenerator/',
'plugin/LayoutGenerator/LayoutGenerator': __dirname + '/../node_modules/webgme/src/plugin/coreplugins/LayoutGenerator/',
'plugin/VisualizerGenerator/VisualizerGenerator': __dirname + '/../node_modules/webgme/src/plugin/coreplugins/VisualizerGenerator/'
text: __dirname+'/../node_modules/webgme-engine/src/common/lib/requirejs/text',
coreplugins: __dirname+'/../node_modules/webgme-engine/src/plugin/coreplugins',
plugin: __dirname + '/../node_modules/webgme-engine/src/plugin',
common: __dirname + '/../node_modules/webgme-engine/src/common',

'plugin/PluginGenerator/PluginGenerator': __dirname + '/../node_modules/webgme-engine/src/plugin/coreplugins/PluginGenerator/',
'plugin/AddOnGenerator/AddOnGenerator': __dirname + '/../node_modules/webgme-engine/src/plugin/coreplugins/AddOnGenerator/',
'plugin/DecoratorGenerator/DecoratorGenerator': __dirname + '/../node_modules/webgme-engine/src/plugin/coreplugins/DecoratorGenerator/',
'plugin/LayoutGenerator/LayoutGenerator': __dirname + '/../node_modules/webgme-engine/src/plugin/coreplugins/LayoutGenerator/',
'plugin/VisualizerGenerator/VisualizerGenerator': __dirname + '/../node_modules/webgme-engine/src/plugin/coreplugins/VisualizerGenerator/'
}
});
};
Expand Down
4 changes: 2 additions & 2 deletions test-src/base.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ describe('BaseManager', function() {
});

// issue 51
it('should use the same version of webgme as the setup tool', function() {
it('should use the same major version of webgme as the setup tool has for webgme-engine', function() {
// Compare the package.json values
var packageJSON = path.join(initProject, 'package.json'),
toolJson = path.join(__dirname, '..', 'package.json'),
toolDeps = require(toolJson).dependencies,
deps = require(packageJSON).peerDependencies;

assert.equal(deps.webgme, toolDeps.webgme);
assert.equal(deps.webgme, toolDeps['webgme-engine']);
});

it('should create webgme app.js file', function() {
Expand Down
16 changes: 8 additions & 8 deletions test-src/res/EmptyProject/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"scripts": {
"start": "node app.js",
"test": "node ./node_modules/mocha/bin/mocha --recursive test",
"apply": "node ./node_modules/webgme/src/bin/apply.js",
"diff": "node ./node_modules/webgme/src/bin/diff.js",
"export": "node ./node_modules/webgme/src/bin/export.js",
"import": "node ./node_modules/webgme/src/bin/import.js",
"merge": "node ./node_modules/webgme/src/bin/merge.js",
"plugin": "node ./node_modules/webgme/src/bin/run_plugin.js",
"users": "node ./node_modules/webgme/src/bin/usermanager.js",
"clean_up": "node ./node_modules/webgme/src/bin/clean_up.js"
"apply": "node ./node_modules/webgme-engine/src/bin/apply.js",
"diff": "node ./node_modules/webgme-engine/src/bin/diff.js",
"export": "node ./node_modules/webgme-engine/src/bin/export.js",
"import": "node ./node_modules/webgme-engine/src/bin/import.js",
"merge": "node ./node_modules/webgme-engine/src/bin/merge.js",
"plugin": "node ./node_modules/webgme-engine/src/bin/run_plugin.js",
"users": "node ./node_modules/webgme-engine/src/bin/usermanager.js",
"clean_up": "node ./node_modules/webgme-engine/src/bin/clean_up.js"
},
"version": "1.0.0",
"peerDependencies": {
Expand Down
34 changes: 32 additions & 2 deletions test-src/seed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,52 @@ describe('Seed tests', function() {
__dirname,
'..',
'node_modules',
'webgme',
'webgme-engine',
'seeds',
'EmptyProject.webgmex'
)
}, () => {
}, err => {
var generatedPath = path.join(
PROJECT_DIR,
'src',
'seeds',
seedName,
seedName + '.webgmex'
);
assert(!err);
assert(exists(generatedPath));
done();
});
});

it('should fail if seed file doesn\'t exist', function(done) {
var seedName = 'notRealSeed',
seedmanager = new SeedManager(logger);

seedmanager.new({
project: seedName,
seedName: seedName,
file: path.join(
__dirname,
'..',
'node_modules',
'webgme',
'seeds',
'NOT_REAL_FILE.webgmex'
)
}, err => {
var generatedPath = path.join(
PROJECT_DIR,
'src',
'seeds',
seedName,
seedName + '.webgmex'
);
assert(!exists(generatedPath));
assert(err.indexOf('file does not exist') > -1);
done();
});
});
});

it('should call the WebGME export script', function(done) {
Expand Down

0 comments on commit fa7bb87

Please sign in to comment.