MCPcopy Index your code
hub / github.com/angular/angular-cli / run

Method run

packages/angular/cli/src/commands/add/cli.ts:167–344  ·  view source on GitHub ↗
(options: Options<AddCommandArgs> & OtherOptions)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 15

isPackageInstalledMethod · 0.95
isProjectVersionValidMethod · 0.95
executeSchematicMethod · 0.95
loadPackageInfoTaskMethod · 0.95
installPackageTaskMethod · 0.95
resolvePackageJsonMethod · 0.95
assertIsErrorFunction · 0.90
existsSyncFunction · 0.85
toStringMethod · 0.80

Tested by

no test coverage detected