@devrune/cli 1.0.6 → 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
|
-
|
|
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
|
package/dist/generate-feature.js
CHANGED
|
@@ -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`),
|
|
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/package.json
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|
package/scripts/constants.ts
CHANGED
|
@@ -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`),
|
|
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));
|