1 | "use strict";
|
2 | var __assign = (this && this.__assign) || function () {
|
3 | __assign = Object.assign || function(t) {
|
4 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5 | s = arguments[i];
|
6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7 | t[p] = s[p];
|
8 | }
|
9 | return t;
|
10 | };
|
11 | return __assign.apply(this, arguments);
|
12 | };
|
13 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
14 | return new (P || (P = Promise))(function (resolve, reject) {
|
15 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
16 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
17 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
18 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
19 | });
|
20 | };
|
21 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
22 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
23 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
24 | function verb(n) { return function (v) { return step([n, v]); }; }
|
25 | function step(op) {
|
26 | if (f) throw new TypeError("Generator is already executing.");
|
27 | while (_) try {
|
28 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
29 | if (y = 0, t) op = [op[0] & 2, t.value];
|
30 | switch (op[0]) {
|
31 | case 0: case 1: t = op; break;
|
32 | case 4: _.label++; return { value: op[1], done: false };
|
33 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
34 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
35 | default:
|
36 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
37 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
38 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
39 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
40 | if (t[2]) _.ops.pop();
|
41 | _.trys.pop(); continue;
|
42 | }
|
43 | op = body.call(thisArg, _);
|
44 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
45 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
46 | }
|
47 | };
|
48 | Object.defineProperty(exports, "__esModule", { value: true });
|
49 | var path_1 = require("path");
|
50 | var fs_1 = require("fs");
|
51 | var types_1 = require("./types");
|
52 | function guessTargets() {
|
53 | return __awaiter(this, void 0, void 0, function () {
|
54 | var _a, pkg, dependencies;
|
55 | return __generator(this, function (_b) {
|
56 | pkg = JSON.parse(fs_1.readFileSync(path_1.resolve(process.cwd(), 'package.json'), {
|
57 | encoding: 'utf-8'
|
58 | }));
|
59 | dependencies = Object.keys(__assign({}, pkg.dependencies, pkg.devDependencies));
|
60 | return [2 , (_a = {},
|
61 | _a[types_1.Tags.angular] = isAngular(dependencies),
|
62 | _a[types_1.Tags.react] = isReact(dependencies),
|
63 | _a[types_1.Tags.stencil] = isStencil(dependencies),
|
64 | _a[types_1.Tags.browser] = false,
|
65 | _a[types_1.Tags.node] = false,
|
66 | _a[types_1.Tags.typescript] = isTypescript(dependencies),
|
67 | _a[types_1.Tags.flow] = isFlow(dependencies),
|
68 | _a)];
|
69 | });
|
70 | });
|
71 | }
|
72 | exports.guessTargets = guessTargets;
|
73 | function isAngular(dependencies) {
|
74 | return dependencies.includes('@angular/core');
|
75 | }
|
76 | function isReact(dependencies) {
|
77 | return dependencies.includes('react');
|
78 | }
|
79 | function isStencil(dependencies) {
|
80 | return dependencies.includes('@stencil/core');
|
81 | }
|
82 | function isTypescript(dependencies) {
|
83 | return dependencies.includes('typescript');
|
84 | }
|
85 | function isFlow(dependencies) {
|
86 | return dependencies.includes('flow');
|
87 | }
|
88 |
|
\ | No newline at end of file |