source: trip-planner-front/node_modules/@angular/cli/lib/init.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.6 KB
RevLine 
[6a3a178]1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10 if (k2 === undefined) k2 = k;
11 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12}) : (function(o, m, k, k2) {
13 if (k2 === undefined) k2 = k;
14 o[k2] = m[k];
15}));
16var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17 Object.defineProperty(o, "default", { enumerable: true, value: v });
18}) : function(o, v) {
19 o["default"] = v;
20});
21var __importStar = (this && this.__importStar) || function (mod) {
22 if (mod && mod.__esModule) return mod;
23 var result = {};
24 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25 __setModuleDefault(result, mod);
26 return result;
27};
28Object.defineProperty(exports, "__esModule", { value: true });
29require("symbol-observable");
30// symbol polyfill must go first
31const fs_1 = require("fs");
32const path = __importStar(require("path"));
33const semver_1 = require("semver");
34const version_1 = require("../models/version");
35const color_1 = require("../utilities/color");
36const config_1 = require("../utilities/config");
37(async () => {
38 var _a;
39 /**
40 * Disable Browserslist old data warning as otherwise with every release we'd need to update this dependency
41 * which is cumbersome considering we pin versions and the warning is not user actionable.
42 * `Browserslist: caniuse-lite is outdated. Please run next command `npm update`
43 * See: https://github.com/browserslist/browserslist/blob/819c4337456996d19db6ba953014579329e9c6e1/node.js#L324
44 */
45 process.env.BROWSERSLIST_IGNORE_OLD_DATA = '1';
46 const disableVersionCheckEnv = process.env['NG_DISABLE_VERSION_CHECK'];
47 /**
48 * Disable CLI version mismatch checks and forces usage of the invoked CLI
49 * instead of invoking the local installed version.
50 */
51 const disableVersionCheck = disableVersionCheckEnv !== undefined &&
52 disableVersionCheckEnv !== '0' &&
53 disableVersionCheckEnv.toLowerCase() !== 'false';
54 if (disableVersionCheck) {
55 return (await Promise.resolve().then(() => __importStar(require('./cli')))).default;
56 }
57 let cli;
58 try {
59 // No error implies a projectLocalCli, which will load whatever
60 // version of ng-cli you have installed in a local package.json
61 const projectLocalCli = require.resolve('@angular/cli', { paths: [process.cwd()] });
62 cli = await Promise.resolve().then(() => __importStar(require(projectLocalCli)));
63 const globalVersion = new semver_1.SemVer(version_1.VERSION.full);
64 // Older versions might not have the VERSION export
65 let localVersion = (_a = cli.VERSION) === null || _a === void 0 ? void 0 : _a.full;
66 if (!localVersion) {
67 try {
68 const localPackageJson = await fs_1.promises.readFile(path.join(path.dirname(projectLocalCli), '../../package.json'), 'utf-8');
69 localVersion = JSON.parse(localPackageJson).version;
70 }
71 catch (error) {
72 // eslint-disable-next-line no-console
73 console.error('Version mismatch check skipped. Unable to retrieve local version: ' + error);
74 }
75 }
76 let isGlobalGreater = false;
77 try {
78 isGlobalGreater = !!localVersion && globalVersion.compare(localVersion) > 0;
79 }
80 catch (error) {
81 // eslint-disable-next-line no-console
82 console.error('Version mismatch check skipped. Unable to compare local version: ' + error);
83 }
84 if (isGlobalGreater) {
85 // If using the update command and the global version is greater, use the newer update command
86 // This allows improvements in update to be used in older versions that do not have bootstrapping
87 if (process.argv[2] === 'update') {
88 cli = await Promise.resolve().then(() => __importStar(require('./cli')));
89 }
90 else if (await config_1.isWarningEnabled('versionMismatch')) {
91 // Otherwise, use local version and warn if global is newer than local
92 const warning = `Your global Angular CLI version (${globalVersion}) is greater than your local ` +
93 `version (${localVersion}). The local Angular CLI version is used.\n\n` +
94 'To disable this warning use "ng config -g cli.warnings.versionMismatch false".';
95 // eslint-disable-next-line no-console
96 console.error(color_1.colors.yellow(warning));
97 }
98 }
99 }
100 catch {
101 // If there is an error, resolve could not find the ng-cli
102 // library from a package.json. Instead, include it from a relative
103 // path to this script file (which is likely a globally installed
104 // npm package). Most common cause for hitting this is `ng new`
105 cli = await Promise.resolve().then(() => __importStar(require('./cli')));
106 }
107 if ('default' in cli) {
108 cli = cli['default'];
109 }
110 return cli;
111})()
112 .then((cli) => {
113 return cli({
114 cliArgs: process.argv.slice(2),
115 inputStream: process.stdin,
116 outputStream: process.stdout,
117 });
118})
119 .then((exitCode) => {
120 process.exit(exitCode);
121})
122 .catch((err) => {
123 // eslint-disable-next-line no-console
124 console.error('Unknown error: ' + err.toString());
125 process.exit(127);
126});
Note: See TracBrowser for help on using the repository browser.