test-gen-js 0.1.1
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.
- package/CHANGELOG.md +71 -0
- package/LICENSE +22 -0
- package/README.md +538 -0
- package/bin/cli.js +4 -0
- package/dist/analyzer/componentAnalyzer.d.ts +12 -0
- package/dist/analyzer/componentAnalyzer.d.ts.map +1 -0
- package/dist/analyzer/componentAnalyzer.js +223 -0
- package/dist/analyzer/componentAnalyzer.js.map +1 -0
- package/dist/analyzer/fileAnalyzer.d.ts +17 -0
- package/dist/analyzer/fileAnalyzer.d.ts.map +1 -0
- package/dist/analyzer/fileAnalyzer.js +201 -0
- package/dist/analyzer/fileAnalyzer.js.map +1 -0
- package/dist/analyzer/functionAnalyzer.d.ts +12 -0
- package/dist/analyzer/functionAnalyzer.d.ts.map +1 -0
- package/dist/analyzer/functionAnalyzer.js +184 -0
- package/dist/analyzer/functionAnalyzer.js.map +1 -0
- package/dist/analyzer/index.d.ts +7 -0
- package/dist/analyzer/index.d.ts.map +1 -0
- package/dist/analyzer/index.js +14 -0
- package/dist/analyzer/index.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +113 -0
- package/dist/cli.js.map +1 -0
- package/dist/generator/index.d.ts +6 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +12 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/mockGenerator.d.ts +14 -0
- package/dist/generator/mockGenerator.d.ts.map +1 -0
- package/dist/generator/mockGenerator.js +123 -0
- package/dist/generator/mockGenerator.js.map +1 -0
- package/dist/generator/testGenerator.d.ts +14 -0
- package/dist/generator/testGenerator.d.ts.map +1 -0
- package/dist/generator/testGenerator.js +301 -0
- package/dist/generator/testGenerator.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/astParser.d.ts +15 -0
- package/dist/parser/astParser.d.ts.map +1 -0
- package/dist/parser/astParser.js +100 -0
- package/dist/parser/astParser.js.map +1 -0
- package/dist/parser/index.d.ts +6 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +12 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/typeExtractor.d.ts +14 -0
- package/dist/parser/typeExtractor.d.ts.map +1 -0
- package/dist/parser/typeExtractor.js +165 -0
- package/dist/parser/typeExtractor.js.map +1 -0
- package/dist/templates/component.ejs +67 -0
- package/dist/templates/function.ejs +59 -0
- package/dist/templates/snapshot.ejs +48 -0
- package/dist/types.d.ts +95 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/fileUtils.d.ts +43 -0
- package/dist/utils/fileUtils.d.ts.map +1 -0
- package/dist/utils/fileUtils.js +109 -0
- package/dist/utils/fileUtils.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/naming.d.ts +37 -0
- package/dist/utils/naming.d.ts.map +1 -0
- package/dist/utils/naming.js +73 -0
- package/dist/utils/naming.js.map +1 -0
- package/package.json +84 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for test-gen-js
|
|
3
|
+
*/
|
|
4
|
+
/** Supported file types */
|
|
5
|
+
export type FileType = 'function' | 'component' | 'hook' | 'class' | 'unknown';
|
|
6
|
+
/** Supported frameworks */
|
|
7
|
+
export type Framework = 'react' | 'react-native' | 'node' | 'vanilla';
|
|
8
|
+
/** Information about a prop */
|
|
9
|
+
export interface PropInfo {
|
|
10
|
+
name: string;
|
|
11
|
+
type: string;
|
|
12
|
+
required: boolean;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Information about an import statement */
|
|
16
|
+
export interface ImportInfo {
|
|
17
|
+
source: string;
|
|
18
|
+
specifiers: string[];
|
|
19
|
+
isDefault: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Information about a function parameter */
|
|
22
|
+
export interface ParamInfo {
|
|
23
|
+
name: string;
|
|
24
|
+
type: string;
|
|
25
|
+
optional: boolean;
|
|
26
|
+
defaultValue?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Analyzed component information */
|
|
29
|
+
export interface ComponentInfo {
|
|
30
|
+
name: string;
|
|
31
|
+
type: 'function' | 'arrow' | 'class';
|
|
32
|
+
props: PropInfo[];
|
|
33
|
+
hooks: string[];
|
|
34
|
+
events: string[];
|
|
35
|
+
children: boolean;
|
|
36
|
+
imports: ImportInfo[];
|
|
37
|
+
filePath: string;
|
|
38
|
+
}
|
|
39
|
+
/** Analyzed function information */
|
|
40
|
+
export interface FunctionInfo {
|
|
41
|
+
name: string;
|
|
42
|
+
params: ParamInfo[];
|
|
43
|
+
returnType: string;
|
|
44
|
+
isAsync: boolean;
|
|
45
|
+
isExported: boolean;
|
|
46
|
+
imports: ImportInfo[];
|
|
47
|
+
filePath: string;
|
|
48
|
+
}
|
|
49
|
+
/** Analyzed file information */
|
|
50
|
+
export interface FileAnalysis {
|
|
51
|
+
filePath: string;
|
|
52
|
+
fileType: FileType;
|
|
53
|
+
framework: Framework;
|
|
54
|
+
components: ComponentInfo[];
|
|
55
|
+
functions: FunctionInfo[];
|
|
56
|
+
imports: ImportInfo[];
|
|
57
|
+
}
|
|
58
|
+
/** Test generation options */
|
|
59
|
+
export interface GeneratorOptions {
|
|
60
|
+
/** Output path for the test file */
|
|
61
|
+
output?: string;
|
|
62
|
+
/** Template type to use */
|
|
63
|
+
template?: 'component' | 'function' | 'hook';
|
|
64
|
+
/** Include snapshot tests */
|
|
65
|
+
snapshot?: boolean;
|
|
66
|
+
/** Auto-generate mocks for dependencies */
|
|
67
|
+
mock?: boolean;
|
|
68
|
+
/** Test file suffix (default: .test) */
|
|
69
|
+
testSuffix?: string;
|
|
70
|
+
/** Overwrite existing test file */
|
|
71
|
+
overwrite?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Generated test result */
|
|
74
|
+
export interface GeneratedTest {
|
|
75
|
+
/** Generated test code */
|
|
76
|
+
code: string;
|
|
77
|
+
/** Output file path */
|
|
78
|
+
outputPath: string;
|
|
79
|
+
/** Original source file path */
|
|
80
|
+
sourcePath: string;
|
|
81
|
+
/** Whether the file was created or updated */
|
|
82
|
+
action: 'created' | 'updated' | 'skipped';
|
|
83
|
+
}
|
|
84
|
+
/** Configuration options */
|
|
85
|
+
export interface Config {
|
|
86
|
+
/** File patterns to include */
|
|
87
|
+
include?: string[];
|
|
88
|
+
/** File patterns to exclude */
|
|
89
|
+
exclude?: string[];
|
|
90
|
+
/** Default generator options */
|
|
91
|
+
generator?: GeneratorOptions;
|
|
92
|
+
/** Custom templates directory */
|
|
93
|
+
templatesDir?: string;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,2BAA2B;AAC3B,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE/E,2BAA2B;AAC3B,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,cAAc,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtE,+BAA+B;AAC/B,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,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A6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,4BAA4B;AAC5B,MAAM,WAAW,aAAa;IAC5B,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;CAC3C;AAED,4BAA4B;AAC5B,MAAM,WAAW,MAAM;IACrB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gCAAgC;IAChC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Utilities
|
|
3
|
+
* Helper functions for file operations
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Find all source files in a directory
|
|
7
|
+
*/
|
|
8
|
+
export declare function findSourceFiles(directory: string, options?: {
|
|
9
|
+
pattern?: string;
|
|
10
|
+
exclude?: string[];
|
|
11
|
+
}): Promise<string[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Get test file path for a source file
|
|
14
|
+
*/
|
|
15
|
+
export declare function getTestFilePath(sourcePath: string, options?: {
|
|
16
|
+
suffix?: string;
|
|
17
|
+
testDir?: string;
|
|
18
|
+
}): string;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a file is a test file
|
|
21
|
+
*/
|
|
22
|
+
export declare function isTestFile(filePath: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a file is a source file (not test, not config)
|
|
25
|
+
*/
|
|
26
|
+
export declare function isSourceFile(filePath: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Ensure directory exists
|
|
29
|
+
*/
|
|
30
|
+
export declare function ensureDir(dirPath: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Read file content
|
|
33
|
+
*/
|
|
34
|
+
export declare function readFile(filePath: string): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Write file content
|
|
37
|
+
*/
|
|
38
|
+
export declare function writeFile(filePath: string, content: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Check if file exists
|
|
41
|
+
*/
|
|
42
|
+
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
43
|
+
//# sourceMappingURL=fileUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileUtils.d.ts","sourceRoot":"","sources":["../../src/utils/fileUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACf,GACL,OAAO,CAAC,MAAM,EAAE,CAAC,CAUnB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACb,GACL,MAAM,CAgBR;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAQpD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAwBtD;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEhE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhF;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEnE"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* File Utilities
|
|
4
|
+
* Helper functions for file operations
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.findSourceFiles = findSourceFiles;
|
|
11
|
+
exports.getTestFilePath = getTestFilePath;
|
|
12
|
+
exports.isTestFile = isTestFile;
|
|
13
|
+
exports.isSourceFile = isSourceFile;
|
|
14
|
+
exports.ensureDir = ensureDir;
|
|
15
|
+
exports.readFile = readFile;
|
|
16
|
+
exports.writeFile = writeFile;
|
|
17
|
+
exports.fileExists = fileExists;
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
20
|
+
const glob_1 = require("glob");
|
|
21
|
+
/**
|
|
22
|
+
* Find all source files in a directory
|
|
23
|
+
*/
|
|
24
|
+
async function findSourceFiles(directory, options = {}) {
|
|
25
|
+
const { pattern = '**/*.{ts,tsx,js,jsx}', exclude = ['node_modules', 'dist', '*.test.*', '*.spec.*'] } = options;
|
|
26
|
+
const files = await (0, glob_1.glob)(pattern, {
|
|
27
|
+
cwd: directory,
|
|
28
|
+
ignore: exclude,
|
|
29
|
+
absolute: true,
|
|
30
|
+
});
|
|
31
|
+
return files;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get test file path for a source file
|
|
35
|
+
*/
|
|
36
|
+
function getTestFilePath(sourcePath, options = {}) {
|
|
37
|
+
const { suffix = '.test', testDir } = options;
|
|
38
|
+
const ext = path_1.default.extname(sourcePath);
|
|
39
|
+
const baseName = path_1.default.basename(sourcePath, ext);
|
|
40
|
+
const dirName = path_1.default.dirname(sourcePath);
|
|
41
|
+
const testFileName = `${baseName}${suffix}${ext}`;
|
|
42
|
+
if (testDir) {
|
|
43
|
+
// Use custom test directory
|
|
44
|
+
const relativePath = path_1.default.relative(process.cwd(), dirName);
|
|
45
|
+
return path_1.default.join(testDir, relativePath, testFileName);
|
|
46
|
+
}
|
|
47
|
+
// Place test file next to source file
|
|
48
|
+
return path_1.default.join(dirName, testFileName);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Check if a file is a test file
|
|
52
|
+
*/
|
|
53
|
+
function isTestFile(filePath) {
|
|
54
|
+
const fileName = path_1.default.basename(filePath);
|
|
55
|
+
return (fileName.includes('.test.') ||
|
|
56
|
+
fileName.includes('.spec.') ||
|
|
57
|
+
fileName.includes('__tests__') ||
|
|
58
|
+
fileName.includes('__mocks__'));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check if a file is a source file (not test, not config)
|
|
62
|
+
*/
|
|
63
|
+
function isSourceFile(filePath) {
|
|
64
|
+
const ext = path_1.default.extname(filePath).toLowerCase();
|
|
65
|
+
const validExtensions = ['.ts', '.tsx', '.js', '.jsx'];
|
|
66
|
+
if (!validExtensions.includes(ext)) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (isTestFile(filePath)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const fileName = path_1.default.basename(filePath);
|
|
73
|
+
const configPatterns = [
|
|
74
|
+
'jest.config',
|
|
75
|
+
'babel.config',
|
|
76
|
+
'webpack.config',
|
|
77
|
+
'vite.config',
|
|
78
|
+
'tsconfig',
|
|
79
|
+
'.eslintrc',
|
|
80
|
+
'.prettierrc',
|
|
81
|
+
];
|
|
82
|
+
return !configPatterns.some((pattern) => fileName.includes(pattern));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Ensure directory exists
|
|
86
|
+
*/
|
|
87
|
+
async function ensureDir(dirPath) {
|
|
88
|
+
await fs_extra_1.default.ensureDir(dirPath);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Read file content
|
|
92
|
+
*/
|
|
93
|
+
async function readFile(filePath) {
|
|
94
|
+
return fs_extra_1.default.readFile(filePath, 'utf-8');
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Write file content
|
|
98
|
+
*/
|
|
99
|
+
async function writeFile(filePath, content) {
|
|
100
|
+
await ensureDir(path_1.default.dirname(filePath));
|
|
101
|
+
await fs_extra_1.default.writeFile(filePath, content, 'utf-8');
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Check if file exists
|
|
105
|
+
*/
|
|
106
|
+
async function fileExists(filePath) {
|
|
107
|
+
return fs_extra_1.default.pathExists(filePath);
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=fileUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileUtils.js","sourceRoot":"","sources":["../../src/utils/fileUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AASH,0CAgBC;AAKD,0CAsBC;AAKD,gCAQC;AAKD,oCAwBC;AAKD,8BAEC;AAKD,4BAEC;AAKD,8BAGC;AAKD,gCAEC;AAzHD,gDAAwB;AACxB,wDAA0B;AAC1B,+BAA4B;AAE5B;;GAEG;A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,QAAgB,EAAE,OAAe;IAC/D,MAAM,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,kBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,UAAU,CAAC,QAAgB;IAC/C,OAAO,kBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utilities module
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./fileUtils"), exports);
|
|
21
|
+
__exportStar(require("./naming"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,2CAAyB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Naming Utilities
|
|
3
|
+
* Helper functions for naming conventions
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Convert to PascalCase
|
|
7
|
+
*/
|
|
8
|
+
export declare function toPascalCase(str: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Convert to camelCase
|
|
11
|
+
*/
|
|
12
|
+
export declare function toCamelCase(str: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Convert to kebab-case
|
|
15
|
+
*/
|
|
16
|
+
export declare function toKebabCase(str: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Convert to snake_case
|
|
19
|
+
*/
|
|
20
|
+
export declare function toSnakeCase(str: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Check if string is PascalCase (likely a component name)
|
|
23
|
+
*/
|
|
24
|
+
export declare function isPascalCase(str: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Check if string is camelCase (likely a function/variable name)
|
|
27
|
+
*/
|
|
28
|
+
export declare function isCamelCase(str: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Generate a describe block name
|
|
31
|
+
*/
|
|
32
|
+
export declare function getDescribeName(name: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Generate a test name from function/component name
|
|
35
|
+
*/
|
|
36
|
+
export declare function getTestName(name: string, action: string): string;
|
|
37
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/utils/naming.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhE"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Naming Utilities
|
|
4
|
+
* Helper functions for naming conventions
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.toPascalCase = toPascalCase;
|
|
8
|
+
exports.toCamelCase = toCamelCase;
|
|
9
|
+
exports.toKebabCase = toKebabCase;
|
|
10
|
+
exports.toSnakeCase = toSnakeCase;
|
|
11
|
+
exports.isPascalCase = isPascalCase;
|
|
12
|
+
exports.isCamelCase = isCamelCase;
|
|
13
|
+
exports.getDescribeName = getDescribeName;
|
|
14
|
+
exports.getTestName = getTestName;
|
|
15
|
+
/**
|
|
16
|
+
* Convert to PascalCase
|
|
17
|
+
*/
|
|
18
|
+
function toPascalCase(str) {
|
|
19
|
+
return str
|
|
20
|
+
.replace(/[-_](.)/g, (_, char) => char.toUpperCase())
|
|
21
|
+
.replace(/^(.)/, (_, char) => char.toUpperCase());
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Convert to camelCase
|
|
25
|
+
*/
|
|
26
|
+
function toCamelCase(str) {
|
|
27
|
+
return str
|
|
28
|
+
.replace(/[-_](.)/g, (_, char) => char.toUpperCase())
|
|
29
|
+
.replace(/^(.)/, (_, char) => char.toLowerCase());
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Convert to kebab-case
|
|
33
|
+
*/
|
|
34
|
+
function toKebabCase(str) {
|
|
35
|
+
return str
|
|
36
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
37
|
+
.replace(/[_\s]+/g, '-')
|
|
38
|
+
.toLowerCase();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Convert to snake_case
|
|
42
|
+
*/
|
|
43
|
+
function toSnakeCase(str) {
|
|
44
|
+
return str
|
|
45
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
46
|
+
.replace(/[-\s]+/g, '_')
|
|
47
|
+
.toLowerCase();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if string is PascalCase (likely a component name)
|
|
51
|
+
*/
|
|
52
|
+
function isPascalCase(str) {
|
|
53
|
+
return /^[A-Z][a-zA-Z0-9]*$/.test(str);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if string is camelCase (likely a function/variable name)
|
|
57
|
+
*/
|
|
58
|
+
function isCamelCase(str) {
|
|
59
|
+
return /^[a-z][a-zA-Z0-9]*$/.test(str);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Generate a describe block name
|
|
63
|
+
*/
|
|
64
|
+
function getDescribeName(name) {
|
|
65
|
+
return name;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generate a test name from function/component name
|
|
69
|
+
*/
|
|
70
|
+
function getTestName(name, action) {
|
|
71
|
+
return `${action} ${toCamelCase(name)}`;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=naming.js.map
|
|
@@ -0,0 +1 @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C,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,IAAY,EAAE,MAAc;IACtD,OAAO,GAAG,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;AAC1C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "test-gen-js",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Auto-generate test boilerplate code for JavaScript/TypeScript, React, and React Native projects",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"test-gen-js": "bin/cli.js",
|
|
9
|
+
"tgjs": "bin/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc && npm run copy-templates",
|
|
13
|
+
"copy-templates": "cp -r src/templates dist/",
|
|
14
|
+
"dev": "tsc --watch",
|
|
15
|
+
"test": "jest",
|
|
16
|
+
"test:watch": "jest --watch",
|
|
17
|
+
"lint": "eslint src --ext .ts",
|
|
18
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
19
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"test",
|
|
24
|
+
"generator",
|
|
25
|
+
"jest",
|
|
26
|
+
"react",
|
|
27
|
+
"react-native",
|
|
28
|
+
"testing-library",
|
|
29
|
+
"boilerplate",
|
|
30
|
+
"scaffold",
|
|
31
|
+
"typescript",
|
|
32
|
+
"javascript",
|
|
33
|
+
"automation"
|
|
34
|
+
],
|
|
35
|
+
"author": "liveforownhappiness",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/liveforownhappiness/test-gen-js-.git"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/liveforownhappiness/test-gen-js-/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/liveforownhappiness/test-gen-js-#readme",
|
|
45
|
+
"files": [
|
|
46
|
+
"dist",
|
|
47
|
+
"bin",
|
|
48
|
+
"README.md",
|
|
49
|
+
"LICENSE",
|
|
50
|
+
"CHANGELOG.md"
|
|
51
|
+
],
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=16.0.0"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@babel/parser": "^7.23.0",
|
|
57
|
+
"@babel/traverse": "^7.23.0",
|
|
58
|
+
"@babel/types": "^7.23.0",
|
|
59
|
+
"@babel/generator": "^7.23.0",
|
|
60
|
+
"commander": "^11.1.0",
|
|
61
|
+
"ejs": "^3.1.9",
|
|
62
|
+
"glob": "^10.3.0",
|
|
63
|
+
"fs-extra": "^11.2.0",
|
|
64
|
+
"chalk": "^4.1.2",
|
|
65
|
+
"ora": "^5.4.1",
|
|
66
|
+
"inquirer": "^8.2.6"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@types/node": "^20.0.0",
|
|
70
|
+
"@types/babel__traverse": "^7.20.0",
|
|
71
|
+
"@types/ejs": "^3.1.0",
|
|
72
|
+
"@types/fs-extra": "^11.0.0",
|
|
73
|
+
"@types/inquirer": "^9.0.0",
|
|
74
|
+
"typescript": "^5.3.0",
|
|
75
|
+
"jest": "^29.7.0",
|
|
76
|
+
"@types/jest": "^29.5.0",
|
|
77
|
+
"ts-jest": "^29.1.0",
|
|
78
|
+
"eslint": "^8.56.0",
|
|
79
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
80
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
81
|
+
"prettier": "^3.2.0"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|