node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
import type { CLIContext, CloudApiService, TrackPayload } from '../types';
declare const trackEvent: (ctx: CLIContext, cloudApiService: CloudApiService, eventName: string, eventData: TrackPayload) => Promise<void>;
export { trackEvent };
//# sourceMappingURL=analytics.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/utils/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE1E,QAAA,MAAM,UAAU,QACT,UAAU,mBACE,eAAe,aACrB,MAAM,aACN,YAAY,kBAOxB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}

View File

@@ -0,0 +1,12 @@
'use strict';
const trackEvent = async (ctx, cloudApiService, eventName, eventData)=>{
try {
await cloudApiService.track(eventName, eventData);
} catch (e) {
ctx.logger.debug(`Failed to track ${eventName}`, e);
}
};
exports.trackEvent = trackEvent;
//# sourceMappingURL=analytics.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"analytics.js","sources":["../../src/utils/analytics.ts"],"sourcesContent":["import type { CLIContext, CloudApiService, TrackPayload } from '../types';\n\nconst trackEvent = async (\n ctx: CLIContext,\n cloudApiService: CloudApiService,\n eventName: string,\n eventData: TrackPayload\n) => {\n try {\n await cloudApiService.track(eventName, eventData);\n } catch (e) {\n ctx.logger.debug(`Failed to track ${eventName}`, e);\n }\n};\n\nexport { trackEvent };\n"],"names":["trackEvent","ctx","cloudApiService","eventName","eventData","track","e","logger","debug"],"mappings":";;AAEA,MAAMA,UAAa,GAAA,OACjBC,GACAC,EAAAA,eAAAA,EACAC,SACAC,EAAAA,SAAAA,GAAAA;IAEA,IAAI;QACF,MAAMF,eAAAA,CAAgBG,KAAK,CAACF,SAAWC,EAAAA,SAAAA,CAAAA;AACzC,KAAA,CAAE,OAAOE,CAAG,EAAA;QACVL,GAAIM,CAAAA,MAAM,CAACC,KAAK,CAAC,CAAC,gBAAgB,EAAEL,SAAU,CAAA,CAAC,EAAEG,CAAAA,CAAAA;AACnD;AACF;;;;"}

View File

@@ -0,0 +1,10 @@
const trackEvent = async (ctx, cloudApiService, eventName, eventData)=>{
try {
await cloudApiService.track(eventName, eventData);
} catch (e) {
ctx.logger.debug(`Failed to track ${eventName}`, e);
}
};
export { trackEvent };
//# sourceMappingURL=analytics.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"analytics.mjs","sources":["../../src/utils/analytics.ts"],"sourcesContent":["import type { CLIContext, CloudApiService, TrackPayload } from '../types';\n\nconst trackEvent = async (\n ctx: CLIContext,\n cloudApiService: CloudApiService,\n eventName: string,\n eventData: TrackPayload\n) => {\n try {\n await cloudApiService.track(eventName, eventData);\n } catch (e) {\n ctx.logger.debug(`Failed to track ${eventName}`, e);\n }\n};\n\nexport { trackEvent };\n"],"names":["trackEvent","ctx","cloudApiService","eventName","eventData","track","e","logger","debug"],"mappings":"AAEA,MAAMA,UAAa,GAAA,OACjBC,GACAC,EAAAA,eAAAA,EACAC,SACAC,EAAAA,SAAAA,GAAAA;IAEA,IAAI;QACF,MAAMF,eAAAA,CAAgBG,KAAK,CAACF,SAAWC,EAAAA,SAAAA,CAAAA;AACzC,KAAA,CAAE,OAAOE,CAAG,EAAA;QACVL,GAAIM,CAAAA,MAAM,CAACC,KAAK,CAAC,CAAC,gBAAgB,EAAEL,SAAU,CAAA,CAAC,EAAEG,CAAAA,CAAAA;AACnD;AACF;;;;"}

View File

