tnp-helpers 19.0.74 → 21.0.2
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/fesm2022/tnp-helpers.mjs +404 -154
- package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base/classes/base-db.d.ts +1 -1
- package/browser/lib/base/classes/base-git.d.ts +3 -1
- package/browser/lib/base/classes/base-global-command-line.d.ts +30 -15
- package/browser/lib/build-info._auto-generated_.d.ts +1 -1
- package/browser/lib/utils.d.ts +28 -4
- package/browser/package.json +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-database-config.js +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker-database-config.js.map +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker.utils.js +1 -1
- package/lib/base/classes/base-cli-worker/base-cli-worker.utils.js.map +1 -1
- package/lib/base/classes/base-db.d.ts +2 -2
- package/lib/base/classes/base-db.js +5 -3
- package/lib/base/classes/base-db.js.map +1 -1
- package/lib/base/classes/base-git.d.ts +3 -1
- package/lib/base/classes/base-git.js +8 -3
- package/lib/base/classes/base-git.js.map +1 -1
- package/lib/base/classes/base-global-command-line.d.ts +27 -12
- package/lib/base/classes/base-global-command-line.js +307 -215
- package/lib/base/classes/base-global-command-line.js.map +1 -1
- package/lib/base/classes/base-node-modules.js +7 -7
- package/lib/base/classes/base-node-modules.js.map +1 -1
- package/lib/base/classes/base-vscode.js +5 -1
- package/lib/base/classes/base-vscode.js.map +1 -1
- package/lib/base/gh-temp-code.js +6 -5
- package/lib/base/gh-temp-code.js.map +1 -1
- package/lib/base/tcp-udp-ports/not-assignable-port.entity.js +2 -2
- package/lib/base/tcp-udp-ports/ports.entity.d.ts +1 -1
- package/lib/base/tcp-udp-ports/tcp-udp-ports.context.d.ts +1 -19
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/env/env.angular-node-app.d.ts +1 -0
- package/lib/env/env.angular-node-app.js +3 -2
- package/lib/env/env.angular-node-app.js.map +1 -1
- package/lib/env/env.docs-webapp.d.ts +1 -0
- package/lib/env/env.docs-webapp.js +3 -2
- package/lib/env/env.docs-webapp.js.map +1 -1
- package/lib/env/env.electron-app.d.ts +1 -0
- package/lib/env/env.electron-app.js +3 -2
- package/lib/env/env.electron-app.js.map +1 -1
- package/lib/env/env.mobile-app.d.ts +1 -0
- package/lib/env/env.mobile-app.js +3 -2
- package/lib/env/env.mobile-app.js.map +1 -1
- package/lib/env/env.npm-lib-and-cli-tool.d.ts +1 -0
- package/lib/env/env.npm-lib-and-cli-tool.js +3 -2
- package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib/env/env.vscode-plugin.d.ts +1 -0
- package/lib/env/env.vscode-plugin.js +3 -2
- package/lib/env/env.vscode-plugin.js.map +1 -1
- package/lib/helpers/for-browser/angular.helper.js +2 -2
- package/lib/old/base-component.js +2 -2
- package/lib/old/base-formly-component.js +2 -2
- package/lib/old/dual-component-ctrl.js +2 -2
- package/lib/utils.d.ts +28 -4
- package/lib/utils.js +167 -26
- package/lib/utils.js.map +1 -1
- package/package.json +5 -5
- package/websql/fesm2022/tnp-helpers.mjs +404 -154
- package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base/classes/base-db.d.ts +1 -1
- package/websql/lib/base/classes/base-git.d.ts +3 -1
- package/websql/lib/base/classes/base-global-command-line.d.ts +30 -15
- package/websql/lib/build-info._auto-generated_.d.ts +1 -1
- package/websql/lib/utils.d.ts +28 -4
- package/websql/package.json +1 -1
|
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BaseGlobalCommandLine = void 0;
|
|
4
4
|
//#region imports
|
|
5
5
|
const readline = require("readline"); // @backend
|
|
6
|
+
const lib_1 = require("magic-renamer/lib"); // @backend
|
|
6
7
|
const rxjs_1 = require("rxjs");
|
|
7
|
-
const lib_1 = require("tnp-core/lib");
|
|
8
8
|
const lib_2 = require("tnp-core/lib");
|
|
9
9
|
const lib_3 = require("tnp-core/lib");
|
|
10
10
|
const lib_4 = require("tnp-core/lib");
|
|
11
11
|
const lib_5 = require("tnp-core/lib");
|
|
12
|
-
const lib_6 = require("tnp-core/lib");
|
|
13
|
-
const lib_7 = require("tnp-core/lib");
|
|
12
|
+
const lib_6 = require("tnp-core/lib");
|
|
13
|
+
const lib_7 = require("tnp-core/lib"); //@backend
|
|
14
|
+
const lib_8 = require("tnp-core/lib");
|
|
14
15
|
const index_1 = require("../../index");
|
|
15
16
|
const commit_data_1 = require("../commit-data");
|
|
16
17
|
const gh_temp_code_1 = require("../gh-temp-code");
|
|
@@ -25,14 +26,14 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
25
26
|
*/
|
|
26
27
|
async _runAsSudoIfNotElevated({ globalCommandName, }) {
|
|
27
28
|
//#region @backendFunc
|
|
28
|
-
if (!(await (0,
|
|
29
|
+
if (!(await (0, lib_3.isElevated)())) {
|
|
29
30
|
if (process.platform === 'win32') {
|
|
30
|
-
await
|
|
31
|
+
await lib_2.UtilsExecProc.spawnAdminSudo(`${lib_2.config.frameworkName} ${globalCommandName}`);
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
let pathOfExecutableNode = await
|
|
34
|
-
let pathOfExecutable = await
|
|
35
|
-
await
|
|
34
|
+
let pathOfExecutableNode = await lib_3.UtilsProcess.getPathOfExecutable('node');
|
|
35
|
+
let pathOfExecutable = await lib_3.UtilsProcess.getPathOfExecutable(lib_2.config.frameworkName);
|
|
36
|
+
await lib_2.UtilsExecProc.spawnAdminSudo(`${pathOfExecutableNode} ${pathOfExecutable} ${globalCommandName}`);
|
|
36
37
|
}
|
|
37
38
|
return true;
|
|
38
39
|
}
|
|
@@ -56,7 +57,7 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
56
57
|
index_1.Helpers.info(`
|
|
57
58
|
Current folder (${this.cwd})
|
|
58
59
|
is not a git root folder, but nearest project with
|
|
59
|
-
git root has been found in: ${
|
|
60
|
+
git root has been found in: ${lib_3.chalk.bold(proj.genericName)}
|
|
60
61
|
|
|
61
62
|
`);
|
|
62
63
|
const useRoot = await index_1.Helpers.questionYesNo('Would you like to use this project ?');
|
|
@@ -66,11 +67,11 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
66
67
|
return true;
|
|
67
68
|
}
|
|
68
69
|
else {
|
|
69
|
-
index_1.Helpers.error(`[${
|
|
70
|
+
index_1.Helpers.error(`[${lib_2.config.frameworkName}] This is not git root project folder`, true, true);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
else {
|
|
73
|
-
index_1.Helpers.error(`[${
|
|
74
|
+
index_1.Helpers.error(`[${lib_2.config.frameworkName}] This folder is not project folder`, false, true);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
return true;
|
|
@@ -80,7 +81,7 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
80
81
|
//#region commands / hosts
|
|
81
82
|
hosts() {
|
|
82
83
|
//#region @backendFunc
|
|
83
|
-
index_1.Helpers.run(`code ${(0,
|
|
84
|
+
index_1.Helpers.run(`code ${(0, lib_4.crossPlatformPath)(lib_6.UtilsNetwork.getEtcHostsPath())}`).sync();
|
|
84
85
|
process.exit(0);
|
|
85
86
|
//#endregion
|
|
86
87
|
}
|
|
@@ -100,9 +101,9 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
100
101
|
for (const folderAbsPath of index_1.Helpers.foldersFrom(this.cwd, {
|
|
101
102
|
recursive: false,
|
|
102
103
|
})) {
|
|
103
|
-
if (index_1.Helpers.exists((0,
|
|
104
|
+
if (index_1.Helpers.exists((0, lib_4.crossPlatformPath)([folderAbsPath, '.git']))) {
|
|
104
105
|
try {
|
|
105
|
-
index_1.Helpers.run(`git rm --cached ${
|
|
106
|
+
index_1.Helpers.run(`git rm --cached ${lib_3.path.basename(folderAbsPath)}`).sync();
|
|
106
107
|
}
|
|
107
108
|
catch (error) { }
|
|
108
109
|
}
|
|
@@ -114,7 +115,7 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
114
115
|
removeSubmodule() {
|
|
115
116
|
//#region @backendFunc
|
|
116
117
|
index_1.Helpers.taskStarted(`Removing submodules.. ${this.firstArg}`);
|
|
117
|
-
if (index_1.Helpers.exists((0,
|
|
118
|
+
if (index_1.Helpers.exists((0, lib_4.crossPlatformPath)([this.cwd, this.firstArg || '', '.git']))) {
|
|
118
119
|
try {
|
|
119
120
|
index_1.Helpers.run(`git rm --cached ${this.firstArg}`).sync();
|
|
120
121
|
}
|
|
@@ -203,123 +204,174 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
203
204
|
//#endregion
|
|
204
205
|
}
|
|
205
206
|
//#endregion
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* quick git update push
|
|
209
|
-
*/
|
|
210
|
-
async _update(commitMessage, force = false) {
|
|
207
|
+
async updateProject(project, options) {
|
|
211
208
|
//#region @backendFunc
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
209
|
+
options = options || {};
|
|
210
|
+
options.force = !!options.force;
|
|
211
|
+
options.updateType = options.updateType || 'only-this';
|
|
212
|
+
options.commitType = options.commitType || 'chore';
|
|
213
|
+
while (project.git.hasActionCommitsToMelt) {
|
|
214
|
+
const choices = {
|
|
215
|
+
openInCode: { name: 'Open in code editor' },
|
|
216
|
+
continue: { name: 'Continue' },
|
|
217
|
+
skipUpdate: { name: 'Skip project update' },
|
|
218
|
+
meltNow: { name: 'Melt action commits now' },
|
|
219
|
+
};
|
|
220
|
+
const resp = await lib_5.UtilsTerminal.select({
|
|
221
|
+
choices,
|
|
222
|
+
question: `Project ${lib_3.chalk.bold(project.genericName)} has action commits to melt. What you want to do ?`,
|
|
223
|
+
});
|
|
224
|
+
if (resp === 'continue') {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (resp === 'openInCode') {
|
|
228
|
+
project.run('code . ').sync();
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (resp === 'skipUpdate') {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (resp === 'meltNow') {
|
|
235
|
+
project.git.meltActionCommits();
|
|
236
|
+
index_1.Helpers.info(`Changes after melting:`);
|
|
237
|
+
console.log(await project.git.changesSummary({
|
|
238
|
+
prefix: `${project.location}/`,
|
|
239
|
+
}));
|
|
240
|
+
await lib_5.UtilsTerminal.pressAnyKeyToContinueAsync({
|
|
241
|
+
message: `Press any key to continue...`,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
218
244
|
}
|
|
219
|
-
catch (error) { }
|
|
220
|
-
await this.project.git.pushCurrentBranch({
|
|
221
|
-
askToRetry: true,
|
|
222
|
-
forcePushNoQuestion: true,
|
|
223
|
-
force,
|
|
224
|
-
});
|
|
225
|
-
index_1.Helpers.info('Done');
|
|
226
|
-
this._exit();
|
|
227
|
-
//#endregion
|
|
228
|
-
}
|
|
229
|
-
async forceup() {
|
|
230
|
-
await this.forceUpdate();
|
|
231
|
-
}
|
|
232
|
-
async forceUpdate() {
|
|
233
|
-
//#region @backendFunc
|
|
234
|
-
await this._update(`chore: ${!!this.firstArg ? this.firstArg : 'update'}`, true);
|
|
235
|
-
//#endregion
|
|
236
|
-
}
|
|
237
|
-
async update() {
|
|
238
|
-
//#region @backendFunc
|
|
239
|
-
await this._update(`chore: ${!!this.firstArg ? this.firstArg : 'update'}`);
|
|
240
|
-
//#endregion
|
|
241
|
-
}
|
|
242
|
-
async docsUp() {
|
|
243
|
-
//#region @backendFunc
|
|
244
|
-
await this._update(`docs: ${!!this.firstArg ? this.firstArg : 'update'}`);
|
|
245
|
-
//#endregion
|
|
246
|
-
}
|
|
247
|
-
async updateProject(project, force = false) {
|
|
248
|
-
//#region @backendFunc
|
|
249
245
|
try {
|
|
250
246
|
await project.packageJson.bumpPatchVersion();
|
|
251
247
|
}
|
|
252
248
|
catch (error) { }
|
|
253
249
|
try {
|
|
254
|
-
project.git.addAndCommit(
|
|
250
|
+
project.git.addAndCommit(`${options.commitType}: ${!!this.firstArg ? this.args.join(' ') : 'update'}`);
|
|
255
251
|
}
|
|
256
252
|
catch (error) { }
|
|
257
253
|
await project.git.pushCurrentBranch({
|
|
258
254
|
askToRetry: true,
|
|
259
255
|
forcePushNoQuestion: true,
|
|
260
|
-
force,
|
|
256
|
+
force: options.force,
|
|
261
257
|
});
|
|
262
|
-
if (!project.isMonorepo) {
|
|
258
|
+
if (!project.isMonorepo && options.updateType !== 'only-this') {
|
|
259
|
+
if (options.updateType === 'first-level') {
|
|
260
|
+
options.updateType = 'only-this';
|
|
261
|
+
}
|
|
263
262
|
for (const child of project.children) {
|
|
264
263
|
if (child.git.isGitRoot) {
|
|
265
|
-
await this.updateProject(child,
|
|
264
|
+
await this.updateProject(child, options);
|
|
266
265
|
}
|
|
267
266
|
}
|
|
268
267
|
}
|
|
269
268
|
//#endregion
|
|
270
269
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
await this.deepUpdate(noExit);
|
|
274
|
-
//#endregion
|
|
275
|
-
}
|
|
276
|
-
async upAll(noExit = false) {
|
|
277
|
-
//#region @backendFunc
|
|
278
|
-
await this.deepUpdate(noExit);
|
|
279
|
-
//#endregion
|
|
280
|
-
}
|
|
281
|
-
async deepUpForce(noExit = false) {
|
|
282
|
-
//#region @backendFunc
|
|
283
|
-
await this.deepUpdateForce(noExit);
|
|
284
|
-
//#endregion
|
|
285
|
-
}
|
|
286
|
-
async deepUpdateForce(noExit = false) {
|
|
287
|
-
//#region @backendFunc
|
|
270
|
+
//#region commands / force update
|
|
271
|
+
async forceUpdate() {
|
|
288
272
|
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
289
273
|
return;
|
|
290
274
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
275
|
+
await this.updateProject(this.project, {
|
|
276
|
+
force: true,
|
|
277
|
+
});
|
|
294
278
|
this._exit();
|
|
295
|
-
//#endregion
|
|
296
279
|
}
|
|
297
|
-
|
|
298
|
-
|
|
280
|
+
/**
|
|
281
|
+
* alias for forceupdate
|
|
282
|
+
*/
|
|
283
|
+
async forceup() {
|
|
284
|
+
await this.forceUpdate();
|
|
285
|
+
}
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region commands / update
|
|
288
|
+
async update() {
|
|
299
289
|
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
300
290
|
return;
|
|
301
291
|
}
|
|
302
|
-
index_1.Helpers.info('Deep updating & pushing project with children...');
|
|
303
292
|
await this.updateProject(this.project);
|
|
304
|
-
index_1.Helpers.info('Done');
|
|
305
293
|
this._exit();
|
|
306
|
-
//#endregion
|
|
307
294
|
}
|
|
308
295
|
/**
|
|
309
|
-
*
|
|
296
|
+
* alias for update
|
|
310
297
|
*/
|
|
311
298
|
async up() {
|
|
312
|
-
//#region @backendFunc
|
|
313
299
|
await this.update();
|
|
314
|
-
//#endregion
|
|
315
300
|
}
|
|
316
301
|
/**
|
|
317
|
-
*
|
|
302
|
+
* alias for update
|
|
318
303
|
*/
|
|
319
304
|
async pu() {
|
|
320
|
-
//#region @backendFunc
|
|
321
305
|
await this.update();
|
|
322
|
-
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region commands / docs update
|
|
309
|
+
async docsUpdate() {
|
|
310
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
await this.updateProject(this.project, {
|
|
314
|
+
commitType: 'docs',
|
|
315
|
+
});
|
|
316
|
+
this._exit();
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* alias for docsUpdate
|
|
320
|
+
*/
|
|
321
|
+
async docsUp() {
|
|
322
|
+
await this.docsUpdate();
|
|
323
|
+
}
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region commands / deep update
|
|
326
|
+
async deepUpdate() {
|
|
327
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
await this.updateProject(this.project, {
|
|
331
|
+
updateType: 'deep',
|
|
332
|
+
});
|
|
333
|
+
this._exit();
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* alias for deepupdate
|
|
337
|
+
*/
|
|
338
|
+
async deepUp() {
|
|
339
|
+
await this.deepUpdate();
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region commands / update all
|
|
343
|
+
async updateAll() {
|
|
344
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
await this.updateProject(this.project, {
|
|
348
|
+
updateType: 'first-level',
|
|
349
|
+
});
|
|
350
|
+
this._exit();
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* alias for updateAll
|
|
354
|
+
*/
|
|
355
|
+
async upAll() {
|
|
356
|
+
await this.updateAll();
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region commands / deep update force
|
|
360
|
+
async deepUpdateForce() {
|
|
361
|
+
if (!(await this.cwdIsProject({ requireProjectWithGitRoot: true }))) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
await this.updateProject(this.project, {
|
|
365
|
+
updateType: 'deep',
|
|
366
|
+
force: true,
|
|
367
|
+
});
|
|
368
|
+
this._exit();
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* alias for deepUpdateForce
|
|
372
|
+
*/
|
|
373
|
+
async deepUpForce() {
|
|
374
|
+
await this.deepUpdateForce();
|
|
323
375
|
}
|
|
324
376
|
//#endregion
|
|
325
377
|
//#region commands / develop
|
|
@@ -372,7 +424,7 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
372
424
|
index_1.Helpers.run(`${editor} ${locaitonFolderToOpen}`).sync();
|
|
373
425
|
};
|
|
374
426
|
if (results.length === 1) {
|
|
375
|
-
await openInEditor(
|
|
427
|
+
await openInEditor(lib_3._.first(results));
|
|
376
428
|
}
|
|
377
429
|
else if (results.length === 0) {
|
|
378
430
|
index_1.Helpers.error(`No project found by name: "${this.args.join(' ')}"`, false, true);
|
|
@@ -461,14 +513,14 @@ class BaseGlobalCommandLine extends base_command_line_feature_1.BaseCommandLineF
|
|
|
461
513
|
index_1.Helpers.info(`
|
|
462
514
|
|
|
463
515
|
YOU ARE RESETING ${withChildren ? 'EVERYTHING' : 'PROJECT'} ` +
|
|
464
|
-
`TO BRANCH: ${
|
|
516
|
+
`TO BRANCH: ${lib_3.chalk.bold(branchToReset)}
|
|
465
517
|
|
|
466
518
|
- curret project (${this.project.name})
|
|
467
519
|
${withChildren &&
|
|
468
|
-
|
|
520
|
+
lib_3._.isArray(this.project.children) &&
|
|
469
521
|
this.project.children.length > 0
|
|
470
522
|
? `- modules:\n${this.project.children
|
|
471
|
-
.map(c => `\t${c.basename} (${
|
|
523
|
+
.map(c => `\t${c.basename} (${lib_3.chalk.yellow(c.name)})`)
|
|
472
524
|
.join('\n')}`
|
|
473
525
|
: ''}
|
|
474
526
|
`);
|
|
@@ -491,7 +543,7 @@ ${withChildren &&
|
|
|
491
543
|
}
|
|
492
544
|
const parent = this.project.parent;
|
|
493
545
|
const branchFromLinkedProjectConfig = parent?.linkedProjects?.linkedProjects.find(l => {
|
|
494
|
-
return ((0,
|
|
546
|
+
return ((0, lib_4.crossPlatformPath)([parent.location, l.relativeClonePath]) ===
|
|
495
547
|
this.project.location);
|
|
496
548
|
})?.defaultBranch;
|
|
497
549
|
let overrideBranchToReset = this.firstArg ||
|
|
@@ -530,10 +582,10 @@ ${withChildren &&
|
|
|
530
582
|
let resetProject = this.project;
|
|
531
583
|
if (this.project.git.isInsideGitRepo && !this.project.git.isGitRoot) {
|
|
532
584
|
index_1.Helpers.warn(`You are not in root of git repo...`, false);
|
|
533
|
-
resetProject = this.ins.nearestTo((0,
|
|
585
|
+
resetProject = this.ins.nearestTo((0, lib_4.crossPlatformPath)([this.project.location, '..']), {
|
|
534
586
|
findGitRoot: true,
|
|
535
587
|
});
|
|
536
|
-
if (!(await index_1.Helpers.questionYesNo(`Would you like to reset root repo instead (project=${
|
|
588
|
+
if (!(await index_1.Helpers.questionYesNo(`Would you like to reset root repo instead (project=${lib_3.chalk.bold.red(resetProject.genericName)}) ?`))) {
|
|
537
589
|
index_1.Helpers.error(`Aborted`, false, true);
|
|
538
590
|
}
|
|
539
591
|
}
|
|
@@ -554,7 +606,7 @@ ${withChildren &&
|
|
|
554
606
|
return;
|
|
555
607
|
}
|
|
556
608
|
const howManyCommits = Number(this.firstArg) || 1;
|
|
557
|
-
|
|
609
|
+
lib_3._.times(howManyCommits, n => {
|
|
558
610
|
console.log(`Resetting soft ${n + 1} commit "${this.project.git.lastCommitMessage()}"`);
|
|
559
611
|
this.project.git.resetSoftHEAD(1);
|
|
560
612
|
});
|
|
@@ -576,7 +628,7 @@ ${withChildren &&
|
|
|
576
628
|
rebaseBranch = await this.__selectBrach(branches, 'rebase');
|
|
577
629
|
}
|
|
578
630
|
else if (branches.length === 1) {
|
|
579
|
-
rebaseBranch =
|
|
631
|
+
rebaseBranch = lib_3._.first(branches);
|
|
580
632
|
}
|
|
581
633
|
else {
|
|
582
634
|
index_1.Helpers.error(`No rebase branch found by name "${rebaseBranch}"`, false, true);
|
|
@@ -586,14 +638,14 @@ ${withChildren &&
|
|
|
586
638
|
|
|
587
639
|
Files from last commit:
|
|
588
640
|
|
|
589
|
-
"${
|
|
590
|
-
(hash: ${
|
|
641
|
+
"${lib_3.chalk.gray(await this.project.git.getCommitMessageByHash(this.project.git.lastCommitHash()))}"
|
|
642
|
+
(hash: ${lib_3.chalk.gray(this.project.git.lastCommitHash())})
|
|
591
643
|
|
|
592
644
|
are going to be applied after rebase.
|
|
593
645
|
|
|
594
646
|
|
|
595
647
|
`);
|
|
596
|
-
if (!(await
|
|
648
|
+
if (!(await lib_5.UtilsTerminal.confirm({
|
|
597
649
|
message: `Do you want to continue ?`,
|
|
598
650
|
defaultValue: true,
|
|
599
651
|
}))) {
|
|
@@ -702,7 +754,7 @@ ${remotes.map((r, i) => `${i + 1}. ${r.origin} ${r.url}`).join('\n')}
|
|
|
702
754
|
`);
|
|
703
755
|
for (let index = 0; index < remotes.length; index++) {
|
|
704
756
|
const { origin, url } = remotes[index];
|
|
705
|
-
index_1.Helpers.taskStarted(`Pushing to ${
|
|
757
|
+
index_1.Helpers.taskStarted(`Pushing to ${lib_3.chalk.bold(origin)} (${url})...`);
|
|
706
758
|
await this.push({ force, origin, noExit: true });
|
|
707
759
|
index_1.Helpers.taskDone(`Pushed to ${origin}`);
|
|
708
760
|
}
|
|
@@ -819,7 +871,7 @@ ${remotes.map((r, i) => `${i + 1}. ${r.origin} ${r.url}`).join('\n')}
|
|
|
819
871
|
${lastCommitMessage}
|
|
820
872
|
|
|
821
873
|
...`);
|
|
822
|
-
await
|
|
874
|
+
await lib_5.UtilsTerminal.pressAnyKeyToContinueAsync({
|
|
823
875
|
message: `Press any key to force push`,
|
|
824
876
|
});
|
|
825
877
|
}
|
|
@@ -960,7 +1012,7 @@ ${lastCommitMessage}
|
|
|
960
1012
|
await this.push({
|
|
961
1013
|
typeofCommit: 'release',
|
|
962
1014
|
commitMessageRequired: true,
|
|
963
|
-
overrideCommitMessage: `${
|
|
1015
|
+
overrideCommitMessage: `${lib_3._.first(this.project.releaseProcess.getReleaseWords())} ` +
|
|
964
1016
|
`version ${this.project.packageJson.version}`,
|
|
965
1017
|
});
|
|
966
1018
|
//#endregion
|
|
@@ -1189,6 +1241,16 @@ ${lastCommitMessage}
|
|
|
1189
1241
|
//#endregion
|
|
1190
1242
|
}
|
|
1191
1243
|
//#endregion
|
|
1244
|
+
//#region copy and rename (vscode option)
|
|
1245
|
+
async $COPY_AND_RENAME() {
|
|
1246
|
+
//#region @backendFunc
|
|
1247
|
+
// console.log(`>> ${args} <<`)
|
|
1248
|
+
const ins = lib_1.MagicRenamer.Instance(this.cwd);
|
|
1249
|
+
await ins.start(this.argsWithParams);
|
|
1250
|
+
this._exit();
|
|
1251
|
+
//#endregion
|
|
1252
|
+
}
|
|
1253
|
+
//#endregion
|
|
1192
1254
|
//#region commands / rename origin
|
|
1193
1255
|
async RENAME_ORIGIN() {
|
|
1194
1256
|
//#region @backendFunc
|
|
@@ -1341,13 +1403,13 @@ ${lastCommitMessage}
|
|
|
1341
1403
|
const libs = proj.children.filter(child => {
|
|
1342
1404
|
process.stdout.write('.');
|
|
1343
1405
|
return child.git.thereAreSomeUncommitedChangeExcept([
|
|
1344
|
-
|
|
1406
|
+
lib_2.config.file.package_json,
|
|
1345
1407
|
]);
|
|
1346
1408
|
});
|
|
1347
1409
|
console.log('\n' + index_1.Helpers.terminalLine());
|
|
1348
1410
|
index_1.Helpers.info(libs.length
|
|
1349
1411
|
? libs
|
|
1350
|
-
.map(c => `${
|
|
1412
|
+
.map(c => `${lib_3.chalk.bold(c.name)} (${c.git.uncommitedFiles.map(p => lib_3.chalk.black(lib_3.path.basename(p))).join(', ')})`)
|
|
1351
1413
|
.join('\n')
|
|
1352
1414
|
: 'Nothing modifed');
|
|
1353
1415
|
this._exit();
|
|
@@ -1394,7 +1456,7 @@ ${lastCommitMessage}
|
|
|
1394
1456
|
let tagToRemove = this.firstArg;
|
|
1395
1457
|
if (!tagToRemove) {
|
|
1396
1458
|
const allTags = await index_1.Helpers.git.getAllTags(this.cwd);
|
|
1397
|
-
tagToRemove = await
|
|
1459
|
+
tagToRemove = await lib_5.UtilsTerminal.select({
|
|
1398
1460
|
question: `Select tag to remove`,
|
|
1399
1461
|
autocomplete: true,
|
|
1400
1462
|
choices: allTags.map(t => {
|
|
@@ -1490,7 +1552,7 @@ ${lastCommitMessage}
|
|
|
1490
1552
|
gitConfig() {
|
|
1491
1553
|
//#region @backendFunc
|
|
1492
1554
|
const root = index_1.Helpers.git.findGitRoot(this.cwd);
|
|
1493
|
-
index_1.Helpers.run(`code ${(0,
|
|
1555
|
+
index_1.Helpers.run(`code ${(0, lib_4.crossPlatformPath)([root, '.git', 'config'])}`).sync();
|
|
1494
1556
|
this._exit();
|
|
1495
1557
|
//#endregion
|
|
1496
1558
|
}
|
|
@@ -1527,12 +1589,12 @@ ${lastCommitMessage}
|
|
|
1527
1589
|
async updateDepsFrom() {
|
|
1528
1590
|
//#region @backendFunc
|
|
1529
1591
|
let locations = this.args.join(' ').trim() === '' ? [] : this.args;
|
|
1530
|
-
if (
|
|
1592
|
+
if (lib_3._.isArray(locations)) {
|
|
1531
1593
|
locations = locations.map(l => {
|
|
1532
|
-
if (
|
|
1533
|
-
return
|
|
1594
|
+
if (lib_3.path.isAbsolute(l)) {
|
|
1595
|
+
return lib_3.path.resolve(l);
|
|
1534
1596
|
}
|
|
1535
|
-
return
|
|
1597
|
+
return lib_3.path.resolve(lib_3.path.join(this.cwd, l));
|
|
1536
1598
|
});
|
|
1537
1599
|
}
|
|
1538
1600
|
this.project.packageJson.updateDepsFrom(locations);
|
|
@@ -1551,7 +1613,7 @@ ${lastCommitMessage}
|
|
|
1551
1613
|
//#region is terminal running inside cmd
|
|
1552
1614
|
isRunningInWindowsCmd() {
|
|
1553
1615
|
//#region @backendFunc
|
|
1554
|
-
console.log(`Is terminal running insdie cmd.exe: ${
|
|
1616
|
+
console.log(`Is terminal running insdie cmd.exe: ${lib_3.UtilsOs.isRunningInWindowsCmd()}`);
|
|
1555
1617
|
this._exit();
|
|
1556
1618
|
//#endregion
|
|
1557
1619
|
}
|
|
@@ -1559,7 +1621,7 @@ ${lastCommitMessage}
|
|
|
1559
1621
|
//#region is running inside powershell
|
|
1560
1622
|
isRunningInWindowsPowerShell() {
|
|
1561
1623
|
//#region @backendFunc
|
|
1562
|
-
console.log(`Is terminal running insdie powershell: ${
|
|
1624
|
+
console.log(`Is terminal running insdie powershell: ${lib_3.UtilsOs.isRunningInWindowsPowerShell()}`);
|
|
1563
1625
|
this._exit();
|
|
1564
1626
|
//#endregion
|
|
1565
1627
|
}
|
|
@@ -1698,7 +1760,7 @@ ${lastCommitMessage}
|
|
|
1698
1760
|
async waitForUserAnyKey() {
|
|
1699
1761
|
//#region @backendFunc
|
|
1700
1762
|
console.log('Press any key to exit...');
|
|
1701
|
-
await
|
|
1763
|
+
await lib_5.UtilsTerminal.waitForUserAnyKey(async () => {
|
|
1702
1764
|
console.log('Exiting...');
|
|
1703
1765
|
this._exit();
|
|
1704
1766
|
});
|
|
@@ -1738,7 +1800,7 @@ ${lastCommitMessage}
|
|
|
1738
1800
|
async isPortInUse() {
|
|
1739
1801
|
//#region @backendFunc
|
|
1740
1802
|
const port = parseInt(this.firstArg);
|
|
1741
|
-
console.log(`Port ${port} is in use: ${await
|
|
1803
|
+
console.log(`Port ${port} is in use: ${await lib_3.UtilsOs.isPortInUse(port)}`);
|
|
1742
1804
|
this._exit();
|
|
1743
1805
|
//#endregion
|
|
1744
1806
|
}
|
|
@@ -1813,16 +1875,16 @@ ${lastCommitMessage}
|
|
|
1813
1875
|
//#region @backendFunc
|
|
1814
1876
|
index_1.Helpers.info(`
|
|
1815
1877
|
|
|
1816
|
-
Is running in CLI mode: ${
|
|
1817
|
-
Is running in Mocha test: ${
|
|
1818
|
-
Is running in VSCode extension: ${
|
|
1819
|
-
Is running in Electron: ${
|
|
1820
|
-
Is running in Docker: ${
|
|
1821
|
-
Is running in WebSQL: ${
|
|
1822
|
-
Is running in WSL: ${
|
|
1823
|
-
Is running in Linux graphics capable environment: ${
|
|
1824
|
-
Is running in Node: ${
|
|
1825
|
-
Is running in Browser: ${
|
|
1878
|
+
Is running in CLI mode: ${lib_3.UtilsOs.isRunningInCliMode()}
|
|
1879
|
+
Is running in Mocha test: ${lib_3.UtilsOs.isRunningInMochaTest()}
|
|
1880
|
+
Is running in VSCode extension: ${lib_3.UtilsOs.isRunningInVscodeExtension()}
|
|
1881
|
+
Is running in Electron: ${lib_3.UtilsOs.isRunningInElectron()}
|
|
1882
|
+
Is running in Docker: ${lib_3.UtilsOs.isRunningInDocker()}
|
|
1883
|
+
Is running in WebSQL: ${lib_3.UtilsOs.isRunningInWebSQL()}
|
|
1884
|
+
Is running in WSL: ${lib_3.UtilsOs.isRunningInWsl()}
|
|
1885
|
+
Is running in Linux graphics capable environment: ${lib_3.UtilsOs.isRunningInLinuxGraphicsCapableEnvironment()}
|
|
1886
|
+
Is running in Node: ${lib_3.UtilsOs.isRunningInNode()}
|
|
1887
|
+
Is running in Browser: ${lib_3.UtilsOs.isRunningInBrowser()}
|
|
1826
1888
|
|
|
1827
1889
|
`);
|
|
1828
1890
|
this._exit();
|
|
@@ -1858,13 +1920,43 @@ ${lastCommitMessage}
|
|
|
1858
1920
|
index_1.Helpers.error(`No ports provided`, false, true);
|
|
1859
1921
|
}
|
|
1860
1922
|
for (const port of ports) {
|
|
1861
|
-
const isPortInUse = await
|
|
1862
|
-
console.log(`Port ${port} is in use: ${isPortInUse ?
|
|
1923
|
+
const isPortInUse = await lib_3.UtilsOs.isPortInUse(port);
|
|
1924
|
+
console.log(`Port ${port} is in use: ${isPortInUse ? lib_3.chalk.red('YES') : lib_3.chalk.green('NO')}`);
|
|
1863
1925
|
}
|
|
1864
1926
|
this._exit();
|
|
1865
1927
|
//#endregion
|
|
1866
1928
|
}
|
|
1867
1929
|
//#endregion
|
|
1930
|
+
symlink() {
|
|
1931
|
+
//#region @backendFunc
|
|
1932
|
+
let [fromArg, toArg] = this.args;
|
|
1933
|
+
if (!lib_3.path.isAbsolute(fromArg)) {
|
|
1934
|
+
fromArg = (0, lib_4.crossPlatformPath)([
|
|
1935
|
+
this.cwd,
|
|
1936
|
+
fromArg.replace('./', '').replace('.\\', ''),
|
|
1937
|
+
]);
|
|
1938
|
+
}
|
|
1939
|
+
if (!lib_3.path.isAbsolute(toArg)) {
|
|
1940
|
+
toArg = (0, lib_4.crossPlatformPath)([
|
|
1941
|
+
this.cwd,
|
|
1942
|
+
toArg.replace('./', '').replace('.\\', ''),
|
|
1943
|
+
]);
|
|
1944
|
+
}
|
|
1945
|
+
if (index_1.Helpers.isUnexistedLink(fromArg)) {
|
|
1946
|
+
index_1.Helpers.error(`Source path "${fromArg}" is an unexisted link`, false, true);
|
|
1947
|
+
}
|
|
1948
|
+
if (!index_1.Helpers.exists(fromArg)) {
|
|
1949
|
+
index_1.Helpers.error(`Source path "${fromArg}" does not exist`, false, true);
|
|
1950
|
+
}
|
|
1951
|
+
fromArg = (0, lib_4.crossPlatformPath)(lib_3.fse.realpathSync(fromArg));
|
|
1952
|
+
if (lib_3.path.basename(fromArg) !== lib_3.path.basename(toArg)) {
|
|
1953
|
+
toArg = (0, lib_4.crossPlatformPath)([toArg, lib_3.path.basename(fromArg)]);
|
|
1954
|
+
}
|
|
1955
|
+
index_1.Helpers.createSymLink(fromArg, toArg);
|
|
1956
|
+
index_1.Helpers.info(`Symlink created from "${fromArg}" to "${toArg}"`);
|
|
1957
|
+
this._exit();
|
|
1958
|
+
//#endregion
|
|
1959
|
+
}
|
|
1868
1960
|
//#region commands / remove symlinks
|
|
1869
1961
|
removeSymlinksDryRun() {
|
|
1870
1962
|
//#region @backendFunc
|
|
@@ -1904,14 +1996,14 @@ ${lastCommitMessage}
|
|
|
1904
1996
|
copy() {
|
|
1905
1997
|
//#region @backendFunc
|
|
1906
1998
|
let [from, to] = this.args;
|
|
1907
|
-
from =
|
|
1908
|
-
? (0,
|
|
1909
|
-
: (0,
|
|
1910
|
-
to =
|
|
1911
|
-
? (0,
|
|
1912
|
-
: (0,
|
|
1913
|
-
if (
|
|
1914
|
-
to = (0,
|
|
1999
|
+
from = lib_3.path.isAbsolute(from)
|
|
2000
|
+
? (0, lib_4.crossPlatformPath)(from)
|
|
2001
|
+
: (0, lib_4.crossPlatformPath)([this.cwd, from]);
|
|
2002
|
+
to = lib_3.path.isAbsolute(to)
|
|
2003
|
+
? (0, lib_4.crossPlatformPath)(to)
|
|
2004
|
+
: (0, lib_4.crossPlatformPath)([this.cwd, to]);
|
|
2005
|
+
if (lib_3.path.basename(to) !== lib_3.path.basename(from)) {
|
|
2006
|
+
to = (0, lib_4.crossPlatformPath)([to, lib_3.path.basename(from)]);
|
|
1915
2007
|
}
|
|
1916
2008
|
index_1.Helpers.taskStarted(`Copying from ${from} to ${to}`);
|
|
1917
2009
|
if (!index_1.Helpers.exists(from)) {
|
|
@@ -1936,7 +2028,7 @@ ${lastCommitMessage}
|
|
|
1936
2028
|
globalCommandName: 'simulateDomain',
|
|
1937
2029
|
});
|
|
1938
2030
|
if (!commandEvaluatedAsSudo) {
|
|
1939
|
-
await
|
|
2031
|
+
await lib_2.UtilsEtcHosts.simulateDomain(this.args);
|
|
1940
2032
|
}
|
|
1941
2033
|
this._exit();
|
|
1942
2034
|
//#endregion
|
|
@@ -1946,20 +2038,20 @@ ${lastCommitMessage}
|
|
|
1946
2038
|
async preview() {
|
|
1947
2039
|
//#region @backendFunc
|
|
1948
2040
|
//#region handle preview of docker compose
|
|
1949
|
-
if ([
|
|
2041
|
+
if ([lib_2.fileName.docker_compose_yml, lib_2.fileName.compose_yml].includes(lib_3.path.basename(this.firstArg))) {
|
|
1950
2042
|
const simulateDomain = this.params['domain'] || this.params['domains'];
|
|
1951
|
-
const firstArg =
|
|
2043
|
+
const firstArg = lib_3.path.isAbsolute(this.firstArg)
|
|
1952
2044
|
? this.firstArg
|
|
1953
|
-
: (0,
|
|
1954
|
-
const cwd = (0,
|
|
1955
|
-
const composeFileName =
|
|
2045
|
+
: (0, lib_4.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
2046
|
+
const cwd = (0, lib_4.crossPlatformPath)(lib_3.path.dirname(firstArg));
|
|
2047
|
+
const composeFileName = lib_3.path.basename(firstArg);
|
|
1956
2048
|
// import { spawn } from 'child_process';
|
|
1957
2049
|
// import { readFileSync } from 'fs';
|
|
1958
2050
|
// import { resolve } from 'path';
|
|
1959
|
-
const envPath = (0,
|
|
1960
|
-
const COMPOSE_PROJECT_NAME =
|
|
1961
|
-
const envContent =
|
|
1962
|
-
const allDomains =
|
|
2051
|
+
const envPath = (0, lib_4.crossPlatformPath)([cwd, '.env']);
|
|
2052
|
+
const COMPOSE_PROJECT_NAME = lib_6.UtilsDotFile.getValueFromDotFile(envPath, 'COMPOSE_PROJECT_NAME');
|
|
2053
|
+
const envContent = lib_6.UtilsDotFile.getValuesKeysAsJsonObject(envPath) || {};
|
|
2054
|
+
const allDomains = lib_3.Utils.uniqArray(Object.keys(envContent)
|
|
1963
2055
|
.filter(key => {
|
|
1964
2056
|
return key.startsWith('FRONTEND_HOST_URL_');
|
|
1965
2057
|
})
|
|
@@ -1971,7 +2063,7 @@ ${lastCommitMessage}
|
|
|
1971
2063
|
|
|
1972
2064
|
env.ts or env.angular-node-app.ENVIRONTMENT_NAME.ts with
|
|
1973
2065
|
|
|
1974
|
-
${
|
|
2066
|
+
${lib_3.chalk.bold(`website.useDomain = true;`)}
|
|
1975
2067
|
|
|
1976
2068
|
`, false, true);
|
|
1977
2069
|
}
|
|
@@ -1980,7 +2072,7 @@ ${lastCommitMessage}
|
|
|
1980
2072
|
let closing = false;
|
|
1981
2073
|
const triggerRevertChangesToEtcHosts = new rxjs_1.Subject();
|
|
1982
2074
|
if (simulateDomain) {
|
|
1983
|
-
await
|
|
2075
|
+
await lib_6.UtilsNetwork.simulateDomain(allDomains, {
|
|
1984
2076
|
triggerRevertChangesToEtcHosts,
|
|
1985
2077
|
});
|
|
1986
2078
|
}
|
|
@@ -1988,8 +2080,8 @@ ${lastCommitMessage}
|
|
|
1988
2080
|
console.log(`
|
|
1989
2081
|
|
|
1990
2082
|
|
|
1991
|
-
${
|
|
1992
|
-
`FOR ${
|
|
2083
|
+
${lib_3.chalk.bold('PRESS ANY KEY TO STOP')} RUNNING CONTAINER(S) ` +
|
|
2084
|
+
`FOR ${lib_3.chalk.bold.underline(COMPOSE_PROJECT_NAME)}
|
|
1993
2085
|
${simulateDomain ? `AND SIMULATING DOMAINS: ${allDomains.join(', ')} IN ETC/HOST` : ''}
|
|
1994
2086
|
|
|
1995
2087
|
|
|
@@ -2028,9 +2120,9 @@ ${lastCommitMessage}
|
|
|
2028
2120
|
async shorten() {
|
|
2029
2121
|
//#region @backendFunc
|
|
2030
2122
|
const rl = readline.createInterface({
|
|
2031
|
-
input:
|
|
2032
|
-
? (0,
|
|
2033
|
-
: (0,
|
|
2123
|
+
input: lib_3.fse.createReadStream(lib_3.path.isAbsolute(this.firstArg)
|
|
2124
|
+
? (0, lib_4.crossPlatformPath)(this.firstArg)
|
|
2125
|
+
: (0, lib_4.crossPlatformPath)([this.cwd, this.firstArg]), { encoding: 'utf8' }),
|
|
2034
2126
|
crlfDelay: Infinity,
|
|
2035
2127
|
});
|
|
2036
2128
|
const keywords = this.args.splice(1);
|
|
@@ -2049,26 +2141,26 @@ ${lastCommitMessage}
|
|
|
2049
2141
|
dumpPackagesVersions() {
|
|
2050
2142
|
//#region @backendFunc
|
|
2051
2143
|
const getData = (location) => {
|
|
2052
|
-
const version = index_1.Helpers.readValueFromJson((0,
|
|
2053
|
-
const name = index_1.Helpers.readValueFromJson((0,
|
|
2144
|
+
const version = index_1.Helpers.readValueFromJson((0, lib_4.crossPlatformPath)([location, lib_2.fileName.package_json]), 'version');
|
|
2145
|
+
const name = index_1.Helpers.readValueFromJson((0, lib_4.crossPlatformPath)([location, lib_2.fileName.package_json]), 'name');
|
|
2054
2146
|
return { version, name };
|
|
2055
2147
|
};
|
|
2056
|
-
const pkgs = index_1.Helpers.foldersFrom([this.cwd,
|
|
2148
|
+
const pkgs = index_1.Helpers.foldersFrom([this.cwd, lib_2.folderName.node_modules], {
|
|
2057
2149
|
recursive: false,
|
|
2058
2150
|
})
|
|
2059
2151
|
.reduce((arr, c) => {
|
|
2060
|
-
if (
|
|
2152
|
+
if (lib_3.path.basename(c).startsWith('@')) {
|
|
2061
2153
|
const newData = index_1.Helpers.foldersFrom([
|
|
2062
2154
|
this.cwd,
|
|
2063
|
-
|
|
2064
|
-
|
|
2155
|
+
lib_2.folderName.node_modules,
|
|
2156
|
+
lib_3.path.basename(c),
|
|
2065
2157
|
]).map(c2 => getData(c2));
|
|
2066
2158
|
return arr.concat(newData);
|
|
2067
2159
|
}
|
|
2068
2160
|
return arr.concat(getData(c));
|
|
2069
2161
|
}, [])
|
|
2070
2162
|
.reduce((arr, c) => {
|
|
2071
|
-
return
|
|
2163
|
+
return lib_3._.merge(arr, { [c.name]: c.version });
|
|
2072
2164
|
}, {});
|
|
2073
2165
|
index_1.Helpers.writeJson([this.cwd, 'packages-versions.json'], pkgs);
|
|
2074
2166
|
index_1.Helpers.info(`packages-versions.json created with ${pkgs.length} packages`);
|
|
@@ -2079,9 +2171,9 @@ ${lastCommitMessage}
|
|
|
2079
2171
|
//#region commands / zip
|
|
2080
2172
|
async zip() {
|
|
2081
2173
|
//#region @backendFunc
|
|
2082
|
-
let folderPath = (0,
|
|
2083
|
-
if (!
|
|
2084
|
-
folderPath = (0,
|
|
2174
|
+
let folderPath = (0, lib_4.crossPlatformPath)(this.firstArg);
|
|
2175
|
+
if (!lib_3.path.isAbsolute(folderPath)) {
|
|
2176
|
+
folderPath = (0, lib_4.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
2085
2177
|
}
|
|
2086
2178
|
if (!index_1.Helpers.exists(folderPath)) {
|
|
2087
2179
|
index_1.Helpers.error(`File or folder to zip does not exist: ${folderPath}`, false, true);
|
|
@@ -2100,9 +2192,9 @@ ${lastCommitMessage}
|
|
|
2100
2192
|
//#region commands / unzip
|
|
2101
2193
|
async unzip() {
|
|
2102
2194
|
//#region @backendFunc
|
|
2103
|
-
let folderPath = (0,
|
|
2104
|
-
if (!
|
|
2105
|
-
folderPath = (0,
|
|
2195
|
+
let folderPath = (0, lib_4.crossPlatformPath)(this.firstArg);
|
|
2196
|
+
if (!lib_3.path.isAbsolute(folderPath)) {
|
|
2197
|
+
folderPath = (0, lib_4.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
2106
2198
|
}
|
|
2107
2199
|
if (!index_1.Helpers.exists(folderPath)) {
|
|
2108
2200
|
index_1.Helpers.error(`File or folder to zip does not exist: ${folderPath}`, false, true);
|
|
@@ -2117,13 +2209,13 @@ ${lastCommitMessage}
|
|
|
2117
2209
|
async startTransmission() {
|
|
2118
2210
|
//#region @backendFunc
|
|
2119
2211
|
await this._removeTransmission();
|
|
2120
|
-
const userProfile = process.env.USERPROFILE ||
|
|
2121
|
-
const downloadsDir =
|
|
2122
|
-
const configDir =
|
|
2123
|
-
await
|
|
2212
|
+
const userProfile = process.env.USERPROFILE || lib_3.os.homedir();
|
|
2213
|
+
const downloadsDir = lib_3.path.join(userProfile, 'Downloads');
|
|
2214
|
+
const configDir = lib_3.path.join(userProfile, 'transmission-config');
|
|
2215
|
+
await lib_3.UtilsProcess.killProcessOnPort(9091);
|
|
2124
2216
|
const ctrl = await this.ins.portsWorker.getRemoteControllerFor({
|
|
2125
2217
|
methodOptions: {
|
|
2126
|
-
calledFrom: `${
|
|
2218
|
+
calledFrom: `${lib_2.config.frameworkName} startTransmission`,
|
|
2127
2219
|
},
|
|
2128
2220
|
});
|
|
2129
2221
|
const data = await ctrl
|
|
@@ -2155,7 +2247,7 @@ ${lastCommitMessage}
|
|
|
2155
2247
|
'linuxserver/transmission:latest',
|
|
2156
2248
|
];
|
|
2157
2249
|
console.log('Running:', 'docker', args.join(' '));
|
|
2158
|
-
const child =
|
|
2250
|
+
const child = lib_7.child_process.spawn('docker', args, { stdio: 'inherit' });
|
|
2159
2251
|
child.on('exit', code => {
|
|
2160
2252
|
if (code === 0) {
|
|
2161
2253
|
console.log('✅ Transmission container started');
|
|
@@ -2173,7 +2265,7 @@ ${lastCommitMessage}
|
|
|
2173
2265
|
return new Promise(resolve => {
|
|
2174
2266
|
const args = ['rm', '-f', 'transmission'];
|
|
2175
2267
|
console.log('Running:', 'docker', args.join(' '));
|
|
2176
|
-
const child =
|
|
2268
|
+
const child = lib_7.child_process.spawn('docker', args, { stdio: 'inherit' });
|
|
2177
2269
|
child.on('exit', code => {
|
|
2178
2270
|
if (code === 0) {
|
|
2179
2271
|
console.log('🗑️ Transmission container removed');
|
|
@@ -2235,9 +2327,9 @@ ${lastCommitMessage}
|
|
|
2235
2327
|
'browser',
|
|
2236
2328
|
];
|
|
2237
2329
|
const walk = (folder) => {
|
|
2238
|
-
const entries =
|
|
2330
|
+
const entries = lib_3.fse.readdirSync(folder, { withFileTypes: true });
|
|
2239
2331
|
for (const entry of entries) {
|
|
2240
|
-
const fullPath =
|
|
2332
|
+
const fullPath = lib_3.path.join(folder, entry.name);
|
|
2241
2333
|
if (skip.some(s => entry.name.startsWith(s))) {
|
|
2242
2334
|
continue;
|
|
2243
2335
|
}
|
|
@@ -2245,16 +2337,16 @@ ${lastCommitMessage}
|
|
|
2245
2337
|
// console.log('Processing: ', path.basename(fullPath));
|
|
2246
2338
|
walk(fullPath);
|
|
2247
2339
|
}
|
|
2248
|
-
else if (extensions.includes(
|
|
2249
|
-
const code =
|
|
2250
|
-
const stats = sloc(code,
|
|
2340
|
+
else if (extensions.includes(lib_3.path.extname(entry.name))) {
|
|
2341
|
+
const code = lib_3.fse.readFileSync(fullPath, 'utf8');
|
|
2342
|
+
const stats = sloc(code, lib_3.path.extname(entry.name).slice(1)); // e.g., "ts" or "js"
|
|
2251
2343
|
for (const key in total) {
|
|
2252
2344
|
total[key] += stats[key] ?? 0;
|
|
2253
2345
|
}
|
|
2254
2346
|
}
|
|
2255
2347
|
}
|
|
2256
2348
|
};
|
|
2257
|
-
walk((0,
|
|
2349
|
+
walk((0, lib_4.crossPlatformPath)([
|
|
2258
2350
|
this.cwd,
|
|
2259
2351
|
// 'src'
|
|
2260
2352
|
]));
|
|
@@ -2269,7 +2361,7 @@ ${lastCommitMessage}
|
|
|
2269
2361
|
isNodeVersionOk() {
|
|
2270
2362
|
//#region @backendFunc
|
|
2271
2363
|
try {
|
|
2272
|
-
|
|
2364
|
+
lib_3.UtilsOs.isNodeVersionOk({
|
|
2273
2365
|
throwErrorIfNotOk: true,
|
|
2274
2366
|
});
|
|
2275
2367
|
console.info(`Node.js version is OK: ${process.version}`);
|
|
@@ -2284,19 +2376,19 @@ ${lastCommitMessage}
|
|
|
2284
2376
|
//#endregion
|
|
2285
2377
|
//#region commands / pwd
|
|
2286
2378
|
pwd() {
|
|
2287
|
-
|
|
2288
|
-
console.log((0,
|
|
2379
|
+
lib_2.config.frameworkName = 'taon';
|
|
2380
|
+
console.log((0, lib_4.crossPlatformPath)(this.cwd));
|
|
2289
2381
|
this._exit();
|
|
2290
2382
|
}
|
|
2291
2383
|
//#endregion
|
|
2292
2384
|
//#region commands / less-more big text files preview
|
|
2293
2385
|
async more() {
|
|
2294
2386
|
//#region @backendFunc
|
|
2295
|
-
const pathToFile =
|
|
2296
|
-
? (0,
|
|
2297
|
-
: (0,
|
|
2387
|
+
const pathToFile = lib_3.path.isAbsolute(this.firstArg)
|
|
2388
|
+
? (0, lib_4.crossPlatformPath)(this.firstArg)
|
|
2389
|
+
: (0, lib_4.crossPlatformPath)([this.cwd, this.firstArg]);
|
|
2298
2390
|
console.log(`Displaying file: ${pathToFile}`);
|
|
2299
|
-
await
|
|
2391
|
+
await lib_5.UtilsTerminal.previewLongListGitLogLike(index_1.Helpers.readFile(pathToFile) || '< empty log file >');
|
|
2300
2392
|
this._exit();
|
|
2301
2393
|
//#endregion
|
|
2302
2394
|
}
|
|
@@ -2314,8 +2406,8 @@ ${lastCommitMessage}
|
|
|
2314
2406
|
*/
|
|
2315
2407
|
MP3(args) {
|
|
2316
2408
|
//#region @backendFunc
|
|
2317
|
-
const downloadPath = (0,
|
|
2318
|
-
|
|
2409
|
+
const downloadPath = (0, lib_4.crossPlatformPath)([
|
|
2410
|
+
lib_3.UtilsOs.getRealHomeDir(),
|
|
2319
2411
|
'Downloads',
|
|
2320
2412
|
'mp3-from-websites',
|
|
2321
2413
|
]);
|
|
@@ -2334,8 +2426,8 @@ ${lastCommitMessage}
|
|
|
2334
2426
|
//#region commands / mp4
|
|
2335
2427
|
MP4(args) {
|
|
2336
2428
|
//#region @backendFunc
|
|
2337
|
-
const downloadPath = (0,
|
|
2338
|
-
|
|
2429
|
+
const downloadPath = (0, lib_4.crossPlatformPath)([
|
|
2430
|
+
lib_3.UtilsOs.getRealHomeDir(),
|
|
2339
2431
|
'Downloads',
|
|
2340
2432
|
'mp4-from-websites',
|
|
2341
2433
|
]);
|
|
@@ -2352,17 +2444,17 @@ ${lastCommitMessage}
|
|
|
2352
2444
|
//#region commands / gif from video
|
|
2353
2445
|
gif() {
|
|
2354
2446
|
//#region @backendFunc
|
|
2355
|
-
const cwdToProcess =
|
|
2356
|
-
?
|
|
2447
|
+
const cwdToProcess = lib_3.path.isAbsolute(this.firstArg)
|
|
2448
|
+
? lib_3.path.dirname(this.firstArg)
|
|
2357
2449
|
: this.cwd;
|
|
2358
|
-
const basenameToProcess =
|
|
2359
|
-
const gifDownloadPath = (0,
|
|
2360
|
-
|
|
2450
|
+
const basenameToProcess = lib_3.path.basename(this.firstArg);
|
|
2451
|
+
const gifDownloadPath = (0, lib_4.crossPlatformPath)([
|
|
2452
|
+
lib_3.UtilsOs.getRealHomeDir(),
|
|
2361
2453
|
'Downloads',
|
|
2362
2454
|
'gif-from-videos',
|
|
2363
|
-
basenameToProcess.replace(
|
|
2455
|
+
basenameToProcess.replace(lib_3.path.extname(basenameToProcess), '.gif'),
|
|
2364
2456
|
]);
|
|
2365
|
-
const palleteBasename = `${
|
|
2457
|
+
const palleteBasename = `${lib_3._.kebabCase(lib_3.path.basename(gifDownloadPath))}-palette.png`;
|
|
2366
2458
|
index_1.Helpers.removeFileIfExists([cwdToProcess, palleteBasename]);
|
|
2367
2459
|
const quality = `fps=10,scale=960`;
|
|
2368
2460
|
index_1.Helpers.info(`Preparing gif from video (creating palette)...`);
|
|
@@ -2374,18 +2466,18 @@ ${lastCommitMessage}
|
|
|
2374
2466
|
index_1.Helpers.info(`Preparing gif from video (creating video)...`);
|
|
2375
2467
|
index_1.Helpers.run(`ffmpeg -i ${basenameToProcess} -i ` +
|
|
2376
2468
|
` ${palleteBasename} -filter_complex ` +
|
|
2377
|
-
`"${quality}:-1:flags=lanczos[x];[x][1:v]paletteuse" ${
|
|
2469
|
+
`"${quality}:-1:flags=lanczos[x];[x][1:v]paletteuse" ${lib_3.path.basename(gifDownloadPath)}`, {
|
|
2378
2470
|
output: true,
|
|
2379
2471
|
cwd: cwdToProcess,
|
|
2380
2472
|
}).sync();
|
|
2381
2473
|
index_1.Helpers.removeFileIfExists(gifDownloadPath);
|
|
2382
|
-
index_1.Helpers.move((0,
|
|
2474
|
+
index_1.Helpers.move((0, lib_4.crossPlatformPath)([cwdToProcess, lib_3.path.basename(gifDownloadPath)]), gifDownloadPath);
|
|
2383
2475
|
index_1.Helpers.taskDone(`Done creating gif from video:
|
|
2384
2476
|
|
|
2385
2477
|
${gifDownloadPath}
|
|
2386
2478
|
|
|
2387
2479
|
`);
|
|
2388
|
-
index_1.Helpers.openFolderInFileExplorer(
|
|
2480
|
+
index_1.Helpers.openFolderInFileExplorer(lib_3.path.dirname(gifDownloadPath));
|
|
2389
2481
|
this._exit();
|
|
2390
2482
|
//#endregion
|
|
2391
2483
|
}
|
|
@@ -2458,7 +2550,7 @@ ${lastCommitMessage}
|
|
|
2458
2550
|
if (!this.firstArg) {
|
|
2459
2551
|
index_1.Helpers.error(`You need to provide command name to check`, false, true);
|
|
2460
2552
|
}
|
|
2461
|
-
const hasSudo = await
|
|
2553
|
+
const hasSudo = await lib_3.UtilsOs.commandExistsAsync(this.firstArg);
|
|
2462
2554
|
console.log(`[ASYNC] Your os has "${this.firstArg}" command: ${hasSudo}`);
|
|
2463
2555
|
this._exit();
|
|
2464
2556
|
//#endregion
|
|
@@ -2468,7 +2560,7 @@ ${lastCommitMessage}
|
|
|
2468
2560
|
if (!this.firstArg) {
|
|
2469
2561
|
index_1.Helpers.error(`You need to provide command name to check`, false, true);
|
|
2470
2562
|
}
|
|
2471
|
-
const hasSudo =
|
|
2563
|
+
const hasSudo = lib_3.UtilsOs.commandExistsSync(this.firstArg);
|
|
2472
2564
|
console.log(`[sync version] Your os has "${this.firstArg}" command: ${hasSudo}`);
|
|
2473
2565
|
this._exit();
|
|
2474
2566
|
//#endregion
|
|
@@ -2476,7 +2568,7 @@ ${lastCommitMessage}
|
|
|
2476
2568
|
//#endregion
|
|
2477
2569
|
//#region commands / public ip address
|
|
2478
2570
|
async publicIpAddress() {
|
|
2479
|
-
const ip = await
|
|
2571
|
+
const ip = await lib_6.UtilsNetwork.getCurrentPublicIpAddress();
|
|
2480
2572
|
console.log(`Your public IP address is: ${ip}`);
|
|
2481
2573
|
this._exit();
|
|
2482
2574
|
}
|
|
@@ -2488,9 +2580,9 @@ ${lastCommitMessage}
|
|
|
2488
2580
|
//#endregion
|
|
2489
2581
|
//#region commands / open origins in vscode
|
|
2490
2582
|
async localIps() {
|
|
2491
|
-
const firstActiveLocalIp = await
|
|
2583
|
+
const firstActiveLocalIp = await lib_6.UtilsNetwork.getFirstIpV4LocalActiveIpAddress();
|
|
2492
2584
|
console.log(`Your first active local IP address is: ${firstActiveLocalIp} `);
|
|
2493
|
-
const ips = await
|
|
2585
|
+
const ips = await lib_6.UtilsNetwork.getLocalIpAddresses();
|
|
2494
2586
|
for (let index = 0; index < ips.length; index++) {
|
|
2495
2587
|
const ip = ips[index];
|
|
2496
2588
|
// console.log(ip);
|
|
@@ -2503,8 +2595,8 @@ ${lastCommitMessage}
|
|
|
2503
2595
|
//#region commands / is online
|
|
2504
2596
|
async isOnline() {
|
|
2505
2597
|
//#region @backendFunc
|
|
2506
|
-
const pingIsOK = await
|
|
2507
|
-
const checkIfServerIsOnline = await
|
|
2598
|
+
const pingIsOK = await lib_6.UtilsNetwork.checkIfServerPings(this.firstArg);
|
|
2599
|
+
const checkIfServerIsOnline = await lib_6.UtilsNetwork.checkIfServerOnline(this.firstArg);
|
|
2508
2600
|
console.log(`Server ${this.firstArg}
|
|
2509
2601
|
|
|
2510
2602
|
is ping ok ?: ${pingIsOK}
|
|
@@ -2549,17 +2641,17 @@ ${lastCommitMessage}
|
|
|
2549
2641
|
//#region commands / is elevated
|
|
2550
2642
|
async isElevated() {
|
|
2551
2643
|
//#region @backendFunc
|
|
2552
|
-
console.log(`Is running with elevated privileges (sudo/admin): ${await (0,
|
|
2644
|
+
console.log(`Is running with elevated privileges (sudo/admin): ${await (0, lib_3.isElevated)()}`);
|
|
2553
2645
|
this._exit();
|
|
2554
2646
|
//#endregion
|
|
2555
2647
|
}
|
|
2556
2648
|
//#endregion
|
|
2557
2649
|
//#region commands / sudo check
|
|
2558
2650
|
async sudoCheck() {
|
|
2559
|
-
const sudoStatus = await
|
|
2651
|
+
const sudoStatus = await lib_8.UtilsSudo.getStatus();
|
|
2560
2652
|
console.log('is command available', sudoStatus.isAvailable);
|
|
2561
2653
|
console.log('is inline sudo enable', sudoStatus.isInline);
|
|
2562
|
-
console.log('is this command elevated (sudo or admin)', await (0,
|
|
2654
|
+
console.log('is this command elevated (sudo or admin)', await (0, lib_3.isElevated)());
|
|
2563
2655
|
this._exit();
|
|
2564
2656
|
}
|
|
2565
2657
|
//#endregion
|
|
@@ -2570,10 +2662,10 @@ ${lastCommitMessage}
|
|
|
2570
2662
|
if (!moduleName) {
|
|
2571
2663
|
index_1.Helpers.error(`You need to provide python module name to check`, false, true);
|
|
2572
2664
|
}
|
|
2573
|
-
let exists = await
|
|
2665
|
+
let exists = await lib_3.UtilsOs.pythonModuleExists(moduleName);
|
|
2574
2666
|
if (!exists) {
|
|
2575
2667
|
index_1.Helpers.warn(`Module not found in global python packages, checking pipx packages...`);
|
|
2576
|
-
exists = await
|
|
2668
|
+
exists = await lib_3.UtilsOs.pipxPackageExists(moduleName);
|
|
2577
2669
|
}
|
|
2578
2670
|
console.log(`Python module "${moduleName}" exists: ${exists ? 'YES' : 'NO'}`);
|
|
2579
2671
|
this._exit();
|