node_modules ignore

This commit is contained in:
oier committed 2025-05-08 23:43:47 +02:00
1 parent e19d52f172
commit 4574544c9f
65041 files changed
+10593536

No files matched your search

+4
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
+1
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"}
+12
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
+1
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;;;;"}
+10
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
+1
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;;;;"}
+4
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
@@ -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"}
+102
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
@@ -0,0 +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,eAAAA,CAAKC,IAAI,CAACN,UAAYC,EAAAA,IAAAA,CAAAA;AAC/C,IAAA,IAAIM,SAAY,GAAA,KAAA;IAChB,KAAK,MAAMC,WAAWN,cAAgB,CAAA;QACpC,IAAIM,OAAAA,CAAQC,UAAU,CAAC,GAAM,CAAA,EAAA;AAC3B,YAAA,IAAIC,mBAAUN,CAAAA,gBAAAA,EAAkBI,OAAQG,CAAAA,KAAK,CAAC,CAAI,CAAA,EAAA;gBAAEC,SAAW,EAAA,IAAA;gBAAMC,GAAK,EAAA;aAAS,CAAA,EAAA;gBACjF,OAAO,KAAA;AACT;SACK,MAAA,IAAIH,mBAAUN,CAAAA,gBAAAA,EAAkBI,OAAS,EAAA;YAAEI,SAAW,EAAA,IAAA;YAAMC,GAAK,EAAA;SAAS,CAAA,EAAA;AAC/E,YAAA,IAAIR,eAAKS,CAAAA,QAAQ,CAACb,IAAAA,CAAAA,KAAU,UAAY,EAAA;gBACtCM,SAAY,GAAA,IAAA;AACd;AACF;AACF;IACA,OAAOA,SAAAA;AACT;AAEA,MAAMQ,WAAW,OACfC,OAAAA,EACAd,iBAA2B,EAAE,EAC7Be,YAAoB,EAAE,GAAA;AAEtB,IAAA,MAAMC,eAAyB,EAAE;IACjC,MAAMC,OAAAA,GAAU,MAAMC,cAAIC,CAAAA,OAAO,CAAChB,eAAKC,CAAAA,IAAI,CAACU,OAASC,EAAAA,SAAAA,CAAAA,CAAAA;IAErD,KAAK,MAAMK,SAASH,OAAS,CAAA;AAC3B,QAAA,MAAMI,iBAAoBlB,GAAAA,eAAAA,CAAKC,IAAI,CAACW,SAAWK,EAAAA,KAAAA,CAAAA;AAC/C,QAAA,MAAME,SAAYnB,GAAAA,eAAAA,CAAKoB,QAAQ,CAACT,OAASO,EAAAA,iBAAAA,CAAAA;QACzC,MAAMhB,SAAAA,GAAYR,aAAciB,CAAAA,OAAAA,EAASO,iBAAmBrB,EAAAA,cAAAA,CAAAA;AAE5D,QAAA,IAAI,CAACK,SAAW,EAAA;AACd,YAAA,IAAIa,cAAIM,CAAAA,QAAQ,CAACF,SAAAA,CAAAA,CAAWG,WAAW,EAAI,EAAA;AACzC,gBAAA,MAAMC,QAAWLine truncated
+78
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
@@ -0,0 +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":";;;;;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,IAAAA,CAAKC,IAAI,CAACN,UAAYC,EAAAA,IAAAA,CAAAA;AAC/C,IAAA,IAAIM,SAAY,GAAA,KAAA;IAChB,KAAK,MAAMC,WAAWN,cAAgB,CAAA;QACpC,IAAIM,OAAAA,CAAQC,UAAU,CAAC,GAAM,CAAA,EAAA;AAC3B,YAAA,IAAIC,SAAUN,CAAAA,gBAAAA,EAAkBI,OAAQG,CAAAA,KAAK,CAAC,CAAI,CAAA,EAAA;gBAAEC,SAAW,EAAA,IAAA;gBAAMC,GAAK,EAAA;aAAS,CAAA,EAAA;gBACjF,OAAO,KAAA;AACT;SACK,MAAA,IAAIH,SAAUN,CAAAA,gBAAAA,EAAkBI,OAAS,EAAA;YAAEI,SAAW,EAAA,IAAA;YAAMC,GAAK,EAAA;SAAS,CAAA,EAAA;AAC/E,YAAA,IAAIR,IAAKS,CAAAA,QAAQ,CAACb,IAAAA,CAAAA,KAAU,UAAY,EAAA;gBACtCM,SAAY,GAAA,IAAA;AACd;AACF;AACF;IACA,OAAOA,SAAAA;AACT;AAEA,MAAMQ,WAAW,OACfC,OAAAA,EACAd,iBAA2B,EAAE,EAC7Be,YAAoB,EAAE,GAAA;AAEtB,IAAA,MAAMC,eAAyB,EAAE;IACjC,MAAMC,OAAAA,GAAU,MAAMC,GAAIC,CAAAA,OAAO,CAAChB,IAAKC,CAAAA,IAAI,CAACU,OAASC,EAAAA,SAAAA,CAAAA,CAAAA;IAErD,KAAK,MAAMK,SAASH,OAAS,CAAA;AAC3B,QAAA,MAAMI,iBAAoBlB,GAAAA,IAAAA,CAAKC,IAAI,CAACW,SAAWK,EAAAA,KAAAA,CAAAA;AAC/C,QAAA,MAAME,SAAYnB,GAAAA,IAAAA,CAAKoB,QAAQ,CAACT,OAASO,EAAAA,iBAAAA,CAAAA;QACzC,MAAMhB,SAAAA,GAAYR,aAAciB,CAAAA,OAAAA,EAASO,iBAAmBrB,EAAAA,cAAAA,CAAAA;AAE5D,QAAA,IAAI,CAACK,SAAW,EAAA;AACd,YAAA,IAAIa,GAAIM,CAAAA,QAAQ,CAACF,SAAAA,CAAAA,CAAWG,WAAW,EAAI,EAAA;AACzC,gBAAA,MAAMC,QAAW,GAAA,MAAMb,QAASC,CAAAA,Line truncated
@@ -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
@@ -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"}
+37
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
@@ -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;;;;;"}
+34
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
@@ -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;;;;"}
+3
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
+1
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"}
+33
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
+1
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;;;;"}
+31
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
+1
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;;;;"}
+121
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
+1
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"}
+65
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
+1
View File
@@ -0,0 +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,EAAAA,cAAAA,CAAIM,IAAI,CAAC,CAACC,QACjBP,cACGC,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,cAAAA,CACRC,MAAM,CAAC;oBACNY,Line truncated
+43
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
+1
View File
@@ -0,0 +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,CAALine truncated
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=compress-files.test.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"compress-files.test.d.ts","sourceRoot":"","sources":["../../../src/utils/tests/compress-files.test.ts"],"names":[],"mappings":""}