@strapi/cloud-cli 5.12.0 → 5.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/dist/bin.d.ts.map +1 -0
  2. package/dist/bin.js +5 -18
  3. package/dist/bin.js.map +1 -1
  4. package/dist/bin.mjs +3 -16
  5. package/dist/bin.mjs.map +1 -1
  6. package/dist/cloud/command.d.ts.map +1 -0
  7. package/dist/cloud/command.js +14 -0
  8. package/dist/cloud/command.js.map +1 -0
  9. package/dist/cloud/command.mjs +12 -0
  10. package/dist/cloud/command.mjs.map +1 -0
  11. package/dist/config/api.d.ts.map +1 -0
  12. package/dist/config/api.js +11 -0
  13. package/dist/config/api.js.map +1 -0
  14. package/dist/config/api.mjs +9 -0
  15. package/dist/config/api.mjs.map +1 -0
  16. package/dist/config/local.d.ts.map +1 -0
  17. package/dist/config/local.js +60 -0
  18. package/dist/config/local.js.map +1 -0
  19. package/dist/config/local.mjs +55 -0
  20. package/dist/config/local.mjs.map +1 -0
  21. package/dist/create-project/action.d.ts.map +1 -0
  22. package/dist/create-project/action.js +95 -0
  23. package/dist/create-project/action.js.map +1 -0
  24. package/dist/create-project/action.mjs +93 -0
  25. package/dist/create-project/action.mjs.map +1 -0
  26. package/dist/create-project/command.d.ts.map +1 -0
  27. package/dist/create-project/command.js +14 -0
  28. package/dist/create-project/command.js.map +1 -0
  29. package/dist/create-project/command.mjs +12 -0
  30. package/dist/create-project/command.mjs.map +1 -0
  31. package/dist/create-project/index.d.ts.map +1 -0
  32. package/dist/create-project/index.js +18 -0
  33. package/dist/create-project/index.js.map +1 -0
  34. package/dist/create-project/index.mjs +12 -0
  35. package/dist/create-project/index.mjs.map +1 -0
  36. package/dist/create-project/utils/get-project-name-from-pkg.d.ts.map +1 -0
  37. package/dist/create-project/utils/get-project-name-from-pkg.js +15 -0
  38. package/dist/create-project/utils/get-project-name-from-pkg.js.map +1 -0
  39. package/dist/create-project/utils/get-project-name-from-pkg.mjs +13 -0
  40. package/dist/create-project/utils/get-project-name-from-pkg.mjs.map +1 -0
  41. package/dist/create-project/utils/project-questions.utils.d.ts.map +1 -0
  42. package/dist/create-project/utils/project-questions.utils.js +63 -0
  43. package/dist/create-project/utils/project-questions.utils.js.map +1 -0
  44. package/dist/create-project/utils/project-questions.utils.mjs +59 -0
  45. package/dist/create-project/utils/project-questions.utils.mjs.map +1 -0
  46. package/dist/deploy-project/action.d.ts.map +1 -0
  47. package/dist/deploy-project/action.js +287 -0
  48. package/dist/deploy-project/action.js.map +1 -0
  49. package/dist/deploy-project/action.mjs +266 -0
  50. package/dist/deploy-project/action.mjs.map +1 -0
  51. package/dist/deploy-project/command.d.ts.map +1 -0
  52. package/dist/deploy-project/command.js +14 -0
  53. package/dist/deploy-project/command.js.map +1 -0
  54. package/dist/deploy-project/command.mjs +12 -0
  55. package/dist/deploy-project/command.mjs.map +1 -0
  56. package/dist/deploy-project/index.d.ts.map +1 -0
  57. package/dist/deploy-project/index.js +18 -0
  58. package/dist/deploy-project/index.js.map +1 -0
  59. package/dist/deploy-project/index.mjs +12 -0
  60. package/dist/deploy-project/index.mjs.map +1 -0
  61. package/dist/environment/command.d.ts.map +1 -0
  62. package/dist/environment/command.js +15 -0
  63. package/dist/environment/command.js.map +1 -0
  64. package/dist/environment/command.mjs +13 -0
  65. package/dist/environment/command.mjs.map +1 -0
  66. package/dist/environment/link/action.d.ts.map +1 -0
  67. package/dist/environment/link/action.js +117 -0
  68. package/dist/environment/link/action.js.map +1 -0
  69. package/dist/environment/link/action.mjs +115 -0
  70. package/dist/environment/link/action.mjs.map +1 -0
  71. package/dist/environment/link/command.d.ts.map +1 -0
  72. package/dist/environment/link/command.js +13 -0
  73. package/dist/environment/link/command.js.map +1 -0
  74. package/dist/environment/link/command.mjs +11 -0
  75. package/dist/environment/link/command.mjs.map +1 -0
  76. package/dist/environment/link/index.d.ts.map +1 -0
  77. package/dist/environment/link/index.js +18 -0
  78. package/dist/environment/link/index.js.map +1 -0
  79. package/dist/environment/link/index.mjs +12 -0
  80. package/dist/environment/link/index.mjs.map +1 -0
  81. package/dist/environment/list/action.d.ts.map +1 -0
  82. package/dist/environment/list/action.js +57 -0
  83. package/dist/environment/list/action.js.map +1 -0
  84. package/dist/environment/list/action.mjs +55 -0
  85. package/dist/environment/list/action.mjs.map +1 -0
  86. package/dist/environment/list/command.d.ts.map +1 -0
  87. package/dist/environment/list/command.js +13 -0
  88. package/dist/environment/list/command.js.map +1 -0
  89. package/dist/environment/list/command.mjs +11 -0
  90. package/dist/environment/list/command.mjs.map +1 -0
  91. package/dist/environment/list/index.d.ts.map +1 -0
  92. package/dist/environment/list/index.js +18 -0
  93. package/dist/environment/list/index.js.map +1 -0
  94. package/dist/environment/list/index.mjs +12 -0
  95. package/dist/environment/list/index.mjs.map +1 -0
  96. package/dist/index.d.ts.map +1 -0
  97. package/dist/index.js +59 -29
  98. package/dist/index.js.map +1 -1
  99. package/dist/index.mjs +60 -25
  100. package/dist/index.mjs.map +1 -1
  101. package/dist/link/action.d.ts.map +1 -0
  102. package/dist/link/action.js +146 -0
  103. package/dist/link/action.js.map +1 -0
  104. package/dist/link/action.mjs +144 -0
  105. package/dist/link/action.mjs.map +1 -0
  106. package/dist/link/command.d.ts.map +1 -0
  107. package/dist/link/command.js +13 -0
  108. package/dist/link/command.js.map +1 -0
  109. package/dist/link/command.mjs +11 -0
  110. package/dist/link/command.mjs.map +1 -0
  111. package/dist/link/index.d.ts.map +1 -0
  112. package/dist/link/index.js +18 -0
  113. package/dist/link/index.js.map +1 -0
  114. package/dist/link/index.mjs +12 -0
  115. package/dist/link/index.mjs.map +1 -0
  116. package/dist/list-projects/action.d.ts.map +1 -0
  117. package/dist/list-projects/action.js +34 -0
  118. package/dist/list-projects/action.js.map +1 -0
  119. package/dist/list-projects/action.mjs +32 -0
  120. package/dist/list-projects/action.mjs.map +1 -0
  121. package/dist/list-projects/command.d.ts.map +1 -0
  122. package/dist/list-projects/command.js +13 -0
  123. package/dist/list-projects/command.js.map +1 -0
  124. package/dist/list-projects/command.mjs +11 -0
  125. package/dist/list-projects/command.mjs.map +1 -0
  126. package/dist/list-projects/index.d.ts.map +1 -0
  127. package/dist/list-projects/index.js +18 -0
  128. package/dist/list-projects/index.js.map +1 -0
  129. package/dist/list-projects/index.mjs +12 -0
  130. package/dist/list-projects/index.mjs.map +1 -0
  131. package/dist/login/action.d.ts.map +1 -0
  132. package/dist/login/action.js +177 -0
  133. package/dist/login/action.js.map +1 -0
  134. package/dist/login/action.mjs +172 -0
  135. package/dist/login/action.mjs.map +1 -0
  136. package/dist/login/command.d.ts.map +1 -0
  137. package/dist/login/command.js +14 -0
  138. package/dist/login/command.js.map +1 -0
  139. package/dist/login/command.mjs +12 -0
  140. package/dist/login/command.mjs.map +1 -0
  141. package/dist/login/index.d.ts.map +1 -0
  142. package/dist/login/index.js +18 -0
  143. package/dist/login/index.js.map +1 -0
  144. package/dist/login/index.mjs +12 -0
  145. package/dist/login/index.mjs.map +1 -0
  146. package/dist/logout/action.d.ts.map +1 -0
  147. package/dist/logout/action.js +46 -0
  148. package/dist/logout/action.js.map +1 -0
  149. package/dist/logout/action.mjs +44 -0
  150. package/dist/logout/action.mjs.map +1 -0
  151. package/dist/logout/command.d.ts.map +1 -0
  152. package/dist/logout/command.js +14 -0
  153. package/dist/logout/command.js.map +1 -0
  154. package/dist/logout/command.mjs +12 -0
  155. package/dist/logout/command.mjs.map +1 -0
  156. package/dist/logout/index.d.ts.map +1 -0
  157. package/dist/logout/index.js +18 -0
  158. package/dist/logout/index.js.map +1 -0
  159. package/dist/logout/index.mjs +12 -0
  160. package/dist/logout/index.mjs.map +1 -0
  161. package/dist/package.json.js +129 -0
  162. package/dist/package.json.js.map +1 -0
  163. package/dist/package.json.mjs +105 -0
  164. package/dist/package.json.mjs.map +1 -0
  165. package/dist/services/build-logs.d.ts.map +1 -0
  166. package/dist/services/build-logs.js +67 -0
  167. package/dist/services/build-logs.js.map +1 -0
  168. package/dist/services/build-logs.mjs +65 -0
  169. package/dist/services/build-logs.mjs.map +1 -0
  170. package/dist/services/cli-api.d.ts.map +1 -0
  171. package/dist/services/cli-api.js +146 -0
  172. package/dist/services/cli-api.js.map +1 -0
  173. package/dist/services/cli-api.mjs +143 -0
  174. package/dist/services/cli-api.mjs.map +1 -0
  175. package/dist/services/index.d.ts.map +1 -0
  176. package/dist/services/index.js +14 -0
  177. package/dist/services/index.js.map +1 -0
  178. package/dist/services/index.mjs +6 -0
  179. package/dist/services/index.mjs.map +1 -0
  180. package/dist/services/logger.d.ts.map +1 -0
  181. package/dist/services/logger.js +128 -0
  182. package/dist/services/logger.js.map +1 -0
  183. package/dist/services/logger.mjs +107 -0
  184. package/dist/services/logger.mjs.map +1 -0
  185. package/dist/services/notification.d.ts.map +1 -0
  186. package/dist/services/notification.js +37 -0
  187. package/dist/services/notification.js.map +1 -0
  188. package/dist/services/notification.mjs +35 -0
  189. package/dist/services/notification.mjs.map +1 -0
  190. package/dist/services/strapi-info-save.d.ts.map +1 -0
  191. package/dist/services/strapi-info-save.js +53 -0
  192. package/dist/services/strapi-info-save.js.map +1 -0
  193. package/dist/services/strapi-info-save.mjs +47 -0
  194. package/dist/services/strapi-info-save.mjs.map +1 -0
  195. package/dist/services/token.d.ts.map +1 -0
  196. package/dist/services/token.js +126 -0
  197. package/dist/services/token.js.map +1 -0
  198. package/dist/services/token.mjs +124 -0
  199. package/dist/services/token.mjs.map +1 -0
  200. package/dist/types.d.ts.map +1 -0
  201. package/dist/utils/analytics.d.ts.map +1 -0
  202. package/dist/utils/analytics.js +12 -0
  203. package/dist/utils/analytics.js.map +1 -0
  204. package/dist/utils/analytics.mjs +10 -0
  205. package/dist/utils/analytics.mjs.map +1 -0
  206. package/dist/utils/compress-files.d.ts.map +1 -0
  207. package/dist/utils/compress-files.js +102 -0
  208. package/dist/utils/compress-files.js.map +1 -0
  209. package/dist/utils/compress-files.mjs +78 -0
  210. package/dist/utils/compress-files.mjs.map +1 -0
  211. package/dist/utils/get-local-config.d.ts.map +1 -0
  212. package/dist/utils/get-local-config.js +37 -0
  213. package/dist/utils/get-local-config.js.map +1 -0
  214. package/dist/utils/get-local-config.mjs +34 -0
  215. package/dist/utils/get-local-config.mjs.map +1 -0
  216. package/dist/utils/helpers.d.ts.map +1 -0
  217. package/dist/utils/helpers.js +33 -0
  218. package/dist/utils/helpers.js.map +1 -0
  219. package/dist/utils/helpers.mjs +31 -0
  220. package/dist/utils/helpers.mjs.map +1 -0
  221. package/dist/utils/pkg.d.ts.map +1 -0
  222. package/dist/utils/pkg.js +65 -0
  223. package/dist/utils/pkg.js.map +1 -0
  224. package/dist/utils/pkg.mjs +43 -0
  225. package/dist/utils/pkg.mjs.map +1 -0
  226. package/dist/utils/tests/compress-files.test.d.ts.map +1 -0
  227. package/package.json +5 -5
  228. package/dist/chunks/index-BZ0dpHa6.js +0 -1896
  229. package/dist/chunks/index-BZ0dpHa6.js.map +0 -1
  230. package/dist/chunks/index-DGQHGTQ5.mjs +0 -1869
  231. package/dist/chunks/index-DGQHGTQ5.mjs.map +0 -1
  232. package/dist/src/bin.d.ts.map +0 -1
  233. package/dist/src/cloud/command.d.ts.map +0 -1
  234. package/dist/src/config/api.d.ts.map +0 -1
  235. package/dist/src/config/local.d.ts.map +0 -1
  236. package/dist/src/create-project/action.d.ts.map +0 -1
  237. package/dist/src/create-project/command.d.ts.map +0 -1
  238. package/dist/src/create-project/index.d.ts.map +0 -1
  239. package/dist/src/create-project/utils/get-project-name-from-pkg.d.ts.map +0 -1
  240. package/dist/src/create-project/utils/project-questions.utils.d.ts.map +0 -1
  241. package/dist/src/deploy-project/action.d.ts.map +0 -1
  242. package/dist/src/deploy-project/command.d.ts.map +0 -1
  243. package/dist/src/deploy-project/index.d.ts.map +0 -1
  244. package/dist/src/environment/command.d.ts.map +0 -1
  245. package/dist/src/environment/link/action.d.ts.map +0 -1
  246. package/dist/src/environment/link/command.d.ts.map +0 -1
  247. package/dist/src/environment/link/index.d.ts.map +0 -1
  248. package/dist/src/environment/list/action.d.ts.map +0 -1
  249. package/dist/src/environment/list/command.d.ts.map +0 -1
  250. package/dist/src/environment/list/index.d.ts.map +0 -1
  251. package/dist/src/index.d.ts.map +0 -1
  252. package/dist/src/link/action.d.ts.map +0 -1
  253. package/dist/src/link/command.d.ts.map +0 -1
  254. package/dist/src/link/index.d.ts.map +0 -1
  255. package/dist/src/list-projects/action.d.ts.map +0 -1
  256. package/dist/src/list-projects/command.d.ts.map +0 -1
  257. package/dist/src/list-projects/index.d.ts.map +0 -1
  258. package/dist/src/login/action.d.ts.map +0 -1
  259. package/dist/src/login/command.d.ts.map +0 -1
  260. package/dist/src/login/index.d.ts.map +0 -1
  261. package/dist/src/logout/action.d.ts.map +0 -1
  262. package/dist/src/logout/command.d.ts.map +0 -1
  263. package/dist/src/logout/index.d.ts.map +0 -1
  264. package/dist/src/services/build-logs.d.ts.map +0 -1
  265. package/dist/src/services/cli-api.d.ts.map +0 -1
  266. package/dist/src/services/index.d.ts.map +0 -1
  267. package/dist/src/services/logger.d.ts.map +0 -1
  268. package/dist/src/services/notification.d.ts.map +0 -1
  269. package/dist/src/services/strapi-info-save.d.ts.map +0 -1
  270. package/dist/src/services/token.d.ts.map +0 -1
  271. package/dist/src/types.d.ts.map +0 -1
  272. package/dist/src/utils/analytics.d.ts.map +0 -1
  273. package/dist/src/utils/compress-files.d.ts.map +0 -1
  274. package/dist/src/utils/get-local-config.d.ts.map +0 -1
  275. package/dist/src/utils/helpers.d.ts.map +0 -1
  276. package/dist/src/utils/pkg.d.ts.map +0 -1
  277. package/dist/src/utils/tests/compress-files.test.d.ts.map +0 -1
  278. /package/dist/{src/bin.d.ts → bin.d.ts} +0 -0
  279. /package/dist/{src/cloud → cloud}/command.d.ts +0 -0
  280. /package/dist/{src/config → config}/api.d.ts +0 -0
  281. /package/dist/{src/config → config}/local.d.ts +0 -0
  282. /package/dist/{src/create-project → create-project}/action.d.ts +0 -0
  283. /package/dist/{src/create-project → create-project}/command.d.ts +0 -0
  284. /package/dist/{src/create-project → create-project}/index.d.ts +0 -0
  285. /package/dist/{src/create-project → create-project}/utils/get-project-name-from-pkg.d.ts +0 -0
  286. /package/dist/{src/create-project → create-project}/utils/project-questions.utils.d.ts +0 -0
  287. /package/dist/{src/deploy-project → deploy-project}/action.d.ts +0 -0
  288. /package/dist/{src/deploy-project → deploy-project}/command.d.ts +0 -0
  289. /package/dist/{src/deploy-project → deploy-project}/index.d.ts +0 -0
  290. /package/dist/{src/environment → environment}/command.d.ts +0 -0
  291. /package/dist/{src/environment → environment}/link/action.d.ts +0 -0
  292. /package/dist/{src/environment → environment}/link/command.d.ts +0 -0
  293. /package/dist/{src/environment → environment}/link/index.d.ts +0 -0
  294. /package/dist/{src/environment → environment}/list/action.d.ts +0 -0
  295. /package/dist/{src/environment → environment}/list/command.d.ts +0 -0
  296. /package/dist/{src/environment → environment}/list/index.d.ts +0 -0
  297. /package/dist/{src/index.d.ts → index.d.ts} +0 -0
  298. /package/dist/{src/link → link}/action.d.ts +0 -0
  299. /package/dist/{src/link → link}/command.d.ts +0 -0
  300. /package/dist/{src/link → link}/index.d.ts +0 -0
  301. /package/dist/{src/list-projects → list-projects}/action.d.ts +0 -0
  302. /package/dist/{src/list-projects → list-projects}/command.d.ts +0 -0
  303. /package/dist/{src/list-projects → list-projects}/index.d.ts +0 -0
  304. /package/dist/{src/login → login}/action.d.ts +0 -0
  305. /package/dist/{src/login → login}/command.d.ts +0 -0
  306. /package/dist/{src/login → login}/index.d.ts +0 -0
  307. /package/dist/{src/logout → logout}/action.d.ts +0 -0
  308. /package/dist/{src/logout → logout}/command.d.ts +0 -0
  309. /package/dist/{src/logout → logout}/index.d.ts +0 -0
  310. /package/dist/{src/services → services}/build-logs.d.ts +0 -0
  311. /package/dist/{src/services → services}/cli-api.d.ts +0 -0
  312. /package/dist/{src/services → services}/index.d.ts +0 -0
  313. /package/dist/{src/services → services}/logger.d.ts +0 -0
  314. /package/dist/{src/services → services}/notification.d.ts +0 -0
  315. /package/dist/{src/services → services}/strapi-info-save.d.ts +0 -0
  316. /package/dist/{src/services → services}/token.d.ts +0 -0
  317. /package/dist/{src/types.d.ts → types.d.ts} +0 -0
  318. /package/dist/{src/utils → utils}/analytics.d.ts +0 -0
  319. /package/dist/{src/utils → utils}/compress-files.d.ts +0 -0
  320. /package/dist/{src/utils → utils}/get-local-config.d.ts +0 -0
  321. /package/dist/{src/utils → utils}/helpers.d.ts +0 -0
  322. /package/dist/{src/utils → utils}/pkg.d.ts +0 -0
  323. /package/dist/{src/utils → utils}/tests/compress-files.test.d.ts +0 -0
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ var fse = require('fs-extra');
4
+ var tar = require('tar');
5
+ var path = require('path');
6
+ var minimatch = require('minimatch');
7
+
8
+ function _interopNamespaceDefault(e) {
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var fse__namespace = /*#__PURE__*/_interopNamespaceDefault(fse);
26
+ var tar__namespace = /*#__PURE__*/_interopNamespaceDefault(tar);
27
+ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
28
+
29
+ const IGNORED_PATTERNS = [
30
+ '**/.git/**',
31
+ '**/node_modules/**',
32
+ '**/build/**',
33
+ '**/dist/**',
34
+ '**/.cache/**',
35
+ '**/.circleci/**',
36
+ '**/.github/**',
37
+ '**/.gitignore',
38
+ '**/.gitkeep',
39
+ '**/.gitlab-ci.yml',
40
+ '**/.idea/**',
41
+ '**/.vscode/**'
42
+ ];
43
+ const isIgnoredFile = (folderPath, file, ignorePatterns)=>{
44
+ ignorePatterns.push(...IGNORED_PATTERNS);
45
+ const relativeFilePath = path__namespace.join(folderPath, file);
46
+ let isIgnored = false;
47
+ for (const pattern of ignorePatterns){
48
+ if (pattern.startsWith('!')) {
49
+ if (minimatch.minimatch(relativeFilePath, pattern.slice(1), {
50
+ matchBase: true,
51
+ dot: true
52
+ })) {
53
+ return false;
54
+ }
55
+ } else if (minimatch.minimatch(relativeFilePath, pattern, {
56
+ matchBase: true,
57
+ dot: true
58
+ })) {
59
+ if (path__namespace.basename(file) !== '.gitkeep') {
60
+ isIgnored = true;
61
+ }
62
+ }
63
+ }
64
+ return isIgnored;
65
+ };
66
+ const getFiles = async (dirPath, ignorePatterns = [], subfolder = '')=>{
67
+ const arrayOfFiles = [];
68
+ const entries = await fse__namespace.readdir(path__namespace.join(dirPath, subfolder));
69
+ for (const entry of entries){
70
+ const entryPathFromRoot = path__namespace.join(subfolder, entry);
71
+ const entryPath = path__namespace.relative(dirPath, entryPathFromRoot);
72
+ const isIgnored = isIgnoredFile(dirPath, entryPathFromRoot, ignorePatterns);
73
+ if (!isIgnored) {
74
+ if (fse__namespace.statSync(entryPath).isDirectory()) {
75
+ const subFiles = await getFiles(dirPath, ignorePatterns, entryPathFromRoot);
76
+ arrayOfFiles.push(...subFiles);
77
+ } else {
78
+ arrayOfFiles.push(entryPath);
79
+ }
80
+ }
81
+ }
82
+ return arrayOfFiles;
83
+ };
84
+ const readGitignore = async (folderPath)=>{
85
+ const gitignorePath = path__namespace.resolve(folderPath, '.gitignore');
86
+ const pathExist = await fse__namespace.pathExists(gitignorePath);
87
+ if (!pathExist) return [];
88
+ const gitignoreContent = await fse__namespace.readFile(gitignorePath, 'utf8');
89
+ return gitignoreContent.split(/\r?\n/).filter((line)=>Boolean(line.trim()) && !line.startsWith('#'));
90
+ };
91
+ const compressFilesToTar = async (storagePath, folderToCompress, filename)=>{
92
+ const ignorePatterns = await readGitignore(folderToCompress);
93
+ const filesToCompress = await getFiles(folderToCompress, ignorePatterns);
94
+ return tar__namespace.c({
95
+ gzip: true,
96
+ file: path__namespace.resolve(storagePath, filename)
97
+ }, filesToCompress);
98
+ };
99
+
100
+ exports.compressFilesToTar = compressFilesToTar;
101
+ exports.isIgnoredFile = isIgnoredFile;
102
+ //# sourceMappingURL=compress-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compress-files.js","sources":["../../src/utils/compress-files.ts"],"sourcesContent":["import * as fse from 'fs-extra';\nimport * as tar from 'tar';\nimport * as path from 'path';\nimport { minimatch } from 'minimatch';\n\nconst IGNORED_PATTERNS = [\n '**/.git/**',\n '**/node_modules/**',\n '**/build/**',\n '**/dist/**',\n '**/.cache/**',\n '**/.circleci/**',\n '**/.github/**',\n '**/.gitignore',\n '**/.gitkeep',\n '**/.gitlab-ci.yml',\n '**/.idea/**',\n '**/.vscode/**',\n];\n\nconst isIgnoredFile = (folderPath: string, file: string, ignorePatterns: string[]): boolean => {\n ignorePatterns.push(...IGNORED_PATTERNS);\n const relativeFilePath = path.join(folderPath, file);\n let isIgnored = false;\n for (const pattern of ignorePatterns) {\n if (pattern.startsWith('!')) {\n if (minimatch(relativeFilePath, pattern.slice(1), { matchBase: true, dot: true })) {\n return false;\n }\n } else if (minimatch(relativeFilePath, pattern, { matchBase: true, dot: true })) {\n if (path.basename(file) !== '.gitkeep') {\n isIgnored = true;\n }\n }\n }\n return isIgnored;\n};\n\nconst getFiles = async (\n dirPath: string,\n ignorePatterns: string[] = [],\n subfolder: string = ''\n): Promise<string[]> => {\n const arrayOfFiles: string[] = [];\n const entries = await fse.readdir(path.join(dirPath, subfolder));\n\n for (const entry of entries) {\n const entryPathFromRoot = path.join(subfolder, entry);\n const entryPath = path.relative(dirPath, entryPathFromRoot);\n const isIgnored = isIgnoredFile(dirPath, entryPathFromRoot, ignorePatterns);\n\n if (!isIgnored) {\n if (fse.statSync(entryPath).isDirectory()) {\n const subFiles = await getFiles(dirPath, ignorePatterns, entryPathFromRoot);\n arrayOfFiles.push(...subFiles);\n } else {\n arrayOfFiles.push(entryPath);\n }\n }\n }\n return arrayOfFiles;\n};\n\nconst readGitignore = async (folderPath: string): Promise<string[]> => {\n const gitignorePath = path.resolve(folderPath, '.gitignore');\n const pathExist = await fse.pathExists(gitignorePath);\n\n if (!pathExist) return [];\n\n const gitignoreContent = await fse.readFile(gitignorePath, 'utf8');\n\n return gitignoreContent\n .split(/\\r?\\n/)\n .filter((line) => Boolean(line.trim()) && !line.startsWith('#'));\n};\n\nconst compressFilesToTar = async (\n storagePath: string,\n folderToCompress: string,\n filename: string\n): Promise<void> => {\n const ignorePatterns = await readGitignore(folderToCompress);\n const filesToCompress = await getFiles(folderToCompress, ignorePatterns);\n\n return tar.c(\n {\n gzip: true,\n file: path.resolve(storagePath, filename),\n },\n filesToCompress\n );\n};\n\nexport { compressFilesToTar, isIgnoredFile };\n"],"names":["IGNORED_PATTERNS","isIgnoredFile","folderPath","file","ignorePatterns","push","relativeFilePath","path","join","isIgnored","pattern","startsWith","minimatch","slice","matchBase","dot","basename","getFiles","dirPath","subfolder","arrayOfFiles","entries","fse","readdir","entry","entryPathFromRoot","entryPath","relative","statSync","isDirectory","subFiles","readGitignore","gitignorePath","resolve","pathExist","pathExists","gitignoreContent","readFile","split","filter","line","Boolean","trim","compressFilesToTar","storagePath","folderToCompress","filename","filesToCompress","tar","c","gzip"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,gBAAmB,GAAA;AACvB,IAAA,YAAA;AACA,IAAA,oBAAA;AACA,IAAA,aAAA;AACA,IAAA,YAAA;AACA,IAAA,cAAA;AACA,IAAA,iBAAA;AACA,IAAA,eAAA;AACA,IAAA,eAAA;AACA,IAAA,aAAA;AACA,IAAA,mBAAA;AACA,IAAA,aAAA;AACA,IAAA;AACD,CAAA;AAEKC,MAAAA,aAAAA,GAAgB,CAACC,UAAAA,EAAoBC,IAAcC,EAAAA,cAAAA,GAAAA;AACvDA,IAAAA,cAAAA,CAAeC,IAAI,CAAIL,GAAAA,gBAAAA,CAAAA;AACvB,IAAA,MAAMM,gBAAmBC,GAAAA,eA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,IAAMI,EAAAA,eAAAA,CAAK0B,OAAO,CAACW,WAAaE,EAAAA,QAAAA;KAElCC,EAAAA,eAAAA,CAAAA;AAEJ;;;;;"}
@@ -0,0 +1,78 @@
1
+ import * as fse from 'fs-extra';
2
+ import * as tar from 'tar';
3
+ import * as path from 'path';
4
+ import { minimatch } from 'minimatch';
5
+
6
+ const IGNORED_PATTERNS = [
7
+ '**/.git/**',
8
+ '**/node_modules/**',
9
+ '**/build/**',
10
+ '**/dist/**',
11
+ '**/.cache/**',
12
+ '**/.circleci/**',
13
+ '**/.github/**',
14
+ '**/.gitignore',
15
+ '**/.gitkeep',
16
+ '**/.gitlab-ci.yml',
17
+ '**/.idea/**',
18
+ '**/.vscode/**'
19
+ ];
20
+ const isIgnoredFile = (folderPath, file, ignorePatterns)=>{
21
+ ignorePatterns.push(...IGNORED_PATTERNS);
22
+ const relativeFilePath = path.join(folderPath, file);
23
+ let isIgnored = false;
24
+ for (const pattern of ignorePatterns){
25
+ if (pattern.startsWith('!')) {
26
+ if (minimatch(relativeFilePath, pattern.slice(1), {
27
+ matchBase: true,
28
+ dot: true
29
+ })) {
30
+ return false;
31
+ }
32
+ } else if (minimatch(relativeFilePath, pattern, {
33
+ matchBase: true,
34
+ dot: true
35
+ })) {
36
+ if (path.basename(file) !== '.gitkeep') {
37
+ isIgnored = true;
38
+ }
39
+ }
40
+ }
41
+ return isIgnored;
42
+ };
43
+ const getFiles = async (dirPath, ignorePatterns = [], subfolder = '')=>{
44
+ const arrayOfFiles = [];
45
+ const entries = await fse.readdir(path.join(dirPath, subfolder));
46
+ for (const entry of entries){
47
+ const entryPathFromRoot = path.join(subfolder, entry);
48
+ const entryPath = path.relative(dirPath, entryPathFromRoot);
49
+ const isIgnored = isIgnoredFile(dirPath, entryPathFromRoot, ignorePatterns);
50
+ if (!isIgnored) {
51
+ if (fse.statSync(entryPath).isDirectory()) {
52
+ const subFiles = await getFiles(dirPath, ignorePatterns, entryPathFromRoot);
53
+ arrayOfFiles.push(...subFiles);
54
+ } else {
55
+ arrayOfFiles.push(entryPath);
56
+ }
57
+ }
58
+ }
59
+ return arrayOfFiles;
60
+ };
61
+ const readGitignore = async (folderPath)=>{
62
+ const gitignorePath = path.resolve(folderPath, '.gitignore');
63
+ const pathExist = await fse.pathExists(gitignorePath);
64
+ if (!pathExist) return [];
65
+ const gitignoreContent = await fse.readFile(gitignorePath, 'utf8');
66
+ return gitignoreContent.split(/\r?\n/).filter((line)=>Boolean(line.trim()) && !line.startsWith('#'));
67
+ };
68
+ const compressFilesToTar = async (storagePath, folderToCompress, filename)=>{
69
+ const ignorePatterns = await readGitignore(folderToCompress);
70
+ const filesToCompress = await getFiles(folderToCompress, ignorePatterns);
71
+ return tar.c({
72
+ gzip: true,
73
+ file: path.resolve(storagePath, filename)
74
+ }, filesToCompress);
75
+ };
76
+
77
+ export { compressFilesToTar, isIgnoredFile };
78
+ //# sourceMappingURL=compress-files.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compress-files.mjs","sources":["../../src/utils/compress-files.ts"],"sourcesContent":["import * as fse from 'fs-extra';\nimport * as tar from 'tar';\nimport * as path from 'path';\nimport { minimatch } from 'minimatch';\n\nconst IGNORED_PATTERNS = [\n '**/.git/**',\n '**/node_modules/**',\n '**/build/**',\n '**/dist/**',\n '**/.cache/**',\n '**/.circleci/**',\n '**/.github/**',\n '**/.gitignore',\n '**/.gitkeep',\n '**/.gitlab-ci.yml',\n '**/.idea/**',\n '**/.vscode/**',\n];\n\nconst isIgnoredFile = (folderPath: string, file: string, ignorePatterns: string[]): boolean => {\n ignorePatterns.push(...IGNORED_PATTERNS);\n const relativeFilePath = path.join(folderPath, file);\n let isIgnored = false;\n for (const pattern of ignorePatterns) {\n if (pattern.startsWith('!')) {\n if (minimatch(relativeFilePath, pattern.slice(1), { matchBase: true, dot: true })) {\n return false;\n }\n } else if (minimatch(relativeFilePath, pattern, { matchBase: true, dot: true })) {\n if (path.basename(file) !== '.gitkeep') {\n isIgnored = true;\n }\n }\n }\n return isIgnored;\n};\n\nconst getFiles = async (\n dirPath: string,\n ignorePatterns: string[] = [],\n subfolder: string = ''\n): Promise<string[]> => {\n const arrayOfFiles: string[] = [];\n const entries = await fse.readdir(path.join(dirPath, subfolder));\n\n for (const entry of entries) {\n const entryPathFromRoot = path.join(subfolder, entry);\n const entryPath = path.relative(dirPath, entryPathFromRoot);\n const isIgnored = isIgnoredFile(dirPath, entryPathFromRoot, ignorePatterns);\n\n if (!isIgnored) {\n if (fse.statSync(entryPath).isDirectory()) {\n const subFiles = await getFiles(dirPath, ignorePatterns, entryPathFromRoot);\n arrayOfFiles.push(...subFiles);\n } else {\n arrayOfFiles.push(entryPath);\n }\n }\n }\n return arrayOfFiles;\n};\n\nconst readGitignore = async (folderPath: string): Promise<string[]> => {\n const gitignorePath = path.resolve(folderPath, '.gitignore');\n const pathExist = await fse.pathExists(gitignorePath);\n\n if (!pathExist) return [];\n\n const gitignoreContent = await fse.readFile(gitignorePath, 'utf8');\n\n return gitignoreContent\n .split(/\\r?\\n/)\n .filter((line) => Boolean(line.trim()) && !line.startsWith('#'));\n};\n\nconst compressFilesToTar = async (\n storagePath: string,\n folderToCompress: string,\n filename: string\n): Promise<void> => {\n const ignorePatterns = await readGitignore(folderToCompress);\n const filesToCompress = await getFiles(folderToCompress, ignorePatterns);\n\n return tar.c(\n {\n gzip: true,\n file: path.resolve(storagePath, filename),\n },\n filesToCompress\n );\n};\n\nexport { compressFilesToTar, isIgnoredFile };\n"],"names":["IGNORED_PATTERNS","isIgnoredFile","folderPath","file","ignorePatterns","push","relativeFilePath","path","join","isIgnored","pattern","startsWith","minimatch","slice","matchBase","dot","basename","getFiles","dirPath","subfolder","arrayOfFiles","entries","fse","readdir","entry","entryPathFromRoot","entryPath","relative","statSync","isDirectory","subFiles","readGitignore","gitignorePath","resolve","pathExist","pathExists","gitignoreContent","readFile","split","filter","line","Boolean","trim","compressFilesToTar","storagePath","folderToCompress","filename","filesToCompress","tar","c","gzip"],"mappings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IAASC,GAAAA,OAAAA,CAAQD,KAAKE,IAAI,EAAA,CAAA,IAAO,CAACF,IAAAA,CAAK7B,UAAU,CAAC,GAAA,CAAA,CAAA;AAC/D,CAAA;AAEMgC,MAAAA,kBAAAA,GAAqB,OACzBC,WAAAA,EACAC,gBACAC,EAAAA,QAAAA,GAAAA;IAEA,MAAM1C,cAAAA,GAAiB,MAAM2B,aAAcc,CAAAA,gBAAAA,CAAAA;IAC3C,MAAME,eAAAA,GAAkB,MAAM9B,QAAAA,CAAS4B,gBAAkBzC,EAAAA,cAAAA,CAAAA;IAEzD,OAAO4C,GAAAA,CAAIC,CAAC,CACV;QACEC,IAAM,EAAA,IAAA;QACN/C,IAAMI,EAAAA,IAAAA,CAAK0B,OAAO,CAACW,WAAaE,EAAAA,QAAAA;KAElCC,EAAAA,eAAAA,CAAAA;AAEJ;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-local-config.d.ts","sourceRoot":"","sources":["../../src/utils/get-local-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,iBAAe,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAQxE;AAED,iBAAe,eAAe,CAAC,GAAG,EAAE,UAAU,uDAY7C;AAED,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ require('axios');
5
+ require('fs-extra');
6
+ require('os');
7
+ require('../config/api.js');
8
+ require('path');
9
+ require('xdg-app-paths');
10
+ var strapiInfoSave = require('../services/strapi-info-save.js');
11
+ require('jwks-rsa');
12
+ require('jsonwebtoken');
13
+ require('fast-safe-stringify');
14
+ require('ora');
15
+ require('cli-progress');
16
+
17
+ async function getLocalConfig(ctx) {
18
+ try {
19
+ return await strapiInfoSave.retrieve();
20
+ } catch (e) {
21
+ ctx.logger.debug('Failed to get project config', e);
22
+ ctx.logger.error('An error occurred while retrieving config data from your local project.');
23
+ return null;
24
+ }
25
+ }
26
+ async function getLocalProject(ctx) {
27
+ const localConfig = await getLocalConfig(ctx);
28
+ if (!localConfig || !localConfig.project) {
29
+ ctx.logger.warn(`\nWe couldn't find a valid local project config.\nPlease link your local project to an existing Strapi Cloud project using the ${chalk.cyan('link')} command.`);
30
+ process.exit(1);
31
+ }
32
+ return localConfig.project;
33
+ }
34
+
35
+ exports.getLocalConfig = getLocalConfig;
36
+ exports.getLocalProject = getLocalProject;
37
+ //# sourceMappingURL=get-local-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-local-config.js","sources":["../../src/utils/get-local-config.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { CLIContext } from '../types';\nimport { local } from '../services';\nimport { LocalSave } from '../services/strapi-info-save';\n\nasync function getLocalConfig(ctx: CLIContext): Promise<LocalSave | null> {\n try {\n return await local.retrieve();\n } catch (e) {\n ctx.logger.debug('Failed to get project config', e);\n ctx.logger.error('An error occurred while retrieving config data from your local project.');\n return null;\n }\n}\n\nasync function getLocalProject(ctx: CLIContext) {\n const localConfig = await getLocalConfig(ctx);\n\n if (!localConfig || !localConfig.project) {\n ctx.logger.warn(\n `\\nWe couldn't find a valid local project config.\\nPlease link your local project to an existing Strapi Cloud project using the ${chalk.cyan(\n 'link'\n )} command.`\n );\n process.exit(1);\n }\n return localConfig.project;\n}\n\nexport { getLocalConfig, getLocalProject };\n"],"names":["getLocalConfig","ctx","local","e","logger","debug","error","getLocalProject","localConfig","project","warn","chalk","cyan","process","exit"],"mappings":";;;;;;;;;;;;;;;;AAKA,eAAeA,eAAeC,GAAe,EAAA;IAC3C,IAAI;QACF,OAAO,MAAMC,uBAAc,EAAA;AAC7B,KAAA,CAAE,OAAOC,CAAG,EAAA;AACVF,QAAAA,GAAAA,CAAIG,MAAM,CAACC,KAAK,CAAC,8BAAgCF,EAAAA,CAAAA,CAAAA;QACjDF,GAAIG,CAAAA,MAAM,CAACE,KAAK,CAAC,yEAAA,CAAA;QACjB,OAAO,IAAA;AACT;AACF;AAEA,eAAeC,gBAAgBN,GAAe,EAAA;IAC5C,MAAMO,WAAAA,GAAc,MAAMR,cAAeC,CAAAA,GAAAA,CAAAA;AAEzC,IAAA,IAAI,CAACO,WAAAA,IAAe,CAACA,WAAAA,CAAYC,OAAO,EAAE;AACxCR,QAAAA,GAAAA,CAAIG,MAAM,CAACM,IAAI,CACb,CAAC,+HAA+H,EAAEC,KAAAA,CAAMC,IAAI,CAC1I,MACA,CAAA,CAAA,SAAS,CAAC,CAAA;AAEdC,QAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf;AACA,IAAA,OAAON,YAAYC,OAAO;AAC5B;;;;;"}
@@ -0,0 +1,34 @@
1
+ import chalk from 'chalk';
2
+ import 'axios';
3
+ import 'fs-extra';
4
+ import 'os';
5
+ import '../config/api.mjs';
6
+ import 'path';
7
+ import 'xdg-app-paths';
8
+ import { retrieve } from '../services/strapi-info-save.mjs';
9
+ import 'jwks-rsa';
10
+ import 'jsonwebtoken';
11
+ import 'fast-safe-stringify';
12
+ import 'ora';
13
+ import 'cli-progress';
14
+
15
+ async function getLocalConfig(ctx) {
16
+ try {
17
+ return await retrieve();
18
+ } catch (e) {
19
+ ctx.logger.debug('Failed to get project config', e);
20
+ ctx.logger.error('An error occurred while retrieving config data from your local project.');
21
+ return null;
22
+ }
23
+ }
24
+ async function getLocalProject(ctx) {
25
+ const localConfig = await getLocalConfig(ctx);
26
+ if (!localConfig || !localConfig.project) {
27
+ ctx.logger.warn(`\nWe couldn't find a valid local project config.\nPlease link your local project to an existing Strapi Cloud project using the ${chalk.cyan('link')} command.`);
28
+ process.exit(1);
29
+ }
30
+ return localConfig.project;
31
+ }
32
+
33
+ export { getLocalConfig, getLocalProject };
34
+ //# sourceMappingURL=get-local-config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-local-config.mjs","sources":["../../src/utils/get-local-config.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { CLIContext } from '../types';\nimport { local } from '../services';\nimport { LocalSave } from '../services/strapi-info-save';\n\nasync function getLocalConfig(ctx: CLIContext): Promise<LocalSave | null> {\n try {\n return await local.retrieve();\n } catch (e) {\n ctx.logger.debug('Failed to get project config', e);\n ctx.logger.error('An error occurred while retrieving config data from your local project.');\n return null;\n }\n}\n\nasync function getLocalProject(ctx: CLIContext) {\n const localConfig = await getLocalConfig(ctx);\n\n if (!localConfig || !localConfig.project) {\n ctx.logger.warn(\n `\\nWe couldn't find a valid local project config.\\nPlease link your local project to an existing Strapi Cloud project using the ${chalk.cyan(\n 'link'\n )} command.`\n );\n process.exit(1);\n }\n return localConfig.project;\n}\n\nexport { getLocalConfig, getLocalProject };\n"],"names":["getLocalConfig","ctx","local","e","logger","debug","error","getLocalProject","localConfig","project","warn","chalk","cyan","process","exit"],"mappings":";;;;;;;;;;;;;;AAKA,eAAeA,eAAeC,GAAe,EAAA;IAC3C,IAAI;QACF,OAAO,MAAMC,QAAc,EAAA;AAC7B,KAAA,CAAE,OAAOC,CAAG,EAAA;AACVF,QAAAA,GAAAA,CAAIG,MAAM,CAACC,KAAK,CAAC,8BAAgCF,EAAAA,CAAAA,CAAAA;QACjDF,GAAIG,CAAAA,MAAM,CAACE,KAAK,CAAC,yEAAA,CAAA;QACjB,OAAO,IAAA;AACT;AACF;AAEA,eAAeC,gBAAgBN,GAAe,EAAA;IAC5C,MAAMO,WAAAA,GAAc,MAAMR,cAAeC,CAAAA,GAAAA,CAAAA;AAEzC,IAAA,IAAI,CAACO,WAAAA,IAAe,CAACA,WAAAA,CAAYC,OAAO,EAAE;AACxCR,QAAAA,GAAAA,CAAIG,MAAM,CAACM,IAAI,CACb,CAAC,+HAA+H,EAAEC,KAAAA,CAAMC,IAAI,CAC1I,MACA,CAAA,CAAA,SAAS,CAAC,CAAA;AAEdC,QAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf;AACA,IAAA,OAAON,YAAYC,OAAO;AAC5B;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AA6BA,QAAA,MAAM,SAAS,SACN,MAAM,UAAU,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,QAAQ,OAAO,CAAC,eACjD,OAAO,EAAE,SAWlB,CAAC;AAEJ,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var chalk = require('chalk');
4
+ var fp = require('lodash/fp');
5
+
6
+ // TODO: Remove duplicated code by extracting to a shared package
7
+ const assertCwdContainsStrapiProject = (name)=>{
8
+ const logErrorAndExit = ()=>{
9
+ console.log(`You need to run ${chalk.yellow(`strapi ${name}`)} in a Strapi project. Make sure you are in the right directory.`);
10
+ process.exit(1);
11
+ };
12
+ try {
13
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
14
+ const pkgJSON = require(`${process.cwd()}/package.json`);
15
+ if (!fp.has('dependencies.@strapi/strapi', pkgJSON) && !fp.has('devDependencies.@strapi/strapi', pkgJSON)) {
16
+ logErrorAndExit();
17
+ }
18
+ } catch (err) {
19
+ logErrorAndExit();
20
+ }
21
+ };
22
+ const runAction = (name, action)=>(...args)=>{
23
+ assertCwdContainsStrapiProject(name);
24
+ Promise.resolve().then(()=>{
25
+ return action(...args);
26
+ }).catch((error)=>{
27
+ console.error(error);
28
+ process.exit(1);
29
+ });
30
+ };
31
+
32
+ exports.runAction = runAction;
33
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../src/utils/helpers.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { has } from 'lodash/fp';\n\n// TODO: Remove duplicated code by extracting to a shared package\n\nconst assertCwdContainsStrapiProject = (name: string) => {\n const logErrorAndExit = () => {\n console.log(\n `You need to run ${chalk.yellow(\n `strapi ${name}`\n )} in a Strapi project. Make sure you are in the right directory.`\n );\n process.exit(1);\n };\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkgJSON = require(`${process.cwd()}/package.json`);\n if (\n !has('dependencies.@strapi/strapi', pkgJSON) &&\n !has('devDependencies.@strapi/strapi', pkgJSON)\n ) {\n logErrorAndExit();\n }\n } catch (err) {\n logErrorAndExit();\n }\n};\n\nconst runAction =\n (name: string, action: (...args: any[]) => Promise<unknown>) =>\n (...args: unknown[]) => {\n assertCwdContainsStrapiProject(name);\n\n Promise.resolve()\n .then(() => {\n return action(...args);\n })\n .catch((error) => {\n console.error(error);\n process.exit(1);\n });\n };\n\nexport { runAction };\n"],"names":["assertCwdContainsStrapiProject","name","logErrorAndExit","console","log","chalk","yellow","process","exit","pkgJSON","require","cwd","has","err","runAction","action","args","Promise","resolve","then","catch","error"],"mappings":";;;;;AAGA;AAEA,MAAMA,iCAAiC,CAACC,IAAAA,GAAAA;AACtC,IAAA,MAAMC,eAAkB,GAAA,IAAA;AACtBC,QAAAA,OAAAA,CAAQC,GAAG,CACT,CAAC,gBAAgB,EAAEC,KAAMC,CAAAA,MAAM,CAC7B,CAAC,OAAO,EAAEL,IAAAA,CAAK,CAAC,CAAA,CAChB,+DAA+D,CAAC,CAAA;AAEpEM,QAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,KAAA;IAEA,IAAI;;QAEF,MAAMC,OAAAA,GAAUC,QAAQ,CAAC,EAAEH,QAAQI,GAAG,EAAA,CAAG,aAAa,CAAC,CAAA;AACvD,QAAA,IACE,CAACC,MAAI,CAAA,6BAAA,EAA+BH,YACpC,CAACG,MAAAA,CAAI,kCAAkCH,OACvC,CAAA,EAAA;AACAP,YAAAA,eAAAA,EAAAA;AACF;AACF,KAAA,CAAE,OAAOW,GAAK,EAAA;AACZX,QAAAA,eAAAA,EAAAA;AACF;AACF,CAAA;AAEA,MAAMY,SACJ,GAAA,CAACb,IAAcc,EAAAA,MAAAA,GACf,CAAC,GAAGC,IAAAA,GAAAA;QACFhB,8BAA+BC,CAAAA,IAAAA,CAAAA;QAE/BgB,OAAQC,CAAAA,OAAO,EACZC,CAAAA,IAAI,CAAC,IAAA;AACJ,YAAA,OAAOJ,MAAUC,CAAAA,GAAAA,IAAAA,CAAAA;SAElBI,CAAAA,CAAAA,KAAK,CAAC,CAACC,KAAAA,GAAAA;AACNlB,YAAAA,OAAAA,CAAQkB,KAAK,CAACA,KAAAA,CAAAA;AACdd,YAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,SAAA,CAAA;AACJ;;;;"}
@@ -0,0 +1,31 @@
1
+ import chalk from 'chalk';
2
+ import { has } from 'lodash/fp';
3
+
4
+ // TODO: Remove duplicated code by extracting to a shared package
5
+ const assertCwdContainsStrapiProject = (name)=>{
6
+ const logErrorAndExit = ()=>{
7
+ console.log(`You need to run ${chalk.yellow(`strapi ${name}`)} in a Strapi project. Make sure you are in the right directory.`);
8
+ process.exit(1);
9
+ };
10
+ try {
11
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
12
+ const pkgJSON = require(`${process.cwd()}/package.json`);
13
+ if (!has('dependencies.@strapi/strapi', pkgJSON) && !has('devDependencies.@strapi/strapi', pkgJSON)) {
14
+ logErrorAndExit();
15
+ }
16
+ } catch (err) {
17
+ logErrorAndExit();
18
+ }
19
+ };
20
+ const runAction = (name, action)=>(...args)=>{
21
+ assertCwdContainsStrapiProject(name);
22
+ Promise.resolve().then(()=>{
23
+ return action(...args);
24
+ }).catch((error)=>{
25
+ console.error(error);
26
+ process.exit(1);
27
+ });
28
+ };
29
+
30
+ export { runAction };
31
+ //# sourceMappingURL=helpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.mjs","sources":["../../src/utils/helpers.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { has } from 'lodash/fp';\n\n// TODO: Remove duplicated code by extracting to a shared package\n\nconst assertCwdContainsStrapiProject = (name: string) => {\n const logErrorAndExit = () => {\n console.log(\n `You need to run ${chalk.yellow(\n `strapi ${name}`\n )} in a Strapi project. Make sure you are in the right directory.`\n );\n process.exit(1);\n };\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkgJSON = require(`${process.cwd()}/package.json`);\n if (\n !has('dependencies.@strapi/strapi', pkgJSON) &&\n !has('devDependencies.@strapi/strapi', pkgJSON)\n ) {\n logErrorAndExit();\n }\n } catch (err) {\n logErrorAndExit();\n }\n};\n\nconst runAction =\n (name: string, action: (...args: any[]) => Promise<unknown>) =>\n (...args: unknown[]) => {\n assertCwdContainsStrapiProject(name);\n\n Promise.resolve()\n .then(() => {\n return action(...args);\n })\n .catch((error) => {\n console.error(error);\n process.exit(1);\n });\n };\n\nexport { runAction };\n"],"names":["assertCwdContainsStrapiProject","name","logErrorAndExit","console","log","chalk","yellow","process","exit","pkgJSON","require","cwd","has","err","runAction","action","args","Promise","resolve","then","catch","error"],"mappings":";;;AAGA;AAEA,MAAMA,iCAAiC,CAACC,IAAAA,GAAAA;AACtC,IAAA,MAAMC,eAAkB,GAAA,IAAA;AACtBC,QAAAA,OAAAA,CAAQC,GAAG,CACT,CAAC,gBAAgB,EAAEC,KAAMC,CAAAA,MAAM,CAC7B,CAAC,OAAO,EAAEL,IAAAA,CAAK,CAAC,CAAA,CAChB,+DAA+D,CAAC,CAAA;AAEpEM,QAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,KAAA;IAEA,IAAI;;QAEF,MAAMC,OAAAA,GAAUC,QAAQ,CAAC,EAAEH,QAAQI,GAAG,EAAA,CAAG,aAAa,CAAC,CAAA;AACvD,QAAA,IACE,CAACC,GAAI,CAAA,6BAAA,EAA+BH,YACpC,CAACG,GAAAA,CAAI,kCAAkCH,OACvC,CAAA,EAAA;AACAP,YAAAA,eAAAA,EAAAA;AACF;AACF,KAAA,CAAE,OAAOW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CAAE,KAAG,QAAQ,WAAW,CAc5F,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,WAAW,YAAmB;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,KAAG,QAAQ,WAAW,CA6CxE,CAAC;AAEF,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ var fse = require('fs-extra');
4
+ var os = require('os');
5
+ var pkgUp = require('pkg-up');
6
+ var yup = require('yup');
7
+ require('chalk');
8
+
9
+ function _interopNamespaceDefault(e) {
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+
26
+ var fse__namespace = /*#__PURE__*/_interopNamespaceDefault(fse);
27
+ var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
28
+
29
+ yup__namespace.object({
30
+ name: yup__namespace.string().required(),
31
+ exports: yup__namespace.lazy((value)=>yup__namespace.object(typeof value === 'object' ? Object.entries(value).reduce((acc, [key, value])=>{
32
+ if (typeof value === 'object') {
33
+ acc[key] = yup__namespace.object({
34
+ types: yup__namespace.string().optional(),
35
+ source: yup__namespace.string().required(),
36
+ module: yup__namespace.string().optional(),
37
+ import: yup__namespace.string().required(),
38
+ require: yup__namespace.string().required(),
39
+ default: yup__namespace.string().required()
40
+ }).noUnknown(true);
41
+ } else {
42
+ acc[key] = yup__namespace.string().matches(/^\.\/.*\.json$/).required();
43
+ }
44
+ return acc;
45
+ }, {}) : undefined).optional())
46
+ });
47
+ /**
48
+ * @description being a task to load the package.json starting from the current working directory
49
+ * using a shallow find for the package.json and `fs` to read the file. If no package.json is found,
50
+ * the process will throw with an appropriate error message.
51
+ */ const loadPkg = async ({ cwd, logger })=>{
52
+ const pkgPath = await pkgUp({
53
+ cwd
54
+ });
55
+ if (!pkgPath) {
56
+ throw new Error('Could not find a package.json in the current directory');
57
+ }
58
+ const buffer = await fse__namespace.readFile(pkgPath);
59
+ const pkg = JSON.parse(buffer.toString());
60
+ logger.debug('Loaded package.json:', os.EOL, pkg);
61
+ return pkg;
62
+ };
63
+
64
+ exports.loadPkg = loadPkg;
65
+ //# sourceMappingURL=pkg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pkg.js","sources":["../../src/utils/pkg.ts"],"sourcesContent":["import * as fse from 'fs-extra';\nimport os from 'os';\nimport pkgUp from 'pkg-up';\nimport * as yup from 'yup';\nimport chalk from 'chalk';\nimport { Logger } from '../services/logger';\n\ninterface Export {\n types?: string;\n source: string;\n module?: string;\n import?: string;\n require?: string;\n default: string;\n}\n\nconst packageJsonSchema = yup.object({\n name: yup.string().required(),\n exports: yup.lazy((value) =>\n yup\n .object(\n typeof value === 'object'\n ? Object.entries(value).reduce(\n (acc, [key, value]) => {\n if (typeof value === 'object') {\n acc[key] = yup\n .object({\n types: yup.string().optional(),\n source: yup.string().required(),\n module: yup.string().optional(),\n import: yup.string().required(),\n require: yup.string().required(),\n default: yup.string().required(),\n })\n .noUnknown(true);\n } else {\n acc[key] = yup\n .string()\n .matches(/^\\.\\/.*\\.json$/)\n .required();\n }\n\n return acc;\n },\n {} as Record<string, yup.SchemaOf<string> | yup.SchemaOf<Export>>\n )\n : undefined\n )\n .optional()\n ),\n});\n\ntype PackageJson = yup.Asserts<typeof packageJsonSchema>;\n\n/**\n * @description being a task to load the package.json starting from the current working directory\n * using a shallow find for the package.json and `fs` to read the file. If no package.json is found,\n * the process will throw with an appropriate error message.\n */\nconst loadPkg = async ({ cwd, logger }: { cwd: string; logger: Logger }): Promise<PackageJson> => {\n const pkgPath = await pkgUp({ cwd });\n\n if (!pkgPath) {\n throw new Error('Could not find a package.json in the current directory');\n }\n\n const buffer = await fse.readFile(pkgPath);\n\n const pkg = JSON.parse(buffer.toString());\n\n logger.debug('Loaded package.json:', os.EOL, pkg);\n\n return pkg;\n};\n\n/**\n * @description validate the package.json against a standardised schema using `yup`.\n * If the validation fails, the process will throw with an appropriate error message.\n */\nconst validatePkg = async ({ pkg }: { pkg: object }): Promise<PackageJson> => {\n try {\n return await packageJsonSchema.validate(pkg, {\n strict: true,\n });\n } catch (err) {\n if (err instanceof yup.ValidationError) {\n switch (err.type) {\n case 'required':\n if (err.path) {\n throw new Error(\n `'${err.path}' in 'package.json' is required as type '${chalk.magenta(\n yup.reach(packageJsonSchema, err.path).type\n )}'`\n );\n }\n break;\n /**\n * This will only be thrown if there are keys in the export map\n * that we don't expect so we can therefore make some assumptions\n */\n case 'noUnknown':\n if (err.path && err.params && 'unknown' in err.params) {\n throw new Error(\n `'${err.path}' in 'package.json' contains the unknown key ${chalk.magenta(\n err.params.unknown\n )}, for compatability only the following keys are allowed: ${chalk.magenta(\n \"['types', 'source', 'import', 'require', 'default']\"\n )}`\n );\n }\n break;\n default:\n if (err.path && err.params && 'type' in err.params && 'value' in err.params) {\n throw new Error(\n `'${err.path}' in 'package.json' must be of type '${chalk.magenta(\n err.params.type\n )}' (recieved '${chalk.magenta(typeof err.params.value)}')`\n );\n }\n }\n }\n\n throw err;\n }\n};\n\nexport type { PackageJson, Export };\nexport { loadPkg, validatePkg };\n"],"names":["yup","object","name","string","required","exports","lazy","value","Object","entries","reduce","acc","key","types","optional","source","module","import","require","default","noUnknown","matches","undefined","loadPkg","cwd","logger","pkgPath","pkgUp","Error","buffer","fse","readFile","pkg","JSON","parse","toString","debug","os","EOL"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgB0BA,cAAIC,CAAAA,MAAM,CAAC;IACnCC,IAAMF,EAAAA,cAAAA,CAAIG,MAAM,EAAA,CAAGC,QAAQ,EAAA;IAC3BC,OAASL,EAAA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AM,IAAIE,KAAM,CAAA,wDAAA,CAAA;AAClB;AAEA,IAAA,MAAMC,MAAS,GAAA,MAAMC,cAAIC,CAAAA,QAAQ,CAACL,OAAAA,CAAAA;AAElC,IAAA,MAAMM,GAAMC,GAAAA,IAAAA,CAAKC,KAAK,CAACL,OAAOM,QAAQ,EAAA,CAAA;AAEtCV,IAAAA,MAAAA,CAAOW,KAAK,CAAC,sBAAwBC,EAAAA,EAAAA,CAAGC,GAAG,EAAEN,GAAAA,CAAAA;IAE7C,OAAOA,GAAAA;AACT;;;;"}
@@ -0,0 +1,43 @@
1
+ import * as fse from 'fs-extra';
2
+ import os from 'os';
3
+ import pkgUp from 'pkg-up';
4
+ import * as yup from 'yup';
5
+ import 'chalk';
6
+
7
+ yup.object({
8
+ name: yup.string().required(),
9
+ exports: yup.lazy((value)=>yup.object(typeof value === 'object' ? Object.entries(value).reduce((acc, [key, value])=>{
10
+ if (typeof value === 'object') {
11
+ acc[key] = yup.object({
12
+ types: yup.string().optional(),
13
+ source: yup.string().required(),
14
+ module: yup.string().optional(),
15
+ import: yup.string().required(),
16
+ require: yup.string().required(),
17
+ default: yup.string().required()
18
+ }).noUnknown(true);
19
+ } else {
20
+ acc[key] = yup.string().matches(/^\.\/.*\.json$/).required();
21
+ }
22
+ return acc;
23
+ }, {}) : undefined).optional())
24
+ });
25
+ /**
26
+ * @description being a task to load the package.json starting from the current working directory
27
+ * using a shallow find for the package.json and `fs` to read the file. If no package.json is found,
28
+ * the process will throw with an appropriate error message.
29
+ */ const loadPkg = async ({ cwd, logger })=>{
30
+ const pkgPath = await pkgUp({
31
+ cwd
32
+ });
33
+ if (!pkgPath) {
34
+ throw new Error('Could not find a package.json in the current directory');
35
+ }
36
+ const buffer = await fse.readFile(pkgPath);
37
+ const pkg = JSON.parse(buffer.toString());
38
+ logger.debug('Loaded package.json:', os.EOL, pkg);
39
+ return pkg;
40
+ };
41
+
42
+ export { loadPkg };
43
+ //# sourceMappingURL=pkg.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pkg.mjs","sources":["../../src/utils/pkg.ts"],"sourcesContent":["import * as fse from 'fs-extra';\nimport os from 'os';\nimport pkgUp from 'pkg-up';\nimport * as yup from 'yup';\nimport chalk from 'chalk';\nimport { Logger } from '../services/logger';\n\ninterface Export {\n types?: string;\n source: string;\n module?: string;\n import?: string;\n require?: string;\n default: string;\n}\n\nconst packageJsonSchema = yup.object({\n name: yup.string().required(),\n exports: yup.lazy((value) =>\n yup\n .object(\n typeof value === 'object'\n ? Object.entries(value).reduce(\n (acc, [key, value]) => {\n if (typeof value === 'object') {\n acc[key] = yup\n .object({\n types: yup.string().optional(),\n source: yup.string().required(),\n module: yup.string().optional(),\n import: yup.string().required(),\n require: yup.string().required(),\n default: yup.string().required(),\n })\n .noUnknown(true);\n } else {\n acc[key] = yup\n .string()\n .matches(/^\\.\\/.*\\.json$/)\n .required();\n }\n\n return acc;\n },\n {} as Record<string, yup.SchemaOf<string> | yup.SchemaOf<Export>>\n )\n : undefined\n )\n .optional()\n ),\n});\n\ntype PackageJson = yup.Asserts<typeof packageJsonSchema>;\n\n/**\n * @description being a task to load the package.json starting from the current working directory\n * using a shallow find for the package.json and `fs` to read the file. If no package.json is found,\n * the process will throw with an appropriate error message.\n */\nconst loadPkg = async ({ cwd, logger }: { cwd: string; logger: Logger }): Promise<PackageJson> => {\n const pkgPath = await pkgUp({ cwd });\n\n if (!pkgPath) {\n throw new Error('Could not find a package.json in the current directory');\n }\n\n const buffer = await fse.readFile(pkgPath);\n\n const pkg = JSON.parse(buffer.toString());\n\n logger.debug('Loaded package.json:', os.EOL, pkg);\n\n return pkg;\n};\n\n/**\n * @description validate the package.json against a standardised schema using `yup`.\n * If the validation fails, the process will throw with an appropriate error message.\n */\nconst validatePkg = async ({ pkg }: { pkg: object }): Promise<PackageJson> => {\n try {\n return await packageJsonSchema.validate(pkg, {\n strict: true,\n });\n } catch (err) {\n if (err instanceof yup.ValidationError) {\n switch (err.type) {\n case 'required':\n if (err.path) {\n throw new Error(\n `'${err.path}' in 'package.json' is required as type '${chalk.magenta(\n yup.reach(packageJsonSchema, err.path).type\n )}'`\n );\n }\n break;\n /**\n * This will only be thrown if there are keys in the export map\n * that we don't expect so we can therefore make some assumptions\n */\n case 'noUnknown':\n if (err.path && err.params && 'unknown' in err.params) {\n throw new Error(\n `'${err.path}' in 'package.json' contains the unknown key ${chalk.magenta(\n err.params.unknown\n )}, for compatability only the following keys are allowed: ${chalk.magenta(\n \"['types', 'source', 'import', 'require', 'default']\"\n )}`\n );\n }\n break;\n default:\n if (err.path && err.params && 'type' in err.params && 'value' in err.params) {\n throw new Error(\n `'${err.path}' in 'package.json' must be of type '${chalk.magenta(\n err.params.type\n )}' (recieved '${chalk.magenta(typeof err.params.value)}')`\n );\n }\n }\n }\n\n throw err;\n }\n};\n\nexport type { PackageJson, Export };\nexport { loadPkg, validatePkg };\n"],"names":["yup","object","name","string","required","exports","lazy","value","Object","entries","reduce","acc","key","types","optional","source","module","import","require","default","noUnknown","matches","undefined","loadPkg","cwd","logger","pkgPath","pkgUp","Error","buffer","fse","readFile","pkg","JSON","parse","toString","debug","os","EOL"],"mappings":";;;;;;AAgB0BA,GAAIC,CAAAA,MAAM,CAAC;IACnCC,IAAMF,EAAAA,GAAAA,CAAIG,MAAM,EAAA,CAAGC,QAAQ,EAAA;IAC3BC,OAASL,EAAAA,GAAAA,CAAIM,IAAI,CAAC,CAACC,QACjBP,GACGC,CAAAA,MAAM,CACL,OAAOM,KAAAA,KAAU,WACbC,MAAOC,CAAAA,OAAO,CAACF,KAAOG,CAAAA,CAAAA,MAAM,CAC1B,CAACC,GAAAA,EAAK,CAACC,GAAAA,EAAKL,KAAM,CAAA,GAAA;YAChB,IAAI,OAAOA,UAAU,QAAU,EAAA;AAC7BI,gBAAAA,GAAG,CAACC,GAAAA,CAAI,GAAGZ,GAAAA,CACRC,MAAM,CAAC;oBACNY,KAAOb,EAAAA,GAAAA,CAAIG,MAAM,EAAA,CAAGW,Q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files.test.d.ts","sourceRoot":"","sources":["../../../src/utils/tests/compress-files.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/cloud-cli",
3
- "version": "5.12.0",
3
+ "version": "5.12.2",
4
4
  "description": "Commands to interact with the Strapi Cloud",
5
5
  "keywords": [
6
6
  "strapi",
@@ -31,7 +31,7 @@
31
31
  "main": "./dist/index.js",
32
32
  "module": "./dist/index.mjs",
33
33
  "source": "./src/index.ts",
34
- "types": "./dist/src/index.d.ts",
34
+ "types": "./dist/index.d.ts",
35
35
  "bin": "./bin/index.js",
36
36
  "files": [
37
37
  "./dist",
@@ -47,7 +47,7 @@
47
47
  "watch": "run -T rollup -c -w"
48
48
  },
49
49
  "dependencies": {
50
- "@strapi/utils": "5.12.0",
50
+ "@strapi/utils": "5.12.2",
51
51
  "axios": "1.8.2",
52
52
  "boxen": "5.1.2",
53
53
  "chalk": "4.1.2",
@@ -72,8 +72,8 @@
72
72
  "@types/cli-progress": "3.11.5",
73
73
  "@types/eventsource": "1.1.15",
74
74
  "@types/lodash": "^4.14.191",
75
- "eslint-config-custom": "5.12.0",
76
- "tsconfig": "5.12.0"
75
+ "eslint-config-custom": "5.12.2",
76
+ "tsconfig": "5.12.2"
77
77
  },
78
78
  "engines": {
79
79
  "node": ">=18.0.0 <=22.x.x",