1 | "use strict";
|
2 |
|
3 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
4 | return new (P || (P = Promise))(function (resolve, reject) {
|
5 | function fulfilled(value) {
|
6 | try {
|
7 | step(generator.next(value));
|
8 | } catch (e) {
|
9 | reject(e);
|
10 | }
|
11 | }
|
12 | function rejected(value) {
|
13 | try {
|
14 | step(generator["throw"](value));
|
15 | } catch (e) {
|
16 | reject(e);
|
17 | }
|
18 | }
|
19 | function step(result) {
|
20 | result.done ? resolve(result.value) : new P(function (resolve) {
|
21 | resolve(result.value);
|
22 | }).then(fulfilled, rejected);
|
23 | }
|
24 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
25 | });
|
26 | };
|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
28 | const fs_extra_1 = require("fs-extra");
|
29 | const path_1 = require("path");
|
30 | const utilities_1 = require("../utilities");
|
31 | const openInEditor = require('open-in-editor');
|
32 | function projectSourceDirectories(workspace) {
|
33 | return utilities_1.flatten([utilities_1.ifElse(workspace.project.isNode, ['client', 'server']), path_1.relative(workspace.paths.root, workspace.paths.app)]);
|
34 | }
|
35 | exports.projectSourceDirectories = projectSourceDirectories;
|
36 | function projectSourceDirectoryGlobPattern(workspace) {
|
37 | const dirs = projectSourceDirectories(workspace);
|
38 | return dirs.length > 1 ? `{${dirs.join(',')}}` : dirs[0];
|
39 | }
|
40 | exports.projectSourceDirectoryGlobPattern = projectSourceDirectoryGlobPattern;
|
41 | function graphQLSchemaPath(workspace, idl = false) {
|
42 | return path_1.join(workspace.paths.build, `schema.${idl ? 'graphql' : 'json'}`);
|
43 | }
|
44 | exports.graphQLSchemaPath = graphQLSchemaPath;
|
45 | function makePrivateDirectory({ paths }) {
|
46 | return __awaiter(this, void 0, void 0, function* () {
|
47 | yield fs_extra_1.mkdirp(paths.private);
|
48 | yield fs_extra_1.writeFile(path_1.join(paths.private, '.gitignore'), '*');
|
49 | });
|
50 | }
|
51 | exports.makePrivateDirectory = makePrivateDirectory;
|
52 | function makeGitIgnoredDirectory(path) {
|
53 | return __awaiter(this, void 0, void 0, function* () {
|
54 | yield fs_extra_1.mkdirp(path);
|
55 | yield fs_extra_1.writeFile(path_1.join(path, '.gitignore'), '*');
|
56 | });
|
57 | }
|
58 | exports.makeGitIgnoredDirectory = makeGitIgnoredDirectory;
|
59 | function openFile(file, { line = 0, column = 0 } = {}) {
|
60 | return __awaiter(this, void 0, void 0, function* () {
|
61 | const editor = openInEditor.configure({
|
62 | pattern: '-r -g',
|
63 | line,
|
64 | column
|
65 | });
|
66 | if (editor == null) {
|
67 | return;
|
68 | }
|
69 | yield editor.open(file);
|
70 | });
|
71 | }
|
72 | exports.openFile = openFile; |
\ | No newline at end of file |