@fireberry/cli 0.0.5-beta.5 → 0.0.5-beta.7

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
@@ -62,14 +66,13 @@ jobs:
62
66
  - name: Run tests
63
67
  run: npm test
64
68
 
69
+ - name: Update npm to latest version
70
+ run: npm install -g npm@latest
71
+
65
72
  - name: Publish to npm (Beta)
66
73
  if: github.event.inputs.type == 'beta'
67
74
  run: npm publish --tag beta --provenance --access public
68
- env:
69
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
70
75
 
71
76
  - name: Publish to npm (Production)
72
77
  if: github.event.inputs.type == 'production'
73
78
  run: npm publish --tag latest --provenance --access public
74
- env:
75
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -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) => {
@@ -29,6 +30,7 @@ program.parseAsync(process.argv).catch((err) => {
29
30
  : typeof err === 'string'
30
31
  ? err
31
32
  : 'Unexpected error';
32
- console.error(chalk.red(errorMessage));
33
+ const formattedError = errorMessage.startsWith('Error:') ? errorMessage : `Error: ${errorMessage}`;
34
+ console.error(chalk.red(formattedError));
33
35
  process.exit(1);
34
36
  });
@@ -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.5",
3
+ "version": "0.0.5-beta.7",
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"
@@ -22,10 +22,11 @@ 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) => {
28
- await runCreate({ name });
27
+ .action(async (nameArgs?: string[]) => {
28
+ const name = nameArgs ? nameArgs.join("-") : undefined;
29
+ await runCreate({ name });
29
30
  });
30
31
 
31
32
  program.parseAsync(process.argv).catch((err: unknown) => {
@@ -34,6 +35,8 @@ program.parseAsync(process.argv).catch((err: unknown) => {
34
35
  : typeof err === 'string'
35
36
  ? err
36
37
  : 'Unexpected error';
37
- console.error(chalk.red(errorMessage));
38
+
39
+ const formattedError = errorMessage.startsWith('Error:') ? errorMessage : `Error: ${errorMessage}`;
40
+ console.error(chalk.red(formattedError));
38
41
  process.exit(1);
39
42
  });
@@ -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();