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.
Files changed (134) hide show
  1. package/.bowerrc +2 -2
  2. package/.eslintignore +1 -0
  3. package/.eslintrc.json +14 -0
  4. package/.github/CONTRIBUTING.md +8 -0
  5. package/.github/ISSUE_TEMPLATE.md +17 -0
  6. package/.github/pull_request_template.md +25 -0
  7. package/.github/workflows/addtomainproject.yml +19 -0
  8. package/.github/workflows/releases.yml +25 -0
  9. package/.travis.yml +46 -46
  10. package/README.md +266 -266
  11. package/bin/adapt.js +3 -0
  12. package/json/help-create/component.json +9 -9
  13. package/json/help-create/course.json +9 -9
  14. package/json/help-create/question.json +9 -0
  15. package/json/help-create.json +12 -11
  16. package/json/help-devinstall.json +9 -9
  17. package/json/help-install.json +10 -10
  18. package/json/help-ls.json +7 -7
  19. package/json/help-register.json +7 -7
  20. package/json/help-rename.json +7 -7
  21. package/json/help-search.json +8 -8
  22. package/json/help-uninstall.json +7 -7
  23. package/json/help-unregister.json +8 -8
  24. package/json/help-update.json +12 -12
  25. package/json/help-version.json +7 -7
  26. package/json/help.json +19 -19
  27. package/lib/api.js +260 -0
  28. package/lib/cli.js +69 -52
  29. package/lib/commands/authenticate.js +18 -0
  30. package/lib/commands/create/component.js +64 -81
  31. package/lib/commands/create/course.js +26 -81
  32. package/lib/commands/create/question.js +18 -0
  33. package/lib/commands/create.js +94 -90
  34. package/lib/commands/devinstall.js +35 -97
  35. package/lib/commands/help.js +31 -52
  36. package/lib/commands/install.js +16 -907
  37. package/lib/commands/ls.js +9 -24
  38. package/lib/commands/register.js +11 -196
  39. package/lib/commands/rename.js +14 -129
  40. package/lib/commands/search.js +11 -29
  41. package/lib/commands/uninstall.js +9 -136
  42. package/lib/commands/unregister.js +12 -96
  43. package/lib/commands/update.js +12 -867
  44. package/lib/commands/version.js +13 -15
  45. package/lib/integration/AdaptFramework/build.js +42 -0
  46. package/lib/integration/AdaptFramework/clone.js +27 -0
  47. package/lib/integration/AdaptFramework/deleteSrcCore.js +9 -0
  48. package/lib/integration/AdaptFramework/deleteSrcCourse.js +9 -0
  49. package/lib/integration/AdaptFramework/download.js +21 -0
  50. package/lib/integration/AdaptFramework/erase.js +34 -0
  51. package/lib/integration/AdaptFramework/getLatestVersion.js +79 -0
  52. package/lib/integration/AdaptFramework/npmInstall.js +21 -0
  53. package/lib/integration/AdaptFramework.js +19 -0
  54. package/lib/integration/Plugin.js +404 -0
  55. package/lib/integration/PluginManagement/autenticate.js +56 -0
  56. package/lib/integration/PluginManagement/install.js +224 -0
  57. package/lib/integration/PluginManagement/print.js +52 -0
  58. package/lib/integration/PluginManagement/register.js +130 -0
  59. package/lib/integration/PluginManagement/rename.js +101 -0
  60. package/lib/integration/PluginManagement/schemas.js +8 -0
  61. package/lib/integration/PluginManagement/search.js +46 -0
  62. package/lib/integration/PluginManagement/uninstall.js +141 -0
  63. package/lib/integration/PluginManagement/unregister.js +101 -0
  64. package/lib/integration/PluginManagement/update.js +224 -0
  65. package/lib/integration/PluginManagement.js +21 -0
  66. package/lib/integration/Project.js +146 -0
  67. package/lib/integration/Target.js +299 -0
  68. package/lib/integration/getBowerRegistryConfig.js +34 -0
  69. package/lib/logger.js +28 -0
  70. package/lib/util/JSONReadValidate.js +34 -0
  71. package/lib/util/constants.js +38 -0
  72. package/lib/util/createPromptTask.js +7 -0
  73. package/lib/util/download.js +45 -0
  74. package/lib/util/errors.js +58 -0
  75. package/lib/util/extract.js +24 -0
  76. package/lib/util/getDirNameFromImportMeta.js +6 -0
  77. package/lib/util/promises.js +36 -0
  78. package/package.json +74 -49
  79. package/TESTING.md +0 -25
  80. package/bin/adapt +0 -3
  81. package/gruntfile.js +0 -18
  82. package/lib/AdaptConsoleApplication.js +0 -19
  83. package/lib/CommandParser.js +0 -19
  84. package/lib/CommandTranslator.js +0 -16
  85. package/lib/ConsoleRenderer.js +0 -10
  86. package/lib/Constants.js +0 -68
  87. package/lib/JsonLoader.js +0 -40
  88. package/lib/JsonWriter.js +0 -21
  89. package/lib/PackageMeta.js +0 -41
  90. package/lib/Plugin.js +0 -53
  91. package/lib/PluginTypeResolver.js +0 -47
  92. package/lib/Project.js +0 -89
  93. package/lib/RendererHelpers.js +0 -41
  94. package/lib/RepositoryDownloader.js +0 -64
  95. package/lib/Slug.js +0 -5
  96. package/lib/VersionChecker.js +0 -7
  97. package/lib/commands/create/index.js +0 -6
  98. package/lib/commands/index.js +0 -16
  99. package/lib/commands/install/InstallLog.js +0 -32
  100. package/lib/commands/install/InstallTarget.js +0 -259
  101. package/lib/commands/install/extend.js +0 -31
  102. package/lib/download.js +0 -101
  103. package/lib/errors.js +0 -58
  104. package/lib/promise/authenticate.js +0 -58
  105. package/lib/promise/build.js +0 -20
  106. package/lib/promise/cloneInstall.js +0 -35
  107. package/lib/promise/confirmBuild.js +0 -6
  108. package/lib/promise/exec.js +0 -39
  109. package/lib/promise/getRepository.js +0 -26
  110. package/lib/promise/highest.js +0 -109
  111. package/lib/promise/install.js +0 -31
  112. package/lib/promise/installAdaptDependencies.js +0 -30
  113. package/lib/promise/installNodeDependencies.js +0 -28
  114. package/lib/promise/removeTemporaryDownload.js +0 -8
  115. package/lib/promise/replaceTextContent.js +0 -10
  116. package/lib/promise/uninstallPackage.js +0 -15
  117. package/lib/promise/update.js +0 -33
  118. package/lib/promise/util.js +0 -16
  119. package/test/fixtures/adapt-with-plugins.json +0 -6
  120. package/test/specs/command_translation_concerns.js +0 -13
  121. package/test/specs/create_command_concerns.js +0 -22
  122. package/test/specs/create_concerns.js +0 -30
  123. package/test/specs/install_concerns.js +0 -31
  124. package/test/specs/installing_compatible_plugins_concerns.js +0 -126
  125. package/test/specs/installing_incompatible_plugins_concerns.js +0 -103
  126. package/test/specs/ls_concerns.js +0 -28
  127. package/test/specs/plugin_name_concerns.js +0 -82
  128. package/test/specs/project_concerns.js +0 -128
  129. package/test/specs/registration_concerns.js +0 -31
  130. package/test/specs/repository_downloader_concerns.js +0 -55
  131. package/test/specs/search_concerns.js +0 -30
  132. package/test/specs/type_resolution_concerns.js +0 -71
  133. package/test/specs/uninstall_command_concerns.js +0 -64
  134. package/test/specs/uninstall_concerns.js +0 -31
