node-cli-tester 21.0.17 → 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.
Files changed (36) hide show
  1. package/browser/package.json +1 -1
  2. package/browser-prod/package.json +1 -1
  3. package/lib/build-info._auto-generated_.d.ts +1 -1
  4. package/lib/build-info._auto-generated_.js +1 -1
  5. package/lib/package.json +1 -1
  6. package/lib-prod/base-project-structure.backend.js +73 -0
  7. package/lib-prod/{build-info._auto-generated_.ts → build-info._auto-generated_.js} +1 -2
  8. package/lib-prod/cli-test.backend.js +137 -0
  9. package/lib-prod/env/{env.angular-node-app.ts → env.angular-node-app.js} +1 -1
  10. package/lib-prod/env/{env.docs-webapp.ts → env.docs-webapp.js} +1 -1
  11. package/lib-prod/env/{env.electron-app.ts → env.electron-app.js} +1 -1
  12. package/lib-prod/env/{env.mobile-app.ts → env.mobile-app.js} +1 -1
  13. package/lib-prod/env/{env.npm-lib-and-cli-tool.ts → env.npm-lib-and-cli-tool.js} +1 -1
  14. package/lib-prod/env/{env.vscode-plugin.ts → env.vscode-plugin.js} +1 -1
  15. package/lib-prod/{index._auto-generated_.ts → index._auto-generated_.js} +1 -1
  16. package/lib-prod/{index.ts → index.js} +1 -1
  17. package/lib-prod/meta-content-md.backend.js +243 -0
  18. package/lib-prod/migrations/index.js +2 -0
  19. package/lib-prod/migrations/{migrations_index._auto-generated_.ts → migrations_index._auto-generated_.js} +0 -2
  20. package/lib-prod/node-cli-tester.js +199 -0
  21. package/lib-prod/package.json +1 -1
  22. package/lib-prod/spec-templates.backend.js +100 -0
  23. package/lib-prod/start.backend.js +25 -0
  24. package/package.json +1 -1
  25. package/websql/package.json +1 -1
  26. package/websql-prod/package.json +1 -1
  27. package/lib-prod/base-project-structure.backend.ts +0 -83
  28. package/lib-prod/cli-test.backend.ts +0 -182
  29. package/lib-prod/lib-info.md +0 -8
  30. package/lib-prod/meta-content-md.backend.ts +0 -320
  31. package/lib-prod/migrations/index.ts +0 -2
  32. package/lib-prod/migrations/migrations-info.md +0 -6
  33. package/lib-prod/node-cli-tester.ts +0 -234
  34. package/lib-prod/spec-templates.backend.ts +0 -105
  35. package/lib-prod/start.backend.ts +0 -32
  36. /package/lib-prod/env/{index.ts → index.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-cli-tester/browser",
3
- "version": "21.0.17",
3
+ "version": "21.0.19",
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/browser-prod",
3
- "version": "21.0.17",
3
+ "version": "21.0.19",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.0",
6
6
  "@angular/core": "^21.0.0"
@@ -21,4 +21,4 @@ export declare const CURRENT_PACKAGE_TAON_VERSION = "v21";
21
21
  /**
22
22
  * Autogenerated by current cli tool. Use *tnp release* to bump version.
23
23
  */
24
- export declare const CURRENT_PACKAGE_VERSION = "21.0.17";
24
+ export declare const CURRENT_PACKAGE_VERSION = "21.0.19";
@@ -25,6 +25,6 @@ exports.CURRENT_PACKAGE_TAON_VERSION = 'v21';
25
25
  /**
26
26
  * Autogenerated by current cli tool. Use *tnp release* to bump version.
27
27
  */
28
- exports.CURRENT_PACKAGE_VERSION = '21.0.17';
28
+ exports.CURRENT_PACKAGE_VERSION = '21.0.19';
29
29
  // THIS FILE IS GENERATED - DO NOT MODIFY
30
30
  //# sourceMappingURL=build-info._auto-generated_.js.map
package/lib/package.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "node-cli-tester/lib",
3
- "version": "21.0.17"
3
+ "version": "21.0.19"
4
4
  }