@@ -0,0 +1,4 @@
declare const isIgnoredFile: (folderPath: string, file: string, ignorePatterns: string[]) => boolean;
declare const compressFilesToTar: (storagePath: string, folderToCompress: string, filename: string) => Promise<void>;
export { compressFilesToTar, isIgnoredFile };
//# sourceMappingURL=compress-files.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compress-files.d.ts","sourceRoot":"","sources":["../../src/utils/compress-files.ts"],"names":[],"mappings":"AAoBA,QAAA,MAAM,aAAa,eAAgB,MAAM,QAAQ,MAAM,kBAAkB,MAAM,EAAE,KAAG,OAgBnF,CAAC;AAwCF,QAAA,MAAM,kBAAkB,gBACT,MAAM,oBACD,MAAM,YACd,MAAM,KACf,QAAQ,IAAI,CAWd,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAC"}

View File

@@ -0,0 +1,102 @@
'use strict';
var fse = require('fs-extra');
var tar = require('tar');
var path = require('path');
var minimatch = require('minimatch');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var fse__namespace = /*#__PURE__*/_interopNamespaceDefault(fse);
var tar__namespace = /*#__PURE__*/_interopNamespaceDefault(tar);
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
const IGNORED_PATTERNS = [
'**/.git/**',
'**/node_modules/**',
'**/build/**',
'**/dist/**',
'**/.cache/**',
'**/.circleci/**',
'**/.github/**',
'**/.gitignore',
'**/.gitkeep',
'**/.gitlab-ci.yml',
'**/.idea/**',
'**/.vscode/**'
];
const isIgnoredFile = (folderPath, file, ignorePatterns)=>{
ignorePatterns.push(...IGNORED_PATTERNS);
const relativeFilePath = path__namespace.join(folderPath, file);
let isIgnored = false;
for (const pattern of ignorePatterns){
if (pattern.startsWith('!')) {
if (minimatch.minimatch(relativeFilePath, pattern.slice(1), {
matchBase: true,
dot: true
})) {
return false;
}
} else if (minimatch.minimatch(relativeFilePath, pattern, {
matchBase: true,
dot: true
})) {
if (path__namespace.basename(file) !== '.gitkeep') {
isIgnored = true;
}
}
}
return isIgnored;
};
const getFiles = async (dirPath, ignorePatterns = [], subfolder = '')=>{
const arrayOfFiles = [];
const entries = await fse__namespace.readdir(path__namespace.join(dirPath, subfolder));
for (const entry of entries){
const entryPathFromRoot = path__namespace.join(subfolder, entry);
const entryPath = path__namespace.relative(dirPath, entryPathFromRoot);
const isIgnored = isIgnoredFile(dirPath, entryPathFromRoot, ignorePatterns);
if (!isIgnored) {
if (fse__namespace.statSync(entryPath).isDirectory()) {
const subFiles = await getFiles(dirPath, ignorePatterns, entryPathFromRoot);
arrayOfFiles.push(...subFiles);
} else {
arrayOfFiles.push(entryPath);
}
}
}
return arrayOfFiles;
};
const readGitignore = async (folderPath)=>{
const gitignorePath = path__namespace.resolve(folderPath, '.gitignore');
const pathExist = await fse__namespace.pathExists(gitignorePath);
if (!pathExist) return [];
const gitignoreContent = await fse__namespace.readFile(gitignorePath, 'utf8');
return gitignoreContent.split(/\r?\n/).filter((line)=>Boolean(line.trim()) && !line.startsWith('#'));
};
const compressFilesToTar = async (storagePath, folderToCompress, filename)=>{
const ignorePatterns = await readGitignore(folderToCompress);
const filesToCompress = await getFiles(folderToCompress, ignorePatterns);
return tar__namespace.c({
gzip: true,
file: path__namespace.resolve(storagePath, filename)
}, filesToCompress);
};
exports.compressFilesToTar = compressFilesToTar;
exports.isIgnoredFile = isIgnoredFile;
//# sourceMappingURL=compress-files.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,78 @@
import * as fse from 'fs-extra';
import * as tar from 'tar';
import * as path from 'path';
import { minimatch } from 'minimatch';
const IGNORED_PATTERNS = [
'**/.git/**',
'**/node_modules/**',
'**/build/**',
'**/dist/**',
'**/.cache/**',
'**/.circleci/**',
'**/.github/**',
'**/.gitignore',
'**/.gitkeep',
'**/.gitlab-ci.yml',
'**/.idea/**',
'**/.vscode/**'
];
const isIgnoredFile = (folderPath, file, ignorePatterns)=>{
ignorePatterns.push(...IGNORED_PATTERNS);
const relativeFilePath = path.join(folderPath, file);
let isIgnored = false;
for (const pattern of ignorePatterns){
if (pattern.startsWith('!')) {
if (minimatch(relativeFilePath, pattern.slice(1), {
matchBase: true,
dot: true
})) {
return false;
}
} else if (minimatch(relativeFilePath, pattern, {
matchBase: true,
dot: true
})) {
if (path.basename(file) !== '.gitkeep') {
isIgnored = true;
}
}
}
return isIgnored;
};
const getFiles = async (dirPath, ignorePatterns = [], subfolder = '')=>{
const arrayOfFiles = [];
const entries = await fse.readdir(path.join(dirPath, subfolder));
for (const entry of entries){
const entryPathFromRoot = path.join(subfolder, entry);
const entryPath = path.relative(dirPath, entryPathFromRoot);
const isIgnored = isIgnoredFile(dirPath, entryPathFromRoot, ignorePatterns);
if (!isIgnored) {
if (fse.statSync(entryPath).isDirectory()) {
const subFiles = await getFiles(dirPath, ignorePatterns, entryPathFromRoot);
arrayOfFiles.push(...subFiles);
} else {
arrayOfFiles.push(entryPath);
}
}
}
return arrayOfFiles;
};
const readGitignore = async (folderPath)=>{
const gitignorePath = path.resolve(folderPath, '.gitignore');
const pathExist = await fse.pathExists(gitignorePath);
if (!pathExist) return [];
const gitignoreContent = await fse.readFile(gitignorePath, 'utf8');
return gitignoreContent.split(/\r?\n/).filter((line)=>Boolean(line.trim()) && !line.startsWith('#'));
};
const compressFilesToTar = async (storagePath, folderToCompress, filename)=>{
const ignorePatterns = await readGitignore(folderToCompress);
const filesToCompress = await getFiles(folderToCompress, ignorePatterns);
return tar.c({
gzip: true,
file: path.resolve(storagePath, filename)
}, filesToCompress);
};
export { compressFilesToTar, isIgnoredFile };
//# sourceMappingURL=compress-files.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
import type { CLIContext } from '../types';
import { LocalSave } from '../services/strapi-info-save';
declare function getLocalConfig(ctx: CLIContext): Promise<LocalSave | null>;
declare function getLocalProject(ctx: CLIContext): Promise<Omit<import("../types").ProjectInfo, "id">>;
export { getLocalConfig, getLocalProject };
//# sourceMappingURL=get-local-config.d.ts.map

