Skip to content

Commit 8dd3361

Browse files
janiceilenephated
authored andcommitted
Docs: Add API Concepts documentation
1 parent 40ee801 commit 8dd3361

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

docs/api/concepts.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!-- front-matter
2+
id: api-concepts
3+
title: API Concepts
4+
hide_title: true
5+
sidebar_label: Concepts
6+
-->
7+
8+
# Concepts
9+
10+
The following concepts are prerequisites to understanding the API docs. They will be referenced throughout, refer back to this page for detailed explanations.
11+
12+
If you're new here, begin with the [Getting Started Guide][quick-start-docs].
13+
14+
## Vinyl
15+
16+
Vinyl is a metadata object that describes a file. The main properties of a Vinyl instance are `path` and `contents` - core aspects of a file on your file system. Vinyl objects can be used to describe files from many sources - on a local file system or any remote storage option.
17+
18+
## Vinyl adapters
19+
20+
While Vinyl provides a way to describe a file, a way to access these files is needed. Each file source is accessed using a Vinyl adapter.
21+
22+
An adapter exposes:
23+
* A method with the signature `src(globs, [options])` and returns a stream that produces Vinyl objects.
24+
* A method with the signature `dest(folder, [options])` and returns a stream that consumes Vinyl objects.
25+
* Any extra methods specific to their input/output medium - such as the `symlink` method `vinyl-fs` provides. They should always return streams that produce and/or consume Vinyl objects.
26+
27+
## Tasks
28+
29+
Each gulp task is an asynchronous JavaScript function that either accepts an error-first callback or returns a stream, promise, event emitter, child process, or observable. Due to some platform limitations, synchronous tasks aren't supported.
30+
31+
For a more detailed explanation, see [Creating Tasks][creating-tasks-doc].
32+
33+
## Globs
34+
35+
A glob is a string of literal and/or wildcard characters, like `*`, `**`, `!`, used to match filepaths. Globbing is the act of locating files on a file system using one or more globs.
36+
37+
If you don't have experience with globs, see [Explaining Globs][explaining-globs-docs].
38+
39+
## Glob base
40+
41+
A glob base - sometimes called glob parent - is the path segment before any special characters in a glob string. As such, the glob base of `/src/js/**.js` is `/src/js/`. All paths that match the glob are guaranteed to share the glob base since that path segment can't be variable.
42+
43+
Vinyl instances generated by `src()` are constructed with the glob base set as their `base` property. When written to the file system with `dest()`, the `base` will be removed from the output path so directory structures will be preserved.
44+
45+
For more in depth information, see the [glob-parent][glob-parent-external] repository.
46+
47+
## File system stats
48+
49+
File metadata is provided as an instance of Node's [`fs.Stats`][fs-stats-external]. It is available as the `stat` property on your Vinyl instances and used internally to determine if a Vinyl object represents a directory or symbolic link. When written to the file system, permissions and time values are synchronized from the Vinyl object's `stat` property.
50+
51+
## File system modes
52+
53+
File system modes determine what permissions exist for a file. Most files and directories on your file system will have a fairly permissive mode, allowing gulp to read/write/update files on your behalf. By default, gulp will create files with the same permissions as the running process, but you can configure the modes through options in `src()`, `dest()`, etc. If you're experiencing permission (EPERM) issues, check the modes on your files.
54+
55+
## Modules
56+
57+
Gulp is made up of many small modules that are pulled together to work cohesively. By utilizing [semver][semver-external] within the small modules, we can release bug fixes and features without publishing new versions of gulp. If you encounter an issue related to one of these modules, open an issue on the individual project repository.
58+
59+
* [undertaker][undertaker-external] - the task registration system
60+
* [vinyl][vinyl-external] - the virtual file objects
61+
* [vinyl-fs][vinyl-fs-external] - a vinyl adapter to your local file system
62+
* [glob-watcher][glob-watcher-external] - the file watcher
63+
* [bach][bach-external] - task orchestration using `series()` and `parallel()`
64+
* [last-run][last-run-external] - tracks the last run time of a task
65+
* [vinyl-sourcemap][vinyl-sourcemap-external] - built-in sourcemap support
66+
* [gulp-cli][gulp-cli-external] - the command line interface for interacting with gulp
67+
68+
69+
[quick-start-docs]: ../getting-started/1-quick-start.md
70+
[creating-tasks-doc]: ../getting-started/3-creating-tasks.md
71+
[explaining-globs-docs]: ../getting-started/6-explaining-globs.md
72+
[undertaker-external]: https://github.com/gulpjs/undertaker
73+
[vinyl-external]: https://github.com/gulpjs/vinyl
74+
[vinyl-fs-external]: https://github.com/gulpjs/vinyl-fs
75+
[glob-watcher-external]: https://github.com/gulpjs/glob-watcher
76+
[bach-external]: https://github.com/gulpjs/bach
77+
[last-run-external]: https://github.com/gulpjs/last-run
78+
[vinyl-sourcemap-external]: https://github.com/gulpjs/vinyl-sourcemap
79+
[gulp-cli-external]: https://github.com/gulpjs/gulp-cli
80+
[semver-external]: https://semver.org
81+
[fs-stats-external]: https://nodejs.org/api/fs.html#fs_class_fs_stats
82+
[glob-parent-external]: https://github.com/es128/glob-parent

0 commit comments

Comments
 (0)