node-cli-tester 21.0.18 → 21.0.20

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.
@@ -1,196 +1,199 @@
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";
6
- class NodeCliTester {
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;
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
- return false;
149
- }));
150
- if (machingMdFile) {
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
- 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
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
- };
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "node-cli-tester/lib-prod",
3
- "version": "21.0.18"
3
+ "version": "21.0.20"
4
4
  }
@@ -1,18 +1,9 @@
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;
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
- let TestTemplates = class {
31
- //#region create test part
32
- static testPart(pathToFiles, projPath, timeHash) {
33
- const describes = `
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
- const projFolder = '${___NS__first(projPath.split("/"))}';
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((pathToFile) => `${___NS__camelCase(path.basename(pathToFile))} : \`${pathToFile.split("/").slice(1).join("/")}\``).join(",\n ")}
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((pathToFile) => `${___NS__camelCase(path.basename(pathToFile))} : path.join(cwd, projFolder, relativePathToFile.${___NS__camelCase(path.basename(pathToFile))})`).join(",\n ")}
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
- const testsImports = `
58
- ${""}
59
- ${""}
54
+ const testsImports = `
55
+ ${'' // baseImports
56
+ }
57
+ ${'' // import { Project } from '${this.PROJECT_ENTITY_LOCATION}';
58
+ }
60
59
 
61
60
  `;
62
- const result = "\n" + testsImports.trim() + `
61
+ const result = '\n'
62
+ + testsImports.trim()
63
+ + `
63
64
  describe('${projPath}',()=> {
64
65
  const cwdHash = '${timeHash}';
65
66
  ${describes}
66
67
  });
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
- `
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() + "\n"
92
- //#endregion
93
- );
91
+ `.trim() + '\n'
92
+ //#endregion
93
+ );
94
+ }
94
95
  }
95
- }
96
- //#endregion
97
96
  };
98
- __publicField(TestTemplates, "DEFAULT_COMMAND", `echo "hello world"`);
99
- __publicField(TestTemplates, "PROJECT_ENTITY_LOCATION", `tnp-helpers`);
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 "./node-cli-tester";
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
- 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;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-cli-tester",
3
- "version": "21.0.18",
3
+ "version": "21.0.20",
4
4
  "scripts": {
5
5
  "taon init": "taon init",
6
6
  "taon start": "taon start",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-cli-tester/websql",
3
- "version": "21.0.18",
3
+ "version": "21.0.20",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.0",
6
6
  "@angular/core": "^21.0.0"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-cli-tester/websql-prod",
3
- "version": "21.0.18",
3
+ "version": "21.0.20",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.0",
6
6
  "@angular/core": "^21.0.0"