@fireberry/cli 0.0.5-beta.3 → 0.0.5-beta.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.
@@ -15,6 +15,7 @@ on:
15
15
  required: false
16
16
  type: choice
17
17
  options:
18
+ - prerelease
18
19
  - patch
19
20
  - minor
20
21
  - major
@@ -26,6 +27,9 @@ jobs:
26
27
  permissions:
27
28
  contents: read
28
29
  id-token: write
30
+ environment:
31
+ name: npm
32
+ url: https://www.npmjs.com/package/@fireberry/cli/v/${{ github.event.inputs.version }}
29
33
 
30
34
  steps:
31
35
  - name: Checkout repository
@@ -44,7 +48,13 @@ jobs:
44
48
 
45
49
  - name: Update version (Beta)
46
50
  if: github.event.inputs.type == 'beta'
47
- run: npm version prerelease --preid=beta --no-git-tag-version
51
+ run: |
52
+ CURRENT_VERSION=$(node -p "require('./package.json').version")
53
+ if [[ $CURRENT_VERSION == *"-beta."* ]]; then
54
+ npm version prerelease --preid=beta --no-git-tag-version
55
+ else
56
+ npm version prepatch --preid=beta --no-git-tag-version
57
+ fi
48
58
 
49
59
  - name: Update version (Production)
50
60
  if: github.event.inputs.type == 'production'
@@ -56,14 +66,13 @@ jobs:
56
66
  - name: Run tests
57
67
  run: npm test
58
68
 
69
+ - name: Update npm to latest version
70
+ run: npm install -g npm@latest
71
+
59
72
  - name: Publish to npm (Beta)
60
73
  if: github.event.inputs.type == 'beta'
61
74
  run: npm publish --tag beta --provenance --access public
62
- env:
63
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
64
75
 
65
76
  - name: Publish to npm (Production)
66
77
  if: github.event.inputs.type == 'production'
67
78
  run: npm publish --tag latest --provenance --access public
68
- env:
69
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/dist/api/axios.js CHANGED
@@ -43,9 +43,19 @@ export async function sendApiRequest(config) {
43
43
  }
44
44
  catch (error) {
45
45
  if (axios.isAxiosError(error)) {
46
- const message = error.response?.data?.message || error.message;
47
46
  const status = error.response?.status;
48
- throw new Error(`API Error${status ? ` (${status})` : ""}: ${message}`);
47
+ let errorMessage;
48
+ switch (status) {
49
+ case 401:
50
+ errorMessage = "Unauthorized user.";
51
+ break;
52
+ case 500:
53
+ errorMessage = "Internal server error.";
54
+ break;
55
+ default:
56
+ errorMessage = error.response?.data?.message || error.message;
57
+ }
58
+ throw new Error(`Error: ${errorMessage}`);
49
59
  }
50
60
  throw error;
51
61
  }
@@ -18,9 +18,10 @@ program
18
18
  });
19
19
  program
20
20
  .command("create")
21
- .argument("[name]", "App name")
21
+ .argument("[name...]", "App name")
22
22
  .description("Create a new Fireberry app")
