
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
create-djangular-app
Advanced tools
一个类似
create-react-app的 Angular 项目脚手架工具,快速创建干净、规范的 Angular 项目。
# 方式1:使用 npx(自动下载,会提示确认)
npx create-djangular-app my-app
# 方式2:使用 npx -y(跳过确认提示)
npx -y create-djangular-app my-app
# 方式3:全局安装后使用(一劳永逸,无提示)
npm install -g create-djangular-app
create-djangular-app my-app
cd my-app
npm install
npm start
打开浏览器访问 http://localhost:4200/ 🎉
运行命令后,会出现交互式配置界面:
npx create-djangular-app my-angular-app
# 回答配置问题
? 请输入项目名称: my-angular-app
? 是否启用 TypeScript 严格模式? Yes
? 选择 CSS 预处理器: SCSS (推荐)
? 是否启用路由? Yes
? 是否启用单元测试? Yes
? 是否启用 E2E 测试? No
? 选择代码规范工具: ESLint (推荐)
? 选择包管理器: npm
# 项目创建完成后,按提示操作
✨ 项目创建成功!
下一步:
cd my-angular-app
npm install
npm start
# 提示:生成的项目默认名称为 "My Angular App"
# 你可以在以下文件中修改项目名称:
# - package.json (name 字段)
# - src/index.html (title 标签)
# - src/app/app.component.ts (title 属性)
# - README.md (标题)
| 选项 | 说明 | 推荐 |
|---|---|---|
| TypeScript 严格模式 | 提供更好的类型安全 | ✅ 启用 |
| CSS 预处理器 | SCSS / CSS / Less | SCSS |
| 路由 | Angular Router | ✅ 启用 |
| 单元测试 | Jasmine + Karma | ✅ 启用 |
| E2E 测试 | 端到端测试 | 按需选择 |
| 代码规范工具 | ESLint | ✅ 启用 |
| 包管理器 | npm / yarn / pnpm | npm |
# 跳过 Git 初始化
npx create-djangular-app my-app --skip-git
# 查看版本
npx create-djangular-app --version
# 查看帮助
npx create-djangular-app --help
my-app/
├── src/
│ ├── app/
│ │ ├── core/ # 核心模块
│ │ │ ├── guards/ # 路由守卫
│ │ │ ├── interceptors/ # HTTP拦截器
│ │ │ └── services/ # 核心服务
│ │ │ ├── loading.service.ts
│ │ │ └── toast.service.ts
│ │ ├── shared/ # 共享模块
│ │ │ ├── components/ # 通用组件
│ │ │ ├── directives/ # 指令
│ │ │ └── pipes/ # 管道
│ │ ├── features/ # 功能模块
│ │ │ ├── welcome/ # 欢迎页面
│ │ │ └── settings/ # 设置页面
│ │ ├── app.component.* # 根组件
│ │ ├── app.routes.ts # 路由配置
│ │ └── app.config.ts # 应用配置
│ ├── assets/ # 静态资源
│ ├── environments/ # 环境配置
│ ├── styles/ # 全局样式
│ │ ├── _variables.scss # SCSS变量
│ │ ├── _mixins.scss # SCSS混入
│ │ └── styles.scss # 主样式文件
│ ├── index.html # HTML入口
│ └── main.ts # TypeScript入口
├── .vscode/ # VSCode配置
├── .editorconfig # 编辑器配置
├── .eslintrc.json # ESLint配置
├── .gitignore # Git忽略文件
├── .prettierrc # Prettier配置
├── angular.json # Angular配置
├── package.json # 依赖配置
├── tsconfig.json # TypeScript配置
└── README.md # 项目文档
import { LoadingService } from '@core/services/loading.service';
constructor(private loading: LoadingService) {}
doSomething() {
this.loading.show();
// 异步操作
this.loading.hide();
}
import { ToastService } from '@core/services/toast.service';
constructor(private toast: ToastService) {}
showMessage() {
this.toast.success('操作成功!');
this.toast.error('操作失败!');
this.toast.warning('警告信息');
this.toast.info('提示信息');
}
已在 app.config.ts 中配置,自动显示/隐藏 loading,可扩展添加认证 token、错误处理等。
// 在 app.routes.ts 中使用
import { authGuard } from '@core/guards/auth.guard';
{
path: 'protected',
canActivate: [authGuard],
component: ProtectedComponent
}
/welcome)/settings)项目配置了路径别名,方便导入:
import { LoadingService } from '@core/services/loading.service';
import { MyComponent } from '@shared/components/my-component';
import { MyFeature } from '@features/my-feature/my-feature.component';
import { environment } from '@environments/environment';
# 启动开发服务器
npm start
# 构建生产版本
npm run build
# 运行测试
npm test
# 代码检查
npm run lint
# 格式化代码
npm run format
ng generate component features/my-feature
# 或简写
ng g c features/my-feature
ng generate service core/services/my-service
# 或简写
ng g s core/services/my-service
编辑 src/app/app.routes.ts:
{
path: 'my-feature',
loadComponent: () => import('./features/my-feature/my-feature.component')
.then(m => m.MyFeatureComponent)
}
项目包含两个环境配置:
environment.development.ts - 开发环境environment.ts - 生产环境使用方式:
import { environment } from '@environments/environment';
const apiUrl = environment.apiUrl;
| 技术 | 版本 | 说明 |
|---|---|---|
| Angular | 17+ | 最新稳定版,Standalone Components |
| TypeScript | 5.2+ | 类型系统、装饰器支持 |
| RxJS | 7.8+ | 响应式编程 |
| SCSS | - | CSS 预处理器 |
| ESLint | 8+ | 代码检查 |
| Prettier | 3+ | 代码格式化 |
@app/*、@core/*、@shared/*、@features/*项目已配置推荐插件,打开项目时会提示安装:
ng serve --port 4300
或在 angular.json 中配置。
npm install library-name
npm run builddist/ 目录部署到服务器完全可以!生成的项目就是你的项目,可以随意修改和定制。
欢迎提交 Issue 和 Pull Request!
MIT License
灵感来源于:
Made with ❤️ by create-djangular-app Team
FAQs
A CLI tool to create clean Angular projects with best practices
The npm package create-djangular-app receives a total of 5 weekly downloads. As such, create-djangular-app popularity was classified as not popular.
We found that create-djangular-app demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.