View File

@@ -0,0 +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"}

View File

@@ -0,0 +1,37 @@
'use strict';
var chalk = require('chalk');
require('axios');
require('fs-extra');
require('os');
require('../config/api.js');
require('path');
require('xdg-app-paths');
var strapiInfoSave = require('../services/strapi-info-save.js');
require('jwks-rsa');
require('jsonwebtoken');
require('fast-safe-stringify');
require('ora');
require('cli-progress');
async function getLocalConfig(ctx) {
try {
return await strapiInfoSave.retrieve();
} catch (e) {
ctx.logger.debug('Failed to get project config', e);
ctx.logger.error('An error occurred while retrieving config data from your local project.');
return null;
}
}
async function getLocalProject(ctx) {
const localConfig = await getLocalConfig(ctx);
if (!localConfig || !localConfig.project) {
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.`);
process.exit(1);
}
return localConfig.project;
}
exports.getLocalConfig = getLocalConfig;
exports.getLocalProject = getLocalProject;
//# sourceMappingURL=get-local-config.js.map

View File

@@ -0,0 +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;;;;;"}

View File

@@ -0,0 +1,34 @@
import chalk from 'chalk';
import 'axios';
import 'fs-extra';
import 'os';
import '../config/api.mjs';
import 'path';
import 'xdg-app-paths';
import { retrieve } from '../services/strapi-info-save.mjs';
import 'jwks-rsa';
import 'jsonwebtoken';
import 'fast-safe-stringify';
import 'ora';
import 'cli-progress';
async function getLocalConfig(ctx) {
try {
return await retrieve();
} catch (e) {
ctx.logger.debug('Failed to get project config', e);
ctx.logger.error('An error occurred while retrieving config data from your local project.');
return null;
}
}
async function getLocalProject(ctx) {
const localConfig = await getLocalConfig(ctx);
if (!localConfig || !localConfig.project) {
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.`);
process.exit(1);
}
return localConfig.project;
}
export { getLocalConfig, getLocalProject };
//# sourceMappingURL=get-local-config.mjs.map

