ui5_easy_use
Version:
A utility package for UI5 projects
1,584 lines (1,295 loc) • 457 kB
JavaScript
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 181:
/***/ ((module) => {
"use strict";
module.exports = require("buffer");
/***/ }),
/***/ 264:
/***/ ((module) => {
"use strict";
module.exports = require("inspector");
/***/ }),
/***/ 356:
/***/ ((module) => {
"use strict";
module.exports = require("node:util");
/***/ }),
/***/ 481:
/***/ ((module) => {
"use strict";
module.exports = require("node:readline");
/***/ }),
/***/ 734:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const conversions = __webpack_require__(8040);
const route = __webpack_require__(8507);
const convert = {};
const models = Object.keys(conversions);
function wrapRaw(fn) {
const wrappedFn = function (...args) {
const arg0 = args[0];
if (arg0 === undefined || arg0 === null) {
return arg0;
}
if (arg0.length > 1) {
args = arg0;
}
return fn(args);
};
// Preserve .conversion property if there is one
if ('conversion' in fn) {
wrappedFn.conversion = fn.conversion;
}
return wrappedFn;
}
function wrapRounded(fn) {
const wrappedFn = function (...args) {
const arg0 = args[0];
if (arg0 === undefined || arg0 === null) {
return arg0;
}
if (arg0.length > 1) {
args = arg0;
}
const result = fn(args);
// We're assuming the result is an array here.
// see notice in conversions.js; don't use box types
// in conversion functions.
if (typeof result === 'object') {
for (let len = result.length, i = 0; i < len; i++) {
result[i] = Math.round(result[i]);
}
}
return result;
};
// Preserve .conversion property if there is one
if ('conversion' in fn) {
wrappedFn.conversion = fn.conversion;
}
return wrappedFn;
}
models.forEach(fromModel => {
convert[fromModel] = {};
Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
const routes = route(fromModel);
const routeModels = Object.keys(routes);
routeModels.forEach(toModel => {
const fn = routes[toModel];
convert[fromModel][toModel] = wrapRounded(fn);
convert[fromModel][toModel].raw = wrapRaw(fn);
});
});
module.exports = convert;
/***/ }),
/***/ 846:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const { XMLi18nTranslator } = __webpack_require__(8199);
const mainPath = 'i18n';
/**
* Handler function to allow users to select files and folders interactively.
* @param {Object} context - The context object containing `fileHandler` and `cliHandler`.
* @returns {Promise<string[]>} - Array of selected file paths.
*/
const handlerGetPaths = async (context) => {
const { fileHandler, cliHandler } = context;
let selectedPaths = [];
/**
* Recursively process directories and collect selected files.
* @param {string} currentPath - The current directory path to process.
*/
const recursiveSelect = async (currentPath) => {
try {
const items = fileHandler.listItemsWithMetadata(currentPath);
const selectedItems = await cliHandler.displayCheckboxList(
items.map(item => ({
name: item.name,
value: item.path,
short: item.name
})),
`Select files or folders inside: ${currentPath || 'root'}`
);
const selectedFolders = selectedItems.filter(item =>
items.find(choice => choice.path === item && choice.isFolder)
);
const selectedFiles = selectedItems.filter(item =>
!selectedFolders.includes(item)
);
selectedPaths.push(...selectedFiles);
for (const folder of selectedFolders) {
if (selectedItems.length === 1 && selectedFolders.length === 1) {
await recursiveSelect(folder);
} else {
const allFilesInFolder = fileHandler.getAllFilesRecursively(folder);
selectedPaths.push(...allFilesInFolder);
}
}
} catch (error) {
console.error("An error occurred during selection:", error.message);
throw error;
}
};
try {
await recursiveSelect(fileHandler.currentPath);
return selectedPaths;
} catch (error) {
console.error("Operation aborted or failed:", error.message);
return [];
}
};
/**
* Main i18n handler object.
*/
const main_i18n = {
message: '\n-----------\nSelect Action:',
parent: 'main',
choices: [
{
name: 'Auto Binding',
value: 'full',
handler: async (context) => {
const helper = new context.Helper();
const selectedPathsXML = await helper.handlerGetPaths(context);
if (!selectedPathsXML.length) {
return;
}
for (const selectedPathXML of selectedPathsXML) {
const pageName = selectedPathXML;
const xmlString = context.fileHandler.readFile(selectedPathXML);
const ex_config = JSON.parse(context.fileHandlerSource.readFile(context.constant.env.i18nConfigPath));
const keysI18N = ex_config.keys;
const translator = new XMLi18nTranslator(xmlString, pageName, keysI18N, context.Logger);
if (!translator.i18nProperties) {
continue;
}
context.fileHandler.writeFile(selectedPathXML, translator.xmlString);
context.fileHandler.addKeysToI18nFile(`${mainPath}/i18n_en_US.properties`, translator.i18nProperties, selectedPathXML);
}
}
}
]
};
const i18nAll = {
main_i18n
};
module.exports = i18nAll;
/***/ }),
/***/ 857:
/***/ ((module) => {
"use strict";
module.exports = require("os");
/***/ }),
/***/ 1146:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const chalk = __webpack_require__(5248);
const { console } = __webpack_require__(264);
const path = __webpack_require__(6928); // Import the 'path' module for cross-platform path handling
const form_menu = __webpack_require__(2361);
const table_menu = __webpack_require__(7975);
const main_components = {
message: '\n-----------\nSelect Action',
parent: 'main', // Allows navigating back to the main menu
choices: [
{ name: '📄 Form Menu:', value: 'form_menu', submenu: 'form_menu' },
{ name: '📊 Table Menu:', value: 'table_menu', submenu: 'table_menu' },]
};
const componentsAll = {
main_components,
...form_menu,
...table_menu
}
module.exports = componentsAll;
/***/ }),
/***/ 1391:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const fs = __webpack_require__(9896);
const path = __webpack_require__(6928);
class JSONFileManager {
constructor(filePath, fileHandler) {
this.fileHandler = fileHandler;
this.filePath = filePath;
}
// Read and parse the JSON file
getContents() {
const content = this.fileHandler.readFile(this.filePath, 'utf-8');
return JSON.parse(content);
}
// Update JSON file with new content
updateFile(newContent) {
const jsonData = JSON.stringify(newContent, null, 2);
this.fileHandler.writeFile(this.filePath, jsonData);
this.fileHandler.logger.log(`File updated: ${this.filePath}`);
}
// Apply a template to the JSON file
applyTemplate(template) {
const currentContent = this.getContents();
const updatedContent = { ...currentContent, ...template };
this.updateFile(updatedContent);
}
// Update specific key-value pair
updateKeyValue(key, value) {
const content = this.getContents();
content[key] = value;
this.updateFile(content);
}
}
module.exports = { JSONFileManager };
/***/ }),
/***/ 1708:
/***/ ((module) => {
"use strict";
module.exports = require("node:process");
/***/ }),
/***/ 1746:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const { JSONFileManager } = __webpack_require__(1391);
class NavListManager extends JSONFileManager {
constructor(fileHandler) {
super('model/navList.json', fileHandler); // Initialize with the navList.json file
}
/**
* Get the navigation entry for a specific page.
* @param {string} pageName - The name of the page.
* @returns {Object[]} - The navigation entry for the page.
*/
getNavigation(pageName) {
const navList = this.getContents(); // Load the current contents of navList.json
return [
{
title: pageName,
icon: "sap-icon://settings", // Default icon, can be customized
key: `Route${pageName}`
}
];
}
/**
* Add or update a navigation entry for a specific page.
* @param {string} pageName - The name of the page.
* @param {string} [icon="sap-icon://settings"] - The icon for the navigation entry.
*/
setNavigation(pageName, icon = "sap-icon://settings") {
const navList = this.getContents(); // Load the current contents of navList.json
// Ensure the structure exists
navList.navigation = navList.navigation || [];
navList.AddtionNavigation = navList.AddtionNavigation || [];
// Check if the navigation entry already exists
const existingEntry = navList.navigation.find(nav => nav.key === `Route${pageName}`);
if (!existingEntry) {
// Add a new navigation entry
navList.navigation.push({
title: pageName,
icon: icon,
key: `Route${pageName}`
});
}
// Save the updated navigation list back to the file
this.updateFile(navList);
}
/**
* Get all navigation entries.
* @returns {Object} - The entire navigation data.
*/
getAllNavigation() {
return this.getContents();
}
/**
* Clear all navigation entries (for testing or reset purposes).
*/
clearNavigation() {
this.updateFile({
navigation: [],
AddtionNavigation: []
});
}
}
module.exports = { NavListManager };
/***/ }),
/***/ 2018:
/***/ ((module) => {
"use strict";
module.exports = require("tty");
/***/ }),
/***/ 2109:
/***/ ((module) => {
class Helper {
/**
* Handler function to allow users to select files and folders interactively.
* @param {Object} context - The context object containing `fileHandler` and `cliHandler`.
* @returns {Promise<string[]>} - Array of selected file paths.
*/
async handlerGetPaths(context) {
const { fileHandler, cliHandler } = context;
let selectedPaths = [];
/**
* Recursively process directories and collect selected files.
* @param {string} currentPath - The current directory path to process.
*/
const recursiveSelect = async (currentPath) => {
try {
const items = fileHandler.listItemsWithMetadata(currentPath);
const selectedItems = await cliHandler.displayCheckboxList(
items.map(item => ({
name: item.name,
value: item.path,
short: item.name
})),
`Select files or folders inside: ${currentPath || 'root'}`
);
const selectedFolders = selectedItems.filter(item =>
items.find(choice => choice.path === item && choice.isFolder)
);
const selectedFiles = selectedItems.filter(item =>
!selectedFolders.includes(item)
);
selectedPaths.push(...selectedFiles);
for (const folder of selectedFolders) {
if (selectedItems.length === 1 && selectedFolders.length === 1) {
await recursiveSelect(folder);
} else {
const allFilesInFolder = fileHandler.getAllFilesRecursively(folder);
selectedPaths.push(...allFilesInFolder);
}
}
} catch (error) {
console.error("An error occurred during selection:", error.message);
throw error;
}
};
try {
await recursiveSelect(fileHandler.currentPath);
return selectedPaths;
} catch (error) {
console.error("Operation aborted or failed:", error.message);
return [];
}
}
}
module.exports = { Helper };
/***/ }),
/***/ 2203:
/***/ ((module) => {
"use strict";
module.exports = require("stream");
/***/ }),
/***/ 2268:
/***/ (function(__unused_webpack_module, exports) {
(function (global, factory) {
true ? factory(exports) :
0;
})(this, (function (exports) { 'use strict';
// AST walker module for ESTree compatible trees
// A simple walk is one where you simply specify callbacks to be
// called on specific nodes. The last two arguments are optional. A
// simple use would be
//
// walk.simple(myTree, {
// Expression: function(node) { ... }
// });
//
// to do something with all expressions. All ESTree node types
// can be used to identify node types, as well as Expression and
// Statement, which denote categories of nodes.
//
// The base argument can be used to pass a custom (recursive)
// walker, and state can be used to give this walked an initial
// state.
function simple(node, visitors, baseVisitor, state, override) {
if (!baseVisitor) { baseVisitor = base
; }(function c(node, st, override) {
var type = override || node.type;
baseVisitor[type](node, st, c);
if (visitors[type]) { visitors[type](node, st); }
})(node, state, override);
}
// An ancestor walk keeps an array of ancestor nodes (including the
// current node) and passes them to the callback as third parameter
// (and also as state parameter when no other state is present).
function ancestor(node, visitors, baseVisitor, state, override) {
var ancestors = [];
if (!baseVisitor) { baseVisitor = base
; }(function c(node, st, override) {
var type = override || node.type;
var isNew = node !== ancestors[ancestors.length - 1];
if (isNew) { ancestors.push(node); }
baseVisitor[type](node, st, c);
if (visitors[type]) { visitors[type](node, st || ancestors, ancestors); }
if (isNew) { ancestors.pop(); }
})(node, state, override);
}
// A recursive walk is one where your functions override the default
// walkers. They can modify and replace the state parameter that's
// threaded through the walk, and can opt how and whether to walk
// their child nodes (by calling their third argument on these
// nodes).
function recursive(node, state, funcs, baseVisitor, override) {
var visitor = funcs ? make(funcs, baseVisitor || undefined) : baseVisitor
;(function c(node, st, override) {
visitor[override || node.type](node, st, c);
})(node, state, override);
}
function makeTest(test) {
if (typeof test === "string")
{ return function (type) { return type === test; } }
else if (!test)
{ return function () { return true; } }
else
{ return test }
}
var Found = function Found(node, state) { this.node = node; this.state = state; };
// A full walk triggers the callback on each node
function full(node, callback, baseVisitor, state, override) {
if (!baseVisitor) { baseVisitor = base; }
var last
;(function c(node, st, override) {
var type = override || node.type;
baseVisitor[type](node, st, c);
if (last !== node) {
callback(node, st, type);
last = node;
}
})(node, state, override);
}
// An fullAncestor walk is like an ancestor walk, but triggers
// the callback on each node
function fullAncestor(node, callback, baseVisitor, state) {
if (!baseVisitor) { baseVisitor = base; }
var ancestors = [], last
;(function c(node, st, override) {
var type = override || node.type;
var isNew = node !== ancestors[ancestors.length - 1];
if (isNew) { ancestors.push(node); }
baseVisitor[type](node, st, c);
if (last !== node) {
callback(node, st || ancestors, ancestors, type);
last = node;
}
if (isNew) { ancestors.pop(); }
})(node, state);
}
// Find a node with a given start, end, and type (all are optional,
// null can be used as wildcard). Returns a {node, state} object, or
// undefined when it doesn't find a matching node.
function findNodeAt(node, start, end, test, baseVisitor, state) {
if (!baseVisitor) { baseVisitor = base; }
test = makeTest(test);
try {
(function c(node, st, override) {
var type = override || node.type;
if ((start == null || node.start <= start) &&
(end == null || node.end >= end))
{ baseVisitor[type](node, st, c); }
if ((start == null || node.start === start) &&
(end == null || node.end === end) &&
test(type, node))
{ throw new Found(node, st) }
})(node, state);
} catch (e) {
if (e instanceof Found) { return e }
throw e
}
}
// Find the innermost node of a given type that contains the given
// position. Interface similar to findNodeAt.
function findNodeAround(node, pos, test, baseVisitor, state) {
test = makeTest(test);
if (!baseVisitor) { baseVisitor = base; }
try {
(function c(node, st, override) {
var type = override || node.type;
if (node.start > pos || node.end < pos) { return }
baseVisitor[type](node, st, c);
if (test(type, node)) { throw new Found(node, st) }
})(node, state);
} catch (e) {
if (e instanceof Found) { return e }
throw e
}
}
// Find the outermost matching node after a given position.
function findNodeAfter(node, pos, test, baseVisitor, state) {
test = makeTest(test);
if (!baseVisitor) { baseVisitor = base; }
try {
(function c(node, st, override) {
if (node.end < pos) { return }
var type = override || node.type;
if (node.start >= pos && test(type, node)) { throw new Found(node, st) }
baseVisitor[type](node, st, c);
})(node, state);
} catch (e) {
if (e instanceof Found) { return e }
throw e
}
}
// Find the outermost matching node before a given position.
function findNodeBefore(node, pos, test, baseVisitor, state) {
test = makeTest(test);
if (!baseVisitor) { baseVisitor = base; }
var max
;(function c(node, st, override) {
if (node.start > pos) { return }
var type = override || node.type;
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
{ max = new Found(node, st); }
baseVisitor[type](node, st, c);
})(node, state);
return max
}
// Used to create a custom walker. Will fill in all missing node
// type properties with the defaults.
function make(funcs, baseVisitor) {
var visitor = Object.create(baseVisitor || base);
for (var type in funcs) { visitor[type] = funcs[type]; }
return visitor
}
function skipThrough(node, st, c) { c(node, st); }
function ignore(_node, _st, _c) {}
// Node walkers.
var base = {};
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
for (var i = 0, list = node.body; i < list.length; i += 1)
{
var stmt = list[i];
c(stmt, st, "Statement");
}
};
base.Statement = skipThrough;
base.EmptyStatement = ignore;
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
function (node, st, c) { return c(node.expression, st, "Expression"); };
base.IfStatement = function (node, st, c) {
c(node.test, st, "Expression");
c(node.consequent, st, "Statement");
if (node.alternate) { c(node.alternate, st, "Statement"); }
};
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
base.BreakStatement = base.ContinueStatement = ignore;
base.WithStatement = function (node, st, c) {
c(node.object, st, "Expression");
c(node.body, st, "Statement");
};
base.SwitchStatement = function (node, st, c) {
c(node.discriminant, st, "Expression");
for (var i = 0, list = node.cases; i < list.length; i += 1) {
var cs = list[i];
c(cs, st);
}
};
base.SwitchCase = function (node, st, c) {
if (node.test) { c(node.test, st, "Expression"); }
for (var i = 0, list = node.consequent; i < list.length; i += 1)
{
var cons = list[i];
c(cons, st, "Statement");
}
};
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
if (node.argument) { c(node.argument, st, "Expression"); }
};
base.ThrowStatement = base.SpreadElement =
function (node, st, c) { return c(node.argument, st, "Expression"); };
base.TryStatement = function (node, st, c) {
c(node.block, st, "Statement");
if (node.handler) { c(node.handler, st); }
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
};
base.CatchClause = function (node, st, c) {
if (node.param) { c(node.param, st, "Pattern"); }
c(node.body, st, "Statement");
};
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
c(node.test, st, "Expression");
c(node.body, st, "Statement");
};
base.ForStatement = function (node, st, c) {
if (node.init) { c(node.init, st, "ForInit"); }
if (node.test) { c(node.test, st, "Expression"); }
if (node.update) { c(node.update, st, "Expression"); }
c(node.body, st, "Statement");
};
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
c(node.left, st, "ForInit");
c(node.right, st, "Expression");
c(node.body, st, "Statement");
};
base.ForInit = function (node, st, c) {
if (node.type === "VariableDeclaration") { c(node, st); }
else { c(node, st, "Expression"); }
};
base.DebuggerStatement = ignore;
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
base.VariableDeclaration = function (node, st, c) {
for (var i = 0, list = node.declarations; i < list.length; i += 1)
{
var decl = list[i];
c(decl, st);
}
};
base.VariableDeclarator = function (node, st, c) {
c(node.id, st, "Pattern");
if (node.init) { c(node.init, st, "Expression"); }
};
base.Function = function (node, st, c) {
if (node.id) { c(node.id, st, "Pattern"); }
for (var i = 0, list = node.params; i < list.length; i += 1)
{
var param = list[i];
c(param, st, "Pattern");
}
c(node.body, st, node.expression ? "Expression" : "Statement");
};
base.Pattern = function (node, st, c) {
if (node.type === "Identifier")
{ c(node, st, "VariablePattern"); }
else if (node.type === "MemberExpression")
{ c(node, st, "MemberPattern"); }
else
{ c(node, st); }
};
base.VariablePattern = ignore;
base.MemberPattern = skipThrough;
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
base.ArrayPattern = function (node, st, c) {
for (var i = 0, list = node.elements; i < list.length; i += 1) {
var elt = list[i];
if (elt) { c(elt, st, "Pattern"); }
}
};
base.ObjectPattern = function (node, st, c) {
for (var i = 0, list = node.properties; i < list.length; i += 1) {
var prop = list[i];
if (prop.type === "Property") {
if (prop.computed) { c(prop.key, st, "Expression"); }
c(prop.value, st, "Pattern");
} else if (prop.type === "RestElement") {
c(prop.argument, st, "Pattern");
}
}
};
base.Expression = skipThrough;
base.ThisExpression = base.Super = base.MetaProperty = ignore;
base.ArrayExpression = function (node, st, c) {
for (var i = 0, list = node.elements; i < list.length; i += 1) {
var elt = list[i];
if (elt) { c(elt, st, "Expression"); }
}
};
base.ObjectExpression = function (node, st, c) {
for (var i = 0, list = node.properties; i < list.length; i += 1)
{
var prop = list[i];
c(prop, st);
}
};
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
base.SequenceExpression = function (node, st, c) {
for (var i = 0, list = node.expressions; i < list.length; i += 1)
{
var expr = list[i];
c(expr, st, "Expression");
}
};
base.TemplateLiteral = function (node, st, c) {
for (var i = 0, list = node.quasis; i < list.length; i += 1)
{
var quasi = list[i];
c(quasi, st);
}
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
{
var expr = list$1[i$1];
c(expr, st, "Expression");
}
};
base.TemplateElement = ignore;
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
c(node.argument, st, "Expression");
};
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
c(node.left, st, "Expression");
c(node.right, st, "Expression");
};
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
c(node.left, st, "Pattern");
c(node.right, st, "Expression");
};
base.ConditionalExpression = function (node, st, c) {
c(node.test, st, "Expression");
c(node.consequent, st, "Expression");
c(node.alternate, st, "Expression");
};
base.NewExpression = base.CallExpression = function (node, st, c) {
c(node.callee, st, "Expression");
if (node.arguments)
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
{
var arg = list[i];
c(arg, st, "Expression");
} }
};
base.MemberExpression = function (node, st, c) {
c(node.object, st, "Expression");
if (node.computed) { c(node.property, st, "Expression"); }
};
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
if (node.declaration)
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
if (node.source) { c(node.source, st, "Expression"); }
};
base.ExportAllDeclaration = function (node, st, c) {
if (node.exported)
{ c(node.exported, st); }
c(node.source, st, "Expression");
};
base.ImportDeclaration = function (node, st, c) {
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
{
var spec = list[i];
c(spec, st);
}
c(node.source, st, "Expression");
};
base.ImportExpression = function (node, st, c) {
c(node.source, st, "Expression");
};
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
base.TaggedTemplateExpression = function (node, st, c) {
c(node.tag, st, "Expression");
c(node.quasi, st, "Expression");
};
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
base.Class = function (node, st, c) {
if (node.id) { c(node.id, st, "Pattern"); }
if (node.superClass) { c(node.superClass, st, "Expression"); }
c(node.body, st);
};
base.ClassBody = function (node, st, c) {
for (var i = 0, list = node.body; i < list.length; i += 1)
{
var elt = list[i];
c(elt, st);
}
};
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
if (node.computed) { c(node.key, st, "Expression"); }
if (node.value) { c(node.value, st, "Expression"); }
};
exports.ancestor = ancestor;
exports.base = base;
exports.findNodeAfter = findNodeAfter;
exports.findNodeAround = findNodeAround;
exports.findNodeAt = findNodeAt;
exports.findNodeBefore = findNodeBefore;
exports.full = full;
exports.fullAncestor = fullAncestor;
exports.make = make;
exports.recursive = recursive;
exports.simple = simple;
}));
/***/ }),
/***/ 2361:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// main.js for components/Form
const chalk = __webpack_require__(5248);
const { console } = __webpack_require__(264);
const path = __webpack_require__(6928); // Import the 'path' module for cross-platform path handling
const form_menu = {
message: '\n-----------\nSelect Action',
parent: 'main_components', // Allows navigating back to the main menu
choices: [
{
name: 'Insert Form with validation to -> PageName.controoler.js:',
value: 'insertFormJs',
handler: async (context) => {
// console.log(chalk.blue('🚀') + chalk.yellow(' Coming Soon...') + chalk.green(' 🔜'));
// Update the JS
// Define the list of options
const optionsAPI = ['1- odataV4', '2- none'];
const logger = new context.Logger();
const helper = new context.Helper();
const selectedPathsXML = await helper.handlerGetPaths(context);
if (!selectedPathsXML.length) {
logger.warn('You did not select any paths. Please think and try again.');
return;
}
console.log(chalk.blue('Selected Paths:'));
selectedPathsXML.forEach((path, index) => {
console.log(chalk.green(`${index + 1}: ${path}`));
});
const confirm = await context.cliHandler.confirm('Do you want to proceed with these paths?');
if (!confirm) {
return;
}
for (const selectedPathXML of selectedPathsXML) {
if (selectedPathXML.endsWith('.js')) {
context.uI5JSHandler.syncFiles("components/form/content/ex_Form.js", selectedPathXML);
// Extract the page name (first word before the '.') in a cross-platform way
const fileName = path.basename(selectedPathXML, '.js'); // Get the file name without extension
const pageName = fileName.split('.')[0]; // Extract the first word before the '.'
context.fileHandler.replacePlaceholdersInFile(selectedPathXML, {
appName: context.constant.appName,
packgName: context.constant.packgName,
controllerName: pageName,
});
const apiIntegration = await context.cliHandler.displayList(optionsAPI, 'Select API Integration?');
if (!apiIntegration) {
continue;
}
// process the api integration: odataV4 or localstorage
if (apiIntegration === '1- odataV4') {
context.uI5JSHandler.syncFiles("api/content/ex_OdataV4.js", selectedPathXML);
} else if (apiIntegration === '2- localstorage') {
// context.fileHandler.replacePlaceholdersInFile(selectedPathXML, {
// apiIntegration: apiIntegration,
// });
}
context.fileHandler.replacePlaceholdersInFile(selectedPathXML, {
appName: context.constant.appName,
packgName: context.constant.packgName,
controllerName: pageName,
});
}
}
// // 1- Language.js
// const xmlString = context.fileHandlerSource.readFile('i18n/content/Language.js')
// const strXML = context.fileHandler.readFile('view/App.view.xml')
// const newxml = xMLManager.setTagWithChilds(sourceParser.getTagByName('OverflowToolbarButton'), "mvc:View > App > tnt:ToolPage > tnt:header > tnt:ToolHeader > OverflowToolbarButton")
// context.fileHandler.writeFileWithFolders('view/App.view.xml', newxml)
// // 2- Component.js
// const uI5JSHandler = new context.UI5JSHandler(context.fileHandlerSource, context.fileHandler, context.Logger);
// uI5JSHandler.syncFiles("i18n/content/ex_Commponet.js", "/Component.js")
}
},
{
name: 'Insert Form with validation to -> PageName.view.xml:',
value: 'insertFormXML',
handler: async (context) => {
const logger = new context.Logger(true);
const helper = new context.Helper();
const selectedPathsXML = await helper.handlerGetPaths(context);
if (!selectedPathsXML.length) {
logger.warn('You did not select any paths. Please think and try again.');
return;
}
console.log(chalk.blue('Selected Paths:'));
selectedPathsXML.forEach((path, index) => {
console.log(chalk.green(`${index + 1}: ${path}`));
});
const confirm = await context.cliHandler.confirm('Do you want to proceed with these paths?');
if (!confirm) {
return;
}
const sourceXML = context.fileHandlerSource.readFile('components/form/content/ex_Form.xml')
for (const selectedPathXML of selectedPathsXML) {
if (selectedPathXML.endsWith('.xml')) {
// Extract the page name (first word before the '.') in a cross-platform way
const fileName = path.basename(selectedPathXML, '.xml'); // Get the file name without extension
const pageName = fileName.split('.')[0]; // Extract the first word before the '.'
// const destinationXML = context.fileHandler.readFile('view/TestJS.view.xml')
const destinationXML = context.fileHandler.readFile(selectedPathXML)
const xmlManager = new context.XMLManager(sourceXML, destinationXML);
let queryTag = "mvc:View > VBox > VBox > form:Form > form:formContainers > form:FormContainer > form:formElements > form:FormElement"
const firstStepOnInsert = xmlManager.firstStepOnInsert(logger, queryTag)
// logger.info("firstStepOnInsert", firstStepOnInsert.withOutFormElements)
// { get the ((this.autoG)) from the controller
const extractedVariable = context.uI5JSHandler.extractVariableFromFunction(
`controller/${pageName}.controller.js`, // Source file path
'initialForm', // Function name (default: "initialForm")
'this.autoG' // Variable name (default: "this.autoG")
);
if (!extractedVariable) {
logger.error(`Failed to extract variable from controller/${pageName}.controller.js`, pageName);
return;
}
const parsedValue = context.uI5JSHandler.getParsedValue(extractedVariable.value);
// logger.info("parsedValue", parsedValue)
// }
let newFormElementsTag = xmlManager.generateFormElements(firstStepOnInsert.TagContainer, parsedValue)
// logger.success("newFormElementsTag", newFormElementsTag)
let queryTag2 = "mvc:View > VBox > VBox > form:Form > form:formContainers > form:FormContainer > form:formElements"
let finalXMLSource = xmlManager.thirdStepOnInsert(logger, newFormElementsTag, queryTag2)
// logger.success("finalXMLSource", finalXMLSource)
//------ Last Step ------
const xmlManager2 = new context.XMLManager(finalXMLSource, destinationXML);
const finalXML = xmlManager2.insertSourceXMLToDestinationXML(logger)
// logger.success("finalXML", finalXML)
context.fileHandler.writeFileWithFolders(selectedPathXML, finalXML)
context.fileHandler.replacePlaceholdersInFile(selectedPathXML, {
appName: context.constant.appName,
packgName: context.constant.packgName,
controllerName: pageName,
});
}
}
}
}
]
};
const componentsAll = {
form_menu
}
module.exports = componentsAll;
/***/ }),
/***/ 2991:
/***/ ((module) => {
"use strict";
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
const ESCAPES = new Map([
['n', '\n'],
['r', '\r'],
['t', '\t'],
['b', '\b'],
['f', '\f'],
['v', '\v'],
['0', '\0'],
['\\', '\\'],
['e', '\u001B'],
['a', '\u0007']
]);
function unescape(c) {
const u = c[0] === 'u';
const bracket = c[1] === '{';
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
return String.fromCharCode(parseInt(c.slice(1), 16));
}
if (u && bracket) {
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
}
return ESCAPES.get(c) || c;
}
function parseArguments(name, arguments_) {
const results = [];
const chunks = arguments_.trim().split(/\s*,\s*/g);
let matches;
for (const chunk of chunks) {
const number = Number(chunk);
if (!Number.isNaN(number)) {
results.push(number);
} else if ((matches = chunk.match(STRING_REGEX))) {
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
} else {
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
}
}
return results;
}
function parseStyle(style) {
STYLE_REGEX.lastIndex = 0;
const results = [];
let matches;
while ((matches = STYLE_REGEX.exec(style)) !== null) {
const name = matches[1];
if (matches[2]) {
const args = parseArguments(name, matches[2]);
results.push([name].concat(args));
} else {
results.push([name]);
}
}
return results;
}
function buildStyle(chalk, styles) {
const enabled = {};
for (const layer of styles) {
for (const style of layer.styles) {
enabled[style[0]] = layer.inverse ? null : style.slice(1);
}
}
let current = chalk;
for (const [styleName, styles] of Object.entries(enabled)) {
if (!Array.isArray(styles)) {
continue;
}
if (!(styleName in current)) {
throw new Error(`Unknown Chalk style: ${styleName}`);
}
current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
}
return current;
}
module.exports = (chalk, temporary) => {
const styles = [];
const chunks = [];
let chunk = [];
// eslint-disable-next-line max-params
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
if (escapeCharacter) {
chunk.push(unescape(escapeCharacter));
} else if (style) {
const string = chunk.join('');
chunk = [];
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
styles.push({inverse, styles: parseStyle(style)});
} else if (close) {
if (styles.length === 0) {
throw new Error('Found extraneous } in Chalk template literal');
}
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
chunk = [];
styles.pop();
} else {
chunk.push(character);
}
});
chunks.push(chunk.join(''));
if (styles.length > 0) {
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
throw new Error(errMessage);
}
return chunks.join('');
};
/***/ }),
/***/ 3193:
/***/ ((module) => {
"use strict";
module.exports = require("string_decoder");
/***/ }),
/***/ 3299:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// Import inquirer dynamically (ES module support in Node.js)
async function loadInquirer() {
const inquirer = await __webpack_require__.e(/* import() */ 535).then(__webpack_require__.bind(__webpack_require__, 7535));
return inquirer.default;
}
class CLIHandler {
/**
* Initialize the CLIHandler instance.
* @param {Logger} Logger - A logger class or instance for logging.
*/
constructor(Logger) {
if (!Logger) {
throw new Error('Logger must be provided.');
}
this.logger = typeof Logger === 'function' ? new Logger() : Logger; // Support both classes and instances
}
/**
* Map a list of items to choices for inquirer prompts.
* @param {Array<string | { name: string, value: any }>} list - The list of items to display.
* @returns {Array<{ name: string, value: any }>} - The mapped choices.
*/
_mapToChoices(list) {
return list.map(item =>
typeof item === 'string' ? { name: item, value: item } : item
);
}
/**
* Display a list of items for the user to select from.
* @param {Array<string | { name: string, value: any }>} list - The list of items to display.
* @param {string} message - The message to display to the user.
* @returns {Promise<any>} - The selected item(s) from the list.
*/
async displayList(list, message = 'Please select an option:') {
return this._prompt({
type: 'list',
name: 'selected',
message: message,
choices: this._mapToChoices(list)
});
}
/**
* Display a checkbox list of items for the user to select multiple options.
* @param {Array<string | { name: string, value: any }>} list - The list of items to display.
* @param {string} message - The message to display to the user.
* @returns {Promise<any[]>} - The array of selected items.
*/
async displayCheckboxList(list, message = 'Please select one or more options:') {
return this._prompt({
type: 'checkbox',
name: 'selected',
message: message,
choices: this._mapToChoices(list)
});
}
/**
* Prompt the user for confirmation.
* @param {string} message - The message to display to the user.
* @returns {Promise<boolean>} - True if the user confirms, false otherwise.
*/
async confirm(message = 'Do you want to proceed?') {
return this._prompt({
type: 'confirm',
name: 'confirmed',
message: message,
default: false
});
}
/**
* Prompt the user for input.
* @param {string} message - The message to display to the user.
* @param {string} defaultValue - The default value for the input.
* @returns {Promise<string>} - The user's input.
*/
async promptInput(message = 'Please enter a value:', defaultValue = '') {
return this._prompt({
type: 'input',
name: 'input',
message: message,
default: defaultValue
});
}
/**
* Prompt the user for a password.
* @param {string} message - The message to display to the user.
* @returns {Promise<string>} - The user's input.
*/
async promptPassword(message = 'Please enter your password:') {
return this._prompt({
type: 'password',
name: 'password',
message: message,
mask: '*'
});
}
/**
* Prompt the user with a raw list.
* @param {Array<string | { name: string, value: any }>} list - The list of items to display.
* @param {string} message - The message to display to the user.
* @returns {Promise<any>} - The selected item from the list.
*/
async displayRawList(list, message = 'Please select an option:') {
return this._prompt({
type: 'rawlist',
name: 'selected',
message: message,
choices: this._mapToChoices(list)
});
}
/**
* General method to handle different types of prompts.
* @param {Object} promptConfig - The configuration object for the prompt.
* @returns {Promise<any>} - The user's response.
*/
async _prompt(promptConfig) {
try {
const inquirer = await loadInquirer();
const answer = await inquirer.prompt([promptConfig]);
return answer[promptConfig.name];
} catch (error) {
this.handleError(error);
throw error;
}
}
/**
* Handle errors during CLI interactions.
* @param {Error} error - The error object.
*/
handleError(error) {
if (error?.isTtyError) {
this.logger.error("Prompt couldn't be rendered in the current environment.");
} else if (error instanceof Error && error.name === 'ExitPromptError') {
this.logger.log("Prompt was forcefully exited by the user.");
} else {
this.logger.error("An unexpected error occurred:", error.message || 'Unknown error');
}
}
}
module.exports = { CLIHandler };
/***/ }),
/***/ 3785:
/***/ ((module) => {
"use strict";
module.exports = require("readline");
/***/ }),
/***/ 4058:
/***/ ((module) => {
"use strict";
const stringReplaceAll = (string, substring, replacer) => {
let index = string.indexOf(substring);
if (index === -1) {
return string;
}
const substringLength = substring.length;
let endIndex = 0;
let returnValue = '';
do {
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
endIndex = index + substringLength;
index = string.indexOf(substring, endIndex);
} while (index !== -1);
returnValue += string.substr(endIndex);
return returnValue;
};
const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
let endIndex = 0;
let returnValue = '';
do {
const gotCR = string[index - 1] === '\r';
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
endIndex = index + 1;
index = string.indexOf('\n', endIndex);
} while (index !== -1);
returnValue += string.substr(endIndex);
return returnValue;
};
module.exports = {
stringReplaceAll,
stringEncaseCRLFWithFirstIndex
};
/***/ }),
/***/ 4083:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
/* module decorator */ module = __webpack_require__.nmd(module);
const wrapAnsi16 = (fn, offset) => (...args) => {
const code = fn(...args);
return `\u001B[${code + offset}m`;
};
const wrapAnsi256 = (fn, offset) => (...args) => {
const code = fn(...args);
return `\u001B[${38 + offset};5;${code}m`;
};
const wrapAnsi16m = (fn, offset) => (...args) => {
const rgb = fn(...args);
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
};
const ansi2ansi = n => n;
const rgb2rgb = (r, g, b) => [r, g, b];
const setLazyProperty = (object, property, get) => {
Object.defineProperty(object, property, {
get: () => {
const value = get();
Object.defineProperty(object, property, {
value,
enumerable: true,
configurable: true
});
return value;
},
enumerable: true,
configurable: true
});
};
/** @type {typeof import('color-convert')} */
let colorConvert;
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
if (colorConvert === undefined) {
colorConvert = __webpack_require__(734);
}
const offset = isBackground ? 10 : 0;
const styles = {};
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
if (sourceSpace === targetSpace) {
styles[name] = wrap(identity, offset);
} else if (typeof suite === 'object') {
styles[name] = wrap(suite[targetSpace], offset);
}
}
return styles;
};
function assembleStyles() {
const codes = new Map();
const styles = {
modifier: {
reset: [0, 0],
// 21 isn't widely supported and 22 does the same thing
bold: [1, 22],
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidd