@strapi/cloud-cli 5.48.1 → 5.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/local.js +17 -10
- package/dist/config/local.js.map +1 -1
- package/dist/deploy-project/action.js +23 -16
- package/dist/deploy-project/action.js.map +1 -1
- package/dist/environment/link/action.js +7 -3
- package/dist/environment/link/action.js.map +1 -1
- package/dist/environment/list/action.js +5 -1
- package/dist/environment/list/action.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/link/action.js +7 -3
- package/dist/link/action.js.map +1 -1
- package/dist/login/action.js +9 -4
- package/dist/login/action.js.map +1 -1
- package/dist/package.json.js +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/services/build-logs.js +5 -1
- package/dist/services/build-logs.js.map +1 -1
- package/dist/services/cli-api.js +10 -4
- package/dist/services/cli-api.js.map +1 -1
- package/dist/services/logger.js +17 -11
- package/dist/services/logger.js.map +1 -1
- package/dist/services/notification.js +7 -2
- package/dist/services/notification.js.map +1 -1
- package/dist/services/strapi-info-save.js +13 -8
- package/dist/services/strapi-info-save.js.map +1 -1
- package/dist/services/token.js +8 -3
- package/dist/services/token.js.map +1 -1
- package/dist/utils/compress-files.js +5 -4
- package/dist/utils/compress-files.js.map +1 -1
- package/dist/utils/error-message-factories.js +9 -4
- package/dist/utils/error-message-factories.js.map +1 -1
- package/dist/utils/get-local-config.js +5 -1
- package/dist/utils/get-local-config.js.map +1 -1
- package/dist/utils/helpers.js +5 -1
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/pkg.js +10 -5
- package/dist/utils/pkg.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sources":["../../src/services/token.ts"],"sourcesContent":["import jwksClient, { type JwksClient, type SigningKey } from 'jwks-rsa';\nimport type { JwtHeader, VerifyErrors } from 'jsonwebtoken';\nimport jwt from 'jsonwebtoken';\nimport { getLocalConfig, saveLocalConfig } from '../config/local';\nimport type { CloudCliConfig, CLIContext } from '../types';\nimport { cloudApiFactory } from './cli-api';\n\nlet cliConfig: CloudCliConfig;\n\ninterface DecodedToken {\n [key: string]: any;\n}\n\nexport async function tokenServiceFactory({ logger }: { logger: CLIContext['logger'] }) {\n const cloudApiService = await cloudApiFactory({ logger });\n\n async function saveToken(str: string) {\n const appConfig = await getLocalConfig();\n\n if (!appConfig) {\n logger.error('There was a problem saving your token. Please try again.');\n return;\n }\n\n appConfig.token = str;\n\n try {\n await saveLocalConfig(appConfig);\n } catch (e: Error | unknown) {\n logger.debug(e);\n logger.error('There was a problem saving your token. Please try again.');\n }\n }\n\n async function retrieveToken() {\n const appConfig = await getLocalConfig();\n if (appConfig.token) {\n // check if token is still valid\n if (await isTokenValid(appConfig.token)) {\n return appConfig.token;\n }\n }\n return undefined;\n }\n\n async function validateToken(idToken: string, jwksUrl: string): Promise<void> {\n const client: JwksClient = jwksClient({\n jwksUri: jwksUrl,\n });\n\n // Get the Key from the JWKS using the token header's Key ID (kid)\n const getKey = (header: JwtHeader, callback: (e: Error | null, key?: string) => void) => {\n client.getSigningKey(header.kid, (e: Error | null, key?: SigningKey) => {\n if (e) {\n callback(e);\n } else if (key) {\n const publicKey = 'publicKey' in key ? key.publicKey : key.rsaPublicKey;\n callback(null, publicKey);\n } else {\n callback(new Error('Key not found'));\n }\n });\n };\n\n const decodedToken = jwt.decode(idToken, { complete: true }) as DecodedToken;\n if (!decodedToken) {\n if (typeof idToken === 'undefined' || idToken === '') {\n logger.warn('You need to be logged in to use this feature. Please log in and try again.');\n } else {\n logger.error(\n 'There seems to be a problem with your login information. Please try logging in again.'\n );\n }\n return Promise.reject(new Error('Invalid token'));\n }\n\n // Verify the JWT token signature using the JWKS Key\n return new Promise<void>((resolve, reject) => {\n jwt.verify(idToken, getKey, (err: VerifyErrors | null) => {\n if (err) {\n reject(err);\n }\n if (decodedToken.payload.exp < Math.floor(Date.now() / 1000)) {\n reject(new Error('Token is expired'));\n }\n resolve();\n });\n });\n }\n\n async function isTokenValid(token: string) {\n try {\n const config = await cloudApiService.config();\n\n cliConfig = config.data;\n if (token) {\n await validateToken(token, cliConfig.jwksUrl);\n return true;\n }\n return false;\n } catch (e) {\n logger.debug(e);\n return false;\n }\n }\n\n async function eraseToken() {\n const appConfig = await getLocalConfig();\n if (!appConfig) {\n return;\n }\n\n delete appConfig.token;\n\n try {\n await saveLocalConfig(appConfig);\n } catch (e: Error | unknown) {\n logger.debug(e);\n logger.error(\n 'There was an issue removing your login information. Please try logging out again.'\n );\n throw e;\n }\n }\n\n async function getValidToken(\n ctx: CLIContext,\n loginAction: (ctx: CLIContext) => Promise<boolean>\n ) {\n let token = await retrieveToken();\n\n while (!token || !(await isTokenValid(token))) {\n logger.log(\n token\n ? 'Oops! Your token seems expired or invalid. Please login again.'\n : \"We couldn't find a valid token. You need to be logged in to use this feature.\"\n );\n if (!(await loginAction(ctx))) return null;\n token = await retrieveToken();\n }\n\n return token;\n }\n\n return {\n saveToken,\n retrieveToken,\n validateToken,\n isTokenValid,\n eraseToken,\n getValidToken,\n };\n}\n"],"names":["cliConfig","tokenServiceFactory","logger","cloudApiService","cloudApiFactory","saveToken","str","appConfig","getLocalConfig","error","token","saveLocalConfig","e","debug","retrieveToken","isTokenValid","undefined","validateToken","idToken","jwksUrl","client","jwksClient","jwksUri","getKey","header","callback","getSigningKey","kid","key","publicKey","rsaPublicKey","Error","decodedToken","jwt","decode","complete","warn","Promise","reject","resolve","verify","err","payload","exp","Math","floor","Date","now","config","data","eraseToken","getValidToken","ctx","loginAction","log"],"mappings":"
|
|
1
|
+
{"version":3,"file":"token.js","sources":["../../src/services/token.ts"],"sourcesContent":["import jwksClient, { type JwksClient, type SigningKey } from 'jwks-rsa';\nimport type { JwtHeader, VerifyErrors } from 'jsonwebtoken';\nimport jwt from 'jsonwebtoken';\nimport { getLocalConfig, saveLocalConfig } from '../config/local';\nimport type { CloudCliConfig, CLIContext } from '../types';\nimport { cloudApiFactory } from './cli-api';\n\nlet cliConfig: CloudCliConfig;\n\ninterface DecodedToken {\n [key: string]: any;\n}\n\nexport async function tokenServiceFactory({ logger }: { logger: CLIContext['logger'] }) {\n const cloudApiService = await cloudApiFactory({ logger });\n\n async function saveToken(str: string) {\n const appConfig = await getLocalConfig();\n\n if (!appConfig) {\n logger.error('There was a problem saving your token. Please try again.');\n return;\n }\n\n appConfig.token = str;\n\n try {\n await saveLocalConfig(appConfig);\n } catch (e: Error | unknown) {\n logger.debug(e);\n logger.error('There was a problem saving your token. Please try again.');\n }\n }\n\n async function retrieveToken() {\n const appConfig = await getLocalConfig();\n if (appConfig.token) {\n // check if token is still valid\n if (await isTokenValid(appConfig.token)) {\n return appConfig.token;\n }\n }\n return undefined;\n }\n\n async function validateToken(idToken: string, jwksUrl: string): Promise<void> {\n const client: JwksClient = jwksClient({\n jwksUri: jwksUrl,\n });\n\n // Get the Key from the JWKS using the token header's Key ID (kid)\n const getKey = (header: JwtHeader, callback: (e: Error | null, key?: string) => void) => {\n client.getSigningKey(header.kid, (e: Error | null, key?: SigningKey) => {\n if (e) {\n callback(e);\n } else if (key) {\n const publicKey = 'publicKey' in key ? key.publicKey : key.rsaPublicKey;\n callback(null, publicKey);\n } else {\n callback(new Error('Key not found'));\n }\n });\n };\n\n const decodedToken = jwt.decode(idToken, { complete: true }) as DecodedToken;\n if (!decodedToken) {\n if (typeof idToken === 'undefined' || idToken === '') {\n logger.warn('You need to be logged in to use this feature. Please log in and try again.');\n } else {\n logger.error(\n 'There seems to be a problem with your login information. Please try logging in again.'\n );\n }\n return Promise.reject(new Error('Invalid token'));\n }\n\n // Verify the JWT token signature using the JWKS Key\n return new Promise<void>((resolve, reject) => {\n jwt.verify(idToken, getKey, (err: VerifyErrors | null) => {\n if (err) {\n reject(err);\n }\n if (decodedToken.payload.exp < Math.floor(Date.now() / 1000)) {\n reject(new Error('Token is expired'));\n }\n resolve();\n });\n });\n }\n\n async function isTokenValid(token: string) {\n try {\n const config = await cloudApiService.config();\n\n cliConfig = config.data;\n if (token) {\n await validateToken(token, cliConfig.jwksUrl);\n return true;\n }\n return false;\n } catch (e) {\n logger.debug(e);\n return false;\n }\n }\n\n async function eraseToken() {\n const appConfig = await getLocalConfig();\n if (!appConfig) {\n return;\n }\n\n delete appConfig.token;\n\n try {\n await saveLocalConfig(appConfig);\n } catch (e: Error | unknown) {\n logger.debug(e);\n logger.error(\n 'There was an issue removing your login information. Please try logging out again.'\n );\n throw e;\n }\n }\n\n async function getValidToken(\n ctx: CLIContext,\n loginAction: (ctx: CLIContext) => Promise<boolean>\n ) {\n let token = await retrieveToken();\n\n while (!token || !(await isTokenValid(token))) {\n logger.log(\n token\n ? 'Oops! Your token seems expired or invalid. Please login again.'\n : \"We couldn't find a valid token. You need to be logged in to use this feature.\"\n );\n if (!(await loginAction(ctx))) return null;\n token = await retrieveToken();\n }\n\n return token;\n }\n\n return {\n saveToken,\n retrieveToken,\n validateToken,\n isTokenValid,\n eraseToken,\n getValidToken,\n };\n}\n"],"names":["cliConfig","tokenServiceFactory","logger","cloudApiService","cloudApiFactory","saveToken","str","appConfig","getLocalConfig","error","token","saveLocalConfig","e","debug","retrieveToken","isTokenValid","undefined","validateToken","idToken","jwksUrl","client","jwksClient","jwksUri","getKey","header","callback","getSigningKey","kid","key","publicKey","rsaPublicKey","Error","decodedToken","jwt","decode","complete","warn","Promise","reject","resolve","verify","err","payload","exp","Math","floor","Date","now","config","data","eraseToken","getValidToken","ctx","loginAction","log"],"mappings":";;;;;;;;;;;;AAOA,IAAIA,SAAAA;AAMG,eAAeC,mBAAAA,CAAoB,EAAEC,MAAM,EAAoC,EAAA;IACpF,MAAMC,eAAAA,GAAkB,MAAMC,sBAAAA,CAAgB;AAAEF,QAAAA;AAAO,KAAA,CAAA;AAEvD,IAAA,eAAeG,UAAUC,GAAW,EAAA;AAClC,QAAA,MAAMC,YAAY,MAAMC,oBAAAA,EAAAA;AAExB,QAAA,IAAI,CAACD,SA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AAA;AACAS,QAAAA,aAAAA;AACAG,QAAAA,aAAAA;AACAF,QAAAA,YAAAA;AACAmC,QAAAA,UAAAA;AACAC,QAAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -5,7 +5,8 @@ var tar = require('tar');
|
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var minimatch = require('minimatch');
|
|
7
7
|
|
|
8
|
-
function
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
9
10
|
var n = Object.create(null);
|
|
10
11
|
if (e) {
|
|
11
12
|
Object.keys(e).forEach(function (k) {
|
|
@@ -22,9 +23,9 @@ function _interopNamespaceDefault(e) {
|
|
|
22
23
|
return Object.freeze(n);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
var fse__namespace = /*#__PURE__*/
|
|
26
|
-
var tar__namespace = /*#__PURE__*/
|
|
27
|
-
var path__namespace = /*#__PURE__*/
|
|
26
|
+
var fse__namespace = /*#__PURE__*/_interopNamespace(fse);
|
|
27
|
+
var tar__namespace = /*#__PURE__*/_interopNamespace(tar);
|
|
28
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
28
29
|
|
|
29
30
|
const IGNORED_PATTERNS = [
|
|
30
31
|
'**/.git/**',
|
|
@@ -1 +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 '**/data/uploads/**',\n '**/dist/**',\n '**/.cache/**',\n '**/.circleci/**',\n '**/.github/**',\n '**/.gitignore',\n '**/.gitkeep',\n '**/.gitlab-ci.yml',\n '**/.idea/**',\n '**/public/uploads/**',\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":"
|
|
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 '**/data/uploads/**',\n '**/dist/**',\n '**/.cache/**',\n '**/.circleci/**',\n '**/.github/**',\n '**/.gitignore',\n '**/.gitkeep',\n '**/.gitlab-ci.yml',\n '**/.idea/**',\n '**/public/uploads/**',\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,gBAAAA,GAAmB;AACvB,IAAA,YAAA;AACA,IAAA,oBAAA;AACA,IAAA,aAAA;AACA,IAAA,oBAAA;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,sBAAA;AACA,IAAA;AACD,CAA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,gBAAAA,EACAC,QAAAA,GAAAA;IAEA,MAAM1C,cAAAA,GAAiB,MAAM2B,aAAAA,CAAcc,gBAAAA,CAAAA;IAC3C,MAAME,eAAAA,GAAkB,MAAM9B,QAAAA,CAAS4B,gBAAAA,EAAkBzC,cAAAA,CAAAA;IAEzD,OAAO4C,cAAAA,CAAIC,CAAC,CACV;QACEC,IAAAA,EAAM,IAAA;QACN/C,IAAAA,EAAMI,eAAAA,CAAK0B,OAAO,CAACW,WAAAA,EAAaE,QAAAA;KAClC,EACAC,eAAAA,CAAAA;AAEJ;;;;;"}
|
|
@@ -4,15 +4,20 @@ var chalk = require('chalk');
|
|
|
4
4
|
var boxen = require('boxen');
|
|
5
5
|
var api = require('../config/api.js');
|
|
6
6
|
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
10
|
+
var boxen__default = /*#__PURE__*/_interopDefault(boxen);
|
|
11
|
+
|
|
7
12
|
const environmentErrorMessageFactory = ({ projectName, firstLine, secondLine })=>{
|
|
8
13
|
return [
|
|
9
|
-
|
|
14
|
+
chalk__default.default.yellow(firstLine),
|
|
10
15
|
'',
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
chalk__default.default.cyan(secondLine),
|
|
17
|
+
chalk__default.default.blue(' → ') + chalk__default.default.blue.underline(`${api.apiConfig.dashboardBaseUrl}/projects/${projectName}`)
|
|
13
18
|
].join('\n');
|
|
14
19
|
};
|
|
15
|
-
const environmentCreationErrorFactory = (environmentErrorMessage)=>
|
|
20
|
+
const environmentCreationErrorFactory = (environmentErrorMessage)=>boxen__default.default(environmentErrorMessage, {
|
|
16
21
|
padding: 1,
|
|
17
22
|
margin: 1,
|
|
18
23
|
borderStyle: 'round',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-message-factories.js","sources":["../../src/utils/error-message-factories.ts"],"sourcesContent":["import chalk from 'chalk';\nimport boxen from 'boxen';\nimport { apiConfig } from '../config/api';\n\ntype EnvironmentErrorMessage = {\n projectName: string;\n firstLine: string;\n secondLine: string;\n};\n\nexport const environmentErrorMessageFactory = ({\n projectName,\n firstLine,\n secondLine,\n}: EnvironmentErrorMessage) => {\n return [\n chalk.yellow(firstLine),\n '',\n chalk.cyan(secondLine),\n chalk.blue(' → ') +\n chalk.blue.underline(`${apiConfig.dashboardBaseUrl}/projects/${projectName}`),\n ].join('\\n');\n};\n\nexport const environmentCreationErrorFactory = (environmentErrorMessage: string) =>\n boxen(environmentErrorMessage, {\n padding: 1,\n margin: 1,\n borderStyle: 'round',\n borderColor: 'white',\n titleAlignment: 'left',\n });\n"],"names":["environmentErrorMessageFactory","projectName","firstLine","secondLine","chalk","yellow","cyan","blue","underline","apiConfig","dashboardBaseUrl","join","environmentCreationErrorFactory","environmentErrorMessage","boxen","padding","margin","borderStyle","borderColor","titleAlignment"],"mappings":"
|
|
1
|
+
{"version":3,"file":"error-message-factories.js","sources":["../../src/utils/error-message-factories.ts"],"sourcesContent":["import chalk from 'chalk';\nimport boxen from 'boxen';\nimport { apiConfig } from '../config/api';\n\ntype EnvironmentErrorMessage = {\n projectName: string;\n firstLine: string;\n secondLine: string;\n};\n\nexport const environmentErrorMessageFactory = ({\n projectName,\n firstLine,\n secondLine,\n}: EnvironmentErrorMessage) => {\n return [\n chalk.yellow(firstLine),\n '',\n chalk.cyan(secondLine),\n chalk.blue(' → ') +\n chalk.blue.underline(`${apiConfig.dashboardBaseUrl}/projects/${projectName}`),\n ].join('\\n');\n};\n\nexport const environmentCreationErrorFactory = (environmentErrorMessage: string) =>\n boxen(environmentErrorMessage, {\n padding: 1,\n margin: 1,\n borderStyle: 'round',\n borderColor: 'white',\n titleAlignment: 'left',\n });\n"],"names":["environmentErrorMessageFactory","projectName","firstLine","secondLine","chalk","yellow","cyan","blue","underline","apiConfig","dashboardBaseUrl","join","environmentCreationErrorFactory","environmentErrorMessage","boxen","padding","margin","borderStyle","borderColor","titleAlignment"],"mappings":";;;;;;;;;;;AAUO,MAAMA,iCAAiC,CAAC,EAC7CC,WAAW,EACXC,SAAS,EACTC,UAAU,EACc,GAAA;IACxB,OAAO;AACLC,QAAAA,sBAAAA,CAAMC,MAAM,CAACH,SAAAA,CAAAA;AACb,QAAA,EAAA;AACAE,QAAAA,sBAAAA,CAAME,IAAI,CAACH,UAAAA,CAAAA;AACXC,QAAAA,sBAAAA,CAAMG,IAAI,CAAC,MAAA,CAAA,GACTH,sBAAAA,CAAMG,IAAI,CAACC,SAAS,CAAC,CAAA,EAAGC,aAAAA,CAAUC,gBAAgB,CAAC,UAAU,EAAET,WAAAA,CAAAA,CAAa;AAC/E,KAAA,CAACU,IAAI,CAAC,IAAA,CAAA;AACT;AAEO,MAAMC,+BAAAA,GAAkC,CAACC,uBAAAA,GAC9CC,uBAAMD,uBAAAA,EAAyB;QAC7BE,OAAAA,EAAS,CAAA;QACTC,MAAAA,EAAQ,CAAA;QACRC,WAAAA,EAAa,OAAA;QACbC,WAAAA,EAAa,OAAA;QACbC,cAAAA,EAAgB;KAClB;;;;;"}
|
|
@@ -14,6 +14,10 @@ require('fast-safe-stringify');
|
|
|
14
14
|
require('ora');
|
|
15
15
|
require('cli-progress');
|
|
16
16
|
|
|
17
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
|
|
19
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
20
|
+
|
|
17
21
|
async function getLocalConfig(ctx) {
|
|
18
22
|
try {
|
|
19
23
|
return await strapiInfoSave.retrieve();
|
|
@@ -26,7 +30,7 @@ async function getLocalConfig(ctx) {
|
|
|
26
30
|
async function getLocalProject(ctx) {
|
|
27
31
|
const localConfig = await getLocalConfig(ctx);
|
|
28
32
|
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 ${
|
|
33
|
+
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__default.default.cyan('link')} command.`);
|
|
30
34
|
process.exit(1);
|
|
31
35
|
}
|
|
32
36
|
return localConfig.project;
|
|
@@ -1 +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":"
|
|
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,IAAA,CAAA,CAAE,OAAOC,CAAAA,EAAG;AACVF,QAAAA,GAAAA,CAAIG,MAAM,CAACC,KAAK,CAAC,8BAAA,EAAgCF,CAAAA,CAAAA;QACjDF,GAAAA,CAAIG,MAAM,CAACE,KAAK,CAAC,yEAAA,CAAA;QACjB,OAAO,IAAA;AACT,IAAA;AACF;AAEA,eAAeC,gBAAgBN,GAAe,EAAA;IAC5C,MAAMO,WAAAA,GAAc,MAAMR,cAAAA,CAAeC,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,sBAAAA,CAAMC,IAAI,CAC1I,MAAA,CAAA,CACA,SAAS,CAAC,CAAA;AAEdC,QAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,IAAA;AACA,IAAA,OAAON,YAAYC,OAAO;AAC5B;;;;;"}
|
package/dist/utils/helpers.js
CHANGED
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
var chalk = require('chalk');
|
|
4
4
|
var fp = require('lodash/fp');
|
|
5
5
|
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
9
|
+
|
|
6
10
|
// TODO: Remove duplicated code by extracting to a shared package
|
|
7
11
|
const assertCwdContainsStrapiProject = (name)=>{
|
|
8
12
|
const logErrorAndExit = ()=>{
|
|
9
|
-
console.log(`You need to run ${
|
|
13
|
+
console.log(`You need to run ${chalk__default.default.yellow(`strapi ${name}`)} in a Strapi project. Make sure you are in the right directory.`);
|
|
10
14
|
process.exit(1);
|
|
11
15
|
};
|
|
12
16
|
try {
|
|
@@ -1 +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":"
|
|
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,eAAAA,GAAkB,IAAA;AACtBC,QAAAA,OAAAA,CAAQC,GAAG,CACT,CAAC,gBAAgB,EAAEC,sBAAAA,CAAMC,MAAM,CAC7B,CAAC,OAAO,EAAEL,IAAAA,CAAAA,CAAM,CAAA,CAChB,+DAA+D,CAAC,CAAA;AAEpEM,QAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,IAAA,CAAA;IAEA,IAAI;;AAEF,QAAA,MAAMC,UAAUC,OAAAA,CAAQ,CAAA,EAAGH,QAAQI,GAAG,EAAA,CAAG,aAAa,CAAC,CAAA;AACvD,QAAA,IACE,CAACC,MAAAA,CAAI,6BAAA,EAA+BH,YACpC,CAACG,MAAAA,CAAI,kCAAkCH,OAAAA,CAAAA,EACvC;AACAP,YAAAA,eAAAA,EAAAA;AACF,QAAA;AACF,IAAA,CAAA,CAAE,OAAOW,GAAAA,EAAK;AACZX,QAAAA,eAAAA,EAAAA;AACF,IAAA;AACF,CAAA;AAEA,MAAMY,SAAAA,GACJ,CAACb,IAAAA,EAAcc,MAAAA,GACf,CAAC,GAAGC,IAAAA,GAAAA;QACFhB,8BAAAA,CAA+BC,IAAAA,CAAAA;QAE/BgB,OAAAA,CAAQC,OAAO,EAAA,CACZC,IAAI,CAAC,IAAA;AACJ,YAAA,OAAOJ,MAAAA,CAAAA,GAAUC,IAAAA,CAAAA;QACnB,CAAA,CAAA,CACCI,KAAK,CAAC,CAACC,KAAAA,GAAAA;AACNlB,YAAAA,OAAAA,CAAQkB,KAAK,CAACA,KAAAA,CAAAA;AACdd,YAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,QAAA,CAAA,CAAA;AACJ,IAAA;;;;"}
|
package/dist/utils/pkg.js
CHANGED
|
@@ -6,7 +6,10 @@ var pkgUp = require('pkg-up');
|
|
|
6
6
|
var yup = require('yup');
|
|
7
7
|
require('chalk');
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
10
13
|
var n = Object.create(null);
|
|
11
14
|
if (e) {
|
|
12
15
|
Object.keys(e).forEach(function (k) {
|
|
@@ -23,8 +26,10 @@ function _interopNamespaceDefault(e) {
|
|
|
23
26
|
return Object.freeze(n);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
var fse__namespace = /*#__PURE__*/
|
|
27
|
-
var
|
|
29
|
+
var fse__namespace = /*#__PURE__*/_interopNamespace(fse);
|
|
30
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
31
|
+
var pkgUp__default = /*#__PURE__*/_interopDefault(pkgUp);
|
|
32
|
+
var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
|
|
28
33
|
|
|
29
34
|
yup__namespace.object({
|
|
30
35
|
name: yup__namespace.string().required(),
|
|
@@ -49,7 +54,7 @@ yup__namespace.object({
|
|
|
49
54
|
* using a shallow find for the package.json and `fs` to read the file. If no package.json is found,
|
|
50
55
|
* the process will throw with an appropriate error message.
|
|
51
56
|
*/ const loadPkg = async ({ cwd, logger })=>{
|
|
52
|
-
const pkgPath = await
|
|
57
|
+
const pkgPath = await pkgUp__default.default({
|
|
53
58
|
cwd
|
|
54
59
|
});
|
|
55
60
|
if (!pkgPath) {
|
|
@@ -57,7 +62,7 @@ yup__namespace.object({
|
|
|
57
62
|
}
|
|
58
63
|
const buffer = await fse__namespace.readFile(pkgPath);
|
|
59
64
|
const pkg = JSON.parse(buffer.toString());
|
|
60
|
-
logger.debug('Loaded package.json:',
|
|
65
|
+
logger.debug('Loaded package.json:', os__default.default.EOL, pkg);
|
|
61
66
|
return pkg;
|
|
62
67
|
};
|
|
63
68
|
|
package/dist/utils/pkg.js.map
CHANGED
|
@@ -1 +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 compatibility 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 )}' (received '${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":"
|
|
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 compatibility 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 )}' (received '${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,cAAAA,CAAIC,MAAM,CAAC;IACnCC,IAAAA,EAAMF,cAAAA,CAAIG,MAAM,EAAA,CAAGC,QAAQ,EAAA;IAC3BC,OAAAA,EAASL,cAAAA,CAAIM,IAAI,CAAC,CAACC,QACjBP,cAAAA,CACGC,MAAM,CACL,OAAOM,KAAAA,KAAU,WACbC,MAAAA,CAAOC,OAAO,CAACF,KAAAA,CAAAA,CAAOG,MAAM,CAC1B,CAACC,GAAAA,EAAK,CAACC,GAAAA,EAAKL,KAAAA,CAAM,GAAA;YAChB,IAAI,OAAOA,UAAU,QAAA,EAAU;AAC7BI,gBAAAA,GAAG,CAACC,GAAAA,CAAI,GAAGZ,cAAAA,CACRC,MAAM,CAAC;oBACNY,KAAAA,EAAOb,cAAAA,CAAIG,MAAM,EAAA,CAAGW,QAAQ,EAAA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 -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/cloud-cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.49.0",
|
|
4
4
|
"description": "Commands to interact with the Strapi Cloud",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"watch": "run -T rollup -c -w"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@strapi/utils": "5.
|
|
51
|
+
"@strapi/utils": "5.49.0",
|
|
52
52
|
"axios": "1.18.0",
|
|
53
53
|
"boxen": "5.1.2",
|
|
54
54
|
"chalk": "4.1.2",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"open": "8.4.2",
|
|
66
66
|
"ora": "5.4.1",
|
|
67
67
|
"pkg-up": "3.1.0",
|
|
68
|
-
"tar": "7.5.
|
|
68
|
+
"tar": "7.5.16",
|
|
69
69
|
"xdg-app-paths": "8.3.0",
|
|
70
70
|
"yup": "0.32.9"
|
|
71
71
|
},
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"@types/cli-progress": "3.11.5",
|
|
74
74
|
"@types/eventsource": "1.1.15",
|
|
75
75
|
"@types/lodash": "^4.14.191",
|
|
76
|
-
"eslint-config-custom": "5.
|
|
77
|
-
"tsconfig": "5.
|
|
76
|
+
"eslint-config-custom": "5.49.0",
|
|
77
|
+
"tsconfig": "5.49.0"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=20.0.0 <=26.x.x",
|