UNPKG

3.86 kBTypeScriptView Raw
1import { CrossbowConfiguration } from "./config";
2import { InputFiles, InputError } from "./task.utils";
3import { CrossbowInput } from "./index";
4import { ParsedPath } from "path";
5import Rx = require("rx");
6export interface ExternalFile {
7 rawInput: string;
8 resolved: string;
9 relative: string;
10 errors: InputError[];
11 parsed: ParsedPath;
12}
13export interface FileNotFoundError extends InputError {
14}
15export interface BinDirectoryNotFoundError extends InputError {
16}
17export interface ExternalFileContent extends ExternalFile {
18 content: string;
19 data?: any;
20}
21export interface ExternalFileInput extends ExternalFile {
22 input: CrossbowInput | any;
23}
24/**
25 * Try to auto-load configuration files
26 * from the users CWD
27 */
28export declare function retrieveDefaultInputFiles(config: CrossbowConfiguration): InputFiles;
29/**
30 * Try to load cbfiles (like gulp) from the users
31 * working directory
32 * @param config
33 * @returns {InputFiles}
34 */
35export declare function retrieveCBFiles(config: CrossbowConfiguration): InputFiles;
36/**
37 * Try to retrieve input files from disk.
38 * This is different from regular file reading as
39 * we deliver errors with context
40 */
41export declare function readInputFiles(paths: string[], cwd: string): InputFiles;
42export declare function readFileFromDiskWithContent(path: string, cwd: string): ExternalFileContent;
43export declare function readFilesFromDiskWithContent(paths: string[], cwd: string): ExternalFileContent[];
44export declare function readFileContent(file: ExternalFile): string;
45export declare function writeFileToDisk(file: ExternalFile, content: string): void;
46export declare function getStubFileWithContent(path: string, cwd: string): ExternalFileContent;
47export declare function readOrCreateJsonFile(path: string, cwd: string): ExternalFileContent;
48export declare function getStubFile(path: string, cwd: string): ExternalFile;
49/**
50 * Take an array of paths and return file info + errors if they don't exist
51 * @param paths
52 * @param cwd
53 * @returns {ExternalFile[]}
54 */
55export declare function readFilesFromDisk(paths: string[], cwd: string): ExternalFile[];
56/**
57 * Attempt to use the LOCALLY installed crossbow version
58 * first, this will ensure anything registered with .task etc
59 * can be picked up by global installs too.
60 * @param config
61 * @returns {InputFiles}
62 */
63export declare function getRequirePaths(config: CrossbowConfiguration): InputFiles;
64export declare function getExternalFiles(dirpaths: string[], cwd: string): ExternalFile[];
65export declare function getPossibleTasksFromDirectories(dirpaths: string[], cwd: string): string[];
66export interface IHashItem {
67 userInput: string;
68 resolved: string;
69 hash: string;
70 changed: boolean;
71}
72export interface IHashInput {
73 userInput: string;
74 pathObj: ExternalFile;
75}
76export interface IHashResults {
77 output: IHashItem[];
78 markedHashes: IHashItem[];
79}
80export declare enum HashDirErrorTypes {
81 HashNotADirectory,
82 HashPathNotFound,
83}
84export interface HashDirError extends Error {
85 code: string;
86 path: string;
87 syscall: string;
88}
89export declare function hashItems(dirs: string[], cwd: string, existingHashes: IHashItem[]): Rx.Observable<IHashResults>;
90/**
91 * Thanks to https://github.com/motdotla/dotenv
92 * @param src
93 * @returns {{}}
94 */
95export declare function parseEnv(src: string): {
96 [index: string]: string;
97};
98export declare const Right: (x: any) => {
99 chain: (f: any) => any;
100 map: (f: any) => any;
101 fold: (f: any, g: any) => any;
102 inspect: () => string;
103};
104export declare const Left: (x: any) => {
105 chain: (f: any) => any;
106 map: (f: any) => any;
107 fold: (f: any, g: any) => any;
108 inspect: () => string;
109};
110export declare const tryCatch: (f: any) => {
111 chain: (f: any) => any;
112 map: (f: any) => any;
113 fold: (f: any, g: any) => any;
114 inspect: () => string;
115};