@yoamigo.com/cli 0.1.4 → 0.1.6
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/dist/index.js +38 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -56,18 +56,23 @@ async function saveCredentials(credentials) {
|
|
|
56
56
|
var loginCommand = new Command("login").description("Authenticate with your API key").option("-k, --key <apiKey>", "API key (or enter interactively)").action(async (options) => {
|
|
57
57
|
let apiKey = options.key;
|
|
58
58
|
if (!apiKey) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
try {
|
|
60
|
+
apiKey = await input({
|
|
61
|
+
message: "Enter your API key:",
|
|
62
|
+
validate: (value) => {
|
|
63
|
+
if (!value || value.trim().length === 0) {
|
|
64
|
+
return "API key is required";
|
|
65
|
+
}
|
|
66
|
+
if (!value.startsWith("ya_dev_")) {
|
|
67
|
+
return "Invalid API key format. Keys should start with ya_dev_";
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
64
70
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
71
|
+
});
|
|
72
|
+
} catch {
|
|
73
|
+
console.log();
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}
|
|
71
76
|
}
|
|
72
77
|
const spinner = ora("Authenticating...").start();
|
|
73
78
|
try {
|
|
@@ -111,23 +116,28 @@ import { fileURLToPath } from "url";
|
|
|
111
116
|
import { input as input2 } from "@inquirer/prompts";
|
|
112
117
|
import { spawn } from "child_process";
|
|
113
118
|
var __dirname = path2.dirname(fileURLToPath(import.meta.url));
|
|
114
|
-
var TEMPLATES_DIR = path2.resolve(__dirname, "
|
|
119
|
+
var TEMPLATES_DIR = path2.resolve(__dirname, "../templates");
|
|
115
120
|
var initCommand = new Command2("init").description("Create a new template project").argument("[name]", "Project name").option("-t, --template <template>", "Template to use", "starter").action(async (name, options) => {
|
|
116
121
|
let projectName = name;
|
|
117
122
|
if (!projectName) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
try {
|
|
124
|
+
projectName = await input2({
|
|
125
|
+
message: "Project name:",
|
|
126
|
+
default: "my-template",
|
|
127
|
+
validate: (value) => {
|
|
128
|
+
if (!value || value.trim().length === 0) {
|
|
129
|
+
return "Project name is required";
|
|
130
|
+
}
|
|
131
|
+
if (!/^[a-z0-9-]+$/.test(value)) {
|
|
132
|
+
return "Project name must be lowercase letters, numbers, and hyphens only";
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
124
135
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
});
|
|
136
|
+
});
|
|
137
|
+
} catch {
|
|
138
|
+
console.log();
|
|
139
|
+
process.exit(0);
|
|
140
|
+
}
|
|
131
141
|
}
|
|
132
142
|
const targetDir = path2.resolve(process.cwd(), projectName);
|
|
133
143
|
const templateDir = path2.join(TEMPLATES_DIR, options.template);
|
|
@@ -239,14 +249,14 @@ import path4 from "path";
|
|
|
239
249
|
var API_BASE_URL2 = getApiBaseUrl();
|
|
240
250
|
var APP_BASE_URL = getAppBaseUrl();
|
|
241
251
|
var EXCLUDE_PATTERNS = ["node_modules", "dist", ".git", "vite.config.ts", "tsconfig.json", "*.log"];
|
|
242
|
-
var deployCommand = new Command4("deploy").description("Upload template to YoAmigo").
|
|
252
|
+
var deployCommand = new Command4("deploy").description("Upload template to YoAmigo").argument("<version>", "Template version (e.g., 1.0.0)").action(async (version) => {
|
|
243
253
|
const credentials = await getCredentials();
|
|
244
254
|
if (!credentials) {
|
|
245
255
|
console.error(chalk4.red("Error: Not logged in. Run `yoamigo login` first."));
|
|
246
256
|
process.exit(1);
|
|
247
257
|
}
|
|
248
258
|
const versionRegex = /^\d+\.\d+\.\d+$/;
|
|
249
|
-
if (!versionRegex.test(
|
|
259
|
+
if (!versionRegex.test(version)) {
|
|
250
260
|
console.error(chalk4.red("Error: Version must be in semver format (e.g., 1.0.0)"));
|
|
251
261
|
process.exit(1);
|
|
252
262
|
}
|
|
@@ -273,7 +283,7 @@ var deployCommand = new Command4("deploy").description("Upload template to YoAmi
|
|
|
273
283
|
},
|
|
274
284
|
body: JSON.stringify({
|
|
275
285
|
name: templateName,
|
|
276
|
-
version
|
|
286
|
+
version,
|
|
277
287
|
description: packageJson.description || ""
|
|
278
288
|
})
|
|
279
289
|
});
|
|
@@ -306,7 +316,7 @@ var deployCommand = new Command4("deploy").description("Upload template to YoAmi
|
|
|
306
316
|
console.warn(chalk4.yellow(`Warning: Failed to upload ${relativePath}`));
|
|
307
317
|
}
|
|
308
318
|
}
|
|
309
|
-
spinner.succeed(`Template v${
|
|
319
|
+
spinner.succeed(`Template v${version} deployed successfully!`);
|
|
310
320
|
console.log();
|
|
311
321
|
console.log(chalk4.green("Preview URL:"));
|
|
312
322
|
console.log(chalk4.cyan(` ${APP_BASE_URL}/preview/${templateId}`));
|