tnp-helpers 19.0.4 → 19.0.6
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/README.md +24 -24
- package/browser/fesm2022/tnp-helpers.mjs +1435 -139
- package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base/classes/base-node-modules.d.ts +1 -1
- package/browser/lib/base/linked-project.d.ts +4 -1
- package/browser/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +6 -6
- package/browser/lib/build-info._auto-generated_.d.ts +2 -1
- package/browser/lib/utils.d.ts +36 -20
- package/browser/package.json +1 -1
- package/client/README.md +24 -24
- package/client/fesm2022/tnp-helpers.mjs +1435 -139
- package/client/fesm2022/tnp-helpers.mjs.map +1 -1
- package/client/lib/base/classes/base-node-modules.d.ts +1 -1
- package/client/lib/base/linked-project.d.ts +4 -1
- package/client/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +6 -6
- package/client/lib/build-info._auto-generated_.d.ts +2 -1
- package/client/lib/utils.d.ts +36 -20
- package/client/package.json +1 -1
- package/index.js.map +1 -1
- package/lib/base/classes/base-bower-json.js +2 -2
- package/lib/base/classes/base-bower-json.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-config.js +2 -2
- package/lib/base/classes/base-cli-worker/base-cli-worker-config.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-controller.d.ts +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-controller.js +14 -14
- package/lib/base/classes/base-cli-worker/base-cli-worker-controller.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.js +10 -10
- package/lib/base/classes/base-cli-worker/base-cli-worker-terminal-ui.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker.d.ts +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker.js +18 -18
- package/lib/base/classes/base-cli-worker/base-cli-worker.js.map +1 -1
- package/lib/base/classes/base-cli-worker/index.js.map +1 -1
- package/lib/base/classes/base-command-line-feature.backend.js +10 -10
- package/lib/base/classes/base-command-line-feature.backend.js.map +1 -1
- package/lib/base/classes/base-compiler-for-project.d.ts +1 -1
- package/lib/base/classes/base-compiler-for-project.js +13 -13
- package/lib/base/classes/base-compiler-for-project.js.map +1 -1
- package/lib/base/classes/base-db.js +7 -7
- package/lib/base/classes/base-db.js.map +1 -1
- package/lib/base/classes/base-debounce-compiler-for-project.d.ts +1 -1
- package/lib/base/classes/base-debounce-compiler-for-project.js +5 -5
- package/lib/base/classes/base-debounce-compiler-for-project.js.map +1 -1
- package/lib/base/classes/base-feature-for-project.js.map +1 -1
- package/lib/base/classes/base-git.js +24 -24
- package/lib/base/classes/base-git.js.map +1 -1
- package/lib/base/classes/base-global-command-line.backend.d.ts +3 -1
- package/lib/base/classes/base-global-command-line.backend.js +60 -49
- package/lib/base/classes/base-global-command-line.backend.js.map +1 -1
- package/lib/base/classes/base-ignore-hide.js +2 -2
- package/lib/base/classes/base-ignore-hide.js.map +1 -1
- package/lib/base/classes/base-json-file-reader.js +24 -24
- package/lib/base/classes/base-json-file-reader.js.map +1 -1
- package/lib/base/classes/base-library-build.js +52 -52
- package/lib/base/classes/base-library-build.js.map +1 -1
- package/lib/base/classes/base-linked-projects.js +23 -23
- package/lib/base/classes/base-linked-projects.js.map +1 -1
- package/lib/base/classes/base-node-modules.d.ts +1 -1
- package/lib/base/classes/base-node-modules.js +37 -37
- package/lib/base/classes/base-node-modules.js.map +1 -1
- package/lib/base/classes/base-npm-helpers.d.ts +1 -1
- package/lib/base/classes/base-npm-helpers.js +14 -14
- package/lib/base/classes/base-npm-helpers.js.map +1 -1
- package/lib/base/classes/base-package-json.d.ts +1 -1
- package/lib/base/classes/base-package-json.js +27 -27
- package/lib/base/classes/base-package-json.js.map +1 -1
- package/lib/base/classes/base-powershell.js +2 -2
- package/lib/base/classes/base-powershell.js.map +1 -1
- package/lib/base/classes/base-process-manager.js +8 -8
- package/lib/base/classes/base-process-manager.js.map +1 -1
- package/lib/base/classes/base-project-resolver.js +30 -30
- package/lib/base/classes/base-project-resolver.js.map +1 -1
- package/lib/base/classes/base-project.d.ts +2 -2
- package/lib/base/classes/base-project.js +62 -62
- package/lib/base/classes/base-project.js.map +1 -1
- package/lib/base/classes/base-quick-fixes.js +9 -9
- package/lib/base/classes/base-quick-fixes.js.map +1 -1
- package/lib/base/classes/base-release-process.d.ts +1 -1
- package/lib/base/classes/base-release-process.js +19 -19
- package/lib/base/classes/base-release-process.js.map +1 -1
- package/lib/base/classes/base-start-config.backend.js +13 -13
- package/lib/base/classes/base-start-config.backend.js.map +1 -1
- package/lib/base/classes/base-static-pages.js +6 -6
- package/lib/base/classes/base-static-pages.js.map +1 -1
- package/lib/base/classes/base-vscode.js +20 -20
- package/lib/base/classes/base-vscode.js.map +1 -1
- package/lib/base/classes/index.js.map +1 -1
- package/lib/base/commit-data.js +25 -25
- package/lib/base/commit-data.js.map +1 -1
- package/lib/base/config-database.js.map +1 -1
- package/lib/base/core-project.d.ts +1 -1
- package/lib/base/core-project.js +9 -9
- package/lib/base/core-project.js.map +1 -1
- package/lib/base/gh-temp-code.js +6 -6
- package/lib/base/gh-temp-code.js.map +1 -1
- package/lib/base/index-rebuilder.backend.js +1 -1
- package/lib/base/index-rebuilder.backend.js.map +1 -1
- package/lib/base/index.js.map +1 -1
- package/lib/base/linked-project.d.ts +4 -1
- package/lib/base/linked-project.js +18 -9
- package/lib/base/linked-project.js.map +1 -1
- package/lib/base/project-database.js.map +1 -1
- package/lib/base/tcp-udp-ports/index.js.map +1 -1
- package/lib/base/tcp-udp-ports/not-assignable-port.entity.js +2 -2
- package/lib/base/tcp-udp-ports/not-assignable-port.entity.js.map +1 -1
- package/lib/base/tcp-udp-ports/ports.controller.d.ts +1 -1
- package/lib/base/tcp-udp-ports/ports.controller.js +21 -21
- package/lib/base/tcp-udp-ports/ports.controller.js.map +1 -1
- package/lib/base/tcp-udp-ports/ports.entity.d.ts +1 -1
- package/lib/base/tcp-udp-ports/ports.entity.js +10 -10
- package/lib/base/tcp-udp-ports/ports.entity.js.map +1 -1
- package/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +9 -9
- package/lib/base/tcp-udp-ports/tcp-udp-ports.context.js +9 -9
- package/lib/base/tcp-udp-ports/tcp-udp-ports.context.js.map +1 -1
- package/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.js +18 -18
- package/lib/base/tcp-udp-ports/tcp-upd-ports-terminal-ui.js.map +1 -1
- package/lib/base/tcp-udp-ports/tcp-upd-ports.worker.js.map +1 -1
- package/lib/base/translate.js.map +1 -1
- package/lib/build-info._auto-generated_.d.ts +2 -1
- package/lib/build-info._auto-generated_.js +3 -2
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/helpers/for-backend/helpers-cli-tool.backend.js +40 -40
- package/lib/helpers/for-backend/helpers-cli-tool.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-console-gui.js +2 -2
- package/lib/helpers/for-backend/helpers-console-gui.js.map +1 -1
- package/lib/helpers/for-backend/helpers-dependencies.backend.js +2 -2
- package/lib/helpers/for-backend/helpers-dependencies.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-file-folders.js +131 -131
- package/lib/helpers/for-backend/helpers-file-folders.js.map +1 -1
- package/lib/helpers/for-backend/helpers-git.backend.js +105 -105
- package/lib/helpers/for-backend/helpers-git.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-network.backend.js +2 -3
- package/lib/helpers/for-backend/helpers-network.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-npm.backend.js +2 -2
- package/lib/helpers/for-backend/helpers-npm.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-path.backend.js +6 -6
- package/lib/helpers/for-backend/helpers-path.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-process.d.ts +1 -1
- package/lib/helpers/for-backend/helpers-process.js +41 -41
- package/lib/helpers/for-backend/helpers-process.js.map +1 -1
- package/lib/helpers/for-backend/helpers-system-terminal.backend.js +2 -2
- package/lib/helpers/for-backend/helpers-system-terminal.backend.js.map +1 -1
- package/lib/helpers/for-backend/helpers-vscode.backend.d.ts +1 -1
- package/lib/helpers/for-backend/helpers-vscode.backend.js +2 -2
- package/lib/helpers/for-backend/helpers-vscode.backend.js.map +1 -1
- package/lib/helpers/for-browser/angular.helper.js +2 -2
- package/lib/helpers/for-browser/angular.helper.js.map +1 -1
- package/lib/helpers/for-browser/helpers-browser.js.map +1 -1
- package/lib/helpers/helpers-array-obj.js +10 -10
- package/lib/helpers/helpers-array-obj.js.map +1 -1
- package/lib/helpers/helpers-json5.backend.js +6 -6
- package/lib/helpers/helpers-json5.backend.js.map +1 -1
- package/lib/helpers/helpers-numbers.js.map +1 -1
- package/lib/helpers/helpers-strings-regexes.js +5 -5
- package/lib/helpers/helpers-strings-regexes.js.map +1 -1
- package/lib/helpers/helpers-strings.js +3 -3
- package/lib/helpers/helpers-strings.js.map +1 -1
- package/lib/helpers/helpers.js +28 -28
- package/lib/helpers/helpers.js.map +1 -1
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/lowdb/adapters/Memory.js.map +1 -1
- package/lib/lowdb/adapters/browser/LocalStorage.js.map +1 -1
- package/lib/lowdb/adapters/browser/SessionStorage.js.map +1 -1
- package/lib/lowdb/adapters/browser/WebStorage.js.map +1 -1
- package/lib/lowdb/adapters/node/DataFile.js.map +1 -1
- package/lib/lowdb/adapters/node/JSONFile.js.map +1 -1
- package/lib/lowdb/adapters/node/TextFile.js +2 -2
- package/lib/lowdb/adapters/node/TextFile.js.map +1 -1
- package/lib/lowdb/adapters/node/steno.js.map +1 -1
- package/lib/lowdb/browser.js.map +1 -1
- package/lib/lowdb/core/Low.js.map +1 -1
- package/lib/lowdb/examples/browser.js.map +1 -1
- package/lib/lowdb/examples/cli.js.map +1 -1
- package/lib/lowdb/examples/in-memory.js.map +1 -1
- package/lib/lowdb/examples/server.js.map +1 -1
- package/lib/lowdb/index.js.map +1 -1
- package/lib/lowdb/node.js.map +1 -1
- package/lib/lowdb/presets/browser.js.map +1 -1
- package/lib/lowdb/presets/node.js.map +1 -1
- package/lib/models.d.ts +1 -1
- package/lib/models.js +8 -8
- package/lib/models.js.map +1 -1
- package/lib/old/base-component.js +2 -2
- package/lib/old/base-component.js.map +1 -1
- package/lib/old/base-formly-component.js +2 -2
- package/lib/old/base-formly-component.js.map +1 -1
- package/lib/old/condition-wait.js.map +1 -1
- package/lib/old/dual-component-ctrl.js +2 -2
- package/lib/old/dual-component-ctrl.js.map +1 -1
- package/lib/old/execute-command.js.map +1 -1
- package/lib/old/helpers.js +2 -2
- package/lib/old/helpers.js.map +1 -1
- package/lib/old/models.d.ts +1 -1
- package/lib/old/models.js.map +1 -1
- package/lib/utils.d.ts +36 -20
- package/lib/utils.js +288 -52
- package/lib/utils.js.map +1 -1
- package/lib/validators/validators-firedev.js +6 -6
- package/lib/validators/validators-firedev.js.map +1 -1
- package/lib/validators/validators-git.js.map +1 -1
- package/lib/validators/validators-network.js +2 -2
- package/lib/validators/validators-network.js.map +1 -1
- package/lib/validators/validators.js.map +1 -1
- package/migrations/1736198527297_init.d.ts +1 -1
- package/migrations/1736198527297_init.js +5 -5
- package/migrations/1736198527297_init.js.map +1 -1
- package/migrations/1736199486472_addingNotAssignablePorts.d.ts +1 -1
- package/migrations/1736199486472_addingNotAssignablePorts.js +8 -8
- package/migrations/1736199486472_addingNotAssignablePorts.js.map +1 -1
- package/migrations/1736454437350_addFreePorts.d.ts +1 -1
- package/migrations/1736454437350_addFreePorts.js +11 -11
- package/migrations/1736454437350_addFreePorts.js.map +1 -1
- package/migrations/index.js.map +1 -1
- package/migrations/migrations_index._auto-generated_.js.map +1 -1
- package/package.json +1 -1
- package/tmp-environment.json +4 -4
- package/websql/README.md +24 -24
- package/websql/fesm2022/tnp-helpers.mjs +1472 -143
- package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base/classes/base-node-modules.d.ts +1 -1
- package/websql/lib/base/linked-project.d.ts +4 -1
- package/websql/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +6 -6
- package/websql/lib/build-info._auto-generated_.d.ts +2 -1
- package/websql/lib/utils.d.ts +36 -20
- package/websql/package.json +1 -1
- package/lib/base/classes/base-cli-worker-config.d.ts +0 -27
- package/lib/base/classes/base-cli-worker-config.js +0 -64
- package/lib/base/classes/base-cli-worker-config.js.map +0 -1
- package/lib/base/classes/base-cli-worker-controller.d.ts +0 -15
- package/lib/base/classes/base-cli-worker-controller.js +0 -124
- package/lib/base/classes/base-cli-worker-controller.js.map +0 -1
- package/lib/base/classes/base-cli-worker.d.ts +0 -111
- package/lib/base/classes/base-cli-worker.js +0 -535
- package/lib/base/classes/base-cli-worker.js.map +0 -1
- package/lib/base/classes/base-detached-service.d.ts +0 -6
- package/lib/base/classes/base-detached-service.js +0 -16
- package/lib/base/classes/base-detached-service.js.map +0 -1
- package/lib/base/classes/base-github-pages.d.ts +0 -14
- package/lib/base/classes/base-github-pages.js +0 -173
- package/lib/base/classes/base-github-pages.js.map +0 -1
- package/lib/helpers/for-backend/helpers-file-folders.backend.d.ts +0 -104
- package/lib/helpers/for-backend/helpers-file-folders.backend.js +0 -896
- package/lib/helpers/for-backend/helpers-file-folders.backend.js.map +0 -1
- package/lib/helpers/for-backend/helpers-process.backend.d.ts +0 -87
- package/lib/helpers/for-backend/helpers-process.backend.js +0 -456
- package/lib/helpers/for-backend/helpers-process.backend.js.map +0 -1
- package/lib/helpers/for-backend/ts-code/index.d.ts +0 -1
- package/lib/helpers/for-backend/ts-code/index.js +0 -5
- package/lib/helpers/for-backend/ts-code/index.js.map +0 -1
- package/lib/helpers/for-backend/ts-code/ts-import-export-extractor.d.ts +0 -29
- package/lib/helpers/for-backend/ts-code/ts-import-export-extractor.js +0 -81
- package/lib/helpers/for-backend/ts-code/ts-import-export-extractor.js.map +0 -1
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HelpersFileFolders = void 0;
|
|
4
4
|
const crypto = require("crypto");
|
|
5
5
|
const glob = require("glob");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const lib_1 = require("tnp-config/lib");
|
|
7
|
+
const lib_2 = require("tnp-core/lib");
|
|
8
8
|
const underscore = require("underscore");
|
|
9
9
|
const index_1 = require("../../index");
|
|
10
10
|
class HelpersFileFolders {
|
|
@@ -13,7 +13,7 @@ class HelpersFileFolders {
|
|
|
13
13
|
*/
|
|
14
14
|
checksum(absolutePathToFileOrContent, algorithm) {
|
|
15
15
|
//#region @backendFunc
|
|
16
|
-
const fileContent =
|
|
16
|
+
const fileContent = lib_2.path.isAbsolute(absolutePathToFileOrContent)
|
|
17
17
|
? index_1.Helpers.readFile(absolutePathToFileOrContent)
|
|
18
18
|
: absolutePathToFileOrContent;
|
|
19
19
|
return crypto
|
|
@@ -24,20 +24,20 @@ class HelpersFileFolders {
|
|
|
24
24
|
}
|
|
25
25
|
getValueFromJSON(filepath, lodashGetPath, defaultValue = void 0) {
|
|
26
26
|
//#region @backendFunc
|
|
27
|
-
if (!
|
|
27
|
+
if (!lib_2.fse.existsSync(filepath)) {
|
|
28
28
|
return defaultValue;
|
|
29
29
|
}
|
|
30
30
|
const json = index_1.Helpers.readJson(filepath);
|
|
31
|
-
return
|
|
31
|
+
return lib_2._.get(json, lodashGetPath, defaultValue);
|
|
32
32
|
//#endregion
|
|
33
33
|
}
|
|
34
34
|
getValueFromJSONC(filepath, lodashGetPath, defaultValue = void 0) {
|
|
35
35
|
//#region @backendFunc
|
|
36
|
-
if (!
|
|
36
|
+
if (!lib_2.fse.existsSync(filepath)) {
|
|
37
37
|
return defaultValue;
|
|
38
38
|
}
|
|
39
39
|
const json = index_1.Helpers.readJson5(filepath);
|
|
40
|
-
return
|
|
40
|
+
return lib_2._.get(json, lodashGetPath, defaultValue);
|
|
41
41
|
//#endregion
|
|
42
42
|
}
|
|
43
43
|
readValueFromJson(filepath, lodashGetPath, defaultValue = void 0) {
|
|
@@ -52,26 +52,26 @@ class HelpersFileFolders {
|
|
|
52
52
|
}
|
|
53
53
|
setValueToJSON(filepath, lodashGetPath, value) {
|
|
54
54
|
//#region @backendFunc
|
|
55
|
-
if (
|
|
56
|
-
filepath = (0,
|
|
55
|
+
if (lib_2._.isArray(filepath)) {
|
|
56
|
+
filepath = (0, lib_2.crossPlatformPath)(filepath);
|
|
57
57
|
}
|
|
58
|
-
if (!
|
|
58
|
+
if (!lib_2.fse.existsSync(filepath)) {
|
|
59
59
|
index_1.Helpers.warn(`Recreating unexised json file: ${filepath}`);
|
|
60
60
|
index_1.Helpers.writeFile(filepath, '{}');
|
|
61
61
|
}
|
|
62
62
|
const json = index_1.Helpers.readJson(filepath);
|
|
63
|
-
|
|
63
|
+
lib_2._.set(json, lodashGetPath, value);
|
|
64
64
|
index_1.Helpers.writeJson(filepath, json);
|
|
65
65
|
//#endregion
|
|
66
66
|
}
|
|
67
67
|
setValueToJSONC(filepath, lodashGetPath, value) {
|
|
68
68
|
//#region @backendFunc
|
|
69
|
-
if (!
|
|
69
|
+
if (!lib_2.fse.existsSync(filepath)) {
|
|
70
70
|
index_1.Helpers.warn(`Recreating unexised json file: ${filepath}`);
|
|
71
71
|
index_1.Helpers.writeFile(filepath, '{}');
|
|
72
72
|
}
|
|
73
73
|
const json = index_1.Helpers.readJsonC(filepath);
|
|
74
|
-
|
|
74
|
+
lib_2._.set(json, lodashGetPath, value);
|
|
75
75
|
index_1.Helpers.writeJsonC(filepath, json);
|
|
76
76
|
//#endregion
|
|
77
77
|
}
|
|
@@ -83,12 +83,12 @@ class HelpersFileFolders {
|
|
|
83
83
|
if (!index_1.Helpers.exists(filePath) || index_1.Helpers.isFolder(filePath)) {
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
86
|
-
return
|
|
86
|
+
return lib_2.fse.lstatSync(filePath).size;
|
|
87
87
|
//#endregion
|
|
88
88
|
}
|
|
89
89
|
pathFromLink(filePath) {
|
|
90
90
|
//#region @backendFunc
|
|
91
|
-
return
|
|
91
|
+
return lib_2.fse.readlinkSync(filePath);
|
|
92
92
|
//#endregion
|
|
93
93
|
}
|
|
94
94
|
// renameFolder(from: string, to: string, cwd?: string) {
|
|
@@ -112,15 +112,15 @@ class HelpersFileFolders {
|
|
|
112
112
|
try {
|
|
113
113
|
const directoryPath = cwd || '.';
|
|
114
114
|
// Read all files in the directory
|
|
115
|
-
const files =
|
|
115
|
+
const files = lib_2.fse.readdirSync(directoryPath);
|
|
116
116
|
files.forEach(file => {
|
|
117
117
|
// Check if the file name includes the 'from' pattern
|
|
118
118
|
if (file.includes(from)) {
|
|
119
119
|
const newFileName = file.replace(from, to);
|
|
120
|
-
const currentPath =
|
|
121
|
-
const newPath =
|
|
120
|
+
const currentPath = lib_2.path.join(directoryPath, file);
|
|
121
|
+
const newPath = lib_2.path.join(directoryPath, newFileName);
|
|
122
122
|
// Rename the file
|
|
123
|
-
|
|
123
|
+
lib_2.fse.renameSync(currentPath, newPath);
|
|
124
124
|
console.log(`Renamed file from ${currentPath} to ${newPath}`);
|
|
125
125
|
}
|
|
126
126
|
});
|
|
@@ -137,7 +137,7 @@ class HelpersFileFolders {
|
|
|
137
137
|
tmp = '/private/tmp';
|
|
138
138
|
}
|
|
139
139
|
if (process.platform === 'win32') {
|
|
140
|
-
tmp = (0,
|
|
140
|
+
tmp = (0, lib_2.crossPlatformPath)(lib_2.path.join((0, lib_2.crossPlatformPath)(lib_2.os.homedir()), '/AppData/Local/Temp'));
|
|
141
141
|
}
|
|
142
142
|
if (!index_1.Helpers.exists(tmp)) {
|
|
143
143
|
index_1.Helpers.mkdirp(tmp);
|
|
@@ -217,13 +217,13 @@ class HelpersFileFolders {
|
|
|
217
217
|
require(jsFilePath) {
|
|
218
218
|
//#region @backendFunc
|
|
219
219
|
const orgPath = jsFilePath;
|
|
220
|
-
if (!
|
|
220
|
+
if (!lib_2.fse.existsSync(jsFilePath)) {
|
|
221
221
|
jsFilePath = `${jsFilePath}.js`;
|
|
222
222
|
}
|
|
223
|
-
if (!
|
|
223
|
+
if (!lib_2.fse.existsSync(jsFilePath)) {
|
|
224
224
|
index_1.Helpers.error(`Not able to find path: ${orgPath}`);
|
|
225
225
|
}
|
|
226
|
-
let fileContent =
|
|
226
|
+
let fileContent = lib_2.fse.readFileSync(jsFilePath).toLocaleString();
|
|
227
227
|
(() => {
|
|
228
228
|
const stringForRegex = `require\\(("|')\\.\\/([a-zA-Z0-9]|\\/|\\-|\\_|\\+|\\.)*("|')\\)`;
|
|
229
229
|
index_1.Helpers.log(`[taon-helpre][require][${jsFilePath}] stringForRegex: ${stringForRegex}`, 1);
|
|
@@ -233,10 +233,10 @@ class HelpersFileFolders {
|
|
|
233
233
|
const matches = line.match(new RegExp(stringForRegex));
|
|
234
234
|
if (matches !== null) {
|
|
235
235
|
// console.log('matched', matches)
|
|
236
|
-
const rep =
|
|
236
|
+
const rep = lib_2._.first(matches);
|
|
237
237
|
if (rep) {
|
|
238
|
-
const newFilename = (0,
|
|
239
|
-
|
|
238
|
+
const newFilename = (0, lib_2.crossPlatformPath)([
|
|
239
|
+
lib_2.path.dirname(jsFilePath),
|
|
240
240
|
rep.split('(')[1].replace(/("|'|\))/g, ''),
|
|
241
241
|
]);
|
|
242
242
|
line = line.replace(rep, `require('${newFilename}')`);
|
|
@@ -258,14 +258,14 @@ class HelpersFileFolders {
|
|
|
258
258
|
const matches = line.match(new RegExp(stringForRegex));
|
|
259
259
|
if (matches !== null) {
|
|
260
260
|
// console.log('matched', matches)
|
|
261
|
-
const rep =
|
|
261
|
+
const rep = lib_2._.first(matches);
|
|
262
262
|
if (rep) {
|
|
263
263
|
const relativePart = rep.split('(')[1].replace(/("|'|\))/g, '');
|
|
264
264
|
// console.log(`RELATIVE PART: "${relativePart}"`)
|
|
265
265
|
if (relativePart.search('/') !== -1 &&
|
|
266
266
|
!relativePart.startsWith('/')) {
|
|
267
|
-
const newFilename = (0,
|
|
268
|
-
|
|
267
|
+
const newFilename = (0, lib_2.crossPlatformPath)([
|
|
268
|
+
lib_2.path.dirname(jsFilePath),
|
|
269
269
|
'node_modules',
|
|
270
270
|
relativePart,
|
|
271
271
|
]);
|
|
@@ -300,27 +300,27 @@ class HelpersFileFolders {
|
|
|
300
300
|
tryCopyFrom(source, destination, options = {}) {
|
|
301
301
|
//#region @backendFunc
|
|
302
302
|
index_1.Helpers.log(`Trying to copy from: ${source} to ${destination}`);
|
|
303
|
-
destination = (0,
|
|
304
|
-
source = (0,
|
|
303
|
+
destination = (0, lib_2.crossPlatformPath)(destination);
|
|
304
|
+
source = (0, lib_2.crossPlatformPath)(source);
|
|
305
305
|
if (source === destination) {
|
|
306
306
|
index_1.Helpers.warn('[taon-helpers] Probably error... trying to copy the same folder...');
|
|
307
307
|
return;
|
|
308
308
|
}
|
|
309
|
-
if (
|
|
309
|
+
if (lib_2.fse.existsSync(source) && !lib_2.fse.lstatSync(source).isDirectory()) {
|
|
310
310
|
// Helpers.warn(`[tryCopyFrom] This source is not directory: ${source} to ${destination}`);
|
|
311
311
|
index_1.Helpers.copyFile(source, destination);
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
|
-
if (
|
|
314
|
+
if (lib_2.fse.existsSync(destination.replace(/\/$/, ''))) {
|
|
315
315
|
const destMaybe = destination.replace(/\/$/, '');
|
|
316
|
-
const stats =
|
|
316
|
+
const stats = lib_2.fse.lstatSync(destMaybe);
|
|
317
317
|
const isNotDirectory = !stats.isDirectory();
|
|
318
318
|
const isSymbolicLink = stats.isSymbolicLink();
|
|
319
319
|
if (isNotDirectory || isSymbolicLink) {
|
|
320
|
-
|
|
320
|
+
lib_2.rimraf.sync(destMaybe);
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
options =
|
|
323
|
+
options = lib_2._.merge({
|
|
324
324
|
overwrite: true,
|
|
325
325
|
recursive: true,
|
|
326
326
|
}, options);
|
|
@@ -329,11 +329,11 @@ class HelpersFileFolders {
|
|
|
329
329
|
options['dereference'] = true;
|
|
330
330
|
}
|
|
331
331
|
try {
|
|
332
|
-
|
|
332
|
+
lib_2.fse.copySync(source, destination, options);
|
|
333
333
|
}
|
|
334
334
|
catch (error) {
|
|
335
|
-
|
|
336
|
-
|
|
335
|
+
lib_2.rimraf.sync(destination);
|
|
336
|
+
lib_2.fse.copySync(source, destination, options);
|
|
337
337
|
}
|
|
338
338
|
//#endregion
|
|
339
339
|
}
|
|
@@ -352,23 +352,23 @@ class HelpersFileFolders {
|
|
|
352
352
|
// };
|
|
353
353
|
move(from, to) {
|
|
354
354
|
//#region @backendFunc
|
|
355
|
-
if (!
|
|
355
|
+
if (!lib_2.fse.existsSync(from)) {
|
|
356
356
|
index_1.Helpers.warn(`[move] File or folder doesnt not exists: ${from}`);
|
|
357
357
|
return;
|
|
358
358
|
}
|
|
359
|
-
if (!
|
|
359
|
+
if (!lib_2.path.isAbsolute(from)) {
|
|
360
360
|
index_1.Helpers.warn(`[move] Source path is not absolute: ${from}`);
|
|
361
361
|
return;
|
|
362
362
|
}
|
|
363
|
-
if (!
|
|
363
|
+
if (!lib_2.path.isAbsolute(to)) {
|
|
364
364
|
index_1.Helpers.warn(`[move] Destination path is not absolute: ${to}`);
|
|
365
365
|
return;
|
|
366
366
|
}
|
|
367
367
|
if (index_1.Helpers.isUnexistedLink(to)) {
|
|
368
368
|
index_1.Helpers.remove(to);
|
|
369
369
|
}
|
|
370
|
-
if (index_1.Helpers.isUnexistedLink(
|
|
371
|
-
index_1.Helpers.remove(
|
|
370
|
+
if (index_1.Helpers.isUnexistedLink(lib_2.path.dirname(to))) {
|
|
371
|
+
index_1.Helpers.remove(lib_2.path.dirname(to));
|
|
372
372
|
}
|
|
373
373
|
// if (!Helpers.exists(path.dirname(to))) {
|
|
374
374
|
// if (Helpers.isUnexistedLink(path.dirname(to))) {
|
|
@@ -386,7 +386,7 @@ class HelpersFileFolders {
|
|
|
386
386
|
// }
|
|
387
387
|
while (true) {
|
|
388
388
|
try {
|
|
389
|
-
|
|
389
|
+
lib_2.fse.moveSync(from, to, {
|
|
390
390
|
overwrite: true,
|
|
391
391
|
});
|
|
392
392
|
break;
|
|
@@ -394,7 +394,7 @@ class HelpersFileFolders {
|
|
|
394
394
|
catch (error) {
|
|
395
395
|
if (global['tnpNonInteractive']) {
|
|
396
396
|
console.log(error);
|
|
397
|
-
index_1.Helpers.error(`[${
|
|
397
|
+
index_1.Helpers.error(`[${lib_1.config.frameworkName}-helpers] Not able to move files
|
|
398
398
|
|
|
399
399
|
from: ${from}
|
|
400
400
|
to: ${to}
|
|
@@ -416,9 +416,9 @@ to: ${to}
|
|
|
416
416
|
findChildren(location, createFn, options) {
|
|
417
417
|
//#region @backendFunc
|
|
418
418
|
const { allowAllNames } = options || {};
|
|
419
|
-
let folders = index_1.Helpers.values(
|
|
419
|
+
let folders = index_1.Helpers.values(lib_1.config.folder);
|
|
420
420
|
folders = folders.filter(f => ![
|
|
421
|
-
|
|
421
|
+
lib_1.config.folder.shared,
|
|
422
422
|
// TODO add something more here ?
|
|
423
423
|
].includes(f));
|
|
424
424
|
const notAllowed = [
|
|
@@ -442,16 +442,16 @@ to: ${to}
|
|
|
442
442
|
]),
|
|
443
443
|
]
|
|
444
444
|
.filter(f => {
|
|
445
|
-
return ![
|
|
445
|
+
return ![lib_1.config.folder.external].includes(f) && lib_2._.isString(f);
|
|
446
446
|
})
|
|
447
447
|
.map(s => new RegExp(`^${index_1.Helpers.escapeStringForRegEx(s)}$`));
|
|
448
|
-
const isDirectory = (source) =>
|
|
449
|
-
const getDirectories = (source) =>
|
|
448
|
+
const isDirectory = (source) => lib_2.fse.lstatSync(source).isDirectory();
|
|
449
|
+
const getDirectories = (source) => lib_2.fse
|
|
450
450
|
.readdirSync(source)
|
|
451
|
-
.map(name =>
|
|
451
|
+
.map(name => lib_2.path.join(source, name))
|
|
452
452
|
.filter(isDirectory);
|
|
453
453
|
let subdirectories = getDirectories(location).filter(f => {
|
|
454
|
-
const folderNam =
|
|
454
|
+
const folderNam = lib_2.path.basename(f);
|
|
455
455
|
const allowed = notAllowed.filter(p => p.test(folderNam)).length === 0;
|
|
456
456
|
return allowed;
|
|
457
457
|
});
|
|
@@ -469,13 +469,13 @@ to: ${to}
|
|
|
469
469
|
*/
|
|
470
470
|
findChildrenNavi(location, createFn) {
|
|
471
471
|
//#region @backendFunc
|
|
472
|
-
if (!
|
|
472
|
+
if (!lib_2.fse.existsSync(location)) {
|
|
473
473
|
return [];
|
|
474
474
|
}
|
|
475
475
|
const notAllowed = [
|
|
476
476
|
'.vscode',
|
|
477
477
|
'node_modules',
|
|
478
|
-
...index_1.Helpers.values(
|
|
478
|
+
...index_1.Helpers.values(lib_1.config.folder),
|
|
479
479
|
'e2e',
|
|
480
480
|
'tmp.*',
|
|
481
481
|
'dist.*',
|
|
@@ -489,13 +489,13 @@ to: ${to}
|
|
|
489
489
|
'bin',
|
|
490
490
|
'custom',
|
|
491
491
|
].map(s => new RegExp(s));
|
|
492
|
-
const isDirectory = source =>
|
|
493
|
-
const getDirectories = source =>
|
|
492
|
+
const isDirectory = source => lib_2.fse.lstatSync(source).isDirectory();
|
|
493
|
+
const getDirectories = source => lib_2.fse
|
|
494
494
|
.readdirSync(source)
|
|
495
|
-
.map(name =>
|
|
495
|
+
.map(name => lib_2.path.join(source, name))
|
|
496
496
|
.filter(isDirectory);
|
|
497
497
|
let subdirectories = getDirectories(location).filter(f => {
|
|
498
|
-
const folderName =
|
|
498
|
+
const folderName = lib_2.path.basename(f);
|
|
499
499
|
if (/.*es\-.*/.test(folderName)) {
|
|
500
500
|
return true;
|
|
501
501
|
}
|
|
@@ -517,16 +517,16 @@ to: ${to}
|
|
|
517
517
|
options = options ? options : {};
|
|
518
518
|
// const withNameOnly = options.withNameOnly;
|
|
519
519
|
let files = [];
|
|
520
|
-
const readedFilesAndFolders =
|
|
521
|
-
?
|
|
520
|
+
const readedFilesAndFolders = lib_2.fse.existsSync(dir)
|
|
521
|
+
? lib_2.fse.readdirSync(dir)
|
|
522
522
|
: [];
|
|
523
523
|
const readed = readedFilesAndFolders
|
|
524
524
|
.map(relativePathToFile => {
|
|
525
|
-
const fullPath = (0,
|
|
525
|
+
const fullPath = (0, lib_2.crossPlatformPath)([dir, relativePathToFile]);
|
|
526
526
|
// console.log(`is direcotry ${fse.lstatSync(fullPath).isDirectory()} `, fullPath)
|
|
527
|
-
if (
|
|
528
|
-
if (ommitFolders.includes(
|
|
529
|
-
ommitFolders.includes(
|
|
527
|
+
if (lib_2.fse.lstatSync(fullPath).isDirectory()) {
|
|
528
|
+
if (ommitFolders.includes(lib_2.path.basename(fullPath)) ||
|
|
529
|
+
ommitFolders.includes(lib_2.path.basename(lib_2.path.dirname(fullPath)))) {
|
|
530
530
|
// Helpers.log(`Omitting: ${fullPath}`)
|
|
531
531
|
}
|
|
532
532
|
else {
|
|
@@ -548,7 +548,7 @@ to: ${to}
|
|
|
548
548
|
const notAllowed = [
|
|
549
549
|
'^.vscode$',
|
|
550
550
|
'^node_modules$',
|
|
551
|
-
...index_1.Helpers.values(
|
|
551
|
+
...index_1.Helpers.values(lib_1.config.tempFolders).map(v => `^${v}$`),
|
|
552
552
|
'^e2e$',
|
|
553
553
|
'^tmp.*',
|
|
554
554
|
'^dist.*',
|
|
@@ -568,7 +568,7 @@ to: ${to}
|
|
|
568
568
|
getLinesFromFiles(filename, lineCount) {
|
|
569
569
|
//#region @backendFunc
|
|
570
570
|
return new Promise((resolve, reject) => {
|
|
571
|
-
let stream =
|
|
571
|
+
let stream = lib_2.fse.createReadStream(filename, {
|
|
572
572
|
flags: 'r',
|
|
573
573
|
encoding: 'utf-8',
|
|
574
574
|
fd: null,
|
|
@@ -610,7 +610,7 @@ to: ${to}
|
|
|
610
610
|
// ctime = creation time is used
|
|
611
611
|
// replace with mtime for modification time
|
|
612
612
|
// console.log( `${fse.statSync(f).mtimeMs} for ${f}` )
|
|
613
|
-
return
|
|
613
|
+
return lib_2.fse.statSync(f).mtimeMs;
|
|
614
614
|
});
|
|
615
615
|
//#endregion
|
|
616
616
|
}
|
|
@@ -618,60 +618,60 @@ to: ${to}
|
|
|
618
618
|
//#region @backendFunc
|
|
619
619
|
const allFiles = index_1.Helpers.getRecrusiveFilesFrom(dir);
|
|
620
620
|
const mrf = index_1.Helpers.getMostRecentFileName(dir);
|
|
621
|
-
const mfrMtime =
|
|
621
|
+
const mfrMtime = lib_2.fse.lstatSync(mrf).mtimeMs;
|
|
622
622
|
return allFiles.filter(f => {
|
|
623
|
-
const info =
|
|
623
|
+
const info = lib_2.fse.lstatSync(f);
|
|
624
624
|
return info.mtimeMs === mfrMtime && !info.isDirectory();
|
|
625
625
|
});
|
|
626
626
|
//#endregion
|
|
627
627
|
}
|
|
628
628
|
removeExcept(fromPath, exceptFolderAndFiles) {
|
|
629
629
|
//#region @backendFunc
|
|
630
|
-
|
|
630
|
+
lib_2.fse
|
|
631
631
|
.readdirSync(fromPath)
|
|
632
632
|
.filter(f => {
|
|
633
633
|
return !exceptFolderAndFiles.includes(f);
|
|
634
634
|
})
|
|
635
|
-
.map(f =>
|
|
635
|
+
.map(f => lib_2.path.join(fromPath, f))
|
|
636
636
|
.forEach(af => index_1.Helpers.removeFolderIfExists(af));
|
|
637
637
|
glob
|
|
638
638
|
.sync(`${fromPath}/*.*`)
|
|
639
639
|
.filter(f => {
|
|
640
|
-
return !exceptFolderAndFiles.includes(
|
|
640
|
+
return !exceptFolderAndFiles.includes(lib_2.path.basename(f));
|
|
641
641
|
})
|
|
642
642
|
.forEach(af => index_1.Helpers.removeFileIfExists(af));
|
|
643
643
|
//#endregion
|
|
644
644
|
}
|
|
645
645
|
copy(sourceDir, destinationDir, options) {
|
|
646
646
|
//#region @backendFunc
|
|
647
|
-
if (
|
|
648
|
-
sourceDir = (0,
|
|
647
|
+
if (lib_2._.isArray(sourceDir)) {
|
|
648
|
+
sourceDir = (0, lib_2.crossPlatformPath)(sourceDir);
|
|
649
649
|
}
|
|
650
|
-
if (
|
|
651
|
-
destinationDir = (0,
|
|
650
|
+
if (lib_2._.isArray(destinationDir)) {
|
|
651
|
+
destinationDir = (0, lib_2.crossPlatformPath)(destinationDir);
|
|
652
652
|
}
|
|
653
653
|
// sourceDir = sourceDir ? (sourceDir.replace(/\/$/, '')) : sourceDir;
|
|
654
654
|
// destinationDir = destinationDir ? (destinationDir.replace(/\/$/, '')) : destinationDir;
|
|
655
|
-
if (!
|
|
655
|
+
if (!lib_2.fse.existsSync(sourceDir)) {
|
|
656
656
|
index_1.Helpers.warn(`[taon-helper][copy] Source dir doesnt exist: ${sourceDir} for destination: ${destinationDir}`);
|
|
657
657
|
return;
|
|
658
658
|
}
|
|
659
|
-
if (!
|
|
660
|
-
if (index_1.Helpers.isUnexistedLink(
|
|
661
|
-
index_1.Helpers.removeFileIfExists(
|
|
659
|
+
if (!lib_2.fse.existsSync(lib_2.path.dirname(destinationDir))) {
|
|
660
|
+
if (index_1.Helpers.isUnexistedLink(lib_2.path.dirname(destinationDir))) {
|
|
661
|
+
index_1.Helpers.removeFileIfExists(lib_2.path.dirname(destinationDir));
|
|
662
662
|
}
|
|
663
|
-
index_1.Helpers.mkdirp(
|
|
663
|
+
index_1.Helpers.mkdirp(lib_2.path.dirname(destinationDir));
|
|
664
664
|
}
|
|
665
665
|
if (!options) {
|
|
666
666
|
options = {};
|
|
667
667
|
}
|
|
668
|
-
if (
|
|
668
|
+
if (lib_2._.isUndefined(options.overwrite)) {
|
|
669
669
|
options.overwrite = true;
|
|
670
670
|
}
|
|
671
|
-
if (
|
|
671
|
+
if (lib_2._.isUndefined(options.recursive)) {
|
|
672
672
|
options.recursive = true;
|
|
673
673
|
}
|
|
674
|
-
if (
|
|
674
|
+
if (lib_2._.isUndefined(options.useTempFolder)) {
|
|
675
675
|
options.useTempFolder = false;
|
|
676
676
|
}
|
|
677
677
|
if (options.copySymlinksAsFiles) {
|
|
@@ -694,11 +694,11 @@ to: ${to}
|
|
|
694
694
|
// `);
|
|
695
695
|
// return;
|
|
696
696
|
// }
|
|
697
|
-
if (
|
|
697
|
+
if (lib_2._.isArray(options.omitFolders) &&
|
|
698
698
|
options.omitFolders.length >= 1 &&
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
699
|
+
lib_2._.isNil(options.filter) &&
|
|
700
|
+
lib_2._.isString(options.omitFoldersBaseFolder) &&
|
|
701
|
+
lib_2.path.isAbsolute(options.omitFoldersBaseFolder)) {
|
|
702
702
|
options.filter = index_1.Helpers.filterDontCopy(options.omitFolders, options.omitFoldersBaseFolder);
|
|
703
703
|
}
|
|
704
704
|
if (options.copySymlinksAsFilesDeleteUnexistedLinksFromSourceFirst) {
|
|
@@ -710,9 +710,9 @@ to: ${to}
|
|
|
710
710
|
}
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
|
-
if ((0,
|
|
714
|
-
(0,
|
|
715
|
-
(0,
|
|
713
|
+
if ((0, lib_2.crossPlatformPath)(sourceDir) === (0, lib_2.crossPlatformPath)(destinationDir) ||
|
|
714
|
+
(0, lib_2.crossPlatformPath)(lib_2.path.resolve(sourceDir)) ===
|
|
715
|
+
(0, lib_2.crossPlatformPath)(lib_2.path.resolve(destinationDir))) {
|
|
716
716
|
index_1.Helpers.warn(`[taon-helper][copy] Trying to copy same source and destination
|
|
717
717
|
from: ${sourceDir}
|
|
718
718
|
to: ${destinationDir}
|
|
@@ -725,16 +725,16 @@ to: ${to}
|
|
|
725
725
|
// Helpers.log(JSON.stringify(options))
|
|
726
726
|
// try {
|
|
727
727
|
if (options.useTempFolder) {
|
|
728
|
-
let tempDestination = `${
|
|
728
|
+
let tempDestination = `${lib_2.os.platform() === 'darwin' ? '/private/tmp' : '/tmp'}/${lib_2._.camelCase(destinationDir)}`;
|
|
729
729
|
index_1.Helpers.removeFolderIfExists(tempDestination);
|
|
730
|
-
|
|
731
|
-
|
|
730
|
+
lib_2.fse.copySync(sourceDir, tempDestination, options);
|
|
731
|
+
lib_2.fse.copySync(tempDestination, destinationDir, options);
|
|
732
732
|
}
|
|
733
733
|
else {
|
|
734
|
-
if ((0,
|
|
735
|
-
(0,
|
|
734
|
+
if ((0, lib_2.crossPlatformPath)(sourceDir) ===
|
|
735
|
+
(0, lib_2.crossPlatformPath)(lib_2.path.resolve(sourceDir)) &&
|
|
736
736
|
index_1.Helpers.isExistedSymlink(sourceDir) &&
|
|
737
|
-
!index_1.Helpers.exists(
|
|
737
|
+
!index_1.Helpers.exists(lib_2.fse.readlinkSync(sourceDir))) {
|
|
738
738
|
index_1.Helpers.warn(`[taon-helpers] Not copying empty link from: ${sourceDir}
|
|
739
739
|
`);
|
|
740
740
|
}
|
|
@@ -748,8 +748,8 @@ to: ${to}
|
|
|
748
748
|
const from = files[index];
|
|
749
749
|
const to = from.replace(sourceDir, destinationDir);
|
|
750
750
|
if (index_1.Helpers.isFolder(from)) {
|
|
751
|
-
if (options.omitFolders.includes(
|
|
752
|
-
options.omitFolders.includes(
|
|
751
|
+
if (options.omitFolders.includes(lib_2.path.basename(lib_2.path.dirname(from))) ||
|
|
752
|
+
options.omitFolders.includes(lib_2.path.basename(from))) {
|
|
753
753
|
continue;
|
|
754
754
|
}
|
|
755
755
|
else {
|
|
@@ -781,7 +781,7 @@ to: ${to}
|
|
|
781
781
|
copyRecFn(sourceDir);
|
|
782
782
|
}
|
|
783
783
|
else {
|
|
784
|
-
|
|
784
|
+
lib_2.fse.copySync(sourceDir, destinationDir, options);
|
|
785
785
|
}
|
|
786
786
|
}
|
|
787
787
|
catch (error) {
|
|
@@ -789,9 +789,9 @@ to: ${to}
|
|
|
789
789
|
index_1.Helpers.log(error);
|
|
790
790
|
if (!options.dontAskOnError) {
|
|
791
791
|
index_1.Helpers.error(`[taon-helper] Not able to copy folder:
|
|
792
|
-
from: ${(0,
|
|
793
|
-
to: ${(0,
|
|
794
|
-
options: ${
|
|
792
|
+
from: ${(0, lib_2.crossPlatformPath)(sourceDir)}
|
|
793
|
+
to: ${(0, lib_2.crossPlatformPath)(destinationDir)}
|
|
794
|
+
options: ${lib_2.json5.stringify(options)}
|
|
795
795
|
error: ${error?.message}
|
|
796
796
|
`, !exitOnError);
|
|
797
797
|
index_1.Helpers.pressKeyAndContinue(`Press any key to repeat copy action...`);
|
|
@@ -828,16 +828,16 @@ to: ${to}
|
|
|
828
828
|
//#region @backendFunc
|
|
829
829
|
return (src, dest) => {
|
|
830
830
|
// console.log('src', src)
|
|
831
|
-
src = (0,
|
|
832
|
-
const baseFolder =
|
|
833
|
-
.replace((0,
|
|
831
|
+
src = (0, lib_2.crossPlatformPath)(src);
|
|
832
|
+
const baseFolder = lib_2._.first((0, lib_2.crossPlatformPath)(src)
|
|
833
|
+
.replace((0, lib_2.crossPlatformPath)(projectOrBasepath), '')
|
|
834
834
|
.replace(/^\//, '')
|
|
835
835
|
.split('/'));
|
|
836
836
|
// console.log('baseFolder', baseFolder)
|
|
837
837
|
if (!baseFolder || baseFolder.trim() === '') {
|
|
838
838
|
return true;
|
|
839
839
|
}
|
|
840
|
-
const isAllowed =
|
|
840
|
+
const isAllowed = lib_2._.isUndefined(basePathFoldersTosSkip.find(f => baseFolder.startsWith((0, lib_2.crossPlatformPath)(f))));
|
|
841
841
|
// console.log('isAllowed', isAllowed)
|
|
842
842
|
return isAllowed;
|
|
843
843
|
};
|
|
@@ -846,42 +846,42 @@ to: ${to}
|
|
|
846
846
|
filterOnlyCopy(basePathFoldersOnlyToInclude, projectOrBasepath) {
|
|
847
847
|
//#region @backendFunc
|
|
848
848
|
return (src, dest) => {
|
|
849
|
-
src = (0,
|
|
850
|
-
const baseFolder =
|
|
851
|
-
.replace((0,
|
|
849
|
+
src = (0, lib_2.crossPlatformPath)(src);
|
|
850
|
+
const baseFolder = lib_2._.first((0, lib_2.crossPlatformPath)(src)
|
|
851
|
+
.replace((0, lib_2.crossPlatformPath)(projectOrBasepath), '')
|
|
852
852
|
.replace(/^\//, '')
|
|
853
853
|
.split('/'));
|
|
854
854
|
if (!baseFolder || baseFolder.trim() === '') {
|
|
855
855
|
return true;
|
|
856
856
|
}
|
|
857
|
-
const isAllowed = !
|
|
857
|
+
const isAllowed = !lib_2._.isUndefined(basePathFoldersOnlyToInclude.find(f => baseFolder.startsWith((0, lib_2.crossPlatformPath)(f))));
|
|
858
858
|
return isAllowed;
|
|
859
859
|
};
|
|
860
860
|
//#endregion
|
|
861
861
|
}
|
|
862
862
|
copyFile(sourcePath, destinationPath, options) {
|
|
863
863
|
//#region @backendFunc
|
|
864
|
-
if (
|
|
864
|
+
if (lib_2._.isUndefined(options)) {
|
|
865
865
|
options = {};
|
|
866
866
|
}
|
|
867
|
-
if (
|
|
867
|
+
if (lib_2._.isUndefined(options.debugMode)) {
|
|
868
868
|
options.debugMode = false;
|
|
869
869
|
}
|
|
870
|
-
if (
|
|
870
|
+
if (lib_2._.isUndefined(options.debugMode)) {
|
|
871
871
|
options.fast = true;
|
|
872
872
|
}
|
|
873
|
-
if (
|
|
873
|
+
if (lib_2._.isUndefined(options.dontCopySameContent)) {
|
|
874
874
|
options.dontCopySameContent = true;
|
|
875
875
|
}
|
|
876
876
|
const { debugMode, fast, transformTextFn, dontCopySameContent } = options;
|
|
877
|
-
if (
|
|
877
|
+
if (lib_2._.isFunction(transformTextFn) && fast) {
|
|
878
878
|
index_1.Helpers.error(`[taon-helpers][copyFile] You cannot use transformTextFn in fast mode`);
|
|
879
879
|
}
|
|
880
|
-
if (!
|
|
880
|
+
if (!lib_2.fse.existsSync(sourcePath)) {
|
|
881
881
|
index_1.Helpers.logWarn(`[taon-helpers][copyFile] No able to find source of ${sourcePath}`);
|
|
882
882
|
return false;
|
|
883
883
|
}
|
|
884
|
-
if (
|
|
884
|
+
if (lib_2.fse.lstatSync(sourcePath).isDirectory()) {
|
|
885
885
|
index_1.Helpers.warn(`[taon-helpers][copyFile] Trying to copy directory as file: ${sourcePath}`, false);
|
|
886
886
|
return false;
|
|
887
887
|
}
|
|
@@ -889,25 +889,25 @@ to: ${to}
|
|
|
889
889
|
index_1.Helpers.warn(`[taon-helpers][copyFile] Trying to copy same file ${sourcePath}`);
|
|
890
890
|
return false;
|
|
891
891
|
}
|
|
892
|
-
let destDirPath =
|
|
892
|
+
let destDirPath = lib_2.path.dirname(destinationPath);
|
|
893
893
|
if (index_1.Helpers.isFolder(destinationPath)) {
|
|
894
894
|
index_1.Helpers.removeFolderIfExists(destinationPath);
|
|
895
895
|
}
|
|
896
896
|
if (!index_1.Helpers.isSymlinkFileExitedOrUnexisted(destDirPath) &&
|
|
897
|
-
!
|
|
897
|
+
!lib_2.fse.existsSync(destDirPath)) {
|
|
898
898
|
index_1.Helpers.mkdirp(destDirPath);
|
|
899
899
|
}
|
|
900
900
|
//#region it is good code
|
|
901
901
|
if (index_1.Helpers.isExistedSymlink(destDirPath)) {
|
|
902
|
-
destDirPath =
|
|
903
|
-
const newDestinationPath = (0,
|
|
902
|
+
destDirPath = lib_2.fse.realpathSync(destDirPath);
|
|
903
|
+
const newDestinationPath = (0, lib_2.crossPlatformPath)(lib_2.path.join(destDirPath, lib_2.path.basename(destinationPath)));
|
|
904
904
|
if (index_1.Helpers.isFolder(newDestinationPath)) {
|
|
905
905
|
index_1.Helpers.removeFolderIfExists(newDestinationPath);
|
|
906
906
|
}
|
|
907
907
|
destinationPath = newDestinationPath;
|
|
908
908
|
}
|
|
909
909
|
//#endregion
|
|
910
|
-
if (dontCopySameContent &&
|
|
910
|
+
if (dontCopySameContent && lib_2.fse.existsSync(destinationPath)) {
|
|
911
911
|
const destinationContent = index_1.Helpers.readFile(destinationPath);
|
|
912
912
|
const sourceContent = index_1.Helpers.readFile(sourcePath).toString();
|
|
913
913
|
if (destinationContent === sourceContent) {
|
|
@@ -917,13 +917,13 @@ to: ${to}
|
|
|
917
917
|
}
|
|
918
918
|
}
|
|
919
919
|
debugMode &&
|
|
920
|
-
index_1.Helpers.log(`path.extname(sourcePath) ${
|
|
921
|
-
if (fast || !
|
|
922
|
-
|
|
920
|
+
index_1.Helpers.log(`path.extname(sourcePath) ${lib_2.path.extname(sourcePath)}`);
|
|
921
|
+
if (fast || !lib_1.extAllowedToReplace.includes(lib_2.path.extname(sourcePath))) {
|
|
922
|
+
lib_2.fse.copyFileSync(sourcePath, destinationPath);
|
|
923
923
|
}
|
|
924
924
|
else {
|
|
925
925
|
let sourceData = index_1.Helpers.readFile(sourcePath).toString();
|
|
926
|
-
if (
|
|
926
|
+
if (lib_2._.isFunction(transformTextFn)) {
|
|
927
927
|
sourceData = transformTextFn(sourceData);
|
|
928
928
|
}
|
|
929
929
|
debugMode &&
|
|
@@ -944,12 +944,12 @@ ${sourceData}
|
|
|
944
944
|
resolve(fileOrFolderPath) {
|
|
945
945
|
//#region @backendFunc
|
|
946
946
|
if (fileOrFolderPath.startsWith('~')) {
|
|
947
|
-
fileOrFolderPath = (0,
|
|
948
|
-
|
|
947
|
+
fileOrFolderPath = (0, lib_2.crossPlatformPath)([
|
|
948
|
+
lib_2.os.homedir(),
|
|
949
949
|
fileOrFolderPath.replace(`~/`, ''),
|
|
950
950
|
]);
|
|
951
951
|
}
|
|
952
|
-
return (0,
|
|
952
|
+
return (0, lib_2.crossPlatformPath)(lib_2.path.resolve(fileOrFolderPath));
|
|
953
953
|
//#endregion
|
|
954
954
|
}
|
|
955
955
|
}
|