dceky 1.0.4-beta.new-divided-export.6 → 1.0.5-beta.ky-declarations.2

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.
Files changed (28) hide show
  1. package/lib/setup/checkRequiredFiles/genEmptyGlobalFile.d.ts +7 -0
  2. package/lib/setup/checkRequiredFiles/genEmptyGlobalFile.js +41 -0
  3. package/lib/setup/checkRequiredFiles/genEmptyGlobalFile.js.map +1 -0
  4. package/lib/setup/checkRequiredFiles/genEmptyProfileFile.d.ts +7 -0
  5. package/lib/setup/checkRequiredFiles/genEmptyProfileFile.js +41 -0
  6. package/lib/setup/checkRequiredFiles/genEmptyProfileFile.js.map +1 -0
  7. package/lib/setup/checkRequiredFiles/index.d.ts +6 -0
  8. package/lib/setup/checkRequiredFiles/index.js +53 -0
  9. package/lib/setup/checkRequiredFiles/index.js.map +1 -0
  10. package/lib/setup/checkRequiredFiles.js +3 -2
  11. package/lib/setup/checkRequiredFiles.js.map +1 -1
  12. package/lib/setup/genE2ELaunchFile.js +1 -0
  13. package/lib/setup/genE2ELaunchFile.js.map +1 -1
  14. package/lib/setup/genEmptyGlobalFile.d.ts +7 -0
  15. package/lib/setup/genEmptyGlobalFile.js +41 -0
  16. package/lib/setup/genEmptyGlobalFile.js.map +1 -0
  17. package/lib/setup/genKyCommandDeclarations.d.ts +6 -0
  18. package/lib/setup/genKyCommandDeclarations.js +100 -0
  19. package/lib/setup/genKyCommandDeclarations.js.map +1 -0
  20. package/lib/setup/index.js +2 -0
  21. package/lib/setup/index.js.map +1 -1
  22. package/package.json +1 -1
  23. package/setup/checkRequiredFiles/genEmptyGlobalFile.ts +42 -0
  24. package/setup/checkRequiredFiles/genEmptyProfileFile.ts +42 -0
  25. package/setup/{checkRequiredFiles.ts → checkRequiredFiles/index.ts} +10 -17
  26. package/setup/genE2ELaunchFile.ts +1 -0
  27. package/setup/genKyCommandDeclarations.ts +103 -0
  28. package/setup/index.ts +2 -0
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generate an empty [Name].ts file at /cypress/globals/[Name].ts
3
+ * @author Gabe Abrams
4
+ * @param name Name of the global file to create (without extension)
5
+ */
6
+ declare const genEmptyGlobalFile: (name: string) => string;
7
+ export default genEmptyGlobalFile;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var fs_1 = __importDefault(require("fs"));
7
+ var path_1 = __importDefault(require("path"));
8
+ // Import shared helpers
9
+ var getRootPath_1 = __importDefault(require("../helpers/getRootPath"));
10
+ /**
11
+ * Generate an empty [Name].ts file at /cypress/globals/[Name].ts
12
+ * @author Gabe Abrams
13
+ * @param name Name of the global file to create (without extension)
14
+ */
15
+ var genEmptyGlobalFile = function (name) {
16
+ var root = (0, getRootPath_1.default)();
17
+ var globalsDir = path_1.default.join(root, 'cypress/globals');
18
+ var outputFile = path_1.default.join(globalsDir, "Global".concat(name, ".ts"));
19
+ // Check if the directory exists
20
+ if (!fs_1.default.existsSync(globalsDir)) {
21
+ // Create the directory
22
+ fs_1.default.mkdirSync(globalsDir, { recursive: true });
23
+ }
24
+ // Create an empty file with a comment
25
+ var fileContents = [
26
+ '/**',
27
+ " * Global ".concat(name),
28
+ ' */',
29
+ '',
30
+ "const Global".concat(name, " = {"),
31
+ " // Add your global ".concat(name.toLowerCase(), " here"),
32
+ '};',
33
+ '',
34
+ "export default Global".concat(name, ";"),
35
+ '',
36
+ ];
37
+ fs_1.default.writeFileSync(outputFile, fileContents.join('\n'), 'utf8');
38
+ return outputFile;
39
+ };
40
+ exports.default = genEmptyGlobalFile;
41
+ //# sourceMappingURL=genEmptyGlobalFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genEmptyGlobalFile.js","sourceRoot":"","sources":["../../../setup/checkRequiredFiles/genEmptyGlobalFile.ts"],"names":[],"mappings":";;;;;AAAA,0CAAoB;AACpB,8CAAwB;AAExB,wBAAwB;AACxB,uEAAiD;AAEjD;;;;GAIG;AACH,IAAM,kBAAkB,GAAG,UAAC,IAAY;IACtC,IAAM,IAAI,GAAG,IAAA,qBAAW,GAAE,CAAC;IAE3B,IAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACtD,IAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,gBAAS,IAAI,QAAK,CAAC,CAAC;IAE7D,gCAAgC;IAChC,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,uBAAuB;QACvB,YAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,sCAAsC;IACtC,IAAM,YAAY,GAAG;QACnB,KAAK;QACL,oBAAa,IAAI,CAAE;QACnB,KAAK;QACL,EAAE;QACF,sBAAe,IAAI,SAAM;QACzB,+BAAwB,IAAI,CAAC,WAAW,EAAE,UAAO;QACjD,IAAI;QACJ,EAAE;QACF,+BAAwB,IAAI,MAAG;QAC/B,EAAE;KACH,CAAC;IACF,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IAE9D,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generate an empty [Name].ts file at /cypress/profiles/[Name].Profile.ts
3
+ * @author Gabe Abrams
4
+ * @param name Name of the global file to create (without extension)
5
+ */
6
+ declare const genEmptyProfileFile: (name: string) => string;
7
+ export default genEmptyProfileFile;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var fs_1 = __importDefault(require("fs"));
7
+ var path_1 = __importDefault(require("path"));
8
+ // Import shared helpers
9
+ var getRootPath_1 = __importDefault(require("../helpers/getRootPath"));
10
+ /**
11
+ * Generate an empty [Name].ts file at /cypress/profiles/[Name].Profile.ts
12
+ * @author Gabe Abrams
13
+ * @param name Name of the global file to create (without extension)
14
+ */
15
+ var genEmptyProfileFile = function (name) {
16
+ var root = (0, getRootPath_1.default)();
17
+ var profilesDir = path_1.default.join(root, 'cypress/profiles');
18
+ var outputFile = path_1.default.join(profilesDir, "".concat(name, ".Profile.ts"));
19
+ // Check if the directory exists
20
+ if (!fs_1.default.existsSync(profilesDir)) {
21
+ // Create the directory
22
+ fs_1.default.mkdirSync(profilesDir, { recursive: true });
23
+ }
24
+ // Create an empty file with a comment
25
+ var fileContents = [
26
+ '/**',
27
+ " * ".concat(name, " Profile"),
28
+ ' */',
29
+ '',
30
+ "const ".concat(name, "Profile = {"),
31
+ ' // Add profile values here',
32
+ '};',
33
+ '',
34
+ "export default ".concat(name, "Profile;"),
35
+ '',
36
+ ];
37
+ fs_1.default.writeFileSync(outputFile, fileContents.join('\n'), 'utf8');
38
+ return outputFile;
39
+ };
40
+ exports.default = genEmptyProfileFile;
41
+ //# sourceMappingURL=genEmptyProfileFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genEmptyProfileFile.js","sourceRoot":"","sources":["../../../setup/checkRequiredFiles/genEmptyProfileFile.ts"],"names":[],"mappings":";;;;;AAAA,0CAAoB;AACpB,8CAAwB;AAExB,wBAAwB;AACxB,uEAAiD;AAEjD;;;;GAIG;AACH,IAAM,mBAAmB,GAAG,UAAC,IAAY;IACvC,IAAM,IAAI,GAAG,IAAA,qBAAW,GAAE,CAAC;IAE3B,IAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACxD,IAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAG,IAAI,gBAAa,CAAC,CAAC;IAEhE,gCAAgC;IAChC,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAChC,uBAAuB;QACvB,YAAE,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,sCAAsC;IACtC,IAAM,YAAY,GAAG;QACnB,KAAK;QACL,aAAM,IAAI,aAAU;QACpB,KAAK;QACL,EAAE;QACF,gBAAS,IAAI,gBAAa;QAC1B,8BAA8B;QAC9B,IAAI;QACJ,EAAE;QACF,yBAAkB,IAAI,aAAU;QAChC,EAAE;KACH,CAAC;IACF,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IAE9D,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,kBAAe,mBAAmB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Ensure required configuration files exist in the consumer repo
3
+ * @author Yuen Ler Chow
4
+ */
5
+ declare const checkRequiredFiles: () => void;
6
+ export default checkRequiredFiles;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ // Import libs
7
+ var fs_1 = require("fs");
8
+ var path_1 = __importDefault(require("path"));
9
+ // Import shared helpers
10
+ var getRootPath_1 = __importDefault(require("../helpers/getRootPath"));
11
+ var genEmptyGlobalFile_1 = __importDefault(require("./genEmptyGlobalFile"));
12
+ var genEmptyProfileFile_1 = __importDefault(require("./genEmptyProfileFile"));
13
+ /**
14
+ * Ensure required configuration files exist in the consumer repo
15
+ * @author Yuen Ler Chow
16
+ */
17
+ var checkRequiredFiles = function () {
18
+ var root = (0, getRootPath_1.default)();
19
+ var globalsPath = path_1.default.join(root, 'cypress/globals');
20
+ var profilesPath = path_1.default.join(root, 'cypress/profiles');
21
+ // Common file extensions to check
22
+ var extensions = ['.js', '.ts', '.json', '.mjs', '.cjs'];
23
+ // Required global files
24
+ var requiredGlobals = [
25
+ 'GlobalCredentials',
26
+ 'GlobalResources',
27
+ 'GlobalValues',
28
+ ];
29
+ // Determine profile file name (default is stage)
30
+ var profileName = process.env.CYPRESS_PROFILE || 'Stage';
31
+ var requiredProfile = "".concat(profileName, ".Profile");
32
+ // Check global files
33
+ requiredGlobals.forEach(function (file) {
34
+ var filePath = path_1.default.join(globalsPath, file);
35
+ var found = extensions.some(function (ext) {
36
+ return (0, fs_1.existsSync)("".concat(filePath).concat(ext));
37
+ });
38
+ if (!found) {
39
+ // Create the file
40
+ (0, genEmptyGlobalFile_1.default)(file);
41
+ }
42
+ });
43
+ // Check profile file
44
+ var profileFilePath = path_1.default.join(profilesPath, requiredProfile);
45
+ var profileFound = extensions.some(function (ext) {
46
+ return (0, fs_1.existsSync)("".concat(profileFilePath).concat(ext));
47
+ });
48
+ if (!profileFound) {
49
+ (0, genEmptyProfileFile_1.default)(profileName);
50
+ }
51
+ };
52
+ exports.default = checkRequiredFiles;
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../setup/checkRequiredFiles/index.ts"],"names":[],"mappings":";;;;;AAAA,cAAc;AACd,yBAAgC;AAChC,8CAAwB;AAExB,wBAAwB;AACxB,uEAAiD;AACjD,4EAAsD;AACtD,8EAAwD;AAExD;;;GAGG;AACH,IAAM,kBAAkB,GAAG;IACzB,IAAM,IAAI,GAAG,IAAA,qBAAW,GAAE,CAAC;IAE3B,IAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACvD,IAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,k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-disable no-console */
7
7
  var fs_1 = require("fs");
