@appthreat/atom-common

中文文档
1.1.0发布于 2025/12/29MITES Module零依赖构建来源已验证近 30 天下载 124万

Common library for the @appthreat/atom project.

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. API Reference
  4. File System Utilities
  5. Runtime Detection Utilities
  6. Configuration
  7. File Ignoring
  8. Custom Binary Paths
  9. License

atom-common

A lightweight Node.js utility library providing file system traversal helpers and runtime environment detectors.

Installation

npm install @appthreat/atom-common
# or
yarn add @appthreat/atom-common

Usage

import { getAllFiles, detectJava, detectRuby } from "@appthreat/atom-common";

// 1. Recursively get all .js files in a directory
const jsFiles = getAllFiles("./src", ".js");
console.log(jsFiles);

// 2. Check if runtimes are available
if (detectJava()) {
  console.log("Java is installed!");
}

if (detectRuby("3.4.x")) {
  console.log("Ruby 3.4.x is installed!");
}

API Reference

File System Utilities

getAllFiles(dir, extn, ...args)

Recursively scans a directory for files with a specific extension. It automatically ignores node_modules, dotfiles (hidden files), and specific directories defined in the configuration.

  • dir (string): The root directory to start scanning.
  • extn (string): The file extension to look for (e.g., .js, .ts).
  • ignore_node_modules (boolean): Defaults to true.

Returns: An array of file paths.

Runtime Detection Utilities

These functions spawn a child process to check version flags. They return true if the runtime is found and exits successfully, otherwise false.

  • detectJava(): Checks for java.
  • detectPhp(): Checks for php.
  • detectScala(): Checks for scala.
  • detectScalac(): Checks for the Scala compiler scalac.
  • detectRuby(versionNeeded): Checks for ruby.
    • versionNeeded (optional): A string (e.g., "3.4.7", "3.4.x", "4.0.x"). If provided, verifies the installed version matches.

Configuration

You can configure the behavior of the utilities using Environment Variables.

File Ignoring

VariableDescriptionDefault
ASTGEN_IGNORE_DIRSCSV string of directory names to ignore during scan.venv, docs, e2e, cypress, node_modules (and others)
ASTGEN_IGNORE_FILE_PATTERNRegex string for files to ignore.(three|\.d)\.(js|ts|jsx|tsx)$

Custom Binary Paths

If your binaries are not in the global system PATH, you can override the commands used for detection:

VariableDescriptionDefault
JAVA_CMDCommand to run Javajava
PHP_CMDCommand to run PHPphp
RUBY_CMDCommand to run Rubyruby
SCALA_CMDCommand to run Scalascala
SCALAC_CMDCommand to run Scalacscalac

License

MIT

版本与发布记录

@appthreat/atom-common 共发布 17 个版本,首次发布于 2025/05/13;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.1.0latest2025/12/2910 个月前
1.0.162025/12/1810 个月前
1.0.142025/12/1710 个月前
1.0.132025/12/0411 个月前
1.0.122025/11/1811 个月前
1.0.112025/09/231.1 年前

关于 @appthreat/atom-common 的常见问题

@appthreat/atom-common 是什么?

Common library for the @appthreat/atom project.

如何安装 @appthreat/atom-common?

在项目目录运行 npm install @appthreat/atom-common,或使用 pnpm add / yarn add / bun add。

@appthreat/atom-common 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/appthreat__atom-common 是否存在。

@appthreat/atom-common 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@appthreat/atom-common 可以商用吗?

@appthreat/atom-common 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@appthreat/atom-common 的下载量有多少?

根据 npm 官方下载统计,@appthreat/atom-common 在 2026/10/07 – 2026/11/05 这 30 天内被下载 1,239,977 次,日均约 41,333 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@appthreat/atom-common 还在维护吗?

最新版本 1.1.0 发布于 2025/12/29(10 个月前);至今共发布 17 个版本,其中过去 12 个月发布了 5 个;首次发布于 2025/05/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。