@webiny/cli-core 6.5.4-beta.1 → 6.5.4
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/WatchCommand/getRandomColorForString.js","sources":["../../../src/features/WatchCommand/getRandomColorForString.ts"],"sourcesContent":["const colors = [\n \"#0000CC\",\n \"#0000FF\",\n \"#0033CC\",\n \"#0033FF\",\n \"#0066CC\",\n \"#0066FF\",\n \"#0099CC\",\n \"#0099FF\",\n \"#00CC00\",\n \"#00CC33\",\n \"#00CC66\",\n \"#00CC99\",\n \"#00CCCC\",\n \"#00CCFF\",\n \"#3300CC\",\n \"#3300FF\",\n \"#3333CC\",\n \"#3333FF\",\n \"#3366CC\",\n \"#3366FF\",\n \"#3399CC\",\n \"#3399FF\",\n \"#33CC00\",\n \"#33CC33\",\n \"#33CC66\",\n \"#33CC99\",\n \"#33CCCC\",\n \"#33CCFF\",\n \"#6600CC\",\n \"#6600FF\",\n \"#6633CC\",\n \"#6633FF\",\n \"#66CC00\",\n \"#66CC33\",\n \"#9900CC\",\n \"#9900FF\",\n \"#9933CC\",\n \"#9933FF\",\n \"#99CC00\",\n \"#99CC33\",\n \"#CC0000\",\n \"#CC0033\",\n \"#CC0066\",\n \"#CC0099\",\n \"#CC00CC\",\n \"#CC00FF\",\n \"#CC3300\",\n \"#CC3333\",\n \"#CC3366\",\n \"#CC3399\",\n \"#CC33CC\",\n \"#CC33FF\",\n \"#CC6600\",\n \"#CC6633\",\n \"#CC9900\",\n \"#CC9933\",\n \"#CCCC00\",\n \"#CCCC33\",\n \"#FF0000\",\n \"#FF0033\",\n \"#FF0066\",\n \"#FF0099\",\n \"#FF00CC\",\n \"#FF00FF\",\n \"#FF3300\",\n \"#FF3333\",\n \"#FF3366\",\n \"#FF3399\",\n \"#FF33CC\",\n \"#FF33FF\",\n \"#FF6600\",\n \"#FF6633\",\n \"#FF9900\",\n \"#FF9933\",\n \"#FFCC00\",\n \"#FFCC33\"\n];\n\nexport const getRandomColorForString = (value: string) => {\n let hash = 0;\n\n for (let i = 0; i < value.length; i++) {\n hash = (hash << 5) - hash + value.charCodeAt(i);\n hash |= 0; // Convert to 32bit integer\n }\n\n return colors[Math.abs(hash) % colors.length];\n};\n"],"names":["colors","getRandomColorForString","value","hash","i","Math"],"mappings":"AAAA,MAAMA,SAAS;IACX;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,MAAMC,0BAA0B,CAACC;IACpC,IAAIC,OAAO;IAEX,IAAK,IAAIC,IAAI,GAAGA,IAAIF,MAAM,MAAM,EAAEE,IAAK;QACnCD,OAAQA,AAAAA,CAAAA,QAAQ,
|
|
1
|
+
{"version":3,"file":"features/WatchCommand/getRandomColorForString.js","sources":["../../../src/features/WatchCommand/getRandomColorForString.ts"],"sourcesContent":["const colors = [\n \"#0000CC\",\n \"#0000FF\",\n \"#0033CC\",\n \"#0033FF\",\n \"#0066CC\",\n \"#0066FF\",\n \"#0099CC\",\n \"#0099FF\",\n \"#00CC00\",\n \"#00CC33\",\n \"#00CC66\",\n \"#00CC99\",\n \"#00CCCC\",\n \"#00CCFF\",\n \"#3300CC\",\n \"#3300FF\",\n \"#3333CC\",\n \"#3333FF\",\n \"#3366CC\",\n \"#3366FF\",\n \"#3399CC\",\n \"#3399FF\",\n \"#33CC00\",\n \"#33CC33\",\n \"#33CC66\",\n \"#33CC99\",\n \"#33CCCC\",\n \"#33CCFF\",\n \"#6600CC\",\n \"#6600FF\",\n \"#6633CC\",\n \"#6633FF\",\n \"#66CC00\",\n \"#66CC33\",\n \"#9900CC\",\n \"#9900FF\",\n \"#9933CC\",\n \"#9933FF\",\n \"#99CC00\",\n \"#99CC33\",\n \"#CC0000\",\n \"#CC0033\",\n \"#CC0066\",\n \"#CC0099\",\n \"#CC00CC\",\n \"#CC00FF\",\n \"#CC3300\",\n \"#CC3333\",\n \"#CC3366\",\n \"#CC3399\",\n \"#CC33CC\",\n \"#CC33FF\",\n \"#CC6600\",\n \"#CC6633\",\n \"#CC9900\",\n \"#CC9933\",\n \"#CCCC00\",\n \"#CCCC33\",\n \"#FF0000\",\n \"#FF0033\",\n \"#FF0066\",\n \"#FF0099\",\n \"#FF00CC\",\n \"#FF00FF\",\n \"#FF3300\",\n \"#FF3333\",\n \"#FF3366\",\n \"#FF3399\",\n \"#FF33CC\",\n \"#FF33FF\",\n \"#FF6600\",\n \"#FF6633\",\n \"#FF9900\",\n \"#FF9933\",\n \"#FFCC00\",\n \"#FFCC33\"\n];\n\nexport const getRandomColorForString = (value: string) => {\n let hash = 0;\n\n for (let i = 0; i < value.length; i++) {\n hash = (hash << 5) - hash + value.charCodeAt(i);\n hash |= 0; // Convert to 32bit integer\n }\n\n return colors[Math.abs(hash) % colors.length];\n};\n"],"names":["colors","getRandomColorForString","value","hash","i","Math"],"mappings":"AAAA,MAAMA,SAAS;IACX;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,MAAMC,0BAA0B,CAACC;IACpC,IAAIC,OAAO;IAEX,IAAK,IAAIC,IAAI,GAAGA,IAAIF,MAAM,MAAM,EAAEE,IAAK;QACnCD,OAAQA,AAAAA,CAAAA,QAAQ,CAAC,IAAIA,OAAOD,MAAM,UAAU,CAACE;QAC7CD,QAAQ;IACZ;IAEA,OAAOH,MAAM,CAACK,KAAK,GAAG,CAACF,QAAQH,OAAO,MAAM,CAAC;AACjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/Wcp/LinkProjectCommand.js","sources":["../../../src/features/Wcp/LinkProjectCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport inquirer from \"inquirer\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { setTimeout } from \"node:timers/promises\";\n\nconst sleep = (ms: number = 1500) => setTimeout(ms);\n\nexport class LinkProjectCommand implements CliCommandFactory.Interface<void> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n const projectSdk = await this.getProjectSdkService.execute();\n const wcp = projectSdk.wcp;\n const ui = this.uiService;\n\n return {\n name: \"link-project\",\n description: \"Link a Webiny project with Webiny Control Panel\",\n examples: [\"$0 link-project\"],\n handler: async () => {\n const user = await wcp.getUser();\n\n if (!user) {\n ui.error(\"You must be logged in to link a project.\");\n return;\n }\n\n // User already linked a project?\n const orgProjectId = await projectSdk.getProjectId();\n if (orgProjectId) {\n const [, projectId] = orgProjectId.split(\"/\");\n const project = user.projects.find(item => item.id === projectId);\n if (project) {\n ui.info(\"Your %s project is already linked.\", orgProjectId);\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to re-link it?\",\n type: \"confirm\",\n default: false\n });\n\n if (!proceed) {\n return;\n }\n\n ui.emptyLine();\n }\n }\n\n const wcpAppUrl = projectSdk.wcp.getWcpAppUrl().toString();\n\n // Get user's organizations.\n if (!user.orgs.length) {\n ui.info(\n \"It seems you're not part of any organization. Please log in to Webiny Control Panel and create one.\"\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to do that now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedOrg;\n if (user.orgs.length === 1) {\n selectedOrg = user.orgs[0];\n } else {\n ui.info(\"It seems you're part of multiple organizations. \");\n const choices = user.orgs.map(item => ({\n name: item.name,\n value: item\n }));\n\n const prompt = inquirer.createPromptModule();\n selectedOrg = await prompt({\n name: \"org\",\n message: \"Select organization:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.org);\n }\n\n const orgProjects = user.projects.filter(item => item.org.id === selectedOrg.id);\n\n // Get user's projects.\n if (!orgProjects.length) {\n ui.info(\n \"It seems there are no projects created within the %s organization.\",\n selectedOrg.name\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to create one now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedProject;\n if (orgProjects.length === 1) {\n selectedProject = user.projects[0];\n } else {\n ui.info(\n `It seems there are multiple projects created within the organization.`,\n selectedOrg.name\n );\n const choices = orgProjects.map(item => ({\n name: item.name,\n value: item\n }));\n const prompt = inquirer.createPromptModule();\n selectedProject = await prompt({\n name: \"project\",\n message: \"Select project:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.project);\n }\n\n await sleep();\n ui.emptyLine();\n\n ui.info(\"Linking %s project...\", selectedProject.name);\n\n await sleep();\n\n // Assign the necessary IDs into root `webiny.project.ts` project file.\n await projectSdk.setProjectId(`${selectedOrg.id}/${selectedProject.id}`, {\n force: true\n });\n\n ui.success(`%s Project %s linked successfully.`, \"✔\", selectedProject.name);\n\n await sleep();\n\n ui.emptyLine();\n ui.textBold(\"Next Steps\");\n\n ui.text(`‣ deploy your project via the yarn webiny deploy command`);\n }\n };\n }\n}\n\nexport const linkProjectCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: LinkProjectCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["sleep","ms","setTimeout","LinkProjectCommand","getProjectSdkService","uiService","projectSdk","wcp","ui","user","orgProjectId","projectId","project","item","prompt","inquirer","proceed","wcpAppUrl","open","selectedOrg","choices","result","orgProjects","selectedProject","linkProjectCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAKA,MAAMA,QAAQ,CAACC,KAAa,IAAI,GAAKC,oBAAWD;AAEzC,MAAME;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAC1D,MAAMC,MAAMD,WAAW,GAAG;QAC1B,MAAME,KAAK,IAAI,CAAC,SAAS;QAEzB,OAAO;YACH,MAAM;YACN,aAAa;YACb,UAAU;gBAAC;aAAkB;YAC7B,SAAS;gBACL,MAAMC,OAAO,MAAMF,IAAI,OAAO;gBAE9B,IAAI,CAACE,MAAM,YACPD,GAAG,KAAK,CAAC;gBAKb,MAAME,eAAe,MAAMJ,WAAW,YAAY;gBAClD,IAAII,cAAc;oBACd,MAAM,GAAGC,UAAU,GAAGD,aAAa,KAAK,CAAC;oBACzC,MAAME,UAAUH,KAAK,QAAQ,CAAC,IAAI,CAACI,CAAAA,OAAQA,KAAK,EAAE,KAAKF;oBACvD,IAAIC,SAAS;wBACTJ,GAAG,IAAI,CAAC,sCAAsCE;wBAE9C,MAAMI,SAASC,SAAS,kBAAkB;wBAC1C,MAAM,EAAEC,OAAO,EAAE,GAAG,MAAMF,OAAO;4BAC7B,MAAM;4BACN,SAAS;4BACT,MAAM;4BACN,SAAS;wBACb;wBAEA,IAAI,CAACE,SACD;wBAGJR,GAAG,SAAS;oBAChB;gBACJ;gBAEA,MAAMS,YAAYX,WAAW,GAAG,CAAC,YAAY,GAAG,QAAQ;gBAGxD,IAAI,CAACG,KAAK,IAAI,CAAC,MAAM,EAAE;oBACnBD,GAAG,IAAI,CACH;oBAGJ,MAAMM,SAASC,SAAS,kBAAkB;oBAC1C,MAAM,EAAEC,OAAO,EAAE,GAAG,MAAMF,OAAO;wBAC7B,MAAM;wBACN,SAAS;wBACT,MAAM;wBACN,SAAS;oBACb;oBAEA,IAAIE,SACAE,KAAKD;oBAET;gBACJ;gBAEA,IAAIE;gBACJ,IAAIV,AAAqB,MAArBA,KAAK,IAAI,CAAC,MAAM,EAChBU,cAAcV,KAAK,IAAI,CAAC,EAAE;qBACvB;oBACHD,GAAG,IAAI,CAAC;oBACR,MAAMY,UAAUX,KAAK,IAAI,CAAC,GAAG,CAACI,CAAAA,OAAS;4BACnC,MAAMA,KAAK,IAAI;4BACf,OAAOA;wBACX;
|
|
1
|
+
{"version":3,"file":"features/Wcp/LinkProjectCommand.js","sources":["../../../src/features/Wcp/LinkProjectCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport inquirer from \"inquirer\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { setTimeout } from \"node:timers/promises\";\n\nconst sleep = (ms: number = 1500) => setTimeout(ms);\n\nexport class LinkProjectCommand implements CliCommandFactory.Interface<void> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n const projectSdk = await this.getProjectSdkService.execute();\n const wcp = projectSdk.wcp;\n const ui = this.uiService;\n\n return {\n name: \"link-project\",\n description: \"Link a Webiny project with Webiny Control Panel\",\n examples: [\"$0 link-project\"],\n handler: async () => {\n const user = await wcp.getUser();\n\n if (!user) {\n ui.error(\"You must be logged in to link a project.\");\n return;\n }\n\n // User already linked a project?\n const orgProjectId = await projectSdk.getProjectId();\n if (orgProjectId) {\n const [, projectId] = orgProjectId.split(\"/\");\n const project = user.projects.find(item => item.id === projectId);\n if (project) {\n ui.info(\"Your %s project is already linked.\", orgProjectId);\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to re-link it?\",\n type: \"confirm\",\n default: false\n });\n\n if (!proceed) {\n return;\n }\n\n ui.emptyLine();\n }\n }\n\n const wcpAppUrl = projectSdk.wcp.getWcpAppUrl().toString();\n\n // Get user's organizations.\n if (!user.orgs.length) {\n ui.info(\n \"It seems you're not part of any organization. Please log in to Webiny Control Panel and create one.\"\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to do that now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedOrg;\n if (user.orgs.length === 1) {\n selectedOrg = user.orgs[0];\n } else {\n ui.info(\"It seems you're part of multiple organizations. \");\n const choices = user.orgs.map(item => ({\n name: item.name,\n value: item\n }));\n\n const prompt = inquirer.createPromptModule();\n selectedOrg = await prompt({\n name: \"org\",\n message: \"Select organization:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.org);\n }\n\n const orgProjects = user.projects.filter(item => item.org.id === selectedOrg.id);\n\n // Get user's projects.\n if (!orgProjects.length) {\n ui.info(\n \"It seems there are no projects created within the %s organization.\",\n selectedOrg.name\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to create one now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedProject;\n if (orgProjects.length === 1) {\n selectedProject = user.projects[0];\n } else {\n ui.info(\n `It seems there are multiple projects created within the organization.`,\n selectedOrg.name\n );\n const choices = orgProjects.map(item => ({\n name: item.name,\n value: item\n }));\n const prompt = inquirer.createPromptModule();\n selectedProject = await prompt({\n name: \"project\",\n message: \"Select project:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.project);\n }\n\n await sleep();\n ui.emptyLine();\n\n ui.info(\"Linking %s project...\", selectedProject.name);\n\n await sleep();\n\n // Assign the necessary IDs into root `webiny.project.ts` project file.\n await projectSdk.setProjectId(`${selectedOrg.id}/${selectedProject.id}`, {\n force: true\n });\n\n ui.success(`%s Project %s linked successfully.`, \"✔\", selectedProject.name);\n\n await sleep();\n\n ui.emptyLine();\n ui.textBold(\"Next Steps\");\n\n ui.text(`‣ deploy your project via the yarn webiny deploy command`);\n }\n };\n }\n}\n\nexport const linkProjectCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: LinkProjectCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["sleep","ms","setTimeout","LinkProjectCommand","getProjectSdkService","uiService","projectSdk","wcp","ui","user","orgProjectId","projectId","project","item","prompt","inquirer","proceed","wcpAppUrl","open","selectedOrg","choices","result","orgProjects","selectedProject","linkProjectCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAKA,MAAMA,QAAQ,CAACC,KAAa,IAAI,GAAKC,oBAAWD;AAEzC,MAAME;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAC1D,MAAMC,MAAMD,WAAW,GAAG;QAC1B,MAAME,KAAK,IAAI,CAAC,SAAS;QAEzB,OAAO;YACH,MAAM;YACN,aAAa;YACb,UAAU;gBAAC;aAAkB;YAC7B,SAAS;gBACL,MAAMC,OAAO,MAAMF,IAAI,OAAO;gBAE9B,IAAI,CAACE,MAAM,YACPD,GAAG,KAAK,CAAC;gBAKb,MAAME,eAAe,MAAMJ,WAAW,YAAY;gBAClD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IACnD,aAAaC;IACb,gBAAgBvB;IAChB,cAAc;QAACwB;QAAsBC;KAAU;AACnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/common/options.js","sources":["../../../src/features/common/options.ts"],"sourcesContent":["import { CliCommandFactory } from \"~/abstractions/index.js\";\nimport { ProjectSdk } from \"@webiny/project\";\n\nexport const createEnvOption = <T extends { env?: string }>(\n overrides: Partial<CliCommandFactory.OptionDefinition<T>> = {}\n): CliCommandFactory.OptionDefinition<T> => {\n return {\n name: \"env\",\n description: \"Environment name (dev, prod, etc.)\",\n type: \"string\",\n default: \"dev\",\n validation: params => {\n const p = params as any;\n const hasApp = p.app || (p.apps && p.apps.length > 0);\n if (hasApp && !p.env) {\n throw new Error(\"Environment name is required.\");\n }\n return true;\n },\n ...overrides\n };\n};\n\nexport const createVariantOption = <T extends { variant?: string }>(\n projectSdk: ProjectSdk,\n overrides: Partial<CliCommandFactory.OptionDefinition<T>> = {}\n): CliCommandFactory.OptionDefinition<T> => {\n return {\n name: \"variant\",\n description: \"Variant name\",\n type: \"string\",\n validation: params => {\n const isValid = projectSdk.isValidVariantName(params.variant);\n if (isValid.isErr()) {\n throw isValid.error;\n }\n return true;\n },\n ...overrides\n };\n};\n\nexport const createRegionOption = <T extends { region?: string }>(\n projectSdk: ProjectSdk,\n overrides: Partial<CliCommandFactory.OptionDefinition<T>> = {}\n): CliCommandFactory.OptionDefinition<T> => {\n return {\n name: \"region\",\n description: \"Region to target\",\n type: \"string\",\n validation: params => {\n const isValid = projectSdk.isValidRegionName(params.region);\n if (isValid.isErr()) {\n throw isValid.error;\n }\n return true;\n },\n ...overrides\n };\n};\n\nexport const createBaseAppOptions = <T extends { env?: string; variant?: string; region?: string }>(\n projectSdk: ProjectSdk,\n overrides: {\n env?: Partial<CliCommandFactory.OptionDefinition<T>>;\n variant?: Partial<CliCommandFactory.OptionDefinition<T>>;\n region?: Partial<CliCommandFactory.OptionDefinition<T>>;\n } = {}\n): CliCommandFactory.OptionDefinition<T>[] => {\n return [\n createEnvOption(overrides.env),\n createVariantOption(projectSdk, overrides.variant),\n createRegionOption(projectSdk, overrides.region)\n ];\n};\n"],"names":["createEnvOption","overrides","params","p","hasApp","Error","createVariantOption","projectSdk","isValid","createRegionOption","createBaseAppOptions"],"mappings":"AAGO,MAAMA,kBAAkB,CAC3BC,YAA4D,CAAC,CAAC,GAEvD;QACH,MAAM;QACN,aAAa;QACb,MAAM;QACN,SAAS;QACT,YAAYC,CAAAA;YACR,MAAMC,IAAID;YACV,MAAME,SAASD,EAAE,GAAG,IAAKA,EAAE,IAAI,IAAIA,EAAE,IAAI,CAAC,MAAM,GAAG;YACnD,IAAIC,UAAU,CAACD,EAAE,GAAG,EAChB,MAAM,IAAIE,MAAM;YAEpB,OAAO;QACX;QACA,GAAGJ,SAAS;IAChB;
|
|
1
|
+
{"version":3,"file":"features/common/options.js","sources":["../../../src/features/common/options.ts"],"sourcesContent":["import { CliCommandFactory } from \"~/abstractions/index.js\";\nimport { ProjectSdk } from \"@webiny/project\";\n\nexport const createEnvOption = <T extends { env?: string }>(\n overrides: Partial<CliCommandFactory.OptionDefinition<T>> = {}\n): CliCommandFactory.OptionDefinition<T> => {\n return {\n name: \"env\",\n description: \"Environment name (dev, prod, etc.)\",\n type: \"string\",\n default: \"dev\",\n validation: params => {\n const p = params as any;\n const hasApp = p.app || (p.apps && p.apps.length > 0);\n if (hasApp && !p.env) {\n throw new Error(\"Environment name is required.\");\n }\n return true;\n },\n ...overrides\n };\n};\n\nexport const createVariantOption = <T extends { variant?: string }>(\n projectSdk: ProjectSdk,\n overrides: Partial<CliCommandFactory.OptionDefinition<T>> = {}\n): CliCommandFactory.OptionDefinition<T> => {\n return {\n name: \"variant\",\n description: \"Variant name\",\n type: \"string\",\n validation: params => {\n const isValid = projectSdk.isValidVariantName(params.variant);\n if (isValid.isErr()) {\n throw isValid.error;\n }\n return true;\n },\n ...overrides\n };\n};\n\nexport const createRegionOption = <T extends { region?: string }>(\n projectSdk: ProjectSdk,\n overrides: Partial<CliCommandFactory.OptionDefinition<T>> = {}\n): CliCommandFactory.OptionDefinition<T> => {\n return {\n name: \"region\",\n description: \"Region to target\",\n type: \"string\",\n validation: params => {\n const isValid = projectSdk.isValidRegionName(params.region);\n if (isValid.isErr()) {\n throw isValid.error;\n }\n return true;\n },\n ...overrides\n };\n};\n\nexport const createBaseAppOptions = <T extends { env?: string; variant?: string; region?: string }>(\n projectSdk: ProjectSdk,\n overrides: {\n env?: Partial<CliCommandFactory.OptionDefinition<T>>;\n variant?: Partial<CliCommandFactory.OptionDefinition<T>>;\n region?: Partial<CliCommandFactory.OptionDefinition<T>>;\n } = {}\n): CliCommandFactory.OptionDefinition<T>[] => {\n return [\n createEnvOption(overrides.env),\n createVariantOption(projectSdk, overrides.variant),\n createRegionOption(projectSdk, overrides.region)\n ];\n};\n"],"names":["createEnvOption","overrides","params","p","hasApp","Error","createVariantOption","projectSdk","isValid","createRegionOption","createBaseAppOptions"],"mappings":"AAGO,MAAMA,kBAAkB,CAC3BC,YAA4D,CAAC,CAAC,GAEvD;QACH,MAAM;QACN,aAAa;QACb,MAAM;QACN,SAAS;QACT,YAAYC,CAAAA;YACR,MAAMC,IAAID;YACV,MAAME,SAASD,EAAE,GAAG,IAAKA,EAAE,IAAI,IAAIA,EAAE,IAAI,CAAC,MAAM,GAAG;YACnD,IAAIC,UAAU,CAACD,EAAE,GAAG,EAChB,MAAM,IAAIE,MAAM;YAEpB,OAAO;QACX;QACA,GAAGJ,SAAS;IAChB,CAAC;AAGE,MAAMK,sBAAsB,CAC/BC,YACAN,YAA4D,CAAC,CAAC,GAEvD;QACH,MAAM;QACN,aAAa;QACb,MAAM;QACN,YAAYC,CAAAA;YACR,MAAMM,UAAUD,WAAW,kBAAkB,CAACL,OAAO,OAAO;YAC5D,IAAIM,QAAQ,KAAK,IACb,MAAMA,QAAQ,KAAK;YAEvB,OAAO;QACX;QACA,GAAGP,SAAS;IAChB,CAAC;AAGE,MAAMQ,qBAAqB,CAC9BF,YACAN,YAA4D,CAAC,CAAC,GAEvD;QACH,MAAM;QACN,aAAa;QACb,MAAM;QACN,YAAYC,CAAAA;YACR,MAAMM,UAAUD,WAAW,iBAAiB,CAACL,OAAO,MAAM;YAC1D,IAAIM,QAAQ,KAAK,IACb,MAAMA,QAAQ,KAAK;YAEvB,OAAO;QACX;QACA,GAAGP,SAAS;IAChB,CAAC;AAGE,MAAMS,uBAAuB,CAChCH,YACAN,YAII,CAAC,CAAC,GAEC;QACHD,gBAAgBC,UAAU,GAAG;QAC7BK,oBAAoBC,YAAYN,UAAU,OAAO;QACjDQ,mBAAmBF,YAAYN,UAAU,MAAM;KAClD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/cli-core",
|
|
3
|
-
"version": "6.5.4
|
|
3
|
+
"version": "6.5.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@webiny/di": "1.1.0",
|
|
17
|
-
"@webiny/feature": "6.5.4
|
|
18
|
-
"@webiny/project": "6.5.4
|
|
19
|
-
"@webiny/pulumi-sdk": "6.5.4
|
|
17
|
+
"@webiny/feature": "6.5.4",
|
|
18
|
+
"@webiny/project": "6.5.4",
|
|
19
|
+
"@webiny/pulumi-sdk": "6.5.4",
|
|
20
20
|
"@webiny/stdlib": "0.0.20",
|
|
21
|
-
"@webiny/telemetry": "6.5.4
|
|
21
|
+
"@webiny/telemetry": "6.5.4",
|
|
22
22
|
"chalk": "6.0.1",
|
|
23
23
|
"ci-info": "4.5.0",
|
|
24
24
|
"execa": "5.1.1",
|
|
25
25
|
"fast-glob": "3.3.3",
|
|
26
26
|
"find-up": "8.0.0",
|
|
27
|
-
"humanize-duration": "3.
|
|
27
|
+
"humanize-duration": "3.36.1",
|
|
28
28
|
"inquirer": "14.3.1",
|
|
29
29
|
"load-json-file": "7.0.1",
|
|
30
30
|
"open": "11.0.4",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"zod": "4.6.7"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@types/lodash": "4.17.
|
|
42
|
-
"@webiny/build-tools": "6.5.4
|
|
41
|
+
"@types/lodash": "4.17.28",
|
|
42
|
+
"@webiny/build-tools": "6.5.4",
|
|
43
43
|
"rimraf": "6.1.4",
|
|
44
44
|
"typescript": "7.0.2"
|
|
45
45
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services/GetCliRunnerService/GetCliRunnerService.js","sources":["../../../src/services/GetCliRunnerService/GetCliRunnerService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n CliCommandFactory,\n CommandsRegistryService,\n GetArgvService,\n GetCliRunnerService,\n GlobalOptionsRegistryService,\n GetProjectSdkService,\n UiService\n} from \"~/abstractions/index.js\";\nimport yargs from \"yargs/yargs\";\nimport chalk from \"chalk\";\nimport { Argv } from \"yargs\";\nimport { GracefulError } from \"@webiny/project\";\nimport { ManuallyReportedError } from \"~/utils/ManuallyReportedError.js\";\n\nconst { blue, bgYellow, bold } = chalk;\n\nexport class DefaultGetCliRunnerService implements GetCliRunnerService.Interface {\n constructor(\n private readonly commandsRegistryService: CommandsRegistryService.Interface,\n private readonly globalOptionsRegistryService: GlobalOptionsRegistryService.Interface,\n private readonly uiService: UiService.Interface,\n private readonly getProjectSdkService: GetProjectSdkService.Interface,\n private readonly getArgvService: GetArgvService.Interface\n ) {}\n\n private yargsRunner: Argv | null = null;\n\n async execute() {\n if (this.yargsRunner) {\n return this.yargsRunner;\n }\n\n const ui = this.uiService;\n const projectSdk = await this.getProjectSdkService.execute();\n\n const yargsRunner = yargs()\n .usage(\"Usage: $0 <command> [options]\")\n .help(false)\n .demandCommand(1)\n .recommendCommands()\n .scriptName(\"webiny\")\n .epilogue(\n `To find more information, docs and tutorials, see ${blue(\n \"https://www.webiny.com/docs\"\n )}.`\n )\n .epilogue(`Want to contribute? ${blue(\"https://github.com/webiny/webiny-js\")}.`);\n\n // Register global options.\n const globalOptions = this.globalOptionsRegistryService.execute();\n for (const globalOption of globalOptions) {\n const { name, config } = await globalOption.execute();\n yargsRunner.option(name, {\n type: config.type,\n default: config.default,\n desc: config.description,\n alias: config.alias,\n choices: config.choices,\n global: true\n });\n }\n\n yargsRunner.fail((invalidParamsMessage, error) => {\n if (invalidParamsMessage) {\n if (invalidParamsMessage.includes(\"Not enough non-option arguments\")) {\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Some non-optional arguments are missing. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n if (invalidParamsMessage.includes(\"Missing required argument\")) {\n const args = invalidParamsMessage\n .split(\":\")[1]\n .split(\",\")\n .map(v => v.trim());\n\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Missing required argument(s): ${args.join(\n \", \"\n )}. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n ui.emptyLine();\n ui.error(invalidParamsMessage);\n\n process.exit(1);\n }\n\n const logger = projectSdk.getLogger();\n logger.error({ err: error }, \"CLI command execution failed.\");\n\n const realError = (error.cause as Error) || error;\n\n if (realError instanceof ManuallyReportedError) {\n // Do nothing as the error reporting has already been\n // handled within the invoked CLI command.\n } else {\n ui.error(realError.message);\n }\n\n const argv = this.getArgvService.execute();\n if (argv.showStackTrace && realError.stack) {\n ui.emptyLine();\n ui.debug(\"Stack trace:\");\n ui.text(realError.stack);\n }\n\n if (error instanceof GracefulError) {\n ui.emptyLine();\n ui.text(bgYellow(bold(\"💡 How can I resolve this?\")));\n ui.text(error.message);\n }\n\n process.exit(1);\n });\n\n const commands = this.commandsRegistryService.execute();\n\n for (const command of commands) {\n const {\n name,\n description,\n params = [],\n options = [],\n handler\n } = await command.execute();\n\n let yargsCommand = name;\n const paramVersionExists = params.some(p => {\n return p.name === \"version\";\n });\n if (paramVersionExists) {\n ui.error(\n `The command \"${name}\" cannot have a parameter named \"version\" as it conflicts with the global --version option.`\n );\n process.exit();\n }\n\n if (params.length > 0) {\n yargsCommand +=\n \" \" +\n params\n .map(param => {\n const paramName = param.array ? `${param.name}..` : param.name;\n return param.required ? `<${paramName}>` : `[${paramName}]`;\n })\n .join(\" \");\n }\n\n yargsRunner.command(\n yargsCommand,\n description,\n yargs => {\n params.forEach((param: CliCommandFactory.ParamDefinition<unknown>) => {\n const { name, required, validation, array, ...rest } = param;\n\n const yargsParam = yargs.positional(name, {\n ...rest,\n ...(array && { array: true }),\n demandOption: required\n });\n\n if (validation) {\n yargsParam.check(validation);\n }\n });\n\n options.forEach((option: CliCommandFactory.OptionDefinition<unknown>) => {\n const { name, required, validation, ...rest } = option;\n\n const yargsOption = yargs.option(name, {\n ...rest,\n demandOption: required\n });\n\n if (option.group) {\n yargsOption.group(option.name, option.group);\n }\n\n if (validation) {\n yargsOption.check(validation);\n }\n });\n },\n handler\n );\n }\n\n yargsRunner.help(true);\n yargsRunner.version(projectSdk.getProjectVersion());\n this.yargsRunner = yargsRunner;\n return this.yargsRunner;\n }\n}\n\nexport const getCliRunnerService = createImplementation({\n abstraction: GetCliRunnerService,\n implementation: DefaultGetCliRunnerService,\n dependencies: [\n CommandsRegistryService,\n GlobalOptionsRegistryService,\n UiService,\n GetProjectSdkService,\n GetArgvService\n ]\n});\n"],"names":["blue","bgYellow","bold","chalk","DefaultGetCliRunnerService","commandsRegistryService","globalOptionsRegistryService","uiService","getProjectSdkService","getArgvService","ui","projectSdk","yargsRunner","yargs","globalOptions","globalOption","name","config","invalidParamsMessage","error","process","args","v","logger","realError","ManuallyReportedError","argv","GracefulError","commands","command","description","params","options","handler","yargsCommand","paramVersionExists","p","param","paramName","required","validation","array","rest","yargsParam","option","yargsOption","getCliRunnerService","createImplementation","GetCliRunnerService","CommandsRegistryService","GlobalOptionsRegistryService","UiService","GetProjectSdkService","GetArgvService"],"mappings":";;;;;;AAgBA,MAAM,EAAEA,IAAI,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGC;AAE1B,MAAMC;IACT,YACqBC,uBAA0D,EAC1DC,4BAAoE,EACpEC,SAA8B,EAC9BC,oBAAoD,EACpDC,cAAwC,CAC3D;aALmBJ,uBAAuB,GAAvBA;aACAC,4BAA4B,GAA5BA;aACAC,SAAS,GAATA;aACAC,oBAAoB,GAApBA;aACAC,cAAc,GAAdA;aAGb,WAAW,GAAgB;IAFhC;IAIH,MAAM,UAAU;QACZ,IAAI,IAAI,CAAC,WAAW,EAChB,OAAO,IAAI,CAAC,WAAW;QAG3B,MAAMC,KAAK,IAAI,CAAC,SAAS;QACzB,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,MAAMC,cAAcC,cACf,KAAK,CAAC,iCACN,IAAI,CAAC,OACL,aAAa,CAAC,GACd,iBAAiB,GACjB,UAAU,CAAC,UACX,QAAQ,CACL,CAAC,kDAAkD,EAAEb,KACjD,+BACF,CAAC,CAAC,EAEP,QAAQ,CAAC,CAAC,oBAAoB,EAAEA,KAAK,uCAAuC,CAAC,CAAC;QAGnF,MAAMc,gBAAgB,IAAI,CAAC,4BAA4B,CAAC,OAAO;QAC/D,KAAK,MAAMC,gBAAgBD,cAAe;YACtC,MAAM,EAAEE,IAAI,EAAEC,MAAM,EAAE,GAAG,MAAMF,aAAa,OAAO;YACnDH,YAAY,MAAM,CAACI,MAAM;gBACrB,MAAMC,OAAO,IAAI;gBACjB,SAASA,OAAO,OAAO;gBACvB,MAAMA,OAAO,WAAW;gBACxB,OAAOA,OAAO,KAAK;gBACnB,SAASA,OAAO,OAAO;gBACvB,QAAQ;YACZ;QACJ;QAEAL,YAAY,IAAI,CAAC,CAACM,sBAAsBC;YACpC,IAAID,sBAAsB;gBACtB,IAAI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H;oBAClB;oBAEA,IAAIK,OAAO,KAAK,EACZC,YAAY,KAAK,CAACD,OAAO,IAAI,EAAEA,OAAO,KAAK;oBAG/C,IAAIJ,YACAK,YAAY,KAAK,CAACL;gBAE1B;YACJ,GACAP;QAER;QAEArB,YAAY,IAAI,CAAC;QACjBA,YAAY,OAAO,CAACD,WAAW,iBAAiB;QAChD,IAAI,CAAC,WAAW,GAAGC;QACnB,OAAO,IAAI,CAAC,WAAW;IAC3B;AACJ;AAEO,MAAMkC,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgB5C;IAChB,cAAc;QACV6C;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
1
|
+
{"version":3,"file":"services/GetCliRunnerService/GetCliRunnerService.js","sources":["../../../src/services/GetCliRunnerService/GetCliRunnerService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n CliCommandFactory,\n CommandsRegistryService,\n GetArgvService,\n GetCliRunnerService,\n GlobalOptionsRegistryService,\n GetProjectSdkService,\n UiService\n} from \"~/abstractions/index.js\";\nimport yargs from \"yargs/yargs\";\nimport chalk from \"chalk\";\nimport { Argv } from \"yargs\";\nimport { GracefulError } from \"@webiny/project\";\nimport { ManuallyReportedError } from \"~/utils/ManuallyReportedError.js\";\n\nconst { blue, bgYellow, bold } = chalk;\n\nexport class DefaultGetCliRunnerService implements GetCliRunnerService.Interface {\n constructor(\n private readonly commandsRegistryService: CommandsRegistryService.Interface,\n private readonly globalOptionsRegistryService: GlobalOptionsRegistryService.Interface,\n private readonly uiService: UiService.Interface,\n private readonly getProjectSdkService: GetProjectSdkService.Interface,\n private readonly getArgvService: GetArgvService.Interface\n ) {}\n\n private yargsRunner: Argv | null = null;\n\n async execute() {\n if (this.yargsRunner) {\n return this.yargsRunner;\n }\n\n const ui = this.uiService;\n const projectSdk = await this.getProjectSdkService.execute();\n\n const yargsRunner = yargs()\n .usage(\"Usage: $0 <command> [options]\")\n .help(false)\n .demandCommand(1)\n .recommendCommands()\n .scriptName(\"webiny\")\n .epilogue(\n `To find more information, docs and tutorials, see ${blue(\n \"https://www.webiny.com/docs\"\n )}.`\n )\n .epilogue(`Want to contribute? ${blue(\"https://github.com/webiny/webiny-js\")}.`);\n\n // Register global options.\n const globalOptions = this.globalOptionsRegistryService.execute();\n for (const globalOption of globalOptions) {\n const { name, config } = await globalOption.execute();\n yargsRunner.option(name, {\n type: config.type,\n default: config.default,\n desc: config.description,\n alias: config.alias,\n choices: config.choices,\n global: true\n });\n }\n\n yargsRunner.fail((invalidParamsMessage, error) => {\n if (invalidParamsMessage) {\n if (invalidParamsMessage.includes(\"Not enough non-option arguments\")) {\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Some non-optional arguments are missing. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n if (invalidParamsMessage.includes(\"Missing required argument\")) {\n const args = invalidParamsMessage\n .split(\":\")[1]\n .split(\",\")\n .map(v => v.trim());\n\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Missing required argument(s): ${args.join(\n \", \"\n )}. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n ui.emptyLine();\n ui.error(invalidParamsMessage);\n\n process.exit(1);\n }\n\n const logger = projectSdk.getLogger();\n logger.error({ err: error }, \"CLI command execution failed.\");\n\n const realError = (error.cause as Error) || error;\n\n if (realError instanceof ManuallyReportedError) {\n // Do nothing as the error reporting has already been\n // handled within the invoked CLI command.\n } else {\n ui.error(realError.message);\n }\n\n const argv = this.getArgvService.execute();\n if (argv.showStackTrace && realError.stack) {\n ui.emptyLine();\n ui.debug(\"Stack trace:\");\n ui.text(realError.stack);\n }\n\n if (error instanceof GracefulError) {\n ui.emptyLine();\n ui.text(bgYellow(bold(\"💡 How can I resolve this?\")));\n ui.text(error.message);\n }\n\n process.exit(1);\n });\n\n const commands = this.commandsRegistryService.execute();\n\n for (const command of commands) {\n const {\n name,\n description,\n params = [],\n options = [],\n handler\n } = await command.execute();\n\n let yargsCommand = name;\n const paramVersionExists = params.some(p => {\n return p.name === \"version\";\n });\n if (paramVersionExists) {\n ui.error(\n `The command \"${name}\" cannot have a parameter named \"version\" as it conflicts with the global --version option.`\n );\n process.exit();\n }\n\n if (params.length > 0) {\n yargsCommand +=\n \" \" +\n params\n .map(param => {\n const paramName = param.array ? `${param.name}..` : param.name;\n return param.required ? `<${paramName}>` : `[${paramName}]`;\n })\n .join(\" \");\n }\n\n yargsRunner.command(\n yargsCommand,\n description,\n yargs => {\n params.forEach((param: CliCommandFactory.ParamDefinition<unknown>) => {\n const { name, required, validation, array, ...rest } = param;\n\n const yargsParam = yargs.positional(name, {\n ...rest,\n ...(array && { array: true }),\n demandOption: required\n });\n\n if (validation) {\n yargsParam.check(validation);\n }\n });\n\n options.forEach((option: CliCommandFactory.OptionDefinition<unknown>) => {\n const { name, required, validation, ...rest } = option;\n\n const yargsOption = yargs.option(name, {\n ...rest,\n demandOption: required\n });\n\n if (option.group) {\n yargsOption.group(option.name, option.group);\n }\n\n if (validation) {\n yargsOption.check(validation);\n }\n });\n },\n handler\n );\n }\n\n yargsRunner.help(true);\n yargsRunner.version(projectSdk.getProjectVersion());\n this.yargsRunner = yargsRunner;\n return this.yargsRunner;\n }\n}\n\nexport const getCliRunnerService = createImplementation({\n abstraction: GetCliRunnerService,\n implementation: DefaultGetCliRunnerService,\n dependencies: [\n CommandsRegistryService,\n GlobalOptionsRegistryService,\n UiService,\n GetProjectSdkService,\n GetArgvService\n ]\n});\n"],"names":["blue","bgYellow","bold","chalk","DefaultGetCliRunnerService","commandsRegistryService","globalOptionsRegistryService","uiService","getProjectSdkService","getArgvService","ui","projectSdk","yargsRunner","yargs","globalOptions","globalOption","name","config","invalidParamsMessage","error","process","args","v","logger","realError","ManuallyReportedError","argv","GracefulError","commands","command","description","params","options","handler","yargsCommand","paramVersionExists","p","param","paramName","required","validation","array","rest","yargsParam","option","yargsOption","getCliRunnerService","createImplementation","GetCliRunnerService","CommandsRegistryService","GlobalOptionsRegistryService","UiService","GetProjectSdkService","GetArgvService"],"mappings":";;;;;;AAgBA,MAAM,EAAEA,IAAI,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGC;AAE1B,MAAMC;IACT,YACqBC,uBAA0D,EAC1DC,4BAAoE,EACpEC,SAA8B,EAC9BC,oBAAoD,EACpDC,cAAwC,CAC3D;aALmBJ,uBAAuB,GAAvBA;aACAC,4BAA4B,GAA5BA;aACAC,SAAS,GAATA;aACAC,oBAAoB,GAApBA;aACAC,cAAc,GAAdA;aAGb,WAAW,GAAgB;IAF/B;IAIJ,MAAM,UAAU;QACZ,IAAI,IAAI,CAAC,WAAW,EAChB,OAAO,IAAI,CAAC,WAAW;QAG3B,MAAMC,KAAK,IAAI,CAAC,SAAS;QACzB,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,MAAMC,cAAcC,cACf,KAAK,CAAC,iCACN,IAAI,CAAC,OACL,aAAa,CAAC,GACd,iBAAiB,GACjB,UAAU,CAAC,UACX,QAAQ,CACL,CAAC,kDAAkD,EAAEb,KACjD,+BACF,CAAC,CAAC,EAEP,QAAQ,CAAC,CAAC,oBAAoB,EAAEA,KAAK,uCAAuC,CAAC,CAAC;QAGnF,MAAMc,gBAAgB,IAAI,CAAC,4BAA4B,CAAC,OAAO;QAC/D,KAAK,MAAMC,gBAAgBD,cAAe;YACtC,MAAM,EAAEE,IAAI,EAAEC,MAAM,EAAE,GAAG,MAAMF,aAAa,OAAO;YACnDH,YAAY,MAAM,CAACI,MAAM;gBACrB,MAAMC,OAAO,IAAI;gBACjB,SAASA,OAAO,OAAO;gBACvB,MAAMA,OAAO,WAAW;gBACxB,OAAOA,OAAO,KAAK;gBACnB,SAASA,OAAO,OAAO;gBACvB,QAAQ;YACZ;QACJ;QAEAL,YAAY,IAAI,CAAC,CAACM,sBAAsBC;YACpC,IAA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