@cenk1cenk2/oclif-common 6.2.8 → 6.3.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.d.ts +11 -5
- package/dist/index.js +41 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -257,14 +257,20 @@ declare class LockerService<LockFile extends LockableData = LockableData> {
|
|
|
257
257
|
hasUnlock(): boolean;
|
|
258
258
|
addLock<T extends LockableData = LockFile>(...data: LockData<T>[]): void;
|
|
259
259
|
addUnlock(...data: UnlockData[]): void;
|
|
260
|
+
applyLockAll<T extends LockableData = LockFile>(lock: T): Promise<T>;
|
|
260
261
|
lockAll(): Promise<void>;
|
|
262
|
+
applyUnlockAll<T extends LockableData = LockFile>(lock: T): Promise<T>;
|
|
261
263
|
unlockAll(): Promise<void>;
|
|
262
264
|
all(): Promise<void>;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
265
|
+
applyAll<T extends LockableData = LockFile>(lock: T): Promise<T>;
|
|
266
|
+
applyLock<T extends LockableData = LockFile>(lock: T, ...data: LockData<T>[]): Promise<T>;
|
|
267
|
+
lock<T extends LockableData = LockFile>(...data: LockData<T>[]): Promise<T>;
|
|
268
|
+
applyUnlock<T extends LockableData = LockFile>(lock: T, ...data: UnlockData[]): Promise<T | undefined>;
|
|
269
|
+
unlock<T extends LockableData = LockFile>(...data: UnlockData[]): Promise<T | undefined>;
|
|
270
|
+
read<T extends LockableData = LockFile>(): Promise<T>;
|
|
271
|
+
tryRead<T extends LockableData = LockFile>(): Promise<T | undefined>;
|
|
272
|
+
tryRemove(): Promise<void>;
|
|
273
|
+
write<T extends LockableData = LockFile>(data: T): Promise<void>;
|
|
268
274
|
private buildPath;
|
|
269
275
|
private normalizePath;
|
|
270
276
|
}
|
package/dist/index.js
CHANGED
|
@@ -1235,14 +1235,26 @@ var _LockerService = class _LockerService {
|
|
|
1235
1235
|
...data
|
|
1236
1236
|
];
|
|
1237
1237
|
}
|
|
1238
|
+
async applyLockAll(lock) {
|
|
1239
|
+
if (this.hasLock()) {
|
|
1240
|
+
return this.applyLock(lock, ...this.toLock);
|
|
1241
|
+
}
|
|
1242
|
+
return lock;
|
|
1243
|
+
}
|
|
1238
1244
|
async lockAll() {
|
|
1239
1245
|
if (this.hasLock()) {
|
|
1240
1246
|
await this.lock(...this.toLock);
|
|
1241
1247
|
this.toLock = [];
|
|
1242
1248
|
}
|
|
1243
1249
|
}
|
|
1250
|
+
async applyUnlockAll(lock) {
|
|
1251
|
+
if (this.hasUnlock()) {
|
|
1252
|
+
return this.applyUnlock(lock, ...this.toUnlock);
|
|
1253
|
+
}
|
|
1254
|
+
return lock;
|
|
1255
|
+
}
|
|
1244
1256
|
async unlockAll() {
|
|
1245
|
-
if (this.
|
|
1257
|
+
if (this.hasUnlock()) {
|
|
1246
1258
|
await this.unlock(...this.toUnlock);
|
|
1247
1259
|
this.toUnlock = [];
|
|
1248
1260
|
}
|
|
@@ -1251,8 +1263,12 @@ var _LockerService = class _LockerService {
|
|
|
1251
1263
|
await this.unlockAll();
|
|
1252
1264
|
await this.lockAll();
|
|
1253
1265
|
}
|
|
1254
|
-
async lock
|
|
1255
|
-
|
|
1266
|
+
async applyAll(lock) {
|
|
1267
|
+
lock = await this.applyUnlockAll(lock);
|
|
1268
|
+
lock = await this.applyLockAll(lock);
|
|
1269
|
+
return lock;
|
|
1270
|
+
}
|
|
1271
|
+
async applyLock(lock, ...data) {
|
|
1256
1272
|
data.forEach((d) => {
|
|
1257
1273
|
if (d?.enabled === false) {
|
|
1258
1274
|
return;
|
|
@@ -1275,12 +1291,15 @@ var _LockerService = class _LockerService {
|
|
|
1275
1291
|
this.logger.verbose("Override lock: %s -> %o", path, d.data);
|
|
1276
1292
|
}
|
|
1277
1293
|
});
|
|
1294
|
+
return lock;
|
|
1295
|
+
}
|
|
1296
|
+
async lock(...data) {
|
|
1297
|
+
const lock = this.applyLock(await this.tryRead() ?? {}, ...data);
|
|
1278
1298
|
await this.write(lock);
|
|
1299
|
+
return lock;
|
|
1279
1300
|
}
|
|
1280
|
-
async
|
|
1281
|
-
let lock = await this.tryRead();
|
|
1301
|
+
async applyUnlock(lock, ...data) {
|
|
1282
1302
|
if (!lock) {
|
|
1283
|
-
this.logger.verbose("Lock file not found. Nothing to unlock.");
|
|
1284
1303
|
return;
|
|
1285
1304
|
}
|
|
1286
1305
|
if (data.length > 0) {
|
|
@@ -1306,7 +1325,15 @@ var _LockerService = class _LockerService {
|
|
|
1306
1325
|
lock = op2.del(lock, this.options.root);
|
|
1307
1326
|
this.logger.verbose("Unlocked module: %s", this.options.root);
|
|
1308
1327
|
}
|
|
1309
|
-
|
|
1328
|
+
}
|
|
1329
|
+
async unlock(...data) {
|
|
1330
|
+
const lock = await this.applyUnlock(await this.tryRead(), ...data);
|
|
1331
|
+
if (!lock) {
|
|
1332
|
+
this.logger.verbose("Lock file not found. Nothing to unlock.");
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
await this.write(lock);
|
|
1336
|
+
return lock;
|
|
1310
1337
|
}
|
|
1311
1338
|
async read() {
|
|
1312
1339
|
return this.parser.fetch(this.options.parser).parse(await this.fs.read(this.options.file));
|
|
@@ -1318,6 +1345,13 @@ var _LockerService = class _LockerService {
|
|
|
1318
1345
|
this.logger.trace("Can not read lockfile: %s", this.options.file);
|
|
1319
1346
|
}
|
|
1320
1347
|
}
|
|
1348
|
+
async tryRemove() {
|
|
1349
|
+
try {
|
|
1350
|
+
await this.fs.remove(this.options.file);
|
|
1351
|
+
} catch {
|
|
1352
|
+
this.logger.trace("Can not remove lockfile: %s", this.options.file);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1321
1355
|
async write(data) {
|
|
1322
1356
|
if (!data || Array.isArray(data) && data.length === 0 || typeof data === "object" && Object.keys(data).length === 0) {
|
|
1323
1357
|
this.logger.trace("Trying to write empty lock file, deleting it instead: %s", this.options.file);
|