wv-gotcha
Version:
 wv-local-service-bus # Purpose To accumulate your walkthroughs to accomplish your common tasks with less effort.
871 lines • 46.1 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WTR_GitCreateDeltaBranch = exports.WTR_GitHardResetToOrigin = exports.WTR_GitAmendToPreviousCommit = exports.WTR_GitOpenRemoteRepoInDefaultBrowser = exports.WTR_GitUntrackFileOrFolder = exports.WTR_CreateCustomSnippet = exports.WTR_UpdateRemoteOrigin = exports.WTR_AmmendAll = exports.WTR_AmmendAllWorktreeChanges = exports.WTR_Ops_PackVsCodeExtension = exports.WTR_Ops_ListGlobalyInstalledPackages = exports.WTR_Ops_FindProcessWhosePort = exports.WTR_Ops_Docker_Image_ExportToTar = exports.WTR_Ops_Docker_Container_ListRunning = exports.WTR_Ops_AnyNodePackageJSProject_Publish = exports.WTR_Ops_AnyNodeJSProject_IncrementPatch = exports.WTR_Notes_NewMinMap = exports.WTR_Fun_GrapWallpapers = exports.WTR_Dev_vscode_empower_WvCodeSnippets = exports.WTR_Dev_vscode_empower_Settings = exports.WTR_Dev_ViewCurrentlyFocusedProjects = exports.WTR_Dev_Generatate_NewNodeJSProject_GlobalTool = exports.WTR_Dev_NewDotNetSolution_GenCleanCodeService = exports.WTR_Dev_Generatate_AnyNodeJSProject_tsConfigJson = exports.WTR_Dev_Generatate_AnyNodeJSProject_GitIgnore = exports.WTR_Dev_DevelopWvGotcha = exports.WTR_Dev_AnyNodeProject_ListDirectDependencies = exports.WTR_Dev_AnyNodeJSProject_CollectPackagesCodeSnippets = exports.WTR_CircuitsTasks = exports.WTR_Dev_Generatate_AnyDotNetProject_GitIgnore = exports.WTR_GenericGen = exports.WTR_Git_ListBranches = exports.WTR_Git_EditGlobalConfiguration = exports.WTR_DenoPublish = void 0;
const Shell_1 = require("../Shell");
const _RegisterWalkthrough_1 = require("./_Foundation/_RegisterWalkthrough");
const UPathMan_1 = require("../UPathMan");
const UTemplatePicker_1 = require("../Libraries/TemplateTranslation/UTemplatePicker");
const temp_circuits_1 = require("temp-circuits");
const UTemplateTranslator_1 = require("../Libraries/TemplateTranslation/UTemplateTranslator");
const decova_filesystem_1 = require("decova-filesystem");
const Mcq_CircuitsTasks_1 = require("../Mcq_CircuitsTasks");
const PackageJson_1 = require("../Libraries/PackageJson/PackageJson");
const wv_filesystem_1 = require("wv-filesystem");
const process_1 = require("process");
const Git_1 = require("../Libraries/Git/Git");
const DynamicMcq_1 = require("../DynamicMcq");
const fs = require('fs');
const os = require('os');
const path = require('path');
// #region Deno-Publish
let WTR_DenoPublish = class WTR_DenoPublish {
constructor() {
this.text = `Deno-Publish`;
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const comment = yield Shell_1.Shell.askForTextAsync(`commit comment:`);
Shell_1.Shell.hintWillExec('Commiting and pushing your changes? press ENTER to continue');
yield Shell_1.Shell.promptContinueAsync();
Shell_1.Shell.exec(`git add .`);
Shell_1.Shell.exec(`git commit -m "${comment}"`);
Shell_1.Shell.exec(`git push`);
Shell_1.Shell.hintWillExec('Openning releases page:');
const dirName = UPathMan_1.UPathMan.$().currentDir.Name;
const releaseUrl = `https://github.com/wV-software/${dirName}/releases/`;
// const releaseUrl = `https://github.com/wV-software/wv_core/releases/`;
Shell_1.Shell.exec(`start ${releaseUrl}`);
yield Shell_1.Shell.instructAsync(`Find "Draft a new realse" button to start`);
});
}
};
exports.WTR_DenoPublish = WTR_DenoPublish;
exports.WTR_DenoPublish = WTR_DenoPublish = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_DenoPublish);
// #endregion
// #region Git >> Edit global configuration
let WTR_Git_EditGlobalConfiguration = class WTR_Git_EditGlobalConfiguration {
constructor() {
this.text = 'Git >> Edit global configuration';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
Shell_1.Shell.exec(`git config --global core.editor "code --wait"`);
Shell_1.Shell.exec(`git config --global -e`);
});
}
};
exports.WTR_Git_EditGlobalConfiguration = WTR_Git_EditGlobalConfiguration;
exports.WTR_Git_EditGlobalConfiguration = WTR_Git_EditGlobalConfiguration = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Git_EditGlobalConfiguration);
// #endregion
// #region Git >> List branches
let WTR_Git_ListBranches = class WTR_Git_ListBranches {
constructor() {
this.text = 'Git >> List branches';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
Shell_1.Shell.exec(`git branch`);
});
}
};
exports.WTR_Git_ListBranches = WTR_Git_ListBranches;
exports.WTR_Git_ListBranches = WTR_Git_ListBranches = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Git_ListBranches);
// #endregion
// #region Dev >> Generate ...
let WTR_GenericGen = class WTR_GenericGen {
constructor() {
this.text = 'Dev >> Generate ...';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
// #region prompt user for his target template mapping
const templatePicker = UTemplatePicker_1.UTemplatePicker.$();
const translationMapping = yield templatePicker.promptTranslationMappingPicking();
// #endregion
const templateDirName = translationMapping.templateDirName;
let count = 0;
function translateFileAsync(srcFileRelPath) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
for (const pattern of (_a = translationMapping.fileRelPathPatternsToIgnore) !== null && _a !== void 0 ? _a : []) {
try {
if (temp_circuits_1.Regex.parse(pattern).hasMatches(srcFileRelPath)) {
Shell_1.Shell.warning(`File '${srcFileRelPath}' skipped by 'fileRelPathPatternsToIgnore = '${pattern}'`);
return false;
}
}
catch (exp) {
Shell_1.Shell.error(`fileRelPathPatternsToIgnore = '${pattern}' is not a valid Regex pattern.`);
return false;
}
}
const isTranslated = yield UTemplateTranslator_1.UTemplateTranslator.$().translateGenericTemplateFileAsync(templateDirName, srcFileRelPath, []);
return isTranslated;
});
}
for (let translationItem of translationMapping.translationItems) {
switch (translationItem.itemType) {
case "file":
const srcFileRelPath = translationItem.relativePath;
const isTranslated = yield translateFileAsync(srcFileRelPath);
if (isTranslated)
count++;
break;
case "folder":
const folder = new decova_filesystem_1.DirectoryInfo(decova_filesystem_1.Path.join(UPathMan_1.UPathMan.$().contentDir.FullName));
if (folder.Exists() === false) {
Shell_1.Shell.error(`Folder '${folder.FullName}' doesn't exist!`);
continue;
}
break;
}
}
if (count < 1) {
Shell_1.Shell.error('No files translated!');
}
else {
if (count > 1) {
Shell_1.Shell.success(`{${count}} Files have been created.`);
}
else {
Shell_1.Shell.success(`1 File has been created.`);
}
}
// const pathMan = UPathMan.$();
// if(new FileInfo(pathMan.dstnGitIgnoreFilePath).exists())
// {
// Dialog.warning(`${CommonFileName.gitIgnore} already exists`);
// return;
// }
});
}
};
exports.WTR_GenericGen = WTR_GenericGen;
exports.WTR_GenericGen = WTR_GenericGen = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_GenericGen);
// #endregion
// #region Dev >> Any .net Project >> Generate >> /.gitignore
let WTR_Dev_Generatate_AnyDotNetProject_GitIgnore = class WTR_Dev_Generatate_AnyDotNetProject_GitIgnore {
constructor() {
this.text = 'Dev >> Any .net Project >> Generate >> /.gitignore';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
if (new decova_filesystem_1.FileInfo(pathMan.dstnGitIgnoreFilePath).exists()) {
Shell_1.Shell.warning(`${UPathMan_1.CommonFileName.gitIgnore} already exists`);
return;
}
function fileSelector(path) {
return new decova_filesystem_1.FileInfo(path).name.toLowerCase() === UPathMan_1.CommonFileName.gitIgnore.toLowerCase();
}
const count = UTemplateTranslator_1.UTemplateTranslator.$().translate(UPathMan_1.CommonDirName.Template_RootDir_AnyDotNetProject, fileSelector);
if (count < 1) {
Shell_1.Shell.error('No files translated!');
}
else {
Shell_1.Shell.success(`{${count}} File ${UPathMan_1.CommonFileName.gitIgnore} has been created.`);
}
});
}
};
exports.WTR_Dev_Generatate_AnyDotNetProject_GitIgnore = WTR_Dev_Generatate_AnyDotNetProject_GitIgnore;
exports.WTR_Dev_Generatate_AnyDotNetProject_GitIgnore = WTR_Dev_Generatate_AnyDotNetProject_GitIgnore = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_Generatate_AnyDotNetProject_GitIgnore);
// #endregion
// #region Circuits
let WTR_CircuitsTasks = class WTR_CircuitsTasks {
constructor() {
this.text = `Circuits`;
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
while (true) {
const task = yield new Mcq_CircuitsTasks_1.Mcq_CircuitsTasks().selectAsync('Pick a task');
yield task.execAsync();
}
});
}
};
exports.WTR_CircuitsTasks = WTR_CircuitsTasks;
exports.WTR_CircuitsTasks = WTR_CircuitsTasks = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_CircuitsTasks);
// #endregion
// #region Dev >> Any NodeJS Project >> Collect node_modules Code Snippets
let WTR_Dev_AnyNodeJSProject_CollectPackagesCodeSnippets = class WTR_Dev_AnyNodeJSProject_CollectPackagesCodeSnippets {
constructor() {
this.text = 'Dev >> Any NodeJS Project >> Collect node_modules Code Snippets';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
const nodeModulesDir = pathMan.currentDir.GetDirectories().xFirstOrNull(d => d.Name === 'node_modules');
if (!nodeModulesDir) {
Shell_1.Shell.error(`node_modules file not found @${pathMan.currentDir}`);
return;
}
let count = 0;
for (let dir of nodeModulesDir.GetDirectories()) {
const snippetsFile = new decova_filesystem_1.FileInfo(decova_filesystem_1.Path.join(dir.FullName, 'package.code-snippets'));
if (snippetsFile.exists()) {
const dstPath = decova_filesystem_1.Path.join(pathMan.dstVscodeDir.FullName, `${dir.Name}.code-snippets`);
Shell_1.Shell.info(`Creating ${dstPath}`);
snippetsFile.copyTo(dstPath);
count++;
}
}
if (count < 1) {
Shell_1.Shell.error('No files translated!');
}
else {
Shell_1.Shell.success(`{${count}} .code-snippets file(s) have been created.`);
}
});
}
};
exports.WTR_Dev_AnyNodeJSProject_CollectPackagesCodeSnippets = WTR_Dev_AnyNodeJSProject_CollectPackagesCodeSnippets;
exports.WTR_Dev_AnyNodeJSProject_CollectPackagesCodeSnippets = WTR_Dev_AnyNodeJSProject_CollectPackagesCodeSnippets = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_AnyNodeJSProject_CollectPackagesCodeSnippets);
// #endregion
// #region Dev >> Any NodeJS Project >> List direct dependencies
let WTR_Dev_AnyNodeProject_ListDirectDependencies = class WTR_Dev_AnyNodeProject_ListDirectDependencies {
constructor() {
this.text = 'Dev >> Any NodeJS Project >> List direct dependencies';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
yield Shell_1.Shell.exec('npm list --depth=0');
});
}
};
exports.WTR_Dev_AnyNodeProject_ListDirectDependencies = WTR_Dev_AnyNodeProject_ListDirectDependencies;
exports.WTR_Dev_AnyNodeProject_ListDirectDependencies = WTR_Dev_AnyNodeProject_ListDirectDependencies = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_AnyNodeProject_ListDirectDependencies);
// #endregion
// #region Dev >> Develop wV Gotcha
let WTR_Dev_DevelopWvGotcha = class WTR_Dev_DevelopWvGotcha {
constructor() {
this.text = `Dev >> Develop wV Gotcha`;
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const path = `G:/_MyProjects/_MyNodeProjects/wv-gotcha`;
Shell_1.Shell.info(`Pleae wait for vscode to open`);
Shell_1.Shell.exec(`code \"${path}\"`);
});
}
};
exports.WTR_Dev_DevelopWvGotcha = WTR_Dev_DevelopWvGotcha;
exports.WTR_Dev_DevelopWvGotcha = WTR_Dev_DevelopWvGotcha = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_DevelopWvGotcha);
// #endregion
// #region Dev >> Any NodeJS Project >> Generate >> /.gitignore
let WTR_Dev_Generatate_AnyNodeJSProject_GitIgnore = class WTR_Dev_Generatate_AnyNodeJSProject_GitIgnore {
constructor() {
this.text = 'Dev >> Any NodeJS Project >> Generate >> /.gitignore';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
if (new decova_filesystem_1.FileInfo(pathMan.dstnGitIgnoreFilePath).exists()) {
Shell_1.Shell.warning(`${UPathMan_1.CommonFileName.gitIgnore} already exists`);
return;
}
function fileSelector(path) {
return new decova_filesystem_1.FileInfo(path).name.toLowerCase() === UPathMan_1.CommonFileName.gitIgnore.toLowerCase();
}
const count = UTemplateTranslator_1.UTemplateTranslator.$().translate(UPathMan_1.CommonDirName.Template_RootDir_AnyNodeProject, fileSelector);
if (count < 1) {
Shell_1.Shell.error('No files translated!');
}
else {
Shell_1.Shell.success(`{${count}} File ${UPathMan_1.CommonFileName.gitIgnore} has been created.`);
}
});
}
};
exports.WTR_Dev_Generatate_AnyNodeJSProject_GitIgnore = WTR_Dev_Generatate_AnyNodeJSProject_GitIgnore;
exports.WTR_Dev_Generatate_AnyNodeJSProject_GitIgnore = WTR_Dev_Generatate_AnyNodeJSProject_GitIgnore = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_Generatate_AnyNodeJSProject_GitIgnore);
// #endregion
// #region Dev >> Any NodeJS Project >> Generate >> /tsconfig.json
let WTR_Dev_Generatate_AnyNodeJSProject_tsConfigJson = class WTR_Dev_Generatate_AnyNodeJSProject_tsConfigJson {
constructor() {
this.text = 'Dev >> Any NodeJS Project >> Generate >> /tsconfig.json';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
if (new decova_filesystem_1.FileInfo(pathMan.dstnTsConfigFilePath).exists()) {
Shell_1.Shell.warning(`${UPathMan_1.CommonFileName.tsConfigJson} already exists`);
return;
}
function fileSelector(path) {
return new decova_filesystem_1.FileInfo(path).name.toLowerCase() === UPathMan_1.CommonFileName.tsConfigJson.toLowerCase();
}
const count = UTemplateTranslator_1.UTemplateTranslator.$().translate(UPathMan_1.CommonDirName.Template_RootDir_AnyNodeProject, fileSelector);
if (count < 1) {
Shell_1.Shell.error('No files translated!');
}
else {
Shell_1.Shell.success(`{${count}} File ${UPathMan_1.CommonFileName.tsConfigJson} has been created.`);
}
});
}
};
exports.WTR_Dev_Generatate_AnyNodeJSProject_tsConfigJson = WTR_Dev_Generatate_AnyNodeJSProject_tsConfigJson;
exports.WTR_Dev_Generatate_AnyNodeJSProject_tsConfigJson = WTR_Dev_Generatate_AnyNodeJSProject_tsConfigJson = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_Generatate_AnyNodeJSProject_tsConfigJson);
// #endregion
// #region Dev >> New .net Solution >> Generate >> New Clean Architecture Service
let WTR_Dev_NewDotNetSolution_GenCleanCodeService = class WTR_Dev_NewDotNetSolution_GenCleanCodeService {
constructor() {
this.text = 'Dev >> New .net Solution >> Generate >> New Clean Architecture Service';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
if (pathMan.currentDir.GetDirectories().xAny() || pathMan.currentDir.GetFiles().xAny()) {
Shell_1.Shell.error(`Current directory is not empty!`);
return;
}
const __TestFile_ = yield Shell_1.Shell.askForTextAsync('__TestFile_?');
const srcDir = decova_filesystem_1.Path.join(UPathMan_1.CommonDirName.Template_RootDir_NewCleanArchitectureSolution);
const count = UTemplateTranslator_1.UTemplateTranslator.$().translate(srcDir, () => true, new Map([['__TestFile_', __TestFile_]]));
// Dialog.exec('npm install');
Shell_1.Shell.success(`{${count}} files has been created.`);
});
}
};
exports.WTR_Dev_NewDotNetSolution_GenCleanCodeService = WTR_Dev_NewDotNetSolution_GenCleanCodeService;
exports.WTR_Dev_NewDotNetSolution_GenCleanCodeService = WTR_Dev_NewDotNetSolution_GenCleanCodeService = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_NewDotNetSolution_GenCleanCodeService);
// #endregion
// #region Dev >> New NodeJS Project >> Generate >> New Global Tool
let WTR_Dev_Generatate_NewNodeJSProject_GlobalTool = class WTR_Dev_Generatate_NewNodeJSProject_GlobalTool {
constructor() {
this.text = 'Dev >> New NodeJS Project >> Generate >> New Global Tool';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
if (pathMan.currentDir.GetDirectories().xAny() || pathMan.currentDir.GetFiles().xAny()) {
Shell_1.Shell.error(`Current directory is not empty!`);
return;
}
const ___PACKAGE_NAME = yield Shell_1.Shell.askForTextAsync('Package name?');
const srcDir = decova_filesystem_1.Path.join(UPathMan_1.CommonDirName.Template_RootDir_NewNodeProject, 'GlobalTool');
const count = UTemplateTranslator_1.UTemplateTranslator.$().translate(srcDir, () => true, new Map([['___PACKAGE_NAME', ___PACKAGE_NAME]]));
Shell_1.Shell.exec('npm install');
Shell_1.Shell.success(`{${count}} files has been created.`);
});
}
};
exports.WTR_Dev_Generatate_NewNodeJSProject_GlobalTool = WTR_Dev_Generatate_NewNodeJSProject_GlobalTool;
exports.WTR_Dev_Generatate_NewNodeJSProject_GlobalTool = WTR_Dev_Generatate_NewNodeJSProject_GlobalTool = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_Generatate_NewNodeJSProject_GlobalTool);
// #endregion
// #region Dev >> View currently focused projects
let WTR_Dev_ViewCurrentlyFocusedProjects = class WTR_Dev_ViewCurrentlyFocusedProjects {
constructor() {
this.text = `Dev >> View currently focused projects`;
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const path = `G:\\_MyProjects\\__CurrentProjects`;
Shell_1.Shell.info(`Pleae wait for {${path}} to open`);
Shell_1.Shell.exec(`explorer \"${path}\"`);
});
}
};
exports.WTR_Dev_ViewCurrentlyFocusedProjects = WTR_Dev_ViewCurrentlyFocusedProjects;
exports.WTR_Dev_ViewCurrentlyFocusedProjects = WTR_Dev_ViewCurrentlyFocusedProjects = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_ViewCurrentlyFocusedProjects);
// #endregion
// #region Dev >> vscode >> empower >> /.vscode/settings.json
let WTR_Dev_vscode_empower_Settings = class WTR_Dev_vscode_empower_Settings {
constructor() {
this.text = 'Dev >> vscode >> empower >> /.vscode/settings.json';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
// if(new FileInfo(pathMan.dstnWvSnippetsFilePath).exists())
// {
// Dialog.warning(`${CommonFileName.wvSnippets} already exists`);
// return;
// }
function fileSelector(path) {
return new decova_filesystem_1.FileInfo(path).name.toLowerCase() === UPathMan_1.CommonFileName.settings.toLowerCase();
}
const count = UTemplateTranslator_1.UTemplateTranslator.$().translate(UPathMan_1.CommonDirName.Template_RootDir_AnyNodeProject, fileSelector, new Map(), true);
Shell_1.Shell.success(`{${count}} File ${UPathMan_1.CommonFileName.wvSnippets} has been created.`);
});
}
};
exports.WTR_Dev_vscode_empower_Settings = WTR_Dev_vscode_empower_Settings;
exports.WTR_Dev_vscode_empower_Settings = WTR_Dev_vscode_empower_Settings = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_vscode_empower_Settings);
// #endregion
// #region Dev >> vscode >> empower >> /.vscode/wv.code-snippets
let WTR_Dev_vscode_empower_WvCodeSnippets = class WTR_Dev_vscode_empower_WvCodeSnippets {
constructor() {
this.text = 'Dev >> vscode >> empower >> /.vscode/wv.code-snippets';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
if (new decova_filesystem_1.FileInfo(pathMan.dstnWvSnippetsFilePath).exists()) {
Shell_1.Shell.warning(`${UPathMan_1.CommonFileName.wvSnippets} already exists`);
return;
}
function fileSelector(path) {
return new decova_filesystem_1.FileInfo(path).name.toLowerCase() === UPathMan_1.CommonFileName.wvSnippets.toLowerCase();
}
const count = UTemplateTranslator_1.UTemplateTranslator.$().translate(UPathMan_1.CommonDirName.Template_RootDir_AnyNodeProject, fileSelector);
Shell_1.Shell.success(`{${count}} File ${UPathMan_1.CommonFileName.wvSnippets} has been created.`);
});
}
};
exports.WTR_Dev_vscode_empower_WvCodeSnippets = WTR_Dev_vscode_empower_WvCodeSnippets;
exports.WTR_Dev_vscode_empower_WvCodeSnippets = WTR_Dev_vscode_empower_WvCodeSnippets = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Dev_vscode_empower_WvCodeSnippets);
// #endregion
// #region Fun >> Grap wallpapers
let WTR_Fun_GrapWallpapers = class WTR_Fun_GrapWallpapers {
constructor() {
this.text = 'Fun >> Grap wallpapers';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const tempDirPath = path.join(wv_filesystem_1.DirectoryInfo.special.tempDir.fullName, 'wv-gotcha/grapped-wallpapers');
const userHomeDir = wv_filesystem_1.DirectoryInfo.special.userProfile;
const tempDir = new wv_filesystem_1.DirectoryInfo(tempDirPath);
tempDir.ensure();
Shell_1.Shell.exec(`explorer \"${tempDir.fullName.xReplaceAll('/', '\\')}\"`);
const spotListDirPath = decova_filesystem_1.Path.join(userHomeDir.fullName, `AppData/Local/Packages/Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy/LocalState/Assets`);
const bingImagePath = decova_filesystem_1.Path.join(userHomeDir.fullName, `/AppData/Roaming/Microsoft/Windows/Themes/TranscodedWallpaper`);
const spotLightFiles = new wv_filesystem_1.DirectoryInfo(spotListDirPath).getFiles().xWhere(f => f.fileSize > 100000);
for (let f of spotLightFiles) {
f.copyTo(`${tempDir.fullName}/${f.name}.jpeg`);
}
const bingImageFile = new decova_filesystem_1.FileInfo(bingImagePath);
if (bingImageFile.exists() === false) {
Shell_1.Shell.warning(`Bing image file doesn\'t exist @${bingImagePath}`);
}
else {
bingImageFile.copyTo(`${tempDir.fullName}/${bingImageFile.name}.jpg`);
}
yield Shell_1.Shell.instructAsync('Please wait the grapped in folder to open in the explorer');
});
}
};
exports.WTR_Fun_GrapWallpapers = WTR_Fun_GrapWallpapers;
exports.WTR_Fun_GrapWallpapers = WTR_Fun_GrapWallpapers = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Fun_GrapWallpapers);
// #endregion
// #region Notes >> New mindmap (.xmmap)
let WTR_Notes_NewMinMap = class WTR_Notes_NewMinMap {
constructor() {
this.text = `Notes >> New mindmap (.xmmap)`;
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
let docName;
while (true) {
docName = yield Shell_1.Shell.askForTextAsync('Document Name?');
const isValid = /^[0-9A-z \-\._\(\)]+$/.test(docName);
if (!isValid) {
Shell_1.Shell.error("File name is expected to contains alphabets, numerics and {-,.,_,(,)} only");
continue;
}
break;
}
var newFile = pathMan.getMindMapFile(docName);
if (newFile.exists() === false) {
const templateFile = new decova_filesystem_1.FileInfo(pathMan.xmmapTemplateFile.fullName);
const content = templateFile.readAllText().xReplaceAll(UPathMan_1.TEMPLATE_PLACEHOLDER, docName);
pathMan.getMindMapFile(docName).writeAllText(content);
}
Shell_1.Shell.info(`Pleae wait for ${docName}.xmmap to open`);
Shell_1.Shell.exec(`\"${newFile.fullName}\"`);
});
}
};
exports.WTR_Notes_NewMinMap = WTR_Notes_NewMinMap;
exports.WTR_Notes_NewMinMap = WTR_Notes_NewMinMap = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Notes_NewMinMap);
// #endregion
// #region Ops >> Any NodeJS Project >> package.json >> patch ++ (increment)
let WTR_Ops_AnyNodeJSProject_IncrementPatch = class WTR_Ops_AnyNodeJSProject_IncrementPatch {
constructor() {
this.text = 'Ops >> Any NodeJS Project >> package.json >> patch ++ (increment)';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
const currentDir = pathMan.currentDir.FullName;
const pkgFile = new decova_filesystem_1.FileInfo(decova_filesystem_1.Path.join(currentDir, 'package.json'));
if (pkgFile.exists() == false) {
Shell_1.Shell.error(`No package.json found @${currentDir}`);
return;
}
Shell_1.Shell.info(`File updated: ${pkgFile.fullName}`);
const pkg = new PackageJson_1.PackageJson(pkgFile.fullName);
pkg.incrementVersionPatch(true);
Shell_1.Shell.success(`Package version updated to ${pkg.version}`);
});
}
};
exports.WTR_Ops_AnyNodeJSProject_IncrementPatch = WTR_Ops_AnyNodeJSProject_IncrementPatch;
exports.WTR_Ops_AnyNodeJSProject_IncrementPatch = WTR_Ops_AnyNodeJSProject_IncrementPatch = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Ops_AnyNodeJSProject_IncrementPatch);
// #endregion
// #region Ops >> Any Package NodeJS Project >> Publish (push)
let WTR_Ops_AnyNodePackageJSProject_Publish = class WTR_Ops_AnyNodePackageJSProject_Publish {
constructor() {
this.text = 'Ops >> Any Package NodeJS Project >> Publish (push)';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
yield Shell_1.Shell.exec('tsc');
yield new WTR_Ops_AnyNodeJSProject_IncrementPatch().execAsync();
yield Shell_1.Shell.exec('npm publish');
});
}
};
exports.WTR_Ops_AnyNodePackageJSProject_Publish = WTR_Ops_AnyNodePackageJSProject_Publish;
exports.WTR_Ops_AnyNodePackageJSProject_Publish = WTR_Ops_AnyNodePackageJSProject_Publish = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Ops_AnyNodePackageJSProject_Publish);
// #endregion
// #region Ops >> Docker >> Container >> List running containers
let WTR_Ops_Docker_Container_ListRunning = class WTR_Ops_Docker_Container_ListRunning {
constructor() {
this.text = 'Ops >> Docker >> Container >> List running containers';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
yield Shell_1.Shell.exec('docker ps');
});
}
};
exports.WTR_Ops_Docker_Container_ListRunning = WTR_Ops_Docker_Container_ListRunning;
exports.WTR_Ops_Docker_Container_ListRunning = WTR_Ops_Docker_Container_ListRunning = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Ops_Docker_Container_ListRunning);
// #endregion
// #region Ops >> Docker >> Image >> Export image to tar file
let WTR_Ops_Docker_Image_ExportToTar = class WTR_Ops_Docker_Image_ExportToTar {
constructor() {
this.text = 'Ops >> Docker >> Image >> Export image to tar file';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
yield Shell_1.Shell.exec('docker image ls');
const imageId = yield Shell_1.Shell.instructAsync('Pick an image Id from the above list');
const outputFilePath = yield Shell_1.Shell.instructAsync('Output .tar file path?');
yield Shell_1.Shell.exec(`docker image save ${imageId} ${outputFilePath}`);
});
}
};
exports.WTR_Ops_Docker_Image_ExportToTar = WTR_Ops_Docker_Image_ExportToTar;
exports.WTR_Ops_Docker_Image_ExportToTar = WTR_Ops_Docker_Image_ExportToTar = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Ops_Docker_Image_ExportToTar);
// #endregion
// #region Ops >> Find process whose port ...
let WTR_Ops_FindProcessWhosePort = class WTR_Ops_FindProcessWhosePort {
constructor() {
this.text = 'Ops >> Find process whose port ...';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const port = yield Shell_1.Shell.askForTextAsync('Port?');
Shell_1.Shell.exec(`netstat -ano | findstr :${port}`);
Shell_1.Shell.instructAsync(`Pick a PID from the above list`);
const pid = yield Shell_1.Shell.askForTextAsync('PID?');
Shell_1.Shell.exec(`tasklist /svc /FI \"PID eq ${pid}\"`);
});
}
};
exports.WTR_Ops_FindProcessWhosePort = WTR_Ops_FindProcessWhosePort;
exports.WTR_Ops_FindProcessWhosePort = WTR_Ops_FindProcessWhosePort = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Ops_FindProcessWhosePort);
// #endregion
// #region Ops >> NodeJS >> List globally installed packages
let WTR_Ops_ListGlobalyInstalledPackages = class WTR_Ops_ListGlobalyInstalledPackages {
constructor() {
this.text = `Ops >> NodeJS >> List globally installed packages`;
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
yield Shell_1.Shell.exec('npm list --global --depth=0');
});
}
};
exports.WTR_Ops_ListGlobalyInstalledPackages = WTR_Ops_ListGlobalyInstalledPackages;
exports.WTR_Ops_ListGlobalyInstalledPackages = WTR_Ops_ListGlobalyInstalledPackages = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Ops_ListGlobalyInstalledPackages);
// #endregion
// #region Ops >> Pack your vscode Extension
let WTR_Ops_PackVsCodeExtension = class WTR_Ops_PackVsCodeExtension {
constructor() {
this.text = 'Ops >> Pack your vscode Extension';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const pathMan = UPathMan_1.UPathMan.$();
yield Shell_1.Shell.exec('tsc');
yield new WTR_Ops_AnyNodeJSProject_IncrementPatch().execAsync();
yield Shell_1.Shell.exec('vsce package');
});
}
};
exports.WTR_Ops_PackVsCodeExtension = WTR_Ops_PackVsCodeExtension;
exports.WTR_Ops_PackVsCodeExtension = WTR_Ops_PackVsCodeExtension = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_Ops_PackVsCodeExtension);
// #endregion
// #region Git >> Ammend all work tree changes
let WTR_AmmendAllWorktreeChanges = class WTR_AmmendAllWorktreeChanges {
constructor() {
this.text = 'Git >> Ammend all work tree changes';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
Shell_1.Shell.exec("git add .");
Shell_1.Shell.exec("git commit --amend");
});
}
};
exports.WTR_AmmendAllWorktreeChanges = WTR_AmmendAllWorktreeChanges;
exports.WTR_AmmendAllWorktreeChanges = WTR_AmmendAllWorktreeChanges = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_AmmendAllWorktreeChanges);
// #endregion
// #region Git >> List remote repos
let WTR_AmmendAll = class WTR_AmmendAll {
constructor() {
this.text = 'Git >> List remote repos';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
Shell_1.Shell.exec("git remote -v");
});
}
};
exports.WTR_AmmendAll = WTR_AmmendAll;
exports.WTR_AmmendAll = WTR_AmmendAll = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_AmmendAll);
// #endregion
// #region Git >> Update remote origin
let WTR_UpdateRemoteOrigin = class WTR_UpdateRemoteOrigin {
constructor() {
this.text = 'Git >> Change remote origin';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const url = yield Shell_1.Shell.askForTextAsync("The new origin URL?");
Shell_1.Shell.exec(`git remote set-url origin ${url}`);
});
}
};
exports.WTR_UpdateRemoteOrigin = WTR_UpdateRemoteOrigin;
exports.WTR_UpdateRemoteOrigin = WTR_UpdateRemoteOrigin = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_UpdateRemoteOrigin);
// #endregion
// #region vscode >> Create custom snippet from existing code
let WTR_CreateCustomSnippet = class WTR_CreateCustomSnippet {
constructor() {
this.text = 'vscode >> Create custom snippet from existing code';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
yield Shell_1.Shell.warning("Recall: Your naming convetion of the prefix is * followed by a descriptive name");
yield Shell_1.Shell.warning("Give a Title but don't worry about the Description");
yield Shell_1.Shell.instructAsync("Select the code you want to create a snippet from.");
yield Shell_1.Shell.instructAsync("Ctrl + Shift + P -> Convert to a snippet");
yield Shell_1.Shell.instructAsync("Follow the steps");
yield Shell_1.Shell.instructAsync("Copy the snippet from the output window.");
yield Shell_1.Shell.instructAsync("Ctrl + Shift + P -> Configure user snippets");
yield Shell_1.Shell.instructAsync("Select GSnippets.codesnippets");
yield Shell_1.Shell.instructAsync("Paste your snippet in GSnippets.codesnippets");
yield Shell_1.Shell.instructAsync(`Find syntax for editing placeholders here: "https://www.notion.so/vscode-code-snippets-syntax-06411fd9411549c4aadbe118e100f682?pvs=4"`);
yield Shell_1.Shell.info("GSnippets.codesnippets will be synced automatically by vscode.");
});
}
};
exports.WTR_CreateCustomSnippet = WTR_CreateCustomSnippet;
exports.WTR_CreateCustomSnippet = WTR_CreateCustomSnippet = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_CreateCustomSnippet);
// #endregion
// #region git >> Untrack file or folder
let WTR_GitUntrackFileOrFolder = class WTR_GitUntrackFileOrFolder {
constructor() {
this.text = 'git >> Untrack file or folder';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
let path = (yield Shell_1.Shell.askForTextAsync("To untrack File or folder RELATIVE path")).trim();
if (new decova_filesystem_1.DirectoryInfo(decova_filesystem_1.Path.join((0, process_1.cwd)(), path)).Exists()) {
if (!path.endsWith("/")) {
Shell_1.Shell.warning(`${path} is a directory. I added a trailing '/' for you. But get accustomed to add a trailing '/' to denote a directory in your future git commands.`);
path = `${path}/`;
}
}
else if (!new decova_filesystem_1.FileInfo(decova_filesystem_1.Path.join((0, process_1.cwd)(), path)).exists()) {
Shell_1.Shell.error(`Path [${decova_filesystem_1.Path.join((0, process_1.cwd)(), path)}] doesn't exist!`);
process.exit(0);
}
yield Shell_1.Shell.confirmThenExecAsync(`git rm --cached -r ${path}`, `This will make a "git change" of untracking the file/folder. To be commited by a next command.`);
yield Shell_1.Shell.confirmThenExecAsync(`git status`, `This will run "git status" to make sure of untracking as a change.`);
yield Shell_1.Shell.instructAsync(`Add this path ${path} as a line to .gitignore.`);
yield Shell_1.Shell.ShowCompletion();
});
}
};
exports.WTR_GitUntrackFileOrFolder = WTR_GitUntrackFileOrFolder;
exports.WTR_GitUntrackFileOrFolder = WTR_GitUntrackFileOrFolder = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_GitUntrackFileOrFolder);
//#endregion
// #region git >> Open remote repo in default browser
let WTR_GitOpenRemoteRepoInDefaultBrowser = class WTR_GitOpenRemoteRepoInDefaultBrowser {
constructor() {
this.text = 'git >> Open remote repo in default browser';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const remoteOrigin = yield Git_1.Git.getRemoteOriginAsync();
Shell_1.Shell.openInBrowser(remoteOrigin);
yield Shell_1.Shell.instructAsync(remoteOrigin);
});
}
};
exports.WTR_GitOpenRemoteRepoInDefaultBrowser = WTR_GitOpenRemoteRepoInDefaultBrowser;
exports.WTR_GitOpenRemoteRepoInDefaultBrowser = WTR_GitOpenRemoteRepoInDefaultBrowser = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_GitOpenRemoteRepoInDefaultBrowser);
// #endregion
// #region git >> amend to previous commit
let WTR_GitAmendToPreviousCommit = class WTR_GitAmendToPreviousCommit {
constructor() {
this.text = 'git >> amend to previous commit';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
yield Shell_1.Shell.confirmThenExecAsync("git commit --amend", "Will amend the already staged changes to the last commit!");
});
}
};
exports.WTR_GitAmendToPreviousCommit = WTR_GitAmendToPreviousCommit;
exports.WTR_GitAmendToPreviousCommit = WTR_GitAmendToPreviousCommit = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_GitAmendToPreviousCommit);
// #endregion
// #region git >> Hard reset a branch to origin
let WTR_GitHardResetToOrigin = class WTR_GitHardResetToOrigin {
constructor() {
this.text = 'git >> Hard reset a branch to origin @ overwrite local remote';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const currentBranch = Git_1.Git.getCurrentBranch();
yield Shell_1.Shell.assert(`Are you aware that you're on branch ${currentBranch} ?`);
yield Shell_1.Shell.assert(`Are you sure you want the current branch to be overwritten by the origin?`);
yield Shell_1.Shell.confirmThenExecAsync("git fetch origin", "Will fetch the origin in local ref");
yield Shell_1.Shell.confirmThenExecAsync(`git reset --hard origin/${currentBranch}`, "Will overwrite the current local branch with the shortly updated local origin ref.");
});
}
};
exports.WTR_GitHardResetToOrigin = WTR_GitHardResetToOrigin;
exports.WTR_GitHardResetToOrigin = WTR_GitHardResetToOrigin = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_GitHardResetToOrigin);
// #endregion
// #region git >> Create delta branch in favor of the current one
let WTR_GitCreateDeltaBranch = class WTR_GitCreateDeltaBranch {
constructor() {
this.text = 'git >> Create delta branch in favor of the current one @ Dev, QC, Prod merge';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
const sourceBranch = Git_1.Git.getCurrentBranch().toLocaleLowerCase();
if (sourceBranch.indexOf("/") >= 0) {
Shell_1.Shell.terminate(`Current branch ${sourceBranch} seems to be a feature branch. Please select a main branch to be the source!`);
}
const allBranches = Git_1.Git.getBranchNames();
const destBranchs = allBranches.xExcept([sourceBranch]).xExcept(allBranches.xWhere(b => b.Contains("/")));
let destBranch = yield new DynamicMcq_1.DynamicMcq(destBranchs).selectAsync("Select destination brance");
const deltaBranchName = `delta/${sourceBranch}_${destBranch}_${Shell_1.Shell.getTimeStamp()}`;
yield Shell_1.Shell.warning(`The following branches will be overwritten by the origin:`);
yield Shell_1.Shell.printDangerList("To be overwritten:", [sourceBranch, destBranch]);
yield Shell_1.Shell.assert("ARE YOU SURE?");
yield Shell_1.Shell.confirmThenExecAsync("git fetch origin", `Will fetch the origin of the current branch ${sourceBranch}`);
yield Shell_1.Shell.confirmThenExecAsync(`git reset --hard origin/${sourceBranch}`, `Will reset the local branch ${sourceBranch} to match the origin!`);
yield Shell_1.Shell.confirmThenExecAsync(`git checkout -b ${deltaBranchName}`, `Will create a delta branch ${deltaBranchName} based on the current branch [The source branch]`);
yield Shell_1.Shell.confirmThenExecAsync(`git checkout ${destBranch}`, `Will check out the destination branch ${destBranch} for updating it.`);
yield Shell_1.Shell.confirmThenExecAsync(`git fetch origin`, `Will fetch the origin of the current branch ${destBranch}`);
yield Shell_1.Shell.confirmThenExecAsync(`git reset --hard origin/${destBranch}`, `This will reset the local branch ${destBranch} to match the origin!`);
yield Shell_1.Shell.confirmThenExecAsync(`git checkout ${deltaBranchName}`, `Will check out the delta branch`);
yield Shell_1.Shell.confirmThenExecAsync(`git merge -s ours ${destBranch}`, `Will merge the destination branch ${destBranch} into the delta branch favoring the delta branch.`);
// git push --set-upstream origin delta_master
yield Shell_1.Shell.confirmThenExecAsync(`git push --set-upstream origin ${deltaBranchName}`, `Will push ${deltaBranchName} for making a pull request of it to ${destBranch}`);
yield Shell_1.Shell.instructAsync(`I'm opening the remote repo in the browser for you to create a pull request of ${deltaBranchName} into ${destBranch}`);
yield Shell_1.Shell.openInBrowser(yield Git_1.Git.getRemoteOriginAsync());
Shell_1.Shell.ShowCompletion();
// just making a fake change 2
});
}
};
exports.WTR_GitCreateDeltaBranch = WTR_GitCreateDeltaBranch;
exports.WTR_GitCreateDeltaBranch = WTR_GitCreateDeltaBranch = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_GitCreateDeltaBranch);
// #endregion
//# sourceMappingURL=Walkthroughs.js.map