View File

@@ -0,0 +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;;;;"}

View File

@@ -0,0 +1,3 @@
declare const runAction: (name: string, action: (...args: any[]) => Promise<unknown>) => (...args: unknown[]) => void;
export { runAction };
//# sourceMappingURL=helpers.d.ts.map

View File

@@ -0,0 +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"}

View File

@@ -0,0 +1,33 @@
'use strict';
var chalk = require('chalk');
var fp = require('lodash/fp');
// TODO: Remove duplicated code by extracting to a shared package
const assertCwdContainsStrapiProject = (name)=>{
const logErrorAndExit = ()=>{
console.log(`You need to run ${chalk.yellow(`strapi ${name}`)} in a Strapi project. Make sure you are in the right directory.`);
process.exit(1);
};
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkgJSON = require(`${process.cwd()}/package.json`);
if (!fp.has('dependencies.@strapi/strapi', pkgJSON) && !fp.has('devDependencies.@strapi/strapi', pkgJSON)) {
logErrorAndExit();
}
} catch (err) {
logErrorAndExit();
}
};
const runAction = (name, action)=>(...args)=>{
assertCwdContainsStrapiProject(name);
Promise.resolve().then(()=>{
return action(...args);
}).catch((error)=>{
console.error(error);
process.exit(1);
});
};
exports.runAction = runAction;
//# sourceMappingURL=helpers.js.map

View File

@@ -0,0 +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;;;;"}

View File

@@ -0,0 +1,31 @@
import chalk from 'chalk';
import { has } from 'lodash/fp';
// TODO: Remove duplicated code by extracting to a shared package
const assertCwdContainsStrapiProject = (name)=>{
const logErrorAndExit = ()=>{
console.log(`You need to run ${chalk.yellow(`strapi ${name}`)} in a Strapi project. Make sure you are in the right directory.`);
process.exit(1);
};
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkgJSON = require(`${process.cwd()}/package.json`);
if (!has('dependencies.@strapi/strapi', pkgJSON) && !has('devDependencies.@strapi/strapi', pkgJSON)) {
logErrorAndExit();
}
} catch (err) {
logErrorAndExit();
}
};
const runAction = (name, action)=>(...args)=>{
assertCwdContainsStrapiProject(name);
Promise.resolve().then(()=>{
return action(...args);
}).catch((error)=>{
console.error(error);
process.exit(1);
});
};
export { runAction };
//# sourceMappingURL=helpers.mjs.map

View File

@@ -0,0 +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,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;;;;"}

View File

@@ -0,0 +1,121 @@
import * as yup from 'yup';
import { Logger } from '../services/logger';
interface Export {
types?: string;
source: string;
module?: string;
import?: string;
require?: string;
default: string;
}
declare const packageJsonSchema: import("yup/lib/object").OptionalObjectSchema<{
name: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
exports: import("yup/lib/Lazy").default<import("yup/lib/object").OptionalObjectSchema<Record<string, yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string> | yup.default<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}>, import("yup/lib/object").AssertsShape<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}>>>, Record<string, any>, import("yup/lib/object").TypeOfShape<Record<string, yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string> | yup.default<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}>, import("yup/lib/object").AssertsShape<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}>>>>>, any>;
}, Record<string, any>, import("yup/lib/object").TypeOfShape<{
name: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
exports: import("yup/lib/Lazy").default<import("yup/lib/object").OptionalObjectSchema<Record<string, yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string> | yup.default<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}>, import("yup/lib/object").AssertsShape<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}>>>, Record<string, any>, import("yup/lib/object").TypeOfShape<Record<string, yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string> | yup.default<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}>, import("yup/lib/object").AssertsShape<{
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
module: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
import: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
require: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
}>>>>>, any>;
}>>;
type PackageJson = yup.Asserts<typeof packageJsonSchema>;
/**
* @description being a task to load the package.json starting from the current working directory
* using a shallow find for the package.json and `fs` to read the file. If no package.json is found,
* the process will throw with an appropriate error message.
*/
declare const loadPkg: ({ cwd, logger }: {
cwd: string;
logger: Logger;
}) => Promise<PackageJson>;
/**
* @description validate the package.json against a standardised schema using `yup`.
* If the validation fails, the process will throw with an appropriate error message.
*/
declare const validatePkg: ({ pkg }: {
pkg: object;
}) => Promise<PackageJson>;
export type { PackageJson, Export };
export { loadPkg, validatePkg };
//# sourceMappingURL=pkg.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"pkg.d.ts","sourceRoot":"","sources":["../../src/utils/pkg.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,UAAU,MAAM;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCrB,CAAC;AAEH,KAAK,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEzD;;;;GAIG;AACH,QAAA,MAAM,OAAO,oBAA2B;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;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"}

