node-cli-tester 21.0.18 → 21.0.19
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/browser/package.json +1 -1
- package/browser-prod/package.json +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib-prod/base-project-structure.backend.js +69 -72
- package/lib-prod/build-info._auto-generated_.js +26 -14
- package/lib-prod/cli-test.backend.js +113 -132
- package/lib-prod/env/env.angular-node-app.js +66 -130
- package/lib-prod/env/env.docs-webapp.js +66 -130
- package/lib-prod/env/env.electron-app.js +66 -130
- package/lib-prod/env/env.mobile-app.js +66 -130
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +66 -130
- package/lib-prod/env/env.vscode-plugin.js +66 -130
- package/lib-prod/env/index.js +6 -6
- package/lib-prod/index._auto-generated_.js +5 -0
- package/lib-prod/index.js +6 -10
- package/lib-prod/meta-content-md.backend.js +223 -216
- package/lib-prod/migrations/index.js +2 -1
- package/lib-prod/migrations/migrations_index._auto-generated_.js +3 -0
- package/lib-prod/node-cli-tester.js +196 -193
- package/lib-prod/package.json +1 -1
- package/lib-prod/spec-templates.backend.js +45 -50
- package/lib-prod/start.backend.js +22 -13
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
|
@@ -1,196 +1,199 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const p = testNameOrPathToTestFolder[index];
|
|
99
|
-
const c = CliTest.from(this.cwd, path.isAbsolute(p) ? path.basename(p) : p);
|
|
100
|
-
await c.regenerateFiles();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region create test and add file
|
|
105
|
-
async createTestAndAddFiles(testName, absoluteFilePathes, editorCwd = process.cwd()) {
|
|
106
|
-
await this.createTest(testName);
|
|
107
|
-
await this.addFilesToTest(testName, absoluteFilePathes, editorCwd);
|
|
108
|
-
}
|
|
109
|
-
//#endregion
|
|
110
|
-
//#region add files to
|
|
111
|
-
//#region add files to / test
|
|
112
|
-
async addFilesToTest(testNameOrPathToTestFolder, filePath, editorCwd = process.cwd()) {
|
|
113
|
-
const c = CliTest.from(this.cwd, path.isAbsolute(testNameOrPathToTestFolder) ? path.basename(testNameOrPathToTestFolder) : testNameOrPathToTestFolder);
|
|
114
|
-
await c.metaMd.add(filePath, editorCwd, CLASS.getFromObject(this));
|
|
115
|
-
}
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region add files to / meta-content.md files
|
|
118
|
-
async addFilesToMdContent(testNameOrPathToTestFolder, mdContentFileBasenameOrPath, filePaths, editorCwd = process.cwd()) {
|
|
119
|
-
const c = CliTest.from(this.cwd, path.isAbsolute(testNameOrPathToTestFolder) ? path.basename(testNameOrPathToTestFolder) : testNameOrPathToTestFolder);
|
|
120
|
-
const mdContentFileBasename = !!mdContentFileBasenameOrPath && (path.isAbsolute(mdContentFileBasenameOrPath) ? path.basename(mdContentFileBasenameOrPath) : mdContentFileBasenameOrPath);
|
|
121
|
-
const m = mdContentFileBasename && c.metaMd.all.find((a) => a.basename === mdContentFileBasename);
|
|
122
|
-
if (m) {
|
|
123
|
-
const NodeCliTestrClass = CLASS.getFromObject(this);
|
|
124
|
-
await m.addFiles(filePaths, c.testDirnamePath, editorCwd, NodeCliTestrClass.foundProjectsFn, c.cwd);
|
|
125
|
-
} else {
|
|
126
|
-
await this.addFilesToTest(testNameOrPathToTestFolder, filePaths, editorCwd);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region regenerate
|
|
132
|
-
//#region regenerate / last regenerate hash file path
|
|
133
|
-
get lastRegenerateHashFile() {
|
|
134
|
-
return path.join(this.cwd, "tmp-last-regenerate-hash-env");
|
|
135
|
-
}
|
|
136
|
-
//#endregion
|
|
137
|
-
//#region regenerate / get last regenerate manu item
|
|
138
|
-
get lastRegenerateMenuItem() {
|
|
139
|
-
const lashHash = Helpers__NS__readFile(this.lastRegenerateHashFile, "").trim();
|
|
140
|
-
if (lashHash) {
|
|
141
|
-
const allTests = CliTest.allFrom(this.cwd);
|
|
142
|
-
let machingMdFile;
|
|
143
|
-
allTests.find((a) => a.metaMd.all.find((b) => {
|
|
144
|
-
if (b.readonlyMetaJson.timeHash === lashHash) {
|
|
145
|
-
machingMdFile = b;
|
|
146
|
-
return true;
|
|
1
|
+
//#region imports
|
|
2
|
+
//#region @backend
|
|
3
|
+
import { path, ___NS__isString } from 'tnp-core/lib-prod';
|
|
4
|
+
import { BaseProject as Project, Helpers__NS__createSymLink, Helpers__NS__error, Helpers__NS__exists, Helpers__NS__log, Helpers__NS__readFile, Helpers__NS__writeFile, HelpersTaon__NS__outputToVScode } from 'tnp-helpers/lib-prod';
|
|
5
|
+
import { config } from 'tnp-core/lib-prod';
|
|
6
|
+
import { CliTest } from './cli-test.backend';
|
|
7
|
+
import { CLASS } from 'typescript-class-helpers/lib-prod';
|
|
8
|
+
//#endregion
|
|
9
|
+
//#endregion
|
|
10
|
+
export class NodeCliTester {
|
|
11
|
+
//#region @backend
|
|
12
|
+
//#region singleton
|
|
13
|
+
static { this._instances = {}; }
|
|
14
|
+
static {
|
|
15
|
+
this.ACTIONS = {
|
|
16
|
+
REGENERATE_LAST_HASH: 'regenerate-last-env-hash'
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static { this.classFn = NodeCliTester; }
|
|
20
|
+
static { this.projectClassFn = Project; }
|
|
21
|
+
static { this.foundProjectsFn = void 0; }
|
|
22
|
+
constructor(cwd = process.cwd()) {
|
|
23
|
+
this.cwd = cwd;
|
|
24
|
+
const pathToScenarios = path.join(cwd, config.folder.scenarios);
|
|
25
|
+
const pathToScenariosTemp = path.join(cwd, config.folder.tmpScenarios);
|
|
26
|
+
if (!Helpers__NS__exists(pathToScenarios)) {
|
|
27
|
+
Helpers__NS__createSymLink(pathToScenariosTemp, pathToScenarios, { continueWhenExistedFolderDoesntExists: true });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
static Instance(cwd = process.cwd()) {
|
|
31
|
+
if (!NodeCliTester._instances[cwd]) {
|
|
32
|
+
NodeCliTester._instances[cwd] = new (this.classFn)(cwd);
|
|
33
|
+
}
|
|
34
|
+
return NodeCliTester._instances[cwd];
|
|
35
|
+
}
|
|
36
|
+
static InstanceNearestTo(cwd) {
|
|
37
|
+
const proj = Project.ins.nearestTo(cwd);
|
|
38
|
+
if (!proj) {
|
|
39
|
+
Helpers__NS__error(`Nearsest project instance not found for ${cwd} `, false, true);
|
|
40
|
+
}
|
|
41
|
+
return this.Instance(proj.location);
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region get menu options
|
|
45
|
+
//#region get menu options / all tests names
|
|
46
|
+
getAllTestsNames() {
|
|
47
|
+
const names = CliTest.allFrom(this.cwd).map(c => {
|
|
48
|
+
return { label: c.testName, option: c.testDirnamePath };
|
|
49
|
+
});
|
|
50
|
+
HelpersTaon__NS__outputToVScode(names);
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region get menu options / all meta-content.md files for test (path as option)
|
|
54
|
+
getMdContentFilesForTest(testNameOrPathToTestFolder) {
|
|
55
|
+
const c = CliTest.from(this.cwd, path.isAbsolute(testNameOrPathToTestFolder) ? path.basename(testNameOrPathToTestFolder) : testNameOrPathToTestFolder);
|
|
56
|
+
const toOutput = [
|
|
57
|
+
{ label: `< create new ${config.file.meta_config_md} file >`, option: null },
|
|
58
|
+
...c.metaMd.all.map(c => {
|
|
59
|
+
const v = c.filePath;
|
|
60
|
+
return { option: v, label: `add to "${path.basename(v)}"` };
|
|
61
|
+
})
|
|
62
|
+
];
|
|
63
|
+
HelpersTaon__NS__outputToVScode(toOutput);
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region get menu options / all meta-content.md files for test (hash as option)
|
|
67
|
+
getMdContentFilesWithHash(testNameOrPathToTestFolder) {
|
|
68
|
+
const c = CliTest.from(this.cwd, path.isAbsolute(testNameOrPathToTestFolder) ? path.basename(testNameOrPathToTestFolder) : testNameOrPathToTestFolder);
|
|
69
|
+
const toOutput = [
|
|
70
|
+
...c.metaMd.all.map(c => {
|
|
71
|
+
return { option: c.readonlyMetaJson.timeHash, label: `add to "${path.basename(c.filePath)}"` };
|
|
72
|
+
})
|
|
73
|
+
];
|
|
74
|
+
HelpersTaon__NS__outputToVScode(toOutput);
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region get menu options / all tests names (with additional options for regenerate)
|
|
78
|
+
getAllTestsNamesForRegenerate() {
|
|
79
|
+
const last = this.lastRegenerateMenuItem;
|
|
80
|
+
const specialOptions = [
|
|
81
|
+
...(last ? [last] : [])
|
|
82
|
+
];
|
|
83
|
+
const names = [
|
|
84
|
+
...specialOptions,
|
|
85
|
+
...CliTest.allFrom(this.cwd).map(c => {
|
|
86
|
+
return { label: c.testName, option: c.testDirnamePath };
|
|
87
|
+
}),
|
|
88
|
+
];
|
|
89
|
+
HelpersTaon__NS__outputToVScode(names);
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region create test
|
|
94
|
+
async createTest(testNameOrPathToTestFolder) {
|
|
95
|
+
Helpers__NS__log(`Create test from node-cli-tester`);
|
|
96
|
+
if (___NS__isString(testNameOrPathToTestFolder)) {
|
|
97
|
+
testNameOrPathToTestFolder = [testNameOrPathToTestFolder];
|
|
147
98
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
99
|
+
for (let index = 0; index < testNameOrPathToTestFolder.length; index++) {
|
|
100
|
+
const p = testNameOrPathToTestFolder[index];
|
|
101
|
+
const c = CliTest.from(this.cwd, path.isAbsolute(p) ? path.basename(p) : p);
|
|
102
|
+
await c.regenerateFiles();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region create test and add file
|
|
107
|
+
async createTestAndAddFiles(testName, absoluteFilePathes, editorCwd = process.cwd()) {
|
|
108
|
+
await this.createTest(testName);
|
|
109
|
+
await this.addFilesToTest(testName, absoluteFilePathes, editorCwd);
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region add files to
|
|
113
|
+
//#region add files to / test
|
|
114
|
+
async addFilesToTest(testNameOrPathToTestFolder, filePath, editorCwd = process.cwd()) {
|
|
115
|
+
const c = CliTest.from(this.cwd, path.isAbsolute(testNameOrPathToTestFolder)
|
|
116
|
+
? path.basename(testNameOrPathToTestFolder) : testNameOrPathToTestFolder);
|
|
117
|
+
await c.metaMd.add(filePath, editorCwd, CLASS.getFromObject(this));
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region add files to / meta-content.md files
|
|
121
|
+
async addFilesToMdContent(testNameOrPathToTestFolder, mdContentFileBasenameOrPath, filePaths, editorCwd = process.cwd()) {
|
|
122
|
+
const c = CliTest.from(this.cwd, path.isAbsolute(testNameOrPathToTestFolder)
|
|
123
|
+
? path.basename(testNameOrPathToTestFolder) : testNameOrPathToTestFolder);
|
|
124
|
+
const mdContentFileBasename = !!mdContentFileBasenameOrPath && (path.isAbsolute(mdContentFileBasenameOrPath)
|
|
125
|
+
? path.basename(mdContentFileBasenameOrPath) : mdContentFileBasenameOrPath);
|
|
126
|
+
const m = mdContentFileBasename && c.metaMd.all.find(a => a.basename === mdContentFileBasename);
|
|
127
|
+
if (m) {
|
|
128
|
+
const NodeCliTestrClass = CLASS.getFromObject(this);
|
|
129
|
+
await m.addFiles(filePaths, c.testDirnamePath, editorCwd, NodeCliTestrClass.foundProjectsFn, c.cwd);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
await this.addFilesToTest(testNameOrPathToTestFolder, filePaths, editorCwd);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region regenerate
|
|
138
|
+
//#region regenerate / last regenerate hash file path
|
|
139
|
+
get lastRegenerateHashFile() {
|
|
140
|
+
return path.join(this.cwd, 'tmp-last-regenerate-hash-env');
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region regenerate / get last regenerate manu item
|
|
144
|
+
get lastRegenerateMenuItem() {
|
|
145
|
+
const lashHash = Helpers__NS__readFile(this.lastRegenerateHashFile, '').trim();
|
|
146
|
+
if (lashHash) {
|
|
147
|
+
const allTests = CliTest.allFrom(this.cwd);
|
|
148
|
+
let machingMdFile;
|
|
149
|
+
allTests.find(a => a.metaMd.all.find(b => {
|
|
150
|
+
if (b.readonlyMetaJson.timeHash === lashHash) {
|
|
151
|
+
machingMdFile = b;
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}));
|
|
156
|
+
if (machingMdFile) {
|
|
157
|
+
const NodeCliTesterClass = CLASS.getFromObject(this);
|
|
158
|
+
const res = {
|
|
159
|
+
label: ` < regenerate last hash env "${machingMdFile.readonlyMetaJson.timeHash}" `
|
|
160
|
+
+ `for project: "${machingMdFile.readonlyMetaJson.firstProjectBasename}" in `
|
|
161
|
+
+ `${machingMdFile.basename} >`,
|
|
162
|
+
option: { action: NodeCliTesterClass.ACTIONS.REGENERATE_LAST_HASH }
|
|
163
|
+
};
|
|
164
|
+
return res;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return void 0;
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region regenerate / aliases
|
|
171
|
+
async regenerate(timeHash) {
|
|
172
|
+
await this.regenerateEnvironment(timeHash);
|
|
173
|
+
}
|
|
174
|
+
async regenerateLast() {
|
|
151
175
|
const NodeCliTesterClass = CLASS.getFromObject(this);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
timeHash = Helpers__NS__readFile(this.lastRegenerateHashFile, "");
|
|
176
|
-
}
|
|
177
|
-
if (!path.isAbsolute(tempFolder)) {
|
|
178
|
-
tempFolder = path.join(this.cwd, tempFolder);
|
|
179
|
-
}
|
|
180
|
-
const c = CliTest.getBy(this.cwd, timeHash);
|
|
181
|
-
const m = c?.metaMd.all.find((a) => a.readonlyMetaJson.timeHash === timeHash);
|
|
182
|
-
if (m) {
|
|
183
|
-
const ProjectClass = NodeCliTesterClass.projectClassFn;
|
|
184
|
-
m.recreate(tempFolder, this.cwd, ProjectClass, onlyIfNotExists);
|
|
185
|
-
Helpers__NS__writeFile(this.lastRegenerateHashFile, timeHash);
|
|
186
|
-
} else {
|
|
187
|
-
Helpers__NS__error(`Not able to find test with hash ${timeHash}`, false, true);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
//#endregion
|
|
191
|
-
//#endregion
|
|
192
|
-
//#endregion
|
|
176
|
+
await this.regenerateEnvironment(NodeCliTesterClass.ACTIONS.REGENERATE_LAST_HASH);
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region regenerate / regenerate environment function
|
|
180
|
+
async regenerateEnvironment(timeHash, tempFolder = config.folder.tmpTestsEnvironments, onlyIfNotExists = false) {
|
|
181
|
+
const NodeCliTesterClass = CLASS.getFromObject(this);
|
|
182
|
+
if (timeHash === NodeCliTesterClass.ACTIONS.REGENERATE_LAST_HASH) {
|
|
183
|
+
timeHash = Helpers__NS__readFile(this.lastRegenerateHashFile, '');
|
|
184
|
+
}
|
|
185
|
+
if (!path.isAbsolute(tempFolder)) {
|
|
186
|
+
tempFolder = path.join(this.cwd, tempFolder);
|
|
187
|
+
}
|
|
188
|
+
const c = CliTest.getBy(this.cwd, timeHash);
|
|
189
|
+
const m = c?.metaMd.all.find(a => a.readonlyMetaJson.timeHash === timeHash);
|
|
190
|
+
if (m) {
|
|
191
|
+
const ProjectClass = NodeCliTesterClass.projectClassFn;
|
|
192
|
+
m.recreate(tempFolder, this.cwd, ProjectClass, onlyIfNotExists);
|
|
193
|
+
Helpers__NS__writeFile(this.lastRegenerateHashFile, timeHash);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
Helpers__NS__error(`Not able to find test with hash ${timeHash}`, false, true);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
193
199
|
}
|
|
194
|
-
export {
|
|
195
|
-
NodeCliTester
|
|
196
|
-
};
|
package/lib-prod/package.json
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (decorator = decorators[i])
|
|
8
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
-
if (kind && result) __defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
13
|
-
import { path, ___NS__camelCase, ___NS__first } from "tnp-core/lib-prod";
|
|
14
|
-
import { CLASS } from "typescript-class-helpers/lib-prod";
|
|
15
|
-
import { Helpers__NS__exists, Helpers__NS__writeFile } from "tnp-helpers/lib-prod";
|
|
1
|
+
//#region imports
|
|
2
|
+
import { path, ___NS__camelCase, ___NS__first } from 'tnp-core/lib-prod';
|
|
3
|
+
import { CLASS } from 'typescript-class-helpers/lib-prod';
|
|
4
|
+
import { Helpers__NS__exists, Helpers__NS__writeFile } from 'tnp-helpers/lib-prod';
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region base imports contant
|
|
16
7
|
const baseImports = `
|
|
17
8
|
import { _, path, crossPlatformPath } from 'tnp-core';
|
|
18
9
|
import chalk from 'chalk';
|
|
@@ -27,23 +18,29 @@ const testMeta = `
|
|
|
27
18
|
// const testName = this.test.title;
|
|
28
19
|
// const testFullName = this.test.fullTitle();
|
|
29
20
|
`.trim();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
//#endregion
|
|
22
|
+
let TestTemplates = class TestTemplates {
|
|
23
|
+
static { this.DEFAULT_COMMAND = `echo "hello world"`; }
|
|
24
|
+
static { this.PROJECT_ENTITY_LOCATION = `tnp-helpers`; }
|
|
25
|
+
//#region create test part
|
|
26
|
+
static testPart(pathToFiles, projPath, timeHash) {
|
|
27
|
+
const describes = `
|
|
34
28
|
|
|
35
29
|
it('Should pass the test with hash ' + cwdHash // chalk.hidden(cwdHash)
|
|
36
30
|
, async () => {
|
|
37
31
|
//#region resolve variables
|
|
38
|
-
${
|
|
39
|
-
|
|
32
|
+
${'' // testMeta
|
|
33
|
+
}
|
|
34
|
+
const projFolder = '${___NS__first(projPath.split('/'))}';
|
|
40
35
|
const tmpTestEnvironmentFolder = 'tmp-tests-environments';
|
|
41
36
|
const cwd = path.resolve(path.join(crossPlatformPath(__dirname), \`../../../../\${tmpTestEnvironmentFolder}\`, cwdHash));
|
|
42
37
|
const relativePathToFile = {
|
|
43
|
-
${pathToFiles.map(
|
|
38
|
+
${pathToFiles.map(pathToFile => `${___NS__camelCase(path.basename(pathToFile))} : \`${pathToFile.split('/').slice(1).join('/')}\``)
|
|
39
|
+
.join(',\n ')}
|
|
44
40
|
};
|
|
45
41
|
const absolutePathToTestFile = {
|
|
46
|
-
${pathToFiles.map(
|
|
42
|
+
${pathToFiles.map(pathToFile => `${___NS__camelCase(path.basename(pathToFile))} : path.join(cwd, projFolder, relativePathToFile.${___NS__camelCase(path.basename(pathToFile))})`)
|
|
43
|
+
.join(',\n ')}
|
|
47
44
|
};
|
|
48
45
|
await NodeCliTester.InstanceNearestTo(cwd).regenerateEnvironment(cwdHash,tmpTestEnvironmentFolder);
|
|
49
46
|
const $Project = Project || CLASS.getBy('Project') as typeof Project;
|
|
@@ -54,27 +51,30 @@ ${""}
|
|
|
54
51
|
expect(proj.runCommandGetString(\`${this.DEFAULT_COMMAND}\`)).to.be.eq('hello world');
|
|
55
52
|
});
|
|
56
53
|
`;
|
|
57
|
-
|
|
58
|
-
${
|
|
59
|
-
|
|
54
|
+
const testsImports = `
|
|
55
|
+
${'' // baseImports
|
|
56
|
+
}
|
|
57
|
+
${'' // import { Project } from '${this.PROJECT_ENTITY_LOCATION}';
|
|
58
|
+
}
|
|
60
59
|
|
|
61
60
|
`;
|
|
62
|
-
|
|
61
|
+
const result = '\n'
|
|
62
|
+
+ testsImports.trim()
|
|
63
|
+
+ `
|
|
63
64
|
describe('${projPath}',()=> {
|
|
64
65
|
const cwdHash = '${timeHash}';
|
|
65
66
|
${describes}
|
|
66
67
|
});
|
|
67
|
-
`.trim() +
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
`
|
|
68
|
+
`.trim() + '\n\n';
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region regenerate spec ts
|
|
73
|
+
static regenerateSpecTs(specTsPath, testRealName) {
|
|
74
|
+
if (!Helpers__NS__exists(specTsPath)) {
|
|
75
|
+
Helpers__NS__writeFile(specTsPath,
|
|
76
|
+
//#region content of *.spec.ts
|
|
77
|
+
`
|
|
78
78
|
${baseImports}
|
|
79
79
|
import { Project } from '${this.PROJECT_ENTITY_LOCATION}';
|
|
80
80
|
|
|
@@ -88,18 +88,13 @@ ${testMeta}
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
});
|
|
91
|
-
`.trim() +
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
`.trim() + '\n'
|
|
92
|
+
//#endregion
|
|
93
|
+
);
|
|
94
|
+
}
|
|
94
95
|
}
|
|
95
|
-
}
|
|
96
|
-
//#endregion
|
|
97
96
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
TestTemplates = __decorateClass([
|
|
101
|
-
CLASS.NAME("TestTemplates")
|
|
97
|
+
TestTemplates = __decorate([
|
|
98
|
+
CLASS.NAME('TestTemplates')
|
|
102
99
|
], TestTemplates);
|
|
103
|
-
export {
|
|
104
|
-
TestTemplates
|
|
105
|
-
};
|
|
100
|
+
export { TestTemplates };
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
import { NodeCliTester } from
|
|
2
|
-
async function run(argsv, instance = NodeCliTester.Instance()) {
|
|
1
|
+
import { NodeCliTester } from './node-cli-tester';
|
|
2
|
+
export async function run(argsv, instance = NodeCliTester.Instance()) {
|
|
3
|
+
// const command: Lowercase<keyof NodeCliTester> = argsv.shift().toLowerCase() as any;
|
|
4
|
+
// TODO
|
|
5
|
+
// const command = argsv.shift().toLowerCase() as any; // TODO up tsc version
|
|
6
|
+
// for (const key in instance) {
|
|
7
|
+
// if (key.toLowerCase() === command && _.isFunction(instance[key])) {
|
|
8
|
+
// const argsToPass: string[] = argsv
|
|
9
|
+
// .filter(a => !a.startsWith('--'))
|
|
10
|
+
// .map(a => parseArr(a)) as any;
|
|
11
|
+
// await Helpers.runSyncOrAsync({ functionFn: [key, instance], arrayOfParams: argsToPass });
|
|
12
|
+
// }
|
|
13
|
+
// }
|
|
14
|
+
// process.exit(0);
|
|
3
15
|
}
|
|
4
16
|
function parseArr(a) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
if (a === 'null') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
if (a.startsWith('[') && a.endsWith(']')) {
|
|
21
|
+
const elems = a.slice(1, a.length - 1).split(',');
|
|
22
|
+
return elems;
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
13
25
|
}
|
|
14
|
-
export {
|
|
15
|
-
run
|
|
16
|
-
};
|
package/package.json
CHANGED
package/websql/package.json
CHANGED