clang-format-node 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2024 루밀LuMir(lumirlumir)
3
+ Copyright (c) 2024-present 루밀LuMir(lumirlumir)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,425 +1,76 @@
1
- # clang-format-node
1
+ <!-- markdownlint-disable-next-line -->
2
+ # <div align="center"> clang-format-node </div>
2
3
 
3
- [![lint](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/lint.yml/badge.svg)](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/lint.yml)
4
- [![test](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/test.yml/badge.svg)](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/test.yml)
5
- [![test-cross-platform](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/test-cross-platform.yml/badge.svg)](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/test-cross-platform.yml)
6
- [![codecov](https://codecov.io/gh/lumirlumir/npm-clang-format-node/graph/badge.svg?token=69BF05THA2)](https://codecov.io/gh/lumirlumir/npm-clang-format-node)
7
- ![Node Current](https://img.shields.io/node/v/clang-format-node)
8
- [![NPM Version](https://img.shields.io/npm/v/clang-format-node)](https://www.npmjs.com/package/clang-format-node)
9
- ![GitHub Release](https://img.shields.io/github/v/release/lumirlumir/npm-clang-format-node?label=release%20(LLVM%20version)&color=violet&display_name=release)
10
-
11
- Node repackaging(wrapping) of the `clang-format` native binary inspired by ['angular/clang-format'](https://github.com/angular/clang-format).🐉
12
-
13
- This package intends to release a new npm package for every **latest** release of the `clang-format`. It **checks** for the latest LLVM release every week, builds `clang-format` using its own pipeline, and makes a **pull request**. All processes are run automatically. If you are interested in build process, take a look at [`.github/workflows/llvm-build-bump-pr.yml`](/.github/workflows/llvm-build-bump-pr.yml)
14
-
15
- > [!IMPORTANT]
16
- >
17
- > Please participate in the issue regarding the introduction of a **glob pattern**. Click [here](https://github.com/lumirlumir/npm-clang-format-node/issues/14).
18
-
19
- ## Why I started this project
20
-
21
- ['angular/clang-format'](https://github.com/angular/clang-format) is no longer maintained. (See [#79](https://github.com/angular/clang-format/issues/79) [#82](https://github.com/angular/clang-format/issues/82) [#83](https://github.com/angular/clang-format/pull/83)) Nevertheless, new versions of `clang-format` continue to be released. Bugs are fixed, and new features are added. However, using `clang-format` directly in a Node.js environment without any support can be somewhat cumbersome. So I decided to make a **new**, **maintained** one.
22
-
23
- Note that some feautures from 'angular/clang-format' are not included in this package. Specifically `check-clang-format` and `git-clang-format` are not used. There are a few reasons for this. Both commands **rely on Python**, so if you haven't installed Python, they cannot be executed. Many people would prefer if this package worked without dependencies beyond Node.js. **So, this package relies only on Node.js.** See the [Migration](#migration-from-angularclang-format) for alternative methods to `check-clang-format` and `git-clang-format`.
24
-
25
- ## Supported
26
-
27
- ### OS Platforms and Architectures
28
-
29
- It supports **ALL** [**Tier1**](https://github.com/nodejs/node/blob/main/BUILDING.md#strategy) and some [**Tier2**](https://github.com/nodejs/node/blob/main/BUILDING.md#strategy) platforms of Node.js. *Note that the functionality cannot be guaranteed on platforms which is not mentioned below*.
4
+ <!-- markdownlint-disable-next-line -->
5
+ <div align="center">
30
6
 
31
- (To see the full list of platforms supported by Node.js, click [here](<https://github.com/nodejs/node/blob/main/BUILDING.md#platform-list>).)
7
+ ⭐If you like this package, please give it a star on [GitHub](https://github.com/lumirlumir/npm-clang-format-node)!⭐<br>
8
+ Your support helps us improve and maintain the project.
32
9
 
33
- <br> | Operating System | Architectures | Support Type |
34
- ---- | ---------------- | ---------------- | ------------ |
35
- 1 | macOS | arm64 | Tier 1 |
36
- 2 | macOS | x64 | Tier 1 |
37
- 3 | GNU/Linux | armv7 | Tier 1 |
38
- 4 | GNU/Linux | arm64 | Tier 1 |
39
- 5 | GNU/Linux | ppc64le >=power8 | Tier 2 |
40
- 6 | GNU/Linux | s390x | Tier 2 |
41
- 7 | GNU/Linux | x64 | Tier 1 |
42
- 8 | Windows | x64 | Tier 1 |
43
-
44
- > [!TIP]
45
- >
46
- > 1. If your platform isn't yet supported, you can build the `clang-format` native binary from the latest upstream clang sources. Refer to [`docs/llvm-build-linux.sh`](/docs/llvm-build-linux.sh) and [`.github/workflows/llvm-build-bump-pr.yml`](/.github/workflows/llvm-build-bump-pr.yml) for the build scripts for **Linux Shell** and **GitHub Actions**, respectively.
47
- >
48
- > 1. Or you can download `clang-format` native binary from [LLVM release assets](https://github.com/llvm/llvm-project/releases) that match your operating system platform and architecture like the lists below.
49
- >
50
- > - `clang+llvm-18.1.7-aarch64-linux-gnu.tar.xz`
51
- > - `clang+llvm-18.1.7-armv7a-linux-gnueabihf.tar.gz`
52
- > - `clang+llvm-18.1.7-powerpc64-ibm-aix-7.2.tar.xz`
53
- > - `clang+llvm-18.1.7-x86_64-pc-windows-msvc.tar.xz`
54
- > - `and more...`
55
-
56
- ### Node.js
10
+ <image src="https://llvm.org/img/LLVMWyvernSmall.png" width="350px" height="220px"/><br /><br />
57
11
 
12
+ ![GitHub Release](https://img.shields.io/github/v/release/lumirlumir/npm-clang-format-node?label=release%20(LLVM%20version)&color=violet&display_name=release)
13
+ [![NPM Version](https://img.shields.io/npm/v/clang-format-node)](https://www.npmjs.com/package/clang-format-node)
14
+ ![NPM Downloads](https://img.shields.io/npm/dm/clang-format-node)
58
15
  ![Node Current](https://img.shields.io/node/v/clang-format-node)
59
16
 
60
- The official support for <u>**Node.js version 16 and above**</u> has been confirmed through [testing](/.github/workflows/test-cross-platform.yml).
61
-
62
- > [!NOTE]
63
- >
64
- > However, this package does not utilize the latest features of Node.js and is transpiled using Babel. Therefore, it is expected to work on versions significantly lower than the officially supported ones. (ex. `"node": ">= 0.7.10"`) Consequently, **if the current package operates on a version of Node.js that is lower than the officially supported version, it should be perfectly fine to use.**
65
-
66
- ### [GitHub Actions Runner Images](https://github.com/actions/runner-images?tab=readme-ov-file#available-images)
67
-
68
- If you want to use `clang-format-node` in continuous integration (CI), You can use **GitHub Actions**. The following basic runner images are compatible(available) with `clang-format-node`.
69
-
70
- Image | YAML Label | Included Software |
71
- ---------------------------- | ---------------------------------------------------------------------- | ----------------- |
72
- macOS 15 | `macos-15-large` | macOS-15 |
73
- macOS 15 Arm64 | `macos-15` or `macos-15-xlarge` | macOS-15-arm64 |
74
- macOS 14 | `macos-latest-large` or `macos-14-large` | macOS-14 |
75
- macOS 14 Arm64 | `macos-latest`, `macos-14`, `macos-latest-xlarge` or `macos-14-xlarge` | macOS-14-arm64 |
76
- macOS 13 | `macos-13` or `macos-13-large` | macOS-13 |
77
- macOS 13 Arm64 | `macos-13-xlarge` | macOS-13-arm64 |
78
- macOS 12 | `macos-12` or `macos-12-large` | macOS-12 |
79
- Ubuntu 24.04 | `ubuntu-latest` or `ubuntu-24.04` | ubuntu-24.04 |
80
- Ubuntu 22.04 | `ubuntu-22.04` | ubuntu-22.04 |
81
- Windows Server 2022 | `windows-latest` or `windows-2022` | windows-2022 |
82
-
83
- However, the following basic runner images are **NOT** compatible(available) with `clang-format-node`. It's because the ***dependencies*** for LLVM's latest release version are not compatible with the following images.
84
-
85
- Image | YAML Label | Included Software |
86
- ----------------------- | -------------- | ----------------- |
87
- ~~Ubuntu 20.04~~ | `ubuntu-20.04` | [ubuntu-20.04] |
88
- ~~Windows Server 2019~~ | `windows-2019` | [windows-2019] |
89
-
90
- ### Docker(Build) Images
91
-
92
- I used the following Images to build `clang-format` excuatable binaries.
93
-
94
- > [!TIP]
95
- >
96
- > If you want to see which software is included in **GitHub Actions runner**, click [here](https://github.com/actions/runner-images?tab=readme-ov-file#available-images) and refer to the 'Included Software' column.
97
-
98
- Binary Folder Name | Docker(Build) Image |
99
- ------------------ | ------------------------------------------------------------------ |
100
- `darwin-arm64` | GitHub Actions runner `macos-14` |
101
- `darwin-x64` | GitHub Actions runner `macos-12` |
102
- `linux-arm` | [`arm32v7/ubuntu:22.04`](https://hub.docker.com/r/arm32v7/ubuntu/) |
103
- `linux-arm64` | [`arm64v8/ubuntu:22.04`](https://hub.docker.com/r/arm64v8/ubuntu/) |
104
- `linux-ppc64` | [`ppc64le/ubuntu:22.04`](https://hub.docker.com/r/ppc64le/ubuntu/) |
105
- `linux-s390x` | [`s390x/ubuntu:22.04`](https://hub.docker.com/r/s390x/ubuntu/) |
106
- `linux-x64` | GitHub Actions runner `ubuntu-22.04` |
107
- `win32-x64` | GitHub Actions runner `windows-2022` |
108
-
109
- ## Installation
110
-
111
- ### global
112
-
113
- ```bash
114
- npm install -g clang-format-node
115
- ```
116
-
117
- ```bash
118
- yarn global add clang-format-node
119
- ```
120
-
121
- ### local(devDependencies)
122
-
123
- ```bash
124
- npm install --save-dev clang-format-node
125
- ```
126
-
127
- ```bash
128
- yarn add --dev clang-format-node
129
- ```
130
-
131
- ## Usages
132
-
133
- If you want to learn more about `clang-format` itself, see the [`clang-format style options`](https://clang.llvm.org/docs/ClangFormatStyleOptions.html).
134
-
135
- > [!TIP]
136
- >
137
- > `clang-format` can take multiple files as arguments.
138
- >
139
- > ```bash
140
- > npx clang-format -n -Werror file1.cpp file2.cpp src/file3.cpp
141
- > ```
142
-
143
- ### Basic
144
-
145
- #### Global
146
-
147
- ```bash
148
- clang-format [options] [@<file>] [<file> ...]
149
- ```
150
-
151
- #### Local
152
-
153
- Use `npx` to run a locally installed package.
154
-
155
- ```bash
156
- npx clang-format [options] [@<file>] [<file> ...]
157
- ```
158
-
159
- #### Frequently used commands
160
-
161
- 1. `--version`: Check the version of `clang-format`.
162
-
163
- ``` bash
164
- npx clang-format --version
165
- ```
166
-
167
- Output example
168
-
169
- ```bash
170
- clang-format version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
171
- ```
172
-
173
- - `https://github.com/llvm/llvm-project`: Git repository URL for the LLVM project, which includes Clang.
174
- - `3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff`: The commit hash of the Git repository where the source code for that version is stored. This hash allows you to precisely trace which source code version was used to generate `clang-format`.
175
-
176
- 1. `--help`: Help view additional options.
177
-
178
- ```bash
179
- npx clang-format --help
180
- ```
181
-
182
- 1. `--dry-run` or `-n`: Makes an **WARNING** when `example.cpp` is not correctly formatted.
183
-
184
- `--dry-run` and `-n` options are equivalent.
185
-
186
- ```bash
187
- npx clang-format --dry-run example.cpp
188
- ```
189
-
190
- ```bash
191
- npx clang-format -n example.cpp
192
- ```
193
-
194
- 1. `-Werror --dry-run` or `-Werror -n`: Makes an **ERROR** when `example.cpp` is not correctly formatted.
195
-
196
- > Similar to `eslint` or `prettier --check` commands.
197
-
198
- `--dry-run` and `-n` options are equivalent.
199
-
200
- ```bash
201
- npx clang-format -Werror --dry-run example.cpp
202
- ```
203
-
204
- ```bash
205
- npx clang-format -Werror -n example.cpp
206
- ```
207
-
208
- 1. `-i`: Automatically fix unformatted files.
209
-
210
- > Similar to `eslint --fix` or `prettier --write` commands.
211
-
212
- ```bash
213
- npx clang-format -i example.cpp
214
- ```
215
-
216
- ### Glob patterns
217
-
218
- Unfortunately, there is no way to apply `clang-format` recursively. `*.cpp` will only match files in the current directory, not subdirectories. Even `**/*` doesn't work.
219
-
220
- **So, you need to use the `find` command in Linux.** If you are a Windows user, use ***git bash***. then you can use the `find` command. The `find` command recursively searches through directories.
221
-
222
- It is simple but can produce an error if the [**Argument list is too long**](https://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands). In that case, use `xargs`
223
-
224
- #### Basic
225
-
226
- To recursively search for all `.cpp` files in the current directory, use:
227
-
228
- ```bash
229
- npx clang-format $(find . -name "*.cpp")
230
- ```
231
-
232
- If the argument list is too long, use `xargs`. And if file names contain spaces or special characters, use `-print0` and `-0` options. `-print0` makes `find` output file names separated by null characters (`\0`), and `-0` tells `xargs` to correctly handle these null-separated file names.
233
-
234
- ```bash
235
- find . -name "*.cpp" -print0 | xargs -0 npx clang-format
236
- ```
237
-
238
- #### With regular expressions
239
-
240
- To recursively search for all `.cpp` and `.h` files in the current directory using a regular expression, use:
241
-
242
- ```bash
243
- npx clang-format $(find . -regex ".*\.\(cpp\|h\)")
244
- ```
245
-
246
- #### With negation patterns
247
-
248
- To exclude `excluded_file.cpp` from the `.cpp` files, use:
249
-
250
- ```bash
251
- npx clang-format $(find . -name "*.cpp" ! -name "excluded_file.cpp")
252
- ```
253
-
254
- ### [`.clang-format-ignore`](https://clang.llvm.org/docs/ClangFormat.html#clang-format-ignore)
255
-
256
- You can create `.clang-format-ignore` files to make `clang-format` ignore certain files. A `.clang-format-ignore` file consists of patterns of file path names. It has the following format:
257
-
258
- - A blank line is skipped.
259
- - Leading and trailing spaces of a line are trimmed.
260
- - A line starting with a hash (`#`) is a comment.
261
- - A non-comment line is a single pattern.
262
- - The slash (`/`) is used as the directory separator.
263
- - A pattern is relative to the directory of the `.clang-format-ignore` file (or the root directory if the pattern starts with a slash). Patterns containing drive names (e.g. `C:`) are not supported.
264
- - Patterns follow the rules specified in [**POSIX 2.13.1, 2.13.2, and Rule 1 of 2.13.3.**](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13)
265
- - A pattern is negated if it starts with a bang (`!`).
266
-
267
- To match all files in a directory, use e.g. `foo/bar/*`. To match all files in the directory of the `.clang-format-ignore` file, use `*`. Multiple `.clang-format-ignore` files are supported similar to the `.clang-format` files, with a lower directory level file voiding the higher level ones.
268
-
269
- ### Use with `husky` and `lint-staged`
270
-
271
- Ensuring that changes to your code are properly formatted is an important part of your development workflow. Use `husky` and `lint-staged` for your continuous integration process.
272
-
273
- #### `husky` (v8.x)
274
-
275
- ```bash
276
- # .husky/pre-commit
277
-
278
- npx lint-staged
279
- ```
280
-
281
- #### `lint-staged` (v15.x)
282
-
283
- 1. Check
284
-
285
- ```jsonc
286
- /* package.json */
287
-
288
- {
289
- // ...
290
- "lint-staged": {
291
- "*.{c,cpp,h}": "npx clang-format -Werror -n",
292
- }
293
- // ...
294
- }
295
- ```
17
+ [![lint](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/lint.yml/badge.svg)](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/lint.yml)
18
+ [![test](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/test.yml/badge.svg)](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/test.yml)
19
+ [![test-cross-platform](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/test-cross-platform.yml/badge.svg)](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/test-cross-platform.yml)
20
+ [![codecov](https://codecov.io/gh/lumirlumir/npm-clang-format-node/graph/badge.svg?token=69BF05THA2)](https://codecov.io/gh/lumirlumir/npm-clang-format-node)
296
21
 
297
- 1. Fix
22
+ [![Static Badge](https://img.shields.io/badge/Official_Documentation-skyblue?style=flat&logo=gitbook&labelColor=gray)](https://clang-format-node.lumir.page)
298
23
 
299
- ```jsonc
300
- /* package.json */
24
+ Node repackaging(wrapping) of the **LLVM Clang's** `clang-format` and `git-clang-format` native binary inspired by ['angular/clang-format'](https://github.com/angular/clang-format).🐉
301
25
 
302
- {
303
- // ...
304
- "lint-staged": {
305
- "*.{c,cpp,h}": "npx clang-format -i",
306
- }
307
- // ...
308
- }
309
- ```
26
+ <!-- markdownlint-disable-next-line -->
27
+ </div>
310
28
 
311
- > [!TIP]
29
+ > [!IMPORTANT]
312
30
  >
313
- > If `example1.cpp` and `example2.c` are staged, then `npx clang-format -Werror -n example1.cpp example2.c` will be excuted.
314
-
315
- ## Migration from 'angular/clang-format'
316
-
317
- ### `check-clang-format`
318
-
319
- This package only uses native `clang-format` features to check formatting. The following commands will produce an error if the target files are not correctly formatted. So use them with `husky` and `lint-staged`. (`--dry-run` and `-n` options are equivalent.)
320
-
321
- ```bash
322
- npx clang-format -Werror --dry-run example.cpp
323
- ```
324
-
325
- ```bash
326
- npx clang-format -Werror -n example.cpp
327
- ```
328
-
329
- ### `git-clang-format`
330
-
331
- Use [`husky`](https://typicode.github.io/husky/) and [`lint-staged`](https://github.com/lint-staged/lint-staged) for the `pre-commit` hook instead. See [Use with `husky` and `lint-staged`](#use-with-husky-and-lint-staged) for details.
332
-
333
- ## Contributing
334
-
335
- Thanks for having attention to this package.🙇‍♂️ Issues and PRs are always welcome.🎉
336
-
337
- I recommend you to read the guides on [LLVM and clang-format mentioned in issues tab](https://github.com/lumirlumir/npm-clang-format-node/issues/new/choose) before contributing.
338
-
339
- ### Installation
340
-
341
- 1. Fork it.
342
-
343
- 1. Clone it to your local directory. ([Git](https://git-scm.com/downloads) is required.)
344
-
345
- ```bash
346
- git clone https://github.com/lumirlumir/npm-clang-format-node.git
347
- ```
348
-
349
- 1. Move to the `npm-clang-format-node` directory.
350
-
351
- ```bash
352
- cd npm-clang-format-node
353
- ```
354
-
355
- 1. Install npm packages. ([Node.js](https://nodejs.org/en) is required.)
356
-
357
- ```bash
358
- npm install
359
- ```
360
-
361
- 1. Edit codes.
362
-
363
- 1. Create `my-branch` branch.
364
-
365
- ```bash
366
- git switch -c my-branch
367
- ```
368
-
369
- 1. Commit your changes. (`husky` and `lint-staged` will lint and test your changed files!)
31
+ > Please participate in the issue regarding the introduction of a **glob pattern**. Click [here](https://github.com/lumirlumir/npm-clang-format-node/issues/14).
370
32
 
371
- ```bash
372
- git commit -am "commit type: title"
373
- ```
33
+ ## Included Packages
374
34
 
375
- 1. Push them to your remote branch.
35
+ This repository is maintained as a **monorepo** and includes the following packages.
376
36
 
377
- 1. Submit a pull request.👍
37
+ 1. `clang-format-node` [![NPM Version](https://img.shields.io/npm/v/clang-format-node)](https://www.npmjs.com/package/clang-format-node):
38
+ Node repackaging of the `clang-format` native binary. (The **CORE** package.) [『Docs』](/docs/02-packages/01-clang-format-node.md), [『Repository』](https://github.com/lumirlumir/npm-clang-format-node/tree/main/packages/clang-format-node), [『npm』](https://www.npmjs.com/package/clang-format-node)
378
39
 
379
- ### About `os.platform()` and `os.arch()` in Node.js
40
+ 1. `clang-format-git` [![NPM Version](https://img.shields.io/npm/v/clang-format-git)](https://www.npmjs.com/package/clang-format-git): Node repackaging of the `git-clang-format` Python script as a standalone native binary to **allow execution without a Python dependency**. [『Docs』](/docs/02-packages/02-clang-format-git.md), [『Repository』](https://github.com/lumirlumir/npm-clang-format-node/tree/main/packages/clang-format-git), [『npm』](https://www.npmjs.com/package/clang-format-git)
380
41
 
381
- #### [os.platform()](https://nodejs.org/docs/v20.17.0/api/os.html#osplatform)
42
+ 1. `clang-format-git-python` [![NPM Version](https://img.shields.io/npm/v/clang-format-git-python)](https://www.npmjs.com/package/clang-format-git-python): Node repackaging of the `git-clang-format` Python script. **This package requires Python3 as a dependency**. [『Docs』](/docs/02-packages/03-clang-format-git-python.md), [『Repository』](https://github.com/lumirlumir/npm-clang-format-node/tree/main/packages/clang-format-git-python), [『npm』](https://www.npmjs.com/package/clang-format-git-python)
382
43
 
383
- The return value is equivalent to `process.platform`.
44
+ ## Supported
384
45
 
385
- OS | Return value of `os.platform()` |
386
- ------- | ---------------------------------- |
387
- macOS | `darwin` |
388
- Linux | `linux` |
389
- Windows | `win32` |
46
+ See the [supported](/docs/01-introduction/05-supported.md) documentation, which lists the supported 'OS Platforms and Architectures', 'Node.js Versions', 'GitHub Actions Runner Images', and 'Docker(Build) Images'.
390
47
 
391
- #### [os.arch()](https://nodejs.org/docs/v20.17.0/api/os.html#osarch)
48
+ ## Releases
392
49
 
393
- The return value is equivalent to `process.arch`.
50
+ Each package intends to release a new npm package for every **latest** release of the `clang-format` and `git-clang-format`. It **checks** for the latest LLVM release every week, builds all packages using its own pipeline, and makes a pull request. **All processes are run automatically**. If you are interested in the build process, take a look at [`.github/workflows/llvm-build-bump-pr.yml`](/.github/workflows/llvm-build-bump-pr.yml).
394
51
 
395
- Architecture | Return value of `os.arch()` | LLVM | Docker Platform | Docker Ubuntu Image |
396
- ------------------ | ------------------------------ | --------- | --------------- | ------------------- |
397
- arm(armv7, armv7l) | `arm` | `ARM` | `arm/v7` | `arm32v7` |
398
- arm64 | `arm64` | `AArch64` | `arm64/v8` | `arm64v8` |
399
- ppc64le[^1] | `ppc64` | `PowerPC` | `ppc64le` | `ppc64le` |
400
- s390x | `s390x` | `SystemZ` | `s390x` | `s390x` |
401
- x64 | `x64` | `X86` | `amd64` | `amd64` |
52
+ ## Contributing (Issues & Pull Requests)
402
53
 
403
- [^1]: `le` stands for little-endian, but the `os.arch()` function does not distinguish between endianness and returns a single value.
54
+ Thanks for having attention to this package🙇‍♂️. We appreciate you spending the time to work on these things. Every issue and pull request about bugs, suggestions and the other topics is always welcome!
404
55
 
405
- ### Build process
56
+ Please read our [Code of Conduct](./CODE_OF_CONDUCT.md) and [Contributing Guides](/docs/04-community/01-contributing.md) before you work on these things. We also recommend you to read the [Guides on LLVM and `clang-format`](docs/03-others/04-guides-on-llvm-and-clang-format.md) mentioned in the documentation before contributing.
406
57
 
407
- Some packages for **cross-compilation** have been deprecated, making it difficult to make build processes directly, so **cross-compilation** is not used. Instead, I utilize **QEMU** and **Docker** to build cross-compiled binaries.
58
+ ## Documentation
408
59
 
409
- If you want to learn more about the images I used, see [Docker(Build) Images](#dockerbuild-images)
60
+ For full documentation, see the [official documentation of the `clang-format-node`](https://clang-format-node.lumir.page) or [`docs` directory of `clang-format-node` repository](https://github.com/lumirlumir/npm-clang-format-node/tree/main/docs).
410
61
 
411
62
  ## Versioning
412
63
 
413
- This project adheres to [Semantic Versioning](https://semver.org/).
64
+ See [Versioning](/docs/04-community/02-versioning.md).
414
65
 
415
- The BREAKING CHANGES, features and bug fixes from [LLVM](https://github.com/llvm/llvm-project/releases) will be reflected in this package.
66
+ ## Change Log
416
67
 
417
- The release title includes the LLVM version, like `v1.0.0 (llvmorg-18.1.8)`. See [`.clang-format-version`](/.clang-format-version) to check the exact current LLVM version.
68
+ See [Change Log](/CHANGELOG.md).
418
69
 
419
- ## Change Log
70
+ ## Code of Conduct
420
71
 
421
- See [`CHANGELOG.md`](/CHANGELOG.md)
72
+ See [Code of Conduct](/CODE_OF_CONDUCT.md).
422
73
 
423
74
  ## License
424
75
 
425
- [MIT](/LICENSE) under [LLVM Apache License 2.0](https://github.com/llvm/llvm-project/blob/main/LICENSE.TXT)
76
+ [MIT](/LICENSE.md) under [LLVM Apache License 2.0](https://github.com/llvm/llvm-project/blob/main/LICENSE.TXT).
package/build/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/build/cli.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var _require=require("child_process"),spawn=_require.spawn;var _require2=require("./utils/clangFormatPath"),clangFormatPath=_require2.clangFormatPath;var spawned=spawn(clangFormatPath,process.argv.slice(2),{stdio:"inherit"});spawned.on("close",function(code){if(code!==0){console.error("Process exited with code: ".concat(code));process.exit(code)}});
@@ -0,0 +1,5 @@
1
+ import { clangFormatPath } from "./utils/clangFormatPath";
2
+ import { clangFormatNodePath } from "./utils/clangFormatPath";
3
+ import { getClangFormatPath } from "./utils/getClangFormatPath";
4
+ import { getClangFormatNodePath } from "./utils/getClangFormatPath";
5
+ export { clangFormatPath, clangFormatNodePath, getClangFormatPath, getClangFormatNodePath };
package/build/index.js CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- "use strict";var _require=require("os"),platform=_require.platform,arch=_require.arch;var _require2=require("child_process"),spawn=_require2.spawn;var getClangFormatPath=require("./getClangFormatPath");var OS_PLATFORM=platform();var ARCHITECTURE=arch();try{var spawned=spawn(getClangFormatPath(OS_PLATFORM,ARCHITECTURE),process.argv.slice(2),{stdio:"inherit"});spawned.on("close",process.exit)}catch(error){console.error(error.message);process.exit(1)}
1
+ "use strict";var _require=require("./utils/clangFormatPath"),clangFormatPath=_require.clangFormatPath,clangFormatNodePath=_require.clangFormatNodePath;var _require2=require("./utils/getClangFormatPath"),getClangFormatPath=_require2.getClangFormatPath,getClangFormatNodePath=_require2.getClangFormatNodePath;module.exports={clangFormatPath:clangFormatPath,clangFormatNodePath:clangFormatNodePath,getClangFormatPath:getClangFormatPath,getClangFormatNodePath:getClangFormatNodePath};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The ABSOLUTE path to the `clang-format` executable binary based on the OS platform and architecture.
3
+ *
4
+ * @alias `clangFormatNodePath`. See {@link clangFormatNodePath}.
5
+ * @version `v1.2.0` Initial release.
6
+ */
7
+ export const clangFormatPath: string;
8
+ /**
9
+ * Alias for `clangFormatPath`.
10
+ *
11
+ * @alias `clangFormatPath`. See {@link clangFormatPath}.
12
+ * @version `v1.2.0` Initial release.
13
+ */
14
+ export const clangFormatNodePath: string;
@@ -0,0 +1 @@
1
+ "use strict";var _require=require("os"),platform=_require.platform,arch=_require.arch;var _require2=require("./getClangFormatPath"),getClangFormatPath=_require2.getClangFormatPath;var clangFormatPath=getClangFormatPath(platform(),arch());var clangFormatNodePath=clangFormatPath;module.exports={clangFormatPath:clangFormatPath,clangFormatNodePath:clangFormatNodePath};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Returns the ABSOLUTE path to the `clang-format` executable binary based on the OS platform and architecture.
3
+ *
4
+ * The possible combinations are `darwin-arm64`, `darwin-x64`, `linux-arm`, `linux-arm64`, `linux-ppc64`, `linux-s390x`, `linux-x64`, `win32-x64`.
5
+ *
6
+ * Throws an error if the executable is not found.
7
+ *
8
+ * @param {string} osPlatform The current operating system platform. (e.g., `darwin`, `linux`, `win32`)
9
+ * @param {string} architecture The current system architecture. (e.g., `arm`, `arm64`, `ppc64`, `s390x`, `x64`)
10
+ * @returns {string} The ABSOLUTE path to the `clang-format` executable binary.
11
+ * @throws `Error` Throws an error if the executable binary is not found for the specified OS platform and architecture.
12
+ * @alias `getClangFormatNodePath`. See {@link getClangFormatNodePath}.
13
+ * @version `v1.2.0` Initial release.
14
+ */
15
+ export function getClangFormatPath(osPlatform: string, architecture: string): string;
16
+ /**
17
+ * Returns the ABSOLUTE path to the `clang-format` executable binary based on the OS platform and architecture.
18
+ *
19
+ * The possible combinations are `darwin-arm64`, `darwin-x64`, `linux-arm`, `linux-arm64`, `linux-ppc64`, `linux-s390x`, `linux-x64`, `win32-x64`.
20
+ *
21
+ * Throws an error if the executable is not found.
22
+ *
23
+ * @param {string} osPlatform The current operating system platform. (e.g., `darwin`, `linux`, `win32`)
24
+ * @param {string} architecture The current system architecture. (e.g., `arm`, `arm64`, `ppc64`, `s390x`, `x64`)
25
+ * @returns {string} The ABSOLUTE path to the `clang-format` executable binary.
26
+ * @throws `Error` Throws an error if the executable binary is not found for the specified OS platform and architecture.
27
+ * @alias `getClangFormatNodePath`. See {@link getClangFormatNodePath}.
28
+ * @version `v1.2.0` Initial release.
29
+ */
30
+ export function getClangFormatNodePath(osPlatform: string, architecture: string): string;
@@ -0,0 +1 @@
1
+ "use strict";var _require=require("fs"),existsSync=_require.existsSync;var _require2=require("path"),resolve=_require2.resolve;function getClangFormatPath(osPlatform,architecture){var clangFormatPath=resolve(__dirname,"..","bin","cfn-".concat(osPlatform,"-").concat(architecture),"clang-format".concat(osPlatform==="win32"?".exe":""));if(!existsSync(clangFormatPath))throw new Error("No executable found for '".concat(osPlatform,"(OS platform)-").concat(architecture,"(architecture)'\nThe possible combinations are 'darwin-arm64', 'darwin-x64', 'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-s390x', 'linux-x64', 'win32-x64'"));return clangFormatPath}var getClangFormatNodePath=getClangFormatPath;module.exports={getClangFormatPath:getClangFormatPath,getClangFormatNodePath:getClangFormatNodePath};
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "clang-format-node",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "Node repackaging of the clang-format native binary inspired by angular/clang-format.🐉",
5
5
  "main": "build/index.js",
6
6
  "files": [
7
7
  "build",
8
- "LICENSE",
8
+ "LICENSE.md",
9
9
  "README.md"
10
10
  ],
11
11
  "bin": {
12
- "clang-format": "build/index.js"
12
+ "clang-format": "build/cli.js",
13
+ "clang-format-node": "build/cli.js"
13
14
  },
14
15
  "keywords": [
15
16
  "clang-format",
@@ -29,7 +30,7 @@
29
30
  ],
30
31
  "author": "루밀LuMir <rpfos@naver.com> (https://github.com/lumirlumir)",
31
32
  "license": "MIT",
32
- "homepage": "https://github.com/lumirlumir/npm-clang-format-node",
33
+ "homepage": "https://clang-format-node.lumir.page",
33
34
  "repository": {
34
35
  "type": "github",
35
36
  "url": "git+https://github.com/lumirlumir/npm-clang-format-node.git"
@@ -41,48 +42,12 @@
41
42
  "node": ">=16"
42
43
  },
43
44
  "scripts": {
44
- "prepare": "husky",
45
- "postinstall": "find ./build/bin -type f -exec chmod 755 {} + || true",
45
+ "postinstall": "test -d src && npm run build || npm run chmod",
46
46
  "prepublishOnly": "npm run build",
47
- "build": "npx babel src -d build --no-comments --compact true --minified && cp -r src/bin build",
48
- "test": "npx mocha ./tests --inline-diffs true",
49
- "coverage": "npx nyc --reporter=lcov npm run test",
50
- "lint": "concurrently \"npm:lint-*\"",
51
- "lint-eslint": "npx eslint . --ext .js",
52
- "lint-prettier": "npx prettier . --check",
53
- "lint-editorconfig": "npx editorconfig-checker",
54
- "lint-markdownlint": "npx markdownlint **/*.md",
55
- "fix": "concurrently \"npm:fix-*\"",
56
- "fix-eslint": "npx eslint . --fix --ext .js",
57
- "fix-prettier": "npx prettier . --write"
47
+ "build": "npx babel src -d build && npx tsc && cp -r src/bin build && cp ../../LICENSE.md ../../README.md .",
48
+ "postbuild": "npm run chmod",
49
+ "test": "node --test",
50
+ "chmod": "find ./src/bin ./build/bin -type f -exec chmod 755 {} + || true"
58
51
  },
59
- "devDependencies": {
60
- "@babel/cli": "^7.24.8",
61
- "@babel/core": "^7.25.2",
62
- "@babel/preset-env": "^7.25.3",
63
- "concurrently": "^9.0.0",
64
- "editorconfig-checker": "^6.0.0",
65
- "eslint": "^8.57.0",
66
- "eslint-config-airbnb-base": "^15.0.0",
67
- "eslint-config-prettier": "^9.1.0",
68
- "eslint-plugin-import": "^2.29.1",
69
- "eslint-plugin-prettier": "^5.2.1",
70
- "husky": "^9.1.5",
71
- "lint-staged": "^15.2.10",
72
- "markdownlint-cli": "^0.42.0",
73
- "mocha": "^10.7.3",
74
- "nyc": "^17.0.0",
75
- "prettier": "^3.3.3"
76
- },
77
- "lint-staged": {
78
- "*": [
79
- "npx prettier --check",
80
- "npx editorconfig-checker -exclude README.md"
81
- ],
82
- "*.js": "npx eslint",
83
- "*.md": "npx markdownlint",
84
- "{src,tests}/**/!(index.js)": [
85
- "npm run test"
86
- ]
87
- }
52
+ "gitHead": "44eb57089c2fe3eacddca8f4c86320aed28493eb"
88
53
  }
@@ -1 +0,0 @@
1
- "use strict";var _require=require("fs"),existsSync=_require.existsSync;var _require2=require("path"),resolve=_require2.resolve;module.exports=function(osPlatform,architecture){var clangFormatPath=resolve(__dirname,"bin","".concat(osPlatform,"-").concat(architecture),"clang-format".concat(osPlatform==="win32"?".exe":""));if(!existsSync(clangFormatPath))throw new Error("No executable found for '".concat(osPlatform,"(OS platform)-").concat(architecture,"(architecture)'\nSee supported OS platform and architecture lists of clang-format-node in README.md"));return clangFormatPath};