ph-cmd 6.0.0-dev.22 → 6.0.0-dev.23

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.
Files changed (3) hide show
  1. package/build/cli.js +694 -43
  2. package/build/cli.old.js +7171 -7161
  3. package/package.json +3 -3
package/build/cli.js CHANGED
@@ -653509,7 +653509,7 @@ globstar while`, file2, fr9, pattern, pr9, swallowee);
653509
653509
  throw err;
653510
653510
  }
653511
653511
  }
653512
- function fetch(url4, dest, proxy) {
653512
+ function fetch2(url4, dest, proxy) {
653513
653513
  return new Promise((fulfil, reject) => {
653514
653514
  let options8 = url4;
653515
653515
  if (proxy) {
@@ -653525,7 +653525,7 @@ globstar while`, file2, fr9, pattern, pr9, swallowee);
653525
653525
  if (code >= 400) {
653526
653526
  reject({ code, message: response.statusMessage });
653527
653527
  } else if (code >= 300) {
653528
- fetch(response.headers.location, dest, proxy).then(fulfil, reject);
653528
+ fetch2(response.headers.location, dest, proxy).then(fulfil, reject);
653529
653529
  } else {
653530
653530
  response.pipe(fs__default["default"].createWriteStream(dest)).on("finish", () => fulfil()).on("error", reject);
653531
653531
  }
