@devrune/cli 1.0.5 โ†’ 1.0.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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fs_1 = __importDefault(require("fs"));
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const util_1 = require("./util");
9
+ const constants_1 = require("./constants");
9
10
  const SRC_DIR = (0, util_1.isRootFolder)();
10
11
  const RESERVED_NEXT_FILES = new Set([
11
12
  "page.tsx",
@@ -74,26 +75,7 @@ const checkFile = (filePath) => {
74
75
  // Hooks (check hooks before UI components since hooks can also be in TSX files)
75
76
  if (fileName.startsWith("use-") && (fileName.endsWith(".hook.ts") || fileName.endsWith(".hook.tsx")))
76
77
  return;
77
- // UI components
78
- if (fileName.endsWith(".ui.tsx"))
79
- return;
80
- // Types
81
- if (fileName.endsWith(".type.ts"))
82
- return;
83
- // Classes
84
- if (fileName.endsWith(".class.ts"))
85
- return;
86
- // Utils
87
- if (fileName.endsWith(".util.ts"))
88
- return;
89
- //Constants
90
- if (fileName.endsWith(".const.ts"))
91
- return;
92
- // API
93
- if (fileName.endsWith(".api.ts"))
94
- return;
95
- // Modals
96
- if (fileName.endsWith(".modal.tsx"))
78
+ if (!constants_1.VALID_FILE_SUFFIXES.some(suffix => fileName.endsWith(suffix)))
97
79
  return;
98
80
  reportError(filePath, "File name does not follow naming convention.");
99
81
  };
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MODALS_DIR = exports.TYPES_DIR = exports.UTILS_DIR = exports.HOOKS_DIR = exports.UI_DIR = exports.API_DIR = exports.ROOT_DIR = exports.SHARED_DIR = exports.FEATURE_DIR = void 0;
3
+ exports.VALID_FILE_SUFFIXES = exports.MODALS_DIR = exports.TYPES_DIR = exports.UTILS_DIR = exports.HOOKS_DIR = exports.UI_DIR = exports.API_DIR = exports.ROOT_DIR = exports.SHARED_DIR = exports.FEATURE_DIR = void 0;
4
4
  exports.FEATURE_DIR = "features";
5
5
  exports.SHARED_DIR = "shared";
6
6
  exports.ROOT_DIR = "src";
@@ -10,4 +10,5 @@ exports.HOOKS_DIR = "hooks";
10
10
  exports.UTILS_DIR = "utils";
11
11
  exports.TYPES_DIR = "types";
12
12
  exports.MODALS_DIR = "modals";
13
+ exports.VALID_FILE_SUFFIXES = [".hook.ts", ".hook.tsx", ".ui.tsx", ".type.ts", ".class.ts", ".util.ts", ".const.ts", ".api.ts", ".modal.tsx", ".provider.tsx"];
13
14
  // CLI api - name.api.ts, ui - name.ui.ts, hooks - name.hook.ts, utils - name.util.ts, types name.type.ts, classes - name.class.ts
@@ -44,7 +44,7 @@ async function main() {
44
44
  ensureDir(node_path_1.default.join(ROOT_DIR_PATH, name));
45
45
  createFile(node_path_1.default.join(ROOT_DIR_PATH, name, `${name}.class.ts`), `// export class ${toPascalCase(name)} = {}`);
46
46
  ensureDir(node_path_1.default.join(ROOT_DIR_PATH, name, constants_1.API_DIR));
47
- createFile(node_path_1.default.join(ROOT_DIR_PATH, name, constants_1.API_DIR, `${name}.api.ts`), `// export const ${toCamelCase(`${name}Api`)} = {}`);
47
+ createFile(node_path_1.default.join(ROOT_DIR_PATH, name, constants_1.API_DIR, `${name}.api.ts`), `"use server";\n// export const ${toCamelCase(`${name}Api`)} = async () => {}`);
48
48
  ensureDir(node_path_1.default.join(ROOT_DIR_PATH, name, constants_1.UI_DIR));
49
49
  createFile(node_path_1.default.join(ROOT_DIR_PATH, name, constants_1.UI_DIR, `${name}.ui.tsx`), `import type { ${toPascalCase(name)}Props } from '../types/${name}.type';\n\nexport const ${toPascalCase(name)} = ({}: ${toPascalCase(name)}Props) => { \n return null;\n};`);
50
50
  ensureDir(node_path_1.default.join(ROOT_DIR_PATH, name, constants_1.HOOKS_DIR));
package/dist/index.js CHANGED
@@ -6,17 +6,51 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const select_1 = __importDefault(require("@inquirer/select"));
8
8
  const util_1 = require("./util");
9
- (0, util_1.isRootFolder)();
10
9
  console.log("Welcome to DevRune CLI! Use this tool to generate features and check file name style guide.");
11
- (0, select_1.default)({
12
- message: 'What do you want to create?',
13
- choices: [{ name: 'Check Style Guide ๐ŸŽจ', value: 'check', description: 'Check project folders according style guide' },
14
- { name: 'Create new feature ๐Ÿ“‚', value: 'feature', description: 'Create new feature' }],
15
- }).then((answer) => {
10
+ async function run() {
11
+ const args = process.argv.slice(2);
12
+ if (args.includes('-h') || args.includes('--help')) {
13
+ console.log(`
14
+ DevRune CLI
15
+
16
+ โ—๏ธโ—๏ธโ—๏ธImportant to call command only from folder where src is located, otherwise it won't work
17
+
18
+ Usage:
19
+ @devrune/cli Interactive mode
20
+ @devrune/cli --check Check folders style guide
21
+ @devrune/cli --feature Create new feature
22
+ @devrune/cli -h Help
23
+ `);
24
+ return;
25
+ }
26
+ (0, util_1.isRootFolder)();
27
+ if (args.includes('--check')) {
28
+ return require('./check-file-name-style-guide');
29
+ }
30
+ if (args.includes('--feature')) {
31
+ return require('./generate-feature');
32
+ }
33
+ // ๐Ÿ‘‰ fallback to interactive mode
34
+ const answer = await (0, select_1.default)({
35
+ message: 'What do you want to create?',
36
+ choices: [
37
+ {
38
+ name: 'Check Style Guide ๐ŸŽจ',
39
+ value: 'check',
40
+ description: 'Check project folders according style guide',
41
+ },
42
+ {
43
+ name: 'Create new feature ๐Ÿ“‚',
44
+ value: 'feature',
45
+ description: 'Create new feature',
46
+ },
47
+ ],
48
+ });
16
49
  if (answer === 'check') {
17
50
  require('./check-file-name-style-guide');
18
51
  }
19
52
  if (answer === 'feature') {
20
53
  require('./generate-feature');
21
54
  }
22
- });
55
+ }
56
+ run();
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@devrune/cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "bin": {
5
5
  "devrune": "./dist/index.js"
6
6
  },
7
7
  "scripts": {
8
8
  "generate-feature": "ts-node ./scripts/generate-feature.ts",
9
- "check-file-name": "ts-node ./scripts/check-file-name-style-guide.ts"
9
+ "check-file-name": "ts-node ./scripts/check-file-name-style-guide.ts",
10
+ "publish:lib": "npx tsc && npm publish --access public"
10
11
  },
11
12
  "devDependencies": {
12
13
  "@types/node": "^25.3.0",
@@ -1,6 +1,7 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
3
  import { isRootFolder } from "./util";
4
+ import { VALID_FILE_SUFFIXES } from "./constants";
4
5
 
5
6
  const SRC_DIR = isRootFolder();
6
7
 
@@ -76,27 +77,8 @@ const checkFile = (filePath: string) => {
76
77
 
77
78
  // Hooks (check hooks before UI components since hooks can also be in TSX files)
78
79
  if (fileName.startsWith("use-") && (fileName.endsWith(".hook.ts") || fileName.endsWith(".hook.tsx"))) return;
79
-
80
- // UI components
81
- if (fileName.endsWith(".ui.tsx")) return;
82
-
83
- // Types
84
- if (fileName.endsWith(".type.ts")) return;
85
-
86
- // Classes
87
- if (fileName.endsWith(".class.ts")) return;
88
-
89
- // Utils
90
- if (fileName.endsWith(".util.ts")) return;
91
-
92
- //Constants
93
- if (fileName.endsWith(".const.ts")) return;
94
-
95
- // API
96
- if (fileName.endsWith(".api.ts")) return;
97
-
98
- // Modals
99
- if (fileName.endsWith(".modal.tsx")) return;
80
+ if (!VALID_FILE_SUFFIXES.some(suffix => fileName.endsWith(suffix))) return;
81
+
100
82
 
101
83
  reportError(filePath, "File name does not follow naming convention.");
102
84
  }
@@ -7,4 +7,6 @@ export const HOOKS_DIR = "hooks";
7
7
  export const UTILS_DIR = "utils";
8
8
  export const TYPES_DIR = "types";
9
9
  export const MODALS_DIR = "modals";
10
+
11
+ export const VALID_FILE_SUFFIXES = [".hook.ts", ".hook.tsx", ".ui.tsx", ".type.ts", ".class.ts", ".util.ts", ".const.ts", ".api.ts", ".modal.tsx", ".provider.tsx"];
10
12
  // CLI api - name.api.ts, ui - name.ui.ts, hooks - name.hook.ts, utils - name.util.ts, types name.type.ts, classes - name.class.ts
@@ -55,7 +55,7 @@ async function main() {
55
55
  ensureDir(path.join(ROOT_DIR_PATH, name));
56
56
  createFile(path.join(ROOT_DIR_PATH, name, `${name}.class.ts`), `// export class ${toPascalCase(name)} = {}`);
57
57
  ensureDir(path.join(ROOT_DIR_PATH, name, API_DIR));
58
- createFile(path.join(ROOT_DIR_PATH, name, API_DIR, `${name}.api.ts`), `// export const ${toCamelCase(`${name}Api`)} = {}`);
58
+ createFile(path.join(ROOT_DIR_PATH, name, API_DIR, `${name}.api.ts`), `"use server";\n// export const ${toCamelCase(`${name}Api`)} = async () => {}`);
59
59
  ensureDir(path.join(ROOT_DIR_PATH, name, UI_DIR));
60
60
  createFile(path.join(ROOT_DIR_PATH, name, UI_DIR, `${name}.ui.tsx`), `import type { ${toPascalCase(name)}Props } from '../types/${name}.type';\n\nexport const ${toPascalCase(name)} = ({}: ${toPascalCase(name)}Props) => { \n return null;\n};`);
61
61
  ensureDir(path.join(ROOT_DIR_PATH, name, HOOKS_DIR));
package/scripts/index.ts CHANGED
@@ -2,22 +2,64 @@
2
2
  import select from "@inquirer/select";
3
3
  import { isRootFolder } from "./util";
4
4
 
5
- isRootFolder();
5
+
6
6
 
7
7
  console.log("Welcome to DevRune CLI! Use this tool to generate features and check file name style guide.");
8
- select(
9
- {
10
- message: 'What do you want to create?',
11
- choices: [{name: 'Check Style Guide ๐ŸŽจ', value: 'check', description: 'Check project folders according style guide'},
12
- {name: 'Create new feature ๐Ÿ“‚', value: 'feature', description: 'Create new feature'}],
13
- },
14
- ).then((answer) => {
15
- if (answer === 'check') {
16
- require('./check-file-name-style-guide');
17
- }
18
-
19
- if (answer === 'feature') {
20
- require('./generate-feature');
21
- }
8
+
9
+
10
+ async function run() {
11
+ const args = process.argv.slice(2);
12
+
13
+
14
+ if (args.includes('-h') || args.includes('--help')) {
15
+ console.log(`
16
+ DevRune CLI
17
+
18
+ โ—๏ธโ—๏ธโ—๏ธImportant to call command only from folder where src is located, otherwise it won't work
19
+
20
+ Usage:
21
+ @devrune/cli Interactive mode
22
+ @devrune/cli --check Check folders style guide
23
+ @devrune/cli --feature Create new feature
24
+ @devrune/cli -h Help
25
+ `);
26
+ return;
27
+ }
28
+
29
+ isRootFolder();
30
+
31
+ if (args.includes('--check')) {
32
+ return require('./check-file-name-style-guide');
33
+ }
34
+
35
+ if (args.includes('--feature')) {
36
+ return require('./generate-feature');
37
+ }
38
+
39
+ // ๐Ÿ‘‰ fallback to interactive mode
40
+ const answer = await select({
41
+ message: 'What do you want to create?',
42
+ choices: [
43
+ {
44
+ name: 'Check Style Guide ๐ŸŽจ',
45
+ value: 'check',
46
+ description: 'Check project folders according style guide',
47
+ },
48
+ {
49
+ name: 'Create new feature ๐Ÿ“‚',
50
+ value: 'feature',
51
+ description: 'Create new feature',
52
+ },
53
+ ],
22
54
  });
23
55
 
56
+ if (answer === 'check') {
57
+ require('./check-file-name-style-guide');
58
+ }
59
+
60
+ if (answer === 'feature') {
61
+ require('./generate-feature');
62
+ }
63
+ }
64
+
65
+ run();