@@ -0,0 +1,73 @@
1
+ //#region imports
2
+ import { path, ___NS__first } from 'tnp-core/lib-prod';
3
+ import { Helpers__NS__exists, Helpers__NS__foldersFrom, Helpers__NS__isFolder, Helpers__NS__log, Helpers__NS__mkdirp, Helpers__NS__readFile, Helpers__NS__removeFolderIfExists, Helpers__NS__writeFile, HelpersTaon__NS__checksum, HelpersTaon__NS__copy, HelpersTaon__NS__copyFile } from 'tnp-helpers/lib-prod';
4
+ //#endregion
5
+ export class BaseProjectStructure {
6
+ static { this.BASE_STRUCTURES_FOLDER = 'base-structures'; }
7
+ get baseStructureHash() {
8
+ return path.basename(this.cwd);
9
+ }
10
+ get projectPathBasename() {
11
+ return ___NS__first(path.basename(this.cwd).split('__'));
12
+ }
13
+ constructor(cwd) {
14
+ this.cwd = cwd;
15
+ }
16
+ copyto(destinationCwd, basename) {
17
+ HelpersTaon__NS__copy(this.cwd, path.join(destinationCwd, basename ? basename : this.projectPathBasename));
18
+ }
19
+ static allBaseStructures(cwd) {
20
+ const folderPath = path.join(cwd, this.BASE_STRUCTURES_FOLDER);
21
+ return Helpers__NS__foldersFrom(folderPath).map(f => new BaseProjectStructure(f));
22
+ }
23
+ static generate(project) {
24
+ const that = this;
25
+ const orgCwd = path.join(project.location);
26
+ const files = []; //= project.forEmptyStructure();
27
+ const filesWithoutLinks = files.filter(f => !f.relativeLinkFrom);
28
+ let hash = files.length.toString();
29
+ for (let index = 0; index < filesWithoutLinks.length; index++) {
30
+ const file = filesWithoutLinks[index];
31
+ const abasolutePAth = path.join(orgCwd, file.relativePath);
32
+ hash +=
33
+ (file.relativePath.length + 1).toString() +
34
+ (Helpers__NS__isFolder(abasolutePAth)
35
+ ? ''
36
+ : (Helpers__NS__readFile(abasolutePAth)?.length + 1).toString());
37
+ }
38
+ hash = `${project.name}__${HelpersTaon__NS__checksum(hash)}`;
39
+ return {
40
+ insideIfNotExists(destinationCwd) {
41
+ const destStruct = path.join(destinationCwd, that.BASE_STRUCTURES_FOLDER, hash);
42
+ if (Helpers__NS__exists(destStruct)) {
43
+ Helpers__NS__log(`Base structure with name: ${hash}`);
44
+ return hash;
45
+ }
46
+ Helpers__NS__removeFolderIfExists(destStruct);
47
+ for (let index = 0; index < filesWithoutLinks.length; index++) {
48
+ const file = filesWithoutLinks[index];
49
+ const orgPath = path.join(orgCwd, file.relativePath);
50
+ const destPath = path.join(destStruct, file.relativePath);
51
+ Helpers__NS__mkdirp(path.dirname(destPath));
52
+ if (Helpers__NS__isFolder(orgPath)) {
53
+ if (file.includeContent) {
54
+ HelpersTaon__NS__copy(orgPath, destPath);
55
+ }
56
+ else {
57
+ Helpers__NS__mkdirp(destPath);
58
+ }
59
+ }
60
+ else {
61
+ if (file.includeContent) {
62
+ HelpersTaon__NS__copyFile(orgPath, destPath);
63
+ }
64
+ else {
65
+ Helpers__NS__writeFile(destPath, '');
66
+ }
67
+ }
68
+ }
69
+ return hash;
70
+ },
71
+ };
72
+ }
73
+ }
@@ -22,6 +22,5 @@ export const CURRENT_PACKAGE_TAON_VERSION = 'v21';
22
22
  /**
23
23
  * Autogenerated by current cli tool. Use *tnp release* to bump version.
24
24
  */
