zerostart-cli 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/cli.js +75 -36
- package/out/managers/NetlifyManager.js +87 -0
- package/package.json +1 -1
package/out/cli.js
CHANGED
|
@@ -48,6 +48,7 @@ const TemplateManager_1 = require("./managers/TemplateManager");
|
|
|
48
48
|
const GitManager_1 = require("./managers/GitManager");
|
|
49
49
|
const GitHubServiceCLI_1 = require("./services/GitHubServiceCLI");
|
|
50
50
|
const VercelManager_1 = require("./managers/VercelManager");
|
|
51
|
+
const NetlifyManager_1 = require("./managers/NetlifyManager");
|
|
51
52
|
const child_process_1 = require("child_process");
|
|
52
53
|
const program = new commander_1.Command();
|
|
53
54
|
// Basic ASCII banner for maximum compatibility
|
|
@@ -277,45 +278,44 @@ program
|
|
|
277
278
|
console.log(chalk_1.default.gray(' - ') + chalk_1.default.cyan(`cd ${name}`));
|
|
278
279
|
console.log(chalk_1.default.gray(' - ') + chalk_1.default.cyan('code .') + chalk_1.default.gray(' (or your favorite editor)'));
|
|
279
280
|
console.log();
|
|
280
|
-
//
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
name: 'installVercel',
|
|
289
|
-
message: 'Vercel CLI not found. Install it globally?',
|
|
290
|
-
default: false
|
|
291
|
-
}
|
|
292
|
-
]);
|
|
293
|
-
if (installVercel) {
|
|
294
|
-
const iSpinner = (0, ora_1.default)('Installing Vercel CLI...').start();
|
|
295
|
-
const installed = await vercelManager.installGlobal();
|
|
296
|
-
if (installed) {
|
|
297
|
-
iSpinner.succeed(chalk_1.default.green('Vercel CLI installed!'));
|
|
298
|
-
vercelInstalled = true;
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
iSpinner.fail(chalk_1.default.red('Failed to install Vercel CLI.'));
|
|
302
|
-
}
|
|
281
|
+
// Deployment Integration
|
|
282
|
+
const { deploymentTarget } = await inquirer_1.default.prompt([
|
|
283
|
+
{
|
|
284
|
+
type: 'list',
|
|
285
|
+
name: 'deploymentTarget',
|
|
286
|
+
message: 'Select Deployment Provider:',
|
|
287
|
+
choices: ['Vercel', 'Netlify', 'None'],
|
|
288
|
+
default: 'None'
|
|
303
289
|
}
|
|
304
|
-
|
|
305
|
-
if (
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
290
|
+
]);
|
|
291
|
+
if (deploymentTarget === 'Vercel') {
|
|
292
|
+
const vercelManager = new VercelManager_1.VercelManager();
|
|
293
|
+
let vercelInstalled = await vercelManager.checkVercelInstalled();
|
|
294
|
+
if (!vercelInstalled) {
|
|
295
|
+
console.log();
|
|
296
|
+
const { installVercel } = await inquirer_1.default.prompt([
|
|
297
|
+
{
|
|
298
|
+
type: 'confirm',
|
|
299
|
+
name: 'installVercel',
|
|
300
|
+
message: 'Vercel CLI not found. Install it globally?',
|
|
301
|
+
default: false
|
|
302
|
+
}
|
|
303
|
+
]);
|
|
304
|
+
if (installVercel) {
|
|
305
|
+
const iSpinner = (0, ora_1.default)('Installing Vercel CLI...').start();
|
|
306
|
+
const installed = await vercelManager.installGlobal();
|
|
307
|
+
if (installed) {
|
|
308
|
+
iSpinner.succeed(chalk_1.default.green('Vercel CLI installed!'));
|
|
309
|
+
vercelInstalled = true;
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
iSpinner.fail(chalk_1.default.red('Failed to install Vercel CLI.'));
|
|
313
|
+
}
|
|
313
314
|
}
|
|
314
|
-
|
|
315
|
-
if (
|
|
315
|
+
}
|
|
316
|
+
if (vercelInstalled) {
|
|
317
|
+
// We assume login or rely on CLI prompts/error handling
|
|
316
318
|
const vSpinner = (0, ora_1.default)('Deploying to Vercel...').start();
|
|
317
|
-
// We need to be inside the project directory for vercel deploy
|
|
318
|
-
// but our process.cwd() is outside. passing cwd to exec is crucial.
|
|
319
319
|
const deploymentUrl = await vercelManager.deploy(config.path);
|
|
320
320
|
if (deploymentUrl) {
|
|
321
321
|
vSpinner.succeed(chalk_1.default.green('Deployed to Vercel!'));
|
|
@@ -327,6 +327,45 @@ program
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
+
else if (deploymentTarget === 'Netlify') {
|
|
331
|
+
const netlifyManager = new NetlifyManager_1.NetlifyManager();
|
|
332
|
+
let netlifyInstalled = await netlifyManager.checkNetlifyInstalled();
|
|
333
|
+
if (!netlifyInstalled) {
|
|
334
|
+
console.log();
|
|
335
|
+
const { installNetlify } = await inquirer_1.default.prompt([
|
|
336
|
+
{
|
|
337
|
+
type: 'confirm',
|
|
338
|
+
name: 'installNetlify',
|
|
339
|
+
message: 'Netlify CLI not found. Install it globally?',
|
|
340
|
+
default: false
|
|
341
|
+
}
|
|
342
|
+
]);
|
|
343
|
+
if (installNetlify) {
|
|
344
|
+
const nSpinner = (0, ora_1.default)('Installing Netlify CLI...').start();
|
|
345
|
+
const installed = await netlifyManager.installGlobal();
|
|
346
|
+
if (installed) {
|
|
347
|
+
nSpinner.succeed(chalk_1.default.green('Netlify CLI installed!'));
|
|
348
|
+
netlifyInstalled = true;
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
nSpinner.fail(chalk_1.default.red('Failed to install Netlify CLI.'));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (netlifyInstalled) {
|
|
356
|
+
const nSpinner = (0, ora_1.default)('Deploying to Netlify...').start();
|
|
357
|
+
const deploymentOutput = await netlifyManager.deploy(config.path);
|
|
358
|
+
if (deploymentOutput) {
|
|
359
|
+
nSpinner.succeed(chalk_1.default.green('Deployed to Netlify!'));
|
|
360
|
+
// Netlify output is verbose, maybe just say success
|
|
361
|
+
console.log(chalk_1.default.gray(' Check output for URL or run ') + chalk_1.default.cyan('netlify open'));
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
nSpinner.fail(chalk_1.default.red('Netlify deployment failed'));
|
|
365
|
+
console.log(chalk_1.default.gray(' Try running ') + chalk_1.default.cyan('netlify login') + chalk_1.default.gray(' and ') + chalk_1.default.cyan('netlify deploy') + chalk_1.default.gray(' manually.'));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
330
369
|
if (!answers.createRemote || !githubToken && authMethod !== 'GitHub CLI') {
|
|
331
370
|
console.log(chalk_1.default.bold.yellow(' To push to GitHub later:'));
|
|
332
371
|
console.log(chalk_1.default.gray(' - Create a repository on GitHub'));
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NetlifyManager = void 0;
|
|
37
|
+
const cp = __importStar(require("child_process"));
|
|
38
|
+
const util = __importStar(require("util"));
|
|
39
|
+
const exec = util.promisify(cp.exec);
|
|
40
|
+
class NetlifyManager {
|
|
41
|
+
async checkNetlifyInstalled() {
|
|
42
|
+
try {
|
|
43
|
+
await exec('netlify --version');
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async installGlobal() {
|
|
51
|
+
try {
|
|
52
|
+
await exec('npm install -g netlify-cli');
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.error('Failed to install Netlify CLI globally');
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async deploy(cwd) {
|
|
61
|
+
try {
|
|
62
|
+
// netlify deploy --prod
|
|
63
|
+
// This might require login. If not logged in, it will fail or prompt.
|
|
64
|
+
// In a non-interactive shell or without TTY, prompts might fail.
|
|
65
|
+
// We assume the user can handle the auth flow if triggered, or we catch the error.
|
|
66
|
+
const { stdout } = await exec('netlify deploy --prod --json', { cwd });
|
|
67
|
+
// Parse JSON output to find the deploy URL if possible, or just return success message
|
|
68
|
+
// Netlify output is complex. simpler:
|
|
69
|
+
return stdout.trim();
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// If failure is due to login, we might want to tell them.
|
|
73
|
+
console.error(`Netlify deployment setup failed: ${error.message}`);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async login() {
|
|
78
|
+
try {
|
|
79
|
+
await exec('netlify status');
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.NetlifyManager = NetlifyManager;
|