New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@farmfe/cli

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@farmfe/cli - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

42

dist/index.js
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { cac } from 'cac';
import { resolveCore, getConfigPath, resolveCommandOptions, handleAsyncOperationErrors, preventExperimentalWarning } from './utils.js';
import { resolveCore, resolveCommandOptions, handleAsyncOperationErrors, preventExperimentalWarning, resolveCliConfig } from './utils.js';
import { COMMANDS } from './plugin/index.js';

@@ -20,2 +19,3 @@ const { version } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)).toString());

.alias('start')
.alias('dev')
.option('-l, --lazy', 'lazyCompilation')

@@ -28,8 +28,5 @@ .option('--host <host>', 'specify host')

.option('--strictPort', 'specified port is already in use, exit with error')
.action(async (root, options) => {
.action(async (rootPath, options) => {
const { root, configPath } = resolveCliConfig(rootPath, options);
const resolveOptions = resolveCommandOptions(options);
const configPath = getConfigPath(options.config);
if (root && !path.isAbsolute(root)) {
root = path.resolve(process.cwd(), root);
}
const defaultOptions = {

@@ -50,3 +47,3 @@ root,

cli
.command('build', 'compile the project in production mode')
.command('build [root]', 'compile the project in production mode')
.option('-o, --outDir <dir>', 'output directory')

@@ -60,5 +57,6 @@ .option('-i, --input <file>', 'input file path')

.option('--minify', 'code compression at build time')
.action(async (options) => {
const configPath = getConfigPath(options.config);
.action(async (rootPath, options) => {
const { root, configPath } = resolveCliConfig(rootPath, options);
const defaultOptions = {
root,
compilation: {

@@ -85,3 +83,3 @@ watch: options.watch,

cli
.command('watch', 'watch file change')
.command('watch [root]', 'watch file change')
.option('-o, --outDir <dir>', 'output directory')

@@ -94,5 +92,6 @@ .option('-i, --input <file>', 'input file path')

.option('--minify', 'code compression at build time')
.action(async (options) => {
const configPath = getConfigPath(options.config);
.action(async (rootPath, options) => {
const { root, configPath } = resolveCliConfig(rootPath, options);
const defaultOptions = {
root,
compilation: {

@@ -118,9 +117,10 @@ output: {

cli
.command('preview', 'compile the project in watch mode')
.command('preview [root]', 'compile the project in watch mode')
.option('--port <port>', 'specify port')
.option('--open', 'open browser on server preview start')
.action(async (options) => {
const configPath = getConfigPath(options.config);
.action(async (rootPath, options) => {
const { root, configPath } = resolveCliConfig(rootPath, options);
const resolveOptions = resolveCommandOptions(options);
const defaultOptions = {
root,
mode: options.mode,

@@ -137,9 +137,7 @@ server: resolveOptions,

.option('--recursive', 'Recursively search for node_modules directories and clean them')
.action(async (cleanPath, options) => {
const rootPath = cleanPath
? path.resolve(process.cwd(), cleanPath)
: process.cwd();
.action(async (rootPath, options) => {
const { root } = resolveCliConfig(rootPath, options);
const { clean } = await resolveCore();
try {
await clean(rootPath, options?.recursive);
await clean(root, options?.recursive);
}

@@ -149,3 +147,3 @@ catch (e) {

const logger = new Logger();
logger.error(`Failed to clean cache:\n${e.stack}`);
logger.error(`Failed to clean cache: \n ${e.stack}`);
process.exit(1);

@@ -152,0 +150,0 @@ }

@@ -106,4 +106,4 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';

}
export function getConfigPath(configPath) {
return path.join(process.cwd(), configPath ?? '');
export function getConfigPath(root, configPath) {
return path.resolve(root, configPath ?? '');
}

@@ -129,2 +129,15 @@ export async function handleAsyncOperationErrors(asyncOperation, errorMessage) {

}
export function resolveRootPath(rootPath = '') {
return rootPath && path.isAbsolute(rootPath)
? rootPath
: path.resolve(process.cwd(), rootPath);
}
export function resolveCliConfig(root, options) {
root = resolveRootPath(root);
const configPath = getConfigPath(root, options.config);
return {
root,
configPath
};
}
//# sourceMappingURL=utils.js.map
{
"name": "@farmfe/cli",
"version": "1.0.0",
"version": "1.0.1",
"description": "CLI of Farm",

@@ -46,4 +46,4 @@ "type": "module",

"@types/inquirer": "^9.0.3",
"@farmfe/cli": "1.0.0",
"@farmfe/core": "1.0.0"
"@farmfe/cli": "1.0.1",
"@farmfe/core": "1.1.0"
},

@@ -50,0 +50,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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