1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | interface String {
|
12 | yellow: string;
|
13 | cyan: string;
|
14 | white: string;
|
15 | magenta: string;
|
16 | green: string;
|
17 | red: string;
|
18 | grey: string;
|
19 | blue: string;
|
20 | }
|
21 |
|
22 | declare namespace node {
|
23 |
|
24 | |
25 |
|
26 |
|
27 | interface NodePackage {
|
28 | name: string;
|
29 | version: string;
|
30 | description?: string | undefined;
|
31 | keywords?: string[] | undefined;
|
32 | homepage?: string | undefined;
|
33 | }
|
34 | }
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | declare namespace minimatch {
|
40 |
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | interface IMinimatchOptions {
|
49 | |
50 |
|
51 |
|
52 |
|
53 | |
54 |
|
55 |
|
56 | debug?: boolean | undefined;
|
57 |
|
58 | |
59 |
|
60 |
|
61 | nobrace?: boolean | undefined;
|
62 |
|
63 | |
64 |
|
65 |
|
66 | noglobstar?: boolean | undefined;
|
67 |
|
68 | |
69 |
|
70 |
|
71 |
|
72 |
|
73 | dot?: boolean | undefined;
|
74 |
|
75 | |
76 |
|
77 |
|
78 | noext?: boolean | undefined;
|
79 |
|
80 | |
81 |
|
82 |
|
83 | nocase?: boolean | undefined;
|
84 |
|
85 | |
86 |
|
87 |
|
88 |
|
89 | nonull?: boolean | undefined;
|
90 |
|
91 | |
92 |
|
93 |
|
94 |
|
95 | matchBase?: boolean | undefined;
|
96 |
|
97 | |
98 |
|
99 |
|
100 | nocomment?: boolean | undefined;
|
101 |
|
102 | |
103 |
|
104 |
|
105 | nonegate?: boolean | undefined;
|
106 |
|
107 | |
108 |
|
109 |
|
110 | flipNegate?: boolean | undefined;
|
111 | }
|
112 | }
|
113 |
|
114 |
|
115 |
|
116 |
|
117 | declare namespace grunt {
|
118 |
|
119 | namespace config {
|
120 |
|
121 | |
122 |
|
123 |
|
124 | interface IProjectConfig{
|
125 | [plugin: string]: any;
|
126 | }
|
127 |
|
128 | |
129 |
|
130 |
|
131 | interface ConfigModule {
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | (prop: string, value: any): any;
|
139 | (prop: string): any;
|
140 |
|
141 | |
142 |
|
143 |
|
144 |
|
145 |
|
146 | init(config: IProjectConfig): void;
|
147 |
|
148 | |
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 | get<T>(prop: string): T;
|
157 | get(): ConfigModule;
|
158 |
|
159 | |
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 | process<T>(value: string): T;
|
170 |
|
171 | |
172 |
|
173 |
|
174 |
|
175 |
|
176 | getRaw<T>(prop: string): T;
|
177 |
|
178 | |
179 |
|
180 |
|
181 |
|
182 | set<T>(prop: string, value: T): T;
|
183 |
|
184 | |
185 |
|
186 |
|
187 | escape(propString: string): string;
|
188 |
|
189 | |
190 |
|
191 |
|
192 |
|
193 | requires(prop: string, ...andProps: string[]): void;
|
194 | requires(prop: string[], ...andProps: string[][]): void;
|
195 |
|
196 | |
197 |
|
198 |
|
199 |
|
200 | merge<T>(configObject: T): void;
|
201 | }
|
202 | }
|
203 |
|
204 | namespace event {
|
205 | |
206 |
|
207 |
|
208 | interface EventModule {
|
209 |
|
210 | |
211 |
|
212 |
|
213 | addListener(event: string, listener: Function): EventModule;
|
214 | on(event: string, listener: Function): EventModule;
|
215 |
|
216 | |
217 |
|
218 |
|
219 | onAny(listener: Function): EventModule;
|
220 |
|
221 | |
222 |
|
223 |
|
224 | offAny(listener: Function): EventModule;
|
225 |
|
226 | |
227 |
|
228 |
|
229 |
|
230 | once(event: string, listener: Function): EventModule;
|
231 |
|
232 | |
233 |
|
234 |
|
235 |
|
236 | many(event: string, timesToListen: number, listener: Function): EventModule;
|
237 |
|
238 | |
239 |
|
240 |
|
241 |
|
242 | removeListener(event: string, listener: Function): EventModule;
|
243 | off(event: string, listener: Function): EventModule;
|
244 |
|
245 | |
246 |
|
247 |
|
248 | removeAllListeners(event: string): EventModule;
|
249 |
|
250 | |
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 | setMaxListener(n: number): void;
|
258 |
|
259 | |
260 |
|
261 |
|
262 |
|
263 | listeners(event: string): Function[];
|
264 |
|
265 | |
266 |
|
267 |
|
268 |
|
269 | listenersAny(): Function[];
|
270 |
|
271 | |
272 |
|
273 |
|
274 |
|
275 | emit(event: string, ...args: any[]): any;
|
276 | }
|
277 | }
|
278 |
|
279 | namespace fail {
|
280 |
|
281 | enum ErrorCode {
|
282 | NoError = 0,
|
283 | Fatal = 1,
|
284 | MissingGruntfile = 2,
|
285 | Task = 3,
|
286 | Template = 4,
|
287 | Autocomplete = 5,
|
288 | Warning = 6,
|
289 | }
|
290 |
|
291 | interface FailModule {
|
292 |
|
293 | |
294 |
|
295 |
|
296 |
|
297 | warn(error: string, errorCode?: ErrorCode): void;
|
298 | warn(error: Error, errorCode?: ErrorCode): void;
|
299 |
|
300 | |
301 |
|
302 |
|
303 | fatal(error: string, errorCode?: ErrorCode): void;
|
304 | fatal(error: Error, errorCode?: ErrorCode): void;
|
305 | }
|
306 | }
|
307 |
|
308 | namespace file {
|
309 |
|
310 | |
311 |
|
312 |
|
313 | interface IFileEncodedOption {
|
314 | encoding: string;
|
315 | }
|
316 |
|
317 | |
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 | interface IFileWriteOptions extends grunt.file.IFileEncodedOption {
|
324 | |
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 | noProcess?: any;
|
333 | }
|
334 |
|
335 | |
336 |
|
337 |
|
338 | interface IFileWriteBufferOption extends grunt.file.IFileWriteOptions {
|
339 | |
340 |
|
341 |
|
342 |
|
343 |
|
344 | process?: ((buffer: Buffer) => boolean) | undefined;
|
345 | }
|
346 |
|
347 | /**
|
348 | * @see IFileWriteOptions
|
349 | */
|
350 | interface IFileWriteStringOption extends grunt.file.IFileWriteOptions {
|
351 | /**
|
352 | * The source file contents, source file path, and destination file path
|
353 | * are passed into this function, whose return value will be used as the
|
354 | * destination file's contents.
|
355 | * If this function returns 'false', the file copy will be aborted.
|
356 | * @example
|
357 | ```ts
|
358 | const copyOptions: grunt.file.IFileWriteStringOption = {
|
359 | encoding: options.encoding,
|
360 | process: (contents: string, srcpath: string, destpath: string): string | boolean => {
|
361 |
|
362 |
|
363 | return contents;
|
364 | },
|
365 | noProcess: options.noProcess,
|
366 | };
|
367 | ```
|
368 | */
|
369 | process?: ((contents: string, srcpath: string, destpath: string) => (string | boolean)) | undefined;
|
370 | }
|
371 |
|
372 | /**
|
373 | * {@link http://gruntjs.com/api/grunt.file}
|
374 | */
|
375 | interface FileModule {
|
376 |
|
377 | /**
|
378 | * Set this property to change the default encoding used by all grunt.file methods.
|
379 | * Defaults to 'utf8'.
|
380 | *
|
381 | * If you do have to change this value, it's recommended that you change
|
382 | * it as early as possible inside your Gruntfile.
|
383 | */
|
384 | defaultEncoding: string;
|
385 |
|
386 | /**
|
387 | * Read and return a file's contents.
|
388 | * Returns a string, unless options.encoding is null in which case it returns a Buffer.
|
389 | */
|
390 | read(filepath: string): string;
|
391 | read(filepath: string, options: IFileEncodedOption): Buffer;
|
392 |
|
393 | /**
|
394 | * Read a file's contents, parsing the data as JSON and returning the result.
|
395 | * @see FileModule.read for a list of supported options.
|
396 | */
|
397 | readJSON(filepath: string): any;
|
398 | readJSON(filepath: string, options: IFileEncodedOption): Buffer;
|
399 |
|
400 | /**
|
401 | * Read a file's contents, parsing the data as YAML and returning the result.
|
402 | * @see FileModule.read for a list of supported options.
|
403 | */
|
404 | readYAML(filepath: string): any;
|
405 | readYAML(filepath: string, options: IFileEncodedOption): Buffer;
|
406 |
|
407 | /**
|
408 | * Write the specified contents to a file, creating intermediate directories if necessary.
|
409 | * Strings will be encoded using the specified character encoding, Buffers will be written to disk as-specified.
|
410 | *
|
411 | * @param contents If `contents` is a Buffer, encoding is ignored.
|
412 | * @param options If an encoding is not specified, default to grunt.file.defaultEncoding.
|
413 | */
|
414 | write(filepath: string, contents: string, options?: IFileEncodedOption): void;
|
415 | write(filepath: string, contents: Buffer): void;
|
416 |
|
417 | /**
|
418 | * Copy a source file to a destination path, creating intermediate directories if necessary.
|
419 | */
|
420 | copy(srcpath: string, destpath: string): void;
|
421 | copy(srcpath: string, destpath: string, options: IFileWriteStringOption): void;
|
422 | copy(srcpath: string, destpath: string, options: IFileWriteBufferOption): void;
|
423 |
|
424 | /**
|
425 | * Delete the specified filepath. Will delete files and folders recursively.
|
426 | *
|
427 | * @return true if the files could be deleted, otherwise false.
|
428 | */
|
429 | delete(filepath: string, options?: { force?: boolean | undefined }): boolean;
|
430 |
|
431 | /**
|
432 | * Works like mkdir -p. Create a directory along with any intermediate directories.
|
433 | * If mode isn't specified, it defaults to 0777 & (~process.umask()).
|
434 | */
|
435 | mkdir(dirpath: string, mode?: string): void;
|
436 |
|
437 | /**
|
438 | * Recurse into a directory, executing callback for each file.
|
439 | *
|
440 | * Callback args:
|
441 | * abspath - The full path to the current file,
|
442 | * which is nothing more than the rootdir + subdir + filename arguments, joined.
|
443 | * rootdir - The root director, as originally specified.
|
444 | * subdir - The current file's directory, relative to rootdir.
|
445 | * filename - The filename of the current file, without any directory parts.
|
446 | */
|
447 | recurse(
|
448 | rootdir: string,
|
449 | callback: (abspath: string, rootdir: string, subdir: string, filename: string) => void
|
450 | ): void;
|
451 |
|
452 | /**
|
453 | * Return a unique array of all file or directory paths that match the given globbing pattern(s).
|
454 | * This method accepts either comma separated globbing patterns or an array of globbing patterns.
|
455 | * Paths matching patterns that begin with ! will be excluded from the returned array.
|
456 | * Patterns are processed in order, so inclusion and exclusion order is significant.
|
457 | *
|
458 | * File paths are relative to the Gruntfile unless the current working directory is changed with
|
459 | * grunt.file.setBase or the --base command-line option.
|
460 | */
|
461 | expand(patterns: string | string[]): string[];
|
462 | expand(options: IFilesConfig, patterns: string | string[]): string[];
|
463 |
|
464 | /**
|
465 | * Returns an array of src-dest file mapping objects.
|
466 | * For each source file matched by a specified pattern, join that file path to the specified dest.
|
467 | * This file path may be flattened or renamed, depending on the options specified.
|
468 | *
|
469 | * @see FileModule.expand method documentation for an explanation of how the patterns
|
470 | * and options arguments may be specified.
|
471 | */
|
472 | expandMapping(patterns: string[], dest: string, options: IExpandedFilesConfig): Array<IFileMap>;
|
473 |
|
474 | /**
|
475 | * Match one or more globbing patterns against one or more file paths.
|
476 | * Returns a uniqued array of all file paths that match any of the specified globbing patterns.
|
477 | * Both the patterns and filepaths argument can be a single string or array of strings.
|
478 | * Paths matching patterns that begin with ! will be excluded from the returned array.
|
479 | * Patterns are processed in order, so inclusion and exclusion order is significant.
|
480 | */
|
481 | match(pattern: string, filepath: string): string[];
|
482 | match(pattern: string, filepaths: string[]): string[];
|
483 | match(patterns: string[], filepath: string): string[];
|
484 | match(patterns: string[], filepaths: string[]): string[];
|
485 | match(options: minimatch.IMinimatchOptions, pattern: string, filepath: string): string[];
|
486 | match(options: minimatch.IMinimatchOptions, pattern: string, filepaths: string[]): string[];
|
487 | match(options: minimatch.IMinimatchOptions, patterns: string[], filepath: string): string[];
|
488 | match(options: minimatch.IMinimatchOptions, patterns: string[], filepaths: string[]): string[];
|
489 |
|
490 | /**
|
491 | * This method contains the same signature and logic as the grunt.file.match method,
|
492 | * but simply returns true if any files were matched, otherwise false.
|
493 | *
|
494 | * @see FileModule.match
|
495 | */
|
496 | isMatch(pattern: string, filepath: string): boolean;
|
497 | isMatch(pattern: string, filepaths: string[]): boolean;
|
498 | isMatch(patterns: string[], filepath: string): boolean;
|
499 | isMatch(patterns: string[], filepaths: string[]): boolean;
|
500 | isMatch(options: minimatch.IMinimatchOptions, pattern: string, filepath: string): boolean;
|
501 | isMatch(options: minimatch.IMinimatchOptions, pattern: string, filepaths: string[]): boolean;
|
502 | isMatch(options: minimatch.IMinimatchOptions, patterns: string[], filepath: string): boolean;
|
503 | isMatch(options: minimatch.IMinimatchOptions, patterns: string[], filepaths: string[]): boolean;
|
504 |
|
505 |
|
506 | /*
|
507 | * Like the Node.js path.join method, the methods below will
|
508 | * join all arguments together and normalize the resulting path.
|
509 | */
|
510 |
|
511 | /**
|
512 | * Does the given path exist?
|
513 | */
|
514 | exists(path: string, ...append: string[]): boolean;
|
515 |
|
516 | /**
|
517 | * Is the given path a symbolic link?
|
518 | */
|
519 | isLink(path: string, ...append: string[]): boolean;
|
520 |
|
521 | /**
|
522 | * Is the given path a symbolic link?
|
523 | */
|
524 | isDir(path: string, ...append: string[]): boolean;
|
525 |
|
526 | /**
|
527 | * Is the given path a file?
|
528 | */
|
529 | isFile(path: string, ...append: string[]): boolean;
|
530 |
|
531 | /**
|
532 | * Is a given file path absolute?
|
533 | */
|
534 | isPathAbsolute(path: string, ...append: string[]): boolean;
|
535 |
|
536 | /**
|
537 | * Do all the specified paths refer to the same path?
|
538 | */
|
539 | arePathsEquivalent(path: string, ...append: string[]): boolean;
|
540 |
|
541 | /**
|
542 | * Are all descendant path(s) contained within the specified ancestor path?
|
543 | */
|
544 | doesPathContain(ancestorPath: string, decendantPaths: string[]): boolean;
|
545 |
|
546 | /**
|
547 | * Is a given file path the current working directory (CWD)?
|
548 | */
|
549 | isPathCwd(path: string, ...append: string[]): boolean;
|
550 |
|
551 | /**
|
552 | * Change grunt's current working directory (CWD).
|
553 | * By default, all file paths are relative to the Gruntfile.
|
554 | * This works just like the --base command-line option.
|
555 | */
|
556 | setBase(path: string, ...append: string[]): void;
|
557 |
|
558 | // External libraries
|
559 | // TODO: Create declarations
|
560 | glob: any;
|
561 | minimatch: any;
|
562 | findup: any;
|
563 | }
|
564 |
|
565 | /**
|
566 | * A convenience type.
|
567 | *
|
568 | * {@link http://gruntjs.com/configuring-tasks#files}
|
569 | */
|
570 | interface IFilesArray extends Array<IFilesConfig> {}
|
571 |
|
572 | /**
|
573 | * {@link http://gruntjs.com/configuring-tasks#files}
|
574 | */
|
575 | interface IFilesConfig extends minimatch.IMinimatchOptions {
|
576 |
|
577 | /**
|
578 | * Pattern(s) to match, relative to the {@link IExpandedFilesConfig.cwd}.
|
579 | */
|
580 | src?: string[] | undefined;
|
581 |
|
582 | /**
|
583 | * Destination path prefix.
|
584 | */
|
585 | dest?: string | undefined;
|
586 |
|
587 | /**
|
588 | * Process a dynamic src-dest file mapping,
|
589 | * @see {@link http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically for more information.
|
590 | */
|
591 | expand?: boolean | undefined; // = false
|
592 |
|
593 | /**
|
594 | * Either a valid fs.Stats method name:
|
595 | * - isFile
|
596 | * - isDirectory
|
597 | * - isBlockDevice
|
598 | * - isCharacterDevice
|
599 | * - isSymbolicLink
|
600 | * - isFIFO
|
601 | * - isSocket
|
602 | *
|
603 | * or a function that is passed the matched src filepath and returns true or false.
|
604 | *
|
605 | * string
|
606 | * (src: string) => boolean
|
607 | */
|
608 | // filter?: string
|
609 | // filter?: (src: string) => boolean
|
610 | filter?: any;
|
611 |
|
612 | /**
|
613 | * Patterns will be matched relative to this path, and all returned filepaths will
|
614 | * also be relative to this path.
|
615 | */
|
616 | cwd?: string | undefined;
|
617 | }
|
618 |
|
619 | /**
|
620 | * These are valid for compact-format
|
621 | */
|
622 | interface IExpandedFilesConfig extends IFilesConfig {
|
623 |
|
624 | /**
|
625 | * Enables the following options
|
626 | */
|
627 | expand?: boolean | undefined; // = true
|
628 |
|
629 | /**
|
630 | * All {@link IExpandedFilesConfig.src} matches are relative to (but don't include) this path.
|
631 | */
|
632 | cwd?: string | undefined;
|
633 |
|
634 | /**
|
635 | * Replace any existing extension with this value in generated {@link IExpandedFilesConfig.dest} paths.
|
636 | */
|
637 | ext?: string | undefined;
|
638 |
|
639 | /**
|
640 | * Remove all path parts from generated {@link IExpandedFilesConfig.dest} paths.
|
641 | */
|
642 | flatten?: boolean | undefined;
|
643 |
|
644 | /**
|
645 | * This function is called for each matched src file, (after extension renaming and flattening).
|
646 | * The {@link IExpandedFilesConfig.dest} and matched {@link IExpandedFilesConfig.src} path are passed in,
|
647 | * and this function must return a new dest value.
|
648 | * If the same dest is returned more than once, each src which used it will be added to an array of sources for it.
|
649 | */
|
650 | rename?: Function | undefined;
|
651 | }
|
652 |
|
653 | /**
|
654 | * @see {@link http://gruntjs.com/configuring-tasks#files-array-format}
|
655 | */
|
656 | interface IFileMap {
|
657 | /**
|
658 | * source filenames.
|
659 | */
|
660 | src: string[];
|
661 | /**
|
662 | * destination filename.
|
663 | */
|
664 | dest: string;
|
665 | }
|
666 | }
|
667 |
|
668 | namespace log {
|
669 |
|
670 | /**
|
671 | * Grunt output should look consistent, and maybe even pretty.
|
672 | * As such, there is a plethora of logging methods, and a few useful patterns.
|
673 | * All of the methods that actually log something are chainable.
|
674 | */
|
675 | interface CommonLogging<T> {
|
676 |
|
677 | /**
|
678 | * Log the specified msg string, with no trailing newline.
|
679 | */
|
680 | write(msg: string): T;
|
681 |
|
682 | /**
|
683 | * Log the specified msg string, with trailing newline.
|
684 | */
|
685 | writeln(msg: string): T;
|
686 |
|
687 | /**
|
688 | * If msg string is omitted, logs ERROR in red,
|
689 | * otherwise logs >> msg, with trailing newline.
|
690 | */
|
691 | error(msg: string): T;
|
692 |
|
693 | /**
|
694 | * Log an error with grunt.log.error, wrapping text to 80 columns using grunt.log.wraptext.
|
695 | */
|
696 | errorlns(msg: string): T;
|
697 |
|
698 | /**
|
699 | * If msg string is omitted, logs OK in green, otherwise logs >> msg, with trailing newline.
|
700 | */
|
701 | ok(msg: string): T;
|
702 |
|
703 | /**
|
704 | * Log an ok message with grunt.log.ok, wrapping text to 80 columns using grunt.log.wraptext.
|
705 | */
|
706 | oklns(msg: string): T;
|
707 |
|
708 | /**
|
709 | * Log the specified msg string in bold, with trailing newline.
|
710 | */
|
711 | subhead(msg: string): T;
|
712 |
|
713 | /**
|
714 | * Log a list of obj properties (good for debugging flags).
|
715 | */
|
716 | writeflags(obj: any): T;
|
717 |
|
718 | /**
|
719 | * Log an warning with grunt.log.warn
|
720 | */
|
721 | warn(msg: string): T;
|
722 | }
|
723 |
|
724 | /**
|
725 | * @note all methods available under grunt.verbose work exactly like grunt.log methods,
|
726 | * but only log if the --verbose command-line option was specified.
|
727 | */
|
728 | interface VerboseLogModule extends CommonLogging<VerboseLogModule> {
|
729 | or: NotVerboseLogModule;
|
730 | }
|
731 |
|
732 | /**
|
733 | * @note all methods available under grunt.verbose work exactly like grunt.log methods,
|
734 | * but only log if the --verbose command-line option was not specified.
|
735 | */
|
736 | interface NotVerboseLogModule extends CommonLogging<NotVerboseLogModule> {
|
737 | or: VerboseLogModule;
|
738 | }
|
739 |
|
740 | /**
|
741 | * {@link http://gruntjs.com/api/grunt.log}
|
742 | */
|
743 | interface LogModule extends CommonLogging<LogModule> {
|
744 | verbose: VerboseLogModule;
|
745 | notverbose: NotVerboseLogModule;
|
746 | }
|
747 | }
|
748 |
|
749 | namespace option {
|
750 |
|
751 | /**
|
752 | * {@link http://gruntjs.com/api/grunt.option}
|
753 | */
|
754 | interface OptionModule {
|
755 |
|
756 | /**
|
757 | * Gets or sets an option.
|
758 | * Boolean options can be negated by prepending no- onto the key. For example:
|
759 | *
|
760 | * grunt.option('staging', false);
|
761 | * var isDev = grunt.option('no-staging');
|
762 | * assert(isDev === true)
|
763 | */
|
764 | <T>(key: string, value: T): void;
|
765 | <T>(key: string): T;
|
766 |
|
767 | /**
|
768 | * Initialize grunt.option.
|
769 | * If initObject is omitted option will be initialized to an empty object
|
770 | * otherwise will be set to initObject.
|
771 | */
|
772 | init(initObject?: any): void;
|
773 |
|
774 | /**
|
775 | * Returns the options as an array of command line parameters.
|
776 | */
|
777 | flags: grunt.IFlag[];
|
778 | }
|
779 |
|
780 | }
|
781 |
|
782 | namespace task {
|
783 |
|
784 | /**
|
785 | * {@link http://gruntjs.com/api/grunt.task}
|
786 | */
|
787 | interface CommonTaskModule {
|
788 |
|
789 | /**
|
790 | * If a task list is specified, the new task will be an alias for one or more other tasks.
|
791 | * Whenever this "alias task" is run, every specified task in taskList will be run, in the order specified.
|
792 | * The taskList argument must be an array of tasks.
|
793 | */
|
794 | registerTask(taskName: string, taskList: string[]): void;
|
795 | registerTask(taskName: string, description: string, taskList: string[]): void;
|
796 |
|
797 | /**
|
798 | * If a description and taskFunction are passed, the specified function will be executed
|
799 | * whenever the task is run.
|
800 | *
|
801 | * In addition, the specified description will be shown when grunt --help is run.
|
802 | * Task-specific properties and methods are available inside the task function as properties
|
803 | * of the this object. The task function can return false to indicate that the task has failed.
|
804 | *
|
805 | * @note taskFunction.apply(scope: grunt.task.ITask, args: any[])
|
806 | */
|
807 | registerTask(taskName: string, taskFunction: (this: ITask, ...args: any[]) => void): void;
|
808 | registerTask(taskName: string, description: string, taskFunction: (this: ITask, ...args: any[]) => void): void;
|
809 |
|
810 | /**
|
811 | * Register a "multi task." A multi task is a task that implicitly iterates over all of its
|
812 | * named sub-properties (AKA targets) if no target was specified.
|
813 | * In addition to the default properties and methods, extra multi task-specific properties
|
814 | * are available inside the task function as properties of the this object.
|
815 | *
|
816 | * @note taskFunction.apply(scope: grunt.task.IMultiTask<any>, args: any[])
|
817 | */
|
818 | registerMultiTask(taskName: string, taskFunction: (this: IMultiTask<any>, ...args: any[]) => void): void;
|
819 | registerMultiTask(taskName: string, taskDescription: string, taskFunction: (this: IMultiTask<any>, ...args: any[]) => void): void;
|
820 |
|
821 | /**
|
822 | * Check with the name, if a task exists in the registered tasks.
|
823 | * @param name The task name to check.
|
824 | * @since 0.4.5
|
825 | */
|
826 | exists(name: string): boolean;
|
827 |
|
828 | /**
|
829 | * Rename a task. This might be useful if you want to override the default behavior of a task, while retaining the old name.
|
830 | * Note that if a task has been renamed, the this.name and this.nameArgs properties will change accordingly.
|
831 | * @see ITask
|
832 | * @param oldname The previous name of the task.
|
833 | * @param newname The new name for the task.
|
834 | */
|
835 | renameTask(oldname: string, newname: string): void;
|
836 | }
|
837 |
|
838 | /**
|
839 | * {@link http://gruntjs.com/api/grunt.task#queueing-tasks}
|
840 | */
|
841 | interface TaskModule extends CommonTaskModule {
|
842 | /**
|
843 | * Enqueue one or more tasks.
|
844 | * Every specified task in taskList will be run immediately after the current task completes,
|
845 | * in the order specified. The task list can be an array of tasks or individual task arguments.
|
846 | */
|
847 | run(tasks: string[]): void;
|
848 | run(task: string, ...thenTasks: string[]): void;
|
849 |
|
850 | /**
|
851 | * Empty the task queue completely. Unless additional tasks are enqueued, no more tasks will be run.
|
852 | */
|
853 | clearQueue(): void;
|
854 |
|
855 | /**
|
856 | * Normalizes a task target configuration object into an array of src-dest file mappings.
|
857 | * This method is used internally by the multi task system this.files / grunt.task.current.files property.
|
858 | */
|
859 | normalizeMultiTaskFiles(data: grunt.config.IProjectConfig, targetname?: string): Array<grunt.file.IFileMap>;
|
860 |
|
861 | /**
|
862 | * The currently running task or multitask.
|
863 | * @see http://gruntjs.com/api/inside-tasks
|
864 | */
|
865 | current: grunt.task.IMultiTask<any>;
|
866 | }
|
867 |
|
868 | interface AsyncResultCatcher {
|
869 | /**
|
870 | * Either false or an Error object may be passed to the done function
|
871 | * to instruct Grunt that the task has failed.
|
872 | */
|
873 | (success: boolean): void;
|
874 | (error: Error): void;
|
875 | (result: any): void;
|
876 | (): void;
|
877 | }
|
878 |
|
879 | /**
|
880 | * @link http://gruntjs.com/inside-tasks
|
881 | *
|
882 | * Grunt version 0.4.x
|
883 | */
|
884 | interface ITask {
|
885 |
|
886 | /**
|
887 | * If a task is asynchronous, this method must be invoked to instruct Grunt to wait.
|
888 | * It returns a handle to a "done" function that should be called when the task has completed.
|
889 | *
|
890 | * // Tell Grunt this task is asynchronous.
|
891 | * var done = this.async();
|
892 | * // Your async code.
|
893 | * setTimeout(function() {
|
894 | * // Let's simulate an error, sometimes.
|
895 | * var success = Math.random() > 0.5;
|
896 | * // All done!
|
897 | * done(success);
|
898 | * }, 1000);
|
899 | */
|
900 | async(): AsyncResultCatcher;
|
901 |
|
902 | /**
|
903 | * If one task depends on the successful completion of another task (or tasks),
|
904 | * this method can be used to force Grunt to abort if the other task didn't run,
|
905 | * or if the other task failed.
|
906 | *
|
907 | * @param tasks an array of task names or individual task names, as arguments.
|
908 | * @note that this won't actually run the specified task(s),
|
909 | * it will just fail the current task if they haven't already run successfully.
|
910 | */
|
911 | requires(tasks: string[]): void
|
912 | requires(tasks: string, ...otherTasks: string[]): void
|
913 | requires(tasks: string[], ...otherTasks: string[][]): void
|
914 |
|
915 | /**
|
916 | * Fail the current task if one or more required config properties is missing.
|
917 | * One or more string or array config properties may be specified.
|
918 | * this.requiresConfig(prop [, prop [, ...]])
|
919 | */
|
920 | requiresConfig(prop: string, ...andProps: string[]): void;
|
921 |
|
922 | /**
|
923 | * The name of the task, as defined in grunt.registerTask.
|
924 | * For example, if a "sample" task was run as grunt sample or grunt sample:foo,
|
925 | * inside the task function, this.name would be "sample".
|
926 | */
|
927 | name: string;
|
928 |
|
929 | /**
|
930 | * The name of the task, including any colon-separated arguments or flags specified on the command-line.
|
931 | * For example, if a "sample" task was run as grunt sample:foo,
|
932 | * inside the task function, this.nameArgs would be "sample:foo".
|
933 | */
|
934 | nameArgs: string;
|
935 |
|
936 | /**
|
937 | * An array of arguments passed to the task.
|
938 | * For example, if a "sample" task was run as grunt sample:foo:bar,
|
939 | * inside the task function, this.args would be ["foo", "bar"].
|
940 | */
|
941 | args: string[];
|
942 |
|
943 | /**
|
944 | * An object generated from the arguments passed to the task.
|
945 | * For example, if a "sample" task was run as grunt sample:foo:bar,
|
946 | * inside the task function, this.flags would be {foo: true, bar: true}.
|
947 | */
|
948 | flags: grunt.IFlag[];
|
949 |
|
950 | /**
|
951 | * The number of grunt.log.error calls that occurred during this task.
|
952 | * This can be used to fail a task if errors were logged during the task.
|
953 | */
|
954 | errorCount: number;
|
955 |
|
956 | /**
|
957 | * Returns an options object.
|
958 | * Properties of the optional defaultsObj argument will be overridden by any task-level options
|
959 | * object properties, which will be further overridden in multi tasks by any target-level
|
960 | * options object properties.
|
961 | */
|
962 | options<T>(defaultsObj: T): T;
|
963 | options(defaultsObj: any): ITaskOptions;
|
964 | }
|
965 |
|
966 | /**
|
967 | * {@link http://gruntjs.com/inside-tasks#inside-multi-tasks}
|
968 | */
|
969 | interface IMultiTask<T> extends ITask {
|
970 | /**
|
971 | * In a multi task, this property contains the name of the target currently being iterated over.
|
972 | * For example, if a "sample" multi task was run as grunt sample:foo with the config data
|
973 | * {sample: {foo: "bar"}}, inside the task function, this.target would be "foo".
|
974 | */
|
975 | target: string;
|
976 |
|
977 | /**
|
978 | * In a multi task, all files specified using any Grunt-supported file formats and options,
|
979 | * globbing patterns or dynamic mappings will automatically be normalized into a single format:
|
980 | * the Files Array file format.
|
981 | *
|
982 | * What this means is that tasks don't need to contain a ton of boilerplate for explicitly
|
983 | * handling custom file formats, globbing patterns, mapping source files to destination files
|
984 | * or filtering out files or directories. A task user can just specify files per the Configuring
|
985 | * tasks guide, and Grunt will handle all the details.
|
986 | *
|
987 | * Your task should iterate over the this.files array, utilizing the src and dest properties of
|
988 | * each object in that array. The this.files property will always be an array.
|
989 | * The src property will also always be an array, in case your task cares about multiple source
|
990 | * files per destination file.
|
991 | *
|
992 | * @note it's possible that nonexistent files might be included in src values,
|
993 | * so you may want to explicitly test that source files exist before using them.
|
994 | */
|
995 | files: grunt.file.IFilesArray;
|
996 |
|
997 | /**
|
998 | * In a multi task, all src files files specified via any file format are reduced to a single array.
|
999 | * If your task is "read only" and doesn't care about destination filepaths,
|
1000 | * use this array instead of this.files.
|
1001 | */
|
1002 | filesSrc: string[];
|
1003 |
|
1004 | /**
|
1005 | * In a multi task, this is the actual data stored in the Grunt config object for the given target.
|
1006 | * For example, if a "sample" multi task was run as grunt sample:foo with the config data
|
1007 | * {sample: {foo: "bar"}}, inside the task function, this.data would be "bar".
|
1008 | *
|
1009 | * @note It is recommended that this.options this.files and this.filesSrc are used instead of this.data,
|
1010 | * as their values are normalized.
|
1011 | */
|
1012 | data: T;
|
1013 | }
|
1014 |
|
1015 | /**
|
1016 | * {@link http://gruntjs.com/configuring-tasks}
|
1017 | *
|
1018 | * A TaskConfig can be either be a full config or a compacted files config.
|
1019 | * @see ITaskCompactOptions
|
1020 | */
|
1021 | interface ITaskOptions {
|
1022 |
|
1023 | options?: any;
|
1024 |
|
1025 | // files?: grunt.file.IFilesArray
|
1026 | // files?: grunt.file.IFilesMap
|
1027 | files?: any;
|
1028 | }
|
1029 |
|
1030 | /**
|
1031 | * @see ITaskOptions
|
1032 | */
|
1033 | interface ITaskCompactOptions extends grunt.task.ITaskOptions, grunt.file.IFilesConfig {}
|
1034 | }
|
1035 |
|
1036 | namespace template {
|
1037 |
|
1038 | interface TemplateModule {
|
1039 |
|
1040 | /**
|
1041 | * Process a Lo-Dash template string.
|
1042 | *
|
1043 | * The template argument will be processed recursively until there are no more templates to process.
|
1044 | *
|
1045 | * The default data object is the entire config object, but if options.data is set, that object will
|
1046 | * be used instead. The default template delimiters are <% %> but if options.delimiters is set to a
|
1047 | * custom delimiter name, those template delimiters will be used instead.
|
1048 | *
|
1049 | * Inside templates, the grunt object is exposed so that you can do things like:
|
1050 | * <%= grunt.template.today('yyyy') %>
|
1051 | *
|
1052 | * @note if the data object already has a grunt property, the grunt API will not be accessible in templates.
|
1053 | */
|
1054 | process(template: string): (options: any) => string;
|
1055 | process(template: string, options: any): string;
|
1056 |
|
1057 | /**
|
1058 | * Set the Lo-Dash template delimiters to a predefined set in case you grunt.util._.template
|
1059 | * needs to be called manually.
|
1060 | *
|
1061 | * The config delimiters <% %> are included by default.
|
1062 | */
|
1063 | setDelimiters(name: string): void;
|
1064 |
|
1065 | /**
|
1066 | * Add a named set of Lo-Dash template delimiters.
|
1067 | *
|
1068 | * You probably won't need to use this method, because the built-in delimiters should be sufficient,
|
1069 | * but you could always add {% %} or [% %] style delimiters.
|
1070 | */
|
1071 | addDelimiters(name: string, opener: string, closer: string): void;
|
1072 |
|
1073 | /**
|
1074 | * Format a date using the dateformat library.
|
1075 | * {@link https://github.com/felixge/node-dateformat}
|
1076 | *
|
1077 | * @note if you don't include the mask argument, dateFormat.masks.default is used
|
1078 | */
|
1079 | date(date?: Date, format?: string): string;
|
1080 | date(date?: number, format?: string): string;
|
1081 | date(date?: string, format?: string): string;
|
1082 |
|
1083 | /**
|
1084 | * Format today's date using the dateformat library using the current date and time.
|
1085 | * {@link https://github.com/felixge/node-dateformat}
|
1086 | *
|
1087 | * @note if you don't include the mask argument, dateFormat.masks.default is used
|
1088 | */
|
1089 | today(format?: string): string;
|
1090 | }
|
1091 | }
|
1092 |
|
1093 | namespace util {
|
1094 |
|
1095 | /**
|
1096 | * {@link http://gruntjs.com/api/grunt.util}
|
1097 | */
|
1098 | interface UtilModule {
|
1099 |
|
1100 | /**
|
1101 | * Return the "kind" of a value. Like typeof but returns the internal [Class](Class/) value.
|
1102 | * Possible results are "number", "string", "boolean", "function", "regexp", "array", "date",
|
1103 | * "error", "null", "undefined" and the catch-all "object".
|
1104 | */
|
1105 | kindOf(value: any): string;
|
1106 |
|
1107 | /**
|
1108 | * Return a new Error instance (that can be thrown) with the appropriate message.
|
1109 | * If an Error object is specified instead of message that object will be returned.
|
1110 | * Also, if an Error object is specified for origError and Grunt was run with the --debug 9 option,
|
1111 | * the original Error stack will be dumped.
|
1112 | */
|
1113 | error(message: string, origError?: Error): Error;
|
1114 | error(error: Error, origError?: Error): Error;
|
1115 | error(error: any, origError?: Error): Error;
|
1116 |
|
1117 | /**
|
1118 | * The linefeed character, normalized for the current operating system.
|
1119 | * (\r\n on Windows, \n otherwise)
|
1120 | */
|
1121 | linefeed: string;
|
1122 |
|
1123 | /**
|
1124 | * Given a string, return a new string with all the linefeeds normalized for the current operating system.
|
1125 | * (\r\n on Windows, \n otherwise)
|
1126 | */
|
1127 | normalizelf(str: string): string;
|
1128 |
|
1129 | /**
|
1130 | * Recurse through nested objects and arrays, executing callbackFunction for each non-object value.
|
1131 | * If continueFunction returns false, a given object or value will be skipped.
|
1132 | */
|
1133 | recurse(object: any, callbackFunction: (value: any) => void, continueFunction: (objOrValue: any) => boolean): void;
|
1134 |
|
1135 | /**
|
1136 | * Return string str repeated n times.
|
1137 | */
|
1138 | repeat(n: number, str: string): string;
|
1139 |
|
1140 | /**
|
1141 | * Given str of "a/b", If n is 1, return "a" otherwise "b".
|
1142 | * You can specify a custom separator if '/' doesn't work for you.
|
1143 | */
|
1144 | pluralize(n: number, str: string, separator?: string): string;
|
1145 |
|
1146 | /**
|
1147 | * Spawn a child process, keeping track of its stdout, stderr and exit code.
|
1148 | * The method returns a reference to the spawned child.
|
1149 | * When the child exits, the done function is called.
|
1150 | *
|
1151 | * @param done a function with arguments:
|
1152 | * error - If the exit code was non-zero and a fallback wasn't specified,
|
1153 | * an Error object, otherwise null.
|
1154 | * result - The result object is an
|
1155 | * code - The numeric exit code.
|
1156 | */
|
1157 | spawn(options: ISpawnOptions, done: (error: Error, result: ISpawnResult, code: number) => void): ISpawnedChild;
|
1158 |
|
1159 | /**
|
1160 | * Given an array or array-like object, return an array.
|
1161 | * Great for converting arguments objects into arrays.
|
1162 | */
|
1163 | toArray<T>(arrayLikeObject: any): T[];
|
1164 |
|
1165 | /**
|
1166 | * Normalizes both "returns a value" and "passes result to a callback" functions to always
|
1167 | * pass a result to the specified callback. If the original function returns a value,
|
1168 | * that value will now be passed to the callback, which is specified as the last argument,
|
1169 | * after all other predefined arguments. If the original function passed a value to a callback,
|
1170 | * it will continue to do so.
|
1171 | */
|
1172 | callbackify<R>(syncOrAsyncFunction: () => R):
|
1173 | (callback: (result: R) => void) => void;
|
1174 | callbackify<A, R>(syncOrAsyncFunction: (a: A) => R):
|
1175 | (a: A, callback: (result: R) => void) => void;
|
1176 | callbackify<A, B, R>(syncOrAsyncFunction: (a: A, b: B) => R):
|
1177 | (a: A, b: B, callback: (result: R) => void) => void;
|
1178 | callbackify<A, B, C, R>(syncOrAsyncFunction: (a: A, b: B, c: C) => R):
|
1179 | (a: A, b: B, c: C, callback: (result: R) => void) => void;
|
1180 | callbackify<A, B, C, D, R>(syncOrAsyncFunction: (a: A, b: B, c: C, d: D) => R):
|
1181 | (a: A, b: B, c: C, d: D, callback: (result: R) => void) => void;
|
1182 |
|
1183 | // Internal libraries
|
1184 | namespace: any
|
1185 | task: any
|
1186 | }
|
1187 |
|
1188 | /**
|
1189 | * {@link http://gruntjs.com/api/grunt.util#grunt.util.spawn}
|
1190 | */
|
1191 | interface ISpawnOptions {
|
1192 |
|
1193 | /**
|
1194 | * The command to execute. It should be in the system path.
|
1195 | */
|
1196 | cmd?: string | undefined;
|
1197 |
|
1198 | /**
|
1199 | * If specified, the same grunt bin that is currently running will be
|
1200 | * spawned as the child command, instead of the "cmd" option.
|
1201 | * Defaults to false.
|
1202 | */
|
1203 | grunt?: boolean | undefined;
|
1204 |
|
1205 | /**
|
1206 | * An array of arguments to pass to the command.
|
1207 | */
|
1208 | args?: string[] | undefined;
|
1209 |
|
1210 | /**
|
1211 | * Additional options for the Node.js child_process spawn method.
|
1212 | */
|
1213 | opts?: {
|
1214 | cwd?: string | undefined;
|
1215 | stdio?: any;
|
1216 | custom?: any;
|
1217 | env?: any;
|
1218 | detached?: boolean | undefined;
|
1219 | } | undefined
|
1220 |
|
1221 | /**
|
1222 | * If this value is set and an error occurs, it will be used as the value
|
1223 | * and null will be passed as the error value.
|
1224 | */
|
1225 | fallback?: any;
|
1226 | }
|
1227 |
|
1228 | /**
|
1229 | * @note When result is coerced to a string, the value is stdout if the exit code
|
1230 | * was zero, the fallback if the exit code was non-zero and a fallback was
|
1231 | * specified, or stderr if the exit code was non-zero and a fallback was
|
1232 | * not specified.
|
1233 | */
|
1234 | interface ISpawnResult {
|
1235 | stdout: string;
|
1236 | stderr: string;
|
1237 | code: number;
|
1238 | }
|
1239 |
|
1240 | /**
|
1241 | * {@link https://github.com/snbartell/node-spawn}
|
1242 | */
|
1243 | interface ISpawnedChild {
|
1244 | /**
|
1245 | * Start the cmd with the options provided.
|
1246 | */
|
1247 | start(): void;
|
1248 |
|
1249 | /**
|
1250 | * Convenience function. Overrides options. restarts to 0.
|
1251 | * Runs command exactly once no matter the options passed into the constructor.
|
1252 | */
|
1253 | once(): void;
|
1254 |
|
1255 | /**
|
1256 | * Convenience function. Overrides options.restarts to -1.
|
1257 | * Runs command indefinitely no matter the options passed into the constructor.
|
1258 | */
|
1259 | forever(): void;
|
1260 |
|
1261 | /**
|
1262 | * Shut down the child and don't let it restart.
|
1263 | */
|
1264 | kill(): void;
|
1265 | }
|
1266 | }
|
1267 |
|
1268 | /*
|
1269 | * Common interfaces
|
1270 | */
|
1271 |
|
1272 | interface IFlag {
|
1273 | [flag: string]: boolean;
|
1274 | }
|
1275 |
|
1276 | /*
|
1277 | * Grunt module mixins.
|
1278 | */
|
1279 |
|
1280 | interface IConfigComponents extends grunt.config.ConfigModule {
|
1281 | /**
|
1282 | * An alias
|
1283 | * @see grunt.config.ConfigModule.init
|
1284 | */
|
1285 | initConfig(config: grunt.config.IProjectConfig): void;
|
1286 | }
|
1287 |
|
1288 | interface ITaskComponents extends grunt.task.CommonTaskModule {
|
1289 | /**
|
1290 | * Load task-related files from the specified directory, relative to the Gruntfile.
|
1291 | * This method can be used to load task-related files from a local Grunt plugin by
|
1292 | * specifying the path to that plugin's "tasks" subdirectory.
|
1293 | */
|
1294 | loadTasks(tasksPath: string): void;
|
1295 |
|
1296 | /**
|
1297 | * Load tasks from the specified Grunt plugin.
|
1298 | * This plugin must be installed locally via npm, and must be relative to the Gruntfile.
|
1299 | * Grunt plugins can be created by using the grunt-init gruntplugin template: grunt init:gruntplugin.
|
1300 | */
|
1301 | loadNpmTasks(pluginName: string): void;
|
1302 | }
|
1303 | }
|
1304 |
|
1305 | /* GRUNT MODULE
|
1306 | **************/
|
1307 |
|
1308 | /**
|
1309 | * The main Grunt module.
|
1310 | *
|
1311 | * {@link http://gruntjs.com/api/grunt}
|
1312 | */
|
1313 | interface IGrunt extends grunt.IConfigComponents, grunt.fail.FailModule, grunt.ITaskComponents {
|
1314 |
|
1315 | config: grunt.config.ConfigModule;
|
1316 |
|
1317 | event: grunt.event.EventModule;
|
1318 |
|
1319 | fail: grunt.fail.FailModule;
|
1320 |
|
1321 | file: grunt.file.FileModule;
|
1322 |
|
1323 | log: grunt.log.LogModule;
|
1324 |
|
1325 | option: grunt.option.OptionModule;
|
1326 |
|
1327 | task: grunt.task.TaskModule;
|
1328 |
|
1329 | template: grunt.template.TemplateModule;
|
1330 |
|
1331 | util: grunt.util.UtilModule;
|
1332 |
|
1333 | /**
|
1334 | * The current Grunt package.json metadata, as an object.
|
1335 | */
|
1336 | package: node.NodePackage;
|
1337 |
|
1338 | /**
|
1339 | * The current Grunt version, as a string. This is just a shortcut to the grunt.package.version property.
|
1340 | */
|
1341 | version: string
|
1342 | }
|
1343 |
|
1344 | // NodeJS Support
|
1345 | declare module 'grunt' {
|
1346 | var grunt: IGrunt;
|
1347 | export = grunt;
|
1348 | }
|
1349 |
|
\ | No newline at end of file |