@gadgetinc/ggt 1.7.3 → 2.2.0
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/README.md +142 -31
- package/dist/{add-VP2I3CKE.js → add-TWLGKL2T.js} +9 -8
- package/dist/add-TWLGKL2T.js.map +7 -0
- package/dist/agent-plugin-TN24O7FB.js +10 -0
- package/dist/agent-plugin-TN24O7FB.js.map +7 -0
- package/dist/chunk-2742UPMB.js +10 -0
- package/dist/chunk-2742UPMB.js.map +7 -0
- package/dist/chunk-3OM5WM7E.js +2 -0
- package/dist/chunk-3OM5WM7E.js.map +7 -0
- package/dist/chunk-442CSROP.js +66 -0
- package/dist/chunk-442CSROP.js.map +7 -0
- package/dist/chunk-DR4CXBD6.js +11 -0
- package/dist/chunk-DR4CXBD6.js.map +7 -0
- package/dist/chunk-F255O64V.js +2 -0
- package/dist/chunk-F255O64V.js.map +7 -0
- package/dist/chunk-GJGBTM5Y.js +2 -0
- package/dist/chunk-GJGBTM5Y.js.map +7 -0
- package/dist/chunk-HCULGPBH.js +2 -0
- package/dist/chunk-HCULGPBH.js.map +7 -0
- package/dist/chunk-J232VCIM.js +2 -0
- package/dist/chunk-J232VCIM.js.map +7 -0
- package/dist/chunk-JG2QCDK2.js +118 -0
- package/dist/chunk-JG2QCDK2.js.map +7 -0
- package/dist/chunk-JKZNSRLU.js +8 -0
- package/dist/chunk-JKZNSRLU.js.map +7 -0
- package/dist/chunk-JYE5LLIF.js +9 -0
- package/dist/chunk-JYE5LLIF.js.map +7 -0
- package/dist/{chunk-SX5LO3XQ.js → chunk-KKIL22RY.js} +1 -1
- package/dist/{chunk-SX5LO3XQ.js.map → chunk-KKIL22RY.js.map} +1 -1
- package/dist/chunk-L2XBSR7G.js +2 -0
- package/dist/chunk-L2XBSR7G.js.map +7 -0
- package/dist/chunk-MW6MXMSN.js +2 -0
- package/dist/chunk-MW6MXMSN.js.map +7 -0
- package/dist/chunk-OUIZQC4D.js +12 -0
- package/dist/chunk-OUIZQC4D.js.map +7 -0
- package/dist/chunk-R6KJLEKY.js +28 -0
- package/dist/chunk-R6KJLEKY.js.map +7 -0
- package/dist/chunk-SIR6HLN3.js +69 -0
- package/dist/chunk-SIR6HLN3.js.map +7 -0
- package/dist/chunk-SVWK2NXG.js +2 -0
- package/dist/chunk-SVWK2NXG.js.map +7 -0
- package/dist/chunk-T6UHSWMT.js +2 -0
- package/dist/{chunk-IZO5RL5L.js.map → chunk-T6UHSWMT.js.map} +2 -2
- package/dist/{chunk-JSGXXXFU.js → chunk-WB6O2V5D.js} +6 -6
- package/dist/{chunk-JSGXXXFU.js.map → chunk-WB6O2V5D.js.map} +3 -3
- package/dist/chunk-XC4F2TLW.js +113 -0
- package/dist/chunk-XC4F2TLW.js.map +7 -0
- package/dist/chunk-YFUOXDPK.js +10 -0
- package/dist/chunk-YFUOXDPK.js.map +7 -0
- package/dist/chunk-ZSREFZXV.js +211 -0
- package/dist/chunk-ZSREFZXV.js.map +7 -0
- package/dist/chunk-ZYDMXS5R.js +6 -0
- package/dist/chunk-ZYDMXS5R.js.map +7 -0
- package/dist/{configure-CXY6JQB7.js → configure-UJS7V2JX.js} +2 -2
- package/dist/configure-UJS7V2JX.js.map +7 -0
- package/dist/debugger-QN2MCLBL.js +41 -0
- package/dist/debugger-QN2MCLBL.js.map +7 -0
- package/dist/deploy-J74PHPQA.js +25 -0
- package/dist/deploy-J74PHPQA.js.map +7 -0
- package/dist/dev-GGUSOOYP.js +59 -0
- package/dist/dev-GGUSOOYP.js.map +7 -0
- package/dist/esm-D77XRR65.js +38 -0
- package/dist/esm-D77XRR65.js.map +7 -0
- package/dist/eval-L6WHUFLU.js +54 -0
- package/dist/eval-L6WHUFLU.js.map +7 -0
- package/dist/getMachineId-bsd-QUXN4NKS.js +2 -0
- package/dist/getMachineId-bsd-QUXN4NKS.js.map +7 -0
- package/dist/getMachineId-darwin-TCXBAX22.js +3 -0
- package/dist/getMachineId-darwin-TCXBAX22.js.map +7 -0
- package/dist/getMachineId-linux-IJ3LYIOX.js +2 -0
- package/dist/getMachineId-linux-IJ3LYIOX.js.map +7 -0
- package/dist/getMachineId-unsupported-IKXBUCYY.js +2 -0
- package/dist/getMachineId-unsupported-IKXBUCYY.js.map +7 -0
- package/dist/getMachineId-win-6CX7VSFF.js +2 -0
- package/dist/getMachineId-win-6CX7VSFF.js.map +7 -0
- package/dist/ggt-5XNRJZSW.js +44 -0
- package/dist/ggt-5XNRJZSW.js.map +7 -0
- package/dist/{list-3QZTSHQV.js → list-756D46N5.js} +2 -2
- package/dist/list-756D46N5.js.map +7 -0
- package/dist/login-GMWQRH7V.js +2 -0
- package/dist/{logout-SWWGI27Q.js → logout-LQABTJFD.js} +2 -2
- package/dist/logout-LQABTJFD.js.map +7 -0
- package/dist/logs-AQZB272X.js +28 -0
- package/dist/logs-AQZB272X.js.map +7 -0
- package/dist/main.js +1 -43
- package/dist/main.js.map +4 -4
- package/dist/{open-65LHZE2M.js → open-OMZWPQ66.js} +11 -11
- package/dist/open-OMZWPQ66.js.map +7 -0
- package/dist/problems-FZJKH52E.js +14 -0
- package/dist/problems-FZJKH52E.js.map +7 -0
- package/dist/pull-XYCYN7QN.js +28 -0
- package/dist/pull-XYCYN7QN.js.map +7 -0
- package/dist/push-3QM7ZFTC.js +2 -0
- package/dist/status-PWAXNK5G.js +14 -0
- package/dist/status-PWAXNK5G.js.map +7 -0
- package/dist/update-QIQFJFRQ.js +2 -0
- package/dist/update-QIQFJFRQ.js.map +7 -0
- package/dist/var-N4WGGJXZ.js +159 -0
- package/dist/var-N4WGGJXZ.js.map +7 -0
- package/dist/{version-NZHW3VLV.js → version-AJKSJJDC.js} +2 -2
- package/dist/version-AJKSJJDC.js.map +7 -0
- package/dist/{whoami-MIJFO4MW.js → whoami-KJYDSQSD.js} +2 -2
- package/dist/whoami-KJYDSQSD.js.map +7 -0
- package/package.json +64 -74
- package/dist/add-VP2I3CKE.js.map +0 -7
- package/dist/chunk-22W3HJQG.js +0 -116
- package/dist/chunk-22W3HJQG.js.map +0 -7
- package/dist/chunk-24OT7GHO.js +0 -65
- package/dist/chunk-24OT7GHO.js.map +0 -7
- package/dist/chunk-DRI75CDO.js +0 -194
- package/dist/chunk-DRI75CDO.js.map +0 -7
- package/dist/chunk-HN3YKQ3C.js +0 -6
- package/dist/chunk-HN3YKQ3C.js.map +0 -7
- package/dist/chunk-IZO5RL5L.js +0 -2
- package/dist/chunk-JBY5A44K.js +0 -7
- package/dist/chunk-JBY5A44K.js.map +0 -7
- package/dist/chunk-L5H5T2T6.js +0 -66
- package/dist/chunk-L5H5T2T6.js.map +0 -7
- package/dist/chunk-MHTXRD5G.js +0 -2
- package/dist/chunk-MHTXRD5G.js.map +0 -7
- package/dist/chunk-OIVNACS7.js +0 -12
- package/dist/chunk-OIVNACS7.js.map +0 -7
- package/dist/chunk-OKVWONGO.js +0 -28
- package/dist/chunk-OKVWONGO.js.map +0 -7
- package/dist/chunk-QXWICGG6.js +0 -2
- package/dist/chunk-QXWICGG6.js.map +0 -7
- package/dist/chunk-WNAYBYSG.js +0 -8
- package/dist/chunk-WNAYBYSG.js.map +0 -7
- package/dist/chunk-X47UA3VR.js +0 -2
- package/dist/chunk-X47UA3VR.js.map +0 -7
- package/dist/chunk-XGQQOMPO.js +0 -2
- package/dist/chunk-XGQQOMPO.js.map +0 -7
- package/dist/configure-CXY6JQB7.js.map +0 -7
- package/dist/deploy-ZRLKAGWM.js +0 -25
- package/dist/deploy-ZRLKAGWM.js.map +0 -7
- package/dist/dev-XI2RDRXJ.js +0 -59
- package/dist/dev-XI2RDRXJ.js.map +0 -7
- package/dist/esm-PLVGBDRY.js +0 -38
- package/dist/esm-PLVGBDRY.js.map +0 -7
- package/dist/list-3QZTSHQV.js.map +0 -7
- package/dist/login-HKGCVIWO.js +0 -2
- package/dist/logout-SWWGI27Q.js.map +0 -7
- package/dist/logs-36QPFIDT.js +0 -28
- package/dist/logs-36QPFIDT.js.map +0 -7
- package/dist/open-65LHZE2M.js.map +0 -7
- package/dist/pull-GS2VSBLT.js +0 -28
- package/dist/pull-GS2VSBLT.js.map +0 -7
- package/dist/push-4LGFNWTC.js +0 -2
- package/dist/status-6QVAIYUR.js +0 -14
- package/dist/status-6QVAIYUR.js.map +0 -7
- package/dist/version-NZHW3VLV.js.map +0 -7
- package/dist/whoami-MIJFO4MW.js.map +0 -7
- /package/dist/{login-HKGCVIWO.js.map → login-GMWQRH7V.js.map} +0 -0
- /package/dist/{push-4LGFNWTC.js.map → push-3QM7ZFTC.js.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/commands/debugger.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Server as HttpServer, IncomingMessage, ServerResponse } from \"node:http\";\nimport type { Duplex } from \"node:stream\";\n\nimport chalk from \"chalk\";\nimport { randomUUID } from \"node:crypto\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createServer } from \"node:http\";\nimport path from \"node:path\";\nimport process, { nextTick } from \"node:process\";\nimport { WebSocket, WebSocketServer, type RawData } from \"ws\";\n\nimport type { ArgsDefinition } from \"../services/command/arg.js\";\nimport type { Run, Usage } from \"../services/command/command.js\";\nimport type { Context } from \"../services/command/context.js\";\n\nimport { AppIdentity, AppIdentityArgs } from \"../services/command/app-identity.js\";\nimport { config } from \"../services/config/config.js\";\nimport { loadSyncJsonDirectory } from \"../services/filesync/sync-json.js\";\nimport { loadAuthHeaders } from \"../services/http/auth.js\";\nimport { http } from \"../services/http/http.js\";\nimport { LoggingArgs } from \"../services/output/log/structured.js\";\nimport { println } from \"../services/output/print.js\";\nimport { reportErrorAndExit } from \"../services/output/report.js\";\nimport { spin } from \"../services/output/spinner.js\";\nimport { sprint } from \"../services/output/sprint.js\";\nimport { symbol } from \"../services/output/symbols.js\";\n\nexport type DebuggerArgs = typeof args;\n\nconst StartingMessage = \"Starting ggt debugger\";\nconst RunningMessage = \"ggt debugger running on\";\n\nexport const args = {\n ...AppIdentityArgs,\n ...LoggingArgs,\n \"--port\": {\n type: Number,\n alias: [\"-p\"],\n },\n \"--configure\": {\n type: String,\n },\n} satisfies ArgsDefinition;\n\nconst SupportedEditors = [\"vscode\", \"cursor\"] as const;\n\nexport const usage: Usage = (_ctx) => {\n return sprint`\n Start a Chrome DevTools Protocol proxy server that connects to the Gadget debugger.\n This allows you to debug your Gadget app using VS Code, Chrome DevTools, or any other\n CDP-compatible debugger client.\n\n {gray Usage}\n $ ggt debugger [DIRECTORY] [options]\n\n DIRECTORY: The directory containing your Gadget app (default: current directory)\n\n {gray Options}\n -a, --app <app_name> Selects the app to debug. Defaults to the app synced to the current directory, if there is one.\n -e, --env <env_name> Selects the environment to debug. Defaults to the environment synced to the current directory, if there is one.\n -p, --port <port> Local port for the inspector proxy (default: 9229)\n --configure <editor> Configure debugger for ${SupportedEditors.join(\", \")}\n\n {gray Examples}\n start debugger proxy for current environment\n {cyanBright $ ggt debugger}\n\n use a custom port\n {cyanBright $ ggt debugger --port 9230}\n\n debug a specific app and environment\n {cyanBright $ ggt debugger --app myApp --env development}\n\n configure VS Code debugger\n {cyanBright $ ggt debugger --configure vscode}\n `;\n};\n\ntype DebuggerSessionResponse = {\n wsUrl: string;\n lease: {\n sessionId: string;\n startedAt: string;\n expiresAt: string;\n };\n};\n\nexport const run: Run<DebuggerArgs> = async (ctx, args) => {\n const directory = await loadSyncJsonDirectory(args._[0] || process.cwd());\n const appIdentity = await AppIdentity.load(ctx, { command: \"debugger\", args, directory });\n\n // Handle --configure option\n if (args[\"--configure\"]) {\n const editor = args[\"--configure\"].toLowerCase();\n if (!SupportedEditors.includes(editor as (typeof SupportedEditors)[number])) {\n throw new Error(`Invalid editor \"${args[\"--configure\"]}\". Supported editors: ${SupportedEditors.join(\", \")}`);\n }\n\n const configurator = new DebuggerConfigurator(directory.path);\n const port = args[\"--port\"] ?? 9229;\n configurator.configure(port);\n\n println({\n ensureEmptyLineAbove: true,\n content: chalk.green(`${symbol.tick} Configured ${editor} debugger`),\n });\n println({\n content: sprint`\n Added configuration to:\n \u2022 ${configurator.launchJsonPath}\n \u2022 ${configurator.tasksJsonPath}\n\n You can now start debugging by running the \"Gadget debugger\" launch configuration.\n `,\n });\n return;\n }\n\n const spinner = spin(`${StartingMessage} for ${appIdentity.environment.name} environment`);\n ctx.log.info(\"debugger command started\");\n\n ctx.log.trace(\"sync json loaded\", {\n app: appIdentity.environment.application.slug,\n environment: appIdentity.environment.name,\n });\n\n const authHeaders = loadAuthHeaders(ctx);\n const port = args[\"--port\"] ?? 9229;\n const sessionId = randomUUID();\n\n // Check if VS Code launch configuration exists\n const configurator = new DebuggerConfigurator(directory.path);\n if (!configurator.hasLaunchConfiguration()) {\n ctx.log.warn(\"vscode/cursor debugger configuration not found\");\n println({\n ensureEmptyLineAbove: true,\n content: chalk.yellow(\n `\u26A0 Gadget debugger not configured. Run \"${chalk.bold(`ggt debugger --configure ${SupportedEditors[0]}`)}\" to set up.`,\n ),\n });\n }\n\n const proxy = new DebuggerProxy(ctx, {\n appIdentity,\n authHeaders,\n sessionId,\n port,\n });\n\n try {\n await proxy.start();\n\n spinner.succeed();\n println({ ensureEmptyLineAbove: true, content: chalk.green(`${symbol.tick} ${RunningMessage} ws://localhost:${port}/${sessionId}`) });\n println({ content: chalk.gray(\"Press Ctrl+C to stop\") });\n\n await new Promise<void>((resolve) => {\n ctx.onAbort(() => {\n ctx.log.info(\"abort signal received\");\n resolve();\n });\n });\n\n proxy.stop();\n println({ ensureEmptyLineAbove: true, content: `${symbol.tick} Proxy server stopped` });\n } catch (error) {\n ctx.log.error(\"debugger command failed\", { error });\n await reportErrorAndExit(ctx, error);\n }\n};\n\ntype DebuggerProxyOptions = {\n appIdentity: AppIdentity;\n authHeaders: Record<string, string>;\n sessionId: string;\n port: number;\n};\n\n/**\n * Manages the local debugger proxy server that connects CDP clients to the remote Gadget debugger.\n */\nclass DebuggerProxy {\n private readonly _ctx: Context;\n private readonly _appIdentity: AppIdentity;\n private readonly _authHeaders: Record<string, string>;\n private readonly _sessionId: string;\n private readonly _port: number;\n private readonly _subdomain: string;\n\n private _httpServer?: HttpServer;\n private _wsServer?: WebSocketServer;\n private _sessionManager?: DebuggerSessionManager;\n\n constructor(ctx: Context, options: DebuggerProxyOptions) {\n this._ctx = ctx;\n this._appIdentity = options.appIdentity;\n this._authHeaders = options.authHeaders;\n this._sessionId = options.sessionId;\n this._port = options.port;\n this._subdomain = this._buildSubdomain();\n }\n\n async start(): Promise<void> {\n this._sessionManager = new DebuggerSessionManager(this._ctx);\n this._httpServer = this._createHttpServer();\n this._wsServer = new WebSocketServer({ noServer: true });\n\n this._httpServer.on(\"upgrade\", (request, socket, head) => {\n this._handleUpgrade(request, socket, head);\n });\n\n await this._listen();\n }\n\n stop(): void {\n this._ctx.log.debug(\"shutting down proxy server\");\n this._wsServer?.close();\n this._httpServer?.close();\n this._ctx.log.info(\"proxy server stopped\");\n }\n\n private _buildSubdomain(): string {\n const { application, name, type } = this._appIdentity.environment;\n return type === \"production\" ? application.slug : `${application.slug}--${name}`;\n }\n\n private _createHttpServer(): HttpServer {\n return createServer((req, res) => {\n const url = new URL(req.url ?? \"/\", `http://${req.headers.host}`);\n this._ctx.log.trace(\"debugger proxy http request received\", {\n method: req.method,\n rUrl: req.url,\n urlPathname: url.pathname,\n url: url.toString(),\n });\n\n try {\n if (url.pathname === \"/json/version\") {\n this._handleVersionRequest(res);\n } else if (url.pathname === \"/json/list\") {\n this._handleListRequest(res);\n } else {\n this._handleNotFound(res, url);\n }\n } catch (error) {\n this._handleError(res, error);\n }\n });\n }\n\n private _handleVersionRequest(res: ServerResponse): void {\n const versionPayload = {\n \"Protocol-Version\": \"1.1\",\n Browser: `node.js/${this._appIdentity.environment.nodeVersion}`,\n };\n this._ctx.log.trace(\"debugger proxy http version request payload\", { payload: versionPayload });\n res.setHeader(\"Content-Type\", \"application/json\");\n res.end(JSON.stringify(versionPayload));\n }\n\n private _handleListRequest(res: ServerResponse): void {\n const listPayload = [\n {\n id: this._sessionId,\n type: \"node\",\n title: \"ggt debugger\",\n description: `authenticated CDP proxy to current sandbox process for ${this._appIdentity.environment.application.slug}@${this._appIdentity.environment.name}`,\n faviconUrl: \"https://assets.gadget.dev/assets/environment/dev/favicon-32.png\",\n webSocketDebuggerUrl: `ws://127.0.0.1:${this._port}/${this._sessionId}`,\n },\n ];\n this._ctx.log.trace(\"debugger proxy http list request payload\", { payload: listPayload });\n res.setHeader(\"Content-Type\", \"application/json\");\n res.end(JSON.stringify(listPayload));\n }\n\n private _handleNotFound(res: ServerResponse, url: URL): void {\n this._ctx.log.warn(\"debugger proxy http request not found\", { url: url.toString() });\n res.statusCode = 404;\n res.end(\"Not Found\");\n }\n\n private _handleError(res: ServerResponse, error: unknown): void {\n this._ctx.log.error(\"error handling debugger proxy http request\", { error });\n res.statusCode = 500;\n res.end(\"Internal Server Error\");\n }\n\n private _handleUpgrade(request: IncomingMessage, socket: Duplex, head: Buffer): void {\n if (!this._sessionManager || !this._wsServer) {\n socket.destroy();\n return;\n }\n\n const url = new URL(request.url ?? \"/\", `http://${request.headers.host}`);\n this._ctx.log.trace(\"debugger proxy websocket upgrade request received\", {\n url: request.url,\n isConnecting: this._sessionManager.isConnecting,\n hasActiveConnection: this._sessionManager.hasActiveConnection,\n });\n\n if (url.pathname !== `/${this._sessionId}`) {\n socket.destroy();\n return;\n }\n\n if (this._sessionManager.hasActiveConnection || this._sessionManager.isConnecting) {\n this._ctx.log.debug(\"rejecting upgrade request\", {\n hasActiveConnection: this._sessionManager.hasActiveConnection,\n isConnecting: this._sessionManager.isConnecting,\n });\n this._rejectUpgrade(socket);\n return;\n }\n\n this._sessionManager.clearStaleConnection();\n this._acceptUpgrade(request, socket, head);\n }\n\n private _rejectUpgrade(socket: Duplex): void {\n const status = 409;\n const text = \"Another debugger session is already running for this environment\";\n socket.write(`HTTP/1.1 ${status} ${text}\\r\\nConnection: close\\r\\n\\r\\n`);\n socket.destroy();\n }\n\n private _acceptUpgrade(request: IncomingMessage, socket: Duplex, head: Buffer): void {\n if (!this._wsServer || !this._sessionManager) {\n return;\n }\n\n this._wsServer.handleUpgrade(request, socket, head, (clientWs) => {\n this._ctx.log.info(\"client websocket upgraded, establishing remote connection\");\n void this._handleClientConnection(clientWs);\n });\n }\n\n private async _handleClientConnection(clientWs: WebSocket): Promise<void> {\n if (!this._sessionManager) {\n return;\n }\n\n const connection = new ClientConnection(this._ctx, clientWs, this._sessionManager);\n\n try {\n const remoteWs = await this._establishRemoteConnection();\n connection.connectToRemote(remoteWs);\n this._sessionManager.setActiveConnection(clientWs);\n } catch (error) {\n this._ctx.log.error(\"error establishing remote debugger connection\", { error });\n connection.closeWithError(\"Failed to establish remote debugger connection\");\n }\n }\n\n private async _establishRemoteConnection(): Promise<WebSocket> {\n const session = await http<DebuggerSessionResponse>({\n context: { ctx: this._ctx },\n method: \"POST\",\n url: `https://${this._subdomain}.${config.domains.app}/edit/api/debugger/start-session`,\n headers: { ...this._authHeaders, \"x-gadget-debugger-session-id\": this._sessionId },\n responseType: \"json\",\n resolveBodyOnly: true,\n });\n\n this._ctx.log.debug(\"debugger session created\", { session });\n\n const remoteConnection = new RemoteDebuggerConnection(this._ctx, {\n wsUrl: session.wsUrl,\n sessionId: this._sessionId,\n authHeaders: this._authHeaders,\n });\n\n return await remoteConnection.connect();\n }\n\n private async _listen(): Promise<void> {\n if (!this._httpServer) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n const server = this._httpServer;\n if (!server) {\n reject(new Error(\"HTTP server is not initialized\"));\n return;\n }\n server.listen(this._port, \"127.0.0.1\", () => {\n this._ctx.log.info(\"debugger proxy server listening\", { port: this._port });\n resolve();\n });\n server.on(\"error\", reject);\n });\n }\n}\n\n/**\n * Manages the state of active debugger sessions and connections.\n */\nclass DebuggerSessionManager {\n private readonly _ctx: Context;\n private _activeConnection?: WebSocket;\n private _isConnecting = false;\n\n constructor(ctx: Context) {\n this._ctx = ctx;\n }\n\n get hasActiveConnection(): boolean {\n return !!this._activeConnection && this._activeConnection.readyState === WebSocket.OPEN;\n }\n\n get isConnecting(): boolean {\n return this._isConnecting;\n }\n\n setActiveConnection(ws: WebSocket): void {\n this._activeConnection = ws;\n this._isConnecting = false;\n }\n\n clearActiveConnection(): void {\n this._activeConnection = undefined;\n }\n\n clearStaleConnection(): void {\n if (this._activeConnection) {\n this._ctx.log.debug(\"clearing stale connection reference\");\n this._activeConnection = undefined;\n }\n }\n\n startConnecting(): void {\n this._isConnecting = true;\n }\n\n stopConnecting(): void {\n this._isConnecting = false;\n }\n}\n\n/**\n * Manages a client connection from a CDP debugger (VS Code, Chrome DevTools, etc).\n */\nclass ClientConnection {\n private readonly _ctx: Context;\n private readonly _clientWs: WebSocket;\n private readonly _sessionManager: DebuggerSessionManager;\n private readonly _messageQueue: { data: RawData; isBinary: boolean }[] = [];\n private _remoteWs?: WebSocket;\n private _remoteReady = false;\n\n constructor(ctx: Context, clientWs: WebSocket, sessionManager: DebuggerSessionManager) {\n this._ctx = ctx;\n this._clientWs = clientWs;\n this._sessionManager = sessionManager;\n this._setupClientHandlers();\n }\n\n connectToRemote(remoteWs: WebSocket): void {\n this._remoteWs = remoteWs;\n this._setupRemoteHandlers();\n this._flushMessageQueue();\n }\n\n closeWithError(reason: string): void {\n this._sessionManager.stopConnecting();\n this._clientWs.close(1011, reason);\n }\n\n private _setupClientHandlers(): void {\n this._clientWs.on(\"message\", (data: RawData, isBinary: boolean) => {\n this._handleClientMessage(data, isBinary);\n });\n\n this._clientWs.on(\"error\", (error: Error) => {\n this._ctx.log.error(\"client websocket error\", { error: error.message, stack: error.stack });\n this._remoteWs?.close();\n });\n\n this._clientWs.on(\"close\", () => {\n this._ctx.log.info(\"client websocket closed\");\n this._sessionManager.clearActiveConnection();\n this._remoteWs?.close();\n });\n }\n\n private _handleClientMessage(data: RawData, isBinary: boolean): void {\n // oxlint-disable-next-line no-base-to-string\n const messageString = isBinary ? \"<binary data>\" : String(data);\n this._ctx.log.trace(\"received message from client\", { message: messageString });\n\n if (this._remoteReady && this._remoteWs) {\n this._remoteWs.send(data, { binary: isBinary });\n } else {\n this._messageQueue.push({ data, isBinary });\n }\n }\n\n private _setupRemoteHandlers(): void {\n if (!this._remoteWs) {\n return;\n }\n\n this._remoteWs.on(\"message\", (data: RawData, isBinary: boolean) => {\n // oxlint-disable-next-line no-base-to-string\n const messageString = isBinary ? \"<binary data>\" : String(data);\n this._ctx.log.trace(\"received message from remote debugger\", { message: messageString });\n this._clientWs.send(data, { binary: isBinary });\n });\n\n this._remoteWs.on(\"error\", (error: Error) => {\n this._ctx.log.error(\"remote debugger error\", { error: error.message, stack: error.stack });\n this._clientWs.close(1011, \"Remote debugger connection error, please reconnect\");\n });\n\n this._remoteWs.on(\"close\", () => {\n this._ctx.log.info(\"remote debugger connection closed\");\n this._clientWs.close(1011, \"Remote debugger connection closed by server, please reconnect\");\n });\n\n this._remoteReady = true;\n }\n\n private _flushMessageQueue(): void {\n if (!this._remoteWs) {\n return;\n }\n\n this._ctx.log.debug(\"remote debugger connected, flushing message queue\", {\n queueLength: this._messageQueue.length,\n });\n\n for (const { data, isBinary } of this._messageQueue) {\n this._remoteWs.send(data, { binary: isBinary });\n }\n this._messageQueue.length = 0;\n }\n}\n\ntype RemoteDebuggerConnectionOptions = {\n wsUrl: string;\n sessionId: string;\n authHeaders: Record<string, string>;\n};\n\n/**\n * Manages a connection to the remote Gadget debugger WebSocket.\n */\nclass RemoteDebuggerConnection {\n private readonly _ctx: Context;\n private readonly _wsUrl: string;\n private readonly _sessionId: string;\n private readonly _authHeaders: Record<string, string>;\n\n constructor(ctx: Context, options: RemoteDebuggerConnectionOptions) {\n this._ctx = ctx;\n this._wsUrl = options.wsUrl;\n this._sessionId = options.sessionId;\n this._authHeaders = options.authHeaders;\n }\n\n async connect(): Promise<WebSocket> {\n let resolveConnection: () => void;\n let rejectConnection: (error: Error) => void;\n let connected = false;\n\n const connectionPromise = new Promise<void>((resolve, reject) => {\n resolveConnection = resolve;\n rejectConnection = reject;\n });\n\n const ws = new WebSocket(this._wsUrl, {\n headers: { ...this._authHeaders, \"x-gadget-debugger-session-id\": this._sessionId },\n });\n\n ws.on(\"open\", () => {\n this._ctx.log.debug(\"connected to remote debugger\");\n if (connected) {\n return;\n }\n connected = true;\n resolveConnection();\n });\n\n ws.on(\"error\", (error: Error) => {\n this._ctx.log.error(\"remote debugger error\", { error: error.message, stack: error.stack });\n if (!connected) {\n rejectConnection(error);\n }\n });\n\n if (ws.readyState === WebSocket.OPEN) {\n nextTick(() => {\n resolveConnection();\n });\n }\n\n await connectionPromise;\n\n return ws;\n }\n}\n\ntype VSCodeLaunchConfiguration = {\n type: string;\n request: string;\n name: string;\n address: string;\n port: number;\n localRoot: string;\n remoteRoot: string;\n preLaunchTask: string;\n restart: boolean;\n timeout: number;\n};\n\ntype VSCodeTask = {\n label: string;\n type: string;\n command: string;\n isBackground: boolean;\n problemMatcher: {\n pattern: { regexp: string };\n background: {\n activeOnStart: boolean;\n beginsPattern: string;\n endsPattern: string;\n };\n };\n};\n\n/**\n * Handles VS Code/Cursor debugger configuration setup.\n */\nclass DebuggerConfigurator {\n private readonly _vscodeDir: string;\n\n constructor(directory: string) {\n this._vscodeDir = path.join(directory, \".vscode\");\n }\n\n get launchJsonPath(): string {\n return path.join(this._vscodeDir, \"launch.json\");\n }\n\n get tasksJsonPath(): string {\n return path.join(this._vscodeDir, \"tasks.json\");\n }\n\n hasLaunchConfiguration(): boolean {\n if (!existsSync(this.launchJsonPath)) {\n return false;\n }\n\n try {\n const launchJson = JSON.parse(readFileSync(this.launchJsonPath, \"utf-8\")) as {\n configurations?: VSCodeLaunchConfiguration[];\n };\n const configurations = launchJson.configurations ?? [];\n return configurations.some((config) => config.name === \"Gadget debugger\");\n } catch {\n return false;\n }\n }\n\n configure(port: number): void {\n // Ensure .vscode directory exists\n if (!existsSync(this._vscodeDir)) {\n mkdirSync(this._vscodeDir, { recursive: true });\n }\n\n this._configureLaunch(port);\n this._configureTasks();\n }\n\n private _configureLaunch(port: number): void {\n const launchConfig: VSCodeLaunchConfiguration = {\n type: \"node\",\n request: \"attach\",\n name: \"Gadget debugger\",\n address: \"127.0.0.1\",\n port,\n localRoot: \"${workspaceFolder}\",\n remoteRoot: \"/gadget/app\",\n preLaunchTask: \"ggt debugger\",\n restart: true,\n timeout: 60000,\n };\n\n let launchJson: { version?: string; configurations: VSCodeLaunchConfiguration[] };\n\n if (existsSync(this.launchJsonPath)) {\n // Read existing launch.json\n const content = readFileSync(this.launchJsonPath, \"utf-8\");\n const parsed = JSON.parse(content) as { version?: string; configurations?: VSCodeLaunchConfiguration[] };\n\n // Ensure configurations array exists\n const configurations = parsed.configurations ?? [];\n\n // Check if configuration already exists\n const existingIndex = configurations.findIndex((config) => config.name === \"Gadget debugger\");\n\n if (existingIndex >= 0) {\n // Update existing configuration\n configurations[existingIndex] = launchConfig;\n } else {\n // Add new configuration\n configurations.push(launchConfig);\n }\n\n launchJson = {\n version: parsed.version,\n configurations,\n };\n } else {\n // Create new launch.json\n launchJson = {\n version: \"0.2.0\",\n configurations: [launchConfig],\n };\n }\n\n writeFileSync(this.launchJsonPath, JSON.stringify(launchJson, undefined, 2) + \"\\n\", \"utf-8\");\n }\n\n private _configureTasks(): void {\n const task: VSCodeTask = {\n label: \"ggt debugger\",\n type: \"shell\",\n command: \"ggt debugger\",\n isBackground: true,\n problemMatcher: {\n pattern: { regexp: \"^$\" },\n background: {\n activeOnStart: true,\n beginsPattern: StartingMessage,\n endsPattern: RunningMessage,\n },\n },\n };\n\n let tasksJson: { version?: string; tasks: VSCodeTask[] };\n\n if (existsSync(this.tasksJsonPath)) {\n // Read existing tasks.json\n const content = readFileSync(this.tasksJsonPath, \"utf-8\");\n const parsed = JSON.parse(content) as { version?: string; tasks?: VSCodeTask[] };\n\n // Ensure tasks array exists\n const tasks = parsed.tasks ?? [];\n\n // Check if task already exists\n const existingIndex = tasks.findIndex((t) => t.label === \"ggt debugger\");\n\n if (existingIndex >= 0) {\n // Update existing task\n tasks[existingIndex] = task;\n } else {\n // Add new task\n tasks.push(task);\n }\n\n tasksJson = {\n version: parsed.version,\n tasks,\n };\n } else {\n // Create new tasks.json\n tasksJson = {\n version: \"2.0.0\",\n tasks: [task],\n };\n }\n\n writeFileSync(this.tasksJsonPath, JSON.stringify(tasksJson, undefined, 2) + \"\\n\", \"utf-8\");\n }\n}\n"],
|
|
5
|
+
"mappings": "meAAAA,IAIA,OAAS,cAAAC,MAAkB,cAC3B,OAAS,cAAAC,EAAY,aAAAC,EAAW,gBAAAC,EAAc,iBAAAC,MAAqB,UACnE,OAAS,gBAAAC,MAAoB,YAC7B,OAAOC,MAAU,YACjB,OAAOC,GAAW,YAAAC,MAAgB,eAqBlC,IAAMC,EAAkB,wBAClBC,EAAiB,0BAEVC,GAAO,CAClB,GAAGC,EACH,GAAGC,EACH,SAAU,CACR,KAAM,OACN,MAAO,CAAC,IAAI,CACd,EACA,cAAe,CACb,KAAM,MACR,CACF,EAEMC,EAAmB,CAAC,SAAU,QAAQ,EAE/BC,GAAeC,EAACC,GACpBC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+DAcsDJ,EAAiB,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAf9D,SAyCfK,GAAyBH,EAAA,MAAOI,EAAKT,IAAS,CACzD,IAAMU,EAAY,MAAMC,EAAsBX,EAAK,EAAE,CAAC,GAAKY,EAAQ,IAAI,CAAC,EAClEC,EAAc,MAAMC,EAAY,KAAKL,EAAK,CAAE,QAAS,WAAY,KAAAT,EAAM,UAAAU,CAAU,CAAC,EAGxF,GAAIV,EAAK,aAAa,EAAG,CACvB,IAAMe,EAASf,EAAK,aAAa,EAAE,YAAY,EAC/C,GAAI,CAACG,EAAiB,SAASY,CAA2C,EACxE,MAAM,I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,WAAY,CACV,cAAe,GACf,cAAenF,EACf,YAAaC,CACf,CACF,CACF,EAEImF,EAEJ,GAAIX,EAAW,KAAK,aAAa,EAAG,CAElC,IAAMK,EAAUJ,EAAa,KAAK,cAAe,OAAO,EAClDK,EAAS,KAAK,MAAMD,CAAO,EAG3BO,EAAQN,EAAO,OAAS,CAAC,EAGzBE,EAAgBI,EAAM,UAAWC,GAAMA,EAAE,QAAU,cAAc,EAEnEL,GAAiB,EAEnBI,EAAMJ,CAAa,EAAIE,EAGvBE,EAAM,KAAKF,CAAI,EAGjBC,EAAY,CACV,QAASL,EAAO,QAChB,MAAAM,CACF,CACF,MAEED,EAAY,CACV,QAAS,QACT,MAAO,CAACD,CAAI,CACd,EAGFD,EAAc,KAAK,cAAe,KAAK,UAAUE,EAAW,OAAW,CAAC,EAAI;AAAA,EAAM,OAAO,CAC3F,CACF",
|
|
6
|
+
"names": ["init_cjs", "randomUUID", "existsSync", "mkdirSync", "readFileSync", "writeFileSync", "createServer", "path", "process", "nextTick", "StartingMessage", "RunningMessage", "args", "AppIdentityArgs", "LoggingArgs", "SupportedEditors", "usage", "__name", "_ctx", "sprint", "run", "ctx", "directory", "loadSyncJsonDirectory", "process", "appIdentity", "AppIdentity", "editor", "configurator", "DebuggerConfigurator", "port", "println", "source_default", "symbol", "spinner", "spin", "authHeaders", "loadAuthHeaders", "sessionId", "randomUUID", "proxy", "DebuggerProxy", "resolve", "error", "reportErrorAndExit", "options", "DebuggerSessionManager", "WebSocketServer", "request", "socket", "head", "application", "name", "type", "createServer", "req", "res", "url", "versionPayload", "listPayload", "clientWs", "connection", "ClientConnection", "remoteWs", "session", "http", "config", "RemoteDebuggerConnection", "reject", "server", "WebSocket", "ws", "sessionManager", "reason", "data", "isBinary", "messageString", "resolveConnection", "rejectConnection", "connected", "connectionPromise", "nextTick", "path", "existsSync", "readFileSync", "mkdirSync", "launchConfig", "launchJson", "content", "parsed", "configurations", "existingIndex", "writeFileSync", "task", "tasksJson", "tasks", "t"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{a as ee}from"./chunk-KKIL22RY.js";import{a as te}from"./chunk-R6KJLEKY.js";import{b as H,c as R,e as y,j as Z}from"./chunk-SIR6HLN3.js";import{b as W}from"./chunk-JKZNSRLU.js";import"./chunk-WB6O2V5D.js";import"./chunk-L2XBSR7G.js";import{g as Y}from"./chunk-ZSREFZXV.js";import{a as J,c as X,d as _,j as Q,q as j,r as K}from"./chunk-XC4F2TLW.js";import"./chunk-T6UHSWMT.js";import"./chunk-DR4CXBD6.js";import"./chunk-ZYDMXS5R.js";import{a as A,c as O,g as z,x as w}from"./chunk-442CSROP.js";import"./chunk-F255O64V.js";import"./chunk-HCULGPBH.js";import"./chunk-OUIZQC4D.js";import{b as i,d as F,ma as G,p as V,pa as q,ra as p,ta as t}from"./chunk-JG2QCDK2.js";import"./chunk-GFQYFEEH.js";import{a as m,h as M}from"./chunk-7DYQUG5M.js";M();import le from"node:assert";var Re={...te,"--env":{type:String,alias:["-e","--environment","--from"]},"--allow-problems":{type:Boolean,alias:"--allow-issues"},"--allow-charges":{type:Boolean},"--allow-data-delete":{type:Boolean}},_e=m(n=>p`
|
|
2
|
+
Deploys your app to production.
|
|
3
|
+
|
|
4
|
+
This command first performs a sync to ensure that your local and environment directories
|
|
5
|
+
match, changes are tracked since last sync. If any conflicts are detected, they must be
|
|
6
|
+
resolved before deployment.
|
|
7
|
+
|
|
8
|
+
{gray Usage}
|
|
9
|
+
$ ggt deploy [options]
|
|
10
|
+
|
|
11
|
+
{gray Options}
|
|
12
|
+
-a, --app <app_name> Selects a specific app to deploy. Defaults to the app synced to the current directory, if there is one.
|
|
13
|
+
--from, -e, --env <env_name> Selects a specific environment to sync and deploy from. Defaults to the environment synced to the current directory, if there is one.
|
|
14
|
+
--force Deploys by discarding any changes made to the environment directory since last sync
|
|
15
|
+
--allow-different-directory Deploys from any local directory with existing files, even if the directory hasn't been synced before
|
|
16
|
+
--allow-different-app Deploys a different app using the --app command, instead of the most recently synced one in the current directory
|
|
17
|
+
--allow-problems Deploys despite any existing issues found in the app (gelly errors, typescript errors etc.)
|
|
18
|
+
--allow-data-delete Deploys even if it results in the deletion of data in production
|
|
19
|
+
--allow-charges Deploys even if it results in additional charges to your plan
|
|
20
|
+
|
|
21
|
+
{gray Examples}
|
|
22
|
+
Deploys code from the staging environment of a myBlog
|
|
23
|
+
{cyanBright $ ggt deploy -a myBlog -from staging}
|
|
24
|
+
`,"usage"),Pe=m(async(n,r)=>{let ne=await K(process.cwd()),s=await j.loadOrAskAndInit(n,{command:"deploy",args:r,directory:ne});t({ensureEmptyLineAbove:!0,content:`Deploying ${s.environment.name} to ${A(s.environment.application.primaryDomain,`https://${s.environment.application.primaryDomain}/`)}`});let T=new Z(s),c=await T.hashes(n);if(!c.inSync&&(c.localChangesToPush.size>0||!c.onlyDotGadgetFilesChanged)){if(await T.print(n,{hashes:c}),!r["--force"])if(t({ensureEmptyLineAbove:!0,content:"Your environment's files must match your local files before you can deploy."}),G.isInteractive||F.testLike){let a;switch(!0){case c.bothChanged:a=p`Would you like to push your local changes and {underline discard your environment's} changes now?`;break;case c.localChangesToPush.size>0:a=p`Would you like to push your local changes now?`;break;case c.environmentChanges.size>0:a=p`Do you want to {underline discard your environment's} changes now?`;break;default:ee("no changes to push or discard")}await w(a)}else t({ensureEmptyLineAbove:!0,content:"Assuming you want to push your local files now."});await T.push(n,{command:"deploy",hashes:c})}let I={localFilesVersion:String(s.filesVersion),force:r["--allow-problems"],allowDeletedData:r["--allow-data-delete"],allowCharges:r["--allow-charges"]},E,f=e.NOT_STARTED,B=!1,v=s.edit.subscribe({subscription:Y,variables:I,onError:m(async a=>{n.log.error("failed to deploy",{error:a}),E?.fail(P(s,f)+" "+y());let D=V(a.cause);if(D){let l=D[0];switch(le(l,"expected graphqlError to be defined"),!0){case l.extensions.requiresUpgrade:t({ensureEmptyLineAbove:!0,content:l.message.replace(/GGT_PAYMENT_REQUIRED:?\s*/,"")}),process.exit(1);case l.extensions.requiresAdditionalCharge:t({ensureEmptyLineAbove:!0,content:l.message.replace(/GGT_PAYMENT_REQUIRED:?\s*/,"")}),await w({ensureEmptyLineAbove:!0,content:"Do you want to continue?"}),v.resubscribe({...I,allowCharges:!0});return}}await O(n,a)},"onError"),onData:m(async({publishStatus:a})=>{if(!a){n.log.warn("received empty publish status");return}let{publishStarted:D,progress:l,issues:N,status:g,deletedModelsAndFields:re}=a,C=N.length>0,{deletedModels:U,deletedModelFields:$}=re??{deletedModels:[],deletedModelFields:[]},x=U.length>0||$.length>0;if(!B&&(C||x)){B=!0;let d=N.filter(u=>u.severity===J.Fatal);if(d.length>0&&await O(n,new Q(_(d))),C&&(t({ensureEmptyLineAbove:!0,content:p`{bold.yellow !} {bold Issues found in your development app}`}),X({problems:_(N)})),x){t({ensureEmptyLineAbove:!0,content:p`{bold.yellow !} {bold Data deleted on deploy}`});let u=i.blueBright("updated"),b=i.redBright("deleted"),S=[];U.forEach(o=>{S.push({symbol:R,name:i.redBright(o),action:b,indent:0})}),$.forEach(({modelIdentifier:o,fields:h})=>{S.push({symbol:H,name:i.blueBright(o),action:u,indent:0}),h.forEach(L=>{S.push({symbol:R,name:i.redBright(L),action:b,indent:2})})});let se=S.reduce((o,h)=>Math.max(o,h.name.length),0),ae=S.reduce((o,h)=>Math.max(o,h.indent),0),k=2;t({ensureEmptyLineAbove:!0,content:i.gray("These changes will be applied to production based on the app you're deploying.")});for(let o of S){let h=" ".repeat(o.indent*k),L=" ".repeat(se-o.name.length+2),ie=" ".repeat((ae-o.indent)*k);t({ensureEmptyLineAbove:!1,content:q(`${h}${o.symbol} ${o.name}${L}${ie}${o.action}`,6)})}}if(!D)await w("Do you want to continue?"),v.resubscribe({...I,force:!0,allowDeletedData:!0});else{let u=r["--allow-data-delete"],b=r["--allow-problems"];if(!u&&!b)throw new z("expected --allow-data-delete or --allow-problems to be true");b&&t(p`Deploying regardless of problems because "${i.gray("--allow-problems")}" was passed.`),u&&t(p`Deploying regardless of deleted data because "${i.gray("--allow-data-delete")}" was passed.`)}return}if(g?.code==="Errored"){E?.fail(P(s,f)+" "+y()),g.message&&t({ensureEmptyLineAbove:!0,content:i.red(g.message)}),g.output&&t({ensureEmptyLineAbove:!0,content:p`${A("Check logs",g.output)}`});return}if(l===e.COMPLETED){E?.succeed(oe(s,f));let d=i.green("Deploy successful!");g?.output&&(d+=` ${A("Check logs",g.output)}.`),t({ensureEmptyLineAbove:!0,content:d});return}if(l!==f){let d=P(s,l);if(d!==E?.text){E?.succeed(oe(s,f));let u=f===e.NOT_STARTED||!G.isInteractive;E=W({ensureEmptyLineAbove:u,content:d})}f=l}},"onData"),onComplete:m(()=>{v.unsubscribe()},"onComplete")})},"run"),e=Object.freeze({NOT_STARTED:"NOT_STARTED",STARTING:"STARTING",BUILDING_ASSETS:"BUILDING_ASSETS",UPLOADING_ASSETS:"UPLOADING_ASSETS",CONVERGING_STORAGE:"CONVERGING_STORAGE",PUBLISHING_TREE:"PUBLISHING_TREE",RELOADING_SANDBOX:"RELOADING_SANDBOX",COMPLETED:"COMPLETED"}),P=m((n,r)=>{switch(r){case e.NOT_STARTED:case e.STARTING:case e.BUILDING_ASSETS:case e.UPLOADING_ASSETS:return"Building frontend assets.";case e.CONVERGING_STORAGE:return"Setting up database.";case e.PUBLISHING_TREE:return`Copying ${n.environment.name}.`;case e.RELOADING_SANDBOX:return"Restarting app.";case e.COMPLETED:return"Deploy complete!";default:return"Unknown step."}},"stepToSpinnerStart"),oe=m((n,r)=>{switch(r){case e.NOT_STARTED:case e.STARTING:case e.BUILDING_ASSETS:case e.UPLOADING_ASSETS:return`Built frontend assets. ${y()}`;case e.CONVERGING_STORAGE:return`Setup database. ${y()}`;case e.PUBLISHING_TREE:return`Copied ${n.environment.name}. ${y()}`;case e.RELOADING_SANDBOX:return`Restarted app. ${y()}`;case e.COMPLETED:return"Deploy successful!";default:return`Completed unknown step. ${y()}`}},"stepToSpinnerEnd");export{e as AppDeploymentSteps,Re as args,Pe as run,oe as stepToSpinnerEnd,P as stepToSpinnerStart,_e as usage};
|
|
25
|
+
//# sourceMappingURL=deploy-J74PHPQA.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/commands/deploy.ts"],
|
|
4
|
+
"sourcesContent": ["import chalk from \"chalk\";\nimport indentString from \"indent-string\";\nimport assert from \"node:assert\";\nimport terminalLink from \"terminal-link\";\n\nimport { PUBLISH_STATUS_SUBSCRIPTION } from \"../services/app/edit/operation.js\";\nimport { type Run, type Usage } from \"../services/command/command.js\";\nimport { env } from \"../services/config/env.js\";\nimport { deletedSymbol, updatedSymbol } from \"../services/filesync/changes.js\";\nimport { DeployDisallowedError } from \"../services/filesync/error.js\";\nimport { FileSync } from \"../services/filesync/filesync.js\";\nimport { SyncJson, loadSyncJsonDirectory } from \"../services/filesync/sync-json.js\";\nimport { confirm } from \"../services/output/confirm.js\";\nimport { output } from \"../services/output/output.js\";\nimport { println } from \"../services/output/print.js\";\nimport { ProblemSeverity, printProblems, publishIssuesToProblems } from \"../services/output/problems.js\";\nimport { UnexpectedError, reportErrorAndExit } from \"../services/output/report.js\";\nimport { spin, type spinner } from \"../services/output/spinner.js\";\nimport { sprint } from \"../services/output/sprint.js\";\nimport { ts } from \"../services/output/timestamp.js\";\nimport { unreachable } from \"../services/util/assert.js\";\nimport { parseGraphQLErrors } from \"../services/util/is.js\";\nimport { args as PushArgs } from \"./push.js\";\n\nexport type DeployArgs = typeof args;\n\nexport const args = {\n ...PushArgs,\n \"--env\": { type: String, alias: [\"-e\", \"--environment\", \"--from\"] },\n \"--allow-problems\": { type: Boolean, alias: \"--allow-issues\" },\n \"--allow-charges\": { type: Boolean },\n \"--allow-data-delete\": { type: Boolean },\n};\n\nexport const usage: Usage = (_ctx) => {\n return sprint`\n Deploys your app to production.\n\n This command first performs a sync to ensure that your local and environment directories\n match, changes are tracked since last sync. If any conflicts are detected, they must be\n resolved before deployment.\n\n {gray Usage}\n $ ggt deploy [options]\n\n {gray Options}\n -a, --app <app_name> Selects a specific app to deploy. Defaults to the app synced to the current directory, if there is one.\n --from, -e, --env <env_name> Selects a specific environment to sync and deploy from. Defaults to the environment synced to the current directory, if there is one.\n --force Deploys by discarding any changes made to the environment directory since last sync\n --allow-different-directory Deploys from any local directory with existing files, even if the directory hasn't been synced before\n --allow-different-app Deploys a different app using the --app command, instead of the most recently synced one in the current directory\n --allow-problems Deploys despite any existing issues found in the app (gelly errors, typescript errors etc.)\n --allow-data-delete Deploys even if it results in the deletion of data in production\n --allow-charges Deploys even if it results in additional charges to your plan\n\n {gray Examples}\n Deploys code from the staging environment of a myBlog\n {cyanBright $ ggt deploy -a myBlog -from staging}\n`;\n};\n\nexport const run: Run<DeployArgs> = async (ctx, args) => {\n const directory = await loadSyncJsonDirectory(process.cwd());\n const syncJson = await SyncJson.loadOrAskAndInit(ctx, { command: \"deploy\", args, directory });\n\n println({\n ensureEmptyLineAbove: true,\n content: `Deploying ${syncJson.environment.name} to ${terminalLink(syncJson.environment.application.primaryDomain, `https://${syncJson.environment.application.primaryDomain}/`)}`,\n });\n\n const filesync = new FileSync(syncJson);\n const hashes = await filesync.hashes(ctx);\n if (!hashes.inSync && (hashes.localChangesToPush.size > 0 || !hashes.onlyDotGadgetFilesChanged)) {\n // the following is true:\n // 1. our local files don't match our environment's files\n // 2. we have local changes to push or non .gadget/ files have changed on our environment\n // therefore, we need to push before we can deploy\n await filesync.print(ctx, { hashes });\n\n if (!args[\"--force\"]) {\n // they didn't pass --force, so we need to ask them if they want to push\n println({\n ensureEmptyLineAbove: true,\n content: \"Your environment's files must match your local files before you can deploy.\",\n });\n\n if (output.isInteractive || env.testLike) {\n // we're interactive, so ask them what they want to do\n let content: string;\n switch (true) {\n case hashes.bothChanged:\n content = sprint`Would you like to push your local changes and {underline discard your environment's} changes now?`;\n break;\n case hashes.localChangesToPush.size > 0:\n content = sprint`Would you like to push your local changes now?`;\n break;\n case hashes.environmentChanges.size > 0:\n content = sprint`Do you want to {underline discard your environment's} changes now?`;\n break;\n default:\n unreachable(\"no changes to push or discard\");\n }\n\n await confirm(content);\n } else {\n // we're not interactive, so we're likely in a CI/CD environment\n // assume they want to push\n println({\n ensureEmptyLineAbove: true,\n content: \"Assuming you want to push your local files now.\",\n });\n }\n }\n\n await filesync.push(ctx, { command: \"deploy\", hashes });\n }\n\n const variables = {\n localFilesVersion: String(syncJson.filesVersion),\n force: args[\"--allow-problems\"],\n allowDeletedData: args[\"--allow-data-delete\"],\n allowCharges: args[\"--allow-charges\"],\n };\n\n let spinner: spinner | undefined;\n let currentStep: AppDeploymentSteps = AppDeploymentSteps.NOT_STARTED;\n let printedProblems = false;\n\n const subscription = syncJson.edit.subscribe({\n subscription: PUBLISH_STATUS_SUBSCRIPTION,\n variables,\n onError: async (error) => {\n ctx.log.error(\"failed to deploy\", { error });\n spinner?.fail(stepToSpinnerStart(syncJson, currentStep) + \" \" + ts());\n\n const graphqlErrors = parseGraphQLErrors(error.cause);\n if (graphqlErrors) {\n const graphqlError = graphqlErrors[0];\n assert(graphqlError, \"expected graphqlError to be defined\");\n\n switch (true) {\n case graphqlError.extensions[\"requiresUpgrade\"]:\n println({ ensureEmptyLineAbove: true, content: graphqlError.message.replace(/GGT_PAYMENT_REQUIRED:?\\s*/, \"\") });\n process.exit(1);\n // falls through\n case graphqlError.extensions[\"requiresAdditionalCharge\"]:\n println({ ensureEmptyLineAbove: true, content: graphqlError.message.replace(/GGT_PAYMENT_REQUIRED:?\\s*/, \"\") });\n await confirm({ ensureEmptyLineAbove: true, content: \"Do you want to continue?\" });\n subscription.resubscribe({ ...variables, allowCharges: true });\n return;\n }\n }\n\n await reportErrorAndExit(ctx, error);\n },\n onData: async ({ publishStatus }): Promise<void> => {\n if (!publishStatus) {\n ctx.log.warn(\"received empty publish status\");\n return;\n }\n\n const { publishStarted, progress: step, issues, status, deletedModelsAndFields } = publishStatus;\n const hasIssues = issues.length > 0;\n\n const { deletedModels, deletedModelFields } = deletedModelsAndFields ?? { deletedModels: [], deletedModelFields: [] };\n const hasDataLoss = deletedModels.length > 0 || deletedModelFields.length > 0;\n\n if (!printedProblems && (hasIssues || hasDataLoss)) {\n printedProblems = true;\n\n const fatalIssues = issues.filter((issue) => issue.severity === ProblemSeverity.Fatal);\n if (fatalIssues.length > 0) {\n await reportErrorAndExit(ctx, new DeployDisallowedError(publishIssuesToProblems(fatalIssues)));\n }\n\n if (hasIssues) {\n println({ ensureEmptyLineAbove: true, content: sprint`{bold.yellow !} {bold Issues found in your development app}` });\n printProblems({ problems: publishIssuesToProblems(issues) });\n }\n\n if (hasDataLoss) {\n println({\n ensureEmptyLineAbove: true,\n content: sprint`{bold.yellow !} {bold Data deleted on deploy}`,\n });\n\n const updated = chalk.blueBright(\"updated\");\n const deleted = chalk.redBright(\"deleted\");\n\n const rows: { symbol: string; name: string; action: string; indent: number }[] = [];\n\n deletedModels.forEach((model: string) => {\n rows.push({ symbol: deletedSymbol, name: chalk.redBright(model), action: deleted, indent: 0 });\n });\n\n deletedModelFields.forEach(({ modelIdentifier, fields }) => {\n rows.push({ symbol: updatedSymbol, name: chalk.blueBright(modelIdentifier), action: updated, indent: 0 });\n fields.forEach((field) => {\n rows.push({ symbol: deletedSymbol, name: chalk.redBright(field), action: deleted, indent: 2 });\n });\n });\n\n const longestNameLength = rows.reduce((longest, row) => Math.max(longest, row.name.length), 0);\n const longestIndent = rows.reduce((longest, row) => Math.max(longest, row.indent), 0);\n const indentSize = 2;\n\n println({\n ensureEmptyLineAbove: true,\n content: chalk.gray(\"These changes will be applied to production based on the app you're deploying.\"),\n });\n for (const row of rows) {\n const indentation = \" \".repeat(row.indent * indentSize);\n const namePadding = \" \".repeat(longestNameLength - row.name.length + 2);\n const actionPadding = \" \".repeat((longestIndent - row.indent) * indentSize);\n println({\n ensureEmptyLineAbove: false,\n content: indentString(`${indentation}${row.symbol} ${row.name}${namePadding}${actionPadding}${row.action}`, 6),\n });\n }\n }\n\n if (!publishStarted) {\n await confirm(\"Do you want to continue?\");\n subscription.resubscribe({ ...variables, force: true, allowDeletedData: true });\n } else {\n const allowDataDelete = args[\"--allow-data-delete\"];\n const allowProblems = args[\"--allow-problems\"];\n\n if (!allowDataDelete && !allowProblems) {\n throw new UnexpectedError(\"expected --allow-data-delete or --allow-problems to be true\");\n }\n\n if (allowProblems) {\n println(sprint`Deploying regardless of problems because \"${chalk.gray(\"--allow-problems\")}\" was passed.`);\n }\n\n if (allowDataDelete) {\n println(sprint`Deploying regardless of deleted data because \"${chalk.gray(\"--allow-data-delete\")}\" was passed.`);\n }\n }\n\n return;\n }\n\n if (status?.code === \"Errored\") {\n spinner?.fail(stepToSpinnerStart(syncJson, currentStep) + \" \" + ts());\n\n if (status.message) {\n println({ ensureEmptyLineAbove: true, content: chalk.red(status.message) });\n }\n if (status.output) {\n println({ ensureEmptyLineAbove: true, content: sprint`${terminalLink(\"Check logs\", status.output)}` });\n }\n return;\n }\n\n if (step === AppDeploymentSteps.COMPLETED) {\n spinner?.succeed(stepToSpinnerEnd(syncJson, currentStep));\n\n let content = chalk.green(\"Deploy successful!\");\n if (status?.output) {\n content += ` ${terminalLink(\"Check logs\", status.output)}.`;\n }\n\n println({ ensureEmptyLineAbove: true, content });\n return;\n }\n\n if (step !== currentStep) {\n const spinnerText = stepToSpinnerStart(syncJson, step);\n if (spinnerText !== spinner?.text) {\n // stop the current spinner, if any, and start a new one\n spinner?.succeed(stepToSpinnerEnd(syncJson, currentStep));\n\n const ensureEmptyLineAbove = currentStep === AppDeploymentSteps.NOT_STARTED || !output.isInteractive;\n spinner = spin({ ensureEmptyLineAbove, content: spinnerText });\n }\n\n currentStep = step as AppDeploymentSteps;\n }\n },\n onComplete: () => {\n subscription.unsubscribe();\n },\n });\n};\n\nexport const AppDeploymentSteps = Object.freeze({\n NOT_STARTED: \"NOT_STARTED\",\n STARTING: \"STARTING\",\n BUILDING_ASSETS: \"BUILDING_ASSETS\",\n UPLOADING_ASSETS: \"UPLOADING_ASSETS\",\n CONVERGING_STORAGE: \"CONVERGING_STORAGE\",\n PUBLISHING_TREE: \"PUBLISHING_TREE\",\n RELOADING_SANDBOX: \"RELOADING_SANDBOX\",\n COMPLETED: \"COMPLETED\",\n});\n\nexport type AppDeploymentSteps = (typeof AppDeploymentSteps)[keyof typeof AppDeploymentSteps];\n\nexport const stepToSpinnerStart = (syncJson: SyncJson, step: string): string => {\n switch (step) {\n case AppDeploymentSteps.NOT_STARTED:\n case AppDeploymentSteps.STARTING:\n case AppDeploymentSteps.BUILDING_ASSETS:\n case AppDeploymentSteps.UPLOADING_ASSETS:\n return \"Building frontend assets.\";\n case AppDeploymentSteps.CONVERGING_STORAGE:\n return \"Setting up database.\";\n case AppDeploymentSteps.PUBLISHING_TREE:\n return `Copying ${syncJson.environment.name}.`;\n case AppDeploymentSteps.RELOADING_SANDBOX:\n return \"Restarting app.\";\n case AppDeploymentSteps.COMPLETED:\n return \"Deploy complete!\";\n default:\n return \"Unknown step.\";\n }\n};\n\nexport const stepToSpinnerEnd = (syncJson: SyncJson, step: string): string => {\n switch (step) {\n case AppDeploymentSteps.NOT_STARTED:\n case AppDeploymentSteps.STARTING:\n case AppDeploymentSteps.BUILDING_ASSETS:\n case AppDeploymentSteps.UPLOADING_ASSETS:\n return `Built frontend assets. ${ts()}`;\n case AppDeploymentSteps.CONVERGING_STORAGE:\n return `Setup database. ${ts()}`;\n case AppDeploymentSteps.PUBLISHING_TREE:\n return `Copied ${syncJson.environment.name}. ${ts()}`;\n case AppDeploymentSteps.RELOADING_SANDBOX:\n return `Restarted app. ${ts()}`;\n case AppDeploymentSteps.COMPLETED:\n return \"Deploy successful!\";\n default:\n return `Completed unknown step. ${ts()}`;\n }\n};\n"],
|
|
5
|
+
"mappings": "wuBAAAA,IAEA,OAAOC,OAAY,cAwBZ,IAAMC,GAAO,CAClB,GAAGA,GACH,QAAS,CAAE,KAAM,OAAQ,MAAO,CAAC,KAAM,gBAAiB,QAAQ,CAAE,EAClE,mBAA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AmB,gBACtB,MAAO,WAAWf,EAAS,YAAY,IAAI,IAC7C,KAAKe,EAAmB,kBACtB,MAAO,kBACT,KAAKA,EAAmB,UACtB,MAAO,mBACT,QACE,MAAO,eACX,CACF,EAlBkC,sBAoBrBkD,GAAmBxE,EAAA,CAACO,EAAoB6B,IAAyB,CAC5E,OAAQA,EAAM,CACZ,KAAKd,EAAmB,YACxB,KAAKA,EAAmB,SACxB,KAAKA,EAAmB,gBACxB,KAAKA,EAAmB,iBACtB,MAAO,0BAA0BM,EAAG,CAAC,GACvC,KAAKN,EAAmB,mBACtB,MAAO,mBAAmBM,EAAG,CAAC,GAChC,KAAKN,EAAmB,gBACtB,MAAO,UAAUf,EAAS,YAAY,IAAI,KAAKqB,EAAG,CAAC,GACrD,KAAKN,EAAmB,kBACtB,MAAO,kBAAkBM,EAAG,CAAC,GAC/B,KAAKN,EAAmB,UACtB,MAAO,qBACT,QACE,MAAO,2BAA2BM,EAAG,CAAC,EAC1C,CACF,EAlBgC",
|
|
6
|
+
"names": ["init_cjs", "assert", "args", "usage", "__name", "_ctx", "sprint", "run", "ctx", "directory", "loadSyncJsonDirectory", "syncJson", "SyncJson", "println", "terminalLink", "filesync", "FileSync", "hashes", "output", "env", "content", "unreachable", "confirm", "variables", "spinner", "currentStep", "AppDeploymentSteps", "printedProblems", "subscription", "PUBLISH_STATUS_SUBSCRIPTION", "error", "stepToSpinnerStart", "ts", "graphqlErrors", "parseGraphQLErrors", "graphqlError", "assert", "reportErrorAndExit", "publishStatus", "publishStarted", "step", "issues", "status", "deletedModelsAndFields", "hasIssues", "deletedModels", "deletedModelFields", "hasDataLoss", "fatalIssues", "issue", "ProblemSeverity", "DeployDisallowedError", "publishIssuesToProblems", "printProblems", "updated", "source_default", "deleted", "rows", "model", "deletedSymbol", "modelIdentifier", "fields", "updatedSymbol", "field", "longestNameLength", "longest", "row", "longestIndent", "indentSize", "indentation", "namePadding", "actionPadding", "indentString", "allowDataDelete", "allowProblems", "UnexpectedError", "stepToSpinnerEnd", "spinnerText", "ensureEmptyLineAbove", "spin"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{a as En}from"./chunk-3OM5WM7E.js";import{a as cr}from"./chunk-MW6MXMSN.js";import{b as lr,d as fr}from"./chunk-YFUOXDPK.js";import{a as rt}from"./chunk-KKIL22RY.js";import{a as Vt,b as Xt}from"./chunk-2742UPMB.js";import{a as tt,d as gn,h as z,i as ir,j as ar}from"./chunk-SIR6HLN3.js";import{b as rr}from"./chunk-JKZNSRLU.js";import"./chunk-WB6O2V5D.js";import"./chunk-L2XBSR7G.js";import"./chunk-ZSREFZXV.js";import{f as Zt,p as nr,q as sr,r as or}from"./chunk-XC4F2TLW.js";import"./chunk-T6UHSWMT.js";import{a as tr}from"./chunk-DR4CXBD6.js";import"./chunk-ZYDMXS5R.js";import{I as Qt,K as er,c as Jt,i as wn}from"./chunk-442CSROP.js";import"./chunk-F255O64V.js";import{c as Yt}from"./chunk-HCULGPBH.js";import"./chunk-OUIZQC4D.js";import{W as et,b as jt,ba as $t,ma as Ge,r as Ht,ra as H,sa as Kt,ta as zt}from"./chunk-JG2QCDK2.js";import{a as yn}from"./chunk-GFQYFEEH.js";import{a as s,b as E,c as q,d as F,e as mn,f as We,g as pn,h as c}from"./chunk-7DYQUG5M.js";var Fr=F(R=>{"use strict";c();var gt=s((e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),"a"),Cn=gt(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sync=e.isexe=void 0;var t=E("node:fs"),r=E("node:fs/promises"),i=s(async(l,f={})=>{let{ignoreErrors:u=!1}=f;try{return o(await(0,r.stat)(l),f)}catch(h){let m=h;if(u||m.code==="EACCES")return!1;throw m}},"q");e.isexe=i;var n=s((l,f={})=>{let{ignoreErrors:u=!1}=f;try{return o((0,t.statSync)(l),f)}catch(h){let m=h;if(u||m.code==="EACCES")return!1;throw m}},"m");e.sync=n;var o=s((l,f)=>l.isFile()&&a(l,f),"d"),a=s((l,f)=>{let u=f.uid??process.getuid?.(),h=f.groups??process.getgroups?.()??[],m=f.gid??process.getgid?.()??h[0];if(u===void 0||m===void 0)throw new Error("cannot get uid or gid");let p=new Set([m,...h]),d=l.mode,x=l.uid,D=l.gid,L=parseInt("100",8),j=parseInt("010",8),b=parseInt("001",8),W=L|j;return!!(d&b||d&j&&p.has(D)||d&L&&x===u||d&W&&u===0)},"A")}),Tn=gt(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sync=e.isexe=void 0;var t=E("node:fs"),r=E("node:fs/promises"),i=E("node:path"),n=s(async(f,u={})=>{let{ignoreErrors:h=!1}=u;try{return l(await(0,r.stat)(f),f,u)}catch(m){let p=m;if(h||p.code==="EACCES")return!1;throw p}},"F");e.isexe=n;var o=s((f,u={})=>{let{ignoreErrors:h=!1}=u;try{return l((0,t.statSync)(f),f,u)}catch(m){let p=m;if(h||p.code==="EACCES")return!1;throw p}},"L");e.sync=o;var a=s((f,u)=>{let{pathExt:h=process.env.PATHEXT||""}=u,m=h.split(i.delimiter);if(m.indexOf("")!==-1)return!0;for(let p of m){let d=p.toLowerCase(),x=f.substring(f.length-d.length).toLowerCase();if(d&&x===d)return!0}return!1},"B"),l=s((f,u,h)=>f.isFile()&&a(u,h),"y")}),Rn=gt(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})}),br=R&&R.__createBinding||(Object.create?(function(e,t,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:s(function(){return t[r]},"get")}),Object.defineProperty(e,i,n)}):(function(e,t,r,i){i===void 0&&(i=r),e[i]=t[r]})),bn=R&&R.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),kr=R&&R.__importStar||(function(){var e=s(function(t){return e=Object.getOwnPropertyNames||function(r){var i=[];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[i.length]=n);return i},e(t)},"t");return function(t){if(t&&t.__esModule)return t;var r={};if(t!=null)for(var i=e(t),n=0;n<i.length;n++)i[n]!=="default"&&br(r,t,i[n]);return bn(r,t),r}})(),kn=R&&R.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&br(t,e,r)};Object.defineProperty(R,"__esModule",{value:!0});R.sync=R.isexe=R.posix=R.win32=void 0;var Lr=kr(Cn());R.posix=Lr;var Or=kr(Tn());R.win32=Or;kn(Rn(),R);var Ln=process.env._ISEXE_TEST_PLATFORM_||process.platform,qr=Ln==="win32"?Or:Lr;R.isexe=qr.isexe;R.sync=qr.sync});var Kr=F((bc,$r)=>{c();var{isexe:On,sync:qn}=Fr(),{join:Fn,delimiter:Pn,sep:Pr,posix:Ur}=E("path"),Mr=process.platform==="win32",Wr=new RegExp(`[${Ur.sep}${Pr===Ur.sep?"":Pr}]`.replace(/(\\)/g,"\\$1")),Un=new RegExp(`^\\.${Wr.source}`),Gr=s(e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),"getNotFoundError"),Br=s((e,{path:t=process.env.PATH,pathExt:r=process.env.PATHEXT,delimiter:i=Pn})=>{let n=e.match(Wr)?[""]:[...Mr?[process.cwd()]:[],...(t||"").split(i)];if(Mr){let o=r||[".EXE",".CMD",".BAT",".COM"].join(i),a=o.split(i).flatMap(l=>[l,l.toLowerCase()]);return e.includes(".")&&a[0]!==""&&a.unshift(""),{pathEnv:n,pathExt:a,pathExtExe:o}}return{pathEnv:n,pathExt:[""]}},"getPathInfo"),jr=s((e,t)=>{let r=/^".*"$/.test(e)?e.slice(1,-1):e;return(!r&&Un.test(t)?t.slice(0,2):"")+Fn(r,t)},"getPathPart"),Hr=s(async(e,t={})=>{let{pathEnv:r,pathExt:i,pathExtExe:n}=Br(e,t),o=[];for(let a of r){let l=jr(a,e);for(let f of i){let u=l+f;if(await On(u,{pathExt:n,ignoreErrors:!0})){if(!t.all)return u;o.push(u)}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw Gr(e)},"which"),Mn=s((e,t={})=>{let{pathEnv:r,pathExt:i,pathExtExe:n}=Br(e,t),o=[];for(let a of r){let l=jr(a,e);for(let f of i){let u=l+f;if(qn(u,{pathExt:n,ignoreErrors:!0})){if(!t.all)return u;o.push(u)}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw Gr(e)},"whichSync");$r.exports=Hr;Hr.sync=Mn});var zr=F(He=>{c();(function(){var e;e=s(function(t,r,i){var n,o;for(o="";t.length>0;)n=t.match(r),n?(o+=t.slice(0,n.index),o+=i(n),t=t.slice(n.index+n[0].length)):(o+=t,t="");return o},"scan"),He.split=function(t){var r,i;return t==null&&(t=""),i=[],r="",e(t,/\s*(?:([^\s\\\'\"]+)|'((?:[^\'\\]|\\.)*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|$)?/,function(n){var o,a,l,f,u,h,m;if(f=n[0],m=n[1],h=n[2],o=n[3],a=n[4],l=n[5],u=n[6],l!=null)throw new Error("Unmatched quote");if(r+=m||(h||o||a).replace(/\\(?=.)/,""),u!=null)return i.push(r),r=""}),r&&i.push(r),i},He.escape=function(t){return t==null&&(t=""),t==null?"''":t.replace(/([^A-Za-z0-9_\-.,:\/@\n])/g,"\\$1").replace(/\n/g,`'
|
|
2
|
+
'`)}}).call(He)});var Vr=F((Bc,Yr)=>{"use strict";c();var Jr=E("fs"),vt;function Wn(){try{return Jr.statSync("/.dockerenv"),!0}catch{return!1}}s(Wn,"hasDockerEnv");function Gn(){try{return Jr.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}s(Gn,"hasDockerCGroup");Yr.exports=()=>(vt===void 0&&(vt=Wn()||Gn()),vt)});var Qr=F(($c,Nt)=>{"use strict";c();var Bn=E("os"),jn=E("fs"),Xr=Vr(),Zr=s(()=>{if(process.platform!=="linux")return!1;if(Bn.release().toLowerCase().includes("microsoft"))return!Xr();try{return jn.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!Xr():!1}catch{return!1}},"isWsl");process.env.__IS_WSL_TEST__?Nt.exports=Zr:Nt.exports=Zr()});var de=F((Jc,C)=>{c();var Hn=zr(),$e=E("child_process"),xt=En(),$n=Qr(),Kn=E("path"),zn=E("url"),he=E("os"),St=E("fs"),Jn=E("net"),Yn=1024;function ii(e){return JSON.parse(JSON.stringify(e))}s(ii,"clone");C.exports.clone=ii;var Vn=s(function(e){return typeof e=="string"?e.replace(/(["$`\\])/g,"\\$1"):e},"escapeQuotes"),Xn=s(function(e,t){return e.indexOf(t)!==-1},"inArray"),ei={u:"urgency",urgency:"urgency",t:"expire-time",time:"expire-time",timeout:"expire-time",e:"expire-time",expire:"expire-time","expire-time":"expire-time",i:"icon",icon:"icon",c:"category",category:"category",subtitle:"category",h:"hint",hint:"hint",a:"app-name","app-name":"app-name"};C.exports.command=function(e,t,r){return e=Hn.escape(e),process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1&&(console.info("node-notifier debug info (command):"),console.info("[notifier path]",e),console.info("[notifier options]",t.join(" "))),$e.exec(e+" "+t.join(" "),function(i,n,o){if(i)return r(i);r(o,n)})};C.exports.fileCommand=function(e,t,r){return process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1&&(console.info("node-notifier debug info (fileCommand):"),console.info("[notifier path]",e),console.info("[notifier options]",t.join(" "))),$e.execFile(e,t,function(i,n,o){if(i)return r(i,n);r(o,n)})};C.exports.fileCommandJson=function(e,t,r){return process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1&&(console.info("node-notifier debug info (fileCommandJson):"),console.info("[notifier path]",e),console.info("[notifier options]",t.join(" "))),$e.execFile(e,t,function(i,n,o){if(i)return r(i,n);if(!n)return r(i,{});try{let a=JSON.parse(n);r(o||null,a)}catch(a){r(a,n)}})};C.exports.immediateFileCommand=function(e,t,r){process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1&&(console.info("node-notifier debug info (notifier):"),console.info("[notifier path]",e)),Zn(e,function(i,n){if(!n)return r(new Error("Notifier ("+e+") not found on system."));$e.execFile(e,t),r()})};function Zn(e,t){return St.stat(e,function(r,i){return r?Kn.extname(e)?t(r,!1):St.stat(e+".exe",function(n,o){if(n)return t(n,!1);t(n,o.isFile())}):t(r,i.isFile())})}s(Zn,"notifierExists");var Ke=s(function(e){return e.appIcon&&(e.icon=e.appIcon,delete e.appIcon),e},"mapAppIcon"),_e=s(function(e){return e.text&&(e.message=e.text,delete e.text),e},"mapText"),ni=s(function(e){return e.i&&(e.icon=e.i,delete e.i),e},"mapIconShorthand");C.exports.mapToNotifySend=function(e){e=Ke(e),e=_e(e),e.timeout===!1&&delete e.timeout,e.wait===!0&&(e["expire-time"]=5);for(let t in e)t==="message"||t==="title"||e.hasOwnProperty(t)&&ei[t]!==t&&(e[ei[t]]=e[t],delete e[t]);return typeof e["expire-time"]>"u"?e["expire-time"]=10*1e3:typeof e["expire-time"]=="number"&&(e["expire-time"]=e["expire-time"]*1e3),e};C.exports.mapToGrowl=function(e){if(e=Ke(e),e=ni(e),e=_e(e),e.icon&&!Buffer.isBuffer(e.icon))try{e.icon=St.readFileSync(e.icon)}catch{}return e};C.exports.mapToMac=function(e){return e=ni(e),e=_e(e),e.icon&&(e.appIcon=e.icon,delete e.icon),e.sound===!0&&(e.sound="Bottle"),e.sound===!1&&delete e.sound,e.sound&&e.sound.indexOf("Notification.")===0&&(e.sound="Bottle"),e.wait===!0&&(e.timeout||(e.timeout=5),delete e.wait),!e.wait&&!e.timeout&&(e.timeout===!1?delete e.timeout:e.timeout=10),e.json=!0,e};function _t(e){return Object.prototype.toString.call(e)==="[object Array]"}s(_t,"isArray");C.exports.isArray=_t;function Qn(){}s(Qn,"noop");C.exports.actionJackerDecorator=function(e,t,r,i){if(t=ii(t),r=r||Qn,typeof r!="function")throw new TypeError("The second argument must be a function callback. You have passed "+typeof r);return function(n,o){let a=o,l={};if(a&&typeof a=="object"&&(l=a,a=a.activationType),a&&(a=a.toLowerCase().trim(),a.match(/^activate|clicked$/)&&(a="activate"),a.match(/^timedout$/)&&(a="timeout")),r.apply(e,[n,a,l]),!i||!a)return;let f=i(a);f&&e.emit(f,e,t,l)}};C.exports.constructArgumentList=function(e,t){let r=[];t=t||{};let i=t.initial||[],n=t.keyExtra||"",o=t.allowedArguments||[],a=t.noEscape!==void 0,l=t.allowedArguments!==void 0,f=!!t.explicitTrue,u=!!t.keepNewlines,h=t.wrapper===void 0?'"':t.wrapper,m=s(function p(d){return _t(d)?ti(d.map(p).join(",")):(a||(d=Vn(d)),typeof d=="string"&&!u&&(d=ti(d)),h+d+h)},"escapeFn");i.forEach(function(p){r.push(m(p))});for(let p in e)if(e.hasOwnProperty(p)&&(!l||Xn(o,p)))if(f&&e[p]===!0)r.push("-"+n+p);else{if(f&&e[p]===!1)continue;r.push("-"+n+p,m(e[p]))}return r};function ti(e){let t=process.platform==="win32"?"\\r\\n":"\\n";return e.replace(/\r?\n/g,t)}s(ti,"removeNewLines");var es=["t","m","b","tb","p","id","s","silent","appID","pid","pipeName","close","install"],ts="Notification.",ri="Notification.Default";C.exports.mapToWin8=function(e){e=Ke(e),e=_e(e),e.icon&&(/^file:\/+/.test(e.icon)?e.p=new zn.URL(e.icon).pathname.replace(/^\/(\w:\/)/,"$1").replace(/\//g,"\\"):e.p=e.icon,delete e.icon),e.message&&(e.m=e.message.replace(/\x1b/g,""),delete e.message),e.title&&(e.t=e.title,delete e.title),e.appName&&(e.appID=e.appName,delete e.appName),typeof e.remove<"u"&&(e.close=e.remove,delete e.remove),(e.quiet||e.silent)&&(e.silent=e.quiet||e.silent,delete e.quiet),typeof e.sound<"u"&&(e.s=e.sound,delete e.sound),e.s===!1&&(e.silent=!0,delete e.s),e.s&&e.silent&&delete e.s,e.s===!0&&(e.s=ri),e.s&&e.s.indexOf(ts)!==0&&(e.s=ri),e.actions&&_t(e.actions)&&(e.b=e.actions.join(";"),delete e.actions);for(let t in e)e.hasOwnProperty(t)&&es.indexOf(t)===-1&&delete e[t];return e};C.exports.mapToNotifu=function(e){return e=Ke(e),e=_e(e),e.icon&&(e.i=e.icon,delete e.icon),e.message&&(e.m=e.message,delete e.message),e.title&&(e.p=e.title,delete e.title),e.time&&(e.d=e.time,delete e.time),e.q!==!1?e.q=!0:delete e.q,e.quiet===!1&&(delete e.q,delete e.quiet),e.sound&&(delete e.q,delete e.sound),e.t&&(e.d=e.t,delete e.t),e.type&&(e.t=rs(e.type),delete e.type),e};C.exports.isMac=function(){return he.type()==="Darwin"};C.exports.isMountainLion=function(){return he.type()==="Darwin"&&xt.satisfies(It(he.release()),">=12.0.0")};C.exports.isWin8=function(){return he.type()==="Windows_NT"&&xt.satisfies(It(he.release()),">=6.2.9200")};C.exports.isWSL=function(){return $n};C.exports.isLessThanWin8=function(){return he.type()==="Windows_NT"&&xt.satisfies(It(he.release()),"<6.2.9200")};function It(e){return e.split(".").length===2&&(e+=".0"),e}s(It,"garanteeSemverFormat");function rs(e){if(typeof e=="string"||e instanceof String){if(e.toLowerCase()==="info")return"info";if(e.toLowerCase()==="warn")return"warn";if(e.toLowerCase()==="error")return"error"}return"info"}s(rs,"sanitizeNotifuTypeArgument");C.exports.createNamedPipe=e=>{let t=Buffer.alloc(Yn);return new Promise(r=>{e.instance=Jn.createServer(i=>{i.on("data",n=>{t.write(n.toString())}),i.on("end",()=>{e.instance.close()})}),e.instance.listen(e.namedPipe,()=>{r(t)})})}});var fi=F((Xc,li)=>{c();var si=E("os"),is=gn(),Ie=de(),ai=E("events").EventEmitter,ns=E("util"),ci="notify-send",ze;li.exports=De;function De(e){if(e=Ie.clone(e||{}),!(this instanceof De))return new De(e);this.options=e,ai.call(this)}s(De,"NotifySend");ns.inherits(De,ai);function ss(){}s(ss,"noop");function os(e,t){if(e=Ie.clone(e||{}),t=t||ss,typeof t!="function")throw new TypeError("The second argument must be a function callback. You have passed "+typeof t);if(typeof e=="string"&&(e={title:"node-notifier",message:e}),!e.message)return t(new Error("Message is required.")),this;if(si.type()!=="Linux"&&!si.type().match(/BSD$/))return t(new Error("Only supported on Linux and *BSD systems")),this;if(ze===!1)return t(new Error("notify-send must be installed on the system.")),this;if(ze||this.options.suppressOsdCheck)return oi(e,t),this;try{ze=!!is.sync(ci),oi(e,t)}catch(r){return ze=!1,t(r)}return this}s(os,"notifyRaw");Object.defineProperty(De.prototype,"notify",{get:s(function(){return this._notify||(this._notify=os.bind(this)),this._notify},"get")});var as=["urgency","expire-time","icon","category","hint","app-name"];function oi(e,t){e=Ie.mapToNotifySend(e),e.title=e.title||"Node Notification:";let r=[e.title,e.message];delete e.title,delete e.message;let i=Ie.constructArgumentList(e,{initial:r,keyExtra:"-",allowedArguments:as});Ie.command(ci,i,t)}s(oi,"doNotification")});var Dt=F((el,hi)=>{c();var cs=E("net"),ui=!1;hi.exports=function(e,t){if(typeof t>"u"&&(t=e,e={}),ui)return t(null,ui);let r=e.port||23053,i=e.host||"localhost",n=cs.connect(r,i);n.setTimeout(100),n.once("connect",function(){n.end(),t(null,!0)}),n.once("error",function(){n.end(),t(null,!1)})}});var pi=F((rl,mi)=>{c();var ls=E("net"),fs=E("crypto"),di=E("util").format,us=E("fs"),B=`\r
|
|
3
|
+
`;function me(e,t){t=t||{},this.type=e,this.host=t.host||"localhost",this.port=t.port||23053,this.request="GNTP/1.0 "+e+" NONE"+B,this.resources=[],this.attempts=0,this.maxAttempts=5}s(me,"GNTP");me.prototype.parseResp=function(e){var t={},r,i;return e=e.slice(0,e.indexOf(B+B)).split(B),r=e[0],i=e.slice(1),t.state=r.match(/-(OK|ERROR|CALLBACK)/)[0].slice(1),i.forEach(function(n){n=n.split(": "),t[n[0]]=n[1]}),t};me.prototype.retry=function(){var e=this,t=arguments;setTimeout(function(){e.send.apply(e,t)},750)};me.prototype.addResource=function(e){var t=fs.createHash("md5").update(e).digest("hex"),r="Identifier: "+t+B+"Length: "+e.length+B+B;return this.resources.push({header:r,file:e}),"x-growl-resource://"+t};me.prototype.add=function(e,t){t!==void 0&&(/-Icon/.test(e)&&!/^https?:\/\//.test(t)&&(/\.(png|gif|jpe?g)$/.test(t)?t=this.addResource(us.readFileSync(t)):t instanceof Buffer&&(t=this.addResource(t))),this.request+=e+": "+t+B)};me.prototype.newline=function(){this.request+=B};me.prototype.send=function(e){var t=this,r=ls.connect(this.port,this.host),i="";e=e||function(){},this.attempts+=1,r.on("connect",function(){r.write(t.request),t.resources.forEach(function(n){r.write(n.header),r.write(n.file),r.write(B+B)})}),r.on("data",function(n){i+=n.toString(),i.slice(i.length-4)===B+B&&(i=t.parseResp(i),i.state==="ERROR"||i.state==="CALLBACK"?r.end():i="")}),r.on("end",function(){if(["200","401","402"].indexOf(i["Error-Code"])>=0)if(t.attempts<=t.maxAttempts)t.retry(e);else{var n='GNTP request to "%s:%d" failed with error code %s (%s)';e(new Error(di(n,t.host,t.port,i["Error-Code"],i["Error-Description"])))}else e(void 0,i)}),r.on("error",function(){e(new Error(di('Error while sending GNTP request to "%s:%d"',t.host,t.port))),r.destroy()})};mi.exports=me});var gi=F((sl,wi)=>{c();var yi=pi();function Ae(){this.appname="Growly",this.notifications=void 0,this.labels=void 0,this.count=0,this.registered=!1,this.host=void 0,this.port=void 0}s(Ae,"Growly");Ae.prototype.getLabels=function(){return this.notifications.map(function(e){return e.label})};Ae.prototype.setHost=function(e,t){this.host=e,this.port=t};Ae.prototype.register=function(e,t,r,i){var n;typeof t=="object"&&(r=t,t=void 0),(r===void 0||!r.length)&&(r=[{label:"default",dispname:"Default Notification",enabled:!0}]),typeof arguments[arguments.length-1]=="function"?i=arguments[arguments.length-1]:i=s(function(){},"callback"),this.appname=e,this.notifications=r,this.labels=this.getLabels(),this.registered=!0,n=new yi("REGISTER",{host:this.host,port:this.port}),n.add("Application-Name",e),n.add("Application-Icon",t),n.add("Notifications-Count",r.length),n.newline(),r.forEach(function(o){o.enabled===void 0&&(o.enabled=!0),n.add("Notification-Name",o.label),n.add("Notification-Display-Name",o.dispname),n.add("Notification-Enabled",o.enabled?"True":"False"),n.add("Notification-Icon",o.icon),n.newline()}),n.send(i)};Ae.prototype.notify=function(e,t,r){var i=this,n;if(!this.registered){this.register(this.appname,function(o){o&&console.log(o),i.notify.call(i,e,t,r)});return}t=t||{},typeof t=="function"&&(r=t,t={}),n=new yi("NOTIFY",{host:this.host,port:this.port}),n.add("Application-Name",this.appname),n.add("Notification-Name",t.label||this.labels[0]),n.add("Notification-ID",++this.count),n.add("Notification-Title",t.title),n.add("Notification-Text",e),n.add("Notification-Sticky",t.sticky?"True":"False"),n.add("Notification-Priority",t.priority),n.add("Notification-Icon",t.icon),n.add("Notification-Coalescing-ID",t.coalescingId||void 0),n.add("Notification-Callback-Context",r?"context":void 0),n.add("Notification-Callback-Context-Type",r?"string":void 0),n.add("Notification-Callback-Target",void 0),n.newline(),n.send(function(o,a){r&&o?r(o):r&&a.state==="CALLBACK"&&r(void 0,a["Notification-Callback-Result"].toLowerCase())})};wi.exports=new Ae});var Ye=F((cl,Ni)=>{c();var hs=Dt(),Je=de(),Ce=gi(),vi=E("events").EventEmitter,ds=E("util"),ms="Couldn't connect to growl (might be used as a fallback). Make sure it is running";Ni.exports=Te;var Ei;function Te(e){if(e=Je.clone(e||{}),!(this instanceof Te))return new Te(e);Ce.appname=e.name||"Node",this.options=e,vi.call(this)}s(Te,"Growl");ds.inherits(Te,vi);function ps(e,t){if(Ce.setHost(this.options.host,this.options.port),e=Je.clone(e||{}),typeof e=="string"&&(e={title:"node-notifier",message:e}),t=Je.actionJackerDecorator(this,e,t,function(r){return r==="click"?"click":r==="timedout"?"timeout":!1}),e=Je.mapToGrowl(e),!e.message)return t(new Error("Message is required.")),this;if(e.title=e.title||"Node Notification:",Ei||e.wait){let r=e.wait?t:ys;return Ce.notify(e.message,e,r),e.wait||t(),this}return hs(Ce,function(r,i){if(Ei=i,!i)return t(new Error(ms));Ce.notify(e.message,e),t()}),this}s(ps,"notifyRaw");Object.defineProperty(Te.prototype,"notify",{get:s(function(){return this._notify||(this._notify=ps.bind(this)),this._notify},"get")});function ys(){}s(ys,"noop")});var Ii=F((ul,_i)=>{c();var pe=de(),ws=Ye(),gs=E("path"),Es=gs.join(__dirname,"../vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier"),xi=E("events").EventEmitter,vs=E("util"),Ns="You need Mac OS X 10.8 or above to use NotificationCenter, or use Growl fallback with constructor option {withFallback: true}.";_i.exports=Re;function Re(e){if(e=pe.clone(e||{}),!(this instanceof Re))return new Re(e);this.options=e,xi.call(this)}s(Re,"NotificationCenter");vs.inherits(Re,xi);var Si=null;function Ss(){}s(Ss,"noop");function xs(e,t){let r,i=_s();if(e=pe.clone(e||{}),Si=i,typeof e=="string"&&(e={title:"node-notifier",message:e}),t=t||Ss,typeof t!="function")throw new TypeError("The second argument must be a function callback. You have passed "+typeof fn);let n=pe.actionJackerDecorator(this,e,t,function(a){return Si!==i?!1:a==="activate"?"click":a==="timeout"?"timeout":a==="replied"?"replied":!1});if(e=pe.mapToMac(e),!e.message&&!e.group&&!e.list&&!e.remove)return t(new Error("Message, group, remove or list property is required.")),this;let o=pe.constructArgumentList(e);return pe.isMountainLion()?(pe.fileCommandJson(this.options.customPath||Es,o,n),this):r||this.options.withFallback?(r=r||new ws(this.options),r.notify(e,t)):(t(new Error(Ns)),this)}s(xs,"notifyRaw");Object.defineProperty(Re.prototype,"notify",{get:s(function(){return this._notify||(this._notify=xs.bind(this)),this._notify},"get")});function _s(){return{_ref:"val"}}s(_s,"identificator")});var At=F((ml,Ti)=>{c();var Is=E("path"),Ds=Is.resolve(__dirname,"../vendor/notifu/notifu"),As=Dt(),ie=de(),Cs=Ct(),Di=Ye(),Ts=E("os"),Ci=E("events").EventEmitter,Rs=E("util"),Ve;Ti.exports=be;function be(e){if(e=ie.clone(e||{}),!(this instanceof be))return new be(e);this.options=e,Ci.call(this)}s(be,"WindowsBalloon");Rs.inherits(be,Ci);function bs(){}s(bs,"noop");function ks(e,t){let r,i=this.options;e=ie.clone(e||{}),t=t||bs,typeof e=="string"&&(e={title:"node-notifier",message:e});let n=ie.actionJackerDecorator(this,e,t,function(o){return o==="activate"?"click":o==="timeout"?"timeout":!1});return this.options.withFallback&&ie.isWin8()?(r=r||new Cs(i),r.notify(e,t)):this.options.withFallback&&(!ie.isLessThanWin8()||Ve===!0)?(r=r||new Di(i),r.notify(e,t)):!this.options.withFallback||Ve===!1?(Ai(e,i,n),this):(As(i,function(o,a){if(Ve=a,Ve)return r=r||new Di(i),r.notify(e,t);Ai(e,i,n)}),this)}s(ks,"notifyRaw");Object.defineProperty(be.prototype,"notify",{get:s(function(){return this._notify||(this._notify=ks.bind(this)),this._notify},"get")});var Ls=["t","d","p","m","i","e","q","w","xp"];function Ai(e,t,r){let i=Ts.arch()==="x64";e=e||{},e=ie.mapToNotifu(e),e.p=e.p||"Node Notification:";let n=Ds+(i?"64":"")+".exe",o=t.customPath||n;if(!e.m)return r(new Error("Message is required.")),this;let a=ie.constructArgumentList(e,{wrapper:"",noEscape:!0,explicitTrue:!0,allowedArguments:Ls});if(e.wait)return ie.fileCommand(o,a,function(l,f){let u=Os(l.code);return u==="error"?r(l,f):r(null,u)});ie.immediateFileCommand(o,a,r)}s(Ai,"doNotification");function Os(e){switch(e){case 2:return"timeout";case 3:case 6:case 7:return"activate";case 4:return"close";default:return"error"}}s(Os,"fromErrorCodeToAction")});import qs from"crypto";function ke(){return Xe>Ze.length-16&&(qs.randomFillSync(Ze),Xe=0),Ze.slice(Xe,Xe+=16)}var Ze,Xe,Tt=q(()=>{c();Ze=new Uint8Array(256),Xe=Ze.length;s(ke,"rng")});var Ri,bi=q(()=>{c();Ri=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i});function Fs(e){return typeof e=="string"&&Ri.test(e)}var ce,Le=q(()=>{c();bi();s(Fs,"validate");ce=Fs});function Ps(e,t=0){let r=(k[e[t+0]]+k[e[t+1]]+k[e[t+2]]+k[e[t+3]]+"-"+k[e[t+4]]+k[e[t+5]]+"-"+k[e[t+6]]+k[e[t+7]]+"-"+k[e[t+8]]+k[e[t+9]]+"-"+k[e[t+10]]+k[e[t+11]]+k[e[t+12]]+k[e[t+13]]+k[e[t+14]]+k[e[t+15]]).toLowerCase();if(!ce(r))throw TypeError("Stringified UUID is invalid");return r}var k,le,Oe=q(()=>{c();Le();k=[];for(let e=0;e<256;++e)k.push((e+256).toString(16).substr(1));s(Ps,"stringify");le=Ps});function Us(e,t,r){let i=t&&r||0,n=t||new Array(16);e=e||{};let o=e.node||ki,a=e.clockseq!==void 0?e.clockseq:Rt;if(o==null||a==null){let p=e.random||(e.rng||ke)();o==null&&(o=ki=[p[0]|1,p[1],p[2],p[3],p[4],p[5]]),a==null&&(a=Rt=(p[6]<<8|p[7])&16383)}let l=e.msecs!==void 0?e.msecs:Date.now(),f=e.nsecs!==void 0?e.nsecs:kt+1,u=l-bt+(f-kt)/1e4;if(u<0&&e.clockseq===void 0&&(a=a+1&16383),(u<0||l>bt)&&e.nsecs===void 0&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");bt=l,kt=f,Rt=a,l+=122192928e5;let h=((l&268435455)*1e4+f)%4294967296;n[i++]=h>>>24&255,n[i++]=h>>>16&255,n[i++]=h>>>8&255,n[i++]=h&255;let m=l/4294967296*1e4&268435455;n[i++]=m>>>8&255,n[i++]=m&255,n[i++]=m>>>24&15|16,n[i++]=m>>>16&255,n[i++]=a>>>8|128,n[i++]=a&255;for(let p=0;p<6;++p)n[i+p]=o[p];return t||le(n)}var ki,Rt,bt,kt,Li,Oi=q(()=>{c();Tt();Oe();bt=0,kt=0;s(Us,"v1");Li=Us});function Ms(e){if(!ce(e))throw TypeError("Invalid UUID");let t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}var Qe,Lt=q(()=>{c();Le();s(Ms,"parse");Qe=Ms});function Ws(e){e=unescape(encodeURIComponent(e));let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}function qe(e,t,r){function i(n,o,a,l){if(typeof n=="string"&&(n=Ws(n)),typeof o=="string"&&(o=Qe(o)),o.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let f=new Uint8Array(16+n.length);if(f.set(o),f.set(n,o.length),f=r(f),f[6]=f[6]&15|t,f[8]=f[8]&63|128,a){l=l||0;for(let u=0;u<16;++u)a[l+u]=f[u];return a}return le(f)}s(i,"generateUUID");try{i.name=e}catch{}return i.DNS=Gs,i.URL=Bs,i}var Gs,Bs,Ot=q(()=>{c();Oe();Lt();s(Ws,"stringToBytes");Gs="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Bs="6ba7b811-9dad-11d1-80b4-00c04fd430c8";s(qe,"default")});import js from"crypto";function Hs(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),js.createHash("md5").update(e).digest()}var qi,Fi=q(()=>{c();s(Hs,"md5");qi=Hs});var $s,Pi,Ui=q(()=>{c();Ot();Fi();$s=qe("v3",48,qi),Pi=$s});function Ks(e,t,r){e=e||{};let i=e.random||(e.rng||ke)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return le(i)}var Mi,Wi=q(()=>{c();Tt();Oe();s(Ks,"v4");Mi=Ks});import zs from"crypto";function Js(e){return Array.isArray(e)?e=Buffer.from(e):typeof e=="string"&&(e=Buffer.from(e,"utf8")),zs.createHash("sha1").update(e).digest()}var Gi,Bi=q(()=>{c();s(Js,"sha1");Gi=Js});var Ys,ji,Hi=q(()=>{c();Ot();Bi();Ys=qe("v5",80,Gi),ji=Ys});var $i,Ki=q(()=>{c();$i="00000000-0000-0000-0000-000000000000"});function Vs(e){if(!ce(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}var zi,Ji=q(()=>{c();Le();s(Vs,"version");zi=Vs});var Yi={};mn(Yi,{NIL:()=>$i,parse:()=>Qe,stringify:()=>le,v1:()=>Li,v3:()=>Pi,v4:()=>Mi,v5:()=>ji,validate:()=>ce,version:()=>zi});var Vi=q(()=>{c();Oi();Ui();Wi();Hi();Ki();Ji();Le();Oe();Lt()});var Ct=F((Tf,Zi)=>{c();var Xs=E("path"),Zs=Xs.resolve(__dirname,"../vendor/snoreToast/snoretoast"),Z=de(),Qs=At(),eo=E("os"),{v4:to}=(Vi(),pn(Yi)),Xi=E("events").EventEmitter,ro=E("util"),qt,io="notifierPipe",no="\\\\.\\pipe\\",so="/tmp/";Zi.exports=Fe;function Fe(e){if(e=Z.clone(e||{}),!(this instanceof Fe))return new Fe(e);this.options=e,Xi.call(this)}s(Fe,"WindowsToaster");ro.inherits(Fe,Xi);function oo(){}s(oo,"noop");function ao(e){return e?e.split(";").reduce((t,r)=>{let i=r.split("=");return i&&i.length===2&&(t[i[0]]=i[1]),t},{}):{}}s(ao,"parseResult");function co(){return`${Z.isWSL()?so:no}${io}-${to()}`}s(co,"getPipeName");function lo(e,t){e=Z.clone(e||{}),t=t||oo;let r=eo.arch()==="x64",i,n={namedPipe:co()};if(typeof e=="string"&&(e={title:"node-notifier",message:e}),typeof t!="function")throw new TypeError("The second argument must be a function callback. You have passed "+typeof fn);let o=s((l,f)=>{let u=ao(i&&i.toString("utf16le"));u.action==="buttonClicked"&&u.button?u.activationType=u.button:u.action&&(u.activationType=u.action),l&&l.code===-1&&f(l,u),f(null,u),n.instance&&n.instance.close()},"snoreToastResultParser"),a=s(l=>o(l,Z.actionJackerDecorator(this,e,t,f=>f==="activate"?"click":f||!1)),"actionJackedCallback");return e.title=e.title||"Node Notification:",typeof e.message>"u"&&typeof e.close>"u"?(t(new Error("Message or ID to close is required.")),this):!Z.isWin8()&&!Z.isWSL()&&this.options.withFallback?(qt=qt||new Qs(this.options),qt.notify(e,t)):(Z.createNamedPipe(n).then(l=>{i=l,e.pipeName=n.namedPipe;let f=e.customPath||this.options.customPath||Zs+"-x"+(r?"64":"86")+".exe";e=Z.mapToWin8(e);let u=Z.constructArgumentList(e,{explicitTrue:!0,wrapper:"",keepNewlines:!0,noEscape:!0});Z.fileCommand(f,u,a)}),this)}s(lo,"notifyRaw");Object.defineProperty(Fe.prototype,"notify",{get:s(function(){return this._notify||(this._notify=lo.bind(this)),this._notify},"get")})});var tn=F((kf,T)=>{c();var Qi=E("os"),en=de(),Pe=fi(),Ft=Ii(),Ue=Ct(),Pt=Ye(),Ut=At(),ye={withFallback:!0},fo=en.isWSL()?"WSL":Qi.type();switch(fo){case"Linux":T.exports=new Pe(ye),T.exports.Notification=Pe;break;case"Darwin":T.exports=new Ft(ye),T.exports.Notification=Ft;break;case"Windows_NT":en.isLessThanWin8()?(T.exports=new Ut(ye),T.exports.Notification=Ut):(T.exports=new Ue(ye),T.exports.Notification=Ue);break;case"WSL":T.exports=new Ue(ye),T.exports.Notification=Ue;break;default:Qi.type().match(/BSD$/)?(T.exports=new Pe(ye),T.exports.Notification=Pe):(T.exports=new Pt(ye),T.exports.Notification=Pt)}T.exports.NotifySend=Pe;T.exports.NotificationCenter=Ft;T.exports.WindowsToaster=Ue;T.exports.WindowsBalloon=Ut;T.exports.Growl=Pt});c();var on=We(wn(),1),ne=We(yn(),1);import uo from"node:fs";import sn from"node:path";c();import{EventEmitter as An}from"node:events";import yt from"node:fs";import ge from"node:path";c();import vn from"node:os";var ur=300,oe=20,Ee=1e7,hr=vn.platform();var Nn=hr==="darwin",it=hr==="win32",ae=Nn||it,dr=3e3,mr=2e4,nt=1250;c();var Y;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(Y||(Y={}));var ue;(function(e){e.CHANGE="change",e.RENAME="rename"})(ue||(ue={}));var ve;(function(e){e.CHANGE="change",e.ERROR="error"})(ve||(ve={}));var y;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(y||(y={}));var P;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(P||(P={}));c();c();c();var Sn=s((e,t=1,r)=>{t=Math.max(1,t);let i=r?.leading??!1,n=r?.trailing??!0,o=Math.max(r?.maxWait??1/0,t),a,l,f=0,u=0,h=s(()=>{let _=Date.now(),G=_-f,se=_-u,fe=G>=t||se>=o;return[_,fe]},"getInstantData"),m=s(_=>{if(u=_,!a)return;let G=a;a=void 0,e.apply(void 0,G)},"invoke"),p=s(()=>{b(0)},"onCancel"),d=s(()=>{l&&(p(),m(Date.now()))},"onFlush"),x=s(_=>{if(u=_,i)return m(_)},"onLeading"),D=s(_=>{if(n&&a)return m(_);a=void 0},"onTrailing"),L=s(()=>{l=void 0;let[_,G]=h();return G?D(_):j(_)},"onTimeout"),j=s(_=>{let G=_-f,se=_-u,fe=t-G,Me=o-se,$=Math.min(fe,Me);return b($)},"updateTimeout"),b=s(_=>{l&&clearTimeout(l),!(_<=0)&&(l=setTimeout(L,_))},"resetTimeout"),W=s((..._)=>{let[G,se]=h(),fe=!!l;if(a=_,f=G,(se||!l)&&b(t),se)return fe?m(G):x(G)},"debounced");return W.cancel=p,W.flush=d,W},"debounce"),Be=Sn;c();import Dr from"node:fs";import ct from"node:path";c();import S from"node:fs";import{promisify as O}from"node:util";c();var ee=s((e,t)=>s(function(...i){return e.apply(void 0,i).catch(t)},"attemptified"),"attemptifyAsync"),V=s((e,t)=>s(function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}},"attemptified"),"attemptifySync");c();import pr from"node:process";var yr=pr.getuid?!pr.getuid():!1,wr=1e4,M=s(()=>{},"NOOP");c();var Ne={isChangeErrorOk:s(e=>{if(!Ne.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!yr&&(t==="EINVAL"||t==="EPERM")},"isChangeErrorOk"),isNodeError:s(e=>e instanceof Error,"isNodeError"),isRetriableError:s(e=>{if(!Ne.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},"isRetriableError"),onChangeError:s(e=>{if(!Ne.isNodeError(e))throw e;if(!Ne.isChangeErrorOk(e))throw e},"onChangeError")},A=Ne;c();c();var st=class{static{s(this,"RetryfyQueue")}constructor(){this.interval=25,this.intervalId=void 0,this.limit=wr,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=s(()=>this.remove(i),"cleanup"),i=s(()=>t(r),"resolver");this.add(i)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},gr=new st;var te=s((e,t)=>s(function(i){return s(function n(...o){return gr.schedule().then(a=>{let l=s(u=>(a(),u),"onResolve"),f=s(u=>{if(a(),Date.now()>=i)throw u;if(t(u)){let h=Math.round(100*Math.random());return new Promise(p=>setTimeout(p,h)).then(()=>n.apply(void 0,o))}throw u},"onReject");return e.apply(void 0,o).then(l,f)})},"attempt")},"retrified"),"retryifyAsync"),re=s((e,t)=>s(function(i){return s(function n(...o){try{return e.apply(void 0,o)}catch(a){if(Date.now()>i)throw a;if(t(a))return n.apply(void 0,o);throw a}},"attempt")},"retrified"),"retryifySync");var xn={attempt:{chmod:ee(O(S.chmod),A.onChangeError),chown:ee(O(S.chown),A.onChangeError),close:ee(O(S.close),M),fsync:ee(O(S.fsync),M),mkdir:ee(O(S.mkdir),M),realpath:ee(O(S.realpath),M),stat:ee(O(S.stat),M),unlink:ee(O(S.unlink),M),chmodSync:V(S.chmodSync,A.onChangeError),chownSync:V(S.chownSync,A.onChangeError),closeSync:V(S.closeSync,M),existsSync:V(S.existsSync,M),fsyncSync:V(S.fsync,M),mkdirSync:V(S.mkdirSync,M),realpathSync:V(S.realpathSync,M),statSync:V(S.statSync,M),unlinkSync:V(S.unlinkSync,M)},retry:{close:te(O(S.close),A.isRetriableError),fsync:te(O(S.fsync),A.isRetriableError),open:te(O(S.open),A.isRetriableError),readFile:te(O(S.readFile),A.isRetriableError),rename:te(O(S.rename),A.isRetriableError),stat:te(O(S.stat),A.isRetriableError),write:te(O(S.write),A.isRetriableError),writeFile:te(O(S.writeFile),A.isRetriableError),closeSync:re(S.closeSync,A.isRetriableError),fsyncSync:re(S.fsyncSync,A.isRetriableError),openSync:re(S.openSync,A.isRetriableError),readFileSync:re(S.readFileSync,A.isRetriableError),renameSync:re(S.renameSync,A.isRetriableError),statSync:re(S.statSync,A.isRetriableError),writeSync:re(S.writeSync,A.isRetriableError),writeFileSync:re(S.writeFileSync,A.isRetriableError)}},Er=xn;c();import at from"node:fs";import je from"node:path";c();c();c();var ot=s(()=>{},"noop");var _n=s(()=>{let e=ot,t=ot,r=!1,i=!1;return{promise:new Promise((f,u)=>{e=s(h=>(r=!0,f(h)),"resolve"),t=s(h=>(i=!0,u(h)),"reject")}),resolve:e,reject:t,isPending:s(()=>!r&&!i,"isPending"),isResolved:s(()=>r,"isResolved"),isRejected:s(()=>i,"isRejected")}},"makeNakedPromise"),vr=_n;var In=s(()=>{let{promise:e,resolve:t,isPending:r}=vr(),i=0,n=s(()=>{i+=1},"increment"),o=s(()=>{i-=1,!i&&t()},"decrement");return s(()=>{n(),queueMicrotask(o)},"init")(),{promise:e,isPending:r,increment:n,decrement:o}},"makeCounterPromise"),Nr=In;c();var Sr={then:s(e=>{e()},"then")};c();var xr=s(e=>Array.isArray(e)?e:[e],"castArray"),_r=s(e=>typeof e=="function","isFunction");var Dn=s((e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,o=t?.ignore??[],a=xr(o).map(v=>_r(v)?v:g=>v.test(g)),l=s((v,g)=>a.some(N=>N(v,g)),"isIgnored"),f=t?.signal??{aborted:!1},u=t?.onDirents||(()=>{}),h=[],m=new Set,p={},d=[],x=new Set,D={},L=[],j=new Set,b={},W={},_=new Set,G={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},se={directories:h,directoriesNames:m,directoriesNamesToPaths:p,files:d,filesNames:x,filesNamesToPaths:D,symlinks:L,symlinksNames:j,symlinksNamesToPaths:b,map:W},{promise:fe,increment:Me,decrement:$}=Nr(),Q=0,Mt=s((v,g,N,I)=>{_.has(g)||Q>=n||(Q+=1,v.directories.push(g),v.directoriesNames.add(N),h.push(g),m.add(N),p.propertyIsEnumerable(N)||(p[N]=[]),p[N].push(g),_.add(g),!(I>=i)&&(Q>=n||Bt(g,I+1)))},"handleDirectory"),Wt=s((v,g,N)=>{_.has(g)||Q>=n||(Q+=1,v.files.push(g),v.filesNames.add(N),d.push(g),x.add(N),D.propertyIsEnumerable(N)||(D[N]=[]),D[N].push(g),_.add(g))},"handleFile"),Gt=s((v,g,N,I)=>{_.has(g)||Q>=n||(Q+=1,v.symlinks.push(g),v.symlinksNames.add(N),L.push(g),j.add(N),b.propertyIsEnumerable(N)||(b[N]=[]),b[N].push(g),_.add(g),r&&(I>=i||Q>=n||hn(g,I+1)))},"handleSymlink"),cn=s((v,g,N,I,K)=>{f.aborted||l(g,I.isDirectory())||(I.isDirectory()?Mt(v,g,N,K):I.isFile()?Wt(v,g,N):I.isSymbolicLink()&&Gt(v,g,N,K))},"handleStat"),ln=s((v,g,N,I)=>{if(f.aborted)return;let K=g===je.sep?"":je.sep,J=N.name,we=`${g}${K}${J}`;l(we,N.isDirectory())||(N.isDirectory()?Mt(v,we,J,I):N.isFile()?Wt(v,we,J):N.isSymbolicLink()&&Gt(v,we,J,I))},"handleDirent"),un=s((v,g,N,I)=>{for(let K=0,J=N.length;K<J;K++)ln(v,g,N[K],I)},"handleDirents"),Bt=s((v,g)=>{f.aborted||g>i||Q>=n||(Me(),at.readdir(v,{withFileTypes:!0},(N,I)=>{if(N||f.aborted||!I.length)return $();(u(I)||Sr).then(()=>{let J=W[v]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};un(J,v,I,g),$()})}))},"populateResultFromPath"),hn=s((v,g)=>{Me(),at.realpath(v,(N,I)=>{if(N||f.aborted)return $();at.stat(I,(K,J)=>{if(K||f.aborted)return $();let we=je.basename(I),dn=W[v]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};cn(dn,I,we,J,g),$()})})},"populateResultFromSymlink");return s(async(v,g=1)=>(v=je.normalize(v),_.add(v),Bt(v,g),await fe,f.aborted?G:se),"populateResultFromRoot")(e)},"readdir"),Ir=Dn;var X={lang:{debounce:Be,attempt:s(e=>{try{return e()}catch(t){return X.lang.castError(t)}},"attempt"),castArray:s(e=>X.lang.isArray(e)?e:[e],"castArray"),castError:s(e=>X.lang.isError(e)?e:X.lang.isString(e)?new Error(e):new Error("Unknown error"),"castError"),defer:s(e=>setTimeout(e,0),"defer"),isArray:s(e=>Array.isArray(e),"isArray"),isError:s(e=>e instanceof Error,"isError"),isFunction:s(e=>typeof e=="function","isFunction"),isNaN:s(e=>Number.isNaN(e),"isNaN"),isNumber:s(e=>typeof e=="number","isNumber"),isPrimitive:s(e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},"isPrimitive"),isShallowEqual:s((e,t)=>{if(e===t)return!0;if(X.lang.isNaN(e))return X.lang.isNaN(t);if(X.lang.isPrimitive(e)||X.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},"isShallowEqual"),isSet:s(e=>e instanceof Set,"isSet"),isString:s(e=>typeof e=="string","isString"),isUndefined:s(e=>e===void 0,"isUndefined"),noop:s(()=>{},"noop"),uniq:s(e=>e.length<2?e:Array.from(new Set(e)),"uniq")},fs:{getDepth:s(e=>Math.max(0,e.split(ct.sep).length-1),"getDepth"),getRealPath:s((e,t)=>{try{return t?Dr.realpathSync.native(e):Dr.realpathSync(e)}catch{return}},"getRealPath"),isSubPath:s((e,t)=>t.startsWith(e)&&t[e.length]===ct.sep&&t.length-e.length>ct.sep.length,"isSubPath"),poll:s((e,t=mr)=>Er.retry.stat(t)(e,{bigint:!0}).catch(X.lang.noop),"poll"),readdir:s(async(e,t,r=1/0,i=1/0,n,o)=>{if(o&&r===1&&e in o){let a=o[e];return[a.directories,a.files]}else{let a=await Ir(e,{depth:r,limit:i,ignore:t,signal:n});return[a.directories,a.files]}},"readdir")}},w=X;c();import lt from"node:path";var ft=class{static{s(this,"WatcherHandler")}constructor(t,r,i){this.base=i,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||w.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=ur){return(()=>{let r=this.watcher._readyWait,i=[],n=new Set,o=s(async(l,f)=>{let u=this.options.ignoreInitial?[]:l,h=await this.eventsPopulate([...f]),m=this.eventsDeduplicate([...u,...h]);this.onTargetEvents(m)},"flush"),a=w.lang.debounce(()=>{this.watcher.isClosed()||(r=o(i,n),i=[],n=new Set)},t);return async(l,f="",u=!1)=>{u?await this.eventsPopulate([f],i,!0):n.add(f),r.then(a)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((i,n)=>{let[o,a]=n,l=r[a];return o===l||o===y.CHANGE&&l===y.ADD||(r[a]=o,i.push(n)),i},[])}async eventsPopulate(t,r=[],i=!1){return await Promise.all(t.map(async n=>{let o=await this.watcher._poller.update(n,this.options.pollingTimeout);await Promise.all(o.map(async a=>{r.push([a,n]),a===y.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):a===y.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,n,r,i)}))})),r}async eventsPopulateAddDir(t,r,i=[],n=!1){if(n)return i;let o=this.options.recursive?this.options.depth??oe:Math.min(1,this.options.depth??oe),a=this.options.limit??Ee,[l,f]=await w.fs.readdir(r,this.options.ignore,o,a,this.watcher._closeSignal),u=new Set(l),h=[...l,...f];return await Promise.all(h.map(m=>{if(!this.watcher.isIgnored(m,this.options.ignore,u.has(m))&&!t.includes(m))return this.eventsPopulate([m],i,!0)})),i}async eventsPopulateUnlinkDir(t,r,i=[],n=!1){if(n)return i;for(let o of this.watcher._poller.stats.keys())w.fs.isSubPath(r,o)&&(t.includes(o)||await this.eventsPopulate([o],i,!0));return i}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(y.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!ae&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(y.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(y.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(lt.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(y.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(lt.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(y.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===y.ADD?this.onTargetAdd(i):r===y.ADD_DIR?this.onTargetAddDir(i):r===y.CHANGE?this.onTargetChange(i):r===y.UNLINK?this.onTargetUnlink(i):r===y.UNLINK_DIR&&this.onTargetUnlinkDir(i)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,i=!1){return this.handlerBatched(t,r,i)}onWatcherChange(t=ue.CHANGE,r){if(this.watcher.isClosed())return;let i=lt.resolve(this.folderPath,r||"");this.filePath&&i!==this.folderPath&&i!==this.filePath||this.watcher.isIgnored(i,this.options.ignore)||this.onWatcherEvent(t,i)}onWatcherError(t){it&&t.code==="EPERM"?this.onWatcherChange(ue.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(ve.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(ve.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(ue.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&ae&&this.options.native!==!1?this.options.depth??oe:Math.min(1,this.options.depth??oe),i=this.options.limit??Ee,[n,o]=await w.fs.readdir(this.folderPath,this.options.ignore,r,i,this.watcher._closeSignal,this.options.readdirMap),a=new Set(n);a.add(this.folderPath);let l=[this.folderPath,...n,...o];await Promise.all(l.map(f=>{if(!this.watcher._poller.stats.has(f)&&!this.watcher.isIgnored(f,this.options.ignore,a.has(f)))return this.onWatcherEvent(ue.CHANGE,f,t)}))}}},Ar=ft;c();c();var U={interval:100,intervalId:void 0,fns:new Map,init:s(()=>{U.intervalId||(U.intervalId=setInterval(U.resolve,U.interval))},"init"),reset:s(()=>{U.intervalId&&(clearInterval(U.intervalId),delete U.intervalId)},"reset"),add:s((e,t)=>{U.fns.set(e,Date.now()+t),U.init()},"add"),remove:s(e=>{U.fns.delete(e)},"remove"),resolve:s(()=>{if(!U.fns.size)return U.reset();let e=Date.now();for(let[t,r]of U.fns)r>=e||(U.remove(t),t())},"resolve")},Se=U;var xe=class e{static{s(this,"WatcherLocker")}constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=nt){let{ino:i,targetPath:n,events:o,locks:a}=t,l=s(()=>{let m=this._watcher._poller.paths.find(i||-1,p=>p!==n);if(m&&m!==n){if(w.fs.getRealPath(n,!0)===m)return;this._watcher.event(o.rename,m,n)}else this._watcher.event(o.add,n)},"emit");if(!i)return l();let f=s(()=>{a.add.delete(i),Se.remove(u)},"cleanup"),u=s(()=>{f(),l()},"free");Se.add(u,r);let h=s(()=>{let m=a.unlink.get(i);if(!m)return;f();let p=m();n===p?o.change&&this._watcher._poller.stats.has(n)&&this._watcher.event(o.change,n):this._watcher.event(o.rename,p,n)},"resolve");a.add.set(i,h),h()}getLockUnlink(t,r=nt){let{ino:i,targetPath:n,events:o,locks:a}=t,l=s(()=>{this._watcher.event(o.unlink,n)},"emit");if(!i)return l();let f=s(()=>{a.unlink.delete(i),Se.remove(u)},"cleanup"),u=s(()=>{f(),l()},"free");Se.add(u,r);let h=s(()=>(f(),n),"overridden");a.unlink.set(i,h),a.add.get(i)?.()}getLockTargetAdd(t,r){let i=this._watcher._poller.getIno(t,y.ADD,Y.FILE);return this.getLockAdd({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let i=this._watcher._poller.getIno(t,y.ADD_DIR,Y.DIR);return this.getLockAdd({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let i=this._watcher._poller.getIno(t,y.UNLINK,Y.FILE);return this.getLockUnlink({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let i=this._watcher._poller.getIno(t,y.UNLINK_DIR,Y.DIR);return this.getLockUnlink({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};xe.DIR_EVENTS={add:y.ADD_DIR,rename:y.RENAME_DIR,unlink:y.UNLINK_DIR};xe.FILE_EVENTS={add:y.ADD,change:y.CHANGE,rename:y.RENAME,unlink:y.UNLINK};var Cr=xe;c();c();var ut=class{static{s(this,"LazyMapSet")}constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(w.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(w.lang.isSet(i)){let n=i.delete(r);return i.size||this.map.delete(t),n}else if(i===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let i=this.map.get(t);if(w.lang.isSet(i))return Array.from(i).find(r);if(r(i))return i}}get(t){return this.map.get(t)}has(t,r){if(w.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return w.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);w.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},ht=ut;c();var dt=class{static{s(this,"WatcherStats")}constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},Tr=dt;var mt=class{static{s(this,"WatcherPoller")}constructor(){this.inos={},this.paths=new ht,this.stats=new Map}getIno(t,r,i){let n=this.inos[r];if(!n)return;let o=n[t];if(o&&!(i&&o[1]!==i))return o[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let i=await w.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new Tr(i)}reset(){this.inos={},this.paths=new ht,this.stats=new Map}async update(t,r){let i=this.getStats(t),n=await this.poll(t,r);if(this.updateStats(t,n),!i&&n){if(n.isFile())return this.updateIno(t,y.ADD,n),[y.ADD];if(n.isDirectory())return this.updateIno(t,y.ADD_DIR,n),[y.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,y.UNLINK,i),[y.UNLINK];if(i.isDirectory())return this.updateIno(t,y.UNLINK_DIR,i),[y.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,y.CHANGE,n),[y.CHANGE]);if(n.isDirectory())return this.updateIno(t,y.UNLINK,i),this.updateIno(t,y.ADD_DIR,n),[y.UNLINK,y.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,y.UNLINK_DIR,i),this.updateIno(t,y.ADD,n),[y.UNLINK_DIR,y.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,y.UNLINK_DIR,i),this.updateIno(t,y.ADD_DIR,n),[y.UNLINK_DIR,y.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),o=i.isFile()?Y.FILE:Y.DIR;n[t]=[i.ino,o]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let i=this.stats.get(t)?.ino||-1;this.paths.delete(i,t),this.stats.delete(t)}}},pt=mt;var wt=class e extends An{static{s(this,"Watcher")}constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(P.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(P.CLOSE,n)),this._readyWait=new Promise(n=>this.on(P.READY,n)),this._locker=new Cr(this),this._roots=new Set,this._poller=new pt,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,i)}isClosed(){return this._closed}isIgnored(t,r,i){return!!r&&(w.lang.isFunction(r)?!!r(t,i):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit(P.CLOSE))}error(t){if(this.isClosed())return!1;let r=w.lang.castError(t);return this.emit(P.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(P.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(P.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&w.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&w.lang.isShallowEqual(i.options,r))return!0;return!1}watchersClose(t,r,i=!0){if(t){let n=this._watchers[t];if(n)for(let o of[...n])r&&o.filePath!==r||this.watcherClose(o);if(i)for(let o in this._watchers)w.fs.isSubPath(t,o)&&this.watchersClose(o,r,!1)}else for(let n in this._watchers)this.watchersClose(n,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,i]of t)this.watchPath(r,i.options,i.handler)}async watcherAdd(t,r){let{folderPath:i}=t;(this._watchers[i]=this._watchers[i]||[]).push(t);let o=new Ar(this,t,r);return await o.init(),o}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let o=r.indexOf(t);r.splice(o,1),r.length||delete this._watchers[t.folderPath]}let i=t.filePath||t.folderPath;this._roots.has(i)&&(this._watchersRestorable[i]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=w.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,i,n){if(this._watchers[t]?.find(l=>l.handler===i&&(!l.filePath||l.filePath===n)&&l.options.ignore===r.ignore&&!!l.options.native==!!r.native&&(!r.recursive||l.options.recursive)))return!0;let a=ge.dirname(t);for(let l=1;l<1/0;l++){if(this._watchers[a]?.find(h=>(l===1||h.options.recursive&&l<=(h.options.depth??oe))&&h.handler===i&&(!h.filePath||h.filePath===n)&&h.options.ignore===r.ignore&&!!h.options.native==!!r.native&&(!r.recursive||h.options.recursive&&ae&&h.options.native!==!1)))return!0;if(!ae)break;let u=ge.dirname(t);if(a===u)break;a=u}return!1}async watchDirectories(t,r,i,n,o){if(this.isClosed())return;t=w.lang.uniq(t).sort();let a;for(let l of t)if(!this.isIgnored(l,r.ignore,!0)&&!this.watcherExists(l,r,i,n))try{let f=!r.recursive||ae&&r.native!==!1?r:{...r,recursive:!1},h={watcher:yt.watch(l,f),handler:i,options:r,folderPath:l,filePath:n},m=a=await this.watcherAdd(h,o);if(this._roots.has(n||l)){let d={...r,ignoreInitial:!0,recursive:!1},x=ge.dirname(l),D=l;await this.watchDirectories([x],d,i,D,m)}}catch(f){this.error(f)}return a}async watchDirectory(t,r,i,n,o){if(!this.isClosed()&&!this.isIgnored(t,r.ignore,!0)){if(!r.recursive||ae&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,o));{r={...r,recursive:!0};let a=r.depth??oe,l=r.limit??Ee,[f]=await w.fs.readdir(t,r.ignore,a,l,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let u=await this.watchDirectories([t],r,i,n,o);if(f.length){let h=w.fs.getDepth(t);for(let m of f){let p=w.fs.getDepth(m),d=Math.max(0,a-(p-h)),x={...r,depth:d};await this.watchDirectories([m],x,i,n,o||u)}}})}}}async watchFileOnce(t,r,i){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let n={targetPath:t,options:r},o=s((u,h)=>{h===t&&(f(),i())},"handler"),a=new e(o),l=s(()=>{this._subwatchers.add(n),this.on(P.CLOSE,f),a.watchFile(t,r,o)},"start"),f=s(()=>{this._subwatchers.delete(n),this.removeListener(P.CLOSE,f),a.close()},"stop");return l()}async watchFile(t,r,i){if(this.isClosed()||this.isIgnored(t,r.ignore,!1))return;r={...r,recursive:!1};let n=ge.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,o=new pt,a=await this.watchPolling(t,r,async()=>{n||!(await o.update(t,r.pollingTimeout)).length||n||(n=!0,a(),i())})}async watchPolling(t,r,i){if(this.isClosed())return w.lang.noop;if(this.pollerExists(t,r))return w.lang.noop;let n={...r,interval:r.pollingInterval??dr},o={targetPath:t,options:r},a=s(()=>{this._pollers.add(o),this.on(P.CLOSE,l),yt.watchFile(t,n,i)},"start"),l=s(()=>{this._pollers.delete(o),this.removeListener(P.CLOSE,l),yt.unwatchFile(t,i)},"stop");return w.lang.attempt(a),()=>w.lang.attempt(l)}async watchUnknownChild(t,r,i){if(this.isClosed())return;let n=s(()=>this.watchPath(t,r,i),"watch");return this.watchFileOnce(t,r,n)}async watchUnknownTarget(t,r,i){if(this.isClosed())return;let n=s(()=>this.watchPath(t,r,i),"watch");return this.watchPollingOnce(t,r,n)}async watchPaths(t,r,i){if(this.isClosed())return;if(t=w.lang.uniq(t).sort(),t.every((o,a)=>t.every((l,f)=>f===a||!w.fs.isSubPath(o,l))))await Promise.all(t.map(o=>this.watchPath(o,r,i)));else for(let o of t)await this.watchPath(o,r,i)}async watchPath(t,r,i){if(this.isClosed()||(t=ge.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await w.fs.poll(t,r.pollingTimeout);if(n){if(n.isFile())return this.watchFile(t,r,i);if(n.isDirectory())return this.watchDirectory(t,r,i);this.error(`"${t}" is not supported`)}else{let o=ge.dirname(t);return(await w.fs.poll(o,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=w.lang.noop){if(w.lang.isFunction(t))return this.watch([],{},t);if(w.lang.isUndefined(t))return this.watch([],r,i);if(w.lang.isFunction(r))return this.watch(t,{},r);if(w.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=w.lang.castArray(t);n.forEach(o=>this._roots.add(o)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==w.lang.noop&&this.on(P.ALL,i),r.readdirMap=void 0,this.ready())}},Rr=wt;var an=We(Kr(),1);c();var Et=s(((e,...t)=>{let r=Kt(e,...t);Ge.isInteractive?Ge.updateFooter(r):Ge.writeStdout(r)}),"footer");c();var rn=We(tn(),1);var nn=s((e,t)=>{e.log.info("notifying user",{notification:t}),rn.default.notify({title:"Gadget",contentImage:et("favicon-128@4x.png"),icon:et("favicon-128@4x.png"),sound:!0,timeout:!1,...t},r=>{r&&e.log.warn("error notifying user",{notification:t})})},"notify");var fu={...nr,...Qt,"--prefer":ir,"--file-push-delay":{type:Number,default:(0,ne.default)("100ms")},"--file-watch-debounce":{type:Number,default:(0,ne.default)("300ms")},"--file-watch-poll-interval":{type:Number,default:(0,ne.default)("3s")},"--file-watch-poll-timeout":{type:Number,default:(0,ne.default)("20s")},"--file-watch-rename-timeout":{type:Number,default:(0,ne.default)("1.25s")},"--no-logs":Boolean},uu=s(e=>H`
|
|
4
|
+
Clones your Gadget environment's files to your local machine and keeps it in sync, in order to
|
|
5
|
+
enable local development with your text editor and source code with Git.
|
|
6
|
+
|
|
7
|
+
If your app's local directory already exists, this command first performs a sync to ensure
|
|
8
|
+
that your local and environment directories match, changes are tracked since last sync. If any
|
|
9
|
+
conflicts are detected, they must be resolved before development starts.
|
|
10
|
+
|
|
11
|
+
{gray Usage}
|
|
12
|
+
$ ggt dev [DIRECTORY] [options]
|
|
13
|
+
|
|
14
|
+
DIRECTORY: The directory to sync files to (default: the current directory)
|
|
15
|
+
|
|
16
|
+
{gray Options}
|
|
17
|
+
-a, --app <app_name> Selects the app to sync files with. Defaults to the app synced to the current directory, if there is one.
|
|
18
|
+
-e, --env <env_name> Selects the environment to sync files with. Defaults to the environment synced to the current directory, if there is one.
|
|
19
|
+
--prefer <source> Auto-select changes from 'local' or 'environment' source on conflict
|
|
20
|
+
--allow-unknown-directory Syncs to any local directory with existing files, even if the directory hasn't been synced before
|
|
21
|
+
--allow-different-app Syncs with a different app using the --app command, instead of the most recently synced one in the current directory
|
|
22
|
+
--log-level <level> Sets the log level for incoming application logs (default: info)
|
|
23
|
+
--no-logs Disables outputting application logs to the console
|
|
24
|
+
--my-logs Only outputs user sourced logs
|
|
25
|
+
|
|
26
|
+
{gray Ignoring files}
|
|
27
|
+
ggt dev uses a .ignore file, similar to .gitignore, to exclude specific files and
|
|
28
|
+
folders from syncing. These files are always ignored:
|
|
29
|
+
|
|
30
|
+
• .DS_Store
|
|
31
|
+
• .gadget
|
|
32
|
+
• .git
|
|
33
|
+
• node_modules
|
|
34
|
+
• .shopify
|
|
35
|
+
|
|
36
|
+
{gray Notes}
|
|
37
|
+
• "ggt dev" only works with development environments
|
|
38
|
+
• "ggt dev" only supports "yarn" v1 for installing dependencies
|
|
39
|
+
• Avoid deleting or moving all of your files while "ggt dev" is running
|
|
40
|
+
|
|
41
|
+
{gray Examples}
|
|
42
|
+
sync an app in a custom path
|
|
43
|
+
{cyanBright $ ggt dev ~/myGadgetApps/myBlog --app myBlogApp}
|
|
44
|
+
|
|
45
|
+
sync with a specific environment and preselect all local changes on conflicts
|
|
46
|
+
{cyanBright $ ggt dev --env main --prefer local}
|
|
47
|
+
|
|
48
|
+
sync a custom path with a specific app, environment and preselect all changes from local on conflicts
|
|
49
|
+
{cyanBright $ ggt dev ~/gadget/example --app=example --env=development --prefer=local}
|
|
50
|
+
`,"usage"),hu=s(async(e,t)=>{if(!await(0,an.default)("yarn",{nothrow:!0}))throw new Zt;let r=await or(t._[0]||process.cwd()),i=await sr.loadOrAskAndInit(e,{command:"dev",args:t,directory:r});await Vt(r),e.onAbort(async()=>{await Xt(r)}),await lr({ctx:e,directory:i.directory}),await fr({ctx:e,directory:i.directory}),Et({ensureEmptyLineAbove:!0,content:i.sprint()});let n=new ar(i),o=await n.hashes(e);if(!o.inSync)if(!i.previousEnvironment||o.localChangesToPush.size===0&&o.onlyDotGadgetFilesChanged)await n.merge(e,{hashes:o,printLocalChangesOptions:{limit:5},printEnvironmentChangesOptions:{limit:5}});else{await n.print(e,{hashes:o});let d=Object.values(z);switch(await tr({ensureEmptyLineAbove:!0,choices:o.bothChanged?d:d.filter(D=>D!==z.MERGE),content:jt.bold("What do you want to do?"),formatChoice:s(D=>{switch(D){case z.CANCEL:return H`Cancel (Ctrl+C)`;case z.MERGE:return H`Merge local and environment's changes`;case z.PUSH:switch(!0){case o.bothChanged:return H`Push local changes and {underline discard environment's} changes`;case o.localChanges.size>0:return H`Push local changes`;case o.environmentChanges.size>0:return H`Discard environment's changes`;default:return rt("no changes to push or discard")}case z.PULL:switch(!0){case o.bothChanged:return H`Pull environment's changes and {underline discard local} changes`;case o.localChanges.size>0:return H`Discard local changes`;case o.environmentChanges.size>0:return H`Pull environment's changes`;default:return rt("no changes to pull or discard")}}},"formatChoice")})){case z.CANCEL:process.exit(0);break;case z.MERGE:await n.merge(e,{hashes:o});break;case z.PUSH:await n.push(e,{command:"dev",hashes:o});break;case z.PULL:await n.pull(e,{hashes:o,force:!0});break}}let a=new Map,l=setInterval(()=>{for(let[d,x]of a)(0,on.default)().isAfter(x+(0,ne.default)("5s"))&&a.delete(d)},(0,ne.default)("1s")).unref(),f=n.subscribeToEnvironmentChanges(e,{onError:s(d=>e.abort(d),"onError"),beforeChanges:s(({changed:d,deleted:x})=>{for(let D of[...d,...x]){a.set(D,Date.now());let L=sn.dirname(D);for(;L!==".";)a.set(L+"/",Date.now()),L=sn.dirname(L)}},"beforeChanges")}),u;t["--no-logs"]||(u=cr(i.edit,t,{onError:s(d=>{e.abort(d)},"onError")}));let h=new tt,m=$t(t["--file-push-delay"],async()=>{try{let d=i.gitBranch;if(await i.loadGitBranch(),d!==i.gitBranch){zt({ensureEmptyLineAbove:!0,content:H`
|
|
51
|
+
Your git branch changed.
|
|
52
|
+
|
|
53
|
+
${d} → ${i.gitBranch}
|
|
54
|
+
`});let D=rr({ensureEmptyLineAbove:!0,content:"Waiting for file changes to settle."});await er("3s"),D.succeed()}let x=new tt(h.entries());h.clear(),await n.mergeChangesWithEnvironment(e,{changes:x})}catch(d){e.log.error("error sending changes to gadget",{error:d}),e.abort(d)}});e.log.debug("watching",{path:i.directory.path});let p=new Rr(i.directory.path,{ignoreInitial:!0,recursive:!0,ignore:s((d,x)=>{if(i.directory.relative(d).startsWith(".gadget"))return!0;if(x===void 0)try{x=uo.statSync(d).isDirectory()}catch{x=!1}return i.directory.ignores(d,x)},"ignore"),renameDetection:!0,renameTimeout:t["--file-watch-rename-timeout"],debounce:t["--file-watch-debounce"]},(d,x,D)=>{let L=d==="rename"||d==="renameDir"?D:x,j=d==="renameDir"||d==="addDir"||d==="unlinkDir",b=i.directory.normalize(L,j);if(e.log.trace("file event",{event:d,isDirectory:j,path:b}),a.delete(b)){e.log.trace("ignoring event because we caused it",{event:d,path:b});return}if(L===i.directory.absolute(".ignore"))i.directory.ignoreFileLoadedWithin((0,ne.default)("2s"))||i.directory.loadIgnoreFile().catch(W=>e.abort(W));else if(i.directory.ignores(L,j))return;switch(d){case"add":case"addDir":h.set(b,{type:"create"});break;case"rename":case"renameDir":{let W=i.directory.normalize(x,j);h.set(b,{type:"create",oldPath:W});break}case"change":{h.set(b,{type:"update"});break}case"unlink":case"unlinkDir":{h.set(b,{type:"delete"});break}}m()}).once("error",d=>e.abort(d));e.onAbort(async d=>{e.log.info("stopping",{reason:d}),u?.unsubscribe(),f.unsubscribe(),p.close(),clearInterval(l),await m.flush();try{await n.idle()}catch(x){e.log.error("error while waiting for idle",{error:x})}Ht(d)||(nn(e,{subtitle:"Uh oh!",message:"An error occurred while syncing files"}),await Jt(e,d))}),Et({ensureEmptyLineAbove:!0,content:H`
|
|
55
|
+
${i.sprint({indent:4})}
|
|
56
|
+
|
|
57
|
+
Waiting for file changes${Yt.ellipsis} {gray Press Ctrl+C to stop}
|
|
58
|
+
`})},"run");export{fu as args,hu as run,uu as usage};
|
|
59
|
+
//# sourceMappingURL=dev-GGUSOOYP.js.map
|