digdesign 0.1.0 → 0.2.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/index.js +64 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -142,25 +142,60 @@ function installDependencies(pm, deps, options = {}) {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
// src/lib/errors.ts
|
|
146
|
+
var DigError = class extends Error {
|
|
147
|
+
constructor(message, options) {
|
|
148
|
+
super(message, options);
|
|
149
|
+
this.name = "DigError";
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
145
153
|
// src/lib/registry.ts
|
|
146
154
|
function resolveUrl(nameOrUrl, registryUrl) {
|
|
147
155
|
if (/^https?:\/\//.test(nameOrUrl)) return nameOrUrl;
|
|
148
156
|
return `${registryUrl}/r/${nameOrUrl}.json`;
|
|
149
157
|
}
|
|
158
|
+
async function fetchFromRegistry(url, subject) {
|
|
159
|
+
let response;
|
|
160
|
+
try {
|
|
161
|
+
const token = process.env.DIG_TOKEN;
|
|
162
|
+
response = token ? await fetch(url, { headers: { Authorization: `Bearer ${token}` } }) : await fetch(url);
|
|
163
|
+
} catch (cause) {
|
|
164
|
+
throw new DigError(
|
|
165
|
+
`\u0628\u0647 \u0631\u062C\u06CC\u0633\u062A\u0631\u06CC \u0648\u0635\u0644 \u0646\u0634\u062F\u0645: ${url}
|
|
166
|
+
\u0627\u062A\u0635\u0627\u0644 \u0627\u06CC\u0646\u062A\u0631\u0646\u062A\u060C \u067E\u0631\u0627\u06A9\u0633\u06CC \u06CC\u0627 \u062F\u0631 \u062F\u0633\u062A\u0631\u0633 \u0628\u0648\u062F\u0646\u0650 \u062F\u0627\u0645\u0646\u0647 \u0631\u0627 \u0628\u0631\u0631\u0633\u06CC \u06A9\u0646\u06CC\u062F.`,
|
|
167
|
+
{ cause }
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
if (response.ok) return response;
|
|
171
|
+
if (response.status === 404) {
|
|
172
|
+
throw new DigError(
|
|
173
|
+
`${subject} \u062F\u0631 \u0631\u062C\u06CC\u0633\u062A\u0631\u06CC \u067E\u06CC\u062F\u0627 \u0646\u0634\u062F (\u06F4\u06F0\u06F4): ${url}
|
|
174
|
+
\u0646\u0627\u0645 \u0631\u0627 \u0628\u0631\u0631\u0633\u06CC \u06A9\u0646\u06CC\u062F\u061B \u0641\u0647\u0631\u0633\u062A\u0650 \u06A9\u0627\u0645\u0644 \u0628\u0627 \xABdig health\xBB \u06CC\u0627 \u062F\u0631 \u0645\u0633\u062A\u0646\u062F\u0627\u062A \u062F\u06CC\u06AF \u0647\u0633\u062A.`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
if (response.status === 401 || response.status === 403) {
|
|
178
|
+
throw new DigError(
|
|
179
|
+
`\u062F\u0633\u062A\u0631\u0633\u06CC \u0628\u0647 \u0631\u062C\u06CC\u0633\u062A\u0631\u06CC \u0631\u062F \u0634\u062F (${response.status}): ${url}
|
|
180
|
+
\u0627\u06AF\u0631 \u067E\u0634\u062A\u0650 VPN \u06CC\u0627 \u0641\u0627\u06CC\u0631\u0648\u0627\u0644 \u0647\u0633\u062A\u06CC\u062F\u060C \u0627\u0632 \u0634\u0628\u06A9\u0647\u0654 \u062F\u06CC\u06AF\u0631\u06CC \u0627\u0645\u062A\u062D\u0627\u0646 \u06A9\u0646\u06CC\u062F.`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
if (response.status >= 500) {
|
|
184
|
+
throw new DigError(
|
|
185
|
+
`\u0631\u062C\u06CC\u0633\u062A\u0631\u06CC \u062E\u0637\u0627\u06CC \u0633\u0631\u0648\u0631 \u062F\u0627\u062F (${response.status}): ${url}
|
|
186
|
+
\u0686\u0646\u062F \u062F\u0642\u06CC\u0642\u0647 \u0628\u0639\u062F \u062F\u0648\u0628\u0627\u0631\u0647 \u0627\u0645\u062A\u062D\u0627\u0646 \u06A9\u0646\u06CC\u062F.`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
throw new DigError(`\u062F\u0631\u06CC\u0627\u0641\u062A ${subject} \u0646\u0627\u0645\u0648\u0641\u0642 \u0628\u0648\u062F (${response.status}): ${url}`);
|
|
190
|
+
}
|
|
150
191
|
async function fetchRegistryIndex(registryUrl) {
|
|
151
192
|
const url = `${registryUrl}/r/registry.json`;
|
|
152
|
-
const response = await
|
|
153
|
-
if (!response.ok) {
|
|
154
|
-
throw new Error(`\u062F\u0631\u06CC\u0627\u0641\u062A \u0641\u0647\u0631\u0633\u062A\u0650 \u0631\u062C\u06CC\u0633\u062A\u0631\u06CC \u0646\u0627\u0645\u0648\u0641\u0642 \u0628\u0648\u062F (${response.status}): ${url}`);
|
|
155
|
-
}
|
|
193
|
+
const response = await fetchFromRegistry(url, "\u0641\u0647\u0631\u0633\u062A\u0650 \u0631\u062C\u06CC\u0633\u062A\u0631\u06CC");
|
|
156
194
|
return await response.json();
|
|
157
195
|
}
|
|
158
196
|
async function fetchRegistryItem(nameOrUrl, registryUrl) {
|
|
159
197
|
const url = resolveUrl(nameOrUrl, registryUrl);
|
|
160
|
-
const response = await
|
|
161
|
-
if (!response.ok) {
|
|
162
|
-
throw new Error(`\u062F\u0631\u06CC\u0627\u0641\u062A \xAB${nameOrUrl}\xBB \u0646\u0627\u0645\u0648\u0641\u0642 \u0628\u0648\u062F (${response.status}): ${url}`);
|
|
163
|
-
}
|
|
198
|
+
const response = await fetchFromRegistry(url, `\xAB${nameOrUrl}\xBB`);
|
|
164
199
|
return await response.json();
|
|
165
200
|
}
|
|
166
201
|
async function resolveRegistryTree(names, registryUrl) {
|
|
@@ -1256,7 +1291,7 @@ async function scanRepositoryForComponent(params) {
|
|
|
1256
1291
|
}
|
|
1257
1292
|
|
|
1258
1293
|
// src/lib/intelligence-export.ts
|
|
1259
|
-
var INTELLIGENCE_EXPORT_SCHEMA_VERSION = "
|
|
1294
|
+
var INTELLIGENCE_EXPORT_SCHEMA_VERSION = "v3";
|
|
1260
1295
|
function buildIntelligenceExport(params) {
|
|
1261
1296
|
const { registryIndexItems, installedComponents } = params;
|
|
1262
1297
|
const healthReport = buildHealthReport({
|
|
@@ -1283,7 +1318,8 @@ function buildIntelligenceExport(params) {
|
|
|
1283
1318
|
migrationPending: governance.impact.requiredMigration,
|
|
1284
1319
|
dependencyImpact: governance.impact.affectedComponents.length,
|
|
1285
1320
|
changeType: governance.changeType,
|
|
1286
|
-
replacement: lifecycle.replacement
|
|
1321
|
+
replacement: lifecycle.replacement,
|
|
1322
|
+
affectedComponentNames: governance.impact.affectedComponents
|
|
1287
1323
|
};
|
|
1288
1324
|
});
|
|
1289
1325
|
return {
|
|
@@ -1338,6 +1374,9 @@ function validateIntelligenceExport(data) {
|
|
|
1338
1374
|
if (typeof entry.changeType !== "string") {
|
|
1339
1375
|
errors.push(`components[${index}].changeType \u0628\u0627\u06CC\u062F \u0631\u0634\u062A\u0647 \u0628\u0627\u0634\u062F.`);
|
|
1340
1376
|
}
|
|
1377
|
+
if (entry.affectedComponentNames !== void 0 && (!Array.isArray(entry.affectedComponentNames) || !entry.affectedComponentNames.every((name) => typeof name === "string"))) {
|
|
1378
|
+
errors.push(`components[${index}].affectedComponentNames \u0628\u0627\u06CC\u062F \u0622\u0631\u0627\u06CC\u0647\u200C\u0627\u06CC \u0627\u0632 \u0631\u0634\u062A\u0647 \u0628\u0627\u0634\u062F.`);
|
|
1379
|
+
}
|
|
1341
1380
|
});
|
|
1342
1381
|
}
|
|
1343
1382
|
return errors.length === 0 ? { valid: true } : { valid: false, errors };
|
|
@@ -2835,7 +2874,7 @@ ${result.name}`);
|
|
|
2835
2874
|
|
|
2836
2875
|
// src/index.ts
|
|
2837
2876
|
var program = new Command();
|
|
2838
|
-
program.name("dig").description("CLI \u0631\u0633\u0645\u06CC \u062F\u06CC\u0632\u0627\u06CC\u0646 \u0633\u06CC\u0633\u062A\u0645 \u062F\u06CC\u06AF").version("0.1.
|
|
2877
|
+
program.name("dig").description("CLI \u0631\u0633\u0645\u06CC \u062F\u06CC\u0632\u0627\u06CC\u0646 \u0633\u06CC\u0633\u062A\u0645 \u062F\u06CC\u06AF").version("0.1.1");
|
|
2839
2878
|
program.command("init").description("\u0631\u0627\u0647\u200C\u0627\u0646\u062F\u0627\u0632\u06CC \u062F\u06CC\u06AF \u062F\u0631 \u067E\u0631\u0648\u0698\u0647 (\u0633\u0627\u062E\u062A dig.json)").option("--yes", "\u067E\u0627\u0633\u062E \u067E\u06CC\u0634\u200C\u0641\u0631\u0636 \u0628\u0647 \u0647\u0645\u0647\u0654 \u0633\u0648\u0627\u0644\u0627\u062A", false).action(initCommand);
|
|
2840
2879
|
program.command("add").description("\u0627\u0641\u0632\u0648\u062F\u0646 \u06CC\u06A9 \u06CC\u0627 \u0686\u0646\u062F \u06A9\u0627\u0645\u067E\u0648\u0646\u0646\u062A \u0627\u0632 \u0631\u062C\u06CC\u0633\u062A\u0631\u06CC \u062F\u06CC\u06AF").argument("<components...>", "\u0646\u0627\u0645 \u06A9\u0627\u0645\u067E\u0648\u0646\u0646\u062A\u200C\u0647\u0627 (\u0645\u062B\u0644 button) \u06CC\u0627 \u0622\u062F\u0631\u0633 \u0631\u062C\u06CC\u0633\u062A\u0631\u06CC").option("--overwrite", "\u0628\u0627\u0632\u0646\u0648\u06CC\u0633\u06CC \u0641\u0627\u06CC\u0644\u200C\u0647\u0627\u06CC \u0645\u0648\u062C\u0648\u062F", false).option("--no-install", "\u0641\u0642\u0637 \u0641\u0627\u06CC\u0644\u200C\u0647\u0627 \u0631\u0627 \u0628\u0646\u0648\u06CC\u0633\u060C \u0648\u0627\u0628\u0633\u062A\u06AF\u06CC\u200C\u0647\u0627 \u0631\u0627 \u0646\u0635\u0628 \u0646\u06A9\u0646").action(addCommand);
|
|
2841
2880
|
program.command("diff").description(
|
|
@@ -2892,4 +2931,17 @@ program.command("doctor").description(
|
|
|
2892
2931
|
program.command("scan").description(
|
|
2893
2932
|
"\u06CC\u0627\u0641\u062A\u0646\u0650 \u0627\u0633\u062A\u0641\u0627\u062F\u0647\u200C\u0647\u0627\u06CC JSX\u0650 \u06CC\u06A9 \u06A9\u0627\u0645\u067E\u0648\u0646\u0646\u062A \u062F\u0631 \u0631\u06CC\u067E\u0627\u0632\u06CC\u062A\u0648\u0631\u06CC\u0650 \u0645\u062D\u0644\u06CC (\u0641\u0642\u0637\u200C\u062E\u0648\u0627\u0646\u062F\u0646\u06CC \u2014 \u0647\u06CC\u0686 \u0641\u0627\u06CC\u0644\u06CC \u062A\u063A\u06CC\u06CC\u0631 \u0646\u0645\u06CC\u200C\u06A9\u0646\u062F)"
|
|
2894
2933
|
).argument("<component>", "\u0646\u0627\u0645\u0650 \u06A9\u0627\u0645\u067E\u0648\u0646\u0646\u062A (\u0645\u062B\u0644 button)").option("--json", "\u062E\u0631\u0648\u062C\u06CC JSON \u0628\u0631\u0627\u06CC \u0627\u0633\u06A9\u0631\u06CC\u067E\u062A/\u0627\u0628\u0632\u0627\u0631", false).action(scanCommand);
|
|
2895
|
-
program.parseAsync()
|
|
2934
|
+
program.parseAsync().catch((error) => {
|
|
2935
|
+
process.exitCode = 1;
|
|
2936
|
+
if (error instanceof DigError) {
|
|
2937
|
+
console.error(`\u2717 ${error.message}`);
|
|
2938
|
+
if (process.env.DIG_DEBUG && error.cause) console.error(error.cause);
|
|
2939
|
+
return;
|
|
2940
|
+
}
|
|
2941
|
+
console.error(`\u2717 \u062E\u0637\u0627\u06CC \u067E\u06CC\u0634\u200C\u0628\u06CC\u0646\u06CC\u200C\u0646\u0634\u062F\u0647: ${error?.message ?? String(error)}`);
|
|
2942
|
+
if (process.env.DIG_DEBUG) {
|
|
2943
|
+
console.error(error);
|
|
2944
|
+
} else {
|
|
2945
|
+
console.error(" \u0628\u0631\u0627\u06CC \u062F\u06CC\u062F\u0646\u0650 \u062C\u0632\u0626\u06CC\u0627\u062A\u060C \u062F\u0648\u0628\u0627\u0631\u0647 \u0628\u0627 DIG_DEBUG=1 \u0627\u062C\u0631\u0627 \u06A9\u0646\u06CC\u062F.");
|
|
2946
|
+
}
|
|
2947
|
+
});
|