New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@scaffit/core

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scaffit/core

Core utilities for Scaffit - Framework detection, AST manipulation, file operations, and scaffold execution

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

@scaffit/core

Core utilities for Scaffit - Framework detection, AST manipulation, file operations, and scaffold execution.

Features

  • Framework Detection: Automatically detect Next.js, React, Vue, Angular, Svelte, Express, Fastify, Node.js
  • AST Engine: Parse, modify, and generate JavaScript/TypeScript code
  • File Operations: Safe file reading/writing with project detection
  • Template Engine: Variable replacement and conditional rendering
  • Scaffold Executor: Common installation logic and dependency management
  • Validation: Zod-based configuration validation

Usage

import { FileOperations, ASTEngine, ScaffoldExecutor } from '@scaffit/core';

// Detect project framework
const framework = FileOperations.detectFramework('./my-project');
const projectInfo = FileOperations.detectProject('./my-project');

// Parse and modify files
const ast = ASTEngine.parseFile('./src/index.ts');
ASTEngine.addImport('./src/index.ts', 'react', ['useState']);

// Execute scaffold
const result = await ScaffoldExecutor.executeScaffold(scaffold, config, './my-project');

API

FileOperations

  • detectFramework(rootDir) - Detect project framework (Next.js, React, Vue, Angular, Svelte, Express, Fastify, Node.js)
  • detectProject(rootDir) - Detect framework and configuration
  • readFile(filePath) - Safely read file
  • writeFile(filePath, content) - Safely write file
  • addDependency(rootDir, name, version, isDev) - Add package dependency
  • addScript(rootDir, name, command) - Add npm script
  • getFrameworkConfigPaths(framework) - Get framework-specific directory paths
  • getFrameworkExtensions(framework) - Get framework-specific file extensions
  • getFrameworkDependencies(framework) - Get recommended dependencies for framework

ASTEngine

  • parseFile(filePath) - Parse JS/TS to AST
  • addImport(filePath, source, specifiers) - Add import statement
  • addExport(filePath, name, value) - Add export statement
  • addFunction(filePath, name, params, body) - Add function
  • applyModifications(filePath, modifications) - Apply multiple changes

TemplateEngine

  • renderTemplate(template, variables) - Simple variable replacement
  • renderTemplateWithConditionals(template, variables) - With if/unless blocks
  • generateFileContent(templatePath, variables) - Generate file content

ScaffoldExecutor

  • executeScaffold(scaffold, config, projectRoot) - Run scaffold installation
  • getScaffoldPreview(scaffold, config, projectRoot) - Preview changes
  • createFileFromTemplate(filePath, templateName, variables) - Create file
  • installDependencies(projectRoot, packageManager) - Install deps

Keywords

scaffolding

FAQs

Package last updated on 23 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts