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,31 +0,0 @@
1
- // the Backbone extend function
2
-
3
- var _ = require('lodash');
4
-
5
- module.exports = function(superClass, protoProps, staticProps) {
6
- var parent = superClass;
7
- var child;
8
-
9
- // The constructor function for the new subclass is either defined by you
10
- // (the "constructor" property in your `extend` definition), or defaulted
11
- // by us to simply call the parent constructor.
12
- if (protoProps && _.has(protoProps, 'constructor')) {
13
- child = protoProps.constructor;
14
- } else {
15
- child = function(){ return parent.apply(this, arguments); };
16
- }
17
-
18
- // Add static properties to the constructor function, if supplied.
19
- _.extend(child, parent, staticProps);
20
-
21
- // Set the prototype chain to inherit from `parent`, without calling
22
- // `parent`'s constructor function and add the prototype properties.
23
- child.prototype = _.create(parent.prototype, protoProps);
24
- child.prototype.constructor = child;
25
-
26
- // Set a convenience property in case the parent's prototype is needed
27
- // later.
28
- child.__super__ = parent.prototype;
29
-
30
- return child;
31
- };
package/lib/download.js DELETED
@@ -1,101 +0,0 @@
1
- 'use strict';
2
-
3
- var decompress = require('decompress');
4
- var eachAsync = require('each-async');
5
- var fs = require('fs');
6
- var mkdir = require('mkdirp');
7
- var path = require('path');
8
- var request = require('request');
9
- var through = require('through2');
10
-
11
- /**
12
- * Download a file to a given destination
13
- *
14
- * Options:
15
- *
16
- * - `extract` Try extracting the file
17
- * - `mode` Set mode on the downloaded files
18
- * - `strip` Equivalent to --strip-components for tar
19
- *
20
- * @param {String|Array|Object} url
21
- * @param {String} dest
22
- * @param {Object} opts
23
- * @api public
24
- */
25
-
26
- module.exports = function (url, dest, opts) {
27
- url = Array.isArray(url) ? url : [url];
28
- opts = opts || {};
29
-
30
- var stream = through();
31
- var strip = opts.strip || '0';
32
- var target;
33
-
34
- eachAsync(url, function (url, index, done) {
35
- opts.url = url;
36
- target = path.join(dest, path.basename(url));
37
-
38
- if (url.url && url.name) {
39
- target = path.join(dest, url.name);
40
- opts.url = url.url;
41
- }
42
-
43
- var req = request.get(opts)
44
- .on('response', function (res) {
45
- stream.emit('response', res);
46
- })
47
- .on('data', function (data) {
48
- stream.emit('data', data);
49
- })
50
- .on('error', function (err) {
51
- stream.emit('error', err);
52
- });
53
-
54
- req.on('response', function (res) {
55
- var mime = res.headers['content-type'];
56
- var status = res.statusCode;
57
- var end;
58
-
59
- if (status < 200 || status >= 300) {
60
- stream.emit('error', status);
61
- return;
62
- }
63
-
64
- if (opts.extract && decompress.canExtract(url, mime)) {
65
- var ext;
66
-
67
- if (decompress.canExtract(url)) {
68
- ext = url;
69
- } else {
70
- ext = mime;
71
- }
72
-
73
- end = decompress.extract({
74
- ext: ext,
75
- path: dest,
76
- strip: strip
77
- });
78
- } else {
79
- if (!fs.existsSync(dest)) {
80
- mkdir.sync(dest);
81
- }
82
-
83
- end = fs.createWriteStream(target);
84
- }
85
-
86
- req.pipe(end);
87
-
88
- end.on('close', function () {
89
- if (!opts.extract && opts.mode) {
90
- fs.chmodSync(target, opts.mode);
91
- }
92
-
93
- done();
94
- });
95
- });
96
- }, function () {
97
- stream.emit('close');
98
- });
99
-
100
- return stream;
101
- };
package/lib/errors.js DELETED
@@ -1,58 +0,0 @@
1
- module.exports = {
2
- ERROR_COURSE_DIR: {
3
- code: 0,
4
- message: "Commands must be run in an Adapt project directory"
5
- },
6
- ERROR_INCOMPATIBLE_VALID_REQUEST: {
7
- code: 1,
8
- message: "No compatible version exists (requested version is valid)"
9
- },
10
- ERROR_INCOMPATIBLE_BAD_REQUEST: {
11
- code: 2,
12
- message: "No compatible version exists (requested version is invalid)"
13
- },
14
- ERROR_INCOMPATIBLE: {
15
- code: 3,
16
- message: "No compatible version exists"
17
- },
18
- ERROR_COMPATIBLE_INC_REQUEST: {
19
- code: 4,
20
- message: "Incompatible version requested (compatible version exists)"
21
- },
22
- ERROR_COMPATIBLE_BAD_REQUEST: {
23
- code: 5,
24
- message: "Requested version is invalid"
25
- },
26
- ERROR_UNINSTALL: {
27
- code: 6,
28
- message: "The plugin could not be uninstalled"
29
- },
30
- ERROR_NOT_FOUND: {
31
- code: 7,
32
- message: "The plugin could not be found"
33
- },
34
- ERROR_NOTHING_TO_UPDATE: {
35
- code: 8,
36
- message: "Could not resolve any plugins to update"
37
- },
38
- ERROR_UPDATE_INCOMPATIBLE: {
39
- code: 9,
40
- message: "Incompatible update requested"
41
- },
42
- ERROR_INSTALL_ERROR: {
43
- code: 10,
44
- message: "Unknown installation error"
45
- },
46
- ERROR_UPDATE_ERROR: {
47
- code: 11,
48
- message: "Unknown update error"
49
- },
50
- ERROR_NO_RELEASES: {
51
- code: 12,
52
- message: "No published releases"
53
- },
54
- ERROR_NO_UPDATE: {
55
- code: 13,
56
- message: "No update available"
57
- }
58
- }
@@ -1,64 +0,0 @@
1
- var bower = require('bower'),
2
- chalk = require('chalk'),
3
- prompt = require('prompt'),
4
- Q = require('q');
5
-
6
- module.exports = function(properties) {
7
- return Q.fcall(ask, properties).then(login);
8
- };
9
-
10
- function ask(properties) {
11
- var deferred = Q.defer();
12
- var schema = {
13
- properties: {
14
- username: {
15
- description: chalk.cyan('GitHub username'),
16
- required: true
17
- },
18
- password: {
19
- description: chalk.cyan('GitHub password'),
20
- hidden: true,
21
- replace: '*',
22
- required: true
23
- }
24
- }
25
- };
26
- prompt.message = '';
27
- prompt.delimiter = ' ';
28
- prompt.start();
29
- prompt.get(schema, function (err, confirmation) {
30
- if(err) return deferred.reject(err);
31
- properties.username = confirmation.username;
32
- properties.password = confirmation.password;
33
- deferred.resolve(properties);
34
- });
35
- return deferred.promise;
36
- }
37
-
38
- function login(properties) {
39
- var deferred = Q.defer();
40
-
41
- bower.commands.login(properties.repository, {interactive:true})
42
- .on('prompt', function (prompts, callback) {
43
- callback({
44
- username:properties.username,
45
- password:properties.password
46
- });
47
- })
48
- .on('end', function (result) {
49
- if (!result || !result.token) {
50
- deferred.reject();
51
- }
52
- else {
53
- //log('end', result);
54
- //log('token ',result.token);
55
- properties.token = result.token;
56
- deferred.resolve(properties);
57
- }
58
- })
59
- .on('error', function (err) {
60
- //log('login:error', err);
61
- deferred.reject(err);
62
- });
63
- return deferred.promise;
64
- }
@@ -1,20 +0,0 @@
1
- var Q = require('q'),
2
- chalk = require('chalk'),
3
- grunt = require('grunt');
4
-
5
- module.exports = function build(properties) {
6
- var deferred = Q.defer(),
7
- cwd = process.cwd();
8
-
9
-
10
-
11
- properties.renderer.log(chalk.cyan('running build'));
12
-
13
- grunt.loadTasks(properties.localDir);
14
-
15
- process.chdir(properties.localDir);
16
- grunt.task.run(['build']);
17
- process.chdir(cwd);
18
-
19
- return properties;
20
- };
@@ -1,35 +0,0 @@
1
- var Q = require('q'),
2
- PackageMeta = require('../PackageMeta'),
3
- path = require('path'),
4
- Plugin = require('../Plugin'),
5
- mkdirp = require('mkdirp'),
6
- exec = require('child_process').exec;
7
-
8
- module.exports = function cloneInstall(plugin, options) {
9
- var deferred = Q.defer();
10
-
11
- PackageMeta.getRepositoryUrl(plugin)
12
- .then(function(repoDetails) {
13
- if (!repoDetails) {
14
- console.log(plugin);
15
- throw "Error: Plugin repository url could not be found.";
16
- }
17
- mkdirp(path.resolve(options.localPath, options.directory), function (err) {
18
- if (err) {
19
- return deferred.reject(err);
20
- }
21
- var pluginPath = path.resolve(options.localPath, options.directory, plugin.name);
22
-
23
- var url = repoDetails.url.replace(/^git:\/\//, 'https://');
24
- exec(`git clone ${url} "${pluginPath}"`);
25
- });
26
- })
27
- .then(function(repo){
28
- deferred.resolve(plugin)
29
- })
30
- .fail(function(err) {
31
- deferred.reject(err);
32
- })
33
- .done();
34
- return deferred.promise;
35
- };
@@ -1,7 +0,0 @@
1
- var Q = requie('q'),
2
- prompt = require('prompt'),
3
- build = require('./build');
4
-
5
- module.exports = function () {
6
-
7
- };
@@ -1,39 +0,0 @@
1
- var spawn = require("child_process").spawn;
2
- var Q = require("q");
3
-
4
- /**
5
- * Wrap executing a command in a promise
6
- * @param {string} command command to execute
7
- * @param {Array<string>} args Arguments to the command.
8
- * @param {string} cwd The working directory to run the command in.
9
- * @return {Promise} A promise for the completion of the command.
10
- */
11
- module.exports = function exec(command, args, cwd) {
12
- if (!command || !cwd) {
13
- return Q.reject(new Error("Both command and working directory must be given, not " + command + " and " + cwd));
14
- }
15
- if (args && !args.every(function (arg) {
16
- var type = typeof arg;
17
- return type === "boolean" || type === "string" || type === "number";
18
- })) {
19
- return Q.reject(new Error("All arguments must be a boolean, string or number"));
20
- }
21
-
22
- var deferred = Q.defer();
23
-
24
- var proc = spawn(command, args, {
25
- cwd: cwd,
26
- stdio: global.DEBUG ? "inherit" : "ignore"
27
- });
28
- proc.on("error", function (error) {
29
- deferred.reject(new Error(command + " " + args.join(" ") + " in " + cwd + " encountered error " + error.message));
30
- });
31
- proc.on("exit", function(code) {
32
- if (code !== 0) {
33
- deferred.reject(new Error(command + " " + args.join(" ") + " in " + cwd + " exited with code " + code));
34
- } else {
35
- deferred.resolve();
36
- }
37
- });
38
- return deferred.promise;
39
- };
@@ -1,26 +0,0 @@
1
- var RepositoryDownloader = require('../RepositoryDownloader'),
2
- uuid = require('uuid'),
3
- fs = require('q-io/fs'),
4
- path = require('path'),
5
- Constants = require('../Constants');
6
-
7
- module.exports = function (properties) {
8
- var downloader = new RepositoryDownloader({
9
- repository: properties.repository || Constants.FrameworkRepository,
10
- branch : properties.branch
11
- }),
12
- tmp = properties.tmp = path.join(Constants.HomeDirectory, '.adapt', 'tmp', uuid.v1());
13
-
14
- return downloader.fetch(tmp)
15
- .then(function (fileName) {
16
- return fs.copyTree(getDownloadedSourcePath(properties, fileName), properties.localDir)
17
- .then(function () {
18
- return properties;
19
- });
20
- });
21
- };
22
-
23
- function getDownloadedSourcePath(properties, fileName) {
24
- var fName = fileName ? fs.base(fileName, fs.extension(fileName)) : ((properties.repositoryName || Constants.FrameworkRepositoryName) + '-' + properties.branch);
25
- return path.join(properties.tmp, fName);
26
- }
@@ -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
- }
@@ -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,8 +0,0 @@
1
- var fs = require('q-io/fs');
2
-
3
- module.exports = function (properties) {
4
- return fs.removeTree(properties.tmp)
5
- .then(function () {
6
- return properties;
7
- });
8
- };
@@ -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
- };
@@ -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
- }
@@ -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,6 +0,0 @@
1
- {
2
- "dependencies": {
3
- "adapt-component" : "0.0.1",
4
- "adapt-extension" : "0.0.2"
5
- }
6
- }