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
@@ -1,82 +0,0 @@
|
|
1
|
-
var sinon = require('sinon'),
|
2
|
-
expect = require('expect.js');
|
3
|
-
|
4
|
-
describe('Given I have a name', function () {
|
5
|
-
var Plugin = require('../../lib/Plugin');
|
6
|
-
|
7
|
-
describe('when I create a plugin from a package name', function () {
|
8
|
-
it('should prefix the name with "adapt"', function () {
|
9
|
-
var plugin = new Plugin('myPackage');
|
10
|
-
expect(plugin.packageName).to.match(/^adapt-myPackage$/);
|
11
|
-
});
|
12
|
-
|
13
|
-
it('should default the version to "*"', function () {
|
14
|
-
var plugin = new Plugin('package');
|
15
|
-
expect(plugin.version).to.match(/^\*$/);
|
16
|
-
});
|
17
|
-
|
18
|
-
it('should stringify to the bower endpoint', function () {
|
19
|
-
var plugin = new Plugin('package');
|
20
|
-
expect(plugin.toString()).to.match(/^adapt-package$/);
|
21
|
-
});
|
22
|
-
});
|
23
|
-
|
24
|
-
describe('when I create a plugin from a multiple word package name', function () {
|
25
|
-
it('should convert the name to a suitable name with hyphens', function () {
|
26
|
-
var plugin = new Plugin('my adapt package');
|
27
|
-
expect(plugin.packageName).to.match(/^adapt-my-adapt-package$/);
|
28
|
-
});
|
29
|
-
});
|
30
|
-
|
31
|
-
describe('when I create a plugin from a specific version package name', function () {
|
32
|
-
it('should parse the correct version', function () {
|
33
|
-
var plugin = new Plugin('package' ,'1.0.0');
|
34
|
-
expect(plugin.packageName).to.match(/^adapt-package$/);
|
35
|
-
expect(plugin.version).to.match(/^1.0.0$/);
|
36
|
-
});
|
37
|
-
|
38
|
-
it('should stringify to the bower endpoint', function () {
|
39
|
-
var plugin = new Plugin('package', '1.0.0');
|
40
|
-
expect(plugin.toString()).to.match(/^adapt-package#1.0.0$/);
|
41
|
-
});
|
42
|
-
});
|
43
|
-
|
44
|
-
describe('when I create a contrib plugin from a package name', function () {
|
45
|
-
it('should be contrib', function () {
|
46
|
-
var plugin = new Plugin('package', true);
|
47
|
-
expect(plugin.isContrib).to.be(true);
|
48
|
-
});
|
49
|
-
|
50
|
-
it('should prefix the name with "adapt-contrib"', function () {
|
51
|
-
var plugin = new Plugin('package', true);
|
52
|
-
expect(plugin.packageName).to.match(/^adapt-contrib-/);
|
53
|
-
});
|
54
|
-
});
|
55
|
-
|
56
|
-
describe('when I create a specific version of a contrib plugin from a package name', function () {
|
57
|
-
it('should be contrib', function () {
|
58
|
-
var plugin = new Plugin('package', '1.0.0', true);
|
59
|
-
expect(plugin.isContrib).to.be(true);
|
60
|
-
});
|
61
|
-
|
62
|
-
it('should prefix the name with "adapt-contrib"', function () {
|
63
|
-
var plugin = new Plugin('package', '1.0.0', true);
|
64
|
-
expect(plugin.packageName).to.match(/^adapt-contrib-/);
|
65
|
-
});
|
66
|
-
});
|
67
|
-
|
68
|
-
describe('when I create a plugin from a 0.0.0 version', function () {
|
69
|
-
it('should support any version', function () {
|
70
|
-
var plugin = new Plugin('package' ,'0.0.0');
|
71
|
-
expect(plugin.packageName).to.match(/^adapt-package$/);
|
72
|
-
expect(plugin.version).to.match(/^\*$/);
|
73
|
-
});
|
74
|
-
|
75
|
-
it('should stringify to the bower endpoint for any version', function () {
|
76
|
-
var plugin = new Plugin('package', '0.0.0');
|
77
|
-
expect(plugin.toString()).to.match(/^adapt-package$/);
|
78
|
-
});
|
79
|
-
});
|
80
|
-
|
81
|
-
|
82
|
-
});
|
@@ -1,128 +0,0 @@
|
|
1
|
-
var sinon = require('sinon'),
|
2
|
-
expect = require('expect.js'),
|
3
|
-
fs = require('fs'),
|
4
|
-
Project = require('../../lib/Project'),
|
5
|
-
Plugin = require('../../lib/Plugin');
|
6
|
-
|
7
|
-
describe('Given I have an adapt.json project file with no installed plugins', function () {
|
8
|
-
|
9
|
-
describe('when I list all plugins', function () {
|
10
|
-
it('should provide an empty list', function () {
|
11
|
-
var project = new Project();
|
12
|
-
expect(project.plugins).to.be.an(Array);
|
13
|
-
expect(project.plugins.length).to.be(0);
|
14
|
-
});
|
15
|
-
});
|
16
|
-
|
17
|
-
});
|
18
|
-
|
19
|
-
describe('Given I have an adapt.json project file with plugins', function () {
|
20
|
-
|
21
|
-
describe('when I list all plugins', function () {
|
22
|
-
before(function () {
|
23
|
-
fs.writeFileSync('./test/fixtures/adapt-when-i-list-plugins.json', JSON.stringify(require('../fixtures/adapt-with-plugins.json')));
|
24
|
-
});
|
25
|
-
|
26
|
-
it('should provide a list of all plugins', function () {
|
27
|
-
var project = new Project('./test/fixtures/adapt-when-i-list-plugins.json');
|
28
|
-
expect(project.plugins).to.be.an(Array);
|
29
|
-
expect(project.plugins.length).to.be(2);
|
30
|
-
expect(project.plugins[0].packageName).to.be('adapt-component');
|
31
|
-
expect(project.plugins[0].version).to.be('0.0.1');
|
32
|
-
expect(project.plugins[1].packageName).to.be('adapt-extension');
|
33
|
-
expect(project.plugins[1].version).to.be('0.0.2');
|
34
|
-
});
|
35
|
-
|
36
|
-
after(function () {
|
37
|
-
fs.unlinkSync('./test/fixtures/adapt-when-i-list-plugins.json');
|
38
|
-
});
|
39
|
-
});
|
40
|
-
|
41
|
-
describe('when I add a plugin', function () {
|
42
|
-
before(function () {
|
43
|
-
fs.writeFileSync('./test/fixtures/adapt-when-I-add-a-plugin.json', JSON.stringify(require('../fixtures/adapt-with-plugins.json')));
|
44
|
-
});
|
45
|
-
|
46
|
-
it('should provide a list with the new plugins', function () {
|
47
|
-
var project = new Project('./test/fixtures/adapt-when-I-add-a-plugin.json');
|
48
|
-
project.add(new Plugin('theme', '0.0.3'));
|
49
|
-
expect(project.plugins).to.be.an(Array);
|
50
|
-
expect(project.plugins.length).to.be(3);
|
51
|
-
expect(project.plugins[0].packageName).to.be('adapt-component');
|
52
|
-
expect(project.plugins[0].version).to.be('0.0.1');
|
53
|
-
expect(project.plugins[1].packageName).to.be('adapt-extension');
|
54
|
-
expect(project.plugins[1].version).to.be('0.0.2');
|
55
|
-
expect(project.plugins[2].packageName).to.be('adapt-theme');
|
56
|
-
expect(project.plugins[2].version).to.be('0.0.3');
|
57
|
-
});
|
58
|
-
|
59
|
-
after(function () {
|
60
|
-
fs.unlinkSync('./test/fixtures/adapt-when-I-add-a-plugin.json');
|
61
|
-
});
|
62
|
-
});
|
63
|
-
|
64
|
-
describe('when I remove a plugin', function () {
|
65
|
-
before(function () {
|
66
|
-
fs.writeFileSync('./test/fixtures/adapt-when-i-remove-a-plugin.json', JSON.stringify(require('../fixtures/adapt-with-plugins.json')));
|
67
|
-
});
|
68
|
-
|
69
|
-
it('should no longer contain that plugin', function () {
|
70
|
-
var project = new Project('./test/fixtures/adapt-when-i-remove-a-plugin.json');
|
71
|
-
project.remove(new Plugin('component'));
|
72
|
-
expect(project.plugins.length).to.be(1);
|
73
|
-
expect(project.plugins[0].packageName).to.be('adapt-extension');
|
74
|
-
expect(project.plugins[0].version).to.be('0.0.2');
|
75
|
-
});
|
76
|
-
|
77
|
-
after(function () {
|
78
|
-
fs.unlinkSync('./test/fixtures/adapt-when-i-remove-a-plugin.json');
|
79
|
-
});
|
80
|
-
});
|
81
|
-
|
82
|
-
});
|
83
|
-
|
84
|
-
describe('Given I have not got an adapt.json project file', function () {
|
85
|
-
|
86
|
-
describe('when I add a plugin', function () {
|
87
|
-
before(function () {
|
88
|
-
if(fs.existsSync('./test/fixtures/adapt-missing.json')) {
|
89
|
-
fs.unlinkSync('./test/fixtures/adapt-missing.json');
|
90
|
-
}
|
91
|
-
});
|
92
|
-
|
93
|
-
it('should create the file', function () {
|
94
|
-
var project = new Project('./test/fixtures/adapt-missing.json');
|
95
|
-
project.add(new Plugin('theme', '0.0.3'));
|
96
|
-
|
97
|
-
expect(fs.existsSync(project.manifestFilePath)).to.be(true);
|
98
|
-
|
99
|
-
var created = new Project('./test/fixtures/adapt-missing.json')
|
100
|
-
expect(created.plugins.length).to.be(1);
|
101
|
-
expect(created.plugins[0].packageName).to.be('adapt-theme');
|
102
|
-
expect(project.plugins[0].version).to.be('0.0.3');
|
103
|
-
});
|
104
|
-
|
105
|
-
after(function () {
|
106
|
-
fs.unlinkSync('./test/fixtures/adapt-missing.json');
|
107
|
-
});
|
108
|
-
});
|
109
|
-
|
110
|
-
});
|
111
|
-
|
112
|
-
describe('Given I have a package.json file with a version number', function () {
|
113
|
-
describe('when I get the framework version', function () {
|
114
|
-
var version = "2.0.1";
|
115
|
-
before(function () {
|
116
|
-
fs.writeFileSync('./test/fixtures/adapt-package-version.json', JSON.stringify({ "version": version }));
|
117
|
-
});
|
118
|
-
|
119
|
-
it('should provide the correct version number', function () {
|
120
|
-
var project = new Project(null, './test/fixtures/adapt-package-version.json')
|
121
|
-
expect(project.getFrameworkVersion()).to.be(version);
|
122
|
-
});
|
123
|
-
|
124
|
-
after(function () {
|
125
|
-
fs.unlinkSync('./test/fixtures/adapt-package-version.json');
|
126
|
-
});
|
127
|
-
});
|
128
|
-
});
|
@@ -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
|
-
registerResult = {
|
8
|
-
success: true
|
9
|
-
},
|
10
|
-
commands = {
|
11
|
-
register: sinon.stub().yields(null, registerResult)
|
12
|
-
},
|
13
|
-
outputDevice = {
|
14
|
-
log: sinon.stub()
|
15
|
-
},
|
16
|
-
argsv = function () {
|
17
|
-
return ['node', 'register-concerns.js'].concat(Array.prototype.slice.call(arguments));
|
18
|
-
},
|
19
|
-
app = new AdaptConsoleApplication(commands, outputDevice);
|
20
|
-
|
21
|
-
describe('when I execute a register command for a new package', function () {
|
22
|
-
it('should register the package', function (done) {
|
23
|
-
var register_command = new CommandParser(argsv('register', 'package-name', 'git-endpoint'));
|
24
|
-
app.do(register_command, function (err, results) {
|
25
|
-
expect(commands.register.calledWith(outputDevice, 'package-name', 'git-endpoint')).to.be(true);
|
26
|
-
done();
|
27
|
-
});
|
28
|
-
});
|
29
|
-
});
|
30
|
-
|
31
|
-
});
|
@@ -1,55 +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
|
-
describe('Given I have a repository downloader', function () {
|
11
|
-
describe('when fetch the repo', function () {
|
12
|
-
var location = './test/fixtures/downloaded-repo',
|
13
|
-
renderer = {
|
14
|
-
log: sinon.stub()
|
15
|
-
},
|
16
|
-
eventEmitter = {
|
17
|
-
on: function (event, handler) {
|
18
|
-
if(event === 'close') {
|
19
|
-
setTimeout(handler, 100);
|
20
|
-
}
|
21
|
-
return eventEmitter;
|
22
|
-
},
|
23
|
-
then: function(handler) {
|
24
|
-
setTimeout(handler, 100);
|
25
|
-
return this;
|
26
|
-
}
|
27
|
-
},
|
28
|
-
download = sinon.stub().returns(eventEmitter);
|
29
|
-
|
30
|
-
before(function () {
|
31
|
-
mockery.registerMock('download', download);
|
32
|
-
});
|
33
|
-
|
34
|
-
it('should download the repo to the target directory', function (done) {
|
35
|
-
mockery.enable({ warnOnUnregistered:false });
|
36
|
-
var RepositoryDownloader = require('../../lib/RepositoryDownloader'),
|
37
|
-
downloader = new RepositoryDownloader({
|
38
|
-
repository : 'https://github.com/adaptlearning/adapt-cli/',
|
39
|
-
branch : 'master'
|
40
|
-
});
|
41
|
-
|
42
|
-
downloader.fetch(location)
|
43
|
-
.then(function () {
|
44
|
-
expect(download.called).to.be(true);
|
45
|
-
done();
|
46
|
-
});
|
47
|
-
});
|
48
|
-
|
49
|
-
after(function () {
|
50
|
-
mockery.deregisterAll();
|
51
|
-
mockery.disable();
|
52
|
-
});
|
53
|
-
});
|
54
|
-
|
55
|
-
});
|
@@ -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
|
-
searchResults = [
|
8
|
-
"blah"
|
9
|
-
],
|
10
|
-
commands = {
|
11
|
-
search: sinon.stub().yields(null, searchResults)
|
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 a search command for a term', function () {
|
22
|
-
it('should perform a search for the term', function (done) {
|
23
|
-
var search_command = new CommandParser(argsv('search', 'term'));
|
24
|
-
app.do(search_command, function (err, results) {
|
25
|
-
expect(commands.search.calledWith(outputDevice, 'term')).to.be(true);
|
26
|
-
done();
|
27
|
-
});
|
28
|
-
});
|
29
|
-
});
|
30
|
-
});
|
@@ -1,71 +0,0 @@
|
|
1
|
-
var sinon = require('sinon'),
|
2
|
-
expect = require('expect.js');
|
3
|
-
|
4
|
-
describe('Given I have a plugin type resolver', function () {
|
5
|
-
var PluginTypeResolver = require('../../lib/PluginTypeResolver'),
|
6
|
-
resolver = new PluginTypeResolver();
|
7
|
-
|
8
|
-
describe('when I resolve the keyword for a component', function () {
|
9
|
-
it('should provide a type of component', function () {
|
10
|
-
var keywords = ['adapt-component'];
|
11
|
-
|
12
|
-
expect(resolver.resolve(keywords).typename).to.be('component');
|
13
|
-
expect(resolver.resolve(keywords).belongsTo).to.be('components');
|
14
|
-
});
|
15
|
-
});
|
16
|
-
|
17
|
-
describe('when I resolve the keyword for an extension', function () {
|
18
|
-
it('should provide a type of extension', function () {
|
19
|
-
var keywords = ['adapt-extension'];
|
20
|
-
|
21
|
-
expect(resolver.resolve(keywords).typename).to.be('extension');
|
22
|
-
expect(resolver.resolve(keywords).belongsTo).to.be('extensions');
|
23
|
-
});
|
24
|
-
});
|
25
|
-
|
26
|
-
describe('when I resolve the keyword for a menu', function () {
|
27
|
-
it('should provide a type of menu', function () {
|
28
|
-
var keywords = ['adapt-menu'];
|
29
|
-
|
30
|
-
expect(resolver.resolve(keywords).belongsTo).to.be('menu');
|
31
|
-
expect(resolver.resolve(keywords).belongsTo).to.be('menu');
|
32
|
-
});
|
33
|
-
});
|
34
|
-
|
35
|
-
describe('when I resolve the keyword for a theme', function () {
|
36
|
-
it('should provide a type of theme', function () {
|
37
|
-
var keywords = ['adapt-theme'];
|
38
|
-
|
39
|
-
expect(resolver.resolve(keywords).belongsTo).to.be('theme');
|
40
|
-
expect(resolver.resolve(keywords).belongsTo).to.be('theme');
|
41
|
-
});
|
42
|
-
});
|
43
|
-
|
44
|
-
describe('when I have no keywords', function () {
|
45
|
-
it('should provide the default type', function () {
|
46
|
-
var keywords = undefined;
|
47
|
-
|
48
|
-
expect(resolver.resolve(keywords).typename).to.be(resolver.defaultType.typename);
|
49
|
-
expect(resolver.resolve(keywords).belongsTo).to.be(resolver.defaultType.belongsTo);
|
50
|
-
});
|
51
|
-
});
|
52
|
-
|
53
|
-
describe('when I have conflicting keywords', function () {
|
54
|
-
it('should provide the first matching type', function () {
|
55
|
-
var keywords = ['adapt-theme', 'adapt-extension'];
|
56
|
-
|
57
|
-
expect(resolver.resolve(keywords).typename).to.be('theme');
|
58
|
-
expect(resolver.resolve(keywords).belongsTo).to.be('theme');
|
59
|
-
});
|
60
|
-
});
|
61
|
-
|
62
|
-
describe('when I have an unknown keyword', function () {
|
63
|
-
it('should provide the first matching type', function () {
|
64
|
-
var keywords = ['unknown-keyword', 'adapt-theme'];
|
65
|
-
|
66
|
-
expect(resolver.resolve(keywords).typename).to.be('theme');
|
67
|
-
expect(resolver.resolve(keywords).belongsTo).to.be('theme');
|
68
|
-
});
|
69
|
-
});
|
70
|
-
|
71
|
-
});
|
@@ -1,64 +0,0 @@
|
|
1
|
-
var fs = require('fs'),
|
2
|
-
mockery = require('mockery'),
|
3
|
-
sinon = require('sinon'),
|
4
|
-
expect = require('expect.js'),
|
5
|
-
Q = require('q'),
|
6
|
-
Project = require('../../lib/Project'),
|
7
|
-
Plugin = require('../../lib/Plugin');
|
8
|
-
|
9
|
-
describe('Given I have an uninstall command', function () {
|
10
|
-
describe('when I uninstall a plugin', function () {
|
11
|
-
var bower = {
|
12
|
-
commands: {}
|
13
|
-
},
|
14
|
-
PackageMeta = {
|
15
|
-
},
|
16
|
-
renderer = {
|
17
|
-
log: sinon.stub()
|
18
|
-
};
|
19
|
-
|
20
|
-
before(function () {
|
21
|
-
fs.writeFileSync('./adapt.json', JSON.stringify(require('../fixtures/adapt.json')));
|
22
|
-
|
23
|
-
mockery.enable();
|
24
|
-
mockery.warnOnUnregistered(false);
|
25
|
-
|
26
|
-
bower.commands.uninstall = sinon.stub().returns({
|
27
|
-
on: function (event, done) {
|
28
|
-
if(event === 'end') {
|
29
|
-
setTimeout(done, 10, true);
|
30
|
-
}
|
31
|
-
return this;
|
32
|
-
}
|
33
|
-
});
|
34
|
-
mockery.registerMock('bower', bower);
|
35
|
-
|
36
|
-
PackageMeta.getKeywords = sinon.stub().returns(Q.fcall(function () {
|
37
|
-
return ['adapt-component'];
|
38
|
-
}));
|
39
|
-
mockery.registerMock('../PackageMeta', PackageMeta);
|
40
|
-
});
|
41
|
-
|
42
|
-
it('should get the keywords', function (done) {
|
43
|
-
var command = require('../../lib/commands/uninstall');
|
44
|
-
command.uninstall(renderer, 'my-plugin', function () {
|
45
|
-
expect(PackageMeta.getKeywords.called).to.be(true);
|
46
|
-
done();
|
47
|
-
});
|
48
|
-
});
|
49
|
-
|
50
|
-
it('should invoke the bower uninstall command', function (done) {
|
51
|
-
var command = require('../../lib/commands/uninstall');
|
52
|
-
command.uninstall(renderer, 'my-plugin', function () {
|
53
|
-
expect(bower.commands.uninstall.called).to.be(true);
|
54
|
-
done();
|
55
|
-
});
|
56
|
-
});
|
57
|
-
|
58
|
-
after(function () {
|
59
|
-
fs.unlinkSync('./adapt.json');
|
60
|
-
mockery.disable();
|
61
|
-
});
|
62
|
-
});
|
63
|
-
|
64
|
-
});
|
@@ -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
|
-
uninstallResult = {
|
8
|
-
success: true
|
9
|
-
},
|
10
|
-
commands = {
|
11
|
-
uninstall: sinon.stub().yields(null, uninstallResult)
|
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 uninstall command for an existing package', function () {
|
22
|
-
it('should uninstall the package', function (done) {
|
23
|
-
var uninstall_command = new CommandParser(argsv('uninstall', 'package-name'));
|
24
|
-
app.do(uninstall_command, function (err, results) {
|
25
|
-
expect(commands.uninstall.calledWith(outputDevice, 'package-name')).to.be(true);
|
26
|
-
done();
|
27
|
-
});
|
28
|
-
});
|
29
|
-
});
|
30
|
-
|
31
|
-
});
|