8
8
  var path_1 = __importDefault(require("path"));
9
+ // Import shared helpers
9
10
  var getRootPath_1 = __importDefault(require("./helpers/getRootPath"));
10
11
  /**
11
12
  * Ensure required configuration files exist in the consumer repo
@@ -24,7 +25,7 @@ var checkRequiredFiles = function () {
24
25
  'GlobalValues',
25
26
  ];
26
27
  // Determine profile file name (default is stage)
27
- var profileName = process.env.CYPRESS_PROFILE || 'stage';
28
+ var profileName = process.env.CYPRESS_PROFILE || 'Stage';
28
29
  var requiredProfile = "".concat(profileName, ".Profile");
29
30
  // Check for missing files
30
31
  var missingFiles = [];
@@ -47,7 +48,7 @@ var checkRequiredFiles = function () {
47
48
  missingFiles.push("cypress/profiles/".concat(requiredProfile, ".ts"));
48
49
  }
49
50
  if (missingFiles.length > 0) {
50
- console.error('\nMissing required configuration files in this project:');
51
+ console.error('\nMissing required configuration files and/or profiles:');
51
52
  missingFiles.forEach(function (file) {
52
53
  console.error(" - ".concat(file));
53
54
  });
@@ -1 +1 @@
1
- {"version":3,"file":"checkRequiredFiles.js","sourceRoot":"","sources":["../../setup/checkRequiredFiles.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/B,yBAAgC;AAChC,8CAAwB;AACxB,sEAAgD;AAEhD;;;GAGG;AACH,IAAM,kBAAkB,GAAG;IACzB,IAAM,IAAI,GAAG,IAAA,qBAAW,GAAE,CAAC;IAE3B,IAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACvD,IAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IAEzD,kCAAkC;IAClC,IAAM,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE3D,wBAAwB;IACxB,IAAM,eAAe,GAAG;QACtB,mBAAmB;QACnB,iBAAiB;QACjB,cAAc;KAC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AAC,CAAC;QACH,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,YAAY,CAAC,IAAI,CAAC,0BAAmB,IAAI,QAAK,CAAC,CAAC;QAClD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,qBAAqB;IACrB,IAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IACjE,IAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC,UAAC,GAAG;QACvC,OAAO,IAAA,eAAU,EAAC,UAAG,eAAe,SAAG,GAAG,CAAE,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,CAAC,IAAI,CAAC,2BAAoB,eAAe,QAAK,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;QACzE,YAAY,CAAC,OAAO,CAAC,UAAC,IAAI;YACxB,OAAO,CAAC,KAAK,CAAC,cAAO,IAAI,CAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;QACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
@@ -19,6 +19,7 @@ var genE2ELaunchFile = function () {
19
19
  '// Auto-generated by dceky - do not edit manually',
20
20
  '',
21
21
  'import commands from \'dceky\';',
22
+ 'import \'./kyCommandDeclarations.ts\';',
22
23
  'import \'../commands\';',
23
24
  '',
24
25
  'commands();',
@@ -1 +1 @@
1
- {"version":3,"file":"genE2ELaunchFile.js","sourceRoot":"","sources":["../../setup/genE2ELaunchFile.ts"],"names":[],"mappings":";;;;;AAAA,0CAAoB;AACpB,8CAAwB;AACxB,sEAAgD;AAEhD;;;;GAIG;AACH,IAAM,gBAAgB,GAAG;IACvB,IAAM,IAAI,GAAG,IAAA,qBAAW,GAAE,CAAC;IAE3B,IAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;IAE9D,wCAAwC;IACxC,IAAM,UAAU,GAAG;QACjB,mDAAmD;QACnD,EAAE;QACF,iCAAiC;QACjC,yBAAyB;QACzB,EAAE;QACF,aAAa;QACb,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,wCAAwC;IACxC,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAEjD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"genE2ELaunchFile.js","sourceRoot":"","sources":["../../setup/genE2ELaunchFile.ts"],"names":[],"mappings":";;;;;AAAA,0CAAoB;AACpB,8CAAwB;AACxB,sEAAgD;AAEhD;;;;GAIG;AACH,IAAM,gBAAgB,GAAG;IACvB,IAAM,IAAI,GAAG,IAAA,qBAAW,GAAE,CAAC;IAE3B,IAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;IAE9D,wCAAwC;IACxC,IAAM,UAAU,GAAG;QACjB,mDAAmD;QACnD,EAAE;QACF,iCAAiC;QACjC,wCAAwC;QACxC,yBAAyB;QACzB,EAAE;QACF,aAAa;QACb,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,wCAAwC;IACxC,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAEjD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generate an empty [Name].ts file at /cypress/globals/[Name].ts
3
+ * @author Gabe Abrams
4
+ * @param name Name of the global file to create (without extension)
5
+ */
6
+ declare const genEmptyGlobalFile: (name: string) => string;
7
+ export default genEmptyGlobalFile;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var fs_1 = __importDefault(require("fs"));
7
+ var path_1 = __importDefault(require("path"));
8
+ // Import shared helpers
9
+ var getRootPath_1 = __importDefault(require("./helpers/getRootPath"));
10
+ /**
11
+ * Generate an empty [Name].ts file at /cypress/globals/[Name].ts
12
+ * @author Gabe Abrams
13
+ * @param name Name of the global file to create (without extension)
14
+ */
15
+ var genEmptyGlobalFile = function (name) {
16
+ var root = (0, getRootPath_1.default)();
17
+ var globalsDir = path_1.default.join(root, 'cypress/globals');
18
+ var outputFile = path_1.default.join(globalsDir, "".concat(name, ".ts"));
19
+ // Check if the directory exists
20
+ if (!fs_1.default.existsSync(globalsDir)) {
21
+ // Create the directory
22
+ fs_1.default.mkdirSync(globalsDir, { recursive: true });
23
+ }
24
+ // Create an empty file with a comment
25
+ var fileContents = [
26
+ '/**',
27
+ " * Global ".concat(name),
28
+ ' */',
29
+ '',
30
+ "const Global".concat(name, " = {"),
31
+ " // Add your global ".concat(name.toLowerCase(), " here"),
32
+ '};',
33
+ '',
34
+ "export default Global".concat(name, ";"),
35
+ '',
36
+ ];
37
+ fs_1.default.writeFileSync(outputFile, fileContents.join('\n'), 'utf8');
38
+ return outputFile;
39
+ };
40
+ exports.default = genEmptyGlobalFile;
41
+ //# sourceMappingURL=genEmptyGlobalFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genEmptyGlobalFile.js","sourceRoot":"","sources":["../../setup/genEmptyGlobalFile.ts"],"names":[],"mappings":";;;;;AAAA,0CAAoB;AACpB,8CAAwB;AAExB,wBAAwB;AACxB,sEAAgD;AAEhD;;;;GAIG;AACH,IAAM,kBAAkB,GAAG,UAAC,IAAY;IACtC,IAAM,IAAI,GAAG,IAAA,qBAAW,GAAE,CAAC;IAE3B,IAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACtD,IAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAG,IAAI,QAAK,CAAC,CAAC;IAEvD,gCAAgC;IAChC,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,uBAAuB;QACvB,YAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,sCAAsC;IACtC,IAAM,YAAY,GAAG;QACnB,KAAK;QACL,oBAAa,IAAI,CAAE;QACnB,KAAK;QACL,EAAE;QACF,sBAAe,IAAI,SAAM;QACzB,+BAAwB,IAAI,CAAC,WAAW,EAAE,UAAO;QACjD,IAAI;QACJ,EAAE;QACF,+BAAwB,IAAI,MAAG;QAC/B,EAAE;KACH,CAAC;IACF,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IAE9D,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generate a single, unified command declarations file for Ky functions
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const genKyCommandDeclarations: () => void;
6
+ export default genKyCommandDeclarations;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ // Import packages
16
+ var fs_1 = __importDefault(require("fs"));
17
+ var path_1 = __importDefault(require("path"));
18
+ // Import shared helpers
19
+ var getRootPath_1 = __importDefault(require("./helpers/getRootPath"));
20
+ /**
21
+ * Generate a single, unified command declarations file for Ky functions
22
+ * @author Gabe Abrams
23
+ */
24
+ var genKyCommandDeclarations = function () {
25
+ var root = (0, getRootPath_1.default)();
26
+ // Get paths
27
+ var kyCommandsDir = path_1.default.join(root, 'node_modules/dceky/src/commands');
28
+ var declarationsPath = path_1.default.join(root, 'cypress/e2e/kyCommandDeclarations.ts');
29
+ // Find all command files
30
+ var commandFiles = (fs_1.default
31
+ // Read all files in the commands directory
32
+ .readdirSync(kyCommandsDir)
33
+ // Only include .ts files
34
+ .filter(function (file) {
35
+ return file.endsWith('.ts');
36
+ })
37
+ // Exclude index file
38
+ .filter(function (file) {
39
+ return file !== 'index.ts';
40
+ }));
41
+ // Read the files, extract declarations
42
+ var unprocessedDeclarations = [];
43
+ for (var i = 0; i < commandFiles.length; i += 1) {
44
+ var file = commandFiles[i];
45
+ var filePath = path_1.default.join(kyCommandsDir, file);
46
+ var fileContents = fs_1.default.readFileSync(filePath, 'utf8');
47
+ // Extract declaration section
48
+ // Format:
49
+ // /*----------------------------------------*/
50
+ // /* ---------------- Type ---------------- */
51
+ // /*----------------------------------------*/
52
+ // [Declaration]
53
+ // /*----------------------------------------*/
54
+ // /* --------------- Command -------------- */
55
+ // /*----------------------------------------*/
56
+ var declarationMatch = fileContents.match(
57
+ // eslint-disable-next-line max-len
58
+ /\/\*[-]{40,}\*\/\s*\/\* [-]{16} Type [-]{16} \*\/\s*\/\*[-]{40,}\*\/\s*([\s\S]*?)\s*\/\*[-]{40,}\*\/\s*\/\* [-]{15} Command [-]{15} \*\/\s*\/\*[-]{40,}\*\//);
59
+ if (declarationMatch
60
+ && declarationMatch[1]
61
+ && declarationMatch[1].trim()) {
62
+ unprocessedDeclarations.push(declarationMatch[1].trim());
63
+ }
64
+ }
65
+ // Process each declaration
66
+ var processedDeclarations = unprocessedDeclarations.map(function (declaration) {
67
+ // Declaration is wrapped in:
68
+ // declare global {
69
+ // namespace Cypress {
70
+ // interface Chainable {
71
+ // [Processed Declaration]
72
+ // }
73
+ // }
74
+ // }
75
+ var match = declaration.match(/declare global \{\s*namespace Cypress \{\s*interface Chainable \{\s*([\s\S]*?)\s*\}\s*\}\s*\}/);
76
+ if (match && match[1] && match[1].trim()) {
77
+ return match[1].trim();
78
+ }
79
+ return '';
80
+ });
81
+ // Merge declarations into one and re-wrap
82
+ var finalDeclarations = __spreadArray(__spreadArray([
83
+ '/// <reference types="cypress" />',
84
+ '',
85
+ '// Auto-generated by dceky - do not edit manually',
86
+ '',
87
+ 'declare global {',
88
+ ' namespace Cypress {',
89
+ ' interface Chainable {'
90
+ ], processedDeclarations, true), [
91
+ ' }',
92
+ ' }',
93
+ '}',
94
+ '',
95
+ ], false).join('\n');
96
+ // Write to file
97
+ fs_1.default.writeFileSync(declarationsPath, finalDeclarations, 'utf8');
98
+ };
99
+ exports.default = genKyCommandDeclarations;
100
+ //# sourceMappingURL=genKyCommandDeclarations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genKyCommandDeclarations.js","sourceRoot":"","sources":["../../setup/genKyCommandDeclarations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kBAAkB;AAClB,0CAAoB;AACpB,8CAAwB;AAExB,wBAAwB;AACxB,sEAAgD;AAEhD;;;GAGG;AACH,IAAM,wBAAwB,GAAG;IAC/B,IAAM,IAAI,GAAG,IAAA,qBAAW,GAAE,CAAC;IAE3B,YAAY;IACZ,IAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,iCAAiC,CAAC,CAAC;IACzE,IAAM,gBAAgB,GAAG,cAAI,CAAC,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,uBAAuB,CAAC,GAAG,CAAC,UAAC,WAAW;QACpE,6BAA6B;QAC7B,mBAAmB;QACnB,wBAAwB;QACxB,4BAA4B;QAC5B,gCAAgC;QAChC,QAAQ;QACR,MAAM;QACN,IAAI;QACJ,IAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAC7B,+FAA+F,CAChG,CAAC;QACF,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACzC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACzB,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,0CAA0C;IAC1C,IAAM,iBAAiB,GAAG;QACxB,mCAAmC;QACnC,EAAE;QACF,mDAAmD;QACnD,EAAE;QACF,kBAAkB;QAClB,uBAAuB;QACvB,2BAA2B;OAExB,qBAAqB;QACxB,OAAO;QACP,KAAK;QACL,GAAG;QACH,EAAE;cACF,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,gBAAgB;IAChB,YAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;AAChE,CAAC,CAAC;AAEF,kBAAe,wBAAwB,CAAC"}
@@ -9,10 +9,12 @@ var addToGitIgnore_1 = __importDefault(require("./addToGitIgnore"));
9
9
  var setupCypressDependencies_1 = __importDefault(require("./setupCypressDependencies"));
10
10
  var checkRequiredFiles_1 = __importDefault(require("./checkRequiredFiles"));
11
11
  var genE2ELaunchFile_1 = __importDefault(require("./genE2ELaunchFile"));
12
+ var genKyCommandDeclarations_1 = __importDefault(require("./genKyCommandDeclarations"));
12
13
  (0, checkRequiredFiles_1.default)();
13
14
  (0, genCommandImportFile_1.default)();
14
15
  (0, genDynamicConfigFile_1.default)();
15
16
  (0, addToGitIgnore_1.default)();
16
17
  (0, setupCypressDependencies_1.default)();
17
18
  (0, genE2ELaunchFile_1.default)();
19
+ (0, genKyCommandDeclarations_1.default)();
18
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../setup/index.ts"],"names":[],"mappings":";;;;;AAAA,gFAA0D;AAC1D,gFAA0D;AAC1D,oEAA8C;AAC9C,wFAAkE;AAClE,4EAAsD;AACtD,wEAAkD;AAElD,IAAA,4BAAkB,GAAE,CAAC;AACrB,IAAA,8BAAoB,GAAE,CAAC;AACvB,IAAA,8BAAoB,GAAE,CAAC;AACvB,IAAA,wBAAc,GAAE,CAAC;AACjB,IAAA,kCAAwB,GAAE,CAAC;AAC3B,IAAA,0BAAgB,GAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../setup/index.ts"],"names":[],"mappings":";;;;;AAAA,gFAA0D;AAC1D,gFAA0D;AAC1D,oEAA8C;AAC9C,wFAAkE;AAClE,4EAAsD;AACtD,wEAAkD;AAClD,wFAAkE;AAElE,IAAA,4BAAkB,GAAE,CAAC;AACrB,IAAA,8BAAoB,GAAE,CAAC;AACvB,IAAA,8BAAoB,GAAE,CAAC;AACvB,IAAA,wBAAc,GAAE,CAAC;AACjB,IAAA,kCAAwB,GAAE,CAAC;AAC3B,IAAA,0BAAgB,GAAE,CAAC;AACnB,IAAA,kCAAwB,GAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dceky",
3
- "version": "1.0.4-beta.new-divided-export.6",
3
+ "version": "1.0.5-beta.ky-declarations.2",
4
4
  "description": "Cypress toolkit for Harvard DCE",
5
5
  "main": "./lib/src/index.js",
6
6
  "types": "./lib/src/index.d.ts",
@@ -0,0 +1,42 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ // Import shared helpers
5
+ import getRootPath from '../helpers/getRootPath';
6
+
7
+ /**
8
+ * Generate an empty [Name].ts file at /cypress/globals/[Name].ts
9
+ * @author Gabe Abrams
10
+ * @param name Name of the global file to create (without extension)
11
+ */
12
+ const genEmptyGlobalFile = (name: string): string => {
13
+ const root = getRootPath();
14
+
15
+ const globalsDir = path.join(root, 'cypress/globals');
16
+ const outputFile = path.join(globalsDir, `Global${name}.ts`);
17
+
18
+ // Check if the directory exists
19
+ if (!fs.existsSync(globalsDir)) {
20
+ // Create the directory
21
+ fs.mkdirSync(globalsDir, { recursive: true });
22
+ }
23
+
24
+ // Create an empty file with a comment
25
+ const fileContents = [
26
+ '/**',
27
+ ` * Global ${name}`,
28
+ ' */',
29
+ '',
30
+ `const Global${name} = {`,
31
+ ` // Add your global ${name.toLowerCase()} here`,
32
+ '};',
33
+ '',
34
+ `export default Global${name};`,
35
+ '',
36
+ ];
37
+ fs.writeFileSync(outputFile, fileContents.join('\n'), 'utf8');
38
+
39
+ return outputFile;
40
+ };
41
+
42
+ export default genEmptyGlobalFile;
@@ -0,0 +1,42 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ // Import shared helpers
5
+ import getRootPath from '../helpers/getRootPath';
6
+
7
+ /**
8
+ * Generate an empty [Name].ts file at /cypress/profiles/[Name].Profile.ts
9
+ * @author Gabe Abrams
10
+ * @param name Name of the global file to create (without extension)
11
+ */
12
+ const genEmptyProfileFile = (name: string): string => {
13
+ const root = getRootPath();
14
+
15
+ const profilesDir = path.join(root, 'cypress/profiles');
16
+ const outputFile = path.join(profilesDir, `${name}.Profile.ts`);
17
+
18
+ // Check if the directory exists
19
+ if (!fs.existsSync(profilesDir)) {
20
+ // Create the directory
21
+ fs.mkdirSync(profilesDir, { recursive: true });
22
+ }
23
+
24
+ // Create an empty file with a comment
25
+ const fileContents = [
26
+ '/**',
27
+ ` * ${name} Profile`,
28
+ ' */',
29
+ '',
30
+ `const ${name}Profile = {`,
31
+ ' // Add profile values here',
32
+ '};',
33
+ '',
34
+ `export default ${name}Profile;`,
35
+ '',
36
+ ];
37
+ fs.writeFileSync(outputFile, fileContents.join('\n'), 'utf8');
38
+
39
+ return outputFile;
40
+ };
41
+
42
+ export default genEmptyProfileFile;
@@ -1,7 +1,11 @@
1
- /* eslint-disable no-console */
1
+ // Import libs
2
2
  import { existsSync } from 'fs';
3
3
  import path from 'path';
4
- import getRootPath from './helpers/getRootPath';
4
+
5
+ // Import shared helpers
6
+ import getRootPath from '../helpers/getRootPath';
7
+ import genEmptyGlobalFile from './genEmptyGlobalFile';
8
+ import genEmptyProfileFile from './genEmptyProfileFile';
5
9
 
6
10
  /**
7
11
  * Ensure required configuration files exist in the consumer repo
@@ -24,12 +28,9 @@ const checkRequiredFiles = (): void => {
24
28
  ];
25
29
 
26
30
  // Determine profile file name (default is stage)
27
- const profileName = process.env.CYPRESS_PROFILE || 'stage';
31
+ const profileName = process.env.CYPRESS_PROFILE || 'Stage';
28
32
  const requiredProfile = `${profileName}.Profile`;
29
33
 
30
- // Check for missing files
31
- const missingFiles: string[] = [];
32
-
33
34
  // Check global files
34
35
  requiredGlobals.forEach((file) => {
35
36
  const filePath = path.join(globalsPath, file);
@@ -37,7 +38,8 @@ const checkRequiredFiles = (): void => {
37
38
  return existsSync(`${filePath}${ext}`);
38
39
  });
39
40
  if (!found) {
40
- missingFiles.push(`cypress/globals/${file}.ts`);
41
+ // Create the file
42
+ genEmptyGlobalFile(file);
41
43
  }
42
44
  });
43
45
 
@@ -47,16 +49,7 @@ const checkRequiredFiles = (): void => {
47
49
  return existsSync(`${profileFilePath}${ext}`);
48
50
  });
49
51
  if (!profileFound) {
50
- missingFiles.push(`cypress/profiles/${requiredProfile}.ts`);
51
- }
52
-
53
- if (missingFiles.length > 0) {
54
- console.error('\nMissing required configuration files in this project:');
55
- missingFiles.forEach((file) => {
56
- console.error(` - ${file}`);
57
- });
58
- console.error('\nPlease create these files before running setup.');
59
- process.exit(1);
52
+ genEmptyProfileFile(profileName);
60
53
  }
61
54
  };
62
55
 
@@ -17,6 +17,7 @@ const genE2ELaunchFile = (): string => {
17
17
  '// Auto-generated by dceky - do not edit manually',
18
18
  '',
19
19
  'import commands from \'dceky\';',
20
+ 'import \'./kyCommandDeclarations.ts\';',
20
21
  'import \'../commands\';',
21
22
  '',
22
23
  'commands();',
@@ -0,0 +1,103 @@
1
+ // Import packages
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ // Import shared helpers
6
+ import getRootPath from './helpers/getRootPath';
7
+
8
+ /**
9
+ * Generate a single, unified command declarations file for Ky functions
10
+ * @author Gabe Abrams
11
+ */
12
+ const genKyCommandDeclarations = () => {
13
+ const root = getRootPath();
14
+
15
+ // Get paths
16
+ const kyCommandsDir = path.join(root, 'node_modules/dceky/src/commands');
17
+ const declarationsPath = path.join(root, 'cypress/e2e/kyCommandDeclarations.ts');
18
+
19
+ // Find all command files
20
+ const commandFiles = (
21
+ fs
22
+ // Read all files in the commands directory
23
+ .readdirSync(kyCommandsDir)
24
+ // Only include .ts files
25
+ .filter((file) => {
26
+ return file.endsWith('.ts');
27
+ })
28
+ // Exclude index file
29
+ .filter((file) => {
30
+ return file !== 'index.ts';
31
+ })
32
+ );
33
+
34
+ // Read the files, extract declarations
35
+ const unprocessedDeclarations: string[] = [];
36
+ for (let i = 0; i < commandFiles.length; i += 1) {
37
+ const file = commandFiles[i];
38
+ const filePath = path.join(kyCommandsDir, file);
39
+ const fileContents = fs.readFileSync(filePath, 'utf8');
40
+
41
+ // Extract declaration section
42
+ // Format:
43
+ // /*----------------------------------------*/
44
+ // /* ---------------- Type ---------------- */
45
+ // /*----------------------------------------*/
46
+ // [Declaration]
47
+ // /*----------------------------------------*/
48
+ // /* --------------- Command -------------- */
49
+ // /*----------------------------------------*/
50
+ const declarationMatch = fileContents.match(
51
+ // eslint-disable-next-line max-len
52
+ /\/\*[-]{40,}\*\/\s*\/\* [-]{16} Type [-]{16} \*\/\s*\/\*[-]{40,}\*\/\s*([\s\S]*?)\s*\/\*[-]{40,}\*\/\s*\/\* [-]{15} Command [-]{15} \*\/\s*\/\*[-]{40,}\*\//,
53
+ );
54
+ if (
55
+ declarationMatch
56
+ && declarationMatch[1]
57
+ && declarationMatch[1].trim()
58
+ ) {
59
+ unprocessedDeclarations.push(declarationMatch[1].trim());
60
+ }
61
+ }
62
+
63
+ // Process each declaration
64
+ const processedDeclarations = unprocessedDeclarations.map((declaration) => {
65
+ // Declaration is wrapped in:
66
+ // declare global {
67
+ // namespace Cypress {
68
+ // interface Chainable {
69
+ // [Processed Declaration]
70
+ // }
71
+ // }
72
+ // }
73
+ const match = declaration.match(
74
+ /declare global \{\s*namespace Cypress \{\s*interface Chainable \{\s*([\s\S]*?)\s*\}\s*\}\s*\}/,
75
+ );
76
+ if (match && match[1] && match[1].trim()) {
77
+ return match[1].trim();
78
+ }
79
+ return '';
80
+ });
81
+
82
+ // Merge declarations into one and re-wrap
83
+ const finalDeclarations = [
84
+ '/// <reference types="cypress" />',
85
+ '',
86
+ '// Auto-generated by dceky - do not edit manually',
87
+ '',
88
+ 'declare global {',
89
+ ' namespace Cypress {',
90
+ ' interface Chainable {',
91
+ // Indent each declaration by 6 spaces
92
+ ...processedDeclarations,
93
+ ' }',
94
+ ' }',
95
+ '}',
96
+ '',
97
+ ].join('\n');
98
+
99
+ // Write to file
100
+ fs.writeFileSync(declarationsPath, finalDeclarations, 'utf8');
101
+ };
102
+
103
+ export default genKyCommandDeclarations;
package/setup/index.ts CHANGED
@@ -4,6 +4,7 @@ import addToGitIgnore from './addToGitIgnore';
4
4
  import setupCypressDependencies from './setupCypressDependencies';
5
5
  import checkRequiredFiles from './checkRequiredFiles';
6
6
  import genE2ELaunchFile from './genE2ELaunchFile';
7
+ import genKyCommandDeclarations from './genKyCommandDeclarations';
7
8
 
8
9
  checkRequiredFiles();
9
10
  genCommandImportFile();
@@ -11,3 +12,4 @@ genDynamicConfigFile();
11
12
  addToGitIgnore();
12
13
  setupCypressDependencies();
13
14
  genE2ELaunchFile();
15
+ genKyCommandDeclarations();