adapt-cli 2.1.11 → 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 (129) hide show
  1. package/.bowerrc +2 -2
  2. package/.eslintignore +1 -0
  3. package/.eslintrc.json +14 -0
  4. package/.travis.yml +46 -46
  5. package/README.md +266 -266
  6. package/bin/adapt.js +3 -0
  7. package/json/help-create/component.json +9 -9
  8. package/json/help-create/course.json +9 -9
  9. package/json/help-create/question.json +9 -0
  10. package/json/help-create.json +12 -11
  11. package/json/help-devinstall.json +9 -9
  12. package/json/help-install.json +10 -10
  13. package/json/help-ls.json +7 -7
  14. package/json/help-register.json +7 -7
  15. package/json/help-rename.json +7 -7
  16. package/json/help-search.json +8 -8
  17. package/json/help-uninstall.json +7 -7
  18. package/json/help-unregister.json +8 -8
  19. package/json/help-update.json +12 -12
  20. package/json/help-version.json +7 -7
  21. package/json/help.json +19 -19
  22. package/lib/api.js +260 -0
  23. package/lib/cli.js +69 -52
  24. package/lib/commands/authenticate.js +18 -0
  25. package/lib/commands/create/component.js +64 -81
  26. package/lib/commands/create/course.js +26 -87
  27. package/lib/commands/create/question.js +18 -0
  28. package/lib/commands/create.js +85 -104
  29. package/lib/commands/devinstall.js +35 -97
  30. package/lib/commands/help.js +31 -52
  31. package/lib/commands/install.js +16 -856
  32. package/lib/commands/ls.js +9 -24
  33. package/lib/commands/register.js +11 -201
  34. package/lib/commands/rename.js +14 -138
  35. package/lib/commands/search.js +11 -29
  36. package/lib/commands/uninstall.js +9 -136
  37. package/lib/commands/unregister.js +12 -105
  38. package/lib/commands/update.js +12 -889
  39. package/lib/commands/version.js +13 -15
  40. package/lib/integration/AdaptFramework/build.js +39 -0
  41. package/lib/integration/AdaptFramework/clone.js +27 -0
  42. package/lib/integration/AdaptFramework/deleteSrcCore.js +9 -0
  43. package/lib/integration/AdaptFramework/deleteSrcCourse.js +9 -0
  44. package/lib/integration/AdaptFramework/download.js +21 -0
  45. package/lib/integration/AdaptFramework/erase.js +34 -0
  46. package/lib/integration/AdaptFramework/getLatestVersion.js +79 -0
  47. package/lib/integration/AdaptFramework/npmInstall.js +21 -0
  48. package/lib/integration/AdaptFramework.js +19 -0
  49. package/lib/integration/Plugin.js +403 -0
  50. package/lib/integration/PluginManagement/autenticate.js +56 -0
  51. package/lib/integration/PluginManagement/install.js +222 -0
  52. package/lib/integration/PluginManagement/print.js +52 -0
  53. package/lib/integration/PluginManagement/register.js +130 -0
  54. package/lib/integration/PluginManagement/rename.js +101 -0
  55. package/lib/integration/PluginManagement/schemas.js +8 -0
  56. package/lib/integration/PluginManagement/search.js +46 -0
  57. package/lib/integration/PluginManagement/uninstall.js +141 -0
  58. package/lib/integration/PluginManagement/unregister.js +101 -0
  59. package/lib/integration/PluginManagement/update.js +224 -0
  60. package/lib/integration/PluginManagement.js +21 -0
  61. package/lib/integration/Project.js +146 -0
  62. package/lib/integration/Target.js +296 -0
  63. package/lib/integration/getBowerRegistryConfig.js +34 -0
  64. package/lib/logger.js +28 -0
  65. package/lib/util/JSONReadValidate.js +34 -0
  66. package/lib/util/constants.js +38 -0
  67. package/lib/util/createPromptTask.js +7 -0
  68. package/lib/util/download.js +45 -0
  69. package/lib/util/errors.js +58 -0
  70. package/lib/util/extract.js +24 -0
  71. package/lib/util/getDirNameFromImportMeta.js +6 -0
  72. package/lib/util/promises.js +36 -0
  73. package/package.json +40 -49
  74. package/TESTING.md +0 -25
  75. package/bin/adapt +0 -3
  76. package/gruntfile.js +0 -18
  77. package/lib/AdaptConsoleApplication.js +0 -19
  78. package/lib/CommandParser.js +0 -19
  79. package/lib/CommandTranslator.js +0 -15
  80. package/lib/ConsoleRenderer.js +0 -10
  81. package/lib/Constants.js +0 -69
  82. package/lib/JsonLoader.js +0 -40
  83. package/lib/JsonWriter.js +0 -21
  84. package/lib/PackageMeta.js +0 -41
  85. package/lib/Plugin.js +0 -53
  86. package/lib/PluginTypeResolver.js +0 -47
  87. package/lib/Project.js +0 -89
  88. package/lib/RendererHelpers.js +0 -51
  89. package/lib/RepositoryDownloader.js +0 -64
  90. package/lib/Slug.js +0 -5
  91. package/lib/VersionChecker.js +0 -7
  92. package/lib/commands/create/index.js +0 -6
  93. package/lib/commands/index.js +0 -16
  94. package/lib/commands/install/InstallLog.js +0 -32
  95. package/lib/commands/install/InstallTarget.js +0 -259
  96. package/lib/commands/install/extend.js +0 -31
  97. package/lib/download.js +0 -101
  98. package/lib/errors.js +0 -58
  99. package/lib/promise/authenticate.js +0 -64
  100. package/lib/promise/build.js +0 -20
  101. package/lib/promise/cloneInstall.js +0 -35
  102. package/lib/promise/confirmBuild.js +0 -7
  103. package/lib/promise/exec.js +0 -39
  104. package/lib/promise/getRepository.js +0 -26
  105. package/lib/promise/highest.js +0 -109
  106. package/lib/promise/install.js +0 -31
  107. package/lib/promise/installAdaptDependencies.js +0 -30
  108. package/lib/promise/installNodeDependencies.js +0 -28
  109. package/lib/promise/removeTemporaryDownload.js +0 -8
  110. package/lib/promise/replaceTextContent.js +0 -10
  111. package/lib/promise/uninstallPackage.js +0 -15
  112. package/lib/promise/update.js +0 -33
  113. package/lib/promise/util.js +0 -16
  114. package/test/fixtures/adapt-with-plugins.json +0 -6
  115. package/test/specs/command_translation_concerns.js +0 -13
  116. package/test/specs/create_command_concerns.js +0 -22
  117. package/test/specs/create_concerns.js +0 -30
  118. package/test/specs/install_concerns.js +0 -31
  119. package/test/specs/installing_compatible_plugins_concerns.js +0 -126
  120. package/test/specs/installing_incompatible_plugins_concerns.js +0 -103
  121. package/test/specs/ls_concerns.js +0 -28
  122. package/test/specs/plugin_name_concerns.js +0 -82
  123. package/test/specs/project_concerns.js +0 -128
  124. package/test/specs/registration_concerns.js +0 -31
  125. package/test/specs/repository_downloader_concerns.js +0 -55
  126. package/test/specs/search_concerns.js +0 -30
  127. package/test/specs/type_resolution_concerns.js +0 -71
  128. package/test/specs/uninstall_command_concerns.js +0 -64
  129. package/test/specs/uninstall_concerns.js +0 -31