@@ -653781,7 +653781,7 @@ globstar while`, file2, fr9, pattern, pr9, swallowee);
653781
653781
  code: "DOWNLOADING",
653782
653782
  message: `downloading ${url4} to ${file2}`
653783
653783
  });
653784
- await fetch(url4, file2, this.proxy);
653784
+ await fetch2(url4, file2, this.proxy);
653785
653785
  }
653786
653786
  }
653787
653787
  } catch (err) {
@@ -659288,7 +659288,7 @@ var exports_version = {};
659288
659288
  __export(exports_version, {
659289
659289
  version: () => version2
659290
659290
  });
659291
- var version2 = "6.0.0-dev.21";
659291
+ var version2 = "6.0.0-dev.22";
659292
659292
 
659293
659293
  // ../../node_modules/.pnpm/imurmurhash@0.1.4/node_modules/imurmurhash/imurmurhash.js
659294
659294
  var require_imurmurhash = __commonJS((exports, module3) => {
@@ -692993,9 +692993,605 @@ PH CLI package manager: ${packageManager}
692993
692993
  }
692994
692994
 
692995
692995
  // src/commands/init.ts
692996
+ init_source();
692996
692997
  var import_cmd_ts12 = __toESM(require_cjs(), 1);
692997
692998
  var import_enquirer2 = __toESM(require_enquirer(), 1);
692998
692999
  var import_semver4 = __toESM(require_semver2(), 1);
693000
+
693001
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/classes/ClientError.js
693002
+ class ClientError extends Error {
693003
+ response;
693004
+ request;
693005
+ constructor(response, request) {
693006
+ const message = `${ClientError.extractMessage(response)}: ${JSON.stringify({
693007
+ response,
693008
+ request
693009
+ })}`;
693010
+ super(message);
693011
+ Object.setPrototypeOf(this, ClientError.prototype);
693012
+ this.response = response;
693013
+ this.request = request;
693014
+ if (typeof Error.captureStackTrace === `function`) {
693015
+ Error.captureStackTrace(this, ClientError);
693016
+ }
693017
+ }
693018
+ static extractMessage(response) {
693019
+ return response.errors?.[0]?.message ?? `GraphQL Error (Code: ${String(response.status)})`;
693020
+ }
693021
+ }
693022
+
693023
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/lib/prelude.js
693024
+ var uppercase2 = (str2) => str2.toUpperCase();
693025
+ var callOrIdentity = (value2) => {
693026
+ return typeof value2 === `function` ? value2() : value2;
693027
+ };
693028
+ var zip = (a5, b25) => a5.map((k8, i4) => [k8, b25[i4]]);
693029
+ var HeadersInitToPlainObject = (headers) => {
693030
+ let oHeaders = {};
693031
+ if (headers instanceof Headers) {
693032
+ oHeaders = HeadersInstanceToPlainObject(headers);
693033
+ } else if (Array.isArray(headers)) {
693034
+ headers.forEach(([name, value2]) => {
693035
+ if (name && value2 !== undefined) {
693036
+ oHeaders[name] = value2;
693037
+ }
693038
+ });
693039
+ } else if (headers) {
693040
+ oHeaders = headers;
693041
+ }
693042
+ return oHeaders;
693043
+ };
693044
+ var HeadersInstanceToPlainObject = (headers) => {
693045
+ const o5 = {};
693046
+ headers.forEach((v25, k8) => {
693047
+ o5[k8] = v25;
693048
+ });
693049
+ return o5;
693050
+ };
693051
+ var tryCatch = (fn9) => {
693052
+ try {
693053
+ const result = fn9();
693054
+ if (isPromiseLikeValue(result)) {
693055
+ return result.catch((error49) => {
693056
+ return errorFromMaybeError(error49);
693057
+ });
693058
+ }
693059
+ return result;
693060
+ } catch (error49) {
693061
+ return errorFromMaybeError(error49);
693062
+ }
693063
+ };
693064
+ var errorFromMaybeError = (maybeError) => {
693065
+ if (maybeError instanceof Error)
693066
+ return maybeError;
693067
+ return new Error(String(maybeError));
693068
+ };
693069
+ var isPromiseLikeValue = (value2) => {
693070
+ return typeof value2 === `object` && value2 !== null && `then` in value2 && typeof value2.then === `function` && `catch` in value2 && typeof value2.catch === `function` && `finally` in value2 && typeof value2.finally === `function`;
693071
+ };
693072
+ var casesExhausted = (value2) => {
693073
+ throw new Error(`Unhandled case: ${String(value2)}`);
693074
+ };
693075
+ var isPlainObject3 = (value2) => {
693076
+ return typeof value2 === `object` && value2 !== null && !Array.isArray(value2);
693077
+ };
693078
+
693079
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/functions/batchRequests.js
693080
+ var parseBatchRequestArgs = (documentsOrOptions, requestHeaders) => {
693081
+ return documentsOrOptions.documents ? documentsOrOptions : {
693082
+ documents: documentsOrOptions,
693083
+ requestHeaders,
693084
+ signal: undefined
693085
+ };
693086
+ };
693087
+
693088
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/functions/rawRequest.js
693089
+ var parseRawRequestArgs = (queryOrOptions, variables, requestHeaders) => {
693090
+ return queryOrOptions.query ? queryOrOptions : {
693091
+ query: queryOrOptions,
693092
+ variables,
693093
+ requestHeaders,
693094
+ signal: undefined
693095
+ };
693096
+ };
693097
+
693098
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/lib/graphql.js
693099
+ var import_graphql29 = __toESM(require_graphql2(), 1);
693100
+
693101
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/lib/http.js
693102
+ var ACCEPT_HEADER = `Accept`;
693103
+ var CONTENT_TYPE_HEADER = `Content-Type`;
693104
+ var CONTENT_TYPE_JSON = `application/json`;
693105
+ var CONTENT_TYPE_GQL = `application/graphql-response+json`;
693106
+
693107
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/lib/graphql.js
693108
+ var cleanQuery = (str2) => str2.replace(/([\s,]|#[^\n\r]+)+/g, ` `).trim();
693109
+ var isGraphQLContentType = (contentType) => {
693110
+ const contentTypeLower = contentType.toLowerCase();
693111
+ return contentTypeLower.includes(CONTENT_TYPE_GQL) || contentTypeLower.includes(CONTENT_TYPE_JSON);
693112
+ };
693113
+ var parseGraphQLExecutionResult = (result) => {
693114
+ try {
693115
+ if (Array.isArray(result)) {
693116
+ return {
693117
+ _tag: `Batch`,
693118
+ executionResults: result.map(parseExecutionResult)
693119
+ };
693120
+ } else if (isPlainObject3(result)) {
693121
+ return {
693122
+ _tag: `Single`,
693123
+ executionResult: parseExecutionResult(result)
693124
+ };
693125
+ } else {
693126
+ throw new Error(`Invalid execution result: result is not object or array.
693127
+ Got:
693128
+ ${String(result)}`);
693129
+ }
693130
+ } catch (e8) {
693131
+ return e8;
693132
+ }
693133
+ };
693134
+ var parseExecutionResult = (result) => {
693135
+ if (typeof result !== `object` || result === null) {
693136
+ throw new Error(`Invalid execution result: result is not object`);
693137
+ }
693138
+ let errors3 = undefined;
693139
+ let data = undefined;
693140
+ let extensions = undefined;
693141
+ if (`errors` in result) {
693142
+ if (!isPlainObject3(result.errors) && !Array.isArray(result.errors)) {
693143
+ throw new Error(`Invalid execution result: errors is not plain object OR array`);
693144
+ }
693145
+ errors3 = result.errors;
693146
+ }
693147
+ if (`data` in result) {
693148
+ if (!isPlainObject3(result.data) && result.data !== null) {
693149
+ throw new Error(`Invalid execution result: data is not plain object`);
693150
+ }
693151
+ data = result.data;
693152
+ }
693153
+ if (`extensions` in result) {
693154
+ if (!isPlainObject3(result.extensions))
693155
+ throw new Error(`Invalid execution result: extensions is not plain object`);
693156
+ extensions = result.extensions;
693157
+ }
693158
+ return {
693159
+ data,
693160
+ errors: errors3,
693161
+ extensions
693162
+ };
693163
+ };
693164
+ var isRequestResultHaveErrors = (result) => result._tag === `Batch` ? result.executionResults.some(isExecutionResultHaveErrors) : isExecutionResultHaveErrors(result.executionResult);
693165
+ var isExecutionResultHaveErrors = (result) => Array.isArray(result.errors) ? result.errors.length > 0 : Boolean(result.errors);
693166
+ var isOperationDefinitionNode = (definition) => {
693167
+ return typeof definition === `object` && definition !== null && `kind` in definition && definition.kind === import_graphql29.Kind.OPERATION_DEFINITION;
693168
+ };
693169
+
693170
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/helpers/analyzeDocument.js
693171
+ var import_graphql31 = __toESM(require_graphql2(), 1);
693172
+ var import_graphql32 = __toESM(require_graphql2(), 1);
693173
+ var extractOperationName = (document2) => {
693174
+ let operationName = undefined;
693175
+ const defs = document2.definitions.filter(isOperationDefinitionNode);
693176
+ if (defs.length === 1) {
693177
+ operationName = defs[0].name?.value;
693178
+ }
693179
+ return operationName;
693180
+ };
693181
+ var extractIsMutation = (document2) => {
693182
+ let isMutation = false;
693183
+ const defs = document2.definitions.filter(isOperationDefinitionNode);
693184
+ if (defs.length === 1) {
693185
+ isMutation = defs[0].operation === `mutation`;
693186
+ }
693187
+ return isMutation;
693188
+ };
693189
+ var analyzeDocument = (document2, excludeOperationName) => {
693190
+ const expression = typeof document2 === `string` ? document2 : import_graphql32.print(document2);
693191
+ let isMutation = false;
693192
+ let operationName = undefined;
693193
+ if (excludeOperationName) {
693194
+ return { expression, isMutation, operationName };
693195
+ }
693196
+ const docNode = tryCatch(() => typeof document2 === `string` ? import_graphql31.parse(document2) : document2);
693197
+ if (docNode instanceof Error) {
693198
+ return { expression, isMutation, operationName };
693199
+ }
693200
+ operationName = extractOperationName(docNode);
693201
+ isMutation = extractIsMutation(docNode);
693202
+ return { expression, operationName, isMutation };
693203
+ };
693204
+
693205
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/helpers/defaultJsonSerializer.js
693206
+ var defaultJsonSerializer = JSON;
693207
+
693208
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/helpers/runRequest.js
693209
+ var runRequest = async (input) => {
693210
+ const config21 = {
693211
+ ...input,
693212
+ method: input.request._tag === `Single` ? input.request.document.isMutation ? `POST` : uppercase2(input.method ?? `post`) : input.request.hasMutations ? `POST` : uppercase2(input.method ?? `post`),
693213
+ fetchOptions: {
693214
+ ...input.fetchOptions,
693215
+ errorPolicy: input.fetchOptions.errorPolicy ?? `none`
693216
+ }
693217
+ };
693218
+ const fetcher = createFetcher(config21.method);
693219
+ const fetchResponse = await fetcher(config21);
693220
+ if (!fetchResponse.ok) {
693221
+ return new ClientError({ status: fetchResponse.status, headers: fetchResponse.headers }, {
693222
+ query: input.request._tag === `Single` ? input.request.document.expression : input.request.query,
693223
+ variables: input.request.variables
693224
+ });
693225
+ }
693226
+ const result = await parseResultFromResponse(fetchResponse, input.fetchOptions.jsonSerializer ?? defaultJsonSerializer);
693227
+ if (result instanceof Error)
693228
+ throw result;
693229
+ const clientResponseBase = {
693230
+ status: fetchResponse.status,
693231
+ headers: fetchResponse.headers
693232
+ };
693233
+ if (isRequestResultHaveErrors(result) && config21.fetchOptions.errorPolicy === `none`) {
693234
+ const clientResponse = result._tag === `Batch` ? { ...result.executionResults, ...clientResponseBase } : {
693235
+ ...result.executionResult,
693236
+ ...clientResponseBase
693237
+ };
693238
+ return new ClientError(clientResponse, {
693239
+ query: input.request._tag === `Single` ? input.request.document.expression : input.request.query,
693240
+ variables: input.request.variables
693241
+ });
693242
+ }
693243
+ switch (result._tag) {
693244
+ case `Single`:
693245
+ return {
693246
+ ...clientResponseBase,
693247
+ ...executionResultClientResponseFields(config21)(result.executionResult)
693248
+ };
693249
+ case `Batch`:
693250
+ return {
693251
+ ...clientResponseBase,
693252
+ data: result.executionResults.map(executionResultClientResponseFields(config21))
693253
+ };
693254
+ default:
693255
+ casesExhausted(result);
693256
+ }
693257
+ };
693258
+ var executionResultClientResponseFields = ($params) => (executionResult) => {
693259
+ return {
693260
+ extensions: executionResult.extensions,
693261
+ data: executionResult.data,
693262
+ errors: $params.fetchOptions.errorPolicy === `all` ? executionResult.errors : undefined
693263
+ };
693264
+ };
693265
+ var parseResultFromResponse = async (response, jsonSerializer) => {
693266
+ const contentType = response.headers.get(CONTENT_TYPE_HEADER);
693267
+ const text = await response.text();
693268
+ if (contentType && isGraphQLContentType(contentType)) {
693269
+ return parseGraphQLExecutionResult(jsonSerializer.parse(text));
693270
+ } else {
693271
+ return parseGraphQLExecutionResult(text);
693272
+ }
693273
+ };
693274
+ var createFetcher = (method) => async (params) => {
693275
+ const headers = new Headers(params.headers);
693276
+ let searchParams = null;
693277
+ let body = undefined;
693278
+ if (!headers.has(ACCEPT_HEADER)) {
693279
+ headers.set(ACCEPT_HEADER, [CONTENT_TYPE_GQL, CONTENT_TYPE_JSON].join(`, `));
693280
+ }
693281
+ if (method === `POST`) {
693282
+ const $jsonSerializer = params.fetchOptions.jsonSerializer ?? defaultJsonSerializer;
693283
+ body = $jsonSerializer.stringify(buildBody(params));
693284
+ if (typeof body === `string` && !headers.has(CONTENT_TYPE_HEADER)) {
693285
+ headers.set(CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON);
693286
+ }
693287
+ } else {
693288
+ searchParams = buildQueryParams(params);
693289
+ }
693290
+ const init4 = { method, headers, body, ...params.fetchOptions };
693291
+ let url4 = new URL(params.url);
693292
+ let initResolved = init4;
693293
+ if (params.middleware) {
693294
+ const result = await Promise.resolve(params.middleware({
693295
+ ...init4,
693296
+ url: params.url,
693297
+ operationName: params.request._tag === `Single` ? params.request.document.operationName : undefined,
693298
+ variables: params.request.variables
693299
+ }));
693300
+ const { url: urlNew, ...initNew } = result;
693301
+ url4 = new URL(urlNew);
693302
+ initResolved = initNew;
693303
+ }
693304
+ if (searchParams) {
693305
+ searchParams.forEach((value2, name) => {
693306
+ url4.searchParams.append(name, value2);
693307
+ });
693308
+ }
693309
+ const $fetch = params.fetch ?? fetch;
693310
+ return await $fetch(url4, initResolved);
693311
+ };
693312
+ var buildBody = (params) => {
693313
+ switch (params.request._tag) {
693314
+ case `Single`:
693315
+ return {
693316
+ query: params.request.document.expression,
693317
+ variables: params.request.variables,
693318
+ operationName: params.request.document.operationName
693319
+ };
693320
+ case `Batch`:
693321
+ return zip(params.request.query, params.request.variables ?? []).map(([query, variables]) => ({
693322
+ query,
693323
+ variables
693324
+ }));
693325
+ default:
693326
+ throw casesExhausted(params.request);
693327
+ }
693328
+ };
693329
+ var buildQueryParams = (params) => {
693330
+ const $jsonSerializer = params.fetchOptions.jsonSerializer ?? defaultJsonSerializer;
693331
+ const searchParams = new URLSearchParams;
693332
+ switch (params.request._tag) {
693333
+ case `Single`: {
693334
+ searchParams.append(`query`, cleanQuery(params.request.document.expression));
693335
+ if (params.request.variables) {
693336
+ searchParams.append(`variables`, $jsonSerializer.stringify(params.request.variables));
693337
+ }
693338
+ if (params.request.document.operationName) {
693339
+ searchParams.append(`operationName`, params.request.document.operationName);
693340
+ }
693341
+ return searchParams;
693342
+ }
693343
+ case `Batch`: {
693344
+ const variablesSerialized = params.request.variables?.map((v25) => $jsonSerializer.stringify(v25)) ?? [];
693345
+ const queriesCleaned = params.request.query.map(cleanQuery);
693346
+ const payload = zip(queriesCleaned, variablesSerialized).map(([query, variables]) => ({
693347
+ query,
693348
+ variables
693349
+ }));
693350
+ searchParams.append(`query`, $jsonSerializer.stringify(payload));
693351
+ return searchParams;
693352
+ }
693353
+ default:
693354
+ throw casesExhausted(params.request);
693355
+ }
693356
+ };
693357
+
693358
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/classes/GraphQLClient.js
693359
+ class GraphQLClient {
693360
+ url;
693361
+ requestConfig;
693362
+ constructor(url4, requestConfig = {}) {
693363
+ this.url = url4;
693364
+ this.requestConfig = requestConfig;
693365
+ }
693366
+ rawRequest = async (...args) => {
693367
+ const [queryOrOptions, variables, requestHeaders] = args;
693368
+ const rawRequestOptions = parseRawRequestArgs(queryOrOptions, variables, requestHeaders);
693369
+ const { headers, fetch: fetch2 = globalThis.fetch, method = `POST`, requestMiddleware, responseMiddleware, excludeOperationName, ...fetchOptions } = this.requestConfig;
693370
+ const { url: url4 } = this;
693371
+ if (rawRequestOptions.signal !== undefined) {
693372
+ fetchOptions.signal = rawRequestOptions.signal;
693373
+ }
693374
+ const document2 = analyzeDocument(rawRequestOptions.query, excludeOperationName);
693375
+ const response = await runRequest({
693376
+ url: url4,
693377
+ request: {
693378
+ _tag: `Single`,
693379
+ document: document2,
693380
+ variables: rawRequestOptions.variables
693381
+ },
693382
+ headers: {
693383
+ ...HeadersInitToPlainObject(callOrIdentity(headers)),
693384
+ ...HeadersInitToPlainObject(rawRequestOptions.requestHeaders)
693385
+ },
693386
+ fetch: fetch2,
693387
+ method,
693388
+ fetchOptions,
693389
+ middleware: requestMiddleware
693390
+ });
693391
+ if (responseMiddleware) {
693392
+ await responseMiddleware(response, {
693393
+ operationName: document2.operationName,
693394
+ variables,
693395
+ url: this.url
693396
+ });
693397
+ }
693398
+ if (response instanceof Error) {
693399
+ throw response;
693400
+ }
693401
+ return response;
693402
+ };
693403
+ async request(documentOrOptions, ...variablesAndRequestHeaders) {
693404
+ const [variables, requestHeaders] = variablesAndRequestHeaders;
693405
+ const requestOptions = parseRequestArgs(documentOrOptions, variables, requestHeaders);
693406
+ const { headers, fetch: fetch2 = globalThis.fetch, method = `POST`, requestMiddleware, responseMiddleware, excludeOperationName, ...fetchOptions } = this.requestConfig;
693407
+ const { url: url4 } = this;
693408
+ if (requestOptions.signal !== undefined) {
693409
+ fetchOptions.signal = requestOptions.signal;
693410
+ }
693411
+ const analyzedDocument = analyzeDocument(requestOptions.document, excludeOperationName);
693412
+ const response = await runRequest({
693413
+ url: url4,
693414
+ request: {
693415
+ _tag: `Single`,
693416
+ document: analyzedDocument,
693417
+ variables: requestOptions.variables
693418
+ },
693419
+ headers: {
693420
+ ...HeadersInitToPlainObject(callOrIdentity(headers)),
693421
+ ...HeadersInitToPlainObject(requestOptions.requestHeaders)
693422
+ },
693423
+ fetch: fetch2,
693424
+ method,
693425
+ fetchOptions,
693426
+ middleware: requestMiddleware
693427
+ });
693428
+ if (responseMiddleware) {
693429
+ await responseMiddleware(response, {
693430
+ operationName: analyzedDocument.operationName,
693431
+ variables: requestOptions.variables,
693432
+ url: this.url
693433
+ });
693434
+ }
693435
+ if (response instanceof Error) {
693436
+ throw response;
693437
+ }
693438
+ return response.data;
693439
+ }
693440
+ async batchRequests(documentsOrOptions, requestHeaders) {
693441
+ const batchRequestOptions = parseBatchRequestArgs(documentsOrOptions, requestHeaders);
693442
+ const { headers, excludeOperationName, ...fetchOptions } = this.requestConfig;
693443
+ if (batchRequestOptions.signal !== undefined) {
693444
+ fetchOptions.signal = batchRequestOptions.signal;
693445
+ }
693446
+ const analyzedDocuments = batchRequestOptions.documents.map(({ document: document2 }) => analyzeDocument(document2, excludeOperationName));
693447
+ const expressions = analyzedDocuments.map(({ expression }) => expression);
693448
+ const hasMutations = analyzedDocuments.some(({ isMutation }) => isMutation);
693449
+ const variables = batchRequestOptions.documents.map(({ variables: variables2 }) => variables2);
693450
+ const response = await runRequest({
693451
+ url: this.url,
693452
+ request: {
693453
+ _tag: `Batch`,
693454
+ operationName: undefined,
693455
+ query: expressions,
693456
+ hasMutations,
693457
+ variables
693458
+ },
693459
+ headers: {
693460
+ ...HeadersInitToPlainObject(callOrIdentity(headers)),
693461
+ ...HeadersInitToPlainObject(batchRequestOptions.requestHeaders)
693462
+ },
693463
+ fetch: this.requestConfig.fetch ?? globalThis.fetch,
693464
+ method: this.requestConfig.method || `POST`,
693465
+ fetchOptions,
693466
+ middleware: this.requestConfig.requestMiddleware
693467
+ });
693468
+ if (this.requestConfig.responseMiddleware) {
693469
+ await this.requestConfig.responseMiddleware(response, {
693470
+ operationName: undefined,
693471
+ variables,
693472
+ url: this.url
693473
+ });
693474
+ }
693475
+ if (response instanceof Error) {
693476
+ throw response;
693477
+ }
693478
+ return response.data;
693479
+ }
693480
+ setHeaders(headers) {
693481
+ this.requestConfig.headers = headers;
693482
+ return this;
693483
+ }
693484
+ setHeader(key2, value2) {
693485
+ const { headers } = this.requestConfig;
693486
+ if (headers) {
693487
+ headers[key2] = value2;
693488
+ } else {
693489
+ this.requestConfig.headers = { [key2]: value2 };
693490
+ }
693491
+ return this;
693492
+ }
693493
+ setEndpoint(value2) {
693494
+ this.url = value2;
693495
+ return this;
693496
+ }
693497
+ }
693498
+
693499
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/functions/request.js
693500
+ var parseRequestArgs = (documentOrOptions, variables, requestHeaders) => {
693501
+ return documentOrOptions.document ? documentOrOptions : {
693502
+ document: documentOrOptions,
693503
+ variables,
693504
+ requestHeaders,
693505
+ signal: undefined
693506
+ };
693507
+ };
693508
+ // ../../node_modules/.pnpm/graphql-request@7.3.1_graphql@16.12.0/node_modules/graphql-request/build/legacy/functions/gql.js
693509
+ var gql = (chunks, ...variables) => {
693510
+ return chunks.reduce((acc, chunk, index) => `${acc}${chunk}${index in variables ? String(variables[index]) : ``}`, ``);
693511
+ };
693512
+ // ../../packages/common/dist/utils/vetra-gql.js
693513
+ async function getVetraDocuments(graphqlEndpoint, driveId) {
693514
+ const client = new GraphQLClient(graphqlEndpoint, {
693515
+ fetch
693516
+ });
693517
+ const query = gql`
693518
+ query GetDocuments($driveId: String!) {
693519
+ VetraPackage {
693520
+ getDocuments(driveId: $driveId) {
693521
+ id
693522
+ state {
693523
+ githubUrl
693524
+ }
693525
+ }
693526
+ }
693527
+ }
693528
+ `;
693529
+ const response = await client.request(query, {
693530
+ driveId
693531
+ });
693532
+ return response.VetraPackage.getDocuments.map((doc2) => ({
693533
+ id: doc2.id,
693534
+ githubUrl: doc2.state.githubUrl
693535
+ }));
693536
+ }
693537
+ async function createVetraDocument(graphqlEndpoint, driveId, name = "vetra-package") {
693538
+ const client = new GraphQLClient(graphqlEndpoint, {
693539
+ fetch
693540
+ });
693541
+ const mutation = gql`
693542
+ mutation CreateDocument($driveId: String, $name: String) {
693543
+ VetraPackage_createDocument(driveId: $driveId, name: $name)
693544
+ }
693545
+ `;
693546
+ const response = await client.request(mutation, {
693547
+ driveId,
693548
+ name
693549
+ });
693550
+ return response.VetraPackage_createDocument;
693551
+ }
693552
+
693553
+ // src/utils/validate-remote-drive.ts
693554
+ async function setupRemoteDrive(remoteDriveUrl) {
693555
+ try {
693556
+ const driveId = remoteDriveUrl.split("/").pop();
693557
+ if (!remoteDriveUrl || remoteDriveUrl.trim() === "") {
693558
+ console.error("❌ Remote drive URL is required");
693559
+ return false;
693560
+ }
693561
+ const url4 = new URL(remoteDriveUrl);
693562
+ const graphqlEndpoint = `${url4.protocol}//${url4.host}/graphql`;
693563
+ let documents = await getVetraDocuments(graphqlEndpoint, driveId);
693564
+ if (documents.length === 0) {
693565
+ console.log("No vetra package document found in the provided drive, creating one...");
693566
+ try {
693567
+ await createVetraDocument(graphqlEndpoint, driveId, "vetra-package");
693568
+ documents = await getVetraDocuments(graphqlEndpoint, driveId);
693569
+ if (documents.length === 0) {
693570
+ console.error("❌ Failed to create vetra package document in the remote drive");
693571
+ return false;
693572
+ }
693573
+ console.log("✅ Vetra package document created successfully");
693574
+ } catch (createError2) {
693575
+ console.error("❌ Failed to create vetra package document:", createError2);
693576
+ return false;
693577
+ }
693578
+ }
693579
+ if (documents.length > 1) {
693580
+ console.warn("⚠️ Multiple vetra package documents were found in the provided remote drive, this might be an error in your remote drive");
693581
+ }
693582
+ const hasGithubUrl = documents.some((doc2) => doc2.githubUrl);
693583
+ if (hasGithubUrl) {
693584
+ console.error("❌ The remote drive provided already has been configured with a github url, please use the checkout command instead: ph checkout --remote-drive <remote drive url>");
693585
+ return false;
693586
+ }
693587
+ return true;
693588
+ } catch (error49) {
693589
+ console.error("❌ Unable to fetch remote drive info:", error49);
693590
+ return false;
693591
+ }
693592
+ }
693593
+
693594
+ // src/commands/init.ts
692999
693595
  var initArgs = {
693000
693596
  namePositional: import_cmd_ts12.positional({
693001
693597
  type: import_cmd_ts12.optional(import_cmd_ts12.string),
@@ -693038,26 +693634,32 @@ var initArgs = {
693038
693634
  long: "remote-drive",
693039
693635
  short: "r",
693040
693636
  description: "Remote drive identifier."
693041
- })
693637
+ }),
693638
+ ...debugArgs
693042
693639
  };
