adapt-cli 3.0.0 → 3.0.7
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.
- package/.bowerrc +2 -2
- package/.eslintignore +1 -1
- package/.eslintrc.json +14 -14
- package/.github/CONTRIBUTING.md +8 -0
- package/.github/ISSUE_TEMPLATE.md +17 -0
- package/.github/pull_request_template.md +25 -0
- package/.github/workflows/addtomainproject.yml +19 -0
- package/.github/workflows/releases.yml +25 -0
- package/.travis.yml +46 -46
- package/README.md +266 -266
- package/bin/adapt.js +3 -3
- package/json/help-create/component.json +9 -9
- package/json/help-create/course.json +9 -9
- package/json/help-create/question.json +9 -9
- package/json/help-create.json +12 -12
- package/json/help-devinstall.json +9 -9
- package/json/help-install.json +10 -10
- package/json/help-ls.json +7 -7
- package/json/help-register.json +7 -7
- package/json/help-rename.json +7 -7
- package/json/help-search.json +8 -8
- package/json/help-uninstall.json +7 -7
- package/json/help-unregister.json +8 -8
- package/json/help-update.json +12 -12
- package/json/help-version.json +7 -7
- package/json/help.json +19 -19
- package/lib/api.js +273 -260
- package/lib/cli.js +70 -69
- package/lib/commands/authenticate.js +18 -18
- package/lib/commands/create/component.js +64 -64
- package/lib/commands/create/course.js +26 -26
- package/lib/commands/create/question.js +18 -18
- package/lib/commands/create.js +94 -85
- package/lib/commands/devinstall.js +35 -35
- package/lib/commands/help.js +31 -31
- package/lib/commands/install.js +16 -16
- package/lib/commands/ls.js +35 -9
- package/lib/commands/register.js +11 -11
- package/lib/commands/rename.js +14 -14
- package/lib/commands/search.js +11 -11
- package/lib/commands/uninstall.js +9 -9
- package/lib/commands/unregister.js +12 -12
- package/lib/commands/update.js +12 -12
- package/lib/commands/version.js +13 -13
- package/lib/econnreset.js +8 -0
- package/lib/integration/AdaptFramework/build.js +42 -39
- package/lib/integration/AdaptFramework/clone.js +27 -27
- package/lib/integration/AdaptFramework/deleteSrcCore.js +9 -9
- package/lib/integration/AdaptFramework/deleteSrcCourse.js +9 -9
- package/lib/integration/AdaptFramework/download.js +21 -21
- package/lib/integration/AdaptFramework/erase.js +34 -34
- package/lib/integration/AdaptFramework/getLatestVersion.js +74 -79
- package/lib/integration/AdaptFramework/npmInstall.js +21 -21
- package/lib/integration/AdaptFramework.js +19 -19
- package/lib/integration/Plugin.js +404 -403
- package/lib/integration/PluginManagement/autenticate.js +47 -56
- package/lib/integration/PluginManagement/install.js +224 -222
- package/lib/integration/PluginManagement/print.js +52 -52
- package/lib/integration/PluginManagement/register.js +130 -130
- package/lib/integration/PluginManagement/rename.js +95 -101
- package/lib/integration/PluginManagement/schemas.js +8 -8
- package/lib/integration/PluginManagement/search.js +37 -46
- package/lib/integration/PluginManagement/uninstall.js +141 -141
- package/lib/integration/PluginManagement/unregister.js +91 -101
- package/lib/integration/PluginManagement/update.js +224 -224
- package/lib/integration/PluginManagement.js +21 -21
- package/lib/integration/Project.js +146 -146
- package/lib/integration/Target.js +299 -296
- package/lib/integration/getBowerRegistryConfig.js +34 -34
- package/lib/logger.js +28 -28
- package/lib/util/JSONReadValidate.js +34 -34
- package/lib/util/constants.js +38 -38
- package/lib/util/createPromptTask.js +7 -7
- package/lib/util/download.js +45 -45
- package/lib/util/errors.js +58 -58
- package/lib/util/extract.js +24 -24
- package/lib/util/getDirNameFromImportMeta.js +6 -6
- package/lib/util/promises.js +36 -36
- package/package.json +74 -40
@@ -1,79 +1,74 @@
|
|
1
|
-
import
|
2
|
-
import semver from 'semver'
|
3
|
-
import gh from 'parse-github-url'
|
4
|
-
import { ADAPT_DEFAULT_USER_AGENT, ADAPT_FRAMEWORK, ADAPT_ALLOW_PRERELEASE } from '../../util/constants.js'
|
5
|
-
const semverOptions = { includePrerelease: ADAPT_ALLOW_PRERELEASE }
|
6
|
-
|
7
|
-
export default async function getLatestVersion ({ versionLimit, repository = ADAPT_FRAMEWORK }) {
|
8
|
-
repository = repository.replace(/\.git/g, '')
|
9
|
-
const OWNER = gh(repository).owner
|
10
|
-
const NAME = gh(repository).name
|
11
|
-
// used in pagination
|
12
|
-
let nextPage = `https://api.github.com/repos/${OWNER}/${NAME}/releases`
|
13
|
-
// taken from https://gist.github.com/niallo/3109252
|
14
|
-
const parseLinkHeader = header => {
|
15
|
-
if (!header || header.length === 0) {
|
16
|
-
return []
|
17
|
-
}
|
18
|
-
const links = {}
|
19
|
-
// Parse each part into a named link
|
20
|
-
header.split(',').forEach(p => {
|
21
|
-
const section = p.split(';')
|
22
|
-
if (section.length !== 2) {
|
23
|
-
throw new Error("section could not be split on ';'")
|
24
|
-
}
|
25
|
-
const url = section[0].replace(/<(.*)>/, '$1').trim()
|
26
|
-
const name = section[1].replace(/rel="(.*)"/, '$1').trim()
|
27
|
-
links[name] = url
|
28
|
-
})
|
29
|
-
return links
|
30
|
-
}
|
31
|
-
const processPage = async () => {
|
32
|
-
const
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
})
|
43
|
-
}
|
44
|
-
if (response?.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
return compatibleRelease.tag_name
|
77
|
-
}
|
78
|
-
return await processPage()
|
79
|
-
}
|
1
|
+
import fetch from 'node-fetch'
|
2
|
+
import semver from 'semver'
|
3
|
+
import gh from 'parse-github-url'
|
4
|
+
import { ADAPT_DEFAULT_USER_AGENT, ADAPT_FRAMEWORK, ADAPT_ALLOW_PRERELEASE } from '../../util/constants.js'
|
5
|
+
const semverOptions = { includePrerelease: ADAPT_ALLOW_PRERELEASE }
|
6
|
+
|
7
|
+
export default async function getLatestVersion ({ versionLimit, repository = ADAPT_FRAMEWORK }) {
|
8
|
+
repository = repository.replace(/\.git/g, '')
|
9
|
+
const OWNER = gh(repository).owner
|
10
|
+
const NAME = gh(repository).name
|
11
|
+
// used in pagination
|
12
|
+
let nextPage = `https://api.github.com/repos/${OWNER}/${NAME}/releases`
|
13
|
+
// taken from https://gist.github.com/niallo/3109252
|
14
|
+
const parseLinkHeader = header => {
|
15
|
+
if (!header || header.length === 0) {
|
16
|
+
return []
|
17
|
+
}
|
18
|
+
const links = {}
|
19
|
+
// Parse each part into a named link
|
20
|
+
header.split(',').forEach(p => {
|
21
|
+
const section = p.split(';')
|
22
|
+
if (section.length !== 2) {
|
23
|
+
throw new Error("section could not be split on ';'")
|
24
|
+
}
|
25
|
+
const url = section[0].replace(/<(.*)>/, '$1').trim()
|
26
|
+
const name = section[1].replace(/rel="(.*)"/, '$1').trim()
|
27
|
+
links[name] = url
|
28
|
+
})
|
29
|
+
return links
|
30
|
+
}
|
31
|
+
const processPage = async () => {
|
32
|
+
const response = await fetch(nextPage, {
|
33
|
+
headers: {
|
34
|
+
'User-Agent': ADAPT_DEFAULT_USER_AGENT
|
35
|
+
},
|
36
|
+
method: 'GET'
|
37
|
+
})
|
38
|
+
const body = await response.text()
|
39
|
+
if (response?.status === 403 && response?.headers['x-ratelimit-remaining'] === '0') {
|
40
|
+
// we've exceeded the API limit
|
41
|
+
const reqsReset = new Date(response.headers['x-ratelimit-reset'] * 1000)
|
42
|
+
throw new Error(`Couldn't check latest version of ${NAME}. 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.`)
|
43
|
+
}
|
44
|
+
if (response?.status !== 200) {
|
45
|
+
throw new Error(`Couldn't check latest version of ${NAME}. GitubAPI did not respond with a 200 status code.`)
|
46
|
+
}
|
47
|
+
nextPage = parseLinkHeader(response.headers.link).next
|
48
|
+
let releases
|
49
|
+
try {
|
50
|
+
// parse and sort releases (newest first)
|
51
|
+
releases = JSON.parse(body).sort((a, b) => {
|
52
|
+
if (semver.lt(a.tag_name, b.tag_name, semverOptions)) return 1
|
53
|
+
if (semver.gt(a.tag_name, b.tag_name, semverOptions)) return -1
|
54
|
+
return 0
|
55
|
+
})
|
56
|
+
} catch (e) {
|
57
|
+
throw new Error(`Failed to parse GitHub release data\n${e}`)
|
58
|
+
}
|
59
|
+
const compatibleRelease = releases.find(release => {
|
60
|
+
const isFullRelease = !release.draft && !release.prerelease
|
61
|
+
const satisfiesVersion = !versionLimit || semver.satisfies(release.tag_name, versionLimit, semverOptions)
|
62
|
+
if (!isFullRelease || !satisfiesVersion) return false
|
63
|
+
return true
|
64
|
+
})
|
65
|
+
if (!compatibleRelease && nextPage) {
|
66
|
+
return await processPage()
|
67
|
+
}
|
68
|
+
if (!compatibleRelease) {
|
69
|
+
throw new Error(`Couldn't find any releases compatible with specified framework version (${versionLimit}), please check that it is a valid version.`)
|
70
|
+
}
|
71
|
+
return compatibleRelease.tag_name
|
72
|
+
}
|
73
|
+
return await processPage()
|
74
|
+
}
|
@@ -1,21 +1,21 @@
|
|
1
|
-
import chalk from 'chalk'
|
2
|
-
import { spawn } from 'child_process'
|
3
|
-
import path from 'path'
|
4
|
-
|
5
|
-
export default async function npmInstall ({
|
6
|
-
logger,
|
7
|
-
cwd
|
8
|
-
} = {}) {
|
9
|
-
cwd = path.resolve(process.cwd(), cwd)
|
10
|
-
await new Promise((resolve, reject) => {
|
11
|
-
logger?.log(chalk.cyan('installing node dependencies'))
|
12
|
-
const npm = spawn((process.platform === 'win32' ? 'npm.cmd' : 'npm'), ['--unsafe-perm', 'install'], {
|
13
|
-
stdio: 'inherit',
|
14
|
-
cwd
|
15
|
-
})
|
16
|
-
npm.on('close', code => {
|
17
|
-
if (code) return reject(new Error('npm install failed'))
|
18
|
-
resolve()
|
19
|
-
})
|
20
|
-
})
|
21
|
-
}
|
1
|
+
import chalk from 'chalk'
|
2
|
+
import { spawn } from 'child_process'
|
3
|
+
import path from 'path'
|
4
|
+
|
5
|
+
export default async function npmInstall ({
|
6
|
+
logger,
|
7
|
+
cwd
|
8
|
+
} = {}) {
|
9
|
+
cwd = path.resolve(process.cwd(), cwd)
|
10
|
+
await new Promise((resolve, reject) => {
|
11
|
+
logger?.log(chalk.cyan('installing node dependencies'))
|
12
|
+
const npm = spawn((process.platform === 'win32' ? 'npm.cmd' : 'npm'), ['--unsafe-perm', 'install'], {
|
13
|
+
stdio: 'inherit',
|
14
|
+
cwd
|
15
|
+
})
|
16
|
+
npm.on('close', code => {
|
17
|
+
if (code) return reject(new Error('npm install failed'))
|
18
|
+
resolve()
|
19
|
+
})
|
20
|
+
})
|
21
|
+
}
|
@@ -1,19 +1,19 @@
|
|
1
|
-
import build from './AdaptFramework/build.js'
|
2
|
-
import getLatestVersion from './AdaptFramework/getLatestVersion.js'
|
3
|
-
import clone from './AdaptFramework/clone.js'
|
4
|
-
import erase from './AdaptFramework/erase.js'
|
5
|
-
import download from './AdaptFramework/download.js'
|
6
|
-
import npmInstall from './AdaptFramework/npmInstall.js'
|
7
|
-
import deleteSrcCourse from './AdaptFramework/deleteSrcCourse.js'
|
8
|
-
import deleteSrcCore from './AdaptFramework/deleteSrcCore.js'
|
9
|
-
|
10
|
-
export {
|
11
|
-
build,
|
12
|
-
getLatestVersion,
|
13
|
-
clone,
|
14
|
-
erase,
|
15
|
-
download,
|
16
|
-
npmInstall,
|
17
|
-
deleteSrcCourse,
|
18
|
-
deleteSrcCore
|
19
|
-
}
|
1
|
+
import build from './AdaptFramework/build.js'
|
2
|
+
import getLatestVersion from './AdaptFramework/getLatestVersion.js'
|
3
|
+
import clone from './AdaptFramework/clone.js'
|
4
|
+
import erase from './AdaptFramework/erase.js'
|
5
|
+
import download from './AdaptFramework/download.js'
|
6
|
+
import npmInstall from './AdaptFramework/npmInstall.js'
|
7
|
+
import deleteSrcCourse from './AdaptFramework/deleteSrcCourse.js'
|
8
|
+
import deleteSrcCore from './AdaptFramework/deleteSrcCore.js'
|
9
|
+
|
10
|
+
export {
|
11
|
+
build,
|
12
|
+
getLatestVersion,
|
13
|
+
clone,
|
14
|
+
erase,
|
15
|
+
download,
|
16
|
+
npmInstall,
|
17
|
+
deleteSrcCourse,
|
18
|
+
deleteSrcCore
|
19
|
+
}
|