dceky 1.0.4-beta.new-divided-export.6 → 1.0.5-beta.ky-declarations.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.
@@ -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,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,IAAI,CAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;IAEjF,yBAAyB;IACzB,IAAM,YAAY,GAAG,CACnB,YAAE;QACA,2CAA2C;SAC1C,WAAW,CAAC,aAAa,CAAC;QAC3B,yBAAyB;SACxB,MAAM,CAAC,UAAC,IAAI;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC;QACF,qBAAqB;SACpB,MAAM,CAAC,UAAC,IAAI;QACX,OAAO,IAAI,KAAK,UAAU,CAAC;IAC7B,CAAC,CAAC,CACL,CAAC;IAEF,uCAAuC;IACvC,IAAM,uBAAuB,GAAa,EAAE,CAAC;IAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAA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C1C,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.1",
4
4
  "description": "Cypress toolkit for Harvard DCE",
5
5
  "main": "./lib/src/index.js",
6
6
  "types": "./lib/src/index.d.ts",
@@ -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();