@yubild/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/dist/commands/deploy.d.ts +6 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +73 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/diff.d.ts +6 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +97 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/export.d.ts +9 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +93 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +95 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +81 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +6 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +17 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/projects.d.ts +6 -0
- package/dist/commands/projects.d.ts.map +1 -0
- package/dist/commands/projects.js +76 -0
- package/dist/commands/projects.js.map +1 -0
- package/dist/commands/publish.d.ts +8 -0
- package/dist/commands/publish.d.ts.map +1 -0
- package/dist/commands/publish.js +81 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/pull.d.ts +8 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +86 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +6 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +73 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/sync.d.ts +8 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +111 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/watch.d.ts +8 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +91 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/commands/whoami.d.ts +6 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +32 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api-client.d.ts +141 -0
- package/dist/lib/api-client.d.ts.map +1 -0
- package/dist/lib/api-client.js +154 -0
- package/dist/lib/api-client.js.map +1 -0
- package/dist/lib/auth.d.ts +36 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +108 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/config.d.ts +28 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +100 -0
- package/dist/lib/config.js.map +1 -0
- package/package.json +30 -0
- package/src/commands/deploy.ts +42 -0
- package/src/commands/diff.ts +81 -0
- package/src/commands/export.ts +71 -0
- package/src/commands/init.ts +69 -0
- package/src/commands/login.ts +52 -0
- package/src/commands/logout.ts +16 -0
- package/src/commands/projects.ts +53 -0
- package/src/commands/publish.ts +51 -0
- package/src/commands/pull.ts +59 -0
- package/src/commands/push.ts +42 -0
- package/src/commands/sync.ts +86 -0
- package/src/commands/watch.ts +71 -0
- package/src/commands/whoami.ts +31 -0
- package/src/index.ts +104 -0
- package/src/lib/api-client.ts +231 -0
- package/src/lib/auth.ts +86 -0
- package/src/lib/config.ts +77 -0
- package/src/types/esm-modules.d.ts +41 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* yubild whoami
|
|
4
|
+
* Show the currently authenticated user
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.whoamiCommand = whoamiCommand;
|
|
8
|
+
const auth_1 = require("../lib/auth");
|
|
9
|
+
const api_client_1 = require("../lib/api-client");
|
|
10
|
+
async function whoamiCommand() {
|
|
11
|
+
if (!(0, auth_1.isAuthenticated)()) {
|
|
12
|
+
console.log('Not authenticated. Run `yubild login` to get started.');
|
|
13
|
+
process.exit(0);
|
|
14
|
+
}
|
|
15
|
+
const creds = (0, auth_1.loadCredentials)();
|
|
16
|
+
if (!creds) {
|
|
17
|
+
console.log('Not authenticated. Run `yubild login` to get started.');
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const client = new api_client_1.ApiClient();
|
|
22
|
+
const { user } = await client.authenticate();
|
|
23
|
+
console.log(`Authenticated as: ${user.email}`);
|
|
24
|
+
console.log(`API URL: ${creds.apiUrl}`);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
console.log(`Stored email: ${creds.email || 'unknown'}`);
|
|
28
|
+
console.log(`API URL: ${creds.apiUrl}`);
|
|
29
|
+
console.log('(Could not verify - API may be unreachable)');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,sCAsBC;AAzBD,sCAA+D;AAC/D,kDAA8C;AAEvC,KAAK,UAAU,aAAa;IACjC,IAAI,CAAC,IAAA,sBAAe,GAAE,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;QACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAG,IAAA,sBAAe,GAAE,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;QACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,sBAAS,EAAE,CAAC;QAC/B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,CAAC,KAAK,IAAI,SAAS,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;GAGG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Yubild CLI
|
|
5
|
+
* Pull design tokens from Yubild into your project
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const login_1 = require("./commands/login");
|
|
10
|
+
const init_1 = require("./commands/init");
|
|
11
|
+
const pull_1 = require("./commands/pull");
|
|
12
|
+
const whoami_1 = require("./commands/whoami");
|
|
13
|
+
const logout_1 = require("./commands/logout");
|
|
14
|
+
const sync_1 = require("./commands/sync");
|
|
15
|
+
const diff_1 = require("./commands/diff");
|
|
16
|
+
const push_1 = require("./commands/push");
|
|
17
|
+
const export_1 = require("./commands/export");
|
|
18
|
+
const deploy_1 = require("./commands/deploy");
|
|
19
|
+
const publish_1 = require("./commands/publish");
|
|
20
|
+
const projects_1 = require("./commands/projects");
|
|
21
|
+
const watch_1 = require("./commands/watch");
|
|
22
|
+
const program = new commander_1.Command();
|
|
23
|
+
program
|
|
24
|
+
.name('yubild')
|
|
25
|
+
.description('Yubild CLI - Design system token management')
|
|
26
|
+
.version('0.1.0');
|
|
27
|
+
program
|
|
28
|
+
.command('login')
|
|
29
|
+
.description('Authenticate with your Yubild account')
|
|
30
|
+
.option('--api-key <key>', 'API key (starts with nxui_sk_)')
|
|
31
|
+
.option('--api-url <url>', 'Yubild API URL', 'https://yubild.com')
|
|
32
|
+
.action(login_1.loginCommand);
|
|
33
|
+
program
|
|
34
|
+
.command('init')
|
|
35
|
+
.description('Initialize a project and create .yubildrc configuration')
|
|
36
|
+
.option('--project-id <id>', 'Yubild project ID')
|
|
37
|
+
.action(init_1.initCommand);
|
|
38
|
+
program
|
|
39
|
+
.command('pull')
|
|
40
|
+
.description('Pull latest design tokens into your project')
|
|
41
|
+
.option('-f, --format <format>', 'Specific format to pull (css, tailwind, json)')
|
|
42
|
+
.action(pull_1.pullCommand);
|
|
43
|
+
program
|
|
44
|
+
.command('whoami')
|
|
45
|
+
.description('Show the currently authenticated user')
|
|
46
|
+
.action(whoami_1.whoamiCommand);
|
|
47
|
+
program
|
|
48
|
+
.command('logout')
|
|
49
|
+
.description('Clear stored authentication credentials')
|
|
50
|
+
.action(logout_1.logoutCommand);
|
|
51
|
+
program
|
|
52
|
+
.command('sync')
|
|
53
|
+
.description('Sync design tokens between local project and Figma')
|
|
54
|
+
.option('--auto-merge', 'Automatically merge changes without prompting', false)
|
|
55
|
+
.action(sync_1.syncCommand);
|
|
56
|
+
program
|
|
57
|
+
.command('diff')
|
|
58
|
+
.description('Show differences between local tokens and Figma tokens')
|
|
59
|
+
.action(diff_1.diffCommand);
|
|
60
|
+
program
|
|
61
|
+
.command('push')
|
|
62
|
+
.description('Push design tokens to Figma')
|
|
63
|
+
.action(push_1.pushCommand);
|
|
64
|
+
program
|
|
65
|
+
.command('export')
|
|
66
|
+
.description('Export design tokens in a specific format')
|
|
67
|
+
.addOption(new commander_1.Option('-f, --format <format>', 'Output format').choices(['css', 'tailwind', 'json', 'scss', 'react', 'vue', 'angular']).makeOptionMandatory())
|
|
68
|
+
.option('-o, --output <dir>', 'Output directory')
|
|
69
|
+
.action(export_1.exportCommand);
|
|
70
|
+
program
|
|
71
|
+
.command('deploy')
|
|
72
|
+
.description('Deploy design tokens to CDN')
|
|
73
|
+
.action(deploy_1.deployCommand);
|
|
74
|
+
program
|
|
75
|
+
.command('publish')
|
|
76
|
+
.description('Publish design tokens to Git via Pull Request')
|
|
77
|
+
.option('--repo <repositoryId>', 'Target repository ID')
|
|
78
|
+
.action(publish_1.publishCommand);
|
|
79
|
+
program
|
|
80
|
+
.command('projects')
|
|
81
|
+
.description('List all projects')
|
|
82
|
+
.action(projects_1.projectsCommand);
|
|
83
|
+
program
|
|
84
|
+
.command('watch')
|
|
85
|
+
.description('Watch for token changes and auto-sync')
|
|
86
|
+
.option('--interval <seconds>', 'Polling interval in seconds', '30')
|
|
87
|
+
.action(watch_1.watchCommand);
|
|
88
|
+
program.parse();
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA;;;GAGG;;AAEH,yCAA4C;AAC5C,4CAAgD;AAChD,0CAA8C;AAC9C,0CAA8C;AAC9C,8CAAkD;AAClD,8CAAkD;AAClD,0CAA8C;AAC9C,0CAA8C;AAC9C,0CAA8C;AAC9C,8CAAkD;AAClD,8CAAkD;AAClD,gDAAoD;AACpD,kDAAsD;AACtD,4CAAgD;AAEhD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ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C,CAAC;AAEvB,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,2CAA2C,CAAC;KACxD,SAAS,CAAC,IAAI,kBAAM,CAAC,uBAAuB,EAAE,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC;KAC7J,MAAM,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;KAChD,MAAM,CAAC,sBAAa,CAAC,CAAC;AAEzB,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,6BAA6B,CAAC;KAC1C,MAAM,CAAC,sBAAa,CAAC,CAAC;AAEzB,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,+CAA+C,CAAC;KAC5D,MAAM,CAAC,uBAAuB,EAAE,sBAAsB,CAAC;KACvD,MAAM,CAAC,wBAAc,CAAC,CAAC;AAE1B,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,mBAAmB,CAAC;KAChC,MAAM,CAAC,0BAAe,CAAC,CAAC;AAE3B,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,uCAAuC,CAAC;KACpD,MAAM,CAAC,sBAAsB,EAAE,6BAA6B,EAAE,IAAI,CAAC;KACnE,MAAM,CAAC,oBAAY,CAAC,CAAC;AAExB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for Yubild API
|
|
3
|
+
*/
|
|
4
|
+
export declare class ApiClient {
|
|
5
|
+
private baseUrl;
|
|
6
|
+
private apiKey;
|
|
7
|
+
constructor(apiUrl?: string, apiKey?: string);
|
|
8
|
+
private request;
|
|
9
|
+
private rawRequest;
|
|
10
|
+
/**
|
|
11
|
+
* Authenticate with API key
|
|
12
|
+
*/
|
|
13
|
+
authenticate(): Promise<{
|
|
14
|
+
user: {
|
|
15
|
+
email: string;
|
|
16
|
+
name: string | null;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Get project status
|
|
21
|
+
*/
|
|
22
|
+
getProjectStatus(projectId: string): Promise<{
|
|
23
|
+
project: {
|
|
24
|
+
name: string;
|
|
25
|
+
version: string;
|
|
26
|
+
framework: string;
|
|
27
|
+
};
|
|
28
|
+
lastBuild: {
|
|
29
|
+
version: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
} | null;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Pull tokens for a project
|
|
35
|
+
*/
|
|
36
|
+
pullTokens(projectId: string, formats: string[]): Promise<{
|
|
37
|
+
files: Array<{
|
|
38
|
+
path: string;
|
|
39
|
+
content: string;
|
|
40
|
+
}>;
|
|
41
|
+
version: string;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Sync tokens between local and Figma
|
|
45
|
+
*/
|
|
46
|
+
syncTokens(projectId: string, autoMerge: boolean): Promise<{
|
|
47
|
+
synced: boolean;
|
|
48
|
+
diff?: {
|
|
49
|
+
entries: Array<{
|
|
50
|
+
tokenKey: string;
|
|
51
|
+
status: string;
|
|
52
|
+
localValue?: string;
|
|
53
|
+
figmaValue?: string;
|
|
54
|
+
}>;
|
|
55
|
+
summary: {
|
|
56
|
+
added: number;
|
|
57
|
+
modified: number;
|
|
58
|
+
removed: number;
|
|
59
|
+
unchanged: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
summary?: {
|
|
63
|
+
added: number;
|
|
64
|
+
modified: number;
|
|
65
|
+
removed: number;
|
|
66
|
+
unchanged: number;
|
|
67
|
+
};
|
|
68
|
+
warnings?: string[];
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Diff tokens between local and Figma
|
|
72
|
+
*/
|
|
73
|
+
diffTokens(projectId: string): Promise<{
|
|
74
|
+
entries: Array<{
|
|
75
|
+
tokenKey: string;
|
|
76
|
+
status: string;
|
|
77
|
+
localValue?: string;
|
|
78
|
+
figmaValue?: string;
|
|
79
|
+
}>;
|
|
80
|
+
summary: {
|
|
81
|
+
added: number;
|
|
82
|
+
modified: number;
|
|
83
|
+
removed: number;
|
|
84
|
+
unchanged: number;
|
|
85
|
+
};
|
|
86
|
+
hasConflicts: boolean;
|
|
87
|
+
warnings?: string[];
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Push tokens to Figma
|
|
91
|
+
*/
|
|
92
|
+
pushToFigma(projectId: string): Promise<{
|
|
93
|
+
data: {
|
|
94
|
+
variables: unknown[];
|
|
95
|
+
projectName: string;
|
|
96
|
+
exportedAt: string;
|
|
97
|
+
};
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Export tokens in a specific format
|
|
101
|
+
*/
|
|
102
|
+
exportTokens(projectId: string, format: string): Promise<{
|
|
103
|
+
files: Array<{
|
|
104
|
+
path: string;
|
|
105
|
+
content: string;
|
|
106
|
+
}>;
|
|
107
|
+
format: string;
|
|
108
|
+
version: string;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Deploy tokens to CDN
|
|
112
|
+
*/
|
|
113
|
+
deployToCdn(projectId: string): Promise<{
|
|
114
|
+
deployed: boolean;
|
|
115
|
+
version: string;
|
|
116
|
+
buildId: string;
|
|
117
|
+
cdnUrl: string;
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* Publish tokens to Git via Pull Request
|
|
121
|
+
*/
|
|
122
|
+
publishToGit(projectId: string, repositoryId?: string): Promise<{
|
|
123
|
+
published: boolean;
|
|
124
|
+
prUrl?: string;
|
|
125
|
+
prNumber?: number;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* List all projects
|
|
129
|
+
*/
|
|
130
|
+
listProjects(): Promise<{
|
|
131
|
+
projects: Array<{
|
|
132
|
+
id: string;
|
|
133
|
+
name: string;
|
|
134
|
+
slug: string;
|
|
135
|
+
version: string;
|
|
136
|
+
framework: string;
|
|
137
|
+
updatedAt: string;
|
|
138
|
+
}>;
|
|
139
|
+
}>;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;YAK9B,OAAO;YAkCP,UAAU;IAkCxB;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAA;KAAE,CAAC;IAM/E;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QACjD,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;QAC9D,SAAS,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAC;KAC1D,CAAC;IAIF;;OAEG;IACG,UAAU,CACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC;QACT,KAAK,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAChD,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAOF;;OAEG;IACG,UA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Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ApiClient = void 0;
|
|
7
|
+
const auth_1 = require("./auth");
|
|
8
|
+
class ApiClient {
|
|
9
|
+
baseUrl;
|
|
10
|
+
apiKey;
|
|
11
|
+
constructor(apiUrl, apiKey) {
|
|
12
|
+
this.baseUrl = apiUrl || (0, auth_1.getApiUrl)();
|
|
13
|
+
this.apiKey = apiKey || (0, auth_1.getApiKey)() || '';
|
|
14
|
+
}
|
|
15
|
+
async request(endpoint, options = {}) {
|
|
16
|
+
const url = `${this.baseUrl}/api${endpoint}`;
|
|
17
|
+
const response = await fetch(url, {
|
|
18
|
+
...options,
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
'User-Agent': 'yubild-cli',
|
|
23
|
+
...options.headers,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
if (response.status === 401) {
|
|
27
|
+
throw new Error('Authentication failed. Run `yubild login` to authenticate.');
|
|
28
|
+
}
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
let errorMessage = `API error: ${response.status}`;
|
|
31
|
+
try {
|
|
32
|
+
const body = (await response.json());
|
|
33
|
+
errorMessage = body.error || body.message || errorMessage;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Use default
|
|
37
|
+
}
|
|
38
|
+
throw new Error(errorMessage);
|
|
39
|
+
}
|
|
40
|
+
return response.json();
|
|
41
|
+
}
|
|
42
|
+
async rawRequest(endpoint, options = {}) {
|
|
43
|
+
const url = `${this.baseUrl}/api${endpoint}`;
|
|
44
|
+
const response = await fetch(url, {
|
|
45
|
+
...options,
|
|
46
|
+
headers: {
|
|
47
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
48
|
+
'Content-Type': 'application/json',
|
|
49
|
+
'User-Agent': 'yubild-cli',
|
|
50
|
+
...options.headers,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
if (response.status === 401) {
|
|
54
|
+
throw new Error('Authentication failed. Run `yubild login` to authenticate.');
|
|
55
|
+
}
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
let errorMessage = `API error: ${response.status}`;
|
|
58
|
+
try {
|
|
59
|
+
const body = (await response.json());
|
|
60
|
+
errorMessage = body.error || body.message || errorMessage;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// Use default
|
|
64
|
+
}
|
|
65
|
+
throw new Error(errorMessage);
|
|
66
|
+
}
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Authenticate with API key
|
|
71
|
+
*/
|
|
72
|
+
async authenticate() {
|
|
73
|
+
return this.request('/cli/auth', {
|
|
74
|
+
method: 'POST',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get project status
|
|
79
|
+
*/
|
|
80
|
+
async getProjectStatus(projectId) {
|
|
81
|
+
return this.request(`/cli/status?projectId=${projectId}`);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Pull tokens for a project
|
|
85
|
+
*/
|
|
86
|
+
async pullTokens(projectId, formats) {
|
|
87
|
+
return this.request('/cli/pull', {
|
|
88
|
+
method: 'POST',
|
|
89
|
+
body: JSON.stringify({ projectId, formats }),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Sync tokens between local and Figma
|
|
94
|
+
*/
|
|
95
|
+
async syncTokens(projectId, autoMerge) {
|
|
96
|
+
return this.request('/cli/sync', {
|
|
97
|
+
method: 'POST',
|
|
98
|
+
body: JSON.stringify({ projectId, autoMerge }),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Diff tokens between local and Figma
|
|
103
|
+
*/
|
|
104
|
+
async diffTokens(projectId) {
|
|
105
|
+
return this.request('/cli/diff', {
|
|
106
|
+
method: 'POST',
|
|
107
|
+
body: JSON.stringify({ projectId }),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Push tokens to Figma
|
|
112
|
+
*/
|
|
113
|
+
async pushToFigma(projectId) {
|
|
114
|
+
return this.request('/cli/push', {
|
|
115
|
+
method: 'POST',
|
|
116
|
+
body: JSON.stringify({ projectId }),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Export tokens in a specific format
|
|
121
|
+
*/
|
|
122
|
+
async exportTokens(projectId, format) {
|
|
123
|
+
return this.request('/cli/export', {
|
|
124
|
+
method: 'POST',
|
|
125
|
+
body: JSON.stringify({ projectId, format }),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Deploy tokens to CDN
|
|
130
|
+
*/
|
|
131
|
+
async deployToCdn(projectId) {
|
|
132
|
+
return this.request('/cli/deploy', {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
body: JSON.stringify({ projectId }),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Publish tokens to Git via Pull Request
|
|
139
|
+
*/
|
|
140
|
+
async publishToGit(projectId, repositoryId) {
|
|
141
|
+
return this.request('/cli/publish', {
|
|
142
|
+
method: 'POST',
|
|
143
|
+
body: JSON.stringify({ projectId, repositoryId }),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* List all projects
|
|
148
|
+
*/
|
|
149
|
+
async listProjects() {
|
|
150
|
+
return this.request('/cli/projects');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.ApiClient = ApiClient;
|
|
154
|
+
//# sourceMappingURL=api-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iCAA8C;AAE9C,MAAa,SAAS;IACZ,OAAO,CAAS;IAChB,MAAM,CAAS;IA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AAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAChB,SAAiB,EACjB,YAAqB;QAMrB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;YAClC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;SAClD,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY;QAUhB,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACvC,CAAC;CACF;AAhOD,8BAgOC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication management for CLI
|
|
3
|
+
* Stores credentials in user's home directory
|
|
4
|
+
*/
|
|
5
|
+
interface AuthCredentials {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
apiUrl: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
expiresAt?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Store authentication credentials
|
|
13
|
+
*/
|
|
14
|
+
export declare function saveCredentials(credentials: AuthCredentials): void;
|
|
15
|
+
/**
|
|
16
|
+
* Load stored credentials
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadCredentials(): AuthCredentials | null;
|
|
19
|
+
/**
|
|
20
|
+
* Clear stored credentials
|
|
21
|
+
*/
|
|
22
|
+
export declare function clearCredentials(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Check if authenticated
|
|
25
|
+
*/
|
|
26
|
+
export declare function isAuthenticated(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Get the API key for making requests
|
|
29
|
+
*/
|
|
30
|
+
export declare function getApiKey(): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Get the API URL
|
|
33
|
+
*/
|
|
34
|
+
export declare function getApiUrl(): string;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI,CAUlE;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,eAAe,GAAG,IAAI,CASxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAIvC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CASzC;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,IAAI,CAGzC;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAGlC"}
|
package/dist/lib/auth.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Authentication management for CLI
|
|
4
|
+
* Stores credentials in user's home directory
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.saveCredentials = saveCredentials;
|
|
41
|
+
exports.loadCredentials = loadCredentials;
|
|
42
|
+
exports.clearCredentials = clearCredentials;
|
|
43
|
+
exports.isAuthenticated = isAuthenticated;
|
|
44
|
+
exports.getApiKey = getApiKey;
|
|
45
|
+
exports.getApiUrl = getApiUrl;
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const os = __importStar(require("os"));
|
|
49
|
+
const AUTH_DIR = path.join(os.homedir(), '.yubild');
|
|
50
|
+
const AUTH_FILE = path.join(AUTH_DIR, 'credentials.json');
|
|
51
|
+
/**
|
|
52
|
+
* Store authentication credentials
|
|
53
|
+
*/
|
|
54
|
+
function saveCredentials(credentials) {
|
|
55
|
+
if (!fs.existsSync(AUTH_DIR)) {
|
|
56
|
+
fs.mkdirSync(AUTH_DIR, { recursive: true, mode: 0o700 });
|
|
57
|
+
}
|
|
58
|
+
fs.writeFileSync(AUTH_FILE, JSON.stringify(credentials, null, 2), { encoding: 'utf-8', mode: 0o600 });
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Load stored credentials
|
|
62
|
+
*/
|
|
63
|
+
function loadCredentials() {
|
|
64
|
+
if (!fs.existsSync(AUTH_FILE))
|
|
65
|
+
return null;
|
|
66
|
+
try {
|
|
67
|
+
const content = fs.readFileSync(AUTH_FILE, 'utf-8');
|
|
68
|
+
return JSON.parse(content);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Clear stored credentials
|
|
76
|
+
*/
|
|
77
|
+
function clearCredentials() {
|
|
78
|
+
if (fs.existsSync(AUTH_FILE)) {
|
|
79
|
+
fs.unlinkSync(AUTH_FILE);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if authenticated
|
|
84
|
+
*/
|
|
85
|
+
function isAuthenticated() {
|
|
86
|
+
const creds = loadCredentials();
|
|
87
|
+
if (!creds)
|
|
88
|
+
return false;
|
|
89
|
+
if (creds.expiresAt && new Date(creds.expiresAt) < new Date()) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return !!creds.apiKey;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the API key for making requests
|
|
96
|
+
*/
|
|
97
|
+
function getApiKey() {
|
|
98
|
+
const creds = loadCredentials();
|
|
99
|
+
return creds?.apiKey || null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get the API URL
|
|
103
|
+
*/
|
|
104
|
+
function getApiUrl() {
|
|
105
|
+
const creds = loadCredentials();
|
|
106
|
+
return creds?.apiUrl || 'https://yubild.com';
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../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,CAAC;QAC7B,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe;IAC7B,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzB,IAAI,KAAK,CAAC,SAAS,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;QAC9D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,OAAO,KAAK,EAAE,MAAM,IAAI,IAAI,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,OAAO,KAAK,EAAE,MAAM,IAAI,oBAAoB,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration file management for .yubildrc
|
|
3
|
+
*/
|
|
4
|
+
export interface YubildConfig {
|
|
5
|
+
projectId: string;
|
|
6
|
+
apiUrl: string;
|
|
7
|
+
outputDir: string;
|
|
8
|
+
formats: string[];
|
|
9
|
+
framework?: string;
|
|
10
|
+
watchInterval?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Find .yubildrc by walking up from cwd
|
|
14
|
+
*/
|
|
15
|
+
export declare function findConfigFile(): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Load configuration from .yubildrc
|
|
18
|
+
*/
|
|
19
|
+
export declare function loadConfig(): YubildConfig | null;
|
|
20
|
+
/**
|
|
21
|
+
* Save configuration to .yubildrc in cwd
|
|
22
|
+
*/
|
|
23
|
+
export declare function saveConfig(config: YubildConfig): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get config path in cwd
|
|
26
|
+
*/
|
|
27
|
+
export declare function getConfigPath(): string;
|
|
28
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AASD;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAe9C;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,YAAY,GAAG,IAAI,CAehD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAGrD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|