@@ -1,24 +1,9 @@
1
- module.exports = function (dependencies) {
2
-
3
- var chalk = dependencies.chalk || require('chalk'),
4
- Project = dependencies.Project || require('../Project'),
5
- Constants = dependencies.Constants || require('../Constants'),
6
- RendererHelpers = dependencies.RendererHelpers || require('../RendererHelpers');
7
-
8
- return {
9
- ls: function(renderer) {
10
- var project = new Project(Constants.DefaultProjectManifestPath),
11
- done = arguments[arguments.length -1];
12
-
13
- if(project.isProjectContainsManifestFile()) {
14
- project.plugins.forEach(function (p) {
15
- renderer.log(chalk.cyan(p.name), p.version);
16
- });
17
- done();
18
- } else {
19
- RendererHelpers.reportInvalidFrameworkDirectory(renderer, done)(true);
20
- }
21
- }
22
- };
23
-
24
- };
1
+ import chalk from 'chalk'
2
+ import Project from '../integration/Project.js'
3
+
4
+ export default async function ls (logger) {
5
+ const project = new Project({ logger })
6
+ project.tryThrowInvalidPath()
7
+ const installTargets = await project.getInstallTargets()
8
+ installTargets.forEach(p => logger?.log(`${chalk.cyan(p.name || p.sourcePath)} ${p.sourcePath || p.requestedVersion}`))
9
+ }
@@ -1,201 +1,11 @@
1
- var bower = require('bower'),
2
- chalk = require('chalk'),
3
- prompt = require('prompt'),
4
- path = require('path'),
5
- _ = require('lodash'),
6
- Q = require('q'),
7
- Constants = require('../Constants'),
8
- JsonLoader = require('../JsonLoader'),
9
- JsonWriter = require('../JsonWriter'),
10
- Project = require('../Project'),
11
- Plugin = require('../Plugin'),
12
- semver = require('semver');
13
-
14
- module.exports = {
15
- register: function (renderer) {
16
- var done = arguments[arguments.length-1] || function () {};
17
-
18
- //renderer.log(chalk.yellow('This will publish this plugin to', Constants.Registry));
19
-
20
- loadPluginProperties('./bower.json', {
21
- name: undefined,
22
- repository: undefined,
23
- framework: undefined
24
- })
25
- .then(confirm)
26
- .then(function (properties) {
27
- savePluginProperties('./bower.json', properties);
28
- return properties;
29
- })
30
- .then(function (properties) {
31
- // given a package name, create two Plugin representations
32
- // if supplied name is adapt-contrib-myPackageName do a check against this name only
33
- // if suppled name is adapt-myPackageName check against this name and adapt-contrib-myPackageName
34
- // becase we don't want to allow adapt-myPackageName if adapt-contrib-myPackageName exists
35
- var plugin = new Plugin(properties.name),
36
- contribPlugin = new Plugin(properties.name, true),
37
- searches = [exists(contribPlugin)];
38
-
39
- if(!plugin.isContrib) {
40
- searches.push(exists(plugin));
41
- }
42
-
43
- return Q.all(searches)
44
- .spread(function (contribExists, pluginExists) {
45
- if(contribExists) {
46
- return reportExistence(contribPlugin, renderer);
47
- }
48
- if(pluginExists) {
49
- return reportExistence(plugin, renderer);
50
- }
51
- return register(plugin, properties.repository);
52
- });
53
- })
54
- .then(function (registered) {
55
- if(!registered.result) throw new Error('The plugin was unable to register.');
56
- renderer.log(chalk.green(registered.plugin.packageName), 'has been registered successfully.');
57
- done();
58
- })
59
- .fail(function (err) {
60
- renderer.log(chalk.red(err));
61
- done(err);
62
- })
63
- .done();
64
- }
65
- };
66
-
67
- function loadPluginProperties(path, defaults) {
68
- var deferred = Q.defer();
69
-
70
- path = path || './bower.json';
71
-
72
- if(!JsonLoader.existsSync(path)) {
73
- deferred.reject(new Error('bower.json is not in the current working directory. Plugins must be a valid bower package.'));
74
- }
75
- JsonLoader.readJSON(path, function (error, data) {
76
- if(error) {
77
- deferred.reject(new Error(error));
78
- } else {
79
- deferred.resolve(_.extend({}, defaults, data));
80
- }
81
- });
82
-
83
- return deferred.promise;
84
- }
85
-
86
- function savePluginProperties(path, values) {
87
- var deferred = Q.defer();
88
-
89
- path = path || './bower.json';
90
-
91
- if(!JsonWriter.existsSync(path)) {
92
- deferred.reject(new Error('bower.json is not in the current working directory. Plugins must be a valid bower package.'));
93
- }
94
- JsonWriter.writeJSON(path, values, function () {
95
- deferred.resolve(true);
96
- });
97
-
98
- return deferred.promise;
99
- }
100
-
101
- function confirm(properties) {
102
- var deferred = Q.defer();
103
- var plugin = new Plugin(properties.name),
104
- schema = {
105
- properties: {
106
- name: {
107
- description: chalk.cyan('name'),
108
- pattern: /^adapt-[\w|-]+?$/,
109
- message: "Name must prefixed with 'adapt' and each word separated with a hyphen(-)",
110
- type: 'string',
111
- default: plugin.toString() || 'not specified',
112
- required: true
113
- },
114
- repositoryUrl: {
115
- description: chalk.cyan('repository URL'),
116
- message: 'Please provide a repository URL of the form git://<domain><path>.git',
117
- pattern: /git:\/\/([\w\.@\:/\-~]+)(\.git)(\/)?/,
118
- type: 'string',
119
- default: properties.repository ? properties.repository.url : undefined,
120
- required: true
121
- },
122
- framework: {
123
- description: chalk.cyan('framework'),
124
- message: 'Please provide a valid semver (see https://semver.org/)',
125
- conform:function(v) {
126
- return semver.valid(semver.coerce(v));
127
- },
128
- type: 'string',
129
- default: properties.framework || '~2.0.0',
130
- required: false
131
- },
132
- ready: {
133
- description: chalk.cyan('Register now?'),
134
- message: 'Please specify (y)es or (n)o',
135
- pattern: /^y$|^n$/i,
136
- type: 'string',
137
- default: 'y',
138
- required: true,
139
- before: function(value) { return /^y$/i.test(value); }
140
- }
141
- }
142
- };
143
- prompt.message = chalk.cyan('Confirm');
144
- prompt.delimiter = ' ';
145
- prompt.start();
146
- prompt.get(schema, function (err, confirmation) {
147
- if(err) return deferred.reject(err);
148
- if(!confirmation.ready) deferred.reject(new Error('Aborted. Nothing has been registered.'));
149
-
150
- properties.name = confirmation.name;
151
- properties.repository = {type:'git', url:confirmation.repositoryUrl};
152
- properties.framework = confirmation.framework;
153
-
154
- deferred.resolve(properties);
155
- });
156
- return deferred.promise;
157
- }
158
-
159
- function register(plugin, repository) {
160
- var deferred = Q.defer();
161
-
162
- bower.commands.register(plugin.toString(), repository.url || repository, { registry: Constants.getRegistry() })
163
- .on('end', function(result) {
164
- deferred.resolve({ result: result, plugin: plugin });
165
- })
166
- .on('error', function (err) {
167
- deferred.reject(err);
168
- });
169
- return deferred.promise;
170
- }
171
-
172
- function exists(plugin) {
173
- var deferred = Q.defer();
174
-
175
- bower.commands.search(plugin.toString(), { registry: Constants.getRegistry() })
176
- .on('end', function(result) {
177
- var matches = result.filter(exactMatch(plugin.toString()));
178
- deferred.resolve(!!matches.length);
179
- })
180
- .on('error', function (err) {
181
- deferred.reject(err);
182
- });
183
- return deferred.promise;
184
- }
185
-
186
- function exactMatch(pattern) {
187
- return function (item) {
188
- if (typeof pattern === 'string') {
189
- if (pattern.toLowerCase() === item.name.toLowerCase()) {
190
- return true;
191
- }
192
- return false
193
- }
194
- var regexp = new RegExp(pattern, 'i');
195
- return regexp.test(item.name);
196
- };
197
- }
198
-
199
- function reportExistence(plugin, renderer) {
200
- renderer.log(chalk.yellow(plugin.toString()), chalk.cyan('has been previously registered. Plugin names must be unique. Try again with a different name.'));
201
- }
1
+ import { register as pluginRegister } from '../integration/PluginManagement.js'
2
+
3
+ export default async function register (logger, ...args) {
4
+ // strip flags
5
+ args = args.filter(arg => !String(arg).startsWith('--'))
6
+ return await pluginRegister({
7
+ logger,
8
+ cwd: process.cwd(),
9
+ args
10
+ })
11
+ }
@@ -1,138 +1,14 @@
1
- var bower = require('bower'),
2
- chalk = require('chalk'),
3
- _ = require('lodash'),
4
- prompt = require('prompt'),
5
- Q = require('q'),
6
- request = require('request'),
7
- Constants = require('../Constants'),
8
- Plugin = require('../Plugin'),
9
- authenticate = require('../promise/authenticate'),
10
- log;
11
-
12
- module.exports = {
13
- rename: function (renderer) {
14
- log = renderer.log;
15
-
16
- var done = arguments[arguments.length-1] || function () {};
17
-
18
- if (arguments.length >= 4) {
19
- var params = {
20
- oldName:arguments[1],
21
- newName:arguments[2]
22
- };
23
-
24
- // use Plugin to standardise name
25
- params.newName = new Plugin(params.newName).packageName;
26
-
27
- log(chalk.yellow('Using registry at', Constants.getRegistry()));
28
- log(chalk.yellow('Plugin will be renamed to', params.newName));
29
-
30
- Q(params)
31
- .then(checkPluginNameExists)
32
- .then(checkNewPluginNameDoesNotExist)
33
- .then(authenticate)
34
- .then(confirm)
35
- .then(rename)
36
- .then(function() {
37
- log(chalk.green('The plugin was successfully renamed.'));
38
- done();
39
- })
40
- .catch(function (err) {
41
- log(chalk.red(err));
42
- log('The plugin was not renamed.');
43
- done(err);
44
- })
45
- .done();
46
-
47
- } else {
48
- log(chalk.red('You must call rename with the following arguments: <plugin name> <new plugin name>'));
49
- done();
50
- }
51
- }
52
- };
53
-
54
- function checkPluginNameExists(params) {
55
- return exists(params.oldName).then(function(exists) {
56
- return exists ? Q.resolve(params) : Q.reject('Plugin "'+params.oldName+'" does not exist');
57
- });
58
- }
59
-
60
- function checkNewPluginNameDoesNotExist(params) {
61
- return exists(params.newName).then(function(exists) {
62
- return exists ? Q.reject('Name "'+params.newName+'" already exists') : Q.resolve(params);
63
- });
64
- }
65
-
66
- function confirm(params) {
67
- var deferred = Q.defer();
68
- var schema = {
69
- properties: {
70
- ready: {
71
- description: chalk.cyan('Confirm rename now?'),
72
- message: 'Please specify (y)es or (n)o',
73
- pattern: /^y$|^n$/i,
74
- type: 'string',
75
- default: 'y',
76
- required: true,
77
- before: function(value) { return /^y$/i.test(value); }
78
- }
79
- }
80
- };
81
- prompt.message = '';
82
- prompt.delimiter = ' ';
83
- prompt.start();
84
- prompt.get(schema, function (err, confirmation) {
85
- if(err) return deferred.reject(err);
86
- if(!confirmation.ready) deferred.reject(new Error('Aborted. Nothing has been renamed.'));
87
- deferred.resolve(params);
88
- });
89
- return deferred.promise;
90
- }
91
-
92
- function rename(params) {
93
- var deferred = Q.defer();
94
- var path = 'packages/rename/'+params.username+'/'+params.oldName+'/'+params.newName;
95
- var query = '?access_token='+params.token;
96
-
97
- request({
98
- url: Constants.getRegistry()+'/'+path+query,
99
- method:'GET',
100
- headers: {'User-Agent':'adapt-cli'},
101
- followRedirect:false
102
- }, function(err, res, body) {
103
- if (err) {
104
- deferred.reject(err);
105
- } else {
106
- res.statusCode==201 ? deferred.resolve(params) : deferred.reject("The server responded with "+res.statusCode);
107
- }
108
- });
109
-
110
- return deferred.promise;
111
- }
112
-
113
- function exists(plugin) {
114
- var deferred = Q.defer();
115
-
116
- bower.commands.search(plugin.toString(), { registry: Constants.getRegistry() })
117
- .on('end', function(result) {
118
- var matches = result.filter(exactMatch(plugin.toString()));
119
- deferred.resolve(!!matches.length);
120
- })
121
- .on('error', function (err) {
122
- deferred.reject(err);
123
- });
124
- return deferred.promise;
125
- }
126
-
127
- function exactMatch(pattern) {
128
- return function (item) {
129
- if (typeof pattern === 'string') {
130
- if (pattern.toLowerCase() === item.name.toLowerCase()) {
131
- return true;
132
- }
133
- return false
134
- }
135
- var regexp = new RegExp(pattern, 'i');
136
- return regexp.test(item.name);
137
- };
138
- }
1
+ import { rename as pluginRename } from '../integration/PluginManagement.js'
2
+
3
+ export default async function rename (logger, ...args) {
4
+ /** strip flags */
5
+ args = args.filter(arg => !String(arg).startsWith('--'))
6
+ const oldName = args[0]
7
+ const newName = args[1]
8
+ await pluginRename({
9
+ logger,
10
+ cwd: process.cwd(),
11
+ oldName,
12
+ newName
13
+ })
14
+ }
@@ -1,29 +1,11 @@
1
- var bower = require('bower'),
2
- chalk = require('chalk'),
3
- Constants = require('../Constants'),
4
- Plugin = require('../Plugin');
5
-
6
-
7
- module.exports = {
8
- search: function(renderer) {
9
- var searchTerm = arguments.length >= 3 ? arguments[1] : '',
10
- done = arguments[arguments.length -1] || function () {};
11
-
12
- var plugin = new Plugin(searchTerm);
13
-
14
- bower.commands.search(searchTerm, { registry: Constants.getRegistry() })
15
- .on('end', function(results) {
16
- if(!results.length) {
17
- renderer.log(chalk.yellow('no plugins found', plugin.toString()));
18
- }
19
- results.forEach(function (result) {
20
- renderer.log(chalk.cyan(result.name) + ' ' + result.url);
21
- });
22
- done();
23
- })
24
- .on('error', function (err) {
25
- renderer.log(chalk.red("Oh dear, something went wrong. I'm terribly sorry."), err);
26
- done(err);
27
- });
28
- }
29
- };
1
+ import { search as pluginsSearch } from '../integration/PluginManagement.js'
2
+
3
+ export default async function search (logger, ...args) {
4
+ /** strip flags */
5
+ args = args.filter(arg => !String(arg).startsWith('--'))
6
+ const searchTerm = (args[0] || '')
7
+ await pluginsSearch({
8
+ logger,
9
+ searchTerm
10
+ })
11
+ }
@@ -1,136 +1,9 @@
1
- var chalk = require('chalk'),
2
- fs = require('fs'),
3
- path = require('path'),
4
- rimraf = require('rimraf'),
5
- Q = require('q'),
6
- Constants = require('../Constants'),
7
- PluginTypeResolver = require('../PluginTypeResolver'),
8
- PackageMeta = require('../PackageMeta'),
9
- Project = require('../Project'),
10
- Plugin = require('../Plugin'),
11
- RendererHelpers = require('../RendererHelpers'),
12
- uninstallPackage = require('../promise/uninstallPackage'),
13
- Errors = require('../errors');
14
-
15
- module.exports = {
16
- apiuninstall:function(pluginName, cwd) {
17
- Constants.setCwd(cwd);
18
-
19
- var project = new Project(Constants.DefaultProjectManifestPath, Constants.DefaultProjectFrameworkPath);
20
-
21
- if(!project.isProjectContainsManifestFile()) {
22
- return Q.reject(Errors.ERROR_COURSE_DIR);
23
- }
24
-
25
- var plugin = Plugin.parse(pluginName);
26
- var deferred = Q.defer();
27
-
28
- PackageMeta.getKeywords(plugin, { registry: Constants.getRegistry() })
29
- .then(function (keywords) {
30
- var resolver = new PluginTypeResolver(),
31
- pluginType = resolver.resolve(keywords);
32
-
33
- return uninstallPackage(plugin, {
34
- directory: path.join('src', pluginType.belongsTo),
35
- cwd:Constants.cwd
36
- });
37
- })
38
- .then(function () {
39
- project.remove(plugin);
40
- })
41
- .then(function () {
42
- deferred.resolve(pluginName);
43
- })
44
- .fail(function() {
45
- // will fail if plugin has not been installed by Bower (i.e. the .bower.json manifest is missing)
46
- // so just try and remove the directory (this is basically what Bower does anyway)
47
-
48
- var removePath;
49
-
50
- ['components', 'extensions', 'menu', 'theme'].forEach(function(pluginType) {
51
- var pluginPath = path.join(Constants.cwd, 'src', pluginType, plugin.packageName);
52
-
53
- if (fs.existsSync(pluginPath)) {
54
- removePath = pluginPath;
55
- }
56
- });
57
-
58
- if (removePath) {
59
- rimraf(removePath, function() {
60
- if (fs.existsSync(removePath)) {
61
- deferred.reject(Errors.ERROR_UNINSTALL);
62
- } else {
63
- project.remove(plugin);
64
- deferred.resolve(pluginName);
65
- }
66
- });
67
- } else {
68
- deferred.reject(Errors.ERROR_NOT_FOUND);
69
- }
70
- });
71
-
72
- return deferred.promise;
73
- },
74
- uninstall: function (renderer) {
75
-
76
- var packageName = arguments.length >= 3 ? arguments[1] : null,
77
- done = arguments[arguments.length - 1];
78
-
79
- if(!packageName) {
80
- return renderer.log(chalk.red('Please specify a plugin to uninstall.'));
81
- }
82
-
83
- var project = new Project(Constants.DefaultProjectManifestPath);
84
- if (!project.isProjectContainsManifestFile()) {
85
- return RendererHelpers.reportInvalidFrameworkDirectory(renderer, done)(true);
86
- }
87
-
88
- var plugin = Plugin.parse(packageName);
89
-
90
- PackageMeta.getKeywords(plugin, { registry: Constants.getRegistry() })
91
- .then(function (keywords) {
92
- var resolver = new PluginTypeResolver(),
93
- pluginType = resolver.resolve(keywords);
94
-
95
- renderer.log(chalk.cyan(plugin.packageName), 'found.', 'Uninstalling', pluginType.typename, '...');
96
- return uninstallPackage(plugin, {
97
- directory: path.join('src', pluginType.belongsTo),
98
- cwd:Constants.cwd
99
- });
100
- })
101
- .then(function () {
102
- project.remove(plugin);
103
- })
104
- .then(function () {
105
- done();
106
- })
107
- .fail(function() {
108
- // will fail if plugin has not been installed by Bower (i.e. the .bower.json manifest is missing)
109
- // so just try and remove the directory (this is basically what Bower does anyway)
110
-
111
- var removePath;
112
-
113
- ['components', 'extensions', 'menu', 'theme'].forEach(function(pluginType) {
114
- var pluginPath = path.join(Constants.cwd, 'src', pluginType, plugin.packageName);
115
-
116
- if (fs.existsSync(pluginPath)) {
117
- removePath = pluginPath;
118
- }
119
- });
120
-
121
- if (removePath) {
122
- rimraf(removePath, function() {
123
- if (fs.existsSync(removePath)) {
124
- RendererHelpers.reportFailure(renderer, done);
125
- } else {
126
- project.remove(plugin);
127
- done();
128
- }
129
- });
130
- } else {
131
- RendererHelpers.reportFailure(renderer, done);
132
- }
133
- });
134
- }
135
-
136
- };
1
+ import { uninstall as pluginsUninstall } from '../integration/PluginManagement.js'
2
+
3
+ export default async function uninstall (logger, ...args) {
4
+ const plugins = args.filter(arg => !String(arg).startsWith('--'))
5
+ await pluginsUninstall({
6
+ logger,
7
+ plugins
8
+ })
9
+ }