25
- export const CURRENT_PACKAGE_VERSION = '21.0.17';
25
+ export const CURRENT_PACKAGE_VERSION = '21.0.19';
26
26
  // THIS FILE IS GENERATED - DO NOT MODIFY
27
-
@@ -0,0 +1,137 @@
1
+ //#region imports
2
+ import { path, ___NS__isUndefined, ___NS__kebabCase } from 'tnp-core/lib-prod';
3
+ import { config } from 'tnp-core/lib-prod';
4
+ import { Helpers__NS__createSymLink, Helpers__NS__exists, Helpers__NS__foldersFrom, Helpers__NS__mkdirp, Helpers__NS__readJson, Helpers__NS__writeFile } from 'tnp-helpers/lib-prod';
5
+ import { MetaMd } from './meta-content-md.backend';
6
+ import { CLASS } from 'typescript-class-helpers/lib-prod';
7
+ //#endregion
8
+ export class CliTest {
9
+ static { this.NAME_FOR_CLI_TESTS_FOLDER = 'src/tests/tests-cli'; }
10
+ //#region singleton / static inst
11
+ static { this.instances = {}; }
12
+ static allFrom(cwd) {
13
+ const folderWithTests = path.join(cwd, this.NAME_FOR_CLI_TESTS_FOLDER);
14
+ const folders = Helpers__NS__foldersFrom(folderWithTests);
15
+ const tests = folders.map(f => CliTest.from(f)).filter(f => !!f);
16
+ return tests;
17
+ }
18
+ static getBy(cwd, timeHash) {
19
+ return this.allFrom(cwd).find(c => !___NS__isUndefined(c.metaMd.all.find(c => c.readonlyMetaJson.timeHash === timeHash)));
20
+ }
21
+ static from(cwd, testName) {
22
+ if (!testName) {
23
+ testName = path.basename(cwd);
24
+ cwd = path.dirname(cwd);
25
+ }
26
+ if (!CliTest.instances[cwd]) {
27
+ CliTest.instances[cwd] = {};
28
+ }
29
+ if (!CliTest.instances[cwd][testName]) {
30
+ CliTest.instances[cwd][testName] = new CliTest(cwd, testName);
31
+ }
32
+ return CliTest.instances[cwd][testName];
33
+ }
34
+ //#endregion
35
+ //#region getters
36
+ //#region getters / meta md
37
+ get metaMd() {
38
+ const that = this;
39
+ return {
40
+ get all() {
41
+ return MetaMd.allInstancesFrom(that.testDirnamePath);
42
+ },
43
+ async add(originalFilePath, baseCwd, NodeCliTestrClass) {
44
+ await MetaMd.preserveFiles(originalFilePath, that.testDirnamePath, baseCwd, NodeCliTestrClass.foundProjectsFn, that.cwd);
45
+ }
46
+ };
47
+ }
48
+ //#endregion
49
+ //#region getters / pathes
50
+ get firedev_jsonc() {
51
+ return path.join(this.testDirnamePath, config.file.firedev_jsonc);
52
+ }
53
+ get packageJsonPath() {
54
+ return path.join(this.testDirnamePath, config.file.package_json);
55
+ }
56
+ get gitignorePath() {
57
+ return path.join(this.testDirnamePath, config.file._gitignore);
58
+ }
59
+ get specTsPath() {
60
+ return path.join(this.testDirnamePath, `${___NS__kebabCase(this.testName)}.spec.ts`);
61
+ }
62
+ //#endregion
63
+ //#endregion
64
+ //#region constructor / init
65
+ constructor(cwd, testName) {
66
+ this.cwd = cwd;
67
+ this.testName = testName;
68
+ cwd = cwd.endsWith(CliTest.NAME_FOR_CLI_TESTS_FOLDER) ? cwd.replace(CliTest.NAME_FOR_CLI_TESTS_FOLDER, '') : cwd;
69
+ this.cwd = cwd;
70
+ this.testDirnamePath = path.join(cwd, CliTest.NAME_FOR_CLI_TESTS_FOLDER, ___NS__kebabCase(this.testName));
71
+ const pathToTempEnvs = path.join(cwd, config.folder.tmpTestsEnvironments);
72
+ const pathToEnvs = path.join(cwd, config.folder.testsEnvironments);
73
+ Helpers__NS__createSymLink(pathToTempEnvs, pathToEnvs, {
74
+ continueWhenExistedFolderDoesntExists: true
75
+ });
76
+ if (Helpers__NS__exists(this.firedev_jsonc)) {
77
+ const testNameFromPJ5 = Helpers__NS__readJson(this.firedev_jsonc, {}, true).description;
78
+ if (testNameFromPJ5) {
79
+ testName = testNameFromPJ5;
80
+ this.testName = testName;
81
+ }
82
+ }
83
+ }
84
+ //#endregion
85
+ //#region public api
86
+ //#region regenerate
87
+ async regenerateFiles() {
88
+ if (!Helpers__NS__exists(this.testDirnamePath)) {
89
+ Helpers__NS__mkdirp(this.testDirnamePath);
90
+ }
91
+ this.regeneratePackageJson5();
92
+ let TestTemplatesClass = CLASS.getBy('TestTemplates');
93
+ if (!TestTemplatesClass) {
94
+ TestTemplatesClass = await (await import('./spec-templates.backend')).TestTemplates;
95
+ }
96
+ TestTemplatesClass.regenerateSpecTs(this.specTsPath, this.testName);
97
+ this.regenerateGitIgnore();
98
+ }
99
+ //#endregion
100
+ //#endregion
101
+ //#region private methods
102
+ //#region regenerate package json 5
103
+ regeneratePackageJson5() {
104
+ if (!Helpers__NS__exists(this.firedev_jsonc)) {
105
+ Helpers__NS__writeFile(this.firedev_jsonc,
106
+ //#region content of package.json5
107
+ `{
108
+ // generated from basename
109
+ "name": "${___NS__kebabCase(this.testName)}",
110
+ "description": "${this.testName}",
111
+ "tnp": {
112
+ "type": "cli-test"
113
+ },
114
+ "version": "0.0.0",
115
+ }`
116
+ //#endregion
117
+ );
118
+ }
119
+ }
120
+ //#endregion
121
+ //#region regenerate gitignore
122
+ regenerateGitIgnore() {
123
+ Helpers__NS__writeFile(this.gitignorePath,
124
+ //#region content of .gitignore
125
+ `
126
+ /**/*.*
127
+ !/.gitignore
128
+ !/${path.basename(this.specTsPath)}
129
+ !/package.json
130
+ !/package.json5
131
+ !/*.md
132
+
133
+ `
134
+ //#endregion
135
+ );
136
+ }
137
+ }
@@ -63,4 +63,4 @@ export const ENV_ANGULAR_NODE_APP_IS_CI_PROCESS = undefined;
63
63
  export const ENV_ANGULAR_NODE_APP_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_ANGULAR_NODE_APP_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_ANGULAR_NODE_APP_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -63,4 +63,4 @@ export const ENV_DOCS_WEBAPP_IS_CI_PROCESS = undefined;
