chore: import upstream snapshot with attribution
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { cli, Strategy } from '@jackwener/opencli/registry';
|
||||
import {
|
||||
getPostDetails,
|
||||
getRawCode,
|
||||
extractExportCode,
|
||||
inferLanguage,
|
||||
getCodeLength,
|
||||
} from './_shared.js';
|
||||
|
||||
cli({
|
||||
site: 'uiverse',
|
||||
name: 'code',
|
||||
access: 'read',
|
||||
description: 'Export Uiverse component code (HTML, CSS, React, or Vue)',
|
||||
domain: 'uiverse.io',
|
||||
strategy: Strategy.PUBLIC,
|
||||
browser: true,
|
||||
navigateBefore: 'https://uiverse.io',
|
||||
args: [
|
||||
{ name: 'input', type: 'str', required: true, positional: true, help: 'Uiverse URL or author/slug identifier' },
|
||||
{ name: 'target', type: 'str', required: true, choices: ['html', 'css', 'react', 'vue'], help: 'Code target to export' },
|
||||
],
|
||||
columns: ['target', 'username', 'slug', 'language', 'length'],
|
||||
func: async (page, kwargs) => {
|
||||
const detail = await getPostDetails(page, kwargs.input);
|
||||
const target = String(kwargs.target).toLowerCase();
|
||||
let code = '';
|
||||
|
||||
if (target === 'react' || target === 'vue') {
|
||||
code = await extractExportCode(page, target);
|
||||
} else {
|
||||
const payload = await getRawCode(page, detail.post.id);
|
||||
code = target === 'html' ? payload.html : payload.css;
|
||||
}
|
||||
|
||||
return {
|
||||
target,
|
||||
username: detail.username,
|
||||
slug: detail.slug,
|
||||
url: detail.url,
|
||||
language: inferLanguage(target, detail.post),
|
||||
length: getCodeLength(code),
|
||||
code,
|
||||
postId: detail.post.id,
|
||||
type: detail.post.type,
|
||||
isTailwind: Boolean(detail.post.isTailwind),
|
||||
};
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user