693043
693640
  var init4 = import_cmd_ts12.command({
693044
693641
  name: "init",
693045
693642
  description: "Initialize a new project",
693046
693643
  args: initArgs,
693047
- handler: async ({
693048
- namePositional,
693049
- nameOption,
693050
- packageManager,
693051
- npm: npm2,
693052
- pnpm: pnpm2,
693053
- yarn: yarn2,
693054
- bun: bun2,
693055
- tag: tag2,
693056
- version: version3,
693057
- dev,
693058
- staging,
693059
- remoteDrive
693060
- }) => {
693644
+ handler: async (args) => {
693645
+ const {
693646
+ namePositional,
693647
+ nameOption,
693648
+ packageManager,
693649
+ npm: npm2,
693650
+ pnpm: pnpm2,
693651
+ yarn: yarn2,
693652
+ bun: bun2,
693653
+ tag: tag2,
693654
+ version: version3,
693655
+ dev,
693656
+ staging,
693657
+ remoteDrive,
693658
+ debug
693659
+ } = args;
693660
+ if (debug) {
693661
+ console.log({ args });
693662
+ }
693061
693663
  let name = namePositional ?? nameOption;
693062
693664
  if (!name) {
693063
693665
  const { prompt } = import_enquirer2.default;
@@ -693075,15 +693677,18 @@ var init4 = import_cmd_ts12.command({
693075
693677
  if (!name) {
693076
693678
  throw new Error("You must provide a name for your project.");
693077
693679
  }
693680
+ console.log("step 1 done");
693078
693681
  if (version3 !== undefined && !import_semver4.valid(import_semver4.clean(version3))) {
693079
693682
  throw new Error(`Invalid version: ${version3}`);
693080
693683
  }
693684
+ console.log("step w done");
693081
693685
  handleMutuallyExclusiveOptions({
693082
693686
  tag: tag2,
693083
693687
  version: version3,
693084
693688
  dev,
693085
693689
  staging
693086
693690
  }, "versioning strategy");
693691
+ console.log("step 3 done");
693087
693692
  handleMutuallyExclusiveOptions({
693088
693693
  npm: npm2,
693089
693694
  pnpm: pnpm2,
@@ -693091,6 +693696,7 @@ var init4 = import_cmd_ts12.command({
693091
693696
  bun: bun2,
693092
693697
  packageManager
693093
693698
  }, "package manager");
693699
+ console.log("step 4 done");
693094
693700
  const parsedPackageManager = parsePackageManager({
693095
693701
  npm: npm2,
693096
693702
  pnpm: pnpm2,
@@ -693098,18 +693704,48 @@ var init4 = import_cmd_ts12.command({
693098
693704
  bun: bun2,
693099
693705
  packageManager
693100
693706
  }) ?? "npm";
693707
+ console.log("step 5 done");
693101
693708
  const parsedTag = parseTag({
693102
693709
  tag: tag2,
693103
693710
  dev,
693104
693711
  staging
693105
693712
  });
693106
- return {
693107
- name,
693108
- version: version3,
693109
- remoteDrive,
693110
- packageManager: parsedPackageManager,
693111
- tag: parsedTag
693112
- };
693713
+ try {
693714
+ if (remoteDrive) {
693715
+ console.log(source_default.blue(`
693716
+ ⏳ Setting up remote drive...
693717
+ `));
693718
+ await setupRemoteDrive(remoteDrive);
693719
+ console.log(source_default.green(`
693720
+ ✅ Remote drive set up.`));
693721
+ }
693722
+ console.log(source_default.bold(`
693723
+ \uD83D\uDE80 Initializing a new project...
693724
+ `));
693725
+ await createProject({
693726
+ ...args,
693727
+ name,
693728
+ packageManager: parsedPackageManager,
693729
+ tag: parsedTag
693730
+ });
693731
+ if (remoteDrive) {
693732
+ console.log();
693733
+ console.log("To link your project to GitHub:");
693734
+ console.log();
693735
+ console.log(" 1. Create a new repository on GitHub");
693736
+ console.log(` 2. cd ${name}`);
693737
+ console.log(" 3. git add . && git commit -m 'Initial commit'");
693738
+ console.log(" 4. git remote add origin <your-github-url>");
693739
+ console.log(` 5. git push -u origin main`);
693740
+ console.log();
693741
+ }
693742
+ } catch (error49) {
693743
+ console.error(`
693744
+ ❌ Failed to initialize project:
693745
+ `);
693746
+ throw error49;
693747
+ }
693748
+ process.exit(0);
693113
693749
  }
693114
693750
  });
693115
693751
 
@@ -693119,7 +693755,11 @@ var setupGlobals = import_cmd_ts13.command({
693119
693755
  name: "setup-globals",
693120
693756
  description: "Initialize a new global project",
693121
693757
  args: initArgs,
693122
- handler: async ({ namePositional, nameOption, ...options8 }) => {
693758
+ handler: async (args) => {
693759
+ const { namePositional, nameOption, debug, ...options8 } = args;
693760
+ if (debug) {
693761
+ console.log({ args });
693762
+ }
693123
693763
  const name = namePositional ?? nameOption;
693124
693764
  await createGlobalProject(name, options8);
693125
693765
  process.exit(0);
@@ -693139,7 +693779,7 @@ import path20 from "node:path";
693139
693779
  import fs13, { promises as fsPromises2 } from "node:fs";
693140
693780
 
693141
693781
  // ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
693142
- function isPlainObject3(value2) {
693782
+ function isPlainObject4(value2) {
693143
693783
  if (typeof value2 !== "object" || value2 === null) {
693144
693784
  return false;
693145
693785
  }
@@ -693149,7 +693789,7 @@ function isPlainObject3(value2) {
693149
693789
 
693150
693790
  // ../../node_modules/.pnpm/sort-keys@5.1.0/node_modules/sort-keys/index.js
693151
693791
  function sortKeys(object2, options8 = {}) {
693152
- if (!isPlainObject3(object2) && !Array.isArray(object2)) {
693792
+ if (!isPlainObject4(object2) && !Array.isArray(object2)) {
693153
693793
  throw new TypeError("Expected a plain object or array");
693154
693794
  }
693155
693795
  const { deep, compare } = options8;
@@ -693165,7 +693805,7 @@ function sortKeys(object2, options8 = {}) {
693165
693805
  if (Array.isArray(item)) {
693166
693806
  return deepSortArray(item);
693167
693807
  }
693168
- if (isPlainObject3(item)) {
693808
+ if (isPlainObject4(item)) {
693169
693809
  return _sortKeys(item);
693170
693810
  }
693171
693811
  return item;
@@ -693186,7 +693826,7 @@ function sortKeys(object2, options8 = {}) {
693186
693826
  if (deep && Array.isArray(value2)) {
693187
693827
  newValue = deepSortArray(value2);
693188
693828
  } else {
693189
- newValue = deep && isPlainObject3(value2) ? _sortKeys(value2) : value2;
693829
+ newValue = deep && isPlainObject4(value2) ? _sortKeys(value2) : value2;
693190
693830
  }
693191
693831
  Object.defineProperty(result, key2, {
693192
693832
  ...Object.getOwnPropertyDescriptor(object3, key2),
@@ -693314,7 +693954,7 @@ var init5 = (function_, filePath, data, options8) => {
693314
693954
  sortKeys: false,
693315
693955
  ...options8
693316
693956
  };
693317
- if (options8.sortKeys && isPlainObject3(data)) {
693957
+ if (options8.sortKeys && isPlainObject4(data)) {
693318
693958
  data = sortKeys(data, {
693319
693959
  deep: true,
693320
693960
  compare: typeof options8.sortKeys === "function" ? options8.sortKeys : undefined
@@ -693424,9 +694064,14 @@ var update = import_cmd_ts14.command({
693424
694064
  long: "skip-install",
693425
694065
  short: "s",
693426
694066
  description: "Skip running `install` with your package manager"
693427
- })
694067
+ }),
694068
+ ...debugArgs
693428
694069
  },
693429
- handler: async ({ skipInstall }) => {
694070
+ handler: async (args) => {
694071
+ const { skipInstall, debug } = args;
694072
+ if (debug) {
694073
+ console.log({ args });
694074
+ }
693430
694075
  console.log(`
693431
694076
  ▶️ Updating Powerhouse dependencies...
693432
694077
  `);
@@ -693542,13 +694187,14 @@ var useLocal = import_cmd_ts15.command({
693542
694187
  long: "skip-install",
693543
694188
  short: "s",
693544
694189
  description: "Skip running `install` with `pnpm`"
693545
- })
694190
+ }),
694191
+ ...debugArgs
693546
694192
  },
693547
- handler: async ({
693548
- monorepoPathPositional,
693549
- monorepoPathOption,
693550
- skipInstall
693551
- }) => {
694193
+ handler: async (args) => {
694194
+ const { monorepoPathPositional, monorepoPathOption, skipInstall, debug } = args;
694195
+ if (debug) {
694196
+ console.log({ args });
694197
+ }
693552
694198
  const monorepoPath = monorepoPathPositional ?? monorepoPathOption;
693553
694199
  if (!monorepoPath) {
693554
694200
  throw new Error("❌ Please provide the path to your local powerhouse monorepo.");
@@ -693665,9 +694311,14 @@ var use = import_cmd_ts16.command({
693665
694311
  long: "skip-install",
693666
694312
  short: "s",
693667
694313
  description: "Skip running `install` with your package manager"
693668
- })
694314
+ }),
694315
+ ...debugArgs
693669
694316
  },
693670
- handler: async ({ tagPositional, tagOption, version: version3, skipInstall }) => {
694317
+ handler: async (args) => {
694318
+ const { tagPositional, tagOption, version: version3, skipInstall, debug } = args;
694319
+ if (debug) {
694320
+ console.log({ args });
694321
+ }
693671
694322
  const tag2 = tagPositional ?? tagOption;
693672
694323
  handleMutuallyExclusiveOptions({ tag: tag2, version: version3 }, "versioning strategy");
693673
694324
  if (!tag2 && !version3) {
@@ -693790,7 +694441,7 @@ async function main2() {
693790
694441
  await executePhCliCommand(command8);
693791
694442
  return;
693792
694443
  }
693793
- await import_cmd_ts18.run(ph2, process.argv.slice(2));
694444
+ await import_cmd_ts18.run(ph2, args);
693794
694445
  }
693795
694446
  await main2().catch((e8) => {
693796
694447
  console.error(e8);