@strapi/cloud-cli 4.25.2 → 4.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +167 -101
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +166 -98
- package/dist/index.mjs.map +1 -1
- package/dist/src/create-project/action.d.ts.map +1 -1
- package/dist/src/create-project/utils/apply-default-name.d.ts +7 -0
- package/dist/src/create-project/utils/apply-default-name.d.ts.map +1 -0
- package/dist/src/create-project/utils/get-project-name-from-pkg.d.ts +3 -0
- package/dist/src/create-project/utils/get-project-name-from-pkg.d.ts.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/list-projects/action.d.ts +4 -0
- package/dist/src/list-projects/action.d.ts.map +1 -0
- package/dist/src/list-projects/command.d.ts +7 -0
- package/dist/src/list-projects/command.d.ts.map +1 -0
- package/dist/src/list-projects/index.d.ts +7 -0
- package/dist/src/list-projects/index.d.ts.map +1 -0
- package/dist/src/services/cli-api.d.ts +6 -1
- package/dist/src/services/cli-api.d.ts.map +1 -1
- package/dist/src/utils/compress-files.d.ts.map +1 -1
- package/dist/src/utils/pkg.d.ts.map +1 -1
- package/package.json +6 -5
- package/dist/src/utils/tests/compress-files.test.d.ts +0 -2
- package/dist/src/utils/tests/compress-files.test.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -29,7 +29,6 @@ const chalk = require("chalk");
|
|
|
29
29
|
const axios = require("axios");
|
|
30
30
|
const crypto = require("node:crypto");
|
|
31
31
|
const utils = require("@strapi/utils");
|
|
32
|
-
const fs = require("fs");
|
|
33
32
|
const tar = require("tar");
|
|
34
33
|
const minimatch = require("minimatch");
|
|
35
34
|
const inquirer = require("inquirer");
|
|
@@ -41,10 +40,10 @@ const jwt = require("jsonwebtoken");
|
|
|
41
40
|
const stringify = require("fast-safe-stringify");
|
|
42
41
|
const ora = require("ora");
|
|
43
42
|
const cliProgress = require("cli-progress");
|
|
44
|
-
const EventSource = require("eventsource");
|
|
45
|
-
const fs$1 = require("fs/promises");
|
|
46
43
|
const pkgUp = require("pkg-up");
|
|
47
44
|
const yup = require("yup");
|
|
45
|
+
const _ = require("lodash");
|
|
46
|
+
const EventSource = require("eventsource");
|
|
48
47
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
49
48
|
function _interopNamespace(e) {
|
|
50
49
|
if (e && e.__esModule)
|
|
@@ -65,12 +64,11 @@ function _interopNamespace(e) {
|
|
|
65
64
|
return Object.freeze(n);
|
|
66
65
|
}
|
|
67
66
|
const crypto__default = /* @__PURE__ */ _interopDefault(crypto$1);
|
|
68
|
-
const
|
|
67
|
+
const fse__namespace = /* @__PURE__ */ _interopNamespace(fse);
|
|
69
68
|
const path__namespace = /* @__PURE__ */ _interopNamespace(path);
|
|
70
69
|
const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
|
|
71
70
|
const axios__default = /* @__PURE__ */ _interopDefault(axios);
|
|
72
71
|
const crypto__namespace = /* @__PURE__ */ _interopNamespace(crypto);
|
|
73
|
-
const fs__namespace = /* @__PURE__ */ _interopNamespace(fs);
|
|
74
72
|
const tar__namespace = /* @__PURE__ */ _interopNamespace(tar);
|
|
75
73
|
const inquirer__default = /* @__PURE__ */ _interopDefault(inquirer);
|
|
76
74
|
const os__default = /* @__PURE__ */ _interopDefault(os);
|
|
@@ -80,10 +78,10 @@ const jwt__default = /* @__PURE__ */ _interopDefault(jwt);
|
|
|
80
78
|
const stringify__default = /* @__PURE__ */ _interopDefault(stringify);
|
|
81
79
|
const ora__default = /* @__PURE__ */ _interopDefault(ora);
|
|
82
80
|
const cliProgress__namespace = /* @__PURE__ */ _interopNamespace(cliProgress);
|
|
83
|
-
const EventSource__default = /* @__PURE__ */ _interopDefault(EventSource);
|
|
84
|
-
const fs__default = /* @__PURE__ */ _interopDefault(fs$1);
|
|
85
81
|
const pkgUp__default = /* @__PURE__ */ _interopDefault(pkgUp);
|
|
86
82
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
|
83
|
+
const ___default = /* @__PURE__ */ _interopDefault(_);
|
|
84
|
+
const EventSource__default = /* @__PURE__ */ _interopDefault(EventSource);
|
|
87
85
|
const apiConfig = {
|
|
88
86
|
apiBaseUrl: utils.env("STRAPI_CLI_CLOUD_API", "https://cloud-cli-api.strapi.io"),
|
|
89
87
|
dashboardBaseUrl: utils.env("STRAPI_CLI_CLOUD_DASHBOARD", "https://cloud.strapi.io")
|
|
@@ -102,23 +100,6 @@ const IGNORED_PATTERNS = [
|
|
|
102
100
|
"**/.idea/**",
|
|
103
101
|
"**/.vscode/**"
|
|
104
102
|
];
|
|
105
|
-
const getFiles = (dirPath, ignorePatterns = [], arrayOfFiles = [], subfolder = "") => {
|
|
106
|
-
const entries = fs__namespace.readdirSync(path__namespace.join(dirPath, subfolder));
|
|
107
|
-
entries.forEach((entry) => {
|
|
108
|
-
const entryPathFromRoot = path__namespace.join(subfolder, entry);
|
|
109
|
-
const entryPath = path__namespace.relative(dirPath, entryPathFromRoot);
|
|
110
|
-
const isIgnored = isIgnoredFile(dirPath, entryPathFromRoot, ignorePatterns);
|
|
111
|
-
if (isIgnored) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (fs__namespace.statSync(entryPath).isDirectory()) {
|
|
115
|
-
getFiles(dirPath, ignorePatterns, arrayOfFiles, entryPathFromRoot);
|
|
116
|
-
} else {
|
|
117
|
-
arrayOfFiles.push(entryPath);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
return arrayOfFiles;
|
|
121
|
-
};
|
|
122
103
|
const isIgnoredFile = (folderPath, file, ignorePatterns) => {
|
|
123
104
|
ignorePatterns.push(...IGNORED_PATTERNS);
|
|
124
105
|
const relativeFilePath = path__namespace.join(folderPath, file);
|
|
@@ -136,16 +117,35 @@ const isIgnoredFile = (folderPath, file, ignorePatterns) => {
|
|
|
136
117
|
}
|
|
137
118
|
return isIgnored;
|
|
138
119
|
};
|
|
139
|
-
const
|
|
120
|
+
const getFiles = async (dirPath, ignorePatterns = [], subfolder = "") => {
|
|
121
|
+
const arrayOfFiles = [];
|
|
122
|
+
const entries = await fse__namespace.readdir(path__namespace.join(dirPath, subfolder));
|
|
123
|
+
for (const entry of entries) {
|
|
124
|
+
const entryPathFromRoot = path__namespace.join(subfolder, entry);
|
|
125
|
+
const entryPath = path__namespace.relative(dirPath, entryPathFromRoot);
|
|
126
|
+
const isIgnored = isIgnoredFile(dirPath, entryPathFromRoot, ignorePatterns);
|
|
127
|
+
if (!isIgnored) {
|
|
128
|
+
if (fse__namespace.statSync(entryPath).isDirectory()) {
|
|
129
|
+
const subFiles = await getFiles(dirPath, ignorePatterns, entryPathFromRoot);
|
|
130
|
+
arrayOfFiles.push(...subFiles);
|
|
131
|
+
} else {
|
|
132
|
+
arrayOfFiles.push(entryPath);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return arrayOfFiles;
|
|
137
|
+
};
|
|
138
|
+
const readGitignore = async (folderPath) => {
|
|
140
139
|
const gitignorePath = path__namespace.resolve(folderPath, ".gitignore");
|
|
141
|
-
|
|
140
|
+
const pathExist = await fse__namespace.pathExists(gitignorePath);
|
|
141
|
+
if (!pathExist)
|
|
142
142
|
return [];
|
|
143
|
-
const gitignoreContent =
|
|
143
|
+
const gitignoreContent = await fse__namespace.readFile(gitignorePath, "utf8");
|
|
144
144
|
return gitignoreContent.split(/\r?\n/).filter((line) => Boolean(line.trim()) && !line.startsWith("#"));
|
|
145
145
|
};
|
|
146
146
|
const compressFilesToTar = async (storagePath, folderToCompress, filename) => {
|
|
147
|
-
const ignorePatterns = readGitignore(folderToCompress);
|
|
148
|
-
const filesToCompress = getFiles(folderToCompress, ignorePatterns);
|
|
147
|
+
const ignorePatterns = await readGitignore(folderToCompress);
|
|
148
|
+
const filesToCompress = await getFiles(folderToCompress, ignorePatterns);
|
|
149
149
|
return tar__namespace.c(
|
|
150
150
|
{
|
|
151
151
|
gzip: true,
|
|
@@ -158,7 +158,7 @@ const APP_FOLDER_NAME = "com.strapi.cli";
|
|
|
158
158
|
const CONFIG_FILENAME = "config.json";
|
|
159
159
|
async function checkDirectoryExists(directoryPath) {
|
|
160
160
|
try {
|
|
161
|
-
const fsStat = await
|
|
161
|
+
const fsStat = await fse__namespace.default.lstat(directoryPath);
|
|
162
162
|
return fsStat.isDirectory();
|
|
163
163
|
} catch (e) {
|
|
164
164
|
return false;
|
|
@@ -166,14 +166,14 @@ async function checkDirectoryExists(directoryPath) {
|
|
|
166
166
|
}
|
|
167
167
|
async function getTmpStoragePath() {
|
|
168
168
|
const storagePath = path__namespace.default.join(os__default.default.tmpdir(), APP_FOLDER_NAME);
|
|
169
|
-
await
|
|
169
|
+
await fse__namespace.default.ensureDir(storagePath);
|
|
170
170
|
return storagePath;
|
|
171
171
|
}
|
|
172
172
|
async function getConfigPath() {
|
|
173
173
|
const configDirs = XDGAppPaths__default.default(APP_FOLDER_NAME).configDirs();
|
|
174
174
|
const configPath = configDirs.find(checkDirectoryExists);
|
|
175
175
|
if (!configPath) {
|
|
176
|
-
await
|
|
176
|
+
await fse__namespace.default.ensureDir(configDirs[0]);
|
|
177
177
|
return configDirs[0];
|
|
178
178
|
}
|
|
179
179
|
return configPath;
|
|
@@ -181,9 +181,9 @@ async function getConfigPath() {
|
|
|
181
181
|
async function getLocalConfig() {
|
|
182
182
|
const configPath = await getConfigPath();
|
|
183
183
|
const configFilePath = path__namespace.default.join(configPath, CONFIG_FILENAME);
|
|
184
|
-
await
|
|
184
|
+
await fse__namespace.default.ensureFile(configFilePath);
|
|
185
185
|
try {
|
|
186
|
-
return await
|
|
186
|
+
return await fse__namespace.default.readJSON(configFilePath, { encoding: "utf8", throws: true });
|
|
187
187
|
} catch (e) {
|
|
188
188
|
return {};
|
|
189
189
|
}
|
|
@@ -191,10 +191,10 @@ async function getLocalConfig() {
|
|
|
191
191
|
async function saveLocalConfig(data) {
|
|
192
192
|
const configPath = await getConfigPath();
|
|
193
193
|
const configFilePath = path__namespace.default.join(configPath, CONFIG_FILENAME);
|
|
194
|
-
await
|
|
194
|
+
await fse__namespace.default.writeJson(configFilePath, data, { encoding: "utf8", spaces: 2, mode: 384 });
|
|
195
195
|
}
|
|
196
196
|
const name = "@strapi/cloud-cli";
|
|
197
|
-
const version = "4.25.
|
|
197
|
+
const version = "4.25.3";
|
|
198
198
|
const description = "Commands to interact with the Strapi Cloud";
|
|
199
199
|
const keywords = [
|
|
200
200
|
"strapi",
|
|
@@ -235,10 +235,11 @@ const scripts = {
|
|
|
235
235
|
build: "pack-up build",
|
|
236
236
|
clean: "run -T rimraf ./dist",
|
|
237
237
|
lint: "run -T eslint .",
|
|
238
|
+
"test:unit": "run -T jest",
|
|
238
239
|
watch: "pack-up watch"
|
|
239
240
|
};
|
|
240
241
|
const dependencies = {
|
|
241
|
-
"@strapi/utils": "4.25.
|
|
242
|
+
"@strapi/utils": "4.25.3",
|
|
242
243
|
axios: "1.6.0",
|
|
243
244
|
chalk: "4.1.2",
|
|
244
245
|
"cli-progress": "3.12.0",
|
|
@@ -263,8 +264,8 @@ const devDependencies = {
|
|
|
263
264
|
"@types/cli-progress": "3.11.5",
|
|
264
265
|
"@types/eventsource": "1.1.15",
|
|
265
266
|
"@types/lodash": "^4.14.191",
|
|
266
|
-
"eslint-config-custom": "4.25.
|
|
267
|
-
tsconfig: "4.25.
|
|
267
|
+
"eslint-config-custom": "4.25.3",
|
|
268
|
+
tsconfig: "4.25.3"
|
|
268
269
|
};
|
|
269
270
|
const engines = {
|
|
270
271
|
node: ">=18.0.0 <=20.x.x",
|
|
@@ -317,7 +318,7 @@ async function cloudApiFactory({ logger }, token) {
|
|
|
317
318
|
deploy({ filePath, project }, { onUploadProgress }) {
|
|
318
319
|
return axiosCloudAPI.post(
|
|
319
320
|
`/deploy/${project.name}`,
|
|
320
|
-
{ file:
|
|
321
|
+
{ file: fse__namespace.default.createReadStream(filePath) },
|
|
321
322
|
{
|
|
322
323
|
headers: {
|
|
323
324
|
"Content-Type": "multipart/form-data"
|
|
@@ -360,8 +361,19 @@ async function cloudApiFactory({ logger }, token) {
|
|
|
360
361
|
throw error;
|
|
361
362
|
}
|
|
362
363
|
},
|
|
363
|
-
listProjects() {
|
|
364
|
-
|
|
364
|
+
async listProjects() {
|
|
365
|
+
try {
|
|
366
|
+
const response = await axiosCloudAPI.get("/projects");
|
|
367
|
+
if (response.status !== 200) {
|
|
368
|
+
throw new Error("Error fetching cloud projects from the server.");
|
|
369
|
+
}
|
|
370
|
+
return response;
|
|
371
|
+
} catch (error) {
|
|
372
|
+
logger.debug(
|
|
373
|
+
"🥲 Oops! Couldn't retrieve your project's list from the server. Please try again."
|
|
374
|
+
);
|
|
375
|
+
throw error;
|
|
376
|
+
}
|
|
365
377
|
},
|
|
366
378
|
track(event, payload = {}) {
|
|
367
379
|
return axiosCloudAPI.post("/track", {
|
|
@@ -376,18 +388,18 @@ async function save(data, { directoryPath } = {}) {
|
|
|
376
388
|
const alreadyInFileData = await retrieve({ directoryPath });
|
|
377
389
|
const storedData = { ...alreadyInFileData, ...data };
|
|
378
390
|
const pathToFile = path__namespace.default.join(directoryPath || process.cwd(), LOCAL_SAVE_FILENAME);
|
|
379
|
-
await
|
|
380
|
-
await
|
|
391
|
+
await fse__namespace.default.ensureDir(path__namespace.default.dirname(pathToFile));
|
|
392
|
+
await fse__namespace.default.writeJson(pathToFile, storedData, { encoding: "utf8" });
|
|
381
393
|
}
|
|
382
394
|
async function retrieve({
|
|
383
395
|
directoryPath
|
|
384
396
|
} = {}) {
|
|
385
397
|
const pathToFile = path__namespace.default.join(directoryPath || process.cwd(), LOCAL_SAVE_FILENAME);
|
|
386
|
-
const pathExists = await
|
|
398
|
+
const pathExists = await fse__namespace.default.pathExists(pathToFile);
|
|
387
399
|
if (!pathExists) {
|
|
388
400
|
return {};
|
|
389
401
|
}
|
|
390
|
-
return
|
|
402
|
+
return fse__namespace.default.readJSON(pathToFile, { encoding: "utf8" });
|
|
391
403
|
}
|
|
392
404
|
const strapiInfoSave = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
393
405
|
__proto__: null,
|
|
@@ -632,6 +644,58 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
632
644
|
local: strapiInfoSave,
|
|
633
645
|
tokenServiceFactory
|
|
634
646
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
647
|
+
yup__namespace.object({
|
|
648
|
+
name: yup__namespace.string().required(),
|
|
649
|
+
exports: yup__namespace.lazy(
|
|
650
|
+
(value) => yup__namespace.object(
|
|
651
|
+
typeof value === "object" ? Object.entries(value).reduce((acc, [key, value2]) => {
|
|
652
|
+
if (typeof value2 === "object") {
|
|
653
|
+
acc[key] = yup__namespace.object({
|
|
654
|
+
types: yup__namespace.string().optional(),
|
|
655
|
+
source: yup__namespace.string().required(),
|
|
656
|
+
module: yup__namespace.string().optional(),
|
|
657
|
+
import: yup__namespace.string().required(),
|
|
658
|
+
require: yup__namespace.string().required(),
|
|
659
|
+
default: yup__namespace.string().required()
|
|
660
|
+
}).noUnknown(true);
|
|
661
|
+
} else {
|
|
662
|
+
acc[key] = yup__namespace.string().matches(/^\.\/.*\.json$/).required();
|
|
663
|
+
}
|
|
664
|
+
return acc;
|
|
665
|
+
}, {}) : void 0
|
|
666
|
+
).optional()
|
|
667
|
+
)
|
|
668
|
+
});
|
|
669
|
+
const loadPkg = async ({ cwd, logger }) => {
|
|
670
|
+
const pkgPath = await pkgUp__default.default({ cwd });
|
|
671
|
+
if (!pkgPath) {
|
|
672
|
+
throw new Error("Could not find a package.json in the current directory");
|
|
673
|
+
}
|
|
674
|
+
const buffer = await fse__namespace.readFile(pkgPath);
|
|
675
|
+
const pkg = JSON.parse(buffer.toString());
|
|
676
|
+
logger.debug("Loaded package.json:", os__default.default.EOL, pkg);
|
|
677
|
+
return pkg;
|
|
678
|
+
};
|
|
679
|
+
async function getProjectNameFromPackageJson(ctx) {
|
|
680
|
+
try {
|
|
681
|
+
const packageJson2 = await loadPkg(ctx);
|
|
682
|
+
return packageJson2.name || "my-strapi-project";
|
|
683
|
+
} catch (e) {
|
|
684
|
+
return "my-strapi-project";
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
function applyDefaultName(newDefaultName, questions, defaultValues) {
|
|
688
|
+
const newDefaultValues = ___default.default.cloneDeep(defaultValues);
|
|
689
|
+
newDefaultValues.name = newDefaultName;
|
|
690
|
+
const newQuestions = questions.map((question) => {
|
|
691
|
+
const questionCopy = ___default.default.cloneDeep(question);
|
|
692
|
+
if (questionCopy.name === "name") {
|
|
693
|
+
questionCopy.default = newDefaultName;
|
|
694
|
+
}
|
|
695
|
+
return questionCopy;
|
|
696
|
+
});
|
|
697
|
+
return { newQuestions, newDefaultValues };
|
|
698
|
+
}
|
|
635
699
|
const openModule$1 = import("open");
|
|
636
700
|
async function promptLogin(ctx) {
|
|
637
701
|
const response = await inquirer__default.default.prompt([
|
|
@@ -847,7 +911,7 @@ async function createProject$1(ctx, cloudApi, projectInput) {
|
|
|
847
911
|
throw e;
|
|
848
912
|
}
|
|
849
913
|
}
|
|
850
|
-
const action$
|
|
914
|
+
const action$3 = async (ctx) => {
|
|
851
915
|
const { logger } = ctx;
|
|
852
916
|
const { getValidToken, eraseToken } = await tokenServiceFactory(ctx);
|
|
853
917
|
const token = await getValidToken(ctx, promptLogin);
|
|
@@ -856,7 +920,11 @@ const action$2 = async (ctx) => {
|
|
|
856
920
|
}
|
|
857
921
|
const cloudApi = await cloudApiFactory(ctx, token);
|
|
858
922
|
const { data: config } = await cloudApi.config();
|
|
859
|
-
const { questions,
|
|
923
|
+
const { newQuestions: questions, newDefaultValues: defaultValues } = applyDefaultName(
|
|
924
|
+
await getProjectNameFromPackageJson(ctx),
|
|
925
|
+
config.projectCreation.questions,
|
|
926
|
+
config.projectCreation.defaults
|
|
927
|
+
);
|
|
860
928
|
const projectAnswersDefaulted = fp.defaults(defaultValues);
|
|
861
929
|
const projectAnswers = await inquirer__default.default.prompt(questions);
|
|
862
930
|
const projectInput = projectAnswersDefaulted(projectAnswers);
|
|
@@ -905,38 +973,6 @@ function notificationServiceFactory({ logger }) {
|
|
|
905
973
|
};
|
|
906
974
|
};
|
|
907
975
|
}
|
|
908
|
-
yup__namespace.object({
|
|
909
|
-
name: yup__namespace.string().required(),
|
|
910
|
-
exports: yup__namespace.lazy(
|
|
911
|
-
(value) => yup__namespace.object(
|
|
912
|
-
typeof value === "object" ? Object.entries(value).reduce((acc, [key, value2]) => {
|
|
913
|
-
if (typeof value2 === "object") {
|
|
914
|
-
acc[key] = yup__namespace.object({
|
|
915
|
-
types: yup__namespace.string().optional(),
|
|
916
|
-
source: yup__namespace.string().required(),
|
|
917
|
-
module: yup__namespace.string().optional(),
|
|
918
|
-
import: yup__namespace.string().required(),
|
|
919
|
-
require: yup__namespace.string().required(),
|
|
920
|
-
default: yup__namespace.string().required()
|
|
921
|
-
}).noUnknown(true);
|
|
922
|
-
} else {
|
|
923
|
-
acc[key] = yup__namespace.string().matches(/^\.\/.*\.json$/).required();
|
|
924
|
-
}
|
|
925
|
-
return acc;
|
|
926
|
-
}, {}) : void 0
|
|
927
|
-
).optional()
|
|
928
|
-
)
|
|
929
|
-
});
|
|
930
|
-
const loadPkg = async ({ cwd, logger }) => {
|
|
931
|
-
const pkgPath = await pkgUp__default.default({ cwd });
|
|
932
|
-
if (!pkgPath) {
|
|
933
|
-
throw new Error("Could not find a package.json in the current directory");
|
|
934
|
-
}
|
|
935
|
-
const buffer = await fs__default.default.readFile(pkgPath);
|
|
936
|
-
const pkg = JSON.parse(buffer.toString());
|
|
937
|
-
logger.debug("Loaded package.json:", os__default.default.EOL, pkg);
|
|
938
|
-
return pkg;
|
|
939
|
-
};
|
|
940
976
|
const buildLogsServiceFactory = ({ logger }) => {
|
|
941
977
|
return async (url, token, cliConfig2) => {
|
|
942
978
|
const CONN_TIMEOUT = Number(cliConfig2.buildLogsConnectionTimeout);
|
|
@@ -1032,13 +1068,13 @@ async function upload(ctx, project, token, maxProjectFileSize) {
|
|
|
1032
1068
|
process.exit(1);
|
|
1033
1069
|
}
|
|
1034
1070
|
const tarFilePath = path__namespace.default.resolve(storagePath, compressedFilename);
|
|
1035
|
-
const fileStats = await
|
|
1071
|
+
const fileStats = await fse__namespace.default.stat(tarFilePath);
|
|
1036
1072
|
if (fileStats.size > maxProjectFileSize) {
|
|
1037
1073
|
ctx.logger.log(
|
|
1038
1074
|
"Unable to proceed: Your project is too big to be transferred, please use a git repo instead."
|
|
1039
1075
|
);
|
|
1040
1076
|
try {
|
|
1041
|
-
await
|
|
1077
|
+
await fse__namespace.default.remove(tarFilePath);
|
|
1042
1078
|
} catch (e) {
|
|
1043
1079
|
ctx.logger.log("Unable to remove file: ", tarFilePath);
|
|
1044
1080
|
ctx.logger.debug(e);
|
|
@@ -1077,7 +1113,7 @@ async function upload(ctx, project, token, maxProjectFileSize) {
|
|
|
1077
1113
|
}
|
|
1078
1114
|
ctx.logger.debug(e);
|
|
1079
1115
|
} finally {
|
|
1080
|
-
await
|
|
1116
|
+
await fse__namespace.default.remove(tarFilePath);
|
|
1081
1117
|
}
|
|
1082
1118
|
process.exit(0);
|
|
1083
1119
|
} catch (e) {
|
|
@@ -1090,7 +1126,7 @@ async function getProject(ctx) {
|
|
|
1090
1126
|
const { project } = await retrieve();
|
|
1091
1127
|
if (!project) {
|
|
1092
1128
|
try {
|
|
1093
|
-
return await action$
|
|
1129
|
+
return await action$3(ctx);
|
|
1094
1130
|
} catch (e) {
|
|
1095
1131
|
ctx.logger.error("An error occurred while deploying the project. Please try again later.");
|
|
1096
1132
|
ctx.logger.debug(e);
|
|
@@ -1099,7 +1135,7 @@ async function getProject(ctx) {
|
|
|
1099
1135
|
}
|
|
1100
1136
|
return project;
|
|
1101
1137
|
}
|
|
1102
|
-
const action$
|
|
1138
|
+
const action$2 = async (ctx) => {
|
|
1103
1139
|
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1104
1140
|
const token = await getValidToken(ctx, promptLogin);
|
|
1105
1141
|
if (!token) {
|
|
@@ -1173,16 +1209,16 @@ const runAction = (name2, action2) => (...args) => {
|
|
|
1173
1209
|
process.exit(1);
|
|
1174
1210
|
});
|
|
1175
1211
|
};
|
|
1176
|
-
const command$
|
|
1177
|
-
command2.command("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").action(() => runAction("deploy", action$
|
|
1212
|
+
const command$4 = ({ command: command2, ctx }) => {
|
|
1213
|
+
command2.command("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").action(() => runAction("deploy", action$2)(ctx));
|
|
1178
1214
|
};
|
|
1179
1215
|
const deployProject = {
|
|
1180
1216
|
name: "deploy-project",
|
|
1181
1217
|
description: "Deploy a Strapi Cloud project",
|
|
1182
|
-
action: action$
|
|
1183
|
-
command: command$
|
|
1218
|
+
action: action$2,
|
|
1219
|
+
command: command$4
|
|
1184
1220
|
};
|
|
1185
|
-
const command$
|
|
1221
|
+
const command$3 = ({ command: command2, ctx }) => {
|
|
1186
1222
|
command2.command("cloud:login").alias("login").description("Strapi Cloud Login").addHelpText(
|
|
1187
1223
|
"after",
|
|
1188
1224
|
"\nAfter running this command, you will be prompted to enter your authentication information."
|
|
@@ -1192,10 +1228,10 @@ const login = {
|
|
|
1192
1228
|
name: "login",
|
|
1193
1229
|
description: "Strapi Cloud Login",
|
|
1194
1230
|
action: loginAction,
|
|
1195
|
-
command: command$
|
|
1231
|
+
command: command$3
|
|
1196
1232
|
};
|
|
1197
1233
|
const openModule = import("open");
|
|
1198
|
-
const action = async (ctx) => {
|
|
1234
|
+
const action$1 = async (ctx) => {
|
|
1199
1235
|
const { logger } = ctx;
|
|
1200
1236
|
const { retrieveToken, eraseToken } = await tokenServiceFactory(ctx);
|
|
1201
1237
|
const token = await retrieveToken();
|
|
@@ -1231,31 +1267,61 @@ const action = async (ctx) => {
|
|
|
1231
1267
|
logger.debug("Failed to track logout event", e);
|
|
1232
1268
|
}
|
|
1233
1269
|
};
|
|
1234
|
-
const command$
|
|
1235
|
-
command2.command("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)(ctx));
|
|
1270
|
+
const command$2 = ({ command: command2, ctx }) => {
|
|
1271
|
+
command2.command("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$1)(ctx));
|
|
1236
1272
|
};
|
|
1237
1273
|
const logout = {
|
|
1238
1274
|
name: "logout",
|
|
1239
1275
|
description: "Strapi Cloud Logout",
|
|
1240
|
-
action,
|
|
1241
|
-
command: command$
|
|
1276
|
+
action: action$1,
|
|
1277
|
+
command: command$2
|
|
1242
1278
|
};
|
|
1243
|
-
const command = ({ command: command2, ctx }) => {
|
|
1244
|
-
command2.command("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$
|
|
1279
|
+
const command$1 = ({ command: command2, ctx }) => {
|
|
1280
|
+
command2.command("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$3)(ctx));
|
|
1245
1281
|
};
|
|
1246
1282
|
const createProject = {
|
|
1247
1283
|
name: "create-project",
|
|
1248
1284
|
description: "Create a new project",
|
|
1249
|
-
action: action$
|
|
1285
|
+
action: action$3,
|
|
1286
|
+
command: command$1
|
|
1287
|
+
};
|
|
1288
|
+
const action = async (ctx) => {
|
|
1289
|
+
const { getValidToken } = await tokenServiceFactory(ctx);
|
|
1290
|
+
const token = await getValidToken(ctx, promptLogin);
|
|
1291
|
+
const { logger } = ctx;
|
|
1292
|
+
if (!token) {
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
const cloudApiService = await cloudApiFactory(ctx, token);
|
|
1296
|
+
const spinner = logger.spinner("Fetching your projects...").start();
|
|
1297
|
+
try {
|
|
1298
|
+
const {
|
|
1299
|
+
data: { data: projectList }
|
|
1300
|
+
} = await cloudApiService.listProjects();
|
|
1301
|
+
spinner.succeed();
|
|
1302
|
+
logger.log(projectList);
|
|
1303
|
+
} catch (e) {
|
|
1304
|
+
ctx.logger.debug("Failed to list projects", e);
|
|
1305
|
+
spinner.fail("An error occurred while fetching your projects from Strapi Cloud.");
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
const command = ({ command: command2, ctx }) => {
|
|
1309
|
+
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("listProjects", action)(ctx));
|
|
1310
|
+
};
|
|
1311
|
+
const listProjects = {
|
|
1312
|
+
name: "list-projects",
|
|
1313
|
+
description: "List Strapi Cloud projects",
|
|
1314
|
+
action,
|
|
1250
1315
|
command
|
|
1251
1316
|
};
|
|
1252
1317
|
const cli = {
|
|
1253
1318
|
deployProject,
|
|
1254
1319
|
login,
|
|
1255
1320
|
logout,
|
|
1256
|
-
createProject
|
|
1321
|
+
createProject,
|
|
1322
|
+
listProjects
|
|
1257
1323
|
};
|
|
1258
|
-
const cloudCommands = [deployProject, login, logout];
|
|
1324
|
+
const cloudCommands = [deployProject, login, logout, listProjects];
|
|
1259
1325
|
async function initCloudCLIConfig() {
|
|
1260
1326
|
const localConfig = await getLocalConfig();
|
|
1261
1327
|
if (!localConfig.deviceId) {
|