uirules 0.0.1 → 0.0.2
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/README.md +72 -0
- package/dist/app.js +152 -34
- package/package.json +6 -3
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# UIRules CLI
|
|
2
|
+
|
|
3
|
+
CLI tool to generate UI guidelines from your design system.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g uirules
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx uirules generate
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Local Development
|
|
18
|
+
|
|
19
|
+
### Testing locally with npm link
|
|
20
|
+
|
|
21
|
+
1. Build the CLI:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cd apps/cli
|
|
25
|
+
bun run build
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. Create a global symlink:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm link
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
3. In another project, link the package:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cd /path/to/your-project
|
|
38
|
+
npm link uirules
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
4. Now you can run the CLI:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx uirules generate
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Unlinking
|
|
48
|
+
|
|
49
|
+
When done testing, remove the symlinks:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# In the test project
|
|
53
|
+
npm unlink uirules
|
|
54
|
+
|
|
55
|
+
# In the CLI directory
|
|
56
|
+
npm unlink
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Development mode
|
|
60
|
+
|
|
61
|
+
For active development with auto-reload:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
cd apps/cli
|
|
65
|
+
bun run dev
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or run directly without building:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
bun run src/app.ts generate
|
|
72
|
+
```
|
package/dist/app.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
#!/usr/bin/env node
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -45,12 +44,14 @@ import path from "path";
|
|
|
45
44
|
import { fileURLToPath } from "url";
|
|
46
45
|
var init_esm_shims = __esm({
|
|
47
46
|
"../../node_modules/.bun/tsup@8.5.1+9c4d6a5e75102cb2/node_modules/tsup/assets/esm_shims.js"() {
|
|
47
|
+
"use strict";
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
// ../../node_modules/.bun/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js
|
|
52
52
|
var require_delayed_stream = __commonJS({
|
|
53
53
|
"../../node_modules/.bun/delayed-stream@1.0.0/node_modules/delayed-stream/lib/delayed_stream.js"(exports, module) {
|
|
54
|
+
"use strict";
|
|
54
55
|
init_esm_shims();
|
|
55
56
|
var Stream = __require("stream").Stream;
|
|
56
57
|
var util3 = __require("util");
|
|
@@ -143,6 +144,7 @@ var require_delayed_stream = __commonJS({
|
|
|
143
144
|
// ../../node_modules/.bun/combined-stream@1.0.8/node_modules/combined-stream/lib/combined_stream.js
|
|
144
145
|
var require_combined_stream = __commonJS({
|
|
145
146
|
"../../node_modules/.bun/combined-stream@1.0.8/node_modules/combined-stream/lib/combined_stream.js"(exports, module) {
|
|
147
|
+
"use strict";
|
|
146
148
|
init_esm_shims();
|
|
147
149
|
var util3 = __require("util");
|
|
148
150
|
var Stream = __require("stream").Stream;
|
|
@@ -8838,6 +8840,7 @@ var require_db = __commonJS({
|
|
|
8838
8840
|
// ../../node_modules/.bun/mime-db@1.52.0/node_modules/mime-db/index.js
|
|
8839
8841
|
var require_mime_db = __commonJS({
|
|
8840
8842
|
"../../node_modules/.bun/mime-db@1.52.0/node_modules/mime-db/index.js"(exports, module) {
|
|
8843
|
+
"use strict";
|
|
8841
8844
|
init_esm_shims();
|
|
8842
8845
|
module.exports = require_db();
|
|
8843
8846
|
}
|
|
@@ -8937,6 +8940,7 @@ var require_mime_types = __commonJS({
|
|
|
8937
8940
|
// ../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/defer.js
|
|
8938
8941
|
var require_defer = __commonJS({
|
|
8939
8942
|
"../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/defer.js"(exports, module) {
|
|
8943
|
+
"use strict";
|
|
8940
8944
|
init_esm_shims();
|
|
8941
8945
|
module.exports = defer;
|
|
8942
8946
|
function defer(fn) {
|
|
@@ -8953,6 +8957,7 @@ var require_defer = __commonJS({
|
|
|
8953
8957
|
// ../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/async.js
|
|
8954
8958
|
var require_async = __commonJS({
|
|
8955
8959
|
"../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/async.js"(exports, module) {
|
|
8960
|
+
"use strict";
|
|
8956
8961
|
init_esm_shims();
|
|
8957
8962
|
var defer = require_defer();
|
|
8958
8963
|
module.exports = async;
|
|
@@ -8977,6 +8982,7 @@ var require_async = __commonJS({
|
|
|
8977
8982
|
// ../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/abort.js
|
|
8978
8983
|
var require_abort = __commonJS({
|
|
8979
8984
|
"../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/abort.js"(exports, module) {
|
|
8985
|
+
"use strict";
|
|
8980
8986
|
init_esm_shims();
|
|
8981
8987
|
module.exports = abort;
|
|
8982
8988
|
function abort(state) {
|
|
@@ -8994,6 +9000,7 @@ var require_abort = __commonJS({
|
|
|
8994
9000
|
// ../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/iterate.js
|
|
8995
9001
|
var require_iterate = __commonJS({
|
|
8996
9002
|
"../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/iterate.js"(exports, module) {
|
|
9003
|
+
"use strict";
|
|
8997
9004
|
init_esm_shims();
|
|
8998
9005
|
var async = require_async();
|
|
8999
9006
|
var abort = require_abort();
|
|
@@ -9028,6 +9035,7 @@ var require_iterate = __commonJS({
|
|
|
9028
9035
|
// ../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/state.js
|
|
9029
9036
|
var require_state = __commonJS({
|
|
9030
9037
|
"../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/state.js"(exports, module) {
|
|
9038
|
+
"use strict";
|
|
9031
9039
|
init_esm_shims();
|
|
9032
9040
|
module.exports = state;
|
|
9033
9041
|
function state(list, sortMethod) {
|
|
@@ -9051,6 +9059,7 @@ var require_state = __commonJS({
|
|
|
9051
9059
|
// ../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/terminator.js
|
|
9052
9060
|
var require_terminator = __commonJS({
|
|
9053
9061
|
"../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/lib/terminator.js"(exports, module) {
|
|
9062
|
+
"use strict";
|
|
9054
9063
|
init_esm_shims();
|
|
9055
9064
|
var abort = require_abort();
|
|
9056
9065
|
var async = require_async();
|
|
@@ -9069,6 +9078,7 @@ var require_terminator = __commonJS({
|
|
|
9069
9078
|
// ../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/parallel.js
|
|
9070
9079
|
var require_parallel = __commonJS({
|
|
9071
9080
|
"../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/parallel.js"(exports, module) {
|
|
9081
|
+
"use strict";
|
|
9072
9082
|
init_esm_shims();
|
|
9073
9083
|
var iterate = require_iterate();
|
|
9074
9084
|
var initState = require_state();
|
|
@@ -9097,6 +9107,7 @@ var require_parallel = __commonJS({
|
|
|
9097
9107
|
// ../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/serialOrdered.js
|
|
9098
9108
|
var require_serialOrdered = __commonJS({
|
|
9099
9109
|
"../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/serialOrdered.js"(exports, module) {
|
|
9110
|
+
"use strict";
|
|
9100
9111
|
init_esm_shims();
|
|
9101
9112
|
var iterate = require_iterate();
|
|
9102
9113
|
var initState = require_state();
|
|
@@ -9132,6 +9143,7 @@ var require_serialOrdered = __commonJS({
|
|
|
9132
9143
|
// ../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/serial.js
|
|
9133
9144
|
var require_serial = __commonJS({
|
|
9134
9145
|
"../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/serial.js"(exports, module) {
|
|
9146
|
+
"use strict";
|
|
9135
9147
|
init_esm_shims();
|
|
9136
9148
|
var serialOrdered = require_serialOrdered();
|
|
9137
9149
|
module.exports = serial;
|
|
@@ -9144,6 +9156,7 @@ var require_serial = __commonJS({
|
|
|
9144
9156
|
// ../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/index.js
|
|
9145
9157
|
var require_asynckit = __commonJS({
|
|
9146
9158
|
"../../node_modules/.bun/asynckit@0.4.0/node_modules/asynckit/index.js"(exports, module) {
|
|
9159
|
+
"use strict";
|
|
9147
9160
|
init_esm_shims();
|
|
9148
9161
|
module.exports = {
|
|
9149
9162
|
parallel: require_parallel(),
|
|
@@ -10443,6 +10456,7 @@ var require_proxy_from_env = __commonJS({
|
|
|
10443
10456
|
// ../../node_modules/.bun/ms@2.1.3/node_modules/ms/index.js
|
|
10444
10457
|
var require_ms = __commonJS({
|
|
10445
10458
|
"../../node_modules/.bun/ms@2.1.3/node_modules/ms/index.js"(exports, module) {
|
|
10459
|
+
"use strict";
|
|
10446
10460
|
init_esm_shims();
|
|
10447
10461
|
var s = 1e3;
|
|
10448
10462
|
var m = s * 60;
|
|
@@ -10560,6 +10574,7 @@ var require_ms = __commonJS({
|
|
|
10560
10574
|
// ../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/common.js
|
|
10561
10575
|
var require_common = __commonJS({
|
|
10562
10576
|
"../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/common.js"(exports, module) {
|
|
10577
|
+
"use strict";
|
|
10563
10578
|
init_esm_shims();
|
|
10564
10579
|
function setup(env2) {
|
|
10565
10580
|
createDebug.debug = createDebug;
|
|
@@ -10738,6 +10753,7 @@ var require_common = __commonJS({
|
|
|
10738
10753
|
// ../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/browser.js
|
|
10739
10754
|
var require_browser = __commonJS({
|
|
10740
10755
|
"../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/browser.js"(exports, module) {
|
|
10756
|
+
"use strict";
|
|
10741
10757
|
init_esm_shims();
|
|
10742
10758
|
exports.formatArgs = formatArgs;
|
|
10743
10759
|
exports.save = save;
|
|
@@ -11041,6 +11057,7 @@ function createSupportsColor(stream4, options = {}) {
|
|
|
11041
11057
|
var env, flagForceColor, supportsColor, supports_color_default;
|
|
11042
11058
|
var init_supports_color = __esm({
|
|
11043
11059
|
"../../node_modules/.bun/supports-color@10.2.2/node_modules/supports-color/index.js"() {
|
|
11060
|
+
"use strict";
|
|
11044
11061
|
init_esm_shims();
|
|
11045
11062
|
({ env } = process2);
|
|
11046
11063
|
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
@@ -11059,6 +11076,7 @@ var init_supports_color = __esm({
|
|
|
11059
11076
|
// ../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/node.js
|
|
11060
11077
|
var require_node = __commonJS({
|
|
11061
11078
|
"../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/node.js"(exports, module) {
|
|
11079
|
+
"use strict";
|
|
11062
11080
|
init_esm_shims();
|
|
11063
11081
|
var tty2 = __require("tty");
|
|
11064
11082
|
var util3 = __require("util");
|
|
@@ -11234,6 +11252,7 @@ var require_node = __commonJS({
|
|
|
11234
11252
|
// ../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/index.js
|
|
11235
11253
|
var require_src = __commonJS({
|
|
11236
11254
|
"../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/index.js"(exports, module) {
|
|
11255
|
+
"use strict";
|
|
11237
11256
|
init_esm_shims();
|
|
11238
11257
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
11239
11258
|
module.exports = require_browser();
|
|
@@ -11246,6 +11265,7 @@ var require_src = __commonJS({
|
|
|
11246
11265
|
// ../../node_modules/.bun/follow-redirects@1.15.11/node_modules/follow-redirects/debug.js
|
|
11247
11266
|
var require_debug = __commonJS({
|
|
11248
11267
|
"../../node_modules/.bun/follow-redirects@1.15.11/node_modules/follow-redirects/debug.js"(exports, module) {
|
|
11268
|
+
"use strict";
|
|
11249
11269
|
init_esm_shims();
|
|
11250
11270
|
var debug;
|
|
11251
11271
|
module.exports = function() {
|
|
@@ -11267,6 +11287,7 @@ var require_debug = __commonJS({
|
|
|
11267
11287
|
// ../../node_modules/.bun/follow-redirects@1.15.11/node_modules/follow-redirects/index.js
|
|
11268
11288
|
var require_follow_redirects = __commonJS({
|
|
11269
11289
|
"../../node_modules/.bun/follow-redirects@1.15.11/node_modules/follow-redirects/index.js"(exports, module) {
|
|
11290
|
+
"use strict";
|
|
11270
11291
|
init_esm_shims();
|
|
11271
11292
|
var url2 = __require("url");
|
|
11272
11293
|
var URL2 = url2.URL;
|
|
@@ -11766,15 +11787,14 @@ init_esm_shims();
|
|
|
11766
11787
|
import "dotenv/config";
|
|
11767
11788
|
import { Command as Command2 } from "commander";
|
|
11768
11789
|
|
|
11769
|
-
// src/commands/index.ts
|
|
11770
|
-
init_esm_shims();
|
|
11771
|
-
|
|
11772
11790
|
// src/commands/generate.ts
|
|
11773
11791
|
init_esm_shims();
|
|
11774
11792
|
import { Command } from "commander";
|
|
11775
11793
|
import ora from "ora";
|
|
11776
|
-
import { readFile, writeFile } from "fs/promises";
|
|
11794
|
+
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
11777
11795
|
import { join as join3 } from "path";
|
|
11796
|
+
import { Readable as Readable2 } from "stream";
|
|
11797
|
+
import unzipper from "unzipper";
|
|
11778
11798
|
|
|
11779
11799
|
// ../../packages/sdk/src/index.ts
|
|
11780
11800
|
init_esm_shims();
|
|
@@ -11786,12 +11806,14 @@ __export(api_exports, {
|
|
|
11786
11806
|
createProject: () => createProject,
|
|
11787
11807
|
deleteProject: () => deleteProject,
|
|
11788
11808
|
exportProject: () => exportProject,
|
|
11809
|
+
exportSkills: () => exportSkills,
|
|
11789
11810
|
getProject: () => getProject,
|
|
11790
11811
|
listProjects: () => listProjects,
|
|
11791
11812
|
needInitBrand: () => needInitBrand,
|
|
11792
11813
|
needInitProject: () => needInitProject,
|
|
11793
11814
|
previewGuidelines: () => previewGuidelines,
|
|
11794
11815
|
updateProject: () => updateProject,
|
|
11816
|
+
updateProjectGuidelines: () => updateProjectGuidelines,
|
|
11795
11817
|
uploadGithubProject: () => uploadGithubProject,
|
|
11796
11818
|
uploadProject: () => uploadProject
|
|
11797
11819
|
});
|
|
@@ -15510,15 +15532,17 @@ var {
|
|
|
15510
15532
|
} = axios_default;
|
|
15511
15533
|
|
|
15512
15534
|
// ../../packages/sdk/src/client.ts
|
|
15513
|
-
var API_URL = process.env.UIRULES_API_URL || "
|
|
15535
|
+
var API_URL = process.env.UIRULES_API_URL || "http://localhost:4000/";
|
|
15514
15536
|
var AXIOS_INSTANCE = axios_default.create({
|
|
15515
15537
|
baseURL: API_URL,
|
|
15516
15538
|
withCredentials: true
|
|
15517
15539
|
});
|
|
15518
15540
|
var customInstance = async (config, options) => {
|
|
15541
|
+
const responseType = config.responseType === "blob" ? "arraybuffer" : config.responseType;
|
|
15519
15542
|
const { data } = await AXIOS_INSTANCE({
|
|
15520
15543
|
...config,
|
|
15521
|
-
...options
|
|
15544
|
+
...options,
|
|
15545
|
+
responseType
|
|
15522
15546
|
});
|
|
15523
15547
|
return data;
|
|
15524
15548
|
};
|
|
@@ -15648,6 +15672,30 @@ var uploadGithubProject = (id, uploadGithubRequest, options) => {
|
|
|
15648
15672
|
options
|
|
15649
15673
|
);
|
|
15650
15674
|
};
|
|
15675
|
+
var updateProjectGuidelines = (updateGuidelinesRequest, options) => {
|
|
15676
|
+
const formData = new FormData();
|
|
15677
|
+
formData.append(`brandContent`, JSON.stringify(updateGuidelinesRequest.brandContent));
|
|
15678
|
+
formData.append(`guidelineContent`, JSON.stringify(updateGuidelinesRequest.guidelineContent));
|
|
15679
|
+
return customInstance(
|
|
15680
|
+
{
|
|
15681
|
+
url: `/api/project/guidelines`,
|
|
15682
|
+
method: "PUT",
|
|
15683
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
15684
|
+
data: formData
|
|
15685
|
+
},
|
|
15686
|
+
options
|
|
15687
|
+
);
|
|
15688
|
+
};
|
|
15689
|
+
var exportSkills = (options) => {
|
|
15690
|
+
return customInstance(
|
|
15691
|
+
{
|
|
15692
|
+
url: `/api/project/skills`,
|
|
15693
|
+
method: "GET",
|
|
15694
|
+
responseType: "blob"
|
|
15695
|
+
},
|
|
15696
|
+
options
|
|
15697
|
+
);
|
|
15698
|
+
};
|
|
15651
15699
|
var exportProject = (id, options) => {
|
|
15652
15700
|
return customInstance(
|
|
15653
15701
|
{
|
|
@@ -15666,7 +15714,7 @@ init_esm_shims();
|
|
|
15666
15714
|
init_esm_shims();
|
|
15667
15715
|
import http3 from "http";
|
|
15668
15716
|
import open from "open";
|
|
15669
|
-
var WEB_URL = process.env.UIRULES_WEB_URL || "
|
|
15717
|
+
var WEB_URL = process.env.UIRULES_WEB_URL || "http://localhost:3000";
|
|
15670
15718
|
async function authenticate() {
|
|
15671
15719
|
return new Promise((resolve, reject) => {
|
|
15672
15720
|
const server = http3.createServer((req, res) => {
|
|
@@ -15767,6 +15815,11 @@ function saveConfig(updates) {
|
|
|
15767
15815
|
const updated = { ...current, ...updates };
|
|
15768
15816
|
writeFileSync(CONFIG_FILE, JSON.stringify(updated, null, 2));
|
|
15769
15817
|
}
|
|
15818
|
+
function clearConfig() {
|
|
15819
|
+
if (existsSync(CONFIG_FILE)) {
|
|
15820
|
+
writeFileSync(CONFIG_FILE, "{}");
|
|
15821
|
+
}
|
|
15822
|
+
}
|
|
15770
15823
|
function isAuthenticated() {
|
|
15771
15824
|
const config = getConfig();
|
|
15772
15825
|
return !!config.sessionToken;
|
|
@@ -15785,6 +15838,27 @@ function getAuthOptions() {
|
|
|
15785
15838
|
}
|
|
15786
15839
|
};
|
|
15787
15840
|
}
|
|
15841
|
+
function isUnauthorizedError(error) {
|
|
15842
|
+
if (typeof error !== "object" || error === null) return false;
|
|
15843
|
+
const err = error;
|
|
15844
|
+
return err.response?.status === 401;
|
|
15845
|
+
}
|
|
15846
|
+
async function withAuthRetry(apiCall, onReAuth) {
|
|
15847
|
+
let authOptions = getAuthOptions();
|
|
15848
|
+
try {
|
|
15849
|
+
return await apiCall(authOptions);
|
|
15850
|
+
} catch (error) {
|
|
15851
|
+
if (isUnauthorizedError(error)) {
|
|
15852
|
+
clearConfig();
|
|
15853
|
+
onReAuth?.();
|
|
15854
|
+
const token = await authenticate();
|
|
15855
|
+
saveConfig({ sessionToken: token });
|
|
15856
|
+
authOptions = getAuthOptions();
|
|
15857
|
+
return await apiCall(authOptions);
|
|
15858
|
+
}
|
|
15859
|
+
throw error;
|
|
15860
|
+
}
|
|
15861
|
+
}
|
|
15788
15862
|
|
|
15789
15863
|
// src/lib/scanner.ts
|
|
15790
15864
|
init_esm_shims();
|
|
@@ -15849,6 +15923,9 @@ async function promptSelectFile(files) {
|
|
|
15849
15923
|
// src/commands/generate.ts
|
|
15850
15924
|
var generateCommand = new Command("generate").description("Initialize UIRules and generate guidelines").action(async () => {
|
|
15851
15925
|
const spinner = ora();
|
|
15926
|
+
const handleReAuth = () => {
|
|
15927
|
+
spinner.start("Session expired. Re-authenticating...");
|
|
15928
|
+
};
|
|
15852
15929
|
try {
|
|
15853
15930
|
if (!isAuthenticated()) {
|
|
15854
15931
|
spinner.start("Opening browser for authentication...");
|
|
@@ -15858,22 +15935,18 @@ var generateCommand = new Command("generate").description("Initialize UIRules an
|
|
|
15858
15935
|
} else {
|
|
15859
15936
|
console.log("Already authenticated.\n");
|
|
15860
15937
|
}
|
|
15861
|
-
|
|
15862
|
-
|
|
15863
|
-
const projects = await api_exports.listProjects(authOptions);
|
|
15938
|
+
spinner.start("Checking your brand...");
|
|
15939
|
+
const projects = await withAuthRetry(api_exports.listProjects, handleReAuth);
|
|
15864
15940
|
spinner.stop();
|
|
15865
|
-
let
|
|
15866
|
-
|
|
15867
|
-
|
|
15868
|
-
|
|
15869
|
-
|
|
15870
|
-
const project = await api_exports.createProject({ name }, authOptions);
|
|
15871
|
-
projectId = project.id;
|
|
15872
|
-
spinner.succeed(`Project "${name}" created!`);
|
|
15941
|
+
let projectName;
|
|
15942
|
+
const hasProjects = projects.length > 0;
|
|
15943
|
+
if (!hasProjects) {
|
|
15944
|
+
console.log("No brand found. Let's create one!\n");
|
|
15945
|
+
projectName = await promptProjectName();
|
|
15873
15946
|
} else {
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
Using
|
|
15947
|
+
const firstProject = projects[0];
|
|
15948
|
+
projectName = firstProject.name;
|
|
15949
|
+
console.log(`Using brand: ${projectName}
|
|
15877
15950
|
`);
|
|
15878
15951
|
}
|
|
15879
15952
|
spinner.start("Scanning for globals.css...");
|
|
@@ -15887,26 +15960,74 @@ Using project: ${projects[0].name}
|
|
|
15887
15960
|
process.exit(1);
|
|
15888
15961
|
}
|
|
15889
15962
|
const selectedFile = cssFiles.length === 1 ? cssFiles[0] : await promptSelectFile(cssFiles);
|
|
15890
|
-
console.log(`
|
|
15891
|
-
Using: ${selectedFile}
|
|
15963
|
+
console.log(`Using: ${selectedFile}
|
|
15892
15964
|
`);
|
|
15893
15965
|
spinner.start("Reading CSS file...");
|
|
15894
15966
|
const cssPath = join3(process.cwd(), selectedFile);
|
|
15895
15967
|
const cssContent = await readFile(cssPath, "utf-8");
|
|
15896
15968
|
spinner.succeed(`Read ${selectedFile}`);
|
|
15897
15969
|
spinner.start("Generating guidelines...");
|
|
15898
|
-
const
|
|
15899
|
-
{
|
|
15900
|
-
|
|
15901
|
-
|
|
15902
|
-
}
|
|
15903
|
-
|
|
15970
|
+
const guidelinesPayload = {
|
|
15971
|
+
css: new File([cssContent], "globals.css", { type: "text/css" }),
|
|
15972
|
+
components: new File(["{}"], "components.json", {
|
|
15973
|
+
type: "application/json"
|
|
15974
|
+
})
|
|
15975
|
+
};
|
|
15976
|
+
const result = await withAuthRetry(
|
|
15977
|
+
(opts) => api_exports.previewGuidelines(guidelinesPayload, opts),
|
|
15978
|
+
handleReAuth
|
|
15904
15979
|
);
|
|
15905
15980
|
spinner.succeed("Guidelines generated!");
|
|
15981
|
+
const brand = result.brands?.at(0);
|
|
15982
|
+
const guideline = result.guidelines?.at(0);
|
|
15983
|
+
if (!brand || !guideline) {
|
|
15984
|
+
throw new Error("Failed to generate guideline content");
|
|
15985
|
+
}
|
|
15986
|
+
spinner.start("Saving brand...");
|
|
15987
|
+
let savedProject;
|
|
15988
|
+
if (!hasProjects) {
|
|
15989
|
+
savedProject = await withAuthRetry(
|
|
15990
|
+
(opts) => api_exports.completeProject(
|
|
15991
|
+
{
|
|
15992
|
+
name: projectName,
|
|
15993
|
+
brandContent: brand.content,
|
|
15994
|
+
guidelineContent: guideline.content
|
|
15995
|
+
},
|
|
15996
|
+
opts
|
|
15997
|
+
),
|
|
15998
|
+
handleReAuth
|
|
15999
|
+
);
|
|
16000
|
+
} else {
|
|
16001
|
+
savedProject = await withAuthRetry(
|
|
16002
|
+
(opts) => api_exports.updateProjectGuidelines(
|
|
16003
|
+
{
|
|
16004
|
+
brandContent: brand.content,
|
|
16005
|
+
guidelineContent: guideline.content
|
|
16006
|
+
},
|
|
16007
|
+
opts
|
|
16008
|
+
),
|
|
16009
|
+
handleReAuth
|
|
16010
|
+
);
|
|
16011
|
+
}
|
|
16012
|
+
spinner.succeed("Brand saved!");
|
|
15906
16013
|
spinner.start("Writing export.md...");
|
|
15907
|
-
const markdown =
|
|
16014
|
+
const markdown = await withAuthRetry(
|
|
16015
|
+
(opts) => api_exports.exportProject(savedProject.project.id, opts),
|
|
16016
|
+
handleReAuth
|
|
16017
|
+
);
|
|
15908
16018
|
await writeFile("export.md", markdown);
|
|
15909
16019
|
spinner.succeed("Guidelines saved to export.md!");
|
|
16020
|
+
spinner.start("Installing Cursor Skills...");
|
|
16021
|
+
const skillsBuffer = await withAuthRetry(
|
|
16022
|
+
(opts) => api_exports.exportSkills(opts),
|
|
16023
|
+
handleReAuth
|
|
16024
|
+
);
|
|
16025
|
+
const targetDir = join3(process.cwd(), ".cursor", "skills");
|
|
16026
|
+
await mkdir(targetDir, { recursive: true });
|
|
16027
|
+
await new Promise((resolve, reject) => {
|
|
16028
|
+
Readable2.from(skillsBuffer).pipe(unzipper.Extract({ path: process.cwd() })).on("close", resolve).on("error", reject);
|
|
16029
|
+
});
|
|
16030
|
+
spinner.succeed("Cursor Skills installed to .cursor/skills/");
|
|
15910
16031
|
console.log("\nDone! Your UI guidelines are ready.\n");
|
|
15911
16032
|
} catch (error) {
|
|
15912
16033
|
spinner.fail("An error occurred");
|
|
@@ -15918,9 +16039,6 @@ Error: ${error.message}
|
|
|
15918
16039
|
process.exit(1);
|
|
15919
16040
|
}
|
|
15920
16041
|
});
|
|
15921
|
-
function formatGuidelines(result) {
|
|
15922
|
-
return "# UI Guidelines\n\n```json\n" + JSON.stringify(result, null, 2) + "\n```\n";
|
|
15923
|
-
}
|
|
15924
16042
|
|
|
15925
16043
|
// src/app.ts
|
|
15926
16044
|
var program = new Command2().name("uirules").description("Generate UI guidelines from your design system").version("0.0.1");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uirules",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "CLI tool to generate UI guidelines from your design system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -24,21 +24,23 @@
|
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "https://github.com/UI-Rules/app/issues"
|
|
26
26
|
},
|
|
27
|
-
"author": "",
|
|
27
|
+
"author": "kapishdima",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
|
-
"
|
|
33
|
+
"develop": "bun --watch ./src/app.ts",
|
|
34
34
|
"start": "node dist/app.js",
|
|
35
35
|
"build": "tsup",
|
|
36
36
|
"prepublishOnly": "bun run build"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@semantic-release/changelog": "^6.0.3",
|
|
40
|
+
"@semantic-release/exec": "^7.1.0",
|
|
40
41
|
"@semantic-release/git": "^10.0.1",
|
|
41
42
|
"@types/node": "^22.15.3",
|
|
43
|
+
"@types/unzipper": "^0.10.11",
|
|
42
44
|
"@uirules/auth": "*",
|
|
43
45
|
"@uirules/core": "*",
|
|
44
46
|
"@uirules/db": "*",
|
|
@@ -58,6 +60,7 @@
|
|
|
58
60
|
"open": "^10.0.0",
|
|
59
61
|
"ora": "^9.0.0",
|
|
60
62
|
"tsup": "^8.5.1",
|
|
63
|
+
"unzipper": "^0.12.3",
|
|
61
64
|
"zod": "^3.23.0"
|
|
62
65
|
}
|
|
63
66
|
}
|