adapt-cli 2.1.13 → 3.0.0

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.
Files changed (114) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.json +14 -0
  3. package/README.md +150 -150
  4. package/bin/adapt.js +3 -0
  5. package/json/help-create/question.json +9 -0
  6. package/json/help-create.json +2 -1
  7. package/lib/api.js +260 -0
  8. package/lib/cli.js +61 -44
  9. package/lib/commands/authenticate.js +18 -0
  10. package/lib/commands/create/component.js +55 -72
  11. package/lib/commands/create/course.js +25 -80
  12. package/lib/commands/create/question.js +18 -0
  13. package/lib/commands/create.js +80 -85
  14. package/lib/commands/devinstall.js +35 -97
  15. package/lib/commands/help.js +31 -52
  16. package/lib/commands/install.js +16 -907
  17. package/lib/commands/ls.js +9 -24
  18. package/lib/commands/register.js +10 -195
  19. package/lib/commands/rename.js +13 -128
  20. package/lib/commands/search.js +10 -28
  21. package/lib/commands/uninstall.js +9 -136
  22. package/lib/commands/unregister.js +11 -95
  23. package/lib/commands/update.js +12 -867
  24. package/lib/commands/version.js +12 -14
  25. package/lib/integration/AdaptFramework/build.js +39 -0
  26. package/lib/integration/AdaptFramework/clone.js +27 -0
  27. package/lib/integration/AdaptFramework/deleteSrcCore.js +9 -0
  28. package/lib/integration/AdaptFramework/deleteSrcCourse.js +9 -0
  29. package/lib/integration/AdaptFramework/download.js +21 -0
  30. package/lib/integration/AdaptFramework/erase.js +34 -0
  31. package/lib/integration/AdaptFramework/getLatestVersion.js +79 -0
  32. package/lib/integration/AdaptFramework/npmInstall.js +21 -0
  33. package/lib/integration/AdaptFramework.js +19 -0
  34. package/lib/integration/Plugin.js +403 -0
  35. package/lib/integration/PluginManagement/autenticate.js +56 -0
  36. package/lib/integration/PluginManagement/install.js +222 -0
  37. package/lib/integration/PluginManagement/print.js +52 -0
  38. package/lib/integration/PluginManagement/register.js +130 -0
  39. package/lib/integration/PluginManagement/rename.js +101 -0
  40. package/lib/integration/PluginManagement/schemas.js +8 -0
  41. package/lib/integration/PluginManagement/search.js +46 -0
  42. package/lib/integration/PluginManagement/uninstall.js +141 -0
  43. package/lib/integration/PluginManagement/unregister.js +101 -0
  44. package/lib/integration/PluginManagement/update.js +224 -0
  45. package/lib/integration/PluginManagement.js +21 -0
  46. package/lib/integration/Project.js +146 -0
  47. package/lib/integration/Target.js +296 -0
  48. package/lib/integration/getBowerRegistryConfig.js +34 -0
  49. package/lib/logger.js +28 -0
  50. package/lib/util/JSONReadValidate.js +34 -0
  51. package/lib/util/constants.js +38 -0
  52. package/lib/util/createPromptTask.js +7 -0
  53. package/lib/util/download.js +45 -0
  54. package/lib/util/errors.js +58 -0
  55. package/lib/util/extract.js +24 -0
  56. package/lib/util/getDirNameFromImportMeta.js +6 -0
  57. package/lib/util/promises.js +36 -0
  58. package/package.json +20 -29
  59. package/TESTING.md +0 -25
  60. package/bin/adapt +0 -3
  61. package/gruntfile.js +0 -18
  62. package/lib/AdaptConsoleApplication.js +0 -19
  63. package/lib/CommandParser.js +0 -19
  64. package/lib/CommandTranslator.js +0 -16
  65. package/lib/ConsoleRenderer.js +0 -10
  66. package/lib/Constants.js +0 -68
  67. package/lib/JsonLoader.js +0 -40
  68. package/lib/JsonWriter.js +0 -21
  69. package/lib/PackageMeta.js +0 -41
  70. package/lib/Plugin.js +0 -53
  71. package/lib/PluginTypeResolver.js +0 -47
  72. package/lib/Project.js +0 -89
  73. package/lib/RendererHelpers.js +0 -41
  74. package/lib/RepositoryDownloader.js +0 -64
  75. package/lib/Slug.js +0 -5
  76. package/lib/VersionChecker.js +0 -7
  77. package/lib/commands/create/index.js +0 -6
  78. package/lib/commands/index.js +0 -16
  79. package/lib/commands/install/InstallLog.js +0 -32
  80. package/lib/commands/install/InstallTarget.js +0 -259
  81. package/lib/commands/install/extend.js +0 -31
  82. package/lib/download.js +0 -101
  83. package/lib/errors.js +0 -58
  84. package/lib/promise/authenticate.js +0 -58
  85. package/lib/promise/build.js +0 -20
  86. package/lib/promise/cloneInstall.js +0 -35
  87. package/lib/promise/confirmBuild.js +0 -6
  88. package/lib/promise/exec.js +0 -39
  89. package/lib/promise/getRepository.js +0 -26
  90. package/lib/promise/highest.js +0 -109
  91. package/lib/promise/install.js +0 -31
  92. package/lib/promise/installAdaptDependencies.js +0 -30
  93. package/lib/promise/installNodeDependencies.js +0 -28
  94. package/lib/promise/removeTemporaryDownload.js +0 -8
  95. package/lib/promise/replaceTextContent.js +0 -10
  96. package/lib/promise/uninstallPackage.js +0 -15
  97. package/lib/promise/update.js +0 -33
  98. package/lib/promise/util.js +0 -16
  99. package/test/fixtures/adapt-with-plugins.json +0 -6
  100. package/test/specs/command_translation_concerns.js +0 -13
  101. package/test/specs/create_command_concerns.js +0 -22
  102. package/test/specs/create_concerns.js +0 -30
  103. package/test/specs/install_concerns.js +0 -31
  104. package/test/specs/installing_compatible_plugins_concerns.js +0 -126
  105. package/test/specs/installing_incompatible_plugins_concerns.js +0 -103
  106. package/test/specs/ls_concerns.js +0 -28
  107. package/test/specs/plugin_name_concerns.js +0 -82
  108. package/test/specs/project_concerns.js +0 -128
  109. package/test/specs/registration_concerns.js +0 -31
  110. package/test/specs/repository_downloader_concerns.js +0 -55
  111. package/test/specs/search_concerns.js +0 -30
  112. package/test/specs/type_resolution_concerns.js +0 -71
  113. package/test/specs/uninstall_command_concerns.js +0 -64
  114. package/test/specs/uninstall_concerns.js +0 -31
@@ -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
- });
@@ -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
- });