Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@omlet/cli

Package Overview
Dependencies
Maintainers
1
Versions
670
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@omlet/cli - npm Package Compare versions

Comparing version 0.0.1-0e7769.0 to 0.0.1-15878a-08161119.0

34

dist/node-src/analyzer.d.ts

@@ -0,1 +1,2 @@

import { AliasMap } from "./repoUtils";
export declare enum LogLevel {

@@ -20,8 +21,2 @@ Error = "error",

tagPatterns: [string, string][];
repo?: {
name?: string;
url?: string;
branch?: string;
scope?: string;
};
logLevel?: LogLevel;

@@ -31,2 +26,3 @@ verbose: boolean;

tsconfigPath?: string;
cliVersion: string;
}

@@ -65,2 +61,8 @@ interface ModuleId {

}
interface AnalysisStats {
num_of_components: number;
num_of_modules: number;
num_of_exports: number;
num_of_dependencies: number;
}
interface Module {

@@ -87,16 +89,16 @@ source_path: string;

}
interface AnalyzeResult {
components: Component[];
exports: Export[];
alias_map: AliasMap;
stats: AnalysisStats & {
duration_msec: number;
};
cli_version: string;
}
export declare function parse(projectRoot: string, options: ParseOptions): Promise<Module[]>;
export declare function analyze(projectRoot: string, options: AnalyzeOptions): Promise<{
data: {
repo: {
name?: string | undefined;
url?: string | undefined;
branch?: string | undefined;
scope?: string | undefined;
};
components: Component[];
exports: Export[];
};
data: AnalyzeResult;
url: string;
}>;
export {};

@@ -52,21 +52,4 @@ "use strict";

