adapt-cli 2.1.13 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.bowerrc +2 -2
- package/.eslintignore +1 -0
- package/.eslintrc.json +14 -0
- package/.github/CONTRIBUTING.md +8 -0
- package/.github/ISSUE_TEMPLATE.md +17 -0
- package/.github/pull_request_template.md +25 -0
- package/.github/workflows/addtomainproject.yml +19 -0
- package/.github/workflows/releases.yml +25 -0
- package/.travis.yml +46 -46
- package/README.md +266 -266
- package/bin/adapt.js +3 -0
- package/json/help-create/component.json +9 -9
- package/json/help-create/course.json +9 -9
- package/json/help-create/question.json +9 -0
- package/json/help-create.json +12 -11
- package/json/help-devinstall.json +9 -9
- package/json/help-install.json +10 -10
- package/json/help-ls.json +7 -7
- package/json/help-register.json +7 -7
- package/json/help-rename.json +7 -7
- package/json/help-search.json +8 -8
- package/json/help-uninstall.json +7 -7
- package/json/help-unregister.json +8 -8
- package/json/help-update.json +12 -12
- package/json/help-version.json +7 -7
- package/json/help.json +19 -19
- package/lib/api.js +260 -0
- package/lib/cli.js +69 -52
- package/lib/commands/authenticate.js +18 -0
- package/lib/commands/create/component.js +64 -81
- package/lib/commands/create/course.js +26 -81
- package/lib/commands/create/question.js +18 -0
- package/lib/commands/create.js +94 -90
- package/lib/commands/devinstall.js +35 -97
- package/lib/commands/help.js +31 -52
- package/lib/commands/install.js +16 -907
- package/lib/commands/ls.js +9 -24
- package/lib/commands/register.js +11 -196
- package/lib/commands/rename.js +14 -129
- package/lib/commands/search.js +11 -29
- package/lib/commands/uninstall.js +9 -136
- package/lib/commands/unregister.js +12 -96
- package/lib/commands/update.js +12 -867
- package/lib/commands/version.js +13 -15
- package/lib/integration/AdaptFramework/build.js +42 -0
- package/lib/integration/AdaptFramework/clone.js +27 -0
- package/lib/integration/AdaptFramework/deleteSrcCore.js +9 -0
- package/lib/integration/AdaptFramework/deleteSrcCourse.js +9 -0
- package/lib/integration/AdaptFramework/download.js +21 -0
- package/lib/integration/AdaptFramework/erase.js +34 -0
- package/lib/integration/AdaptFramework/getLatestVersion.js +79 -0
- package/lib/integration/AdaptFramework/npmInstall.js +21 -0
- package/lib/integration/AdaptFramework.js +19 -0
- package/lib/integration/Plugin.js +404 -0
- package/lib/integration/PluginManagement/autenticate.js +56 -0
- package/lib/integration/PluginManagement/install.js +224 -0
- package/lib/integration/PluginManagement/print.js +52 -0
- package/lib/integration/PluginManagement/register.js +130 -0
- package/lib/integration/PluginManagement/rename.js +101 -0
- package/lib/integration/PluginManagement/schemas.js +8 -0
- package/lib/integration/PluginManagement/search.js +46 -0
- package/lib/integration/PluginManagement/uninstall.js +141 -0
- package/lib/integration/PluginManagement/unregister.js +101 -0
- package/lib/integration/PluginManagement/update.js +224 -0
- package/lib/integration/PluginManagement.js +21 -0
- package/lib/integration/Project.js +146 -0
- package/lib/integration/Target.js +299 -0
- package/lib/integration/getBowerRegistryConfig.js +34 -0
- package/lib/logger.js +28 -0
- package/lib/util/JSONReadValidate.js +34 -0
- package/lib/util/constants.js +38 -0
- package/lib/util/createPromptTask.js +7 -0
- package/lib/util/download.js +45 -0
- package/lib/util/errors.js +58 -0
- package/lib/util/extract.js +24 -0
- package/lib/util/getDirNameFromImportMeta.js +6 -0
- package/lib/util/promises.js +36 -0
- package/package.json +74 -49
- package/TESTING.md +0 -25
- package/bin/adapt +0 -3
- package/gruntfile.js +0 -18
- package/lib/AdaptConsoleApplication.js +0 -19
- package/lib/CommandParser.js +0 -19
- package/lib/CommandTranslator.js +0 -16
- package/lib/ConsoleRenderer.js +0 -10
- package/lib/Constants.js +0 -68
- package/lib/JsonLoader.js +0 -40
- package/lib/JsonWriter.js +0 -21
- package/lib/PackageMeta.js +0 -41
- package/lib/Plugin.js +0 -53
- package/lib/PluginTypeResolver.js +0 -47
- package/lib/Project.js +0 -89
- package/lib/RendererHelpers.js +0 -41
- package/lib/RepositoryDownloader.js +0 -64
- package/lib/Slug.js +0 -5
- package/lib/VersionChecker.js +0 -7
- package/lib/commands/create/index.js +0 -6
- package/lib/commands/index.js +0 -16
- package/lib/commands/install/InstallLog.js +0 -32
- package/lib/commands/install/InstallTarget.js +0 -259
- package/lib/commands/install/extend.js +0 -31
- package/lib/download.js +0 -101
- package/lib/errors.js +0 -58
- package/lib/promise/authenticate.js +0 -58
- package/lib/promise/build.js +0 -20
- package/lib/promise/cloneInstall.js +0 -35
- package/lib/promise/confirmBuild.js +0 -6
- package/lib/promise/exec.js +0 -39
- package/lib/promise/getRepository.js +0 -26
- package/lib/promise/highest.js +0 -109
- package/lib/promise/install.js +0 -31
- package/lib/promise/installAdaptDependencies.js +0 -30
- package/lib/promise/installNodeDependencies.js +0 -28
- package/lib/promise/removeTemporaryDownload.js +0 -8
- package/lib/promise/replaceTextContent.js +0 -10
- package/lib/promise/uninstallPackage.js +0 -15
- package/lib/promise/update.js +0 -33
- package/lib/promise/util.js +0 -16
- package/test/fixtures/adapt-with-plugins.json +0 -6
- package/test/specs/command_translation_concerns.js +0 -13
- package/test/specs/create_command_concerns.js +0 -22
- package/test/specs/create_concerns.js +0 -30
- package/test/specs/install_concerns.js +0 -31
- package/test/specs/installing_compatible_plugins_concerns.js +0 -126
- package/test/specs/installing_incompatible_plugins_concerns.js +0 -103
- package/test/specs/ls_concerns.js +0 -28
- package/test/specs/plugin_name_concerns.js +0 -82
- package/test/specs/project_concerns.js +0 -128
- package/test/specs/registration_concerns.js +0 -31
- package/test/specs/repository_downloader_concerns.js +0 -55
- package/test/specs/search_concerns.js +0 -30
- package/test/specs/type_resolution_concerns.js +0 -71
- package/test/specs/uninstall_command_concerns.js +0 -64
- package/test/specs/uninstall_concerns.js +0 -31
package/lib/promise/highest.js
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
var async = require('async');
|
2
|
-
var Q = require('q');
|
3
|
-
var request = require('request');
|
4
|
-
var semver = require('semver');
|
5
|
-
var Constants = require('../Constants');
|
6
|
-
var _ = require('lodash');
|
7
|
-
|
8
|
-
module.exports = function () {
|
9
|
-
var deferred = Q.defer();
|
10
|
-
|
11
|
-
checkLatestAdaptRepoVersion(function (error, latestFrameworkTag) {
|
12
|
-
if (error) {
|
13
|
-
deferred.reject(error);
|
14
|
-
} else {
|
15
|
-
deferred.resolve(latestFrameworkTag);
|
16
|
-
}
|
17
|
-
});
|
18
|
-
|
19
|
-
return deferred.promise;
|
20
|
-
}
|
21
|
-
|
22
|
-
function checkLatestAdaptRepoVersion(versionLimit, callback) {
|
23
|
-
if (typeof versionLimit === 'function') {
|
24
|
-
callback = versionLimit;
|
25
|
-
versionLimit = undefined;
|
26
|
-
}
|
27
|
-
// used in pagination
|
28
|
-
var nextPage = `https://api.github.com/repos/${Constants.DefaultGitHubOrg}/${Constants.FrameworkRepositoryName}/releases`;
|
29
|
-
|
30
|
-
var _getReleases = function (done) {
|
31
|
-
request({
|
32
|
-
headers: {
|
33
|
-
'User-Agent': Constants.DefaultUserAgent
|
34
|
-
},
|
35
|
-
uri: nextPage,
|
36
|
-
method: 'GET'
|
37
|
-
}, done);
|
38
|
-
};
|
39
|
-
var _requestHandler = function (error, response, body) {
|
40
|
-
if (response) {
|
41
|
-
// we've exceeded the API limit
|
42
|
-
if (response.statusCode === 403 && response.headers['x-ratelimit-remaining'] === '0') {
|
43
|
-
var reqsReset = new Date(response.headers['x-ratelimit-reset'] * 1000);
|
44
|
-
error = `You have exceeded GitHub's request limit of ${response.headers['x-ratelimit-limit']} requests per hour. Please wait until at least ${reqsReset.toTimeString()} before trying again.`;
|
45
|
-
}
|
46
|
-
else if (response.statusCode !== 200) {
|
47
|
-
error = 'GitubAPI did not respond with a 200 status code.';
|
48
|
-
}
|
49
|
-
}
|
50
|
-
if (error) {
|
51
|
-
return callback(new Error(`Couldn't check latest version of ${Constants.FrameworkRepositoryName}. ${error}`));
|
52
|
-
}
|
53
|
-
nextPage = parseLinkHeader(response.headers.link).next;
|
54
|
-
try {
|
55
|
-
// parse and sort releases (newest first)
|
56
|
-
var releases = JSON.parse(body).sort((a, b) => {
|
57
|
-
if (semver.lt(a.tag_name, b.tag_name)) return 1;
|
58
|
-
if (semver.gt(a.tag_name, b.tag_name)) return -1;
|
59
|
-
return 0;
|
60
|
-
});
|
61
|
-
} catch (e) {
|
62
|
-
return callback(new Error(`Failed to parse GitHub release data\n${e}`));
|
63
|
-
}
|
64
|
-
var compatibleRelease;
|
65
|
-
async.someSeries(releases, function (release, cb) {
|
66
|
-
var isFullRelease = !release.draft && !release.prerelease;
|
67
|
-
var satisfiesVersion = !versionLimit || semver.satisfies(release.tag_name, versionLimit);
|
68
|
-
|
69
|
-
if (!isFullRelease || !satisfiesVersion) {
|
70
|
-
return cb(null, false);
|
71
|
-
}
|
72
|
-
|
73
|
-
compatibleRelease = release;
|
74
|
-
return cb(null, true);
|
75
|
-
}, function (error, satisfied) {
|
76
|
-
if (!satisfied) {
|
77
|
-
if (nextPage) {
|
78
|
-
return _getReleases(_requestHandler);
|
79
|
-
}
|
80
|
-
error = new Error(`Couldn't find any releases compatible with specified framework version (${versionLimit}), please check that it is a valid version.`);
|
81
|
-
}
|
82
|
-
if (error) {
|
83
|
-
return callback(error);
|
84
|
-
}
|
85
|
-
callback(error, compatibleRelease.tag_name);
|
86
|
-
});
|
87
|
-
};
|
88
|
-
// start recursion
|
89
|
-
_getReleases(_requestHandler);
|
90
|
-
}
|
91
|
-
|
92
|
-
// taken from https://gist.github.com/niallo/3109252
|
93
|
-
function parseLinkHeader(header) {
|
94
|
-
if (!header || header.length === 0) {
|
95
|
-
return [];
|
96
|
-
}
|
97
|
-
var links = {};
|
98
|
-
// Parse each part into a named link
|
99
|
-
_.each(header.split(','), function (p) {
|
100
|
-
var section = p.split(';');
|
101
|
-
if (section.length !== 2) {
|
102
|
-
throw new Error("section could not be split on ';'");
|
103
|
-
}
|
104
|
-
var url = section[0].replace(/<(.*)>/, '$1').trim();
|
105
|
-
var name = section[1].replace(/rel="(.*)"/, '$1').trim();
|
106
|
-
links[name] = url;
|
107
|
-
});
|
108
|
-
return links;
|
109
|
-
}
|
package/lib/promise/install.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
var bower = require('bower'),
|
2
|
-
Q = require('q'),
|
3
|
-
path = require('path'),
|
4
|
-
rimraf = require('rimraf'),
|
5
|
-
Plugin = require('../Plugin');
|
6
|
-
|
7
|
-
module.exports = function install (plugin, config) {
|
8
|
-
var deferred = Q.defer();
|
9
|
-
|
10
|
-
// (reliably) remove the plugin first
|
11
|
-
rimraf(path.join(config.cwd || '.', config.directory, plugin.packageName), {disableGlob:true}, doInstall);
|
12
|
-
|
13
|
-
function doInstall(err) {
|
14
|
-
if (err) {
|
15
|
-
deferred.notify();
|
16
|
-
deferred.resolve({error:'There was a problem writing to the target directory'});
|
17
|
-
} else {
|
18
|
-
bower.commands.install([plugin.packageName+'#'+plugin._versionToInstall], null, config)
|
19
|
-
.on('end', function() {
|
20
|
-
deferred.notify();
|
21
|
-
deferred.resolve({_wasInstalled:true});
|
22
|
-
})
|
23
|
-
.on('error', function (err) {
|
24
|
-
deferred.notify();
|
25
|
-
deferred.resolve({error:'Bower reported '+err});
|
26
|
-
});
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
return deferred.promise;
|
31
|
-
}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
var chalk = require('chalk'),
|
2
|
-
Q = require('q'),
|
3
|
-
npm = require('npm'),
|
4
|
-
installCommand = invokeFactoryOrProvideObject(require('../commands/install')),
|
5
|
-
Constants = require('../Constants'),
|
6
|
-
path = require('path');
|
7
|
-
|
8
|
-
module.exports = function installAdaptDependencies (properties /* { renderer, localDir } */) {
|
9
|
-
var deferred = Q.defer(),
|
10
|
-
cwd = process.cwd();
|
11
|
-
|
12
|
-
properties.renderer.log(chalk.cyan('installing adapt dependencies'));
|
13
|
-
|
14
|
-
if(path.relative(cwd, properties.localDir)) {
|
15
|
-
process.chdir(properties.localDir);
|
16
|
-
console.log(cwd, 'change to', process.cwd());
|
17
|
-
}
|
18
|
-
installCommand.install(properties.renderer, function (err) {
|
19
|
-
if(err) deferred.reject(err);
|
20
|
-
|
21
|
-
process.chdir(cwd);
|
22
|
-
deferred.resolve(properties);
|
23
|
-
});
|
24
|
-
return deferred.promise;
|
25
|
-
};
|
26
|
-
|
27
|
-
function invokeFactoryOrProvideObject(factoryOrObject, dependencies) {
|
28
|
-
if(typeof factoryOrObject === 'function') return factoryOrObject(dependencies || {});
|
29
|
-
return factoryOrObject;
|
30
|
-
}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
var chalk = require('chalk'),
|
2
|
-
Q = require('q'),
|
3
|
-
npm = require('npm'),
|
4
|
-
Constants = require('../Constants'),
|
5
|
-
path = require('path');
|
6
|
-
|
7
|
-
module.exports = function installNodeDependencies (properties /* { renderer, localDir } */) {
|
8
|
-
var deferred = Q.defer(),
|
9
|
-
cwd = process.cwd();
|
10
|
-
|
11
|
-
properties.renderer.log(chalk.cyan('installing node dependencies'));
|
12
|
-
|
13
|
-
if(path.relative(cwd, properties.localDir)) {
|
14
|
-
process.chdir(properties.localDir);
|
15
|
-
}
|
16
|
-
npm.load(function (err) {
|
17
|
-
if(err) deferred.reject(err);
|
18
|
-
|
19
|
-
npm.commands.install(function () {
|
20
|
-
if(err) deferred.reject(err);
|
21
|
-
|
22
|
-
process.chdir(cwd);
|
23
|
-
|
24
|
-
deferred.resolve(properties);
|
25
|
-
});
|
26
|
-
});
|
27
|
-
return deferred.promise;
|
28
|
-
};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
var Q = require('q'),
|
2
|
-
fs = require('q-io/fs');
|
3
|
-
|
4
|
-
module.exports = function (path, match, replacement) {
|
5
|
-
return fs.read(path)
|
6
|
-
.then(function (content) {
|
7
|
-
var modifiedContent = content.replace(match, replacement);
|
8
|
-
return fs.write(path, modifiedContent);
|
9
|
-
});
|
10
|
-
};
|
@@ -1,15 +0,0 @@
|
|
1
|
-
var bower = require('bower'),
|
2
|
-
Q = require('q');
|
3
|
-
|
4
|
-
module.exports = function uninstall (plugin, config) {
|
5
|
-
var deferred = Q.defer();
|
6
|
-
|
7
|
-
bower.commands.uninstall([plugin.toString()], {}, config)
|
8
|
-
.on('end', function(uninstalled) {
|
9
|
-
uninstalled.hasOwnProperty(plugin.toString()) ? deferred.resolve() : deferred.reject();
|
10
|
-
})
|
11
|
-
.on('error', function (err) {
|
12
|
-
deferred.reject(err);
|
13
|
-
});
|
14
|
-
return deferred.promise;
|
15
|
-
};
|
package/lib/promise/update.js
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
var bower = require('bower'),
|
2
|
-
chalk = require('chalk'),
|
3
|
-
Q = require('q');
|
4
|
-
|
5
|
-
module.exports = function update (plugin, options, config) {
|
6
|
-
var deferred = Q.defer();
|
7
|
-
|
8
|
-
function onSuccess() {
|
9
|
-
//console.log('onSuccess');
|
10
|
-
deferred.notify();
|
11
|
-
deferred.resolve({updated:true});
|
12
|
-
}
|
13
|
-
|
14
|
-
function onFail(err) {
|
15
|
-
console.log('onFail', err);
|
16
|
-
deferred.notify();
|
17
|
-
deferred.resolve({updated:false, error:err});
|
18
|
-
}
|
19
|
-
|
20
|
-
function onLog(obj) {
|
21
|
-
//console.log(chalk.cyan(obj.level), obj.id, obj.message);
|
22
|
-
}
|
23
|
-
|
24
|
-
try {
|
25
|
-
//console.log('UPDATE', plugin.packageName, config);
|
26
|
-
bower.commands.update([plugin.packageName], options, config).on('end', onSuccess).on('error', onFail).on('log', onLog);
|
27
|
-
} catch(err) {
|
28
|
-
console.log('bower update threw error');
|
29
|
-
onFail(err);
|
30
|
-
}
|
31
|
-
|
32
|
-
return deferred.promise;
|
33
|
-
}
|
package/lib/promise/util.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
var Q = require('q');
|
2
|
-
|
3
|
-
module.exports = {
|
4
|
-
serialise: function (arr, iterator) {
|
5
|
-
// create a empty promise to start our series (so we can use `then`)
|
6
|
-
var currentPromise = Q();
|
7
|
-
var promises = arr.map(function (el) {
|
8
|
-
return currentPromise = currentPromise.then(function () {
|
9
|
-
// execute the next function after the previous has resolved successfully
|
10
|
-
return iterator(el)
|
11
|
-
})
|
12
|
-
});
|
13
|
-
// group the results and return the group promise
|
14
|
-
return Q.all(promises)
|
15
|
-
}
|
16
|
-
};
|
@@ -1,13 +0,0 @@
|
|
1
|
-
var mockery = require('mockery'),
|
2
|
-
sinon = require('sinon'),
|
3
|
-
expect = require('expect.js'),
|
4
|
-
CommandTranslator = require('../../lib/CommandTranslator');
|
5
|
-
|
6
|
-
describe('Given I a list of parameters', function () {
|
7
|
-
describe('when I translate them', function () {
|
8
|
-
it('should translate -v to version', function () {
|
9
|
-
var parameters = [ '-v' ];
|
10
|
-
expect(CommandTranslator(parameters)[0]).to.be('version');
|
11
|
-
});
|
12
|
-
});
|
13
|
-
});
|
@@ -1,22 +0,0 @@
|
|
1
|
-
var mockery = require('mockery'),
|
2
|
-
sinon = require('sinon'),
|
3
|
-
expect = require('expect.js'),
|
4
|
-
Q = require('q'),
|
5
|
-
Constants = require('../../lib/Constants'),
|
6
|
-
Project = require('../../lib/Project'),
|
7
|
-
Plugin = require('../../lib/Plugin'),
|
8
|
-
rimraf = require('rimraf');
|
9
|
-
|
10
|
-
/* mockery is just too slow to run as a unit test
|
11
|
-
describe('Given I have an create command', function () {
|
12
|
-
describe('when I create a course', function () {
|
13
|
-
it('should download the framework', function (done) {
|
14
|
-
var command = require('../../lib/commands/create');
|
15
|
-
command.create(console, 'course', './downloaded-files', 'develop', function () {
|
16
|
-
expect(false).to.be(true);
|
17
|
-
done();
|
18
|
-
});
|
19
|
-
});
|
20
|
-
});
|
21
|
-
});
|
22
|
-
*/
|
@@ -1,30 +0,0 @@
|
|
1
|
-
var sinon = require('sinon'),
|
2
|
-
expect = require('expect.js');
|
3
|
-
|
4
|
-
describe('Given I have an application', function () {
|
5
|
-
var AdaptConsoleApplication = require('../../lib/AdaptConsoleApplication'),
|
6
|
-
CommandParser = require('../../lib/CommandParser'),
|
7
|
-
createResult = {
|
8
|
-
success: true
|
9
|
-
},
|
10
|
-
commands = {
|
11
|
-
create: sinon.stub().yields(null, createResult)
|
12
|
-
},
|
13
|
-
outputDevice = {
|
14
|
-
log: sinon.stub()
|
15
|
-
},
|
16
|
-
argsv = function () {
|
17
|
-
return ['node', 'create-concerns.js'].concat(Array.prototype.slice.call(arguments));
|
18
|
-
},
|
19
|
-
app = new AdaptConsoleApplication(commands, outputDevice);
|
20
|
-
|
21
|
-
describe('when I execute a create command', function () {
|
22
|
-
it('should create the package', function (done) {
|
23
|
-
var create_command = new CommandParser(argsv('create', 'package-name'));
|
24
|
-
app.do(create_command, function (err, results) {
|
25
|
-
expect(commands.create.calledWith(outputDevice, 'package-name')).to.be(true);
|
26
|
-
done();
|
27
|
-
});
|
28
|
-
});
|
29
|
-
});
|
30
|
-
});
|
@@ -1,31 +0,0 @@
|
|
1
|
-
var sinon = require('sinon'),
|
2
|
-
expect = require('expect.js');
|
3
|
-
|
4
|
-
describe('Given I have an application', function () {
|
5
|
-
var AdaptConsoleApplication = require('../../lib/AdaptConsoleApplication'),
|
6
|
-
CommandParser = require('../../lib/CommandParser'),
|
7
|
-
installResult = {
|
8
|
-
success: true
|
9
|
-
},
|
10
|
-
commands = {
|
11
|
-
install: sinon.stub().yields(null, installResult)
|
12
|
-
},
|
13
|
-
outputDevice = {
|
14
|
-
log: sinon.stub()
|
15
|
-
},
|
16
|
-
argsv = function () {
|
17
|
-
return ['node', 'search-concerns.js'].concat(Array.prototype.slice.call(arguments));
|
18
|
-
},
|
19
|
-
app = new AdaptConsoleApplication(commands, outputDevice);
|
20
|
-
|
21
|
-
describe('when I execute an install command for an existing package', function () {
|
22
|
-
it('should install the package', function (done) {
|
23
|
-
var install_command = new CommandParser(argsv('install', 'package-name'));
|
24
|
-
app.do(install_command, function (err, results) {
|
25
|
-
expect(commands.install.calledWith(outputDevice, 'package-name')).to.be(true);
|
26
|
-
done();
|
27
|
-
});
|
28
|
-
});
|
29
|
-
});
|
30
|
-
|
31
|
-
});
|
@@ -1,126 +0,0 @@
|
|
1
|
-
var fs = require('fs'),
|
2
|
-
sinon = require('sinon'),
|
3
|
-
expect = require('expect.js'),
|
4
|
-
Project = require('../../lib/Project'),
|
5
|
-
RendererHelpers = require('../../lib/RendererHelpers'),
|
6
|
-
Q = require('q');
|
7
|
-
|
8
|
-
describe('Given that I have Adapt Framework version 2', function () {
|
9
|
-
describe('When I install a plugin that is tagged as compatible with Adapt V2 framework version', function () {
|
10
|
-
before(function () {
|
11
|
-
fs.writeFileSync('./adapt.json', JSON.stringify(require('../fixtures/adapt.json')));
|
12
|
-
});
|
13
|
-
|
14
|
-
it('should install it', function (done) {
|
15
|
-
|
16
|
-
var context = createContext({
|
17
|
-
pluginCompatibility: '~2.0.0',
|
18
|
-
frameworkVersion: '2.0.0'
|
19
|
-
});
|
20
|
-
|
21
|
-
var installCommand = require('../../lib/commands/install')(context);
|
22
|
-
|
23
|
-
installCommand.install(context.renderer, 'plugin', function () {
|
24
|
-
expect(context.install.called).to.be(true);
|
25
|
-
done();
|
26
|
-
});
|
27
|
-
});
|
28
|
-
|
29
|
-
after(function() {
|
30
|
-
fs.unlinkSync('./adapt.json');
|
31
|
-
Project.prototype.getFrameworkVersion.restore();
|
32
|
-
RendererHelpers.reportCompatibilityWarning.restore();
|
33
|
-
});
|
34
|
-
});
|
35
|
-
});
|
36
|
-
|
37
|
-
describe('Given that I have Adapt Framework version 1.1.1 or earlier', function () {
|
38
|
-
describe('When I install a plugin that is tagged as compatible with Adapt V1.1 framework version', function () {
|
39
|
-
before(function () {
|
40
|
-
fs.writeFileSync('./adapt.json', JSON.stringify(require('../fixtures/adapt.json')));
|
41
|
-
});
|
42
|
-
|
43
|
-
it('should install it', function (done) {
|
44
|
-
|
45
|
-
var context = createContext({
|
46
|
-
pluginCompatibility: '1.1.1',
|
47
|
-
frameworkVersion: '1.1.1'
|
48
|
-
});
|
49
|
-
|
50
|
-
var installCommand = require('../../lib/commands/install')(context);
|
51
|
-
|
52
|
-
installCommand.install(context.renderer, 'plugin', function (err) {
|
53
|
-
expect(context.install.called).to.be(true);
|
54
|
-
done();
|
55
|
-
});
|
56
|
-
});
|
57
|
-
|
58
|
-
after(function() {
|
59
|
-
fs.unlinkSync('./adapt.json');
|
60
|
-
Project.prototype.getFrameworkVersion.restore();
|
61
|
-
RendererHelpers.reportCompatibilityWarning.restore();
|
62
|
-
});
|
63
|
-
});
|
64
|
-
});
|
65
|
-
|
66
|
-
describe('Given that I have Adapt Framework version 1.1.1 or earlier', function () {
|
67
|
-
describe('When I install a plugin that is NOT tagged', function () {
|
68
|
-
before(function () {
|
69
|
-
fs.writeFileSync('./adapt.json', JSON.stringify(require('../fixtures/adapt.json')));
|
70
|
-
});
|
71
|
-
|
72
|
-
it('should install it', function (done) {
|
73
|
-
|
74
|
-
var context = createContext({
|
75
|
-
pluginCompatibility: '*',
|
76
|
-
frameworkVersion: '1.1.1'
|
77
|
-
});
|
78
|
-
|
79
|
-
var installCommand = require('../../lib/commands/install')(context);
|
80
|
-
|
81
|
-
installCommand.install(context.renderer, 'plugin', function () {
|
82
|
-
expect(context.install.called).to.be(true);
|
83
|
-
done();
|
84
|
-
});
|
85
|
-
});
|
86
|
-
|
87
|
-
after(function() {
|
88
|
-
fs.unlinkSync('./adapt.json');
|
89
|
-
Project.prototype.getFrameworkVersion.restore();
|
90
|
-
RendererHelpers.reportCompatibilityWarning.restore();
|
91
|
-
});
|
92
|
-
});
|
93
|
-
});
|
94
|
-
|
95
|
-
function createContext(values) {
|
96
|
-
var getKeywordsSuccessfully = Q.defer(),
|
97
|
-
getFrameworkCompatibilitySuccessfully = Q.defer(),
|
98
|
-
installSuccessfully = Q.defer();
|
99
|
-
|
100
|
-
getKeywordsSuccessfully.resolve('adapt-extension');
|
101
|
-
getFrameworkCompatibilitySuccessfully.resolve(values.pluginCompatibility);
|
102
|
-
installSuccessfully.resolve(true);
|
103
|
-
|
104
|
-
var warning = sinon.stub().yields();
|
105
|
-
|
106
|
-
var stubs = {
|
107
|
-
bower: {
|
108
|
-
commands: {
|
109
|
-
install: sinon.stub()
|
110
|
-
}
|
111
|
-
},
|
112
|
-
renderer: values.renderer || { log: sinon.stub() },
|
113
|
-
RendererHelpers: RendererHelpers,
|
114
|
-
Project: Project,
|
115
|
-
PackageMeta: {
|
116
|
-
getKeywords: sinon.stub().returns(getKeywordsSuccessfully.promise),
|
117
|
-
getFrameworkCompatibility: sinon.stub().returns(getFrameworkCompatibilitySuccessfully.promise)
|
118
|
-
},
|
119
|
-
install: sinon.stub().returns(installSuccessfully.promise),
|
120
|
-
warning: warning
|
121
|
-
};
|
122
|
-
|
123
|
-
sinon.stub(stubs.RendererHelpers, 'reportCompatibilityWarning').returns(warning);
|
124
|
-
sinon.stub(stubs.Project.prototype, 'getFrameworkVersion').returns(values.frameworkVersion);
|
125
|
-
return stubs;
|
126
|
-
}
|
@@ -1,103 +0,0 @@
|
|
1
|
-
var fs = require('fs'),
|
2
|
-
sinon = require('sinon'),
|
3
|
-
expect = require('expect.js'),
|
4
|
-
Project = require('../../lib/Project'),
|
5
|
-
RendererHelpers = require('../../lib/RendererHelpers'),
|
6
|
-
Q = require('q');
|
7
|
-
|
8
|
-
describe('Given that I have Adapt Framework version 2', function () {
|
9
|
-
describe('When I install a plugin that is tagged as incompatible with Adapt V2 framework version', function () {
|
10
|
-
before(function () {
|
11
|
-
fs.writeFileSync('./adapt.json', JSON.stringify(require('../fixtures/adapt.json')));
|
12
|
-
});
|
13
|
-
|
14
|
-
it('should warn that the plugin is incompatible', function (done) {
|
15
|
-
|
16
|
-
var context = createContext({
|
17
|
-
frameworkVersion: '2.0.0',
|
18
|
-
pluginCompatibility: '1.1.1'
|
19
|
-
});
|
20
|
-
|
21
|
-
var installCommand = require('../../lib/commands/install')(context);
|
22
|
-
|
23
|
-
installCommand.install(context.renderer, 'plugin', function (err) {
|
24
|
-
try {
|
25
|
-
expect(RendererHelpers.reportCompatibilityWarning.called).to.be(true);
|
26
|
-
done();
|
27
|
-
}
|
28
|
-
catch(ex) { done(ex); }
|
29
|
-
});
|
30
|
-
});
|
31
|
-
|
32
|
-
after(function() {
|
33
|
-
fs.unlinkSync('./adapt.json');
|
34
|
-
Project.prototype.getFrameworkVersion.restore();
|
35
|
-
RendererHelpers.reportCompatibilityWarning.restore();
|
36
|
-
});
|
37
|
-
});
|
38
|
-
});
|
39
|
-
|
40
|
-
describe('Given that I have Adapt Framework version 1.1.1 or earlier', function () {
|
41
|
-
describe('When I install a plugin that is tagged as compatible with Adapt V2 framework version', function () {
|
42
|
-
before(function () {
|
43
|
-
fs.writeFileSync('./adapt.json', JSON.stringify(require('../fixtures/adapt.json')));
|
44
|
-
});
|
45
|
-
|
46
|
-
it('should warn that the plugin is incompatible', function (done) {
|
47
|
-
|
48
|
-
var context = createContext({
|
49
|
-
frameworkVersion: '1.1.1',
|
50
|
-
pluginCompatibility: '>2.0.0'
|
51
|
-
});
|
52
|
-
|
53
|
-
var installCommand = require('../../lib/commands/install')(context);
|
54
|
-
|
55
|
-
installCommand.install(context.renderer, 'plugin', function (err) {
|
56
|
-
try {
|
57
|
-
expect(RendererHelpers.reportCompatibilityWarning.called).to.be(true);
|
58
|
-
done();
|
59
|
-
}
|
60
|
-
catch(ex) { done(ex); }
|
61
|
-
});
|
62
|
-
});
|
63
|
-
|
64
|
-
after(function() {
|
65
|
-
fs.unlinkSync('./adapt.json');
|
66
|
-
Project.prototype.getFrameworkVersion.restore();
|
67
|
-
RendererHelpers.reportCompatibilityWarning.restore();
|
68
|
-
});
|
69
|
-
});
|
70
|
-
});
|
71
|
-
|
72
|
-
function createContext(values) {
|
73
|
-
var getKeywordsSuccessfully = Q.defer(),
|
74
|
-
getFrameworkCompatibilitySuccessfully = Q.defer(),
|
75
|
-
userAbandonsInstallation = Q.defer(),
|
76
|
-
installSuccessfully = Q.defer();
|
77
|
-
|
78
|
-
getKeywordsSuccessfully.resolve('adapt-extension');
|
79
|
-
getFrameworkCompatibilitySuccessfully.resolve(values.pluginCompatibility);
|
80
|
-
userAbandonsInstallation.resolve({ continueWithInstall: true });
|
81
|
-
installSuccessfully.resolve(true);
|
82
|
-
|
83
|
-
var stubs = {
|
84
|
-
bower: {
|
85
|
-
commands: {
|
86
|
-
install: sinon.stub()
|
87
|
-
}
|
88
|
-
},
|
89
|
-
renderer: { log: sinon.stub() },
|
90
|
-
RendererHelpers: RendererHelpers,
|
91
|
-
Project: Project,
|
92
|
-
PackageMeta: {
|
93
|
-
getKeywords: sinon.stub().returns(getKeywordsSuccessfully.promise),
|
94
|
-
getFrameworkCompatibility: sinon.stub().returns(getFrameworkCompatibilitySuccessfully.promise)
|
95
|
-
},
|
96
|
-
install: sinon.stub().returns(installSuccessfully.promise)
|
97
|
-
};
|
98
|
-
|
99
|
-
sinon.stub(stubs.RendererHelpers, 'reportCompatibilityWarning').returns(userAbandonsInstallation.promise);
|
100
|
-
sinon.stub(stubs.Project.prototype, 'getFrameworkVersion').returns(values.frameworkVersion);
|
101
|
-
return stubs;
|
102
|
-
}
|
103
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
var sinon = require('sinon'),
|
2
|
-
expect = require('expect.js');
|
3
|
-
|
4
|
-
describe('Given I have an application', function () {
|
5
|
-
var AdaptConsoleApplication = require('../../lib/AdaptConsoleApplication'),
|
6
|
-
CommandParser = require('../../lib/CommandParser'),
|
7
|
-
commands = {
|
8
|
-
ls: sinon.stub().yields()
|
9
|
-
},
|
10
|
-
outputDevice = {
|
11
|
-
log: sinon.stub()
|
12
|
-
},
|
13
|
-
argsv = function () {
|
14
|
-
return ['node', 'search-concerns.js'].concat(Array.prototype.slice.call(arguments));
|
15
|
-
},
|
16
|
-
app = new AdaptConsoleApplication(commands, outputDevice);
|
17
|
-
|
18
|
-
describe('when I execute an ls command for an existing package', function () {
|
19
|
-
it('should list the package', function (done) {
|
20
|
-
var ls_command = new CommandParser(argsv('ls'));
|
21
|
-
app.do(ls_command, function (err, results) {
|
22
|
-
expect(commands.ls.calledWith(outputDevice)).to.be(true);
|
23
|
-
done();
|
24
|
-
});
|
25
|
-
});
|
26
|
-
});
|
27
|
-
|
28
|
-
});
|