(args: string[])
| 213 | } |
| 214 | |
| 215 | async function main(args: string[]): Promise<number> { |
| 216 | /** Parse the command line. */ |
| 217 | const { positionals, cliOptions, builderOptions } = parseOptions(args); |
| 218 | |
| 219 | /** Create the DevKit Logger used through the CLI. */ |
| 220 | const logger = createConsoleLogger(!!cliOptions['verbose'], process.stdout, process.stderr, { |
| 221 | info: (s) => s, |
| 222 | debug: (s) => s, |
| 223 | warn: (s) => styleText(['yellow', 'bold'], s), |
| 224 | error: (s) => styleText(['red', 'bold'], s), |
| 225 | fatal: (s) => styleText(['red', 'bold'], s), |
| 226 | }); |
| 227 | |
| 228 | // Check the target. |
| 229 | const targetStr = positionals[0]; |
| 230 | if (!targetStr || cliOptions.help) { |
| 231 | // Show architect usage if there's no target. |
| 232 | usage(logger); |
| 233 | } |
| 234 | |
| 235 | // Load workspace configuration file. |
| 236 | const currentPath = process.cwd(); |
| 237 | const configFileNames = ['angular.json', '.angular.json', 'workspace.json', '.workspace.json']; |
| 238 | |
| 239 | const configFilePath = findUp(configFileNames, currentPath); |
| 240 | |
| 241 | if (!configFilePath) { |
| 242 | logger.fatal( |
| 243 | `Workspace configuration file (${configFileNames.join(', ')}) cannot be found in ` + |
| 244 | `'${currentPath}' or in parent directories.`, |
| 245 | ); |
| 246 | |
| 247 | return 3; |
| 248 | } |
| 249 | |
| 250 | const root = path.dirname(configFilePath); |
| 251 | |
| 252 | const registry = new schema.CoreSchemaRegistry(); |
| 253 | registry.addPostTransform(schema.transforms.addUndefinedDefaults); |
| 254 | |
| 255 | // Show usage of deprecated options |
| 256 | registry.useXDeprecatedProvider((msg) => logger.warn(msg)); |
| 257 | |
| 258 | const { workspace } = await workspaces.readWorkspace( |
| 259 | configFilePath, |
| 260 | workspaces.createWorkspaceHost(new NodeJsSyncHost()), |
| 261 | ); |
| 262 | |
| 263 | // Clear the console. |
| 264 | process.stdout.write('\u001Bc'); |
| 265 | |
| 266 | return await _executeTarget(logger, workspace, root, targetStr, builderOptions, registry); |
| 267 | } |
| 268 | |
| 269 | main(process.argv.slice(2)).then( |
| 270 | (code) => { |
no test coverage detected