Skip to content

Commit

Permalink
fix(build): sync-ts-config script needs import assertion of type json
Browse files Browse the repository at this point in the history
Fixes hyperledger-cacti#2163

Signed-off-by: aldousalvarez <aldousss.alvarez@gmail.com>
  • Loading branch information
aldousalvarez committed Nov 15, 2022
1 parent d7cb611 commit 997eab6
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions tools/sync-npm-deps-to-tsc-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,28 @@ import JSON5 from "json5";
import fs from "fs-extra";
import { globby, Options as GlobbyOptions } from "globby";
import { RuntimeError } from "run-time-error";
import lernaJson from "../lerna.json";
import { readFile } from "fs/promises";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const TS_CONFIG = "tsconfig.json";
const PACKAGE_JSON = "package.json";
const LERNA_JSON = "lerna.json";
const SCRIPT_DIR = __dirname;
const PROJECT_DIR = path.join(SCRIPT_DIR, "../");
const lernaJson = JSON.parse(await readFile(PROJECT_DIR + LERNA_JSON, "utf-8"));
console.log(`SCRIPT_DIR=${SCRIPT_DIR}`);
console.log(`PROJECT_DIR=${PROJECT_DIR}`);
console.log(`LERNA_JSON=${lernaJson}`);

const pkgJsonGlobPatterns = lernaJson.packages.map((it: string) =>
"./".concat(it).concat(`/${PACKAGE_JSON}`),
);

const tsConfigJsonGlobPatterns = lernaJson.packages.map((it: string) =>
"./".concat(it).concat(`/${TS_CONFIG}`),
);
console.log("Globbing lerna package patterns: ", pkgJsonGlobPatterns);

const main = async (argv: string[], env: NodeJS.ProcessEnv) => {
if (!argv) {
Expand All @@ -17,21 +35,6 @@ const main = async (argv: string[], env: NodeJS.ProcessEnv) => {
if (!env) {
throw new RuntimeError(`Process env cannot be falsy.`);
}
const TS_CONFIG = "tsconfig.json";
const PACKAGE_JSON = "package.json";
const SCRIPT_DIR = __dirname;
const PROJECT_DIR = path.join(SCRIPT_DIR, "../");
console.log(`SCRIPT_DIR=${SCRIPT_DIR}`);
console.log(`PROJECT_DIR=${PROJECT_DIR}`);

const pkgJsonGlobPatterns = lernaJson.packages.map((it) =>
"./".concat(it).concat(`/${PACKAGE_JSON}`),
);

const tsConfigJsonGlobPatterns = lernaJson.packages.map((it) =>
"./".concat(it).concat(`/${TS_CONFIG}`),
);
console.log("Globbing lerna package patterns: ", pkgJsonGlobPatterns);

const globbyOptions: GlobbyOptions = {
cwd: PROJECT_DIR,
Expand Down

0 comments on commit 997eab6

Please sign in to comment.