@strapi/cloud-cli 5.9.0 → 5.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,1921 +1,34 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
- const crypto$1 = require("crypto");
26
- const fse = require("fs-extra");
27
- const inquirer = require("inquirer");
28
- const boxen = require("boxen");
29
- const path = require("path");
30
- const chalk = require("chalk");
31
- const axios = require("axios");
32
- const crypto = require("node:crypto");
33
- const utils = require("@strapi/utils");
34
- const tar = require("tar");
35
- const minimatch = require("minimatch");
36
- const fp = require("lodash/fp");
37
- const os = require("os");
38
- const XDGAppPaths = require("xdg-app-paths");
39
- const lodash = require("lodash");
40
- const jwksClient = require("jwks-rsa");
41
- const jwt = require("jsonwebtoken");
42
- const stringify = require("fast-safe-stringify");
43
- const ora = require("ora");
44
- const cliProgress = require("cli-progress");
45
- const pkgUp = require("pkg-up");
46
- const yup = require("yup");
47
- const EventSource = require("eventsource");
48
- const commander = require("commander");
49
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
50
- function _interopNamespace(e) {
51
- if (e && e.__esModule) return e;
52
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
53
- if (e) {
54
- for (const k in e) {
55
- if (k !== "default") {
56
- const d = Object.getOwnPropertyDescriptor(e, k);
57
- Object.defineProperty(n, k, d.get ? d : {
58
- enumerable: true,
59
- get: () => e[k]
60
- });
61
- }
62
- }
63
- }
64
- n.default = e;
65
- return Object.freeze(n);
66
- }
67
- const crypto__default = /* @__PURE__ */ _interopDefault(crypto$1);
68
- const fse__namespace = /* @__PURE__ */ _interopNamespace(fse);
69
- const inquirer__default = /* @__PURE__ */ _interopDefault(inquirer);
70
- const boxen__default = /* @__PURE__ */ _interopDefault(boxen);
71
- const path__namespace = /* @__PURE__ */ _interopNamespace(path);
72
- const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
73
- const axios__default = /* @__PURE__ */ _interopDefault(axios);
74
- const crypto__namespace = /* @__PURE__ */ _interopNamespace(crypto);
75
- const tar__namespace = /* @__PURE__ */ _interopNamespace(tar);
76
- const os__default = /* @__PURE__ */ _interopDefault(os);
77
- const XDGAppPaths__default = /* @__PURE__ */ _interopDefault(XDGAppPaths);
78
- const jwksClient__default = /* @__PURE__ */ _interopDefault(jwksClient);
79
- const jwt__default = /* @__PURE__ */ _interopDefault(jwt);
80
- const stringify__default = /* @__PURE__ */ _interopDefault(stringify);
81
- const ora__default = /* @__PURE__ */ _interopDefault(ora);
82
- const cliProgress__namespace = /* @__PURE__ */ _interopNamespace(cliProgress);
83
- const pkgUp__default = /* @__PURE__ */ _interopDefault(pkgUp);
84
- const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
85
- const EventSource__default = /* @__PURE__ */ _interopDefault(EventSource);
86
- const apiConfig = {
87
- apiBaseUrl: utils.env("STRAPI_CLI_CLOUD_API", "https://cloud-cli-api.strapi.io"),
88
- dashboardBaseUrl: utils.env("STRAPI_CLI_CLOUD_DASHBOARD", "https://cloud.strapi.io")
89
- };
90
- const IGNORED_PATTERNS = [
91
- "**/.git/**",
92
- "**/node_modules/**",
93
- "**/build/**",
94
- "**/dist/**",
95
- "**/.cache/**",
96
- "**/.circleci/**",
97
- "**/.github/**",
98
- "**/.gitignore",
99
- "**/.gitkeep",
100
- "**/.gitlab-ci.yml",
101
- "**/.idea/**",
102
- "**/.vscode/**"
103
- ];
104
- const isIgnoredFile = (folderPath, file, ignorePatterns) => {
105
- ignorePatterns.push(...IGNORED_PATTERNS);
106
- const relativeFilePath = path__namespace.join(folderPath, file);
107
- let isIgnored = false;
108
- for (const pattern of ignorePatterns) {
109
- if (pattern.startsWith("!")) {
110
- if (minimatch.minimatch(relativeFilePath, pattern.slice(1), { matchBase: true, dot: true })) {
111
- return false;
112
- }
113
- } else if (minimatch.minimatch(relativeFilePath, pattern, { matchBase: true, dot: true })) {
114
- if (path__namespace.basename(file) !== ".gitkeep") {
115
- isIgnored = true;
116
- }
117
- }
118
- }
119
- return isIgnored;
120
- };
121
- const getFiles = async (dirPath, ignorePatterns = [], subfolder = "") => {
122
- const arrayOfFiles = [];
123
- const entries = await fse__namespace.readdir(path__namespace.join(dirPath, subfolder));
124
- for (const entry of entries) {
125
- const entryPathFromRoot = path__namespace.join(subfolder, entry);
126
- const entryPath = path__namespace.relative(dirPath, entryPathFromRoot);
127
- const isIgnored = isIgnoredFile(dirPath, entryPathFromRoot, ignorePatterns);
128
- if (!isIgnored) {
129
- if (fse__namespace.statSync(entryPath).isDirectory()) {
130
- const subFiles = await getFiles(dirPath, ignorePatterns, entryPathFromRoot);
131
- arrayOfFiles.push(...subFiles);
132
- } else {
133
- arrayOfFiles.push(entryPath);
134
- }
135
- }
136
- }
137
- return arrayOfFiles;
138
- };
139
- const readGitignore = async (folderPath) => {
140
- const gitignorePath = path__namespace.resolve(folderPath, ".gitignore");
141
- const pathExist = await fse__namespace.pathExists(gitignorePath);
142
- if (!pathExist) return [];
143
- const gitignoreContent = await fse__namespace.readFile(gitignorePath, "utf8");
144
- return gitignoreContent.split(/\r?\n/).filter((line) => Boolean(line.trim()) && !line.startsWith("#"));
145
- };
146
- const compressFilesToTar = async (storagePath, folderToCompress, filename) => {
147
- const ignorePatterns = await readGitignore(folderToCompress);
148
- const filesToCompress = await getFiles(folderToCompress, ignorePatterns);
149
- return tar__namespace.c(
150
- {
151
- gzip: true,
152
- file: path__namespace.resolve(storagePath, filename)
153
- },
154
- filesToCompress
155
- );
156
- };
157
- const APP_FOLDER_NAME = "com.strapi.cli";
158
- const CONFIG_FILENAME = "config.json";
159
- async function checkDirectoryExists(directoryPath) {
160
- try {
161
- const fsStat = await fse__namespace.default.lstat(directoryPath);
162
- return fsStat.isDirectory();
163
- } catch (e) {
164
- return false;
165
- }
166
- }
167
- async function getTmpStoragePath() {
168
- const storagePath = path__namespace.default.join(os__default.default.tmpdir(), APP_FOLDER_NAME);
169
- await fse__namespace.default.ensureDir(storagePath);
170
- return storagePath;
171
- }
172
- async function getConfigPath() {
173
- const configDirs = XDGAppPaths__default.default(APP_FOLDER_NAME).configDirs();
174
- const configPath = configDirs.find(checkDirectoryExists);
175
- if (!configPath) {
176
- await fse__namespace.default.ensureDir(configDirs[0]);
177
- return configDirs[0];
178
- }
179
- return configPath;
180
- }
181
- async function getLocalConfig$1() {
182
- const configPath = await getConfigPath();
183
- const configFilePath = path__namespace.default.join(configPath, CONFIG_FILENAME);
184
- await fse__namespace.default.ensureFile(configFilePath);
185
- try {
186
- return await fse__namespace.default.readJSON(configFilePath, { encoding: "utf8", throws: true });
187
- } catch (e) {
188
- return {};
189
- }
190
- }
191
- async function saveLocalConfig(data) {
192
- const configPath = await getConfigPath();
193
- const configFilePath = path__namespace.default.join(configPath, CONFIG_FILENAME);
194
- await fse__namespace.default.writeJson(configFilePath, data, { encoding: "utf8", spaces: 2, mode: 384 });
195
- }
196
- const name = "@strapi/cloud-cli";
197
- const version = "5.8.1";
198
- const description = "Commands to interact with the Strapi Cloud";
199
- const keywords = [
200
- "strapi",
201
- "cloud",
202
- "cli"
203
- ];
204
- const homepage = "https://strapi.io";
205
- const bugs = {
206
- url: "https://github.com/strapi/strapi/issues"
207
- };
208
- const repository = {
209
- type: "git",
210
- url: "git://github.com/strapi/strapi.git"
211
- };
212
- const license = "SEE LICENSE IN LICENSE";
213
- const author = {
214
- name: "Strapi Solutions SAS",
215
- email: "hi@strapi.io",
216
- url: "https://strapi.io"
217
- };
218
- const maintainers = [
219
- {
220
- name: "Strapi Solutions SAS",
221
- email: "hi@strapi.io",
222
- url: "https://strapi.io"
223
- }
224
- ];
225
- const main = "./dist/index.js";
226
- const module$1 = "./dist/index.mjs";
227
- const source = "./src/index.ts";
228
- const types = "./dist/src/index.d.ts";
229
- const bin = "./bin/index.js";
230
- const files = [
231
- "./dist",
232
- "./bin"
233
- ];
234
- const scripts = {
235
- build: "pack-up build",
236
- clean: "run -T rimraf ./dist",
237
- lint: "run -T eslint .",
238
- "test:unit": "run -T jest",
239
- watch: "pack-up watch"
240
- };
241
- const dependencies = {
242
- "@strapi/utils": "5.8.1",
243
- axios: "1.7.4",
244
- boxen: "5.1.2",
245
- chalk: "4.1.2",
246
- "cli-progress": "3.12.0",
247
- commander: "8.3.0",
248
- eventsource: "2.0.2",
249
- "fast-safe-stringify": "2.1.1",
250
- "fs-extra": "11.2.0",
251
- inquirer: "8.2.5",
252
- jsonwebtoken: "9.0.0",
253
- "jwks-rsa": "3.1.0",
254
- lodash: "4.17.21",
255
- minimatch: "9.0.3",
256
- open: "8.4.0",
257
- ora: "5.4.1",
258
- "pkg-up": "3.1.0",
259
- tar: "6.2.1",
260
- "xdg-app-paths": "8.3.0",
261
- yup: "0.32.9"
262
- };
263
- const devDependencies = {
264
- "@strapi/pack-up": "5.0.2",
265
- "@types/cli-progress": "3.11.5",
266
- "@types/eventsource": "1.1.15",
267
- "@types/lodash": "^4.14.191",
268
- "eslint-config-custom": "5.8.1",
269
- tsconfig: "5.8.1"
270
- };
271
- const engines = {
272
- node: ">=18.0.0 <=22.x.x",
273
- npm: ">=6.0.0"
274
- };
275
- const packageJson = {
276
- name,
277
- version,
278
- description,
279
- keywords,
280
- homepage,
281
- bugs,
282
- repository,
283
- license,
284
- author,
285
- maintainers,
286
- main,
287
- module: module$1,
288
- source,
289
- types,
290
- bin,
291
- files,
292
- scripts,
293
- dependencies,
294
- devDependencies,
295
- engines
296
- };
297
- const VERSION = "v1";
298
- async function cloudApiFactory({ logger }, token) {
299
- const localConfig = await getLocalConfig$1();
300
- const customHeaders = {
301
- "x-device-id": localConfig.deviceId,
302
- "x-app-version": packageJson.version,
303
- "x-os-name": os__default.default.type(),
304
- "x-os-version": os__default.default.version(),
305
- "x-language": Intl.DateTimeFormat().resolvedOptions().locale,
306
- "x-node-version": process.versions.node
307
- };
308
- const axiosCloudAPI = axios__default.default.create({
309
- baseURL: `${apiConfig.apiBaseUrl}/${VERSION}`,
310
- headers: {
311
- "Content-Type": "application/json",
312
- ...customHeaders
313
- }
314
- });
315
- if (token) {
316
- axiosCloudAPI.defaults.headers.Authorization = `Bearer ${token}`;
317
- }
318
- return {
319
- deploy({ filePath, project }, { onUploadProgress }) {
320
- return axiosCloudAPI.post(
321
- `/deploy/${project.name}`,
322
- { file: fse__namespace.default.createReadStream(filePath), targetEnvironment: project.targetEnvironment },
323
- {
324
- headers: {
325
- "Content-Type": "multipart/form-data"
326
- },
327
- onUploadProgress
328
- }
329
- );
330
- },
331
- async createProject({ name: name2, nodeVersion, region, plan }) {
332
- const response = await axiosCloudAPI.post("/project", {
333
- projectName: name2,
334
- region,
335
- nodeVersion,
336
- plan
337
- });
338
- return {
339
- data: {
340
- id: response.data.id,
341
- name: response.data.name,
342
- nodeVersion: response.data.nodeVersion,
343
- region: response.data.region
344
- },
345
- status: response.status
346
- };
347
- },
348
- getUserInfo() {
349
- return axiosCloudAPI.get("/user");
350
- },
351
- async config() {
352
- try {
353
- const response = await axiosCloudAPI.get("/config");
354
- if (response.status !== 200) {
355
- throw new Error("Error fetching cloud CLI config from the server.");
356
- }
357
- return response;
358
- } catch (error) {
359
- logger.debug(
360
- "🥲 Oops! Couldn't retrieve the cloud CLI config from the server. Please try again."
361
- );
362
- throw error;
363
- }
364
- },
365
- async listProjects() {
366
- try {
367
- const response = await axiosCloudAPI.get("/projects");
368
- if (response.status !== 200) {
369
- throw new Error("Error fetching cloud projects from the server.");
370
- }
371
- return response;
372
- } catch (error) {
373
- logger.debug(
374
- "🥲 Oops! Couldn't retrieve your project's list from the server. Please try again."
375
- );
376
- throw error;
377
- }
378
- },
379
- async listLinkProjects() {
380
- try {
381
- const response = await axiosCloudAPI.get("/projects-linkable");
382
- if (response.status !== 200) {
383
- throw new Error("Error fetching cloud projects from the server.");
384
- }
385
- return response;
386
- } catch (error) {
387
- logger.debug(
388
- "🥲 Oops! Couldn't retrieve your project's list from the server. Please try again."
389
- );
390
- throw error;
391
- }
392
- },
393
- async listEnvironments({ name: name2 }) {
394
- try {
395
- const response = await axiosCloudAPI.get(`/projects/${name2}/environments`);
396
- if (response.status !== 200) {
397
- throw new Error("Error fetching cloud environments from the server.");
398
- }
399
- return response;
400
- } catch (error) {
401
- logger.debug(
402
- "🥲 Oops! Couldn't retrieve your project's environments from the server. Please try again."
403
- );
404
- throw error;
405
- }
406
- },
407
- async listLinkEnvironments({ name: name2 }) {
408
- try {
409
- const response = await axiosCloudAPI.get(`/projects/${name2}/environments-linkable`);
410
- if (response.status !== 200) {
411
- throw new Error("Error fetching cloud environments from the server.");
412
- }
413
- return response;
414
- } catch (error) {
415
- logger.debug(
416
- "🥲 Oops! Couldn't retrieve your project's environments from the server. Please try again."
417
- );
418
- throw error;
419
- }
420
- },
421
- async getProject({ name: name2 }) {
422
- try {
423
- const response = await axiosCloudAPI.get(`/projects/${name2}`);
424
- if (response.status !== 200) {
425
- throw new Error("Error fetching project's details.");
426
- }
427
- return response;
428
- } catch (error) {
429
- logger.debug(
430
- "🥲 Oops! There was a problem retrieving your project's details. Please try again."
431
- );
432
- throw error;
433
- }
434
- },
435
- track(event, payload = {}) {
436
- return axiosCloudAPI.post("/track", {
437
- event,
438
- payload
439
- });
440
- }
441
- };
442
- }
443
- const LOCAL_SAVE_FILENAME = ".strapi-cloud.json";
444
- const getFilePath = (directoryPath) => path__namespace.default.join(directoryPath || process.cwd(), LOCAL_SAVE_FILENAME);
445
- async function save(data, { directoryPath } = {}) {
446
- const pathToFile = getFilePath(directoryPath);
447
- await fse__namespace.default.ensureDir(path__namespace.default.dirname(pathToFile));
448
- await fse__namespace.default.writeJson(pathToFile, data, { encoding: "utf8" });
449
- }
450
- async function retrieve({
451
- directoryPath
452
- } = {}) {
453
- const pathToFile = getFilePath(directoryPath);
454
- const pathExists = await fse__namespace.default.pathExists(pathToFile);
455
- if (!pathExists) {
456
- return {};
457
- }
458
- return fse__namespace.default.readJSON(pathToFile, { encoding: "utf8" });
459
- }
460
- async function patch(patchData, { directoryPath } = {}) {
461
- const pathToFile = getFilePath(directoryPath);
462
- const existingData = await retrieve({ directoryPath });
463
- if (!existingData) {
464
- throw new Error("No configuration data found to patch.");
465
- }
466
- const newData = lodash.merge(existingData, patchData);
467
- await fse__namespace.default.writeJson(pathToFile, newData, { encoding: "utf8" });
468
- }
469
- async function deleteConfig({ directoryPath } = {}) {
470
- const pathToFile = getFilePath(directoryPath);
471
- const pathExists = await fse__namespace.default.pathExists(pathToFile);
472
- if (pathExists) {
473
- await fse__namespace.default.remove(pathToFile);
474
- }
475
- }
476
- const strapiInfoSave = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
477
- __proto__: null,
478
- LOCAL_SAVE_FILENAME,
479
- deleteConfig,
480
- patch,
481
- retrieve,
482
- save
483
- }, Symbol.toStringTag, { value: "Module" }));
484
- let cliConfig;
485
- async function tokenServiceFactory({ logger }) {
486
- const cloudApiService = await cloudApiFactory({ logger });
487
- async function saveToken(str) {
488
- const appConfig = await getLocalConfig$1();
489
- if (!appConfig) {
490
- logger.error("There was a problem saving your token. Please try again.");
491
- return;
492
- }
493
- appConfig.token = str;
494
- try {
495
- await saveLocalConfig(appConfig);
496
- } catch (e) {
497
- logger.debug(e);
498
- logger.error("There was a problem saving your token. Please try again.");
499
- }
500
- }
501
- async function retrieveToken() {
502
- const appConfig = await getLocalConfig$1();
503
- if (appConfig.token) {
504
- if (await isTokenValid(appConfig.token)) {
505
- return appConfig.token;
506
- }
507
- }
508
- return void 0;
509
- }
510
- async function validateToken(idToken, jwksUrl) {
511
- const client = jwksClient__default.default({
512
- jwksUri: jwksUrl
513
- });
514
- const getKey = (header, callback) => {
515
- client.getSigningKey(header.kid, (e, key) => {
516
- if (e) {
517
- callback(e);
518
- } else if (key) {
519
- const publicKey = "publicKey" in key ? key.publicKey : key.rsaPublicKey;
520
- callback(null, publicKey);
521
- } else {
522
- callback(new Error("Key not found"));
523
- }
524
- });
525
- };
526
- const decodedToken = jwt__default.default.decode(idToken, { complete: true });
527
- if (!decodedToken) {
528
- if (typeof idToken === "undefined" || idToken === "") {
529
- logger.warn("You need to be logged in to use this feature. Please log in and try again.");
530
- } else {
531
- logger.error(
532
- "There seems to be a problem with your login information. Please try logging in again."
533
- );
534
- }
535
- return Promise.reject(new Error("Invalid token"));
536
- }
537
- return new Promise((resolve, reject) => {
538
- jwt__default.default.verify(idToken, getKey, (err) => {
539
- if (err) {
540
- reject(err);
541
- }
542
- if (decodedToken.payload.exp < Math.floor(Date.now() / 1e3)) {
543
- reject(new Error("Token is expired"));
544
- }
545
- resolve();
546
- });
547
- });
548
- }
549
- async function isTokenValid(token) {
550
- try {
551
- const config = await cloudApiService.config();
552
- cliConfig = config.data;
553
- if (token) {
554
- await validateToken(token, cliConfig.jwksUrl);
555
- return true;
556
- }
557
- return false;
558
- } catch (e) {
559
- logger.debug(e);
560
- return false;
561
- }
562
- }
563
- async function eraseToken() {
564
- const appConfig = await getLocalConfig$1();
565
- if (!appConfig) {
566
- return;
567
- }
568
- delete appConfig.token;
569
- try {
570
- await saveLocalConfig(appConfig);
571
- } catch (e) {
572
- logger.debug(e);
573
- logger.error(
574
- "There was an issue removing your login information. Please try logging out again."
575
- );
576
- throw e;
577
- }
578
- }
579
- async function getValidToken(ctx, loginAction2) {
580
- let token = await retrieveToken();
581
- while (!token || !await isTokenValid(token)) {
582
- logger.log(
583
- token ? "Oops! Your token seems expired or invalid. Please login again." : "We couldn't find a valid token. You need to be logged in to use this feature."
584
- );
585
- if (!await loginAction2(ctx)) return null;
586
- token = await retrieveToken();
587
- }
588
- return token;
589
- }
590
- return {
591
- saveToken,
592
- retrieveToken,
593
- validateToken,
594
- isTokenValid,
595
- eraseToken,
596
- getValidToken
597
- };
598
- }
599
- const stringifyArg = (arg) => {
600
- return typeof arg === "object" ? stringify__default.default(arg) : arg;
601
- };
602
- const createLogger = (options = {}) => {
603
- const { silent = false, debug = false, timestamp = true } = options;
604
- const state = { errors: 0, warning: 0 };
605
- return {
606
- get warnings() {
607
- return state.warning;
608
- },
609
- get errors() {
610
- return state.errors;
611
- },
612
- async debug(...args) {
613
- if (silent || !debug) {
614
- return;
615
- }
616
- console.log(
617
- chalk__default.default.cyan(`[DEBUG]${timestamp ? ` [${(/* @__PURE__ */ new Date()).toISOString()}]` : ""}`),
618
- ...args.map(stringifyArg)
619
- );
620
- },
621
- info(...args) {
622
- if (silent) {
623
- return;
624
- }
625
- console.info(
626
- chalk__default.default.blue(`[INFO]${timestamp ? ` [${(/* @__PURE__ */ new Date()).toISOString()}]` : ""}`),
627
- ...args.map(stringifyArg)
628
- );
629
- },
630
- log(...args) {
631
- if (silent) {
632
- return;
633
- }
634
- console.info(
635
- chalk__default.default.blue(`${timestamp ? ` [${(/* @__PURE__ */ new Date()).toISOString()}]` : ""}`),
636
- ...args.map(stringifyArg)
637
- );
638
- },
639
- success(...args) {
640
- if (silent) {
641
- return;
642
- }
643
- console.info(
644
- chalk__default.default.green(`[SUCCESS]${timestamp ? ` [${(/* @__PURE__ */ new Date()).toISOString()}]` : ""}`),
645
- ...args.map(stringifyArg)
646
- );
647
- },
648
- warn(...args) {
649
- state.warning += 1;
650
- if (silent) {
651
- return;
652
- }
653
- console.warn(
654
- chalk__default.default.yellow(`[WARN]${timestamp ? ` [${(/* @__PURE__ */ new Date()).toISOString()}]` : ""}`),
655
- ...args.map(stringifyArg)
656
- );
657
- },
658
- error(...args) {
659
- state.errors += 1;
660
- if (silent) {
661
- return;
662
- }
663
- console.error(
664
- chalk__default.default.red(`[ERROR]${timestamp ? ` [${(/* @__PURE__ */ new Date()).toISOString()}]` : ""}`),
665
- ...args.map(stringifyArg)
666
- );
667
- },
668
- // @ts-expect-error – returning a subpart of ora is fine because the types tell us what is what.
669
- spinner(text) {
670
- if (silent) {
671
- return {
672
- succeed() {
673
- return this;
674
- },
675
- fail() {
676
- return this;
677
- },
678
- start() {
679
- return this;
680
- },
681
- text: "",
682
- isSpinning: false
683
- };
684
- }
685
- return ora__default.default(text);
686
- },
687
- progressBar(totalSize, text) {
688
- if (silent) {
689
- return {
690
- start() {
691
- return this;
692
- },
693
- stop() {
694
- return this;
695
- },
696
- update() {
697
- return this;
698
- }
699
- };
700
- }
701
- const progressBar = new cliProgress__namespace.SingleBar({
702
- format: `${text ? `${text} |` : ""}${chalk__default.default.green("{bar}")}| {percentage}%`,
703
- barCompleteChar: "█",
704
- barIncompleteChar: "░",
705
- hideCursor: true,
706
- forceRedraw: true
707
- });
708
- progressBar.start(totalSize, 0);
709
- return progressBar;
710
- }
711
- };
712
- };
713
- const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
714
- __proto__: null,
715
- cloudApiFactory,
716
- createLogger,
717
- local: strapiInfoSave,
718
- tokenServiceFactory
719
- }, Symbol.toStringTag, { value: "Module" }));
720
- yup__namespace.object({
721
- name: yup__namespace.string().required(),
722
- exports: yup__namespace.lazy(
723
- (value) => yup__namespace.object(
724
- typeof value === "object" ? Object.entries(value).reduce(
725
- (acc, [key, value2]) => {
726
- if (typeof value2 === "object") {
727
- acc[key] = yup__namespace.object({
728
- types: yup__namespace.string().optional(),
729
- source: yup__namespace.string().required(),
730
- module: yup__namespace.string().optional(),
731
- import: yup__namespace.string().required(),
732
- require: yup__namespace.string().required(),
733
- default: yup__namespace.string().required()
734
- }).noUnknown(true);
735
- } else {
736
- acc[key] = yup__namespace.string().matches(/^\.\/.*\.json$/).required();
737
- }
738
- return acc;
739
- },
740
- {}
741
- ) : void 0
742
- ).optional()
743
- )
744
- });
745
- const loadPkg = async ({ cwd, logger }) => {
746
- const pkgPath = await pkgUp__default.default({ cwd });
747
- if (!pkgPath) {
748
- throw new Error("Could not find a package.json in the current directory");
749
- }
750
- const buffer = await fse__namespace.readFile(pkgPath);
751
- const pkg = JSON.parse(buffer.toString());
752
- logger.debug("Loaded package.json:", os__default.default.EOL, pkg);
753
- return pkg;
754
- };
755
- async function getProjectNameFromPackageJson(ctx) {
756
- try {
757
- const packageJson2 = await loadPkg(ctx);
758
- return packageJson2.name || "my-strapi-project";
759
- } catch (e) {
760
- return "my-strapi-project";
761
- }
762
- }
763
- const trackEvent = async (ctx, cloudApiService, eventName, eventData) => {
764
- try {
765
- await cloudApiService.track(eventName, eventData);
766
- } catch (e) {
767
- ctx.logger.debug(`Failed to track ${eventName}`, e);
768
- }
769
- };
770
- const openModule$1 = import("open");
771
- async function promptLogin(ctx) {
772
- const response = await inquirer__default.default.prompt([
773
- {
774
- type: "confirm",
775
- name: "login",
776
- message: "Would you like to login?"
777
- }
778
- ]);
779
- if (response.login) {
780
- const loginSuccessful = await loginAction(ctx);
781
- return loginSuccessful;
782
- }
783
- return false;
784
- }
785
- async function loginAction(ctx) {
786
- const { logger } = ctx;
787
- const tokenService = await tokenServiceFactory(ctx);
788
- const existingToken = await tokenService.retrieveToken();
789
- const cloudApiService = await cloudApiFactory(ctx, existingToken || void 0);
790
- if (existingToken) {
791
- const isTokenValid = await tokenService.isTokenValid(existingToken);
792
- if (isTokenValid) {
793
- try {
794
- const userInfo = await cloudApiService.getUserInfo();
795
- const { email } = userInfo.data.data;
796
- if (email) {
797
- logger.log(`You are already logged into your account (${email}).`);
798
- } else {
799
- logger.log("You are already logged in.");
800
- }
801
- logger.log(
802
- "To access your dashboard, please copy and paste the following URL into your web browser:"
803
- );
804
- logger.log(chalk__default.default.underline(`${apiConfig.dashboardBaseUrl}/projects`));
805
- return true;
806
- } catch (e) {
807
- logger.debug("Failed to fetch user info", e);
808
- }
809
- }
810
- }
811
- let cliConfig2;
812
- try {
813
- logger.info("🔌 Connecting to the Strapi Cloud API...");
814
- const config = await cloudApiService.config();
815
- cliConfig2 = config.data;
816
- } catch (e) {
817
- logger.error("🥲 Oops! Something went wrong while logging you in. Please try again.");
818
- logger.debug(e);
819
- return false;
820
- }
821
- await trackEvent(ctx, cloudApiService, "willLoginAttempt", {});
822
- logger.debug("🔐 Creating device authentication request...", {
823
- client_id: cliConfig2.clientId,
824
- scope: cliConfig2.scope,
825
- audience: cliConfig2.audience
826
- });
827
- const deviceAuthResponse = await axios__default.default.post(cliConfig2.deviceCodeAuthUrl, {
828
- client_id: cliConfig2.clientId,
829
- scope: cliConfig2.scope,
830
- audience: cliConfig2.audience
831
- }).catch((e) => {
832
- logger.error("There was an issue with the authentication process. Please try again.");
833
- if (e.message) {
834
- logger.debug(e.message, e);
835
- } else {
836
- logger.debug(e);
837
- }
838
- });
839
- openModule$1.then((open) => {
840
- open.default(deviceAuthResponse.data.verification_uri_complete).catch((e) => {
841
- logger.error("We encountered an issue opening the browser. Please try again later.");
842
- logger.debug(e.message, e);
843
- });
844
- });
845
- logger.log("If a browser tab does not open automatically, please follow the next steps:");
846
- logger.log(
847
- `1. Open this url in your device: ${deviceAuthResponse.data.verification_uri_complete}`
848
- );
849
- logger.log(
850
- `2. Enter the following code: ${deviceAuthResponse.data.user_code} and confirm to login.
851
- `
852
- );
853
- const tokenPayload = {
854
- grant_type: "urn:ietf:params:oauth:grant-type:device_code",
855
- device_code: deviceAuthResponse.data.device_code,
856
- client_id: cliConfig2.clientId
857
- };
858
- let isAuthenticated = false;
859
- const authenticate = async () => {
860
- const spinner = logger.spinner("Waiting for authentication");
861
- spinner.start();
862
- const spinnerFail = () => spinner.fail("Authentication failed!");
863
- while (!isAuthenticated) {
864
- try {
865
- const tokenResponse = await axios__default.default.post(cliConfig2.tokenUrl, tokenPayload);
866
- const authTokenData = tokenResponse.data;
867
- if (tokenResponse.status === 200) {
868
- try {
869
- logger.debug("🔐 Validating token...");
870
- await tokenService.validateToken(authTokenData.id_token, cliConfig2.jwksUrl);
871
- logger.debug("🔐 Token validation successful!");
872
- } catch (e) {
873
- logger.debug(e);
874
- spinnerFail();
875
- throw new Error("Unable to proceed: Token validation failed");
876
- }
877
- logger.debug("🔍 Fetching user information...");
878
- const cloudApiServiceWithToken = await cloudApiFactory(ctx, authTokenData.access_token);
879
- await cloudApiServiceWithToken.getUserInfo();
880
- logger.debug("🔍 User information fetched successfully!");
881
- try {
882
- logger.debug("📝 Saving login information...");
883
- await tokenService.saveToken(authTokenData.access_token);
884
- logger.debug("📝 Login information saved successfully!");
885
- isAuthenticated = true;
886
- } catch (e) {
887
- logger.error(
888
- "There was a problem saving your login information. Please try logging in again."
889
- );
890
- logger.debug(e);
891
- spinnerFail();
892
- return false;
893
- }
894
- }
895
- } catch (e) {
896
- if (e.message === "Unable to proceed: Token validation failed") {
897
- logger.error(
898
- "There seems to be a problem with your login information. Please try logging in again."
899
- );
900
- spinnerFail();
901
- await trackEvent(ctx, cloudApiService, "didNotLogin", { loginMethod: "cli" });
902
- return false;
903
- }
904
- if (e.response?.data.error && !["authorization_pending", "slow_down"].includes(e.response.data.error)) {
905
- logger.debug(e);
906
- spinnerFail();
907
- await trackEvent(ctx, cloudApiService, "didNotLogin", { loginMethod: "cli" });
908
- return false;
909
- }
910
- await new Promise((resolve) => {
911
- setTimeout(resolve, deviceAuthResponse.data.interval * 1e3);
912
- });
913
- }
914
- }
915
- spinner.succeed("Authentication successful!");
916
- logger.log("You are now logged into Strapi Cloud.");
917
- logger.log(
918
- "To access your dashboard, please copy and paste the following URL into your web browser:"
919
- );
920
- logger.log(chalk__default.default.underline(`${apiConfig.dashboardBaseUrl}/projects`));
921
- await trackEvent(ctx, cloudApiService, "didLogin", { loginMethod: "cli" });
922
- };
923
- await authenticate();
924
- return isAuthenticated;
925
- }
926
- function questionDefaultValuesMapper(questionsMap) {
927
- return (questions) => {
928
- return questions.map((question) => {
929
- const questionName = question.name;
930
- if (questionName in questionsMap) {
931
- const questionDefault = questionsMap[questionName];
932
- if (typeof questionDefault === "function") {
933
- return {
934
- ...question,
935
- default: questionDefault(question)
936
- };
937
- }
938
- return {
939
- ...question,
940
- default: questionDefault
941
- };
942
- }
943
- return question;
944
- });
945
- };
946
- }
947
- function getDefaultsFromQuestions(questions) {
948
- return questions.reduce((acc, question) => {
949
- if (question.default && question.name) {
950
- return { ...acc, [question.name]: question.default };
951
- }
952
- return acc;
953
- }, {});
954
- }
955
- function getProjectNodeVersionDefault(question) {
956
- const currentNodeVersion = process.versions.node.split(".")[0];
957
- if (question.type === "list" && Array.isArray(question.choices)) {
958
- const choice = question.choices.find((choice2) => choice2.value === currentNodeVersion);
959
- if (choice) {
960
- return choice.value;
961
- }
962
- }
963
- return question.default;
964
- }
965
- async function handleError(ctx, error) {
966
- const { logger } = ctx;
967
- logger.debug(error);
968
- if (error instanceof axios.AxiosError) {
969
- const errorMessage = typeof error.response?.data === "string" ? error.response.data : null;
970
- switch (error.response?.status) {
971
- case 403:
972
- logger.error(
973
- errorMessage || "You do not have permission to create a project. Please contact support for assistance."
974
- );
975
- return;
976
- case 400:
977
- logger.error(errorMessage || "Invalid input. Please check your inputs and try again.");
978
- return;
979
- case 503:
980
- logger.error(
981
- "Strapi Cloud project creation is currently unavailable. Please try again later."
982
- );
983
- return;
984
- default:
985
- if (errorMessage) {
986
- logger.error(errorMessage);
987
- return;
988
- }
989
- break;
990
- }
991
- }
992
- logger.error(
993
- "We encountered an issue while creating your project. Please try again in a moment. If the problem persists, contact support for assistance."
994
- );
995
- }
996
- async function createProject$1(ctx, cloudApi, projectInput) {
997
- const { logger } = ctx;
998
- const spinner = logger.spinner("Setting up your project...").start();
999
- try {
1000
- const { data } = await cloudApi.createProject(projectInput);
1001
- await save({ project: data });
1002
- spinner.succeed("Project created successfully!");
1003
- return data;
1004
- } catch (e) {
1005
- spinner.fail("An error occurred while creating the project on Strapi Cloud.");
1006
- throw e;
1007
- }
1008
- }
1009
- const action$6 = async (ctx) => {
1010
- const { logger } = ctx;
1011
- const { getValidToken, eraseToken } = await tokenServiceFactory(ctx);
1012
- const token = await getValidToken(ctx, promptLogin);
1013
- if (!token) {
1014
- return;
1015
- }
1016
- const cloudApi = await cloudApiFactory(ctx, token);
1017
- const { data: config } = await cloudApi.config();
1018
- const projectName = await getProjectNameFromPackageJson(ctx);
1019
- const defaultAnswersMapper = questionDefaultValuesMapper({
1020
- name: projectName,
1021
- nodeVersion: getProjectNodeVersionDefault
1022
- });
1023
- const questions = defaultAnswersMapper(config.projectCreation.questions);
1024
- const defaultValues = {
1025
- ...config.projectCreation.defaults,
1026
- ...getDefaultsFromQuestions(questions)
1027
- };
1028
- const projectAnswersDefaulted = fp.defaults(defaultValues);
1029
- const projectAnswers = await inquirer__default.default.prompt(questions);
1030
- const projectInput = projectAnswersDefaulted(projectAnswers);
1031
- try {
1032
- return await createProject$1(ctx, cloudApi, projectInput);
1033
- } catch (e) {
1034
- if (e instanceof axios.AxiosError && e.response?.status === 401) {
1035
- logger.warn("Oops! Your session has expired. Please log in again to retry.");
1036
- await eraseToken();
1037
- if (await promptLogin(ctx)) {
1038
- return await createProject$1(ctx, cloudApi, projectInput);
1039
- }
1040
- } else {
1041
- await handleError(ctx, e);
1042
- }
1043
- }
1044
- };
1045
- function notificationServiceFactory({ logger }) {
1046
- return (url, token, cliConfig2) => {
1047
- const CONN_TIMEOUT = Number(cliConfig2.notificationsConnectionTimeout);
1048
- const es = new EventSource__default.default(url, {
1049
- headers: {
1050
- Authorization: `Bearer ${token}`
1051
- }
1052
- });
1053
- let timeoutId;
1054
- const resetTimeout = () => {
1055
- clearTimeout(timeoutId);
1056
- timeoutId = setTimeout(() => {
1057
- logger.log(
1058
- "We were unable to connect to the server at this time. This could be due to a temporary issue. Please try again in a moment."
1059
- );
1060
- es.close();
1061
- }, CONN_TIMEOUT);
1062
- };
1063
- es.onopen = resetTimeout;
1064
- es.onmessage = (event) => {
1065
- resetTimeout();
1066
- const data = JSON.parse(event.data);
1067
- if (data.message) {
1068
- logger.log(data.message);
1069
- }
1070
- if (data.event === "deploymentFinished" || data.event === "deploymentFailed") {
1071
- es.close();
1072
- }
1073
- };
1074
- };
1075
- }
1076
- const buildLogsServiceFactory = ({ logger }) => {
1077
- return async (url, token, cliConfig2) => {
1078
- const CONN_TIMEOUT = Number(cliConfig2.buildLogsConnectionTimeout);
1079
- const MAX_RETRIES = Number(cliConfig2.buildLogsMaxRetries);
1080
- return new Promise((resolve, reject) => {
1081
- let timeoutId = null;
1082
- let retries = 0;
1083
- const connect = (url2) => {
1084
- const spinner = logger.spinner("Connecting to server to get build logs");
1085
- spinner.start();
1086
- const es = new EventSource__default.default(`${url2}`, {
1087
- headers: {
1088
- Authorization: `Bearer ${token}`
1089
- }
1090
- });
1091
- const clearExistingTimeout = () => {
1092
- if (timeoutId) {
1093
- clearTimeout(timeoutId);
1094
- }
1095
- };
1096
- const resetTimeout = () => {
1097
- clearExistingTimeout();
1098
- timeoutId = setTimeout(() => {
1099
- if (spinner.isSpinning) {
1100
- spinner.fail(
1101
- "We were unable to connect to the server to get build logs at this time. This could be due to a temporary issue."
1102
- );
1103
- }
1104
- es.close();
1105
- reject(new Error("Connection timed out"));
1106
- }, CONN_TIMEOUT);
1107
- };
1108
- es.onopen = resetTimeout;
1109
- es.addEventListener("finished", (event) => {
1110
- const data = JSON.parse(event.data);
1111
- logger.log(data.msg);
1112
- es.close();
1113
- clearExistingTimeout();
1114
- resolve(null);
1115
- });
1116
- es.addEventListener("log", (event) => {
1117
- if (spinner.isSpinning) {
1118
- spinner.succeed();
1119
- }
1120
- resetTimeout();
1121
- const data = JSON.parse(event.data);
1122
- logger.log(data.msg);
1123
- });
1124
- es.onerror = async () => {
1125
- retries += 1;
1126
- if (retries > MAX_RETRIES) {
1127
- spinner.fail("We were unable to connect to the server to get build logs at this time.");
1128
- es.close();
1129
- clearExistingTimeout();
1130
- reject(new Error("Max retries reached"));
1131
- }
1132
- };
1133
- };
1134
- connect(url);
1135
- });
1136
- };
1137
- };
1138
- const boxenOptions = {
1139
- padding: 1,
1140
- margin: 1,
1141
- align: "center",
1142
- borderColor: "yellow",
1143
- borderStyle: "round"
1144
- };
1145
- const QUIT_OPTION$2 = "Quit";
1146
- async function promptForEnvironment(environments) {
1147
- const choices = environments.map((env) => ({ name: env, value: env }));
1148
- const { selectedEnvironment } = await inquirer__default.default.prompt([
1149
- {
1150
- type: "list",
1151
- name: "selectedEnvironment",
1152
- message: "Select the environment to deploy:",
1153
- choices: [...choices, { name: chalk__default.default.grey(`(${QUIT_OPTION$2})`), value: null }]
1154
- }
1155
- ]);
1156
- if (selectedEnvironment === null) {
1157
- process.exit(1);
1158
- }
1159
- return selectedEnvironment;
1160
- }
1161
- async function upload(ctx, project, token, maxProjectFileSize) {
1162
- const cloudApi = await cloudApiFactory(ctx, token);
1163
- try {
1164
- const storagePath = await getTmpStoragePath();
1165
- const projectFolder = path__namespace.default.resolve(process.cwd());
1166
- const packageJson2 = await loadPkg(ctx);
1167
- if (!packageJson2) {
1168
- ctx.logger.error(
1169
- "Unable to deploy the project. Please make sure the package.json file is correctly formatted."
1170
- );
1171
- return;
1172
- }
1173
- ctx.logger.log("📦 Compressing project...");
1174
- const hashname = crypto__namespace.createHash("sha512").update(packageJson2.name).digest("hex");
1175
- const compressedFilename = `${hashname}.tar.gz`;
1176
- try {
1177
- ctx.logger.debug(
1178
- "Compression parameters\n",
1179
- `Storage path: ${storagePath}
1180
- `,
1181
- `Project folder: ${projectFolder}
1182
- `,
1183
- `Compressed filename: ${compressedFilename}`
1184
- );
1185
- await compressFilesToTar(storagePath, projectFolder, compressedFilename);
1186
- ctx.logger.log("📦 Project compressed successfully!");
1187
- } catch (e) {
1188
- ctx.logger.error(
1189
- "⚠️ Project compression failed. Try again later or check for large/incompatible files."
1190
- );
1191
- ctx.logger.debug(e);
1192
- process.exit(1);
1193
- }
1194
- const tarFilePath = path__namespace.default.resolve(storagePath, compressedFilename);
1195
- const fileStats = await fse__namespace.default.stat(tarFilePath);
1196
- if (fileStats.size > maxProjectFileSize) {
1197
- ctx.logger.log(
1198
- "Unable to proceed: Your project is too big to be transferred, please use a git repo instead."
1199
- );
1200
- try {
1201
- await fse__namespace.default.remove(tarFilePath);
1202
- } catch (e) {
1203
- ctx.logger.log("Unable to remove file: ", tarFilePath);
1204
- ctx.logger.debug(e);
1205
- }
1206
- return;
1207
- }
1208
- ctx.logger.info("🚀 Uploading project...");
1209
- const progressBar = ctx.logger.progressBar(100, "Upload Progress");
1210
- try {
1211
- const { data } = await cloudApi.deploy(
1212
- { filePath: tarFilePath, project },
1213
- {
1214
- onUploadProgress(progressEvent) {
1215
- const total = progressEvent.total || fileStats.size;
1216
- const percentage = Math.round(progressEvent.loaded * 100 / total);
1217
- progressBar.update(percentage);
1218
- }
1219
- }
1220
- );
1221
- progressBar.update(100);
1222
- progressBar.stop();
1223
- ctx.logger.success("✨ Upload finished!");
1224
- return data.build_id;
1225
- } catch (e) {
1226
- progressBar.stop();
1227
- ctx.logger.error("An error occurred while deploying the project. Please try again later.");
1228
- ctx.logger.debug(e);
1229
- } finally {
1230
- await fse__namespace.default.remove(tarFilePath);
1231
- }
1232
- process.exit(0);
1233
- } catch (e) {
1234
- ctx.logger.error("An error occurred while deploying the project. Please try again later.");
1235
- ctx.logger.debug(e);
1236
- process.exit(1);
1237
- }
1238
- }
1239
- async function getProject(ctx) {
1240
- const { project } = await retrieve();
1241
- if (!project) {
1242
- try {
1243
- return await action$6(ctx);
1244
- } catch (e) {
1245
- ctx.logger.error("An error occurred while deploying the project. Please try again later.");
1246
- ctx.logger.debug(e);
1247
- process.exit(1);
1248
- }
1249
- }
1250
- return project;
1251
- }
1252
- async function getConfig({
1253
- ctx,
1254
- cloudApiService
1255
- }) {
1256
- try {
1257
- const { data: cliConfig2 } = await cloudApiService.config();
1258
- return cliConfig2;
1259
- } catch (e) {
1260
- ctx.logger.debug("Failed to get cli config", e);
1261
- return null;
1262
- }
1263
- }
1264
- function validateEnvironment(ctx, environment, environments) {
1265
- if (!environments.includes(environment)) {
1266
- ctx.logger.error(`Environment ${environment} does not exist.`);
1267
- process.exit(1);
1268
- }
1269
- }
1270
- async function getTargetEnvironment(ctx, opts, project, environments) {
1271
- if (opts.env) {
1272
- validateEnvironment(ctx, opts.env, environments);
1273
- return opts.env;
1274
- }
1275
- if (project.targetEnvironment) {
1276
- return project.targetEnvironment;
1277
- }
1278
- if (environments.length > 1) {
1279
- return promptForEnvironment(environments);
1280
- }
1281
- return environments[0];
1282
- }
1283
- function hasPendingOrLiveDeployment(environments, targetEnvironment) {
1284
- const environment = environments.find((env) => env.name === targetEnvironment);
1285
- if (!environment) {
1286
- throw new Error(`Environment details ${targetEnvironment} not found.`);
1287
- }
1288
- return environment.hasPendingDeployment || environment.hasLiveDeployment || false;
1289
- }
1290
- const action$5 = async (ctx, opts) => {
1291
- const { getValidToken } = await tokenServiceFactory(ctx);
1292
- const token = await getValidToken(ctx, promptLogin);
1293
- if (!token) {
1294
- return;
1295
- }
1296
- const project = await getProject(ctx);
1297
- if (!project) {
1298
- return;
1299
- }
1300
- const cloudApiService = await cloudApiFactory(ctx, token);
1301
- let projectData;
1302
- let environments;
1303
- let environmentsDetails;
1304
- try {
1305
- const {
1306
- data: { data, metadata }
1307
- } = await cloudApiService.getProject({ name: project.name });
1308
- projectData = data;
1309
- environments = projectData.environments;
1310
- environmentsDetails = projectData.environmentsDetails;
1311
- const isProjectSuspended = projectData.suspendedAt;
1312
- if (isProjectSuspended) {
1313
- ctx.logger.log(
1314
- "\n Oops! This project has been suspended. \n\n Please reactivate it from the dashboard to continue deploying: "
1315
- );
1316
- ctx.logger.log(chalk__default.default.underline(`${metadata.dashboardUrls.project}`));
1317
- return;
1318
- }
1319
- } catch (e) {
1320
- if (e instanceof axios.AxiosError && e.response?.data) {
1321
- if (e.response.status === 404) {
1322
- ctx.logger.warn(
1323
- `The project associated with this folder does not exist in Strapi Cloud.
1324
- Please link your local project to an existing Strapi Cloud project using the ${chalk__default.default.cyan(
1325
- "link"
1326
- )} command before deploying.`
1327
- );
1328
- } else {
1329
- ctx.logger.error(e.response.data);
1330
- }
1331
- } else {
1332
- ctx.logger.error(
1333
- "An error occurred while retrieving the project's information. Please try again later."
1334
- );
1335
- }
1336
- ctx.logger.debug(e);
1337
- return;
1338
- }
1339
- await trackEvent(ctx, cloudApiService, "willDeployWithCLI", {
1340
- projectInternalName: project.name
1341
- });
1342
- const notificationService = notificationServiceFactory(ctx);
1343
- const buildLogsService = buildLogsServiceFactory(ctx);
1344
- const cliConfig2 = await getConfig({ ctx, cloudApiService });
1345
- if (!cliConfig2) {
1346
- ctx.logger.error(
1347
- "An error occurred while retrieving data from Strapi Cloud. Please check your network or try again later."
1348
- );
1349
- return;
1350
- }
1351
- let maxSize = parseInt(cliConfig2.maxProjectFileSize, 10);
1352
- if (Number.isNaN(maxSize)) {
1353
- ctx.logger.debug(
1354
- "An error occurred while parsing the maxProjectFileSize. Using default value."
1355
- );
1356
- maxSize = 1e8;
1357
- }
1358
- project.targetEnvironment = await getTargetEnvironment(ctx, opts, project, environments);
1359
- if (!opts.force) {
1360
- const shouldDisplayWarning = hasPendingOrLiveDeployment(
1361
- environmentsDetails,
1362
- project.targetEnvironment
1363
- );
1364
- if (shouldDisplayWarning) {
1365
- ctx.logger.log(boxen__default.default(cliConfig2.projectDeployment.confirmationText, boxenOptions));
1366
- const { confirm } = await inquirer__default.default.prompt([
1367
- {
1368
- type: "confirm",
1369
- name: "confirm",
1370
- message: `Do you want to proceed with deployment to ${chalk__default.default.cyan(projectData.displayName)} on ${chalk__default.default.cyan(project.targetEnvironment)} environment?`
1371
- }
1372
- ]);
1373
- if (!confirm) {
1374
- process.exit(1);
1375
- }
1376
- }
1377
- }
1378
- const buildId = await upload(ctx, project, token, maxSize);
1379
- if (!buildId) {
1380
- return;
1381
- }
1382
- try {
1383
- ctx.logger.log(
1384
- `🚀 Deploying project to ${chalk__default.default.cyan(project.targetEnvironment ?? `production`)} environment...`
1385
- );
1386
- notificationService(`${apiConfig.apiBaseUrl}/notifications`, token, cliConfig2);
1387
- await buildLogsService(`${apiConfig.apiBaseUrl}/v1/logs/${buildId}`, token, cliConfig2);
1388
- ctx.logger.log(
1389
- "Visit the following URL for deployment logs. Your deployment will be available here shortly."
1390
- );
1391
- ctx.logger.log(
1392
- chalk__default.default.underline(`${apiConfig.dashboardBaseUrl}/projects/${project.name}/deployments`)
1393
- );
1394
- } catch (e) {
1395
- ctx.logger.debug(e);
1396
- if (e instanceof Error) {
1397
- ctx.logger.error(e.message);
1398
- } else {
1399
- ctx.logger.error("An error occurred while deploying the project. Please try again later.");
1400
- }
1401
- }
1402
- };
1403
- const assertCwdContainsStrapiProject = (name2) => {
1404
- const logErrorAndExit = () => {
1405
- console.log(
1406
- `You need to run ${chalk__default.default.yellow(
1407
- `strapi ${name2}`
1408
- )} in a Strapi project. Make sure you are in the right directory.`
1409
- );
1410
- process.exit(1);
1411
- };
1412
- try {
1413
- const pkgJSON = require(`${process.cwd()}/package.json`);
1414
- if (!fp.has("dependencies.@strapi/strapi", pkgJSON) && !fp.has("devDependencies.@strapi/strapi", pkgJSON)) {
1415
- logErrorAndExit();
1416
- }
1417
- } catch (err) {
1418
- logErrorAndExit();
1419
- }
1420
- };
1421
- const runAction = (name2, action2) => (...args) => {
1422
- assertCwdContainsStrapiProject(name2);
1423
- Promise.resolve().then(() => {
1424
- return action2(...args);
1425
- }).catch((error) => {
1426
- console.error(error);
1427
- process.exit(1);
1428
- });
1429
- };
1430
- const command$7 = ({ ctx }) => {
1431
- return commander.createCommand("cloud:deploy").alias("deploy").description("Deploy a Strapi Cloud project").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").option("-f, --force", "Skip confirmation to deploy").option("-e, --env <name>", "Specify the environment to deploy").action((opts) => runAction("deploy", action$5)(ctx, opts));
1432
- };
1433
- const deployProject = {
1434
- name: "deploy-project",
1435
- description: "Deploy a Strapi Cloud project",
1436
- action: action$5,
1437
- command: command$7
1438
- };
1439
- async function getLocalConfig(ctx) {
1440
- try {
1441
- return await retrieve();
1442
- } catch (e) {
1443
- ctx.logger.debug("Failed to get project config", e);
1444
- ctx.logger.error("An error occurred while retrieving config data from your local project.");
1445
- return null;
1446
- }
1447
- }
1448
- async function getLocalProject(ctx) {
1449
- const localConfig = await getLocalConfig(ctx);
1450
- if (!localConfig || !localConfig.project) {
1451
- ctx.logger.warn(
1452
- `
1453
- We couldn't find a valid local project config.
1454
- Please link your local project to an existing Strapi Cloud project using the ${chalk__default.default.cyan(
1455
- "link"
1456
- )} command.`
1457
- );
1458
- process.exit(1);
1459
- }
1460
- return localConfig.project;
1461
- }
1462
- const QUIT_OPTION$1 = "Quit";
1463
- async function promptForRelink(ctx, cloudApiService, existingConfig) {
1464
- if (existingConfig && existingConfig.project) {
1465
- const { shouldRelink } = await inquirer__default.default.prompt([
1466
- {
1467
- type: "confirm",
1468
- name: "shouldRelink",
1469
- message: `A project named ${chalk__default.default.cyan(
1470
- existingConfig.project.displayName ? existingConfig.project.displayName : existingConfig.project.name
1471
- )} is already linked to this local folder. Do you want to update the link?`,
1472
- default: false
1473
- }
1474
- ]);
1475
- if (!shouldRelink) {
1476
- await trackEvent(ctx, cloudApiService, "didNotLinkProject", {
1477
- currentProjectName: existingConfig.project?.name
1478
- });
1479
- return false;
1480
- }
1481
- }
1482
- return true;
1483
- }
1484
- async function getProjectsList(ctx, cloudApiService, existingConfig) {
1485
- const spinner = ctx.logger.spinner("Fetching your projects...\n").start();
1486
- try {
1487
- const {
1488
- data: { data: projectList }
1489
- } = await cloudApiService.listLinkProjects();
1490
- spinner.succeed();
1491
- if (!Array.isArray(projectList)) {
1492
- ctx.logger.log("We couldn't find any projects available for linking in Strapi Cloud.");
1493
- return null;
1494
- }
1495
- const projects = projectList.filter(
1496
- (project) => !(project.isMaintainer || project.name === existingConfig?.project?.name)
1497
- ).map((project) => {
1498
- return {
1499
- name: project.displayName,
1500
- value: { name: project.name, displayName: project.displayName }
1501
- };
1502
- });
1503
- if (projects.length === 0) {
1504
- ctx.logger.log("We couldn't find any projects available for linking in Strapi Cloud.");
1505
- return null;
1506
- }
1507
- return projects;
1508
- } catch (e) {
1509
- spinner.fail("An error occurred while fetching your projects from Strapi Cloud.");
1510
- ctx.logger.debug("Failed to list projects", e);
1511
- return null;
1512
- }
1513
- }
1514
- async function getUserSelection(ctx, projects) {
1515
- const { logger } = ctx;
1516
- try {
1517
- const answer = await inquirer__default.default.prompt([
1518
- {
1519
- type: "list",
1520
- name: "linkProject",
1521
- message: "Which project do you want to link?",
1522
- choices: [...projects, { name: chalk__default.default.grey(`(${QUIT_OPTION$1})`), value: null }]
1523
- }
1524
- ]);
1525
- if (!answer.linkProject) {
1526
- return null;
1527
- }
1528
- return answer;
1529
- } catch (e) {
1530
- logger.debug("Failed to get user input", e);
1531
- logger.error("An error occurred while trying to get your input.");
1532
- return null;
1533
- }
1534
- }
1535
- const action$4 = async (ctx) => {
1536
- const { getValidToken } = await tokenServiceFactory(ctx);
1537
- const token = await getValidToken(ctx, promptLogin);
1538
- const { logger } = ctx;
1539
- if (!token) {
1540
- return;
1541
- }
1542
- const cloudApiService = await cloudApiFactory(ctx, token);
1543
- const existingConfig = await getLocalConfig(ctx);
1544
- const shouldRelink = await promptForRelink(ctx, cloudApiService, existingConfig);
1545
- if (!shouldRelink) {
1546
- return;
1547
- }
1548
- await trackEvent(ctx, cloudApiService, "willLinkProject", {});
1549
- const projects = await getProjectsList(
1550
- ctx,
1551
- cloudApiService,
1552
- existingConfig
1553
- );
1554
- if (!projects) {
1555
- return;
1556
- }
1557
- const answer = await getUserSelection(ctx, projects);
1558
- if (!answer) {
1559
- return;
1560
- }
1561
- try {
1562
- const { confirmAction } = await inquirer__default.default.prompt([
1563
- {
1564
- type: "confirm",
1565
- name: "confirmAction",
1566
- message: "Warning: Once linked, deploying from CLI will replace the existing project and its data. Confirm to proceed:",
1567
- default: false
1568
- }
1569
- ]);
1570
- if (!confirmAction) {
1571
- await trackEvent(ctx, cloudApiService, "didNotLinkProject", {
1572
- cancelledProjectName: answer.linkProject.name,
1573
- currentProjectName: existingConfig ? existingConfig.project?.name : null
1574
- });
1575
- return;
1576
- }
1577
- await save({ project: answer.linkProject });
1578
- logger.log(
1579
- ` You have successfully linked your project to ${chalk__default.default.cyan(answer.linkProject.displayName)}. You are now able to deploy your project.`
1580
- );
1581
- await trackEvent(ctx, cloudApiService, "didLinkProject", {
1582
- projectInternalName: answer.linkProject
1583
- });
1584
- } catch (e) {
1585
- logger.debug("Failed to link project", e);
1586
- logger.error("An error occurred while linking the project.");
1587
- await trackEvent(ctx, cloudApiService, "didNotLinkProject", {
1588
- projectInternalName: answer.linkProject
1589
- });
1590
- }
1591
- };
1592
- const command$6 = ({ command: command2, ctx }) => {
1593
- command2.command("cloud:link").alias("link").description("Link a local directory to a Strapi Cloud project").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("link", action$4)(ctx));
1594
- };
1595
- const link = {
1596
- name: "link-project",
1597
- description: "Link a local directory to a Strapi Cloud project",
1598
- action: action$4,
1599
- command: command$6
1600
- };
1601
- const command$5 = ({ ctx }) => {
1602
- return commander.createCommand("cloud:login").alias("login").description("Strapi Cloud Login").addHelpText(
1603
- "after",
1604
- "\nAfter running this command, you will be prompted to enter your authentication information."
1605
- ).option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("login", loginAction)(ctx));
1606
- };
1607
- const login = {
1608
- name: "login",
1609
- description: "Strapi Cloud Login",
1610
- action: loginAction,
1611
- command: command$5
1612
- };
1613
- const openModule = import("open");
1614
- const action$3 = async (ctx) => {
1615
- const { logger } = ctx;
1616
- const { retrieveToken, eraseToken } = await tokenServiceFactory(ctx);
1617
- const token = await retrieveToken();
1618
- if (!token) {
1619
- logger.log("You're already logged out.");
1620
- return;
1621
- }
1622
- const cloudApiService = await cloudApiFactory(ctx, token);
1623
- const config = await cloudApiService.config();
1624
- const cliConfig2 = config.data;
1625
- try {
1626
- await eraseToken();
1627
- openModule.then((open) => {
1628
- open.default(
1629
- `${cliConfig2.baseUrl}/oidc/logout?client_id=${encodeURIComponent(
1630
- cliConfig2.clientId
1631
- )}&logout_hint=${encodeURIComponent(token)}
1632
- `
1633
- ).catch((e) => {
1634
- logger.debug(e.message, e);
1635
- });
1636
- });
1637
- logger.log(
1638
- "🔌 You have been logged out from the CLI. If you are on a shared computer, please make sure to log out from the Strapi Cloud Dashboard as well."
1639
- );
1640
- } catch (e) {
1641
- logger.error("🥲 Oops! Something went wrong while logging you out. Please try again.");
1642
- logger.debug(e);
1643
- }
1644
- await trackEvent(ctx, cloudApiService, "didLogout", { loginMethod: "cli" });
1645
- };
1646
- const command$4 = ({ ctx }) => {
1647
- return commander.createCommand("cloud:logout").alias("logout").description("Strapi Cloud Logout").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("logout", action$3)(ctx));
1648
- };
1649
- const logout = {
1650
- name: "logout",
1651
- description: "Strapi Cloud Logout",
1652
- action: action$3,
1653
- command: command$4
1654
- };
1655
- const command$3 = ({ ctx }) => {
1656
- return commander.createCommand("cloud:create-project").description("Create a Strapi Cloud project").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("cloud:create-project", action$6)(ctx));
1657
- };
1658
- const createProject = {
1659
- name: "create-project",
1660
- description: "Create a new project",
1661
- action: action$6,
1662
- command: command$3
1663
- };
1664
- const action$2 = async (ctx) => {
1665
- const { getValidToken } = await tokenServiceFactory(ctx);
1666
- const token = await getValidToken(ctx, promptLogin);
1667
- const { logger } = ctx;
1668
- if (!token) {
1669
- return;
1670
- }
1671
- const cloudApiService = await cloudApiFactory(ctx, token);
1672
- const spinner = logger.spinner("Fetching your projects...").start();
1673
- try {
1674
- const {
1675
- data: { data: projectList }
1676
- } = await cloudApiService.listProjects();
1677
- spinner.succeed();
1678
- logger.log(projectList);
1679
- } catch (e) {
1680
- ctx.logger.debug("Failed to list projects", e);
1681
- spinner.fail("An error occurred while fetching your projects from Strapi Cloud.");
1682
- }
1683
- };
1684
- const command$2 = ({ command: command2, ctx }) => {
1685
- command2.command("cloud:projects").alias("projects").description("List Strapi Cloud projects").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("projects", action$2)(ctx));
1686
- };
1687
- const listProjects = {
1688
- name: "list-projects",
1689
- description: "List Strapi Cloud projects",
1690
- action: action$2,
1691
- command: command$2
1692
- };
1693
- const action$1 = async (ctx) => {
1694
- const { getValidToken } = await tokenServiceFactory(ctx);
1695
- const token = await getValidToken(ctx, promptLogin);
1696
- const { logger } = ctx;
1697
- if (!token) {
1698
- return;
1699
- }
1700
- const project = await getLocalProject(ctx);
1701
- if (!project) {
1702
- ctx.logger.debug(`No valid local project configuration was found.`);
1703
- return;
1704
- }
1705
- const cloudApiService = await cloudApiFactory(ctx, token);
1706
- const spinner = logger.spinner("Fetching environments...").start();
1707
- await trackEvent(ctx, cloudApiService, "willListEnvironment", {
1708
- projectInternalName: project.name
1709
- });
1710
- try {
1711
- const {
1712
- data: { data: environmentsList }
1713
- } = await cloudApiService.listEnvironments({ name: project.name });
1714
- spinner.succeed();
1715
- logger.log(environmentsList);
1716
- await trackEvent(ctx, cloudApiService, "didListEnvironment", {
1717
- projectInternalName: project.name
1718
- });
1719
- } catch (e) {
1720
- if (e.response && e.response.status === 404) {
1721
- spinner.succeed();
1722
- logger.warn(
1723
- `
1724
- The project associated with this folder does not exist in Strapi Cloud.
1725
- Please link your local project to an existing Strapi Cloud project using the ${chalk__default.default.cyan(
1726
- "link"
1727
- )} command`
1728
- );
1729
- } else {
1730
- spinner.fail("An error occurred while fetching environments data from Strapi Cloud.");
1731
- logger.debug("Failed to list environments", e);
1732
- }
1733
- await trackEvent(ctx, cloudApiService, "didNotListEnvironment", {
1734
- projectInternalName: project.name
1735
- });
1736
- }
1737
- };
1738
- function defineCloudNamespace(command2, ctx) {
1739
- const cloud = command2.command("cloud").description("Manage Strapi Cloud projects");
1740
- cloud.command("environments").description("Alias for cloud environment list").action(() => runAction("list", action$1)(ctx));
1741
- return cloud;
1742
- }
1743
- let environmentCmd = null;
1744
- const initializeEnvironmentCommand = (command2, ctx) => {
1745
- if (!environmentCmd) {
1746
- const cloud = defineCloudNamespace(command2, ctx);
1747
- environmentCmd = cloud.command("environment").description("Manage environments");
1748
- }
1749
- return environmentCmd;
1750
- };
1751
- const command$1 = ({ command: command2, ctx }) => {
1752
- const environmentCmd2 = initializeEnvironmentCommand(command2, ctx);
1753
- environmentCmd2.command("list").description("List Strapi Cloud project environments").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("list", action$1)(ctx));
1754
- };
1755
- const listEnvironments = {
1756
- name: "list-environments",
1757
- description: "List Strapi Cloud environments",
1758
- action: action$1,
1759
- command: command$1
1760
- };
1761
- const QUIT_OPTION = "Quit";
1762
- const action = async (ctx) => {
1763
- const { getValidToken } = await tokenServiceFactory(ctx);
1764
- const token = await getValidToken(ctx, promptLogin);
1765
- const { logger } = ctx;
1766
- if (!token) {
1767
- return;
1768
- }
1769
- const project = await getLocalProject(ctx);
1770
- if (!project) {
1771
- logger.debug(`No valid local project configuration was found.`);
1772
- return;
1773
- }
1774
- const cloudApiService = await cloudApiFactory(ctx, token);
1775
- const environments = await getEnvironmentsList(ctx, cloudApiService, project);
1776
- if (!environments) {
1777
- logger.debug(`Fetching environments failed.`);
1778
- return;
1779
- }
1780
- if (environments.length === 0) {
1781
- logger.log(
1782
- `The only available environment is already linked. You can add a new one from your project settings on the Strapi Cloud dashboard.`
1783
- );
1784
- return;
1785
- }
1786
- const answer = await promptUserForEnvironment(ctx, environments);
1787
- if (!answer) {
1788
- return;
1789
- }
1790
- await trackEvent(ctx, cloudApiService, "willLinkEnvironment", {
1791
- projectName: project.name,
1792
- environmentName: answer.targetEnvironment
1793
- });
1794
- try {
1795
- await patch({ project: { targetEnvironment: answer.targetEnvironment } });
1796
- } catch (e) {
1797
- await trackEvent(ctx, cloudApiService, "didNotLinkEnvironment", {
1798
- projectName: project.name,
1799
- environmentName: answer.targetEnvironment
1800
- });
1801
- logger.debug("Failed to link environment", e);
1802
- logger.error(
1803
- "Failed to link the environment. If this issue persists, try re-linking your project or contact support."
1804
- );
1805
- process.exit(1);
1806
- }
1807
- logger.log(
1808
- ` You have successfully linked your project to ${chalk__default.default.cyan(answer.targetEnvironment)}, on ${chalk__default.default.cyan(project.displayName)}. You are now able to deploy your project.`
1809
- );
1810
- await trackEvent(ctx, cloudApiService, "didLinkEnvironment", {
1811
- projectName: project.name,
1812
- environmentName: answer.targetEnvironment
1813
- });
1814
- };
1815
- async function promptUserForEnvironment(ctx, environments) {
1816
- const { logger } = ctx;
1817
- try {
1818
- const answer = await inquirer__default.default.prompt([
1819
- {
1820
- type: "list",
1821
- name: "targetEnvironment",
1822
- message: "Which environment do you want to link?",
1823
- choices: [...environments, { name: chalk__default.default.grey(`(${QUIT_OPTION})`), value: null }]
1824
- }
1825
- ]);
1826
- if (!answer.targetEnvironment) {
1827
- return null;
1828
- }
1829
- return answer;
1830
- } catch (e) {
1831
- logger.debug("Failed to get user input", e);
1832
- logger.error("An error occurred while trying to get your environment selection.");
1833
- return null;
1834
- }
1835
- }
1836
- async function getEnvironmentsList(ctx, cloudApiService, project) {
1837
- const spinner = ctx.logger.spinner("Fetching environments...\n").start();
1838
- try {
1839
- const {
1840
- data: { data: environmentsList }
1841
- } = await cloudApiService.listLinkEnvironments({ name: project.name });
1842
- if (!Array.isArray(environmentsList) || environmentsList.length === 0) {
1843
- throw new Error("Environments not found in server response");
1844
- }
1845
- spinner.succeed();
1846
- return environmentsList.filter(
1847
- (environment) => environment.name !== project.targetEnvironment
1848
- );
1849
- } catch (e) {
1850
- if (e.response && e.response.status === 404) {
1851
- spinner.succeed();
1852
- ctx.logger.warn(
1853
- `
1854
- The project associated with this folder does not exist in Strapi Cloud.
1855
- Please link your local project to an existing Strapi Cloud project using the ${chalk__default.default.cyan(
1856
- "link"
1857
- )} command.`
1858
- );
1859
- } else {
1860
- spinner.fail("An error occurred while fetching environments data from Strapi Cloud.");
1861
- ctx.logger.debug("Failed to list environments", e);
1862
- }
1863
- }
1864
- }
1865
- const command = ({ command: command2, ctx }) => {
1866
- const environmentCmd2 = initializeEnvironmentCommand(command2, ctx);
1867
- environmentCmd2.command("link").description("Link project to a specific Strapi Cloud project environment").option("-d, --debug", "Enable debugging mode with verbose logs").option("-s, --silent", "Don't log anything").action(() => runAction("link", action)(ctx));
1868
- };
1869
- const linkEnvironment = {
1870
- name: "link-environment",
1871
- description: "Link Strapi Cloud environment to a local project",
1872
- action,
1873
- command
1874
- };
1875
- const cli = {
1876
- deployProject,
1877
- link,
1878
- login,
1879
- logout,
1880
- createProject,
1881
- linkEnvironment,
1882
- listProjects,
1883
- listEnvironments
1884
- };
1885
- const cloudCommands = [
1886
- deployProject,
1887
- link,
1888
- login,
1889
- logout,
1890
- linkEnvironment,
1891
- listProjects,
1892
- listEnvironments
1893
- ];
1894
- async function initCloudCLIConfig() {
1895
- const localConfig = await getLocalConfig$1();
1896
- if (!localConfig.deviceId) {
1897
- localConfig.deviceId = crypto__default.default.randomUUID();
1898
- }
1899
- await saveLocalConfig(localConfig);
1900
- }
1901
- async function buildStrapiCloudCommands({
1902
- command: command2,
1903
- ctx,
1904
- argv
1905
- }) {
1906
- await initCloudCLIConfig();
1907
- for (const cloudCommand of cloudCommands) {
1908
- try {
1909
- const subCommand = await cloudCommand.command({ command: command2, ctx, argv });
1910
- if (subCommand) {
1911
- command2.addCommand(subCommand);
1912
- }
1913
- } catch (e) {
1914
- console.error(`Failed to load command ${cloudCommand.name}`, e);
1915
- }
1916
- }
1917
- }
1918
- exports.buildStrapiCloudCommands = buildStrapiCloudCommands;
1919
- exports.cli = cli;
1920
- exports.services = index;
1
+ 'use strict';
2
+
3
+ require('crypto');
4
+ var index = require('./chunks/index-Cq5rtMZ4.js');
5
+ require('fs-extra');
6
+ require('inquirer');
7
+ require('boxen');
8
+ require('path');
9
+ require('chalk');
10
+ require('axios');
11
+ require('node:crypto');
12
+ require('@strapi/utils');
13
+ require('tar');
14
+ require('minimatch');
15
+ require('lodash/fp');
16
+ require('os');
17
+ require('xdg-app-paths');
18
+ require('lodash');
19
+ require('jwks-rsa');
20
+ require('jsonwebtoken');
21
+ require('fast-safe-stringify');
22
+ require('ora');
23
+ require('cli-progress');
24
+ require('pkg-up');
25
+ require('yup');
26
+ require('eventsource');
27
+ require('commander');
28
+
29
+
30
+
31
+ exports.buildStrapiCloudCommands = index.buildStrapiCloudCommands;
32
+ exports.cli = index.cli;
33
+ exports.services = index.index;
1921
34
  //# sourceMappingURL=index.js.map