@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.
Files changed (2) hide show
  1. package/dist/index.js +38 -28
  2. 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
- apiKey = await input({
60
- message: "Enter your API key:",
61
- validate: (value) => {
62
- if (!value || value.trim().length === 0) {
63
- return "API key is required";
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
- if (!value.startsWith("ya_dev_")) {
66
- return "Invalid API key format. Keys should start with ya_dev_";
67
- }
68
- return true;
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, "../../templates");
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
- projectName = await input2({
119
- message: "Project name:",
120
- default: "my-template",
121
- validate: (value) => {
122
- if (!value || value.trim().length === 0) {
123
- return "Project name is required";
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
- if (!/^[a-z0-9-]+$/.test(value)) {
126
- return "Project name must be lowercase letters, numbers, and hyphens only";
127
- }
128
- return true;
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").requiredOption("--version <semver>", "Template version (e.g., 1.0.0)").action(async (options) => {
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(options.version)) {
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: options.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${options.version} deployed successfully!`);
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}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoamigo.com/cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "CLI for creating and managing YoAmigo templates",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",