digdesign 0.4.0 → 0.5.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 +75 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -444,7 +444,7 @@ async function addCommand(components, options) {
|
|
|
444
444
|
console.log(`\u062F\u0631\u06CC\u0627\u0641\u062A \u0627\u0632 ${config.registryUrl} \u2026`);
|
|
445
445
|
const items = await resolveRegistryTree(names, config.registryUrl);
|
|
446
446
|
let overwrite = Boolean(options.overwrite);
|
|
447
|
-
if (!overwrite) {
|
|
447
|
+
if (!overwrite && !options.skipExisting) {
|
|
448
448
|
const existing = [];
|
|
449
449
|
for (const item of items.values()) {
|
|
450
450
|
for (const file of item.files) {
|
|
@@ -471,9 +471,9 @@ ${existing.length} \u0641\u0627\u06CC\u0644 \u0627\u0632 \u0642\u0628\u0644 \u06
|
|
|
471
471
|
for (const dep of item.dependencies ?? []) npmDeps.add(dep);
|
|
472
472
|
for (const file of item.files) {
|
|
473
473
|
const target = path6.join(cwd, resolveTargetPath(file.path, config.aliases, targetPathOptions(config)));
|
|
474
|
-
const
|
|
475
|
-
const mark =
|
|
476
|
-
const note =
|
|
474
|
+
const exists3 = await pathExists(target);
|
|
475
|
+
const mark = exists3 ? overwrite ? "~" : "-" : "+";
|
|
476
|
+
const note = exists3 ? overwrite ? " (\u0628\u0627\u0632\u0646\u0648\u06CC\u0633\u06CC)" : " (\u0631\u062F \u0645\u06CC\u200C\u0634\u0648\u062F\u060C \u0648\u062C\u0648\u062F \u062F\u0627\u0631\u062F)" : "";
|
|
477
477
|
console.log(`${mark} ${path6.relative(cwd, target)}${note}`);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
@@ -499,7 +499,7 @@ ${items.size} \u0622\u06CC\u062A\u0645 \u0627\u0632 \u0631\u062C\u06CC\u0633\u06
|
|
|
499
499
|
for (const file of item.files) {
|
|
500
500
|
const target = path6.join(cwd, resolveTargetPath(file.path, config.aliases, targetPathOptions(config)));
|
|
501
501
|
if (!overwrite && await pathExists(target)) {
|
|
502
|
-
console.log(`- \u0631\u062F \u0634\u062F (\u0648\u062C\u0648\u062F \u062F\u0627\u0631\u062F): ${path6.relative(cwd, target)}`);
|
|
502
|
+
if (!options.skipExisting) console.log(`- \u0631\u062F \u0634\u062F (\u0648\u062C\u0648\u062F \u062F\u0627\u0631\u062F): ${path6.relative(cwd, target)}`);
|
|
503
503
|
skipped++;
|
|
504
504
|
continue;
|
|
505
505
|
}
|
|
@@ -3293,9 +3293,45 @@ ${entry.migrationHint}`);
|
|
|
3293
3293
|
}
|
|
3294
3294
|
}
|
|
3295
3295
|
|
|
3296
|
+
// src/lib/missing-dependencies.ts
|
|
3297
|
+
import { access as access6 } from "fs/promises";
|
|
3298
|
+
import path14 from "path";
|
|
3299
|
+
async function exists2(target) {
|
|
3300
|
+
try {
|
|
3301
|
+
await access6(target);
|
|
3302
|
+
return true;
|
|
3303
|
+
} catch {
|
|
3304
|
+
return false;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
async function findMissingDependencies(params) {
|
|
3308
|
+
const { cwd, config, lock, items } = params;
|
|
3309
|
+
const requested = new Set(items.map((item) => item.name));
|
|
3310
|
+
const direct = [
|
|
3311
|
+
...new Set(items.flatMap((item) => item.registryDependencies ?? []))
|
|
3312
|
+
].filter((name) => !requested.has(name));
|
|
3313
|
+
if (direct.length === 0) return [];
|
|
3314
|
+
const tree = await resolveRegistryTree(direct, config.registryUrl);
|
|
3315
|
+
const missing = [];
|
|
3316
|
+
for (const item of tree.values()) {
|
|
3317
|
+
if (requested.has(item.name) || lock.components[item.name]) continue;
|
|
3318
|
+
for (const file of item.files) {
|
|
3319
|
+
const target = path14.join(
|
|
3320
|
+
cwd,
|
|
3321
|
+
resolveTargetPath(file.path, config.aliases, targetPathOptions(config))
|
|
3322
|
+
);
|
|
3323
|
+
if (!await exists2(target)) {
|
|
3324
|
+
missing.push(item);
|
|
3325
|
+
break;
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
return missing;
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3296
3332
|
// src/lib/update.ts
|
|
3297
3333
|
import { mkdir as mkdir5, readFile as readFile10, rm as rm2, writeFile as writeFile8 } from "fs/promises";
|
|
3298
|
-
import
|
|
3334
|
+
import path15 from "path";
|
|
3299
3335
|
function safeFileIndexes(drift) {
|
|
3300
3336
|
const indexes = [];
|
|
3301
3337
|
drift.files.forEach((file, index) => {
|
|
@@ -3315,7 +3351,7 @@ async function applySafeFiles(cwd, aliases, drift, registryItem, dryRun, paths)
|
|
|
3315
3351
|
for (const index of safeIndexes) {
|
|
3316
3352
|
const file = drift.files[index];
|
|
3317
3353
|
const registryFile = registryItem.files[index];
|
|
3318
|
-
const target =
|
|
3354
|
+
const target = path15.join(cwd, resolveTargetPath(registryFile.path, aliases, paths));
|
|
3319
3355
|
const isNewFile = file.status === "new_upstream";
|
|
3320
3356
|
pending.push({
|
|
3321
3357
|
index,
|
|
@@ -3329,7 +3365,7 @@ async function applySafeFiles(cwd, aliases, drift, registryItem, dryRun, paths)
|
|
|
3329
3365
|
const written = [];
|
|
3330
3366
|
try {
|
|
3331
3367
|
for (const item of pending) {
|
|
3332
|
-
if (item.isNewFile) await mkdir5(
|
|
3368
|
+
if (item.isNewFile) await mkdir5(path15.dirname(item.target), { recursive: true });
|
|
3333
3369
|
await writeFile8(item.target, item.newContent, "utf8");
|
|
3334
3370
|
written.push(item);
|
|
3335
3371
|
}
|
|
@@ -3452,6 +3488,30 @@ async function updateCommand(components, options) {
|
|
|
3452
3488
|
if (entries.some((entry) => entry.result.lockUpdated)) {
|
|
3453
3489
|
await writeLock(lock, cwd);
|
|
3454
3490
|
}
|
|
3491
|
+
let missing = [];
|
|
3492
|
+
try {
|
|
3493
|
+
missing = (await findMissingDependencies({
|
|
3494
|
+
cwd,
|
|
3495
|
+
config,
|
|
3496
|
+
lock,
|
|
3497
|
+
items: entries.filter((entry) => entry.result.tracked && entry.registryItem).map((entry) => entry.registryItem)
|
|
3498
|
+
})).map((item) => item.name);
|
|
3499
|
+
} catch (error) {
|
|
3500
|
+
console.error(`\u2717 \u0628\u0631\u0631\u0633\u06CC\u0650 \u0648\u0627\u0628\u0633\u062A\u06AF\u06CC\u200C\u0647\u0627\u06CC \u062A\u0627\u0632\u0647: ${error.message}`);
|
|
3501
|
+
}
|
|
3502
|
+
if (missing.length && !dryRun) {
|
|
3503
|
+
if (!options.json) {
|
|
3504
|
+
console.log(`
|
|
3505
|
+
\u0648\u0627\u0628\u0633\u062A\u06AF\u06CC\u200C\u0647\u0627\u06CC \u062A\u0627\u0632\u0647\u200C\u0627\u06CC \u06A9\u0647 \u067E\u0631\u0648\u0698\u0647 \u0646\u062F\u0627\u0634\u062A \u0646\u0635\u0628 \u0645\u06CC\u200C\u0634\u0648\u0646\u062F: ${missing.join("\u060C ")}`);
|
|
3506
|
+
}
|
|
3507
|
+
const log = console.log;
|
|
3508
|
+
if (options.json) console.log = console.error;
|
|
3509
|
+
try {
|
|
3510
|
+
await addCommand(missing, { skipExisting: true });
|
|
3511
|
+
} finally {
|
|
3512
|
+
console.log = log;
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3455
3515
|
if (options.json) {
|
|
3456
3516
|
console.log(
|
|
3457
3517
|
JSON.stringify(
|
|
@@ -3466,7 +3526,8 @@ async function updateCommand(components, options) {
|
|
|
3466
3526
|
action: result.actions?.[index] ?? "skipped"
|
|
3467
3527
|
})),
|
|
3468
3528
|
...result.snapshotError ? { snapshotError: result.snapshotError } : {}
|
|
3469
|
-
}))
|
|
3529
|
+
})),
|
|
3530
|
+
[dryRun ? "missingDependencies" : "addedDependencies"]: missing
|
|
3470
3531
|
},
|
|
3471
3532
|
null,
|
|
3472
3533
|
2
|
|
@@ -3484,6 +3545,10 @@ async function updateCommand(components, options) {
|
|
|
3484
3545
|
await printUpdateResult(cwd, config, entry);
|
|
3485
3546
|
}
|
|
3486
3547
|
}
|
|
3548
|
+
if (missing.length && dryRun) {
|
|
3549
|
+
console.log(`
|
|
3550
|
+
\u0648\u0627\u0628\u0633\u062A\u06AF\u06CC\u200C\u0647\u0627\u06CC \u062A\u0627\u0632\u0647\u200C\u0627\u06CC \u06A9\u0647 \u0646\u0635\u0628 \u0645\u06CC\u200C\u0634\u062F\u0646\u062F: ${missing.join("\u060C ")}`);
|
|
3551
|
+
}
|
|
3487
3552
|
}
|
|
3488
3553
|
function printUpdateSummary(entries) {
|
|
3489
3554
|
console.log("\u062E\u0644\u0627\u0635\u0647\u0654 \u0628\u0631\u0648\u0632\u0631\u0633\u0627\u0646\u06CC");
|
|
@@ -3630,7 +3695,7 @@ ${result.name}`);
|
|
|
3630
3695
|
}
|
|
3631
3696
|
|
|
3632
3697
|
// src/lib/version.ts
|
|
3633
|
-
var CLI_VERSION = "0.
|
|
3698
|
+
var CLI_VERSION = "0.5.0";
|
|
3634
3699
|
|
|
3635
3700
|
// src/index.ts
|
|
3636
3701
|
var program = new Command();
|