View File

@@ -0,0 +1,65 @@
'use strict';
var fse = require('fs-extra');
var os = require('os');
var pkgUp = require('pkg-up');
var yup = require('yup');
require('chalk');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var fse__namespace = /*#__PURE__*/_interopNamespaceDefault(fse);
var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
yup__namespace.object({
name: yup__namespace.string().required(),
exports: yup__namespace.lazy((value)=>yup__namespace.object(typeof value === 'object' ? Object.entries(value).reduce((acc, [key, value])=>{
if (typeof value === 'object') {
acc[key] = yup__namespace.object({
types: yup__namespace.string().optional(),
source: yup__namespace.string().required(),
module: yup__namespace.string().optional(),
import: yup__namespace.string().required(),
require: yup__namespace.string().required(),
default: yup__namespace.string().required()
}).noUnknown(true);
} else {
acc[key] = yup__namespace.string().matches(/^\.\/.*\.json$/).required();
}
return acc;
}, {}) : undefined).optional())
});
/**
* @description being a task to load the package.json starting from the current working directory
* using a shallow find for the package.json and `fs` to read the file. If no package.json is found,
* the process will throw with an appropriate error message.
*/ const loadPkg = async ({ cwd, logger })=>{
const pkgPath = await pkgUp({
cwd
});
if (!pkgPath) {
throw new Error('Could not find a package.json in the current directory');
}
const buffer = await fse__namespace.readFile(pkgPath);
const pkg = JSON.parse(buffer.toString());
logger.debug('Loaded package.json:', os.EOL, pkg);
return pkg;
};
exports.loadPkg = loadPkg;
//# sourceMappingURL=pkg.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,43 @@
import * as fse from 'fs-extra';
import os from 'os';
import pkgUp from 'pkg-up';
import * as yup from 'yup';
import 'chalk';
yup.object({
name: yup.string().required(),
exports: yup.lazy((value)=>yup.object(typeof value === 'object' ? Object.entries(value).reduce((acc, [key, value])=>{
if (typeof value === 'object') {
acc[key] = yup.object({
types: yup.string().optional(),
source: yup.string().required(),
module: yup.string().optional(),
import: yup.string().required(),
require: yup.string().required(),
default: yup.string().required()
}).noUnknown(true);
} else {
acc[key] = yup.string().matches(/^\.\/.*\.json$/).required();
}
return acc;
}, {}) : undefined).optional())
});
/**
* @description being a task to load the package.json starting from the current working directory
* using a shallow find for the package.json and `fs` to read the file. If no package.json is found,
* the process will throw with an appropriate error message.
*/ const loadPkg = async ({ cwd, logger })=>{
const pkgPath = await pkgUp({
cwd
});
if (!pkgPath) {
throw new Error('Could not find a package.json in the current directory');
}
const buffer = await fse.readFile(pkgPath);
const pkg = JSON.parse(buffer.toString());
logger.debug('Loaded package.json:', os.EOL, pkg);
return pkg;
};
export { loadPkg };
//# sourceMappingURL=pkg.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=compress-files.test.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"compress-files.test.d.ts","sourceRoot":"","sources":["../../../src/utils/tests/compress-files.test.ts"],"names":[],"mappings":""}