@cenk1cenk2/oclif-common 6.3.0 → 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 +11 -11
- package/dist/index.js +19 -18
- 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
|
@@ -1294,14 +1294,11 @@ var _LockerService = class _LockerService {
|
|
|
1294
1294
|
return lock;
|
|
1295
1295
|
}
|
|
1296
1296
|
async lock(...data) {
|
|
1297
|
-
const lock = this.applyLock(await this.tryRead() ?? {}, ...data);
|
|
1297
|
+
const lock = await this.applyLock(await this.tryRead() ?? {}, ...data);
|
|
1298
1298
|
await this.write(lock);
|
|
1299
1299
|
return lock;
|
|
1300
1300
|
}
|
|
1301
1301
|
async applyUnlock(lock, ...data) {
|
|
1302
|
-
if (!lock) {
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
1302
|
if (data.length > 0) {
|
|
1306
1303
|
data.forEach((d) => {
|
|
1307
1304
|
if (d?.enabled === false) {
|
|
@@ -1321,17 +1318,19 @@ var _LockerService = class _LockerService {
|
|
|
1321
1318
|
}
|
|
1322
1319
|
}
|
|
1323
1320
|
});
|
|
1324
|
-
|
|
1325
|
-
lock = op2.del(lock, this.options.root);
|
|
1326
|
-
this.logger.verbose("Unlocked module: %s", this.options.root);
|
|
1321
|
+
return lock;
|
|
1327
1322
|
}
|
|
1323
|
+
lock = op2.del(lock, this.options.root);
|
|
1324
|
+
this.logger.verbose("Unlocked module: %s", this.options.root);
|
|
1325
|
+
return lock;
|
|
1328
1326
|
}
|
|
1329
1327
|
async unlock(...data) {
|
|
1330
|
-
const
|
|
1331
|
-
if (!
|
|
1328
|
+
const state = await this.tryRead();
|
|
1329
|
+
if (!state) {
|
|
1332
1330
|
this.logger.verbose("Lock file not found. Nothing to unlock.");
|
|
1333
1331
|
return;
|
|
1334
1332
|
}
|
|
1333
|
+
const lock = await this.applyUnlock(state, ...data);
|
|
1335
1334
|
await this.write(lock);
|
|
1336
1335
|
return lock;
|
|
1337
1336
|
}
|
|
@@ -1339,18 +1338,20 @@ var _LockerService = class _LockerService {
|
|
|
1339
1338
|
return this.parser.fetch(this.options.parser).parse(await this.fs.read(this.options.file));
|
|
1340
1339
|
}
|
|
1341
1340
|
async tryRead() {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
}
|
|
1345
|
-
|
|
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;
|
|
1346
1346
|
}
|
|
1347
|
+
return this.parser.fetch(this.options.parser).parse(lock);
|
|
1347
1348
|
}
|
|
1348
1349
|
async tryRemove() {
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
}
|
|
1352
|
-
this.logger.trace("Can not remove lockfile: %s", this.options.file);
|
|
1353
|
-
}
|
|
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
|
+
});
|
|
1354
1355
|
}
|
|
1355
1356
|
async write(data) {
|
|
1356
1357
|
if (!data || Array.isArray(data) && data.length === 0 || typeof data === "object" && Object.keys(data).length === 0) {
|