23
- .action(async (name) => {
23
+ .action(async (nameArgs) => {
24
+ const name = nameArgs ? nameArgs.join("-") : undefined;
24
25
  await runCreate({ name });
25
26
  });
26
27
  program.parseAsync(process.argv).catch((err) => {
@@ -13,11 +13,7 @@ function slugifyName(name) {
13
13
  if (!validPattern.test(name)) {
14
14
  throw new Error(`Invalid app name: "${name}". Only alphanumeric characters, underscores, and hyphens are allowed.`);
15
15
  }
16
- return name
17
- .toLowerCase()
18
- .replace(/[^a-z0-9]+/g, "-")
19
- .replace(/-+/g, "-")
20
- .replace(/^-|-$/g, "");
16
+ return name;
21
17
  }
22
18
  export async function runCreate({ name }) {
23
19
  let appName = name;
@@ -28,13 +24,13 @@ export async function runCreate({ name }) {
28
24
  appName = (answers.name || "").trim();
29
25
  }
30
26
  if (!appName) {
31
- throw new Error("App name is required.");
27
+ throw new Error("Missing name.");
32
28
  }
33
29
  const slug = slugifyName(appName);
34
30
  const appId = uuidv4();
35
31
  const appDir = path.resolve(process.cwd(), slug);
36
32
  if (await fs.pathExists(appDir)) {
37
- throw new Error(`Directory already exists: ${chalk.yellow(appDir)}`);
33
+ throw new Error(`Already exists. ${chalk.yellow(slug)}`);
38
34
  }
39
35
  const spinner = ora(`Creating app "${chalk.cyan(appName)}"...`).start();
40
36
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireberry/cli",
3
- "version": "0.0.5-beta.3",
3
+ "version": "0.0.5-beta.6",
4
4
  "description": "Fireberry CLI tool",
5
5
  "type": "module",
6
6
  "author": "",
@@ -30,7 +30,7 @@
30
30
  ],
31
31
  "repository": {
32
32
  "type": "git",
33
- "url": "git+https://github.com/fireberry-crm/cli"
33
+ "url": "git+https://github.com/fireberry-crm/cli.git"
34
34
  },
35
35
  "bugs": {
36
36
  "url": "https://github.com/fireberry-crm/cli/issues"
package/src/api/axios.ts CHANGED
@@ -55,9 +55,21 @@ export async function sendApiRequest<T = any>(
55
55
  return response.data;
56
56
  } catch (error) {
57
57
  if (axios.isAxiosError(error)) {
58
- const message = error.response?.data?.message || error.message;
59
58
  const status = error.response?.status;
60
- throw new Error(`API Error${status ? ` (${status})` : ""}: ${message}`);
59
+ let errorMessage:string;
60
+
61
+ switch (status) {
62
+ case 401:
63
+ errorMessage = "Unauthorized user.";
64
+ break;
65
+ case 500:
66
+ errorMessage = "Internal server error.";
67
+ break;
68
+ default:
69
+ errorMessage = error.response?.data?.message || error.message;
70
+ }
71
+
72
+ throw new Error(`Error: ${errorMessage}`);
61
73
  }
62
74
  throw error;
63
75
  }
@@ -22,9 +22,10 @@ program
22
22
 
23
23
  program
24
24
  .command("create")
25
- .argument("[name]", "App name")
25
+ .argument("[name...]", "App name")
26
26
  .description("Create a new Fireberry app")
27
- .action(async (name?: string) => {
27
+ .action(async (nameArgs?: string[]) => {
28
+ const name = nameArgs ? nameArgs.join("-") : undefined;
28
29
  await runCreate({ name });
29
30
  });
30
31
 
@@ -22,15 +22,12 @@ function slugifyName(name: string) {
22
22
  );
23
23
  }
24
24
 
25
- return name
26
- .toLowerCase()
27
- .replace(/[^a-z0-9]+/g, "-")
28
- .replace(/-+/g, "-")
29
- .replace(/^-|-$/g, "");
25
+ return name;
30
26
  }
31
27
 
32
28
  export async function runCreate({ name }: CreateOptions): Promise<void> {
33
29
  let appName = name;
30
+
34
31
  if (!appName) {
35
32
  const answers = await inquirer.prompt([
36
33
  { type: "input", name: "name", message: "App name" },
@@ -38,7 +35,7 @@ export async function runCreate({ name }: CreateOptions): Promise<void> {
38
35
  appName = (answers.name || "").trim();
39
36
  }
40
37
  if (!appName) {
41
- throw new Error("App name is required.");
38
+ throw new Error("Missing name.");
42
39
  }
43
40
 
44
41
  const slug = slugifyName(appName);
@@ -46,7 +43,7 @@ export async function runCreate({ name }: CreateOptions): Promise<void> {
46
43
  const appDir = path.resolve(process.cwd(), slug);
47
44
 
48
45
  if (await fs.pathExists(appDir)) {
49
- throw new Error(`Directory already exists: ${chalk.yellow(appDir)}`);
46
+ throw new Error(`Already exists. ${chalk.yellow(slug)}`);
50
47
  }
51
48
 
52
49
  const spinner = ora(`Creating app "${chalk.cyan(appName)}"...`).start();