(options: Options<AddCommandArgs> & OtherOptions)
| 165 | } |
| 166 | |
| 167 | async run(options: Options<AddCommandArgs> & OtherOptions): Promise<number | void> { |
| 168 | this.#projectVersionCache.clear(); |
| 169 | this.#rootManifestCache = null; |
| 170 | const { logger } = this.context; |
| 171 | const { collection, skipConfirmation } = options; |
| 172 | |
| 173 | let packageIdentifier; |
| 174 | try { |
| 175 | packageIdentifier = npa(collection); |
| 176 | } catch (e) { |
| 177 | assertIsError(e); |
| 178 | logger.error(e.message); |
| 179 | |
| 180 | return 1; |
| 181 | } |
| 182 | |
| 183 | if ( |
| 184 | packageIdentifier.name && |
| 185 | packageIdentifier.registry && |
| 186 | this.isPackageInstalled(packageIdentifier.name) |
| 187 | ) { |
| 188 | const validVersion = await this.isProjectVersionValid(packageIdentifier); |
| 189 | if (validVersion) { |
| 190 | // Already installed so just run schematic |
| 191 | logger.info('Skipping installation: Package already installed'); |
| 192 | |
| 193 | return this.executeSchematic({ ...options, collection: packageIdentifier.name }); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | const taskContext = { |
| 198 | packageIdentifier, |
| 199 | isExactVersion: packageIdentifier.type === 'version', |
| 200 | executeSchematic: this.executeSchematic.bind(this), |
| 201 | getPeerDependencyConflicts: this.getPeerDependencyConflicts.bind(this), |
| 202 | dryRun: options.dryRun, |
| 203 | } as AddCommandTaskContext; |
| 204 | |
| 205 | const tasks = new Listr<AddCommandTaskContext>( |
| 206 | [ |
| 207 | { |
| 208 | title: 'Determining Package Manager', |
| 209 | task: (_context, task) => |
| 210 | (task.output = `Using package manager: ${color.dim(this.context.packageManager.name)}`), |
| 211 | rendererOptions: { persistentOutput: true }, |
| 212 | }, |
| 213 | { |
| 214 | title: 'Searching for compatible package version', |
| 215 | enabled: packageIdentifier.type === 'range' && packageIdentifier.rawSpec === '*', |
| 216 | task: (context, task) => this.findCompatiblePackageVersionTask(context, task, options), |
| 217 | rendererOptions: { persistentOutput: true }, |
| 218 | }, |
| 219 | { |
| 220 | title: 'Loading package information', |
| 221 | task: (context, task) => this.loadPackageInfoTask(context, task, options), |
| 222 | rendererOptions: { persistentOutput: true }, |
| 223 | }, |
| 224 | { |
nothing calls this directly
no test coverage detected