-
Notifications
You must be signed in to change notification settings - Fork 294
/
Copy pathget-all-tgz-path.ts
66 lines (57 loc) · 3.01 KB
/
get-all-tgz-path.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import path from "path";
import { fileURLToPath } from "url";
import { globby, Options as GlobbyOptions } from "globby";
import lernaCfg from "../../lerna.json" assert { type: "json" };
/**
* Interface for the response of the getAllTgzPath function.
* @property {Array<string>} relativePaths - An array of relative paths to the
* package directories.
*/
export interface IGetAllTgzPathResponse {
readonly relativePaths: Readonly<Array<string>>;
}
/**
* Asynchronous function to get all tgz filepaths in a Lerna monorepo.
* @returns {Promise<IGetAllTgzPathResponse>} A promise that resolves to an
* object containing the arrays of relative paths to the all tgz files.
*/
export async function getAllTgzPath(): Promise<IGetAllTgzPathResponse> {
const TAG = "[tools/get-all-tgz-path.ts]";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const SCRIPT_DIR = __dirname;
const PROJECT_DIR = path.join(SCRIPT_DIR, "../../");
console.log(`${TAG} SCRIPT_DIR=${SCRIPT_DIR}`);
console.log(`${TAG} PROJECT_DIR=${PROJECT_DIR}`);
const globbyOpts: GlobbyOptions = {
cwd: PROJECT_DIR,
onlyFiles: true,
expandDirectories: false,
// ignore pattern is added temporarily so that the yarn custom-checks github action will pass. These packages
// are failing and needs to be fixed. Each issue ticket link is added above each ignore path. More details and
// links are in the description of the issue ticket.
ignore: [
"**/node_modules",
// link for issue ticket relating to this package: https://github.com/hyperledger-cacti/cacti/issues/3623
"weaver/core/drivers/fabric-driver/hyperledger-cacti-weaver-driver-fabric-*.tgz",
// link for issue ticket relating to this package: https://github.com/hyperledger-cacti/cacti/issues/3626
"weaver/core/identity-management/iin-agent/hyperledger-cacti-weaver-iin-agent-*.tgz",
// link for issue ticket relating to this package: https://github.com/hyperledger-cacti/cacti/issues/3627
"weaver/sdks/fabric/interoperation-node-sdk/hyperledger-cacti-weaver-sdk-fabric-*.tgz",
// link for issue ticket relating to this package: https://github.com/hyperledger-cacti/cacti/issues/3628
"packages/cacti-plugin-weaver-driver-fabric/src/main/typescript/hyperledger-cacti-weaver-driver-fabric-*.tgz",
// link for issue ticket relating to this package: https://github.com/hyperledger-cacti/cacti/issues/3632
"examples/cactus-common-example-server/hyperledger-cactus-common-example-server-*.tgz",
// link for issue ticket relating to this package: https://github.com/hyperledger-cacti/cacti/issues/3633
"packages/cactus-verifier-client/hyperledger-cactus-verifier-client-*.tgz",
],
};
const tgzFilesPattern = lernaCfg.packages.map(
(pkg: string) => `${pkg}/**/hyperledger-*.tgz`,
);
const tgzFilesRelative = await globby(tgzFilesPattern, globbyOpts);
console.log("%s Found %s tgz files.", TAG, tgzFilesRelative.length);
return {
relativePaths: tgzFilesRelative,
};
}