@fivepixels-js/cli 0.1.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.
- package/LICENSE +202 -0
- package/README.md +206 -0
- package/dist/adapters/lite.d.ts +10 -0
- package/dist/adapters/lite.d.ts.map +1 -0
- package/dist/adapters/lite.js +37 -0
- package/dist/adapters/lite.js.map +1 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +89 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +6 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +5 -0
- package/dist/io.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Fivepixels CLI
|
|
2
|
+
|
|
3
|
+
`@fivepixels-js/cli` `0.1.0`은 `fivepixels` 명령으로 Lite API를 실행·관리하는 독립 CLI입니다. API 프로젝트나 SDK를 이 저장소로 옮기지 않습니다.
|
|
4
|
+
|
|
5
|
+
## 관련 저장소와 런타임
|
|
6
|
+
|
|
7
|
+
- [fivepixels-cli](https://github.com/siwan315/fivepixels-cli): 이 CLI의 독립 Git 저장소
|
|
8
|
+
- [fivepixels-lite-api](https://github.com/siwan315/fivepixels-lite-api): HTTP 서버·DB를 소유하는 독립 Git 저장소. 환경변수, 인증, DDL, Docker, 백업·복원 상세 안내는 이 저장소의 README를 참고하십시오.
|
|
9
|
+
|
|
10
|
+
소스 저장소는 비공개이므로 접근 권한이 필요합니다. npm 패키지 설치에는 소스 checkout이 필요하지 않습니다. 개발 환경 구성은 아래의 **소스 개발 설치**를 참고하십시오.
|
|
11
|
+
|
|
12
|
+
런타임 의존성은 공개 진입점이 추가된 `@fivepixels-js/lite-api` **`0.2.1`로 정확히 고정**합니다. 같은 버전이라도 runtime export가 없는 이전 개발 tarball은 사용할 수 없습니다. CLI 패키지에 Lite 코드를 복사해 묶지는 않습니다.
|
|
13
|
+
|
|
14
|
+
## 라이선스
|
|
15
|
+
|
|
16
|
+
Copyright (c) 2026 Fivepixels
|
|
17
|
+
|
|
18
|
+
이 저장소의 CLI 자체 코드는 [Apache License 2.0](LICENSE), SPDX 식별자 `Apache-2.0`으로 제공합니다.
|
|
19
|
+
|
|
20
|
+
함께 설치되는 `@fivepixels-js/lite-api` 서버는 별도의 **Elastic License 2.0 (`Elastic-2.0`)**을 따릅니다. API 서버는 source-available이며, CLI의 Apache-2.0 라이선스가 서버에 재라이선스되거나 서버의 호스팅·관리형 서비스 제공 제한을 해제하지 않습니다. 공개 runtime과 기존 `fivepixels-lite-api` 명령도 서버 패키지에 속합니다.
|
|
21
|
+
|
|
22
|
+
서버의 정확한 조건은 설치된 `@fivepixels-js/lite-api/LICENSE`와 [서버 README](https://github.com/siwan315/fivepixels-lite-api#라이선스)를 확인하십시오. 다른 제3자 의존성도 각자의 라이선스·고지를 유지합니다. 이 저장소 변경은 SDK나 다른 API 저장소의 라이선스 파일을 변경하지 않습니다.
|
|
23
|
+
|
|
24
|
+
이전에 적법하게 배포된 MIT 코드의 권한을 소급해서 회수하지 않습니다. 배포자는 외부 기여·제3자 코드의 권리와 과거 배포 이력을 별도로 확인해야 합니다.
|
|
25
|
+
|
|
26
|
+
## 요구사항
|
|
27
|
+
|
|
28
|
+
- Node.js 22 또는 24 LTS, npm 10 이상 권장
|
|
29
|
+
- DB를 둘 로컬 디스크. NFS/SMB/NAS는 사용하지 않습니다.
|
|
30
|
+
|
|
31
|
+
## 빠른 시작
|
|
32
|
+
|
|
33
|
+
### 1. npm 설치
|
|
34
|
+
|
|
35
|
+
패키지 이름은 `@fivepixels-js/cli`이고 실행 명령은 `fivepixels`입니다.
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install -g @fivepixels-js/cli
|
|
39
|
+
fivepixels --help
|
|
40
|
+
fivepixels --version
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
순서대로 npm의 `latest` 태그에 연결된 CLI를 전역 설치하고 도움말·CLI 버전을 확인합니다. 버전 접미사는 패키지 이름의 일부가 아니며, 특정 버전이 필요한 경우에만 `@fivepixels-js/cli@0.1.0`처럼 지정합니다. 이 문서의 CLI `0.1.0`은 Lite `0.2.1`을 함께 설치하고 정확한 호환 버전을 유지합니다. 설치·도움말·버전 조회만으로 서버·DB·JWT 키는 생성하지 않습니다.
|
|
44
|
+
|
|
45
|
+
### 2. 개발용 DB 초기화와 서버 실행
|
|
46
|
+
|
|
47
|
+
이후 명령은 모두 같은 작업 디렉터리에서 실행합니다. `../fivepixels-local-data/cli/data.db`는 개발용 예시입니다. 기존 운영 데이터가 없는 경로인지 확인하고, 다른 배포의 토큰·JWT 파일 환경변수가 적용되지 않은 셸을 사용하십시오.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
fivepixels init --db-path ../fivepixels-local-data/cli/data.db
|
|
51
|
+
fivepixels start --host 127.0.0.1 --port 3000 --db-path ../fivepixels-local-data/cli/data.db
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`init`은 해당 DB·마이그레이션과 DB 옆 JWT 키를 준비하고, `start`는 같은 DB로 포그라운드 서버를 실행합니다. 기존 DB를 지정하면 pending migration이 적용될 수 있습니다. 3000 포트가 사용 중이면 이후 조회 명령까지 같은 새 포트로 변경하십시오.
|
|
55
|
+
|
|
56
|
+
### 3. 별도 터미널에서 상태 확인과 백업
|
|
57
|
+
|
|
58
|
+
두 번째 터미널도 같은 작업 디렉터리에서 실행합니다.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
fivepixels status --host 127.0.0.1 --port 3000 --db-path ../fivepixels-local-data/cli/data.db
|
|
62
|
+
node -e "fetch('http://127.0.0.1:3000/health').then(r => { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); }).then(console.log)"
|
|
63
|
+
fivepixels backup --db-path ../fivepixels-local-data/cli/data.db
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
순서대로 HTTP·DB·마이그레이션 상태를 확인하고, health 응답의 `status: 'ok'`, `database: 'ok'`를 확인한 뒤 DB 옆 `backups/`에 온라인 백업을 만듭니다. 기존 백업은 덮어쓰지 않습니다. `status`는 DB가 없으면 생성하지 않으며, 서버가 없거나 미적용 마이그레이션이 있으면 종료 코드 `1`을 반환합니다.
|
|
67
|
+
|
|
68
|
+
### 4. 정상 종료와 마이그레이션 확인
|
|
69
|
+
|
|
70
|
+
서버를 시작한 첫 번째 터미널에서 Ctrl+C로 종료한 뒤 실행합니다.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
fivepixels migrate --db-path ../fivepixels-local-data/cli/data.db
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
서버를 다시 열지 않고 미적용 마이그레이션을 적용합니다. 최신 DB라면 `No pending migrations.`가 정상입니다. CLI에는 `stop` 명령이 없으며, POSIX에서는 기존 SIGINT/SIGTERM 종료 처리를 사용합니다.
|
|
77
|
+
|
|
78
|
+
모든 데이터 명령에서 같은 `--db-path`를 유지하십시오. 생략하면 OS별 기본 데이터 경로를 사용하므로 위 개발 DB가 아닌 다른 DB를 조회·생성·마이그레이션할 수 있습니다.
|
|
79
|
+
|
|
80
|
+
## 역할과 지원 범위
|
|
81
|
+
|
|
82
|
+
| 주체 | 책임 |
|
|
83
|
+
|---|---|
|
|
84
|
+
| 이 CLI | 명령·도움말·CLI 버전, Lite 버전/공개 진입점 확인 |
|
|
85
|
+
| Lite API | HTTP 서버, 설정·보안 검증, JWT 키, DB·마이그레이션·온라인 백업 |
|
|
86
|
+
| SDK | HTTP API 호출. 이번 CLI 분리로 요청 계약은 바뀌지 않음 |
|
|
87
|
+
|
|
88
|
+
CLI는 `@fivepixels-js/lite-api/package.json`과 `@fivepixels-js/lite-api/runtime`만 사용합니다. DB 모듈이나 내부 src/dist 파일을 직접 불러오지 않습니다. Lite를 같은 Node 프로세스에서 실행하므로 별도 서버 자식 프로세스나 종료 신호 전달 계층을 두지 않습니다.
|
|
89
|
+
|
|
90
|
+
현재 지원은 Lite뿐입니다. selfdev 선택, Docker 관리, stop/logs/restore/upgrade, API 버전 선택, 자동 다운로드·복구는 포함하지 않습니다. 기존 `fivepixels-lite-api` 명령과 Lite Docker 진입점은 그대로 사용할 수 있습니다.
|
|
91
|
+
|
|
92
|
+
## 명령과 설정
|
|
93
|
+
|
|
94
|
+
아래 표는 설치된 `fivepixels` 명령 기준입니다. 소스 개발 설치에서는 `fivepixels` 대신 `node dist/index.js`를 사용합니다.
|
|
95
|
+
|
|
96
|
+
| 명령 | 의미 |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `fivepixels init` | 데이터 디렉터리·DB·JWT 키 초기화 |
|
|
99
|
+
| `fivepixels start` | 미적용 마이그레이션 후 포그라운드 API 실행 |
|
|
100
|
+
| `fivepixels status` | HTTP·DB·마이그레이션 상태 확인; 없는 DB를 만들지 않음 |
|
|
101
|
+
| `fivepixels backup` | SQLite 온라인 백업·무결성 확인; 기존 백업을 덮어쓰지 않음 |
|
|
102
|
+
| `fivepixels migrate` | 미적용 마이그레이션 실행 |
|
|
103
|
+
| `fivepixels --help`, `fivepixels --version` | CLI 도움말·버전; DB·서버 작업 없음 |
|
|
104
|
+
|
|
105
|
+
`--db-path`, `--host`, `--port`, `--log-level`, `--cors-origin`, `--docs-enabled`, `--admin-token-file`, `--jwt-secret-file`, `--registration-enabled`, `--trust-proxy`, 백업 전용 `--output`을 그대로 Lite로 전달합니다. 옵션 값은 Lite가 검증합니다. `--docs-enabled`, `--registration-enabled`에는 `true` 또는 `false` 값을 명시합니다.
|
|
106
|
+
|
|
107
|
+
설정은 `CLI 옵션 > 환경변수 > 기본값`입니다. 기본 수신은 `127.0.0.1:3000`, CORS는 비활성입니다. 외부 바인딩에는 32자 이상의 관리 토큰이 필요하며, 원문 명령줄 옵션이 아닌 `--admin-token-file` 또는 Lite 환경변수를 사용합니다. 관리 토큰은 업무 API의 사용자 JWT를 대신하지 않습니다. 실제 .env/DB/키/백업을 저장소나 패키지에 넣지 마십시오.
|
|
108
|
+
|
|
109
|
+
종료 코드는 성공 `0`, 실행 실패 `1`, 잘못된 명령·설정 `2`입니다. `--version`은 CLI 버전 `0.1.0`이며 API 버전 `0.2.1`과 다릅니다. 버전 불일치·runtime 누락은 데이터 작업 전에 실패합니다. 제품 명령 실행 중 npm/npx를 호출하지 않습니다.
|
|
110
|
+
|
|
111
|
+
## 소스 개발 설치
|
|
112
|
+
|
|
113
|
+
Lite와 CLI의 소스 checkout 접근 권한이 필요합니다. 다음 예시는 `fivepixels-lite-api`와 `fivepixels-cli` 디렉터리가 같은 상위 디렉터리에 있는 경우입니다. npm 패키지 이름 공간과 Git 저장소·디렉터리 이름은 서로 다릅니다.
|
|
114
|
+
|
|
115
|
+
### 1. Lite tarball 준비
|
|
116
|
+
|
|
117
|
+
두 checkout의 버전·변경 내용을 먼저 확인한 뒤 **Lite 디렉터리**에서 실행합니다.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npm ci
|
|
121
|
+
npm pack
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
의존성을 설치하고 Lite를 빌드하여 `fivepixels-js-lite-api-0.2.1.tgz`를 만듭니다. npm 공개는 하지 않습니다.
|
|
125
|
+
|
|
126
|
+
### 2. CLI 의존성 설치와 빌드
|
|
127
|
+
|
|
128
|
+
**CLI 디렉터리**로 이동해 실행합니다. Lite가 다른 위치에 있으면 tarball 경로를 실제 위치로 바꾸십시오.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npm run setup:local -- ../fivepixels-lite-api/fivepixels-js-lite-api-0.2.1.tgz
|
|
132
|
+
npm run build
|
|
133
|
+
node dist/index.js --help
|
|
134
|
+
node dist/index.js --version
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
순서대로 Lite tarball을 검증·준비하고 고정 lockfile로 의존성을 설치한 뒤 CLI를 빌드하고 도움말·CLI 버전 `0.1.0`을 확인합니다. **전역 `fivepixels` 명령은 설치되지 않으므로 개발 중에는 `node dist/index.js`로 실행합니다.** 빠른 시작의 `fivepixels`를 `node dist/index.js`로 바꾸되 같은 `--db-path`를 유지하십시오. 설치·빌드·도움말·버전 조회만으로 서버·DB·JWT 키는 생성하지 않습니다.
|
|
138
|
+
|
|
139
|
+
개발용 `package-lock.json`은 Lite tarball을 `.artifacts/`의 상대 경로와 실제 SHA-512로 고정합니다. `.artifacts/`는 Git/npm 패키지에서 제외됩니다. 새 checkout에서 바로 `npm ci`를 실행하지 말고 `setup:local`로 tarball을 먼저 공급하십시오. 공개 `package.json`의 의존성은 `0.2.1`이며 로컬 경로가 아닙니다.
|
|
140
|
+
|
|
141
|
+
**`Tarball differs from the reviewed lock`가 나오면 여기서 멈추십시오.** Lite의 README만 바뀌어도 체크섬은 달라집니다. lockfile은 ELv2 라이선스·문서·메타데이터를 포함한 검토된 Lite tarball의 체크섬으로 고정됩니다. 이후 소스나 포함 문서를 다시 수정해 pack하면 재검토가 필요합니다. 새 tarball의 소스·포함 파일을 검토한 뒤 승인한 개발 변경에 대해서만 다음 명령으로 갱신합니다.
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm run setup:local -- --update-lock ../fivepixels-lite-api/fivepixels-js-lite-api-0.2.1.tgz
|
|
145
|
+
npm run build
|
|
146
|
+
node dist/index.js --version
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
첫 명령은 이름·버전·필수 파일을 확인하고 개발용 Lite의 경로·체크섬을 갱신한 뒤 의존성을 재설치합니다. 나머지 고정 의존성은 유지합니다. 이후 CLI를 다시 빌드하고 아래 연동 검증까지 수행해야 합니다. 검증을 우회하려고 임의의 tarball을 승인하거나 CI에 `--update-lock`을 넣지 마십시오.
|
|
150
|
+
|
|
151
|
+
## 검증
|
|
152
|
+
|
|
153
|
+
개발 설치와 빌드가 끝난 CLI 디렉터리에서 실행합니다.
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm run typecheck
|
|
157
|
+
npm run lint
|
|
158
|
+
npm test
|
|
159
|
+
npm run test:package
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
타입 검사, 정적 검사, 단위/구조 테스트, 실제 tarball 설치·실행 검증입니다. 마지막 명령의 기본 로컬 모드는 CLI를 빌드·패키징한 뒤 준비된 Lite tarball과 함께 임시 위치에 설치하고 다음을 검증합니다.
|
|
163
|
+
|
|
164
|
+
- 설치·help/version/status에서 불필요한 DB·키가 생성되지 않음
|
|
165
|
+
- 모든 옵션 전달, 외부 바인딩 보안 거부, 공개 runtime import의 무부작용
|
|
166
|
+
- init/start/health/status/온라인 backup/migrate, 백업 무결성·FK·미덮어쓰기
|
|
167
|
+
- 기존 Lite 명령과 새 CLI가 같은 DB를 정상 사용
|
|
168
|
+
- POSIX에서 실제 CLI SIGINT/SIGTERM 정상 종료 코드 0과 포트 해제
|
|
169
|
+
- 패키지 allowlist, CLI shebang·실행 권한, 민감 파일 제외
|
|
170
|
+
|
|
171
|
+
이미 생성한 CLI 패키지를 검증할 때는 `test:package`에 `--cli-tarball <CLI tgz 경로>`와 `--cli-integrity <준비 단계의 SHA-512>`를 함께 전달합니다. 이 모드는 CLI를 다시 빌드·압축하지 않으며, 설치 전에 파일 체크섬·패키지 이름/버전·실행 권한을 검사합니다. 둘 중 하나가 없거나 체크섬이 다르면 설치하지 않습니다. Lite tarball은 기존 `--lite-tarball` 옵션과 lockfile의 고정 SHA-512로 검증합니다.
|
|
172
|
+
|
|
173
|
+
Windows의 파일 권한 표현 차이로 로컬 재패키징 결과가 POSIX 아카이브와 달라질 수 있습니다. Windows에서는 CI 준비 단계에서 제공한 두 tgz와 CLI SHA-512를 사용하는 입력 모드를 권장합니다. 체크섬을 Windows 값으로 덮어쓰거나 실행 권한 검사를 생략하지 않습니다.
|
|
174
|
+
|
|
175
|
+
`.gitattributes`는 checkout 줄바꿈을 LF로 고정합니다. CI에서 내려받은 `.runtime-source/`와 준비된 `.artifacts/`는 CLI lint 범위에서 제외합니다. API의 검증은 Lite 저장소에서 별도로 수행하고, CLI 검증이 API 테스트를 대신한다고 보지 않습니다.
|
|
176
|
+
|
|
177
|
+
의존성 캐시가 모두 준비된 경우에만 `setup:local` 또는 `test:package`에 `--offline`을 추가합니다. 예를 들어 `npm run test:package -- --offline`은 네트워크 다운로드 없이 패키지 연동을 검증하며 캐시가 부족하면 실패합니다.
|
|
178
|
+
|
|
179
|
+
테스트의 SQLite 직접 검사는 테스트 스크립트에만 있고 제품 CLI에는 없습니다. 테스트는 임시 DB만 사용하며 성공 시 임시 설치·DB·키·백업을 정리합니다. 실패한 임시 경로는 진단을 위해 표시하고 보존합니다.
|
|
180
|
+
|
|
181
|
+
기존 로컬 실행 검증은 macOS / Node 24 기준입니다. Windows에서는 process.kill이 POSIX 종료 신호와 같지 않으므로 테스트가 실제 콘솔 Ctrl+C 정상 종료를 보장하지 않습니다. Windows 콘솔 종료는 별도 release 점검 대상입니다.
|
|
182
|
+
|
|
183
|
+
## CI 실행 조건
|
|
184
|
+
|
|
185
|
+
CI는 Linux의 패키지 준비 단계와 Node 22·24 및 Linux/macOS/Windows의 6개 검증 단계로 나뉩니다. 준비 단계에서 Lite와 CLI tgz를 한 번 생성·검증한 뒤, 같은 실행의 artifact ID로 두 파일만 전달합니다. 6개 환경은 동일한 아카이브를 설치하므로 OS별 재패키징 권한 차이를 피하며, 각 환경의 타입 검사·lint·단위 테스트·빌드는 유지합니다.
|
|
186
|
+
|
|
187
|
+
Lite 체크섬은 기존 lockfile에 고정하고, CLI 체크섬은 준비 단계의 SHA-512 출력과 대조합니다. 체크섬·실행 권한 검증을 통과한 tgz만 artifact에 포함하며 소스 checkout·토큰·설치 디렉터리·테스트 DB는 업로드하지 않습니다. Artifact 보존 기간은 7일입니다. 업로드·다운로드 액션은 커밋 SHA로 고정합니다.
|
|
188
|
+
|
|
189
|
+
- 기본 push/PR CI와 입력이 없는 수동 실행은 `fetch:runtime`으로 공개된 정확한 Lite tarball을 가져옵니다. Lite 선행 공개 전에는 이 단계에서 실패합니다.
|
|
190
|
+
- 공개 이후에도 실제 tarball과 CLI lockfile의 체크섬을 검토·일치시켜야 합니다. 버전 문자열만 같다고 통과하는 것은 아닙니다.
|
|
191
|
+
- 미공개 수동 검증은 `lite_repository=siwan315/fivepixels-lite-api`와 `lite_ref`에 검토된 **전체 40자리 커밋 SHA**를 지정합니다. 브랜치·태그·짧은 SHA·다른 저장소는 checkout 전에 거부합니다. 해당 커밋은 원격에 올라가 있어야 합니다.
|
|
192
|
+
- 다른 비공개 저장소는 CLI 저장소의 기본 `GITHUB_TOKEN`으로 읽을 수 없습니다. 수동 소스 checkout에는 `LITE_REPOSITORY_TOKEN` secret을 사용하며, Lite 저장소에만 `Contents: read` 권한이 있는 fine-grained PAT 등 최소 읽기 권한의 토큰을 별도로 준비해야 합니다. 토큰이 없으면 명확한 오류로 중단하고 checkout 인증은 저장하지 않습니다. [GitHub 공식 안내](https://github.com/actions/checkout#checkout-multiple-repos-private)
|
|
193
|
+
|
|
194
|
+
수동 소스 검증에는 CLI 저장소의 Settings → Secrets and variables → Actions에 `LITE_REPOSITORY_TOKEN` 등록이 필요합니다. 이 토큰은 패키지 준비 단계의 소스 확인에만 사용하며 6개 검증 단계에는 전달하지 않습니다. 토큰을 README나 입력 문자열에 붙여 넣지 마십시오. `fetch:runtime`은 개발/CI 준비 도구이며 제품 CLI의 자동 다운로드 기능이 아닙니다. CI 설정 존재가 모든 환경의 통과를 의미하지는 않으므로 해당 커밋의 실제 실행 결과를 확인하십시오.
|
|
195
|
+
|
|
196
|
+
## 공개와 운영 주의
|
|
197
|
+
|
|
198
|
+
1. README·포함 파일·민감정보를 점검하고 `@fivepixels-js` npm 이름 공간의 소유·배포 권한을 확인합니다.
|
|
199
|
+
2. `package.json`의 `repository`, `homepage`, `bugs`는 `siwan315/fivepixels-cli`로 연결되어 있습니다. 공개 전 실제 저장소·이슈 접근 정책을 다시 확인합니다.
|
|
200
|
+
3. 호환 Lite `0.2.1`을 먼저 공개합니다.
|
|
201
|
+
4. 실제 공개 Lite tarball이 검토한 파일과 같은지 SHA-512를 비교하고, registry 기반 설치·CI·패키지 연동을 재검증합니다. 개발용 lock의 `.artifacts/` 경로·체크섬은 유지하며 조회한 버전의 파일이 다르면 공개를 중단합니다.
|
|
202
|
+
5. 검증 후 CLI `0.1.0`을 공개합니다.
|
|
203
|
+
|
|
204
|
+
현재 두 패키지의 `publishConfig.access`는 `public`입니다. GitHub가 비공개여도 npm에 배포한 코드·문서는 공개되므로 파일의 공개 범위를 별도로 확인해야 합니다. npm 공개, Git commit/push, 인증·권한 변경, 운영 배포는 각각 명시적으로 승인한 단계에서만 수행합니다.
|
|
205
|
+
|
|
206
|
+
실제 운영 명령 실행 전 DB 경로·로컬 디스크·포트·권한·토큰 파일·백업 상태를 확인하십시오. 이번 CLI 분리 자체에 새 DB 마이그레이션은 없습니다. 기존 Lite의 pending migration은 `start/init/migrate`에서 기존 규칙대로 실행될 수 있습니다. CLI 문제가 생기면 기존 `fivepixels-lite-api` 명령을 사용하면 되며, 분리만 되돌리는 데 DB 복원이나 DDL 재실행은 필요하지 않습니다.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type RuntimeCommand = (args: string[]) => Promise<number>;
|
|
2
|
+
export interface RuntimeLoader {
|
|
3
|
+
metadata: () => unknown;
|
|
4
|
+
runtime: () => Promise<unknown>;
|
|
5
|
+
}
|
|
6
|
+
export declare class LiteRuntimeError extends Error {
|
|
7
|
+
}
|
|
8
|
+
/** Only public package metadata and the public runtime entrypoint are loaded. */
|
|
9
|
+
export declare function loadLiteRuntime(loader?: RuntimeLoader): Promise<RuntimeCommand>;
|
|
10
|
+
//# sourceMappingURL=lite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lite.d.ts","sourceRoot":"","sources":["../../src/adapters/lite.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEjE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACjC;AAED,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAY9C,iFAAiF;AACjF,wBAAsB,eAAe,CAAC,MAAM,GAAE,aAAgC,GAAG,OAAO,CAAC,cAAc,CAAC,CAoBvG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { LITE_VERSION } from '../version.js';
|
|
3
|
+
export class LiteRuntimeError extends Error {
|
|
4
|
+
}
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const installedRuntime = {
|
|
7
|
+
metadata: () => require('@fivepixels-js/lite-api/package.json'),
|
|
8
|
+
runtime: () => import('@fivepixels-js/lite-api/runtime'),
|
|
9
|
+
};
|
|
10
|
+
function isRecord(value) {
|
|
11
|
+
return value !== null && typeof value === 'object';
|
|
12
|
+
}
|
|
13
|
+
/** Only public package metadata and the public runtime entrypoint are loaded. */
|
|
14
|
+
export async function loadLiteRuntime(loader = installedRuntime) {
|
|
15
|
+
let metadata;
|
|
16
|
+
try {
|
|
17
|
+
metadata = loader.metadata();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new LiteRuntimeError('Lite runtime is missing. Reinstall @fivepixels-js/cli with its dependencies.');
|
|
21
|
+
}
|
|
22
|
+
if (!isRecord(metadata) || metadata.name !== '@fivepixels-js/lite-api' || metadata.version !== LITE_VERSION) {
|
|
23
|
+
throw new LiteRuntimeError('Unsupported Lite runtime. Required version: @fivepixels-js/lite-api ' + LITE_VERSION + '.');
|
|
24
|
+
}
|
|
25
|
+
let runtime;
|
|
26
|
+
try {
|
|
27
|
+
runtime = await loader.runtime();
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new LiteRuntimeError('Lite runtime entrypoint is unavailable. Install the compatible runtime with @fivepixels-js/cli.');
|
|
31
|
+
}
|
|
32
|
+
if (!isRecord(runtime) || typeof runtime.runRuntimeCommand !== 'function') {
|
|
33
|
+
throw new LiteRuntimeError('Lite runtime does not provide runRuntimeCommand. Install the compatible runtime.');
|
|
34
|
+
}
|
|
35
|
+
return runtime.runRuntimeCommand;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=lite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lite.js","sourceRoot":"","sources":["../../src/adapters/lite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAS7C,MAAM,OAAO,gBAAiB,SAAQ,KAAK;CAAG;AAE9C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,gBAAgB,GAAkB;IACtC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,sCAAsC,CAAY;IAC1E,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,iCAAiC,CAAC;CACzD,CAAC;AAEF,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrD,CAAC;AAED,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAAwB,gBAAgB;IAC5E,IAAI,QAAiB,CAAC;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,gBAAgB,CAAC,8EAA8E,CAAC,CAAC;IAC7G,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,IAAI,KAAK,yBAAyB,IAAI,QAAQ,CAAC,OAAO,KAAK,YAAY,EAAE,CAAC;QAC5G,MAAM,IAAI,gBAAgB,CAAC,sEAAsE,GAAG,YAAY,GAAG,GAAG,CAAC,CAAC;IAC1H,CAAC;IACD,IAAI,OAAgB,CAAC;IACrB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,gBAAgB,CAAC,iGAAiG,CAAC,CAAC;IAChI,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,OAAO,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QAC1E,MAAM,IAAI,gBAAgB,CAAC,kFAAkF,CAAC,CAAC;IACjH,CAAC;IACD,OAAO,OAAO,CAAC,iBAAmC,CAAC;AACrD,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqC,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAuDpD,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,GAAE,SAAqB,EACzB,WAAW,GAAE,MAAM,OAAO,CAAC,cAAc,CAAmB,GAC3D,OAAO,CAAC,MAAM,CAAC,CAgCjB"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { LiteRuntimeError, loadLiteRuntime } from './adapters/lite.js';
|
|
3
|
+
import { consoleIo } from './io.js';
|
|
4
|
+
import { CLI_VERSION, LITE_VERSION } from './version.js';
|
|
5
|
+
const HELP = `Fivepixels CLI ${CLI_VERSION}
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
fivepixels <command> [options]
|
|
9
|
+
fivepixels --help
|
|
10
|
+
fivepixels --version
|
|
11
|
+
|
|
12
|
+
Commands:
|
|
13
|
+
init Initialize the Lite data directory, database and JWT key
|
|
14
|
+
start Run migrations and start the Lite API in the foreground
|
|
15
|
+
status Check HTTP, database and migration status
|
|
16
|
+
backup Create an online SQLite backup
|
|
17
|
+
migrate Apply pending database migrations
|
|
18
|
+
|
|
19
|
+
Options:
|
|
20
|
+
--host <host>
|
|
21
|
+
--port <port>
|
|
22
|
+
--db-path <path>
|
|
23
|
+
--log-level <level>
|
|
24
|
+
--cors-origin <origins>
|
|
25
|
+
--docs-enabled <true|false>
|
|
26
|
+
--admin-token-file <path>
|
|
27
|
+
--jwt-secret-file <path>
|
|
28
|
+
--registration-enabled <true|false>
|
|
29
|
+
--trust-proxy <addresses>
|
|
30
|
+
--output <path> Backup output path (backup only)
|
|
31
|
+
-h, --help
|
|
32
|
+
-v, --version
|
|
33
|
+
|
|
34
|
+
Runtime: @fivepixels-js/lite-api ${LITE_VERSION}
|
|
35
|
+
Settings and security checks belong to Lite. Use local storage for SQLite.
|
|
36
|
+
The CLI does not download or upgrade runtimes while running commands.
|
|
37
|
+
`;
|
|
38
|
+
// Public argument syntax only. Value validation and configuration belong to Lite.
|
|
39
|
+
const options = {
|
|
40
|
+
'admin-token-file': { type: 'string' },
|
|
41
|
+
'cors-origin': { type: 'string' },
|
|
42
|
+
'db-path': { type: 'string' },
|
|
43
|
+
'docs-enabled': { type: 'string' },
|
|
44
|
+
help: { type: 'boolean', short: 'h' },
|
|
45
|
+
host: { type: 'string' },
|
|
46
|
+
'jwt-secret-file': { type: 'string' },
|
|
47
|
+
'log-level': { type: 'string' },
|
|
48
|
+
output: { type: 'string' },
|
|
49
|
+
port: { type: 'string' },
|
|
50
|
+
'registration-enabled': { type: 'string' },
|
|
51
|
+
'trust-proxy': { type: 'string' },
|
|
52
|
+
version: { type: 'boolean', short: 'v' },
|
|
53
|
+
};
|
|
54
|
+
const commands = new Set(['init', 'start', 'status', 'backup', 'migrate']);
|
|
55
|
+
export async function runCli(args, io = consoleIo, loadRuntime = loadLiteRuntime) {
|
|
56
|
+
try {
|
|
57
|
+
const { positionals, values } = parseArgs({ args, options, strict: true, allowPositionals: true });
|
|
58
|
+
if (values.version) {
|
|
59
|
+
io.output(CLI_VERSION);
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
if (values.help) {
|
|
63
|
+
io.output(HELP);
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
if (positionals.length !== 1 || !commands.has(positionals[0])) {
|
|
67
|
+
io.error('A supported command is required. Use fivepixels --help for usage.');
|
|
68
|
+
return 2;
|
|
69
|
+
}
|
|
70
|
+
if (values.output !== undefined && positionals[0] !== 'backup') {
|
|
71
|
+
io.error('--output can only be used with the backup command.');
|
|
72
|
+
return 2;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Never echo untrusted arguments: they can contain credentials.
|
|
77
|
+
io.error('Invalid command arguments. Use fivepixels --help for usage.');
|
|
78
|
+
return 2;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const run = await loadRuntime();
|
|
82
|
+
return await run([...args]);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
io.error(error instanceof LiteRuntimeError ? error.message : 'Lite command failed. Check the runtime installation and logs.');
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,CAAC,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/io.d.ts
ADDED
package/dist/io.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,eAAO,MAAM,SAAS,EAAE,SAGvB,CAAC"}
|
package/dist/io.js
ADDED
package/dist/io.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,SAAS,GAAc;IAClC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IACvC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;CACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,QAAmB,CAAC;AAC5C,eAAO,MAAM,YAAY,QAAmD,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
const metadata = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
3
|
+
export const CLI_VERSION = metadata.version;
|
|
4
|
+
export const LITE_VERSION = metadata.dependencies['@fivepixels-js/lite-api'];
|
|
5
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CACzB,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CACU,CAAC;AAE9E,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fivepixels-js/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fivepixels CLI for running and managing a compatible Lite API runtime.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/siwan315/fivepixels-cli.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/siwan315/fivepixels-cli#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/siwan315/fivepixels-cli/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": "^22.0.0 || ^24.0.0"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"fivepixels": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "node scripts/clean-dist.mjs && tsc -p tsconfig.build.json && node scripts/copy-assets.mjs",
|
|
31
|
+
"dev": "tsx src/index.ts",
|
|
32
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
33
|
+
"lint": "eslint .",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"test:package": "node scripts/test-package.mjs",
|
|
36
|
+
"setup:local": "node scripts/setup-local.mjs",
|
|
37
|
+
"prepack": "npm run build",
|
|
38
|
+
"fetch:runtime": "node scripts/fetch-runtime.mjs"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@fivepixels-js/lite-api": "0.2.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@eslint/js": "10.0.1",
|
|
45
|
+
"@types/node": "24.13.3",
|
|
46
|
+
"eslint": "10.9.1",
|
|
47
|
+
"tsx": "4.23.13",
|
|
48
|
+
"typescript": "6.0.3",
|
|
49
|
+
"typescript-eslint": "8.69.0",
|
|
50
|
+
"vitest": "4.1.11"
|
|
51
|
+
}
|
|
52
|
+
}
|