dceky 1.0.0-beta-auto-import.1 → 1.0.0-beta-auto-import.3
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/lib/genCommandPaths.d.ts +2 -3
- package/lib/genCommandPaths.js +24 -14
- package/lib/genCommandPaths.js.map +1 -1
- package/lib/init.js +1 -1
- package/lib/init.js.map +1 -1
- package/package.json +1 -1
- package/src/genCommandPaths.ts +29 -14
- package/src/init.ts +1 -1
package/lib/genCommandPaths.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generate
|
|
2
|
+
* Generate an index.ts file that imports and runs all command files in cypress/commands
|
|
3
3
|
* This should be called from cypress.config.js (Node.js context)
|
|
4
|
-
* @param projectRoot - The root directory of the Cypress project (optional, defaults to process.cwd())
|
|
5
4
|
* @returns The path to the generated file
|
|
6
|
-
* @author
|
|
5
|
+
* @author Yuen Ler Chow
|
|
7
6
|
*/
|
|
8
7
|
declare const genCommandPaths: () => string;
|
|
9
8
|
export default genCommandPaths;
|
package/lib/genCommandPaths.js
CHANGED
|
@@ -36,35 +36,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
var fs = __importStar(require("fs"));
|
|
37
37
|
var path = __importStar(require("path"));
|
|
38
38
|
/**
|
|
39
|
-
* Generate
|
|
39
|
+
* Generate an index.ts file that imports and runs all command files in cypress/commands
|
|
40
40
|
* This should be called from cypress.config.js (Node.js context)
|
|
41
|
-
* @param projectRoot - The root directory of the Cypress project (optional, defaults to process.cwd())
|
|
42
41
|
* @returns The path to the generated file
|
|
43
|
-
* @author
|
|
42
|
+
* @author Yuen Ler Chow
|
|
44
43
|
*/
|
|
45
44
|
var genCommandPaths = function () {
|
|
46
45
|
var root = process.cwd();
|
|
47
|
-
var cypressCommandsDir = path.resolve(root, 'cypress
|
|
48
|
-
var outputFile = path.resolve(cypressCommandsDir, '.
|
|
46
|
+
var cypressCommandsDir = path.resolve(root, 'cypress/commands');
|
|
47
|
+
var outputFile = path.resolve(cypressCommandsDir, 'index.ts');
|
|
49
48
|
// Check if the directory exists
|
|
50
49
|
if (!fs.existsSync(cypressCommandsDir)) {
|
|
51
50
|
// eslint-disable-next-line no-console
|
|
52
51
|
console.warn("Cypress commands directory not found at: ".concat(cypressCommandsDir));
|
|
53
52
|
// Create an empty file so init doesn't fail
|
|
54
|
-
fs.writeFileSync(outputFile, '
|
|
53
|
+
fs.writeFileSync(outputFile, '// Auto-generated by dceky - do not edit manually\n');
|
|
55
54
|
return outputFile;
|
|
56
55
|
}
|
|
57
56
|
// Get all files in the directory
|
|
58
57
|
var files = fs.readdirSync(cypressCommandsDir);
|
|
59
|
-
var
|
|
58
|
+
var commandFiles = [];
|
|
60
59
|
// Filter out non-JS/TS files and process each file
|
|
61
60
|
files.forEach(function (file) {
|
|
62
|
-
// Skip non-JS files (like .d.ts, .map, etc.)
|
|
61
|
+
// Skip non-JS/TS files (like .d.ts, .map, etc.)
|
|
63
62
|
if (!file.endsWith('.js') && !file.endsWith('.ts')) {
|
|
64
63
|
return;
|
|
65
64
|
}
|
|
66
|
-
// Skip index files
|
|
67
|
-
if (file === 'index.js' || file === 'index.ts'
|
|
65
|
+
// Skip index files
|
|
66
|
+
if (file === 'index.js' || file === 'index.ts') {
|
|
68
67
|
return;
|
|
69
68
|
}
|
|
70
69
|
var filePath = path.join(cypressCommandsDir, file);
|
|
@@ -73,13 +72,24 @@ var genCommandPaths = function () {
|
|
|
73
72
|
if (!stats.isFile()) {
|
|
74
73
|
return;
|
|
75
74
|
}
|
|
76
|
-
// Store the
|
|
77
|
-
|
|
75
|
+
// Store the file name
|
|
76
|
+
commandFiles.push(file);
|
|
78
77
|
});
|
|
79
|
-
|
|
78
|
+
// Generate require statements and function calls
|
|
79
|
+
var requires = [];
|
|
80
|
+
var calls = [];
|
|
81
|
+
commandFiles.forEach(function (file) {
|
|
82
|
+
var requirePath = "./".concat(file);
|
|
83
|
+
// Create a safe variable name (replace non-alphanumeric with underscore)
|
|
84
|
+
var importName = file.replace(/\.(js|ts)$/, '');
|
|
85
|
+
var varName = importName.replace(/[^a-zA-Z0-9]/g, '_');
|
|
86
|
+
requires.push("const ".concat(varName, " = require('").concat(requirePath, "');"));
|
|
87
|
+
calls.push("".concat(varName, ".default();"));
|
|
88
|
+
});
|
|
89
|
+
var content = "// Auto-generated by dceky - do not edit manually\n".concat(requires.join('\n'), "\n\n").concat(calls.join('\n'), "\n");
|
|
80
90
|
fs.writeFileSync(outputFile, content);
|
|
81
91
|
// eslint-disable-next-line no-console
|
|
82
|
-
console.log("Generated command
|
|
92
|
+
console.log("Generated command index file: ".concat(outputFile, " (").concat(commandFiles.length, " commands)"));
|
|
83
93
|
return outputFile;
|
|
84
94
|
};
|
|
85
95
|
exports.default = genCommandPaths;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genCommandPaths.js","sourceRoot":"","sources":["../src/genCommandPaths.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAE7B
|
|
1
|
+
{"version":3,"file":"genCommandPaths.js","sourceRoot":"","sources":["../src/genCommandPaths.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAE7B;;;;;GAKG;AACH,IAAM,eAAe,GAAG;IACtB,IAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IAClE,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;IAEhE,gCAAgC;IAChC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACvC,sCAAsC;QACtC,OAAO,CAAC,IAAI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CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;QAEzD,QAAQ,CAAC,IAAI,CAAC,gBAAS,OAAO,yBAAe,WAAW,QAAK,CAAC,CAAC;QAC/D,KAAK,CAAC,IAAI,CAAC,UAAG,OAAO,gBAAa,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,IAAM,OAAO,GAAG,6DAChB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,iBAEnB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OACjB,CAAC;IAEA,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAEtC,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,wCAAiC,UAAU,eAAK,YAAY,CAAC,MAAM,eAAY,CAAC,CAAC;IAE7F,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
package/lib/init.js
CHANGED
|
@@ -62,7 +62,7 @@ var init = function (CypressRequire, c) {
|
|
|
62
62
|
// const pwd = (process.env.PWD || process.env.CWD);
|
|
63
63
|
var pwd = __dirname;
|
|
64
64
|
c.log('pwd:', pwd);
|
|
65
|
-
var playVideoPath = path_1.default.join(pwd, '
|
|
65
|
+
var playVideoPath = path_1.default.join(pwd, './../../../cypress/commands/playVideo.ts');
|
|
66
66
|
c.log('playVideoPath:', playVideoPath);
|
|
67
67
|
c.log('About to require playVideo...');
|
|
68
68
|
var playVideoModule = CypressRequire(playVideoPath);
|
package/lib/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;AACA,8CAAwB;AACxB,yBAAyB;AACzB,0EAA0E;AAC1E,0DAA0D;AAC1D,gEAAgE;AAChE,0DAA0D;AAC1D,8DAA8D;AAC9D,8CAA8C;AAC9C,oEAAoE;AACpE,0DAA0D;AAC1D,gDAAgD;AAChD,8CAA8C;AAC9C,0EAA0E;A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H,2GAAoG,KAAK,CAAE,CAC5G,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
package/src/genCommandPaths.ts
CHANGED
|
@@ -2,39 +2,38 @@ import * as fs from 'fs';
|
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Generate
|
|
5
|
+
* Generate an index.ts file that imports and runs all command files in cypress/commands
|
|
6
6
|
* This should be called from cypress.config.js (Node.js context)
|
|
7
|
-
* @param projectRoot - The root directory of the Cypress project (optional, defaults to process.cwd())
|
|
8
7
|
* @returns The path to the generated file
|
|
9
|
-
* @author
|
|
8
|
+
* @author Yuen Ler Chow
|
|
10
9
|
*/
|
|
11
10
|
const genCommandPaths = (): string => {
|
|
12
11
|
const root = process.cwd();
|
|
13
|
-
const cypressCommandsDir = path.resolve(root, 'cypress
|
|
14
|
-
const outputFile = path.resolve(cypressCommandsDir, '.
|
|
12
|
+
const cypressCommandsDir = path.resolve(root, 'cypress/commands');
|
|
13
|
+
const outputFile = path.resolve(cypressCommandsDir, 'index.ts');
|
|
15
14
|
|
|
16
15
|
// Check if the directory exists
|
|
17
16
|
if (!fs.existsSync(cypressCommandsDir)) {
|
|
18
17
|
// eslint-disable-next-line no-console
|
|
19
18
|
console.warn(`Cypress commands directory not found at: ${cypressCommandsDir}`);
|
|
20
19
|
// Create an empty file so init doesn't fail
|
|
21
|
-
fs.writeFileSync(outputFile, '
|
|
20
|
+
fs.writeFileSync(outputFile, '// Auto-generated by dceky - do not edit manually\n');
|
|
22
21
|
return outputFile;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
// Get all files in the directory
|
|
26
25
|
const files = fs.readdirSync(cypressCommandsDir);
|
|
27
|
-
const
|
|
26
|
+
const commandFiles: string[] = [];
|
|
28
27
|
|
|
29
28
|
// Filter out non-JS/TS files and process each file
|
|
30
29
|
files.forEach((file) => {
|
|
31
|
-
// Skip non-JS files (like .d.ts, .map, etc.)
|
|
30
|
+
// Skip non-JS/TS files (like .d.ts, .map, etc.)
|
|
32
31
|
if (!file.endsWith('.js') && !file.endsWith('.ts')) {
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
// Skip index files
|
|
37
|
-
if (file === 'index.js' || file === 'index.ts'
|
|
35
|
+
// Skip index files
|
|
36
|
+
if (file === 'index.js' || file === 'index.ts') {
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -46,18 +45,34 @@ const genCommandPaths = (): string => {
|
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
// Store the
|
|
50
|
-
|
|
48
|
+
// Store the file name
|
|
49
|
+
commandFiles.push(file);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Generate require statements and function calls
|
|
53
|
+
const requires: string[] = [];
|
|
54
|
+
const calls: string[] = [];
|
|
55
|
+
|
|
56
|
+
commandFiles.forEach((file) => {
|
|
57
|
+
const requirePath = `./${file}`;
|
|
58
|
+
// Create a safe variable name (replace non-alphanumeric with underscore)
|
|
59
|
+
const importName = file.replace(/\.(js|ts)$/, '');
|
|
60
|
+
const varName = importName.replace(/[^a-zA-Z0-9]/g, '_');
|
|
61
|
+
|
|
62
|
+
requires.push(`const ${varName} = require('${requirePath}');`);
|
|
63
|
+
calls.push(`${varName}.default();`);
|
|
51
64
|
});
|
|
52
65
|
|
|
53
66
|
const content = `// Auto-generated by dceky - do not edit manually
|
|
54
|
-
|
|
67
|
+
${requires.join('\n')}
|
|
68
|
+
|
|
69
|
+
${calls.join('\n')}
|
|
55
70
|
`;
|
|
56
71
|
|
|
57
72
|
fs.writeFileSync(outputFile, content);
|
|
58
73
|
|
|
59
74
|
// eslint-disable-next-line no-console
|
|
60
|
-
console.log(`Generated command
|
|
75
|
+
console.log(`Generated command index file: ${outputFile} (${commandFiles.length} commands)`);
|
|
61
76
|
|
|
62
77
|
return outputFile;
|
|
63
78
|
};
|
package/src/init.ts
CHANGED
|
@@ -65,7 +65,7 @@ const init = (CypressRequire: <T = any>(id: string) => T, c: any) => {
|
|
|
65
65
|
// const pwd = (process.env.PWD || process.env.CWD);
|
|
66
66
|
const pwd = __dirname;
|
|
67
67
|
c.log('pwd:', pwd);
|
|
68
|
-
const playVideoPath = path.join(pwd, '
|
|
68
|
+
const playVideoPath = path.join(pwd, './../../../cypress/commands/playVideo.ts');
|
|
69
69
|
c.log('playVideoPath:', playVideoPath);
|
|
70
70
|
c.log('About to require playVideo...');
|
|
71
71
|
const playVideoModule = CypressRequire(playVideoPath);
|