zerostart-cli 0.0.10 → 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
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,22 +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
|
-
|
|
289
|
-
|
|
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'
|
|
289
|
+
}
|
|
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
|
+
}
|
|
290
314
|
}
|
|
291
|
-
|
|
292
|
-
if (
|
|
315
|
+
}
|
|
316
|
+
if (vercelInstalled) {
|
|
317
|
+
// We assume login or rely on CLI prompts/error handling
|
|
293
318
|
const vSpinner = (0, ora_1.default)('Deploying to Vercel...').start();
|
|
294
|
-
// We need to be inside the project directory for vercel deploy
|
|
295
|
-
// but our process.cwd() is outside. passing cwd to exec is crucial.
|
|
296
319
|
const deploymentUrl = await vercelManager.deploy(config.path);
|
|
297
320
|
if (deploymentUrl) {
|
|
298
321
|
vSpinner.succeed(chalk_1.default.green('Deployed to Vercel!'));
|
|
@@ -304,6 +327,45 @@ program
|
|
|
304
327
|
}
|
|
305
328
|
}
|
|
306
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
|
+
}
|
|
307
369
|
if (!answers.createRemote || !githubToken && authMethod !== 'GitHub CLI') {
|
|
308
370
|
console.log(chalk_1.default.bold.yellow(' To push to GitHub later:'));
|
|
309
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;
|
|
@@ -71,5 +71,15 @@ class VercelManager {
|
|
|
71
71
|
return false;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
async installGlobal() {
|
|
75
|
+
try {
|
|
76
|
+
await exec('npm install -g vercel');
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error('Failed to install Vercel CLI globally');
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
74
84
|
}
|
|
75
85
|
exports.VercelManager = VercelManager;
|
|
@@ -44,7 +44,10 @@ class GitHubServiceCLI {
|
|
|
44
44
|
await client.repos.replaceAllTopics({
|
|
45
45
|
owner: user.login,
|
|
46
46
|
repo: config.name,
|
|
47
|
-
names: [
|
|
47
|
+
names: [
|
|
48
|
+
config.type.toLowerCase().replace(/[^a-z0-9-]/g, '-'),
|
|
49
|
+
config.language.toLowerCase().replace(/[^a-z0-9-]/g, '-')
|
|
50
|
+
]
|
|
48
51
|
});
|
|
49
52
|
}
|
|
50
53
|
catch (e) {
|