UNPKG

3.09 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3var program = require("commander"),
4 fs = require("fs"),
5 path = require("path"),
6 chalk = require("chalk"),
7 config = require("../lib/settings/config"),
8 createSite = require("../lib/commands/create_site"),
9 deleteSite = require("../lib/commands/delete_site"),
10 deploy = require("../lib/commands/deploy"),
11 publish = require("../lib/commands/publish"),
12 init = require("../lib/commands/init"),
13 list = require("../lib/commands/list_sites"),
14 updateSite = require("../lib/commands/update_site"),
15 openSite = require("../lib/commands/open"),
16 updateNotifier = require('update-notifier'),
17 pkg = require('../package.json');
18
19updateNotifier({pkg: pkg}).notify();
20
21program
22 .version(pkg.version)
23 .usage(
24 "[options] [command]\n\n" +
25 chalk.bold(" The premium hosting service for modern static websites\n\n") +
26 " Read more at https://www.netlify.com/docs/cli"
27 )
28 .option("-t --access-token <token>", "Override the default Access Token")
29 .option("-e --env <environment>", "Specify an environment for the local configuration")
30
31program
32 .command("create")
33 .description("Create a new site")
34 .option("-n --name <name>", "Set <name>.netlify.com")
35 .option("-d --custom-domain [domain]", "Set the custom domain for the site")
36 .option("-p --password [password]", "Set the password for the site")
37 .action(config.wrap(program, createSite.cmd));
38
39program
40 .command("deploy")
41 .description("Push a new deploy to netlify")
42 .option("-s --site-id [id]", "Deploy to site with <id>")
43 .option("-p --path [path]", "Path to a folder or zip file to deploy")
44 .option("-d --draft", "Deploy as a draft without publishing")
45 .action(config.wrap(program, deploy.cmd));
46
47program
48 .command("update")
49 .description("Updates site attributes")
50 .option("-s --site-id [id]", "The site to update")
51 .option("-n --name [name]", "Set <name>.netlify.com")
52 .option("-d --custom-domain [domain]", "Set the custom domain for the site")
53 .option("-p --password [password]", "Set the password for the site")
54 .action(config.wrap(program, updateSite.cmd));
55
56program
57 .command("delete")
58 .description("Delete site")
59 .option("-s --site-id [id]", "The id of the site to delete")
60 .option("-y --yes", "Don't prompt for confirmation")
61 .action(config.wrap(program, deleteSite.cmd));
62
63program
64 .command("sites")
65 .description("List your sites")
66 .option("-g --guest", "List sites you have access to as a collaborator")
67 .action(config.wrap(program, list.cmd));
68
69program
70 .command("open")
71 .description("Open site in the webui")
72 .option("-s --site-id [id]", "The id of the site to open")
73 .action(config.wrap(program, openSite.cmd));
74
75program
76 .command("init")
77 .description("Configure continuous deployment")
78 .action(config.wrap(program, init.cmd));
79
80program
81 .command("*","",{noHelp: true})
82 .action(function(cmd) {
83 console.log("Unknown command", cmd);
84 process.exit(1);
85 });
86
87program.parse(process.argv);
88
89if(!program.args.length) {
90 program.help();
91}