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.
- 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 +73 -0
- package/lib-prod/{build-info._auto-generated_.ts → build-info._auto-generated_.js} +1 -2
- package/lib-prod/cli-test.backend.js +137 -0
- package/lib-prod/env/{env.angular-node-app.ts → env.angular-node-app.js} +1 -1
- package/lib-prod/env/{env.docs-webapp.ts → env.docs-webapp.js} +1 -1
- package/lib-prod/env/{env.electron-app.ts → env.electron-app.js} +1 -1
- package/lib-prod/env/{env.mobile-app.ts → env.mobile-app.js} +1 -1
- package/lib-prod/env/{env.npm-lib-and-cli-tool.ts → env.npm-lib-and-cli-tool.js} +1 -1
- package/lib-prod/env/{env.vscode-plugin.ts → env.vscode-plugin.js} +1 -1
- package/lib-prod/{index._auto-generated_.ts → index._auto-generated_.js} +1 -1
- package/lib-prod/{index.ts → index.js} +1 -1
- package/lib-prod/meta-content-md.backend.js +243 -0
- package/lib-prod/migrations/index.js +2 -0
- package/lib-prod/migrations/{migrations_index._auto-generated_.ts → migrations_index._auto-generated_.js} +0 -2
- package/lib-prod/node-cli-tester.js +199 -0
- package/lib-prod/package.json +1 -1
- package/lib-prod/spec-templates.backend.js +100 -0
- package/lib-prod/start.backend.js +25 -0
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
- package/lib-prod/base-project-structure.backend.ts +0 -83
- package/lib-prod/cli-test.backend.ts +0 -182
- package/lib-prod/lib-info.md +0 -8
- package/lib-prod/meta-content-md.backend.ts +0 -320
- package/lib-prod/migrations/index.ts +0 -2
- package/lib-prod/migrations/migrations-info.md +0 -6
- package/lib-prod/node-cli-tester.ts +0 -234
- package/lib-prod/spec-templates.backend.ts +0 -105
- package/lib-prod/start.backend.ts +0 -32
- /package/lib-prod/env/{index.ts → index.js} +0 -0
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
//#region imports
|
|
2
|
-
import * as glob from 'glob';
|
|
3
|
-
import { path, ___NS__add, ___NS__after, ___NS__ary, ___NS__assign, ___NS__assignIn, ___NS__assignInWith, ___NS__assignWith, ___NS__at, ___NS__attempt, ___NS__before, ___NS__bind, ___NS__bindAll, ___NS__bindKey, ___NS__camelCase, ___NS__capitalize, ___NS__castArray, ___NS__ceil, ___NS__chain, ___NS__chunk, ___NS__clamp, ___NS__clone, ___NS__cloneDeep, ___NS__cloneDeepWith, ___NS__cloneWith, ___NS__compact, ___NS__concat, ___NS__cond, ___NS__conforms, ___NS__conformsTo, ___NS__constant, ___NS__countBy, ___NS__create, ___NS__curry, ___NS__curryRight, ___NS__debounce, ___NS__deburr, ___NS__defaults, ___NS__defaultsDeep, ___NS__defaultTo, ___NS__defer, ___NS__delay, ___NS__difference, ___NS__differenceBy, ___NS__differenceWith, ___NS__divide, ___NS__drop, ___NS__dropRight, ___NS__dropRightWhile, ___NS__dropWhile, ___NS__each, ___NS__eachRight, ___NS__endsWith, ___NS__entries, ___NS__entriesIn, ___NS__eq, ___NS__escape, ___NS__escapeRegExp, ___NS__every, ___NS__extend, ___NS__extendWith, ___NS__fill, ___NS__filter, ___NS__find, ___NS__findIndex, ___NS__findKey, ___NS__findLast, ___NS__findLastIndex, ___NS__findLastKey, ___NS__first, ___NS__flatMap, ___NS__flatMapDeep, ___NS__flatMapDepth, ___NS__flatten, ___NS__flattenDeep, ___NS__flattenDepth, ___NS__flip, ___NS__floor, ___NS__flow, ___NS__flowRight, ___NS__forEach, ___NS__forEachRight, ___NS__forIn, ___NS__forInRight, ___NS__forOwn, ___NS__forOwnRight, ___NS__fromPairs, ___NS__functions, ___NS__functionsIn, ___NS__get, ___NS__groupBy, ___NS__gt, ___NS__gte, ___NS__has, ___NS__hasIn, ___NS__head, ___NS__identity, ___NS__includes, ___NS__indexOf, ___NS__initial, ___NS__inRange, ___NS__intersection, ___NS__intersectionBy, ___NS__intersectionWith, ___NS__invert, ___NS__invertBy, ___NS__invoke, ___NS__invokeMap, ___NS__isArguments, ___NS__isArray, ___NS__isArrayBuffer, ___NS__isArrayLike, ___NS__isArrayLikeObject, ___NS__isBoolean, ___NS__isBuffer, ___NS__isDate, ___NS__isElement, ___NS__isEmpty, ___NS__isEqual, ___NS__isEqualWith, ___NS__isError, ___NS__isFinite, ___NS__isFunction, ___NS__isInteger, ___NS__isLength, ___NS__isMap, ___NS__isMatch, ___NS__isMatchWith, ___NS__isNaN, ___NS__isNative, ___NS__isNil, ___NS__isNull, ___NS__isNumber, ___NS__isObject, ___NS__isObjectLike, ___NS__isPlainObject, ___NS__isRegExp, ___NS__isSafeInteger, ___NS__isSet, ___NS__isString, ___NS__isSymbol, ___NS__isTypedArray, ___NS__isUndefined, ___NS__isWeakMap, ___NS__isWeakSet, ___NS__iteratee, ___NS__join, ___NS__kebabCase, ___NS__keyBy, ___NS__keys, ___NS__keysIn, ___NS__last, ___NS__lastIndexOf, ___NS__lowerCase, ___NS__lowerFirst, ___NS__lt, ___NS__lte, ___NS__map, ___NS__mapKeys, ___NS__mapValues, ___NS__matches, ___NS__matchesProperty, ___NS__max, ___NS__maxBy, ___NS__mean, ___NS__meanBy, ___NS__memoize, ___NS__merge, ___NS__mergeWith, ___NS__method, ___NS__methodOf, ___NS__min, ___NS__minBy, ___NS__mixin, ___NS__multiply, ___NS__negate, ___NS__noop, ___NS__now, ___NS__nth, ___NS__nthArg, ___NS__omit, ___NS__omitBy, ___NS__once, ___NS__orderBy, ___NS__over, ___NS__overArgs, ___NS__overEvery, ___NS__overSome, ___NS__pad, ___NS__padEnd, ___NS__padStart, ___NS__parseInt, ___NS__partial, ___NS__partialRight, ___NS__partition, ___NS__pick, ___NS__pickBy, ___NS__property, ___NS__propertyOf, ___NS__pull, ___NS__pullAll, ___NS__pullAllBy, ___NS__pullAllWith, ___NS__pullAt, ___NS__random, ___NS__range, ___NS__rangeRight, ___NS__rearg, ___NS__reduce, ___NS__reduceRight, ___NS__reject, ___NS__remove, ___NS__repeat, ___NS__replace, ___NS__rest, ___NS__result, ___NS__reverse, ___NS__round, ___NS__sample, ___NS__sampleSize, ___NS__set, ___NS__setWith, ___NS__shuffle, ___NS__size, ___NS__slice, ___NS__snakeCase, ___NS__some, ___NS__sortBy, ___NS__sortedIndex, ___NS__sortedIndexBy, ___NS__sortedIndexOf, ___NS__sortedLastIndex, ___NS__sortedLastIndexBy, ___NS__sortedLastIndexOf, ___NS__sortedUniq, ___NS__sortedUniqBy, ___NS__split, ___NS__spread, ___NS__startCase, ___NS__startsWith, ___NS__stubArray, ___NS__stubFalse, ___NS__stubObject, ___NS__stubString, ___NS__stubTrue, ___NS__subtract, ___NS__sum, ___NS__sumBy, ___NS__tail, ___NS__take, ___NS__takeRight, ___NS__takeRightWhile, ___NS__takeWhile, ___NS__tap, ___NS__template, ___NS__templateSettings, ___NS__throttle, ___NS__thru, ___NS__times, ___NS__toArray, ___NS__toFinite, ___NS__toInteger, ___NS__toLength, ___NS__toLower, ___NS__toNumber, ___NS__toPairs, ___NS__toPairsIn, ___NS__toPath, ___NS__toPlainObject, ___NS__toSafeInteger, ___NS__toString, ___NS__toUpper, ___NS__transform, ___NS__trim, ___NS__trimEnd, ___NS__trimStart, ___NS__truncate, ___NS__unary, ___NS__unescape, ___NS__union, ___NS__unionBy, ___NS__unionWith, ___NS__uniq, ___NS__uniqBy, ___NS__uniqueId, ___NS__uniqWith, ___NS__unset, ___NS__unzip, ___NS__unzipWith, ___NS__update, ___NS__updateWith, ___NS__upperCase, ___NS__upperFirst, ___NS__values, ___NS__valuesIn, ___NS__without, ___NS__words, ___NS__wrap, ___NS__xor, ___NS__xorBy, ___NS__xorWith, ___NS__zip, ___NS__zipObject, ___NS__zipObjectDeep, ___NS__zipWith, Utils__NS__binary__NS__base64toBlob, Utils__NS__binary__NS__base64toBuffer, Utils__NS__binary__NS__base64toDbBinaryFormat, Utils__NS__binary__NS__blobToArrayBuffer, Utils__NS__binary__NS__blobToBase64, Utils__NS__binary__NS__blobToBuffer, Utils__NS__binary__NS__blobToFile, Utils__NS__binary__NS__blobToJson, Utils__NS__binary__NS__blobToText, Utils__NS__binary__NS__bufferToBase64, Utils__NS__binary__NS__bufferToBlob, Utils__NS__binary__NS__bufferToText, Utils__NS__binary__NS__dbBinaryFormatToBase64, Utils__NS__binary__NS__dbBinaryFormatToText, Utils__NS__binary__NS__fileToBlob, Utils__NS__binary__NS__fileToText, Utils__NS__binary__NS__getBlobFrom, Utils__NS__binary__NS__jsonToBlob, Utils__NS__binary__NS__textToBlob, Utils__NS__binary__NS__textToBuffer, Utils__NS__binary__NS__textToDbBinaryFormat, Utils__NS__binary__NS__textToFile, Utils__NS__camelize, Utils__NS__css__NS__numValue, Utils__NS__DbBinaryFormat, Utils__NS__DbBinaryFormatEnum, Utils__NS__DbBinaryFormatForBackend, Utils__NS__DbBinaryFormatForBrowser, Utils__NS__escapeStringForRegEx, Utils__NS__fullDate, Utils__NS__fullDateTime, Utils__NS__getFreePort, Utils__NS__removeChalkSpecialChars, Utils__NS__requireUncached, Utils__NS__sortKeys, Utils__NS__uniqArray, Utils__NS__wait, Utils__NS__waitMilliseconds } from 'tnp-core/lib-prod';
|
|
4
|
-
import { config } from 'tnp-core/lib-prod';
|
|
5
|
-
import { BaseProject as Project, Helpers__NS___fixCommand, Helpers__NS__bigMaxBuffer, Helpers__NS__checkProcess, Helpers__NS__cleanExit, Helpers__NS__clearConsole, Helpers__NS__command, Helpers__NS__commandOutputAsString, Helpers__NS__commandOutputAsStringAsync, Helpers__NS__compilationWrapper, Helpers__NS__contain, Helpers__NS__createFolder, Helpers__NS__createSymLink, Helpers__NS__error, Helpers__NS__execute, Helpers__NS__exists, Helpers__NS__filesFrom, Helpers__NS__foldersFrom, Helpers__NS__getFilesFrom, Helpers__NS__getFoldersFrom, Helpers__NS__getIsBrowser, Helpers__NS__getIsElectron, Helpers__NS__getIsNode, Helpers__NS__getIsRunningInGitBash, Helpers__NS__getIsSupportedTaonTerminal, Helpers__NS__getIsVerboseMode, Helpers__NS__getIsWebSQL, Helpers__NS__getIsWsl, Helpers__NS__getStdio, Helpers__NS__hideNodeWarnings, Helpers__NS__info, Helpers__NS__isBlob, Helpers__NS__isBuffer, Helpers__NS__isClass, Helpers__NS__isExistedSymlink, Helpers__NS__isFile, Helpers__NS__isFolder, Helpers__NS__isRunningInDocker, Helpers__NS__isRunningInLinuxGraphicsCapableEnvironment, Helpers__NS__isSymlinkFileExitedOrUnexisted, Helpers__NS__isSymlinkThatMatchesUrl, Helpers__NS__isUnexistedLink, Helpers__NS__killOnPort, Helpers__NS__killProcess, Helpers__NS__killProcessByPort, Helpers__NS__linksToFolderFrom, Helpers__NS__linksToFoldersFrom, Helpers__NS__log, Helpers__NS__logError, Helpers__NS__logInfo, Helpers__NS__logProc, Helpers__NS__logSuccess, Helpers__NS__logWarn, Helpers__NS__mediaTypeFromSrc, Helpers__NS__mkdirp, Helpers__NS__modifyLineByLine, Helpers__NS__msgCacheClear, Helpers__NS__openFolderInFileExplorer, Helpers__NS__parse, Helpers__NS__pathContainLink, Helpers__NS__questionYesNo, Helpers__NS__readFile, Helpers__NS__readJson, Helpers__NS__readJson5, Helpers__NS__readJsonC, Helpers__NS__relative, Helpers__NS__remove, Helpers__NS__removeEmptyLineFromString, Helpers__NS__removeFileIfExists, Helpers__NS__removeFolderIfExists, Helpers__NS__removeIfExists, Helpers__NS__removeSlashAtBegin, Helpers__NS__removeSlashAtEnd, Helpers__NS__removeSymlinks, Helpers__NS__renderError, Helpers__NS__replaceLinesInFile, Helpers__NS__run, Helpers__NS__runAsyncIn, Helpers__NS__runSyncIn, Helpers__NS__runSyncOrAsync, Helpers__NS__sleep, Helpers__NS__stopApplication, Helpers__NS__stringify, Helpers__NS__success, Helpers__NS__taskDone, Helpers__NS__taskStarted, Helpers__NS__throwError, Helpers__NS__timeout, Helpers__NS__tryCatchError, Helpers__NS__tryReadFile, Helpers__NS__tryRemoveDir, Helpers__NS__values, Helpers__NS__wait, Helpers__NS__warn, Helpers__NS__writeFile, Helpers__NS__writeJson, Helpers__NS__writeJson5, Helpers__NS__writeJsonC } from 'tnp-helpers/lib-prod';
|
|
6
|
-
import type { TestTemplates } from './spec-templates.backend';
|
|
7
|
-
import { CLASS } from 'typescript-class-helpers/lib-prod';
|
|
8
|
-
import { BaseProjectStructure } from './base-project-structure.backend';
|
|
9
|
-
//#endregion
|
|
10
|
-
|
|
11
|
-
//#region models
|
|
12
|
-
export interface MetaMdJSONProject {
|
|
13
|
-
githash?: string;
|
|
14
|
-
name?: MetaMdJSONProjects;
|
|
15
|
-
baseStructureHash?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type MetaMdJSONProjects = { [projPath: string]: MetaMdJSONProject; };
|
|
19
|
-
|
|
20
|
-
export interface MetaMdJSON {
|
|
21
|
-
orgFileBasenames: string[];
|
|
22
|
-
orgRelativePathes: string[];
|
|
23
|
-
timeHash: string;
|
|
24
|
-
firstProjectBasename: string;
|
|
25
|
-
projects: MetaMdJSONProjects;
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Special forma of .md for keeping metadata, testfile, and test template for file
|
|
31
|
-
*/
|
|
32
|
-
export class MetaMd {
|
|
33
|
-
|
|
34
|
-
//#region static fields
|
|
35
|
-
static readonly JSON_PART = '@jsonPart';
|
|
36
|
-
static readonly FILE_CONTENT_PART = '@fileContentPart';
|
|
37
|
-
static readonly TEST_PART = '@testPart';
|
|
38
|
-
|
|
39
|
-
//#region static fields / create
|
|
40
|
-
static async create(json: MetaMdJSON, fileContent: string[], testContent?: string) {
|
|
41
|
-
return await create((___NS__isObject(json) ? Helpers__NS__stringify(json) : json) as any, fileContent, testContent);
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
|
|
45
|
-
//#region static fields / preserve file
|
|
46
|
-
static async preserveFiles(
|
|
47
|
-
originalAnyTypeFiles: string[],
|
|
48
|
-
destinationFolder: string,
|
|
49
|
-
editorCwd: string,
|
|
50
|
-
foundProjectsFn: (projects: Project[]) => Project[] = (a) => a,
|
|
51
|
-
baseProjectsStructurePath: string, // navi-cli folder or current folder,
|
|
52
|
-
overrideThisFileName = void 0 as string,
|
|
53
|
-
overrideTimehash = void 0
|
|
54
|
-
) {
|
|
55
|
-
|
|
56
|
-
const properDestName = overrideThisFileName ? overrideThisFileName :
|
|
57
|
-
`${path.basename(___NS__first(originalAnyTypeFiles))}.${config.file.meta_config_md}`; // TODO later menu to confirm name
|
|
58
|
-
|
|
59
|
-
if (!Helpers__NS__isFolder(destinationFolder)) {
|
|
60
|
-
Helpers__NS__error(`[tnp-helpers][meta-content-md] Destination folder "${destinationFolder}"
|
|
61
|
-
is not a folder`, false, true)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let foundedProjectsInPath = resolveFoundedProject(originalAnyTypeFiles, editorCwd, foundProjectsFn);
|
|
65
|
-
const mostBaseLocationFound = ___NS__minBy(foundedProjectsInPath, p => p.location.length).location;
|
|
66
|
-
// console.log(foundedProjectsInPath.map(p => p.location))
|
|
67
|
-
const projects = foundedProjectsInPath
|
|
68
|
-
.reduce((a, b) => {
|
|
69
|
-
const baseStructureHash = BaseProjectStructure.generate(b).insideIfNotExists(baseProjectsStructurePath);
|
|
70
|
-
return ___NS__merge(a, {
|
|
71
|
-
[path.join(path.basename(mostBaseLocationFound), b.location.replace(mostBaseLocationFound, ''))]: {
|
|
72
|
-
githash: b.git.lastCommitHash(),
|
|
73
|
-
name: b.name,
|
|
74
|
-
baseStructureHash,
|
|
75
|
-
}
|
|
76
|
-
} as MetaMdJSONProject)
|
|
77
|
-
}, {} as MetaMdJSONProjects);
|
|
78
|
-
const timeHash = overrideTimehash ? overrideTimehash : (+new Date).toString(36);
|
|
79
|
-
|
|
80
|
-
const c = await MetaMd.create({
|
|
81
|
-
orgFileBasenames: originalAnyTypeFiles.map(a => path.basename(a)),
|
|
82
|
-
orgRelativePathes: originalAnyTypeFiles.map(a => {
|
|
83
|
-
return path.join(path.basename(mostBaseLocationFound), a.replace(mostBaseLocationFound, ''))
|
|
84
|
-
}),
|
|
85
|
-
projects,
|
|
86
|
-
firstProjectBasename: path.basename(mostBaseLocationFound),
|
|
87
|
-
timeHash,
|
|
88
|
-
}, originalAnyTypeFiles.map(a => Helpers__NS__readFile(a)));
|
|
89
|
-
|
|
90
|
-
Helpers__NS__writeFile(path.join(destinationFolder, properDestName), c);
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
|
|
94
|
-
async addFiles(
|
|
95
|
-
newFilesPathes: string[],
|
|
96
|
-
destinationFolder: string,
|
|
97
|
-
editorCwd?: string,
|
|
98
|
-
foundProjectFn: (projects: Project[]) => Project[] = void 0,
|
|
99
|
-
baseProjectsStructurePath?: string, // navi-cli folder or current folder
|
|
100
|
-
) {
|
|
101
|
-
let foundedProjectsInPath = resolveFoundedProject(newFilesPathes, editorCwd, foundProjectFn);
|
|
102
|
-
const mostBaseLocationFound = ___NS__minBy(foundedProjectsInPath, p => p.location.length).location;
|
|
103
|
-
|
|
104
|
-
newFilesPathes = Utils__NS__uniqArray([
|
|
105
|
-
...newFilesPathes,
|
|
106
|
-
...this.readonlyMetaJson.orgRelativePathes.map(a => {
|
|
107
|
-
return path.join(path.dirname(mostBaseLocationFound), a)
|
|
108
|
-
}),
|
|
109
|
-
]);
|
|
110
|
-
|
|
111
|
-
newFilesPathes.forEach(f => {
|
|
112
|
-
if (!Helpers__NS__exists(f)) {
|
|
113
|
-
Helpers__NS__error(`File doesn't exists`, false, true);
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
await MetaMd.preserveFiles(
|
|
118
|
-
newFilesPathes,
|
|
119
|
-
destinationFolder,
|
|
120
|
-
editorCwd,
|
|
121
|
-
foundProjectFn,
|
|
122
|
-
baseProjectsStructurePath,
|
|
123
|
-
path.basename(this.filePath),
|
|
124
|
-
this.readonlyMetaJson.timeHash,
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
//#region static fields / handle instance from meta-content.md file
|
|
130
|
-
static instanceFrom(filePath: string): MetaMd {
|
|
131
|
-
return new MetaMd(filePath);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
static allInstancesFrom(folderPath: string): MetaMd[] {
|
|
135
|
-
return glob.sync(`${folderPath}/*.${config.file.meta_config_md}`).map(f => {
|
|
136
|
-
return MetaMd.instanceFrom(f);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
|
|
143
|
-
//#region getters
|
|
144
|
-
private get json(): MetaMdJSON {
|
|
145
|
-
const content = Helpers__NS__readFile(this.filePath) || '';
|
|
146
|
-
try {
|
|
147
|
-
const extracted = ___NS__first(extract(content, MetaMd.JSON_PART));
|
|
148
|
-
const parsed = Helpers__NS__parse(extracted, true);
|
|
149
|
-
return parsed;
|
|
150
|
-
} catch (error) {
|
|
151
|
-
return {} as any;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
public get readonlyMetaJson() {
|
|
156
|
-
return Object.freeze(this.json);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
public fileContentByIndex(i: number): string {
|
|
160
|
-
const content = Helpers__NS__readFile(this.filePath) || '';
|
|
161
|
-
const extracted = extract(content, MetaMd.FILE_CONTENT_PART)[i];
|
|
162
|
-
return extracted;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
get basename() {
|
|
166
|
-
return path.basename(this.filePath);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
get dirname() {
|
|
170
|
-
return path.dirname(this.filePath);
|
|
171
|
-
}
|
|
172
|
-
//#endregion
|
|
173
|
-
|
|
174
|
-
//#region constructor
|
|
175
|
-
constructor(
|
|
176
|
-
public readonly filePath: string,
|
|
177
|
-
) { }
|
|
178
|
-
//#endregion
|
|
179
|
-
|
|
180
|
-
//#region recreate files/content/env before any tests
|
|
181
|
-
/**
|
|
182
|
-
* recate original files before any unit/intergration test
|
|
183
|
-
*/
|
|
184
|
-
public recreate(testCwd: string, cwdProj: string, ProjectClass: typeof Project = Project, onlyIfNotExists = false) {
|
|
185
|
-
// recreat whole structure
|
|
186
|
-
const hashDir = path.join(testCwd, this.json.timeHash);
|
|
187
|
-
if (onlyIfNotExists && Helpers__NS__exists(hashDir)) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
Helpers__NS__removeFolderIfExists(hashDir);
|
|
191
|
-
Helpers__NS__mkdirp(hashDir);
|
|
192
|
-
|
|
193
|
-
const firstToFind = this.json.projects[this.json.firstProjectBasename].baseStructureHash;
|
|
194
|
-
const allBaseStructures = BaseProjectStructure.allBaseStructures(cwdProj);
|
|
195
|
-
const baseStructure = allBaseStructures.find(p => p.baseStructureHash === firstToFind);
|
|
196
|
-
if (!baseStructure) {
|
|
197
|
-
Helpers__NS__error(`[node-cli-test][regenerate] base structure was not generated for ${firstToFind}`, false, true);
|
|
198
|
-
}
|
|
199
|
-
baseStructure.copyto(hashDir);
|
|
200
|
-
___NS__keys(this.json.projects)
|
|
201
|
-
.filter(key => key !== this.json.firstProjectBasename)
|
|
202
|
-
.map(key => {
|
|
203
|
-
const baseStructureHashChild = this.json.projects[key].baseStructureHash;
|
|
204
|
-
const childBaseStruct = allBaseStructures.find(p => p.baseStructureHash === baseStructureHashChild);
|
|
205
|
-
if (childBaseStruct) {
|
|
206
|
-
childBaseStruct.copyto(path.join(
|
|
207
|
-
hashDir,
|
|
208
|
-
path.dirname(key)
|
|
209
|
-
), path.basename(key));
|
|
210
|
-
}
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
this.readonlyMetaJson.orgRelativePathes.forEach((f, i) => {
|
|
214
|
-
const fileToWritePath = path.join(hashDir, f);
|
|
215
|
-
Helpers__NS__writeFile(fileToWritePath, this.fileContentByIndex(i));
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
const proj = ProjectClass.ins.From(path.join(hashDir, this.readonlyMetaJson.firstProjectBasename));
|
|
219
|
-
const linksToLInk = []; // proj?.forEmptyStructure().filter(f => !!f.relativeLinkFrom) || [];
|
|
220
|
-
linksToLInk.forEach(l => {
|
|
221
|
-
const source = path.resolve(path.join(proj.location, l.relativeLinkFrom));
|
|
222
|
-
if (Helpers__NS__exists(source)) {
|
|
223
|
-
const dest = path.resolve(path.join(proj.location, l.relativePath));
|
|
224
|
-
Helpers__NS__createSymLink(source, dest);
|
|
225
|
-
} else {
|
|
226
|
-
Helpers__NS__log(`[cli-tester][recreate-env] not exist ${source}`);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
//#endregion
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
//#region create
|
|
235
|
-
async function create(json5string: string, fileContents: string[], testContent?: string) {
|
|
236
|
-
const metadataJSON = Helpers__NS__parse<MetaMdJSON>(json5string, true);
|
|
237
|
-
// Helpers__NS__log(`metadataJSON.orgFileBasename: ${metadataJSON.orgFileBasename}`)
|
|
238
|
-
|
|
239
|
-
if (!testContent) {
|
|
240
|
-
const projPath = ___NS__maxBy(___NS__keys(metadataJSON.projects).map(projRelPath => {
|
|
241
|
-
return { path: projRelPath, length: projRelPath.length };
|
|
242
|
-
}), c => c.length)?.path || '';
|
|
243
|
-
let TestTemplatesClass = CLASS.getBy('TestTemplates') as typeof TestTemplates;
|
|
244
|
-
if (!TestTemplatesClass) {
|
|
245
|
-
TestTemplatesClass = await (await import('./spec-templates.backend')).TestTemplates;
|
|
246
|
-
}
|
|
247
|
-
testContent = TestTemplatesClass.testPart(metadataJSON.orgRelativePathes, projPath, metadataJSON.timeHash);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const filesContestString = fileContents.map((fileContent, i) => {
|
|
251
|
-
const ext = path.extname(metadataJSON.orgFileBasenames[i]).replace(/^\./, '');
|
|
252
|
-
return `\`\`\`${ext} ${MetaMd.FILE_CONTENT_PART}
|
|
253
|
-
${fileContent}
|
|
254
|
-
\`\`\``
|
|
255
|
-
}).join('\n\n')
|
|
256
|
-
|
|
257
|
-
return `
|
|
258
|
-
\`\`\`ts ${MetaMd.TEST_PART}
|
|
259
|
-
${testContent}
|
|
260
|
-
\`\`\`
|
|
261
|
-
|
|
262
|
-
\`\`\`json5 ${MetaMd.JSON_PART}
|
|
263
|
-
${json5string}
|
|
264
|
-
\`\`\`
|
|
265
|
-
|
|
266
|
-
${filesContestString}
|
|
267
|
-
`.split('\n').map(l => {
|
|
268
|
-
return l.trim().startsWith('\`\`\`') ? l.trimLeft() : l;
|
|
269
|
-
}).join('\n').trim() + '\n';
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
//#endregion
|
|
273
|
-
|
|
274
|
-
//#region extract data parts from content md file
|
|
275
|
-
export function extract(content: string, PARTS_TO_FIND: string): string[] {
|
|
276
|
-
if (!content) {
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
const parts = [] as string[];
|
|
280
|
-
let lines = [];
|
|
281
|
-
const allLines = content.split('\n');
|
|
282
|
-
let pushingActive = false;
|
|
283
|
-
for (let index = 0; index < allLines.length; index++) {
|
|
284
|
-
const orgLine = (allLines[index] || '');
|
|
285
|
-
const line = orgLine.trim();
|
|
286
|
-
if (pushingActive) {
|
|
287
|
-
if (line.startsWith('\`\`\`')) {
|
|
288
|
-
parts.push(lines.join('\n'));
|
|
289
|
-
lines = []
|
|
290
|
-
} else {
|
|
291
|
-
lines.push(orgLine);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
if (line.startsWith('\`\`\`') && (line.search(PARTS_TO_FIND) !== -1)) {
|
|
295
|
-
pushingActive = true;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
return parts.filter(f => !!f.trim())
|
|
299
|
-
}
|
|
300
|
-
//#endregion
|
|
301
|
-
|
|
302
|
-
//#region resolve founded projects
|
|
303
|
-
function resolveFoundedProject(originalAnyTypeFiles: string[], editorCwd: string, foundProjectFn: Function) {
|
|
304
|
-
let foundedProjectsInPath = [];
|
|
305
|
-
for (let index = 0; index < originalAnyTypeFiles.length; index++) {
|
|
306
|
-
const fileAbsPath = originalAnyTypeFiles[index];
|
|
307
|
-
foundedProjectsInPath = [
|
|
308
|
-
...foundedProjectsInPath,
|
|
309
|
-
...Project.ins.allProjectFrom(fileAbsPath, editorCwd)
|
|
310
|
-
];
|
|
311
|
-
if (foundProjectFn) {
|
|
312
|
-
foundedProjectsInPath = foundProjectFn(Utils__NS__uniqArray<Project>(foundedProjectsInPath, 'location'));
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
foundedProjectsInPath = Utils__NS__uniqArray<Project>(foundedProjectsInPath, 'location');
|
|
316
|
-
return foundedProjectsInPath;
|
|
317
|
-
}
|
|
318
|
-
//#endregion
|
|
319
|
-
|
|
320
|
-
//#endregion
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
//#region imports
|
|
2
|
-
//#region @backend
|
|
3
|
-
import { path, ___NS__add, ___NS__after, ___NS__ary, ___NS__assign, ___NS__assignIn, ___NS__assignInWith, ___NS__assignWith, ___NS__at, ___NS__attempt, ___NS__before, ___NS__bind, ___NS__bindAll, ___NS__bindKey, ___NS__camelCase, ___NS__capitalize, ___NS__castArray, ___NS__ceil, ___NS__chain, ___NS__chunk, ___NS__clamp, ___NS__clone, ___NS__cloneDeep, ___NS__cloneDeepWith, ___NS__cloneWith, ___NS__compact, ___NS__concat, ___NS__cond, ___NS__conforms, ___NS__conformsTo, ___NS__constant, ___NS__countBy, ___NS__create, ___NS__curry, ___NS__curryRight, ___NS__debounce, ___NS__deburr, ___NS__defaults, ___NS__defaultsDeep, ___NS__defaultTo, ___NS__defer, ___NS__delay, ___NS__difference, ___NS__differenceBy, ___NS__differenceWith, ___NS__divide, ___NS__drop, ___NS__dropRight, ___NS__dropRightWhile, ___NS__dropWhile, ___NS__each, ___NS__eachRight, ___NS__endsWith, ___NS__entries, ___NS__entriesIn, ___NS__eq, ___NS__escape, ___NS__escapeRegExp, ___NS__every, ___NS__extend, ___NS__extendWith, ___NS__fill, ___NS__filter, ___NS__find, ___NS__findIndex, ___NS__findKey, ___NS__findLast, ___NS__findLastIndex, ___NS__findLastKey, ___NS__first, ___NS__flatMap, ___NS__flatMapDeep, ___NS__flatMapDepth, ___NS__flatten, ___NS__flattenDeep, ___NS__flattenDepth, ___NS__flip, ___NS__floor, ___NS__flow, ___NS__flowRight, ___NS__forEach, ___NS__forEachRight, ___NS__forIn, ___NS__forInRight, ___NS__forOwn, ___NS__forOwnRight, ___NS__fromPairs, ___NS__functions, ___NS__functionsIn, ___NS__get, ___NS__groupBy, ___NS__gt, ___NS__gte, ___NS__has, ___NS__hasIn, ___NS__head, ___NS__identity, ___NS__includes, ___NS__indexOf, ___NS__initial, ___NS__inRange, ___NS__intersection, ___NS__intersectionBy, ___NS__intersectionWith, ___NS__invert, ___NS__invertBy, ___NS__invoke, ___NS__invokeMap, ___NS__isArguments, ___NS__isArray, ___NS__isArrayBuffer, ___NS__isArrayLike, ___NS__isArrayLikeObject, ___NS__isBoolean, ___NS__isBuffer, ___NS__isDate, ___NS__isElement, ___NS__isEmpty, ___NS__isEqual, ___NS__isEqualWith, ___NS__isError, ___NS__isFinite, ___NS__isFunction, ___NS__isInteger, ___NS__isLength, ___NS__isMap, ___NS__isMatch, ___NS__isMatchWith, ___NS__isNaN, ___NS__isNative, ___NS__isNil, ___NS__isNull, ___NS__isNumber, ___NS__isObject, ___NS__isObjectLike, ___NS__isPlainObject, ___NS__isRegExp, ___NS__isSafeInteger, ___NS__isSet, ___NS__isString, ___NS__isSymbol, ___NS__isTypedArray, ___NS__isUndefined, ___NS__isWeakMap, ___NS__isWeakSet, ___NS__iteratee, ___NS__join, ___NS__kebabCase, ___NS__keyBy, ___NS__keys, ___NS__keysIn, ___NS__last, ___NS__lastIndexOf, ___NS__lowerCase, ___NS__lowerFirst, ___NS__lt, ___NS__lte, ___NS__map, ___NS__mapKeys, ___NS__mapValues, ___NS__matches, ___NS__matchesProperty, ___NS__max, ___NS__maxBy, ___NS__mean, ___NS__meanBy, ___NS__memoize, ___NS__merge, ___NS__mergeWith, ___NS__method, ___NS__methodOf, ___NS__min, ___NS__minBy, ___NS__mixin, ___NS__multiply, ___NS__negate, ___NS__noop, ___NS__now, ___NS__nth, ___NS__nthArg, ___NS__omit, ___NS__omitBy, ___NS__once, ___NS__orderBy, ___NS__over, ___NS__overArgs, ___NS__overEvery, ___NS__overSome, ___NS__pad, ___NS__padEnd, ___NS__padStart, ___NS__parseInt, ___NS__partial, ___NS__partialRight, ___NS__partition, ___NS__pick, ___NS__pickBy, ___NS__property, ___NS__propertyOf, ___NS__pull, ___NS__pullAll, ___NS__pullAllBy, ___NS__pullAllWith, ___NS__pullAt, ___NS__random, ___NS__range, ___NS__rangeRight, ___NS__rearg, ___NS__reduce, ___NS__reduceRight, ___NS__reject, ___NS__remove, ___NS__repeat, ___NS__replace, ___NS__rest, ___NS__result, ___NS__reverse, ___NS__round, ___NS__sample, ___NS__sampleSize, ___NS__set, ___NS__setWith, ___NS__shuffle, ___NS__size, ___NS__slice, ___NS__snakeCase, ___NS__some, ___NS__sortBy, ___NS__sortedIndex, ___NS__sortedIndexBy, ___NS__sortedIndexOf, ___NS__sortedLastIndex, ___NS__sortedLastIndexBy, ___NS__sortedLastIndexOf, ___NS__sortedUniq, ___NS__sortedUniqBy, ___NS__split, ___NS__spread, ___NS__startCase, ___NS__startsWith, ___NS__stubArray, ___NS__stubFalse, ___NS__stubObject, ___NS__stubString, ___NS__stubTrue, ___NS__subtract, ___NS__sum, ___NS__sumBy, ___NS__tail, ___NS__take, ___NS__takeRight, ___NS__takeRightWhile, ___NS__takeWhile, ___NS__tap, ___NS__template, ___NS__templateSettings, ___NS__throttle, ___NS__thru, ___NS__times, ___NS__toArray, ___NS__toFinite, ___NS__toInteger, ___NS__toLength, ___NS__toLower, ___NS__toNumber, ___NS__toPairs, ___NS__toPairsIn, ___NS__toPath, ___NS__toPlainObject, ___NS__toSafeInteger, ___NS__toString, ___NS__toUpper, ___NS__transform, ___NS__trim, ___NS__trimEnd, ___NS__trimStart, ___NS__truncate, ___NS__unary, ___NS__unescape, ___NS__union, ___NS__unionBy, ___NS__unionWith, ___NS__uniq, ___NS__uniqBy, ___NS__uniqueId, ___NS__uniqWith, ___NS__unset, ___NS__unzip, ___NS__unzipWith, ___NS__update, ___NS__updateWith, ___NS__upperCase, ___NS__upperFirst, ___NS__values, ___NS__valuesIn, ___NS__without, ___NS__words, ___NS__wrap, ___NS__xor, ___NS__xorBy, ___NS__xorWith, ___NS__zip, ___NS__zipObject, ___NS__zipObjectDeep, ___NS__zipWith } from 'tnp-core/lib-prod';
|
|
4
|
-
import { BaseProject as Project, Helpers__NS___fixCommand, Helpers__NS__bigMaxBuffer, Helpers__NS__checkProcess, Helpers__NS__cleanExit, Helpers__NS__clearConsole, Helpers__NS__command, Helpers__NS__commandOutputAsString, Helpers__NS__commandOutputAsStringAsync, Helpers__NS__compilationWrapper, Helpers__NS__contain, Helpers__NS__createFolder, Helpers__NS__createSymLink, Helpers__NS__error, Helpers__NS__execute, Helpers__NS__exists, Helpers__NS__filesFrom, Helpers__NS__foldersFrom, Helpers__NS__getFilesFrom, Helpers__NS__getFoldersFrom, Helpers__NS__getIsBrowser, Helpers__NS__getIsElectron, Helpers__NS__getIsNode, Helpers__NS__getIsRunningInGitBash, Helpers__NS__getIsSupportedTaonTerminal, Helpers__NS__getIsVerboseMode, Helpers__NS__getIsWebSQL, Helpers__NS__getIsWsl, Helpers__NS__getStdio, Helpers__NS__hideNodeWarnings, Helpers__NS__info, Helpers__NS__isBlob, Helpers__NS__isBuffer, Helpers__NS__isClass, Helpers__NS__isExistedSymlink, Helpers__NS__isFile, Helpers__NS__isFolder, Helpers__NS__isRunningInDocker, Helpers__NS__isRunningInLinuxGraphicsCapableEnvironment, Helpers__NS__isSymlinkFileExitedOrUnexisted, Helpers__NS__isSymlinkThatMatchesUrl, Helpers__NS__isUnexistedLink, Helpers__NS__killOnPort, Helpers__NS__killProcess, Helpers__NS__killProcessByPort, Helpers__NS__linksToFolderFrom, Helpers__NS__linksToFoldersFrom, Helpers__NS__log, Helpers__NS__logError, Helpers__NS__logInfo, Helpers__NS__logProc, Helpers__NS__logSuccess, Helpers__NS__logWarn, Helpers__NS__mediaTypeFromSrc, Helpers__NS__mkdirp, Helpers__NS__modifyLineByLine, Helpers__NS__msgCacheClear, Helpers__NS__openFolderInFileExplorer, Helpers__NS__parse, Helpers__NS__pathContainLink, Helpers__NS__questionYesNo, Helpers__NS__readFile, Helpers__NS__readJson, Helpers__NS__readJson5, Helpers__NS__readJsonC, Helpers__NS__relative, Helpers__NS__remove, Helpers__NS__removeEmptyLineFromString, Helpers__NS__removeFileIfExists, Helpers__NS__removeFolderIfExists, Helpers__NS__removeIfExists, Helpers__NS__removeSlashAtBegin, Helpers__NS__removeSlashAtEnd, Helpers__NS__removeSymlinks, Helpers__NS__renderError, Helpers__NS__replaceLinesInFile, Helpers__NS__run, Helpers__NS__runAsyncIn, Helpers__NS__runSyncIn, Helpers__NS__runSyncOrAsync, Helpers__NS__sleep, Helpers__NS__stopApplication, Helpers__NS__stringify, Helpers__NS__success, Helpers__NS__taskDone, Helpers__NS__taskStarted, Helpers__NS__throwError, Helpers__NS__timeout, Helpers__NS__tryCatchError, Helpers__NS__tryReadFile, Helpers__NS__tryRemoveDir, Helpers__NS__values, Helpers__NS__wait, Helpers__NS__warn, Helpers__NS__writeFile, Helpers__NS__writeJson, Helpers__NS__writeJson5, Helpers__NS__writeJsonC, HelpersTaon__NS__actionWrapper, HelpersTaon__NS__applyMixins, HelpersTaon__NS__arrays__NS__arrayMoveElementAfterB, HelpersTaon__NS__arrays__NS__arrayMoveElementBefore, HelpersTaon__NS__arrays__NS__from, HelpersTaon__NS__arrays__NS__fuzzy, HelpersTaon__NS__arrays__NS__moveObjectAfter, HelpersTaon__NS__arrays__NS__moveObjectBefore, HelpersTaon__NS__arrays__NS__second, HelpersTaon__NS__arrays__NS__sortKeys, HelpersTaon__NS__arrays__NS__uniqArray, HelpersTaon__NS__autocompleteAsk, HelpersTaon__NS__bundleCodeIntoSingleFile, HelpersTaon__NS__changeCwd, HelpersTaon__NS__changeCwdWrapper, HelpersTaon__NS__checkEnvironment, HelpersTaon__NS__checkIfNameAllowedForTaonProj, HelpersTaon__NS__checksum, HelpersTaon__NS__cliTool__NS__cleanCommand, HelpersTaon__NS__cliTool__NS__fixUnexpectedCommandCharacters, HelpersTaon__NS__cliTool__NS__getPramsFromArgs, HelpersTaon__NS__cliTool__NS__globalArgumentsParserTnp, HelpersTaon__NS__cliTool__NS__match, HelpersTaon__NS__cliTool__NS__removeArg, HelpersTaon__NS__cliTool__NS__removeArgsFromCommand, HelpersTaon__NS__cliTool__NS__resolveItemFromArgsBegin, HelpersTaon__NS__cliTool__NS__resolveItemsFromArgsBegin, HelpersTaon__NS__CLIWRAP, HelpersTaon__NS__consoleGui__NS__multiselect, HelpersTaon__NS__consoleGui__NS__pressAnyKey, HelpersTaon__NS__consoleGui__NS__question__NS__yesNo, HelpersTaon__NS__consoleGui__NS__select, HelpersTaon__NS__consoleGui__NS__wait, HelpersTaon__NS__copy, HelpersTaon__NS__copyFile, HelpersTaon__NS__copyFolderOsNative, HelpersTaon__NS__filterDontCopy, HelpersTaon__NS__filterOnlyCopy, HelpersTaon__NS__findChildren, HelpersTaon__NS__findChildrenNavi, HelpersTaon__NS__fixWebpackEnv, HelpersTaon__NS__formatPath, HelpersTaon__NS__generatedFileWrap, HelpersTaon__NS__getLinesFromFiles, HelpersTaon__NS__getMethodName, HelpersTaon__NS__getMostRecentFileName, HelpersTaon__NS__getMostRecentFilesNames, HelpersTaon__NS__getRecrusiveFilesFrom, HelpersTaon__NS__getStringFrom, HelpersTaon__NS__getTempFolder, HelpersTaon__NS__getValueFromJSON, HelpersTaon__NS__getValueFromJSONC, HelpersTaon__NS__getWorkingDirOfProcess, HelpersTaon__NS__git__NS___pull, HelpersTaon__NS__git__NS__allOrigins, HelpersTaon__NS__git__NS__backupBranch, HelpersTaon__NS__git__NS__changeRemoteFromHttpsToSSh, HelpersTaon__NS__git__NS__changeRemoveFromSshToHttps, HelpersTaon__NS__git__NS__changesSummary, HelpersTaon__NS__git__NS__checkIfthereAreSomeUncommitedChange, HelpersTaon__NS__git__NS__checkout, HelpersTaon__NS__git__NS__checkoutDefaultBranch, HelpersTaon__NS__git__NS__checkoutFromTo, HelpersTaon__NS__git__NS__checkTagExists, HelpersTaon__NS__git__NS__cleanRepoFromAnyFilesExceptDotGitFolder, HelpersTaon__NS__git__NS__clone, HelpersTaon__NS__git__NS__commit, HelpersTaon__NS__git__NS__countCommits, HelpersTaon__NS__git__NS__currentBranchName, HelpersTaon__NS__git__NS__defaultRepoBranch, HelpersTaon__NS__git__NS__fetch, HelpersTaon__NS__git__NS__findGitRoot, HelpersTaon__NS__git__NS__getACTION_MSG_RESET_GIT_HARD_COMMIT, HelpersTaon__NS__git__NS__getAllTags, HelpersTaon__NS__git__NS__getBranchesNames, HelpersTaon__NS__git__NS__getChangedFiles, HelpersTaon__NS__git__NS__getChangedFilesInCommitByHash, HelpersTaon__NS__git__NS__getChangedFilesInCommitByIndex, HelpersTaon__NS__git__NS__getCommitHashByIndex, HelpersTaon__NS__git__NS__getCommitMessageByHash, HelpersTaon__NS__git__NS__getCommitMessageByIndex, HelpersTaon__NS__git__NS__getListOfCurrentGitChanges, HelpersTaon__NS__git__NS__getOriginURL, HelpersTaon__NS__git__NS__getRemoteProvider, HelpersTaon__NS__git__NS__getUserInfo, HelpersTaon__NS__git__NS__hasAnyCommits, HelpersTaon__NS__git__NS__isGitRoot, HelpersTaon__NS__git__NS__isInMergeProcess, HelpersTaon__NS__git__NS__isInsideGitRepo, HelpersTaon__NS__git__NS__isValidRepoUrl, HelpersTaon__NS__git__NS__lastCommitDate, HelpersTaon__NS__git__NS__lastCommitHash, HelpersTaon__NS__git__NS__lastCommitMessage, HelpersTaon__NS__git__NS__lastTagHash, HelpersTaon__NS__git__NS__lastTagNameForMajorVersion, HelpersTaon__NS__git__NS__lastTagVersionName, HelpersTaon__NS__git__NS__meltActionCommits, HelpersTaon__NS__git__NS__originHttpToSsh, HelpersTaon__NS__git__NS__originSshToHttp, HelpersTaon__NS__git__NS__penultimateCommitHash, HelpersTaon__NS__git__NS__penultimateCommitMessage, HelpersTaon__NS__git__NS__pullCurrentBranch, HelpersTaon__NS__git__NS__pushCurrentBranch, HelpersTaon__NS__git__NS__rebase, HelpersTaon__NS__git__NS__removeTag, HelpersTaon__NS__git__NS__resetFiles, HelpersTaon__NS__git__NS__resetHard, HelpersTaon__NS__git__NS__resetSoftHEAD, HelpersTaon__NS__git__NS__restoreLastVersion, HelpersTaon__NS__git__NS__revertFileChanges, HelpersTaon__NS__git__NS__setUserInfos, HelpersTaon__NS__git__NS__stageAllAndCommit, HelpersTaon__NS__git__NS__stageAllFiles, HelpersTaon__NS__git__NS__stagedFiles, HelpersTaon__NS__git__NS__stageFile, HelpersTaon__NS__git__NS__stash, HelpersTaon__NS__git__NS__stashApply, HelpersTaon__NS__git__NS__tagAndPushToGitRepo, HelpersTaon__NS__git__NS__thereAreSomeUncommitedChangeExcept, HelpersTaon__NS__git__NS__uncommitedFiles, HelpersTaon__NS__git__NS__unstageAllFiles, HelpersTaon__NS__goToDir, HelpersTaon__NS__HelpersNumber, HelpersTaon__NS__input, HelpersTaon__NS__isElevated, HelpersTaon__NS__isPlainFileOrFolder, HelpersTaon__NS__killAllNode, HelpersTaon__NS__killAllNodeExceptCurrentProcess, HelpersTaon__NS__list, HelpersTaon__NS__mesureExectionInMs, HelpersTaon__NS__mesureExectionInMsSync, HelpersTaon__NS__move, HelpersTaon__NS__multipleChoicesAsk, HelpersTaon__NS__osIsMacOs, HelpersTaon__NS__outputToVScode, HelpersTaon__NS__pathFromLink, HelpersTaon__NS__paths__NS__create, HelpersTaon__NS__paths__NS__PREFIX, HelpersTaon__NS__paths__NS__removeExt, HelpersTaon__NS__paths__NS__removeExtension, HelpersTaon__NS__paths__NS__removeRootFolder, HelpersTaon__NS__prepareWatchCommand, HelpersTaon__NS__pressKeyAndContinue, HelpersTaon__NS__pressKeyOrWait, HelpersTaon__NS__randomInteger, HelpersTaon__NS__readValueFromJson, HelpersTaon__NS__readValueFromJsonC, HelpersTaon__NS__removeExcept, HelpersTaon__NS__renameFiles, HelpersTaon__NS__renameFolder, HelpersTaon__NS__requireJs, HelpersTaon__NS__requireUncached, HelpersTaon__NS__resolve, HelpersTaon__NS__restartApplicationItself, HelpersTaon__NS__selectChoicesAsk, HelpersTaon__NS__setValueToJSON, HelpersTaon__NS__setValueToJSONC, HelpersTaon__NS__size, HelpersTaon__NS__slash, HelpersTaon__NS__strings__NS__interpolateString, HelpersTaon__NS__strings__NS__numValue, HelpersTaon__NS__strings__NS__plural, HelpersTaon__NS__strings__NS__removeDoubleOrMoreEmptyLines, HelpersTaon__NS__strings__NS__singular, HelpersTaon__NS__strings__NS__splitIfNeed, HelpersTaon__NS__terminalLine, HelpersTaon__NS__tryCopyFrom, HelpersTaon__NS__tryRecreateDir, HelpersTaon__NS__uniqArray, HelpersTaon__NS__waitForCondition, HelpersTaon__NS__waitForMessegeInStdout, HelpersTaon__NS__workerCalculateArray } 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
|
-
import { MetaMd } from './meta-content-md.backend';
|
|
9
|
-
//#endregion
|
|
10
|
-
//#endregion
|
|
11
|
-
|
|
12
|
-
export class NodeCliTester {
|
|
13
|
-
//#region @backend
|
|
14
|
-
//#region singleton
|
|
15
|
-
private static _instances = {};
|
|
16
|
-
|
|
17
|
-
private static ACTIONS = {
|
|
18
|
-
REGENERATE_LAST_HASH: 'regenerate-last-env-hash'
|
|
19
|
-
}
|
|
20
|
-
public static classFn = NodeCliTester;
|
|
21
|
-
public static projectClassFn = Project;
|
|
22
|
-
|
|
23
|
-
public static foundProjectsFn: (projects: Project[]) => Project[] = void 0;
|
|
24
|
-
|
|
25
|
-
protected constructor(
|
|
26
|
-
protected readonly cwd = process.cwd()
|
|
27
|
-
) {
|
|
28
|
-
const pathToScenarios = path.join(cwd, config.folder.scenarios);
|
|
29
|
-
const pathToScenariosTemp = path.join(cwd, config.folder.tmpScenarios);
|
|
30
|
-
if (!Helpers__NS__exists(pathToScenarios)) {
|
|
31
|
-
Helpers__NS__createSymLink(pathToScenariosTemp, pathToScenarios,
|
|
32
|
-
{ continueWhenExistedFolderDoesntExists: true })
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public static Instance(cwd = process.cwd()) {
|
|
37
|
-
if (!NodeCliTester._instances[cwd]) {
|
|
38
|
-
NodeCliTester._instances[cwd] = new (this.classFn)(cwd);
|
|
39
|
-
}
|
|
40
|
-
return NodeCliTester._instances[cwd] as NodeCliTester;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public static InstanceNearestTo(cwd: string) {
|
|
44
|
-
const proj = Project.ins.nearestTo(cwd);
|
|
45
|
-
if (!proj) {
|
|
46
|
-
Helpers__NS__error(`Nearsest project instance not found for ${cwd} `, false, true);
|
|
47
|
-
}
|
|
48
|
-
return this.Instance(proj.location);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
|
|
53
|
-
//#region get menu options
|
|
54
|
-
|
|
55
|
-
//#region get menu options / all tests names
|
|
56
|
-
protected getAllTestsNames() {
|
|
57
|
-
const names = CliTest.allFrom(this.cwd).map(c => {
|
|
58
|
-
return { label: c.testName, option: c.testDirnamePath };
|
|
59
|
-
});
|
|
60
|
-
HelpersTaon__NS__outputToVScode(names);
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
|
-
|
|
64
|
-
//#region get menu options / all meta-content.md files for test (path as option)
|
|
65
|
-
protected getMdContentFilesForTest(testNameOrPathToTestFolder: string) {
|
|
66
|
-
const c = CliTest.from(this.cwd, path.isAbsolute(testNameOrPathToTestFolder) ? path.basename(testNameOrPathToTestFolder) : testNameOrPathToTestFolder);
|
|
67
|
-
const toOutput = [
|
|
68
|
-
{ label: `< create new ${config.file.meta_config_md} file >`, option: null },
|
|
69
|
-
...c.metaMd.all.map(c => {
|
|
70
|
-
const v = c.filePath;
|
|
71
|
-
return { option: v, label: `add to "${path.basename(v)}"` }
|
|
72
|
-
})
|
|
73
|
-
];
|
|
74
|
-
HelpersTaon__NS__outputToVScode(toOutput);
|
|
75
|
-
}
|
|
76
|
-
//#endregion
|
|
77
|
-
|
|
78
|
-
//#region get menu options / all meta-content.md files for test (hash as option)
|
|
79
|
-
protected getMdContentFilesWithHash(testNameOrPathToTestFolder: string) {
|
|
80
|
-
const c = CliTest.from(this.cwd, path.isAbsolute(testNameOrPathToTestFolder) ? path.basename(testNameOrPathToTestFolder) : testNameOrPathToTestFolder);
|
|
81
|
-
const toOutput = [
|
|
82
|
-
...c.metaMd.all.map(c => {
|
|
83
|
-
return { option: c.readonlyMetaJson.timeHash, label: `add to "${path.basename(c.filePath)}"` }
|
|
84
|
-
})
|
|
85
|
-
];
|
|
86
|
-
HelpersTaon__NS__outputToVScode(toOutput);
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
|
-
|
|
90
|
-
//#region get menu options / all tests names (with additional options for regenerate)
|
|
91
|
-
protected getAllTestsNamesForRegenerate() {
|
|
92
|
-
const last = this.lastRegenerateMenuItem;
|
|
93
|
-
const specialOptions = [
|
|
94
|
-
...(last ? [last] : [])
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
const names = [
|
|
98
|
-
...specialOptions,
|
|
99
|
-
...CliTest.allFrom(this.cwd).map(c => {
|
|
100
|
-
return { label: c.testName, option: c.testDirnamePath };
|
|
101
|
-
}),
|
|
102
|
-
];
|
|
103
|
-
HelpersTaon__NS__outputToVScode(names);
|
|
104
|
-
}
|
|
105
|
-
//#endregion
|
|
106
|
-
|
|
107
|
-
//#endregion
|
|
108
|
-
|
|
109
|
-
//#region create test
|
|
110
|
-
public async createTest(testNameOrPathToTestFolder: string[] | string) {
|
|
111
|
-
Helpers__NS__log(`Create test from node-cli-tester`);
|
|
112
|
-
if (___NS__isString(testNameOrPathToTestFolder)) {
|
|
113
|
-
testNameOrPathToTestFolder = [testNameOrPathToTestFolder];
|
|
114
|
-
}
|
|
115
|
-
for (let index = 0; index < testNameOrPathToTestFolder.length; index++) {
|
|
116
|
-
const p = testNameOrPathToTestFolder[index];
|
|
117
|
-
const c = CliTest.from(this.cwd, path.isAbsolute(p) ? path.basename(p) : p);
|
|
118
|
-
await c.regenerateFiles();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
//#endregion
|
|
122
|
-
|
|
123
|
-
//#region create test and add file
|
|
124
|
-
public async createTestAndAddFiles(testName: string, absoluteFilePathes: string[], editorCwd: string = process.cwd()) {
|
|
125
|
-
await this.createTest(testName);
|
|
126
|
-
await this.addFilesToTest(testName, absoluteFilePathes, editorCwd);
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
129
|
-
|
|
130
|
-
//#region add files to
|
|
131
|
-
|
|
132
|
-
//#region add files to / test
|
|
133
|
-
public async addFilesToTest(testNameOrPathToTestFolder: string, filePath: string[], editorCwd: string = process.cwd()) {
|
|
134
|
-
const c = CliTest.from(this.cwd, path.isAbsolute(testNameOrPathToTestFolder)
|
|
135
|
-
? path.basename(testNameOrPathToTestFolder) : testNameOrPathToTestFolder);
|
|
136
|
-
await c.metaMd.add(filePath, editorCwd, CLASS.getFromObject(this));
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
|
|
140
|
-
//#region add files to / meta-content.md files
|
|
141
|
-
public async addFilesToMdContent(
|
|
142
|
-
testNameOrPathToTestFolder: string,
|
|
143
|
-
mdContentFileBasenameOrPath: string | null, filePaths: string[],
|
|
144
|
-
editorCwd: string = process.cwd()
|
|
145
|
-
) {
|
|
146
|
-
const c = CliTest.from(this.cwd, path.isAbsolute(testNameOrPathToTestFolder)
|
|
147
|
-
? path.basename(testNameOrPathToTestFolder) : testNameOrPathToTestFolder);
|
|
148
|
-
|
|
149
|
-
const mdContentFileBasename = !!mdContentFileBasenameOrPath && (path.isAbsolute(mdContentFileBasenameOrPath)
|
|
150
|
-
? path.basename(mdContentFileBasenameOrPath) : mdContentFileBasenameOrPath);
|
|
151
|
-
const m = mdContentFileBasename && c.metaMd.all.find(a => a.basename === mdContentFileBasename);
|
|
152
|
-
if (m) {
|
|
153
|
-
const NodeCliTestrClass = CLASS.getFromObject(this);
|
|
154
|
-
await m.addFiles(filePaths, c.testDirnamePath, editorCwd, NodeCliTestrClass.foundProjectsFn, c.cwd);
|
|
155
|
-
} else {
|
|
156
|
-
await this.addFilesToTest(testNameOrPathToTestFolder, filePaths, editorCwd);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
//#endregion
|
|
160
|
-
|
|
161
|
-
//#endregion
|
|
162
|
-
|
|
163
|
-
//#region regenerate
|
|
164
|
-
|
|
165
|
-
//#region regenerate / last regenerate hash file path
|
|
166
|
-
private get lastRegenerateHashFile() {
|
|
167
|
-
return path.join(this.cwd, 'tmp-last-regenerate-hash-env');
|
|
168
|
-
}
|
|
169
|
-
//#endregion
|
|
170
|
-
|
|
171
|
-
//#region regenerate / get last regenerate manu item
|
|
172
|
-
private get lastRegenerateMenuItem(): { label: string; option: any; } {
|
|
173
|
-
const lashHash = Helpers__NS__readFile(this.lastRegenerateHashFile, '').trim();
|
|
174
|
-
if (lashHash) {
|
|
175
|
-
const allTests = CliTest.allFrom(this.cwd);
|
|
176
|
-
let machingMdFile: MetaMd;
|
|
177
|
-
allTests.find(a => a.metaMd.all.find(b => {
|
|
178
|
-
if (b.readonlyMetaJson.timeHash === lashHash) {
|
|
179
|
-
machingMdFile = b;
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
return false;
|
|
183
|
-
}));
|
|
184
|
-
if (machingMdFile) {
|
|
185
|
-
const NodeCliTesterClass = (CLASS.getFromObject(this) as typeof NodeCliTester);
|
|
186
|
-
const res = {
|
|
187
|
-
label: ` < regenerate last hash env "${machingMdFile.readonlyMetaJson.timeHash}" `
|
|
188
|
-
+ `for project: "${machingMdFile.readonlyMetaJson.firstProjectBasename}" in `
|
|
189
|
-
+ `${machingMdFile.basename} >`,
|
|
190
|
-
option: { action: NodeCliTesterClass.ACTIONS.REGENERATE_LAST_HASH }
|
|
191
|
-
};
|
|
192
|
-
return res;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return void 0;
|
|
196
|
-
}
|
|
197
|
-
//#endregion
|
|
198
|
-
|
|
199
|
-
//#region regenerate / aliases
|
|
200
|
-
public async regenerate(timeHash: string) {
|
|
201
|
-
await this.regenerateEnvironment(timeHash);
|
|
202
|
-
}
|
|
203
|
-
public async regenerateLast() {
|
|
204
|
-
const NodeCliTesterClass = (CLASS.getFromObject(this) as typeof NodeCliTester);
|
|
205
|
-
await this.regenerateEnvironment(NodeCliTesterClass.ACTIONS.REGENERATE_LAST_HASH);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
//#endregion
|
|
209
|
-
|
|
210
|
-
//#region regenerate / regenerate environment function
|
|
211
|
-
public async regenerateEnvironment(timeHash: string, tempFolder = config.folder.tmpTestsEnvironments, onlyIfNotExists = false) {
|
|
212
|
-
const NodeCliTesterClass = (CLASS.getFromObject(this) as typeof NodeCliTester);
|
|
213
|
-
if (timeHash === NodeCliTesterClass.ACTIONS.REGENERATE_LAST_HASH) {
|
|
214
|
-
timeHash = Helpers__NS__readFile(this.lastRegenerateHashFile, '');
|
|
215
|
-
}
|
|
216
|
-
if (!path.isAbsolute(tempFolder)) {
|
|
217
|
-
tempFolder = path.join(this.cwd, tempFolder);
|
|
218
|
-
}
|
|
219
|
-
const c = CliTest.getBy(this.cwd, timeHash);
|
|
220
|
-
const m = c?.metaMd.all.find(a => a.readonlyMetaJson.timeHash === timeHash);
|
|
221
|
-
if (m) {
|
|
222
|
-
const ProjectClass = NodeCliTesterClass.projectClassFn;
|
|
223
|
-
m.recreate(tempFolder, this.cwd, ProjectClass, onlyIfNotExists);
|
|
224
|
-
Helpers__NS__writeFile(this.lastRegenerateHashFile, timeHash);
|
|
225
|
-
} else {
|
|
226
|
-
Helpers__NS__error(`Not able to find test with hash ${timeHash}`, false, true);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
//#endregion
|
|
230
|
-
|
|
231
|
-
//#endregion
|
|
232
|
-
|
|
233
|
-
//#endregion
|
|
234
|
-
}
|