-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
executable file
·102 lines (90 loc) · 2.93 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#! /usr/bin/env node
/*
* Copyright 2018 Adobe Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const cli = require("cli");
const package = require("./package.json");
const terms = {
use: "https://www.adobe.com/legal/terms.html",
dev: "http://www.adobe.com/go/developer-terms"
};
const sampleDirs = require("./commands/bootstrap").sampleDirs;
const sampleTypes = Object.keys(sampleDirs)
.filter(el => el !== "default")
.join(", ");
cli.enable("status", "version");
cli.setApp(package.name, package.version);
const commands = {
bootstrap: `Create a new plugin scaffold: ${sampleTypes}. Optionally specify the name for your new plugin's directory.`,
install: "Install a plugin in development mode",
ls: "List all plugins in development mode",
package: "Package a plugin",
validate: "Validate a plugin's manifest",
watch:
"Watch a plugin directory. If no directory is specified, `.` is assumed"
};
const options = {
clean: ["c", "Clean before install", "bool", false],
json: [
"j",
"If true, indicates that JSON output should be generated",
"bool",
false
],
// mode: ["m", "Indicates which plugin mode to use", ["d", "p"], "d"],
overwrite: ["o", "Allow overwriting plugins", "bool", false],
which: [
"w",
"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'
]
};
const parsedOpts = cli.parse(options, commands);
if (parsedOpts.json) {
cli.status = function() {};
} else {
cli.info(`xdpm ${package.version} - XD Plugin Manager CLI`);
cli.info(`Use of this tool means you agree to:
- the Adobe Terms of Use at ${terms.use}
- the Developer Additional Terms at ${terms.dev}`);
}
const { command, args } = cli;
if (parsedOpts.which) {
parsedOpts.which = parsedOpts.which[0];
}
switch (command.toLowerCase()) {
case "ls":
require("./commands/ls")(parsedOpts, args);
break;
case "install":
require("./commands/install")(parsedOpts, args);
break;
case "watch":
require("./commands/watch")(parsedOpts, args);
break;
case "package":
require("./commands/package")(parsedOpts, args);
break;
case "validate":
require("./commands/validate")(parsedOpts, args);
break;
case "bootstrap":
require("./commands/bootstrap").bootstrap(parsedOpts, args);
break;
}