VS-Shell-Format 项目使用教程

VS-Shell-Format 项目使用教程

vs-shell-formatthe shellscript、Dockerfile、properties ...... format extension项目地址:https://gitcode.com/gh_mirrors/vs/vs-shell-format

1. 项目的目录结构及介绍

VS-Shell-Format 是一个用于 Visual Studio Code 的插件,主要用于格式化 Shell 脚本、Dockerfile、gitignore 等文件。项目的目录结构如下:

vs-shell-format/
├── .github/
│   └── workflows/
├── client/
│   ├── src/
│   │   ├── commands/
│   │   ├── extension.ts
│   │   └── test/
│   ├── package.json
│   └── tsconfig.json
├── server/
│   ├── src/
│   │   ├── main.ts
│   │   └── test/
│   ├── package.json
│   └── tsconfig.json
├── .gitignore
├── LICENSE
├── package.json
├── README.md
└── tsconfig.json

目录结构介绍

  • .github/workflows: 包含 GitHub Actions 的工作流配置文件。
  • client: 包含插件客户端的源代码和配置文件。
    • src: 客户端的源代码目录。
      • commands: 包含插件的命令实现。
      • extension.ts: 插件的主入口文件。
      • test: 客户端的测试代码。
    • package.json: 客户端的 npm 配置文件。
    • tsconfig.json: 客户端的 TypeScript 配置文件。
  • server: 包含插件服务端的源代码和配置文件。
    • src: 服务端的源代码目录。
      • main.ts: 服务端的主入口文件。
      • test: 服务端的测试代码。
    • package.json: 服务端的 npm 配置文件。
    • tsconfig.json: 服务端的 TypeScript 配置文件。
  • .gitignore: Git 忽略文件配置。
  • LICENSE: 项目的开源许可证。
  • package.json: 项目的 npm 配置文件。
  • README.md: 项目的说明文档。
  • tsconfig.json: 项目的 TypeScript 配置文件。

2. 项目的启动文件介绍

VS-Shell-Format 插件的启动文件主要位于 client/src/extension.ts。这个文件是插件的入口点,负责初始化插件并注册命令。

import * as vscode from 'vscode';
import { format } from './commands/format';

export function activate(context: vscode.ExtensionContext) {
    context.subscriptions.push(
        vscode.commands.registerCommand('shell-format.format', format)
    );
}

export function deactivate() {}

启动文件介绍

  • activate: 插件激活时调用的函数,注册了 shell-format.format 命令。
  • deactivate: 插件停用时调用的函数,目前为空。

3. 项目的配置文件介绍

VS-Shell-Format 插件的配置文件主要位于 client/package.jsonserver/package.json。这些文件包含了插件的依赖、命令、配置等信息。

client/package.json

{
  "name": "shell-format",
  "displayName": "shell-format",
  "description": "A formatter for shell scripts, Dockerfile, gitignore, properties, etc.",
  "version": "7.0.0",
  "publisher": "foxundermoon",
  "engines": {
    "vscode": "^1.50.0"
  },
  "categories": [
    "Formatters"
  ],
  "activationEvents": [
    "onCommand:shell-format.format"
  ],
  "main": "./out/extension.js",
  "contributes": {
    "commands": [
      {
        "command": "shell-format.format",
        "title": "Format Shell Script"
      }
    ]
  },
  "scripts": {
    "vscode:prepublish": "npm run compile",
    "compile": "tsc -p ./",
    "watch": "tsc -watch -p ./",
    "pretest": "npm run compile && npm run lint",
    "lint": "eslint src --ext ts",
    "test": "node ./out/test/runTest.js"

vs-shell-formatthe shellscript、Dockerfile、properties ...... format extension项目地址:https://gitcode.com/gh_mirrors/vs/vs-shell-format

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蔡妙露Percy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值