@powerplatformdevops/cli 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,50 @@
1
+ Copyright (c) Scott Durow, http://github.com/scottdurow/sparklexrm
2
+ Copyright (c) 2019 Andrew https://github.com/abvogel/Microsoft.Xrm.DevOps.Data/
3
+ Copyright (c) 2017 Delegate A/S https://github.com/delegateas/
4
+ Copyright (c) 2014-2016 Jordi Montana https://github.com/jordimontana82/fake-xrm-easy
5
+
6
+ Copyright (c) 2020 Dylan Haskins & Eugene van Staden
7
+
8
+ MIT License with Commons Clause Restriction
9
+
10
+ The Software is provided to you by the Licensor under the License, as
11
+ defined below, subject to the following condition.
12
+
13
+ Without limiting other conditions in the License, the grant of rights
14
+ under the License will not include, and the License does not grant you,
15
+ the right to Sell the Software.
16
+
17
+ For purposes of the foregoing, "Sell" means practicing any or all of
18
+ the rights granted to you under the License to provide to third parties,
19
+ for a fee or other consideration (including without limitation fees for
20
+ hosting or consulting/support services related to the Software), a
21
+ product or service whose value derives, entirely or substantially, from
22
+ the functionality of the Software. Any license notice or attribution
23
+ required by the License must also include this Commons Clause License
24
+ Condition notice.
25
+
26
+ Licensor: Dylan Haskins & Eugene van Staden
27
+ Software: Microsoft.PowerPlatform.DevOps
28
+ License: MIT License
29
+
30
+ The MIT License terms below are modified by the Commons Clause condition above.
31
+
32
+ MIT License
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining a copy
35
+ of this software and associated documentation files (the "Software"), to deal
36
+ in the Software without restriction, including without limitation the rights
37
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
38
+ copies of the Software, and to permit persons to whom the Software is
39
+ furnished to do so, subject to the following conditions:
40
+
41
+ The above copyright notice and this permission notice shall be included in all
42
+ copies or substantial portions of the Software.
43
+
44
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
47
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
49
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
50
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ ![Power Platform DevOps Studio](https://raw.githubusercontent.com/dylanhaskins/PowerPlatform-DevOpsStudio-Releases/main/assets/banner.png)
2
+
3
+ [![npm](https://badgen.net/npm/v/@powerplatformdevops/cli/beta)](https://www.npmjs.com/package/@powerplatformdevops/cli)
4
+ [![Downloads](https://badgen.net/npm/dt/@powerplatformdevops/cli)](https://www.npmjs.com/package/@powerplatformdevops/cli)
5
+ ![license](https://badgen.net/badge/license/MIT%20+%20Commons%20Clause/blue)
6
+
7
+ ## Overview
8
+
9
+ Cross-platform deployment runner for Power Platform solutions, from
10
+ [Power Platform DevOps Studio](https://github.com/dylanhaskins/PowerPlatform-DevOpsStudio-Releases).
11
+
12
+
13
+ Plans and executes solution deployments against a Dataverse environment: resolves installed
14
+ versions, decides per solution whether to install, upgrade or skip, packs and imports, runs
15
+ pre/post action scripts, and streams structured progress events for a CI log or a UI to fold.
16
+
17
+ > **Beta.** The command surface and the event schema may still change between beta releases.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install -g @powerplatformdevops/cli@beta
23
+ ```
24
+
25
+ Requires Node.js 20 or later. The [Power Platform CLI](https://aka.ms/pac/cli) (`pac`) must be on
26
+ `PATH` — it is used for pack, import, upgrade and data operations. Version checks and flow
27
+ activation go through the Dataverse Web API directly and need no `pac`.
28
+
29
+ ## Usage
30
+
31
+ ```bash
32
+ # Read-only: report what a deployment would do, change nothing
33
+ ppdevops plan --project . --environment MyEnvironment
34
+
35
+ # Execute the deployment
36
+ ppdevops deploy --project . --environment MyEnvironment --solutions MySolution
37
+ ```
38
+
39
+ `--project` is the repository root holding `deployPackages.json`; `--environment` is a name from
40
+ `Environments.json`, not a URL.
41
+
42
+ ### Authentication
43
+
44
+ Service-principal credentials are read from the environment:
45
+
46
+ | Variable | Purpose |
47
+ | --- | --- |
48
+ | `PPDEVOPS_CLIENT_ID` | Application (client) ID |
49
+ | `PPDEVOPS_CLIENT_SECRET` | Client secret |
50
+ | `PPDEVOPS_TENANT_ID` | Directory (tenant) ID |
51
+
52
+ Equivalent `--client-id` / `--client-secret` / `--tenant-id` flags exist, but prefer the environment
53
+ variables: arguments are visible in process listings and shell history.
54
+
55
+ ### Structured output
56
+
57
+ `--json` emits Run Event Schema v1 as NDJSON. Prefer writing it to a file rather than parsing
58
+ stdout:
59
+
60
+ ```bash
61
+ PPDEVOPS_EVENTS_FILE=run-events.ndjson ppdevops deploy ... --json
62
+ ```
63
+
64
+ The events file exists because Windows ConPTY reflows long lines, which corrupts NDJSON on stdout.
65
+ The human-readable log stays on stdout either way.
66
+
67
+ ## Version
68
+
69
+ `ppdevops --version` reports the version, the commit it was built from, and the build timestamp, so
70
+ a CI log identifies the exact build that ran.
71
+
72
+ ## Licence
73
+
74
+ MIT with the [Commons Clause](https://commonsclause.com/) restriction — you may use, modify and
75
+ redistribute it, but not sell it or sell a service whose value derives substantially from it. See
76
+ the bundled `LICENSE` for the full terms.
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@powerplatformdevops/cli",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "Power Platform DevOps Studio – cross-platform deployment CLI",
5
+ "keywords": [
6
+ "power-platform",
7
+ "devops",
8
+ "dataverse",
9
+ "pac",
10
+ "deployment"
11
+ ],
12
+ "license": "SEE LICENSE IN LICENSE",
13
+ "bin": {
14
+ "ppdevops": "ppdevops-cli.js"
15
+ },
16
+ "files": [
17
+ "ppdevops-cli.js"
18
+ ],
19
+ "engines": {
20
+ "node": ">=20"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "ppdevops": {
26
+ "upstreamCommit": "3c2c2f0",
27
+ "builtOn": "2026-09-15T02:32:15Z"
28
+ }
29
+ }
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var _r=Object.create;var Si=Object.defineProperty;var xr=Object.getOwnPropertyDescriptor;var yr=Object.getOwnPropertyNames;var Sr=Object.getPrototypeOf,Ar=Object.prototype.hasOwnProperty;var Q=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var Cr=(e,n,i,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of yr(n))!Ar.call(e,r)&&r!==i&&Si(e,r,{get:()=>n[r],enumerable:!(t=xr(n,r))||t.enumerable});return e};var S=(e,n,i)=>(i=e!=null?_r(Sr(e)):{},Cr(n||!e||!e.__esModule?Si(i,"default",{value:e,enumerable:!0}):i,e));var $e=Q(yn=>{var He=class extends Error{constructor(n,i,t){super(t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=i,this.exitCode=n,this.nestedError=void 0}},xn=class extends He{constructor(n){super(1,"commander.invalidArgument",n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};yn.CommanderError=He;yn.InvalidArgumentError=xn});var Ue=Q(An=>{var{InvalidArgumentError:wr}=$e(),Sn=class{constructor(n,i){switch(this.description=i||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,n[0]){case"<":this.required=!0,this._name=n.slice(1,-1);break;case"[":this.required=!1,this._name=n.slice(1,-1);break;default:this.required=!0,this._name=n;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(n,i){return i===this.defaultValue||!Array.isArray(i)?[n]:i.concat(n)}default(n,i){return this.defaultValue=n,this.defaultValueDescription=i,this}argParser(n){return this.parseArg=n,this}choices(n){return this.argChoices=n.slice(),this.parseArg=(i,t)=>{if(!this.argChoices.includes(i))throw new wr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(i,t):i},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Er(e){let n=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+n+">":"["+n+"]"}An.Argument=Sn;An.humanReadableArgName=Er});var wn=Q(Ai=>{var{humanReadableArgName:br}=Ue(),Cn=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(n){let i=n.commands.filter(r=>!r._hidden),t=n._getHelpCommand();return t&&!t._hidden&&i.push(t),this.sortSubcommands&&i.sort((r,o)=>r.name().localeCompare(o.name())),i}compareOptions(n,i){let t=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");return t(n).localeCompare(t(i))}visibleOptions(n){let i=n.options.filter(r=>!r.hidden),t=n._getHelpOption();if(t&&!t.hidden){let r=t.short&&n._findOption(t.short),o=t.long&&n._findOption(t.long);!r&&!o?i.push(t):t.long&&!o?i.push(n.createOption(t.long,t.description)):t.short&&!r&&i.push(n.createOption(t.short,t.description))}return this.sortOptions&&i.sort(this.compareOptions),i}visibleGlobalOptions(n){if(!this.showGlobalOptions)return[];let i=[];for(let t=n.parent;t;t=t.parent){let r=t.options.filter(o=>!o.hidden);i.push(...r)}return this.sortOptions&&i.sort(this.compareOptions),i}visibleArguments(n){return n._argsDescription&&n.registeredArguments.forEach(i=>{i.description=i.description||n._argsDescription[i.name()]||""}),n.registeredArguments.find(i=>i.description)?n.registeredArguments:[]}subcommandTerm(n){let i=n.registeredArguments.map(t=>br(t)).join(" ");return n._name+(n._aliases[0]?"|"+n._aliases[0]:"")+(n.options.length?" [options]":"")+(i?" "+i:"")}optionTerm(n){return n.flags}argumentTerm(n){return n.name()}longestSubcommandTermLength(n,i){return i.visibleCommands(n).reduce((t,r)=>Math.max(t,i.subcommandTerm(r).length),0)}longestOptionTermLength(n,i){return i.visibleOptions(n).reduce((t,r)=>Math.max(t,i.optionTerm(r).length),0)}longestGlobalOptionTermLength(n,i){return i.visibleGlobalOptions(n).reduce((t,r)=>Math.max(t,i.optionTerm(r).length),0)}longestArgumentTermLength(n,i){return i.visibleArguments(n).reduce((t,r)=>Math.max(t,i.argumentTerm(r).length),0)}commandUsage(n){let i=n._name;n._aliases[0]&&(i=i+"|"+n._aliases[0]);let t="";for(let r=n.parent;r;r=r.parent)t=r.name()+" "+t;return t+i+" "+n.usage()}commandDescription(n){return n.description()}subcommandDescription(n){return n.summary()||n.description()}optionDescription(n){let i=[];return n.argChoices&&i.push(`choices: ${n.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),n.defaultValue!==void 0&&(n.required||n.optional||n.isBoolean()&&typeof n.defaultValue=="boolean")&&i.push(`default: ${n.defaultValueDescription||JSON.stringify(n.defaultValue)}`),n.presetArg!==void 0&&n.optional&&i.push(`preset: ${JSON.stringify(n.presetArg)}`),n.envVar!==void 0&&i.push(`env: ${n.envVar}`),i.length>0?`${n.description} (${i.join(", ")})`:n.description}argumentDescription(n){let i=[];if(n.argChoices&&i.push(`choices: ${n.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),n.defaultValue!==void 0&&i.push(`default: ${n.defaultValueDescription||JSON.stringify(n.defaultValue)}`),i.length>0){let t=`(${i.join(", ")})`;return n.description?`${n.description} ${t}`:t}return n.description}formatHelp(n,i){let t=i.padWidth(n,i),r=i.helpWidth||80,o=2,s=2;function a(h,_){if(_){let y=`${h.padEnd(t+s)}${_}`;return i.wrap(y,r-o,t+s)}return h}function l(h){return h.join(`
3
+ `).replace(/^/gm," ".repeat(o))}let u=[`Usage: ${i.commandUsage(n)}`,""],c=i.commandDescription(n);c.length>0&&(u=u.concat([i.wrap(c,r,0),""]));let p=i.visibleArguments(n).map(h=>a(i.argumentTerm(h),i.argumentDescription(h)));p.length>0&&(u=u.concat(["Arguments:",l(p),""]));let f=i.visibleOptions(n).map(h=>a(i.optionTerm(h),i.optionDescription(h)));if(f.length>0&&(u=u.concat(["Options:",l(f),""])),this.showGlobalOptions){let h=i.visibleGlobalOptions(n).map(_=>a(i.optionTerm(_),i.optionDescription(_)));h.length>0&&(u=u.concat(["Global Options:",l(h),""]))}let d=i.visibleCommands(n).map(h=>a(i.subcommandTerm(h),i.subcommandDescription(h)));return d.length>0&&(u=u.concat(["Commands:",l(d),""])),u.join(`
4
+ `)}padWidth(n,i){return Math.max(i.longestOptionTermLength(n,i),i.longestGlobalOptionTermLength(n,i),i.longestSubcommandTermLength(n,i),i.longestArgumentTermLength(n,i))}wrap(n,i,t,r=40){let o=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",s=new RegExp(`[\\n][${o}]+`);if(n.match(s))return n;let a=i-t;if(a<r)return n;let l=n.slice(0,t),u=n.slice(t).replace(`\r
5
+ `,`
6
+ `),c=" ".repeat(t),f="\\s\u200B",d=new RegExp(`
7
+ |.{1,${a-1}}([${f}]|$)|[^${f}]+?([${f}]|$)`,"g"),h=u.match(d)||[];return l+h.map((_,y)=>_===`
8
+ `?"":(y>0?c:"")+_.trimEnd()).join(`
9
+ `)}};Ai.Help=Cn});var kn=Q(On=>{var{InvalidArgumentError:Or}=$e(),En=class{constructor(n,i){this.flags=n,this.description=i||"",this.required=n.includes("<"),this.optional=n.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(n),this.mandatory=!1;let t=$r(n);this.short=t.shortFlag,this.long=t.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(n,i){return this.defaultValue=n,this.defaultValueDescription=i,this}preset(n){return this.presetArg=n,this}conflicts(n){return this.conflictsWith=this.conflictsWith.concat(n),this}implies(n){let i=n;return typeof n=="string"&&(i={[n]:!0}),this.implied=Object.assign(this.implied||{},i),this}env(n){return this.envVar=n,this}argParser(n){return this.parseArg=n,this}makeOptionMandatory(n=!0){return this.mandatory=!!n,this}hideHelp(n=!0){return this.hidden=!!n,this}_concatValue(n,i){return i===this.defaultValue||!Array.isArray(i)?[n]:i.concat(n)}choices(n){return this.argChoices=n.slice(),this.parseArg=(i,t)=>{if(!this.argChoices.includes(i))throw new Or(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(i,t):i},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return kr(this.name().replace(/^no-/,""))}is(n){return this.short===n||this.long===n}isBoolean(){return!this.required&&!this.optional&&!this.negate}},bn=class{constructor(n){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,n.forEach(i=>{i.negate?this.negativeOptions.set(i.attributeName(),i):this.positiveOptions.set(i.attributeName(),i)}),this.negativeOptions.forEach((i,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(n,i){let t=i.attributeName();if(!this.dualOptions.has(t))return!0;let r=this.negativeOptions.get(t).presetArg,o=r!==void 0?r:!1;return i.negate===(o===n)}};function kr(e){return e.split("-").reduce((n,i)=>n+i[0].toUpperCase()+i.slice(1))}function $r(e){let n,i,t=e.split(/[ |,]+/);return t.length>1&&!/^[[<]/.test(t[1])&&(n=t.shift()),i=t.shift(),!n&&/^-[^-]$/.test(i)&&(n=i,i=void 0),{shortFlag:n,longFlag:i}}On.Option=En;On.DualOptions=bn});var wi=Q(Ci=>{function Pr(e,n){if(Math.abs(e.length-n.length)>3)return Math.max(e.length,n.length);let i=[];for(let t=0;t<=e.length;t++)i[t]=[t];for(let t=0;t<=n.length;t++)i[0][t]=t;for(let t=1;t<=n.length;t++)for(let r=1;r<=e.length;r++){let o=1;e[r-1]===n[t-1]?o=0:o=1,i[r][t]=Math.min(i[r-1][t]+1,i[r][t-1]+1,i[r-1][t-1]+o),r>1&&t>1&&e[r-1]===n[t-2]&&e[r-2]===n[t-1]&&(i[r][t]=Math.min(i[r][t],i[r-2][t-2]+1))}return i[e.length][n.length]}function Ir(e,n){if(!n||n.length===0)return"";n=Array.from(new Set(n));let i=e.startsWith("--");i&&(e=e.slice(2),n=n.map(s=>s.slice(2)));let t=[],r=3,o=.4;return n.forEach(s=>{if(s.length<=1)return;let a=Pr(e,s),l=Math.max(e.length,s.length);(l-a)/l>o&&(a<r?(r=a,t=[s]):a===r&&t.push(s))}),t.sort((s,a)=>s.localeCompare(a)),i&&(t=t.map(s=>`--${s}`)),t.length>1?`
10
+ (Did you mean one of ${t.join(", ")}?)`:t.length===1?`
11
+ (Did you mean ${t[0]}?)`:""}Ci.suggestSimilar=Ir});var $i=Q(ki=>{var Tr=require("node:events").EventEmitter,$n=require("node:child_process"),G=require("node:path"),Pn=require("node:fs"),E=require("node:process"),{Argument:Fr,humanReadableArgName:Nr}=Ue(),{CommanderError:In}=$e(),{Help:Dr}=wn(),{Option:Ei,DualOptions:Lr}=kn(),{suggestSimilar:bi}=wi(),Tn=class e extends Tr{constructor(n){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=n||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:i=>E.stdout.write(i),writeErr:i=>E.stderr.write(i),getOutHelpWidth:()=>E.stdout.isTTY?E.stdout.columns:void 0,getErrHelpWidth:()=>E.stderr.isTTY?E.stderr.columns:void 0,outputError:(i,t)=>t(i)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(n){return this._outputConfiguration=n._outputConfiguration,this._helpOption=n._helpOption,this._helpCommand=n._helpCommand,this._helpConfiguration=n._helpConfiguration,this._exitCallback=n._exitCallback,this._storeOptionsAsProperties=n._storeOptionsAsProperties,this._combineFlagAndOptionalValue=n._combineFlagAndOptionalValue,this._allowExcessArguments=n._allowExcessArguments,this._enablePositionalOptions=n._enablePositionalOptions,this._showHelpAfterError=n._showHelpAfterError,this._showSuggestionAfterError=n._showSuggestionAfterError,this}_getCommandAndAncestors(){let n=[];for(let i=this;i;i=i.parent)n.push(i);return n}command(n,i,t){let r=i,o=t;typeof r=="object"&&r!==null&&(o=r,r=null),o=o||{};let[,s,a]=n.match(/([^ ]+) *(.*)/),l=this.createCommand(s);return r&&(l.description(r),l._executableHandler=!0),o.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(o.noHelp||o.hidden),l._executableFile=o.executableFile||null,a&&l.arguments(a),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),r?this:l}createCommand(n){return new e(n)}createHelp(){return Object.assign(new Dr,this.configureHelp())}configureHelp(n){return n===void 0?this._helpConfiguration:(this._helpConfiguration=n,this)}configureOutput(n){return n===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,n),this)}showHelpAfterError(n=!0){return typeof n!="string"&&(n=!!n),this._showHelpAfterError=n,this}showSuggestionAfterError(n=!0){return this._showSuggestionAfterError=!!n,this}addCommand(n,i){if(!n._name)throw new Error(`Command passed to .addCommand() must have a name
12
+ - specify the name in Command constructor or using .name()`);return i=i||{},i.isDefault&&(this._defaultCommandName=n._name),(i.noHelp||i.hidden)&&(n._hidden=!0),this._registerCommand(n),n.parent=this,n._checkForBrokenPassThrough(),this}createArgument(n,i){return new Fr(n,i)}argument(n,i,t,r){let o=this.createArgument(n,i);return typeof t=="function"?o.default(r).argParser(t):o.default(t),this.addArgument(o),this}arguments(n){return n.trim().split(/ +/).forEach(i=>{this.argument(i)}),this}addArgument(n){let i=this.registeredArguments.slice(-1)[0];if(i&&i.variadic)throw new Error(`only the last argument can be variadic '${i.name()}'`);if(n.required&&n.defaultValue!==void 0&&n.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${n.name()}'`);return this.registeredArguments.push(n),this}helpCommand(n,i){if(typeof n=="boolean")return this._addImplicitHelpCommand=n,this;n=n??"help [command]";let[,t,r]=n.match(/([^ ]+) *(.*)/),o=i??"display help for command",s=this.createCommand(t);return s.helpOption(!1),r&&s.arguments(r),o&&s.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=s,this}addHelpCommand(n,i){return typeof n!="object"?(this.helpCommand(n,i),this):(this._addImplicitHelpCommand=!0,this._helpCommand=n,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(n,i){let t=["preSubcommand","preAction","postAction"];if(!t.includes(n))throw new Error(`Unexpected value for event passed to hook : '${n}'.
13
+ Expecting one of '${t.join("', '")}'`);return this._lifeCycleHooks[n]?this._lifeCycleHooks[n].push(i):this._lifeCycleHooks[n]=[i],this}exitOverride(n){return n?this._exitCallback=n:this._exitCallback=i=>{if(i.code!=="commander.executeSubCommandAsync")throw i},this}_exit(n,i,t){this._exitCallback&&this._exitCallback(new In(n,i,t)),E.exit(n)}action(n){let i=t=>{let r=this.registeredArguments.length,o=t.slice(0,r);return this._storeOptionsAsProperties?o[r]=this:o[r]=this.opts(),o.push(this),n.apply(this,o)};return this._actionHandler=i,this}createOption(n,i){return new Ei(n,i)}_callParseArg(n,i,t,r){try{return n.parseArg(i,t)}catch(o){if(o.code==="commander.invalidArgument"){let s=`${r} ${o.message}`;this.error(s,{exitCode:o.exitCode,code:o.code})}throw o}}_registerOption(n){let i=n.short&&this._findOption(n.short)||n.long&&this._findOption(n.long);if(i){let t=n.long&&this._findOption(n.long)?n.long:n.short;throw new Error(`Cannot add option '${n.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${t}'
14
+ - already used by option '${i.flags}'`)}this.options.push(n)}_registerCommand(n){let i=r=>[r.name()].concat(r.aliases()),t=i(n).find(r=>this._findCommand(r));if(t){let r=i(this._findCommand(t)).join("|"),o=i(n).join("|");throw new Error(`cannot add command '${o}' as already have command '${r}'`)}this.commands.push(n)}addOption(n){this._registerOption(n);let i=n.name(),t=n.attributeName();if(n.negate){let o=n.long.replace(/^--no-/,"--");this._findOption(o)||this.setOptionValueWithSource(t,n.defaultValue===void 0?!0:n.defaultValue,"default")}else n.defaultValue!==void 0&&this.setOptionValueWithSource(t,n.defaultValue,"default");let r=(o,s,a)=>{o==null&&n.presetArg!==void 0&&(o=n.presetArg);let l=this.getOptionValue(t);o!==null&&n.parseArg?o=this._callParseArg(n,o,l,s):o!==null&&n.variadic&&(o=n._concatValue(o,l)),o==null&&(n.negate?o=!1:n.isBoolean()||n.optional?o=!0:o=""),this.setOptionValueWithSource(t,o,a)};return this.on("option:"+i,o=>{let s=`error: option '${n.flags}' argument '${o}' is invalid.`;r(o,s,"cli")}),n.envVar&&this.on("optionEnv:"+i,o=>{let s=`error: option '${n.flags}' value '${o}' from env '${n.envVar}' is invalid.`;r(o,s,"env")}),this}_optionEx(n,i,t,r,o){if(typeof i=="object"&&i instanceof Ei)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(i,t);if(s.makeOptionMandatory(!!n.mandatory),typeof r=="function")s.default(o).argParser(r);else if(r instanceof RegExp){let a=r;r=(l,u)=>{let c=a.exec(l);return c?c[0]:u},s.default(o).argParser(r)}else s.default(r);return this.addOption(s)}option(n,i,t,r){return this._optionEx({},n,i,t,r)}requiredOption(n,i,t,r){return this._optionEx({mandatory:!0},n,i,t,r)}combineFlagAndOptionalValue(n=!0){return this._combineFlagAndOptionalValue=!!n,this}allowUnknownOption(n=!0){return this._allowUnknownOption=!!n,this}allowExcessArguments(n=!0){return this._allowExcessArguments=!!n,this}enablePositionalOptions(n=!0){return this._enablePositionalOptions=!!n,this}passThroughOptions(n=!0){return this._passThroughOptions=!!n,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(n=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!n,this}getOptionValue(n){return this._storeOptionsAsProperties?this[n]:this._optionValues[n]}setOptionValue(n,i){return this.setOptionValueWithSource(n,i,void 0)}setOptionValueWithSource(n,i,t){return this._storeOptionsAsProperties?this[n]=i:this._optionValues[n]=i,this._optionValueSources[n]=t,this}getOptionValueSource(n){return this._optionValueSources[n]}getOptionValueSourceWithGlobals(n){let i;return this._getCommandAndAncestors().forEach(t=>{t.getOptionValueSource(n)!==void 0&&(i=t.getOptionValueSource(n))}),i}_prepareUserArgs(n,i){if(n!==void 0&&!Array.isArray(n))throw new Error("first parameter to parse must be array or undefined");if(i=i||{},n===void 0&&i.from===void 0){E.versions?.electron&&(i.from="electron");let r=E.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(i.from="eval")}n===void 0&&(n=E.argv),this.rawArgs=n.slice();let t;switch(i.from){case void 0:case"node":this._scriptPath=n[1],t=n.slice(2);break;case"electron":E.defaultApp?(this._scriptPath=n[1],t=n.slice(2)):t=n.slice(1);break;case"user":t=n.slice(0);break;case"eval":t=n.slice(1);break;default:throw new Error(`unexpected parse option { from: '${i.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",t}parse(n,i){let t=this._prepareUserArgs(n,i);return this._parseCommand([],t),this}async parseAsync(n,i){let t=this._prepareUserArgs(n,i);return await this._parseCommand([],t),this}_executeSubCommand(n,i){i=i.slice();let t=!1,r=[".js",".ts",".tsx",".mjs",".cjs"];function o(c,p){let f=G.resolve(c,p);if(Pn.existsSync(f))return f;if(r.includes(G.extname(p)))return;let d=r.find(h=>Pn.existsSync(`${f}${h}`));if(d)return`${f}${d}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=n._executableFile||`${this._name}-${n._name}`,a=this._executableDir||"";if(this._scriptPath){let c;try{c=Pn.realpathSync(this._scriptPath)}catch{c=this._scriptPath}a=G.resolve(G.dirname(c),a)}if(a){let c=o(a,s);if(!c&&!n._executableFile&&this._scriptPath){let p=G.basename(this._scriptPath,G.extname(this._scriptPath));p!==this._name&&(c=o(a,`${p}-${n._name}`))}s=c||s}t=r.includes(G.extname(s));let l;E.platform!=="win32"?t?(i.unshift(s),i=Oi(E.execArgv).concat(i),l=$n.spawn(E.argv[0],i,{stdio:"inherit"})):l=$n.spawn(s,i,{stdio:"inherit"}):(i.unshift(s),i=Oi(E.execArgv).concat(i),l=$n.spawn(E.execPath,i,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(p=>{E.on(p,()=>{l.killed===!1&&l.exitCode===null&&l.kill(p)})});let u=this._exitCallback;l.on("close",c=>{c=c??1,u?u(new In(c,"commander.executeSubCommandAsync","(close)")):E.exit(c)}),l.on("error",c=>{if(c.code==="ENOENT"){let p=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",f=`'${s}' does not exist
15
+ - if '${n._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
16
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
17
+ - ${p}`;throw new Error(f)}else if(c.code==="EACCES")throw new Error(`'${s}' not executable`);if(!u)E.exit(1);else{let p=new In(1,"commander.executeSubCommandAsync","(error)");p.nestedError=c,u(p)}}),this.runningCommand=l}_dispatchSubcommand(n,i,t){let r=this._findCommand(n);r||this.help({error:!0});let o;return o=this._chainOrCallSubCommandHook(o,r,"preSubcommand"),o=this._chainOrCall(o,()=>{if(r._executableHandler)this._executeSubCommand(r,i.concat(t));else return r._parseCommand(i,t)}),o}_dispatchHelpCommand(n){n||this.help();let i=this._findCommand(n);return i&&!i._executableHandler&&i.help(),this._dispatchSubcommand(n,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((n,i)=>{n.required&&this.args[i]==null&&this.missingArgument(n.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let n=(t,r,o)=>{let s=r;if(r!==null&&t.parseArg){let a=`error: command-argument value '${r}' is invalid for argument '${t.name()}'.`;s=this._callParseArg(t,r,o,a)}return s};this._checkNumberOfArguments();let i=[];this.registeredArguments.forEach((t,r)=>{let o=t.defaultValue;t.variadic?r<this.args.length?(o=this.args.slice(r),t.parseArg&&(o=o.reduce((s,a)=>n(t,a,s),t.defaultValue))):o===void 0&&(o=[]):r<this.args.length&&(o=this.args[r],t.parseArg&&(o=n(t,o,t.defaultValue))),i[r]=o}),this.processedArgs=i}_chainOrCall(n,i){return n&&n.then&&typeof n.then=="function"?n.then(()=>i()):i()}_chainOrCallHooks(n,i){let t=n,r=[];return this._getCommandAndAncestors().reverse().filter(o=>o._lifeCycleHooks[i]!==void 0).forEach(o=>{o._lifeCycleHooks[i].forEach(s=>{r.push({hookedCommand:o,callback:s})})}),i==="postAction"&&r.reverse(),r.forEach(o=>{t=this._chainOrCall(t,()=>o.callback(o.hookedCommand,this))}),t}_chainOrCallSubCommandHook(n,i,t){let r=n;return this._lifeCycleHooks[t]!==void 0&&this._lifeCycleHooks[t].forEach(o=>{r=this._chainOrCall(r,()=>o(this,i))}),r}_parseCommand(n,i){let t=this.parseOptions(i);if(this._parseOptionsEnv(),this._parseOptionsImplied(),n=n.concat(t.operands),i=t.unknown,this.args=n.concat(i),n&&this._findCommand(n[0]))return this._dispatchSubcommand(n[0],n.slice(1),i);if(this._getHelpCommand()&&n[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(n[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(i),this._dispatchSubcommand(this._defaultCommandName,n,i);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(t.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{t.unknown.length>0&&this.unknownOption(t.unknown[0])},o=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(o,n,i)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent&&this.parent.listenerCount(o))r(),this._processArguments(),this.parent.emit(o,n,i);else if(n.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",n,i);this.listenerCount("command:*")?this.emit("command:*",n,i):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(n){if(n)return this.commands.find(i=>i._name===n||i._aliases.includes(n))}_findOption(n){return this.options.find(i=>i.is(n))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(n=>{n.options.forEach(i=>{i.mandatory&&n.getOptionValue(i.attributeName())===void 0&&n.missingMandatoryOptionValue(i)})})}_checkForConflictingLocalOptions(){let n=this.options.filter(t=>{let r=t.attributeName();return this.getOptionValue(r)===void 0?!1:this.getOptionValueSource(r)!=="default"});n.filter(t=>t.conflictsWith.length>0).forEach(t=>{let r=n.find(o=>t.conflictsWith.includes(o.attributeName()));r&&this._conflictingOption(t,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(n=>{n._checkForConflictingLocalOptions()})}parseOptions(n){let i=[],t=[],r=i,o=n.slice();function s(l){return l.length>1&&l[0]==="-"}let a=null;for(;o.length;){let l=o.shift();if(l==="--"){r===t&&r.push(l),r.push(...o);break}if(a&&!s(l)){this.emit(`option:${a.name()}`,l);continue}if(a=null,s(l)){let u=this._findOption(l);if(u){if(u.required){let c=o.shift();c===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,c)}else if(u.optional){let c=null;o.length>0&&!s(o[0])&&(c=o.shift()),this.emit(`option:${u.name()}`,c)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let u=this._findOption(`-${l[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,l.slice(2)):(this.emit(`option:${u.name()}`),o.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),c=this._findOption(l.slice(0,u));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,l.slice(u+1));continue}}if(s(l)&&(r=t),(this._enablePositionalOptions||this._passThroughOptions)&&i.length===0&&t.length===0){if(this._findCommand(l)){i.push(l),o.length>0&&t.push(...o);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){i.push(l),o.length>0&&i.push(...o);break}else if(this._defaultCommandName){t.push(l),o.length>0&&t.push(...o);break}}if(this._passThroughOptions){r.push(l),o.length>0&&r.push(...o);break}r.push(l)}return{operands:i,unknown:t}}opts(){if(this._storeOptionsAsProperties){let n={},i=this.options.length;for(let t=0;t<i;t++){let r=this.options[t].attributeName();n[r]=r===this._versionOptionName?this._version:this[r]}return n}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((n,i)=>Object.assign(n,i.opts()),{})}error(n,i){this._outputConfiguration.outputError(`${n}
18
+ `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
19
+ `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
20
+ `),this.outputHelp({error:!0}));let t=i||{},r=t.exitCode||1,o=t.code||"commander.error";this._exit(r,o,n)}_parseOptionsEnv(){this.options.forEach(n=>{if(n.envVar&&n.envVar in E.env){let i=n.attributeName();(this.getOptionValue(i)===void 0||["default","config","env"].includes(this.getOptionValueSource(i)))&&(n.required||n.optional?this.emit(`optionEnv:${n.name()}`,E.env[n.envVar]):this.emit(`optionEnv:${n.name()}`))}})}_parseOptionsImplied(){let n=new Lr(this.options),i=t=>this.getOptionValue(t)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter(t=>t.implied!==void 0&&i(t.attributeName())&&n.valueFromOption(this.getOptionValue(t.attributeName()),t)).forEach(t=>{Object.keys(t.implied).filter(r=>!i(r)).forEach(r=>{this.setOptionValueWithSource(r,t.implied[r],"implied")})})}missingArgument(n){let i=`error: missing required argument '${n}'`;this.error(i,{code:"commander.missingArgument"})}optionMissingArgument(n){let i=`error: option '${n.flags}' argument missing`;this.error(i,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(n){let i=`error: required option '${n.flags}' not specified`;this.error(i,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(n,i){let t=s=>{let a=s.attributeName(),l=this.getOptionValue(a),u=this.options.find(p=>p.negate&&a===p.attributeName()),c=this.options.find(p=>!p.negate&&a===p.attributeName());return u&&(u.presetArg===void 0&&l===!1||u.presetArg!==void 0&&l===u.presetArg)?u:c||s},r=s=>{let a=t(s),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},o=`error: ${r(n)} cannot be used with ${r(i)}`;this.error(o,{code:"commander.conflictingOption"})}unknownOption(n){if(this._allowUnknownOption)return;let i="";if(n.startsWith("--")&&this._showSuggestionAfterError){let r=[],o=this;do{let s=o.createHelp().visibleOptions(o).filter(a=>a.long).map(a=>a.long);r=r.concat(s),o=o.parent}while(o&&!o._enablePositionalOptions);i=bi(n,r)}let t=`error: unknown option '${n}'${i}`;this.error(t,{code:"commander.unknownOption"})}_excessArguments(n){if(this._allowExcessArguments)return;let i=this.registeredArguments.length,t=i===1?"":"s",o=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${i} argument${t} but got ${n.length}.`;this.error(o,{code:"commander.excessArguments"})}unknownCommand(){let n=this.args[0],i="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach(o=>{r.push(o.name()),o.alias()&&r.push(o.alias())}),i=bi(n,r)}let t=`error: unknown command '${n}'${i}`;this.error(t,{code:"commander.unknownCommand"})}version(n,i,t){if(n===void 0)return this._version;this._version=n,i=i||"-V, --version",t=t||"output the version number";let r=this.createOption(i,t);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${n}
21
+ `),this._exit(0,"commander.version",n)}),this}description(n,i){return n===void 0&&i===void 0?this._description:(this._description=n,i&&(this._argsDescription=i),this)}summary(n){return n===void 0?this._summary:(this._summary=n,this)}alias(n){if(n===void 0)return this._aliases[0];let i=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(i=this.commands[this.commands.length-1]),n===i._name)throw new Error("Command alias can't be the same as its name");let t=this.parent?._findCommand(n);if(t){let r=[t.name()].concat(t.aliases()).join("|");throw new Error(`cannot add alias '${n}' to command '${this.name()}' as already have command '${r}'`)}return i._aliases.push(n),this}aliases(n){return n===void 0?this._aliases:(n.forEach(i=>this.alias(i)),this)}usage(n){if(n===void 0){if(this._usage)return this._usage;let i=this.registeredArguments.map(t=>Nr(t));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?i:[]).join(" ")}return this._usage=n,this}name(n){return n===void 0?this._name:(this._name=n,this)}nameFromFilename(n){return this._name=G.basename(n,G.extname(n)),this}executableDir(n){return n===void 0?this._executableDir:(this._executableDir=n,this)}helpInformation(n){let i=this.createHelp();return i.helpWidth===void 0&&(i.helpWidth=n&&n.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),i.formatHelp(this,i)}_getHelpContext(n){n=n||{};let i={error:!!n.error},t;return i.error?t=r=>this._outputConfiguration.writeErr(r):t=r=>this._outputConfiguration.writeOut(r),i.write=n.write||t,i.command=this,i}outputHelp(n){let i;typeof n=="function"&&(i=n,n=void 0);let t=this._getHelpContext(n);this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",t)),this.emit("beforeHelp",t);let r=this.helpInformation(t);if(i&&(r=i(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");t.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",t),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",t))}helpOption(n,i){return typeof n=="boolean"?(n?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(n=n??"-h, --help",i=i??"display help for command",this._helpOption=this.createOption(n,i),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(n){return this._helpOption=n,this}help(n){this.outputHelp(n);let i=E.exitCode||0;i===0&&n&&typeof n!="function"&&n.error&&(i=1),this._exit(i,"commander.help","(outputHelp)")}addHelpText(n,i){let t=["beforeAll","before","after","afterAll"];if(!t.includes(n))throw new Error(`Unexpected value for position to addHelpText.
22
+ Expecting one of '${t.join("', '")}'`);let r=`${n}Help`;return this.on(r,o=>{let s;typeof i=="function"?s=i({error:o.error,command:o.command}):s=i,s&&o.write(`${s}
23
+ `)}),this}_outputHelpIfRequested(n){let i=this._getHelpOption();i&&n.find(r=>i.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Oi(e){return e.map(n=>{if(!n.startsWith("--inspect"))return n;let i,t="127.0.0.1",r="9229",o;return(o=n.match(/^(--inspect(-brk)?)$/))!==null?i=o[1]:(o=n.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(i=o[1],/^\d+$/.test(o[3])?r=o[3]:t=o[3]):(o=n.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(i=o[1],t=o[3],r=o[4]),i&&r!=="0"?`${i}=${t}:${parseInt(r)+1}`:n})}ki.Command=Tn});var Fi=Q(H=>{var{Argument:Pi}=Ue(),{Command:Fn}=$i(),{CommanderError:Rr,InvalidArgumentError:Ii}=$e(),{Help:Vr}=wn(),{Option:Ti}=kn();H.program=new Fn;H.createCommand=e=>new Fn(e);H.createOption=(e,n)=>new Ti(e,n);H.createArgument=(e,n)=>new Pi(e,n);H.Command=Fn;H.Option=Ti;H.Argument=Pi;H.Help=Vr;H.CommanderError=Rr;H.InvalidArgumentError=Ii;H.InvalidOptionArgumentError=Ii});var K=Q(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.WS_EVENTS=ee.RUN_EVENT_SCHEMA_VERSION=ee.RunnerStage=void 0;ee.RunnerStage={Auth:"Auth",EnvPreAction:"EnvPreAction",VersionCheck:"VersionCheck",SolutionPack:"SolutionPack",SolutionCheck:"SolutionCheck",PreAction:"PreAction",Import:"Import",Upgrade:"Upgrade",DataImport:"DataImport",FlowActivation:"FlowActivation",PostAction:"PostAction",Cleanup:"Cleanup",EnvPostAction:"EnvPostAction"};ee.RUN_EVENT_SCHEMA_VERSION=1;ee.WS_EVENTS={TERMINAL_OUTPUT:"terminal:output",TERMINAL_INPUT:"terminal:input",TERMINAL_RESIZE:"terminal:resize",TERMINAL_START:"terminal:start",TERMINAL_DONE:"terminal:done",TERMINAL_ERROR:"terminal:error",TERMINAL_ATTACH:"terminal:attach",TERMINAL_KILL:"terminal:kill",RUNNER_EVENT:"runner:event",IDLE_WARNING:"idle:warning",IDLE_CANCELLED:"idle:cancelled"}});var Ni=S(Fi(),1),{program:Ma,createCommand:ja,createArgument:Ha,createOption:Ua,CommanderError:Ba,InvalidArgumentError:qa,InvalidOptionArgumentError:Wa,Command:le,Argument:Ya,Option:za,Help:Ga}=Ni.default;var M=S(require("path")),I=S(require("fs")),_i=S(require("os"));var Di=S(require("fs")),Li=S(K()),Ln=!1,Nn=process.env.PPDEVOPS_EVENTS_FILE||"";function ce(){return Ln}function Ri(){return!Ln||!!Nn}function j(e){Ri()&&console.log(e)}function Be(e){Ri()&&console.error(e)}var re="~run",Mr="~env",W=null,J=null,ue=null;function Vi(){return W??Mr}function jr(){return W??re}function Rn(e){return`${Vi()}::${e}`}function Mi(e,n){return`${Vi()}::${e}::${n}`}function qe(e){Ln=e}function ji(e){if(Nn)try{Di.appendFileSync(Nn,e+`
24
+ `)}catch{}else process.stdout.write(`
25
+ `+e+`
26
+ `)}function Dn(e){ce()&&ji(JSON.stringify(e))}function U(e){if(!ce())return;let n={v:Li.RUN_EVENT_SCHEMA_VERSION,ts:new Date().toISOString(),...e};ji(JSON.stringify(n))}function Hi(e){ce()&&U({type:"log",message:e,id:J?Rn(J):void 0})}function w(e){Hi(`[INFO] ${e}`),j(`[INFO] ${e}`)}function A(e){Hi(`[WARN] ${e}`),j(`\x1B[33m[WARN]\x1B[0m ${e}`)}function Ui(e,n){W=null,J=null,U({type:"run",id:re,name:e,status:"running",message:n?.environment}),j(`
27
+ \x1B[1m\u25B6 Deployment run: ${e}${n?.environment?` \u2192 ${n.environment}`:""}\x1B[0m`)}function Vn(e=0){U({type:"run",id:re,status:e===0?"done":"error",exitCode:e})}function Bi(e){W=e,J=null,U({type:"solution",id:e,parentId:re,name:e,status:"running"}),j(`
28
+ \x1B[36m\u2501\u2501 ${e} \u2501\u2501\x1B[0m`)}function qi(e){!ce()||!W||U({type:"solution",id:W,name:W,status:"running",fromVersion:e.fromVersion??void 0,toVersion:e.toVersion??void 0})}function Mn(e,n){ce()&&W&&U({type:"solution",id:W,name:W,status:e,message:n}),J=null}function Wi(e){Mn("done",e)}function Yi(e){Mn("skipped",e)}function zi(e){Mn("error",e)}function We(e,n,i){U({type:"stage",stage:e,status:n,message:i,id:Rn(e),parentId:jr(),name:e})}function P(e,n){J=e,We(e,"running",n),j(`
29
+ \x1B[36m[${e}]\x1B[0m ${n??"Starting..."}`)}function b(e,n){We(e,"done",n),j(`\x1B[32m[${e}] \u2713\x1B[0m ${n??"Done"}`)}function m(e,n){We(e,"skipped",n),j(`\x1B[90m[${e}] \u2013\x1B[0m ${n??"Skipped"}`)}function Z(e,n){We(e,"error",n),Be(`\x1B[31m[${e}] \u2717\x1B[0m ${n}`)}function Pe(e,n,i){let t=i?.stage??J;t&&U({type:"step",id:Mi(t,e),parentId:Rn(t),name:e,status:n,message:i?.message??i?.type,metrics:i?.metrics})}function Gi(e,n){Pe(e,"pending",n)}function Ki(e,n){ue=e,Pe(e,"running",n),j(` \x1B[34m\u25B6\x1B[0m ${e}${n?.type?` (${n.type})`:""}`)}function Ji(e,n){Pe(e,"done",n),j(` \x1B[32m\u2713\x1B[0m ${e}${n?.message?` \u2014 ${n.message}`:""}`),ue=null}function Ie(e,n){Pe(e,"skipped",n),j(` \x1B[90m\u2298\x1B[0m ${e}${n?.message?` \u2014 ${n.message}`:""}`),ue=null}function jn(e,n,i){Pe(e,"error",{...i,message:n}),Be(` \x1B[31m\u2717\x1B[0m ${e} \u2014 ${n}`),ue=null}function Hn(e){!ce()||!J||!ue||U({type:"log",message:e,id:Mi(J,ue)})}function Zi(e,n){U({type:"plan",id:re,name:e,status:"running",message:n}),j(`
30
+ \x1B[1m\u25B6 Plan for ${e}${n?` \u2192 ${n}`:""}\x1B[0m`)}function Xi(e){U({type:"solution",id:e.name,parentId:re,name:e.name,status:e.plan.action==="skip"?"skipped":"pending",fromVersion:e.fromVersion??void 0,toVersion:e.toVersion??void 0,plan:e.plan});let n=e.plan.action==="install"?"+":e.plan.action==="upgrade"?"~":"\u2212";j(` ${n} ${e.plan.action.padEnd(8)} ${e.name.padEnd(28)} ${e.fromVersion??"\u2014"} \u2192 ${e.toVersion??"\u2014"}`)}function Un(){U({type:"plan",id:re,status:"done"})}function pe(e=0){Dn({type:"done",exitCode:e}),e===0?j(`
31
+ \x1B[32mCompleted successfully.\x1B[0m`):Be(`
32
+ \x1B[31mFailed.\x1B[0m`)}function C(e,n=1){Dn({type:"error",message:e,exitCode:n}),Dn({type:"done",exitCode:n}),Be(`\x1B[31m[FATAL]\x1B[0m ${e}`),process.exit(n)}var Ye=S(require("fs")),Bn=S(require("path"));function Qi(e,n){if(!Ye.existsSync(e))return n&&C(`Required file not found: ${e}`),null;try{let i=Ye.readFileSync(e,"utf-8");return JSON.parse(i)}catch(i){C(`Failed to parse ${e}: ${i instanceof Error?i.message:String(i)}`)}}function ze(e){let n=Bn.join(e,"deployPackages.json"),i=Bn.join(e,"Environments.json"),t=Qi(n,!0),r=Qi(i,!0);return Array.isArray(t)||C(`deployPackages.json must be a JSON array: ${n}`),Array.isArray(r)||C(`Environments.json must be a JSON array: ${i}`),{deployPackages:t,environments:r}}function Ge(e,n){let i=e.find(t=>t.EnvironmentName.toLowerCase()===n.toLowerCase());return i||C(`Environment "${n}" not found in Environments.json. Available: ${e.map(t=>t.EnvironmentName).join(", ")}`),i}function Ke(e,n){if(!n||n.length===0)return e;let i=e.filter(t=>n.some(r=>r.toLowerCase()===t.SolutionName.toLowerCase()));return i.length===0&&C(`No matching solutions found. Available: ${e.map(t=>t.SolutionName).join(", ")}`),i}var Te=require("child_process"),Je=S(require("os")),ge=S(require("fs")),Ze=S(require("path"));var Wn=S(K());var fe=S(require("fs")),B=S(require("path")),qn=require("child_process");function Hr(e){let n=e.trim().replace(/^"+|"+$/g,"");if(!n)return"";if(process.platform==="win32"&&n.toLowerCase().endsWith("\\pac.cmd")){let i=B.join(B.dirname(n),"pac.launcher.exe");if(fe.existsSync(i))return i}return n}function Ur(){try{let e=process.platform==="win32"?(0,qn.spawnSync)("where.exe",["pac"],{encoding:"utf8",windowsHide:!0}):(0,qn.spawnSync)("which",["pac"],{encoding:"utf8"});return e.status!==0?null:`${e.stdout??""}
33
+ ${e.stderr??""}`.split(/\r?\n/).map(Hr).filter(Boolean).find(i=>B.isAbsolute(i)&&fe.existsSync(i))??null}catch{return null}}function Br(){if(process.env.PPDEVOPS_PAC_EXE)return process.env.PPDEVOPS_PAC_EXE;if(process.platform==="win32"){let i=process.env.LOCALAPPDATA??B.join(process.env.USERPROFILE??"","AppData","Local");for(let t of[B.join(i,"Microsoft","PowerAppsCLI","pac.launcher.exe"),B.join(i,"Microsoft","PowerAppsCLI","pac.cmd"),"C:\\Program Files (x86)\\Microsoft Power Apps CLI\\tools\\pac.exe"])if(fe.existsSync(t))return t}let e=B.join(process.env.HOME??process.env.USERPROFILE??"",".dotnet","tools",process.platform==="win32"?"pac.exe":"pac");if(fe.existsSync(e))return e;for(let i of["/usr/local/bin/pac","/usr/local/lib/dotnet-tools/pac"])if(fe.existsSync(i))return i;let n=Ur();return n||"pac"}var q=Br();function N(e){return B.isAbsolute(q)?`"${q}" ${e}`:`pac ${e}`}var et="ppdo-cli",Yn=Je.platform()!=="win32",he,zn;function de(e,n,i=18e4){try{let t=n?{...process.env,...n}:process.env;return(0,Te.execSync)(e,{stdio:"pipe",encoding:"utf-8",env:t,timeout:i}).trim()}catch(t){let r=t,o=(Buffer.isBuffer(r.stderr)?r.stderr.toString():r.stderr??"").trim(),s=(Buffer.isBuffer(r.stdout)?r.stdout.toString():r.stdout??"").trim(),a=o||s||r.message;throw new Error(`[exit=${r.status}] ${a}`)}}function qr(){if(w(`[pac-check] PAC_EXE=${q}`),Ze.isAbsolute(q)){let i=ge.existsSync(q);return w(`[pac-check] Absolute path ${q} exists: ${i}`),i}let e=Yn?`command -v ${q}`:`where ${q}`;try{let i=(0,Te.execSync)(e,{stdio:"pipe",encoding:"utf-8"}).trim();return w(`[pac-check] Found on PATH: ${i}`),!0}catch{}let n=N("--version");try{let i=(0,Te.execSync)(n,{stdio:"pipe",encoding:"utf-8"});return w(`[pac-check] Version OK: ${i.trim().split(`
34
+ `)[0]}`),!0}catch(i){let t=i,r=(Buffer.isBuffer(t.stderr)?t.stderr.toString():t.stderr??"").trim(),o=(Buffer.isBuffer(t.stdout)?t.stdout.toString():t.stdout??"").trim();return A(`[pac-check] Not found. exit=${t.status} stderr="${r}" stdout="${o}" msg="${t.message}"`),!1}}function Wr(){try{return(0,Te.execSync)("az --version",{stdio:"pipe",timeout:15e3}),!0}catch{return!1}}async function nt(e){qr()||C("pac CLI not found. Install the Power Platform CLI before running ppdevops deploy.");let n=e.profileName??et;P(Wn.RunnerStage.Auth,`Setting up PAC auth profile '${n}'`);try{de(N(`auth delete --name ${n}`))}catch{}let i=Yn?" --accept-cleartext-caching":"",t=Yn?'"$PPDO_CLIENT_SECRET"':'"%PPDO_CLIENT_SECRET%"';return de(N("auth create")+` --name ${n} --environment "${e.environmentUrl}" --applicationId "${e.clientId}" --clientSecret ${t} --tenant "${e.tenantId}"`+i,{PPDO_CLIENT_SECRET:e.clientSecret}),de(N(`auth select --name ${n}`)),de(N(`org select --environment "${e.environmentUrl}"`)),b(Wn.RunnerStage.Auth,`PAC auth configured for ${e.environmentUrl}`),n}async function it(e){if(!Wr()){A("az CLI not found \u2014 skipping Azure CLI auth. Key Vault lookups will fail.");return}zn=process.env.AZURE_CONFIG_DIR,he=Ze.join(Je.tmpdir(),`ppdevops-az-${Date.now()}`),ge.mkdirSync(he,{recursive:!0}),process.env.AZURE_CONFIG_DIR=he;try{de(`az login --service-principal --username "${e.clientId}" --password "${e.clientSecret}" --tenant "${e.tenantId}" --output none`,void 0,6e4),w("Azure CLI authenticated.")}catch(n){A(`Azure CLI auth failed (non-fatal): ${n instanceof Error?n.message:String(n)}`)}}function tt(e=et){try{de(N(`auth delete --name ${e}`)),w(`PAC auth profile '${e}' removed.`)}catch{}}function rt(){if(zn!==void 0?process.env.AZURE_CONFIG_DIR=zn:delete process.env.AZURE_CONFIG_DIR,he){try{ge.rmSync(he,{recursive:!0,force:!0})}catch{}he=void 0}}var Xe=S(require("path")),Fe=S(require("fs")),st=require("child_process");var me=S(K());function ot(e,n){return new Promise((i,t)=>{let r=(0,st.spawn)(e,{stdio:["inherit","pipe","pipe"],shell:!0});r.stdout?.on("data",o=>process.stdout.write(o)),r.stderr?.on("data",o=>process.stderr.write(o)),r.on("close",o=>{if(o!==0){t(new Error(`Command exited with code ${o??"unknown"}`));return}if(!Fe.existsSync(n)){t(new Error(`pac solution pack completed but output zip was not created: ${n}`));return}i()}),r.on("error",t)})}async function Gn(e,n,i,t="Managed"){let r=Xe.join(e,"Other","Customizations.xml");if(!Fe.existsSync(r))return m(me.RunnerStage.SolutionPack,`${n}: Other/Customizations.xml not found \u2014 run Export & Unpack first.`),null;Fe.mkdirSync(i,{recursive:!0});let o=t!=="Unmanaged",s=t==="Unmanaged",a=o&&s?"Unmanaged + Managed":t;P(me.RunnerStage.SolutionPack,`Packing ${n} (${a})`);let l=Xe.join(i,`${n}.zip`),u=Xe.join(i,`${n}_managed.zip`);if(s)try{await ot(N(`solution pack --folder "${e}" --zipfile "${l}" --packagetype Unmanaged`),l),w(` Unmanaged zip: ${l}`)}catch(c){return Z(me.RunnerStage.SolutionPack,`Failed to pack Unmanaged: ${c.message}`),null}if(o)try{await ot(N(`solution pack --folder "${e}" --zipfile "${u}" --packagetype Managed`),u),w(` Managed zip: ${u}`)}catch(c){return Z(me.RunnerStage.SolutionPack,`Failed to pack Managed: ${c.message}`),null}return b(me.RunnerStage.SolutionPack,`Packed to ${i}`),{unmanagedZip:s?l:null,managedZip:o?u:null}}var Qe=S(require("fs")),ut=S(require("path"));var ve=S(K());function Kn(){let e=process.env.PPDEVOPS_CLIENT_ID,n=process.env.PPDEVOPS_CLIENT_SECRET,i=process.env.PPDEVOPS_TENANT_ID;return!e||!n||!i?null:{clientId:e,clientSecret:n,tenantId:i}}async function Jn(e,n){let i=`${e.replace(/\/+$/,"")}/.default`,t=`https://login.microsoftonline.com/${n.tenantId}/oauth2/v2.0/token`,r=new URLSearchParams({grant_type:"client_credentials",client_id:n.clientId,client_secret:n.clientSecret,scope:i}),o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()});if(!o.ok)throw new Error(`Token request failed: ${o.status} ${await o.text()}`);return(await o.json()).access_token}async function Yr(e,n,i,t="GET",r){let o=`${n.replace(/\/+$/,"")}${i}`,s=await fetch(o,{method:t,headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json","OData-MaxVersion":"4.0","OData-Version":"4.0"},body:r!==void 0?JSON.stringify(r):void 0});if(!s.ok){let a=await s.text();throw new Error(`Dataverse API error ${s.status}: ${a}`)}if(!(s.status===204||s.headers.get("content-length")==="0"))return s.json()}async function at(e){let n=Kn();if(!n){let i=[process.env.PPDEVOPS_CLIENT_ID?null:"PPDEVOPS_CLIENT_ID",process.env.PPDEVOPS_CLIENT_SECRET?null:"PPDEVOPS_CLIENT_SECRET",process.env.PPDEVOPS_TENANT_ID?null:"PPDEVOPS_TENANT_ID"].filter(Boolean).join(", ");throw new Error(`Cannot query ${e}: service-principal credentials are incomplete (missing ${i}). In Studio this usually means the client secret could not be read from Key Vault.`)}try{let i=await Jn(e,n);return(await Yr(i,e,"/api/data/v9.2/solutions?$select=uniquename,version&$filter=isvisible eq true&$orderby=uniquename")).value}catch(i){let t=i instanceof Error?i.message:String(i);throw new Error(`Dataverse Web API query against ${e} failed: ${t}`)}}function lt(e){return e.split(".").map(n=>parseInt(n,10)||0)}function Zn(e,n){let i=lt(e),t=lt(n);for(let r=0;r<Math.max(i.length,t.length);r++){let o=i[r]??0,s=t[r]??0;if(o>s)return!0;if(o<s)return!1}return!0}async function en(e){let n=await at(e);return w(`Fetched ${n.length} solution(s) via Dataverse Web API.`),n.map(i=>({SolutionUniqueName:i.uniquename,VersionNumber:i.version}))}function Xn(e,n,i){let t=ut.join(e,n,`${n}.version`),r=null;if(Qe.existsSync(t))try{let u=JSON.parse(Qe.readFileSync(t,"utf-8"));r=(u.find(p=>(p.SolutionName??"").toLowerCase()===n.toLowerCase())??u[0])?.Version??null}catch{A(`Could not parse ${n}.version \u2014 version comparison skipped.`)}else A(`No .version file found for ${n} \u2014 version comparison skipped.`);let o=i.find(u=>(u.SolutionUniqueName??u.uniquename??"").toLowerCase()===n.toLowerCase()),s=o?o.VersionNumber??o.Version??o.version??null:null,a=s===null;return{skip:!!r&&!a&&Zn(s,r),localVersion:r,installedVersion:s,isFirstDeploy:a}}function ct(e,n,i,t){P(ve.RunnerStage.VersionCheck,`Checking version of ${n}`);let r=Xn(e,n,t),{localVersion:o,installedVersion:s,isFirstDeploy:a}=r;return o?a?b(ve.RunnerStage.VersionCheck,`${n} not installed \u2014 fresh deploy (local: ${o})`):r.skip?m(ve.RunnerStage.VersionCheck,`Installed (${s}) >= local (${o}) \u2014 skipping ${n}.`):b(ve.RunnerStage.VersionCheck,`Upgrading ${n}: ${s} \u2192 ${o}`):b(ve.RunnerStage.VersionCheck,`No local version info \u2014 deploying. Installed: ${s??"not installed"}`),r}var Qn=S(require("fs")),ft=S(require("path")),dt=require("child_process");var _e=S(K());var pt=e=>e===!0||String(e).toLowerCase()==="true";function ht(e){return new Promise((n,i)=>{let t=(0,dt.spawn)(e,{stdio:["inherit","pipe","pipe"],shell:!0});t.stdout?.on("data",r=>process.stdout.write(r)),t.stderr?.on("data",r=>process.stderr.write(r)),t.on("close",r=>{r!==0?i(new Error(`Command exited with code ${r??"unknown"}`)):n()}),t.on("error",i)})}async function ei(e){let{environmentUrl:n,managedZip:i,solutionName:t,target:r,deploymentSettingsPath:o}=e;Qn.existsSync(i)||C(`Managed zip not found: ${i}`);let s=pt(r.StageForUpgrade),a=pt(r.DeployAsHolding),l=s,u=a&&!s;P(_e.RunnerStage.Import,`Importing ${t} to ${n}`);let c=r.OverwriteUnmanagedCustomisations?.toLowerCase()!=="false",p=N("solution import")+` --path "${i}" --environment "${n}" --activate-plugins --async`+(l?" --import-as-holding":"")+(u?" --stage-and-upgrade":"")+(c?" --force-overwrite":"");return o&&Qn.existsSync(o)?(p+=` --deployment-settings "${o}"`,w(` Using deployment settings: ${ft.basename(o)}`)):r.SettingsFile&&A(` SettingsFile "${r.SettingsFile}" specified but not found \u2014 connection refs may need manual setup.`),await ht(p),b(_e.RunnerStage.Import,`${t} imported.`),u&&b(_e.RunnerStage.Upgrade,`${t} upgraded (applied atomically via --stage-and-upgrade).`),l}async function ni(e,n){P(_e.RunnerStage.Upgrade,`Upgrading ${n} (applying holding solution)`),await ht(N(`solution upgrade --solution-name "${n}" --environment "${e}" --async`)),b(_e.RunnerStage.Upgrade,`${n} upgraded.`)}var nn=S(require("fs")),oe=S(require("path")),tn=S(require("os")),mt=require("child_process");var xe=S(K());function ii(e){(0,mt.execSync)(e,{stdio:"inherit"})}var gt=e=>e===!0||String(e).toLowerCase()==="true";function zr(e,n){return gt(e.DeployData)?gt(e.AlwaysDeployData)?!0:n:!1}function rn(e,n,i,t){if(!zr(i,t)){m(xe.RunnerStage.DataImport,"Data import not required for this deployment.");return}let r=oe.join(n,"data");if(!nn.existsSync(r)){m(xe.RunnerStage.DataImport,`No data/ directory in ${n} \u2014 skipping.`);return}let o=oe.join(r,"data.zip"),s=oe.join(r,"Extracted");if(!nn.existsSync(o)){if(!nn.existsSync(s)){m(xe.RunnerStage.DataImport,"No data.zip or Extracted/ folder found \u2014 skipping.");return}let a=oe.join(tn.tmpdir(),`ppdevops-data-${Date.now()}.zip`);w(` Compressing Extracted/ -> ${a}`),tn.platform()==="win32"?ii(`powershell -NoProfile -Command "Compress-Archive -Path '${s}\\*' -DestinationPath '${a}' -Force"`):ii(`cd "${s}" && zip -r "${a}" .`),o=a}P(xe.RunnerStage.DataImport,`Importing data from ${oe.basename(o)}`),ii(N(`data import --data "${o}" --environment "${e}"`)),b(xe.RunnerStage.DataImport,"Data import complete.")}var on=S(require("fs")),sn=S(require("path")),vt=S(require("https"));var ye=S(K());var Ne=e=>e===!0||String(e).toLowerCase()==="true";async function Gr(e){let n=Kn();if(!n)throw new Error("Service-principal credentials not available (PPDEVOPS_CLIENT_ID / PPDEVOPS_CLIENT_SECRET / PPDEVOPS_TENANT_ID).");return Jn(e,n)}function _t(e,n,i,t){return new Promise((r,o)=>{let s=t?JSON.stringify(t):void 0,a=new URL(n),l={hostname:a.hostname,path:a.pathname+a.search,method:e,headers:{Authorization:`Bearer ${i}`,"OData-MaxVersion":"4.0","OData-Version":"4.0","Content-Type":"application/json",Accept:"application/json",...s?{"Content-Length":Buffer.byteLength(s)}:{}}},u=vt.request(l,c=>{let p="";c.on("data",f=>{p+=f}),c.on("end",()=>{if((c.statusCode??0)>=400)o(new Error(`HTTP ${c.statusCode}: ${p}`));else try{r(p?JSON.parse(p):null)}catch{r(p)}})});u.on("error",o),s&&u.write(s),u.end()})}async function Kr(e,n,i,t){let r=e.replace(/\/$/,""),o=t?1:2;await _t("PATCH",`${r}/api/data/v9.2/workflows(${i})`,n,{statecode:o,statuscode:t?2:1})}async function Jr(e,n,i){let t=e.replace(/\/$/,"");return(await _t("GET",`${t}/api/data/v9.2/workflows?$filter=name eq '${encodeURIComponent(i)}'&$select=workflowid,name,statecode`,n))?.value?.[0]?.workflowid??null}async function an(e,n,i,t=!0){let r=i.Flows;if(!r||!Ne(r.ActivateFlows)){m(ye.RunnerStage.FlowActivation,"Flow activation not configured for this target.");return}if(!t&&!Ne(r.AlwaysTryActivate)){m(ye.RunnerStage.FlowActivation,"Solution is up-to-date \u2014 AlwaysTryActivate not set, skipping.");return}P(ye.RunnerStage.FlowActivation,"Activating flows...");let o=r.OverrideFile?sn.resolve(n,r.OverrideFile):sn.join(n,"Flows_Default.json");if(!on.existsSync(o)){m(ye.RunnerStage.FlowActivation,`Flow override file not found: ${o} \u2014 skipping.`);return}let s;try{s=JSON.parse(on.readFileSync(o,"utf-8"))}catch(u){let c=u instanceof Error?u.message:String(u);Ne(r.FailonError)&&C(`Failed to parse flow override file: ${c}`),A(`Failed to parse flow override file: ${c} \u2014 skipping flow activation.`);return}let a;try{a=await Gr(e)}catch(u){let c=u instanceof Error?u.message:String(u);Ne(r.FailonError)&&C(`Could not get access token: ${c}`),A(`Could not get access token: ${c} \u2014 skipping flow activation.`);return}let l=0;for(let u of s.flows??[])try{let c=await Jr(e,a,u.flowName);if(!c){A(` Flow not found: ${u.flowName}`);continue}await Kr(e,a,c,u.activate),w(` ${u.activate?"Activated":"Deactivated"}: ${u.flowName}`)}catch(c){let p=c instanceof Error?c.message:String(c);A(` Failed for ${u.flowName}: ${p}`),l++}l>0&&Ne(r.FailonError)&&C(`Flow activation completed with ${l} error(s).`),b(ye.RunnerStage.FlowActivation,`Flow activation complete (${l} error(s)).`)}var Ee=S(require("fs")),O=S(require("path")),ur=S(require("os")),cr=require("child_process");function Nt(e){return typeof e>"u"||e===null}function Zr(e){return typeof e=="object"&&e!==null}function Xr(e){return Array.isArray(e)?e:Nt(e)?[]:[e]}function Qr(e,n){var i,t,r,o;if(n)for(o=Object.keys(n),i=0,t=o.length;i<t;i+=1)r=o[i],e[r]=n[r];return e}function eo(e,n){var i="",t;for(t=0;t<n;t+=1)i+=e;return i}function no(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var io=Nt,to=Zr,ro=Xr,oo=eo,so=no,ao=Qr,$={isNothing:io,isObject:to,toArray:ro,repeat:oo,isNegativeZero:so,extend:ao};function Dt(e,n){var i="",t=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(i+='in "'+e.mark.name+'" '),i+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!n&&e.mark.snippet&&(i+=`
35
+
36
+ `+e.mark.snippet),t+" "+i):t}function Le(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=Dt(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Le.prototype=Object.create(Error.prototype);Le.prototype.constructor=Le;Le.prototype.toString=function(n){return this.name+": "+Dt(this,n)};var R=Le;function ti(e,n,i,t,r){var o="",s="",a=Math.floor(r/2)-1;return t-n>a&&(o=" ... ",n=t-a+o.length),i-t>a&&(s=" ...",i=t+a-s.length),{str:o+e.slice(n,i).replace(/\t/g,"\u2192")+s,pos:t-n+o.length}}function ri(e,n){return $.repeat(" ",n-e.length)+e}function lo(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var i=/\r?\n|\r|\0/g,t=[0],r=[],o,s=-1;o=i.exec(e.buffer);)r.push(o.index),t.push(o.index+o[0].length),e.position<=o.index&&s<0&&(s=t.length-2);s<0&&(s=t.length-1);var a="",l,u,c=Math.min(e.line+n.linesAfter,r.length).toString().length,p=n.maxLength-(n.indent+c+3);for(l=1;l<=n.linesBefore&&!(s-l<0);l++)u=ti(e.buffer,t[s-l],r[s-l],e.position-(t[s]-t[s-l]),p),a=$.repeat(" ",n.indent)+ri((e.line-l+1).toString(),c)+" | "+u.str+`
37
+ `+a;for(u=ti(e.buffer,t[s],r[s],e.position,p),a+=$.repeat(" ",n.indent)+ri((e.line+1).toString(),c)+" | "+u.str+`
38
+ `,a+=$.repeat("-",n.indent+c+3+u.pos)+`^
39
+ `,l=1;l<=n.linesAfter&&!(s+l>=r.length);l++)u=ti(e.buffer,t[s+l],r[s+l],e.position-(t[s]-t[s+l]),p),a+=$.repeat(" ",n.indent)+ri((e.line+l+1).toString(),c)+" | "+u.str+`
40
+ `;return a.replace(/\n$/,"")}var uo=lo,co=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],po=["scalar","sequence","mapping"];function fo(e){var n={};return e!==null&&Object.keys(e).forEach(function(i){e[i].forEach(function(t){n[String(t)]=i})}),n}function ho(e,n){if(n=n||{},Object.keys(n).forEach(function(i){if(co.indexOf(i)===-1)throw new R('Unknown option "'+i+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(i){return i},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||!1,this.styleAliases=fo(n.styleAliases||null),po.indexOf(this.kind)===-1)throw new R('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var T=ho;function xt(e,n){var i=[];return e[n].forEach(function(t){var r=i.length;i.forEach(function(o,s){o.tag===t.tag&&o.kind===t.kind&&o.multi===t.multi&&(r=s)}),i[r]=t}),i}function go(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,i;function t(r){r.multi?(e.multi[r.kind].push(r),e.multi.fallback.push(r)):e[r.kind][r.tag]=e.fallback[r.tag]=r}for(n=0,i=arguments.length;n<i;n+=1)arguments[n].forEach(t);return e}function si(e){return this.extend(e)}si.prototype.extend=function(n){var i=[],t=[];if(n instanceof T)t.push(n);else if(Array.isArray(n))t=t.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(i=i.concat(n.implicit)),n.explicit&&(t=t.concat(n.explicit));else throw new R("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");i.forEach(function(o){if(!(o instanceof T))throw new R("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new R("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(o.multi)throw new R("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),t.forEach(function(o){if(!(o instanceof T))throw new R("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var r=Object.create(si.prototype);return r.implicit=(this.implicit||[]).concat(i),r.explicit=(this.explicit||[]).concat(t),r.compiledImplicit=xt(r,"implicit"),r.compiledExplicit=xt(r,"explicit"),r.compiledTypeMap=go(r.compiledImplicit,r.compiledExplicit),r};var mo=si,vo=new T("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),_o=new T("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),xo=new T("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),yo=new mo({explicit:[vo,_o,xo]});function So(e){if(e===null)return!0;var n=e.length;return n===1&&e==="~"||n===4&&(e==="null"||e==="Null"||e==="NULL")}function Ao(){return null}function Co(e){return e===null}var wo=new T("tag:yaml.org,2002:null",{kind:"scalar",resolve:So,construct:Ao,predicate:Co,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Eo(e){if(e===null)return!1;var n=e.length;return n===4&&(e==="true"||e==="True"||e==="TRUE")||n===5&&(e==="false"||e==="False"||e==="FALSE")}function bo(e){return e==="true"||e==="True"||e==="TRUE"}function Oo(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var ko=new T("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Eo,construct:bo,predicate:Oo,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function $o(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Po(e){return 48<=e&&e<=55}function Io(e){return 48<=e&&e<=57}function To(e){if(e===null)return!1;var n=e.length,i=0,t=!1,r;if(!n)return!1;if(r=e[i],(r==="-"||r==="+")&&(r=e[++i]),r==="0"){if(i+1===n)return!0;if(r=e[++i],r==="b"){for(i++;i<n;i++)if(r=e[i],r!=="_"){if(r!=="0"&&r!=="1")return!1;t=!0}return t&&r!=="_"}if(r==="x"){for(i++;i<n;i++)if(r=e[i],r!=="_"){if(!$o(e.charCodeAt(i)))return!1;t=!0}return t&&r!=="_"}if(r==="o"){for(i++;i<n;i++)if(r=e[i],r!=="_"){if(!Po(e.charCodeAt(i)))return!1;t=!0}return t&&r!=="_"}}if(r==="_")return!1;for(;i<n;i++)if(r=e[i],r!=="_"){if(!Io(e.charCodeAt(i)))return!1;t=!0}return!(!t||r==="_")}function Fo(e){var n=e,i=1,t;if(n.indexOf("_")!==-1&&(n=n.replace(/_/g,"")),t=n[0],(t==="-"||t==="+")&&(t==="-"&&(i=-1),n=n.slice(1),t=n[0]),n==="0")return 0;if(t==="0"){if(n[1]==="b")return i*parseInt(n.slice(2),2);if(n[1]==="x")return i*parseInt(n.slice(2),16);if(n[1]==="o")return i*parseInt(n.slice(2),8)}return i*parseInt(n,10)}function No(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!$.isNegativeZero(e)}var Do=new T("tag:yaml.org,2002:int",{kind:"scalar",resolve:To,construct:Fo,predicate:No,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Lo=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Ro(e){return!(e===null||!Lo.test(e)||e[e.length-1]==="_")}function Vo(e){var n,i;return n=e.replace(/_/g,"").toLowerCase(),i=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?i===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:i*parseFloat(n,10)}var Mo=/^[-+]?[0-9]+e/;function jo(e,n){var i;if(isNaN(e))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if($.isNegativeZero(e))return"-0.0";return i=e.toString(10),Mo.test(i)?i.replace("e",".e"):i}function Ho(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||$.isNegativeZero(e))}var Uo=new T("tag:yaml.org,2002:float",{kind:"scalar",resolve:Ro,construct:Vo,predicate:Ho,represent:jo,defaultStyle:"lowercase"}),Bo=yo.extend({implicit:[wo,ko,Do,Uo]}),qo=Bo,Lt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Rt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Wo(e){return e===null?!1:Lt.exec(e)!==null||Rt.exec(e)!==null}function Yo(e){var n,i,t,r,o,s,a,l=0,u=null,c,p,f;if(n=Lt.exec(e),n===null&&(n=Rt.exec(e)),n===null)throw new Error("Date resolve error");if(i=+n[1],t=+n[2]-1,r=+n[3],!n[4])return new Date(Date.UTC(i,t,r));if(o=+n[4],s=+n[5],a=+n[6],n[7]){for(l=n[7].slice(0,3);l.length<3;)l+="0";l=+l}return n[9]&&(c=+n[10],p=+(n[11]||0),u=(c*60+p)*6e4,n[9]==="-"&&(u=-u)),f=new Date(Date.UTC(i,t,r,o,s,a,l)),u&&f.setTime(f.getTime()-u),f}function zo(e){return e.toISOString()}var Go=new T("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Wo,construct:Yo,instanceOf:Date,represent:zo});function Ko(e){return e==="<<"||e===null}var Jo=new T("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Ko}),pi=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
41
+ \r`;function Zo(e){if(e===null)return!1;var n,i,t=0,r=e.length,o=pi;for(i=0;i<r;i++)if(n=o.indexOf(e.charAt(i)),!(n>64)){if(n<0)return!1;t+=6}return t%8===0}function Xo(e){var n,i,t=e.replace(/[\r\n=]/g,""),r=t.length,o=pi,s=0,a=[];for(n=0;n<r;n++)n%4===0&&n&&(a.push(s>>16&255),a.push(s>>8&255),a.push(s&255)),s=s<<6|o.indexOf(t.charAt(n));return i=r%4*6,i===0?(a.push(s>>16&255),a.push(s>>8&255),a.push(s&255)):i===18?(a.push(s>>10&255),a.push(s>>2&255)):i===12&&a.push(s>>4&255),new Uint8Array(a)}function Qo(e){var n="",i=0,t,r,o=e.length,s=pi;for(t=0;t<o;t++)t%3===0&&t&&(n+=s[i>>18&63],n+=s[i>>12&63],n+=s[i>>6&63],n+=s[i&63]),i=(i<<8)+e[t];return r=o%3,r===0?(n+=s[i>>18&63],n+=s[i>>12&63],n+=s[i>>6&63],n+=s[i&63]):r===2?(n+=s[i>>10&63],n+=s[i>>4&63],n+=s[i<<2&63],n+=s[64]):r===1&&(n+=s[i>>2&63],n+=s[i<<4&63],n+=s[64],n+=s[64]),n}function es(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var ns=new T("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Zo,construct:Xo,predicate:es,represent:Qo}),is=Object.prototype.hasOwnProperty,ts=Object.prototype.toString;function rs(e){if(e===null)return!0;var n=[],i,t,r,o,s,a=e;for(i=0,t=a.length;i<t;i+=1){if(r=a[i],s=!1,ts.call(r)!=="[object Object]")return!1;for(o in r)if(is.call(r,o))if(!s)s=!0;else return!1;if(!s)return!1;if(n.indexOf(o)===-1)n.push(o);else return!1}return!0}function os(e){return e!==null?e:[]}var ss=new T("tag:yaml.org,2002:omap",{kind:"sequence",resolve:rs,construct:os}),as=Object.prototype.toString;function ls(e){if(e===null)return!0;var n,i,t,r,o,s=e;for(o=new Array(s.length),n=0,i=s.length;n<i;n+=1){if(t=s[n],as.call(t)!=="[object Object]"||(r=Object.keys(t),r.length!==1))return!1;o[n]=[r[0],t[r[0]]]}return!0}function us(e){if(e===null)return[];var n,i,t,r,o,s=e;for(o=new Array(s.length),n=0,i=s.length;n<i;n+=1)t=s[n],r=Object.keys(t),o[n]=[r[0],t[r[0]]];return o}var cs=new T("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:ls,construct:us}),ps=Object.prototype.hasOwnProperty;function fs(e){if(e===null)return!0;var n,i=e;for(n in i)if(ps.call(i,n)&&i[n]!==null)return!1;return!0}function ds(e){return e!==null?e:{}}var hs=new T("tag:yaml.org,2002:set",{kind:"mapping",resolve:fs,construct:ds}),Vt=qo.extend({implicit:[Go,Jo],explicit:[ns,ss,cs,hs]}),ie=Object.prototype.hasOwnProperty,ln=1,Mt=2,jt=3,un=4,oi=1,gs=2,yt=3,ms=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,vs=/[\x85\u2028\u2029]/,_s=/[,\[\]\{\}]/,Ht=/^(?:!|!!|![a-z\-]+!)$/i,Ut=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function St(e){return Object.prototype.toString.call(e)}function z(e){return e===10||e===13}function ae(e){return e===9||e===32}function V(e){return e===9||e===32||e===10||e===13}function Ae(e){return e===44||e===91||e===93||e===123||e===125}function xs(e){var n;return 48<=e&&e<=57?e-48:(n=e|32,97<=n&&n<=102?n-97+10:-1)}function ys(e){return e===120?2:e===117?4:e===85?8:0}function Ss(e){return 48<=e&&e<=57?e-48:-1}function At(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
42
+ `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function As(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function Bt(e,n,i){n==="__proto__"?Object.defineProperty(e,n,{configurable:!0,enumerable:!0,writable:!0,value:i}):e[n]=i}var qt=new Array(256),Wt=new Array(256);for(se=0;se<256;se++)qt[se]=At(se)?1:0,Wt[se]=At(se);var se;function Cs(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||Vt,this.onWarning=n.onWarning||null,this.legacy=n.legacy||!1,this.json=n.json||!1,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Yt(e,n){var i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=uo(i),new R(n,i)}function g(e,n){throw Yt(e,n)}function cn(e,n){e.onWarning&&e.onWarning.call(null,Yt(e,n))}var Ct={YAML:function(n,i,t){var r,o,s;n.version!==null&&g(n,"duplication of %YAML directive"),t.length!==1&&g(n,"YAML directive accepts exactly one argument"),r=/^([0-9]+)\.([0-9]+)$/.exec(t[0]),r===null&&g(n,"ill-formed argument of the YAML directive"),o=parseInt(r[1],10),s=parseInt(r[2],10),o!==1&&g(n,"unacceptable YAML version of the document"),n.version=t[0],n.checkLineBreaks=s<2,s!==1&&s!==2&&cn(n,"unsupported YAML version of the document")},TAG:function(n,i,t){var r,o;t.length!==2&&g(n,"TAG directive accepts exactly two arguments"),r=t[0],o=t[1],Ht.test(r)||g(n,"ill-formed tag handle (first argument) of the TAG directive"),ie.call(n.tagMap,r)&&g(n,'there is a previously declared suffix for "'+r+'" tag handle'),Ut.test(o)||g(n,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch{g(n,"tag prefix is malformed: "+o)}n.tagMap[r]=o}};function ne(e,n,i,t){var r,o,s,a;if(n<i){if(a=e.input.slice(n,i),t)for(r=0,o=a.length;r<o;r+=1)s=a.charCodeAt(r),s===9||32<=s&&s<=1114111||g(e,"expected valid JSON character");else ms.test(a)&&g(e,"the stream contains non-printable characters");e.result+=a}}function wt(e,n,i,t){var r,o,s,a;for($.isObject(i)||g(e,"cannot merge mappings; the provided source object is unacceptable"),r=Object.keys(i),s=0,a=r.length;s<a;s+=1)o=r[s],ie.call(n,o)||(Bt(n,o,i[o]),t[o]=!0)}function Ce(e,n,i,t,r,o,s,a,l){var u,c;if(Array.isArray(r))for(r=Array.prototype.slice.call(r),u=0,c=r.length;u<c;u+=1)Array.isArray(r[u])&&g(e,"nested arrays are not supported inside keys"),typeof r=="object"&&St(r[u])==="[object Object]"&&(r[u]="[object Object]");if(typeof r=="object"&&St(r)==="[object Object]"&&(r="[object Object]"),r=String(r),n===null&&(n={}),t==="tag:yaml.org,2002:merge")if(Array.isArray(o))for(u=0,c=o.length;u<c;u+=1)wt(e,n,o[u],i);else wt(e,n,o,i);else!e.json&&!ie.call(i,r)&&ie.call(n,r)&&(e.line=s||e.line,e.lineStart=a||e.lineStart,e.position=l||e.position,g(e,"duplicated mapping key")),Bt(n,r,o),delete i[r];return n}function fi(e){var n;n=e.input.charCodeAt(e.position),n===10?e.position++:n===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):g(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function k(e,n,i){for(var t=0,r=e.input.charCodeAt(e.position);r!==0;){for(;ae(r);)r===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(n&&r===35)do r=e.input.charCodeAt(++e.position);while(r!==10&&r!==13&&r!==0);if(z(r))for(fi(e),r=e.input.charCodeAt(e.position),t++,e.lineIndent=0;r===32;)e.lineIndent++,r=e.input.charCodeAt(++e.position);else break}return i!==-1&&t!==0&&e.lineIndent<i&&cn(e,"deficient indentation"),t}function dn(e){var n=e.position,i;return i=e.input.charCodeAt(n),!!((i===45||i===46)&&i===e.input.charCodeAt(n+1)&&i===e.input.charCodeAt(n+2)&&(n+=3,i=e.input.charCodeAt(n),i===0||V(i)))}function di(e,n){n===1?e.result+=" ":n>1&&(e.result+=$.repeat(`
43
+ `,n-1))}function ws(e,n,i){var t,r,o,s,a,l,u,c,p=e.kind,f=e.result,d;if(d=e.input.charCodeAt(e.position),V(d)||Ae(d)||d===35||d===38||d===42||d===33||d===124||d===62||d===39||d===34||d===37||d===64||d===96||(d===63||d===45)&&(r=e.input.charCodeAt(e.position+1),V(r)||i&&Ae(r)))return!1;for(e.kind="scalar",e.result="",o=s=e.position,a=!1;d!==0;){if(d===58){if(r=e.input.charCodeAt(e.position+1),V(r)||i&&Ae(r))break}else if(d===35){if(t=e.input.charCodeAt(e.position-1),V(t))break}else{if(e.position===e.lineStart&&dn(e)||i&&Ae(d))break;if(z(d))if(l=e.line,u=e.lineStart,c=e.lineIndent,k(e,!1,-1),e.lineIndent>=n){a=!0,d=e.input.charCodeAt(e.position);continue}else{e.position=s,e.line=l,e.lineStart=u,e.lineIndent=c;break}}a&&(ne(e,o,s,!1),di(e,e.line-l),o=s=e.position,a=!1),ae(d)||(s=e.position+1),d=e.input.charCodeAt(++e.position)}return ne(e,o,s,!1),e.result?!0:(e.kind=p,e.result=f,!1)}function Es(e,n){var i,t,r;if(i=e.input.charCodeAt(e.position),i!==39)return!1;for(e.kind="scalar",e.result="",e.position++,t=r=e.position;(i=e.input.charCodeAt(e.position))!==0;)if(i===39)if(ne(e,t,e.position,!0),i=e.input.charCodeAt(++e.position),i===39)t=e.position,e.position++,r=e.position;else return!0;else z(i)?(ne(e,t,r,!0),di(e,k(e,!1,n)),t=r=e.position):e.position===e.lineStart&&dn(e)?g(e,"unexpected end of the document within a single quoted scalar"):(e.position++,r=e.position);g(e,"unexpected end of the stream within a single quoted scalar")}function bs(e,n){var i,t,r,o,s,a;if(a=e.input.charCodeAt(e.position),a!==34)return!1;for(e.kind="scalar",e.result="",e.position++,i=t=e.position;(a=e.input.charCodeAt(e.position))!==0;){if(a===34)return ne(e,i,e.position,!0),e.position++,!0;if(a===92){if(ne(e,i,e.position,!0),a=e.input.charCodeAt(++e.position),z(a))k(e,!1,n);else if(a<256&&qt[a])e.result+=Wt[a],e.position++;else if((s=ys(a))>0){for(r=s,o=0;r>0;r--)a=e.input.charCodeAt(++e.position),(s=xs(a))>=0?o=(o<<4)+s:g(e,"expected hexadecimal character");e.result+=As(o),e.position++}else g(e,"unknown escape sequence");i=t=e.position}else z(a)?(ne(e,i,t,!0),di(e,k(e,!1,n)),i=t=e.position):e.position===e.lineStart&&dn(e)?g(e,"unexpected end of the document within a double quoted scalar"):(e.position++,t=e.position)}g(e,"unexpected end of the stream within a double quoted scalar")}function Os(e,n){var i=!0,t,r,o,s=e.tag,a,l=e.anchor,u,c,p,f,d,h=Object.create(null),_,y,D,v;if(v=e.input.charCodeAt(e.position),v===91)c=93,d=!1,a=[];else if(v===123)c=125,d=!0,a={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),v=e.input.charCodeAt(++e.position);v!==0;){if(k(e,!0,n),v=e.input.charCodeAt(e.position),v===c)return e.position++,e.tag=s,e.anchor=l,e.kind=d?"mapping":"sequence",e.result=a,!0;i?v===44&&g(e,"expected the node content, but found ','"):g(e,"missed comma between flow collection entries"),y=_=D=null,p=f=!1,v===63&&(u=e.input.charCodeAt(e.position+1),V(u)&&(p=f=!0,e.position++,k(e,!0,n))),t=e.line,r=e.lineStart,o=e.position,we(e,n,ln,!1,!0),y=e.tag,_=e.result,k(e,!0,n),v=e.input.charCodeAt(e.position),(f||e.line===t)&&v===58&&(p=!0,v=e.input.charCodeAt(++e.position),k(e,!0,n),we(e,n,ln,!1,!0),D=e.result),d?Ce(e,a,h,y,_,D,t,r,o):p?a.push(Ce(e,null,h,y,_,D,t,r,o)):a.push(_),k(e,!0,n),v=e.input.charCodeAt(e.position),v===44?(i=!0,v=e.input.charCodeAt(++e.position)):i=!1}g(e,"unexpected end of the stream within a flow collection")}function ks(e,n){var i,t,r=oi,o=!1,s=!1,a=n,l=0,u=!1,c,p;if(p=e.input.charCodeAt(e.position),p===124)t=!1;else if(p===62)t=!0;else return!1;for(e.kind="scalar",e.result="";p!==0;)if(p=e.input.charCodeAt(++e.position),p===43||p===45)oi===r?r=p===43?yt:gs:g(e,"repeat of a chomping mode identifier");else if((c=Ss(p))>=0)c===0?g(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?g(e,"repeat of an indentation width identifier"):(a=n+c-1,s=!0);else break;if(ae(p)){do p=e.input.charCodeAt(++e.position);while(ae(p));if(p===35)do p=e.input.charCodeAt(++e.position);while(!z(p)&&p!==0)}for(;p!==0;){for(fi(e),e.lineIndent=0,p=e.input.charCodeAt(e.position);(!s||e.lineIndent<a)&&p===32;)e.lineIndent++,p=e.input.charCodeAt(++e.position);if(!s&&e.lineIndent>a&&(a=e.lineIndent),z(p)){l++;continue}if(e.lineIndent<a){r===yt?e.result+=$.repeat(`
44
+ `,o?1+l:l):r===oi&&o&&(e.result+=`
45
+ `);break}for(t?ae(p)?(u=!0,e.result+=$.repeat(`
46
+ `,o?1+l:l)):u?(u=!1,e.result+=$.repeat(`
47
+ `,l+1)):l===0?o&&(e.result+=" "):e.result+=$.repeat(`
48
+ `,l):e.result+=$.repeat(`
49
+ `,o?1+l:l),o=!0,s=!0,l=0,i=e.position;!z(p)&&p!==0;)p=e.input.charCodeAt(++e.position);ne(e,i,e.position,!1)}return!0}function Et(e,n){var i,t=e.tag,r=e.anchor,o=[],s,a=!1,l;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=o),l=e.input.charCodeAt(e.position);l!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,g(e,"tab characters must not be used in indentation")),!(l!==45||(s=e.input.charCodeAt(e.position+1),!V(s))));){if(a=!0,e.position++,k(e,!0,-1)&&e.lineIndent<=n){o.push(null),l=e.input.charCodeAt(e.position);continue}if(i=e.line,we(e,n,jt,!1,!0),o.push(e.result),k(e,!0,-1),l=e.input.charCodeAt(e.position),(e.line===i||e.lineIndent>n)&&l!==0)g(e,"bad indentation of a sequence entry");else if(e.lineIndent<n)break}return a?(e.tag=t,e.anchor=r,e.kind="sequence",e.result=o,!0):!1}function $s(e,n,i){var t,r,o,s,a,l,u=e.tag,c=e.anchor,p={},f=Object.create(null),d=null,h=null,_=null,y=!1,D=!1,v;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=p),v=e.input.charCodeAt(e.position);v!==0;){if(!y&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,g(e,"tab characters must not be used in indentation")),t=e.input.charCodeAt(e.position+1),o=e.line,(v===63||v===58)&&V(t))v===63?(y&&(Ce(e,p,f,d,h,null,s,a,l),d=h=_=null),D=!0,y=!0,r=!0):y?(y=!1,r=!0):g(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,v=t;else{if(s=e.line,a=e.lineStart,l=e.position,!we(e,i,Mt,!1,!0))break;if(e.line===o){for(v=e.input.charCodeAt(e.position);ae(v);)v=e.input.charCodeAt(++e.position);if(v===58)v=e.input.charCodeAt(++e.position),V(v)||g(e,"a whitespace character is expected after the key-value separator within a block mapping"),y&&(Ce(e,p,f,d,h,null,s,a,l),d=h=_=null),D=!0,y=!1,r=!1,d=e.tag,h=e.result;else if(D)g(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=u,e.anchor=c,!0}else if(D)g(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=u,e.anchor=c,!0}if((e.line===o||e.lineIndent>n)&&(y&&(s=e.line,a=e.lineStart,l=e.position),we(e,n,un,!0,r)&&(y?h=e.result:_=e.result),y||(Ce(e,p,f,d,h,_,s,a,l),d=h=_=null),k(e,!0,-1),v=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>n)&&v!==0)g(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return y&&Ce(e,p,f,d,h,null,s,a,l),D&&(e.tag=u,e.anchor=c,e.kind="mapping",e.result=p),D}function Ps(e){var n,i=!1,t=!1,r,o,s;if(s=e.input.charCodeAt(e.position),s!==33)return!1;if(e.tag!==null&&g(e,"duplication of a tag property"),s=e.input.charCodeAt(++e.position),s===60?(i=!0,s=e.input.charCodeAt(++e.position)):s===33?(t=!0,r="!!",s=e.input.charCodeAt(++e.position)):r="!",n=e.position,i){do s=e.input.charCodeAt(++e.position);while(s!==0&&s!==62);e.position<e.length?(o=e.input.slice(n,e.position),s=e.input.charCodeAt(++e.position)):g(e,"unexpected end of the stream within a verbatim tag")}else{for(;s!==0&&!V(s);)s===33&&(t?g(e,"tag suffix cannot contain exclamation marks"):(r=e.input.slice(n-1,e.position+1),Ht.test(r)||g(e,"named tag handle cannot contain such characters"),t=!0,n=e.position+1)),s=e.input.charCodeAt(++e.position);o=e.input.slice(n,e.position),_s.test(o)&&g(e,"tag suffix cannot contain flow indicator characters")}o&&!Ut.test(o)&&g(e,"tag name cannot contain such characters: "+o);try{o=decodeURIComponent(o)}catch{g(e,"tag name is malformed: "+o)}return i?e.tag=o:ie.call(e.tagMap,r)?e.tag=e.tagMap[r]+o:r==="!"?e.tag="!"+o:r==="!!"?e.tag="tag:yaml.org,2002:"+o:g(e,'undeclared tag handle "'+r+'"'),!0}function Is(e){var n,i;if(i=e.input.charCodeAt(e.position),i!==38)return!1;for(e.anchor!==null&&g(e,"duplication of an anchor property"),i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!V(i)&&!Ae(i);)i=e.input.charCodeAt(++e.position);return e.position===n&&g(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),!0}function Ts(e){var n,i,t;if(t=e.input.charCodeAt(e.position),t!==42)return!1;for(t=e.input.charCodeAt(++e.position),n=e.position;t!==0&&!V(t)&&!Ae(t);)t=e.input.charCodeAt(++e.position);return e.position===n&&g(e,"name of an alias node must contain at least one character"),i=e.input.slice(n,e.position),ie.call(e.anchorMap,i)||g(e,'unidentified alias "'+i+'"'),e.result=e.anchorMap[i],k(e,!0,-1),!0}function we(e,n,i,t,r){var o,s,a,l=1,u=!1,c=!1,p,f,d,h,_,y;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=s=a=un===i||jt===i,t&&k(e,!0,-1)&&(u=!0,e.lineIndent>n?l=1:e.lineIndent===n?l=0:e.lineIndent<n&&(l=-1)),l===1)for(;Ps(e)||Is(e);)k(e,!0,-1)?(u=!0,a=o,e.lineIndent>n?l=1:e.lineIndent===n?l=0:e.lineIndent<n&&(l=-1)):a=!1;if(a&&(a=u||r),(l===1||un===i)&&(ln===i||Mt===i?_=n:_=n+1,y=e.position-e.lineStart,l===1?a&&(Et(e,y)||$s(e,y,_))||Os(e,_)?c=!0:(s&&ks(e,_)||Es(e,_)||bs(e,_)?c=!0:Ts(e)?(c=!0,(e.tag!==null||e.anchor!==null)&&g(e,"alias node should not have any properties")):ws(e,_,ln===i)&&(c=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):l===0&&(c=a&&Et(e,y))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&g(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),p=0,f=e.implicitTypes.length;p<f;p+=1)if(h=e.implicitTypes[p],h.resolve(e.result)){e.result=h.construct(e.result),e.tag=h.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(ie.call(e.typeMap[e.kind||"fallback"],e.tag))h=e.typeMap[e.kind||"fallback"][e.tag];else for(h=null,d=e.typeMap.multi[e.kind||"fallback"],p=0,f=d.length;p<f;p+=1)if(e.tag.slice(0,d[p].tag.length)===d[p].tag){h=d[p];break}h||g(e,"unknown tag !<"+e.tag+">"),e.result!==null&&h.kind!==e.kind&&g(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+h.kind+'", not "'+e.kind+'"'),h.resolve(e.result,e.tag)?(e.result=h.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):g(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||c}function Fs(e){var n=e.position,i,t,r,o=!1,s;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(s=e.input.charCodeAt(e.position))!==0&&(k(e,!0,-1),s=e.input.charCodeAt(e.position),!(e.lineIndent>0||s!==37));){for(o=!0,s=e.input.charCodeAt(++e.position),i=e.position;s!==0&&!V(s);)s=e.input.charCodeAt(++e.position);for(t=e.input.slice(i,e.position),r=[],t.length<1&&g(e,"directive name must not be less than one character in length");s!==0;){for(;ae(s);)s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!z(s));break}if(z(s))break;for(i=e.position;s!==0&&!V(s);)s=e.input.charCodeAt(++e.position);r.push(e.input.slice(i,e.position))}s!==0&&fi(e),ie.call(Ct,t)?Ct[t](e,t,r):cn(e,'unknown document directive "'+t+'"')}if(k(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,k(e,!0,-1)):o&&g(e,"directives end mark is expected"),we(e,e.lineIndent-1,un,!1,!0),k(e,!0,-1),e.checkLineBreaks&&vs.test(e.input.slice(n,e.position))&&cn(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&dn(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,k(e,!0,-1));return}if(e.position<e.length-1)g(e,"end of the stream or a document separator is expected");else return}function zt(e,n){e=String(e),n=n||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
50
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var i=new Cs(e,n),t=e.indexOf("\0");for(t!==-1&&(i.position=t,g(i,"null byte is not allowed in input")),i.input+="\0";i.input.charCodeAt(i.position)===32;)i.lineIndent+=1,i.position+=1;for(;i.position<i.length-1;)Fs(i);return i.documents}function Ns(e,n,i){n!==null&&typeof n=="object"&&typeof i>"u"&&(i=n,n=null);var t=zt(e,i);if(typeof n!="function")return t;for(var r=0,o=t.length;r<o;r+=1)n(t[r])}function Ds(e,n){var i=zt(e,n);if(i.length!==0){if(i.length===1)return i[0];throw new R("expected a single document in the stream, but found more")}}var Ls=Ns,Rs=Ds,Gt={loadAll:Ls,load:Rs},Kt=Object.prototype.toString,Jt=Object.prototype.hasOwnProperty,hi=65279,Vs=9,Re=10,Ms=13,js=32,Hs=33,Us=34,ai=35,Bs=37,qs=38,Ws=39,Ys=42,Zt=44,zs=45,pn=58,Gs=61,Ks=62,Js=63,Zs=64,Xt=91,Qt=93,Xs=96,er=123,Qs=124,nr=125,F={};F[0]="\\0";F[7]="\\a";F[8]="\\b";F[9]="\\t";F[10]="\\n";F[11]="\\v";F[12]="\\f";F[13]="\\r";F[27]="\\e";F[34]='\\"';F[92]="\\\\";F[133]="\\N";F[160]="\\_";F[8232]="\\L";F[8233]="\\P";var ea=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],na=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function ia(e,n){var i,t,r,o,s,a,l;if(n===null)return{};for(i={},t=Object.keys(n),r=0,o=t.length;r<o;r+=1)s=t[r],a=String(n[s]),s.slice(0,2)==="!!"&&(s="tag:yaml.org,2002:"+s.slice(2)),l=e.compiledTypeMap.fallback[s],l&&Jt.call(l.styleAliases,a)&&(a=l.styleAliases[a]),i[s]=a;return i}function ta(e){var n,i,t;if(n=e.toString(16).toUpperCase(),e<=255)i="x",t=2;else if(e<=65535)i="u",t=4;else if(e<=4294967295)i="U",t=8;else throw new R("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+i+$.repeat("0",t-n.length)+n}var ra=1,Ve=2;function oa(e){this.schema=e.schema||Vt,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=$.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=ia(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?Ve:ra,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function bt(e,n){for(var i=$.repeat(" ",n),t=0,r=-1,o="",s,a=e.length;t<a;)r=e.indexOf(`
51
+ `,t),r===-1?(s=e.slice(t),t=a):(s=e.slice(t,r+1),t=r+1),s.length&&s!==`
52
+ `&&(o+=i),o+=s;return o}function li(e,n){return`
53
+ `+$.repeat(" ",e.indent*n)}function sa(e,n){var i,t,r;for(i=0,t=e.implicitTypes.length;i<t;i+=1)if(r=e.implicitTypes[i],r.resolve(n))return!0;return!1}function fn(e){return e===js||e===Vs}function Me(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==hi||65536<=e&&e<=1114111}function Ot(e){return Me(e)&&e!==hi&&e!==Ms&&e!==Re}function kt(e,n,i){var t=Ot(e),r=t&&!fn(e);return(i?t:t&&e!==Zt&&e!==Xt&&e!==Qt&&e!==er&&e!==nr)&&e!==ai&&!(n===pn&&!r)||Ot(n)&&!fn(n)&&e===ai||n===pn&&r}function aa(e){return Me(e)&&e!==hi&&!fn(e)&&e!==zs&&e!==Js&&e!==pn&&e!==Zt&&e!==Xt&&e!==Qt&&e!==er&&e!==nr&&e!==ai&&e!==qs&&e!==Ys&&e!==Hs&&e!==Qs&&e!==Gs&&e!==Ks&&e!==Ws&&e!==Us&&e!==Bs&&e!==Zs&&e!==Xs}function la(e){return!fn(e)&&e!==pn}function De(e,n){var i=e.charCodeAt(n),t;return i>=55296&&i<=56319&&n+1<e.length&&(t=e.charCodeAt(n+1),t>=56320&&t<=57343)?(i-55296)*1024+t-56320+65536:i}function ir(e){var n=/^\n* /;return n.test(e)}var tr=1,ui=2,rr=3,or=4,Se=5;function ua(e,n,i,t,r,o,s,a){var l,u=0,c=null,p=!1,f=!1,d=t!==-1,h=-1,_=aa(De(e,0))&&la(De(e,e.length-1));if(n||s)for(l=0;l<e.length;u>=65536?l+=2:l++){if(u=De(e,l),!Me(u))return Se;_=_&&kt(u,c,a),c=u}else{for(l=0;l<e.length;u>=65536?l+=2:l++){if(u=De(e,l),u===Re)p=!0,d&&(f=f||l-h-1>t&&e[h+1]!==" ",h=l);else if(!Me(u))return Se;_=_&&kt(u,c,a),c=u}f=f||d&&l-h-1>t&&e[h+1]!==" "}return!p&&!f?_&&!s&&!r(e)?tr:o===Ve?Se:ui:i>9&&ir(e)?Se:s?o===Ve?Se:ui:f?or:rr}function ca(e,n,i,t,r){e.dump=(function(){if(n.length===0)return e.quotingType===Ve?'""':"''";if(!e.noCompatMode&&(ea.indexOf(n)!==-1||na.test(n)))return e.quotingType===Ve?'"'+n+'"':"'"+n+"'";var o=e.indent*Math.max(1,i),s=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),a=t||e.flowLevel>-1&&i>=e.flowLevel;function l(u){return sa(e,u)}switch(ua(n,a,e.indent,s,l,e.quotingType,e.forceQuotes&&!t,r)){case tr:return n;case ui:return"'"+n.replace(/'/g,"''")+"'";case rr:return"|"+$t(n,e.indent)+Pt(bt(n,o));case or:return">"+$t(n,e.indent)+Pt(bt(pa(n,s),o));case Se:return'"'+fa(n)+'"';default:throw new R("impossible error: invalid scalar style")}})()}function $t(e,n){var i=ir(e)?String(n):"",t=e[e.length-1]===`
54
+ `,r=t&&(e[e.length-2]===`
55
+ `||e===`
56
+ `),o=r?"+":t?"":"-";return i+o+`
57
+ `}function Pt(e){return e[e.length-1]===`
58
+ `?e.slice(0,-1):e}function pa(e,n){for(var i=/(\n+)([^\n]*)/g,t=(function(){var u=e.indexOf(`
59
+ `);return u=u!==-1?u:e.length,i.lastIndex=u,It(e.slice(0,u),n)})(),r=e[0]===`
60
+ `||e[0]===" ",o,s;s=i.exec(e);){var a=s[1],l=s[2];o=l[0]===" ",t+=a+(!r&&!o&&l!==""?`
61
+ `:"")+It(l,n),r=o}return t}function It(e,n){if(e===""||e[0]===" ")return e;for(var i=/ [^ ]/g,t,r=0,o,s=0,a=0,l="";t=i.exec(e);)a=t.index,a-r>n&&(o=s>r?s:a,l+=`
62
+ `+e.slice(r,o),r=o+1),s=a;return l+=`
63
+ `,e.length-r>n&&s>r?l+=e.slice(r,s)+`
64
+ `+e.slice(s+1):l+=e.slice(r),l.slice(1)}function fa(e){for(var n="",i=0,t,r=0;r<e.length;i>=65536?r+=2:r++)i=De(e,r),t=F[i],!t&&Me(i)?(n+=e[r],i>=65536&&(n+=e[r+1])):n+=t||ta(i);return n}function da(e,n,i){var t="",r=e.tag,o,s,a;for(o=0,s=i.length;o<s;o+=1)a=i[o],e.replacer&&(a=e.replacer.call(i,String(o),a)),(X(e,n,a,!1,!1)||typeof a>"u"&&X(e,n,null,!1,!1))&&(t!==""&&(t+=","+(e.condenseFlow?"":" ")),t+=e.dump);e.tag=r,e.dump="["+t+"]"}function Tt(e,n,i,t){var r="",o=e.tag,s,a,l;for(s=0,a=i.length;s<a;s+=1)l=i[s],e.replacer&&(l=e.replacer.call(i,String(s),l)),(X(e,n+1,l,!0,!0,!1,!0)||typeof l>"u"&&X(e,n+1,null,!0,!0,!1,!0))&&((!t||r!=="")&&(r+=li(e,n)),e.dump&&Re===e.dump.charCodeAt(0)?r+="-":r+="- ",r+=e.dump);e.tag=o,e.dump=r||"[]"}function ha(e,n,i){var t="",r=e.tag,o=Object.keys(i),s,a,l,u,c;for(s=0,a=o.length;s<a;s+=1)c="",t!==""&&(c+=", "),e.condenseFlow&&(c+='"'),l=o[s],u=i[l],e.replacer&&(u=e.replacer.call(i,l,u)),X(e,n,l,!1,!1)&&(e.dump.length>1024&&(c+="? "),c+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),X(e,n,u,!1,!1)&&(c+=e.dump,t+=c));e.tag=r,e.dump="{"+t+"}"}function ga(e,n,i,t){var r="",o=e.tag,s=Object.keys(i),a,l,u,c,p,f;if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys=="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new R("sortKeys must be a boolean or a function");for(a=0,l=s.length;a<l;a+=1)f="",(!t||r!=="")&&(f+=li(e,n)),u=s[a],c=i[u],e.replacer&&(c=e.replacer.call(i,u,c)),X(e,n+1,u,!0,!0,!0)&&(p=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,p&&(e.dump&&Re===e.dump.charCodeAt(0)?f+="?":f+="? "),f+=e.dump,p&&(f+=li(e,n)),X(e,n+1,c,!0,p)&&(e.dump&&Re===e.dump.charCodeAt(0)?f+=":":f+=": ",f+=e.dump,r+=f));e.tag=o,e.dump=r||"{}"}function Ft(e,n,i){var t,r,o,s,a,l;for(r=i?e.explicitTypes:e.implicitTypes,o=0,s=r.length;o<s;o+=1)if(a=r[o],(a.instanceOf||a.predicate)&&(!a.instanceOf||typeof n=="object"&&n instanceof a.instanceOf)&&(!a.predicate||a.predicate(n))){if(i?a.multi&&a.representName?e.tag=a.representName(n):e.tag=a.tag:e.tag="?",a.represent){if(l=e.styleMap[a.tag]||a.defaultStyle,Kt.call(a.represent)==="[object Function]")t=a.represent(n,l);else if(Jt.call(a.represent,l))t=a.represent[l](n,l);else throw new R("!<"+a.tag+'> tag resolver accepts not "'+l+'" style');e.dump=t}return!0}return!1}function X(e,n,i,t,r,o,s){e.tag=null,e.dump=i,Ft(e,i,!1)||Ft(e,i,!0);var a=Kt.call(e.dump),l=t,u;t&&(t=e.flowLevel<0||e.flowLevel>n);var c=a==="[object Object]"||a==="[object Array]",p,f;if(c&&(p=e.duplicates.indexOf(i),f=p!==-1),(e.tag!==null&&e.tag!=="?"||f||e.indent!==2&&n>0)&&(r=!1),f&&e.usedDuplicates[p])e.dump="*ref_"+p;else{if(c&&f&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),a==="[object Object]")t&&Object.keys(e.dump).length!==0?(ga(e,n,e.dump,r),f&&(e.dump="&ref_"+p+e.dump)):(ha(e,n,e.dump),f&&(e.dump="&ref_"+p+" "+e.dump));else if(a==="[object Array]")t&&e.dump.length!==0?(e.noArrayIndent&&!s&&n>0?Tt(e,n-1,e.dump,r):Tt(e,n,e.dump,r),f&&(e.dump="&ref_"+p+e.dump)):(da(e,n,e.dump),f&&(e.dump="&ref_"+p+" "+e.dump));else if(a==="[object String]")e.tag!=="?"&&ca(e,e.dump,n,o,l);else{if(a==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new R("unacceptable kind of an object to dump "+a)}e.tag!==null&&e.tag!=="?"&&(u=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?u="!"+u:u.slice(0,18)==="tag:yaml.org,2002:"?u="!!"+u.slice(18):u="!<"+u+">",e.dump=u+" "+e.dump)}return!0}function ma(e,n){var i=[],t=[],r,o;for(ci(e,i,t),r=0,o=t.length;r<o;r+=1)n.duplicates.push(i[t[r]]);n.usedDuplicates=new Array(o)}function ci(e,n,i){var t,r,o;if(e!==null&&typeof e=="object")if(r=n.indexOf(e),r!==-1)i.indexOf(r)===-1&&i.push(r);else if(n.push(e),Array.isArray(e))for(r=0,o=e.length;r<o;r+=1)ci(e[r],n,i);else for(t=Object.keys(e),r=0,o=t.length;r<o;r+=1)ci(e[t[r]],n,i)}function va(e,n){n=n||{};var i=new oa(n);i.noRefs||ma(e,i);var t=e;return i.replacer&&(t=i.replacer.call({"":t},"",t)),X(i,0,t,!0,!0)?i.dump+`
65
+ `:""}var _a=va,xa={dump:_a};function gi(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var hn=Gt.load,Al=Gt.loadAll,Cl=xa.dump;var wl=gi("safeLoad","load"),El=gi("safeLoadAll","loadAll"),bl=gi("safeDump","dump");var vi=ur.platform()==="win32";function mi(e,n){return e.replace(/\{\{\s*env\.url\s*\}\}/g,n.envUrl??"").replace(/\{\{\s*env\.name\s*\}\}/g,n.envName??"").replace(/\{\{\s*solution\.name\s*\}\}/g,n.solutionName??"").replace(/\{\{\s*project\.path\s*\}\}/g,n.projectPath??"").replace(/\{\{\s*project\.name\s*\}\}/g,n.projectName??"").replace(/\{\{\s*auth\.clientId\s*\}\}/g,n.clientId??"").replace(/\{\{\s*auth\.tenantId\s*\}\}/g,n.tenantId??"").replace(/\{\{\s*auth\.clientSecret\s*\}\}/g,n.clientSecret??"")}function ar(e){let n=[],i=/"([^"]*)"|'([^']*)'|(\S+)/g,t;for(;(t=i.exec(e))!==null;)n.push(t[1]??t[2]??t[3]??"");return n}var ya=" ";function pr(e,n,i,t){return new Promise((r,o)=>{let s=(0,cr.spawn)(e,n,{cwd:i,shell:!1,stdio:["ignore","pipe","pipe"]}),a="",l="",u=p=>{process.stdout.write((p.trim()?ya+p:"")+`
66
+ `)},c=(p,f)=>{let d=(f==="out"?a:l)+p.toString(),h=d.split(`
67
+ `);d=h.pop()??"";for(let _ of h){let y=_.replace(/\r$/,"");u(y),t&&y.trim()&&Hn(y)}f==="out"?a=d:l=d};s.stdout.on("data",p=>c(p,"out")),s.stderr.on("data",p=>c(p,"err")),s.on("error",o),s.on("close",p=>{for(let f of[a,l]){let d=f.replace(/\r$/,"");d.trim()&&(u(d),t&&Hn(d))}a="",l="",r(p??0)})})}async function Sa(e,n){if(e.enabled===!1){Ie(e.name,{type:e.type,message:"disabled"});return}Ki(e.name,{type:e.type});let i=mi(e.run??"",n),t=e.script?O.resolve(n.scriptBaseDir??n.solutionDir??n.projectPath??process.cwd(),e.script):void 0,r,o;switch(e.type){case"pac":r=q,o=ar(i.replace(/^pac\s+/,""));break;case"az":r="az",o=ar(i.replace(/^az\s+/,""));break;case"pwsh":case"powershell":{if(r=e.type==="pwsh"?"pwsh":vi?"powershell.exe":"pwsh",t){if(o=["-NoProfile","-NonInteractive","-File",t],e.params)for(let[a,l]of Object.entries(e.params))o.push(`-${a}`,mi(l,n))}else o=["-NoProfile","-NonInteractive","-Command",i];break}case"node":{if(!t){Ie(e.name,{type:e.type,message:'requires a "script" field'});return}if(r="node",o=[t],e.params)for(let[a,l]of Object.entries(e.params))o.push(`--${a}`,mi(l,n));break}case"rest":Ie(e.name,{type:e.type,message:"rest steps are not supported in the CLI runner"});return;default:Ie(e.name,{type:e.type,message:"unknown step type"});return}let s;try{s=await pr(r,o,n.projectPath??process.cwd(),!0)}catch(a){let l=a instanceof Error?a.message:String(a);throw jn(e.name,`Failed to start ${r}: ${l}`,{type:e.type}),new Error(`Failed to start ${r}: ${l}`)}if(s!==0)throw jn(e.name,`exited with code ${s}`,{type:e.type}),new Error(`Step "${e.name}" exited with code ${s}`);Ji(e.name,{type:e.type})}async function lr(e,n,i,t,r,o){let s;try{let l=hn(Ee.readFileSync(n,"utf-8"));s=Array.isArray(l?.steps)?l.steps:[]}catch(l){let u=l instanceof Error?l.message:String(l);r&&(Z(e,u),C(`Failed to parse ${O.basename(n)}: ${u}`)),A(`Failed to parse ${O.basename(n)}: ${u} \u2014 skipping.`);return}if(s.length===0){m(e,`No steps in ${O.basename(n)}.`);return}let a={envUrl:t,...o,scriptBaseDir:i,clientId:process.env.PPDEVOPS_CLIENT_ID,tenantId:process.env.PPDEVOPS_TENANT_ID,clientSecret:process.env.PPDEVOPS_CLIENT_SECRET};P(e,`Running ${O.basename(n)} (${s.length} step${s.length===1?"":"s"})`);for(let l of s)Gi(l.name,{type:l.type});try{for(let l of s)await Sa(l,a);b(e,`${O.basename(n)} completed.`)}catch(l){let u=l instanceof Error?l.message:String(l);r&&(Z(e,u),C(`Action failed: ${u}`)),A(`Action failed (non-fatal): ${u}`)}}function Aa(e,n){let i=[".ps1",".sh",...vi?[".bat"]:[]];for(let t of i){let r=O.join(e,n+t);if(Ee.existsSync(r))return r}return null}async function Ca(e,n,i=[]){let t=O.extname(e).toLowerCase(),r,o;t===".ps1"?(r=vi?"powershell.exe":"pwsh",o=["-NoProfile","-NonInteractive","-File",e,n,...i]):t===".sh"?(r="bash",o=[e,n,...i]):(r="cmd.exe",o=["/c",e,n,...i]);let s;try{s=await pr(r,o,process.cwd(),!1)}catch(a){throw new Error(`Failed to start ${r}: ${a instanceof Error?a.message:String(a)}`)}if(s!==0)throw new Error(`Script exited with code ${s}`)}async function gn(e,n,i,t,r=!0,o=[],s){if(!n||n==="False"||n===""){m(e,"No script configured.");return}let a=/\.(ps1|sh|bat|yaml|yml)$/i.test(n);if(a){if(/\.(yaml|yml)$/i.test(n)){let u=O.isAbsolute(n)?n:O.join(i,n);await lr(e,u,i,t,r,s);return}}else{let u=O.isAbsolute(n)?`${n}.yaml`:O.join(i,`${n}.yaml`);if(Ee.existsSync(u)){await lr(e,u,i,t,r,s);return}}let l=a?O.isAbsolute(n)?n:O.join(i,n):Aa(i,n);if(!l||!Ee.existsSync(l)){r&&C(`Script not found: ${n} (looked in ${i})`),A(`Script not found: ${n} \u2014 skipping.`);return}P(e,`Running ${O.basename(l)}`);try{await Ca(l,t,o),b(e,`${O.basename(l)} completed.`)}catch(u){let c=u instanceof Error?u.message:String(u);r&&(Z(e,c),C(`Script failed: ${c}`)),A(`Script failed (non-fatal): ${c}`)}}var x=S(K()),be=e=>e===!0||String(e).toLowerCase()==="true",wa=e=>!!e&&e.toLowerCase()!=="false"&&e.toLowerCase()!=="true"&&e.trim()!=="";function Ea(e,n){let i=e.clientId??process.env.PPDEVOPS_CLIENT_ID,t=e.clientSecret??process.env.PPDEVOPS_CLIENT_SECRET,r=e.tenantId??process.env.PPDEVOPS_TENANT_ID;if((!i||!t||!r)&&I.existsSync(n))try{let o=JSON.parse(I.readFileSync(n,"utf-8"));i??=o.ClientID??o.clientId,r??=o.TenantID??o.tenantId}catch{}return(!i||!t||!r)&&C("Missing credentials. Provide --client-id, --client-secret, --tenant-id or set PPDEVOPS_CLIENT_ID / PPDEVOPS_CLIENT_SECRET / PPDEVOPS_TENANT_ID."),{clientId:i,clientSecret:t,tenantId:r}}function ba(e){let i=I.readdirSync(e).filter(t=>t.endsWith(".json")&&t!=="package.json").find(t=>!["deployPackages","Environments","tsconfig","package-lock"].some(r=>t.startsWith(r)));return M.join(e,i??"")}function Oa(e,n){let i=M.join(e,n,`${n}.version`);if(!I.existsSync(i))return[];try{return JSON.parse(I.readFileSync(i,"utf-8"))}catch{return[]}}function ka(e,n){let i=e.SolutionName,t=n.find(o=>(o.SolutionUniqueName??o.uniquename??"").toLowerCase()===i.toLowerCase()),r=t?t.VersionNumber??t.Version??t.version??null:null;return r&&Zn(r,e.Version)?(m(x.RunnerStage.VersionCheck,`Patch ${i}: installed (${r}) >= local (${e.Version}) \u2014 skipping.`),{skip:!0,installedVersion:r}):(b(x.RunnerStage.VersionCheck,r?`Patch ${i}: upgrading ${r} \u2192 ${e.Version}`:`Patch ${i}: not installed \u2014 fresh deploy (${e.Version})`),{skip:!1,installedVersion:r})}async function $a(e,n,i,t,r,o){let s=e.SolutionName,a=i.EnvironmentURL,l=M.join(t,s,"src"),u=M.join(_i.tmpdir(),`ppdevops-${s}-${Date.now()}`),c=M.join(t,s),f=Oa(t,s).slice(1).filter(v=>v.SolutionName!==s),d=f.length>0;Bi(s);let h="done",_,y=ct(t,s,a,o),D=y.isFirstDeploy;if(qi({fromVersion:y.installedVersion,toVersion:y.localVersion}),y.skip){let v=`Solution is up-to-date (${y.installedVersion}).`;h="skipped",_=v,m(x.RunnerStage.SolutionCheck,v),m(x.RunnerStage.SolutionPack,v),m(x.RunnerStage.PreAction,v),m(x.RunnerStage.Import,v),m(x.RunnerStage.Upgrade,v),m(x.RunnerStage.PostAction,v),m(x.RunnerStage.Cleanup,v),rn(a,l,n,!1),await an(a,c,n,!1);try{I.rmSync(u,{recursive:!0,force:!0})}catch{}}else{let v=M.join(l,"Other","Customizations.xml");if(!I.existsSync(v)){Z(x.RunnerStage.SolutionCheck,`Unpacked source not found at ${l} \u2014 run Export & Unpack first.`),m(x.RunnerStage.SolutionPack,"Source check failed."),m(x.RunnerStage.PreAction,"Source check failed."),m(x.RunnerStage.Import,"Source check failed."),m(x.RunnerStage.Upgrade,"Source check failed."),m(x.RunnerStage.DataImport,"Source check failed."),m(x.RunnerStage.FlowActivation,"Source check failed."),m(x.RunnerStage.PostAction,"Source check failed."),m(x.RunnerStage.Cleanup,"Source check failed."),zi(`Unpacked source not found for ${s}.`);return}b(x.RunnerStage.SolutionCheck,`Source verified for ${s}.`);let L=await Gn(l,s,u,n.DeploymentType??"Managed");if(!L)A(`[${s}] Skipping root deploy \u2014 solution could not be packed.`),m(x.RunnerStage.PreAction,"Pack failed."),m(x.RunnerStage.Import,"Pack failed."),m(x.RunnerStage.Upgrade,"Pack failed."),rn(a,l,n,D),await an(a,c,n,!1),m(x.RunnerStage.PostAction,"Pack failed."),m(x.RunnerStage.Cleanup,"Pack failed.");else{let je=L.managedZip??L.unmanagedZip;if(be(n.PreAction)?await gn(x.RunnerStage.PreAction,"Scripts/PreAction",c,a,!1,["-EnvironmentName",i.EnvironmentName,"-Path",t],{envName:i.EnvironmentName,projectPath:t,solutionName:s,solutionDir:l}):m(x.RunnerStage.PreAction,"No pre-action configured."),r.dryRun)w(`[DRY RUN] Would import ${s} (${n.DeploymentType}) to ${i.EnvironmentName}`),m(x.RunnerStage.Import,"Dry run \u2014 not imported."),m(x.RunnerStage.Upgrade,"Dry run \u2014 upgrade skipped."),m(x.RunnerStage.DataImport,"Dry run \u2014 data import skipped."),m(x.RunnerStage.FlowActivation,"Dry run \u2014 flow activation skipped.");else{let ke=n.SettingsFile?M.resolve(c,n.SettingsFile):void 0;await ei({environmentUrl:a,managedZip:je,solutionName:s,target:n,deploymentSettingsPath:ke})?await ni(a,s):be(n.DeployAsHolding)||m(x.RunnerStage.Upgrade,"No holding solution upgrade required."),rn(a,l,n,D),await an(a,c,n,!0)}be(n.PostAction)?await gn(x.RunnerStage.PostAction,"Scripts/PostAction",c,a,!1,["-EnvironmentName",i.EnvironmentName,"-Path",t],{envName:i.EnvironmentName,projectPath:t,solutionName:s,solutionDir:l}):m(x.RunnerStage.PostAction,"No post-action configured."),wa(n.CleanupAction)?await gn(x.RunnerStage.Cleanup,n.CleanupAction,c,a,!1):m(x.RunnerStage.Cleanup,"No cleanup action configured.")}try{I.rmSync(u,{recursive:!0,force:!0})}catch{}}d&&w(`[${s}] Processing ${f.length} patch solution(s) from version manifest.`);for(let v of f){let L=v.SolutionName,je=M.join(t,s,`pac_${L}`,"src"),ke=M.join(_i.tmpdir(),`ppdevops-${L}-${Date.now()}`);P(x.RunnerStage.VersionCheck,`Checking version of patch ${L}`);let{skip:yi}=ka(v,o);if(yi)continue;let mr=M.join(je,"Other","Customizations.xml");if(!I.existsSync(mr)){A(`[${L}] pac_${L}/src/Other/Customizations.xml not found \u2014 run Export & Unpack to obtain the patch source. Skipping.`);continue}let _n=await Gn(je,L,ke,n.DeploymentType??"Managed");if(!_n){A(`[${L}] Skipping patch deploy \u2014 solution could not be packed.`);try{I.rmSync(ke,{recursive:!0,force:!0})}catch{}continue}let vr=_n.managedZip??_n.unmanagedZip;r.dryRun?w(`[DRY RUN] Would import patch ${L} (${n.DeploymentType}) to ${i.EnvironmentName}`):await ei({environmentUrl:a,managedZip:vr,solutionName:L,target:n,deploymentSettingsPath:void 0})&&await ni(a,L);try{I.rmSync(ke,{recursive:!0,force:!0})}catch{}}h==="skipped"?Yi(_):Wi(_)}var fr=new le("deploy").description("Deploy one or more Power Platform solutions to a target environment").requiredOption("-p, --project <path>","Path to the project root (contains deployPackages.json)").requiredOption("-e, --environment <name>","Target environment name (from Environments.json)").option("-s, --solutions <names>","Comma-separated solution names to deploy (default: all)").option("--client-id <id>","Service principal client ID").option("--client-secret <secret>","Service principal client secret").option("--tenant-id <id>","Azure tenant ID").option("--profile-name <name>","PAC auth profile name (default: ppdo-cli)").option("--json","Output structured JSON events (for CI/Studio integration)",!1).option("--dry-run","Validate and pack only \u2014 do not import",!1).action(async e=>{qe(e.json);let n=M.resolve(e.project);I.existsSync(n)||C(`Project path not found: ${n}`);let{deployPackages:i,environments:t}=ze(n),r=Ge(t,e.environment),s=Ke(i,e.solutions?e.solutions.split(",").map(p=>p.trim()):null).filter(p=>p.DeployTo?.some(f=>f.EnvironmentName.toLowerCase()===e.environment.toLowerCase()&&be(f.Deploy)));if(s.length===0){A(`No solutions are configured to deploy to "${e.environment}". Nothing to do.`),pe(0);return}w(`Deploying ${s.length} solution(s) to ${e.environment} (${r.EnvironmentURL})`),Ui(r.EnvironmentName,{environment:r.EnvironmentURL});let a=ba(n),l=Ea(e,a),u=e.profileName??"ppdo-cli",c=!1;try{e.dryRun||(await nt({...l,environmentUrl:r.EnvironmentURL,profileName:u}),await it({...l,environmentUrl:r.EnvironmentURL}),c=!0),be(r.PreAction)&&r.PreFunctions?.length?(A(`[EnvPreAction] Skipping env-level functions (${r.PreFunctions.join(", ")}): legacy PS functions require a CRM $Conn object not available in next-gen runner. Migrate to explicit script files to run with ppdevops-cli.`),m(x.RunnerStage.EnvPreAction,`Skipped \u2014 legacy $Conn functions (${r.PreFunctions.join(", ")}) require migration.`)):m(x.RunnerStage.EnvPreAction,"No env pre-action configured."),w(`Fetching installed solutions from ${r.EnvironmentURL} (one-time cache)\u2026`);let p=await en(r.EnvironmentURL);for(let f of s){let d=f.DeployTo.find(h=>h.EnvironmentName.toLowerCase()===e.environment.toLowerCase());await $a(f,d,r,n,e,p)}if(be(r.PostAction)&&r.PostFunctions?.length){let f=M.join(n,"Common","Environments","Scripts","PostAction.ps1");I.existsSync(f)&&A(`[EnvPostAction] Skipping env-level functions (${r.PostFunctions.join(", ")}): legacy PS functions require a CRM $Conn object not available in next-gen runner. Migrate to explicit script files to run with ppdevops-cli.`),m(x.RunnerStage.EnvPostAction,"Skipped \u2014 legacy $Conn functions require migration.")}else m(x.RunnerStage.EnvPostAction,"No env post-action configured.");Vn(0),pe(0),process.exit(0)}catch(p){let f=p instanceof Error?p.message:String(p);Vn(1),C(f)}finally{c&&tt(u),rt()}});var te=S(require("path")),Oe=S(require("fs"));var mn=e=>e===!0||String(e).toLowerCase()==="true";function dr(e,n){let i=te.join(e,`${n}.yaml`);if(Oe.existsSync(i))try{return(hn(Oe.readFileSync(i,"utf-8"))?.steps??[]).map(r=>({name:r.name,type:r.type,enabled:r.enabled!==!1}))}catch{return[]}for(let t of[".ps1",".sh",".bat"])if(Oe.existsSync(te.join(e,`${n}${t}`)))return[{name:`${te.basename(n)}${t}`,type:"script",enabled:!0}];return[]}var hr=new le("plan").description("Dry-run pre-flight: report what a deployment will do without changing anything").requiredOption("-p, --project <path>","Path to the project root (contains deployPackages.json)").requiredOption("-e, --environment <name>","Target environment name (from Environments.json)").option("-s, --solutions <names>","Comma-separated solution names to plan (default: all)").option("--client-id <id>","Service principal client ID").option("--client-secret <secret>","Service principal client secret").option("--tenant-id <id>","Azure tenant ID").option("--json","Output structured JSON events (for CI/Studio integration)",!1).action(async e=>{qe(e.json);let n=te.resolve(e.project);Oe.existsSync(n)||C(`Project path not found: ${n}`);let{deployPackages:i,environments:t}=ze(n),r=Ge(t,e.environment),s=Ke(i,e.solutions?e.solutions.split(",").map(a=>a.trim()):null).filter(a=>a.DeployTo?.some(l=>l.EnvironmentName.toLowerCase()===e.environment.toLowerCase()&&mn(l.Deploy)));if(Zi(r.EnvironmentName,r.EnvironmentURL),s.length===0){A(`No solutions are configured to deploy to "${e.environment}".`),Un(),pe(0);return}try{w(`Querying installed solutions on ${r.EnvironmentURL}\u2026`);let a=await en(r.EnvironmentURL);for(let l of s){let u=l.DeployTo.find(y=>y.EnvironmentName.toLowerCase()===e.environment.toLowerCase()),c=l.SolutionName,p=Xn(n,c,a),f=p.skip?"skip":p.isFirstDeploy?"install":"upgrade",d=te.join(n,c),h=f!=="skip"&&mn(u.PreAction)?dr(d,"Scripts/PreAction"):[],_=f!=="skip"&&mn(u.PostAction)?dr(d,"Scripts/PostAction"):[];Xi({name:c,fromVersion:p.installedVersion,toVersion:p.localVersion,plan:{action:f,deploymentType:u.DeploymentType??"Managed",deployData:mn(u.DeployData),preActions:h,postActions:_}})}Un(),pe(0)}catch(a){let l=a instanceof Error?a.message:String(a);C(l)}});var xi={version:"1.0.0-beta.1",commit:"3c2c2f0",builtOn:"2026-09-15T02:32:15Z"};function gr(){return`${xi.version} (${xi.commit}, built ${xi.builtOn})`}var vn=new le;vn.name("ppdevops").description("Power Platform DevOps Studio CLI \u2014 cross-platform solution deployment runner").version(gr());vn.addCommand(fr);vn.addCommand(hr);vn.parseAsync(process.argv).catch(e=>{console.error("Fatal error:",e instanceof Error?e.message:String(e)),process.exit(1)});
68
+ /*! Bundled license information:
69
+
70
+ js-yaml/dist/js-yaml.mjs:
71
+ (*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
72
+ */