Skip to content

Commit

Permalink
feat: Added ignoreFiles option to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrtovmach committed Jun 9, 2020
1 parent 5fd0396 commit 2313497
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ Plugin type options:
## Installing a plugin

```shell
xdpm install # Install the current folder into Adobe XD
xdpm install path/to/plugin # Install the specified folder into Adobe XD
xdpm install -w release # Install to Adobe XD CC Release (`r` is also valid; default)
xdpm install -w prerelease # Install to Adobe XD CC Prerelease (`p` is also valid)
xdpm install -o # Overwrite plugin if it exists
xdpm install -c # Install cleanly (remove existing)
xdpm install # Install the current folder into Adobe XD
xdpm install path/to/plugin # Install the specified folder into Adobe XD
xdpm install -w release # Install to Adobe XD CC Release (`r` is also valid; default)
xdpm install -w prerelease # Install to Adobe XD CC Prerelease (`p` is also valid)
xdpm install -o # Overwrite plugin if it exists
xdpm install -c # Install cleanly (remove existing)
xdpm install --ignore-files ".xdignore, .npmignore" # Override default list of .*ignore files ".gitignore, .xdignore, .npmignore"
```

You can install a plugin folder into Adobe XD using `xdpm install [...folders]`. If you don't specify a folder `xdpm install` assumes your current directory is a plugin and will install it into Adobe XD.
Expand All @@ -58,11 +59,12 @@ If the plugin folder is not a valid XD plugin, you'll receive an error upon atte
## Watching a plugin

```shell
xdpm watch # Watch current folder and install changes into Adobe XD
xdpm watch path/to/plugin # Watch the specified folder and install changes into Adobe XD
xdpm watch -w release # Install to Adobe XD CC Release (`r` is also valid; default)
xdpm watch -w prerelease # Install to Adobe XD CC Prerelease (`p` is also valid)
xdpm watch -c # Perform clean installs when watching
xdpm watch # Watch current folder and install changes into Adobe XD
xdpm watch path/to/plugin # Watch the specified folder and install changes into Adobe XD
xdpm watch -w release # Install to Adobe XD CC Release (`r` is also valid; default)
xdpm watch -w prerelease # Install to Adobe XD CC Prerelease (`p` is also valid)
xdpm watch -c # Perform clean installs when watching
xdpm watch --ignore-files ".xdignore, .npmignore" # Override default list of .*ignore files ".gitignore, .xdignore, .npmignore"
```

When developing a plugin, you can work directly in Adobe XD's `develop` folder, but this may not fit your particular workflow. In this case, you can invoke `xdpm watch` on a folder (or the current directory) and whenever changes are made, `xdpm install` will be automatically invoked to reinstall the plugins. This can simplify your development process significantly, especially if you don't use a build process.
Expand Down Expand Up @@ -111,13 +113,14 @@ Options:
[r|p|d|release|pre|prerelease|dev|development] (Default is r)
-k, --no-color Omit color from output
--debug Show debug information
--ignore-files Provide a custom list of .*ignore files, to override default ".gitignore, .xdignore, .npmignore"
-h, --help Display help and usage details

Commands:
install Install a plugin in development mode
ls List all plugins in development mode
package Package a plugin
validate Validate a plugin's manifest
validate Validate a plugin\'s manifest
watch Watch a plugin directory. If no directory is
specified, `.` is assumed
```
Expand Down
19 changes: 16 additions & 3 deletions commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,29 @@ function install(opts, args) {
} else {
shell.mkdir(targetFolder);
}

// the comment below doesn't respect .xdignore (or other ignore files)
// but this is the gist of what we're trying to accomplish
// shell.cp("-R", path.join(sourcePath, "*"), targetFolder)

const files = ignoreWalk.sync({
const walkConfig = {
path: sourcePath,
ignoreFiles: [".gitignore", ".xdignore", ".npmignore"],
includeEmpty: false,
}).filter(filterAlwaysIgnoredFile);
}
if (opts.ignoreFiles) {
const ignoreFilesOpt = opts.ignoreFiles
.split(/,|\s/)
.map((f) => f.trim())
.filter(Boolean);

walkConfig.ignoreFiles =
(ignoreFilesOpt && ignoreFilesOpt.length) || walkConfig.ignoreFiles;
}

const files = ignoreWalk
.sync(walkConfig)
.filter(filterAlwaysIgnoredFile);

files.forEach(file => {
const srcFile = path.join(sourcePath, file);
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const options = {
"Which Adobe XD instance to target",
["r", "p", "d", "release", "pre", "prerelease", "dev", "development"],
"r"
],
ignoreFiles: [
"ignore-files", "List of .*ignore files to proceed. Default is \".gitignore, .xdignore, .npmignore\"", 'string'
]
};

Expand Down

0 comments on commit 2313497

Please sign in to comment.