63
63
  export const ENV_DOCS_WEBAPP_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_DOCS_WEBAPP_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_DOCS_WEBAPP_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -63,4 +63,4 @@ export const ENV_ELECTRON_APP_IS_CI_PROCESS = undefined;
63
63
  export const ENV_ELECTRON_APP_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_ELECTRON_APP_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_ELECTRON_APP_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -63,4 +63,4 @@ export const ENV_MOBILE_APP_IS_CI_PROCESS = undefined;
63
63
  export const ENV_MOBILE_APP_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_MOBILE_APP_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_MOBILE_APP_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -63,4 +63,4 @@ export const ENV_NPM_LIB_AND_CLI_TOOL_IS_CI_PROCESS = undefined;
63
63
  export const ENV_NPM_LIB_AND_CLI_TOOL_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_NPM_LIB_AND_CLI_TOOL_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_NPM_LIB_AND_CLI_TOOL_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -63,4 +63,4 @@ export const ENV_VSCODE_PLUGIN_IS_CI_PROCESS = undefined;
63
63
  export const ENV_VSCODE_PLUGIN_DOCKER_ADDITIONAL_CONTAINER = undefined;
64
64
  export const ENV_VSCODE_PLUGIN_DOCKER_SKIP_START_IN_ORDER = undefined;
