@cenk1cenk2/oclif-common 6.3.0 → 6.3.2
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 -11
- package/dist/index.js +21 -26
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -255,22 +255,22 @@ 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
|
|
260
|
+
applyLockAll(lock: LockFile): Promise<LockFile>;
|
|
261
261
|
lockAll(): Promise<void>;
|
|
262
|
-
applyUnlockAll
|
|
262
|
+
applyUnlockAll(lock: LockFile): Promise<LockFile>;
|
|
263
263
|
unlockAll(): Promise<void>;
|
|
264
264
|
all(): Promise<void>;
|
|
265
|
-
applyAll
|
|
266
|
-
applyLock
|
|
267
|
-
lock
|
|
268
|
-
applyUnlock
|
|
269
|
-
unlock
|
|
270
|
-
read
|
|
271
|
-
tryRead
|
|
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>;
|
|
270
|
+
read(): Promise<LockFile>;
|
|
271
|
+
tryRead(): Promise<LockFile | undefined>;
|
|
272
272
|
tryRemove(): Promise<void>;
|
|
273
|
-
write
|
|
273
|
+
write(data: LockFile): Promise<void>;
|
|
274
274
|
private buildPath;
|
|
275
275
|
private normalizePath;
|
|
276
276
|
}
|
package/dist/index.js
CHANGED
|
@@ -1224,16 +1224,10 @@ var _LockerService = class _LockerService {
|
|
|
1224
1224
|
return this.toUnlock.length > 0;
|
|
1225
1225
|
}
|
|
1226
1226
|
addLock(...data) {
|
|
1227
|
-
this.toLock
|
|
1228
|
-
...this.toLock,
|
|
1229
|
-
...data
|
|
1230
|
-
];
|
|
1227
|
+
this.toLock.push(...data);
|
|
1231
1228
|
}
|
|
1232
1229
|
addUnlock(...data) {
|
|
1233
|
-
this.toUnlock
|
|
1234
|
-
...this.toUnlock,
|
|
1235
|
-
...data
|
|
1236
|
-
];
|
|
1230
|
+
this.toUnlock.push(...data);
|
|
1237
1231
|
}
|
|
1238
1232
|
async applyLockAll(lock) {
|
|
1239
1233
|
if (this.hasLock()) {
|
|
@@ -1294,14 +1288,11 @@ var _LockerService = class _LockerService {
|
|
|
1294
1288
|
return lock;
|
|
1295
1289
|
}
|
|
1296
1290
|
async lock(...data) {
|
|
1297
|
-
const lock = this.applyLock(await this.tryRead() ?? {}, ...data);
|
|
1291
|
+
const lock = await this.applyLock(await this.tryRead() ?? {}, ...data);
|
|
1298
1292
|
await this.write(lock);
|
|
1299
1293
|
return lock;
|
|
1300
1294
|
}
|
|
1301
1295
|
async applyUnlock(lock, ...data) {
|
|
1302
|
-
if (!lock) {
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
1296
|
if (data.length > 0) {
|
|
1306
1297
|
data.forEach((d) => {
|
|
1307
1298
|
if (d?.enabled === false) {
|
|
@@ -1321,17 +1312,19 @@ var _LockerService = class _LockerService {
|
|
|
1321
1312
|
}
|
|
1322
1313
|
}
|
|
1323
1314
|
});
|
|
1324
|
-
|
|
1325
|
-
lock = op2.del(lock, this.options.root);
|
|
1326
|
-
this.logger.verbose("Unlocked module: %s", this.options.root);
|
|
1315
|
+
return lock;
|
|
1327
1316
|
}
|
|
1317
|
+
lock = op2.del(lock, this.options.root);
|
|
1318
|
+
this.logger.verbose("Unlocked module: %s", this.options.root);
|
|
1319
|
+
return lock;
|
|
1328
1320
|
}
|
|
1329
1321
|
async unlock(...data) {
|
|
1330
|
-
const
|
|
1331
|
-
if (!
|
|
1322
|
+
const state = await this.tryRead();
|
|
1323
|
+
if (!state) {
|
|
1332
1324
|
this.logger.verbose("Lock file not found. Nothing to unlock.");
|
|
1333
1325
|
return;
|
|
1334
1326
|
}
|
|
1327
|
+
const lock = await this.applyUnlock(state, ...data);
|
|
1335
1328
|
await this.write(lock);
|
|
1336
1329
|
return lock;
|
|
1337
1330
|
}
|
|
@@ -1339,18 +1332,20 @@ var _LockerService = class _LockerService {
|
|
|
1339
1332
|
return this.parser.fetch(this.options.parser).parse(await this.fs.read(this.options.file));
|
|
1340
1333
|
}
|
|
1341
1334
|
async tryRead() {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1335
|
+
const lock = await this.fs.read(this.options.file).catch((err) => {
|
|
1336
|
+
this.logger.trace("Can not read lockfile: %s -> %s", this.options.file, err.message);
|
|
1337
|
+
});
|
|
1338
|
+
if (!lock) {
|
|
1339
|
+
return;
|
|
1346
1340
|
}
|
|
1341
|
+
return this.parser.fetch(this.options.parser).parse(lock);
|
|
1347
1342
|
}
|
|
1348
1343
|
async tryRemove() {
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
}
|
|
1352
|
-
this.logger.trace("Can not remove lockfile: %s", this.options.file);
|
|
1353
|
-
}
|
|
1344
|
+
return this.fs.remove(this.options.file).then(() => {
|
|
1345
|
+
this.logger.trace("Removed lockfile: %s", this.options.file);
|
|
1346
|
+
}).catch((err) => {
|
|
1347
|
+
this.logger.trace("Can not remove lockfile: %s -> %s", this.options.file, err.message);
|
|
1348
|
+
});
|
|
1354
1349
|
}
|
|
1355
1350
|
async write(data) {
|
|
1356
1351
|
if (!data || Array.isArray(data) && data.length === 0 || typeof data === "object" && Object.keys(data).length === 0) {
|