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