@cenk1cenk2/oclif-common 6.2.8 → 6.3.1
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 +9 -3
- package/dist/index.js +52 -17
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -255,15 +255,21 @@ declare class LockerService<LockFile extends LockableData = LockableData> {
|
|
|
255
255
|
constructor(logger: LoggerService, fs: FileSystemService, parser: ParserService, options: LockerServiceOptions);
|
|
256
256
|
hasLock(): boolean;
|
|
257
257
|
hasUnlock(): boolean;
|
|
258
|
-
addLock
|
|
258
|
+
addLock(...data: LockData<LockFile>[]): void;
|
|
259
259
|
addUnlock(...data: UnlockData[]): void;
|
|
260
|
+
applyLockAll(lock: LockFile): Promise<LockFile>;
|
|
260
261
|
lockAll(): Promise<void>;
|
|
262
|
+
applyUnlockAll(lock: LockFile): Promise<LockFile>;
|
|
261
263
|
unlockAll(): Promise<void>;
|
|
262
264
|
all(): Promise<void>;
|
|
263
|
-
lock
|
|
264
|
-
|
|
265
|
+
applyAll(lock: LockFile): Promise<LockFile>;
|
|
266
|
+
applyLock(lock: LockFile, ...data: LockData<LockFile>[]): Promise<LockFile>;
|
|
267
|
+
lock(...data: LockData<LockFile>[]): Promise<LockFile>;
|
|
268
|
+
applyUnlock(lock: LockFile, ...data: UnlockData[]): Promise<LockFile>;
|
|
269
|
+
unlock(...data: UnlockData[]): Promise<LockFile | undefined>;
|
|
265
270
|
read(): Promise<LockFile>;
|
|
266
271
|
tryRead(): Promise<LockFile | undefined>;
|
|
272
|
+
tryRemove(): Promise<void>;
|
|
267
273
|
write(data: LockFile): Promise<void>;
|
|
268
274
|
private buildPath;
|
|
269
275
|
private normalizePath;
|
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,14 +1291,14 @@ 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 = await 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();
|
|
1282
|
-
if (!lock) {
|
|
1283
|
-
this.logger.verbose("Lock file not found. Nothing to unlock.");
|
|
1284
|
-
return;
|
|
1285
|
-
}
|
|
1301
|
+
async applyUnlock(lock, ...data) {
|
|
1286
1302
|
if (data.length > 0) {
|
|
1287
1303
|
data.forEach((d) => {
|
|
1288
1304
|
if (d?.enabled === false) {
|
|
@@ -1302,21 +1318,40 @@ var _LockerService = class _LockerService {
|
|
|
1302
1318
|
}
|
|
1303
1319
|
}
|
|
1304
1320
|
});
|
|
1305
|
-
|
|
1306
|
-
lock = op2.del(lock, this.options.root);
|
|
1307
|
-
this.logger.verbose("Unlocked module: %s", this.options.root);
|
|
1321
|
+
return lock;
|
|
1308
1322
|
}
|
|
1309
|
-
|
|
1323
|
+
lock = op2.del(lock, this.options.root);
|
|
1324
|
+
this.logger.verbose("Unlocked module: %s", this.options.root);
|
|
1325
|
+
return lock;
|
|
1326
|
+
}
|
|
1327
|
+
async unlock(...data) {
|
|
1328
|
+
const state = await this.tryRead();
|
|
1329
|
+
if (!state) {
|
|
1330
|
+
this.logger.verbose("Lock file not found. Nothing to unlock.");
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
const lock = await this.applyUnlock(state, ...data);
|
|
1334
|
+
await this.write(lock);
|
|
1335
|
+
return lock;
|
|
1310
1336
|
}
|
|
1311
1337
|
async read() {
|
|
1312
1338
|
return this.parser.fetch(this.options.parser).parse(await this.fs.read(this.options.file));
|
|
1313
1339
|
}
|
|
1314
1340
|
async tryRead() {
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1341
|
+
const lock = await this.fs.read(this.options.file).catch((err) => {
|
|
1342
|
+
this.logger.trace("Can not read lockfile: %s -> %s", this.options.file, err.message);
|
|
1343
|
+
});
|
|
1344
|
+
if (!lock) {
|
|
1345
|
+
return;
|
|
1319
1346
|
}
|
|
1347
|
+
return this.parser.fetch(this.options.parser).parse(lock);
|
|
1348
|
+
}
|
|
1349
|
+
async tryRemove() {
|
|
1350
|
+
return this.fs.remove(this.options.file).then(() => {
|
|
1351
|
+
this.logger.trace("Removed lockfile: %s", this.options.file);
|
|
1352
|
+
}).catch((err) => {
|
|
1353
|
+
this.logger.trace("Can not remove lockfile: %s -> %s", this.options.file, err.message);
|
|
1354
|
+
});
|
|
1320
1355
|
}
|
|
1321
1356
|
async write(data) {
|
|
1322
1357
|
if (!data || Array.isArray(data) && data.length === 0 || typeof data === "object" && Object.keys(data).length === 0) {
|