function getComponentId(sws) {
return `${sws.source.hash}-${getComponentName(sws)}`;
return `${sws.source.package_name}:${getComponentName(sws)}`;
}
const CHUNK_SIZE = 20;
function getComponentsCreatedDates(components, workspaceSlug, projectRoot) {
return __awaiter(this, void 0, void 0, function* () {
const previousComponentCreatedDates = yield getLatestComponentsCreatedDates(workspaceSlug);
const previousComponentCreatedDateMap = Object.fromEntries(previousComponentCreatedDates.map(c => [c.definitionId, c.createdAt]));
const componentCreatedDates = [];
for (let i = 0; i < components.length; i += CHUNK_SIZE) {
const componentChunk = components.slice(i, i + CHUNK_SIZE);
const dates = yield Promise.all(componentChunk.map(component => {
var _a;
return (_a = previousComponentCreatedDateMap[getComponentId(component.source)]) !== null && _a !== void 0 ? _a : (0, repoUtils_1.getFileCreated)(component.source.source.path, projectRoot);
}));
componentCreatedDates.push(...dates);
}
return componentCreatedDates;
});
}
function createGlobMatcher(patterns) {

@@ -91,8 +74,4 @@ if (patterns.length) {

}
function transformComponent(nativeComp, globMatchers, projectRoot, createdAt) {
function transformComponent(nativeComp, globMatchers) {
const sws = nativeComp.source;
let updatedAt;
if (nativeComp.source.source.mtype === "local") {
updatedAt = (0, repoUtils_1.getFileUpdated)(nativeComp.source.source.path, projectRoot);
}
const tags = [];

@@ -104,3 +83,3 @@ for (const [tag, globMatcher] of globMatchers) {

}
return (Object.assign(Object.assign({}, nativeComp), { id: getComponentId(sws), name: getComponentName(sws), package_name: sws.source.package_name, created_at: createdAt, updated_at: updatedAt, tags, dependencies: nativeComp.dependencies.map(transformDependency), reverse_dependencies: nativeComp.reverse_dependencies.map(transformDependency) }));
return (Object.assign(Object.assign({}, nativeComp), { id: getComponentId(sws), name: getComponentName(sws), package_name: sws.source.package_name, tags, dependencies: nativeComp.dependencies.map(transformDependency), reverse_dependencies: nativeComp.reverse_dependencies.map(transformDependency) }));
}

@@ -117,10 +96,14 @@ function parse(projectRoot, options) {

return __awaiter(this, void 0, void 0, function* () {
const extractedAliasMap = JSON.stringify(yield (0, repoUtils_1.extractAliasConfig)(projectRoot, { tsconfig: options.tsconfigPath }));
const startTime = performance.now();
const aliasMap = yield (0, repoUtils_1.extractAliasConfig)(projectRoot, { tsconfig: options.tsconfigPath });
const extractedAliasMap = JSON.stringify(aliasMap);
const result = JSON.parse((0, binding_1.analyze)(projectRoot, options.inputPatterns, options.ignorePatterns, options.verbose, options.logLevel, LOG_FILE_PATH, extractedAliasMap));
const componentCreatedDates = yield getComponentsCreatedDates(result.components, workspaceSlug, projectRoot);
const globMatchers = [["core", createGlobMatcher(options.corePatterns)]];
globMatchers.push(...options.tagPatterns.map(([tag, pattern]) => [tag, createGlobMatcher([pattern])]));
return {
components: result.components.map((c, index) => transformComponent(c, globMatchers, projectRoot, componentCreatedDates[index])),
exports: result.exports
components: result.components.map(c => transformComponent(c, globMatchers)),
exports: result.exports,
alias_map: aliasMap,
stats: Object.assign(Object.assign({}, result.stats), { duration_msec: Math.floor(performance.now() - startTime) }),
cli_version: options.cliVersion
};

@@ -168,32 +151,7 @@ });

}
function getLatestComponentsCreatedDates(workspaceSlug) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield apiRequest(`/api/workspaces/${workspaceSlug}/components/created`);
return data;
});
}
function analyze(projectRoot, options) {
var _a, _b, _c, _d;
var _e, _f, _g, _h;
return __awaiter(this, void 0, void 0, function* () {
console.log(`Running analysis on ${projectRoot}`);
const workspace = yield getDefaultWorkspace();
const repoInfo = yield (0, repoUtils_1.getRepoInfo)(projectRoot);
if (!options.repo) {
options.repo = {};
}
(_a = (_e = options.repo).scope) !== null && _a !== void 0 ? _a : (_e.scope = repoInfo === null || repoInfo === void 0 ? void 0 : repoInfo.scope);
(_b = (_f = options.repo).name) !== null && _b !== void 0 ? _b : (_f.name = repoInfo === null || repoInfo === void 0 ? void 0 : repoInfo.name);
(_c = (_g = options.repo).url) !== null && _c !== void 0 ? _c : (_g.url = repoInfo === null || repoInfo === void 0 ? void 0 : repoInfo.url);
(_d = (_h = options.repo).branch) !== null && _d !== void 0 ? _d : (_h.branch = repoInfo === null || repoInfo === void 0 ? void 0 : repoInfo.branch);
if (!options.repo.name || !options.repo.branch) {
throw new error_1.CliError("Repository name and current branch are required", {
context: {
repoInfo,
analyzeParams: options
}
});
}
console.log(`Running analysis on ${options.repo.name}@${options.repo.branch} (${projectRoot})`);
const result = yield runAnalysis(projectRoot, workspace.slug, options);
const analysisData = Object.assign(Object.assign({}, result), { repo: options.repo });
const analysisData = yield runAnalysis(projectRoot, workspace.slug, options);
if (options.output) {

@@ -200,0 +158,0 @@ console.log(`Writing results to ${options.output}`);

@@ -106,5 +106,2 @@ "use strict";

.requiredOption("-i, --input <glob-pattern>", "List of glob patterns for input files", accumulateValues)
.option("--repo-name <repo-name>", "Name of the repository <scope>/<name> (e.g. omlet/cli)")
.option("--repo-url <repo-url>", "URL of the repository")
.option("--current-branch <current-branch>", "Current branch in the repository")
.option("--ignore <glob-pattern>", "List of ignore patterns for skipping input files", accumulateValues, ["**/node_modules/**", "**/*.d.ts"])

@@ -118,3 +115,3 @@ .option("-c, --core <glob-pattern>", "List of core patterns to identify reusable components", accumulateValues, [])

.action((args) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c;
var _a;
try {

@@ -127,3 +124,2 @@ if (!(yield (0, auth_1.isAuthenticated)())) {

const tagPatterns = collectTagPatterns((_a = args.tag) !== null && _a !== void 0 ? _a : []);
const [repoScope, repoName] = (_c = (_b = args.repoName) === null || _b === void 0 ? void 0 : _b.split("/")) !== null && _c !== void 0 ? _c : [];
yield (0, analyzer_1.analyze)(args.root, {

@@ -134,12 +130,7 @@ inputPatterns: args.input,

tagPatterns,
repo: {
url: args.repoUrl,
scope: repoScope,
name: repoName,
branch: args.currentBranch
},
logLevel: args.logLevel,
verbose: args.verbose,
output: args.output,
tsconfigPath: args.tsconfigPath
tsconfigPath: args.tsconfigPath,
cliVersion: pkgInfo.version
});

@@ -146,0 +137,0 @@ }

{
"name": "@omlet/cli",
"version": "0.0.1-0e7769.0",
"version": "0.0.1-15878a-08161119.0",
"bin": {

@@ -5,0 +5,0 @@ "omlet": "bin/omlet"

{
"name": "@omlet/cli",
"version": "0.0.1-0e7769.0",
"version": "0.0.1-15878a-08161119.0",
"bin": {

@@ -68,8 +68,8 @@ "omlet": "bin/omlet"

"optionalDependencies": {
"@omlet/cli-darwin-arm64": "0.0.1-0e7769.0",
"@omlet/cli-darwin-x64": "0.0.1-0e7769.0",
"@omlet/cli-linux-x64-gnu": "0.0.1-0e7769.0",
"@omlet/cli-linux-x64-musl": "0.0.1-0e7769.0",
"@omlet/cli-linux-arm64-gnu": "0.0.1-0e7769.0",
"@omlet/cli-linux-arm64-musl": "0.0.1-0e7769.0"
"@omlet/cli-darwin-arm64": "0.0.1-15878a-08161119.0",
"@omlet/cli-darwin-x64": "0.0.1-15878a-08161119.0",
"@omlet/cli-linux-x64-gnu": "0.0.1-15878a-08161119.0",
"@omlet/cli-linux-x64-musl": "0.0.1-15878a-08161119.0",
"@omlet/cli-linux-arm64-gnu": "0.0.1-15878a-08161119.0",
"@omlet/cli-linux-arm64-musl": "0.0.1-15878a-08161119.0"
},

@@ -76,0 +76,0 @@ "dependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc