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