65
65
  export const ENV_VSCODE_PLUGIN_DOCKER_SKIP_USING_MYSQL_DB = undefined;
66
- // THIS FILE IS GENERATED - DO NOT MODIFY
66
+ // THIS FILE IS GENERATED - DO NOT MODIFY
@@ -2,4 +2,4 @@
2
2
  // This file is auto-generated during init process. Do not modify.
3
3
  // This is only placeholder.
4
4
  // Use property "shouldGenerateAutogenIndexFile: true"
5
- // in taon.jsonc to enable ts exports auto generation.
5
+ // in taon.jsonc to enable ts exports auto generation.
@@ -3,4 +3,4 @@ export { NodeCliTester } from './node-cli-tester';
3
3
  export { TestTemplates } from './spec-templates.backend';
4
4
  export { CliTest } from './cli-test.backend';
5
5
  export { run } from './start.backend';
6
- //#endregion
6
+ //#endregion
@@ -0,0 +1,243 @@
1
+ //#region imports
2
+ import * as glob from 'glob';
3
+ import { path, ___NS__first, ___NS__isObject, ___NS__keys, ___NS__maxBy, ___NS__merge, ___NS__minBy, Utils__NS__uniqArray } from 'tnp-core/lib-prod';
4
+ import { config } from 'tnp-core/lib-prod';
5
+ import { BaseProject as Project, Helpers__NS__createSymLink, Helpers__NS__error, Helpers__NS__exists, Helpers__NS__isFolder, Helpers__NS__log, Helpers__NS__mkdirp, Helpers__NS__parse, Helpers__NS__readFile, Helpers__NS__removeFolderIfExists, Helpers__NS__stringify, Helpers__NS__writeFile } from 'tnp-helpers/lib-prod';
6
+ import { CLASS } from 'typescript-class-helpers/lib-prod';
7
+ import { BaseProjectStructure } from './base-project-structure.backend';
8
+ //#endregion
9
+ /**
10
+ * Special forma of .md for keeping metadata, testfile, and test template for file
11
+ */
12
+ export class MetaMd {
13
+ //#region static fields
14
+ static { this.JSON_PART = '@jsonPart'; }
15
+ static { this.FILE_CONTENT_PART = '@fileContentPart'; }
16
+ static { this.TEST_PART = '@testPart'; }
17
+ //#region static fields / create
18
+ static async create(json, fileContent, testContent) {
19
+ return await create((___NS__isObject(json) ? Helpers__NS__stringify(json) : json), fileContent, testContent);
20
+ }
21
+ //#endregion
22
+ //#region static fields / preserve file
23
+ static async preserveFiles(originalAnyTypeFiles, destinationFolder, editorCwd, foundProjectsFn = (a) => a, baseProjectsStructurePath, // navi-cli folder or current folder,
24
+ overrideThisFileName = void 0, overrideTimehash = void 0) {
25
+ const properDestName = overrideThisFileName ? overrideThisFileName :
26
+ `${path.basename(___NS__first(originalAnyTypeFiles))}.${config.file.meta_config_md}`; // TODO later menu to confirm name
27
+ if (!Helpers__NS__isFolder(destinationFolder)) {
28
+ Helpers__NS__error(`[tnp-helpers][meta-content-md] Destination folder "${destinationFolder}"
29
+ is not a folder`, false, true);
30
+ }
31
+ let foundedProjectsInPath = resolveFoundedProject(originalAnyTypeFiles, editorCwd, foundProjectsFn);
32
+ const mostBaseLocationFound = ___NS__minBy(foundedProjectsInPath, p => p.location.length).location;
33
+ // console.log(foundedProjectsInPath.map(p => p.location))
34
+ const projects = foundedProjectsInPath
35
+ .reduce((a, b) => {
36
+ const baseStructureHash = BaseProjectStructure.generate(b).insideIfNotExists(baseProjectsStructurePath);
37
+ return ___NS__merge(a, {
38
+ [path.join(path.basename(mostBaseLocationFound), b.location.replace(mostBaseLocationFound, ''))]: {
39
+ githash: b.git.lastCommitHash(),
40
+ name: b.name,
41
+ baseStructureHash,
42
+ }
43
+ });
44
+ }, {});
45
+ const timeHash = overrideTimehash ? overrideTimehash : (+new Date).toString(36);
46
+ const c = await MetaMd.create({
47
+ orgFileBasenames: originalAnyTypeFiles.map(a => path.basename(a)),
48
+ orgRelativePathes: originalAnyTypeFiles.map(a => {
49
+ return path.join(path.basename(mostBaseLocationFound), a.replace(mostBaseLocationFound, ''));
50
+ }),
51
+ projects,
52
+ firstProjectBasename: path.basename(mostBaseLocationFound),
53
+ timeHash,
54
+ }, originalAnyTypeFiles.map(a => Helpers__NS__readFile(a)));
55
+ Helpers__NS__writeFile(path.join(destinationFolder, properDestName), c);
56
+ }
57
+ //#endregion
58
+ async addFiles(newFilesPathes, destinationFolder, editorCwd, foundProjectFn = void 0, baseProjectsStructurePath) {
59
+ let foundedProjectsInPath = resolveFoundedProject(newFilesPathes, editorCwd, foundProjectFn);
60
+ const mostBaseLocationFound = ___NS__minBy(foundedProjectsInPath, p => p.location.length).location;
61
+ newFilesPathes = Utils__NS__uniqArray([
62
+ ...newFilesPathes,
63
+ ...this.readonlyMetaJson.orgRelativePathes.map(a => {
64
+ return path.join(path.dirname(mostBaseLocationFound), a);
65
+ }),
66
+ ]);
67
+ newFilesPathes.forEach(f => {
68
+ if (!Helpers__NS__exists(f)) {
69
+ Helpers__NS__error(`File doesn't exists`, false, true);
70
+ }
71
+ });
72
+ await MetaMd.preserveFiles(newFilesPathes, destinationFolder, editorCwd, foundProjectFn, baseProjectsStructurePath, path.basename(this.filePath), this.readonlyMetaJson.timeHash);
73
+ }
74
+ //#region static fields / handle instance from meta-content.md file
75
+ static instanceFrom(filePath) {
76
+ return new MetaMd(filePath);
77
+ }
78
+ static allInstancesFrom(folderPath) {
79
+ return glob.sync(`${folderPath}/*.${config.file.meta_config_md}`).map(f => {
80
+ return MetaMd.instanceFrom(f);
81
+ });
82
+ }
83
+ //#endregion
84
+ //#endregion
85
+ //#region getters
86
+ get json() {
87
+ const content = Helpers__NS__readFile(this.filePath) || '';
88
+ try {
89
+ const extracted = ___NS__first(extract(content, MetaMd.JSON_PART));
90
+ const parsed = Helpers__NS__parse(extracted, true);
91
+ return parsed;
92
+ }
93
+ catch (error) {
94
+ return {};
95
+ }
96
+ }
97
+ get readonlyMetaJson() {
98
+ return Object.freeze(this.json);
99
+ }
100
+ fileContentByIndex(i) {
101
+ const content = Helpers__NS__readFile(this.filePath) || '';
102
+ const extracted = extract(content, MetaMd.FILE_CONTENT_PART)[i];
103
+ return extracted;
104
+ }
105
+ get basename() {
106
+ return path.basename(this.filePath);
107
+ }
108
+ get dirname() {
109
+ return path.dirname(this.filePath);
110
+ }
111
+ //#endregion
112
+ //#region constructor
113
+ constructor(filePath) {
114
+ this.filePath = filePath;
115
+ }
116
+ //#endregion
117
+ //#region recreate files/content/env before any tests
118
+ /**
119
+ * recate original files before any unit/intergration test
120
+ */
121
+ recreate(testCwd, cwdProj, ProjectClass = Project, onlyIfNotExists = false) {
122
+ // recreat whole structure
123
+ const hashDir = path.join(testCwd, this.json.timeHash);
124
+ if (onlyIfNotExists && Helpers__NS__exists(hashDir)) {
125
+ return;
126
+ }
127
+ Helpers__NS__removeFolderIfExists(hashDir);
128
+ Helpers__NS__mkdirp(hashDir);
129
+ const firstToFind = this.json.projects[this.json.firstProjectBasename].baseStructureHash;
130
+ const allBaseStructures = BaseProjectStructure.allBaseStructures(cwdProj);
131
+ const baseStructure = allBaseStructures.find(p => p.baseStructureHash === firstToFind);
132
+ if (!baseStructure) {
133
+ Helpers__NS__error(`[node-cli-test][regenerate] base structure was not generated for ${firstToFind}`, false, true);
134
+ }
135
+ baseStructure.copyto(hashDir);
136
+ ___NS__keys(this.json.projects)
137
+ .filter(key => key !== this.json.firstProjectBasename)
138
+ .map(key => {
139
+ const baseStructureHashChild = this.json.projects[key].baseStructureHash;
140
+ const childBaseStruct = allBaseStructures.find(p => p.baseStructureHash === baseStructureHashChild);
141
+ if (childBaseStruct) {
142
+ childBaseStruct.copyto(path.join(hashDir, path.dirname(key)), path.basename(key));
143
+ }
144
+ });
145
+ this.readonlyMetaJson.orgRelativePathes.forEach((f, i) => {
146
+ const fileToWritePath = path.join(hashDir, f);
147
+ Helpers__NS__writeFile(fileToWritePath, this.fileContentByIndex(i));
148
+ });
149
+ const proj = ProjectClass.ins.From(path.join(hashDir, this.readonlyMetaJson.firstProjectBasename));
150
+ const linksToLInk = []; // proj?.forEmptyStructure().filter(f => !!f.relativeLinkFrom) || [];
151
+ linksToLInk.forEach(l => {
152
+ const source = path.resolve(path.join(proj.location, l.relativeLinkFrom));
153
+ if (Helpers__NS__exists(source)) {
154
+ const dest = path.resolve(path.join(proj.location, l.relativePath));
155
+ Helpers__NS__createSymLink(source, dest);
156
+ }
157
+ else {
158
+ Helpers__NS__log(`[cli-tester][recreate-env] not exist ${source}`);
159
+ }
160
+ });
161
+ }
162
+ }
163
+ //#region create
164
+ async function create(json5string, fileContents, testContent) {
165
+ const metadataJSON = Helpers__NS__parse(json5string, true);
166
+ // Helpers__NS__log(`metadataJSON.orgFileBasename: ${metadataJSON.orgFileBasename}`)
167
+ if (!testContent) {
168
+ const projPath = ___NS__maxBy(___NS__keys(metadataJSON.projects).map(projRelPath => {
169
+ return { path: projRelPath, length: projRelPath.length };
170
+ }), c => c.length)?.path || '';
171
+ let TestTemplatesClass = CLASS.getBy('TestTemplates');
172
+ if (!TestTemplatesClass) {
173
+ TestTemplatesClass = await (await import('./spec-templates.backend')).TestTemplates;
174
+ }
175
+ testContent = TestTemplatesClass.testPart(metadataJSON.orgRelativePathes, projPath, metadataJSON.timeHash);
176
+ }
177
+ const filesContestString = fileContents.map((fileContent, i) => {
178
+ const ext = path.extname(metadataJSON.orgFileBasenames[i]).replace(/^\./, '');
179
+ return `\`\`\`${ext} ${MetaMd.FILE_CONTENT_PART}
180
+ ${fileContent}
181
+ \`\`\``;
182
+ }).join('\n\n');
183
+ return `
184
+ \`\`\`ts ${MetaMd.TEST_PART}
185
+ ${testContent}
186
+ \`\`\`
187
+
188
+ \`\`\`json5 ${MetaMd.JSON_PART}
189
+ ${json5string}
190
+ \`\`\`
191
+
192
+ ${filesContestString}
193
+ `.split('\n').map(l => {
194
+ return l.trim().startsWith('\`\`\`') ? l.trimLeft() : l;
195
+ }).join('\n').trim() + '\n';
196
+ }
197
+ //#endregion
198
+ //#region extract data parts from content md file
199
+ export function extract(content, PARTS_TO_FIND) {
200
+ if (!content) {
201
+ return;
202
+ }
203
+ const parts = [];
204
+ let lines = [];
205
+ const allLines = content.split('\n');
206
+ let pushingActive = false;
207
+ for (let index = 0; index < allLines.length; index++) {
208
+ const orgLine = (allLines[index] || '');
209
+ const line = orgLine.trim();
210
+ if (pushingActive) {
211
+ if (line.startsWith('\`\`\`')) {
212
+ parts.push(lines.join('\n'));
213
+ lines = [];
214
+ }
215
+ else {
216
+ lines.push(orgLine);
217
+ }
218
+ }
219
+ if (line.startsWith('\`\`\`') && (line.search(PARTS_TO_FIND) !== -1)) {
220
+ pushingActive = true;
221
+ }
222
+ }
223
+ return parts.filter(f => !!f.trim());
224
+ }
225
+ //#endregion
226
+ //#region resolve founded projects
227
+ function resolveFoundedProject(originalAnyTypeFiles, editorCwd, foundProjectFn) {
228
+ let foundedProjectsInPath = [];
229
+ for (let index = 0; index < originalAnyTypeFiles.length; index++) {
230
+ const fileAbsPath = originalAnyTypeFiles[index];
231
+ foundedProjectsInPath = [
232
+ ...foundedProjectsInPath,
233
+ ...Project.ins.allProjectFrom(fileAbsPath, editorCwd)
234
+ ];
235
+ if (foundProjectFn) {
236
+ foundedProjectsInPath = foundProjectFn(Utils__NS__uniqArray(foundedProjectsInPath, 'location'));
237
+ }
238
+ }
239
+ foundedProjectsInPath = Utils__NS__uniqArray(foundedProjectsInPath, 'location');
240
+ return foundedProjectsInPath;
241
+ }
242
+ //#endregion
243
+ //#endregion
@@ -0,0 +1,2 @@
1
+ //@ts-nocheck
2
+ export * from './migrations_index._auto-generated_';
@@ -1,5 +1,3 @@
1
1
  // THIS FILE IS GENERATED - DO NOT MODIFY
2
-
3
2
  // THIS FILE IS GENERATED - DO NOT MODIFY
4
-
5
3
  // THIS FILE IS GENERATED - DO NOT MODIFY