@neurodevs/meta-node 0.9.2 → 0.10.0
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/build/__tests__/AbstractAutomoduleTest.d.ts +2 -0
- package/build/__tests__/AbstractAutomoduleTest.js +13 -0
- package/build/__tests__/AbstractAutomoduleTest.js.map +1 -1
- package/build/__tests__/modules/ImplAutomodule.test.d.ts +1 -2
- package/build/__tests__/modules/ImplAutomodule.test.js +7 -21
- package/build/__tests__/modules/ImplAutomodule.test.js.map +1 -1
- package/build/__tests__/modules/UiAutomodule.test.d.ts +4 -0
- package/build/__tests__/modules/UiAutomodule.test.js +52 -0
- package/build/__tests__/modules/UiAutomodule.test.js.map +1 -1
- package/build/modules/AbstractAutomodule.d.ts +14 -1
- package/build/modules/AbstractAutomodule.js +37 -1
- package/build/modules/AbstractAutomodule.js.map +1 -1
- package/build/modules/ImplAutomodule.d.ts +1 -14
- package/build/modules/ImplAutomodule.js +1 -41
- package/build/modules/ImplAutomodule.js.map +1 -1
- package/build/modules/UiAutomodule.d.ts +2 -1
- package/build/modules/UiAutomodule.js +13 -0
- package/build/modules/UiAutomodule.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/AbstractAutomoduleTest.ts +21 -1
- package/src/__tests__/modules/ImplAutomodule.test.ts +7 -30
- package/src/__tests__/modules/UiAutomodule.test.ts +72 -1
- package/src/modules/AbstractAutomodule.ts +52 -1
- package/src/modules/ImplAutomodule.ts +2 -57
- package/src/modules/UiAutomodule.ts +15 -4
|
@@ -12,6 +12,8 @@ export default class AbstractAutomoduleTest extends AbstractPackageTest {
|
|
|
12
12
|
protected static readonly moduleSaveDir: string;
|
|
13
13
|
protected static readonly fakeSaveDir: string;
|
|
14
14
|
protected static readonly indexFilePath = "./src/index.ts";
|
|
15
|
+
protected static setFakeExec(): void;
|
|
15
16
|
protected static setFakePathExists(): void;
|
|
17
|
+
protected static setFakeReadFile(): void;
|
|
16
18
|
protected static setFakeWriteFile(): void;
|
|
17
19
|
}
|
|
@@ -3,14 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const util_1 = require("util");
|
|
6
8
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
7
9
|
const fake_node_core_1 = require("@neurodevs/fake-node-core");
|
|
8
10
|
const AbstractAutomodule_1 = __importDefault(require("../modules/AbstractAutomodule"));
|
|
9
11
|
const AbstractPackageTest_1 = __importDefault(require("./AbstractPackageTest"));
|
|
12
|
+
const exec = (0, util_1.promisify)(child_process_1.exec);
|
|
10
13
|
class AbstractAutomoduleTest extends AbstractPackageTest_1.default {
|
|
11
14
|
static async beforeEach() {
|
|
12
15
|
await super.beforeEach();
|
|
16
|
+
this.setFakeExec();
|
|
13
17
|
this.setFakePathExists();
|
|
18
|
+
this.setFakeReadFile();
|
|
14
19
|
this.setFakeWriteFile();
|
|
15
20
|
}
|
|
16
21
|
static async runAbstractTests() {
|
|
@@ -35,6 +40,10 @@ class AbstractAutomoduleTest extends AbstractPackageTest_1.default {
|
|
|
35
40
|
static async run() {
|
|
36
41
|
return this.instance.run();
|
|
37
42
|
}
|
|
43
|
+
static setFakeExec() {
|
|
44
|
+
AbstractAutomodule_1.default.exec = fake_node_core_1.fakeExec;
|
|
45
|
+
(0, fake_node_core_1.resetCallsToExec)();
|
|
46
|
+
}
|
|
38
47
|
static setFakePathExists() {
|
|
39
48
|
AbstractAutomodule_1.default.pathExists = fake_node_core_1.fakePathExists;
|
|
40
49
|
(0, fake_node_core_1.setPathShouldExist)(this.testSaveDir, true);
|
|
@@ -43,6 +52,10 @@ class AbstractAutomoduleTest extends AbstractPackageTest_1.default {
|
|
|
43
52
|
(0, fake_node_core_1.setPathShouldExist)(this.indexFilePath, true);
|
|
44
53
|
(0, fake_node_core_1.resetCallsToPathExists)();
|
|
45
54
|
}
|
|
55
|
+
static setFakeReadFile() {
|
|
56
|
+
AbstractAutomodule_1.default.readFile = fake_node_core_1.fakeReadFile;
|
|
57
|
+
(0, fake_node_core_1.resetCallsToReadFile)();
|
|
58
|
+
}
|
|
46
59
|
static setFakeWriteFile() {
|
|
47
60
|
AbstractAutomodule_1.default.writeFile = fake_node_core_1.fakeWriteFile;
|
|
48
61
|
(0, fake_node_core_1.resetCallsToWriteFile)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractAutomoduleTest.js","sourceRoot":"","sources":["../../src/__tests__/AbstractAutomoduleTest.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"AbstractAutomoduleTest.js","sourceRoot":"","sources":["../../src/__tests__/AbstractAutomoduleTest.ts"],"names":[],"mappings":";;;;;AAAA,iDAAgD;AAEhD,+BAAgC;AAChC,uDAA2D;AAC3D,8DAUkC;AAClC,uFAA8D;AAE9D,gFAAuD;AAEvD,MAAM,IAAI,GAAG,IAAA,gBAAS,EAAC,oBAAQ,CAAC,CAAA;AAEhC,MAAqB,sBAAuB,SAAQ,6BAAmB;IAGzD,MAAM,CAAC,KAAK,CAAC,UAAU;QAC7B,MAAM,KAAK,CAAC,UAAU,EAAE,CAAA;QAExB,IAAI,CAAC,WAAW,EAAE,CAAA;QAClB,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACxB,IAAI,CAAC,eAAe,EAAE,CAAA;QACtB,IAAI,CAAC,gBAAgB,EAAE,CAAA;IAC3B,CAAC;IAES,MAAM,CAAC,KAAK,CAAC,gBAAgB;QACnC,MAAM,IAAI,CAAC,6BAA6B,EAAE,CAAA;QAC1C,MAAM,IAAI,CAAC,+BAA+B,EAAE,CAAA;QAC5C,MAAM,IAAI,CAAC,6BAA6B,EAAE,CAAA;IAC9C,CAAC;IAES,MAAM,CAAC,KAAK,CAAC,6BAA6B;QAChD,IAAA,mCAAkB,EA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IAAA,mCAAkB,EAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;QAC5C,IAAA,mCAAkB,EAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;QAC1C,IAAA,mCAAkB,EAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;QAE5C,IAAA,uCAAsB,GAAE,CAAA;IAC5B,CAAC;IAES,MAAM,CAAC,eAAe;QAC5B,4BAAkB,CAAC,QAAQ,GAAG,6BAA0C,CAAA;QACxE,IAAA,qCAAoB,GAAE,CAAA;IAC1B,CAAC;IAES,MAAM,CAAC,gBAAgB;QAC7B,4BAAkB,CAAC,SAAS,GAAG,8BAAiC,CAAA;QAChE,IAAA,sCAAqB,GAAE,CAAA;IAC3B,CAAC;;AA7ByB,kCAAW,GAAG,IAAA,uBAAU,GAAE,CAAA;AAC1B,oCAAa,GAAG,IAAA,uBAAU,GAAE,CAAA;AAC5B,kCAAW,GAAG,IAAA,uBAAU,GAAE,CAAA;AAC1B,oCAAa,GAAG,gBAAgB,CAAA;kBAtDzC,sBAAsB"}
|
|
@@ -8,8 +8,7 @@ export default class ImplAutomoduleTest extends AbstractAutomoduleTest {
|
|
|
8
8
|
protected static createsFakeFileAsExpected(): Promise<void>;
|
|
9
9
|
protected static sortsIndexFileExportsAlphabetically(): Promise<void>;
|
|
10
10
|
protected static bumpsMinorVersionWithYarn(): Promise<void>;
|
|
11
|
-
private static
|
|
12
|
-
private static setFakeReadFile;
|
|
11
|
+
private static readonly originalIndexFile;
|
|
13
12
|
private static readonly interfaceName;
|
|
14
13
|
private static readonly implName;
|
|
15
14
|
private static get testFilePattern();
|
|
@@ -9,18 +9,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const child_process_1 = require("child_process");
|
|
13
|
-
const util_1 = require("util");
|
|
14
12
|
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
15
13
|
const fake_node_core_1 = require("@neurodevs/fake-node-core");
|
|
16
14
|
const ImplAutomodule_1 = __importDefault(require("../../modules/ImplAutomodule"));
|
|
17
15
|
const AbstractAutomoduleTest_1 = __importDefault(require("../AbstractAutomoduleTest"));
|
|
18
|
-
const exec = (0, util_1.promisify)(child_process_1.exec);
|
|
19
16
|
class ImplAutomoduleTest extends AbstractAutomoduleTest_1.default {
|
|
20
17
|
static async beforeEach() {
|
|
21
18
|
await super.beforeEach();
|
|
22
|
-
this.setFakeExec();
|
|
23
|
-
this.setFakeReadFile();
|
|
24
19
|
this.instance = this.ImplAutomodule();
|
|
25
20
|
}
|
|
26
21
|
static async passesAbstractTests() {
|
|
@@ -56,11 +51,7 @@ class ImplAutomoduleTest extends AbstractAutomoduleTest_1.default {
|
|
|
56
51
|
}, 'Did not write expected fake file!');
|
|
57
52
|
}
|
|
58
53
|
static async sortsIndexFileExportsAlphabetically() {
|
|
59
|
-
(0, fake_node_core_1.setFakeReadFileResult)(
|
|
60
|
-
// A-${fake_node_core_1.fakeReadFileResult}
|
|
61
|
-
|
|
62
|
-
// C-${fake_node_core_1.fakeReadFileResult}
|
|
63
|
-
`);
|
|
54
|
+
(0, fake_node_core_1.setFakeReadFileResult)(this.originalIndexFile);
|
|
64
55
|
await this.run();
|
|
65
56
|
const call = fake_node_core_1.callsToWriteFile[3];
|
|
66
57
|
test_utils_1.assert.isEqualDeep({
|
|
@@ -75,14 +66,6 @@ class ImplAutomoduleTest extends AbstractAutomoduleTest_1.default {
|
|
|
75
66
|
await this.run();
|
|
76
67
|
test_utils_1.assert.isEqualDeep(fake_node_core_1.callsToExec[0], 'yarn version --minor --no-git-tag-version', 'Did not bump minor version!');
|
|
77
68
|
}
|
|
78
|
-
static setFakeExec() {
|
|
79
|
-
ImplAutomodule_1.default.exec = fake_node_core_1.fakeExec;
|
|
80
|
-
(0, fake_node_core_1.resetCallsToExec)();
|
|
81
|
-
}
|
|
82
|
-
static setFakeReadFile() {
|
|
83
|
-
ImplAutomodule_1.default.readFile = fake_node_core_1.fakeReadFile;
|
|
84
|
-
(0, fake_node_core_1.resetCallsToReadFile)();
|
|
85
|
-
}
|
|
86
69
|
static get testFilePattern() {
|
|
87
70
|
return `
|
|
88
71
|
import AbstractSpruceTest, { test, assert } from '@sprucelabs/test-utils'
|
|
@@ -144,8 +127,6 @@ class ImplAutomoduleTest extends AbstractAutomoduleTest_1.default {
|
|
|
144
127
|
}
|
|
145
128
|
static get indexFilePattern() {
|
|
146
129
|
return `
|
|
147
|
-
${fake_node_core_1.fakeReadFileResult}
|
|
148
|
-
|
|
149
130
|
// ${this.interfaceName}
|
|
150
131
|
|
|
151
132
|
export { default as ${this.implName} } from './modules/${this.implName}'
|
|
@@ -157,7 +138,7 @@ class ImplAutomoduleTest extends AbstractAutomoduleTest_1.default {
|
|
|
157
138
|
`;
|
|
158
139
|
}
|
|
159
140
|
static get sortedIndexFile() {
|
|
160
|
-
const blocks = this.indexFilePattern
|
|
141
|
+
const blocks = `${this.originalIndexFile}${this.indexFilePattern}`
|
|
161
142
|
.split(/(?=\/\/)/)
|
|
162
143
|
.map((s) => s.trim())
|
|
163
144
|
.filter(Boolean);
|
|
@@ -178,6 +159,11 @@ class ImplAutomoduleTest extends AbstractAutomoduleTest_1.default {
|
|
|
178
159
|
});
|
|
179
160
|
}
|
|
180
161
|
}
|
|
162
|
+
ImplAutomoduleTest.originalIndexFile = `
|
|
163
|
+
// C-${(0, test_utils_1.generateId)()}
|
|
164
|
+
|
|
165
|
+
// A-${(0, test_utils_1.generateId)()}
|
|
166
|
+
`;
|
|
181
167
|
ImplAutomoduleTest.interfaceName = `B-${(0, test_utils_1.generateId)()}`;
|
|
182
168
|
ImplAutomoduleTest.implName = (0, test_utils_1.generateId)();
|
|
183
169
|
exports.default = ImplAutomoduleTest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImplAutomodule.test.js","sourceRoot":"","sources":["../../../src/__tests__/modules/ImplAutomodule.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"ImplAutomodule.test.js","sourceRoot":"","sources":["../../../src/__tests__/modules/ImplAutomodule.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uDAAiE;AACjE,8DAIkC;AAClC,kFAAyD;AACzD,uFAA8D;AAE9D,MAAqB,kBAAmB,SAAQ,gCAAsB;IACxD,MAAM,CAAC,KAAK,CAAC,UAAU;QAC7B,MAAM,KAAK,CAAC,UAAU,EAAE,CAAA;QAExB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;IACzC,CAAC;IAGsB,AAAb,MAAM,CAAC,KAAK,CAAC,mBAAmB;QACtC,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAA;IACjC,CAAC;IAGsB,AAAb,MAAM,CAAC,KAAK,CAAC,eAAe;QAClC,mBAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAA;IAChE,CAAC;IAGsB,AAAb,MAAM,CAAC,KAAK,CAAC,yBAAyB;QAC5C,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;QAEhB,mBAAM,CAAC,WAAW,CACd;YACI,IAAI,EAAE,iCAAgB,CAAC,CAAC,CAAC,CAAC,IAAI;YAC9B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,iCAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;SACjD,EACD;YACI,IAAI,EAAE,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,QAAQ,UAAU;YACpD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC;SAC7C,EACD,mCAAmC,CACtC,CAAA;IACL,CAAC;IAGsB,AAAb,MAAM,CAAC,KAAK,CAAC,2BAA2B;QAC9C,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;QAE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;yDAaN;AAGsB;IADtB,IAAA,iBAAI,GAAE;mEAmBN;AAGsB;IADtB,IAAA,iBAAI,GAAE;yDASN"}
|
|
@@ -6,11 +6,15 @@ export default class UiAutomoduleTest extends AbstractAutomoduleTest {
|
|
|
6
6
|
protected static createsTestFileAsExpected(): Promise<void>;
|
|
7
7
|
protected static createsModuleFileAsExpected(): Promise<void>;
|
|
8
8
|
protected static createsFakeFileAsExpected(): Promise<void>;
|
|
9
|
+
protected static updatesIndexFileExportsAndSortsAlphabetically(): Promise<void>;
|
|
10
|
+
protected static bumpsMinorVersionWithYarn(): Promise<void>;
|
|
9
11
|
private static readonly componentName;
|
|
10
12
|
private static readonly componentNameKebabCase;
|
|
11
13
|
private static get testFilePattern();
|
|
12
14
|
private static get moduleFilePattern();
|
|
13
15
|
private static get fakeFilePattern();
|
|
16
|
+
private static get indexFilePattern();
|
|
17
|
+
private static get sortedIndexFile();
|
|
14
18
|
private static toKebabCase;
|
|
15
19
|
private static UiAutomodule;
|
|
16
20
|
}
|
|
@@ -49,6 +49,26 @@ class UiAutomoduleTest extends AbstractAutomoduleTest_1.default {
|
|
|
49
49
|
options: undefined,
|
|
50
50
|
}, 'Did not write expected module file!');
|
|
51
51
|
}
|
|
52
|
+
static async updatesIndexFileExportsAndSortsAlphabetically() {
|
|
53
|
+
(0, fake_node_core_1.setFakeReadFileResult)(`
|
|
54
|
+
// C-${fake_node_core_1.fakeReadFileResult}
|
|
55
|
+
|
|
56
|
+
// A-${fake_node_core_1.fakeReadFileResult}
|
|
57
|
+
`);
|
|
58
|
+
await this.run();
|
|
59
|
+
const call = fake_node_core_1.callsToWriteFile[3];
|
|
60
|
+
test_utils_1.assert.isEqualDeep({
|
|
61
|
+
file: call.file,
|
|
62
|
+
data: this.normalize(call.data),
|
|
63
|
+
}, {
|
|
64
|
+
file: this.indexFilePath,
|
|
65
|
+
data: this.normalize(this.sortedIndexFile),
|
|
66
|
+
}, 'Did not update index file exports as expected!');
|
|
67
|
+
}
|
|
68
|
+
static async bumpsMinorVersionWithYarn() {
|
|
69
|
+
await this.run();
|
|
70
|
+
test_utils_1.assert.isEqualDeep(fake_node_core_1.callsToExec[0], 'yarn version --minor --no-git-tag-version', 'Did not bump minor version!');
|
|
71
|
+
}
|
|
52
72
|
static get testFilePattern() {
|
|
53
73
|
return `
|
|
54
74
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
@@ -134,6 +154,32 @@ class UiAutomoduleTest extends AbstractAutomoduleTest_1.default {
|
|
|
134
154
|
export default Fake${this.componentName}
|
|
135
155
|
`;
|
|
136
156
|
}
|
|
157
|
+
static get indexFilePattern() {
|
|
158
|
+
return `
|
|
159
|
+
${fake_node_core_1.fakeReadFileResult}
|
|
160
|
+
|
|
161
|
+
// ${this.componentName}
|
|
162
|
+
|
|
163
|
+
export { default as ${this.componentName} } from './ui/${this.componentName}'
|
|
164
|
+
export * from './ui/${this.componentName}'
|
|
165
|
+
|
|
166
|
+
export { default as Fake${this.componentName} } from './testDoubles/${this.componentName}/Fake${this.componentName}'
|
|
167
|
+
export * from './testDoubles/${this.componentName}/Fake${this.componentName}'
|
|
168
|
+
|
|
169
|
+
`;
|
|
170
|
+
}
|
|
171
|
+
static get sortedIndexFile() {
|
|
172
|
+
const blocks = this.indexFilePattern
|
|
173
|
+
.split(/(?=\/\/)/)
|
|
174
|
+
.map((s) => s.trim())
|
|
175
|
+
.filter(Boolean);
|
|
176
|
+
blocks.sort((a, b) => {
|
|
177
|
+
const aKey = a.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? '';
|
|
178
|
+
const bKey = b.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? '';
|
|
179
|
+
return aKey.localeCompare(bKey);
|
|
180
|
+
});
|
|
181
|
+
return blocks.join('\n\n');
|
|
182
|
+
}
|
|
137
183
|
static toKebabCase(str) {
|
|
138
184
|
return str
|
|
139
185
|
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
@@ -168,4 +214,10 @@ __decorate([
|
|
|
168
214
|
__decorate([
|
|
169
215
|
(0, test_utils_1.test)()
|
|
170
216
|
], UiAutomoduleTest, "createsFakeFileAsExpected", null);
|
|
217
|
+
__decorate([
|
|
218
|
+
(0, test_utils_1.test)()
|
|
219
|
+
], UiAutomoduleTest, "updatesIndexFileExportsAndSortsAlphabetically", null);
|
|
220
|
+
__decorate([
|
|
221
|
+
(0, test_utils_1.test)()
|
|
222
|
+
], UiAutomoduleTest, "bumpsMinorVersionWithYarn", null);
|
|
171
223
|
//# sourceMappingURL=UiAutomodule.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiAutomodule.test.js","sourceRoot":"","sources":["../../../src/__tests__/modules/UiAutomodule.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"UiAutomodule.test.js","sourceRoot":"","sources":["../../../src/__tests__/modules/UiAutomodule.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAiE;AACjE,8DAKkC;AAClC,8EAAqD;AACrD,uFAA8D;AAE9D,MAAqB,gBAAiB,SAAQ,gCAAsB;IACtD,MAAM,CAAC,KAAK,CAAC,UAAU;QAC7B,MAAM,KAAK,CAAC,UAAU,EAAE,CAAA;QAExB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAA;IACvC,CAAC;IAGsB,AAAb,MAAM,CAAC,KAAK,CAAC,mBAAmB;QACtC,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAA;IACjC,CAAC;IAGsB,AAAb,MAAM,CAAC,KAAK,CAAC,eAAe;QAClC,mBAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAA;IAChE,CAAC;IAGsB,AAAb,MAAM,CAAC,KAAK,CAAC,yBAAyB;QAC5C,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;QAEhB,mBAAM,CAAC,WAAW,CACd,iCAAgB,CAAC,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,EAAE,IAAI,CAAC,WAAW;YAC7B,aAAa,EAAE,IAAI,CAAC,aAAa;SACpC,CAAC,CAAA;IACN,CAAC;;;AA1IuB,8BAAa,GAAG,IAAA,uBAAU,GAAE,AAAf,CAAe;AAE5B,uCAAsB,GAAG,EAAI,CAAC,WAAW,CAC7D,EAAI,CAAC,aAAa,CACrB,AAF6C,CAE7C;kBAtGgB,gBAAgB;AAQV;IADtB,IAAA,iBAAI,GAAE;iDAGN;AAGsB;IADtB,IAAA,iBAAI,GAAE;6CAGN;AAGsB;IADtB,IAAA,iBAAI,GAAE;uDAaN;AAGsB;IADtB,IAAA,iBAAI,GAAE;yDAaN;AAGsB;IADtB,IAAA,iBAAI,GAAE;uDAaN;AAGsB;IADtB,IAAA,iBAAI,GAAE;2EAuBN;AAGsB;IADtB,IAAA,iBAAI,GAAE;uDASN"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { exec as execSync } from 'child_process';
|
|
2
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
2
3
|
import { pathExists } from 'fs-extra';
|
|
3
4
|
import { Automodule, BaseAutomoduleOptions } from '../types';
|
|
4
5
|
export default abstract class AbstractAutomodule implements Automodule {
|
|
6
|
+
static exec: typeof execSync.__promisify__;
|
|
5
7
|
static pathExists: typeof pathExists;
|
|
6
8
|
static writeFile: typeof writeFile;
|
|
9
|
+
static readFile: typeof readFile;
|
|
7
10
|
protected testSaveDir: string;
|
|
8
11
|
protected moduleSaveDir: string;
|
|
9
12
|
protected fakeSaveDir: string;
|
|
@@ -13,6 +16,8 @@ export default abstract class AbstractAutomodule implements Automodule {
|
|
|
13
16
|
protected moduleFileContent: string;
|
|
14
17
|
protected fakeFileName: string;
|
|
15
18
|
protected fakeFileContent: string;
|
|
19
|
+
protected indexFileContent: string;
|
|
20
|
+
protected originalIndexFile: string;
|
|
16
21
|
protected constructor(options: BaseAutomoduleOptions);
|
|
17
22
|
abstract run(): Promise<void>;
|
|
18
23
|
protected runAbstract(options: AbstractAutomoduleRunOptions): Promise<void>;
|
|
@@ -27,8 +32,15 @@ export default abstract class AbstractAutomodule implements Automodule {
|
|
|
27
32
|
private get moduleFilePath();
|
|
28
33
|
private createFakeFile;
|
|
29
34
|
private get fakeFilePath();
|
|
35
|
+
private updateIndexFileExports;
|
|
36
|
+
private loadOriginalIndexFile;
|
|
37
|
+
private readonly indexFilePath;
|
|
38
|
+
private get sortedIndexFile();
|
|
39
|
+
private bumpMinorVersion;
|
|
40
|
+
private get exec();
|
|
30
41
|
private get pathExists();
|
|
31
42
|
protected get writeFile(): typeof writeFile;
|
|
43
|
+
private get readFile();
|
|
32
44
|
}
|
|
33
45
|
export interface AbstractAutomoduleOptions extends BaseAutomoduleOptions {
|
|
34
46
|
testFileName: string;
|
|
@@ -41,4 +53,5 @@ export interface AbstractAutomoduleRunOptions {
|
|
|
41
53
|
moduleFileContent: string;
|
|
42
54
|
fakeFileName: string;
|
|
43
55
|
fakeFileContent: string;
|
|
56
|
+
indexFileContent: string;
|
|
44
57
|
}
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_1 = require("child_process");
|
|
3
4
|
const promises_1 = require("fs/promises");
|
|
5
|
+
const util_1 = require("util");
|
|
4
6
|
const fs_extra_1 = require("fs-extra");
|
|
5
7
|
class AbstractAutomodule {
|
|
6
8
|
constructor(options) {
|
|
9
|
+
this.indexFilePath = './src/index.ts';
|
|
7
10
|
const { testSaveDir, moduleSaveDir, fakeSaveDir } = options;
|
|
8
11
|
this.testSaveDir = testSaveDir;
|
|
9
12
|
this.moduleSaveDir = moduleSaveDir;
|
|
10
13
|
this.fakeSaveDir = fakeSaveDir;
|
|
11
14
|
}
|
|
12
15
|
async runAbstract(options) {
|
|
13
|
-
const { testFileName, testFileContent, moduleFileName, moduleFileContent, fakeFileName, fakeFileContent, } = options;
|
|
16
|
+
const { testFileName, testFileContent, moduleFileName, moduleFileContent, fakeFileName, fakeFileContent, indexFileContent, } = options;
|
|
14
17
|
this.testFileName = testFileName;
|
|
15
18
|
this.testFileContent = testFileContent;
|
|
16
19
|
this.moduleFileName = moduleFileName;
|
|
17
20
|
this.moduleFileContent = moduleFileContent;
|
|
18
21
|
this.fakeFileName = fakeFileName;
|
|
19
22
|
this.fakeFileContent = fakeFileContent;
|
|
23
|
+
this.indexFileContent = indexFileContent;
|
|
20
24
|
await this.throwIfDirectoriesDoNotExist();
|
|
21
25
|
await this.createTestFile();
|
|
22
26
|
await this.createModuleFile();
|
|
23
27
|
await this.createFakeFile();
|
|
28
|
+
await this.updateIndexFileExports();
|
|
29
|
+
await this.bumpMinorVersion();
|
|
24
30
|
}
|
|
25
31
|
async throwIfDirectoriesDoNotExist() {
|
|
26
32
|
await this.throwIfTestDirDoesNotExist();
|
|
@@ -66,14 +72,44 @@ class AbstractAutomodule {
|
|
|
66
72
|
get fakeFilePath() {
|
|
67
73
|
return `${this.fakeSaveDir}/${this.fakeFileName}`;
|
|
68
74
|
}
|
|
75
|
+
async updateIndexFileExports() {
|
|
76
|
+
this.originalIndexFile = await this.loadOriginalIndexFile();
|
|
77
|
+
await this.writeFile(this.indexFilePath, this.sortedIndexFile);
|
|
78
|
+
}
|
|
79
|
+
async loadOriginalIndexFile() {
|
|
80
|
+
return await this.readFile(this.indexFilePath, 'utf-8');
|
|
81
|
+
}
|
|
82
|
+
get sortedIndexFile() {
|
|
83
|
+
const blocks = `${this.originalIndexFile}${this.indexFileContent}`
|
|
84
|
+
.split(/(?=\/\/)/)
|
|
85
|
+
.map((s) => s.trim())
|
|
86
|
+
.filter(Boolean);
|
|
87
|
+
blocks.sort((a, b) => {
|
|
88
|
+
const aKey = a.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? '';
|
|
89
|
+
const bKey = b.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? '';
|
|
90
|
+
return aKey.localeCompare(bKey);
|
|
91
|
+
});
|
|
92
|
+
return blocks.join('\n\n');
|
|
93
|
+
}
|
|
94
|
+
async bumpMinorVersion() {
|
|
95
|
+
await this.exec('yarn version --minor --no-git-tag-version');
|
|
96
|
+
}
|
|
97
|
+
get exec() {
|
|
98
|
+
return AbstractAutomodule.exec;
|
|
99
|
+
}
|
|
69
100
|
get pathExists() {
|
|
70
101
|
return AbstractAutomodule.pathExists;
|
|
71
102
|
}
|
|
72
103
|
get writeFile() {
|
|
73
104
|
return AbstractAutomodule.writeFile;
|
|
74
105
|
}
|
|
106
|
+
get readFile() {
|
|
107
|
+
return AbstractAutomodule.readFile;
|
|
108
|
+
}
|
|
75
109
|
}
|
|
110
|
+
AbstractAutomodule.exec = (0, util_1.promisify)(child_process_1.exec);
|
|
76
111
|
AbstractAutomodule.pathExists = fs_extra_1.pathExists;
|
|
77
112
|
AbstractAutomodule.writeFile = promises_1.writeFile;
|
|
113
|
+
AbstractAutomodule.readFile = promises_1.readFile;
|
|
78
114
|
exports.default = AbstractAutomodule;
|
|
79
115
|
//# sourceMappingURL=AbstractAutomodule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractAutomodule.js","sourceRoot":"","sources":["../../src/modules/AbstractAutomodule.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"AbstractAutomodule.js","sourceRoot":"","sources":["../../src/modules/AbstractAutomodule.ts"],"names":[],"mappings":";;AAAA,iDAAgD;AAChD,0CAAiD;AACjD,+BAAgC;AAChC,uCAAqC;AAGrC,MAA8B,kBAAkB;IAoB5C,YAAsB,OAA8B;QA0GnC,kBAAa,GAAG,gBAAgB,CAAA;QAzG7C,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,OAAO,CAAA;QAE3D,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAClC,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IAED,IAAc,SAAS;QACnB,OAAO,kBAAkB,CAAC,SAAS,CAAA;IACvC,CAAC;IAED,IAAY,QAAQ;QAChB,OAAO,kBAAkB,CAAC,QAAQ,CAAA;IACtC,CAAC;;AAhKa,uBAAI,GAAG,IAAA,gBAAS,EAAC,oBAAQ,CAAC,AAAtB,CAAsB;AAC1B,6BAAU,GAAG,qBAAU,AAAb,CAAa;AACvB,4BAAS,GAAG,oBAAS,AAAZ,CAAY;AACrB,2BAAQ,GAAG,mBAAQ,AAAX,CAAW;kBAJP,kBAAkB"}
|
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
import { exec as execSync } from 'child_process';
|
|
2
|
-
import { readFile } from 'fs/promises';
|
|
3
1
|
import { Automodule, BaseAutomoduleOptions } from '../types';
|
|
4
2
|
import AbstractAutomodule from './AbstractAutomodule';
|
|
5
|
-
export default class ImplAutomodule extends AbstractAutomodule
|
|
3
|
+
export default class ImplAutomodule extends AbstractAutomodule {
|
|
6
4
|
static Class?: ImplAutomoduleConstructor;
|
|
7
|
-
static exec: typeof execSync.__promisify__;
|
|
8
|
-
static readFile: typeof readFile;
|
|
9
5
|
private interfaceName;
|
|
10
6
|
private implName;
|
|
11
|
-
private originalIndexFile;
|
|
12
7
|
protected constructor(options: ImplAutomoduleOptions);
|
|
13
8
|
static Create(options: ImplAutomoduleOptions): Automodule;
|
|
14
9
|
run(): Promise<void>;
|
|
15
|
-
private generateFiles;
|
|
16
|
-
private updateIndexFileExports;
|
|
17
|
-
private loadOriginalIndexFile;
|
|
18
|
-
private readonly indexFilePath;
|
|
19
|
-
private get sortedIndexFile();
|
|
20
|
-
private bumpMinorVersion;
|
|
21
|
-
private get exec();
|
|
22
|
-
private get readFile();
|
|
23
10
|
private get testFilePattern();
|
|
24
11
|
private get moduleFilePattern();
|
|
25
12
|
private get fakeFilePattern();
|
|
@@ -3,9 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const child_process_1 = require("child_process");
|
|
7
|
-
const promises_1 = require("fs/promises");
|
|
8
|
-
const util_1 = require("util");
|
|
9
6
|
const AbstractAutomodule_1 = __importDefault(require("./AbstractAutomodule"));
|
|
10
7
|
class ImplAutomodule extends AbstractAutomodule_1.default {
|
|
11
8
|
constructor(options) {
|
|
@@ -15,7 +12,6 @@ class ImplAutomodule extends AbstractAutomodule_1.default {
|
|
|
15
12
|
moduleSaveDir,
|
|
16
13
|
fakeSaveDir,
|
|
17
14
|
});
|
|
18
|
-
this.indexFilePath = './src/index.ts';
|
|
19
15
|
this.interfaceName = interfaceName;
|
|
20
16
|
this.implName = implName;
|
|
21
17
|
}
|
|
@@ -23,11 +19,6 @@ class ImplAutomodule extends AbstractAutomodule_1.default {
|
|
|
23
19
|
return new (this.Class ?? this)(options);
|
|
24
20
|
}
|
|
25
21
|
async run() {
|
|
26
|
-
await this.generateFiles();
|
|
27
|
-
await this.updateIndexFileExports();
|
|
28
|
-
await this.bumpMinorVersion();
|
|
29
|
-
}
|
|
30
|
-
async generateFiles() {
|
|
31
22
|
await this.runAbstract({
|
|
32
23
|
testFileName: `${this.implName}.test.ts`,
|
|
33
24
|
testFileContent: this.testFilePattern,
|
|
@@ -35,36 +26,9 @@ class ImplAutomodule extends AbstractAutomodule_1.default {
|
|
|
35
26
|
moduleFileContent: this.moduleFilePattern,
|
|
36
27
|
fakeFileName: `Fake${this.interfaceName}.ts`,
|
|
37
28
|
fakeFileContent: this.fakeFilePattern,
|
|
29
|
+
indexFileContent: this.indexFilePattern,
|
|
38
30
|
});
|
|
39
31
|
}
|
|
40
|
-
async updateIndexFileExports() {
|
|
41
|
-
this.originalIndexFile = await this.loadOriginalIndexFile();
|
|
42
|
-
await this.writeFile(this.indexFilePath, this.sortedIndexFile);
|
|
43
|
-
}
|
|
44
|
-
async loadOriginalIndexFile() {
|
|
45
|
-
return await this.readFile(this.indexFilePath, 'utf-8');
|
|
46
|
-
}
|
|
47
|
-
get sortedIndexFile() {
|
|
48
|
-
const blocks = this.indexFilePattern
|
|
49
|
-
.split(/(?=\/\/)/)
|
|
50
|
-
.map((s) => s.trim())
|
|
51
|
-
.filter(Boolean);
|
|
52
|
-
blocks.sort((a, b) => {
|
|
53
|
-
const aKey = a.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? '';
|
|
54
|
-
const bKey = b.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? '';
|
|
55
|
-
return aKey.localeCompare(bKey);
|
|
56
|
-
});
|
|
57
|
-
return blocks.join('\n\n');
|
|
58
|
-
}
|
|
59
|
-
async bumpMinorVersion() {
|
|
60
|
-
await this.exec('yarn version --minor --no-git-tag-version');
|
|
61
|
-
}
|
|
62
|
-
get exec() {
|
|
63
|
-
return ImplAutomodule.exec;
|
|
64
|
-
}
|
|
65
|
-
get readFile() {
|
|
66
|
-
return ImplAutomodule.readFile;
|
|
67
|
-
}
|
|
68
32
|
get testFilePattern() {
|
|
69
33
|
return `
|
|
70
34
|
import AbstractSpruceTest, { test, assert } from '@sprucelabs/test-utils'
|
|
@@ -126,8 +90,6 @@ class ImplAutomodule extends AbstractAutomodule_1.default {
|
|
|
126
90
|
}
|
|
127
91
|
get indexFilePattern() {
|
|
128
92
|
return `
|
|
129
|
-
${this.originalIndexFile}
|
|
130
|
-
|
|
131
93
|
// ${this.interfaceName}
|
|
132
94
|
|
|
133
95
|
export { default as ${this.implName} } from './modules/${this.implName}'
|
|
@@ -138,7 +100,5 @@ class ImplAutomodule extends AbstractAutomodule_1.default {
|
|
|
138
100
|
`;
|
|
139
101
|
}
|
|
140
102
|
}
|
|
141
|
-
ImplAutomodule.exec = (0, util_1.promisify)(child_process_1.exec);
|
|
142
|
-
ImplAutomodule.readFile = promises_1.readFile;
|
|
143
103
|
exports.default = ImplAutomodule;
|
|
144
104
|
//# sourceMappingURL=ImplAutomodule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImplAutomodule.js","sourceRoot":"","sources":["../../src/modules/ImplAutomodule.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"ImplAutomodule.js","sourceRoot":"","sources":["../../src/modules/ImplAutomodule.ts"],"names":[],"mappings":";;;;;AACA,8EAAqD;AAErD,MAAqB,cAAe,SAAQ,4BAAkB;IAM1D,YAAsB,OAA8B;QAChD,MAAM,EACF,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,QAAQ,GACX,GAAG,OAAO,CAAA;QAEX,KAAK,CAAC;YACF,WAAW;YACX,aAAa;YACb,WAAW;SACd,CAAC,CAAA;QAEF,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC5B,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,OAA8B;QAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC;IAEM,KAAK,CAAC,GAAG;QACZ,MAAM,IAAI,CAAC,WAAW,CAAC;YACnB,YAAY,EAAE,GAAG,IAAI,CAAC,QAAQ,UAAU;YACxC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,cAAc,EAAE,GAAG,IAAI,CAAC,QAAQ,KAAK;YACrC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,YAAY,EAAE,OAAO,IAAI,CAAC,aAAa,KAAK;YAC5C,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;SAC1C,CAAC,CAAA;IACN,CAAC;IAED,IAAY,eAAe;QACvB,OAAO;;qBAEM,IAAI,CAAC,QAAQ,OAAO,IAAI,CAAC,aAAa,0BAA0B,IAAI,CAAC,QAAQ;;mCAE/D,IAAI,CAAC,QAAQ;2CACL,IAAI,CAAC,aAAa;;;;;2CAKlB,IAAI,CAAC,QAAQ;;;;;;;;iCAQvB,IAAI,CAAC,QAAQ;6BACjB,IAAI,CAAC,QAAQ;;;SAGjC,CAAA;IACL,CAAC;IAED,IAAY,iBAAiB;QACzB,OAAO;mCACoB,IAAI,CAAC,QAAQ,eAAe,IAAI,CAAC,aAAa;wCACzC,IAAI,CAAC,aAAa;;;;;;;;;+BAS3B,IAAI,CAAC,aAAa;;0BAEvB,IAAI,CAAC,aAAa,2BAA2B,IAAI,CAAC,aAAa;SAChF,CAAA;IACL,CAAC;IAED,IAAY,eAAe;QACvB,OAAO;uBACQ,IAAI,CAAC,aAAa,0BAA0B,IAAI,CAAC,QAAQ;;uCAEzC,IAAI,CAAC,aAAa,eAAe,IAAI,CAAC,aAAa;;;;0BAIhE,IAAI,CAAC,aAAa;;;;0BAIlB,IAAI,CAAC,aAAa;;;SAGnC,CAAA;IACL,CAAC;IAED,IAAY,gBAAgB;QACxB,OAAO;iBACE,IAAI,CAAC,aAAa;;kCAED,IAAI,CAAC,QAAQ,sBAAsB,IAAI,CAAC,QAAQ;uCAC3C,IAAI,CAAC,QAAQ;;sCAEd,IAAI,CAAC,aAAa,0BAA0B,IAAI,CAAC,aAAa,QAAQ,IAAI,CAAC,aAAa;2CACnF,IAAI,CAAC,aAAa,QAAQ,IAAI,CAAC,aAAa;SAC9E,CAAA;IACL,CAAC;CACJ;AAlHD,iCAkHC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pathExists } from 'fs-extra';
|
|
2
2
|
import { Automodule, BaseAutomoduleOptions } from '../types';
|
|
3
3
|
import AbstractAutomodule from './AbstractAutomodule';
|
|
4
|
-
export default class UiAutomodule extends AbstractAutomodule
|
|
4
|
+
export default class UiAutomodule extends AbstractAutomodule {
|
|
5
5
|
static Class?: UiAutomoduleConstructor;
|
|
6
6
|
static pathExists: typeof pathExists;
|
|
7
7
|
protected componentName: string;
|
|
@@ -13,6 +13,7 @@ export default class UiAutomodule extends AbstractAutomodule implements Automodu
|
|
|
13
13
|
private get testFileTemplate();
|
|
14
14
|
private get moduleFilePattern();
|
|
15
15
|
private get fakeFilePattern();
|
|
16
|
+
private get indexFilePattern();
|
|
16
17
|
}
|
|
17
18
|
export type UiAutomoduleConstructor = new (options: UiAutomoduleOptions) => Automodule;
|
|
18
19
|
export interface UiAutomoduleOptions extends BaseAutomoduleOptions {
|
|
@@ -33,6 +33,7 @@ class UiAutomodule extends AbstractAutomodule_1.default {
|
|
|
33
33
|
moduleFileContent: this.moduleFilePattern,
|
|
34
34
|
fakeFileName: `Fake${this.componentName}.tsx`,
|
|
35
35
|
fakeFileContent: this.fakeFilePattern,
|
|
36
|
+
indexFileContent: this.indexFilePattern,
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
get testFileTemplate() {
|
|
@@ -120,6 +121,18 @@ class UiAutomodule extends AbstractAutomodule_1.default {
|
|
|
120
121
|
export default Fake${this.componentName}
|
|
121
122
|
`;
|
|
122
123
|
}
|
|
124
|
+
get indexFilePattern() {
|
|
125
|
+
return `
|
|
126
|
+
// ${this.componentName}
|
|
127
|
+
|
|
128
|
+
export { default as ${this.componentName} } from './ui/${this.componentName}'
|
|
129
|
+
export * from './ui/${this.componentName}'
|
|
130
|
+
|
|
131
|
+
export { default as Fake${this.componentName} } from './testDoubles/${this.componentName}/Fake${this.componentName}'
|
|
132
|
+
export * from './testDoubles/${this.componentName}/Fake${this.componentName}'
|
|
133
|
+
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
123
136
|
}
|
|
124
137
|
UiAutomodule.pathExists = fs_extra_1.pathExists;
|
|
125
138
|
exports.default = UiAutomodule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiAutomodule.js","sourceRoot":"","sources":["../../src/modules/UiAutomodule.ts"],"names":[],"mappings":";;;;;AAAA,uCAAqC;AAErC,8EAAqD;AAErD,MAAqB,
|
|
1
|
+
{"version":3,"file":"UiAutomodule.js","sourceRoot":"","sources":["../../src/modules/UiAut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;;;;;;;;;uDA+BE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC;;;qCAGtD,IAAI,CAAC,aAAa;;;SAG9C,CAAA;IACL,CAAC;IAED,IAAY,iBAAiB;QACzB,OAAO;;;+BAGgB,IAAI,CAAC,aAAa;;oBAE7B,IAAI,CAAC,aAAa,cAAc,IAAI,CAAC,aAAa,qBAAqB,IAAI,CAAC,aAAa;;;qCAGxE,IAAI,CAAC,sBAAsB;uCACzB,IAAI,CAAC,sBAAsB;;;;;6BAKrC,IAAI,CAAC,aAAa;SACtC,CAAA;IACL,CAAC;IAED,IAAY,eAAe;QACvB,OAAO;;uBAEQ,IAAI,CAAC,aAAa,0BAA0B,IAAI,CAAC,aAAa;;6BAExD,IAAI,CAAC,aAAa,UAAU,IAAI,CAAC,aAAa;;wBAEnD,IAAI,CAAC,aAAa,cAAc,IAAI,CAAC,aAAa;yBACjD,IAAI,CAAC,aAAa;;sBAErB,IAAI,CAAC,aAAa;;;wCAGA,IAAI,CAAC,sBAAsB;;;;iCAIlC,IAAI,CAAC,aAAa;SAC1C,CAAA;IACL,CAAC;IAED,IAAY,gBAAgB;QACxB,OAAO;iBACE,IAAI,CAAC,aAAa;;kCAED,IAAI,CAAC,aAAa,iBAAiB,IAAI,CAAC,aAAa;kCACrD,IAAI,CAAC,aAAa;;sCAEd,IAAI,CAAC,aAAa,0BAA0B,IAAI,CAAC,aAAa,QAAQ,IAAI,CAAC,aAAa;2CACnF,IAAI,CAAC,aAAa,QAAQ,IAAI,CAAC,aAAa;;SAE9E,CAAA;IACL,CAAC;;AA7Ia,uBAAU,GAAG,qBAAU,CAAA;kBAFpB,YAAY"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { exec as execSync } from 'child_process'
|
|
2
|
+
import { readFile, writeFile } from 'fs/promises'
|
|
3
|
+
import { promisify } from 'util'
|
|
2
4
|
import { assert, generateId } from '@sprucelabs/test-utils'
|
|
3
5
|
import {
|
|
6
|
+
fakeExec,
|
|
4
7
|
fakePathExists,
|
|
8
|
+
fakeReadFile,
|
|
5
9
|
fakeWriteFile,
|
|
10
|
+
resetCallsToExec,
|
|
6
11
|
resetCallsToPathExists,
|
|
12
|
+
resetCallsToReadFile,
|
|
7
13
|
resetCallsToWriteFile,
|
|
8
14
|
setPathShouldExist,
|
|
9
15
|
} from '@neurodevs/fake-node-core'
|
|
@@ -11,13 +17,17 @@ import AbstractAutomodule from '../modules/AbstractAutomodule'
|
|
|
11
17
|
import { Automodule } from '../types'
|
|
12
18
|
import AbstractPackageTest from './AbstractPackageTest'
|
|
13
19
|
|
|
20
|
+
const exec = promisify(execSync)
|
|
21
|
+
|
|
14
22
|
export default class AbstractAutomoduleTest extends AbstractPackageTest {
|
|
15
23
|
protected static instance: Automodule
|
|
16
24
|
|
|
17
25
|
protected static async beforeEach() {
|
|
18
26
|
await super.beforeEach()
|
|
19
27
|
|
|
28
|
+
this.setFakeExec()
|
|
20
29
|
this.setFakePathExists()
|
|
30
|
+
this.setFakeReadFile()
|
|
21
31
|
this.setFakeWriteFile()
|
|
22
32
|
}
|
|
23
33
|
|
|
@@ -65,6 +75,11 @@ export default class AbstractAutomoduleTest extends AbstractPackageTest {
|
|
|
65
75
|
protected static readonly fakeSaveDir = generateId()
|
|
66
76
|
protected static readonly indexFilePath = './src/index.ts'
|
|
67
77
|
|
|
78
|
+
protected static setFakeExec() {
|
|
79
|
+
AbstractAutomodule.exec = fakeExec as unknown as typeof exec
|
|
80
|
+
resetCallsToExec()
|
|
81
|
+
}
|
|
82
|
+
|
|
68
83
|
protected static setFakePathExists() {
|
|
69
84
|
AbstractAutomodule.pathExists = fakePathExists
|
|
70
85
|
|
|
@@ -76,6 +91,11 @@ export default class AbstractAutomoduleTest extends AbstractPackageTest {
|
|
|
76
91
|
resetCallsToPathExists()
|
|
77
92
|
}
|
|
78
93
|
|
|
94
|
+
protected static setFakeReadFile() {
|
|
95
|
+
AbstractAutomodule.readFile = fakeReadFile as unknown as typeof readFile
|
|
96
|
+
resetCallsToReadFile()
|
|
97
|
+
}
|
|
98
|
+
|
|
79
99
|
protected static setFakeWriteFile() {
|
|
80
100
|
AbstractAutomodule.writeFile = fakeWriteFile as typeof writeFile
|
|
81
101
|
resetCallsToWriteFile()
|
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
import { exec as execSync } from 'child_process'
|
|
2
|
-
import { readFile } from 'fs/promises'
|
|
3
|
-
import { promisify } from 'util'
|
|
4
1
|
import { test, assert, generateId } from '@sprucelabs/test-utils'
|
|
5
2
|
import {
|
|
6
3
|
callsToExec,
|
|
7
4
|
callsToWriteFile,
|
|
8
|
-
fakeExec,
|
|
9
|
-
fakeReadFile,
|
|
10
|
-
fakeReadFileResult,
|
|
11
|
-
resetCallsToExec,
|
|
12
|
-
resetCallsToReadFile,
|
|
13
5
|
setFakeReadFileResult,
|
|
14
6
|
} from '@neurodevs/fake-node-core'
|
|
15
7
|
import ImplAutomodule from '../../modules/ImplAutomodule'
|
|
16
8
|
import AbstractAutomoduleTest from '../AbstractAutomoduleTest'
|
|
17
9
|
|
|
18
|
-
const exec = promisify(execSync)
|
|
19
|
-
|
|
20
10
|
export default class ImplAutomoduleTest extends AbstractAutomoduleTest {
|
|
21
11
|
protected static async beforeEach() {
|
|
22
12
|
await super.beforeEach()
|
|
23
13
|
|
|
24
|
-
this.setFakeExec()
|
|
25
|
-
this.setFakeReadFile()
|
|
26
|
-
|
|
27
14
|
this.instance = this.ImplAutomodule()
|
|
28
15
|
}
|
|
29
16
|
|
|
@@ -86,11 +73,7 @@ export default class ImplAutomoduleTest extends AbstractAutomoduleTest {
|
|
|
86
73
|
|
|
87
74
|
@test()
|
|
88
75
|
protected static async sortsIndexFileExportsAlphabetically() {
|
|
89
|
-
setFakeReadFileResult(
|
|
90
|
-
// A-${fakeReadFileResult}
|
|
91
|
-
|
|
92
|
-
// C-${fakeReadFileResult}
|
|
93
|
-
`)
|
|
76
|
+
setFakeReadFileResult(this.originalIndexFile)
|
|
94
77
|
|
|
95
78
|
await this.run()
|
|
96
79
|
|
|
@@ -120,15 +103,11 @@ export default class ImplAutomoduleTest extends AbstractAutomoduleTest {
|
|
|
120
103
|
)
|
|
121
104
|
}
|
|
122
105
|
|
|
123
|
-
private static
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
private static setFakeReadFile() {
|
|
129
|
-
ImplAutomodule.readFile = fakeReadFile as unknown as typeof readFile
|
|
130
|
-
resetCallsToReadFile()
|
|
131
|
-
}
|
|
106
|
+
private static readonly originalIndexFile = `
|
|
107
|
+
// C-${generateId()}
|
|
108
|
+
|
|
109
|
+
// A-${generateId()}
|
|
110
|
+
`
|
|
132
111
|
|
|
133
112
|
private static readonly interfaceName = `B-${generateId()}`
|
|
134
113
|
private static readonly implName = generateId()
|
|
@@ -197,8 +176,6 @@ export default class ImplAutomoduleTest extends AbstractAutomoduleTest {
|
|
|
197
176
|
|
|
198
177
|
private static get indexFilePattern() {
|
|
199
178
|
return `
|
|
200
|
-
${fakeReadFileResult}
|
|
201
|
-
|
|
202
179
|
// ${this.interfaceName}
|
|
203
180
|
|
|
204
181
|
export { default as ${this.implName} } from './modules/${this.implName}'
|
|
@@ -211,7 +188,7 @@ export default class ImplAutomoduleTest extends AbstractAutomoduleTest {
|
|
|
211
188
|
}
|
|
212
189
|
|
|
213
190
|
private static get sortedIndexFile() {
|
|
214
|
-
const blocks = this.indexFilePattern
|
|
191
|
+
const blocks = `${this.originalIndexFile}${this.indexFilePattern}`
|
|
215
192
|
.split(/(?=\/\/)/)
|
|
216
193
|
.map((s) => s.trim())
|
|
217
194
|
.filter(Boolean)
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { test, assert, generateId } from '@sprucelabs/test-utils'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
callsToExec,
|
|
4
|
+
callsToWriteFile,
|
|
5
|
+
fakeReadFileResult,
|
|
6
|
+
setFakeReadFileResult,
|
|
7
|
+
} from '@neurodevs/fake-node-core'
|
|
3
8
|
import UiAutomodule from '../../modules/UiAutomodule'
|
|
4
9
|
import AbstractAutomoduleTest from '../AbstractAutomoduleTest'
|
|
5
10
|
|
|
@@ -65,6 +70,42 @@ export default class UiAutomoduleTest extends AbstractAutomoduleTest {
|
|
|
65
70
|
)
|
|
66
71
|
}
|
|
67
72
|
|
|
73
|
+
@test()
|
|
74
|
+
protected static async updatesIndexFileExportsAndSortsAlphabetically() {
|
|
75
|
+
setFakeReadFileResult(`
|
|
76
|
+
// C-${fakeReadFileResult}
|
|
77
|
+
|
|
78
|
+
// A-${fakeReadFileResult}
|
|
79
|
+
`)
|
|
80
|
+
|
|
81
|
+
await this.run()
|
|
82
|
+
|
|
83
|
+
const call = callsToWriteFile[3]
|
|
84
|
+
|
|
85
|
+
assert.isEqualDeep(
|
|
86
|
+
{
|
|
87
|
+
file: call.file,
|
|
88
|
+
data: this.normalize(call.data),
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
file: this.indexFilePath,
|
|
92
|
+
data: this.normalize(this.sortedIndexFile),
|
|
93
|
+
},
|
|
94
|
+
'Did not update index file exports as expected!'
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@test()
|
|
99
|
+
protected static async bumpsMinorVersionWithYarn() {
|
|
100
|
+
await this.run()
|
|
101
|
+
|
|
102
|
+
assert.isEqualDeep(
|
|
103
|
+
callsToExec[0],
|
|
104
|
+
'yarn version --minor --no-git-tag-version',
|
|
105
|
+
'Did not bump minor version!'
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
68
109
|
private static readonly componentName = generateId()
|
|
69
110
|
|
|
70
111
|
private static readonly componentNameKebabCase = this.toKebabCase(
|
|
@@ -159,6 +200,36 @@ export default class UiAutomoduleTest extends AbstractAutomoduleTest {
|
|
|
159
200
|
`
|
|
160
201
|
}
|
|
161
202
|
|
|
203
|
+
private static get indexFilePattern() {
|
|
204
|
+
return `
|
|
205
|
+
${fakeReadFileResult}
|
|
206
|
+
|
|
207
|
+
// ${this.componentName}
|
|
208
|
+
|
|
209
|
+
export { default as ${this.componentName} } from './ui/${this.componentName}'
|
|
210
|
+
export * from './ui/${this.componentName}'
|
|
211
|
+
|
|
212
|
+
export { default as Fake${this.componentName} } from './testDoubles/${this.componentName}/Fake${this.componentName}'
|
|
213
|
+
export * from './testDoubles/${this.componentName}/Fake${this.componentName}'
|
|
214
|
+
|
|
215
|
+
`
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
private static get sortedIndexFile() {
|
|
219
|
+
const blocks = this.indexFilePattern
|
|
220
|
+
.split(/(?=\/\/)/)
|
|
221
|
+
.map((s) => s.trim())
|
|
222
|
+
.filter(Boolean)
|
|
223
|
+
|
|
224
|
+
blocks.sort((a, b) => {
|
|
225
|
+
const aKey = a.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? ''
|
|
226
|
+
const bKey = b.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? ''
|
|
227
|
+
return aKey.localeCompare(bKey)
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
return blocks.join('\n\n')
|
|
231
|
+
}
|
|
232
|
+
|
|
162
233
|
private static toKebabCase(str: string): string {
|
|
163
234
|
return str
|
|
164
235
|
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { exec as execSync } from 'child_process'
|
|
2
|
+
import { readFile, writeFile } from 'fs/promises'
|
|
3
|
+
import { promisify } from 'util'
|
|
2
4
|
import { pathExists } from 'fs-extra'
|
|
3
5
|
import { Automodule, BaseAutomoduleOptions } from '../types'
|
|
4
6
|
|
|
5
7
|
export default abstract class AbstractAutomodule implements Automodule {
|
|
8
|
+
public static exec = promisify(execSync)
|
|
6
9
|
public static pathExists = pathExists
|
|
7
10
|
public static writeFile = writeFile
|
|
11
|
+
public static readFile = readFile
|
|
8
12
|
|
|
9
13
|
protected testSaveDir: string
|
|
10
14
|
protected moduleSaveDir: string
|
|
@@ -16,6 +20,9 @@ export default abstract class AbstractAutomodule implements Automodule {
|
|
|
16
20
|
protected moduleFileContent!: string
|
|
17
21
|
protected fakeFileName!: string
|
|
18
22
|
protected fakeFileContent!: string
|
|
23
|
+
protected indexFileContent!: string
|
|
24
|
+
|
|
25
|
+
protected originalIndexFile!: string
|
|
19
26
|
|
|
20
27
|
protected constructor(options: BaseAutomoduleOptions) {
|
|
21
28
|
const { testSaveDir, moduleSaveDir, fakeSaveDir } = options
|
|
@@ -35,6 +42,7 @@ export default abstract class AbstractAutomodule implements Automodule {
|
|
|
35
42
|
moduleFileContent,
|
|
36
43
|
fakeFileName,
|
|
37
44
|
fakeFileContent,
|
|
45
|
+
indexFileContent,
|
|
38
46
|
} = options
|
|
39
47
|
|
|
40
48
|
this.testFileName = testFileName
|
|
@@ -43,12 +51,16 @@ export default abstract class AbstractAutomodule implements Automodule {
|
|
|
43
51
|
this.moduleFileContent = moduleFileContent
|
|
44
52
|
this.fakeFileName = fakeFileName
|
|
45
53
|
this.fakeFileContent = fakeFileContent
|
|
54
|
+
this.indexFileContent = indexFileContent
|
|
46
55
|
|
|
47
56
|
await this.throwIfDirectoriesDoNotExist()
|
|
48
57
|
|
|
49
58
|
await this.createTestFile()
|
|
50
59
|
await this.createModuleFile()
|
|
51
60
|
await this.createFakeFile()
|
|
61
|
+
|
|
62
|
+
await this.updateIndexFileExports()
|
|
63
|
+
await this.bumpMinorVersion()
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
private async throwIfDirectoriesDoNotExist() {
|
|
@@ -109,6 +121,40 @@ export default abstract class AbstractAutomodule implements Automodule {
|
|
|
109
121
|
return `${this.fakeSaveDir}/${this.fakeFileName}`
|
|
110
122
|
}
|
|
111
123
|
|
|
124
|
+
private async updateIndexFileExports() {
|
|
125
|
+
this.originalIndexFile = await this.loadOriginalIndexFile()
|
|
126
|
+
await this.writeFile(this.indexFilePath, this.sortedIndexFile)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private async loadOriginalIndexFile() {
|
|
130
|
+
return await this.readFile(this.indexFilePath, 'utf-8')
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private readonly indexFilePath = './src/index.ts'
|
|
134
|
+
|
|
135
|
+
private get sortedIndexFile() {
|
|
136
|
+
const blocks = `${this.originalIndexFile}${this.indexFileContent}`
|
|
137
|
+
.split(/(?=\/\/)/)
|
|
138
|
+
.map((s) => s.trim())
|
|
139
|
+
.filter(Boolean)
|
|
140
|
+
|
|
141
|
+
blocks.sort((a, b) => {
|
|
142
|
+
const aKey = a.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? ''
|
|
143
|
+
const bKey = b.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? ''
|
|
144
|
+
return aKey.localeCompare(bKey)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
return blocks.join('\n\n')
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private async bumpMinorVersion() {
|
|
151
|
+
await this.exec('yarn version --minor --no-git-tag-version')
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private get exec() {
|
|
155
|
+
return AbstractAutomodule.exec
|
|
156
|
+
}
|
|
157
|
+
|
|
112
158
|
private get pathExists() {
|
|
113
159
|
return AbstractAutomodule.pathExists
|
|
114
160
|
}
|
|
@@ -116,6 +162,10 @@ export default abstract class AbstractAutomodule implements Automodule {
|
|
|
116
162
|
protected get writeFile() {
|
|
117
163
|
return AbstractAutomodule.writeFile
|
|
118
164
|
}
|
|
165
|
+
|
|
166
|
+
private get readFile() {
|
|
167
|
+
return AbstractAutomodule.readFile
|
|
168
|
+
}
|
|
119
169
|
}
|
|
120
170
|
|
|
121
171
|
export interface AbstractAutomoduleOptions extends BaseAutomoduleOptions {
|
|
@@ -130,4 +180,5 @@ export interface AbstractAutomoduleRunOptions {
|
|
|
130
180
|
moduleFileContent: string
|
|
131
181
|
fakeFileName: string
|
|
132
182
|
fakeFileContent: string
|
|
183
|
+
indexFileContent: string
|
|
133
184
|
}
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import { exec as execSync } from 'child_process'
|
|
2
|
-
import { readFile } from 'fs/promises'
|
|
3
|
-
import { promisify } from 'util'
|
|
4
1
|
import { Automodule, BaseAutomoduleOptions } from '../types'
|
|
5
2
|
import AbstractAutomodule from './AbstractAutomodule'
|
|
6
3
|
|
|
7
|
-
export default class ImplAutomodule
|
|
8
|
-
extends AbstractAutomodule
|
|
9
|
-
implements Automodule
|
|
10
|
-
{
|
|
4
|
+
export default class ImplAutomodule extends AbstractAutomodule {
|
|
11
5
|
public static Class?: ImplAutomoduleConstructor
|
|
12
|
-
public static exec = promisify(execSync)
|
|
13
|
-
public static readFile = readFile
|
|
14
6
|
|
|
15
7
|
private interfaceName: string
|
|
16
8
|
private implName: string
|
|
17
9
|
|
|
18
|
-
private originalIndexFile!: string
|
|
19
|
-
|
|
20
10
|
protected constructor(options: ImplAutomoduleOptions) {
|
|
21
11
|
const {
|
|
22
12
|
testSaveDir,
|
|
@@ -41,12 +31,6 @@ export default class ImplAutomodule
|
|
|
41
31
|
}
|
|
42
32
|
|
|
43
33
|
public async run() {
|
|
44
|
-
await this.generateFiles()
|
|
45
|
-
await this.updateIndexFileExports()
|
|
46
|
-
await this.bumpMinorVersion()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private async generateFiles() {
|
|
50
34
|
await this.runAbstract({
|
|
51
35
|
testFileName: `${this.implName}.test.ts`,
|
|
52
36
|
testFileContent: this.testFilePattern,
|
|
@@ -54,47 +38,10 @@ export default class ImplAutomodule
|
|
|
54
38
|
moduleFileContent: this.moduleFilePattern,
|
|
55
39
|
fakeFileName: `Fake${this.interfaceName}.ts`,
|
|
56
40
|
fakeFileContent: this.fakeFilePattern,
|
|
41
|
+
indexFileContent: this.indexFilePattern,
|
|
57
42
|
})
|
|
58
43
|
}
|
|
59
44
|
|
|
60
|
-
private async updateIndexFileExports() {
|
|
61
|
-
this.originalIndexFile = await this.loadOriginalIndexFile()
|
|
62
|
-
await this.writeFile(this.indexFilePath, this.sortedIndexFile)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
private async loadOriginalIndexFile() {
|
|
66
|
-
return await this.readFile(this.indexFilePath, 'utf-8')
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private readonly indexFilePath = './src/index.ts'
|
|
70
|
-
|
|
71
|
-
private get sortedIndexFile() {
|
|
72
|
-
const blocks = this.indexFilePattern
|
|
73
|
-
.split(/(?=\/\/)/)
|
|
74
|
-
.map((s) => s.trim())
|
|
75
|
-
.filter(Boolean)
|
|
76
|
-
|
|
77
|
-
blocks.sort((a, b) => {
|
|
78
|
-
const aKey = a.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? ''
|
|
79
|
-
const bKey = b.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? ''
|
|
80
|
-
return aKey.localeCompare(bKey)
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
return blocks.join('\n\n')
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private async bumpMinorVersion() {
|
|
87
|
-
await this.exec('yarn version --minor --no-git-tag-version')
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private get exec() {
|
|
91
|
-
return ImplAutomodule.exec
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
private get readFile() {
|
|
95
|
-
return ImplAutomodule.readFile
|
|
96
|
-
}
|
|
97
|
-
|
|
98
45
|
private get testFilePattern() {
|
|
99
46
|
return `
|
|
100
47
|
import AbstractSpruceTest, { test, assert } from '@sprucelabs/test-utils'
|
|
@@ -159,8 +106,6 @@ export default class ImplAutomodule
|
|
|
159
106
|
|
|
160
107
|
private get indexFilePattern() {
|
|
161
108
|
return `
|
|
162
|
-
${this.originalIndexFile}
|
|
163
|
-
|
|
164
109
|
// ${this.interfaceName}
|
|
165
110
|
|
|
166
111
|
export { default as ${this.implName} } from './modules/${this.implName}'
|
|
@@ -2,10 +2,7 @@ import { pathExists } from 'fs-extra'
|
|
|
2
2
|
import { Automodule, BaseAutomoduleOptions } from '../types'
|
|
3
3
|
import AbstractAutomodule from './AbstractAutomodule'
|
|
4
4
|
|
|
5
|
-
export default class UiAutomodule
|
|
6
|
-
extends AbstractAutomodule
|
|
7
|
-
implements Automodule
|
|
8
|
-
{
|
|
5
|
+
export default class UiAutomodule extends AbstractAutomodule {
|
|
9
6
|
public static Class?: UiAutomoduleConstructor
|
|
10
7
|
public static pathExists = pathExists
|
|
11
8
|
|
|
@@ -45,6 +42,7 @@ export default class UiAutomodule
|
|
|
45
42
|
moduleFileContent: this.moduleFilePattern,
|
|
46
43
|
fakeFileName: `Fake${this.componentName}.tsx`,
|
|
47
44
|
fakeFileContent: this.fakeFilePattern,
|
|
45
|
+
indexFileContent: this.indexFilePattern,
|
|
48
46
|
})
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -135,6 +133,19 @@ export default class UiAutomodule
|
|
|
135
133
|
export default Fake${this.componentName}
|
|
136
134
|
`
|
|
137
135
|
}
|
|
136
|
+
|
|
137
|
+
private get indexFilePattern() {
|
|
138
|
+
return `
|
|
139
|
+
// ${this.componentName}
|
|
140
|
+
|
|
141
|
+
export { default as ${this.componentName} } from './ui/${this.componentName}'
|
|
142
|
+
export * from './ui/${this.componentName}'
|
|
143
|
+
|
|
144
|
+
export { default as Fake${this.componentName} } from './testDoubles/${this.componentName}/Fake${this.componentName}'
|
|
145
|
+
export * from './testDoubles/${this.componentName}/Fake${this.componentName}'
|
|
146
|
+
|
|
147
|
+
`
|
|
148
|
+
}
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
export type UiAutomoduleConstructor = new (
|