@qodalis/cli-core 0.0.4 → 0.0.5
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.
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { constants } from '../constants';
|
|
2
2
|
import { utils } from '../utils';
|
|
3
|
-
const global = window;
|
|
4
3
|
export const initializeBrowserEnvironment = ({ handlers, }) => {
|
|
5
|
-
|
|
4
|
+
window.cliCore = {
|
|
6
5
|
onUmdModuleBoot: handlers || [],
|
|
7
6
|
bootUmdModule: async (module) => {
|
|
8
7
|
console.log('Booting UMD module', module.name);
|
|
9
|
-
|
|
8
|
+
window[module.name] = module;
|
|
10
9
|
handlers.forEach(async (handler) => await handler(module));
|
|
11
10
|
},
|
|
12
|
-
Injectable: () => { },
|
|
13
11
|
...constants,
|
|
14
12
|
...utils,
|
|
15
13
|
};
|
|
@@ -18,11 +16,11 @@ export const initializeBrowserEnvironment = ({ handlers, }) => {
|
|
|
18
16
|
};
|
|
19
17
|
};
|
|
20
18
|
export const bootUmdModule = async (module) => {
|
|
21
|
-
if (typeof
|
|
22
|
-
await
|
|
19
|
+
if (typeof window !== 'undefined') {
|
|
20
|
+
await window.cliCore.bootUmdModule(module);
|
|
23
21
|
}
|
|
24
22
|
else {
|
|
25
23
|
console.log('window is undefined');
|
|
26
24
|
}
|
|
27
25
|
};
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9jb3JlL3NyYy9saWIvbW9kdWxlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sY0FBYyxDQUFDO0FBRXpDLE9BQU8sRUFBRSxLQUFLL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ICd1bmRlZmluZWQnKSB7XG4gICAgICAgIGF3YWl0ICh3aW5kb3cgYXMgYW55KS5jbGlDb3JlLmJvb3RVbWRNb2R1bGUobW9kdWxlKTtcbiAgICB9IGVsc2Uge1xuICAgICAgICBjb25zb2xlLmxvZygnd2luZG93IGlzIHVuZGVmaW5lZCcpO1xuICAgIH1cbn07XG4iXX0=
|
|
@@ -86,16 +86,14 @@ const utils = {
|
|
|
86
86
|
getRightOfWord,
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
const global = window;
|
|
90
89
|
const initializeBrowserEnvironment = ({ handlers, }) => {
|
|
91
|
-
|
|
90
|
+
window.cliCore = {
|
|
92
91
|
onUmdModuleBoot: handlers || [],
|
|
93
92
|
bootUmdModule: async (module) => {
|
|
94
93
|
console.log('Booting UMD module', module.name);
|
|
95
|
-
|
|
94
|
+
window[module.name] = module;
|
|
96
95
|
handlers.forEach(async (handler) => await handler(module));
|
|
97
96
|
},
|
|
98
|
-
Injectable: () => { },
|
|
99
97
|
...constants,
|
|
100
98
|
...utils,
|
|
101
99
|
};
|
|
@@ -104,8 +102,8 @@ const initializeBrowserEnvironment = ({ handlers, }) => {
|
|
|
104
102
|
};
|
|
105
103
|
};
|
|
106
104
|
const bootUmdModule = async (module) => {
|
|
107
|
-
if (typeof
|
|
108
|
-
await
|
|
105
|
+
if (typeof window !== 'undefined') {
|
|
106
|
+
await window.cliCore.bootUmdModule(module);
|
|
109
107
|
}
|
|
110
108
|
else {
|
|
111
109
|
console.log('window is undefined');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qodalis-cli-core.mjs","sources":["../../../projects/core/src/lib/models/index.ts","../../../projects/core/src/lib/constants/index.ts","../../../projects/core/src/lib/utils/index.ts","../../../projects/core/src/lib/modules/index.ts","../../../projects/core/src/public-api.ts","../../../projects/core/src/qodalis-cli-core.ts"],"sourcesContent":["import { ITerminalInitOnlyOptions, ITerminalOptions } from '@xterm/xterm';\n\nexport type CliProcessCommand = {\n /**\n * The command that was entered\n */\n command: string;\n\n /**\n * The chain of commands that were entered\n */\n chainCommands: string[];\n\n /**\n * The raw command that was entered\n */\n rawCommand: string;\n\n /**\n * The value of the command\n */\n value?: string;\n\n /**\n * The arguments that were entered\n */\n args: Record<string, any>;\n};\n\nexport enum CliForegroundColor {\n Black = '\\x1b[30m',\n Red = '\\x1b[31m',\n Green = '\\x1b[32m',\n Yellow = '\\x1b[33m',\n Blue = '\\x1b[34m',\n Magenta = '\\x1b[35m',\n Cyan = '\\x1b[36m',\n White = '\\x1b[37m',\n Reset = '\\x1b[0m',\n}\n\nexport enum CliBackgroundColor {\n Black = '\\x1b[40m',\n Red = '\\x1b[41m',\n Green = '\\x1b[42m',\n Yellow = '\\x1b[43m',\n Blue = '\\x1b[44m',\n Magenta = '\\x1b[45m',\n Cyan = '\\x1b[46m',\n White = '\\x1b[47m',\n}\n\nexport interface ICliUser extends Record<string, any> {\n /**\n * The id of the user\n */\n id: string;\n\n /**\n * The name of the user\n */\n name: string;\n\n /**\n * The email of the user\n */\n email: string;\n}\n\nexport interface ICliUserSession {\n /**\n * The user associated with the session\n */\n user: ICliUser;\n\n /**\n * The data associated with the user session\n */\n data?: Record<string, any>;\n}\n\n/**\n * Options for the CLI\n */\nexport type CliOptions = {\n /**\n * The welcome message to display when the CLI starts\n */\n welcomeMessage?: string;\n\n /**\n * Hide the prompt to display when the CLI is ready to accept input\n */\n hideUserName?: boolean;\n\n /**\n * Custom terminal options\n */\n terminalOptions?: ITerminalOptions & ITerminalInitOnlyOptions;\n};\n\n/**\n * Represents a package that can be installed\n */\nexport interface Package {\n /**\n * The name of the package\n */\n name: string;\n\n /**\n * The global name used to access the package\n */\n globalName?: string;\n\n /**\n * The version of the package\n */\n version: string;\n\n /**\n * The unpkg url to the package\n */\n url: string;\n\n /**\n * The dependencies for the module\n */\n dependencies?: Package[];\n}\n","import { ICliCommandAuthor } from '../interfaces';\n\nexport const DefaultLibraryAuthor: ICliCommandAuthor = {\n name: 'Nicolae Lupei',\n email: 'nicolae.lupei@qodalis.com',\n};\n\nexport const constants = {\n DefaultLibraryAuthor,\n};\n","import { ICliCommandParameterDescriptor } from '../interfaces';\nimport { CliBackgroundColor, CliForegroundColor } from '../models';\n\nexport const getParameterValue = (\n p: ICliCommandParameterDescriptor,\n args: Record<string, any>,\n): any | undefined => {\n return (\n args[p.name] ??\n (p.aliases?.find((alias) => args[alias]) &&\n args[p.aliases!.find((alias) => args[alias])!])\n );\n};\n\nexport const formatJson = (json: any): string => {\n const identedJson = JSON.stringify(json, null, 2);\n\n return colorizeJson(identedJson.split('\\n').join('\\r\\n'));\n};\n\nexport const colorizeJson = (jsonString: any): string => {\n return jsonString\n .replace(/\"([^\"]+)\":/g, '\\x1b[33m\"$1\":\\x1b[0m') // Keys (yellow)\n .replace(/: \"([^\"]*)\"/g, ': \\x1b[32m\"$1\"\\x1b[0m') // Strings (green)\n .replace(/: (\\d+)/g, ': \\x1b[34m$1\\x1b[0m') // Numbers (blue)\n .replace(/: (true|false)/g, ': \\x1b[35m$1\\x1b[0m') // Booleans (magenta)\n .replace(/: (null)/g, ': \\x1b[36m$1\\x1b[0m'); // Null (cyan)\n};\n\nexport const toQueryString = (params: Record<string, any>): string => {\n const searchParams = new URLSearchParams();\n\n for (const key in params) {\n if (params.hasOwnProperty(key)) {\n const value = params[key];\n // Handle array and non-primitive values\n if (Array.isArray(value)) {\n value.forEach((v) => searchParams.append(key, v.toString()));\n } else if (value !== null && value !== undefined) {\n searchParams.append(key, value.toString());\n }\n }\n }\n\n return searchParams.toString();\n};\n\nexport const highlightTextWithBg = (\n text: string,\n pattern: RegExp,\n bgColor: CliBackgroundColor = CliBackgroundColor.Yellow,\n): string => {\n // Replace matches with background-colored text\n return text.replace(\n pattern,\n (match) => `${bgColor}${match}${CliForegroundColor.Reset}`,\n );\n};\n\nexport const getRightOfWord = (\n command: string,\n word: string,\n): string | undefined => {\n // Find the position of the word in the command\n const index = command.indexOf(word);\n\n // If the word is found, extract the substring to the right\n if (index !== -1) {\n return command.slice(index + word.length).trim();\n }\n\n // If the word is not found, return null\n return undefined;\n};\n\nexport const utils = {\n getParameterValue,\n formatJson,\n colorizeJson,\n toQueryString,\n highlightTextWithBg,\n getRightOfWord,\n};\n","import { constants } from '../constants';\nimport { ICliUmdModule } from '../interfaces';\nimport { utils } from '../utils';\n\nconst global = window as any;\n\nexport const initializeBrowserEnvironment = ({\n handlers,\n}: {\n handlers: ((module: ICliUmdModule) => Promise<void>)[];\n}): void => {\n global.core = {\n onUmdModuleBoot: handlers || [],\n bootUmdModule: async (module: ICliUmdModule) => {\n console.log('Booting UMD module', module.name);\n global[module.name] = module;\n handlers.forEach(async (handler) => await handler(module));\n },\n Injectable: () => {},\n ...constants,\n ...utils,\n };\n\n (window as any).ngCore = {\n Injectable: () => {},\n };\n};\n\nexport const bootUmdModule = async (module: ICliUmdModule): Promise<void> => {\n if (typeof global !== 'undefined') {\n await global.core.bootUmdModule(module);\n } else {\n console.log('window is undefined');\n }\n};\n","/*\n * Public API Surface of core\n */\n\nexport * from './lib/models';\n\nexport * from './lib/interfaces';\n\nexport * from './lib/modules';\n\nexport * from './lib/utils';\n\nexport * from './lib/constants';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"IA6BY,mBAUX;AAVD,CAAA,UAAY,kBAAkB,EAAA;AAC1B,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,YAAgB,CAAA;AAChB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,YAAmB,CAAA;AACnB,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,YAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,YAAoB,CAAA;AACpB,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,YA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AA,UAAU,EAAE,MAAK,GAAG;AACpB,QAAA,GAAG,SAAS;AACZ,QAAA,GAAG,KAAK;KACX,CAAC;IAED,MAAc,CAAC,MAAM,GAAG;AACrB,QAAA,UAAU,EAAE,MAAK,GAAG;KACvB,CAAC;AACN,EAAE;MAEW,aAAa,GAAG,OAAO,MAAqB,KAAmB;AACxE,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAC/B,MAAM,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAC3C,KAAA;AAAM,SAAA;AACH,QAAA,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AACtC,KAAA;AACL;;AClCA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"qodalis-cli-core.mjs","sources":["../../../projects/core/src/lib/models/index.ts","../../../projects/core/src/lib/constants/index.ts","../../../projects/core/src/lib/utils/index.ts","../../../projects/core/src/lib/modules/index.ts","../../../projects/core/src/public-api.ts","../../../projects/core/src/qodalis-cli-core.ts"],"sourcesContent":["import { ITerminalInitOnlyOptions, ITerminalOptions } from '@xterm/xterm';\n\nexport type CliProcessCommand = {\n /**\n * The command that was entered\n */\n command: string;\n\n /**\n * The chain of commands that were entered\n */\n chainCommands: string[];\n\n /**\n * The raw command that was entered\n */\n rawCommand: string;\n\n /**\n * The value of the command\n */\n value?: string;\n\n /**\n * The arguments that were entered\n */\n args: Record<string, any>;\n};\n\nexport enum CliForegroundColor {\n Black = '\\x1b[30m',\n Red = '\\x1b[31m',\n Green = '\\x1b[32m',\n Yellow = '\\x1b[33m',\n Blue = '\\x1b[34m',\n Magenta = '\\x1b[35m',\n Cyan = '\\x1b[36m',\n White = '\\x1b[37m',\n Reset = '\\x1b[0m',\n}\n\nexport enum CliBackgroundColor {\n Black = '\\x1b[40m',\n Red = '\\x1b[41m',\n Green = '\\x1b[42m',\n Yellow = '\\x1b[43m',\n Blue = '\\x1b[44m',\n Magenta = '\\x1b[45m',\n Cyan = '\\x1b[46m',\n White = '\\x1b[47m',\n}\n\nexport interface ICliUser extends Record<string, any> {\n /**\n * The id of the user\n */\n id: string;\n\n /**\n * The name of the user\n */\n name: string;\n\n /**\n * The email of the user\n */\n email: string;\n}\n\nexport interface ICliUserSession {\n /**\n * The user associated with the session\n */\n user: ICliUser;\n\n /**\n * The data associated with the user session\n */\n data?: Record<string, any>;\n}\n\n/**\n * Options for the CLI\n */\nexport type CliOptions = {\n /**\n * The welcome message to display when the CLI starts\n */\n welcomeMessage?: string;\n\n /**\n * Hide the prompt to display when the CLI is ready to accept input\n */\n hideUserName?: boolean;\n\n /**\n * Custom terminal options\n */\n terminalOptions?: ITerminalOptions & ITerminalInitOnlyOptions;\n};\n\n/**\n * Represents a package that can be installed\n */\nexport interface Package {\n /**\n * The name of the package\n */\n name: string;\n\n /**\n * The global name used to access the package\n */\n globalName?: string;\n\n /**\n * The version of the package\n */\n version: string;\n\n /**\n * The unpkg url to the package\n */\n url: string;\n\n /**\n * The dependencies for the module\n */\n dependencies?: Package[];\n}\n","import { ICliCommandAuthor } from '../interfaces';\n\nexport const DefaultLibraryAuthor: ICliCommandAuthor = {\n name: 'Nicolae Lupei',\n email: 'nicolae.lupei@qodalis.com',\n};\n\nexport const constants = {\n DefaultLibraryAuthor,\n};\n","import { ICliCommandParameterDescriptor } from '../interfaces';\nimport { CliBackgroundColor, CliForegroundColor } from '../models';\n\nexport const getParameterValue = (\n p: ICliCommandParameterDescriptor,\n args: Record<string, any>,\n): any | undefined => {\n return (\n args[p.name] ??\n (p.aliases?.find((alias) => args[alias]) &&\n args[p.aliases!.find((alias) => args[alias])!])\n );\n};\n\nexport const formatJson = (json: any): string => {\n const identedJson = JSON.stringify(json, null, 2);\n\n return colorizeJson(identedJson.split('\\n').join('\\r\\n'));\n};\n\nexport const colorizeJson = (jsonString: any): string => {\n return jsonString\n .replace(/\"([^\"]+)\":/g, '\\x1b[33m\"$1\":\\x1b[0m') // Keys (yellow)\n .replace(/: \"([^\"]*)\"/g, ': \\x1b[32m\"$1\"\\x1b[0m') // Strings (green)\n .replace(/: (\\d+)/g, ': \\x1b[34m$1\\x1b[0m') // Numbers (blue)\n .replace(/: (true|false)/g, ': \\x1b[35m$1\\x1b[0m') // Booleans (magenta)\n .replace(/: (null)/g, ': \\x1b[36m$1\\x1b[0m'); // Null (cyan)\n};\n\nexport const toQueryString = (params: Record<string, any>): string => {\n const searchParams = new URLSearchParams();\n\n for (const key in params) {\n if (params.hasOwnProperty(key)) {\n const value = params[key];\n // Handle array and non-primitive values\n if (Array.isArray(value)) {\n value.forEach((v) => searchParams.append(key, v.toString()));\n } else if (value !== null && value !== undefined) {\n searchParams.append(key, value.toString());\n }\n }\n }\n\n return searchParams.toString();\n};\n\nexport const highlightTextWithBg = (\n text: string,\n pattern: RegExp,\n bgColor: CliBackgroundColor = CliBackgroundColor.Yellow,\n): string => {\n // Replace matches with background-colored text\n return text.replace(\n pattern,\n (match) => `${bgColor}${match}${CliForegroundColor.Reset}`,\n );\n};\n\nexport const getRightOfWord = (\n command: string,\n word: string,\n): string | undefined => {\n // Find the position of the word in the command\n const index = command.indexOf(word);\n\n // If the word is found, extract the substring to the right\n if (index !== -1) {\n return command.slice(index + word.length).trim();\n }\n\n // If the word is not found, return null\n return undefined;\n};\n\nexport const utils = {\n getParameterValue,\n formatJson,\n colorizeJson,\n toQueryString,\n highlightTextWithBg,\n getRightOfWord,\n};\n","import { constants } from '../constants';\nimport { ICliUmdModule } from '../interfaces';\nimport { utils } from '../utils';\n\nexport const initializeBrowserEnvironment = ({\n handlers,\n}: {\n handlers: ((module: ICliUmdModule) => Promise<void>)[];\n}): void => {\n (window as any).cliCore = {\n onUmdModuleBoot: handlers || [],\n bootUmdModule: async (module: ICliUmdModule) => {\n console.log('Booting UMD module', module.name);\n (window as any)[module.name] = module;\n handlers.forEach(async (handler) => await handler(module));\n },\n ...constants,\n ...utils,\n };\n\n (window as any).ngCore = {\n Injectable: () => {},\n };\n};\n\nexport const bootUmdModule = async (module: ICliUmdModule): Promise<void> => {\n if (typeof (window as any) !== 'undefined') {\n await (window as any).cliCore.bootUmdModule(module);\n } else {\n console.log('window is undefined');\n }\n};\n","/*\n * Public API Surface of core\n */\n\nexport * from './lib/models';\n\nexport * from './lib/interfaces';\n\nexport * from './lib/modules';\n\nexport * from './lib/utils';\n\nexport * from './lib/constants';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"IA6BY,mBAUX;AAVD,CAAA,UAAY,kBAAkB,EAAA;AAC1B,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,YAAgB,CAAA;AAChB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,YAAmB,CAAA;AACnB,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,YAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,YAAoB,CAAA;AACpB,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,YAAiB,CAAA;AACjB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,WAAiB,CAAA;AACrB,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,GAU7B,EAAA,CAAA,CAAA,CAAA;IAEW,mBASX;AATD,CAAA,UAAY,kBAAkB,EAAA;AAC1B,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,YAAgB,CAAA;AAChB,IAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,YAAkB,CAAA;AAClB,IAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,YAAmB,CAAA;AACnB,IAAA,kBAAA,CAAA,MAAA,CAAA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