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
@@ -0,0 +1,34 @@
1
+ import fs from 'fs-extra'
2
+ import { findUpSync } from 'find-up'
3
+
4
+ export default function getBowerRegistryConfig ({ cwd = process.cwd() } = {}) {
5
+ function getConfig () {
6
+ if (process.env.ADAPT_REGISTRY) {
7
+ return process.env.ADAPT_REGISTRY
8
+ }
9
+ const configPath = findUpSync('.bowerrc', { cwd })
10
+ if (configPath) {
11
+ // a manifest exists, load it
12
+ const config = fs.readJSONSync(configPath)
13
+ return config.registry
14
+ }
15
+ // use the default Adapt registry
16
+ return 'http://adapt-bower-repository.herokuapp.com/'
17
+ }
18
+ // normalize to https://github.com/bower/spec/blob/master/config.md
19
+ const config = getConfig()
20
+ let normalized = {}
21
+ switch (typeof config) {
22
+ case 'string':
23
+ normalized = {
24
+ register: config,
25
+ search: [config]
26
+ }
27
+ break
28
+ case 'object':
29
+ Object.assign(normalized, config)
30
+ break
31
+ }
32
+ if (typeof normalized.search === 'string') normalized.search = [normalized.search].filter(Boolean)
33
+ return normalized
34
+ }
package/lib/logger.js ADDED
@@ -0,0 +1,28 @@
1
+ import readline from 'readline'
2
+ import chalk from 'chalk'
3
+
4
+ export default {
5
+ isLoggingProgress: false,
6
+ logProgress (...args) {
7
+ this.isLoggingProgress = true
8
+ readline.cursorTo(process.stdout, 0)
9
+ this.write(args.join(' '))
10
+ },
11
+ warn (...args) {
12
+ chalk.yellow(...args)
13
+ },
14
+ error (...args) {
15
+ chalk.red(...args)
16
+ },
17
+ log (...args) {
18
+ if (this.isLoggingProgress) {
19
+ this.isLoggingProgress = false
20
+ readline.cursorTo(process.stdout, 0)
21
+ this.write(args.join(' '))
22
+ this.write('\n')
23
+ return
24
+ }
25
+ console.log.apply(console, args)
26
+ },
27
+ write: process.stdout.write.bind(process.stdout)
28
+ }
@@ -0,0 +1,34 @@
1
+ import fs from 'fs-extra'
2
+ import JSONLint from 'json-lint'
3
+
4
+ /**
5
+ * @param {string} filepath
6
+ * @param {function} [done]
7
+ * @returns {Promise}
8
+ */
9
+ export async function readValidateJSON (filepath, done) {
10
+ try {
11
+ const data = await fs.readFile(filepath, 'utf8')
12
+ validateJSON(data, filepath)
13
+ done?.(null, JSON.parse(data))
14
+ return JSON.parse(data)
15
+ } catch (err) {
16
+ done?.(err.message)
17
+ }
18
+ }
19
+
20
+ export function readValidateJSONSync (filepath) {
21
+ const data = fs.readFileSync(filepath, 'utf-8')
22
+ validateJSON(data, filepath)
23
+ return JSON.parse(data)
24
+ }
25
+
26
+ function validateJSON (jsonData, filepath) {
27
+ const lint = JSONLint(jsonData)
28
+ if (!lint.error) return
29
+ let errorMessage = 'JSON parsing error: ' + lint.error + ', line: ' + lint.line + ', character: ' + lint.character
30
+ if (filepath) {
31
+ errorMessage += ', file: \'' + filepath + '\''
32
+ }
33
+ throw new Error(errorMessage)
34
+ }
@@ -0,0 +1,38 @@
1
+ import fs from 'fs-extra'
2
+
3
+ export const ADAPT_ALLOW_PRERELEASE = process.env.ADAPT_ALLOW_PRERELEASE !== 'false'
4
+
5
+ export const ADAPT_FRAMEWORK = process.env.ADAPT_FRAMEWORK || 'https://github.com/adaptlearning/adapt_framework'
6
+
7
+ export const ADAPT_COMPONENT = process.env.ADAPT_COMPONENT || 'https://github.com/adaptlearning/adapt-component'
8
+
9
+ export const ADAPT_QUESTION = process.env.ADAPT_QUESTION || 'https://github.com/adaptlearning/adapt-questionComponent'
10
+
11
+ export const ADAPT_DEFAULT_USER_AGENT = process.env.ADAPT_DEFAULT_USER_AGENT || 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36'
12
+
13
+ export const HOME_DIRECTORY = [
14
+ process.env.HOME,
15
+ (process.env.HOMEDRIVE + process.env.HOMEPATH),
16
+ process.env.USERPROFILE,
17
+ '/tmp',
18
+ '/temp'
19
+ ].filter(fs.existsSync)[0]
20
+
21
+ /** @type {string} */
22
+ export const PLUGIN_TYPES = [
23
+ 'component',
24
+ 'extension',
25
+ 'menu',
26
+ 'theme'
27
+ ]
28
+
29
+ /** @type {Object} */
30
+ export const PLUGIN_TYPE_FOLDERS = {
31
+ component: 'components',
32
+ extension: 'extensions',
33
+ menu: 'menu',
34
+ theme: 'theme'
35
+ }
36
+
37
+ /** @type {string} */
38
+ export const PLUGIN_DEFAULT_TYPE = PLUGIN_TYPES[0]
@@ -0,0 +1,7 @@
1
+ import inquirer from 'inquirer'
2
+
3
+ export async function createPromptTask (question) {
4
+ question = Object.assign({}, { name: 'question' }, question)
5
+ const confirmation = await inquirer.prompt([question])
6
+ return confirmation.question
7
+ }
@@ -0,0 +1,45 @@
1
+ import chalk from 'chalk'
2
+ import uuid from 'uuid'
3
+ import fs from 'fs-extra'
4
+ import path from 'path'
5
+ import urljoin from 'url-join'
6
+ import fetch from 'download'
7
+ import { HOME_DIRECTORY } from './constants.js'
8
+ import gh from 'parse-github-url'
9
+
10
+ export default async function download ({
11
+ repository,
12
+ branch,
13
+ tmp,
14
+ cwd,
15
+ logger
16
+ } = {}) {
17
+ if (!branch && !repository) throw new Error('Repository details are required.')
18
+ const repositoryName = gh(repository).name
19
+ logger?.write(chalk.cyan(`downloading ${repositoryName} to ${cwd}\t`))
20
+ tmp = (tmp || path.join(HOME_DIRECTORY, '.adapt', 'tmp', uuid.v1()))
21
+ const downloadFileName = await new Promise((resolve, reject) => {
22
+ let downloadFileName = ''
23
+ const url = urljoin(repository, 'archive', branch + '.zip')
24
+ fetch(url, tmp, {
25
+ extract: true
26
+ })
27
+ .on('response', response => {
28
+ const disposition = response.headers['content-disposition']
29
+ if (disposition?.indexOf('attachment') === -1) return
30
+ const regex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/
31
+ const matches = regex.exec(disposition)
32
+ if (!matches?.[1]) return
33
+ downloadFileName = matches[1].replace(/['"]/g, '')
34
+ })
35
+ .on('error', reject)
36
+ .then(() => resolve(downloadFileName))
37
+ })
38
+ const sourceFileName = downloadFileName
39
+ ? path.parse(downloadFileName).name
40
+ : `${repositoryName}-${branch}`
41
+ const sourcePath = path.join(tmp, sourceFileName)
42
+ await fs.copy(sourcePath, cwd)
43
+ await fs.rm(tmp, { recursive: true })
44
+ logger?.log(' ', 'done!')
45
+ }
@@ -0,0 +1,58 @@
1
+ export default {
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
+ }
@@ -0,0 +1,24 @@
1
+ import uuid from 'uuid'
2
+ import path from 'path'
3
+ import decompress from 'decompress'
4
+ import { HOME_DIRECTORY } from './constants.js'
5
+
6
+ export default async function extract ({
7
+ sourcePath,
8
+ cwd
9
+ } = {}) {
10
+ const rootPath = path.join(HOME_DIRECTORY, '.adapt', 'tmp', uuid.v1()).replace(/\\/g, '/')
11
+ const files = await decompress(path.join(cwd, sourcePath), rootPath, {
12
+ filter: file => !file.path.endsWith('/')
13
+ })
14
+ const rootDirectories = Object.keys(files.reduce((memo, file) => { memo[file.path.split(/\\|\//g)[0]] = true; return memo }, {}))
15
+ let copyPath = rootPath
16
+ if (rootDirectories.length === 1) {
17
+ const rootDirectory = files[0].path.split(/\\|\//g)[0]
18
+ copyPath = path.join(rootPath, rootDirectory)
19
+ }
20
+ return {
21
+ rootPath,
22
+ copyPath
23
+ }
24
+ }
@@ -0,0 +1,6 @@
1
+ export default function getDirNameFromImportMeta (importMeta) {
2
+ const __dirname = (process.platform === 'win32')
3
+ ? new URL('.', importMeta.url).pathname.slice(1)
4
+ : new URL('.', import.meta.url).pathname
5
+ return __dirname
6
+ }
@@ -0,0 +1,36 @@
1
+ import { eachOfLimit, eachOfSeries } from 'async'
2
+ /**
3
+ * Execute all promises in parallel, call progress at each promise to allow
4
+ * progress reporting
5
+ * @param {Array} array
6
+ * @param {function} iterator
7
+ * @param {function} progress
8
+ * @returns
9
+ */
10
+ export async function eachOfLimitProgress (array, iterator, progress) {
11
+ let currentIndex = 0
12
+ progress(0)
13
+ await eachOfLimit(array, 8, async item => {
14
+ currentIndex++
15
+ progress(parseInt((currentIndex * 100) / array.length))
16
+ return iterator(item)
17
+ })
18
+ }
19
+
20
+ /**
21
+ * Execute iterator against each item in the array waiting for the iterator returned
22
+ * to finish before continuing, calling progress as each stage
23
+ * @param {Array} array
24
+ * @param {function} iterator
25
+ * @param {function} progress
26
+ * @returns
27
+ */
28
+ export async function eachOfSeriesProgress (array, iterator, progress) {
29
+ let currentIndex = 0
30
+ progress(0)
31
+ await eachOfSeries(array, async item => {
32
+ currentIndex++
33
+ progress(parseInt((currentIndex * 100) / array.length))
34
+ return iterator(item)
35
+ })
36
+ }
package/package.json CHANGED
@@ -1,49 +1,40 @@
1
- {
2
- "name": "adapt-cli",
3
- "version": "2.1.11",
4
- "description": "Command line tools for Adapt",
5
- "main": "./lib/cli.js",
6
- "directories": {
7
- "test": "test"
8
- },
9
- "dependencies": {
10
- "async": "^3.1.0",
11
- "bower": "^1.8.4",
12
- "bower-endpoint-parser": "^0.2.2",
13
- "chalk": "^2.4.1",
14
- "debug": "^4.1.0",
15
- "download": "^7.1.0",
16
- "grunt": "^1.0.3",
17
- "json-lint": "^0.1.0",
18
- "lodash": "^4.17.11",
19
- "mkdirp": "^0.5.1",
20
- "npm": "^6.4.1",
21
- "prompt": "^1.0.0",
22
- "q": "^1.5.1",
23
- "q-io": "^1.13.6",
24
- "request": "^2.88.0",
25
- "semver": "^5.6.0",
26
- "speakingurl": "^14.0.1",
27
- "url-join": "^4.0.0",
28
- "uuid": "^3.3.2"
29
- },
30
- "devDependencies": {
31
- "expect.js": "^0.3.1",
32
- "grunt-mocha-test": "^0.13.3",
33
- "matchdep": "^2.0.0",
34
- "mocha": "^5.2.0",
35
- "mockery": "^2.1.0",
36
- "rimraf": "^2.6.2",
37
- "sinon": "^7.1.0"
38
- },
39
- "scripts": {
40
- "test": "grunt test"
41
- },
42
- "author": "",
43
- "repository": "http://github.com/adaptlearning/adapt-cli",
44
- "license": "GPL-3.0",
45
- "preferGlobal": true,
46
- "bin": {
47
- "adapt": "./bin/adapt"
48
- }
49
- }
1
+ {
2
+ "name": "adapt-cli",
3
+ "version": "3.0.0",
4
+ "description": "Command line tools for Adapt",
5
+ "main": "./lib/api.js",
6
+ "type": "module",
7
+ "dependencies": {
8
+ "async": "^3.2.3",
9
+ "bower": "^1.8.13",
10
+ "bower-endpoint-parser": "^0.2.2",
11
+ "chalk": "^2.4.1",
12
+ "decompress": "^4.2.1",
13
+ "download": "^7.1.0",
14
+ "find-up": "^6.2.0",
15
+ "fs-extra": "^10.0.0",
16
+ "globs": "^0.1.4",
17
+ "inquirer": "^7.3.3",
18
+ "json-lint": "^0.1.0",
19
+ "lodash-es": "^4.17.21",
20
+ "parse-github-url": "^1.0.2",
21
+ "request": "^2.88.0",
22
+ "semver": "^7.3.5",
23
+ "speakingurl": "^14.0.1",
24
+ "url-join": "^4.0.0",
25
+ "uuid": "^3.3.2"
26
+ },
27
+ "repository": "http://github.com/adaptlearning/adapt-cli",
28
+ "license": "GPL-3.0",
29
+ "preferGlobal": true,
30
+ "bin": {
31
+ "adapt": "./bin/adapt.js"
32
+ },
33
+ "devDependencies": {
34
+ "eslint": "^7.31.0",
35
+ "eslint-config-standard": "^16.0.3",
36
+ "eslint-plugin-import": "^2.23.4",
37
+ "eslint-plugin-node": "^11.1.0",
38
+ "eslint-plugin-promise": "^5.1.0"
39
+ }
40
+ }
package/TESTING.md DELETED
@@ -1,25 +0,0 @@
1
- ### Instructions for testing the adapt-cli update command
2
-
3
- - Use the current LTS version of Node (v8.11.1) as per the [guidance](https://github.com/adaptlearning/adapt_framework/wiki/Setting-up-your-development-environment). Don’t forget to have `grunt` installed globally (`npm install –g grunt-cli`) when you install a new version of Node.
4
- - Install globally the latest pre-release of adapt-cli (`npm install -g adapt-cli@next`)
5
- - Select an Adapt project to test against. At this point you may find it useful to add the contents of the Adapt installation to version control if you haven't already. This will allow you test the functionality and be able to see easily any changes made to the file system and also be able to revert changes and test alternative commands.
6
- - Run `adapt help update` for guidance using the `update` command and for command syntax.
7
- - Now run `adapt update`. If you installed the latest version of the framework together with all the latest plugins there should not have been any changes to the installed plugins and you will see a summary of your installed plugins.
8
- - You can add the `--check` option to review installed plugins without making changes. For each plugin the output will give its name, the version installed and indicate whether the plugin can be updated.
9
- - The update can be limited to specific plugins by providing their names, or to specific groups of plugins by specifying one or more of `components`, `extensions`, `menu`, `theme`.
10
- - Attempt to install different versions of various plugins; e.g. `adapt update adapt-contrib-media@>=3`. Observe the changes (if any).
11
- - Explore different scenarios; for example updating multiple plugins or groups of plugins together, try different semver ranges and also try the above with older versions of the Adapt framework.
12
-
13
- ### Important Notes
14
-
15
- The outcome of an `update` command ensures that all updated plugins reflect the requested versions held on the server. As such **any local changes will be overwritten**.
16
-
17
- The `update` command does **not** use or modify the Adapt manifest (`adapt.json`).
18
-
19
- Occasionally the command may report that one or more plugins cannot be found at the repository. This is a known limitation. The command will attempt to query the repository mulitple times before giving up. The issue is usually resolved by running the command again.
20
-
21
- ### Issue logging
22
-
23
- Log issues to the adapt-cli [issue list](https://github.com/adaptlearning/adapt-cli/issues) on GitHub. Please check the list before submission to see if the issue has already been reported.
24
-
25
- As always please report any problems with full steps to reproduce; including what version of Adapt you are using, list of plugins being updated (giving current and target version numbers), the `update` command, the environment (platform, version of Node etc) and of course the error (with stack trace if available).
package/bin/adapt DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- var cli = require('../lib/cli');
3
- cli.withOptions().withPackage().execute();
package/gruntfile.js DELETED
@@ -1,18 +0,0 @@
1
- module.exports = function(grunt) {
2
- require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
3
-
4
- grunt.initConfig({
5
- pkg: grunt.file.readJSON('package.json'),
6
- mochaTest: {
7
- test: {
8
- options: {
9
- reporter: 'spec'
10
- },
11
- src: ['test/specs/**/*.js']
12
- }
13
- }
14
- });
15
-
16
- grunt.registerTask('default', ['mochaTest']);
17
- grunt.registerTask('test', ['mochaTest']);
18
- };
@@ -1,19 +0,0 @@
1
- var AdaptConsoleApplication = function (commands, renderer) {
2
- this.renderer = renderer || require('./ConsoleRenderer');
3
- this.commands = commands;
4
- };
5
-
6
- AdaptConsoleApplication.prototype.do = function (command, done) {
7
- done = done || function () {};
8
-
9
- if(!this.commands.hasOwnProperty(command.name)) {
10
- var e = new Error('Unknown command "' + command.name + '", please check the documentation.');
11
- this.renderer.log(e.message);
12
- done(e);
13
- }
14
-
15
- var commandArguments = [this.renderer].concat(command.parameters).concat([done]);
16
- this.commands[command.name].apply(this.commands, commandArguments);
17
- };
18
-
19
- module.exports = AdaptConsoleApplication;
@@ -1,19 +0,0 @@
1
-
2
- var delimiter = ',',
3
- CommandTranslator = require('./CommandTranslator'),
4
- CommandParser = function (argv) {
5
- argv = argv || ['node', 'path'];
6
- this.parameters = CommandTranslator(argv.slice(2));
7
- if(this.parameters.length) {
8
- this.name = String.prototype.toLowerCase.call(this.parameters.shift());
9
- }
10
- };
11
-
12
- CommandParser.prototype.param = function (index) {
13
- if(index >= this.parameters.length)
14
- return undefined;
15
-
16
- return this.parameters[index];
17
- };
18
-
19
- module.exports = CommandParser;
@@ -1,15 +0,0 @@
1
- var _ = require('lodash'),
2
- translationTable = [
3
- { pattern: /^-v$|^--version$/i, replacement: 'version' }
4
- ],
5
- CommandTranslator = function (parameters) {
6
- parameters = Array.isArray(parameters) ? parameters : [parameters];
7
- return parameters.map(function (param) {
8
- var translation = _.find(translationTable, function (item) {
9
- return item.pattern.test(param);
10
- });
11
- return translation ? translation.replacement : param;
12
- });
13
- };
14
-
15
- module.exports = CommandTranslator;
@@ -1,10 +0,0 @@
1
- var chalk = require('chalk');
2
-
3
- module.exports = {
4
- log: function () {
5
- console.log.apply(this, arguments);
6
- },
7
- error: function () {
8
- console.error.apply(this, arguments);
9
- }
10
- };
package/lib/Constants.js DELETED
@@ -1,69 +0,0 @@
1
- var bower = require('bower'),
2
- fs = require('fs'),
3
- path = require('path');
4
-
5
- module.exports = {
6
- ManifestFilename: 'adapt.json',
7
- FrameworkFilename: 'package.json',
8
- DefaultProjectManifestPath: './adapt.json',
9
- DefaultProjectFrameworkPath: './package.json',
10
- DefaultCreateType : 'course',
11
- DefaultTypeNames : {
12
- 'course':'my-adapt-course',
13
- 'component':'my-adapt-component'
14
- },
15
- DefaultUserAgent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36',
16
- DefaultGitHubOrg: 'adaptlearning',
17
- FrameworkRepository : process.env.ADAPT_FRAMEWORK || 'https://github.com/adaptlearning/adapt_framework',
18
- FrameworkRepositoryName : 'adapt_framework',
19
- ComponentRepository : process.env.ADAPT_COMPONENT || 'https://github.com/adaptlearning/adapt-component',
20
- ComponentRepositoryName : 'adapt-component',
21
- DefaultBranch : process.env.ADAPT_BRANCH || 'master',
22
- HomeDirectory : searchForHome(),
23
- getRegistry:getRegistry,
24
- setCwd: setCwd,
25
- cwd: '.'
26
- };
27
-
28
- var registry = null;
29
-
30
- function searchForHome() {
31
- var locations = [
32
- process.env.HOME,
33
- (process.env.HOMEDRIVE + process.env.HOMEPATH),
34
- process.env.USERPROFILE,
35
- '/tmp',
36
- '/temp',
37
- ];
38
- var validLocations = locations.filter(fs.existsSync);
39
- return validLocations[0];
40
- }
41
-
42
- function getRegistry() {
43
- if (registry !== null) {
44
- return registry;
45
- }
46
-
47
- if (process.env.ADAPT_REGISTRY) {
48
- registry = process.env.ADAPT_REGISTRY;
49
-
50
- } else if (fs.existsSync(path.join(this.cwd, './.bowerrc'))) {
51
- // a manifest exists; let bower determine the registry
52
- registry = undefined;
53
-
54
- } else {
55
- // use the default Adapt registry
56
- registry = 'http://adapt-bower-repository.herokuapp.com/';
57
- }
58
-
59
- return registry;
60
- }
61
-
62
- function setCwd(cwd) {
63
- if (!cwd) return;
64
-
65
- this.cwd = cwd;
66
-
67
- this.DefaultProjectManifestPath = path.join(this.cwd, this.ManifestFilename);
68
- this.DefaultProjectFrameworkPath = path.join(this.cwd, this.FrameworkFilename);
69
- }
package/lib/JsonLoader.js DELETED
@@ -1,40 +0,0 @@
1
- var fs = require('fs'),
2
- JSONLint = require('json-lint');
3
-
4
- module.exports = {
5
- existsSync: fs.existsSync,
6
-
7
- exists: fs.exists,
8
-
9
- readJSON: function (filepath, done) {
10
- done = done || function () {};
11
-
12
- fs.readFile(filepath, 'utf8', function (err, data) {
13
- if(err) return done(err);
14
-
15
- try {
16
- validateJSON(data, filepath);
17
- done(null, JSON.parse(data));
18
- } catch (ex) {
19
- done(ex.message);
20
- }
21
- });
22
- },
23
-
24
- readJSONSync: function (filepath) {
25
- var data = fs.readFileSync(filepath, 'utf-8');
26
- validateJSON(data, filepath);
27
- return JSON.parse(data);
28
- }
29
- };
30
-
31
- function validateJSON(jsonData, filepath) {
32
- var lint = JSONLint(jsonData);
33
- if (lint.error) {
34
- var errorMessage = 'JSON parsing error: ' + lint.error + ', line: ' + lint.line + ', character: ' + lint.character;
35
- if(filepath) {
36
- errorMessage += ', file: \'' + filepath + '\'';
37
- }
38
- throw new Error(errorMessage);
39
- }
40
- }
package/lib/JsonWriter.js DELETED
@@ -1,21 +0,0 @@
1
- var fs = require('fs');
2
-
3
- module.exports = {
4
- existsSync: fs.existsSync,
5
-
6
- exists: fs.exists,
7
-
8
- writeJSON: function (filepath, values, done) {
9
- done = done || function () {};
10
-
11
- fs.writeFile(filepath, JSON.stringify(values, null, 4), { encoding: 'utf8' }, function (err) {
12
- if(err) return done(err);
13
-
14
- done();
15
- });
16
- },
17
-
18
- writeJSONSync: function (filepath, values) {
19
- return fs.writeFileSync(filepath, JSON.stringify(values, null, 4), { encoding: 'utf8' });
20
- }
21
- }