adapt-cli 3.0.2 → 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.
- 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 +260 -260
- package/lib/cli.js +69 -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 +9 -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/integration/AdaptFramework/build.js +42 -42
- 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 +79 -79
- package/lib/integration/AdaptFramework/npmInstall.js +21 -21
- package/lib/integration/AdaptFramework.js +19 -19
- package/lib/integration/Plugin.js +404 -404
- package/lib/integration/PluginManagement/autenticate.js +56 -56
- package/lib/integration/PluginManagement/install.js +224 -224
- package/lib/integration/PluginManagement/print.js +52 -52
- package/lib/integration/PluginManagement/register.js +130 -130
- package/lib/integration/PluginManagement/rename.js +101 -101
- package/lib/integration/PluginManagement/schemas.js +8 -8
- package/lib/integration/PluginManagement/search.js +46 -46
- package/lib/integration/PluginManagement/uninstall.js +141 -141
- package/lib/integration/PluginManagement/unregister.js +101 -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 -299
- 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,224 +1,224 @@
|
|
1
|
-
import chalk from 'chalk'
|
2
|
-
import { eachOfSeries } from 'async'
|
3
|
-
import path from 'path'
|
4
|
-
import Project from '../Project.js'
|
5
|
-
import { createPromptTask } from '../../util/createPromptTask.js'
|
6
|
-
import { errorPrinter, packageNamePrinter, versionPrinter, existingVersionPrinter } from './print.js'
|
7
|
-
import { eachOfLimitProgress, eachOfSeriesProgress } from '../../util/promises.js'
|
8
|
-
/** @typedef {import("../Target.js").default} Target */
|
9
|
-
|
10
|
-
export default async function update ({
|
11
|
-
plugins,
|
12
|
-
// whether to summarise installed plugins without modifying anything
|
13
|
-
isDryRun = false,
|
14
|
-
isInteractive = true,
|
15
|
-
cwd = process.cwd(),
|
16
|
-
logger = null
|
17
|
-
}) {
|
18
|
-
cwd = path.resolve(process.cwd(), cwd)
|
19
|
-
const project = new Project({ cwd, logger })
|
20
|
-
project.tryThrowInvalidPath()
|
21
|
-
|
22
|
-
logger?.log(chalk.cyan('update adapt dependencies...'))
|
23
|
-
|
24
|
-
const targets = await getUpdateTargets({ logger, project, plugins, isDryRun, isInteractive })
|
25
|
-
if (!targets?.length) return targets
|
26
|
-
|
27
|
-
await loadPluginData({ logger, project, targets })
|
28
|
-
await conflictResolution({ logger, targets, isInteractive })
|
29
|
-
if (isDryRun) {
|
30
|
-
await summariseDryRun({ logger, targets })
|
31
|
-
return targets
|
32
|
-
}
|
33
|
-
const updateTargetsToBeUpdated = targets.filter(target => target.isToBeInstalled)
|
34
|
-
if (updateTargetsToBeUpdated.length) {
|
35
|
-
await eachOfSeriesProgress(
|
36
|
-
updateTargetsToBeUpdated,
|
37
|
-
target => target.update(),
|
38
|
-
percentage => logger?.logProgress?.(`${chalk.bold.cyan('<info>')} Updating plugins ${percentage}% complete`)
|
39
|
-
)
|
40
|
-
logger?.log(`${chalk.bold.cyan('<info>')} Updating plugins 100% complete`)
|
41
|
-
}
|
42
|
-
await summariseUpdates({ logger, targets })
|
43
|
-
return targets
|
44
|
-
}
|
45
|
-
|
46
|
-
/**
|
47
|
-
* @param {Object} options
|
48
|
-
* @param {Project} options.project
|
49
|
-
* @param {[string]} options.plugins
|
50
|
-
*/
|
51
|
-
async function getUpdateTargets ({ project, plugins, isDryRun, isInteractive }) {
|
52
|
-
if (typeof plugins === 'string') plugins = [plugins]
|
53
|
-
if (!plugins) plugins = []
|
54
|
-
const allowedTypes = ['all', 'components', 'extensions', 'menu', 'theme']
|
55
|
-
const selectedTypes = [...new Set(plugins.filter(type => allowedTypes.includes(type)))]
|
56
|
-
const isEmpty = (!plugins.length)
|
57
|
-
const isAll = (isDryRun || isEmpty || selectedTypes.includes('all'))
|
58
|
-
const pluginNames = plugins
|
59
|
-
// remove types
|
60
|
-
.filter(arg => !allowedTypes.includes(arg))
|
61
|
-
// split name/version
|
62
|
-
.map(arg => {
|
63
|
-
const [name, version = '*'] = arg.split(/[#@]/)
|
64
|
-
return [name, version]
|
65
|
-
})
|
66
|
-
// make sure last applies
|
67
|
-
.reverse()
|
68
|
-
|
69
|
-
/** @type {[Target]} */
|
70
|
-
let targets = await project.getUpdateTargets()
|
71
|
-
for (const target of targets) {
|
72
|
-
await target.fetchProjectInfo()
|
73
|
-
}
|
74
|
-
if (!isDryRun && isEmpty && isInteractive) {
|
75
|
-
const shouldContinue = await createPromptTask({
|
76
|
-
message: chalk.reset('This command will attempt to update all installed plugins. Do you wish to continue?'),
|
77
|
-
type: 'confirm'
|
78
|
-
})
|
79
|
-
if (!shouldContinue) return
|
80
|
-
}
|
81
|
-
if (!isAll) {
|
82
|
-
const filtered = {}
|
83
|
-
for (const target of targets) {
|
84
|
-
const typeFolder = await target.getTypeFolder()
|
85
|
-
if (!typeFolder) continue
|
86
|
-
const lastSpecifiedPluginName = pluginNames.find(([name]) => target.isNameMatch(name))
|
87
|
-
const isPluginNameIncluded = Boolean(lastSpecifiedPluginName)
|
88
|
-
const isTypeIncluded = selectedTypes.includes(typeFolder)
|
89
|
-
if (!isPluginNameIncluded && !isTypeIncluded) continue
|
90
|
-
// Resolve duplicates
|
91
|
-
filtered[target.packageName] = target
|
92
|
-
// Set requested version from name
|
93
|
-
target.requestedVersion = lastSpecifiedPluginName[1] || '*'
|
94
|
-
}
|
95
|
-
targets = Object.values(filtered)
|
96
|
-
}
|
97
|
-
return targets
|
98
|
-
}
|
99
|
-
|
100
|
-
/**
|
101
|
-
* @param {Object} options
|
102
|
-
* @param {Project} options.project
|
103
|
-
* @param {[Target]} options.targets
|
104
|
-
*/
|
105
|
-
async function loadPluginData ({ logger, project, targets }) {
|
106
|
-
const frameworkVersion = project.version
|
107
|
-
await eachOfLimitProgress(
|
108
|
-
targets,
|
109
|
-
target => target.fetchSourceInfo(),
|
110
|
-
percentage => logger?.logProgress?.(`${chalk.bold.cyan('<info>')} Getting plugin info ${percentage}% complete`)
|
111
|
-
)
|
112
|
-
logger?.log(`${chalk.bold.cyan('<info>')} Getting plugin info 100% complete`)
|
113
|
-
await eachOfLimitProgress(
|
114
|
-
targets,
|
115
|
-
target => target.findCompatibleVersion(frameworkVersion),
|
116
|
-
percentage => logger?.logProgress?.(`${chalk.bold.cyan('<info>')} Finding compatible source versions ${percentage}% complete`)
|
117
|
-
)
|
118
|
-
logger?.log(`${chalk.bold.cyan('<info>')} Finding compatible source versions 100% complete`)
|
119
|
-
await eachOfLimitProgress(
|
120
|
-
targets,
|
121
|
-
target => target.markUpdateable(),
|
122
|
-
percentage => logger?.logProgress?.(`${chalk.bold.cyan('<info>')} Marking updateable ${percentage}% complete`)
|
123
|
-
)
|
124
|
-
logger?.log(`${chalk.bold.cyan('<info>')} Marking updateable 100% complete`)
|
125
|
-
}
|
126
|
-
|
127
|
-
/**
|
128
|
-
* @param {Object} options
|
129
|
-
* @param {[Target]} options.targets
|
130
|
-
*/
|
131
|
-
async function conflictResolution ({ logger, targets, isInteractive }) {
|
132
|
-
/** @param {Target} target */
|
133
|
-
async function checkVersion (target) {
|
134
|
-
const canApplyRequested = target.hasValidRequestVersion &&
|
135
|
-
(target.hasFrameworkCompatibleVersion
|
136
|
-
? (target.latestCompatibleSourceVersion !== target.matchedVersion)
|
137
|
-
: (target.latestSourceVersion !== target.matchedVersion))
|
138
|
-
if (!isInteractive) {
|
139
|
-
if (target.canApplyRequested) return target.markRequestedForInstallation()
|
140
|
-
return target.markSkipped()
|
141
|
-
}
|
142
|
-
const choices = [
|
143
|
-
canApplyRequested && { name: `requested version [${target.matchedVersion}]`, value: 'r' },
|
144
|
-
target.hasFrameworkCompatibleVersion
|
145
|
-
? { name: `latest compatible version [${target.latestCompatibleSourceVersion}]`, value: 'l' }
|
146
|
-
: { name: `latest version [${target.latestSourceVersion}]`, value: 'l' },
|
147
|
-
{ name: 'skip', value: 's' }
|
148
|
-
].filter(Boolean)
|
149
|
-
const result = await createPromptTask({ message: chalk.reset(target.packageName), choices, type: 'list', default: 's' })
|
150
|
-
const installRequested = (result === 'r')
|
151
|
-
const installLatest = result === 'l'
|
152
|
-
const skipped = result === 's'
|
153
|
-
if (installRequested) target.markRequestedForInstallation()
|
154
|
-
if (installLatest && target.hasFrameworkCompatibleVersion) target.markLatestCompatibleForInstallation()
|
155
|
-
if (installLatest && !target.hasFrameworkCompatibleVersion) target.markLatestForInstallation()
|
156
|
-
if (skipped) target.markSkipped()
|
157
|
-
}
|
158
|
-
function add (list, header, prompt) {
|
159
|
-
if (!list.length) return
|
160
|
-
return {
|
161
|
-
header: chalk.bold.cyan('<info> ') + header,
|
162
|
-
list,
|
163
|
-
prompt
|
164
|
-
}
|
165
|
-
}
|
166
|
-
const preFilteredPlugins = targets.filter(target => !target.isLocalSource)
|
167
|
-
const allQuestions = [
|
168
|
-
add(preFilteredPlugins.filter(target => !target.hasFrameworkCompatibleVersion), 'There is no compatible version of the following plugins:', checkVersion),
|
169
|
-
add(preFilteredPlugins.filter(target => target.hasFrameworkCompatibleVersion && !target.hasValidRequestVersion), 'The version requested is invalid, there are newer compatible versions of the following plugins:', checkVersion),
|
170
|
-
add(preFilteredPlugins.filter(target => target.hasFrameworkCompatibleVersion && target.hasValidRequestVersion && !target.isApplyLatestCompatibleVersion), 'There are newer compatible versions of the following plugins:', checkVersion)
|
171
|
-
].filter(Boolean)
|
172
|
-
if (allQuestions.length === 0) return
|
173
|
-
for (const question of allQuestions) {
|
174
|
-
logger?.log(question.header)
|
175
|
-
await eachOfSeries(question.list, question.prompt)
|
176
|
-
}
|
177
|
-
}
|
178
|
-
|
179
|
-
/**
|
180
|
-
* @param {Object} options
|
181
|
-
* @param {[Target]} options.targets
|
182
|
-
*/
|
183
|
-
function summariseDryRun ({ logger, targets }) {
|
184
|
-
const preFilteredPlugins = targets.filter(target => !target.isLocalSource)
|
185
|
-
const localSources = targets.filter(target => target.isLocalSource)
|
186
|
-
const toBeInstalled = preFilteredPlugins.filter(target => target.isToBeUpdated)
|
187
|
-
const toBeSkipped = preFilteredPlugins.filter(target => !target.isToBeUpdated || target.isSkipped)
|
188
|
-
const missing = preFilteredPlugins.filter(target => target.isMissing)
|
189
|
-
summarise(logger, localSources, packageNamePrinter, 'The following plugins were installed from a local source and cannot be updated:')
|
190
|
-
summarise(logger, toBeSkipped, packageNamePrinter, 'The following plugins will be skipped:')
|
191
|
-
summarise(logger, missing, packageNamePrinter, 'There was a problem locating the following plugins:')
|
192
|
-
summarise(logger, toBeInstalled, versionPrinter, 'The following plugins will be updated:')
|
193
|
-
}
|
194
|
-
|
195
|
-
/**
|
196
|
-
* @param {Object} options
|
197
|
-
* @param {[Target]} options.targets
|
198
|
-
*/
|
199
|
-
function summariseUpdates ({ logger, targets }) {
|
200
|
-
const preFilteredPlugins = targets.filter(target => !target.isLocalSource)
|
201
|
-
const localSources = targets.filter(target => target.isLocalSource)
|
202
|
-
const installSucceeded = preFilteredPlugins.filter(target => target.isUpdateSuccessful)
|
203
|
-
const installSkipped = preFilteredPlugins.filter(target => target.isSkipped)
|
204
|
-
const noUpdateAvailable = preFilteredPlugins.filter(target => !target.isToBeUpdated && !target.isSkipped)
|
205
|
-
const installErrored = preFilteredPlugins.filter(target => target.isUpdateFailure)
|
206
|
-
const missing = preFilteredPlugins.filter(target => target.isMissing)
|
207
|
-
const noneInstalled = (installSucceeded.length === 0)
|
208
|
-
const allInstalledSuccessfully = (installErrored.length === 0 && missing.length === 0)
|
209
|
-
const someInstalledSuccessfully = (!noneInstalled && !allInstalledSuccessfully)
|
210
|
-
summarise(logger, localSources, existingVersionPrinter, 'The following plugins were installed from a local source and cannot be updated:')
|
211
|
-
summarise(logger, installSkipped, existingVersionPrinter, 'The following plugins were skipped:')
|
212
|
-
summarise(logger, noUpdateAvailable, existingVersionPrinter, 'The following plugins had no update available:')
|
213
|
-
summarise(logger, missing, packageNamePrinter, 'There was a problem locating the following plugins:')
|
214
|
-
summarise(logger, installErrored, errorPrinter, 'The following plugins could not be updated:')
|
215
|
-
if (noneInstalled) logger?.log(chalk.cyanBright('None of the requested plugins could be updated'))
|
216
|
-
else if (allInstalledSuccessfully) summarise(logger, installSucceeded, existingVersionPrinter, 'All requested plugins were successfully updated. Summary of installation:')
|
217
|
-
else if (someInstalledSuccessfully) summarise(logger, installSucceeded, existingVersionPrinter, 'The following plugins were successfully updated:')
|
218
|
-
}
|
219
|
-
|
220
|
-
function summarise (logger, list, iterator, header) {
|
221
|
-
if (!list || !iterator || list.length === 0) return
|
222
|
-
logger?.log(chalk.cyanBright(header))
|
223
|
-
list.forEach(item => iterator(item, logger))
|
224
|
-
}
|
1
|
+
import chalk from 'chalk'
|
2
|
+
import { eachOfSeries } from 'async'
|
3
|
+
import path from 'path'
|
4
|
+
import Project from '../Project.js'
|
5
|
+
import { createPromptTask } from '../../util/createPromptTask.js'
|
6
|
+
import { errorPrinter, packageNamePrinter, versionPrinter, existingVersionPrinter } from './print.js'
|
7
|
+
import { eachOfLimitProgress, eachOfSeriesProgress } from '../../util/promises.js'
|
8
|
+
/** @typedef {import("../Target.js").default} Target */
|
9
|
+
|
10
|
+
export default async function update ({
|
11
|
+
plugins,
|
12
|
+
// whether to summarise installed plugins without modifying anything
|
13
|
+
isDryRun = false,
|
14
|
+
isInteractive = true,
|
15
|
+
cwd = process.cwd(),
|
16
|
+
logger = null
|
17
|
+
}) {
|
18
|
+
cwd = path.resolve(process.cwd(), cwd)
|
19
|
+
const project = new Project({ cwd, logger })
|
20
|
+
project.tryThrowInvalidPath()
|
21
|
+
|
22
|
+
logger?.log(chalk.cyan('update adapt dependencies...'))
|
23
|
+
|
24
|
+
const targets = await getUpdateTargets({ logger, project, plugins, isDryRun, isInteractive })
|
25
|
+
if (!targets?.length) return targets
|
26
|
+
|
27
|
+
await loadPluginData({ logger, project, targets })
|
28
|
+
await conflictResolution({ logger, targets, isInteractive })
|
29
|
+
if (isDryRun) {
|
30
|
+
await summariseDryRun({ logger, targets })
|
31
|
+
return targets
|
32
|
+
}
|
33
|
+
const updateTargetsToBeUpdated = targets.filter(target => target.isToBeInstalled)
|
34
|
+
if (updateTargetsToBeUpdated.length) {
|
35
|
+
await eachOfSeriesProgress(
|
36
|
+
updateTargetsToBeUpdated,
|
37
|
+
target => target.update(),
|
38
|
+
percentage => logger?.logProgress?.(`${chalk.bold.cyan('<info>')} Updating plugins ${percentage}% complete`)
|
39
|
+
)
|
40
|
+
logger?.log(`${chalk.bold.cyan('<info>')} Updating plugins 100% complete`)
|
41
|
+
}
|
42
|
+
await summariseUpdates({ logger, targets })
|
43
|
+
return targets
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* @param {Object} options
|
48
|
+
* @param {Project} options.project
|
49
|
+
* @param {[string]} options.plugins
|
50
|
+
*/
|
51
|
+
async function getUpdateTargets ({ project, plugins, isDryRun, isInteractive }) {
|
52
|
+
if (typeof plugins === 'string') plugins = [plugins]
|
53
|
+
if (!plugins) plugins = []
|
54
|
+
const allowedTypes = ['all', 'components', 'extensions', 'menu', 'theme']
|
55
|
+
const selectedTypes = [...new Set(plugins.filter(type => allowedTypes.includes(type)))]
|
56
|
+
const isEmpty = (!plugins.length)
|
57
|
+
const isAll = (isDryRun || isEmpty || selectedTypes.includes('all'))
|
58
|
+
const pluginNames = plugins
|
59
|
+
// remove types
|
60
|
+
.filter(arg => !allowedTypes.includes(arg))
|
61
|
+
// split name/version
|
62
|
+
.map(arg => {
|
63
|
+
const [name, version = '*'] = arg.split(/[#@]/)
|
64
|
+
return [name, version]
|
65
|
+
})
|
66
|
+
// make sure last applies
|
67
|
+
.reverse()
|
68
|
+
|
69
|
+
/** @type {[Target]} */
|
70
|
+
let targets = await project.getUpdateTargets()
|
71
|
+
for (const target of targets) {
|
72
|
+
await target.fetchProjectInfo()
|
73
|
+
}
|
74
|
+
if (!isDryRun && isEmpty && isInteractive) {
|
75
|
+
const shouldContinue = await createPromptTask({
|
76
|
+
message: chalk.reset('This command will attempt to update all installed plugins. Do you wish to continue?'),
|
77
|
+
type: 'confirm'
|
78
|
+
})
|
79
|
+
if (!shouldContinue) return
|
80
|
+
}
|
81
|
+
if (!isAll) {
|
82
|
+
const filtered = {}
|
83
|
+
for (const target of targets) {
|
84
|
+
const typeFolder = await target.getTypeFolder()
|
85
|
+
if (!typeFolder) continue
|
86
|
+
const lastSpecifiedPluginName = pluginNames.find(([name]) => target.isNameMatch(name))
|
87
|
+
const isPluginNameIncluded = Boolean(lastSpecifiedPluginName)
|
88
|
+
const isTypeIncluded = selectedTypes.includes(typeFolder)
|
89
|
+
if (!isPluginNameIncluded && !isTypeIncluded) continue
|
90
|
+
// Resolve duplicates
|
91
|
+
filtered[target.packageName] = target
|
92
|
+
// Set requested version from name
|
93
|
+
target.requestedVersion = lastSpecifiedPluginName[1] || '*'
|
94
|
+
}
|
95
|
+
targets = Object.values(filtered)
|
96
|
+
}
|
97
|
+
return targets
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* @param {Object} options
|
102
|
+
* @param {Project} options.project
|
103
|
+
* @param {[Target]} options.targets
|
104
|
+
*/
|
105
|
+
async function loadPluginData ({ logger, project, targets }) {
|
106
|
+
const frameworkVersion = project.version
|
107
|
+
await eachOfLimitProgress(
|
108
|
+
targets,
|
109
|
+
target => target.fetchSourceInfo(),
|
110
|
+
percentage => logger?.logProgress?.(`${chalk.bold.cyan('<info>')} Getting plugin info ${percentage}% complete`)
|
111
|
+
)
|
112
|
+
logger?.log(`${chalk.bold.cyan('<info>')} Getting plugin info 100% complete`)
|
113
|
+
await eachOfLimitProgress(
|
114
|
+
targets,
|
115
|
+
target => target.findCompatibleVersion(frameworkVersion),
|
116
|
+
percentage => logger?.logProgress?.(`${chalk.bold.cyan('<info>')} Finding compatible source versions ${percentage}% complete`)
|
117
|
+
)
|
118
|
+
logger?.log(`${chalk.bold.cyan('<info>')} Finding compatible source versions 100% complete`)
|
119
|
+
await eachOfLimitProgress(
|
120
|
+
targets,
|
121
|
+
target => target.markUpdateable(),
|
122
|
+
percentage => logger?.logProgress?.(`${chalk.bold.cyan('<info>')} Marking updateable ${percentage}% complete`)
|
123
|
+
)
|
124
|
+
logger?.log(`${chalk.bold.cyan('<info>')} Marking updateable 100% complete`)
|
125
|
+
}
|
126
|
+
|
127
|
+
/**
|
128
|
+
* @param {Object} options
|
129
|
+
* @param {[Target]} options.targets
|
130
|
+
*/
|
131
|
+
async function conflictResolution ({ logger, targets, isInteractive }) {
|
132
|
+
/** @param {Target} target */
|
133
|
+
async function checkVersion (target) {
|
134
|
+
const canApplyRequested = target.hasValidRequestVersion &&
|
135
|
+
(target.hasFrameworkCompatibleVersion
|
136
|
+
? (target.latestCompatibleSourceVersion !== target.matchedVersion)
|
137
|
+
: (target.latestSourceVersion !== target.matchedVersion))
|
138
|
+
if (!isInteractive) {
|
139
|
+
if (target.canApplyRequested) return target.markRequestedForInstallation()
|
140
|
+
return target.markSkipped()
|
141
|
+
}
|
142
|
+
const choices = [
|
143
|
+
canApplyRequested && { name: `requested version [${target.matchedVersion}]`, value: 'r' },
|
144
|
+
target.hasFrameworkCompatibleVersion
|
145
|
+
? { name: `latest compatible version [${target.latestCompatibleSourceVersion}]`, value: 'l' }
|
146
|
+
: { name: `latest version [${target.latestSourceVersion}]`, value: 'l' },
|
147
|
+
{ name: 'skip', value: 's' }
|
148
|
+
].filter(Boolean)
|
149
|
+
const result = await createPromptTask({ message: chalk.reset(target.packageName), choices, type: 'list', default: 's' })
|
150
|
+
const installRequested = (result === 'r')
|
151
|
+
const installLatest = result === 'l'
|
152
|
+
const skipped = result === 's'
|
153
|
+
if (installRequested) target.markRequestedForInstallation()
|
154
|
+
if (installLatest && target.hasFrameworkCompatibleVersion) target.markLatestCompatibleForInstallation()
|
155
|
+
if (installLatest && !target.hasFrameworkCompatibleVersion) target.markLatestForInstallation()
|
156
|
+
if (skipped) target.markSkipped()
|
157
|
+
}
|
158
|
+
function add (list, header, prompt) {
|
159
|
+
if (!list.length) return
|
160
|
+
return {
|
161
|
+
header: chalk.bold.cyan('<info> ') + header,
|
162
|
+
list,
|
163
|
+
prompt
|
164
|
+
}
|
165
|
+
}
|
166
|
+
const preFilteredPlugins = targets.filter(target => !target.isLocalSource)
|
167
|
+
const allQuestions = [
|
168
|
+
add(preFilteredPlugins.filter(target => !target.hasFrameworkCompatibleVersion), 'There is no compatible version of the following plugins:', checkVersion),
|
169
|
+
add(preFilteredPlugins.filter(target => target.hasFrameworkCompatibleVersion && !target.hasValidRequestVersion), 'The version requested is invalid, there are newer compatible versions of the following plugins:', checkVersion),
|
170
|
+
add(preFilteredPlugins.filter(target => target.hasFrameworkCompatibleVersion && target.hasValidRequestVersion && !target.isApplyLatestCompatibleVersion), 'There are newer compatible versions of the following plugins:', checkVersion)
|
171
|
+
].filter(Boolean)
|
172
|
+
if (allQuestions.length === 0) return
|
173
|
+
for (const question of allQuestions) {
|
174
|
+
logger?.log(question.header)
|
175
|
+
await eachOfSeries(question.list, question.prompt)
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
/**
|
180
|
+
* @param {Object} options
|
181
|
+
* @param {[Target]} options.targets
|
182
|
+
*/
|
183
|
+
function summariseDryRun ({ logger, targets }) {
|
184
|
+
const preFilteredPlugins = targets.filter(target => !target.isLocalSource)
|
185
|
+
const localSources = targets.filter(target => target.isLocalSource)
|
186
|
+
const toBeInstalled = preFilteredPlugins.filter(target => target.isToBeUpdated)
|
187
|
+
const toBeSkipped = preFilteredPlugins.filter(target => !target.isToBeUpdated || target.isSkipped)
|
188
|
+
const missing = preFilteredPlugins.filter(target => target.isMissing)
|
189
|
+
summarise(logger, localSources, packageNamePrinter, 'The following plugins were installed from a local source and cannot be updated:')
|
190
|
+
summarise(logger, toBeSkipped, packageNamePrinter, 'The following plugins will be skipped:')
|
191
|
+
summarise(logger, missing, packageNamePrinter, 'There was a problem locating the following plugins:')
|
192
|
+
summarise(logger, toBeInstalled, versionPrinter, 'The following plugins will be updated:')
|
193
|
+
}
|
194
|
+
|
195
|
+
/**
|
196
|
+
* @param {Object} options
|
197
|
+
* @param {[Target]} options.targets
|
198
|
+
*/
|
199
|
+
function summariseUpdates ({ logger, targets }) {
|
200
|
+
const preFilteredPlugins = targets.filter(target => !target.isLocalSource)
|
201
|
+
const localSources = targets.filter(target => target.isLocalSource)
|
202
|
+
const installSucceeded = preFilteredPlugins.filter(target => target.isUpdateSuccessful)
|
203
|
+
const installSkipped = preFilteredPlugins.filter(target => target.isSkipped)
|
204
|
+
const noUpdateAvailable = preFilteredPlugins.filter(target => !target.isToBeUpdated && !target.isSkipped)
|
205
|
+
const installErrored = preFilteredPlugins.filter(target => target.isUpdateFailure)
|
206
|
+
const missing = preFilteredPlugins.filter(target => target.isMissing)
|
207
|
+
const noneInstalled = (installSucceeded.length === 0)
|
208
|
+
const allInstalledSuccessfully = (installErrored.length === 0 && missing.length === 0)
|
209
|
+
const someInstalledSuccessfully = (!noneInstalled && !allInstalledSuccessfully)
|
210
|
+
summarise(logger, localSources, existingVersionPrinter, 'The following plugins were installed from a local source and cannot be updated:')
|
211
|
+
summarise(logger, installSkipped, existingVersionPrinter, 'The following plugins were skipped:')
|
212
|
+
summarise(logger, noUpdateAvailable, existingVersionPrinter, 'The following plugins had no update available:')
|
213
|
+
summarise(logger, missing, packageNamePrinter, 'There was a problem locating the following plugins:')
|
214
|
+
summarise(logger, installErrored, errorPrinter, 'The following plugins could not be updated:')
|
215
|
+
if (noneInstalled) logger?.log(chalk.cyanBright('None of the requested plugins could be updated'))
|
216
|
+
else if (allInstalledSuccessfully) summarise(logger, installSucceeded, existingVersionPrinter, 'All requested plugins were successfully updated. Summary of installation:')
|
217
|
+
else if (someInstalledSuccessfully) summarise(logger, installSucceeded, existingVersionPrinter, 'The following plugins were successfully updated:')
|
218
|
+
}
|
219
|
+
|
220
|
+
function summarise (logger, list, iterator, header) {
|
221
|
+
if (!list || !iterator || list.length === 0) return
|
222
|
+
logger?.log(chalk.cyanBright(header))
|
223
|
+
list.forEach(item => iterator(item, logger))
|
224
|
+
}
|
@@ -1,21 +1,21 @@
|
|
1
|
-
import authenticate from './PluginManagement/autenticate.js'
|
2
|
-
import install from './PluginManagement/install.js'
|
3
|
-
import register from './PluginManagement/register.js'
|
4
|
-
import rename from './PluginManagement/rename.js'
|
5
|
-
import schemas from './PluginManagement/schemas.js'
|
6
|
-
import search from './PluginManagement/search.js'
|
7
|
-
import uninstall from './PluginManagement/uninstall.js'
|
8
|
-
import unregister from './PluginManagement/unregister.js'
|
9
|
-
import update from './PluginManagement/update.js'
|
10
|
-
|
11
|
-
export {
|
12
|
-
authenticate,
|
13
|
-
install,
|
14
|
-
register,
|
15
|
-
rename,
|
16
|
-
schemas,
|
17
|
-
search,
|
18
|
-
uninstall,
|
19
|
-
unregister,
|
20
|
-
update
|
21
|
-
}
|
1
|
+
import authenticate from './PluginManagement/autenticate.js'
|
2
|
+
import install from './PluginManagement/install.js'
|
3
|
+
import register from './PluginManagement/register.js'
|
4
|
+
import rename from './PluginManagement/rename.js'
|
5
|
+
import schemas from './PluginManagement/schemas.js'
|
6
|
+
import search from './PluginManagement/search.js'
|
7
|
+
import uninstall from './PluginManagement/uninstall.js'
|
8
|
+
import unregister from './PluginManagement/unregister.js'
|
9
|
+
import update from './PluginManagement/update.js'
|
10
|
+
|
11
|
+
export {
|
12
|
+
authenticate,
|
13
|
+
install,
|
14
|
+
register,
|
15
|
+
rename,
|
16
|
+
schemas,
|
17
|
+
search,
|
18
|
+
uninstall,
|
19
|
+
unregister,
|
20
|
+
update
|
21
|
+
}
|