@@ -1,81 +1,64 @@
1
- var chalk = require('chalk'),
2
- Q = require('q'),
3
- getRepository = require('../../promise/getRepository'),
4
- removeTemporaryDownload = require('../../promise/removeTemporaryDownload'),
5
- replaceTextContent = require('../../promise/replaceTextContent'),
6
- slug = require('../../Slug'),
7
- Constants = require('../../Constants');
8
-
9
- module.exports = function (properties) {
10
- var fs = require('fs'),
11
- path = require('path');
12
-
13
- properties.component = {
14
- name: slug(properties.localDir),
15
- files: []
16
- };
17
- properties.relative = function (file) {
18
- return path.join(this.localDir, file);
19
- };
20
-
21
- if(addComponentToCurrentCourse()) {
22
- var componentsDirectory = 'src/components';
23
- properties.localDir = path.join(componentsDirectory, properties.localDir);
24
- if(!fs.existsSync(componentsDirectory)) fs.mkdirSync(componentsDirectory);
25
- }
26
- properties.component.files.push(properties.relative('bower.json'));
27
-
28
- return createComponent(properties)
29
- .then(function (properties) {
30
- properties.renderer.log('\n' + chalk.green(properties.localDir), 'has been created.\n');
31
-
32
- if(addComponentToCurrentCourse()) {
33
- properties.renderer.log(chalk.grey('To use this component in your course, use the registered name:') + chalk.yellow(properties.component.name));
34
- }
35
- });
36
- };
37
-
38
- function addComponentToCurrentCourse() {
39
- var fs = require('fs');
40
- return fs.existsSync('./adapt.json');
41
- }
42
-
43
- function createComponent(properties) {
44
- properties.repository = Constants.ComponentRepository;
45
- properties.repositoryName = Constants.ComponentRepositoryName;
46
- return getRepository(properties)
47
- .then(removeTemporaryDownload)
48
- .then(renameFiles)
49
- .then(renameVariables);
50
- }
51
-
52
- function renameFiles(properties) {
53
- var fs = require('fs'),
54
- path = require('path');
55
-
56
- var files = [
57
- { match: 'js/adapt-contrib-componentName.js', replace: /contrib-componentName/ },
58
- { match: 'less/componentName.less', replace: /componentName/ },
59
- { match: 'templates/componentName.hbs', replace: /componentName/ }
60
- ];
61
- var renameFiles = files.map(function (file) {
62
- return {
63
- from: properties.relative(file.match),
64
- to: properties.relative(file.match.replace(file.replace, properties.component.name))
65
- };
66
- });
67
- renameFiles.forEach(function (file) {
68
- fs.renameSync(file.from, file.to);
69
- properties.component.files.push(file.to);
70
- });
71
- return properties;
72
- }
73
-
74
- function renameVariables(properties) {
75
- var renameFileContentPromises = properties.component.files.map(function (file) {
76
- return replaceTextContent(file, (/((contrib-)?componentName)/g), properties.component.name);
77
- });
78
- return Q.all(renameFileContentPromises).then(function () {
79
- return properties;
80
- });
81
- }
1
+ import fs from 'fs-extra'
2
+ import globs from 'globs'
3
+ import path from 'path'
4
+ import chalk from 'chalk'
5
+ import slug from 'speakingurl'
6
+ import Project from '../../integration/Project.js'
7
+ import downloader from '../../util/download.js'
8
+ import { ADAPT_COMPONENT } from '../../util/constants.js'
9
+
10
+ export default async function component ({
11
+ name,
12
+ repository = ADAPT_COMPONENT,
13
+ cwd,
14
+ branch,
15
+ logger
16
+ }) {
17
+ name = slug(name, { maintainCase: true })
18
+
19
+ const project = new Project({ cwd, logger })
20
+ let pluginDir
21
+ if (project.containsManifestFile) {
22
+ const componentsDirectory = 'src/components'
23
+ pluginDir = path.join(cwd, componentsDirectory, 'adapt-' + name)
24
+ if (!fs.existsSync(componentsDirectory)) fs.mkdirSync(componentsDirectory)
25
+ } else {
26
+ pluginDir = path.join(cwd, name)
27
+ }
28
+
29
+ await downloader({
30
+ branch,
31
+ repository,
32
+ cwd: pluginDir,
33
+ logger
34
+ })
35
+
36
+ const files = await new Promise((resolve, reject) => {
37
+ globs('**', { cwd: pluginDir }, (err, matches) => {
38
+ if (err) return reject(err)
39
+ resolve(matches.map(match => path.join(pluginDir, match)))
40
+ })
41
+ })
42
+
43
+ const filesRenamed = files.map(from => {
44
+ const to = from.replace(/((contrib-)?componentName)/g, name)
45
+ fs.renameSync(from, to)
46
+ return to
47
+ })
48
+
49
+ await Promise.all(filesRenamed.map(async function (file) {
50
+ if (fs.statSync(file).isDirectory()) return
51
+ const lowerCaseName = name.toLowerCase()
52
+ const content = (await fs.readFile(file)).toString()
53
+ const modifiedContent = content
54
+ .replace(/((contrib-)?componentName)/g, name)
55
+ .replace(/((contrib-)?componentname)/g, lowerCaseName)
56
+ return fs.writeFile(file, modifiedContent)
57
+ }))
58
+
59
+ logger?.log('\n' + chalk.green(pluginDir), 'has been created.\n')
60
+
61
+ if (fs.existsSync('./adapt.json')) {
62
+ logger?.log(chalk.grey('To use this component in your course, use the registered name:') + chalk.yellow(name))
63
+ }
64
+ }
@@ -1,81 +1,26 @@
1
- var bower = require('bower'),
2
- chalk = require('chalk'),
3
- inquirer = require('inquirer'),
4
- path = require('path'),
5
- Q = require('q'),
6
- fs = require('q-io/fs'),
7
- Plugin = require('../../Plugin'),
8
- getRepository = require('../../promise/getRepository'),
9
- removeTemporaryDownload = require('../../promise/removeTemporaryDownload'),
10
- installNodeDependencies = require('../../promise/installNodeDependencies'),
11
- installAdaptDependencies = require('../../promise/installAdaptDependencies'),
12
- _ = require('lodash');
13
-
14
- module.exports = function (properties) {
15
- var progress = _.throttle(function () {
16
- properties.renderer.write(chalk.grey('.'));
17
- }, 300);
18
-
19
- return deleteExistingCourse(properties)
20
- .then(function (properties) {
21
- properties.renderer.write(chalk.cyan('downloading framework to', properties.localDir, '\t'));
22
- return properties;
23
- })
24
- .then(getRepository)
25
- .progress(function (data) {
26
- progress();
27
- return data;
28
- })
29
- .then(function (properties) {
30
- properties.renderer.log(' ', 'done!');
31
- return properties;
32
- })
33
- .then(removeTemporaryDownload)
34
- .then(installNodeDependencies)
35
- .then(installAdaptDependencies)
36
- .then(function (properties) {
37
- properties.renderer.log('\n' + chalk.green(properties.localDir), 'has been created.\n');
38
-
39
- properties.renderer.log(chalk.grey('To build the course, run:') +
40
- '\n\tcd ' + properties.localDir +
41
- '\n\tgrunt build\n');
42
-
43
- properties.renderer.log(chalk.grey('Then to view the course, run:') +
44
- '\n\tgrunt server\n');
45
- });
46
-
47
- };
48
-
49
- function deleteExistingCourse(properties) {
50
- return fs.exists(properties.localDir)
51
- .then(function (exists) {
52
- if(exists) {
53
- var deferred = Q.defer();
54
-
55
- inquirer.prompt([
56
- {
57
- name: 'overwrite existing course?',
58
- type: 'confirm',
59
- default: false
60
- }
61
- ]).then(results => {
62
- if(results['overwrite existing course?']) {
63
- fs.removeTree(properties.localDir)
64
- .then(function (){
65
- deferred.resolve(properties);
66
- })
67
- .fail(function (err) {
68
- deferred.reject(err);
69
- });
70
- } else {
71
- deferred.reject(new Error('Course already exists and cannot overwrite.'));
72
- }
73
- }).catch(err => deferred.reject(err));
74
-
75
- return deferred.promise;
76
- }
77
- })
78
- .then(function () {
79
- return properties;
80
- });
81
- }
1
+ import chalk from 'chalk'
2
+ import {
3
+ erase,
4
+ download,
5
+ npmInstall
6
+ } from '../../integration/AdaptFramework.js'
7
+ import path from 'path'
8
+ import { install as pluginsInstall } from '../../integration/PluginManagement.js'
9
+
10
+ export default async function course ({ name, branch, cwd, logger }) {
11
+ cwd = path.join(cwd, name)
12
+ await erase({ logger, cwd })
13
+ await download({ logger, cwd, branch })
14
+ await npmInstall({ logger, cwd })
15
+ await pluginsInstall({ logger, cwd })
16
+ logger?.log(`
17
+ ${chalk.green(name)} has been created.
18
+
19
+ ${chalk.grey('To build the course, run:')}
20
+ cd ${name}
21
+ grunt build
22
+
23
+ ${chalk.grey('Then to view the course, run:')}
24
+ grunt server
25
+ `)
26
+ }
@@ -0,0 +1,18 @@
1
+ import component from './component.js'
2
+ import { ADAPT_QUESTION } from '../../util/constants.js'
3
+
4
+ export default async function question ({
5
+ name,
6
+ repository = ADAPT_QUESTION,
7
+ cwd,
8
+ branch,
9
+ logger
10
+ }) {
11
+ return component({
12
+ name,
13
+ repository,
14
+ cwd,
15
+ branch,
16
+ logger
17
+ })
18
+ }
@@ -1,90 +1,94 @@
1
- var bower = require('bower'),
2
- chalk = require('chalk'),
3
- inquirer = require('inquirer'),
4
- path = require('path'),
5
- Q = require('q'),
6
- Constants = require('../Constants'),
7
- Plugin = require('../Plugin'),
8
- create = require('./create/index'),
9
- highest = require('../promise/highest'),
10
- _ = require('lodash');
11
-
12
- module.exports = {
13
- create: function (renderer) {
14
- var type = arguments.length >= 3 ? arguments[1] : Constants.DefaultCreateType,
15
- localDir = arguments.length >= 4 ? arguments[2] : undefined,
16
- branch = arguments.length >= 5 ? arguments[3] : undefined,
17
- done = arguments[arguments.length-1];
18
- highest()
19
- .then(function (tag) {
20
- return confirm({
21
- type: type,
22
- localDir: localDir,
23
- branch: branch || tag,
24
- renderer: renderer
25
- });
26
- })
27
- .then(function (properties) {
28
- var action = create[properties.type];
29
- if(!action) throw new Error('' + properties.type + ' is not a supported type');
30
- return action(properties);
31
- })
32
- .then(function () {
33
- done();
34
- })
35
- .fail(function (err) {
36
- renderer.log(chalk.red("Oh dear, something went wrong. I'm terribly sorry."), err.message);
37
- done(err);
38
- });
39
- }
40
- };
41
-
42
- function confirm(properties) {
43
- var deferred = Q.defer(),
44
- renderer = properties.renderer;
45
-
46
- var typeSchema = [
47
- {
48
- name: 'type',
49
- choices: [ 'course', 'component' ],
50
- type: 'list',
51
- default: properties.type
52
- }
53
- ];
54
-
55
- inquirer.prompt(typeSchema).then(typeSchemaResults => {
56
- var propertySchema = [
57
- {
58
- name: 'localDir',
59
- message: 'name',
60
- type: 'input',
61
- default: properties.localDir || Constants.DefaultTypeNames[typeSchemaResults.type]
62
- },
63
- {
64
- name: 'branch',
65
- message: 'branch/tag',
66
- type: 'input',
67
- default: properties.branch || 'not specified'
68
- },
69
- {
70
- name: 'ready',
71
- message: 'create now?',
72
- type: 'confirm',
73
- default: true
74
- }
75
- ];
76
-
77
- inquirer.prompt(propertySchema).then(propertySchemaResults => {
78
- if(!propertySchemaResults.ready) deferred.reject(new Error('Aborted. Nothing has been created.'));
79
-
80
- var properties = _.extend({},
81
- typeSchemaResults,
82
- propertySchemaResults,
83
- {
84
- renderer: renderer
85
- });
86
- deferred.resolve(properties);
87
- }).catch(err => deferred.reject(err));
88
- }).catch(err => deferred.reject(err));
89
- return deferred.promise;
90
- }
1
+ import inquirer from 'inquirer'
2
+ import component from './create/component.js'
3
+ import question from './create/question.js'
4
+ import course from './create/course.js'
5
+ import { ADAPT_FRAMEWORK } from '../util/constants.js'
6
+ import { getLatestVersion as getAdaptLatestVersion } from '../integration/AdaptFramework.js'
7
+
8
+ const subTasks = {
9
+ component,
10
+ question,
11
+ course
12
+ }
13
+
14
+ /**
15
+ * TODO: Change component name to camel case
16
+ */
17
+ export const DEFAULT_TYPE_NAME = {
18
+ course: 'my-adapt-course',
19
+ component: 'myAdaptComponent',
20
+ question: 'myAdaptQuestion'
21
+ }
22
+
23
+ export default async function create (logger, type = 'course', name, branch, bypassPrompts) {
24
+ let options = {
25
+ type,
26
+ name,
27
+ branch
28
+ }
29
+
30
+ if (!bypassPrompts) {
31
+ options = await confirmOptions({
32
+ type,
33
+ name,
34
+ branch,
35
+ logger
36
+ })
37
+ }
38
+
39
+ const action = subTasks[options.type]
40
+ if (!action) throw new Error('' + options.type + ' is not a supported type')
41
+ try {
42
+ await action({
43
+ name: options.name,
44
+ branch: options.branch,
45
+ cwd: process.cwd(),
46
+ logger
47
+ })
48
+ } catch (err) {
49
+ logger?.error("Oh dear, something went wrong. I'm terribly sorry.", err.message)
50
+ throw err
51
+ }
52
+ }
53
+
54
+ async function confirmOptions ({ logger, type, name, branch }) {
55
+ const typeSchema = [
56
+ {
57
+ name: 'type',
58
+ choices: ['course', 'component', 'question'],
59
+ type: 'list',
60
+ default: type
61
+ }
62
+ ]
63
+ const typeSchemaResults = await inquirer.prompt(typeSchema)
64
+ branch = branch || (typeSchemaResults.type === 'course')
65
+ ? await getAdaptLatestVersion({ repository: ADAPT_FRAMEWORK })
66
+ : 'master'
67
+ const propertySchema = [
68
+ {
69
+ name: 'name',
70
+ message: 'name',
71
+ type: 'input',
72
+ default: name || DEFAULT_TYPE_NAME[typeSchemaResults.type]
73
+ },
74
+ {
75
+ name: 'branch',
76
+ message: 'branch/tag',
77
+ type: 'input',
78
+ default: branch || 'not specified'
79
+ },
80
+ {
81
+ name: 'ready',
82
+ message: 'create now?',
83
+ type: 'confirm',
84
+ default: true
85
+ }
86
+ ]
87
+ const propertySchemaResults = await inquirer.prompt(propertySchema)
88
+ if (!propertySchemaResults.ready) throw new Error('Aborted. Nothing has been created.')
89
+ const finalProperties = {
90
+ ...typeSchemaResults,
91
+ ...propertySchemaResults
92
+ }
93
+ return finalProperties
94
+ }
@@ -1,97 +1,35 @@
1
- var promise = require('../promise/util');
2
-
3
- module.exports = function (dependencies) {
4
-
5
- var chalk = dependencies.chalk || require('chalk'),
6
- path = dependencies.path || require('path'),
7
- Q = dependencies.Q || require('q'),
8
- Constants = dependencies.Constants || require('../Constants'),
9
- PluginTypeResolver = dependencies.PluginTypeResolver || require('../PluginTypeResolver'),
10
- PackageMeta = dependencies.PackageMeta || require('../PackageMeta'),
11
- Project = dependencies.Project || require('../Project'),
12
- Plugin = dependencies.Plugin || require('../Plugin'),
13
- RendererHelpers = dependencies.RendererHelpers || require('../RendererHelpers'),
14
- VersionChecker = dependencies.VersionChecker || require('../VersionChecker'),
15
- install = dependencies.install || require('../promise/install'),
16
- cloneInstall = dependencies.cloneInstall || require('../promise/cloneInstall'),
17
- mkdirp = require('mkdirp'),
18
- exec = require('child_process').exec;
19
-
20
- function clonePlugins(localPath, renderer) {
21
- renderer.log("Cloning Plugins");
22
-
23
- var project = new Project(
24
- path.resolve(localPath, Constants.DefaultProjectManifestPath),
25
- path.resolve(localPath, Constants.DefaultProjectFrameworkPath)
26
- ),
27
- plugins = project.plugins;
28
-
29
-
30
-
31
- plugins.forEach(function(plugin, index, array) {
32
- createInstallationTask(plugin, localPath, renderer);
33
- });
34
- }
35
-
36
-
37
- function createInstallationTask(plugin, localPath, renderer) {
38
- return PackageMeta.getKeywords(plugin, { registry: Constants.getRegistry() })
39
- .then(function (keywords) {
40
- var resolver = new PluginTypeResolver(),
41
- pluginType = resolver.resolve(keywords);
42
-
43
- renderer.log(chalk.cyan(plugin.packageName), 'found.', 'Installing', pluginType.typename, '...');
44
- return cloneInstall(plugin, {
45
- localPath: localPath,
46
- directory: path.join('src', pluginType.belongsTo),
47
- registry: Constants.getRegistry()
48
- });
49
- })
50
- .then(function (installed) {
51
- if (!installed) throw new Error('The plugin was found but failed to download and install.');
52
- renderer.log(chalk.green(plugin.packageName), 'has been installed successfully.');
53
- })
54
- .done();
55
- }
56
-
57
- return {
58
- devinstall: function (renderer) {
59
-
60
- var repository = arguments.length >= 3 ? arguments[1] : Constants.FrameworkRepository,
61
- localPath = path.resolve(Constants.FrameworkRepositoryName),
62
- done = arguments[arguments.length-1] || function () {};
63
-
64
- try {
65
- // Are we inside an existing adapt_framework project.
66
- var packageJson = require(process.cwd() + '/package.json');
67
- if (packageJson.name === 'adapt_framework') {
68
- localPath = process.cwd();
69
- }
70
- } catch (err) {
71
- // Don't worry, we're not inside a framework directory.
72
- }
73
-
74
- // we're trying to install a single plugin.
75
- if (repository !== Constants.FrameworkRepository) {
76
- return createInstallationTask(Plugin.parse(repository), localPath, renderer)
77
- }
78
-
79
- function promiseFromChildProcess(child) {
80
- return new Promise(function (resolve, reject) {
81
- child.addListener("error", reject);
82
- child.addListener("exit", resolve);
83
- });
84
- }
85
- var child = exec(`git clone ${repository} "${localPath}"`);
86
-
87
- // clone the framework and all the bundled plugins.
88
- renderer.log("Cloning adapt_framework");
89
- promiseFromChildProcess(child)
90
- .then(function(repo){
91
- renderer.log("Framework cloned.");
92
- process.chdir(localPath);
93
- clonePlugins(localPath, renderer, done);
94
- });
95
- }
96
- };
97
- };
1
+ import { clone as adaptClone } from '../integration/AdaptFramework.js'
2
+ import { install as pluginsInstall } from '../integration/PluginManagement.js'
3
+ import { ADAPT_FRAMEWORK } from '../util/constants.js'
4
+ import path from 'path'
5
+ import Project from '../integration/Project.js'
6
+ import gh from 'parse-github-url'
7
+
8
+ export default async function devinstall (logger, ...args) {
9
+ const NAME = gh(ADAPT_FRAMEWORK).repo
10
+ const isInAdapt = new Project().isAdaptDirectory
11
+ // In adapt folder or download adapt into adapt_framework folder
12
+ const cwd = isInAdapt
13
+ ? process.cwd()
14
+ : path.resolve(NAME)
15
+ // strip flags
16
+ const isClean = args.includes('--clean')
17
+ const isDryRun = args.includes('--dry-run') || args.includes('--check')
18
+ const isCompatibleEnabled = args.includes('--compatible')
19
+ args = args.filter(arg => !String(arg).startsWith('--'))
20
+ // always perform a clone on the adapt directory
21
+ if (!isInAdapt || args.includes(NAME)) {
22
+ await adaptClone({ logger, cwd })
23
+ args = args.filter(arg => arg !== NAME)
24
+ }
25
+ const plugins = args
26
+ return await pluginsInstall({
27
+ logger,
28
+ cwd,
29
+ isClean,
30
+ isDryRun,
31
+ isCompatibleEnabled,
32
+ dev: true,
33
+ plugins
34
+ })
35
+ }