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,105 +1,12 @@
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
- JsonLoader = require('../JsonLoader'),
9
- authenticate = require('../promise/authenticate'),
10
- log;
11
-
12
- module.exports = {
13
- unregister: function (renderer) {
14
- log = renderer.log;
15
-
16
- var done = arguments[arguments.length-1] || function () {};
17
- var pluginName;
18
-
19
- if (arguments.length >= 3) {
20
- pluginName = arguments[1];
21
- }
22
-
23
- log(chalk.yellow('This will unregister the plugin at', Constants.getRegistry()));
24
-
25
- getProperties(pluginName)
26
- .then(authenticate)
27
- .then(confirm)
28
- .then(unregister)
29
- .then(function() {
30
- log(chalk.green('The plugin was successfully unregistered.'));
31
- done();
32
- })
33
- .catch(function (err) {
34
- log(chalk.red(err));
35
- log('The plugin was not unregistered.');
36
- done(err);
37
- })
38
- .done();
39
- }
40
- };
41
-
42
- function getProperties(pluginName) {
43
- if (pluginName) {
44
- return Q.resolve({name:pluginName});
45
- }
46
-
47
- return loadPluginProperties('./bower.json');
48
- }
49
-
50
- function loadPluginProperties(path, defaults) {
51
- var deferred = Q.defer();
52
-
53
- path = path || './bower.json';
54
-
55
- if(!JsonLoader.existsSync(path)) {
56
- deferred.reject(new Error('bower.json is not in the current working directory. Plugins must be a valid bower package.'));
57
- }
58
- JsonLoader.readJSON(path, function (data) {
59
- deferred.resolve(_.extend({}, defaults, data));
60
- });
61
-
62
- return deferred.promise;
63
- }
64
-
65
- function confirm(properties) {
66
- var deferred = Q.defer();
67
- var schema = {
68
- properties: {
69
- ready: {
70
- description: chalk.cyan('Confirm Unregister now?'),
71
- message: 'Please specify (y)es or (n)o',
72
- pattern: /^y$|^n$/i,
73
- type: 'string',
74
- default: 'y',
75
- required: true,
76
- before: function(value) { return /^y$/i.test(value); }
77
- }
78
- }
79
- };
80
- prompt.message = '';
81
- prompt.delimiter = ' ';
82
- prompt.start();
83
- prompt.get(schema, function (err, confirmation) {
84
- if(err) return deferred.reject(err);
85
- if(!confirmation.ready) deferred.reject(new Error('Aborted. Nothing has been unregistered.'));
86
- deferred.resolve(properties);
87
- });
88
- return deferred.promise;
89
- }
90
-
91
- function unregister(properties) {
92
- var deferred = Q.defer();
93
-
94
- // user (username) with OAuth (token) wants to unregister the registered plugin (name) from registry
95
- bower.commands.unregister(properties.username+'/'+properties.name, {token:properties.token, registry: Constants.getRegistry()})
96
- .on('end', function (result) {
97
- //log('end', result);
98
- deferred.resolve();
99
- })
100
- .on('error', function (err) {
101
- //log('error', err);
102
- deferred.reject(err);
103
- });
104
- return deferred.promise;
105
- }
1
+ import { unregister as pluginUnregister } 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
+ const pluginName = args[0]
7
+ return await pluginUnregister({
8
+ logger,
9
+ cwd: process.cwd(),
10
+ pluginName
11
+ })
12
+ }