@sublay/cli 7.0.0 → 7.0.1
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/NOTICE +9 -0
- package/README.md +109 -0
- package/dist/index.js +166 -46
- package/package.json +46 -19
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 2025 Sublay
|
|
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/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Sublay Client Modules
|
|
2
|
+
Copyright 2025 Sublay
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Sublay under the Apache License, Version 2.0.
|
|
5
|
+
|
|
6
|
+
Trademark Policy:
|
|
7
|
+
"Sublay" and the Sublay logo are trademarks of Sublay. You may not use these trademarks, or any confusingly similar marks, in connection with your own products or services without prior written permission. This includes, but is not limited to, using the trademarks in advertising, promotional materials, or as part of your product names.
|
|
8
|
+
|
|
9
|
+
For more information or to request permission, please contact: support@sublay.io
|
package/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# @sublay/cli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@sublay/cli)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
> **Backend infrastructure for user-powered products.** Pre-modeled bundles for the layers every app ends up rebuilding — comments, notifications, files, search, chat, and more. Install what you need, call through one SDK. Build the part that's actually yours.
|
|
7
|
+
|
|
8
|
+
Component installer for Sublay. It copies full, working UI components — comment sections, notification controls — into your own source tree as editable files, the way `shadcn/ui` does. They are yours after that: no component package to upgrade, no wrapper to fight, just files you can edit.
|
|
9
|
+
|
|
10
|
+
The components it installs are built on the Sublay SDKs ([`@sublay/react-js`](https://www.npmjs.com/package/@sublay/react-js), [`@sublay/react-native`](https://www.npmjs.com/package/@sublay/react-native), [`@sublay/expo`](https://www.npmjs.com/package/@sublay/expo)) and the [`@sublay/ui-core-*`](https://www.npmjs.com/package/@sublay/ui-core-react-js) primitives, so install those in your project first.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
No global install needed — run it with `npx`.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx @sublay/cli init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`init` detects your framework and TypeScript setup, asks which platform (`react`, `react-native`, or `expo`) and style (`styled` or `tailwind`) you want, and writes a `sublay.json` at your project root recording those answers plus where components should land.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @sublay/cli add comments-threaded
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`add` reads `sublay.json`, downloads the matching component from the registry, writes its files into your components directory, and generates an `index.ts` barrel so you can import it directly:
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { ThreadedCommentSection } from "@/components/comments-threaded";
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Available components
|
|
33
|
+
|
|
34
|
+
| Component | React | React Native / Expo |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| `comments-threaded` | styled, tailwind | tailwind |
|
|
37
|
+
| `comments-social` | styled, tailwind | styled, tailwind |
|
|
38
|
+
| `notifications-control` | styled, tailwind | — |
|
|
39
|
+
|
|
40
|
+
Expo projects install the React Native variants. Not every component ships every platform/style pairing yet; `add` tells you when the combination in your `sublay.json` isn't available.
|
|
41
|
+
|
|
42
|
+
See [docs.sublay.io](https://docs.sublay.io) for the full component reference.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## What is Sublay
|
|
47
|
+
|
|
48
|
+
Every user-powered product runs into the same engineering problems — content modeling, threaded discussions, permission graphs, ranking pipelines, search indexing, notification fan-out, social graphs, and moderation queues. Sublay solves them, so you don't have to.
|
|
49
|
+
|
|
50
|
+
Sublay ships these layers as **pre-modeled bundles** that attach to one shared entity model. You install the bundles you need from the dashboard, call them through any Sublay SDK, and build the part that's actually yours on top.
|
|
51
|
+
|
|
52
|
+
## Bundles you can install
|
|
53
|
+
|
|
54
|
+
- **Comments & Threads** — threaded discussions with mentions, replies, sorting
|
|
55
|
+
- **Reactions & Votes** — upvotes, downvotes, multi-emoji reactions
|
|
56
|
+
- **Spaces & Communities** — groups, sub-forums, membership
|
|
57
|
+
- **Notifications** — in-app notification fan-out with optional webhook delivery
|
|
58
|
+
- **Feeds & Discovery** — hot / top / new / controversial, filtered by tag, geography, timeframe, or follow graph
|
|
59
|
+
- **Real-Time Chat** — direct messages and group threads
|
|
60
|
+
- **Follows & Connections** — one-way follows, mutual connections
|
|
61
|
+
- **Files & Storage** — file blob storage with managed upload URLs
|
|
62
|
+
- **AI-Powered Search** — semantic search across your entity tree
|
|
63
|
+
- **Moderation** — report queues and content-removal workflows
|
|
64
|
+
|
|
65
|
+
Every bundle attaches to the same model. No mismatches, no extra databases. One schema for everything.
|
|
66
|
+
|
|
67
|
+
## How it works
|
|
68
|
+
|
|
69
|
+
1. Create a project at [dash.sublay.io](https://dash.sublay.io) and install the bundles you need.
|
|
70
|
+
2. Install a Sublay SDK in your app — this one, or one of its siblings (see below).
|
|
71
|
+
3. Optionally drop in the open-source [`@sublay/ui-core-*`](https://github.com/sublay-io/monorepo/tree/main/packages/ui-core-react-js) primitives, or install full components via the Sublay CLI registry.
|
|
72
|
+
|
|
73
|
+
## The Sublay dashboard
|
|
74
|
+
|
|
75
|
+
The dashboard at [dash.sublay.io](https://dash.sublay.io) is a database/backend console for your project:
|
|
76
|
+
|
|
77
|
+
- **Overview** — usage metrics and project health
|
|
78
|
+
- **Authentication** — end users and OAuth providers
|
|
79
|
+
- **Database** — schema browser (tables, relationships) and a table editor for browsing rows
|
|
80
|
+
- **Storage** — file blobs uploaded through the Files bundle
|
|
81
|
+
- **Reports** — moderation queue across entity and comment reports
|
|
82
|
+
- **Broadcast** — send notifications to your users
|
|
83
|
+
- **Settings** — domains, webhooks, integrations, members, secrets, billing
|
|
84
|
+
|
|
85
|
+
## The Sublay SDK family
|
|
86
|
+
|
|
87
|
+
- [`@sublay/core`](https://www.npmjs.com/package/@sublay/core) — platform-agnostic hooks and utilities
|
|
88
|
+
- [`@sublay/react-js`](https://www.npmjs.com/package/@sublay/react-js) — React (web)
|
|
89
|
+
- [`@sublay/react-native`](https://www.npmjs.com/package/@sublay/react-native) — React Native
|
|
90
|
+
- [`@sublay/expo`](https://www.npmjs.com/package/@sublay/expo) — Expo with SecureStore token storage
|
|
91
|
+
- [`@sublay/node`](https://www.npmjs.com/package/@sublay/node) — server-side Node.js (backends, server actions, webhook handlers)
|
|
92
|
+
- [`@sublay/js`](https://www.npmjs.com/package/@sublay/js) — framework-agnostic JavaScript (browser apps without React)
|
|
93
|
+
- [`@sublay/ui-core-react-js`](https://www.npmjs.com/package/@sublay/ui-core-react-js) / [`@sublay/ui-core-react-native`](https://www.npmjs.com/package/@sublay/ui-core-react-native) — open-source UI primitives
|
|
94
|
+
|
|
95
|
+
## Documentation
|
|
96
|
+
|
|
97
|
+
Full API reference, SDK guides, and recipes: **[docs.sublay.io](https://docs.sublay.io)**
|
|
98
|
+
|
|
99
|
+
## Community & support
|
|
100
|
+
|
|
101
|
+
- **Discord** — [discord.gg/REKxnCJzPz](https://discord.gg/REKxnCJzPz)
|
|
102
|
+
- **Blog** — [blog.sublay.io](https://blog.sublay.io)
|
|
103
|
+
- **X** — [@yantsab](https://x.com/yantsab)
|
|
104
|
+
- **LinkedIn** — [linkedin.com/company/sublay](https://www.linkedin.com/company/sublay)
|
|
105
|
+
- **Email** — [support@sublay.io](mailto:support@sublay.io)
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
Apache 2.0
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
+
import { createRequire } from "module";
|
|
4
5
|
import { Command } from "commander";
|
|
5
6
|
|
|
6
7
|
// src/commands/init.ts
|
|
@@ -18,12 +19,15 @@ async function detectProjectType() {
|
|
|
18
19
|
if (!await fs.pathExists(packageJsonPath)) {
|
|
19
20
|
return "unknown";
|
|
20
21
|
}
|
|
21
|
-
const
|
|
22
|
+
const packageJson2 = await fs.readJson(packageJsonPath);
|
|
22
23
|
const deps = {
|
|
23
|
-
...
|
|
24
|
-
...
|
|
24
|
+
...packageJson2.dependencies,
|
|
25
|
+
...packageJson2.devDependencies
|
|
25
26
|
};
|
|
26
|
-
if (deps["
|
|
27
|
+
if (deps["expo"]) {
|
|
28
|
+
return "expo";
|
|
29
|
+
}
|
|
30
|
+
if (deps["react-native"]) {
|
|
27
31
|
return "react-native";
|
|
28
32
|
}
|
|
29
33
|
if (deps["react"]) {
|
|
@@ -42,12 +46,12 @@ async function detectTypeScript() {
|
|
|
42
46
|
}
|
|
43
47
|
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
44
48
|
if (await fs.pathExists(packageJsonPath)) {
|
|
45
|
-
const
|
|
49
|
+
const packageJson2 = await fs.readJson(packageJsonPath);
|
|
46
50
|
const deps = {
|
|
47
|
-
...
|
|
48
|
-
...
|
|
51
|
+
...packageJson2.dependencies,
|
|
52
|
+
...packageJson2.devDependencies
|
|
49
53
|
};
|
|
50
|
-
if (deps["typescript"]
|
|
54
|
+
if (deps["typescript"]) {
|
|
51
55
|
return true;
|
|
52
56
|
}
|
|
53
57
|
}
|
|
@@ -62,6 +66,19 @@ async function init() {
|
|
|
62
66
|
console.log(chalk.bold("\n\u{1F680} Welcome to Sublay CLI\n"));
|
|
63
67
|
const projectType = await detectProjectType();
|
|
64
68
|
const hasTypeScript = await detectTypeScript();
|
|
69
|
+
if (!process.stdin.isTTY) {
|
|
70
|
+
console.error(
|
|
71
|
+
chalk.red(
|
|
72
|
+
"\n\u274C sublay init requires an interactive terminal \u2014 no TTY detected."
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
console.error(
|
|
76
|
+
chalk.dim(
|
|
77
|
+
" Run it directly in a terminal, not through a script or pipe.\n"
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
65
82
|
const answers = await prompts([
|
|
66
83
|
{
|
|
67
84
|
type: "select",
|
|
@@ -72,7 +89,7 @@ async function init() {
|
|
|
72
89
|
{ title: "React Native", value: "react-native" },
|
|
73
90
|
{ title: "Expo", value: "expo" }
|
|
74
91
|
],
|
|
75
|
-
initial: projectType === "react-native" ? 1 : 0
|
|
92
|
+
initial: projectType === "expo" ? 2 : projectType === "react-native" ? 1 : 0
|
|
76
93
|
},
|
|
77
94
|
{
|
|
78
95
|
type: "select",
|
|
@@ -90,22 +107,26 @@ async function init() {
|
|
|
90
107
|
initial: "src/components"
|
|
91
108
|
}
|
|
92
109
|
]);
|
|
93
|
-
if (!answers.platform) {
|
|
110
|
+
if (!answers.platform || answers.style === void 0 || answers.componentsPath === void 0) {
|
|
94
111
|
console.log(chalk.yellow("\n\u26A0\uFE0F Setup cancelled"));
|
|
95
112
|
process.exit(0);
|
|
96
113
|
}
|
|
114
|
+
const componentsPath = answers.componentsPath || "src/components";
|
|
97
115
|
const config = {
|
|
98
116
|
platform: answers.platform,
|
|
99
117
|
style: answers.style || "styled",
|
|
100
118
|
typescript: hasTypeScript,
|
|
101
119
|
paths: {
|
|
102
|
-
components:
|
|
120
|
+
components: componentsPath
|
|
103
121
|
},
|
|
104
122
|
aliases: {
|
|
105
|
-
"@/components":
|
|
123
|
+
"@/components": `./${componentsPath}`
|
|
106
124
|
}
|
|
107
125
|
};
|
|
108
126
|
const configPath = path2.join(process.cwd(), "sublay.json");
|
|
127
|
+
if (await fs2.pathExists(configPath)) {
|
|
128
|
+
console.log(chalk.yellow("\n\u26A0\uFE0F Overwriting existing configuration: sublay.json"));
|
|
129
|
+
}
|
|
109
130
|
await fs2.writeJson(configPath, config, { spaces: 2 });
|
|
110
131
|
console.log(chalk.green("\n\u2705 Configuration saved to sublay.json"));
|
|
111
132
|
console.log(chalk.bold("\n\u{1F389} Sublay CLI initialized successfully!\n"));
|
|
@@ -129,6 +150,7 @@ import { fileURLToPath } from "url";
|
|
|
129
150
|
var __filename = fileURLToPath(import.meta.url);
|
|
130
151
|
var __dirname = path3.dirname(__filename);
|
|
131
152
|
var LOCAL_REGISTRY_PATH = path3.resolve(__dirname, "..", "..", "..", "registry");
|
|
153
|
+
var REMOTE_REGISTRY_BASE = "https://raw.githubusercontent.com/sublay-io/monorepo/main/registry";
|
|
132
154
|
async function fetchRegistry(componentName, config) {
|
|
133
155
|
try {
|
|
134
156
|
const registryPlatform = config.platform === "expo" ? "react-native" : config.platform;
|
|
@@ -143,7 +165,7 @@ async function fetchRegistry(componentName, config) {
|
|
|
143
165
|
if (localExists) {
|
|
144
166
|
return await fs3.readJson(registryPath);
|
|
145
167
|
}
|
|
146
|
-
const url =
|
|
168
|
+
const url = `${REMOTE_REGISTRY_BASE}/${registryPlatform}/${componentName}/${config.style}/registry.json`;
|
|
147
169
|
try {
|
|
148
170
|
const response = await fetch(url);
|
|
149
171
|
if (!response.ok) {
|
|
@@ -202,9 +224,9 @@ async function fetchFile(registryUrl, filePath) {
|
|
|
202
224
|
// src/utils/transform.ts
|
|
203
225
|
function transformImports(content, config) {
|
|
204
226
|
let transformed = content;
|
|
205
|
-
transformed = transformed.replace(/from\s+['"]\.\.\/files\//g,
|
|
206
|
-
transformed = transformed.replace(/import\s+['"]\.\.\/files\//g,
|
|
207
|
-
transformed = transformed.replace(/import\(['"]\.\.\/files\//g,
|
|
227
|
+
transformed = transformed.replace(/from(\s+)(['"])\.\.\/files\//g, "from$1$2../components/");
|
|
228
|
+
transformed = transformed.replace(/import(\s+)(['"])\.\.\/files\//g, "import$1$2../components/");
|
|
229
|
+
transformed = transformed.replace(/import\((['"])\.\.\/files\//g, "import($1../components/");
|
|
208
230
|
if (config.platform === "expo") {
|
|
209
231
|
transformed = transformed.replace(
|
|
210
232
|
/from\s+["']@sublay\/react-native["']/g,
|
|
@@ -251,6 +273,13 @@ async function detectPackageManager() {
|
|
|
251
273
|
}
|
|
252
274
|
return "npm";
|
|
253
275
|
}
|
|
276
|
+
function parseDependencyName(dep) {
|
|
277
|
+
const parts = dep.split("@").filter(Boolean);
|
|
278
|
+
if (dep.startsWith("@")) {
|
|
279
|
+
return `@${parts[0]}`;
|
|
280
|
+
}
|
|
281
|
+
return parts[0];
|
|
282
|
+
}
|
|
254
283
|
async function checkComponentDependencies(dependencies) {
|
|
255
284
|
try {
|
|
256
285
|
const packageJsonPath = path4.join(process.cwd(), "package.json");
|
|
@@ -258,37 +287,32 @@ async function checkComponentDependencies(dependencies) {
|
|
|
258
287
|
console.log(chalk2.yellow("\n\u26A0\uFE0F No package.json found"));
|
|
259
288
|
return;
|
|
260
289
|
}
|
|
261
|
-
const
|
|
290
|
+
const packageJson2 = await fs4.readJson(packageJsonPath);
|
|
262
291
|
const allDeps = {
|
|
263
|
-
...
|
|
264
|
-
...
|
|
292
|
+
...packageJson2.dependencies,
|
|
293
|
+
...packageJson2.devDependencies
|
|
265
294
|
};
|
|
266
|
-
const requiredDeps = dependencies.map(
|
|
267
|
-
const parts = dep.split("@").filter(Boolean);
|
|
268
|
-
if (dep.startsWith("@")) {
|
|
269
|
-
return `@${parts[0]}`;
|
|
270
|
-
} else {
|
|
271
|
-
return parts[0];
|
|
272
|
-
}
|
|
273
|
-
});
|
|
295
|
+
const requiredDeps = dependencies.map(parseDependencyName);
|
|
274
296
|
const missingDeps = requiredDeps.filter((dep) => !allDeps[dep]);
|
|
275
297
|
if (missingDeps.length === 0) {
|
|
276
298
|
console.log(chalk2.green("\n\u2705 All required dependencies are installed"));
|
|
277
299
|
return;
|
|
278
300
|
}
|
|
279
301
|
console.log(chalk2.yellow("\n\u26A0\uFE0F Missing required dependencies:"));
|
|
280
|
-
const missingDepsWithVersions = dependencies.filter(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
return missingDeps.includes(pkgName);
|
|
284
|
-
});
|
|
302
|
+
const missingDepsWithVersions = dependencies.filter(
|
|
303
|
+
(dep) => missingDeps.includes(parseDependencyName(dep))
|
|
304
|
+
);
|
|
285
305
|
missingDepsWithVersions.forEach((dep) => console.log(chalk2.dim(` - ${dep}`)));
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
306
|
+
let install = false;
|
|
307
|
+
if (process.stdin.isTTY) {
|
|
308
|
+
const answer = await prompts2({
|
|
309
|
+
type: "confirm",
|
|
310
|
+
name: "install",
|
|
311
|
+
message: "Would you like to install them now?",
|
|
312
|
+
initial: true
|
|
313
|
+
});
|
|
314
|
+
install = Boolean(answer.install);
|
|
315
|
+
}
|
|
292
316
|
if (install) {
|
|
293
317
|
await installDependencies(missingDepsWithVersions);
|
|
294
318
|
} else {
|
|
@@ -358,7 +382,34 @@ async function add(componentName) {
|
|
|
358
382
|
console.log(chalk3.yellow("\n\u26A0\uFE0F Please run: npx @sublay/cli init"));
|
|
359
383
|
process.exit(1);
|
|
360
384
|
}
|
|
361
|
-
|
|
385
|
+
let rawConfig;
|
|
386
|
+
try {
|
|
387
|
+
rawConfig = await fs5.readJson(configPath);
|
|
388
|
+
} catch {
|
|
389
|
+
rawConfig = null;
|
|
390
|
+
}
|
|
391
|
+
if (!isValidConfig(rawConfig)) {
|
|
392
|
+
spinner.fail("sublay.json is malformed");
|
|
393
|
+
console.error(
|
|
394
|
+
chalk3.red(
|
|
395
|
+
"\n\u274C sublay.json is missing or malformed \u2014 delete it and run `npx @sublay/cli init` again."
|
|
396
|
+
)
|
|
397
|
+
);
|
|
398
|
+
process.exit(1);
|
|
399
|
+
}
|
|
400
|
+
const config = rawConfig;
|
|
401
|
+
const componentDir = path5.join(
|
|
402
|
+
process.cwd(),
|
|
403
|
+
config.paths.components,
|
|
404
|
+
componentName
|
|
405
|
+
);
|
|
406
|
+
if (await fs5.pathExists(componentDir)) {
|
|
407
|
+
spinner.stop();
|
|
408
|
+
console.log(
|
|
409
|
+
chalk3.yellow(`\u26A0\uFE0F Overwriting existing component: ${componentName}`)
|
|
410
|
+
);
|
|
411
|
+
spinner.start(`Fetching ${componentName}...`);
|
|
412
|
+
}
|
|
362
413
|
spinner.text = `Fetching ${componentName}...`;
|
|
363
414
|
const registry = await fetchRegistry(componentName, config);
|
|
364
415
|
if (!registry) {
|
|
@@ -423,12 +474,15 @@ async function add(componentName) {
|
|
|
423
474
|
` import { ${componentInfo.mainComponent} } from './${relativeImportPath}';`
|
|
424
475
|
)
|
|
425
476
|
);
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
477
|
+
if (componentInfo.typeExport) {
|
|
478
|
+
console.log(chalk3.dim(` // With types:`));
|
|
479
|
+
console.log(
|
|
480
|
+
chalk3.dim(
|
|
481
|
+
` import { ${componentInfo.mainComponent}, type ${componentInfo.typeExport} } from './${relativeImportPath}';`
|
|
482
|
+
)
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
printAppSetupNotes(registry.dependencies);
|
|
432
486
|
console.log();
|
|
433
487
|
} catch (error) {
|
|
434
488
|
spinner.fail("Failed to add component");
|
|
@@ -436,6 +490,70 @@ async function add(componentName) {
|
|
|
436
490
|
process.exit(1);
|
|
437
491
|
}
|
|
438
492
|
}
|
|
493
|
+
function isValidConfig(value) {
|
|
494
|
+
if (typeof value !== "object" || value === null) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
const config = value;
|
|
498
|
+
if (config.platform !== "react" && config.platform !== "react-native" && config.platform !== "expo") {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
if (config.style !== "styled" && config.style !== "tailwind") {
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
if (typeof config.typescript !== "boolean") {
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
const paths = config.paths;
|
|
508
|
+
if (typeof paths !== "object" || paths === null) {
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
if (typeof paths.components !== "string") {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
const aliases = config.aliases;
|
|
515
|
+
if (typeof aliases !== "object" || aliases === null) {
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
if (typeof aliases["@/components"] !== "string") {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
return true;
|
|
522
|
+
}
|
|
523
|
+
function printAppSetupNotes(dependencies) {
|
|
524
|
+
const deps = dependencies.map((dep) => dep.toLowerCase());
|
|
525
|
+
const usesNativeWind = deps.some((dep) => dep.includes("nativewind"));
|
|
526
|
+
const usesBottomSheet = deps.some((dep) => dep.includes("@gorhom/bottom-sheet"));
|
|
527
|
+
if (!usesNativeWind && !usesBottomSheet) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
console.log(chalk3.bold("\n\u{1F527} App-level setup required:"));
|
|
531
|
+
if (usesNativeWind) {
|
|
532
|
+
console.log(
|
|
533
|
+
chalk3.yellow(" \u2022 NativeWind: these files use `className` props.")
|
|
534
|
+
);
|
|
535
|
+
console.log(
|
|
536
|
+
chalk3.dim(
|
|
537
|
+
" Wire up babel.config.js, metro.config.js, and add this component"
|
|
538
|
+
)
|
|
539
|
+
);
|
|
540
|
+
console.log(
|
|
541
|
+
chalk3.dim(" directory to your Tailwind config's `content` globs.")
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
if (usesBottomSheet) {
|
|
545
|
+
console.log(
|
|
546
|
+
chalk3.yellow(" \u2022 Bottom sheets need a gesture-handler root.")
|
|
547
|
+
);
|
|
548
|
+
console.log(
|
|
549
|
+
chalk3.dim(
|
|
550
|
+
" Wrap your app root in <GestureHandlerRootView style={{ flex: 1 }}>"
|
|
551
|
+
)
|
|
552
|
+
);
|
|
553
|
+
console.log(chalk3.dim(" from 'react-native-gesture-handler'."));
|
|
554
|
+
}
|
|
555
|
+
console.log(chalk3.dim("\n Setup guides: https://docs.sublay.io"));
|
|
556
|
+
}
|
|
439
557
|
function getTargetPath(filePath, config, componentName) {
|
|
440
558
|
const componentDir = path5.join(config.paths.components, componentName);
|
|
441
559
|
if (filePath.startsWith("hooks/")) {
|
|
@@ -499,8 +617,10 @@ function shouldExcludeFile(filePath) {
|
|
|
499
617
|
}
|
|
500
618
|
|
|
501
619
|
// src/index.ts
|
|
620
|
+
var require2 = createRequire(import.meta.url);
|
|
621
|
+
var packageJson = require2("../package.json");
|
|
502
622
|
var program = new Command();
|
|
503
|
-
program.name("sublay").description("CLI for installing Sublay UI components").version(
|
|
623
|
+
program.name("sublay").description("CLI for installing Sublay UI components").version(packageJson.version);
|
|
504
624
|
program.command("init").description("Initialize Sublay configuration in your project").action(init);
|
|
505
625
|
program.command("add <component>").description("Add a component to your project").action(add);
|
|
506
626
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,42 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sublay/cli",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Sublay, maintained by Yanay Tsabary",
|
|
4
7
|
"description": "CLI for installing Sublay UI components",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"sublay",
|
|
10
|
+
"cli",
|
|
11
|
+
"components",
|
|
12
|
+
"comments",
|
|
13
|
+
"social",
|
|
14
|
+
"react",
|
|
15
|
+
"react-native",
|
|
16
|
+
"expo",
|
|
17
|
+
"typescript"
|
|
18
|
+
],
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://discord.com/invite/REKxnCJzPz"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://docs.sublay.io",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/sublay-io/monorepo.git",
|
|
26
|
+
"directory": "packages/cli"
|
|
27
|
+
},
|
|
5
28
|
"type": "module",
|
|
6
29
|
"bin": {
|
|
7
30
|
"sublay": "dist/index.js"
|
|
8
31
|
},
|
|
9
32
|
"files": [
|
|
10
|
-
"dist"
|
|
33
|
+
"dist",
|
|
34
|
+
"NOTICE"
|
|
11
35
|
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
14
|
-
"dev": "tsup src/index.ts --format esm --watch",
|
|
15
|
-
"typecheck": "tsc --noEmit"
|
|
16
|
-
},
|
|
17
36
|
"dependencies": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
37
|
+
"@babel/core": "^7.29.0",
|
|
38
|
+
"@babel/plugin-syntax-jsx": "^7.28.6",
|
|
39
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
20
40
|
"chalk": "^5.6.2",
|
|
21
|
-
"
|
|
41
|
+
"commander": "^14.0.3",
|
|
42
|
+
"execa": "^9.6.1",
|
|
22
43
|
"fs-extra": "^11.3.4",
|
|
23
44
|
"node-fetch": "^3.3.2",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"@babel/preset-typescript": "^7.28.5",
|
|
27
|
-
"@babel/plugin-syntax-jsx": "^7.28.6"
|
|
45
|
+
"ora": "^9.3.0",
|
|
46
|
+
"prompts": "^2.4.2"
|
|
28
47
|
},
|
|
29
48
|
"devDependencies": {
|
|
30
|
-
"@types/
|
|
31
|
-
"@types/prompts": "^2.4.9",
|
|
49
|
+
"@types/babel__core": "^7.20.5",
|
|
32
50
|
"@types/fs-extra": "^11.0.4",
|
|
51
|
+
"@types/node": "^25.9.2",
|
|
52
|
+
"@types/prompts": "^2.4.9",
|
|
33
53
|
"tsup": "^8.5.1",
|
|
34
|
-
"typescript": "^6.0.3"
|
|
54
|
+
"typescript": "^6.0.3",
|
|
55
|
+
"vitest": "^1.6.1"
|
|
35
56
|
},
|
|
36
57
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
58
|
+
"node": ">=20.5.0"
|
|
38
59
|
},
|
|
39
60
|
"publishConfig": {
|
|
40
61
|
"access": "public"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
65
|
+
"dev": "tsup src/index.ts --format esm --watch",
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"test": "pnpm run build && vitest run"
|
|
41
68
|
}
|
|
42
|
-
}
|
|
69
|
+
}
|