798 lines
25 KiB
HTML
798 lines
25 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="fa" dir="rtl">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>راهنمای گامبهگام توسعه افزونه Azure DevOps | HTML/CSS/JS</title>
|
||
<style>
|
||
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
|
||
:root {
|
||
--primary: #1a365d;
|
||
--primary-light: #2c5282;
|
||
--accent: #c9a961;
|
||
--accent-dark: #a8893f;
|
||
--bg: #faf9f6;
|
||
--card-bg: #ffffff;
|
||
--text: #1a202c;
|
||
--text-muted: #4a5568;
|
||
--border: #e2e8f0;
|
||
--success: #38a169;
|
||
--danger: #e53e3e;
|
||
--warning: #dd6b20;
|
||
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
|
||
}
|
||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||
body {
|
||
font-family: 'Vazirmatn', Tahoma, sans-serif;
|
||
background: var(--bg);
|
||
color: var(--text);
|
||
line-height: 1.9;
|
||
font-size: 15px;
|
||
padding: 30px 15px;
|
||
}
|
||
.document-container {
|
||
max-width: 950px;
|
||
margin: 0 auto;
|
||
background: var(--card-bg);
|
||
box-shadow: var(--shadow);
|
||
border-radius: 12px;
|
||
overflow: hidden;
|
||
}
|
||
.document-header {
|
||
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
|
||
color: white;
|
||
padding: 50px 40px 40px;
|
||
position: relative;
|
||
border-bottom: 4px solid var(--accent);
|
||
}
|
||
.document-header::before {
|
||
content: '';
|
||
position: absolute;
|
||
top: 0; right: 0;
|
||
width: 200px; height: 200px;
|
||
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
|
||
border-radius: 50%;
|
||
transform: translate(50%, -50%);
|
||
}
|
||
.header-top {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 30px;
|
||
position: relative;
|
||
z-index: 1;
|
||
}
|
||
.company-badge {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
}
|
||
.company-logo {
|
||
width: 60px; height: 60px;
|
||
background: var(--accent);
|
||
border-radius: 12px;
|
||
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
|
||
}
|
||
.doc-meta {
|
||
text-align: left;
|
||
font-size: 12px;
|
||
opacity: 0.9;
|
||
}
|
||
.doc-meta div { margin-bottom: 3px; }
|
||
.document-title {
|
||
text-align: center;
|
||
position: relative;
|
||
z-index: 1;
|
||
padding: 20px 0;
|
||
}
|
||
.document-title .label {
|
||
display: inline-block;
|
||
background: rgba(201,169,97,0.2);
|
||
color: var(--accent);
|
||
padding: 4px 16px;
|
||
border-radius: 20px;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
margin-bottom: 15px;
|
||
border: 1px solid rgba(201,169,97,0.4);
|
||
}
|
||
.document-title h1 {
|
||
font-size: 28px;
|
||
font-weight: 800;
|
||
margin-bottom: 10px;
|
||
letter-spacing: -0.5px;
|
||
}
|
||
.document-title h2 {
|
||
font-size: 16px;
|
||
font-weight: 400;
|
||
opacity: 0.9;
|
||
}
|
||
.document-body {
|
||
padding: 40px;
|
||
}
|
||
.intro-text {
|
||
background: linear-gradient(to left, #f7fafc, #edf2f7);
|
||
border-right: 4px solid var(--accent);
|
||
padding: 20px 25px;
|
||
border-radius: 8px;
|
||
margin-bottom: 35px;
|
||
font-size: 14px;
|
||
color: var(--text-muted);
|
||
}
|
||
.section {
|
||
margin-bottom: 40px;
|
||
page-break-inside: avoid;
|
||
}
|
||
.section-header {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 15px;
|
||
padding-bottom: 12px;
|
||
border-bottom: 2px solid var(--border);
|
||
margin-bottom: 20px;
|
||
}
|
||
.section-number {
|
||
width: 50px; height: 50px;
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
border-radius: 12px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-weight: 800;
|
||
font-size: 20px;
|
||
flex-shrink: 0;
|
||
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
|
||
}
|
||
.section-title { flex: 1; }
|
||
.section-title h3 {
|
||
font-size: 19px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 2px;
|
||
}
|
||
.section-title .subtitle {
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
}
|
||
.section-content {
|
||
padding-right: 10px;
|
||
}
|
||
.section-content p {
|
||
margin-bottom: 12px;
|
||
text-align: justify;
|
||
text-indent: 20px;
|
||
}
|
||
.section-content p.no-indent { text-indent: 0; }
|
||
.highlight-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #f6e05e;
|
||
border-right: 4px solid var(--accent);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
.highlight-box strong {
|
||
color: var(--accent-dark);
|
||
}
|
||
.info-box {
|
||
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
|
||
border: 1px solid #90cdf4;
|
||
border-right: 4px solid var(--primary-light);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
.success-box {
|
||
background: linear-gradient(to left, #f0fff4, #e6fffa);
|
||
border: 1px solid #9ae6b4;
|
||
border-right: 4px solid var(--success);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
.warning-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #fbd38d;
|
||
border-right: 4px solid var(--warning);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
.styled-table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
margin: 20px 0;
|
||
background: white;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
||
}
|
||
.styled-table thead {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
}
|
||
.styled-table th {
|
||
padding: 14px 16px;
|
||
text-align: right;
|
||
font-weight: 600;
|
||
font-size: 13px;
|
||
}
|
||
.styled-table td {
|
||
padding: 13px 16px;
|
||
border-bottom: 1px solid var(--border);
|
||
font-size: 13px;
|
||
}
|
||
.styled-table tbody tr:last-child td { border-bottom: none; }
|
||
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
|
||
.styled-table .highlight-row {
|
||
background: #fffaf0 !important;
|
||
font-weight: 600;
|
||
}
|
||
.code-block {
|
||
background: #1e1e1e;
|
||
color: #d4d4d4;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
direction: ltr;
|
||
text-align: left;
|
||
font-family: 'Consolas', 'Courier New', monospace;
|
||
font-size: 13px;
|
||
line-height: 1.6;
|
||
overflow-x: auto;
|
||
border-right: 4px solid var(--accent);
|
||
}
|
||
.code-block .comment { color: #6a9955; }
|
||
.code-block .keyword { color: #569cd6; }
|
||
.code-block .string { color: #ce9178; }
|
||
.code-block .function { color: #dcdcaa; }
|
||
.quote-box {
|
||
background: linear-gradient(135deg, #f7fafc, #edf2f7);
|
||
border-right: 4px solid var(--accent);
|
||
padding: 20px 25px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
position: relative;
|
||
}
|
||
.quote-box::before {
|
||
content: '"';
|
||
position: absolute;
|
||
top: -10px;
|
||
right: 15px;
|
||
font-size: 60px;
|
||
color: var(--accent);
|
||
opacity: 0.3;
|
||
font-family: Georgia, serif;
|
||
}
|
||
.quote-box p {
|
||
font-style: italic;
|
||
color: var(--text-muted);
|
||
margin-bottom: 10px;
|
||
text-indent: 0 !important;
|
||
}
|
||
.quote-box .source {
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
text-align: left;
|
||
font-style: normal;
|
||
}
|
||
.stats-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(3, 1fr);
|
||
gap: 15px;
|
||
margin: 25px 0;
|
||
}
|
||
.stat-card {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
padding: 20px;
|
||
border-radius: 10px;
|
||
text-align: center;
|
||
box-shadow: 0 4px 12px rgba(26,54,93,0.2);
|
||
}
|
||
.stat-card .stat-value {
|
||
font-size: 24px;
|
||
font-weight: 800;
|
||
margin-bottom: 5px;
|
||
color: var(--accent);
|
||
line-height: 1.3;
|
||
}
|
||
.stat-card .stat-label {
|
||
font-size: 12px;
|
||
opacity: 0.9;
|
||
}
|
||
.timeline {
|
||
position: relative;
|
||
padding: 20px 0;
|
||
margin: 25px 0;
|
||
}
|
||
.timeline::before {
|
||
content: '';
|
||
position: absolute;
|
||
right: 50%;
|
||
top: 0;
|
||
bottom: 0;
|
||
width: 3px;
|
||
background: var(--border);
|
||
transform: translateX(50%);
|
||
}
|
||
.timeline-item {
|
||
display: flex;
|
||
margin-bottom: 20px;
|
||
position: relative;
|
||
}
|
||
.timeline-item:nth-child(odd) {
|
||
flex-direction: row-reverse;
|
||
}
|
||
.timeline-content {
|
||
width: 45%;
|
||
background: #f8fafc;
|
||
border: 1px solid var(--border);
|
||
border-radius: 8px;
|
||
padding: 15px;
|
||
position: relative;
|
||
}
|
||
.timeline-item:nth-child(odd) .timeline-content {
|
||
margin-left: 5%;
|
||
}
|
||
.timeline-item:nth-child(even) .timeline-content {
|
||
margin-right: 5%;
|
||
}
|
||
.timeline-dot {
|
||
position: absolute;
|
||
right: 50%;
|
||
top: 20px;
|
||
width: 16px;
|
||
height: 16px;
|
||
background: var(--accent);
|
||
border: 3px solid white;
|
||
border-radius: 50%;
|
||
transform: translateX(50%);
|
||
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
|
||
z-index: 1;
|
||
}
|
||
.timeline-content h5 {
|
||
font-size: 14px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin-bottom: 8px;
|
||
}
|
||
.timeline-content p {
|
||
font-size: 12px;
|
||
color: var(--text-muted);
|
||
text-indent: 0 !important;
|
||
margin-bottom: 0 !important;
|
||
}
|
||
.reference-list {
|
||
list-style: none;
|
||
padding: 0;
|
||
margin: 20px 0;
|
||
}
|
||
.reference-list li {
|
||
background: #f8fafc;
|
||
border-right: 3px solid var(--primary-light);
|
||
padding: 15px 20px;
|
||
margin-bottom: 10px;
|
||
border-radius: 6px;
|
||
font-size: 13px;
|
||
}
|
||
.reference-list li strong {
|
||
color: var(--primary);
|
||
display: block;
|
||
margin-bottom: 5px;
|
||
}
|
||
.reference-list li .ref-source {
|
||
font-size: 11px;
|
||
color: var(--text-muted);
|
||
margin-top: 5px;
|
||
}
|
||
.conclusion-box {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
padding: 30px;
|
||
border-radius: 12px;
|
||
margin: 30px 0;
|
||
text-align: center;
|
||
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
|
||
}
|
||
.conclusion-box h3 {
|
||
font-size: 22px;
|
||
font-weight: 800;
|
||
margin-bottom: 15px;
|
||
color: var(--accent);
|
||
}
|
||
.conclusion-box p {
|
||
font-size: 14px;
|
||
line-height: 1.8;
|
||
text-indent: 0 !important;
|
||
margin-bottom: 15px;
|
||
}
|
||
.conclusion-box .highlight {
|
||
background: rgba(201,169,97,0.2);
|
||
padding: 15px 20px;
|
||
border-radius: 8px;
|
||
margin-top: 20px;
|
||
border: 1px solid rgba(201,169,97,0.4);
|
||
}
|
||
.document-footer {
|
||
background: var(--primary);
|
||
color: white;
|
||
padding: 25px 40px;
|
||
text-align: center;
|
||
font-size: 12px;
|
||
margin-top: 40px;
|
||
}
|
||
.document-footer .footer-brand {
|
||
font-weight: 700;
|
||
color: var(--accent);
|
||
margin-bottom: 5px;
|
||
font-size: 14px;
|
||
}
|
||
.footer-divider {
|
||
width: 60px;
|
||
height: 2px;
|
||
background: var(--accent);
|
||
margin: 10px auto;
|
||
}
|
||
.page-info {
|
||
text-align: center;
|
||
padding: 15px;
|
||
font-size: 11px;
|
||
color: var(--text-muted);
|
||
border-top: 1px solid var(--border);
|
||
margin-top: 30px;
|
||
}
|
||
@media print {
|
||
body { background: white; padding: 0; }
|
||
.document-container { box-shadow: none; border-radius: 0; }
|
||
.section { page-break-inside: avoid; }
|
||
}
|
||
@media (max-width: 768px) {
|
||
.document-body { padding: 25px 20px; }
|
||
.document-header { padding: 30px 20px; }
|
||
.stats-grid { grid-template-columns: 1fr; }
|
||
.header-top { flex-direction: column; gap: 15px; }
|
||
.doc-meta { text-align: center; }
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="document-container">
|
||
<header class="document-header">
|
||
<div class="header-top">
|
||
<div class="company-badge">
|
||
<div class="company-logo"></div>
|
||
</div>
|
||
<div class="doc-meta">
|
||
<div>شماره مستند: AZDO-EXT-TUT-001</div>
|
||
<div>نسخه: ۱.۰</div>
|
||
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
|
||
<div>طبقهبندی: آموزشی / فنی</div>
|
||
</div>
|
||
</div>
|
||
<div class="document-title">
|
||
<span class="label">STEP-BY-STEP TUTORIAL</span>
|
||
<h1>توسعه افزونه Azure DevOps با HTML/CSS/JS</h1>
|
||
<h2>راهنمای عملیاتی ساخت اولین افزونه ساده بدون فریمورک</h2>
|
||
</div>
|
||
</header>
|
||
<div class="document-body">
|
||
<div class="intro-text">
|
||
<strong>توسعهدهنده گرامی،</strong><br>
|
||
این مستند یک راهنمای کاملاً عملی و گامبهگام برای ایجاد اولین افزونه Azure DevOps با استفاده از تکنولوژیهای پایه وب (HTML, CSS, Vanilla JS) است. هدف این است که بدون درگیر شدن با پیچیدگیهای بیلد سیستمها، مفهوم اصلی توسعه افزونه را درک کرده و یک نمونه کارکردی بسازید.
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۱</div>
|
||
<div class="section-title">
|
||
<h3>آمادهسازی محیط و ابزارها</h3>
|
||
<div class="subtitle">Environment Setup & Prerequisites</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>قبل از نوشتن هرگونه کدی، باید ابزارهای خط فرمان مایکروسافت را نصب کنید. این ابزارها وظیفه بستهبندی و ارتباط با Marketplace را بر عهده دارند.</p>
|
||
<div class="stats-grid">
|
||
<div class="stat-card">
|
||
<div class="stat-value">Node.js<br>v18+</div>
|
||
<div class="stat-label">پیشنیاز اجرای tfx-cli</div>
|
||
</div>
|
||
<div class="stat-card">
|
||
<div class="stat-value">tfx-cli<br>Global</div>
|
||
<div class="stat-label">ابزار رسمی بستهبندی</div>
|
||
</div>
|
||
<div class="stat-card">
|
||
<div class="stat-value">VS Code<br>Editor</div>
|
||
<div class="stat-label">ویرایشگر پیشنهادی</div>
|
||
</div>
|
||
</div>
|
||
<div class="code-block">
|
||
<span class="comment"># نصب ابزار خط فرمان Azure DevOps Extensions</span>
|
||
npm install -g tfx-cli
|
||
|
||
<span class="comment"># ایجاد پوشه پروژه و ورود به آن</span>
|
||
mkdir my-first-extension
|
||
cd my-first-extension
|
||
</div>
|
||
<div class="info-box">
|
||
<strong>💡 نکته مهم:</strong> برای این آموزش نیازی به <code>npm init</code> یا نصب پکیجهای سنگین نداریم. ما از CDN برای بارگذاری SDK استفاده خواهیم کرد تا فرآیند تا حد ممکن ساده و شفاف باشد.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۲</div>
|
||
<div class="section-title">
|
||
<h3>تعریف شناسنامه افزونه (Manifest)</h3>
|
||
<div class="subtitle">Creating vss-extension.json</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>فایل <code>vss-extension.json</code> قلب تپنده افزونه شماست. این فایل به Azure DevOps میگوید که افزونه شما چیست، چه نامی دارد و قرار است کجا نمایش داده شود.</p>
|
||
<div class="code-block">
|
||
{
|
||
<span class="string">"manifestVersion"</span>: 1,
|
||
<span class="string">"id"</span>: <span class="string">"my-simple-hub"</span>,
|
||
<span class="string">"version"</span>: <span class="string">"1.0.0"</span>,
|
||
<span class="string">"name"</span>: <span class="string">"My First Extension"</span>,
|
||
<span class="string">"description"</span>: <span class="string">"A simple HTML/JS extension tutorial"</span>,
|
||
<span class="string">"publisher"</span>: <span class="string">"YOUR_PUBLISHER_ID"</span>,
|
||
<span class="string">"targets"</span>: [
|
||
{ <span class="string">"id"</span>: <span class="string">"Microsoft.VisualStudio.Services"</span> }
|
||
],
|
||
<span class="string">"icons"</span>: {
|
||
<span class="string">"default"</span>: <span class="string">"images/logo.png"</span>
|
||
},
|
||
<span class="string">"contributions"</span>: [
|
||
{
|
||
<span class="string">"id"</span>: <span class="string">"simpleHub"</span>,
|
||
<span class="string">"type"</span>: <span class="string">"ms.vss-web.hub"</span>,
|
||
<span class="string">"targets"</span>: [<span class="string">"ms.vss-code.code-hub-group"</span>],
|
||
<span class="string">"properties"</span>: {
|
||
<span class="string">"name"</span>: <span class="string">"Simple Hub"</span>,
|
||
<span class="string">"uri"</span>: <span class="string">"index.html"</span>
|
||
}
|
||
}
|
||
],
|
||
<span class="string">"files"</span>: [
|
||
{ <span class="string">"path"</span>: <span class="string">"index.html"</span>, <span class="string">"addressable"</span>: true },
|
||
{ <span class="string">"path"</span>: <span class="string">"images"</span>, <span class="string">"addressable"</span>: true }
|
||
]
|
||
}
|
||
</div>
|
||
<div class="warning-box">
|
||
<strong>⚠️ توجه:</strong> مقدار <code>YOUR_PUBLISHER_ID</code> را حتماً با شناسه ناشر خود که از Marketplace دریافت کردهاید جایگزین کنید. همچنین مسیر <code>uri</code> باید دقیقاً به فایل HTML شما اشاره داشته باشد.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۳</div>
|
||
<div class="section-title">
|
||
<h3>پیادهسازی رابط کاربری (HTML + CSS)</h3>
|
||
<div class="subtitle">Building the UI Layer</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>فایل <code>index.html</code> را در ریشه پروژه ایجاد کنید. ما از CDN رسمی مایکروسافت برای بارگذاری SDK استفاده میکنیم تا نیازی به باندل کردن نداشته باشید.</p>
|
||
<div class="code-block">
|
||
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>Simple Extension</title>
|
||
<span class="comment"><!-- بارگذاری SDK رسمی Azure DevOps --></span>
|
||
<script src="https://cdn.jsdelivr.net/npm/azure-devops-extension-sdk@3.1.2/dist/index.min.js"></script>
|
||
<style>
|
||
body { font-family: 'Segoe UI', sans-serif; padding: 20px; color: #333; }
|
||
.container { max-width: 600px; margin: 0 auto; }
|
||
h2 { color: #0078d4; border-bottom: 2px solid #eee; padding-bottom: 10px; }
|
||
.info-card { background: #f8f9fa; padding: 15px; border-radius: 6px; margin-top: 20px; border-left: 4px solid #0078d4; }
|
||
button { background: #0078d4; color: white; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; margin-top: 15px; }
|
||
button:hover { background: #005a9e; }
|
||
#result { margin-top: 15px; font-weight: bold; color: #107c10; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<h2>👋 سلام از افزونه من!</h2>
|
||
<p>این یک افزونه ساده است که اطلاعات پروژه جاری را نمایش میدهد.</p>
|
||
|
||
<button id="btnGetInfo">دریافت اطلاعات پروژه</button>
|
||
<div id="result"></div>
|
||
|
||
<div class="info-card">
|
||
<strong>وضعیت اتصال:</strong> <span id="status">در حال初始化...</span>
|
||
</div>
|
||
</div>
|
||
|
||
<script src="app.js"></script>
|
||
</body>
|
||
</html>
|
||
</div>
|
||
<div class="success-box">
|
||
<strong>✓ بهترین تمرین:</strong> حتی در افزونههای ساده نیز از CSS مجزا یا بلوکهای مرتب استفاده کنید. ظاهر افزونه شما باید با تم روشن/تیره Azure DevOps سازگار باشد.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۴</div>
|
||
<div class="section-title">
|
||
<h3>منطق برنامه و ارتباط با SDK</h3>
|
||
<div class="subtitle">JavaScript Logic & SDK Integration</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>فایل <code>app.js</code> را ایجاد کنید. در اینجا ما SDK را اولیه کرده و از سرویس Project Page Service برای دریافت اطلاعات زمینه (Context) استفاده میکنیم.</p>
|
||
<div class="code-block">
|
||
<span class="comment">// app.js</span>
|
||
<span class="keyword">const</span> resultDiv = document.getElementById(<span class="string">'result'</span>);
|
||
<span class="keyword">const</span> statusSpan = document.getElementById(<span class="string">'status'</span>);
|
||
<span class="keyword">const</span> btn = document.getElementById(<span class="string">'btnGetInfo'</span>);
|
||
|
||
<span class="comment">// 1. مقداردهی اولیه SDK (حیاتیترین مرحله)</span>
|
||
AZDevOps.init().then(() => {
|
||
statusSpan.textContent = <span class="string">'✅ متصل به Azure DevOps'</span>;
|
||
statusSpan.style.color = <span class="string">'#107c10'</span>;
|
||
}).catch(err => {
|
||
statusSpan.textContent = <span class="string">'❌ خطا در اتصال'</span>;
|
||
statusSpan.style.color = <span class="string">'#d13438'</span>;
|
||
});
|
||
|
||
<span class="comment">// 2. تعریف عملکرد دکمه</span>
|
||
btn.addEventListener(<span class="string">'click'</span>, async () => {
|
||
try {
|
||
<span class="comment">// دریافت سرویس مربوط به صفحه پروژه</span>
|
||
<span class="keyword">const</span> projectService = await AZDevOps.getService(
|
||
AZDevOps.CommonServiceIds.ProjectPageService
|
||
);
|
||
|
||
<span class="comment">// دریافت اطلاعات پروژه جاری</span>
|
||
<span class="keyword">const</span> project = await projectService.getProject();
|
||
|
||
if (project) {
|
||
resultDiv.innerHTML = `
|
||
📁 نام پروژه: ${project.name}<br>
|
||
🆔 شناسه: ${project.id}<br>
|
||
🔗 توضیحات: ${project.description || 'بدون توضیحات'}
|
||
`;
|
||
} else {
|
||
resultDiv.textContent = <span class="string">'اطلاعات پروژه یافت نشد.'</span>;
|
||
}
|
||
} catch (error) {
|
||
console.error(error);
|
||
resultDiv.textContent = <span class="string">'خطا در دریافت اطلاعات: '</span> + error.message;
|
||
}
|
||
});
|
||
</div>
|
||
<div class="highlight-box">
|
||
<strong>🔑 کلید موفقیت:</strong> همیشه ابتدا <code>AZDevOps.init()</code> را صدا بزنید و منتظر Promise آن بمانید. بدون این مرحله، هیچیک از سرویسهای Azure DevOps در دسترس نخواهند بود.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۵</div>
|
||
<div class="section-title">
|
||
<h3>بستهبندی و تست محلی</h3>
|
||
<div class="subtitle">Packaging & Local Testing</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>حال که کدها آماده هستند، باید آنها را به فرمت استاندارد VSIX تبدیل کنید. این فرمت همان چیزی است که Azure DevOps قادر به نصب آن است.</p>
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>مرحله</th>
|
||
<th>دستور / عملیات</th>
|
||
<th>توضیحات</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>اعتبارسنجی</td>
|
||
<td><code>tfx extension validate</code></td>
|
||
<td>بررسی صحت ساختار manifest و فایلها</td>
|
||
</tr>
|
||
<tr>
|
||
<td>بستهبندی</td>
|
||
<td><code>tfx extension create</code></td>
|
||
<td>تولید فایل my-first-extension-1.0.0.vsix</td>
|
||
</tr>
|
||
<tr>
|
||
<td>نصب دستی</td>
|
||
<td>Marketplace > Manage > Upload</td>
|
||
<td>آپلود فایل vsix در سازمان تست</td>
|
||
</tr>
|
||
<tr class="highlight-row">
|
||
<td><strong>مشاهده نتیجه</strong></td>
|
||
<td><strong>رفرش صفحه Azure DevOps</strong></td>
|
||
<td><strong>افزونه در منوی Code ظاهر میشود</strong></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="quote-box">
|
||
<p>تست محلی (Sideload) به شما اجازه میدهد بدون انتشار عمومی، افزونه را در محیط واقعی سازمان خود بررسی کنید. این امنترین روش برای دیباگ کردن است.</p>
|
||
<div class="source">— Azure DevOps Extension Best Practices</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۶</div>
|
||
<div class="section-title">
|
||
<h3>عیبیابی و نکات طلایی</h3>
|
||
<div class="subtitle">Troubleshooting & Pro Tips</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>در توسعه افزونههای مبتنی بر iframe، برخی مشکلات رایج هستند. جدول زیر راهکارهای سریع برای رفع آنها ارائه میدهد:</p>
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>مشکل رایج</th>
|
||
<th>علت احتمالی</th>
|
||
<th>راه حل</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>صفحه سفید / خالی</td>
|
||
<td>عدم فراخوانی init() یا خطای JS</td>
|
||
<td>Console مرورگر را چک کنید؛ init() را در ابتدای اسکریپت قرار دهید</td>
|
||
</tr>
|
||
<tr>
|
||
<td>خطای 401/403</td>
|
||
<td>مجوزهای ناکافی در manifest</td>
|
||
<td>scopes مورد نیاز را به vss-extension.json اضافه کنید</td>
|
||
</tr>
|
||
<tr>
|
||
<td>ظاهر بهم ریخته</td>
|
||
<td>تداخل CSS با هاست</td>
|
||
<td>از Reset CSS استفاده کنید یا از کامپوننتهای azure-devops-ui بهره ببرید</td>
|
||
</tr>
|
||
<tr>
|
||
<td>تغییرات اعمال نمیشود</td>
|
||
<td>کش مرورگر یا نسخه قدیمی</td>
|
||
<td>نسخه manifest را افزایش دهید و کش را پاک کنید</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="info-box">
|
||
<strong>💡 پیشنهاد حرفهای:</strong> پس از تسلط بر این روش ساده، به سراغ استفاده از TypeScript و Webpack بروید. این ابزارها برای پروژههای بزرگتر ضروری هستند اما برای یادگیری مفاهیم پایه، همین روش Vanilla JS کافی و آموزنده است.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="conclusion-box">
|
||
<h3>🎉 تبریک! شما یک توسعهدهنده افزونه هستید</h3>
|
||
<p>با تکمیل این مراحل، شما اکنون دانش بنیادی لازم برای ایجاد هر نوع افزونهای در Azure DevOps را دارید. از اینجا به بعد میتوانید با مطالعه API Reference، قابلیتهای پیشرفتهتری مانند Custom Widgets، Build Tasks و Pipeline Decorators را پیادهسازی کنید.</p>
|
||
<div class="highlight">
|
||
<strong>💎 مسیر پیش رو:</strong><br>
|
||
یادگیری مفاهیم پایه ✓ → پیادهسازی اولین افزونه ✓ → مطالعه API پیشرفته → انتشار در Marketplace
|
||
</div>
|
||
</div>
|
||
|
||
<div class="page-info">
|
||
این مستند آموزشی بوده و جهت استفاده شخصی و تیمی تهیه شده است. کدهای ارائه شده تحت مجوز MIT قابل استفاده هستند.
|
||
</div>
|
||
</div>
|
||
<footer class="document-footer">
|
||
<div class="footer-brand">واحد آموزش و توسعه | Azure DevOps Practice</div>
|
||
<div class="footer-divider"></div>
|
||
<div>تاریخ تهیه: آبان ۱۴۰۵ | نسخه: ۱.۰ | طبقهبندی: آموزشی</div>
|
||
</footer>
|
||
</div>
|
||
</body>
|
||
</html> |